ltmain.sh revision 0cc67336
10cc67336Smrg# Generated from ltmain.m4sh. 20cc67336Smrg 30cc67336Smrg# ltmain.sh (GNU libtool) 2.2.6 40cc67336Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 50cc67336Smrg 60cc67336Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc. 70cc67336Smrg# This is free software; see the source for copying conditions. There is NO 80cc67336Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 90cc67336Smrg 100cc67336Smrg# GNU Libtool is free software; you can redistribute it and/or modify 11301ea0f4Smrg# it under the terms of the GNU General Public License as published by 12301ea0f4Smrg# the Free Software Foundation; either version 2 of the License, or 13301ea0f4Smrg# (at your option) any later version. 14301ea0f4Smrg# 150cc67336Smrg# As a special exception to the GNU General Public License, 160cc67336Smrg# if you distribute this file as part of a program or library that 170cc67336Smrg# is built using GNU Libtool, you may include this file under the 180cc67336Smrg# same distribution terms that you use for the rest of that program. 190cc67336Smrg# 200cc67336Smrg# GNU Libtool is distributed in the hope that it will be useful, but 21301ea0f4Smrg# WITHOUT ANY WARRANTY; without even the implied warranty of 22301ea0f4Smrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23301ea0f4Smrg# General Public License for more details. 24301ea0f4Smrg# 25301ea0f4Smrg# You should have received a copy of the GNU General Public License 260cc67336Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 270cc67336Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 280cc67336Smrg# or obtained by writing to the Free Software Foundation, Inc., 290cc67336Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 300cc67336Smrg 310cc67336Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 320cc67336Smrg# 330cc67336Smrg# Provide generalized library-building support services. 34301ea0f4Smrg# 350cc67336Smrg# --config show all configuration variables 360cc67336Smrg# --debug enable verbose shell tracing 370cc67336Smrg# -n, --dry-run display commands without modifying any files 380cc67336Smrg# --features display basic configuration information and exit 390cc67336Smrg# --mode=MODE use operation mode MODE 400cc67336Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 410cc67336Smrg# --quiet, --silent don't print informational messages 420cc67336Smrg# --tag=TAG use configuration variables from tag TAG 430cc67336Smrg# -v, --verbose print informational messages (default) 440cc67336Smrg# --version print version information 450cc67336Smrg# -h, --help print short or long help message 460cc67336Smrg# 470cc67336Smrg# MODE must be one of the following: 480cc67336Smrg# 490cc67336Smrg# clean remove files from the build directory 500cc67336Smrg# compile compile a source file into a libtool object 510cc67336Smrg# execute automatically set library path, then run a program 520cc67336Smrg# finish complete the installation of libtool libraries 530cc67336Smrg# install install libraries or executables 540cc67336Smrg# link create a library or an executable 550cc67336Smrg# uninstall remove libraries from an installed directory 560cc67336Smrg# 570cc67336Smrg# MODE-ARGS vary depending on the MODE. 580cc67336Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 590cc67336Smrg# 600cc67336Smrg# When reporting a bug, please describe a test case to reproduce it and 610cc67336Smrg# include the following information: 620cc67336Smrg# 630cc67336Smrg# host-triplet: $host 640cc67336Smrg# shell: $SHELL 650cc67336Smrg# compiler: $LTCC 660cc67336Smrg# compiler flags: $LTCFLAGS 670cc67336Smrg# linker: $LD (gnu? $with_gnu_ld) 680cc67336Smrg# $progname: (GNU libtool) 2.2.6 690cc67336Smrg# automake: $automake_version 700cc67336Smrg# autoconf: $autoconf_version 710cc67336Smrg# 720cc67336Smrg# Report bugs to <bug-libtool@gnu.org>. 730cc67336Smrg 740cc67336SmrgPROGRAM=ltmain.sh 750cc67336SmrgPACKAGE=libtool 760cc67336SmrgVERSION=2.2.6 770cc67336SmrgTIMESTAMP="" 780cc67336Smrgpackage_revision=1.3012 790cc67336Smrg 800cc67336Smrg# Be Bourne compatible 810cc67336Smrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 820cc67336Smrg emulate sh 830cc67336Smrg NULLCMD=: 840cc67336Smrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 850cc67336Smrg # is contrary to our usage. Disable this feature. 860cc67336Smrg alias -g '${1+"$@"}'='"$@"' 870cc67336Smrg setopt NO_GLOB_SUBST 880cc67336Smrgelse 890cc67336Smrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 900cc67336Smrgfi 910cc67336SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 920cc67336SmrgDUALCASE=1; export DUALCASE # for MKS sh 930cc67336Smrg 940cc67336Smrg# NLS nuisances: We save the old values to restore during execute mode. 950cc67336Smrg# Only set LANG and LC_ALL to C if already set. 960cc67336Smrg# These must not be set unconditionally because not all systems understand 970cc67336Smrg# e.g. LANG=C (notably SCO). 980cc67336Smrglt_user_locale= 990cc67336Smrglt_safe_locale= 1000cc67336Smrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1010cc67336Smrgdo 1020cc67336Smrg eval "if test \"\${$lt_var+set}\" = set; then 1030cc67336Smrg save_$lt_var=\$$lt_var 1040cc67336Smrg $lt_var=C 1050cc67336Smrg export $lt_var 1060cc67336Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 1070cc67336Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 1080cc67336Smrg fi" 1090cc67336Smrgdone 1100cc67336Smrg 1110cc67336Smrg$lt_unset CDPATH 1120cc67336Smrg 1130cc67336Smrg 1140cc67336Smrg 1150cc67336Smrg 1160cc67336Smrg 1170cc67336Smrg: ${CP="cp -f"} 1180cc67336Smrg: ${ECHO="echo"} 1190cc67336Smrg: ${EGREP="/bin/grep -E"} 1200cc67336Smrg: ${FGREP="/bin/grep -F"} 1210cc67336Smrg: ${GREP="/bin/grep"} 1220cc67336Smrg: ${LN_S="ln -s"} 1230cc67336Smrg: ${MAKE="make"} 1240cc67336Smrg: ${MKDIR="mkdir"} 1250cc67336Smrg: ${MV="mv -f"} 1260cc67336Smrg: ${RM="rm -f"} 1270cc67336Smrg: ${SED="/bin/sed"} 1280cc67336Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 1290cc67336Smrg: ${Xsed="$SED -e 1s/^X//"} 130301ea0f4Smrg 1310cc67336Smrg# Global variables: 1320cc67336SmrgEXIT_SUCCESS=0 1330cc67336SmrgEXIT_FAILURE=1 1340cc67336SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 1350cc67336SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 1360cc67336Smrg 1370cc67336Smrgexit_status=$EXIT_SUCCESS 1380cc67336Smrg 1390cc67336Smrg# Make sure IFS has a sensible default 1400cc67336Smrglt_nl=' 1410cc67336Smrg' 1420cc67336SmrgIFS=" $lt_nl" 1430cc67336Smrg 1440cc67336Smrgdirname="s,/[^/]*$,," 1450cc67336Smrgbasename="s,^.*/,," 1460cc67336Smrg 1470cc67336Smrg# func_dirname_and_basename file append nondir_replacement 1480cc67336Smrg# perform func_basename and func_dirname in a single function 1490cc67336Smrg# call: 1500cc67336Smrg# dirname: Compute the dirname of FILE. If nonempty, 1510cc67336Smrg# add APPEND to the result, otherwise set result 1520cc67336Smrg# to NONDIR_REPLACEMENT. 1530cc67336Smrg# value returned in "$func_dirname_result" 1540cc67336Smrg# basename: Compute filename of FILE. 1550cc67336Smrg# value retuned in "$func_basename_result" 1560cc67336Smrg# Implementation must be kept synchronized with func_dirname 1570cc67336Smrg# and func_basename. For efficiency, we do not delegate to 1580cc67336Smrg# those functions but instead duplicate the functionality here. 1590cc67336Smrgfunc_dirname_and_basename () 1600cc67336Smrg{ 1610cc67336Smrg # Extract subdirectory from the argument. 1620cc67336Smrg func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` 1630cc67336Smrg if test "X$func_dirname_result" = "X${1}"; then 1640cc67336Smrg func_dirname_result="${3}" 1650cc67336Smrg else 1660cc67336Smrg func_dirname_result="$func_dirname_result${2}" 1670cc67336Smrg fi 1680cc67336Smrg func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` 1690cc67336Smrg} 1700cc67336Smrg 1710cc67336Smrg# Generated shell functions inserted here. 172301ea0f4Smrg 173301ea0f4Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 174301ea0f4Smrg# is ksh but when the shell is invoked as "sh" and the current value of 175301ea0f4Smrg# the _XPG environment variable is not equal to 1 (one), the special 176301ea0f4Smrg# positional parameter $0, within a function call, is the name of the 177301ea0f4Smrg# function. 178301ea0f4Smrgprogpath="$0" 179301ea0f4Smrg 180301ea0f4Smrg# The name of this program: 1810cc67336Smrg# In the unlikely event $progname began with a '-', it would play havoc with 1820cc67336Smrg# func_echo (imagine progname=-n), so we prepend ./ in that case: 1830cc67336Smrgfunc_dirname_and_basename "$progpath" 1840cc67336Smrgprogname=$func_basename_result 1850cc67336Smrgcase $progname in 1860cc67336Smrg -*) progname=./$progname ;; 1870cc67336Smrgesac 188301ea0f4Smrg 1890cc67336Smrg# Make sure we have an absolute path for reexecution: 1900cc67336Smrgcase $progpath in 1910cc67336Smrg [\\/]*|[A-Za-z]:\\*) ;; 1920cc67336Smrg *[\\/]*) 1930cc67336Smrg progdir=$func_dirname_result 1940cc67336Smrg progdir=`cd "$progdir" && pwd` 1950cc67336Smrg progpath="$progdir/$progname" 1960cc67336Smrg ;; 1970cc67336Smrg *) 1980cc67336Smrg save_IFS="$IFS" 1990cc67336Smrg IFS=: 2000cc67336Smrg for progdir in $PATH; do 2010cc67336Smrg IFS="$save_IFS" 2020cc67336Smrg test -x "$progdir/$progname" && break 2030cc67336Smrg done 2040cc67336Smrg IFS="$save_IFS" 2050cc67336Smrg test -n "$progdir" || progdir=`pwd` 2060cc67336Smrg progpath="$progdir/$progname" 2070cc67336Smrg ;; 2080cc67336Smrgesac 209301ea0f4Smrg 2100cc67336Smrg# Sed substitution that helps us do robust quoting. It backslashifies 2110cc67336Smrg# metacharacters that are still active within double-quoted strings. 2120cc67336SmrgXsed="${SED}"' -e 1s/^X//' 2130cc67336Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 2140cc67336Smrg 2150cc67336Smrg# Same as above, but do not quote variable references. 2160cc67336Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 2170cc67336Smrg 2180cc67336Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 2190cc67336Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 2200cc67336Smrg# in input to double_quote_subst, that '$' was protected from expansion. 2210cc67336Smrg# Since each input `\' is now two `\'s, look for any number of runs of 2220cc67336Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 2230cc67336Smrgbs='\\' 2240cc67336Smrgbs2='\\\\' 2250cc67336Smrgbs4='\\\\\\\\' 2260cc67336Smrgdollar='\$' 2270cc67336Smrgsed_double_backslash="\ 2280cc67336Smrg s/$bs4/&\\ 2290cc67336Smrg/g 2300cc67336Smrg s/^$bs2$dollar/$bs&/ 2310cc67336Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 2320cc67336Smrg s/\n//g" 2330cc67336Smrg 2340cc67336Smrg# Standard options: 2350cc67336Smrgopt_dry_run=false 2360cc67336Smrgopt_help=false 2370cc67336Smrgopt_quiet=false 2380cc67336Smrgopt_verbose=false 2390cc67336Smrgopt_warning=: 2400cc67336Smrg 2410cc67336Smrg# func_echo arg... 2420cc67336Smrg# Echo program name prefixed message, along with the current mode 2430cc67336Smrg# name if it has been set yet. 2440cc67336Smrgfunc_echo () 2450cc67336Smrg{ 2460cc67336Smrg $ECHO "$progname${mode+: }$mode: $*" 2470cc67336Smrg} 248301ea0f4Smrg 2490cc67336Smrg# func_verbose arg... 2500cc67336Smrg# Echo program name prefixed message in verbose mode only. 2510cc67336Smrgfunc_verbose () 2520cc67336Smrg{ 2530cc67336Smrg $opt_verbose && func_echo ${1+"$@"} 254301ea0f4Smrg 2550cc67336Smrg # A bug in bash halts the script if the last line of a function 2560cc67336Smrg # fails when set -e is in force, so we need another command to 2570cc67336Smrg # work around that: 2580cc67336Smrg : 2590cc67336Smrg} 260301ea0f4Smrg 2610cc67336Smrg# func_error arg... 2620cc67336Smrg# Echo program name prefixed message to standard error. 2630cc67336Smrgfunc_error () 2640cc67336Smrg{ 2650cc67336Smrg $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 2660cc67336Smrg} 267301ea0f4Smrg 2680cc67336Smrg# func_warning arg... 2690cc67336Smrg# Echo program name prefixed warning message to standard error. 2700cc67336Smrgfunc_warning () 2710cc67336Smrg{ 2720cc67336Smrg $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 273301ea0f4Smrg 2740cc67336Smrg # bash bug again: 2750cc67336Smrg : 2760cc67336Smrg} 277301ea0f4Smrg 2780cc67336Smrg# func_fatal_error arg... 2790cc67336Smrg# Echo program name prefixed message to standard error, and exit. 2800cc67336Smrgfunc_fatal_error () 2810cc67336Smrg{ 2820cc67336Smrg func_error ${1+"$@"} 2830cc67336Smrg exit $EXIT_FAILURE 2840cc67336Smrg} 285301ea0f4Smrg 2860cc67336Smrg# func_fatal_help arg... 2870cc67336Smrg# Echo program name prefixed message to standard error, followed by 2880cc67336Smrg# a help hint, and exit. 2890cc67336Smrgfunc_fatal_help () 2900cc67336Smrg{ 2910cc67336Smrg func_error ${1+"$@"} 2920cc67336Smrg func_fatal_error "$help" 2930cc67336Smrg} 2940cc67336Smrghelp="Try \`$progname --help' for more information." ## default 295301ea0f4Smrg 296301ea0f4Smrg 2970cc67336Smrg# func_grep expression filename 2980cc67336Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 2990cc67336Smrgfunc_grep () 3000cc67336Smrg{ 3010cc67336Smrg $GREP "$1" "$2" >/dev/null 2>&1 3020cc67336Smrg} 3030cc67336Smrg 3040cc67336Smrg 3050cc67336Smrg# func_mkdir_p directory-path 3060cc67336Smrg# Make sure the entire path to DIRECTORY-PATH is available. 3070cc67336Smrgfunc_mkdir_p () 3080cc67336Smrg{ 3090cc67336Smrg my_directory_path="$1" 3100cc67336Smrg my_dir_list= 3110cc67336Smrg 3120cc67336Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 3130cc67336Smrg 3140cc67336Smrg # Protect directory names starting with `-' 3150cc67336Smrg case $my_directory_path in 3160cc67336Smrg -*) my_directory_path="./$my_directory_path" ;; 3170cc67336Smrg esac 3180cc67336Smrg 3190cc67336Smrg # While some portion of DIR does not yet exist... 3200cc67336Smrg while test ! -d "$my_directory_path"; do 3210cc67336Smrg # ...make a list in topmost first order. Use a colon delimited 3220cc67336Smrg # list incase some portion of path contains whitespace. 3230cc67336Smrg my_dir_list="$my_directory_path:$my_dir_list" 3240cc67336Smrg 3250cc67336Smrg # If the last portion added has no slash in it, the list is done 3260cc67336Smrg case $my_directory_path in */*) ;; *) break ;; esac 3270cc67336Smrg 3280cc67336Smrg # ...otherwise throw away the child directory and loop 3290cc67336Smrg my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"` 3300cc67336Smrg done 3310cc67336Smrg my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'` 3320cc67336Smrg 3330cc67336Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 3340cc67336Smrg for my_dir in $my_dir_list; do 3350cc67336Smrg IFS="$save_mkdir_p_IFS" 3360cc67336Smrg # mkdir can fail with a `File exist' error if two processes 3370cc67336Smrg # try to create one of the directories concurrently. Don't 3380cc67336Smrg # stop in that case! 3390cc67336Smrg $MKDIR "$my_dir" 2>/dev/null || : 3400cc67336Smrg done 3410cc67336Smrg IFS="$save_mkdir_p_IFS" 3420cc67336Smrg 3430cc67336Smrg # Bail out if we (or some other process) failed to create a directory. 3440cc67336Smrg test -d "$my_directory_path" || \ 3450cc67336Smrg func_fatal_error "Failed to create \`$1'" 3460cc67336Smrg fi 3470cc67336Smrg} 348301ea0f4Smrg 349301ea0f4Smrg 350301ea0f4Smrg# func_mktempdir [string] 351301ea0f4Smrg# Make a temporary directory that won't clash with other running 352301ea0f4Smrg# libtool processes, and avoids race conditions if possible. If 353301ea0f4Smrg# given, STRING is the basename for that directory. 354301ea0f4Smrgfunc_mktempdir () 355301ea0f4Smrg{ 356301ea0f4Smrg my_template="${TMPDIR-/tmp}/${1-$progname}" 357301ea0f4Smrg 3580cc67336Smrg if test "$opt_dry_run" = ":"; then 359301ea0f4Smrg # Return a directory name, but don't create it in dry-run mode 360301ea0f4Smrg my_tmpdir="${my_template}-$$" 361301ea0f4Smrg else 362301ea0f4Smrg 363301ea0f4Smrg # If mktemp works, use that first and foremost 364301ea0f4Smrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 365301ea0f4Smrg 366301ea0f4Smrg if test ! -d "$my_tmpdir"; then 3670cc67336Smrg # Failing that, at least try and use $RANDOM to avoid a race 3680cc67336Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 369301ea0f4Smrg 3700cc67336Smrg save_mktempdir_umask=`umask` 3710cc67336Smrg umask 0077 3720cc67336Smrg $MKDIR "$my_tmpdir" 3730cc67336Smrg umask $save_mktempdir_umask 374301ea0f4Smrg fi 375301ea0f4Smrg 376301ea0f4Smrg # If we're not in dry-run mode, bomb out on failure 3770cc67336Smrg test -d "$my_tmpdir" || \ 3780cc67336Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 379301ea0f4Smrg fi 380301ea0f4Smrg 3810cc67336Smrg $ECHO "X$my_tmpdir" | $Xsed 382301ea0f4Smrg} 383301ea0f4Smrg 384301ea0f4Smrg 3850cc67336Smrg# func_quote_for_eval arg 3860cc67336Smrg# Aesthetically quote ARG to be evaled later. 3870cc67336Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 3880cc67336Smrg# is double-quoted, suitable for a subsequent eval, whereas 3890cc67336Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 3900cc67336Smrg# which are still active within double quotes backslashified. 3910cc67336Smrgfunc_quote_for_eval () 392301ea0f4Smrg{ 3930cc67336Smrg case $1 in 3940cc67336Smrg *[\\\`\"\$]*) 3950cc67336Smrg func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;; 3960cc67336Smrg *) 3970cc67336Smrg func_quote_for_eval_unquoted_result="$1" ;; 3980cc67336Smrg esac 3990cc67336Smrg 4000cc67336Smrg case $func_quote_for_eval_unquoted_result in 4010cc67336Smrg # Double-quote args containing shell metacharacters to delay 4020cc67336Smrg # word splitting, command substitution and and variable 4030cc67336Smrg # expansion for a subsequent eval. 4040cc67336Smrg # Many Bourne shells cannot handle close brackets correctly 4050cc67336Smrg # in scan sets, so we specify it separately. 4060cc67336Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 4070cc67336Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 4080cc67336Smrg ;; 4090cc67336Smrg *) 4100cc67336Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 411301ea0f4Smrg esac 412301ea0f4Smrg} 413301ea0f4Smrg 414301ea0f4Smrg 4150cc67336Smrg# func_quote_for_expand arg 4160cc67336Smrg# Aesthetically quote ARG to be evaled later; same as above, 4170cc67336Smrg# but do not quote variable references. 4180cc67336Smrgfunc_quote_for_expand () 419301ea0f4Smrg{ 4200cc67336Smrg case $1 in 4210cc67336Smrg *[\\\`\"]*) 4220cc67336Smrg my_arg=`$ECHO "X$1" | $Xsed \ 4230cc67336Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 424301ea0f4Smrg *) 4250cc67336Smrg my_arg="$1" ;; 4260cc67336Smrg esac 4270cc67336Smrg 4280cc67336Smrg case $my_arg in 4290cc67336Smrg # Double-quote args containing shell metacharacters to delay 4300cc67336Smrg # word splitting and command substitution for a subsequent eval. 4310cc67336Smrg # Many Bourne shells cannot handle close brackets correctly 4320cc67336Smrg # in scan sets, so we specify it separately. 4330cc67336Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 4340cc67336Smrg my_arg="\"$my_arg\"" 4350cc67336Smrg ;; 4360cc67336Smrg esac 4370cc67336Smrg 4380cc67336Smrg func_quote_for_expand_result="$my_arg" 439301ea0f4Smrg} 440301ea0f4Smrg 441301ea0f4Smrg 4420cc67336Smrg# func_show_eval cmd [fail_exp] 4430cc67336Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 4440cc67336Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 4450cc67336Smrg# is given, then evaluate it. 4460cc67336Smrgfunc_show_eval () 447301ea0f4Smrg{ 4480cc67336Smrg my_cmd="$1" 4490cc67336Smrg my_fail_exp="${2-:}" 450301ea0f4Smrg 4510cc67336Smrg ${opt_silent-false} || { 4520cc67336Smrg func_quote_for_expand "$my_cmd" 4530cc67336Smrg eval "func_echo $func_quote_for_expand_result" 4540cc67336Smrg } 4550cc67336Smrg 4560cc67336Smrg if ${opt_dry_run-false}; then :; else 4570cc67336Smrg eval "$my_cmd" 4580cc67336Smrg my_status=$? 4590cc67336Smrg if test "$my_status" -eq 0; then :; else 4600cc67336Smrg eval "(exit $my_status); $my_fail_exp" 4610cc67336Smrg fi 462301ea0f4Smrg fi 463301ea0f4Smrg} 464301ea0f4Smrg 4650cc67336Smrg 4660cc67336Smrg# func_show_eval_locale cmd [fail_exp] 4670cc67336Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 4680cc67336Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 4690cc67336Smrg# is given, then evaluate it. Use the saved locale for evaluation. 4700cc67336Smrgfunc_show_eval_locale () 471301ea0f4Smrg{ 4720cc67336Smrg my_cmd="$1" 4730cc67336Smrg my_fail_exp="${2-:}" 474301ea0f4Smrg 4750cc67336Smrg ${opt_silent-false} || { 4760cc67336Smrg func_quote_for_expand "$my_cmd" 4770cc67336Smrg eval "func_echo $func_quote_for_expand_result" 4780cc67336Smrg } 4790cc67336Smrg 4800cc67336Smrg if ${opt_dry_run-false}; then :; else 4810cc67336Smrg eval "$lt_user_locale 4820cc67336Smrg $my_cmd" 4830cc67336Smrg my_status=$? 4840cc67336Smrg eval "$lt_safe_locale" 4850cc67336Smrg if test "$my_status" -eq 0; then :; else 4860cc67336Smrg eval "(exit $my_status); $my_fail_exp" 487301ea0f4Smrg fi 4880cc67336Smrg fi 489301ea0f4Smrg} 490301ea0f4Smrg 491301ea0f4Smrg 492301ea0f4Smrg 4930cc67336Smrg 4940cc67336Smrg 4950cc67336Smrg# func_version 4960cc67336Smrg# Echo version message to standard output and exit. 4970cc67336Smrgfunc_version () 4980cc67336Smrg{ 4990cc67336Smrg $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / { 5000cc67336Smrg s/^# // 5010cc67336Smrg s/^# *$// 5020cc67336Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 5030cc67336Smrg p 5040cc67336Smrg }' < "$progpath" 5050cc67336Smrg exit $? 5060cc67336Smrg} 5070cc67336Smrg 5080cc67336Smrg# func_usage 5090cc67336Smrg# Echo short help message to standard output and exit. 5100cc67336Smrgfunc_usage () 5110cc67336Smrg{ 5120cc67336Smrg $SED -n '/^# Usage:/,/# -h/ { 5130cc67336Smrg s/^# // 5140cc67336Smrg s/^# *$// 5150cc67336Smrg s/\$progname/'$progname'/ 5160cc67336Smrg p 5170cc67336Smrg }' < "$progpath" 5180cc67336Smrg $ECHO 5190cc67336Smrg $ECHO "run \`$progname --help | more' for full usage" 5200cc67336Smrg exit $? 5210cc67336Smrg} 5220cc67336Smrg 5230cc67336Smrg# func_help 5240cc67336Smrg# Echo long help message to standard output and exit. 5250cc67336Smrgfunc_help () 5260cc67336Smrg{ 5270cc67336Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 5280cc67336Smrg s/^# // 5290cc67336Smrg s/^# *$// 5300cc67336Smrg s*\$progname*'$progname'* 5310cc67336Smrg s*\$host*'"$host"'* 5320cc67336Smrg s*\$SHELL*'"$SHELL"'* 5330cc67336Smrg s*\$LTCC*'"$LTCC"'* 5340cc67336Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 5350cc67336Smrg s*\$LD*'"$LD"'* 5360cc67336Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 5370cc67336Smrg s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 5380cc67336Smrg s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 5390cc67336Smrg p 5400cc67336Smrg }' < "$progpath" 5410cc67336Smrg exit $? 5420cc67336Smrg} 5430cc67336Smrg 5440cc67336Smrg# func_missing_arg argname 5450cc67336Smrg# Echo program name prefixed message to standard error and set global 5460cc67336Smrg# exit_cmd. 5470cc67336Smrgfunc_missing_arg () 5480cc67336Smrg{ 5490cc67336Smrg func_error "missing argument for $1" 5500cc67336Smrg exit_cmd=exit 5510cc67336Smrg} 5520cc67336Smrg 5530cc67336Smrgexit_cmd=: 5540cc67336Smrg 5550cc67336Smrg 5560cc67336Smrg 5570cc67336Smrg 5580cc67336Smrg 5590cc67336Smrg# Check that we have a working $ECHO. 5600cc67336Smrgif test "X$1" = X--no-reexec; then 5610cc67336Smrg # Discard the --no-reexec flag, and continue. 562301ea0f4Smrg shift 5630cc67336Smrgelif test "X$1" = X--fallback-echo; then 5640cc67336Smrg # Avoid inline document here, it may be left over 5650cc67336Smrg : 5660cc67336Smrgelif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then 5670cc67336Smrg # Yippee, $ECHO works! 5680cc67336Smrg : 5690cc67336Smrgelse 5700cc67336Smrg # Restart under the correct shell, and then maybe $ECHO will work. 5710cc67336Smrg exec $SHELL "$progpath" --no-reexec ${1+"$@"} 5720cc67336Smrgfi 573301ea0f4Smrg 5740cc67336Smrgif test "X$1" = X--fallback-echo; then 5750cc67336Smrg # used as fallback echo 5760cc67336Smrg shift 5770cc67336Smrg cat <<EOF 5780cc67336Smrg$* 5790cc67336SmrgEOF 5800cc67336Smrg exit $EXIT_SUCCESS 5810cc67336Smrgfi 582301ea0f4Smrg 5830cc67336Smrgmagic="%%%MAGIC variable%%%" 5840cc67336Smrgmagic_exe="%%%MAGIC EXE variable%%%" 585301ea0f4Smrg 5860cc67336Smrg# Global variables. 5870cc67336Smrg# $mode is unset 5880cc67336Smrgnonopt= 5890cc67336Smrgexecute_dlfiles= 5900cc67336Smrgpreserve_args= 5910cc67336Smrglo2o="s/\\.lo\$/.${objext}/" 5920cc67336Smrgo2lo="s/\\.${objext}\$/.lo/" 5930cc67336Smrgextracted_archives= 5940cc67336Smrgextracted_serial=0 595301ea0f4Smrg 5960cc67336Smrgopt_dry_run=false 5970cc67336Smrgopt_duplicate_deps=false 5980cc67336Smrgopt_silent=false 5990cc67336Smrgopt_debug=: 600301ea0f4Smrg 6010cc67336Smrg# If this variable is set in any of the actions, the command in it 6020cc67336Smrg# will be execed at the end. This prevents here-documents from being 6030cc67336Smrg# left over by shells. 6040cc67336Smrgexec_cmd= 605301ea0f4Smrg 6060cc67336Smrg# func_fatal_configuration arg... 6070cc67336Smrg# Echo program name prefixed message to standard error, followed by 6080cc67336Smrg# a configuration failure hint, and exit. 6090cc67336Smrgfunc_fatal_configuration () 6100cc67336Smrg{ 6110cc67336Smrg func_error ${1+"$@"} 6120cc67336Smrg func_error "See the $PACKAGE documentation for more information." 6130cc67336Smrg func_fatal_error "Fatal configuration error." 6140cc67336Smrg} 6150cc67336Smrg 6160cc67336Smrg 6170cc67336Smrg# func_config 6180cc67336Smrg# Display the configuration for all the tags in this script. 6190cc67336Smrgfunc_config () 6200cc67336Smrg{ 6210cc67336Smrg re_begincf='^# ### BEGIN LIBTOOL' 6220cc67336Smrg re_endcf='^# ### END LIBTOOL' 6230cc67336Smrg 6240cc67336Smrg # Default configuration. 6250cc67336Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 626301ea0f4Smrg 627301ea0f4Smrg # Now print the configurations for the tags. 628301ea0f4Smrg for tagname in $taglist; do 6290cc67336Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 630301ea0f4Smrg done 631301ea0f4Smrg 6320cc67336Smrg exit $? 6330cc67336Smrg} 634301ea0f4Smrg 6350cc67336Smrg# func_features 6360cc67336Smrg# Display the features supported by this script. 6370cc67336Smrgfunc_features () 6380cc67336Smrg{ 6390cc67336Smrg $ECHO "host: $host" 640301ea0f4Smrg if test "$build_libtool_libs" = yes; then 6410cc67336Smrg $ECHO "enable shared libraries" 642301ea0f4Smrg else 6430cc67336Smrg $ECHO "disable shared libraries" 644301ea0f4Smrg fi 645301ea0f4Smrg if test "$build_old_libs" = yes; then 6460cc67336Smrg $ECHO "enable static libraries" 647301ea0f4Smrg else 6480cc67336Smrg $ECHO "disable static libraries" 649301ea0f4Smrg fi 6500cc67336Smrg 651301ea0f4Smrg exit $? 6520cc67336Smrg} 6530cc67336Smrg 6540cc67336Smrg# func_enable_tag tagname 6550cc67336Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 6560cc67336Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 6570cc67336Smrg# variable here. 6580cc67336Smrgfunc_enable_tag () 6590cc67336Smrg{ 6600cc67336Smrg # Global variable: 6610cc67336Smrg tagname="$1" 662301ea0f4Smrg 6630cc67336Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 6640cc67336Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 6650cc67336Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 666301ea0f4Smrg 6670cc67336Smrg # Validate tagname. 6680cc67336Smrg case $tagname in 6690cc67336Smrg *[!-_A-Za-z0-9,/]*) 6700cc67336Smrg func_fatal_error "invalid tag name: $tagname" 6710cc67336Smrg ;; 6720cc67336Smrg esac 673301ea0f4Smrg 6740cc67336Smrg # Don't test for the "default" C tag, as we know it's 6750cc67336Smrg # there but not specially marked. 6760cc67336Smrg case $tagname in 6770cc67336Smrg CC) ;; 6780cc67336Smrg *) 6790cc67336Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 6800cc67336Smrg taglist="$taglist $tagname" 6810cc67336Smrg 6820cc67336Smrg # Evaluate the configuration. Be careful to quote the path 6830cc67336Smrg # and the sed script, to avoid splitting on whitespace, but 6840cc67336Smrg # also don't use non-portable quotes within backquotes within 6850cc67336Smrg # quotes we have to do it in 2 steps: 6860cc67336Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 6870cc67336Smrg eval "$extractedcf" 6880cc67336Smrg else 6890cc67336Smrg func_error "ignoring unknown tag $tagname" 6900cc67336Smrg fi 6910cc67336Smrg ;; 6920cc67336Smrg esac 6930cc67336Smrg} 694301ea0f4Smrg 6950cc67336Smrg# Parse options once, thoroughly. This comes as soon as possible in 6960cc67336Smrg# the script to make things like `libtool --version' happen quickly. 6970cc67336Smrg{ 698301ea0f4Smrg 6990cc67336Smrg # Shorthand for --mode=foo, only valid as the first argument 7000cc67336Smrg case $1 in 7010cc67336Smrg clean|clea|cle|cl) 7020cc67336Smrg shift; set dummy --mode clean ${1+"$@"}; shift 703301ea0f4Smrg ;; 7040cc67336Smrg compile|compil|compi|comp|com|co|c) 7050cc67336Smrg shift; set dummy --mode compile ${1+"$@"}; shift 706301ea0f4Smrg ;; 7070cc67336Smrg execute|execut|execu|exec|exe|ex|e) 7080cc67336Smrg shift; set dummy --mode execute ${1+"$@"}; shift 709301ea0f4Smrg ;; 7100cc67336Smrg finish|finis|fini|fin|fi|f) 7110cc67336Smrg shift; set dummy --mode finish ${1+"$@"}; shift 712301ea0f4Smrg ;; 7130cc67336Smrg install|instal|insta|inst|ins|in|i) 7140cc67336Smrg shift; set dummy --mode install ${1+"$@"}; shift 7150cc67336Smrg ;; 7160cc67336Smrg link|lin|li|l) 7170cc67336Smrg shift; set dummy --mode link ${1+"$@"}; shift 7180cc67336Smrg ;; 7190cc67336Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 7200cc67336Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 721301ea0f4Smrg ;; 722301ea0f4Smrg esac 723301ea0f4Smrg 7240cc67336Smrg # Parse non-mode specific arguments: 7250cc67336Smrg while test "$#" -gt 0; do 7260cc67336Smrg opt="$1" 7270cc67336Smrg shift 728301ea0f4Smrg 7290cc67336Smrg case $opt in 7300cc67336Smrg --config) func_config ;; 731301ea0f4Smrg 7320cc67336Smrg --debug) preserve_args="$preserve_args $opt" 7330cc67336Smrg func_echo "enabling shell trace mode" 7340cc67336Smrg opt_debug='set -x' 7350cc67336Smrg $opt_debug 7360cc67336Smrg ;; 737301ea0f4Smrg 7380cc67336Smrg -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break 7390cc67336Smrg execute_dlfiles="$execute_dlfiles $1" 7400cc67336Smrg shift 7410cc67336Smrg ;; 742301ea0f4Smrg 7430cc67336Smrg --dry-run | -n) opt_dry_run=: ;; 7440cc67336Smrg --features) func_features ;; 7450cc67336Smrg --finish) mode="finish" ;; 7460cc67336Smrg 7470cc67336Smrg --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break 7480cc67336Smrg case $1 in 7490cc67336Smrg # Valid mode arguments: 7500cc67336Smrg clean) ;; 7510cc67336Smrg compile) ;; 7520cc67336Smrg execute) ;; 7530cc67336Smrg finish) ;; 7540cc67336Smrg install) ;; 7550cc67336Smrg link) ;; 7560cc67336Smrg relink) ;; 7570cc67336Smrg uninstall) ;; 7580cc67336Smrg 7590cc67336Smrg # Catch anything else as an error 7600cc67336Smrg *) func_error "invalid argument for $opt" 7610cc67336Smrg exit_cmd=exit 7620cc67336Smrg break 7630cc67336Smrg ;; 7640cc67336Smrg esac 7650cc67336Smrg 7660cc67336Smrg mode="$1" 7670cc67336Smrg shift 7680cc67336Smrg ;; 7690cc67336Smrg 7700cc67336Smrg --preserve-dup-deps) 7710cc67336Smrg opt_duplicate_deps=: ;; 7720cc67336Smrg 7730cc67336Smrg --quiet|--silent) preserve_args="$preserve_args $opt" 7740cc67336Smrg opt_silent=: 7750cc67336Smrg ;; 7760cc67336Smrg 7770cc67336Smrg --verbose| -v) preserve_args="$preserve_args $opt" 7780cc67336Smrg opt_silent=false 7790cc67336Smrg ;; 7800cc67336Smrg 7810cc67336Smrg --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break 7820cc67336Smrg preserve_args="$preserve_args $opt $1" 7830cc67336Smrg func_enable_tag "$1" # tagname is set here 7840cc67336Smrg shift 7850cc67336Smrg ;; 7860cc67336Smrg 7870cc67336Smrg # Separate optargs to long options: 7880cc67336Smrg -dlopen=*|--mode=*|--tag=*) 7890cc67336Smrg func_opt_split "$opt" 7900cc67336Smrg set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} 7910cc67336Smrg shift 7920cc67336Smrg ;; 7930cc67336Smrg 7940cc67336Smrg -\?|-h) func_usage ;; 7950cc67336Smrg --help) opt_help=: ;; 7960cc67336Smrg --version) func_version ;; 7970cc67336Smrg 7980cc67336Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 7990cc67336Smrg 8000cc67336Smrg *) nonopt="$opt" 8010cc67336Smrg break 8020cc67336Smrg ;; 8030cc67336Smrg esac 8040cc67336Smrg done 8050cc67336Smrg 8060cc67336Smrg 8070cc67336Smrg case $host in 8080cc67336Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 8090cc67336Smrg # don't eliminate duplications in $postdeps and $predeps 8100cc67336Smrg opt_duplicate_compiler_generated_deps=: 811301ea0f4Smrg ;; 812301ea0f4Smrg *) 8130cc67336Smrg opt_duplicate_compiler_generated_deps=$opt_duplicate_deps 8140cc67336Smrg ;; 8150cc67336Smrg esac 816301ea0f4Smrg 8170cc67336Smrg # Having warned about all mis-specified options, bail out if 8180cc67336Smrg # anything was wrong. 8190cc67336Smrg $exit_cmd $EXIT_FAILURE 8200cc67336Smrg} 8210cc67336Smrg 8220cc67336Smrg# func_check_version_match 8230cc67336Smrg# Ensure that we are using m4 macros, and libtool script from the same 8240cc67336Smrg# release of libtool. 8250cc67336Smrgfunc_check_version_match () 8260cc67336Smrg{ 8270cc67336Smrg if test "$package_revision" != "$macro_revision"; then 8280cc67336Smrg if test "$VERSION" != "$macro_version"; then 8290cc67336Smrg if test -z "$macro_version"; then 8300cc67336Smrg cat >&2 <<_LT_EOF 8310cc67336Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 8320cc67336Smrg$progname: definition of this LT_INIT comes from an older release. 8330cc67336Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 8340cc67336Smrg$progname: and run autoconf again. 8350cc67336Smrg_LT_EOF 8360cc67336Smrg else 8370cc67336Smrg cat >&2 <<_LT_EOF 8380cc67336Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 8390cc67336Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 8400cc67336Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 8410cc67336Smrg$progname: and run autoconf again. 8420cc67336Smrg_LT_EOF 843301ea0f4Smrg fi 8440cc67336Smrg else 8450cc67336Smrg cat >&2 <<_LT_EOF 8460cc67336Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 8470cc67336Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 8480cc67336Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 8490cc67336Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 8500cc67336Smrg_LT_EOF 8510cc67336Smrg fi 8520cc67336Smrg 8530cc67336Smrg exit $EXIT_MISMATCH 8540cc67336Smrg fi 8550cc67336Smrg} 8560cc67336Smrg 8570cc67336Smrg 8580cc67336Smrg## ----------- ## 8590cc67336Smrg## Main. ## 8600cc67336Smrg## ----------- ## 8610cc67336Smrg 8620cc67336Smrg$opt_help || { 8630cc67336Smrg # Sanity checks first: 8640cc67336Smrg func_check_version_match 8650cc67336Smrg 8660cc67336Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 8670cc67336Smrg func_fatal_configuration "not configured to build any kind of library" 868301ea0f4Smrg fi 869301ea0f4Smrg 8700cc67336Smrg test -z "$mode" && func_fatal_error "error: you must specify a MODE." 8710cc67336Smrg 8720cc67336Smrg 8730cc67336Smrg # Darwin sucks 8740cc67336Smrg eval std_shrext=\"$shrext_cmds\" 8750cc67336Smrg 8760cc67336Smrg 877301ea0f4Smrg # Only execute mode is allowed to have -dlopen flags. 878301ea0f4Smrg if test -n "$execute_dlfiles" && test "$mode" != execute; then 8790cc67336Smrg func_error "unrecognized option \`-dlopen'" 8800cc67336Smrg $ECHO "$help" 1>&2 881301ea0f4Smrg exit $EXIT_FAILURE 882301ea0f4Smrg fi 883301ea0f4Smrg 884301ea0f4Smrg # Change the help message to a mode-specific one. 885301ea0f4Smrg generic_help="$help" 8860cc67336Smrg help="Try \`$progname --help --mode=$mode' for more information." 8870cc67336Smrg} 888301ea0f4Smrg 889301ea0f4Smrg 8900cc67336Smrg# func_lalib_p file 8910cc67336Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 8920cc67336Smrg# This function is only a basic sanity check; it will hardly flush out 8930cc67336Smrg# determined imposters. 8940cc67336Smrgfunc_lalib_p () 8950cc67336Smrg{ 8960cc67336Smrg test -f "$1" && 8970cc67336Smrg $SED -e 4q "$1" 2>/dev/null \ 8980cc67336Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 8990cc67336Smrg} 900301ea0f4Smrg 9010cc67336Smrg# func_lalib_unsafe_p file 9020cc67336Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 9030cc67336Smrg# This function implements the same check as func_lalib_p without 9040cc67336Smrg# resorting to external programs. To this end, it redirects stdin and 9050cc67336Smrg# closes it afterwards, without saving the original file descriptor. 9060cc67336Smrg# As a safety measure, use it only where a negative result would be 9070cc67336Smrg# fatal anyway. Works if `file' does not exist. 9080cc67336Smrgfunc_lalib_unsafe_p () 9090cc67336Smrg{ 9100cc67336Smrg lalib_p=no 9110cc67336Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 9120cc67336Smrg for lalib_p_l in 1 2 3 4 9130cc67336Smrg do 9140cc67336Smrg read lalib_p_line 9150cc67336Smrg case "$lalib_p_line" in 9160cc67336Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 9170cc67336Smrg esac 9180cc67336Smrg done 9190cc67336Smrg exec 0<&5 5<&- 9200cc67336Smrg fi 9210cc67336Smrg test "$lalib_p" = yes 9220cc67336Smrg} 923301ea0f4Smrg 9240cc67336Smrg# func_ltwrapper_script_p file 9250cc67336Smrg# True iff FILE is a libtool wrapper script 9260cc67336Smrg# This function is only a basic sanity check; it will hardly flush out 9270cc67336Smrg# determined imposters. 9280cc67336Smrgfunc_ltwrapper_script_p () 9290cc67336Smrg{ 9300cc67336Smrg func_lalib_p "$1" 9310cc67336Smrg} 932301ea0f4Smrg 9330cc67336Smrg# func_ltwrapper_executable_p file 9340cc67336Smrg# True iff FILE is a libtool wrapper executable 9350cc67336Smrg# This function is only a basic sanity check; it will hardly flush out 9360cc67336Smrg# determined imposters. 9370cc67336Smrgfunc_ltwrapper_executable_p () 9380cc67336Smrg{ 9390cc67336Smrg func_ltwrapper_exec_suffix= 9400cc67336Smrg case $1 in 9410cc67336Smrg *.exe) ;; 9420cc67336Smrg *) func_ltwrapper_exec_suffix=.exe ;; 9430cc67336Smrg esac 9440cc67336Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 9450cc67336Smrg} 946301ea0f4Smrg 9470cc67336Smrg# func_ltwrapper_scriptname file 9480cc67336Smrg# Assumes file is an ltwrapper_executable 9490cc67336Smrg# uses $file to determine the appropriate filename for a 9500cc67336Smrg# temporary ltwrapper_script. 9510cc67336Smrgfunc_ltwrapper_scriptname () 9520cc67336Smrg{ 9530cc67336Smrg func_ltwrapper_scriptname_result="" 9540cc67336Smrg if func_ltwrapper_executable_p "$1"; then 9550cc67336Smrg func_dirname_and_basename "$1" "" "." 9560cc67336Smrg func_stripname '' '.exe' "$func_basename_result" 9570cc67336Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 9580cc67336Smrg fi 9590cc67336Smrg} 960301ea0f4Smrg 9610cc67336Smrg# func_ltwrapper_p file 9620cc67336Smrg# True iff FILE is a libtool wrapper script or wrapper executable 9630cc67336Smrg# This function is only a basic sanity check; it will hardly flush out 9640cc67336Smrg# determined imposters. 9650cc67336Smrgfunc_ltwrapper_p () 9660cc67336Smrg{ 9670cc67336Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 9680cc67336Smrg} 969301ea0f4Smrg 970301ea0f4Smrg 9710cc67336Smrg# func_execute_cmds commands fail_cmd 9720cc67336Smrg# Execute tilde-delimited COMMANDS. 9730cc67336Smrg# If FAIL_CMD is given, eval that upon failure. 9740cc67336Smrg# FAIL_CMD may read-access the current command in variable CMD! 9750cc67336Smrgfunc_execute_cmds () 9760cc67336Smrg{ 9770cc67336Smrg $opt_debug 9780cc67336Smrg save_ifs=$IFS; IFS='~' 9790cc67336Smrg for cmd in $1; do 9800cc67336Smrg IFS=$save_ifs 9810cc67336Smrg eval cmd=\"$cmd\" 9820cc67336Smrg func_show_eval "$cmd" "${2-:}" 9830cc67336Smrg done 9840cc67336Smrg IFS=$save_ifs 9850cc67336Smrg} 9860cc67336Smrg 9870cc67336Smrg 9880cc67336Smrg# func_source file 9890cc67336Smrg# Source FILE, adding directory component if necessary. 9900cc67336Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 9910cc67336Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 9920cc67336Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 9930cc67336Smrg# `FILE.' does not work on cygwin managed mounts. 9940cc67336Smrgfunc_source () 9950cc67336Smrg{ 9960cc67336Smrg $opt_debug 9970cc67336Smrg case $1 in 9980cc67336Smrg */* | *\\*) . "$1" ;; 9990cc67336Smrg *) . "./$1" ;; 10000cc67336Smrg esac 10010cc67336Smrg} 10020cc67336Smrg 10030cc67336Smrg 10040cc67336Smrg# func_infer_tag arg 10050cc67336Smrg# Infer tagged configuration to use if any are available and 10060cc67336Smrg# if one wasn't chosen via the "--tag" command line option. 10070cc67336Smrg# Only attempt this if the compiler in the base compile 10080cc67336Smrg# command doesn't match the default compiler. 10090cc67336Smrg# arg is usually of the form 'gcc ...' 10100cc67336Smrgfunc_infer_tag () 10110cc67336Smrg{ 10120cc67336Smrg $opt_debug 10130cc67336Smrg if test -n "$available_tags" && test -z "$tagname"; then 10140cc67336Smrg CC_quoted= 10150cc67336Smrg for arg in $CC; do 10160cc67336Smrg func_quote_for_eval "$arg" 10170cc67336Smrg CC_quoted="$CC_quoted $func_quote_for_eval_result" 10180cc67336Smrg done 10190cc67336Smrg case $@ in 10200cc67336Smrg # Blanks in the command may have been stripped by the calling shell, 10210cc67336Smrg # but not from the CC environment variable when configure was run. 10220cc67336Smrg " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;; 10230cc67336Smrg # Blanks at the start of $base_compile will cause this to fail 10240cc67336Smrg # if we don't check for them as well. 10250cc67336Smrg *) 10260cc67336Smrg for z in $available_tags; do 10270cc67336Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 10280cc67336Smrg # Evaluate the configuration. 10290cc67336Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 10300cc67336Smrg CC_quoted= 10310cc67336Smrg for arg in $CC; do 10320cc67336Smrg # Double-quote args containing other shell metacharacters. 10330cc67336Smrg func_quote_for_eval "$arg" 10340cc67336Smrg CC_quoted="$CC_quoted $func_quote_for_eval_result" 10350cc67336Smrg done 10360cc67336Smrg case "$@ " in 10370cc67336Smrg " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) 10380cc67336Smrg # The compiler in the base compile command matches 10390cc67336Smrg # the one in the tagged configuration. 10400cc67336Smrg # Assume this is the tagged configuration we want. 10410cc67336Smrg tagname=$z 10420cc67336Smrg break 10430cc67336Smrg ;; 1044301ea0f4Smrg esac 10450cc67336Smrg fi 10460cc67336Smrg done 10470cc67336Smrg # If $tagname still isn't set, then no tagged configuration 10480cc67336Smrg # was found and let the user know that the "--tag" command 10490cc67336Smrg # line option must be used. 10500cc67336Smrg if test -z "$tagname"; then 10510cc67336Smrg func_echo "unable to infer tagged configuration" 10520cc67336Smrg func_fatal_error "specify a tag with \`--tag'" 10530cc67336Smrg# else 10540cc67336Smrg# func_verbose "using $tagname tagged configuration" 10550cc67336Smrg fi 10560cc67336Smrg ;; 10570cc67336Smrg esac 10580cc67336Smrg fi 10590cc67336Smrg} 10600cc67336Smrg 10610cc67336Smrg 10620cc67336Smrg 10630cc67336Smrg# func_write_libtool_object output_name pic_name nonpic_name 10640cc67336Smrg# Create a libtool object file (analogous to a ".la" file), 10650cc67336Smrg# but don't create it if we're doing a dry run. 10660cc67336Smrgfunc_write_libtool_object () 10670cc67336Smrg{ 10680cc67336Smrg write_libobj=${1} 10690cc67336Smrg if test "$build_libtool_libs" = yes; then 10700cc67336Smrg write_lobj=\'${2}\' 10710cc67336Smrg else 10720cc67336Smrg write_lobj=none 10730cc67336Smrg fi 10740cc67336Smrg 10750cc67336Smrg if test "$build_old_libs" = yes; then 10760cc67336Smrg write_oldobj=\'${3}\' 10770cc67336Smrg else 10780cc67336Smrg write_oldobj=none 10790cc67336Smrg fi 10800cc67336Smrg 10810cc67336Smrg $opt_dry_run || { 10820cc67336Smrg cat >${write_libobj}T <<EOF 10830cc67336Smrg# $write_libobj - a libtool object file 10840cc67336Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 10850cc67336Smrg# 10860cc67336Smrg# Please DO NOT delete this file! 10870cc67336Smrg# It is necessary for linking the library. 10880cc67336Smrg 10890cc67336Smrg# Name of the PIC object. 10900cc67336Smrgpic_object=$write_lobj 10910cc67336Smrg 10920cc67336Smrg# Name of the non-PIC object 10930cc67336Smrgnon_pic_object=$write_oldobj 10940cc67336Smrg 10950cc67336SmrgEOF 10960cc67336Smrg $MV "${write_libobj}T" "${write_libobj}" 10970cc67336Smrg } 10980cc67336Smrg} 10990cc67336Smrg 11000cc67336Smrg# func_mode_compile arg... 11010cc67336Smrgfunc_mode_compile () 11020cc67336Smrg{ 11030cc67336Smrg $opt_debug 11040cc67336Smrg # Get the compilation command and the source file. 11050cc67336Smrg base_compile= 11060cc67336Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 11070cc67336Smrg suppress_opt=yes 11080cc67336Smrg suppress_output= 11090cc67336Smrg arg_mode=normal 11100cc67336Smrg libobj= 11110cc67336Smrg later= 11120cc67336Smrg pie_flag= 11130cc67336Smrg 11140cc67336Smrg for arg 11150cc67336Smrg do 11160cc67336Smrg case $arg_mode in 11170cc67336Smrg arg ) 11180cc67336Smrg # do not "continue". Instead, add this to base_compile 11190cc67336Smrg lastarg="$arg" 11200cc67336Smrg arg_mode=normal 11210cc67336Smrg ;; 11220cc67336Smrg 11230cc67336Smrg target ) 11240cc67336Smrg libobj="$arg" 11250cc67336Smrg arg_mode=normal 11260cc67336Smrg continue 11270cc67336Smrg ;; 11280cc67336Smrg 11290cc67336Smrg normal ) 11300cc67336Smrg # Accept any command-line options. 11310cc67336Smrg case $arg in 11320cc67336Smrg -o) 11330cc67336Smrg test -n "$libobj" && \ 11340cc67336Smrg func_fatal_error "you cannot specify \`-o' more than once" 11350cc67336Smrg arg_mode=target 11360cc67336Smrg continue 11370cc67336Smrg ;; 11380cc67336Smrg 11390cc67336Smrg -pie | -fpie | -fPIE) 11400cc67336Smrg pie_flag="$pie_flag $arg" 11410cc67336Smrg continue 11420cc67336Smrg ;; 11430cc67336Smrg 11440cc67336Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 11450cc67336Smrg later="$later $arg" 11460cc67336Smrg continue 11470cc67336Smrg ;; 11480cc67336Smrg 11490cc67336Smrg -no-suppress) 11500cc67336Smrg suppress_opt=no 11510cc67336Smrg continue 11520cc67336Smrg ;; 11530cc67336Smrg 11540cc67336Smrg -Xcompiler) 11550cc67336Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 11560cc67336Smrg continue # The current "srcfile" will either be retained or 11570cc67336Smrg ;; # replaced later. I would guess that would be a bug. 11580cc67336Smrg 11590cc67336Smrg -Wc,*) 11600cc67336Smrg func_stripname '-Wc,' '' "$arg" 11610cc67336Smrg args=$func_stripname_result 11620cc67336Smrg lastarg= 11630cc67336Smrg save_ifs="$IFS"; IFS=',' 11640cc67336Smrg for arg in $args; do 11650cc67336Smrg IFS="$save_ifs" 11660cc67336Smrg func_quote_for_eval "$arg" 11670cc67336Smrg lastarg="$lastarg $func_quote_for_eval_result" 1168301ea0f4Smrg done 1169301ea0f4Smrg IFS="$save_ifs" 11700cc67336Smrg func_stripname ' ' '' "$lastarg" 11710cc67336Smrg lastarg=$func_stripname_result 1172301ea0f4Smrg 1173301ea0f4Smrg # Add the arguments to base_compile. 1174301ea0f4Smrg base_compile="$base_compile $lastarg" 1175301ea0f4Smrg continue 1176301ea0f4Smrg ;; 1177301ea0f4Smrg 11780cc67336Smrg *) 1179301ea0f4Smrg # Accept the current argument as the source file. 1180301ea0f4Smrg # The previous "srcfile" becomes the current argument. 1181301ea0f4Smrg # 1182301ea0f4Smrg lastarg="$srcfile" 1183301ea0f4Smrg srcfile="$arg" 1184301ea0f4Smrg ;; 1185301ea0f4Smrg esac # case $arg 1186301ea0f4Smrg ;; 1187301ea0f4Smrg esac # case $arg_mode 1188301ea0f4Smrg 1189301ea0f4Smrg # Aesthetically quote the previous argument. 11900cc67336Smrg func_quote_for_eval "$lastarg" 11910cc67336Smrg base_compile="$base_compile $func_quote_for_eval_result" 1192301ea0f4Smrg done # for arg 1193301ea0f4Smrg 1194301ea0f4Smrg case $arg_mode in 1195301ea0f4Smrg arg) 11960cc67336Smrg func_fatal_error "you must specify an argument for -Xcompile" 1197301ea0f4Smrg ;; 1198301ea0f4Smrg target) 11990cc67336Smrg func_fatal_error "you must specify a target with \`-o'" 1200301ea0f4Smrg ;; 1201301ea0f4Smrg *) 1202301ea0f4Smrg # Get the name of the library object. 12030cc67336Smrg test -z "$libobj" && { 12040cc67336Smrg func_basename "$srcfile" 12050cc67336Smrg libobj="$func_basename_result" 12060cc67336Smrg } 1207301ea0f4Smrg ;; 1208301ea0f4Smrg esac 1209301ea0f4Smrg 1210301ea0f4Smrg # Recognize several different file suffixes. 1211301ea0f4Smrg # If the user specifies -o file.o, it is replaced with file.lo 1212301ea0f4Smrg case $libobj in 12130cc67336Smrg *.[cCFSifmso] | \ 12140cc67336Smrg *.ada | *.adb | *.ads | *.asm | \ 12150cc67336Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 12160cc67336Smrg *.[fF][09]? | *.for | *.java | *.obj | *.sx) 12170cc67336Smrg func_xform "$libobj" 12180cc67336Smrg libobj=$func_xform_result 12190cc67336Smrg ;; 1220301ea0f4Smrg esac 1221301ea0f4Smrg 1222301ea0f4Smrg case $libobj in 12230cc67336Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 1224301ea0f4Smrg *) 12250cc67336Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 1226301ea0f4Smrg ;; 1227301ea0f4Smrg esac 1228301ea0f4Smrg 1229301ea0f4Smrg func_infer_tag $base_compile 1230301ea0f4Smrg 1231301ea0f4Smrg for arg in $later; do 1232301ea0f4Smrg case $arg in 12330cc67336Smrg -shared) 12340cc67336Smrg test "$build_libtool_libs" != yes && \ 12350cc67336Smrg func_fatal_configuration "can not build a shared library" 12360cc67336Smrg build_old_libs=no 12370cc67336Smrg continue 12380cc67336Smrg ;; 12390cc67336Smrg 1240301ea0f4Smrg -static) 12410cc67336Smrg build_libtool_libs=no 1242301ea0f4Smrg build_old_libs=yes 1243301ea0f4Smrg continue 1244301ea0f4Smrg ;; 1245301ea0f4Smrg 1246301ea0f4Smrg -prefer-pic) 1247301ea0f4Smrg pic_mode=yes 1248301ea0f4Smrg continue 1249301ea0f4Smrg ;; 1250301ea0f4Smrg 1251301ea0f4Smrg -prefer-non-pic) 1252301ea0f4Smrg pic_mode=no 1253301ea0f4Smrg continue 1254301ea0f4Smrg ;; 1255301ea0f4Smrg esac 1256301ea0f4Smrg done 1257301ea0f4Smrg 12580cc67336Smrg func_quote_for_eval "$libobj" 12590cc67336Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 12600cc67336Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 12610cc67336Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 12620cc67336Smrg func_dirname_and_basename "$obj" "/" "" 12630cc67336Smrg objname="$func_basename_result" 12640cc67336Smrg xdir="$func_dirname_result" 1265301ea0f4Smrg lobj=${xdir}$objdir/$objname 1266301ea0f4Smrg 12670cc67336Smrg test -z "$base_compile" && \ 12680cc67336Smrg func_fatal_help "you must specify a compilation command" 1269301ea0f4Smrg 1270301ea0f4Smrg # Delete any leftover library objects. 1271301ea0f4Smrg if test "$build_old_libs" = yes; then 1272301ea0f4Smrg removelist="$obj $lobj $libobj ${libobj}T" 1273301ea0f4Smrg else 1274301ea0f4Smrg removelist="$lobj $libobj ${libobj}T" 1275301ea0f4Smrg fi 1276301ea0f4Smrg 1277301ea0f4Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 1278301ea0f4Smrg case $host_os in 12790cc67336Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 1280301ea0f4Smrg pic_mode=default 1281301ea0f4Smrg ;; 1282301ea0f4Smrg esac 1283301ea0f4Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 1284301ea0f4Smrg # non-PIC code in shared libraries is not supported 1285301ea0f4Smrg pic_mode=default 1286301ea0f4Smrg fi 1287301ea0f4Smrg 1288301ea0f4Smrg # Calculate the filename of the output object if compiler does 1289301ea0f4Smrg # not support -o with -c 1290301ea0f4Smrg if test "$compiler_c_o" = no; then 12910cc67336Smrg output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} 1292301ea0f4Smrg lockfile="$output_obj.lock" 1293301ea0f4Smrg else 1294301ea0f4Smrg output_obj= 1295301ea0f4Smrg need_locks=no 1296301ea0f4Smrg lockfile= 1297301ea0f4Smrg fi 1298301ea0f4Smrg 1299301ea0f4Smrg # Lock this critical section if it is needed 1300301ea0f4Smrg # We use this script file to make the link, it avoids creating a new file 1301301ea0f4Smrg if test "$need_locks" = yes; then 13020cc67336Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 13030cc67336Smrg func_echo "Waiting for $lockfile to be removed" 1304301ea0f4Smrg sleep 2 1305301ea0f4Smrg done 1306301ea0f4Smrg elif test "$need_locks" = warn; then 1307301ea0f4Smrg if test -f "$lockfile"; then 13080cc67336Smrg $ECHO "\ 1309301ea0f4Smrg*** ERROR, $lockfile exists and contains: 1310301ea0f4Smrg`cat $lockfile 2>/dev/null` 1311301ea0f4Smrg 1312301ea0f4SmrgThis indicates that another process is trying to use the same 1313301ea0f4Smrgtemporary object file, and libtool could not work around it because 1314301ea0f4Smrgyour compiler does not support \`-c' and \`-o' together. If you 1315301ea0f4Smrgrepeat this compilation, it may succeed, by chance, but you had better 1316301ea0f4Smrgavoid parallel builds (make -j) in this platform, or get a better 1317301ea0f4Smrgcompiler." 1318301ea0f4Smrg 13190cc67336Smrg $opt_dry_run || $RM $removelist 1320301ea0f4Smrg exit $EXIT_FAILURE 1321301ea0f4Smrg fi 13220cc67336Smrg removelist="$removelist $output_obj" 13230cc67336Smrg $ECHO "$srcfile" > "$lockfile" 1324301ea0f4Smrg fi 1325301ea0f4Smrg 13260cc67336Smrg $opt_dry_run || $RM $removelist 13270cc67336Smrg removelist="$removelist $lockfile" 13280cc67336Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 13290cc67336Smrg 1330301ea0f4Smrg if test -n "$fix_srcfile_path"; then 1331301ea0f4Smrg eval srcfile=\"$fix_srcfile_path\" 1332301ea0f4Smrg fi 13330cc67336Smrg func_quote_for_eval "$srcfile" 13340cc67336Smrg qsrcfile=$func_quote_for_eval_result 1335301ea0f4Smrg 1336301ea0f4Smrg # Only build a PIC object if we are building libtool libraries. 1337301ea0f4Smrg if test "$build_libtool_libs" = yes; then 1338301ea0f4Smrg # Without this assignment, base_compile gets emptied. 1339301ea0f4Smrg fbsd_hideous_sh_bug=$base_compile 1340301ea0f4Smrg 1341301ea0f4Smrg if test "$pic_mode" != no; then 1342301ea0f4Smrg command="$base_compile $qsrcfile $pic_flag" 1343301ea0f4Smrg else 1344301ea0f4Smrg # Don't build PIC code 1345301ea0f4Smrg command="$base_compile $qsrcfile" 1346301ea0f4Smrg fi 1347301ea0f4Smrg 13480cc67336Smrg func_mkdir_p "$xdir$objdir" 1349301ea0f4Smrg 1350301ea0f4Smrg if test -z "$output_obj"; then 1351301ea0f4Smrg # Place PIC objects in $objdir 1352301ea0f4Smrg command="$command -o $lobj" 1353301ea0f4Smrg fi 1354301ea0f4Smrg 13550cc67336Smrg func_show_eval_locale "$command" \ 13560cc67336Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 1357301ea0f4Smrg 1358301ea0f4Smrg if test "$need_locks" = warn && 1359301ea0f4Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 13600cc67336Smrg $ECHO "\ 1361301ea0f4Smrg*** ERROR, $lockfile contains: 1362301ea0f4Smrg`cat $lockfile 2>/dev/null` 1363301ea0f4Smrg 1364301ea0f4Smrgbut it should contain: 1365301ea0f4Smrg$srcfile 1366301ea0f4Smrg 1367301ea0f4SmrgThis indicates that another process is trying to use the same 1368301ea0f4Smrgtemporary object file, and libtool could not work around it because 1369301ea0f4Smrgyour compiler does not support \`-c' and \`-o' together. If you 1370301ea0f4Smrgrepeat this compilation, it may succeed, by chance, but you had better 1371301ea0f4Smrgavoid parallel builds (make -j) in this platform, or get a better 1372301ea0f4Smrgcompiler." 1373301ea0f4Smrg 13740cc67336Smrg $opt_dry_run || $RM $removelist 1375301ea0f4Smrg exit $EXIT_FAILURE 1376301ea0f4Smrg fi 1377301ea0f4Smrg 1378301ea0f4Smrg # Just move the object if needed, then go on to compile the next one 1379301ea0f4Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 13800cc67336Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 13810cc67336Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 1382301ea0f4Smrg fi 1383301ea0f4Smrg 1384301ea0f4Smrg # Allow error messages only from the first compilation. 1385301ea0f4Smrg if test "$suppress_opt" = yes; then 13860cc67336Smrg suppress_output=' >/dev/null 2>&1' 1387301ea0f4Smrg fi 1388301ea0f4Smrg fi 1389301ea0f4Smrg 1390301ea0f4Smrg # Only build a position-dependent object if we build old libraries. 1391301ea0f4Smrg if test "$build_old_libs" = yes; then 1392301ea0f4Smrg if test "$pic_mode" != yes; then 1393301ea0f4Smrg # Don't build PIC code 13940cc67336Smrg command="$base_compile $qsrcfile$pie_flag" 1395301ea0f4Smrg else 1396301ea0f4Smrg command="$base_compile $qsrcfile $pic_flag" 1397301ea0f4Smrg fi 1398301ea0f4Smrg if test "$compiler_c_o" = yes; then 1399301ea0f4Smrg command="$command -o $obj" 1400301ea0f4Smrg fi 1401301ea0f4Smrg 1402301ea0f4Smrg # Suppress compiler output if we already did a PIC compilation. 1403301ea0f4Smrg command="$command$suppress_output" 14040cc67336Smrg func_show_eval_locale "$command" \ 14050cc67336Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1406301ea0f4Smrg 1407301ea0f4Smrg if test "$need_locks" = warn && 1408301ea0f4Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 14090cc67336Smrg $ECHO "\ 1410301ea0f4Smrg*** ERROR, $lockfile contains: 1411301ea0f4Smrg`cat $lockfile 2>/dev/null` 1412301ea0f4Smrg 1413301ea0f4Smrgbut it should contain: 1414301ea0f4Smrg$srcfile 1415301ea0f4Smrg 1416301ea0f4SmrgThis indicates that another process is trying to use the same 1417301ea0f4Smrgtemporary object file, and libtool could not work around it because 1418301ea0f4Smrgyour compiler does not support \`-c' and \`-o' together. If you 1419301ea0f4Smrgrepeat this compilation, it may succeed, by chance, but you had better 1420301ea0f4Smrgavoid parallel builds (make -j) in this platform, or get a better 1421301ea0f4Smrgcompiler." 1422301ea0f4Smrg 14230cc67336Smrg $opt_dry_run || $RM $removelist 1424301ea0f4Smrg exit $EXIT_FAILURE 1425301ea0f4Smrg fi 1426301ea0f4Smrg 1427301ea0f4Smrg # Just move the object if needed 1428301ea0f4Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 14290cc67336Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 14300cc67336Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 1431301ea0f4Smrg fi 1432301ea0f4Smrg fi 1433301ea0f4Smrg 14340cc67336Smrg $opt_dry_run || { 14350cc67336Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 1436301ea0f4Smrg 14370cc67336Smrg # Unlock the critical section if it was locked 14380cc67336Smrg if test "$need_locks" != no; then 14390cc67336Smrg removelist=$lockfile 14400cc67336Smrg $RM "$lockfile" 14410cc67336Smrg fi 14420cc67336Smrg } 1443301ea0f4Smrg 1444301ea0f4Smrg exit $EXIT_SUCCESS 14450cc67336Smrg} 1446301ea0f4Smrg 14470cc67336Smrg$opt_help || { 14480cc67336Smrgtest "$mode" = compile && func_mode_compile ${1+"$@"} 14490cc67336Smrg} 1450301ea0f4Smrg 14510cc67336Smrgfunc_mode_help () 14520cc67336Smrg{ 14530cc67336Smrg # We need to display help for each of the modes. 14540cc67336Smrg case $mode in 14550cc67336Smrg "") 14560cc67336Smrg # Generic help is extracted from the usage comments 14570cc67336Smrg # at the start of this file. 14580cc67336Smrg func_help 14590cc67336Smrg ;; 1460301ea0f4Smrg 14610cc67336Smrg clean) 14620cc67336Smrg $ECHO \ 14630cc67336Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 1464301ea0f4Smrg 14650cc67336SmrgRemove files from the build directory. 1466301ea0f4Smrg 14670cc67336SmrgRM is the name of the program to use to delete files associated with each FILE 14680cc67336Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 14690cc67336Smrgto RM. 1470301ea0f4Smrg 14710cc67336SmrgIf FILE is a libtool library, object or program, all the files associated 14720cc67336Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 14730cc67336Smrg ;; 1474301ea0f4Smrg 14750cc67336Smrg compile) 14760cc67336Smrg $ECHO \ 14770cc67336Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 1478301ea0f4Smrg 14790cc67336SmrgCompile a source file into a libtool library object. 1480301ea0f4Smrg 14810cc67336SmrgThis mode accepts the following additional options: 1482301ea0f4Smrg 14830cc67336Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 14840cc67336Smrg -no-suppress do not suppress compiler output for multiple passes 14850cc67336Smrg -prefer-pic try to building PIC objects only 14860cc67336Smrg -prefer-non-pic try to building non-PIC objects only 14870cc67336Smrg -shared do not build a \`.o' file suitable for static linking 14880cc67336Smrg -static only build a \`.o' file suitable for static linking 1489301ea0f4Smrg 14900cc67336SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 14910cc67336Smrgfrom the given SOURCEFILE. 1492301ea0f4Smrg 14930cc67336SmrgThe output file name is determined by removing the directory component from 14940cc67336SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 14950cc67336Smrglibrary object suffix, \`.lo'." 14960cc67336Smrg ;; 1497301ea0f4Smrg 14980cc67336Smrg execute) 14990cc67336Smrg $ECHO \ 15000cc67336Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 1501301ea0f4Smrg 15020cc67336SmrgAutomatically set library path, then run a program. 1503301ea0f4Smrg 15040cc67336SmrgThis mode accepts the following additional options: 1505301ea0f4Smrg 15060cc67336Smrg -dlopen FILE add the directory containing FILE to the library path 1507301ea0f4Smrg 15080cc67336SmrgThis mode sets the library path environment variable according to \`-dlopen' 15090cc67336Smrgflags. 1510301ea0f4Smrg 15110cc67336SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 15120cc67336Smrginto their corresponding uninstalled binary, and any of their required library 15130cc67336Smrgdirectories are added to the library path. 1514301ea0f4Smrg 15150cc67336SmrgThen, COMMAND is executed, with ARGS as arguments." 15160cc67336Smrg ;; 1517301ea0f4Smrg 15180cc67336Smrg finish) 15190cc67336Smrg $ECHO \ 15200cc67336Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 1521301ea0f4Smrg 15220cc67336SmrgComplete the installation of libtool libraries. 1523301ea0f4Smrg 15240cc67336SmrgEach LIBDIR is a directory that contains libtool libraries. 1525301ea0f4Smrg 15260cc67336SmrgThe commands that this mode executes may require superuser privileges. Use 15270cc67336Smrgthe \`--dry-run' option if you just want to see what would be executed." 15280cc67336Smrg ;; 1529301ea0f4Smrg 15300cc67336Smrg install) 15310cc67336Smrg $ECHO \ 15320cc67336Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 1533301ea0f4Smrg 15340cc67336SmrgInstall executables or libraries. 1535301ea0f4Smrg 15360cc67336SmrgINSTALL-COMMAND is the installation command. The first component should be 15370cc67336Smrgeither the \`install' or \`cp' program. 1538301ea0f4Smrg 15390cc67336SmrgThe following components of INSTALL-COMMAND are treated specially: 1540301ea0f4Smrg 15410cc67336Smrg -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation 1542301ea0f4Smrg 15430cc67336SmrgThe rest of the components are interpreted as arguments to that command (only 15440cc67336SmrgBSD-compatible install options are recognized)." 15450cc67336Smrg ;; 1546301ea0f4Smrg 15470cc67336Smrg link) 15480cc67336Smrg $ECHO \ 15490cc67336Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 1550301ea0f4Smrg 15510cc67336SmrgLink object files or libraries together to form another library, or to 15520cc67336Smrgcreate an executable program. 1553301ea0f4Smrg 15540cc67336SmrgLINK-COMMAND is a command using the C compiler that you would use to create 15550cc67336Smrga program from several object files. 1556301ea0f4Smrg 15570cc67336SmrgThe following components of LINK-COMMAND are treated specially: 1558301ea0f4Smrg 15590cc67336Smrg -all-static do not do any dynamic linking at all 15600cc67336Smrg -avoid-version do not add a version suffix if possible 15610cc67336Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 15620cc67336Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 15630cc67336Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 15640cc67336Smrg -export-symbols SYMFILE 15650cc67336Smrg try to export only the symbols listed in SYMFILE 15660cc67336Smrg -export-symbols-regex REGEX 15670cc67336Smrg try to export only the symbols matching REGEX 15680cc67336Smrg -LLIBDIR search LIBDIR for required installed libraries 15690cc67336Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 15700cc67336Smrg -module build a library that can dlopened 15710cc67336Smrg -no-fast-install disable the fast-install mode 15720cc67336Smrg -no-install link a not-installable executable 15730cc67336Smrg -no-undefined declare that a library does not refer to external symbols 15740cc67336Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 15750cc67336Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 15760cc67336Smrg -precious-files-regex REGEX 15770cc67336Smrg don't remove output files matching REGEX 15780cc67336Smrg -release RELEASE specify package release information 15790cc67336Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 15800cc67336Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 15810cc67336Smrg -shared only do dynamic linking of libtool libraries 15820cc67336Smrg -shrext SUFFIX override the standard shared library file extension 15830cc67336Smrg -static do not do any dynamic linking of uninstalled libtool libraries 15840cc67336Smrg -static-libtool-libs 15850cc67336Smrg do not do any dynamic linking of libtool libraries 15860cc67336Smrg -version-info CURRENT[:REVISION[:AGE]] 15870cc67336Smrg specify library version info [each variable defaults to 0] 15880cc67336Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 1589301ea0f4Smrg 15900cc67336SmrgAll other options (arguments beginning with \`-') are ignored. 1591301ea0f4Smrg 15920cc67336SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 15930cc67336Smrgtreated as uninstalled libtool libraries, other files are standard or library 15940cc67336Smrgobject files. 1595301ea0f4Smrg 15960cc67336SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 15970cc67336Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 15980cc67336Smrgrequired, except when creating a convenience library. 1599301ea0f4Smrg 16000cc67336SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 16010cc67336Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 1602301ea0f4Smrg 16030cc67336SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 16040cc67336Smrgis created, otherwise an executable program is created." 1605301ea0f4Smrg ;; 1606301ea0f4Smrg 16070cc67336Smrg uninstall) 16080cc67336Smrg $ECHO \ 16090cc67336Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 1610301ea0f4Smrg 16110cc67336SmrgRemove libraries from an installation directory. 1612301ea0f4Smrg 16130cc67336SmrgRM is the name of the program to use to delete files associated with each FILE 16140cc67336Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 16150cc67336Smrgto RM. 1616301ea0f4Smrg 16170cc67336SmrgIf FILE is a libtool library, all the files associated with it are deleted. 16180cc67336SmrgOtherwise, only FILE itself is deleted using RM." 16190cc67336Smrg ;; 1620301ea0f4Smrg 16210cc67336Smrg *) 16220cc67336Smrg func_fatal_help "invalid operation mode \`$mode'" 16230cc67336Smrg ;; 16240cc67336Smrg esac 1625301ea0f4Smrg 16260cc67336Smrg $ECHO 16270cc67336Smrg $ECHO "Try \`$progname --help' for more information about other modes." 1628301ea0f4Smrg 16290cc67336Smrg exit $? 16300cc67336Smrg} 1631301ea0f4Smrg 16320cc67336Smrg # Now that we've collected a possible --mode arg, show help if necessary 16330cc67336Smrg $opt_help && func_mode_help 1634301ea0f4Smrg 1635301ea0f4Smrg 16360cc67336Smrg# func_mode_execute arg... 16370cc67336Smrgfunc_mode_execute () 16380cc67336Smrg{ 16390cc67336Smrg $opt_debug 16400cc67336Smrg # The first argument is the command name. 16410cc67336Smrg cmd="$nonopt" 16420cc67336Smrg test -z "$cmd" && \ 16430cc67336Smrg func_fatal_help "you must specify a COMMAND" 1644301ea0f4Smrg 16450cc67336Smrg # Handle -dlopen flags immediately. 16460cc67336Smrg for file in $execute_dlfiles; do 16470cc67336Smrg test -f "$file" \ 16480cc67336Smrg || func_fatal_help "\`$file' is not a file" 1649301ea0f4Smrg 16500cc67336Smrg dir= 16510cc67336Smrg case $file in 16520cc67336Smrg *.la) 16530cc67336Smrg # Check to see that this really is a libtool archive. 16540cc67336Smrg func_lalib_unsafe_p "$file" \ 16550cc67336Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 1656301ea0f4Smrg 16570cc67336Smrg # Read the libtool library. 16580cc67336Smrg dlname= 16590cc67336Smrg library_names= 16600cc67336Smrg func_source "$file" 1661301ea0f4Smrg 16620cc67336Smrg # Skip this library if it cannot be dlopened. 16630cc67336Smrg if test -z "$dlname"; then 16640cc67336Smrg # Warn if it was a shared library. 16650cc67336Smrg test -n "$library_names" && \ 16660cc67336Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 16670cc67336Smrg continue 16680cc67336Smrg fi 1669301ea0f4Smrg 16700cc67336Smrg func_dirname "$file" "" "." 16710cc67336Smrg dir="$func_dirname_result" 1672301ea0f4Smrg 16730cc67336Smrg if test -f "$dir/$objdir/$dlname"; then 16740cc67336Smrg dir="$dir/$objdir" 16750cc67336Smrg else 16760cc67336Smrg if test ! -f "$dir/$dlname"; then 16770cc67336Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 16780cc67336Smrg fi 16790cc67336Smrg fi 1680301ea0f4Smrg ;; 1681301ea0f4Smrg 16820cc67336Smrg *.lo) 16830cc67336Smrg # Just add the directory containing the .lo file. 16840cc67336Smrg func_dirname "$file" "" "." 16850cc67336Smrg dir="$func_dirname_result" 1686301ea0f4Smrg ;; 1687301ea0f4Smrg 16880cc67336Smrg *) 16890cc67336Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 1690301ea0f4Smrg continue 1691301ea0f4Smrg ;; 16920cc67336Smrg esac 1693301ea0f4Smrg 16940cc67336Smrg # Get the absolute pathname. 16950cc67336Smrg absdir=`cd "$dir" && pwd` 16960cc67336Smrg test -n "$absdir" && dir="$absdir" 1697301ea0f4Smrg 16980cc67336Smrg # Now add the directory to shlibpath_var. 16990cc67336Smrg if eval "test -z \"\$$shlibpath_var\""; then 17000cc67336Smrg eval "$shlibpath_var=\"\$dir\"" 17010cc67336Smrg else 17020cc67336Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 17030cc67336Smrg fi 17040cc67336Smrg done 1705301ea0f4Smrg 17060cc67336Smrg # This variable tells wrapper scripts just to set shlibpath_var 17070cc67336Smrg # rather than running their programs. 17080cc67336Smrg libtool_execute_magic="$magic" 1709301ea0f4Smrg 17100cc67336Smrg # Check if any of the arguments is a wrapper script. 17110cc67336Smrg args= 17120cc67336Smrg for file 17130cc67336Smrg do 17140cc67336Smrg case $file in 17150cc67336Smrg -*) ;; 17160cc67336Smrg *) 17170cc67336Smrg # Do a test to see if this is really a libtool program. 17180cc67336Smrg if func_ltwrapper_script_p "$file"; then 17190cc67336Smrg func_source "$file" 17200cc67336Smrg # Transform arg to wrapped name. 17210cc67336Smrg file="$progdir/$program" 17220cc67336Smrg elif func_ltwrapper_executable_p "$file"; then 17230cc67336Smrg func_ltwrapper_scriptname "$file" 17240cc67336Smrg func_source "$func_ltwrapper_scriptname_result" 17250cc67336Smrg # Transform arg to wrapped name. 17260cc67336Smrg file="$progdir/$program" 17270cc67336Smrg fi 17280cc67336Smrg ;; 17290cc67336Smrg esac 17300cc67336Smrg # Quote arguments (to preserve shell metacharacters). 17310cc67336Smrg func_quote_for_eval "$file" 17320cc67336Smrg args="$args $func_quote_for_eval_result" 17330cc67336Smrg done 1734301ea0f4Smrg 17350cc67336Smrg if test "X$opt_dry_run" = Xfalse; then 17360cc67336Smrg if test -n "$shlibpath_var"; then 17370cc67336Smrg # Export the shlibpath_var. 17380cc67336Smrg eval "export $shlibpath_var" 17390cc67336Smrg fi 1740301ea0f4Smrg 17410cc67336Smrg # Restore saved environment variables 17420cc67336Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 17430cc67336Smrg do 17440cc67336Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 17450cc67336Smrg $lt_var=\$save_$lt_var; export $lt_var 17460cc67336Smrg else 17470cc67336Smrg $lt_unset $lt_var 17480cc67336Smrg fi" 17490cc67336Smrg done 1750301ea0f4Smrg 17510cc67336Smrg # Now prepare to actually exec the command. 17520cc67336Smrg exec_cmd="\$cmd$args" 17530cc67336Smrg else 17540cc67336Smrg # Display what would be done. 17550cc67336Smrg if test -n "$shlibpath_var"; then 17560cc67336Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 17570cc67336Smrg $ECHO "export $shlibpath_var" 17580cc67336Smrg fi 17590cc67336Smrg $ECHO "$cmd$args" 17600cc67336Smrg exit $EXIT_SUCCESS 17610cc67336Smrg fi 17620cc67336Smrg} 1763301ea0f4Smrg 17640cc67336Smrgtest "$mode" = execute && func_mode_execute ${1+"$@"} 1765301ea0f4Smrg 1766301ea0f4Smrg 17670cc67336Smrg# func_mode_finish arg... 17680cc67336Smrgfunc_mode_finish () 17690cc67336Smrg{ 17700cc67336Smrg $opt_debug 17710cc67336Smrg libdirs="$nonopt" 17720cc67336Smrg admincmds= 1773301ea0f4Smrg 17740cc67336Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 17750cc67336Smrg for dir 17760cc67336Smrg do 17770cc67336Smrg libdirs="$libdirs $dir" 17780cc67336Smrg done 1779301ea0f4Smrg 17800cc67336Smrg for libdir in $libdirs; do 17810cc67336Smrg if test -n "$finish_cmds"; then 17820cc67336Smrg # Do each command in the finish commands. 17830cc67336Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 17840cc67336Smrg'"$cmd"'"' 17850cc67336Smrg fi 17860cc67336Smrg if test -n "$finish_eval"; then 17870cc67336Smrg # Do the single finish_eval. 17880cc67336Smrg eval cmds=\"$finish_eval\" 17890cc67336Smrg $opt_dry_run || eval "$cmds" || admincmds="$admincmds 17900cc67336Smrg $cmds" 17910cc67336Smrg fi 17920cc67336Smrg done 17930cc67336Smrg fi 1794301ea0f4Smrg 17950cc67336Smrg # Exit here if they wanted silent mode. 17960cc67336Smrg $opt_silent && exit $EXIT_SUCCESS 1797301ea0f4Smrg 17980cc67336Smrg $ECHO "X----------------------------------------------------------------------" | $Xsed 17990cc67336Smrg $ECHO "Libraries have been installed in:" 18000cc67336Smrg for libdir in $libdirs; do 18010cc67336Smrg $ECHO " $libdir" 18020cc67336Smrg done 18030cc67336Smrg $ECHO 18040cc67336Smrg $ECHO "If you ever happen to want to link against installed libraries" 18050cc67336Smrg $ECHO "in a given directory, LIBDIR, you must either use libtool, and" 18060cc67336Smrg $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'" 18070cc67336Smrg $ECHO "flag during linking and do at least one of the following:" 18080cc67336Smrg if test -n "$shlibpath_var"; then 18090cc67336Smrg $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable" 18100cc67336Smrg $ECHO " during execution" 18110cc67336Smrg fi 18120cc67336Smrg if test -n "$runpath_var"; then 18130cc67336Smrg $ECHO " - add LIBDIR to the \`$runpath_var' environment variable" 18140cc67336Smrg $ECHO " during linking" 18150cc67336Smrg fi 18160cc67336Smrg if test -n "$hardcode_libdir_flag_spec"; then 18170cc67336Smrg libdir=LIBDIR 18180cc67336Smrg eval flag=\"$hardcode_libdir_flag_spec\" 1819301ea0f4Smrg 18200cc67336Smrg $ECHO " - use the \`$flag' linker flag" 18210cc67336Smrg fi 18220cc67336Smrg if test -n "$admincmds"; then 18230cc67336Smrg $ECHO " - have your system administrator run these commands:$admincmds" 18240cc67336Smrg fi 18250cc67336Smrg if test -f /etc/ld.so.conf; then 18260cc67336Smrg $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 18270cc67336Smrg fi 18280cc67336Smrg $ECHO 1829301ea0f4Smrg 18300cc67336Smrg $ECHO "See any operating system documentation about shared libraries for" 18310cc67336Smrg case $host in 18320cc67336Smrg solaris2.[6789]|solaris2.1[0-9]) 18330cc67336Smrg $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual" 18340cc67336Smrg $ECHO "pages." 1835301ea0f4Smrg ;; 18360cc67336Smrg *) 18370cc67336Smrg $ECHO "more information, such as the ld(1) and ld.so(8) manual pages." 18380cc67336Smrg ;; 18390cc67336Smrg esac 18400cc67336Smrg $ECHO "X----------------------------------------------------------------------" | $Xsed 18410cc67336Smrg exit $EXIT_SUCCESS 18420cc67336Smrg} 1843301ea0f4Smrg 18440cc67336Smrgtest "$mode" = finish && func_mode_finish ${1+"$@"} 1845301ea0f4Smrg 1846301ea0f4Smrg 18470cc67336Smrg# func_mode_install arg... 18480cc67336Smrgfunc_mode_install () 18490cc67336Smrg{ 18500cc67336Smrg $opt_debug 18510cc67336Smrg # There may be an optional sh(1) argument at the beginning of 18520cc67336Smrg # install_prog (especially on Windows NT). 18530cc67336Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 18540cc67336Smrg # Allow the use of GNU shtool's install command. 18550cc67336Smrg $ECHO "X$nonopt" | $GREP shtool >/dev/null; then 18560cc67336Smrg # Aesthetically quote it. 18570cc67336Smrg func_quote_for_eval "$nonopt" 18580cc67336Smrg install_prog="$func_quote_for_eval_result " 18590cc67336Smrg arg=$1 18600cc67336Smrg shift 18610cc67336Smrg else 18620cc67336Smrg install_prog= 18630cc67336Smrg arg=$nonopt 18640cc67336Smrg fi 1865301ea0f4Smrg 18660cc67336Smrg # The real first argument should be the name of the installation program. 18670cc67336Smrg # Aesthetically quote it. 18680cc67336Smrg func_quote_for_eval "$arg" 18690cc67336Smrg install_prog="$install_prog$func_quote_for_eval_result" 18700cc67336Smrg 18710cc67336Smrg # We need to accept at least all the BSD install flags. 18720cc67336Smrg dest= 18730cc67336Smrg files= 18740cc67336Smrg opts= 18750cc67336Smrg prev= 18760cc67336Smrg install_type= 18770cc67336Smrg isdir=no 18780cc67336Smrg stripme= 18790cc67336Smrg for arg 18800cc67336Smrg do 18810cc67336Smrg if test -n "$dest"; then 18820cc67336Smrg files="$files $dest" 18830cc67336Smrg dest=$arg 18840cc67336Smrg continue 1885301ea0f4Smrg fi 1886301ea0f4Smrg 18870cc67336Smrg case $arg in 18880cc67336Smrg -d) isdir=yes ;; 18890cc67336Smrg -f) 18900cc67336Smrg case " $install_prog " in 18910cc67336Smrg *[\\\ /]cp\ *) ;; 18920cc67336Smrg *) prev=$arg ;; 18930cc67336Smrg esac 18940cc67336Smrg ;; 18950cc67336Smrg -g | -m | -o) 18960cc67336Smrg prev=$arg 18970cc67336Smrg ;; 18980cc67336Smrg -s) 18990cc67336Smrg stripme=" -s" 19000cc67336Smrg continue 19010cc67336Smrg ;; 19020cc67336Smrg -*) 19030cc67336Smrg ;; 19040cc67336Smrg *) 19050cc67336Smrg # If the previous option needed an argument, then skip it. 19060cc67336Smrg if test -n "$prev"; then 19070cc67336Smrg prev= 19080cc67336Smrg else 19090cc67336Smrg dest=$arg 19100cc67336Smrg continue 19110cc67336Smrg fi 19120cc67336Smrg ;; 19130cc67336Smrg esac 1914301ea0f4Smrg 19150cc67336Smrg # Aesthetically quote the argument. 19160cc67336Smrg func_quote_for_eval "$arg" 19170cc67336Smrg install_prog="$install_prog $func_quote_for_eval_result" 19180cc67336Smrg done 1919301ea0f4Smrg 19200cc67336Smrg test -z "$install_prog" && \ 19210cc67336Smrg func_fatal_help "you must specify an install program" 1922301ea0f4Smrg 19230cc67336Smrg test -n "$prev" && \ 19240cc67336Smrg func_fatal_help "the \`$prev' option requires an argument" 1925301ea0f4Smrg 19260cc67336Smrg if test -z "$files"; then 19270cc67336Smrg if test -z "$dest"; then 19280cc67336Smrg func_fatal_help "no file or destination specified" 19290cc67336Smrg else 19300cc67336Smrg func_fatal_help "you must specify a destination" 1931301ea0f4Smrg fi 1932301ea0f4Smrg fi 1933301ea0f4Smrg 19340cc67336Smrg # Strip any trailing slash from the destination. 19350cc67336Smrg func_stripname '' '/' "$dest" 19360cc67336Smrg dest=$func_stripname_result 1937301ea0f4Smrg 19380cc67336Smrg # Check to see that the destination is a directory. 19390cc67336Smrg test -d "$dest" && isdir=yes 19400cc67336Smrg if test "$isdir" = yes; then 19410cc67336Smrg destdir="$dest" 19420cc67336Smrg destname= 19430cc67336Smrg else 19440cc67336Smrg func_dirname_and_basename "$dest" "" "." 19450cc67336Smrg destdir="$func_dirname_result" 19460cc67336Smrg destname="$func_basename_result" 19470cc67336Smrg 19480cc67336Smrg # Not a directory, so check to see that there is only one file specified. 19490cc67336Smrg set dummy $files; shift 19500cc67336Smrg test "$#" -gt 1 && \ 19510cc67336Smrg func_fatal_help "\`$dest' is not a directory" 19520cc67336Smrg fi 19530cc67336Smrg case $destdir in 19540cc67336Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 1955301ea0f4Smrg *) 19560cc67336Smrg for file in $files; do 19570cc67336Smrg case $file in 19580cc67336Smrg *.lo) ;; 19590cc67336Smrg *) 19600cc67336Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 19610cc67336Smrg ;; 19620cc67336Smrg esac 19630cc67336Smrg done 1964301ea0f4Smrg ;; 1965301ea0f4Smrg esac 1966301ea0f4Smrg 19670cc67336Smrg # This variable tells wrapper scripts just to set variables rather 19680cc67336Smrg # than running their programs. 19690cc67336Smrg libtool_install_magic="$magic" 1970301ea0f4Smrg 19710cc67336Smrg staticlibs= 19720cc67336Smrg future_libdirs= 19730cc67336Smrg current_libdirs= 19740cc67336Smrg for file in $files; do 1975301ea0f4Smrg 19760cc67336Smrg # Do each installation. 19770cc67336Smrg case $file in 19780cc67336Smrg *.$libext) 19790cc67336Smrg # Do the static libraries later. 19800cc67336Smrg staticlibs="$staticlibs $file" 19810cc67336Smrg ;; 19820cc67336Smrg 19830cc67336Smrg *.la) 19840cc67336Smrg # Check to see that this really is a libtool archive. 19850cc67336Smrg func_lalib_unsafe_p "$file" \ 19860cc67336Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 19870cc67336Smrg 19880cc67336Smrg library_names= 19890cc67336Smrg old_library= 19900cc67336Smrg relink_command= 19910cc67336Smrg func_source "$file" 19920cc67336Smrg 19930cc67336Smrg # Add the libdir to current_libdirs if it is the destination. 19940cc67336Smrg if test "X$destdir" = "X$libdir"; then 19950cc67336Smrg case "$current_libdirs " in 19960cc67336Smrg *" $libdir "*) ;; 19970cc67336Smrg *) current_libdirs="$current_libdirs $libdir" ;; 1998301ea0f4Smrg esac 19990cc67336Smrg else 20000cc67336Smrg # Note the libdir as a future libdir. 20010cc67336Smrg case "$future_libdirs " in 20020cc67336Smrg *" $libdir "*) ;; 20030cc67336Smrg *) future_libdirs="$future_libdirs $libdir" ;; 20040cc67336Smrg esac 20050cc67336Smrg fi 2006301ea0f4Smrg 20070cc67336Smrg func_dirname "$file" "/" "" 20080cc67336Smrg dir="$func_dirname_result" 20090cc67336Smrg dir="$dir$objdir" 20100cc67336Smrg 20110cc67336Smrg if test -n "$relink_command"; then 20120cc67336Smrg # Determine the prefix the user has applied to our future dir. 20130cc67336Smrg inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"` 20140cc67336Smrg 20150cc67336Smrg # Don't allow the user to place us outside of our expected 20160cc67336Smrg # location b/c this prevents finding dependent libraries that 20170cc67336Smrg # are installed to the same prefix. 20180cc67336Smrg # At present, this check doesn't affect windows .dll's that 20190cc67336Smrg # are installed into $libdir/../bin (currently, that works fine) 20200cc67336Smrg # but it's something to keep an eye on. 20210cc67336Smrg test "$inst_prefix_dir" = "$destdir" && \ 20220cc67336Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 20230cc67336Smrg 20240cc67336Smrg if test -n "$inst_prefix_dir"; then 20250cc67336Smrg # Stick the inst_prefix_dir data into the link command. 20260cc67336Smrg relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 20270cc67336Smrg else 20280cc67336Smrg relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"` 20290cc67336Smrg fi 20300cc67336Smrg 20310cc67336Smrg func_warning "relinking \`$file'" 20320cc67336Smrg func_show_eval "$relink_command" \ 20330cc67336Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 20340cc67336Smrg fi 20350cc67336Smrg 20360cc67336Smrg # See the names of the shared library. 20370cc67336Smrg set dummy $library_names; shift 20380cc67336Smrg if test -n "$1"; then 20390cc67336Smrg realname="$1" 20400cc67336Smrg shift 20410cc67336Smrg 20420cc67336Smrg srcname="$realname" 20430cc67336Smrg test -n "$relink_command" && srcname="$realname"T 20440cc67336Smrg 20450cc67336Smrg # Install the shared library and build the symlinks. 20460cc67336Smrg func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \ 20470cc67336Smrg 'exit $?' 20480cc67336Smrg tstripme="$stripme" 20490cc67336Smrg case $host_os in 20500cc67336Smrg cygwin* | mingw* | pw32* | cegcc*) 20510cc67336Smrg case $realname in 20520cc67336Smrg *.dll.a) 20530cc67336Smrg tstripme="" 20540cc67336Smrg ;; 20550cc67336Smrg esac 2056301ea0f4Smrg ;; 2057301ea0f4Smrg esac 20580cc67336Smrg if test -n "$tstripme" && test -n "$striplib"; then 20590cc67336Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 2060301ea0f4Smrg fi 20610cc67336Smrg 20620cc67336Smrg if test "$#" -gt 0; then 20630cc67336Smrg # Delete the old symlinks, and create new ones. 20640cc67336Smrg # Try `ln -sf' first, because the `ln' binary might depend on 20650cc67336Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 20660cc67336Smrg # so we also need to try rm && ln -s. 20670cc67336Smrg for linkname 20680cc67336Smrg do 20690cc67336Smrg test "$linkname" != "$realname" \ 20700cc67336Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 2071301ea0f4Smrg done 2072301ea0f4Smrg fi 2073301ea0f4Smrg 20740cc67336Smrg # Do each command in the postinstall commands. 20750cc67336Smrg lib="$destdir/$realname" 20760cc67336Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 2077301ea0f4Smrg fi 2078301ea0f4Smrg 20790cc67336Smrg # Install the pseudo-library for information purposes. 20800cc67336Smrg func_basename "$file" 20810cc67336Smrg name="$func_basename_result" 20820cc67336Smrg instname="$dir/$name"i 20830cc67336Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 2084301ea0f4Smrg 20850cc67336Smrg # Maybe install the static library, too. 20860cc67336Smrg test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" 20870cc67336Smrg ;; 2088301ea0f4Smrg 20890cc67336Smrg *.lo) 20900cc67336Smrg # Install (i.e. copy) a libtool object. 2091301ea0f4Smrg 20920cc67336Smrg # Figure out destination file name, if it wasn't already specified. 20930cc67336Smrg if test -n "$destname"; then 20940cc67336Smrg destfile="$destdir/$destname" 20950cc67336Smrg else 20960cc67336Smrg func_basename "$file" 20970cc67336Smrg destfile="$func_basename_result" 20980cc67336Smrg destfile="$destdir/$destfile" 20990cc67336Smrg fi 21000cc67336Smrg 21010cc67336Smrg # Deduce the name of the destination old-style object file. 21020cc67336Smrg case $destfile in 21030cc67336Smrg *.lo) 21040cc67336Smrg func_lo2o "$destfile" 21050cc67336Smrg staticdest=$func_lo2o_result 21060cc67336Smrg ;; 21070cc67336Smrg *.$objext) 21080cc67336Smrg staticdest="$destfile" 21090cc67336Smrg destfile= 21100cc67336Smrg ;; 21110cc67336Smrg *) 21120cc67336Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 21130cc67336Smrg ;; 2114301ea0f4Smrg esac 2115301ea0f4Smrg 21160cc67336Smrg # Install the libtool object if requested. 21170cc67336Smrg test -n "$destfile" && \ 21180cc67336Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 21190cc67336Smrg 21200cc67336Smrg # Install the old object if enabled. 21210cc67336Smrg if test "$build_old_libs" = yes; then 21220cc67336Smrg # Deduce the name of the old-style object file. 21230cc67336Smrg func_lo2o "$file" 21240cc67336Smrg staticobj=$func_lo2o_result 21250cc67336Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 2126301ea0f4Smrg fi 21270cc67336Smrg exit $EXIT_SUCCESS 21280cc67336Smrg ;; 2129301ea0f4Smrg 21300cc67336Smrg *) 21310cc67336Smrg # Figure out destination file name, if it wasn't already specified. 21320cc67336Smrg if test -n "$destname"; then 21330cc67336Smrg destfile="$destdir/$destname" 21340cc67336Smrg else 21350cc67336Smrg func_basename "$file" 21360cc67336Smrg destfile="$func_basename_result" 21370cc67336Smrg destfile="$destdir/$destfile" 21380cc67336Smrg fi 21390cc67336Smrg 21400cc67336Smrg # If the file is missing, and there is a .exe on the end, strip it 21410cc67336Smrg # because it is most likely a libtool script we actually want to 21420cc67336Smrg # install 21430cc67336Smrg stripped_ext="" 21440cc67336Smrg case $file in 21450cc67336Smrg *.exe) 21460cc67336Smrg if test ! -f "$file"; then 21470cc67336Smrg func_stripname '' '.exe' "$file" 21480cc67336Smrg file=$func_stripname_result 21490cc67336Smrg stripped_ext=".exe" 2150301ea0f4Smrg fi 21510cc67336Smrg ;; 21520cc67336Smrg esac 2153301ea0f4Smrg 21540cc67336Smrg # Do a test to see if this is really a libtool program. 21550cc67336Smrg case $host in 21560cc67336Smrg *cygwin* | *mingw*) 21570cc67336Smrg if func_ltwrapper_executable_p "$file"; then 21580cc67336Smrg func_ltwrapper_scriptname "$file" 21590cc67336Smrg wrapper=$func_ltwrapper_scriptname_result 21600cc67336Smrg else 21610cc67336Smrg func_stripname '' '.exe' "$file" 21620cc67336Smrg wrapper=$func_stripname_result 21630cc67336Smrg fi 21640cc67336Smrg ;; 21650cc67336Smrg *) 21660cc67336Smrg wrapper=$file 21670cc67336Smrg ;; 21680cc67336Smrg esac 21690cc67336Smrg if func_ltwrapper_script_p "$wrapper"; then 21700cc67336Smrg notinst_deplibs= 21710cc67336Smrg relink_command= 2172301ea0f4Smrg 21730cc67336Smrg func_source "$wrapper" 2174301ea0f4Smrg 21750cc67336Smrg # Check the variables that should have been set. 21760cc67336Smrg test -z "$generated_by_libtool_version" && \ 21770cc67336Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 21780cc67336Smrg 21790cc67336Smrg finalize=yes 21800cc67336Smrg for lib in $notinst_deplibs; do 21810cc67336Smrg # Check to see that each library is installed. 21820cc67336Smrg libdir= 21830cc67336Smrg if test -f "$lib"; then 21840cc67336Smrg func_source "$lib" 21850cc67336Smrg fi 21860cc67336Smrg libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test 21870cc67336Smrg if test -n "$libdir" && test ! -f "$libfile"; then 21880cc67336Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 21890cc67336Smrg finalize=no 21900cc67336Smrg fi 21910cc67336Smrg done 21920cc67336Smrg 21930cc67336Smrg relink_command= 21940cc67336Smrg func_source "$wrapper" 21950cc67336Smrg 21960cc67336Smrg outputname= 21970cc67336Smrg if test "$fast_install" = no && test -n "$relink_command"; then 21980cc67336Smrg $opt_dry_run || { 21990cc67336Smrg if test "$finalize" = yes; then 22000cc67336Smrg tmpdir=`func_mktempdir` 22010cc67336Smrg func_basename "$file$stripped_ext" 22020cc67336Smrg file="$func_basename_result" 22030cc67336Smrg outputname="$tmpdir/$file" 22040cc67336Smrg # Replace the output file specification. 22050cc67336Smrg relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` 22060cc67336Smrg 22070cc67336Smrg $opt_silent || { 22080cc67336Smrg func_quote_for_expand "$relink_command" 22090cc67336Smrg eval "func_echo $func_quote_for_expand_result" 22100cc67336Smrg } 22110cc67336Smrg if eval "$relink_command"; then : 22120cc67336Smrg else 22130cc67336Smrg func_error "error: relink \`$file' with the above command before installing it" 22140cc67336Smrg $opt_dry_run || ${RM}r "$tmpdir" 22150cc67336Smrg continue 22160cc67336Smrg fi 22170cc67336Smrg file="$outputname" 22180cc67336Smrg else 22190cc67336Smrg func_warning "cannot relink \`$file'" 22200cc67336Smrg fi 22210cc67336Smrg } 2222301ea0f4Smrg else 22230cc67336Smrg # Install the binary that we compiled earlier. 22240cc67336Smrg file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` 2225301ea0f4Smrg fi 22260cc67336Smrg fi 2227301ea0f4Smrg 22280cc67336Smrg # remove .exe since cygwin /usr/bin/install will append another 22290cc67336Smrg # one anyway 22300cc67336Smrg case $install_prog,$host in 22310cc67336Smrg */usr/bin/install*,*cygwin*) 22320cc67336Smrg case $file:$destfile in 22330cc67336Smrg *.exe:*.exe) 22340cc67336Smrg # this is ok 22350cc67336Smrg ;; 22360cc67336Smrg *.exe:*) 22370cc67336Smrg destfile=$destfile.exe 22380cc67336Smrg ;; 22390cc67336Smrg *:*.exe) 22400cc67336Smrg func_stripname '' '.exe' "$destfile" 22410cc67336Smrg destfile=$func_stripname_result 22420cc67336Smrg ;; 22430cc67336Smrg esac 2244301ea0f4Smrg ;; 2245301ea0f4Smrg esac 22460cc67336Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 22470cc67336Smrg $opt_dry_run || if test -n "$outputname"; then 22480cc67336Smrg ${RM}r "$tmpdir" 22490cc67336Smrg fi 22500cc67336Smrg ;; 22510cc67336Smrg esac 22520cc67336Smrg done 2253301ea0f4Smrg 22540cc67336Smrg for file in $staticlibs; do 22550cc67336Smrg func_basename "$file" 22560cc67336Smrg name="$func_basename_result" 2257301ea0f4Smrg 22580cc67336Smrg # Set up the ranlib parameters. 22590cc67336Smrg oldlib="$destdir/$name" 2260301ea0f4Smrg 22610cc67336Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 2262301ea0f4Smrg 22630cc67336Smrg if test -n "$stripme" && test -n "$old_striplib"; then 22640cc67336Smrg func_show_eval "$old_striplib $oldlib" 'exit $?' 22650cc67336Smrg fi 2266301ea0f4Smrg 22670cc67336Smrg # Do each command in the postinstall commands. 22680cc67336Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 22690cc67336Smrg done 2270301ea0f4Smrg 22710cc67336Smrg test -n "$future_libdirs" && \ 22720cc67336Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 2273301ea0f4Smrg 22740cc67336Smrg if test -n "$current_libdirs"; then 22750cc67336Smrg # Maybe just do a dry run. 22760cc67336Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 22770cc67336Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 22780cc67336Smrg else 22790cc67336Smrg exit $EXIT_SUCCESS 22800cc67336Smrg fi 22810cc67336Smrg} 2282301ea0f4Smrg 22830cc67336Smrgtest "$mode" = install && func_mode_install ${1+"$@"} 2284301ea0f4Smrg 2285301ea0f4Smrg 22860cc67336Smrg# func_generate_dlsyms outputname originator pic_p 22870cc67336Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 22880cc67336Smrg# a dlpreopen symbol table. 22890cc67336Smrgfunc_generate_dlsyms () 22900cc67336Smrg{ 22910cc67336Smrg $opt_debug 22920cc67336Smrg my_outputname="$1" 22930cc67336Smrg my_originator="$2" 22940cc67336Smrg my_pic_p="${3-no}" 22950cc67336Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 22960cc67336Smrg my_dlsyms= 22970cc67336Smrg 22980cc67336Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 22990cc67336Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 23000cc67336Smrg my_dlsyms="${my_outputname}S.c" 23010cc67336Smrg else 23020cc67336Smrg func_error "not configured to extract global symbols from dlpreopened files" 23030cc67336Smrg fi 23040cc67336Smrg fi 2305301ea0f4Smrg 23060cc67336Smrg if test -n "$my_dlsyms"; then 23070cc67336Smrg case $my_dlsyms in 23080cc67336Smrg "") ;; 23090cc67336Smrg *.c) 23100cc67336Smrg # Discover the nlist of each of the dlfiles. 23110cc67336Smrg nlist="$output_objdir/${my_outputname}.nm" 23120cc67336Smrg 23130cc67336Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 23140cc67336Smrg 23150cc67336Smrg # Parse the name list into a source file. 23160cc67336Smrg func_verbose "creating $output_objdir/$my_dlsyms" 23170cc67336Smrg 23180cc67336Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 23190cc67336Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 23200cc67336Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 23210cc67336Smrg 23220cc67336Smrg#ifdef __cplusplus 23230cc67336Smrgextern \"C\" { 23240cc67336Smrg#endif 23250cc67336Smrg 23260cc67336Smrg/* External symbol declarations for the compiler. */\ 23270cc67336Smrg" 23280cc67336Smrg 23290cc67336Smrg if test "$dlself" = yes; then 23300cc67336Smrg func_verbose "generating symbol list for \`$output'" 23310cc67336Smrg 23320cc67336Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 23330cc67336Smrg 23340cc67336Smrg # Add our own program objects to the symbol list. 23350cc67336Smrg progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` 23360cc67336Smrg for progfile in $progfiles; do 23370cc67336Smrg func_verbose "extracting global C symbols from \`$progfile'" 23380cc67336Smrg $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" 23390cc67336Smrg done 23400cc67336Smrg 23410cc67336Smrg if test -n "$exclude_expsyms"; then 23420cc67336Smrg $opt_dry_run || { 23430cc67336Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 23440cc67336Smrg eval '$MV "$nlist"T "$nlist"' 23450cc67336Smrg } 2346301ea0f4Smrg fi 2347301ea0f4Smrg 23480cc67336Smrg if test -n "$export_symbols_regex"; then 23490cc67336Smrg $opt_dry_run || { 23500cc67336Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 23510cc67336Smrg eval '$MV "$nlist"T "$nlist"' 23520cc67336Smrg } 2353301ea0f4Smrg fi 23540cc67336Smrg 23550cc67336Smrg # Prepare the list of exported symbols 23560cc67336Smrg if test -z "$export_symbols"; then 23570cc67336Smrg export_symbols="$output_objdir/$outputname.exp" 23580cc67336Smrg $opt_dry_run || { 23590cc67336Smrg $RM $export_symbols 23600cc67336Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 23610cc67336Smrg case $host in 23620cc67336Smrg *cygwin* | *mingw* | *cegcc* ) 23630cc67336Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 23640cc67336Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 23650cc67336Smrg ;; 2366301ea0f4Smrg esac 23670cc67336Smrg } 23680cc67336Smrg else 23690cc67336Smrg $opt_dry_run || { 23700cc67336Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 23710cc67336Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 23720cc67336Smrg eval '$MV "$nlist"T "$nlist"' 23730cc67336Smrg case $host in 23740cc67336Smrg *cygwin | *mingw* | *cegcc* ) 23750cc67336Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 23760cc67336Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 23770cc67336Smrg ;; 2378301ea0f4Smrg esac 23790cc67336Smrg } 2380301ea0f4Smrg fi 23810cc67336Smrg fi 2382301ea0f4Smrg 23830cc67336Smrg for dlprefile in $dlprefiles; do 23840cc67336Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 23850cc67336Smrg func_basename "$dlprefile" 23860cc67336Smrg name="$func_basename_result" 23870cc67336Smrg $opt_dry_run || { 23880cc67336Smrg eval '$ECHO ": $name " >> "$nlist"' 23890cc67336Smrg eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" 23900cc67336Smrg } 23910cc67336Smrg done 2392301ea0f4Smrg 23930cc67336Smrg $opt_dry_run || { 23940cc67336Smrg # Make sure we have at least an empty file. 23950cc67336Smrg test -f "$nlist" || : > "$nlist" 2396301ea0f4Smrg 23970cc67336Smrg if test -n "$exclude_expsyms"; then 23980cc67336Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 23990cc67336Smrg $MV "$nlist"T "$nlist" 2400301ea0f4Smrg fi 2401301ea0f4Smrg 24020cc67336Smrg # Try sorting and uniquifying the output. 24030cc67336Smrg if $GREP -v "^: " < "$nlist" | 24040cc67336Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 24050cc67336Smrg sort -k 3 2406301ea0f4Smrg else 24070cc67336Smrg sort +2 24080cc67336Smrg fi | 24090cc67336Smrg uniq > "$nlist"S; then 24100cc67336Smrg : 2411301ea0f4Smrg else 24120cc67336Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 2413301ea0f4Smrg fi 2414301ea0f4Smrg 24150cc67336Smrg if test -f "$nlist"S; then 24160cc67336Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 2417301ea0f4Smrg else 24180cc67336Smrg $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms" 2419301ea0f4Smrg fi 2420301ea0f4Smrg 24210cc67336Smrg $ECHO >> "$output_objdir/$my_dlsyms" "\ 2422301ea0f4Smrg 24230cc67336Smrg/* The mapping between symbol names and symbols. */ 24240cc67336Smrgtypedef struct { 24250cc67336Smrg const char *name; 24260cc67336Smrg void *address; 24270cc67336Smrg} lt_dlsymlist; 24280cc67336Smrg" 24290cc67336Smrg case $host in 24300cc67336Smrg *cygwin* | *mingw* | *cegcc* ) 24310cc67336Smrg $ECHO >> "$output_objdir/$my_dlsyms" "\ 24320cc67336Smrg/* DATA imports from DLLs on WIN32 con't be const, because 24330cc67336Smrg runtime relocations are performed -- see ld's documentation 24340cc67336Smrg on pseudo-relocs. */" 24350cc67336Smrg lt_dlsym_const= ;; 24360cc67336Smrg *osf5*) 24370cc67336Smrg echo >> "$output_objdir/$my_dlsyms" "\ 24380cc67336Smrg/* This system does not cope well with relocations in const data */" 24390cc67336Smrg lt_dlsym_const= ;; 24400cc67336Smrg *) 24410cc67336Smrg lt_dlsym_const=const ;; 24420cc67336Smrg esac 24430cc67336Smrg 24440cc67336Smrg $ECHO >> "$output_objdir/$my_dlsyms" "\ 24450cc67336Smrgextern $lt_dlsym_const lt_dlsymlist 24460cc67336Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 24470cc67336Smrg$lt_dlsym_const lt_dlsymlist 24480cc67336Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 24490cc67336Smrg{\ 24500cc67336Smrg { \"$my_originator\", (void *) 0 }," 24510cc67336Smrg 24520cc67336Smrg case $need_lib_prefix in 24530cc67336Smrg no) 24540cc67336Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 24550cc67336Smrg ;; 24560cc67336Smrg *) 24570cc67336Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 24580cc67336Smrg ;; 24590cc67336Smrg esac 24600cc67336Smrg $ECHO >> "$output_objdir/$my_dlsyms" "\ 24610cc67336Smrg {0, (void *) 0} 24620cc67336Smrg}; 24630cc67336Smrg 24640cc67336Smrg/* This works around a problem in FreeBSD linker */ 24650cc67336Smrg#ifdef FREEBSD_WORKAROUND 24660cc67336Smrgstatic const void *lt_preloaded_setup() { 24670cc67336Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 24680cc67336Smrg} 24690cc67336Smrg#endif 24700cc67336Smrg 24710cc67336Smrg#ifdef __cplusplus 24720cc67336Smrg} 24730cc67336Smrg#endif\ 24740cc67336Smrg" 24750cc67336Smrg } # !$opt_dry_run 24760cc67336Smrg 24770cc67336Smrg pic_flag_for_symtable= 24780cc67336Smrg case "$compile_command " in 24790cc67336Smrg *" -static "*) ;; 24800cc67336Smrg *) 24810cc67336Smrg case $host in 24820cc67336Smrg # compiling the symbol table file with pic_flag works around 24830cc67336Smrg # a FreeBSD bug that causes programs to crash when -lm is 24840cc67336Smrg # linked before any other PIC object. But we must not use 24850cc67336Smrg # pic_flag when linking with -static. The problem exists in 24860cc67336Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 24870cc67336Smrg *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 24880cc67336Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 24890cc67336Smrg *-*-hpux*) 24900cc67336Smrg pic_flag_for_symtable=" $pic_flag" ;; 24910cc67336Smrg *) 24920cc67336Smrg if test "X$my_pic_p" != Xno; then 24930cc67336Smrg pic_flag_for_symtable=" $pic_flag" 2494301ea0f4Smrg fi 24950cc67336Smrg ;; 24960cc67336Smrg esac 24970cc67336Smrg ;; 24980cc67336Smrg esac 24990cc67336Smrg symtab_cflags= 25000cc67336Smrg for arg in $LTCFLAGS; do 25010cc67336Smrg case $arg in 25020cc67336Smrg -pie | -fpie | -fPIE) ;; 25030cc67336Smrg *) symtab_cflags="$symtab_cflags $arg" ;; 25040cc67336Smrg esac 25050cc67336Smrg done 2506301ea0f4Smrg 25070cc67336Smrg # Now compile the dynamic symbol file. 25080cc67336Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 2509301ea0f4Smrg 25100cc67336Smrg # Clean up the generated files. 25110cc67336Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 25120cc67336Smrg 25130cc67336Smrg # Transform the symbol file into the correct name. 25140cc67336Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 25150cc67336Smrg case $host in 25160cc67336Smrg *cygwin* | *mingw* | *cegcc* ) 25170cc67336Smrg if test -f "$output_objdir/$my_outputname.def"; then 25180cc67336Smrg compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 25190cc67336Smrg finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 25200cc67336Smrg else 25210cc67336Smrg compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` 25220cc67336Smrg finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` 25230cc67336Smrg fi 25240cc67336Smrg ;; 25250cc67336Smrg *) 25260cc67336Smrg compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` 25270cc67336Smrg finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` 2528301ea0f4Smrg ;; 2529301ea0f4Smrg esac 25300cc67336Smrg ;; 25310cc67336Smrg *) 25320cc67336Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 25330cc67336Smrg ;; 25340cc67336Smrg esac 25350cc67336Smrg else 25360cc67336Smrg # We keep going just in case the user didn't refer to 25370cc67336Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 25380cc67336Smrg # really was required. 25390cc67336Smrg 25400cc67336Smrg # Nullify the symbol file. 25410cc67336Smrg compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` 25420cc67336Smrg finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` 2543301ea0f4Smrg fi 25440cc67336Smrg} 2545301ea0f4Smrg 25460cc67336Smrg# func_win32_libid arg 25470cc67336Smrg# return the library type of file 'arg' 25480cc67336Smrg# 25490cc67336Smrg# Need a lot of goo to handle *both* DLLs and import libs 25500cc67336Smrg# Has to be a shell function in order to 'eat' the argument 25510cc67336Smrg# that is supplied when $file_magic_command is called. 25520cc67336Smrgfunc_win32_libid () 25530cc67336Smrg{ 25540cc67336Smrg $opt_debug 25550cc67336Smrg win32_libid_type="unknown" 25560cc67336Smrg win32_fileres=`file -L $1 2>/dev/null` 25570cc67336Smrg case $win32_fileres in 25580cc67336Smrg *ar\ archive\ import\ library*) # definitely import 25590cc67336Smrg win32_libid_type="x86 archive import" 25600cc67336Smrg ;; 25610cc67336Smrg *ar\ archive*) # could be an import, or static 25620cc67336Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 25630cc67336Smrg $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then 25640cc67336Smrg win32_nmres=`eval $NM -f posix -A $1 | 25650cc67336Smrg $SED -n -e ' 25660cc67336Smrg 1,100{ 25670cc67336Smrg / I /{ 25680cc67336Smrg s,.*,import, 25690cc67336Smrg p 25700cc67336Smrg q 25710cc67336Smrg } 25720cc67336Smrg }'` 25730cc67336Smrg case $win32_nmres in 25740cc67336Smrg import*) win32_libid_type="x86 archive import";; 25750cc67336Smrg *) win32_libid_type="x86 archive static";; 25760cc67336Smrg esac 25770cc67336Smrg fi 25780cc67336Smrg ;; 25790cc67336Smrg *DLL*) 25800cc67336Smrg win32_libid_type="x86 DLL" 25810cc67336Smrg ;; 25820cc67336Smrg *executable*) # but shell scripts are "executable" too... 25830cc67336Smrg case $win32_fileres in 25840cc67336Smrg *MS\ Windows\ PE\ Intel*) 25850cc67336Smrg win32_libid_type="x86 DLL" 25860cc67336Smrg ;; 25870cc67336Smrg esac 25880cc67336Smrg ;; 25890cc67336Smrg esac 25900cc67336Smrg $ECHO "$win32_libid_type" 25910cc67336Smrg} 2592301ea0f4Smrg 2593301ea0f4Smrg 2594301ea0f4Smrg 25950cc67336Smrg# func_extract_an_archive dir oldlib 25960cc67336Smrgfunc_extract_an_archive () 25970cc67336Smrg{ 25980cc67336Smrg $opt_debug 25990cc67336Smrg f_ex_an_ar_dir="$1"; shift 26000cc67336Smrg f_ex_an_ar_oldlib="$1" 26010cc67336Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?' 26020cc67336Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 26030cc67336Smrg : 26040cc67336Smrg else 26050cc67336Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 26060cc67336Smrg fi 26070cc67336Smrg} 2608301ea0f4Smrg 2609301ea0f4Smrg 26100cc67336Smrg# func_extract_archives gentop oldlib ... 26110cc67336Smrgfunc_extract_archives () 26120cc67336Smrg{ 26130cc67336Smrg $opt_debug 26140cc67336Smrg my_gentop="$1"; shift 26150cc67336Smrg my_oldlibs=${1+"$@"} 26160cc67336Smrg my_oldobjs="" 26170cc67336Smrg my_xlib="" 26180cc67336Smrg my_xabs="" 26190cc67336Smrg my_xdir="" 2620301ea0f4Smrg 26210cc67336Smrg for my_xlib in $my_oldlibs; do 26220cc67336Smrg # Extract the objects. 26230cc67336Smrg case $my_xlib in 26240cc67336Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 26250cc67336Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 26260cc67336Smrg esac 26270cc67336Smrg func_basename "$my_xlib" 26280cc67336Smrg my_xlib="$func_basename_result" 26290cc67336Smrg my_xlib_u=$my_xlib 26300cc67336Smrg while :; do 26310cc67336Smrg case " $extracted_archives " in 26320cc67336Smrg *" $my_xlib_u "*) 26330cc67336Smrg func_arith $extracted_serial + 1 26340cc67336Smrg extracted_serial=$func_arith_result 26350cc67336Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 26360cc67336Smrg *) break ;; 26370cc67336Smrg esac 26380cc67336Smrg done 26390cc67336Smrg extracted_archives="$extracted_archives $my_xlib_u" 26400cc67336Smrg my_xdir="$my_gentop/$my_xlib_u" 2641301ea0f4Smrg 26420cc67336Smrg func_mkdir_p "$my_xdir" 2643301ea0f4Smrg 26440cc67336Smrg case $host in 26450cc67336Smrg *-darwin*) 26460cc67336Smrg func_verbose "Extracting $my_xabs" 26470cc67336Smrg # Do not bother doing anything if just a dry run 26480cc67336Smrg $opt_dry_run || { 26490cc67336Smrg darwin_orig_dir=`pwd` 26500cc67336Smrg cd $my_xdir || exit $? 26510cc67336Smrg darwin_archive=$my_xabs 26520cc67336Smrg darwin_curdir=`pwd` 26530cc67336Smrg darwin_base_archive=`basename "$darwin_archive"` 26540cc67336Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 26550cc67336Smrg if test -n "$darwin_arches"; then 26560cc67336Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 26570cc67336Smrg darwin_arch= 26580cc67336Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 26590cc67336Smrg for darwin_arch in $darwin_arches ; do 26600cc67336Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 26610cc67336Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 26620cc67336Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 26630cc67336Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 26640cc67336Smrg cd "$darwin_curdir" 26650cc67336Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 26660cc67336Smrg done # $darwin_arches 26670cc67336Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 26680cc67336Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 26690cc67336Smrg darwin_file= 26700cc67336Smrg darwin_files= 26710cc67336Smrg for darwin_file in $darwin_filelist; do 26720cc67336Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` 26730cc67336Smrg $LIPO -create -output "$darwin_file" $darwin_files 26740cc67336Smrg done # $darwin_filelist 26750cc67336Smrg $RM -rf unfat-$$ 26760cc67336Smrg cd "$darwin_orig_dir" 26770cc67336Smrg else 26780cc67336Smrg cd $darwin_orig_dir 26790cc67336Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 26800cc67336Smrg fi # $darwin_arches 26810cc67336Smrg } # !$opt_dry_run 26820cc67336Smrg ;; 26830cc67336Smrg *) 26840cc67336Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 26850cc67336Smrg ;; 2686301ea0f4Smrg esac 26870cc67336Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` 26880cc67336Smrg done 2689301ea0f4Smrg 26900cc67336Smrg func_extract_archives_result="$my_oldobjs" 26910cc67336Smrg} 2692301ea0f4Smrg 2693301ea0f4Smrg 2694301ea0f4Smrg 26950cc67336Smrg# func_emit_wrapper_part1 [arg=no] 26960cc67336Smrg# 26970cc67336Smrg# Emit the first part of a libtool wrapper script on stdout. 26980cc67336Smrg# For more information, see the description associated with 26990cc67336Smrg# func_emit_wrapper(), below. 27000cc67336Smrgfunc_emit_wrapper_part1 () 27010cc67336Smrg{ 27020cc67336Smrg func_emit_wrapper_part1_arg1=no 27030cc67336Smrg if test -n "$1" ; then 27040cc67336Smrg func_emit_wrapper_part1_arg1=$1 2705301ea0f4Smrg fi 2706301ea0f4Smrg 27070cc67336Smrg $ECHO "\ 27080cc67336Smrg#! $SHELL 2709301ea0f4Smrg 27100cc67336Smrg# $output - temporary wrapper script for $objdir/$outputname 27110cc67336Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 27120cc67336Smrg# 27130cc67336Smrg# The $output program cannot be directly executed until all the libtool 27140cc67336Smrg# libraries that it depends on are installed. 27150cc67336Smrg# 27160cc67336Smrg# This wrapper script should never be moved out of the build directory. 27170cc67336Smrg# If it is, it will not operate correctly. 2718301ea0f4Smrg 27190cc67336Smrg# Sed substitution that helps us do robust quoting. It backslashifies 27200cc67336Smrg# metacharacters that are still active within double-quoted strings. 27210cc67336SmrgXsed='${SED} -e 1s/^X//' 27220cc67336Smrgsed_quote_subst='$sed_quote_subst' 2723301ea0f4Smrg 27240cc67336Smrg# Be Bourne compatible 27250cc67336Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 27260cc67336Smrg emulate sh 27270cc67336Smrg NULLCMD=: 27280cc67336Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 27290cc67336Smrg # is contrary to our usage. Disable this feature. 27300cc67336Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 27310cc67336Smrg setopt NO_GLOB_SUBST 27320cc67336Smrgelse 27330cc67336Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 27340cc67336Smrgfi 27350cc67336SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 27360cc67336SmrgDUALCASE=1; export DUALCASE # for MKS sh 2737301ea0f4Smrg 27380cc67336Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 27390cc67336Smrg# if CDPATH is set. 27400cc67336Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 2741301ea0f4Smrg 27420cc67336Smrgrelink_command=\"$relink_command\" 2743301ea0f4Smrg 27440cc67336Smrg# This environment variable determines our operation mode. 27450cc67336Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 27460cc67336Smrg # install mode needs the following variables: 27470cc67336Smrg generated_by_libtool_version='$macro_version' 27480cc67336Smrg notinst_deplibs='$notinst_deplibs' 27490cc67336Smrgelse 27500cc67336Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 27510cc67336Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 27520cc67336Smrg ECHO=\"$qecho\" 27530cc67336Smrg file=\"\$0\" 27540cc67336Smrg # Make sure echo works. 27550cc67336Smrg if test \"X\$1\" = X--no-reexec; then 27560cc67336Smrg # Discard the --no-reexec flag, and continue. 27570cc67336Smrg shift 27580cc67336Smrg elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then 27590cc67336Smrg # Yippee, \$ECHO works! 27600cc67336Smrg : 27610cc67336Smrg else 27620cc67336Smrg # Restart under the correct shell, and then maybe \$ECHO will work. 27630cc67336Smrg exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} 27640cc67336Smrg fi 27650cc67336Smrg fi\ 27660cc67336Smrg" 27670cc67336Smrg $ECHO "\ 2768301ea0f4Smrg 27690cc67336Smrg # Find the directory that this script lives in. 27700cc67336Smrg thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` 27710cc67336Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 2772301ea0f4Smrg 27730cc67336Smrg # Follow symbolic links until we get to the real thisdir. 27740cc67336Smrg file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` 27750cc67336Smrg while test -n \"\$file\"; do 27760cc67336Smrg destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` 2777301ea0f4Smrg 27780cc67336Smrg # If there was a directory component, then change thisdir. 27790cc67336Smrg if test \"x\$destdir\" != \"x\$file\"; then 27800cc67336Smrg case \"\$destdir\" in 27810cc67336Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 27820cc67336Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 27830cc67336Smrg esac 27840cc67336Smrg fi 2785301ea0f4Smrg 27860cc67336Smrg file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\` 27870cc67336Smrg file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` 27880cc67336Smrg done 27890cc67336Smrg" 27900cc67336Smrg} 27910cc67336Smrg# end: func_emit_wrapper_part1 2792301ea0f4Smrg 27930cc67336Smrg# func_emit_wrapper_part2 [arg=no] 27940cc67336Smrg# 27950cc67336Smrg# Emit the second part of a libtool wrapper script on stdout. 27960cc67336Smrg# For more information, see the description associated with 27970cc67336Smrg# func_emit_wrapper(), below. 27980cc67336Smrgfunc_emit_wrapper_part2 () 27990cc67336Smrg{ 28000cc67336Smrg func_emit_wrapper_part2_arg1=no 28010cc67336Smrg if test -n "$1" ; then 28020cc67336Smrg func_emit_wrapper_part2_arg1=$1 28030cc67336Smrg fi 2804301ea0f4Smrg 28050cc67336Smrg $ECHO "\ 2806301ea0f4Smrg 28070cc67336Smrg # Usually 'no', except on cygwin/mingw when embedded into 28080cc67336Smrg # the cwrapper. 28090cc67336Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1 28100cc67336Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 28110cc67336Smrg # special case for '.' 28120cc67336Smrg if test \"\$thisdir\" = \".\"; then 28130cc67336Smrg thisdir=\`pwd\` 28140cc67336Smrg fi 28150cc67336Smrg # remove .libs from thisdir 28160cc67336Smrg case \"\$thisdir\" in 28170cc67336Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;; 28180cc67336Smrg $objdir ) thisdir=. ;; 28190cc67336Smrg esac 28200cc67336Smrg fi 2821301ea0f4Smrg 28220cc67336Smrg # Try to get the absolute directory name. 28230cc67336Smrg absdir=\`cd \"\$thisdir\" && pwd\` 28240cc67336Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 28250cc67336Smrg" 2826301ea0f4Smrg 28270cc67336Smrg if test "$fast_install" = yes; then 28280cc67336Smrg $ECHO "\ 28290cc67336Smrg program=lt-'$outputname'$exeext 28300cc67336Smrg progdir=\"\$thisdir/$objdir\" 2831301ea0f4Smrg 28320cc67336Smrg if test ! -f \"\$progdir/\$program\" || 28330cc67336Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 28340cc67336Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 2835301ea0f4Smrg 28360cc67336Smrg file=\"\$\$-\$program\" 2837301ea0f4Smrg 28380cc67336Smrg if test ! -d \"\$progdir\"; then 28390cc67336Smrg $MKDIR \"\$progdir\" 28400cc67336Smrg else 28410cc67336Smrg $RM \"\$progdir/\$file\" 28420cc67336Smrg fi" 2843301ea0f4Smrg 28440cc67336Smrg $ECHO "\ 2845301ea0f4Smrg 28460cc67336Smrg # relink executable if necessary 28470cc67336Smrg if test -n \"\$relink_command\"; then 28480cc67336Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 28490cc67336Smrg else 28500cc67336Smrg $ECHO \"\$relink_command_output\" >&2 28510cc67336Smrg $RM \"\$progdir/\$file\" 28520cc67336Smrg exit 1 28530cc67336Smrg fi 28540cc67336Smrg fi 2855301ea0f4Smrg 28560cc67336Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 28570cc67336Smrg { $RM \"\$progdir/\$program\"; 28580cc67336Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 28590cc67336Smrg $RM \"\$progdir/\$file\" 28600cc67336Smrg fi" 28610cc67336Smrg else 28620cc67336Smrg $ECHO "\ 28630cc67336Smrg program='$outputname' 28640cc67336Smrg progdir=\"\$thisdir/$objdir\" 28650cc67336Smrg" 28660cc67336Smrg fi 2867301ea0f4Smrg 28680cc67336Smrg $ECHO "\ 2869301ea0f4Smrg 28700cc67336Smrg if test -f \"\$progdir/\$program\"; then" 2871301ea0f4Smrg 28720cc67336Smrg # Export our shlibpath_var if we have one. 28730cc67336Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 28740cc67336Smrg $ECHO "\ 28750cc67336Smrg # Add our own library path to $shlibpath_var 28760cc67336Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 2877301ea0f4Smrg 28780cc67336Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 28790cc67336Smrg # The second colon is a workaround for a bug in BeOS R4 sed 28800cc67336Smrg $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` 2881301ea0f4Smrg 28820cc67336Smrg export $shlibpath_var 28830cc67336Smrg" 2884301ea0f4Smrg fi 2885301ea0f4Smrg 28860cc67336Smrg # fixup the dll searchpath if we need to. 28870cc67336Smrg if test -n "$dllsearchpath"; then 28880cc67336Smrg $ECHO "\ 28890cc67336Smrg # Add the dll search path components to the executable PATH 28900cc67336Smrg PATH=$dllsearchpath:\$PATH 28910cc67336Smrg" 2892301ea0f4Smrg fi 2893301ea0f4Smrg 28940cc67336Smrg $ECHO "\ 28950cc67336Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 28960cc67336Smrg # Run the actual program with our arguments. 28970cc67336Smrg" 28980cc67336Smrg case $host in 28990cc67336Smrg # Backslashes separate directories on plain windows 29000cc67336Smrg *-*-mingw | *-*-os2* | *-cegcc*) 29010cc67336Smrg $ECHO "\ 29020cc67336Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 29030cc67336Smrg" 29040cc67336Smrg ;; 29050cc67336Smrg 29060cc67336Smrg *) 29070cc67336Smrg $ECHO "\ 29080cc67336Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 29090cc67336Smrg" 29100cc67336Smrg ;; 29110cc67336Smrg esac 29120cc67336Smrg $ECHO "\ 29130cc67336Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 29140cc67336Smrg exit 1 29150cc67336Smrg fi 29160cc67336Smrg else 29170cc67336Smrg # The program doesn't exist. 29180cc67336Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 29190cc67336Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 29200cc67336Smrg $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 29210cc67336Smrg exit 1 29220cc67336Smrg fi 29230cc67336Smrgfi\ 29240cc67336Smrg" 29250cc67336Smrg} 29260cc67336Smrg# end: func_emit_wrapper_part2 29270cc67336Smrg 29280cc67336Smrg 29290cc67336Smrg# func_emit_wrapper [arg=no] 29300cc67336Smrg# 29310cc67336Smrg# Emit a libtool wrapper script on stdout. 29320cc67336Smrg# Don't directly open a file because we may want to 29330cc67336Smrg# incorporate the script contents within a cygwin/mingw 29340cc67336Smrg# wrapper executable. Must ONLY be called from within 29350cc67336Smrg# func_mode_link because it depends on a number of variables 29360cc67336Smrg# set therein. 29370cc67336Smrg# 29380cc67336Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 29390cc67336Smrg# variable will take. If 'yes', then the emitted script 29400cc67336Smrg# will assume that the directory in which it is stored is 29410cc67336Smrg# the $objdir directory. This is a cygwin/mingw-specific 29420cc67336Smrg# behavior. 29430cc67336Smrgfunc_emit_wrapper () 29440cc67336Smrg{ 29450cc67336Smrg func_emit_wrapper_arg1=no 29460cc67336Smrg if test -n "$1" ; then 29470cc67336Smrg func_emit_wrapper_arg1=$1 2948301ea0f4Smrg fi 2949301ea0f4Smrg 29500cc67336Smrg # split this up so that func_emit_cwrapperexe_src 29510cc67336Smrg # can call each part independently. 29520cc67336Smrg func_emit_wrapper_part1 "${func_emit_wrapper_arg1}" 29530cc67336Smrg func_emit_wrapper_part2 "${func_emit_wrapper_arg1}" 29540cc67336Smrg} 2955301ea0f4Smrg 2956301ea0f4Smrg 29570cc67336Smrg# func_to_host_path arg 29580cc67336Smrg# 29590cc67336Smrg# Convert paths to host format when used with build tools. 29600cc67336Smrg# Intended for use with "native" mingw (where libtool itself 29610cc67336Smrg# is running under the msys shell), or in the following cross- 29620cc67336Smrg# build environments: 29630cc67336Smrg# $build $host 29640cc67336Smrg# mingw (msys) mingw [e.g. native] 29650cc67336Smrg# cygwin mingw 29660cc67336Smrg# *nix + wine mingw 29670cc67336Smrg# where wine is equipped with the `winepath' executable. 29680cc67336Smrg# In the native mingw case, the (msys) shell automatically 29690cc67336Smrg# converts paths for any non-msys applications it launches, 29700cc67336Smrg# but that facility isn't available from inside the cwrapper. 29710cc67336Smrg# Similar accommodations are necessary for $host mingw and 29720cc67336Smrg# $build cygwin. Calling this function does no harm for other 29730cc67336Smrg# $host/$build combinations not listed above. 29740cc67336Smrg# 29750cc67336Smrg# ARG is the path (on $build) that should be converted to 29760cc67336Smrg# the proper representation for $host. The result is stored 29770cc67336Smrg# in $func_to_host_path_result. 29780cc67336Smrgfunc_to_host_path () 29790cc67336Smrg{ 29800cc67336Smrg func_to_host_path_result="$1" 29810cc67336Smrg if test -n "$1" ; then 29820cc67336Smrg case $host in 29830cc67336Smrg *mingw* ) 29840cc67336Smrg lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 29850cc67336Smrg case $build in 29860cc67336Smrg *mingw* ) # actually, msys 29870cc67336Smrg # awkward: cmd appends spaces to result 29880cc67336Smrg lt_sed_strip_trailing_spaces="s/[ ]*\$//" 29890cc67336Smrg func_to_host_path_tmp1=`( cmd //c echo "$1" |\ 29900cc67336Smrg $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` 29910cc67336Smrg func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ 29920cc67336Smrg $SED -e "$lt_sed_naive_backslashify"` 29930cc67336Smrg ;; 29940cc67336Smrg *cygwin* ) 29950cc67336Smrg func_to_host_path_tmp1=`cygpath -w "$1"` 29960cc67336Smrg func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ 29970cc67336Smrg $SED -e "$lt_sed_naive_backslashify"` 29980cc67336Smrg ;; 29990cc67336Smrg * ) 30000cc67336Smrg # Unfortunately, winepath does not exit with a non-zero 30010cc67336Smrg # error code, so we are forced to check the contents of 30020cc67336Smrg # stdout. On the other hand, if the command is not 30030cc67336Smrg # found, the shell will set an exit code of 127 and print 30040cc67336Smrg # *an error message* to stdout. So we must check for both 30050cc67336Smrg # error code of zero AND non-empty stdout, which explains 30060cc67336Smrg # the odd construction: 30070cc67336Smrg func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` 30080cc67336Smrg if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then 30090cc67336Smrg func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ 30100cc67336Smrg $SED -e "$lt_sed_naive_backslashify"` 30110cc67336Smrg else 30120cc67336Smrg # Allow warning below. 30130cc67336Smrg func_to_host_path_result="" 30140cc67336Smrg fi 30150cc67336Smrg ;; 30160cc67336Smrg esac 30170cc67336Smrg if test -z "$func_to_host_path_result" ; then 30180cc67336Smrg func_error "Could not determine host path corresponding to" 30190cc67336Smrg func_error " '$1'" 30200cc67336Smrg func_error "Continuing, but uninstalled executables may not work." 30210cc67336Smrg # Fallback: 30220cc67336Smrg func_to_host_path_result="$1" 30230cc67336Smrg fi 30240cc67336Smrg ;; 30250cc67336Smrg esac 30260cc67336Smrg fi 30270cc67336Smrg} 30280cc67336Smrg# end: func_to_host_path 3029301ea0f4Smrg 30300cc67336Smrg# func_to_host_pathlist arg 30310cc67336Smrg# 30320cc67336Smrg# Convert pathlists to host format when used with build tools. 30330cc67336Smrg# See func_to_host_path(), above. This function supports the 30340cc67336Smrg# following $build/$host combinations (but does no harm for 30350cc67336Smrg# combinations not listed here): 30360cc67336Smrg# $build $host 30370cc67336Smrg# mingw (msys) mingw [e.g. native] 30380cc67336Smrg# cygwin mingw 30390cc67336Smrg# *nix + wine mingw 30400cc67336Smrg# 30410cc67336Smrg# Path separators are also converted from $build format to 30420cc67336Smrg# $host format. If ARG begins or ends with a path separator 30430cc67336Smrg# character, it is preserved (but converted to $host format) 30440cc67336Smrg# on output. 30450cc67336Smrg# 30460cc67336Smrg# ARG is a pathlist (on $build) that should be converted to 30470cc67336Smrg# the proper representation on $host. The result is stored 30480cc67336Smrg# in $func_to_host_pathlist_result. 30490cc67336Smrgfunc_to_host_pathlist () 30500cc67336Smrg{ 30510cc67336Smrg func_to_host_pathlist_result="$1" 30520cc67336Smrg if test -n "$1" ; then 30530cc67336Smrg case $host in 30540cc67336Smrg *mingw* ) 30550cc67336Smrg lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 30560cc67336Smrg # Remove leading and trailing path separator characters from 30570cc67336Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 30580cc67336Smrg # into '.;' and ';.', and winepath ignores them completely. 30590cc67336Smrg func_to_host_pathlist_tmp2="$1" 30600cc67336Smrg # Once set for this call, this variable should not be 30610cc67336Smrg # reassigned. It is used in tha fallback case. 30620cc67336Smrg func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\ 30630cc67336Smrg $SED -e 's|^:*||' -e 's|:*$||'` 30640cc67336Smrg case $build in 30650cc67336Smrg *mingw* ) # Actually, msys. 30660cc67336Smrg # Awkward: cmd appends spaces to result. 30670cc67336Smrg lt_sed_strip_trailing_spaces="s/[ ]*\$//" 30680cc67336Smrg func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\ 30690cc67336Smrg $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` 30700cc67336Smrg func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ 30710cc67336Smrg $SED -e "$lt_sed_naive_backslashify"` 30720cc67336Smrg ;; 30730cc67336Smrg *cygwin* ) 30740cc67336Smrg func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"` 30750cc67336Smrg func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ 30760cc67336Smrg $SED -e "$lt_sed_naive_backslashify"` 30770cc67336Smrg ;; 30780cc67336Smrg * ) 30790cc67336Smrg # unfortunately, winepath doesn't convert pathlists 30800cc67336Smrg func_to_host_pathlist_result="" 30810cc67336Smrg func_to_host_pathlist_oldIFS=$IFS 30820cc67336Smrg IFS=: 30830cc67336Smrg for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do 30840cc67336Smrg IFS=$func_to_host_pathlist_oldIFS 30850cc67336Smrg if test -n "$func_to_host_pathlist_f" ; then 30860cc67336Smrg func_to_host_path "$func_to_host_pathlist_f" 30870cc67336Smrg if test -n "$func_to_host_path_result" ; then 30880cc67336Smrg if test -z "$func_to_host_pathlist_result" ; then 30890cc67336Smrg func_to_host_pathlist_result="$func_to_host_path_result" 30900cc67336Smrg else 30910cc67336Smrg func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result" 30920cc67336Smrg fi 30930cc67336Smrg fi 30940cc67336Smrg fi 30950cc67336Smrg IFS=: 30960cc67336Smrg done 30970cc67336Smrg IFS=$func_to_host_pathlist_oldIFS 30980cc67336Smrg ;; 30990cc67336Smrg esac 31000cc67336Smrg if test -z "$func_to_host_pathlist_result" ; then 31010cc67336Smrg func_error "Could not determine the host path(s) corresponding to" 31020cc67336Smrg func_error " '$1'" 31030cc67336Smrg func_error "Continuing, but uninstalled executables may not work." 31040cc67336Smrg # Fallback. This may break if $1 contains DOS-style drive 31050cc67336Smrg # specifications. The fix is not to complicate the expression 31060cc67336Smrg # below, but for the user to provide a working wine installation 31070cc67336Smrg # with winepath so that path translation in the cross-to-mingw 31080cc67336Smrg # case works properly. 31090cc67336Smrg lt_replace_pathsep_nix_to_dos="s|:|;|g" 31100cc67336Smrg func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ 31110cc67336Smrg $SED -e "$lt_replace_pathsep_nix_to_dos"` 31120cc67336Smrg fi 31130cc67336Smrg # Now, add the leading and trailing path separators back 31140cc67336Smrg case "$1" in 31150cc67336Smrg :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" 31160cc67336Smrg ;; 31170cc67336Smrg esac 31180cc67336Smrg case "$1" in 31190cc67336Smrg *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;" 31200cc67336Smrg ;; 31210cc67336Smrg esac 31220cc67336Smrg ;; 31230cc67336Smrg esac 31240cc67336Smrg fi 31250cc67336Smrg} 31260cc67336Smrg# end: func_to_host_pathlist 3127301ea0f4Smrg 31280cc67336Smrg# func_emit_cwrapperexe_src 31290cc67336Smrg# emit the source code for a wrapper executable on stdout 31300cc67336Smrg# Must ONLY be called from within func_mode_link because 31310cc67336Smrg# it depends on a number of variable set therein. 31320cc67336Smrgfunc_emit_cwrapperexe_src () 31330cc67336Smrg{ 31340cc67336Smrg cat <<EOF 3135301ea0f4Smrg 31360cc67336Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 31370cc67336Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3138301ea0f4Smrg 31390cc67336Smrg The $output program cannot be directly executed until all the libtool 31400cc67336Smrg libraries that it depends on are installed. 3141301ea0f4Smrg 31420cc67336Smrg This wrapper executable should never be moved out of the build directory. 31430cc67336Smrg If it is, it will not operate correctly. 31440cc67336Smrg 31450cc67336Smrg Currently, it simply execs the wrapper *script* "$SHELL $output", 31460cc67336Smrg but could eventually absorb all of the scripts functionality and 31470cc67336Smrg exec $objdir/$outputname directly. 31480cc67336Smrg*/ 31490cc67336SmrgEOF 31500cc67336Smrg cat <<"EOF" 31510cc67336Smrg#include <stdio.h> 31520cc67336Smrg#include <stdlib.h> 31530cc67336Smrg#ifdef _MSC_VER 31540cc67336Smrg# include <direct.h> 31550cc67336Smrg# include <process.h> 31560cc67336Smrg# include <io.h> 31570cc67336Smrg# define setmode _setmode 31580cc67336Smrg#else 31590cc67336Smrg# include <unistd.h> 31600cc67336Smrg# include <stdint.h> 31610cc67336Smrg# ifdef __CYGWIN__ 31620cc67336Smrg# include <io.h> 31630cc67336Smrg# define HAVE_SETENV 31640cc67336Smrg# ifdef __STRICT_ANSI__ 31650cc67336Smrgchar *realpath (const char *, char *); 31660cc67336Smrgint putenv (char *); 31670cc67336Smrgint setenv (const char *, const char *, int); 31680cc67336Smrg# endif 31690cc67336Smrg# endif 31700cc67336Smrg#endif 31710cc67336Smrg#include <malloc.h> 31720cc67336Smrg#include <stdarg.h> 31730cc67336Smrg#include <assert.h> 31740cc67336Smrg#include <string.h> 31750cc67336Smrg#include <ctype.h> 31760cc67336Smrg#include <errno.h> 31770cc67336Smrg#include <fcntl.h> 31780cc67336Smrg#include <sys/stat.h> 31790cc67336Smrg 31800cc67336Smrg#if defined(PATH_MAX) 31810cc67336Smrg# define LT_PATHMAX PATH_MAX 31820cc67336Smrg#elif defined(MAXPATHLEN) 31830cc67336Smrg# define LT_PATHMAX MAXPATHLEN 31840cc67336Smrg#else 31850cc67336Smrg# define LT_PATHMAX 1024 31860cc67336Smrg#endif 31870cc67336Smrg 31880cc67336Smrg#ifndef S_IXOTH 31890cc67336Smrg# define S_IXOTH 0 31900cc67336Smrg#endif 31910cc67336Smrg#ifndef S_IXGRP 31920cc67336Smrg# define S_IXGRP 0 31930cc67336Smrg#endif 31940cc67336Smrg 31950cc67336Smrg#ifdef _MSC_VER 31960cc67336Smrg# define S_IXUSR _S_IEXEC 31970cc67336Smrg# define stat _stat 31980cc67336Smrg# ifndef _INTPTR_T_DEFINED 31990cc67336Smrg# define intptr_t int 32000cc67336Smrg# endif 32010cc67336Smrg#endif 32020cc67336Smrg 32030cc67336Smrg#ifndef DIR_SEPARATOR 32040cc67336Smrg# define DIR_SEPARATOR '/' 32050cc67336Smrg# define PATH_SEPARATOR ':' 32060cc67336Smrg#endif 32070cc67336Smrg 32080cc67336Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 32090cc67336Smrg defined (__OS2__) 32100cc67336Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 32110cc67336Smrg# define FOPEN_WB "wb" 32120cc67336Smrg# ifndef DIR_SEPARATOR_2 32130cc67336Smrg# define DIR_SEPARATOR_2 '\\' 32140cc67336Smrg# endif 32150cc67336Smrg# ifndef PATH_SEPARATOR_2 32160cc67336Smrg# define PATH_SEPARATOR_2 ';' 32170cc67336Smrg# endif 32180cc67336Smrg#endif 32190cc67336Smrg 32200cc67336Smrg#ifndef DIR_SEPARATOR_2 32210cc67336Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 32220cc67336Smrg#else /* DIR_SEPARATOR_2 */ 32230cc67336Smrg# define IS_DIR_SEPARATOR(ch) \ 32240cc67336Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 32250cc67336Smrg#endif /* DIR_SEPARATOR_2 */ 32260cc67336Smrg 32270cc67336Smrg#ifndef PATH_SEPARATOR_2 32280cc67336Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 32290cc67336Smrg#else /* PATH_SEPARATOR_2 */ 32300cc67336Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 32310cc67336Smrg#endif /* PATH_SEPARATOR_2 */ 32320cc67336Smrg 32330cc67336Smrg#ifdef __CYGWIN__ 32340cc67336Smrg# define FOPEN_WB "wb" 32350cc67336Smrg#endif 32360cc67336Smrg 32370cc67336Smrg#ifndef FOPEN_WB 32380cc67336Smrg# define FOPEN_WB "w" 32390cc67336Smrg#endif 32400cc67336Smrg#ifndef _O_BINARY 32410cc67336Smrg# define _O_BINARY 0 32420cc67336Smrg#endif 32430cc67336Smrg 32440cc67336Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 32450cc67336Smrg#define XFREE(stale) do { \ 32460cc67336Smrg if (stale) { free ((void *) stale); stale = 0; } \ 32470cc67336Smrg} while (0) 32480cc67336Smrg 32490cc67336Smrg#undef LTWRAPPER_DEBUGPRINTF 32500cc67336Smrg#if defined DEBUGWRAPPER 32510cc67336Smrg# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args 32520cc67336Smrgstatic void 32530cc67336Smrgltwrapper_debugprintf (const char *fmt, ...) 32540cc67336Smrg{ 32550cc67336Smrg va_list args; 32560cc67336Smrg va_start (args, fmt); 32570cc67336Smrg (void) vfprintf (stderr, fmt, args); 32580cc67336Smrg va_end (args); 32590cc67336Smrg} 32600cc67336Smrg#else 32610cc67336Smrg# define LTWRAPPER_DEBUGPRINTF(args) 32620cc67336Smrg#endif 32630cc67336Smrg 32640cc67336Smrgconst char *program_name = NULL; 32650cc67336Smrg 32660cc67336Smrgvoid *xmalloc (size_t num); 32670cc67336Smrgchar *xstrdup (const char *string); 32680cc67336Smrgconst char *base_name (const char *name); 32690cc67336Smrgchar *find_executable (const char *wrapper); 32700cc67336Smrgchar *chase_symlinks (const char *pathspec); 32710cc67336Smrgint make_executable (const char *path); 32720cc67336Smrgint check_executable (const char *path); 32730cc67336Smrgchar *strendzap (char *str, const char *pat); 32740cc67336Smrgvoid lt_fatal (const char *message, ...); 32750cc67336Smrgvoid lt_setenv (const char *name, const char *value); 32760cc67336Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 32770cc67336Smrgvoid lt_opt_process_env_set (const char *arg); 32780cc67336Smrgvoid lt_opt_process_env_prepend (const char *arg); 32790cc67336Smrgvoid lt_opt_process_env_append (const char *arg); 32800cc67336Smrgint lt_split_name_value (const char *arg, char** name, char** value); 32810cc67336Smrgvoid lt_update_exe_path (const char *name, const char *value); 32820cc67336Smrgvoid lt_update_lib_path (const char *name, const char *value); 32830cc67336Smrg 32840cc67336Smrgstatic const char *script_text_part1 = 32850cc67336SmrgEOF 32860cc67336Smrg 32870cc67336Smrg func_emit_wrapper_part1 yes | 32880cc67336Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 32890cc67336Smrg -e 's/^/ "/' -e 's/$/\\n"/' 32900cc67336Smrg echo ";" 32910cc67336Smrg cat <<EOF 32920cc67336Smrg 32930cc67336Smrgstatic const char *script_text_part2 = 32940cc67336SmrgEOF 32950cc67336Smrg func_emit_wrapper_part2 yes | 32960cc67336Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 32970cc67336Smrg -e 's/^/ "/' -e 's/$/\\n"/' 32980cc67336Smrg echo ";" 32990cc67336Smrg 33000cc67336Smrg cat <<EOF 33010cc67336Smrgconst char * MAGIC_EXE = "$magic_exe"; 33020cc67336Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 33030cc67336SmrgEOF 33040cc67336Smrg 33050cc67336Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 33060cc67336Smrg func_to_host_pathlist "$temp_rpath" 33070cc67336Smrg cat <<EOF 33080cc67336Smrgconst char * LIB_PATH_VALUE = "$func_to_host_pathlist_result"; 3309301ea0f4SmrgEOF 3310301ea0f4Smrg else 33110cc67336Smrg cat <<"EOF" 33120cc67336Smrgconst char * LIB_PATH_VALUE = ""; 33130cc67336SmrgEOF 3314301ea0f4Smrg fi 33150cc67336Smrg 33160cc67336Smrg if test -n "$dllsearchpath"; then 33170cc67336Smrg func_to_host_pathlist "$dllsearchpath:" 33180cc67336Smrg cat <<EOF 33190cc67336Smrgconst char * EXE_PATH_VARNAME = "PATH"; 33200cc67336Smrgconst char * EXE_PATH_VALUE = "$func_to_host_pathlist_result"; 33210cc67336SmrgEOF 3322301ea0f4Smrg else 33230cc67336Smrg cat <<"EOF" 33240cc67336Smrgconst char * EXE_PATH_VARNAME = ""; 33250cc67336Smrgconst char * EXE_PATH_VALUE = ""; 33260cc67336SmrgEOF 3327301ea0f4Smrg fi 33280cc67336Smrg 33290cc67336Smrg if test "$fast_install" = yes; then 33300cc67336Smrg cat <<EOF 33310cc67336Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 33320cc67336SmrgEOF 3333301ea0f4Smrg else 33340cc67336Smrg cat <<EOF 33350cc67336Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 33360cc67336SmrgEOF 3337301ea0f4Smrg fi 3338301ea0f4Smrg 3339301ea0f4Smrg 33400cc67336Smrg cat <<"EOF" 3341301ea0f4Smrg 33420cc67336Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 33430cc67336Smrg#define LTWRAPPER_OPTION_PREFIX_LENGTH 5 3344301ea0f4Smrg 33450cc67336Smrgstatic const size_t opt_prefix_len = LTWRAPPER_OPTION_PREFIX_LENGTH; 33460cc67336Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 3347301ea0f4Smrg 33480cc67336Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 3349301ea0f4Smrg 33500cc67336Smrgstatic const size_t env_set_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 7; 33510cc67336Smrgstatic const char *env_set_opt = LTWRAPPER_OPTION_PREFIX "env-set"; 33520cc67336Smrg /* argument is putenv-style "foo=bar", value of foo is set to bar */ 3353301ea0f4Smrg 33540cc67336Smrgstatic const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11; 33550cc67336Smrgstatic const char *env_prepend_opt = LTWRAPPER_OPTION_PREFIX "env-prepend"; 33560cc67336Smrg /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */ 3357301ea0f4Smrg 33580cc67336Smrgstatic const size_t env_append_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 10; 33590cc67336Smrgstatic const char *env_append_opt = LTWRAPPER_OPTION_PREFIX "env-append"; 33600cc67336Smrg /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */ 3361301ea0f4Smrg 33620cc67336Smrgint 33630cc67336Smrgmain (int argc, char *argv[]) 33640cc67336Smrg{ 33650cc67336Smrg char **newargz; 33660cc67336Smrg int newargc; 33670cc67336Smrg char *tmp_pathspec; 33680cc67336Smrg char *actual_cwrapper_path; 33690cc67336Smrg char *actual_cwrapper_name; 33700cc67336Smrg char *target_name; 33710cc67336Smrg char *lt_argv_zero; 33720cc67336Smrg intptr_t rval = 127; 3373301ea0f4Smrg 33740cc67336Smrg int i; 3375301ea0f4Smrg 33760cc67336Smrg program_name = (char *) xstrdup (base_name (argv[0])); 33770cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(main) argv[0] : %s\n", argv[0])); 33780cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name)); 3379301ea0f4Smrg 33800cc67336Smrg /* very simple arg parsing; don't want to rely on getopt */ 33810cc67336Smrg for (i = 1; i < argc; i++) 33820cc67336Smrg { 33830cc67336Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 33840cc67336Smrg { 33850cc67336SmrgEOF 33860cc67336Smrg case "$host" in 33870cc67336Smrg *mingw* | *cygwin* ) 33880cc67336Smrg # make stdout use "unix" line endings 33890cc67336Smrg echo " setmode(1,_O_BINARY);" 33900cc67336Smrg ;; 33910cc67336Smrg esac 3392301ea0f4Smrg 33930cc67336Smrg cat <<"EOF" 33940cc67336Smrg printf ("%s", script_text_part1); 33950cc67336Smrg printf ("%s", script_text_part2); 33960cc67336Smrg return 0; 33970cc67336Smrg } 33980cc67336Smrg } 3399301ea0f4Smrg 34000cc67336Smrg newargz = XMALLOC (char *, argc + 1); 34010cc67336Smrg tmp_pathspec = find_executable (argv[0]); 34020cc67336Smrg if (tmp_pathspec == NULL) 34030cc67336Smrg lt_fatal ("Couldn't find %s", argv[0]); 34040cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n", 34050cc67336Smrg tmp_pathspec)); 34060cc67336Smrg 34070cc67336Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 34080cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n", 34090cc67336Smrg actual_cwrapper_path)); 34100cc67336Smrg XFREE (tmp_pathspec); 34110cc67336Smrg 34120cc67336Smrg actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path)); 34130cc67336Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 34140cc67336Smrg 34150cc67336Smrg /* wrapper name transforms */ 34160cc67336Smrg strendzap (actual_cwrapper_name, ".exe"); 34170cc67336Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 34180cc67336Smrg XFREE (actual_cwrapper_name); 34190cc67336Smrg actual_cwrapper_name = tmp_pathspec; 34200cc67336Smrg tmp_pathspec = 0; 34210cc67336Smrg 34220cc67336Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 34230cc67336Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 34240cc67336Smrg strendzap (target_name, ".exe"); 34250cc67336Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 34260cc67336Smrg XFREE (target_name); 34270cc67336Smrg target_name = tmp_pathspec; 34280cc67336Smrg tmp_pathspec = 0; 34290cc67336Smrg 34300cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n", 34310cc67336Smrg target_name)); 34320cc67336SmrgEOF 3433301ea0f4Smrg 34340cc67336Smrg cat <<EOF 34350cc67336Smrg newargz[0] = 34360cc67336Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 34370cc67336Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 34380cc67336Smrg strcpy (newargz[0], actual_cwrapper_path); 34390cc67336Smrg strcat (newargz[0], "$objdir"); 34400cc67336Smrg strcat (newargz[0], "/"); 34410cc67336SmrgEOF 3442301ea0f4Smrg 34430cc67336Smrg cat <<"EOF" 34440cc67336Smrg /* stop here, and copy so we don't have to do this twice */ 34450cc67336Smrg tmp_pathspec = xstrdup (newargz[0]); 3446301ea0f4Smrg 34470cc67336Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 34480cc67336Smrg strcat (newargz[0], actual_cwrapper_name); 3449301ea0f4Smrg 34500cc67336Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 34510cc67336Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 34520cc67336Smrg XFREE (tmp_pathspec); 34530cc67336Smrg tmp_pathspec = NULL; 34540cc67336SmrgEOF 3455301ea0f4Smrg 34560cc67336Smrg case $host_os in 34570cc67336Smrg mingw*) 34580cc67336Smrg cat <<"EOF" 34590cc67336Smrg { 34600cc67336Smrg char* p; 34610cc67336Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 34620cc67336Smrg { 34630cc67336Smrg *p = '/'; 34640cc67336Smrg } 34650cc67336Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 34660cc67336Smrg { 34670cc67336Smrg *p = '/'; 34680cc67336Smrg } 34690cc67336Smrg } 34700cc67336SmrgEOF 34710cc67336Smrg ;; 34720cc67336Smrg esac 3473301ea0f4Smrg 34740cc67336Smrg cat <<"EOF" 34750cc67336Smrg XFREE (target_name); 34760cc67336Smrg XFREE (actual_cwrapper_path); 34770cc67336Smrg XFREE (actual_cwrapper_name); 3478301ea0f4Smrg 34790cc67336Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 34800cc67336Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 34810cc67336Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 34820cc67336Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 3483301ea0f4Smrg 34840cc67336Smrg newargc=0; 34850cc67336Smrg for (i = 1; i < argc; i++) 34860cc67336Smrg { 34870cc67336Smrg if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0) 34880cc67336Smrg { 34890cc67336Smrg if (argv[i][env_set_opt_len] == '=') 34900cc67336Smrg { 34910cc67336Smrg const char *p = argv[i] + env_set_opt_len + 1; 34920cc67336Smrg lt_opt_process_env_set (p); 34930cc67336Smrg } 34940cc67336Smrg else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc) 34950cc67336Smrg { 34960cc67336Smrg lt_opt_process_env_set (argv[++i]); /* don't copy */ 34970cc67336Smrg } 34980cc67336Smrg else 34990cc67336Smrg lt_fatal ("%s missing required argument", env_set_opt); 35000cc67336Smrg continue; 35010cc67336Smrg } 35020cc67336Smrg if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0) 35030cc67336Smrg { 35040cc67336Smrg if (argv[i][env_prepend_opt_len] == '=') 35050cc67336Smrg { 35060cc67336Smrg const char *p = argv[i] + env_prepend_opt_len + 1; 35070cc67336Smrg lt_opt_process_env_prepend (p); 35080cc67336Smrg } 35090cc67336Smrg else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc) 35100cc67336Smrg { 35110cc67336Smrg lt_opt_process_env_prepend (argv[++i]); /* don't copy */ 35120cc67336Smrg } 35130cc67336Smrg else 35140cc67336Smrg lt_fatal ("%s missing required argument", env_prepend_opt); 35150cc67336Smrg continue; 35160cc67336Smrg } 35170cc67336Smrg if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0) 35180cc67336Smrg { 35190cc67336Smrg if (argv[i][env_append_opt_len] == '=') 35200cc67336Smrg { 35210cc67336Smrg const char *p = argv[i] + env_append_opt_len + 1; 35220cc67336Smrg lt_opt_process_env_append (p); 35230cc67336Smrg } 35240cc67336Smrg else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc) 35250cc67336Smrg { 35260cc67336Smrg lt_opt_process_env_append (argv[++i]); /* don't copy */ 35270cc67336Smrg } 35280cc67336Smrg else 35290cc67336Smrg lt_fatal ("%s missing required argument", env_append_opt); 35300cc67336Smrg continue; 35310cc67336Smrg } 35320cc67336Smrg if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0) 35330cc67336Smrg { 35340cc67336Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 35350cc67336Smrg namespace, but it is not one of the ones we know about and 35360cc67336Smrg have already dealt with, above (inluding dump-script), then 35370cc67336Smrg report an error. Otherwise, targets might begin to believe 35380cc67336Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 35390cc67336Smrg namespace. The first time any user complains about this, we'll 35400cc67336Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 35410cc67336Smrg or a configure.ac-settable value. 35420cc67336Smrg */ 35430cc67336Smrg lt_fatal ("Unrecognized option in %s namespace: '%s'", 35440cc67336Smrg ltwrapper_option_prefix, argv[i]); 35450cc67336Smrg } 35460cc67336Smrg /* otherwise ... */ 35470cc67336Smrg newargz[++newargc] = xstrdup (argv[i]); 35480cc67336Smrg } 35490cc67336Smrg newargz[++newargc] = NULL; 3550301ea0f4Smrg 35510cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>"))); 35520cc67336Smrg for (i = 0; i < newargc; i++) 35530cc67336Smrg { 35540cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>"))); 35550cc67336Smrg } 3556301ea0f4Smrg 35570cc67336SmrgEOF 3558301ea0f4Smrg 35590cc67336Smrg case $host_os in 35600cc67336Smrg mingw*) 35610cc67336Smrg cat <<"EOF" 35620cc67336Smrg /* execv doesn't actually work on mingw as expected on unix */ 35630cc67336Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 35640cc67336Smrg if (rval == -1) 35650cc67336Smrg { 35660cc67336Smrg /* failed to start process */ 35670cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno)); 35680cc67336Smrg return 127; 35690cc67336Smrg } 35700cc67336Smrg return rval; 35710cc67336SmrgEOF 35720cc67336Smrg ;; 35730cc67336Smrg *) 35740cc67336Smrg cat <<"EOF" 35750cc67336Smrg execv (lt_argv_zero, newargz); 35760cc67336Smrg return rval; /* =127, but avoids unused variable warning */ 35770cc67336SmrgEOF 35780cc67336Smrg ;; 35790cc67336Smrg esac 3580301ea0f4Smrg 35810cc67336Smrg cat <<"EOF" 35820cc67336Smrg} 3583301ea0f4Smrg 35840cc67336Smrgvoid * 35850cc67336Smrgxmalloc (size_t num) 35860cc67336Smrg{ 35870cc67336Smrg void *p = (void *) malloc (num); 35880cc67336Smrg if (!p) 35890cc67336Smrg lt_fatal ("Memory exhausted"); 3590301ea0f4Smrg 35910cc67336Smrg return p; 35920cc67336Smrg} 3593301ea0f4Smrg 35940cc67336Smrgchar * 35950cc67336Smrgxstrdup (const char *string) 35960cc67336Smrg{ 35970cc67336Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 35980cc67336Smrg string) : NULL; 35990cc67336Smrg} 3600301ea0f4Smrg 36010cc67336Smrgconst char * 36020cc67336Smrgbase_name (const char *name) 36030cc67336Smrg{ 36040cc67336Smrg const char *base; 3605301ea0f4Smrg 36060cc67336Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 36070cc67336Smrg /* Skip over the disk name in MSDOS pathnames. */ 36080cc67336Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 36090cc67336Smrg name += 2; 36100cc67336Smrg#endif 3611301ea0f4Smrg 36120cc67336Smrg for (base = name; *name; name++) 36130cc67336Smrg if (IS_DIR_SEPARATOR (*name)) 36140cc67336Smrg base = name + 1; 36150cc67336Smrg return base; 36160cc67336Smrg} 3617301ea0f4Smrg 36180cc67336Smrgint 36190cc67336Smrgcheck_executable (const char *path) 36200cc67336Smrg{ 36210cc67336Smrg struct stat st; 3622301ea0f4Smrg 36230cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n", 36240cc67336Smrg path ? (*path ? path : "EMPTY!") : "NULL!")); 36250cc67336Smrg if ((!path) || (!*path)) 36260cc67336Smrg return 0; 3627301ea0f4Smrg 36280cc67336Smrg if ((stat (path, &st) >= 0) 36290cc67336Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 36300cc67336Smrg return 1; 36310cc67336Smrg else 36320cc67336Smrg return 0; 36330cc67336Smrg} 3634301ea0f4Smrg 36350cc67336Smrgint 36360cc67336Smrgmake_executable (const char *path) 36370cc67336Smrg{ 36380cc67336Smrg int rval = 0; 36390cc67336Smrg struct stat st; 3640301ea0f4Smrg 36410cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n", 36420cc67336Smrg path ? (*path ? path : "EMPTY!") : "NULL!")); 36430cc67336Smrg if ((!path) || (!*path)) 36440cc67336Smrg return 0; 3645301ea0f4Smrg 36460cc67336Smrg if (stat (path, &st) >= 0) 36470cc67336Smrg { 36480cc67336Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 36490cc67336Smrg } 36500cc67336Smrg return rval; 36510cc67336Smrg} 3652301ea0f4Smrg 36530cc67336Smrg/* Searches for the full path of the wrapper. Returns 36540cc67336Smrg newly allocated full path name if found, NULL otherwise 36550cc67336Smrg Does not chase symlinks, even on platforms that support them. 36560cc67336Smrg*/ 36570cc67336Smrgchar * 36580cc67336Smrgfind_executable (const char *wrapper) 36590cc67336Smrg{ 36600cc67336Smrg int has_slash = 0; 36610cc67336Smrg const char *p; 36620cc67336Smrg const char *p_next; 36630cc67336Smrg /* static buffer for getcwd */ 36640cc67336Smrg char tmp[LT_PATHMAX + 1]; 36650cc67336Smrg int tmp_len; 36660cc67336Smrg char *concat_name; 3667301ea0f4Smrg 36680cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n", 36690cc67336Smrg wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!")); 3670301ea0f4Smrg 36710cc67336Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 36720cc67336Smrg return NULL; 3673301ea0f4Smrg 36740cc67336Smrg /* Absolute path? */ 36750cc67336Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 36760cc67336Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 36770cc67336Smrg { 36780cc67336Smrg concat_name = xstrdup (wrapper); 36790cc67336Smrg if (check_executable (concat_name)) 36800cc67336Smrg return concat_name; 36810cc67336Smrg XFREE (concat_name); 36820cc67336Smrg } 36830cc67336Smrg else 36840cc67336Smrg { 36850cc67336Smrg#endif 36860cc67336Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 36870cc67336Smrg { 36880cc67336Smrg concat_name = xstrdup (wrapper); 36890cc67336Smrg if (check_executable (concat_name)) 36900cc67336Smrg return concat_name; 36910cc67336Smrg XFREE (concat_name); 36920cc67336Smrg } 36930cc67336Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 36940cc67336Smrg } 36950cc67336Smrg#endif 3696301ea0f4Smrg 36970cc67336Smrg for (p = wrapper; *p; p++) 36980cc67336Smrg if (*p == '/') 36990cc67336Smrg { 37000cc67336Smrg has_slash = 1; 37010cc67336Smrg break; 37020cc67336Smrg } 37030cc67336Smrg if (!has_slash) 37040cc67336Smrg { 37050cc67336Smrg /* no slashes; search PATH */ 37060cc67336Smrg const char *path = getenv ("PATH"); 37070cc67336Smrg if (path != NULL) 37080cc67336Smrg { 37090cc67336Smrg for (p = path; *p; p = p_next) 37100cc67336Smrg { 37110cc67336Smrg const char *q; 37120cc67336Smrg size_t p_len; 37130cc67336Smrg for (q = p; *q; q++) 37140cc67336Smrg if (IS_PATH_SEPARATOR (*q)) 37150cc67336Smrg break; 37160cc67336Smrg p_len = q - p; 37170cc67336Smrg p_next = (*q == '\0' ? q : q + 1); 37180cc67336Smrg if (p_len == 0) 37190cc67336Smrg { 37200cc67336Smrg /* empty path: current directory */ 37210cc67336Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 37220cc67336Smrg lt_fatal ("getcwd failed"); 37230cc67336Smrg tmp_len = strlen (tmp); 37240cc67336Smrg concat_name = 37250cc67336Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 37260cc67336Smrg memcpy (concat_name, tmp, tmp_len); 37270cc67336Smrg concat_name[tmp_len] = '/'; 37280cc67336Smrg strcpy (concat_name + tmp_len + 1, wrapper); 37290cc67336Smrg } 37300cc67336Smrg else 37310cc67336Smrg { 37320cc67336Smrg concat_name = 37330cc67336Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 37340cc67336Smrg memcpy (concat_name, p, p_len); 37350cc67336Smrg concat_name[p_len] = '/'; 37360cc67336Smrg strcpy (concat_name + p_len + 1, wrapper); 37370cc67336Smrg } 37380cc67336Smrg if (check_executable (concat_name)) 37390cc67336Smrg return concat_name; 37400cc67336Smrg XFREE (concat_name); 37410cc67336Smrg } 37420cc67336Smrg } 37430cc67336Smrg /* not found in PATH; assume curdir */ 37440cc67336Smrg } 37450cc67336Smrg /* Relative path | not found in path: prepend cwd */ 37460cc67336Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 37470cc67336Smrg lt_fatal ("getcwd failed"); 37480cc67336Smrg tmp_len = strlen (tmp); 37490cc67336Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 37500cc67336Smrg memcpy (concat_name, tmp, tmp_len); 37510cc67336Smrg concat_name[tmp_len] = '/'; 37520cc67336Smrg strcpy (concat_name + tmp_len + 1, wrapper); 3753301ea0f4Smrg 37540cc67336Smrg if (check_executable (concat_name)) 37550cc67336Smrg return concat_name; 37560cc67336Smrg XFREE (concat_name); 37570cc67336Smrg return NULL; 37580cc67336Smrg} 3759301ea0f4Smrg 37600cc67336Smrgchar * 37610cc67336Smrgchase_symlinks (const char *pathspec) 37620cc67336Smrg{ 37630cc67336Smrg#ifndef S_ISLNK 37640cc67336Smrg return xstrdup (pathspec); 37650cc67336Smrg#else 37660cc67336Smrg char buf[LT_PATHMAX]; 37670cc67336Smrg struct stat s; 37680cc67336Smrg char *tmp_pathspec = xstrdup (pathspec); 37690cc67336Smrg char *p; 37700cc67336Smrg int has_symlinks = 0; 37710cc67336Smrg while (strlen (tmp_pathspec) && !has_symlinks) 37720cc67336Smrg { 37730cc67336Smrg LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n", 37740cc67336Smrg tmp_pathspec)); 37750cc67336Smrg if (lstat (tmp_pathspec, &s) == 0) 37760cc67336Smrg { 37770cc67336Smrg if (S_ISLNK (s.st_mode) != 0) 37780cc67336Smrg { 37790cc67336Smrg has_symlinks = 1; 37800cc67336Smrg break; 37810cc67336Smrg } 3782301ea0f4Smrg 37830cc67336Smrg /* search backwards for last DIR_SEPARATOR */ 37840cc67336Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 37850cc67336Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 37860cc67336Smrg p--; 37870cc67336Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 37880cc67336Smrg { 37890cc67336Smrg /* no more DIR_SEPARATORS left */ 37900cc67336Smrg break; 37910cc67336Smrg } 37920cc67336Smrg *p = '\0'; 37930cc67336Smrg } 37940cc67336Smrg else 37950cc67336Smrg { 37960cc67336Smrg char *errstr = strerror (errno); 37970cc67336Smrg lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr); 37980cc67336Smrg } 37990cc67336Smrg } 38000cc67336Smrg XFREE (tmp_pathspec); 3801301ea0f4Smrg 38020cc67336Smrg if (!has_symlinks) 38030cc67336Smrg { 38040cc67336Smrg return xstrdup (pathspec); 38050cc67336Smrg } 3806301ea0f4Smrg 38070cc67336Smrg tmp_pathspec = realpath (pathspec, buf); 38080cc67336Smrg if (tmp_pathspec == 0) 38090cc67336Smrg { 38100cc67336Smrg lt_fatal ("Could not follow symlinks for %s", pathspec); 38110cc67336Smrg } 38120cc67336Smrg return xstrdup (tmp_pathspec); 38130cc67336Smrg#endif 38140cc67336Smrg} 3815301ea0f4Smrg 38160cc67336Smrgchar * 38170cc67336Smrgstrendzap (char *str, const char *pat) 38180cc67336Smrg{ 38190cc67336Smrg size_t len, patlen; 3820301ea0f4Smrg 38210cc67336Smrg assert (str != NULL); 38220cc67336Smrg assert (pat != NULL); 3823301ea0f4Smrg 38240cc67336Smrg len = strlen (str); 38250cc67336Smrg patlen = strlen (pat); 3826301ea0f4Smrg 38270cc67336Smrg if (patlen <= len) 38280cc67336Smrg { 38290cc67336Smrg str += len - patlen; 38300cc67336Smrg if (strcmp (str, pat) == 0) 38310cc67336Smrg *str = '\0'; 38320cc67336Smrg } 38330cc67336Smrg return str; 38340cc67336Smrg} 3835301ea0f4Smrg 38360cc67336Smrgstatic void 38370cc67336Smrglt_error_core (int exit_status, const char *mode, 38380cc67336Smrg const char *message, va_list ap) 38390cc67336Smrg{ 38400cc67336Smrg fprintf (stderr, "%s: %s: ", program_name, mode); 38410cc67336Smrg vfprintf (stderr, message, ap); 38420cc67336Smrg fprintf (stderr, ".\n"); 3843301ea0f4Smrg 38440cc67336Smrg if (exit_status >= 0) 38450cc67336Smrg exit (exit_status); 38460cc67336Smrg} 3847301ea0f4Smrg 38480cc67336Smrgvoid 38490cc67336Smrglt_fatal (const char *message, ...) 38500cc67336Smrg{ 38510cc67336Smrg va_list ap; 38520cc67336Smrg va_start (ap, message); 38530cc67336Smrg lt_error_core (EXIT_FAILURE, "FATAL", message, ap); 38540cc67336Smrg va_end (ap); 38550cc67336Smrg} 3856301ea0f4Smrg 38570cc67336Smrgvoid 38580cc67336Smrglt_setenv (const char *name, const char *value) 38590cc67336Smrg{ 38600cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n", 38610cc67336Smrg (name ? name : "<NULL>"), 38620cc67336Smrg (value ? value : "<NULL>"))); 38630cc67336Smrg { 38640cc67336Smrg#ifdef HAVE_SETENV 38650cc67336Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 38660cc67336Smrg char *str = xstrdup (value); 38670cc67336Smrg setenv (name, str, 1); 38680cc67336Smrg#else 38690cc67336Smrg int len = strlen (name) + 1 + strlen (value) + 1; 38700cc67336Smrg char *str = XMALLOC (char, len); 38710cc67336Smrg sprintf (str, "%s=%s", name, value); 38720cc67336Smrg if (putenv (str) != EXIT_SUCCESS) 38730cc67336Smrg { 38740cc67336Smrg XFREE (str); 38750cc67336Smrg } 38760cc67336Smrg#endif 38770cc67336Smrg } 38780cc67336Smrg} 3879301ea0f4Smrg 38800cc67336Smrgchar * 38810cc67336Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 38820cc67336Smrg{ 38830cc67336Smrg char *new_value; 38840cc67336Smrg if (orig_value && *orig_value) 38850cc67336Smrg { 38860cc67336Smrg int orig_value_len = strlen (orig_value); 38870cc67336Smrg int add_len = strlen (add); 38880cc67336Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 38890cc67336Smrg if (to_end) 38900cc67336Smrg { 38910cc67336Smrg strcpy (new_value, orig_value); 38920cc67336Smrg strcpy (new_value + orig_value_len, add); 38930cc67336Smrg } 38940cc67336Smrg else 38950cc67336Smrg { 38960cc67336Smrg strcpy (new_value, add); 38970cc67336Smrg strcpy (new_value + add_len, orig_value); 38980cc67336Smrg } 38990cc67336Smrg } 39000cc67336Smrg else 39010cc67336Smrg { 39020cc67336Smrg new_value = xstrdup (add); 39030cc67336Smrg } 39040cc67336Smrg return new_value; 39050cc67336Smrg} 3906301ea0f4Smrg 39070cc67336Smrgint 39080cc67336Smrglt_split_name_value (const char *arg, char** name, char** value) 39090cc67336Smrg{ 39100cc67336Smrg const char *p; 39110cc67336Smrg int len; 39120cc67336Smrg if (!arg || !*arg) 39130cc67336Smrg return 1; 3914301ea0f4Smrg 39150cc67336Smrg p = strchr (arg, (int)'='); 3916301ea0f4Smrg 39170cc67336Smrg if (!p) 39180cc67336Smrg return 1; 3919301ea0f4Smrg 39200cc67336Smrg *value = xstrdup (++p); 3921301ea0f4Smrg 39220cc67336Smrg len = strlen (arg) - strlen (*value); 39230cc67336Smrg *name = XMALLOC (char, len); 39240cc67336Smrg strncpy (*name, arg, len-1); 39250cc67336Smrg (*name)[len - 1] = '\0'; 3926301ea0f4Smrg 39270cc67336Smrg return 0; 39280cc67336Smrg} 3929301ea0f4Smrg 39300cc67336Smrgvoid 39310cc67336Smrglt_opt_process_env_set (const char *arg) 39320cc67336Smrg{ 39330cc67336Smrg char *name = NULL; 39340cc67336Smrg char *value = NULL; 3935301ea0f4Smrg 39360cc67336Smrg if (lt_split_name_value (arg, &name, &value) != 0) 39370cc67336Smrg { 39380cc67336Smrg XFREE (name); 39390cc67336Smrg XFREE (value); 39400cc67336Smrg lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg); 39410cc67336Smrg } 3942301ea0f4Smrg 39430cc67336Smrg lt_setenv (name, value); 39440cc67336Smrg XFREE (name); 39450cc67336Smrg XFREE (value); 39460cc67336Smrg} 3947301ea0f4Smrg 39480cc67336Smrgvoid 39490cc67336Smrglt_opt_process_env_prepend (const char *arg) 39500cc67336Smrg{ 39510cc67336Smrg char *name = NULL; 39520cc67336Smrg char *value = NULL; 39530cc67336Smrg char *new_value = NULL; 3954301ea0f4Smrg 39550cc67336Smrg if (lt_split_name_value (arg, &name, &value) != 0) 39560cc67336Smrg { 39570cc67336Smrg XFREE (name); 39580cc67336Smrg XFREE (value); 39590cc67336Smrg lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg); 39600cc67336Smrg } 3961301ea0f4Smrg 39620cc67336Smrg new_value = lt_extend_str (getenv (name), value, 0); 39630cc67336Smrg lt_setenv (name, new_value); 39640cc67336Smrg XFREE (new_value); 39650cc67336Smrg XFREE (name); 39660cc67336Smrg XFREE (value); 39670cc67336Smrg} 3968301ea0f4Smrg 39690cc67336Smrgvoid 39700cc67336Smrglt_opt_process_env_append (const char *arg) 39710cc67336Smrg{ 39720cc67336Smrg char *name = NULL; 39730cc67336Smrg char *value = NULL; 39740cc67336Smrg char *new_value = NULL; 3975301ea0f4Smrg 39760cc67336Smrg if (lt_split_name_value (arg, &name, &value) != 0) 39770cc67336Smrg { 39780cc67336Smrg XFREE (name); 39790cc67336Smrg XFREE (value); 39800cc67336Smrg lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg); 39810cc67336Smrg } 3982301ea0f4Smrg 39830cc67336Smrg new_value = lt_extend_str (getenv (name), value, 1); 39840cc67336Smrg lt_setenv (name, new_value); 39850cc67336Smrg XFREE (new_value); 39860cc67336Smrg XFREE (name); 39870cc67336Smrg XFREE (value); 39880cc67336Smrg} 3989301ea0f4Smrg 39900cc67336Smrgvoid 39910cc67336Smrglt_update_exe_path (const char *name, const char *value) 39920cc67336Smrg{ 39930cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 39940cc67336Smrg (name ? name : "<NULL>"), 39950cc67336Smrg (value ? value : "<NULL>"))); 3996301ea0f4Smrg 39970cc67336Smrg if (name && *name && value && *value) 39980cc67336Smrg { 39990cc67336Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 40000cc67336Smrg /* some systems can't cope with a ':'-terminated path #' */ 40010cc67336Smrg int len = strlen (new_value); 40020cc67336Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 40030cc67336Smrg { 40040cc67336Smrg new_value[len-1] = '\0'; 40050cc67336Smrg } 40060cc67336Smrg lt_setenv (name, new_value); 40070cc67336Smrg XFREE (new_value); 40080cc67336Smrg } 40090cc67336Smrg} 4010301ea0f4Smrg 40110cc67336Smrgvoid 40120cc67336Smrglt_update_lib_path (const char *name, const char *value) 40130cc67336Smrg{ 40140cc67336Smrg LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 40150cc67336Smrg (name ? name : "<NULL>"), 40160cc67336Smrg (value ? value : "<NULL>"))); 4017301ea0f4Smrg 40180cc67336Smrg if (name && *name && value && *value) 40190cc67336Smrg { 40200cc67336Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 40210cc67336Smrg lt_setenv (name, new_value); 40220cc67336Smrg XFREE (new_value); 40230cc67336Smrg } 40240cc67336Smrg} 4025301ea0f4Smrg 4026301ea0f4Smrg 40270cc67336SmrgEOF 40280cc67336Smrg} 40290cc67336Smrg# end: func_emit_cwrapperexe_src 4030301ea0f4Smrg 40310cc67336Smrg# func_mode_link arg... 40320cc67336Smrgfunc_mode_link () 40330cc67336Smrg{ 40340cc67336Smrg $opt_debug 40350cc67336Smrg case $host in 40360cc67336Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 40370cc67336Smrg # It is impossible to link a dll without this setting, and 40380cc67336Smrg # we shouldn't force the makefile maintainer to figure out 40390cc67336Smrg # which system we are compiling for in order to pass an extra 40400cc67336Smrg # flag for every libtool invocation. 40410cc67336Smrg # allow_undefined=no 4042301ea0f4Smrg 40430cc67336Smrg # FIXME: Unfortunately, there are problems with the above when trying 40440cc67336Smrg # to make a dll which has undefined symbols, in which case not 40450cc67336Smrg # even a static library is built. For now, we need to specify 40460cc67336Smrg # -no-undefined on the libtool link line when we can be certain 40470cc67336Smrg # that all symbols are satisfied, otherwise we get a static library. 40480cc67336Smrg allow_undefined=yes 40490cc67336Smrg ;; 40500cc67336Smrg *) 40510cc67336Smrg allow_undefined=yes 40520cc67336Smrg ;; 40530cc67336Smrg esac 40540cc67336Smrg libtool_args=$nonopt 40550cc67336Smrg base_compile="$nonopt $@" 40560cc67336Smrg compile_command=$nonopt 40570cc67336Smrg finalize_command=$nonopt 4058301ea0f4Smrg 40590cc67336Smrg compile_rpath= 40600cc67336Smrg finalize_rpath= 40610cc67336Smrg compile_shlibpath= 40620cc67336Smrg finalize_shlibpath= 40630cc67336Smrg convenience= 40640cc67336Smrg old_convenience= 40650cc67336Smrg deplibs= 40660cc67336Smrg old_deplibs= 40670cc67336Smrg compiler_flags= 40680cc67336Smrg linker_flags= 40690cc67336Smrg dllsearchpath= 40700cc67336Smrg lib_search_path=`pwd` 40710cc67336Smrg inst_prefix_dir= 40720cc67336Smrg new_inherited_linker_flags= 4073301ea0f4Smrg 40740cc67336Smrg avoid_version=no 40750cc67336Smrg dlfiles= 40760cc67336Smrg dlprefiles= 40770cc67336Smrg dlself=no 40780cc67336Smrg export_dynamic=no 40790cc67336Smrg export_symbols= 40800cc67336Smrg export_symbols_regex= 40810cc67336Smrg generated= 40820cc67336Smrg libobjs= 40830cc67336Smrg ltlibs= 40840cc67336Smrg module=no 40850cc67336Smrg no_install=no 40860cc67336Smrg objs= 40870cc67336Smrg non_pic_objects= 40880cc67336Smrg precious_files_regex= 40890cc67336Smrg prefer_static_libs=no 40900cc67336Smrg preload=no 40910cc67336Smrg prev= 40920cc67336Smrg prevarg= 40930cc67336Smrg release= 40940cc67336Smrg rpath= 40950cc67336Smrg xrpath= 40960cc67336Smrg perm_rpath= 40970cc67336Smrg temp_rpath= 40980cc67336Smrg thread_safe=no 40990cc67336Smrg vinfo= 41000cc67336Smrg vinfo_number=no 41010cc67336Smrg weak_libs= 41020cc67336Smrg single_module="${wl}-single_module" 41030cc67336Smrg func_infer_tag $base_compile 4104301ea0f4Smrg 41050cc67336Smrg # We need to know -static, to get the right output filenames. 41060cc67336Smrg for arg 41070cc67336Smrg do 41080cc67336Smrg case $arg in 41090cc67336Smrg -shared) 41100cc67336Smrg test "$build_libtool_libs" != yes && \ 41110cc67336Smrg func_fatal_configuration "can not build a shared library" 41120cc67336Smrg build_old_libs=no 41130cc67336Smrg break 41140cc67336Smrg ;; 41150cc67336Smrg -all-static | -static | -static-libtool-libs) 41160cc67336Smrg case $arg in 41170cc67336Smrg -all-static) 41180cc67336Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 41190cc67336Smrg func_warning "complete static linking is impossible in this configuration" 4120301ea0f4Smrg fi 41210cc67336Smrg if test -n "$link_static_flag"; then 41220cc67336Smrg dlopen_self=$dlopen_self_static 4123301ea0f4Smrg fi 41240cc67336Smrg prefer_static_libs=yes 4125301ea0f4Smrg ;; 41260cc67336Smrg -static) 41270cc67336Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 41280cc67336Smrg dlopen_self=$dlopen_self_static 41290cc67336Smrg fi 41300cc67336Smrg prefer_static_libs=built 41310cc67336Smrg ;; 41320cc67336Smrg -static-libtool-libs) 41330cc67336Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 41340cc67336Smrg dlopen_self=$dlopen_self_static 41350cc67336Smrg fi 41360cc67336Smrg prefer_static_libs=yes 4137301ea0f4Smrg ;; 4138301ea0f4Smrg esac 41390cc67336Smrg build_libtool_libs=no 41400cc67336Smrg build_old_libs=yes 41410cc67336Smrg break 41420cc67336Smrg ;; 41430cc67336Smrg esac 41440cc67336Smrg done 4145301ea0f4Smrg 41460cc67336Smrg # See if our shared archives depend on static archives. 41470cc67336Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 4148301ea0f4Smrg 41490cc67336Smrg # Go through the arguments, transforming them on the way. 41500cc67336Smrg while test "$#" -gt 0; do 41510cc67336Smrg arg="$1" 41520cc67336Smrg shift 41530cc67336Smrg func_quote_for_eval "$arg" 41540cc67336Smrg qarg=$func_quote_for_eval_unquoted_result 41550cc67336Smrg func_append libtool_args " $func_quote_for_eval_result" 4156301ea0f4Smrg 41570cc67336Smrg # If the previous option needs an argument, assign it. 41580cc67336Smrg if test -n "$prev"; then 41590cc67336Smrg case $prev in 41600cc67336Smrg output) 41610cc67336Smrg func_append compile_command " @OUTPUT@" 41620cc67336Smrg func_append finalize_command " @OUTPUT@" 41630cc67336Smrg ;; 41640cc67336Smrg esac 4165301ea0f4Smrg 41660cc67336Smrg case $prev in 41670cc67336Smrg dlfiles|dlprefiles) 41680cc67336Smrg if test "$preload" = no; then 41690cc67336Smrg # Add the symbol object into the linking commands. 41700cc67336Smrg func_append compile_command " @SYMFILE@" 41710cc67336Smrg func_append finalize_command " @SYMFILE@" 41720cc67336Smrg preload=yes 41730cc67336Smrg fi 41740cc67336Smrg case $arg in 41750cc67336Smrg *.la | *.lo) ;; # We handle these cases below. 41760cc67336Smrg force) 41770cc67336Smrg if test "$dlself" = no; then 41780cc67336Smrg dlself=needless 41790cc67336Smrg export_dynamic=yes 41800cc67336Smrg fi 41810cc67336Smrg prev= 41820cc67336Smrg continue 41830cc67336Smrg ;; 41840cc67336Smrg self) 41850cc67336Smrg if test "$prev" = dlprefiles; then 41860cc67336Smrg dlself=yes 41870cc67336Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 41880cc67336Smrg dlself=yes 41890cc67336Smrg else 41900cc67336Smrg dlself=needless 41910cc67336Smrg export_dynamic=yes 41920cc67336Smrg fi 41930cc67336Smrg prev= 41940cc67336Smrg continue 4195301ea0f4Smrg ;; 4196301ea0f4Smrg *) 41970cc67336Smrg if test "$prev" = dlfiles; then 41980cc67336Smrg dlfiles="$dlfiles $arg" 41990cc67336Smrg else 42000cc67336Smrg dlprefiles="$dlprefiles $arg" 42010cc67336Smrg fi 42020cc67336Smrg prev= 42030cc67336Smrg continue 4204301ea0f4Smrg ;; 4205301ea0f4Smrg esac 42060cc67336Smrg ;; 42070cc67336Smrg expsyms) 42080cc67336Smrg export_symbols="$arg" 42090cc67336Smrg test -f "$arg" \ 42100cc67336Smrg || func_fatal_error "symbol file \`$arg' does not exist" 42110cc67336Smrg prev= 42120cc67336Smrg continue 42130cc67336Smrg ;; 42140cc67336Smrg expsyms_regex) 42150cc67336Smrg export_symbols_regex="$arg" 42160cc67336Smrg prev= 42170cc67336Smrg continue 42180cc67336Smrg ;; 42190cc67336Smrg framework) 42200cc67336Smrg case $host in 42210cc67336Smrg *-*-darwin*) 42220cc67336Smrg case "$deplibs " in 42230cc67336Smrg *" $qarg.ltframework "*) ;; 42240cc67336Smrg *) deplibs="$deplibs $qarg.ltframework" # this is fixed later 42250cc67336Smrg ;; 42260cc67336Smrg esac 42270cc67336Smrg ;; 42280cc67336Smrg esac 42290cc67336Smrg prev= 42300cc67336Smrg continue 42310cc67336Smrg ;; 42320cc67336Smrg inst_prefix) 42330cc67336Smrg inst_prefix_dir="$arg" 42340cc67336Smrg prev= 42350cc67336Smrg continue 42360cc67336Smrg ;; 42370cc67336Smrg objectlist) 42380cc67336Smrg if test -f "$arg"; then 42390cc67336Smrg save_arg=$arg 42400cc67336Smrg moreargs= 42410cc67336Smrg for fil in `cat "$save_arg"` 42420cc67336Smrg do 42430cc67336Smrg# moreargs="$moreargs $fil" 42440cc67336Smrg arg=$fil 42450cc67336Smrg # A libtool-controlled object. 4246301ea0f4Smrg 42470cc67336Smrg # Check to see that this really is a libtool object. 42480cc67336Smrg if func_lalib_unsafe_p "$arg"; then 42490cc67336Smrg pic_object= 42500cc67336Smrg non_pic_object= 4251301ea0f4Smrg 42520cc67336Smrg # Read the .lo file 42530cc67336Smrg func_source "$arg" 4254301ea0f4Smrg 42550cc67336Smrg if test -z "$pic_object" || 42560cc67336Smrg test -z "$non_pic_object" || 42570cc67336Smrg test "$pic_object" = none && 42580cc67336Smrg test "$non_pic_object" = none; then 42590cc67336Smrg func_fatal_error "cannot find name of object for \`$arg'" 42600cc67336Smrg fi 4261301ea0f4Smrg 42620cc67336Smrg # Extract subdirectory from the argument. 42630cc67336Smrg func_dirname "$arg" "/" "" 42640cc67336Smrg xdir="$func_dirname_result" 4265301ea0f4Smrg 42660cc67336Smrg if test "$pic_object" != none; then 42670cc67336Smrg # Prepend the subdirectory the object is found in. 42680cc67336Smrg pic_object="$xdir$pic_object" 4269301ea0f4Smrg 42700cc67336Smrg if test "$prev" = dlfiles; then 42710cc67336Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 42720cc67336Smrg dlfiles="$dlfiles $pic_object" 42730cc67336Smrg prev= 42740cc67336Smrg continue 42750cc67336Smrg else 42760cc67336Smrg # If libtool objects are unsupported, then we need to preload. 42770cc67336Smrg prev=dlprefiles 42780cc67336Smrg fi 42790cc67336Smrg fi 4280301ea0f4Smrg 42810cc67336Smrg # CHECK ME: I think I busted this. -Ossama 42820cc67336Smrg if test "$prev" = dlprefiles; then 42830cc67336Smrg # Preload the old-style object. 42840cc67336Smrg dlprefiles="$dlprefiles $pic_object" 42850cc67336Smrg prev= 42860cc67336Smrg fi 4287301ea0f4Smrg 42880cc67336Smrg # A PIC object. 42890cc67336Smrg func_append libobjs " $pic_object" 42900cc67336Smrg arg="$pic_object" 42910cc67336Smrg fi 4292301ea0f4Smrg 42930cc67336Smrg # Non-PIC object. 42940cc67336Smrg if test "$non_pic_object" != none; then 42950cc67336Smrg # Prepend the subdirectory the object is found in. 42960cc67336Smrg non_pic_object="$xdir$non_pic_object" 4297301ea0f4Smrg 42980cc67336Smrg # A standard non-PIC object 42990cc67336Smrg func_append non_pic_objects " $non_pic_object" 43000cc67336Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 43010cc67336Smrg arg="$non_pic_object" 43020cc67336Smrg fi 43030cc67336Smrg else 43040cc67336Smrg # If the PIC object exists, use it instead. 43050cc67336Smrg # $xdir was prepended to $pic_object above. 43060cc67336Smrg non_pic_object="$pic_object" 43070cc67336Smrg func_append non_pic_objects " $non_pic_object" 43080cc67336Smrg fi 43090cc67336Smrg else 43100cc67336Smrg # Only an error if not doing a dry-run. 43110cc67336Smrg if $opt_dry_run; then 43120cc67336Smrg # Extract subdirectory from the argument. 43130cc67336Smrg func_dirname "$arg" "/" "" 43140cc67336Smrg xdir="$func_dirname_result" 43150cc67336Smrg 43160cc67336Smrg func_lo2o "$arg" 43170cc67336Smrg pic_object=$xdir$objdir/$func_lo2o_result 43180cc67336Smrg non_pic_object=$xdir$func_lo2o_result 43190cc67336Smrg func_append libobjs " $pic_object" 43200cc67336Smrg func_append non_pic_objects " $non_pic_object" 43210cc67336Smrg else 43220cc67336Smrg func_fatal_error "\`$arg' is not a valid libtool object" 43230cc67336Smrg fi 43240cc67336Smrg fi 43250cc67336Smrg done 43260cc67336Smrg else 43270cc67336Smrg func_fatal_error "link input file \`$arg' does not exist" 43280cc67336Smrg fi 43290cc67336Smrg arg=$save_arg 43300cc67336Smrg prev= 43310cc67336Smrg continue 43320cc67336Smrg ;; 43330cc67336Smrg precious_regex) 43340cc67336Smrg precious_files_regex="$arg" 43350cc67336Smrg prev= 43360cc67336Smrg continue 43370cc67336Smrg ;; 43380cc67336Smrg release) 43390cc67336Smrg release="-$arg" 43400cc67336Smrg prev= 43410cc67336Smrg continue 43420cc67336Smrg ;; 43430cc67336Smrg rpath | xrpath) 43440cc67336Smrg # We need an absolute path. 43450cc67336Smrg case $arg in 43460cc67336Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 43470cc67336Smrg *) 43480cc67336Smrg func_fatal_error "only absolute run-paths are allowed" 43490cc67336Smrg ;; 43500cc67336Smrg esac 43510cc67336Smrg if test "$prev" = rpath; then 43520cc67336Smrg case "$rpath " in 43530cc67336Smrg *" $arg "*) ;; 43540cc67336Smrg *) rpath="$rpath $arg" ;; 43550cc67336Smrg esac 43560cc67336Smrg else 43570cc67336Smrg case "$xrpath " in 43580cc67336Smrg *" $arg "*) ;; 43590cc67336Smrg *) xrpath="$xrpath $arg" ;; 43600cc67336Smrg esac 43610cc67336Smrg fi 43620cc67336Smrg prev= 43630cc67336Smrg continue 43640cc67336Smrg ;; 43650cc67336Smrg shrext) 43660cc67336Smrg shrext_cmds="$arg" 43670cc67336Smrg prev= 43680cc67336Smrg continue 43690cc67336Smrg ;; 43700cc67336Smrg weak) 43710cc67336Smrg weak_libs="$weak_libs $arg" 43720cc67336Smrg prev= 43730cc67336Smrg continue 43740cc67336Smrg ;; 43750cc67336Smrg xcclinker) 43760cc67336Smrg linker_flags="$linker_flags $qarg" 43770cc67336Smrg compiler_flags="$compiler_flags $qarg" 43780cc67336Smrg prev= 43790cc67336Smrg func_append compile_command " $qarg" 43800cc67336Smrg func_append finalize_command " $qarg" 43810cc67336Smrg continue 43820cc67336Smrg ;; 43830cc67336Smrg xcompiler) 43840cc67336Smrg compiler_flags="$compiler_flags $qarg" 43850cc67336Smrg prev= 43860cc67336Smrg func_append compile_command " $qarg" 43870cc67336Smrg func_append finalize_command " $qarg" 43880cc67336Smrg continue 43890cc67336Smrg ;; 43900cc67336Smrg xlinker) 43910cc67336Smrg linker_flags="$linker_flags $qarg" 43920cc67336Smrg compiler_flags="$compiler_flags $wl$qarg" 43930cc67336Smrg prev= 43940cc67336Smrg func_append compile_command " $wl$qarg" 43950cc67336Smrg func_append finalize_command " $wl$qarg" 43960cc67336Smrg continue 43970cc67336Smrg ;; 43980cc67336Smrg *) 43990cc67336Smrg eval "$prev=\"\$arg\"" 44000cc67336Smrg prev= 44010cc67336Smrg continue 44020cc67336Smrg ;; 4403301ea0f4Smrg esac 44040cc67336Smrg fi # test -n "$prev" 4405301ea0f4Smrg 44060cc67336Smrg prevarg="$arg" 4407301ea0f4Smrg 44080cc67336Smrg case $arg in 44090cc67336Smrg -all-static) 44100cc67336Smrg if test -n "$link_static_flag"; then 44110cc67336Smrg # See comment for -static flag below, for more details. 44120cc67336Smrg func_append compile_command " $link_static_flag" 44130cc67336Smrg func_append finalize_command " $link_static_flag" 44140cc67336Smrg fi 44150cc67336Smrg continue 44160cc67336Smrg ;; 4417301ea0f4Smrg 44180cc67336Smrg -allow-undefined) 44190cc67336Smrg # FIXME: remove this flag sometime in the future. 44200cc67336Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 44210cc67336Smrg ;; 4422301ea0f4Smrg 44230cc67336Smrg -avoid-version) 44240cc67336Smrg avoid_version=yes 44250cc67336Smrg continue 44260cc67336Smrg ;; 4427301ea0f4Smrg 44280cc67336Smrg -dlopen) 44290cc67336Smrg prev=dlfiles 44300cc67336Smrg continue 44310cc67336Smrg ;; 4432301ea0f4Smrg 44330cc67336Smrg -dlpreopen) 44340cc67336Smrg prev=dlprefiles 44350cc67336Smrg continue 44360cc67336Smrg ;; 4437301ea0f4Smrg 44380cc67336Smrg -export-dynamic) 44390cc67336Smrg export_dynamic=yes 44400cc67336Smrg continue 44410cc67336Smrg ;; 4442301ea0f4Smrg 44430cc67336Smrg -export-symbols | -export-symbols-regex) 44440cc67336Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 44450cc67336Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 44460cc67336Smrg fi 44470cc67336Smrg if test "X$arg" = "X-export-symbols"; then 44480cc67336Smrg prev=expsyms 44490cc67336Smrg else 44500cc67336Smrg prev=expsyms_regex 44510cc67336Smrg fi 44520cc67336Smrg continue 44530cc67336Smrg ;; 4454301ea0f4Smrg 44550cc67336Smrg -framework) 44560cc67336Smrg prev=framework 44570cc67336Smrg continue 44580cc67336Smrg ;; 4459301ea0f4Smrg 44600cc67336Smrg -inst-prefix-dir) 44610cc67336Smrg prev=inst_prefix 44620cc67336Smrg continue 44630cc67336Smrg ;; 4464301ea0f4Smrg 44650cc67336Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 44660cc67336Smrg # so, if we see these flags be careful not to treat them like -L 44670cc67336Smrg -L[A-Z][A-Z]*:*) 44680cc67336Smrg case $with_gcc/$host in 44690cc67336Smrg no/*-*-irix* | /*-*-irix*) 44700cc67336Smrg func_append compile_command " $arg" 44710cc67336Smrg func_append finalize_command " $arg" 44720cc67336Smrg ;; 44730cc67336Smrg esac 44740cc67336Smrg continue 44750cc67336Smrg ;; 4476301ea0f4Smrg 44770cc67336Smrg -L*) 44780cc67336Smrg func_stripname '-L' '' "$arg" 44790cc67336Smrg dir=$func_stripname_result 44800cc67336Smrg if test -z "$dir"; then 44810cc67336Smrg if test "$#" -gt 0; then 44820cc67336Smrg func_fatal_error "require no space between \`-L' and \`$1'" 44830cc67336Smrg else 44840cc67336Smrg func_fatal_error "need path for \`-L' option" 44850cc67336Smrg fi 44860cc67336Smrg fi 44870cc67336Smrg # We need an absolute path. 44880cc67336Smrg case $dir in 44890cc67336Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 44900cc67336Smrg *) 44910cc67336Smrg absdir=`cd "$dir" && pwd` 44920cc67336Smrg test -z "$absdir" && \ 44930cc67336Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 44940cc67336Smrg dir="$absdir" 44950cc67336Smrg ;; 44960cc67336Smrg esac 44970cc67336Smrg case "$deplibs " in 44980cc67336Smrg *" -L$dir "*) ;; 44990cc67336Smrg *) 45000cc67336Smrg deplibs="$deplibs -L$dir" 45010cc67336Smrg lib_search_path="$lib_search_path $dir" 45020cc67336Smrg ;; 45030cc67336Smrg esac 45040cc67336Smrg case $host in 45050cc67336Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 45060cc67336Smrg testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'` 45070cc67336Smrg case :$dllsearchpath: in 45080cc67336Smrg *":$dir:"*) ;; 45090cc67336Smrg ::) dllsearchpath=$dir;; 45100cc67336Smrg *) dllsearchpath="$dllsearchpath:$dir";; 45110cc67336Smrg esac 45120cc67336Smrg case :$dllsearchpath: in 45130cc67336Smrg *":$testbindir:"*) ;; 45140cc67336Smrg ::) dllsearchpath=$testbindir;; 45150cc67336Smrg *) dllsearchpath="$dllsearchpath:$testbindir";; 45160cc67336Smrg esac 45170cc67336Smrg ;; 45180cc67336Smrg esac 45190cc67336Smrg continue 45200cc67336Smrg ;; 4521301ea0f4Smrg 45220cc67336Smrg -l*) 45230cc67336Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 45240cc67336Smrg case $host in 45250cc67336Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*) 45260cc67336Smrg # These systems don't actually have a C or math library (as such) 45270cc67336Smrg continue 45280cc67336Smrg ;; 45290cc67336Smrg *-*-os2*) 45300cc67336Smrg # These systems don't actually have a C library (as such) 45310cc67336Smrg test "X$arg" = "X-lc" && continue 45320cc67336Smrg ;; 45330cc67336Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 45340cc67336Smrg # Do not include libc due to us having libc/libc_r. 45350cc67336Smrg test "X$arg" = "X-lc" && continue 45360cc67336Smrg ;; 45370cc67336Smrg *-*-rhapsody* | *-*-darwin1.[012]) 45380cc67336Smrg # Rhapsody C and math libraries are in the System framework 45390cc67336Smrg deplibs="$deplibs System.ltframework" 45400cc67336Smrg continue 45410cc67336Smrg ;; 45420cc67336Smrg *-*-sco3.2v5* | *-*-sco5v6*) 45430cc67336Smrg # Causes problems with __ctype 45440cc67336Smrg test "X$arg" = "X-lc" && continue 45450cc67336Smrg ;; 45460cc67336Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 45470cc67336Smrg # Compiler inserts libc in the correct place for threads to work 45480cc67336Smrg test "X$arg" = "X-lc" && continue 45490cc67336Smrg ;; 45500cc67336Smrg esac 45510cc67336Smrg elif test "X$arg" = "X-lc_r"; then 45520cc67336Smrg case $host in 45530cc67336Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 45540cc67336Smrg # Do not include libc_r directly, use -pthread flag. 45550cc67336Smrg continue 45560cc67336Smrg ;; 45570cc67336Smrg esac 45580cc67336Smrg fi 45590cc67336Smrg deplibs="$deplibs $arg" 45600cc67336Smrg continue 45610cc67336Smrg ;; 4562301ea0f4Smrg 45630cc67336Smrg -module) 45640cc67336Smrg module=yes 45650cc67336Smrg continue 45660cc67336Smrg ;; 4567301ea0f4Smrg 45680cc67336Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 45690cc67336Smrg # classes, name mangling, and exception handling. 45700cc67336Smrg # Darwin uses the -arch flag to determine output architecture. 45710cc67336Smrg -model|-arch|-isysroot) 45720cc67336Smrg compiler_flags="$compiler_flags $arg" 45730cc67336Smrg func_append compile_command " $arg" 45740cc67336Smrg func_append finalize_command " $arg" 45750cc67336Smrg prev=xcompiler 45760cc67336Smrg continue 45770cc67336Smrg ;; 4578301ea0f4Smrg 45790cc67336Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 45800cc67336Smrg compiler_flags="$compiler_flags $arg" 45810cc67336Smrg func_append compile_command " $arg" 45820cc67336Smrg func_append finalize_command " $arg" 45830cc67336Smrg case "$new_inherited_linker_flags " in 45840cc67336Smrg *" $arg "*) ;; 45850cc67336Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; 45860cc67336Smrg esac 45870cc67336Smrg continue 45880cc67336Smrg ;; 4589301ea0f4Smrg 45900cc67336Smrg -multi_module) 45910cc67336Smrg single_module="${wl}-multi_module" 45920cc67336Smrg continue 45930cc67336Smrg ;; 4594301ea0f4Smrg 45950cc67336Smrg -no-fast-install) 45960cc67336Smrg fast_install=no 45970cc67336Smrg continue 45980cc67336Smrg ;; 4599301ea0f4Smrg 46000cc67336Smrg -no-install) 46010cc67336Smrg case $host in 46020cc67336Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 46030cc67336Smrg # The PATH hackery in wrapper scripts is required on Windows 46040cc67336Smrg # and Darwin in order for the loader to find any dlls it needs. 46050cc67336Smrg func_warning "\`-no-install' is ignored for $host" 46060cc67336Smrg func_warning "assuming \`-no-fast-install' instead" 46070cc67336Smrg fast_install=no 46080cc67336Smrg ;; 46090cc67336Smrg *) no_install=yes ;; 46100cc67336Smrg esac 46110cc67336Smrg continue 46120cc67336Smrg ;; 4613301ea0f4Smrg 46140cc67336Smrg -no-undefined) 46150cc67336Smrg allow_undefined=no 46160cc67336Smrg continue 46170cc67336Smrg ;; 4618301ea0f4Smrg 46190cc67336Smrg -objectlist) 46200cc67336Smrg prev=objectlist 46210cc67336Smrg continue 46220cc67336Smrg ;; 4623301ea0f4Smrg 46240cc67336Smrg -o) prev=output ;; 4625301ea0f4Smrg 46260cc67336Smrg -precious-files-regex) 46270cc67336Smrg prev=precious_regex 46280cc67336Smrg continue 46290cc67336Smrg ;; 4630301ea0f4Smrg 46310cc67336Smrg -release) 46320cc67336Smrg prev=release 46330cc67336Smrg continue 46340cc67336Smrg ;; 4635301ea0f4Smrg 46360cc67336Smrg -rpath) 46370cc67336Smrg prev=rpath 46380cc67336Smrg continue 46390cc67336Smrg ;; 4640301ea0f4Smrg 46410cc67336Smrg -R) 46420cc67336Smrg prev=xrpath 46430cc67336Smrg continue 46440cc67336Smrg ;; 4645301ea0f4Smrg 46460cc67336Smrg -R*) 46470cc67336Smrg func_stripname '-R' '' "$arg" 46480cc67336Smrg dir=$func_stripname_result 46490cc67336Smrg # We need an absolute path. 46500cc67336Smrg case $dir in 46510cc67336Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 46520cc67336Smrg *) 46530cc67336Smrg func_fatal_error "only absolute run-paths are allowed" 46540cc67336Smrg ;; 46550cc67336Smrg esac 46560cc67336Smrg case "$xrpath " in 46570cc67336Smrg *" $dir "*) ;; 46580cc67336Smrg *) xrpath="$xrpath $dir" ;; 46590cc67336Smrg esac 46600cc67336Smrg continue 46610cc67336Smrg ;; 4662301ea0f4Smrg 46630cc67336Smrg -shared) 46640cc67336Smrg # The effects of -shared are defined in a previous loop. 46650cc67336Smrg continue 46660cc67336Smrg ;; 4667301ea0f4Smrg 46680cc67336Smrg -shrext) 46690cc67336Smrg prev=shrext 46700cc67336Smrg continue 46710cc67336Smrg ;; 4672301ea0f4Smrg 46730cc67336Smrg -static | -static-libtool-libs) 46740cc67336Smrg # The effects of -static are defined in a previous loop. 46750cc67336Smrg # We used to do the same as -all-static on platforms that 46760cc67336Smrg # didn't have a PIC flag, but the assumption that the effects 46770cc67336Smrg # would be equivalent was wrong. It would break on at least 46780cc67336Smrg # Digital Unix and AIX. 46790cc67336Smrg continue 46800cc67336Smrg ;; 4681301ea0f4Smrg 46820cc67336Smrg -thread-safe) 46830cc67336Smrg thread_safe=yes 46840cc67336Smrg continue 46850cc67336Smrg ;; 4686301ea0f4Smrg 46870cc67336Smrg -version-info) 46880cc67336Smrg prev=vinfo 46890cc67336Smrg continue 46900cc67336Smrg ;; 4691301ea0f4Smrg 46920cc67336Smrg -version-number) 46930cc67336Smrg prev=vinfo 46940cc67336Smrg vinfo_number=yes 46950cc67336Smrg continue 46960cc67336Smrg ;; 4697301ea0f4Smrg 46980cc67336Smrg -weak) 46990cc67336Smrg prev=weak 47000cc67336Smrg continue 47010cc67336Smrg ;; 4702301ea0f4Smrg 47030cc67336Smrg -Wc,*) 47040cc67336Smrg func_stripname '-Wc,' '' "$arg" 47050cc67336Smrg args=$func_stripname_result 47060cc67336Smrg arg= 47070cc67336Smrg save_ifs="$IFS"; IFS=',' 47080cc67336Smrg for flag in $args; do 47090cc67336Smrg IFS="$save_ifs" 47100cc67336Smrg func_quote_for_eval "$flag" 47110cc67336Smrg arg="$arg $wl$func_quote_for_eval_result" 47120cc67336Smrg compiler_flags="$compiler_flags $func_quote_for_eval_result" 47130cc67336Smrg done 47140cc67336Smrg IFS="$save_ifs" 47150cc67336Smrg func_stripname ' ' '' "$arg" 47160cc67336Smrg arg=$func_stripname_result 47170cc67336Smrg ;; 4718301ea0f4Smrg 47190cc67336Smrg -Wl,*) 47200cc67336Smrg func_stripname '-Wl,' '' "$arg" 47210cc67336Smrg args=$func_stripname_result 47220cc67336Smrg arg= 47230cc67336Smrg save_ifs="$IFS"; IFS=',' 47240cc67336Smrg for flag in $args; do 47250cc67336Smrg IFS="$save_ifs" 47260cc67336Smrg func_quote_for_eval "$flag" 47270cc67336Smrg arg="$arg $wl$func_quote_for_eval_result" 47280cc67336Smrg compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" 47290cc67336Smrg linker_flags="$linker_flags $func_quote_for_eval_result" 47300cc67336Smrg done 47310cc67336Smrg IFS="$save_ifs" 47320cc67336Smrg func_stripname ' ' '' "$arg" 47330cc67336Smrg arg=$func_stripname_result 47340cc67336Smrg ;; 4735301ea0f4Smrg 47360cc67336Smrg -Xcompiler) 47370cc67336Smrg prev=xcompiler 47380cc67336Smrg continue 47390cc67336Smrg ;; 4740301ea0f4Smrg 47410cc67336Smrg -Xlinker) 47420cc67336Smrg prev=xlinker 47430cc67336Smrg continue 47440cc67336Smrg ;; 4745301ea0f4Smrg 47460cc67336Smrg -XCClinker) 47470cc67336Smrg prev=xcclinker 47480cc67336Smrg continue 47490cc67336Smrg ;; 4750301ea0f4Smrg 47510cc67336Smrg # -msg_* for osf cc 47520cc67336Smrg -msg_*) 47530cc67336Smrg func_quote_for_eval "$arg" 47540cc67336Smrg arg="$func_quote_for_eval_result" 47550cc67336Smrg ;; 4756301ea0f4Smrg 47570cc67336Smrg # -64, -mips[0-9] enable 64-bit mode on the SGI compiler 47580cc67336Smrg # -r[0-9][0-9]* specifies the processor on the SGI compiler 47590cc67336Smrg # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler 47600cc67336Smrg # +DA*, +DD* enable 64-bit mode on the HP compiler 47610cc67336Smrg # -q* pass through compiler args for the IBM compiler 47620cc67336Smrg # -m*, -t[45]*, -txscale* pass through architecture-specific 47630cc67336Smrg # compiler args for GCC 47640cc67336Smrg # -F/path gives path to uninstalled frameworks, gcc on darwin 47650cc67336Smrg # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC 47660cc67336Smrg # @file GCC response files 47670cc67336Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 47680cc67336Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*) 47690cc67336Smrg func_quote_for_eval "$arg" 47700cc67336Smrg arg="$func_quote_for_eval_result" 47710cc67336Smrg func_append compile_command " $arg" 47720cc67336Smrg func_append finalize_command " $arg" 47730cc67336Smrg compiler_flags="$compiler_flags $arg" 47740cc67336Smrg continue 47750cc67336Smrg ;; 4776301ea0f4Smrg 47770cc67336Smrg # Some other compiler flag. 47780cc67336Smrg -* | +*) 47790cc67336Smrg func_quote_for_eval "$arg" 47800cc67336Smrg arg="$func_quote_for_eval_result" 47810cc67336Smrg ;; 4782301ea0f4Smrg 47830cc67336Smrg *.$objext) 47840cc67336Smrg # A standard object. 47850cc67336Smrg objs="$objs $arg" 47860cc67336Smrg ;; 47870cc67336Smrg 47880cc67336Smrg *.lo) 47890cc67336Smrg # A libtool-controlled object. 47900cc67336Smrg 47910cc67336Smrg # Check to see that this really is a libtool object. 47920cc67336Smrg if func_lalib_unsafe_p "$arg"; then 47930cc67336Smrg pic_object= 47940cc67336Smrg non_pic_object= 47950cc67336Smrg 47960cc67336Smrg # Read the .lo file 47970cc67336Smrg func_source "$arg" 47980cc67336Smrg 47990cc67336Smrg if test -z "$pic_object" || 48000cc67336Smrg test -z "$non_pic_object" || 48010cc67336Smrg test "$pic_object" = none && 48020cc67336Smrg test "$non_pic_object" = none; then 48030cc67336Smrg func_fatal_error "cannot find name of object for \`$arg'" 48040cc67336Smrg fi 48050cc67336Smrg 48060cc67336Smrg # Extract subdirectory from the argument. 48070cc67336Smrg func_dirname "$arg" "/" "" 48080cc67336Smrg xdir="$func_dirname_result" 48090cc67336Smrg 48100cc67336Smrg if test "$pic_object" != none; then 48110cc67336Smrg # Prepend the subdirectory the object is found in. 48120cc67336Smrg pic_object="$xdir$pic_object" 48130cc67336Smrg 48140cc67336Smrg if test "$prev" = dlfiles; then 48150cc67336Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 48160cc67336Smrg dlfiles="$dlfiles $pic_object" 48170cc67336Smrg prev= 48180cc67336Smrg continue 48190cc67336Smrg else 48200cc67336Smrg # If libtool objects are unsupported, then we need to preload. 48210cc67336Smrg prev=dlprefiles 48220cc67336Smrg fi 48230cc67336Smrg fi 48240cc67336Smrg 48250cc67336Smrg # CHECK ME: I think I busted this. -Ossama 48260cc67336Smrg if test "$prev" = dlprefiles; then 48270cc67336Smrg # Preload the old-style object. 48280cc67336Smrg dlprefiles="$dlprefiles $pic_object" 48290cc67336Smrg prev= 48300cc67336Smrg fi 48310cc67336Smrg 48320cc67336Smrg # A PIC object. 48330cc67336Smrg func_append libobjs " $pic_object" 48340cc67336Smrg arg="$pic_object" 48350cc67336Smrg fi 48360cc67336Smrg 48370cc67336Smrg # Non-PIC object. 48380cc67336Smrg if test "$non_pic_object" != none; then 48390cc67336Smrg # Prepend the subdirectory the object is found in. 48400cc67336Smrg non_pic_object="$xdir$non_pic_object" 48410cc67336Smrg 48420cc67336Smrg # A standard non-PIC object 48430cc67336Smrg func_append non_pic_objects " $non_pic_object" 48440cc67336Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 48450cc67336Smrg arg="$non_pic_object" 48460cc67336Smrg fi 48470cc67336Smrg else 48480cc67336Smrg # If the PIC object exists, use it instead. 48490cc67336Smrg # $xdir was prepended to $pic_object above. 48500cc67336Smrg non_pic_object="$pic_object" 48510cc67336Smrg func_append non_pic_objects " $non_pic_object" 48520cc67336Smrg fi 48530cc67336Smrg else 48540cc67336Smrg # Only an error if not doing a dry-run. 48550cc67336Smrg if $opt_dry_run; then 48560cc67336Smrg # Extract subdirectory from the argument. 48570cc67336Smrg func_dirname "$arg" "/" "" 48580cc67336Smrg xdir="$func_dirname_result" 48590cc67336Smrg 48600cc67336Smrg func_lo2o "$arg" 48610cc67336Smrg pic_object=$xdir$objdir/$func_lo2o_result 48620cc67336Smrg non_pic_object=$xdir$func_lo2o_result 48630cc67336Smrg func_append libobjs " $pic_object" 48640cc67336Smrg func_append non_pic_objects " $non_pic_object" 48650cc67336Smrg else 48660cc67336Smrg func_fatal_error "\`$arg' is not a valid libtool object" 48670cc67336Smrg fi 48680cc67336Smrg fi 48690cc67336Smrg ;; 48700cc67336Smrg 48710cc67336Smrg *.$libext) 48720cc67336Smrg # An archive. 48730cc67336Smrg deplibs="$deplibs $arg" 48740cc67336Smrg old_deplibs="$old_deplibs $arg" 48750cc67336Smrg continue 48760cc67336Smrg ;; 48770cc67336Smrg 48780cc67336Smrg *.la) 48790cc67336Smrg # A libtool-controlled library. 48800cc67336Smrg 48810cc67336Smrg if test "$prev" = dlfiles; then 48820cc67336Smrg # This library was specified with -dlopen. 48830cc67336Smrg dlfiles="$dlfiles $arg" 48840cc67336Smrg prev= 48850cc67336Smrg elif test "$prev" = dlprefiles; then 48860cc67336Smrg # The library was specified with -dlpreopen. 48870cc67336Smrg dlprefiles="$dlprefiles $arg" 48880cc67336Smrg prev= 48890cc67336Smrg else 48900cc67336Smrg deplibs="$deplibs $arg" 48910cc67336Smrg fi 48920cc67336Smrg continue 48930cc67336Smrg ;; 48940cc67336Smrg 48950cc67336Smrg # Some other compiler argument. 48960cc67336Smrg *) 48970cc67336Smrg # Unknown arguments in both finalize_command and compile_command need 48980cc67336Smrg # to be aesthetically quoted because they are evaled later. 48990cc67336Smrg func_quote_for_eval "$arg" 49000cc67336Smrg arg="$func_quote_for_eval_result" 49010cc67336Smrg ;; 49020cc67336Smrg esac # arg 49030cc67336Smrg 49040cc67336Smrg # Now actually substitute the argument into the commands. 49050cc67336Smrg if test -n "$arg"; then 49060cc67336Smrg func_append compile_command " $arg" 49070cc67336Smrg func_append finalize_command " $arg" 49080cc67336Smrg fi 49090cc67336Smrg done # argument parsing loop 49100cc67336Smrg 49110cc67336Smrg test -n "$prev" && \ 49120cc67336Smrg func_fatal_help "the \`$prevarg' option requires an argument" 49130cc67336Smrg 49140cc67336Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 49150cc67336Smrg eval arg=\"$export_dynamic_flag_spec\" 49160cc67336Smrg func_append compile_command " $arg" 49170cc67336Smrg func_append finalize_command " $arg" 49180cc67336Smrg fi 49190cc67336Smrg 49200cc67336Smrg oldlibs= 49210cc67336Smrg # calculate the name of the file, without its directory 49220cc67336Smrg func_basename "$output" 49230cc67336Smrg outputname="$func_basename_result" 49240cc67336Smrg libobjs_save="$libobjs" 49250cc67336Smrg 49260cc67336Smrg if test -n "$shlibpath_var"; then 49270cc67336Smrg # get the directories listed in $shlibpath_var 49280cc67336Smrg eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` 4929301ea0f4Smrg else 49300cc67336Smrg shlib_search_path= 4931301ea0f4Smrg fi 49320cc67336Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 49330cc67336Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 4934301ea0f4Smrg 49350cc67336Smrg func_dirname "$output" "/" "" 49360cc67336Smrg output_objdir="$func_dirname_result$objdir" 49370cc67336Smrg # Create the object directory. 49380cc67336Smrg func_mkdir_p "$output_objdir" 4939301ea0f4Smrg 49400cc67336Smrg # Determine the type of output 49410cc67336Smrg case $output in 49420cc67336Smrg "") 49430cc67336Smrg func_fatal_help "you must specify an output file" 49440cc67336Smrg ;; 49450cc67336Smrg *.$libext) linkmode=oldlib ;; 49460cc67336Smrg *.lo | *.$objext) linkmode=obj ;; 49470cc67336Smrg *.la) linkmode=lib ;; 49480cc67336Smrg *) linkmode=prog ;; # Anything else should be a program. 49490cc67336Smrg esac 49500cc67336Smrg 49510cc67336Smrg specialdeplibs= 49520cc67336Smrg 49530cc67336Smrg libs= 49540cc67336Smrg # Find all interdependent deplibs by searching for libraries 49550cc67336Smrg # that are linked more than once (e.g. -la -lb -la) 49560cc67336Smrg for deplib in $deplibs; do 49570cc67336Smrg if $opt_duplicate_deps ; then 49580cc67336Smrg case "$libs " in 49590cc67336Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 49600cc67336Smrg esac 49610cc67336Smrg fi 49620cc67336Smrg libs="$libs $deplib" 49630cc67336Smrg done 49640cc67336Smrg 49650cc67336Smrg if test "$linkmode" = lib; then 49660cc67336Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 49670cc67336Smrg 49680cc67336Smrg # Compute libraries that are listed more than once in $predeps 49690cc67336Smrg # $postdeps and mark them as special (i.e., whose duplicates are 49700cc67336Smrg # not to be eliminated). 49710cc67336Smrg pre_post_deps= 49720cc67336Smrg if $opt_duplicate_compiler_generated_deps; then 49730cc67336Smrg for pre_post_dep in $predeps $postdeps; do 49740cc67336Smrg case "$pre_post_deps " in 49750cc67336Smrg *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; 49760cc67336Smrg esac 49770cc67336Smrg pre_post_deps="$pre_post_deps $pre_post_dep" 49780cc67336Smrg done 49790cc67336Smrg fi 49800cc67336Smrg pre_post_deps= 49810cc67336Smrg fi 49820cc67336Smrg 49830cc67336Smrg deplibs= 49840cc67336Smrg newdependency_libs= 49850cc67336Smrg newlib_search_path= 49860cc67336Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 49870cc67336Smrg notinst_deplibs= # not-installed libtool libraries 49880cc67336Smrg notinst_path= # paths that contain not-installed libtool libraries 49890cc67336Smrg 49900cc67336Smrg case $linkmode in 49910cc67336Smrg lib) 49920cc67336Smrg passes="conv dlpreopen link" 49930cc67336Smrg for file in $dlfiles $dlprefiles; do 49940cc67336Smrg case $file in 49950cc67336Smrg *.la) ;; 49960cc67336Smrg *) 49970cc67336Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 49980cc67336Smrg ;; 49990cc67336Smrg esac 50000cc67336Smrg done 50010cc67336Smrg ;; 50020cc67336Smrg prog) 50030cc67336Smrg compile_deplibs= 50040cc67336Smrg finalize_deplibs= 50050cc67336Smrg alldeplibs=no 50060cc67336Smrg newdlfiles= 50070cc67336Smrg newdlprefiles= 50080cc67336Smrg passes="conv scan dlopen dlpreopen link" 50090cc67336Smrg ;; 50100cc67336Smrg *) passes="conv" 50110cc67336Smrg ;; 50120cc67336Smrg esac 50130cc67336Smrg 50140cc67336Smrg for pass in $passes; do 50150cc67336Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 50160cc67336Smrg # so that -L comes before libs that need it for instance... 50170cc67336Smrg if test "$linkmode,$pass" = "lib,link"; then 50180cc67336Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 50190cc67336Smrg ## order, and fix it there properly 50200cc67336Smrg tmp_deplibs= 50210cc67336Smrg for deplib in $deplibs; do 50220cc67336Smrg tmp_deplibs="$deplib $tmp_deplibs" 50230cc67336Smrg done 50240cc67336Smrg deplibs="$tmp_deplibs" 50250cc67336Smrg fi 50260cc67336Smrg 50270cc67336Smrg if test "$linkmode,$pass" = "lib,link" || 50280cc67336Smrg test "$linkmode,$pass" = "prog,scan"; then 50290cc67336Smrg libs="$deplibs" 50300cc67336Smrg deplibs= 50310cc67336Smrg fi 50320cc67336Smrg if test "$linkmode" = prog; then 50330cc67336Smrg case $pass in 50340cc67336Smrg dlopen) libs="$dlfiles" ;; 50350cc67336Smrg dlpreopen) libs="$dlprefiles" ;; 50360cc67336Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 50370cc67336Smrg esac 50380cc67336Smrg fi 50390cc67336Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 50400cc67336Smrg # Collect and forward deplibs of preopened libtool libs 50410cc67336Smrg for lib in $dlprefiles; do 50420cc67336Smrg # Ignore non-libtool-libs 50430cc67336Smrg dependency_libs= 50440cc67336Smrg case $lib in 50450cc67336Smrg *.la) func_source "$lib" ;; 50460cc67336Smrg esac 50470cc67336Smrg 50480cc67336Smrg # Collect preopened libtool deplibs, except any this library 50490cc67336Smrg # has declared as weak libs 50500cc67336Smrg for deplib in $dependency_libs; do 50510cc67336Smrg deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"` 50520cc67336Smrg case " $weak_libs " in 50530cc67336Smrg *" $deplib_base "*) ;; 50540cc67336Smrg *) deplibs="$deplibs $deplib" ;; 50550cc67336Smrg esac 50560cc67336Smrg done 50570cc67336Smrg done 50580cc67336Smrg libs="$dlprefiles" 50590cc67336Smrg fi 50600cc67336Smrg if test "$pass" = dlopen; then 50610cc67336Smrg # Collect dlpreopened libraries 50620cc67336Smrg save_deplibs="$deplibs" 50630cc67336Smrg deplibs= 50640cc67336Smrg fi 50650cc67336Smrg 50660cc67336Smrg for deplib in $libs; do 50670cc67336Smrg lib= 50680cc67336Smrg found=no 50690cc67336Smrg case $deplib in 50700cc67336Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 50710cc67336Smrg if test "$linkmode,$pass" = "prog,link"; then 50720cc67336Smrg compile_deplibs="$deplib $compile_deplibs" 50730cc67336Smrg finalize_deplibs="$deplib $finalize_deplibs" 50740cc67336Smrg else 50750cc67336Smrg compiler_flags="$compiler_flags $deplib" 50760cc67336Smrg if test "$linkmode" = lib ; then 50770cc67336Smrg case "$new_inherited_linker_flags " in 50780cc67336Smrg *" $deplib "*) ;; 50790cc67336Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; 50800cc67336Smrg esac 50810cc67336Smrg fi 50820cc67336Smrg fi 50830cc67336Smrg continue 50840cc67336Smrg ;; 50850cc67336Smrg -l*) 50860cc67336Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 50870cc67336Smrg func_warning "\`-l' is ignored for archives/objects" 50880cc67336Smrg continue 50890cc67336Smrg fi 50900cc67336Smrg func_stripname '-l' '' "$deplib" 50910cc67336Smrg name=$func_stripname_result 50920cc67336Smrg if test "$linkmode" = lib; then 50930cc67336Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 50940cc67336Smrg else 50950cc67336Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 50960cc67336Smrg fi 50970cc67336Smrg for searchdir in $searchdirs; do 50980cc67336Smrg for search_ext in .la $std_shrext .so .a; do 50990cc67336Smrg # Search the libtool library 51000cc67336Smrg lib="$searchdir/lib${name}${search_ext}" 51010cc67336Smrg if test -f "$lib"; then 51020cc67336Smrg if test "$search_ext" = ".la"; then 51030cc67336Smrg found=yes 51040cc67336Smrg else 51050cc67336Smrg found=no 51060cc67336Smrg fi 51070cc67336Smrg break 2 51080cc67336Smrg fi 51090cc67336Smrg done 51100cc67336Smrg done 51110cc67336Smrg if test "$found" != yes; then 51120cc67336Smrg # deplib doesn't seem to be a libtool library 51130cc67336Smrg if test "$linkmode,$pass" = "prog,link"; then 51140cc67336Smrg compile_deplibs="$deplib $compile_deplibs" 51150cc67336Smrg finalize_deplibs="$deplib $finalize_deplibs" 51160cc67336Smrg else 51170cc67336Smrg deplibs="$deplib $deplibs" 51180cc67336Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 51190cc67336Smrg fi 51200cc67336Smrg continue 51210cc67336Smrg else # deplib is a libtool library 51220cc67336Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 51230cc67336Smrg # We need to do some special things here, and not later. 51240cc67336Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 51250cc67336Smrg case " $predeps $postdeps " in 51260cc67336Smrg *" $deplib "*) 51270cc67336Smrg if func_lalib_p "$lib"; then 51280cc67336Smrg library_names= 51290cc67336Smrg old_library= 51300cc67336Smrg func_source "$lib" 51310cc67336Smrg for l in $old_library $library_names; do 51320cc67336Smrg ll="$l" 51330cc67336Smrg done 51340cc67336Smrg if test "X$ll" = "X$old_library" ; then # only static version available 51350cc67336Smrg found=no 51360cc67336Smrg func_dirname "$lib" "" "." 51370cc67336Smrg ladir="$func_dirname_result" 51380cc67336Smrg lib=$ladir/$old_library 51390cc67336Smrg if test "$linkmode,$pass" = "prog,link"; then 51400cc67336Smrg compile_deplibs="$deplib $compile_deplibs" 51410cc67336Smrg finalize_deplibs="$deplib $finalize_deplibs" 51420cc67336Smrg else 51430cc67336Smrg deplibs="$deplib $deplibs" 51440cc67336Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 51450cc67336Smrg fi 51460cc67336Smrg continue 51470cc67336Smrg fi 51480cc67336Smrg fi 51490cc67336Smrg ;; 51500cc67336Smrg *) ;; 51510cc67336Smrg esac 51520cc67336Smrg fi 51530cc67336Smrg fi 51540cc67336Smrg ;; # -l 51550cc67336Smrg *.ltframework) 51560cc67336Smrg if test "$linkmode,$pass" = "prog,link"; then 51570cc67336Smrg compile_deplibs="$deplib $compile_deplibs" 51580cc67336Smrg finalize_deplibs="$deplib $finalize_deplibs" 51590cc67336Smrg else 51600cc67336Smrg deplibs="$deplib $deplibs" 51610cc67336Smrg if test "$linkmode" = lib ; then 51620cc67336Smrg case "$new_inherited_linker_flags " in 51630cc67336Smrg *" $deplib "*) ;; 51640cc67336Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; 51650cc67336Smrg esac 51660cc67336Smrg fi 51670cc67336Smrg fi 51680cc67336Smrg continue 51690cc67336Smrg ;; 51700cc67336Smrg -L*) 51710cc67336Smrg case $linkmode in 51720cc67336Smrg lib) 51730cc67336Smrg deplibs="$deplib $deplibs" 51740cc67336Smrg test "$pass" = conv && continue 51750cc67336Smrg newdependency_libs="$deplib $newdependency_libs" 51760cc67336Smrg func_stripname '-L' '' "$deplib" 51770cc67336Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 51780cc67336Smrg ;; 51790cc67336Smrg prog) 51800cc67336Smrg if test "$pass" = conv; then 51810cc67336Smrg deplibs="$deplib $deplibs" 51820cc67336Smrg continue 51830cc67336Smrg fi 51840cc67336Smrg if test "$pass" = scan; then 51850cc67336Smrg deplibs="$deplib $deplibs" 51860cc67336Smrg else 51870cc67336Smrg compile_deplibs="$deplib $compile_deplibs" 51880cc67336Smrg finalize_deplibs="$deplib $finalize_deplibs" 51890cc67336Smrg fi 51900cc67336Smrg func_stripname '-L' '' "$deplib" 51910cc67336Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 51920cc67336Smrg ;; 51930cc67336Smrg *) 51940cc67336Smrg func_warning "\`-L' is ignored for archives/objects" 51950cc67336Smrg ;; 51960cc67336Smrg esac # linkmode 51970cc67336Smrg continue 51980cc67336Smrg ;; # -L 51990cc67336Smrg -R*) 52000cc67336Smrg if test "$pass" = link; then 52010cc67336Smrg func_stripname '-R' '' "$deplib" 52020cc67336Smrg dir=$func_stripname_result 52030cc67336Smrg # Make sure the xrpath contains only unique directories. 52040cc67336Smrg case "$xrpath " in 52050cc67336Smrg *" $dir "*) ;; 52060cc67336Smrg *) xrpath="$xrpath $dir" ;; 52070cc67336Smrg esac 52080cc67336Smrg fi 52090cc67336Smrg deplibs="$deplib $deplibs" 52100cc67336Smrg continue 52110cc67336Smrg ;; 52120cc67336Smrg *.la) lib="$deplib" ;; 52130cc67336Smrg *.$libext) 52140cc67336Smrg if test "$pass" = conv; then 52150cc67336Smrg deplibs="$deplib $deplibs" 52160cc67336Smrg continue 52170cc67336Smrg fi 52180cc67336Smrg case $linkmode in 52190cc67336Smrg lib) 52200cc67336Smrg # Linking convenience modules into shared libraries is allowed, 52210cc67336Smrg # but linking other static libraries is non-portable. 52220cc67336Smrg case " $dlpreconveniencelibs " in 52230cc67336Smrg *" $deplib "*) ;; 52240cc67336Smrg *) 52250cc67336Smrg valid_a_lib=no 52260cc67336Smrg case $deplibs_check_method in 52270cc67336Smrg match_pattern*) 52280cc67336Smrg set dummy $deplibs_check_method; shift 52290cc67336Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 52300cc67336Smrg if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \ 52310cc67336Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 52320cc67336Smrg valid_a_lib=yes 52330cc67336Smrg fi 52340cc67336Smrg ;; 52350cc67336Smrg pass_all) 52360cc67336Smrg valid_a_lib=yes 52370cc67336Smrg ;; 52380cc67336Smrg esac 52390cc67336Smrg if test "$valid_a_lib" != yes; then 52400cc67336Smrg $ECHO 52410cc67336Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 52420cc67336Smrg $ECHO "*** I have the capability to make that library automatically link in when" 52430cc67336Smrg $ECHO "*** you link to this library. But I can only do this if you have a" 52440cc67336Smrg $ECHO "*** shared version of the library, which you do not appear to have" 52450cc67336Smrg $ECHO "*** because the file extensions .$libext of this argument makes me believe" 52460cc67336Smrg $ECHO "*** that it is just a static archive that I should not use here." 52470cc67336Smrg else 52480cc67336Smrg $ECHO 52490cc67336Smrg $ECHO "*** Warning: Linking the shared library $output against the" 52500cc67336Smrg $ECHO "*** static library $deplib is not portable!" 52510cc67336Smrg deplibs="$deplib $deplibs" 52520cc67336Smrg fi 52530cc67336Smrg ;; 52540cc67336Smrg esac 52550cc67336Smrg continue 52560cc67336Smrg ;; 52570cc67336Smrg prog) 52580cc67336Smrg if test "$pass" != link; then 52590cc67336Smrg deplibs="$deplib $deplibs" 52600cc67336Smrg else 52610cc67336Smrg compile_deplibs="$deplib $compile_deplibs" 52620cc67336Smrg finalize_deplibs="$deplib $finalize_deplibs" 52630cc67336Smrg fi 52640cc67336Smrg continue 52650cc67336Smrg ;; 52660cc67336Smrg esac # linkmode 52670cc67336Smrg ;; # *.$libext 52680cc67336Smrg *.lo | *.$objext) 52690cc67336Smrg if test "$pass" = conv; then 52700cc67336Smrg deplibs="$deplib $deplibs" 52710cc67336Smrg elif test "$linkmode" = prog; then 52720cc67336Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 52730cc67336Smrg # If there is no dlopen support or we're linking statically, 52740cc67336Smrg # we need to preload. 52750cc67336Smrg newdlprefiles="$newdlprefiles $deplib" 52760cc67336Smrg compile_deplibs="$deplib $compile_deplibs" 52770cc67336Smrg finalize_deplibs="$deplib $finalize_deplibs" 52780cc67336Smrg else 52790cc67336Smrg newdlfiles="$newdlfiles $deplib" 52800cc67336Smrg fi 52810cc67336Smrg fi 52820cc67336Smrg continue 52830cc67336Smrg ;; 52840cc67336Smrg %DEPLIBS%) 52850cc67336Smrg alldeplibs=yes 52860cc67336Smrg continue 52870cc67336Smrg ;; 52880cc67336Smrg esac # case $deplib 52890cc67336Smrg 52900cc67336Smrg if test "$found" = yes || test -f "$lib"; then : 52910cc67336Smrg else 52920cc67336Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 52930cc67336Smrg fi 52940cc67336Smrg 52950cc67336Smrg # Check to see that this really is a libtool archive. 52960cc67336Smrg func_lalib_unsafe_p "$lib" \ 52970cc67336Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 52980cc67336Smrg 52990cc67336Smrg func_dirname "$lib" "" "." 53000cc67336Smrg ladir="$func_dirname_result" 53010cc67336Smrg 53020cc67336Smrg dlname= 53030cc67336Smrg dlopen= 53040cc67336Smrg dlpreopen= 53050cc67336Smrg libdir= 53060cc67336Smrg library_names= 53070cc67336Smrg old_library= 53080cc67336Smrg inherited_linker_flags= 53090cc67336Smrg # If the library was installed with an old release of libtool, 53100cc67336Smrg # it will not redefine variables installed, or shouldnotlink 53110cc67336Smrg installed=yes 53120cc67336Smrg shouldnotlink=no 53130cc67336Smrg avoidtemprpath= 53140cc67336Smrg 53150cc67336Smrg 53160cc67336Smrg # Read the .la file 53170cc67336Smrg func_source "$lib" 53180cc67336Smrg 53190cc67336Smrg # Convert "-framework foo" to "foo.ltframework" 53200cc67336Smrg if test -n "$inherited_linker_flags"; then 53210cc67336Smrg tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'` 53220cc67336Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 53230cc67336Smrg case " $new_inherited_linker_flags " in 53240cc67336Smrg *" $tmp_inherited_linker_flag "*) ;; 53250cc67336Smrg *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; 53260cc67336Smrg esac 53270cc67336Smrg done 53280cc67336Smrg fi 53290cc67336Smrg dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 53300cc67336Smrg if test "$linkmode,$pass" = "lib,link" || 53310cc67336Smrg test "$linkmode,$pass" = "prog,scan" || 53320cc67336Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 53330cc67336Smrg test -n "$dlopen" && dlfiles="$dlfiles $dlopen" 53340cc67336Smrg test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" 53350cc67336Smrg fi 53360cc67336Smrg 53370cc67336Smrg if test "$pass" = conv; then 53380cc67336Smrg # Only check for convenience libraries 53390cc67336Smrg deplibs="$lib $deplibs" 53400cc67336Smrg if test -z "$libdir"; then 53410cc67336Smrg if test -z "$old_library"; then 53420cc67336Smrg func_fatal_error "cannot find name of link library for \`$lib'" 53430cc67336Smrg fi 53440cc67336Smrg # It is a libtool convenience library, so add in its objects. 53450cc67336Smrg convenience="$convenience $ladir/$objdir/$old_library" 53460cc67336Smrg old_convenience="$old_convenience $ladir/$objdir/$old_library" 53470cc67336Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 53480cc67336Smrg func_fatal_error "\`$lib' is not a convenience library" 53490cc67336Smrg fi 53500cc67336Smrg tmp_libs= 53510cc67336Smrg for deplib in $dependency_libs; do 53520cc67336Smrg deplibs="$deplib $deplibs" 53530cc67336Smrg if $opt_duplicate_deps ; then 53540cc67336Smrg case "$tmp_libs " in 53550cc67336Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 53560cc67336Smrg esac 53570cc67336Smrg fi 53580cc67336Smrg tmp_libs="$tmp_libs $deplib" 53590cc67336Smrg done 53600cc67336Smrg continue 53610cc67336Smrg fi # $pass = conv 53620cc67336Smrg 53630cc67336Smrg 53640cc67336Smrg # Get the name of the library we link against. 53650cc67336Smrg linklib= 53660cc67336Smrg for l in $old_library $library_names; do 53670cc67336Smrg linklib="$l" 53680cc67336Smrg done 53690cc67336Smrg if test -z "$linklib"; then 53700cc67336Smrg func_fatal_error "cannot find name of link library for \`$lib'" 53710cc67336Smrg fi 53720cc67336Smrg 53730cc67336Smrg # This library was specified with -dlopen. 53740cc67336Smrg if test "$pass" = dlopen; then 53750cc67336Smrg if test -z "$libdir"; then 53760cc67336Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 53770cc67336Smrg fi 53780cc67336Smrg if test -z "$dlname" || 53790cc67336Smrg test "$dlopen_support" != yes || 53800cc67336Smrg test "$build_libtool_libs" = no; then 53810cc67336Smrg # If there is no dlname, no dlopen support or we're linking 53820cc67336Smrg # statically, we need to preload. We also need to preload any 53830cc67336Smrg # dependent libraries so libltdl's deplib preloader doesn't 53840cc67336Smrg # bomb out in the load deplibs phase. 53850cc67336Smrg dlprefiles="$dlprefiles $lib $dependency_libs" 53860cc67336Smrg else 53870cc67336Smrg newdlfiles="$newdlfiles $lib" 53880cc67336Smrg fi 53890cc67336Smrg continue 53900cc67336Smrg fi # $pass = dlopen 53910cc67336Smrg 53920cc67336Smrg # We need an absolute path. 53930cc67336Smrg case $ladir in 53940cc67336Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 53950cc67336Smrg *) 53960cc67336Smrg abs_ladir=`cd "$ladir" && pwd` 53970cc67336Smrg if test -z "$abs_ladir"; then 53980cc67336Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 53990cc67336Smrg func_warning "passing it literally to the linker, although it might fail" 54000cc67336Smrg abs_ladir="$ladir" 54010cc67336Smrg fi 54020cc67336Smrg ;; 54030cc67336Smrg esac 54040cc67336Smrg func_basename "$lib" 54050cc67336Smrg laname="$func_basename_result" 54060cc67336Smrg 54070cc67336Smrg # Find the relevant object directory and library name. 54080cc67336Smrg if test "X$installed" = Xyes; then 54090cc67336Smrg if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 54100cc67336Smrg func_warning "library \`$lib' was moved." 54110cc67336Smrg dir="$ladir" 54120cc67336Smrg absdir="$abs_ladir" 54130cc67336Smrg libdir="$abs_ladir" 54140cc67336Smrg else 54150cc67336Smrg dir="$libdir" 54160cc67336Smrg absdir="$libdir" 54170cc67336Smrg fi 54180cc67336Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 54190cc67336Smrg else 54200cc67336Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 54210cc67336Smrg dir="$ladir" 54220cc67336Smrg absdir="$abs_ladir" 54230cc67336Smrg # Remove this search path later 54240cc67336Smrg notinst_path="$notinst_path $abs_ladir" 54250cc67336Smrg else 54260cc67336Smrg dir="$ladir/$objdir" 54270cc67336Smrg absdir="$abs_ladir/$objdir" 54280cc67336Smrg # Remove this search path later 54290cc67336Smrg notinst_path="$notinst_path $abs_ladir" 54300cc67336Smrg fi 54310cc67336Smrg fi # $installed = yes 54320cc67336Smrg func_stripname 'lib' '.la' "$laname" 54330cc67336Smrg name=$func_stripname_result 54340cc67336Smrg 54350cc67336Smrg # This library was specified with -dlpreopen. 54360cc67336Smrg if test "$pass" = dlpreopen; then 54370cc67336Smrg if test -z "$libdir" && test "$linkmode" = prog; then 54380cc67336Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 54390cc67336Smrg fi 54400cc67336Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 54410cc67336Smrg # are required to link). 54420cc67336Smrg if test -n "$old_library"; then 54430cc67336Smrg newdlprefiles="$newdlprefiles $dir/$old_library" 54440cc67336Smrg # Keep a list of preopened convenience libraries to check 54450cc67336Smrg # that they are being used correctly in the link pass. 54460cc67336Smrg test -z "$libdir" && \ 54470cc67336Smrg dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" 54480cc67336Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 54490cc67336Smrg elif test -n "$dlname"; then 54500cc67336Smrg newdlprefiles="$newdlprefiles $dir/$dlname" 54510cc67336Smrg else 54520cc67336Smrg newdlprefiles="$newdlprefiles $dir/$linklib" 54530cc67336Smrg fi 54540cc67336Smrg fi # $pass = dlpreopen 54550cc67336Smrg 54560cc67336Smrg if test -z "$libdir"; then 54570cc67336Smrg # Link the convenience library 54580cc67336Smrg if test "$linkmode" = lib; then 54590cc67336Smrg deplibs="$dir/$old_library $deplibs" 54600cc67336Smrg elif test "$linkmode,$pass" = "prog,link"; then 54610cc67336Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 54620cc67336Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 54630cc67336Smrg else 54640cc67336Smrg deplibs="$lib $deplibs" # used for prog,scan pass 54650cc67336Smrg fi 54660cc67336Smrg continue 54670cc67336Smrg fi 54680cc67336Smrg 54690cc67336Smrg 54700cc67336Smrg if test "$linkmode" = prog && test "$pass" != link; then 54710cc67336Smrg newlib_search_path="$newlib_search_path $ladir" 54720cc67336Smrg deplibs="$lib $deplibs" 54730cc67336Smrg 54740cc67336Smrg linkalldeplibs=no 54750cc67336Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 54760cc67336Smrg test "$build_libtool_libs" = no; then 54770cc67336Smrg linkalldeplibs=yes 54780cc67336Smrg fi 54790cc67336Smrg 54800cc67336Smrg tmp_libs= 54810cc67336Smrg for deplib in $dependency_libs; do 54820cc67336Smrg case $deplib in 54830cc67336Smrg -L*) func_stripname '-L' '' "$deplib" 54840cc67336Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 54850cc67336Smrg ;; 54860cc67336Smrg esac 54870cc67336Smrg # Need to link against all dependency_libs? 54880cc67336Smrg if test "$linkalldeplibs" = yes; then 54890cc67336Smrg deplibs="$deplib $deplibs" 54900cc67336Smrg else 54910cc67336Smrg # Need to hardcode shared library paths 54920cc67336Smrg # or/and link against static libraries 54930cc67336Smrg newdependency_libs="$deplib $newdependency_libs" 54940cc67336Smrg fi 54950cc67336Smrg if $opt_duplicate_deps ; then 54960cc67336Smrg case "$tmp_libs " in 54970cc67336Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 54980cc67336Smrg esac 54990cc67336Smrg fi 55000cc67336Smrg tmp_libs="$tmp_libs $deplib" 55010cc67336Smrg done # for deplib 55020cc67336Smrg continue 55030cc67336Smrg fi # $linkmode = prog... 55040cc67336Smrg 55050cc67336Smrg if test "$linkmode,$pass" = "prog,link"; then 55060cc67336Smrg if test -n "$library_names" && 55070cc67336Smrg { { test "$prefer_static_libs" = no || 55080cc67336Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 55090cc67336Smrg test -z "$old_library"; }; then 55100cc67336Smrg # We need to hardcode the library path 55110cc67336Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 55120cc67336Smrg # Make sure the rpath contains only unique directories. 55130cc67336Smrg case "$temp_rpath:" in 55140cc67336Smrg *"$absdir:"*) ;; 55150cc67336Smrg *) temp_rpath="$temp_rpath$absdir:" ;; 55160cc67336Smrg esac 55170cc67336Smrg fi 55180cc67336Smrg 55190cc67336Smrg # Hardcode the library path. 55200cc67336Smrg # Skip directories that are in the system default run-time 55210cc67336Smrg # search path. 55220cc67336Smrg case " $sys_lib_dlsearch_path " in 55230cc67336Smrg *" $absdir "*) ;; 55240cc67336Smrg *) 55250cc67336Smrg case "$compile_rpath " in 55260cc67336Smrg *" $absdir "*) ;; 55270cc67336Smrg *) compile_rpath="$compile_rpath $absdir" 55280cc67336Smrg esac 55290cc67336Smrg ;; 55300cc67336Smrg esac 55310cc67336Smrg case " $sys_lib_dlsearch_path " in 55320cc67336Smrg *" $libdir "*) ;; 55330cc67336Smrg *) 55340cc67336Smrg case "$finalize_rpath " in 55350cc67336Smrg *" $libdir "*) ;; 55360cc67336Smrg *) finalize_rpath="$finalize_rpath $libdir" 55370cc67336Smrg esac 55380cc67336Smrg ;; 55390cc67336Smrg esac 55400cc67336Smrg fi # $linkmode,$pass = prog,link... 55410cc67336Smrg 55420cc67336Smrg if test "$alldeplibs" = yes && 55430cc67336Smrg { test "$deplibs_check_method" = pass_all || 55440cc67336Smrg { test "$build_libtool_libs" = yes && 55450cc67336Smrg test -n "$library_names"; }; }; then 55460cc67336Smrg # We only need to search for static libraries 55470cc67336Smrg continue 55480cc67336Smrg fi 55490cc67336Smrg fi 55500cc67336Smrg 55510cc67336Smrg link_static=no # Whether the deplib will be linked statically 55520cc67336Smrg use_static_libs=$prefer_static_libs 55530cc67336Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 55540cc67336Smrg use_static_libs=no 55550cc67336Smrg fi 55560cc67336Smrg if test -n "$library_names" && 55570cc67336Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 55580cc67336Smrg case $host in 55590cc67336Smrg *cygwin* | *mingw* | *cegcc*) 55600cc67336Smrg # No point in relinking DLLs because paths are not encoded 55610cc67336Smrg notinst_deplibs="$notinst_deplibs $lib" 55620cc67336Smrg need_relink=no 55630cc67336Smrg ;; 55640cc67336Smrg *) 55650cc67336Smrg if test "$installed" = no; then 55660cc67336Smrg notinst_deplibs="$notinst_deplibs $lib" 55670cc67336Smrg need_relink=yes 55680cc67336Smrg fi 55690cc67336Smrg ;; 55700cc67336Smrg esac 55710cc67336Smrg # This is a shared library 55720cc67336Smrg 55730cc67336Smrg # Warn about portability, can't link against -module's on some 55740cc67336Smrg # systems (darwin). Don't bleat about dlopened modules though! 55750cc67336Smrg dlopenmodule="" 55760cc67336Smrg for dlpremoduletest in $dlprefiles; do 55770cc67336Smrg if test "X$dlpremoduletest" = "X$lib"; then 55780cc67336Smrg dlopenmodule="$dlpremoduletest" 55790cc67336Smrg break 55800cc67336Smrg fi 55810cc67336Smrg done 55820cc67336Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 55830cc67336Smrg $ECHO 55840cc67336Smrg if test "$linkmode" = prog; then 55850cc67336Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 55860cc67336Smrg else 55870cc67336Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 55880cc67336Smrg fi 55890cc67336Smrg $ECHO "*** $linklib is not portable!" 55900cc67336Smrg fi 55910cc67336Smrg if test "$linkmode" = lib && 55920cc67336Smrg test "$hardcode_into_libs" = yes; then 55930cc67336Smrg # Hardcode the library path. 55940cc67336Smrg # Skip directories that are in the system default run-time 55950cc67336Smrg # search path. 55960cc67336Smrg case " $sys_lib_dlsearch_path " in 55970cc67336Smrg *" $absdir "*) ;; 55980cc67336Smrg *) 55990cc67336Smrg case "$compile_rpath " in 56000cc67336Smrg *" $absdir "*) ;; 56010cc67336Smrg *) compile_rpath="$compile_rpath $absdir" 56020cc67336Smrg esac 56030cc67336Smrg ;; 56040cc67336Smrg esac 56050cc67336Smrg case " $sys_lib_dlsearch_path " in 56060cc67336Smrg *" $libdir "*) ;; 56070cc67336Smrg *) 56080cc67336Smrg case "$finalize_rpath " in 56090cc67336Smrg *" $libdir "*) ;; 56100cc67336Smrg *) finalize_rpath="$finalize_rpath $libdir" 56110cc67336Smrg esac 56120cc67336Smrg ;; 56130cc67336Smrg esac 56140cc67336Smrg fi 56150cc67336Smrg 56160cc67336Smrg if test -n "$old_archive_from_expsyms_cmds"; then 56170cc67336Smrg # figure out the soname 56180cc67336Smrg set dummy $library_names 56190cc67336Smrg shift 56200cc67336Smrg realname="$1" 56210cc67336Smrg shift 56220cc67336Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 56230cc67336Smrg # use dlname if we got it. it's perfectly good, no? 56240cc67336Smrg if test -n "$dlname"; then 56250cc67336Smrg soname="$dlname" 56260cc67336Smrg elif test -n "$soname_spec"; then 56270cc67336Smrg # bleh windows 56280cc67336Smrg case $host in 56290cc67336Smrg *cygwin* | mingw* | *cegcc*) 56300cc67336Smrg func_arith $current - $age 56310cc67336Smrg major=$func_arith_result 56320cc67336Smrg versuffix="-$major" 56330cc67336Smrg ;; 56340cc67336Smrg esac 56350cc67336Smrg eval soname=\"$soname_spec\" 56360cc67336Smrg else 56370cc67336Smrg soname="$realname" 56380cc67336Smrg fi 56390cc67336Smrg 56400cc67336Smrg # Make a new name for the extract_expsyms_cmds to use 56410cc67336Smrg soroot="$soname" 56420cc67336Smrg func_basename "$soroot" 56430cc67336Smrg soname="$func_basename_result" 56440cc67336Smrg func_stripname 'lib' '.dll' "$soname" 56450cc67336Smrg newlib=libimp-$func_stripname_result.a 56460cc67336Smrg 56470cc67336Smrg # If the library has no export list, then create one now 56480cc67336Smrg if test -f "$output_objdir/$soname-def"; then : 56490cc67336Smrg else 56500cc67336Smrg func_verbose "extracting exported symbol list from \`$soname'" 56510cc67336Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 56520cc67336Smrg fi 56530cc67336Smrg 56540cc67336Smrg # Create $newlib 56550cc67336Smrg if test -f "$output_objdir/$newlib"; then :; else 56560cc67336Smrg func_verbose "generating import library for \`$soname'" 56570cc67336Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 56580cc67336Smrg fi 56590cc67336Smrg # make sure the library variables are pointing to the new library 56600cc67336Smrg dir=$output_objdir 56610cc67336Smrg linklib=$newlib 56620cc67336Smrg fi # test -n "$old_archive_from_expsyms_cmds" 56630cc67336Smrg 56640cc67336Smrg if test "$linkmode" = prog || test "$mode" != relink; then 56650cc67336Smrg add_shlibpath= 56660cc67336Smrg add_dir= 56670cc67336Smrg add= 56680cc67336Smrg lib_linked=yes 56690cc67336Smrg case $hardcode_action in 56700cc67336Smrg immediate | unsupported) 56710cc67336Smrg if test "$hardcode_direct" = no; then 56720cc67336Smrg add="$dir/$linklib" 56730cc67336Smrg case $host in 56740cc67336Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 56750cc67336Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 56760cc67336Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 56770cc67336Smrg *-*-unixware7*) add_dir="-L$dir" ;; 56780cc67336Smrg *-*-darwin* ) 56790cc67336Smrg # if the lib is a (non-dlopened) module then we can not 56800cc67336Smrg # link against it, someone is ignoring the earlier warnings 56810cc67336Smrg if /usr/bin/file -L $add 2> /dev/null | 56820cc67336Smrg $GREP ": [^:]* bundle" >/dev/null ; then 56830cc67336Smrg if test "X$dlopenmodule" != "X$lib"; then 56840cc67336Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 56850cc67336Smrg if test -z "$old_library" ; then 56860cc67336Smrg $ECHO 56870cc67336Smrg $ECHO "*** And there doesn't seem to be a static archive available" 56880cc67336Smrg $ECHO "*** The link will probably fail, sorry" 56890cc67336Smrg else 56900cc67336Smrg add="$dir/$old_library" 56910cc67336Smrg fi 56920cc67336Smrg elif test -n "$old_library"; then 56930cc67336Smrg add="$dir/$old_library" 56940cc67336Smrg fi 56950cc67336Smrg fi 56960cc67336Smrg esac 56970cc67336Smrg elif test "$hardcode_minus_L" = no; then 56980cc67336Smrg case $host in 56990cc67336Smrg *-*-sunos*) add_shlibpath="$dir" ;; 57000cc67336Smrg esac 57010cc67336Smrg add_dir="-L$dir" 57020cc67336Smrg add="-l$name" 57030cc67336Smrg elif test "$hardcode_shlibpath_var" = no; then 57040cc67336Smrg add_shlibpath="$dir" 57050cc67336Smrg add="-l$name" 57060cc67336Smrg else 57070cc67336Smrg lib_linked=no 57080cc67336Smrg fi 57090cc67336Smrg ;; 57100cc67336Smrg relink) 57110cc67336Smrg if test "$hardcode_direct" = yes && 57120cc67336Smrg test "$hardcode_direct_absolute" = no; then 57130cc67336Smrg add="$dir/$linklib" 57140cc67336Smrg elif test "$hardcode_minus_L" = yes; then 57150cc67336Smrg add_dir="-L$dir" 57160cc67336Smrg # Try looking first in the location we're being installed to. 57170cc67336Smrg if test -n "$inst_prefix_dir"; then 57180cc67336Smrg case $libdir in 57190cc67336Smrg [\\/]*) 57200cc67336Smrg add_dir="$add_dir -L$inst_prefix_dir$libdir" 57210cc67336Smrg ;; 57220cc67336Smrg esac 57230cc67336Smrg fi 57240cc67336Smrg add="-l$name" 57250cc67336Smrg elif test "$hardcode_shlibpath_var" = yes; then 57260cc67336Smrg add_shlibpath="$dir" 57270cc67336Smrg add="-l$name" 57280cc67336Smrg else 57290cc67336Smrg lib_linked=no 57300cc67336Smrg fi 57310cc67336Smrg ;; 57320cc67336Smrg *) lib_linked=no ;; 57330cc67336Smrg esac 57340cc67336Smrg 57350cc67336Smrg if test "$lib_linked" != yes; then 57360cc67336Smrg func_fatal_configuration "unsupported hardcode properties" 57370cc67336Smrg fi 57380cc67336Smrg 57390cc67336Smrg if test -n "$add_shlibpath"; then 57400cc67336Smrg case :$compile_shlibpath: in 57410cc67336Smrg *":$add_shlibpath:"*) ;; 57420cc67336Smrg *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; 57430cc67336Smrg esac 57440cc67336Smrg fi 57450cc67336Smrg if test "$linkmode" = prog; then 57460cc67336Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 57470cc67336Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 57480cc67336Smrg else 57490cc67336Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 57500cc67336Smrg test -n "$add" && deplibs="$add $deplibs" 57510cc67336Smrg if test "$hardcode_direct" != yes && 57520cc67336Smrg test "$hardcode_minus_L" != yes && 57530cc67336Smrg test "$hardcode_shlibpath_var" = yes; then 57540cc67336Smrg case :$finalize_shlibpath: in 57550cc67336Smrg *":$libdir:"*) ;; 57560cc67336Smrg *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; 57570cc67336Smrg esac 57580cc67336Smrg fi 57590cc67336Smrg fi 57600cc67336Smrg fi 57610cc67336Smrg 57620cc67336Smrg if test "$linkmode" = prog || test "$mode" = relink; then 57630cc67336Smrg add_shlibpath= 57640cc67336Smrg add_dir= 57650cc67336Smrg add= 57660cc67336Smrg # Finalize command for both is simple: just hardcode it. 57670cc67336Smrg if test "$hardcode_direct" = yes && 57680cc67336Smrg test "$hardcode_direct_absolute" = no; then 57690cc67336Smrg add="$libdir/$linklib" 57700cc67336Smrg elif test "$hardcode_minus_L" = yes; then 57710cc67336Smrg add_dir="-L$libdir" 57720cc67336Smrg add="-l$name" 57730cc67336Smrg elif test "$hardcode_shlibpath_var" = yes; then 57740cc67336Smrg case :$finalize_shlibpath: in 57750cc67336Smrg *":$libdir:"*) ;; 57760cc67336Smrg *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; 57770cc67336Smrg esac 57780cc67336Smrg add="-l$name" 57790cc67336Smrg elif test "$hardcode_automatic" = yes; then 57800cc67336Smrg if test -n "$inst_prefix_dir" && 57810cc67336Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 57820cc67336Smrg add="$inst_prefix_dir$libdir/$linklib" 57830cc67336Smrg else 57840cc67336Smrg add="$libdir/$linklib" 57850cc67336Smrg fi 57860cc67336Smrg else 57870cc67336Smrg # We cannot seem to hardcode it, guess we'll fake it. 57880cc67336Smrg add_dir="-L$libdir" 57890cc67336Smrg # Try looking first in the location we're being installed to. 57900cc67336Smrg if test -n "$inst_prefix_dir"; then 57910cc67336Smrg case $libdir in 57920cc67336Smrg [\\/]*) 57930cc67336Smrg add_dir="$add_dir -L$inst_prefix_dir$libdir" 57940cc67336Smrg ;; 57950cc67336Smrg esac 57960cc67336Smrg fi 57970cc67336Smrg add="-l$name" 57980cc67336Smrg fi 57990cc67336Smrg 58000cc67336Smrg if test "$linkmode" = prog; then 58010cc67336Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 58020cc67336Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 58030cc67336Smrg else 58040cc67336Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 58050cc67336Smrg test -n "$add" && deplibs="$add $deplibs" 58060cc67336Smrg fi 58070cc67336Smrg fi 58080cc67336Smrg elif test "$linkmode" = prog; then 58090cc67336Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 58100cc67336Smrg # is not unsupported. This is valid on all known static and 58110cc67336Smrg # shared platforms. 58120cc67336Smrg if test "$hardcode_direct" != unsupported; then 58130cc67336Smrg test -n "$old_library" && linklib="$old_library" 58140cc67336Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 58150cc67336Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 58160cc67336Smrg else 58170cc67336Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 58180cc67336Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 58190cc67336Smrg fi 58200cc67336Smrg elif test "$build_libtool_libs" = yes; then 58210cc67336Smrg # Not a shared library 58220cc67336Smrg if test "$deplibs_check_method" != pass_all; then 58230cc67336Smrg # We're trying link a shared library against a static one 58240cc67336Smrg # but the system doesn't support it. 58250cc67336Smrg 58260cc67336Smrg # Just print a warning and add the library to dependency_libs so 58270cc67336Smrg # that the program can be linked against the static library. 58280cc67336Smrg $ECHO 58290cc67336Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 58300cc67336Smrg $ECHO "*** I have the capability to make that library automatically link in when" 58310cc67336Smrg $ECHO "*** you link to this library. But I can only do this if you have a" 58320cc67336Smrg $ECHO "*** shared version of the library, which you do not appear to have." 58330cc67336Smrg if test "$module" = yes; then 58340cc67336Smrg $ECHO "*** But as you try to build a module library, libtool will still create " 58350cc67336Smrg $ECHO "*** a static module, that should work as long as the dlopening application" 58360cc67336Smrg $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime." 58370cc67336Smrg if test -z "$global_symbol_pipe"; then 58380cc67336Smrg $ECHO 58390cc67336Smrg $ECHO "*** However, this would only work if libtool was able to extract symbol" 58400cc67336Smrg $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" 58410cc67336Smrg $ECHO "*** not find such a program. So, this module is probably useless." 58420cc67336Smrg $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." 58430cc67336Smrg fi 58440cc67336Smrg if test "$build_old_libs" = no; then 58450cc67336Smrg build_libtool_libs=module 58460cc67336Smrg build_old_libs=yes 58470cc67336Smrg else 58480cc67336Smrg build_libtool_libs=no 58490cc67336Smrg fi 58500cc67336Smrg fi 58510cc67336Smrg else 58520cc67336Smrg deplibs="$dir/$old_library $deplibs" 58530cc67336Smrg link_static=yes 58540cc67336Smrg fi 58550cc67336Smrg fi # link shared/static library? 58560cc67336Smrg 58570cc67336Smrg if test "$linkmode" = lib; then 58580cc67336Smrg if test -n "$dependency_libs" && 58590cc67336Smrg { test "$hardcode_into_libs" != yes || 58600cc67336Smrg test "$build_old_libs" = yes || 58610cc67336Smrg test "$link_static" = yes; }; then 58620cc67336Smrg # Extract -R from dependency_libs 58630cc67336Smrg temp_deplibs= 58640cc67336Smrg for libdir in $dependency_libs; do 58650cc67336Smrg case $libdir in 58660cc67336Smrg -R*) func_stripname '-R' '' "$libdir" 58670cc67336Smrg temp_xrpath=$func_stripname_result 58680cc67336Smrg case " $xrpath " in 58690cc67336Smrg *" $temp_xrpath "*) ;; 58700cc67336Smrg *) xrpath="$xrpath $temp_xrpath";; 58710cc67336Smrg esac;; 58720cc67336Smrg *) temp_deplibs="$temp_deplibs $libdir";; 58730cc67336Smrg esac 58740cc67336Smrg done 58750cc67336Smrg dependency_libs="$temp_deplibs" 58760cc67336Smrg fi 58770cc67336Smrg 58780cc67336Smrg newlib_search_path="$newlib_search_path $absdir" 58790cc67336Smrg # Link against this library 58800cc67336Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 58810cc67336Smrg # ... and its dependency_libs 58820cc67336Smrg tmp_libs= 58830cc67336Smrg for deplib in $dependency_libs; do 58840cc67336Smrg newdependency_libs="$deplib $newdependency_libs" 58850cc67336Smrg if $opt_duplicate_deps ; then 58860cc67336Smrg case "$tmp_libs " in 58870cc67336Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 58880cc67336Smrg esac 58890cc67336Smrg fi 58900cc67336Smrg tmp_libs="$tmp_libs $deplib" 58910cc67336Smrg done 58920cc67336Smrg 58930cc67336Smrg if test "$link_all_deplibs" != no; then 58940cc67336Smrg # Add the search paths of all dependency libraries 58950cc67336Smrg for deplib in $dependency_libs; do 58960cc67336Smrg case $deplib in 58970cc67336Smrg -L*) path="$deplib" ;; 58980cc67336Smrg *.la) 58990cc67336Smrg func_dirname "$deplib" "" "." 59000cc67336Smrg dir="$func_dirname_result" 59010cc67336Smrg # We need an absolute path. 59020cc67336Smrg case $dir in 59030cc67336Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 59040cc67336Smrg *) 59050cc67336Smrg absdir=`cd "$dir" && pwd` 59060cc67336Smrg if test -z "$absdir"; then 59070cc67336Smrg func_warning "cannot determine absolute directory name of \`$dir'" 59080cc67336Smrg absdir="$dir" 59090cc67336Smrg fi 59100cc67336Smrg ;; 59110cc67336Smrg esac 59120cc67336Smrg if $GREP "^installed=no" $deplib > /dev/null; then 59130cc67336Smrg case $host in 59140cc67336Smrg *-*-darwin*) 59150cc67336Smrg depdepl= 59160cc67336Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 59170cc67336Smrg if test -n "$deplibrary_names" ; then 59180cc67336Smrg for tmp in $deplibrary_names ; do 59190cc67336Smrg depdepl=$tmp 59200cc67336Smrg done 59210cc67336Smrg if test -f "$absdir/$objdir/$depdepl" ; then 59220cc67336Smrg depdepl="$absdir/$objdir/$depdepl" 59230cc67336Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 59240cc67336Smrg if test -z "$darwin_install_name"; then 59250cc67336Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 59260cc67336Smrg fi 59270cc67336Smrg compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 59280cc67336Smrg linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" 59290cc67336Smrg path= 59300cc67336Smrg fi 59310cc67336Smrg fi 59320cc67336Smrg ;; 59330cc67336Smrg *) 59340cc67336Smrg path="-L$absdir/$objdir" 59350cc67336Smrg ;; 59360cc67336Smrg esac 59370cc67336Smrg else 59380cc67336Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 59390cc67336Smrg test -z "$libdir" && \ 59400cc67336Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 59410cc67336Smrg test "$absdir" != "$libdir" && \ 59420cc67336Smrg func_warning "\`$deplib' seems to be moved" 59430cc67336Smrg 59440cc67336Smrg path="-L$absdir" 59450cc67336Smrg fi 59460cc67336Smrg ;; 59470cc67336Smrg esac 59480cc67336Smrg case " $deplibs " in 59490cc67336Smrg *" $path "*) ;; 59500cc67336Smrg *) deplibs="$path $deplibs" ;; 59510cc67336Smrg esac 59520cc67336Smrg done 59530cc67336Smrg fi # link_all_deplibs != no 59540cc67336Smrg fi # linkmode = lib 59550cc67336Smrg done # for deplib in $libs 59560cc67336Smrg if test "$pass" = link; then 59570cc67336Smrg if test "$linkmode" = "prog"; then 59580cc67336Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 59590cc67336Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 59600cc67336Smrg else 59610cc67336Smrg compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 59620cc67336Smrg fi 59630cc67336Smrg fi 59640cc67336Smrg dependency_libs="$newdependency_libs" 59650cc67336Smrg if test "$pass" = dlpreopen; then 59660cc67336Smrg # Link the dlpreopened libraries before other libraries 59670cc67336Smrg for deplib in $save_deplibs; do 59680cc67336Smrg deplibs="$deplib $deplibs" 59690cc67336Smrg done 59700cc67336Smrg fi 59710cc67336Smrg if test "$pass" != dlopen; then 59720cc67336Smrg if test "$pass" != conv; then 59730cc67336Smrg # Make sure lib_search_path contains only unique directories. 59740cc67336Smrg lib_search_path= 59750cc67336Smrg for dir in $newlib_search_path; do 59760cc67336Smrg case "$lib_search_path " in 59770cc67336Smrg *" $dir "*) ;; 59780cc67336Smrg *) lib_search_path="$lib_search_path $dir" ;; 59790cc67336Smrg esac 59800cc67336Smrg done 59810cc67336Smrg newlib_search_path= 59820cc67336Smrg fi 59830cc67336Smrg 59840cc67336Smrg if test "$linkmode,$pass" != "prog,link"; then 59850cc67336Smrg vars="deplibs" 59860cc67336Smrg else 59870cc67336Smrg vars="compile_deplibs finalize_deplibs" 59880cc67336Smrg fi 59890cc67336Smrg for var in $vars dependency_libs; do 59900cc67336Smrg # Add libraries to $var in reverse order 59910cc67336Smrg eval tmp_libs=\"\$$var\" 59920cc67336Smrg new_libs= 59930cc67336Smrg for deplib in $tmp_libs; do 59940cc67336Smrg # FIXME: Pedantically, this is the right thing to do, so 59950cc67336Smrg # that some nasty dependency loop isn't accidentally 59960cc67336Smrg # broken: 59970cc67336Smrg #new_libs="$deplib $new_libs" 59980cc67336Smrg # Pragmatically, this seems to cause very few problems in 59990cc67336Smrg # practice: 60000cc67336Smrg case $deplib in 60010cc67336Smrg -L*) new_libs="$deplib $new_libs" ;; 60020cc67336Smrg -R*) ;; 60030cc67336Smrg *) 60040cc67336Smrg # And here is the reason: when a library appears more 60050cc67336Smrg # than once as an explicit dependence of a library, or 60060cc67336Smrg # is implicitly linked in more than once by the 60070cc67336Smrg # compiler, it is considered special, and multiple 60080cc67336Smrg # occurrences thereof are not removed. Compare this 60090cc67336Smrg # with having the same library being listed as a 60100cc67336Smrg # dependency of multiple other libraries: in this case, 60110cc67336Smrg # we know (pedantically, we assume) the library does not 60120cc67336Smrg # need to be listed more than once, so we keep only the 60130cc67336Smrg # last copy. This is not always right, but it is rare 60140cc67336Smrg # enough that we require users that really mean to play 60150cc67336Smrg # such unportable linking tricks to link the library 60160cc67336Smrg # using -Wl,-lname, so that libtool does not consider it 60170cc67336Smrg # for duplicate removal. 60180cc67336Smrg case " $specialdeplibs " in 60190cc67336Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 60200cc67336Smrg *) 60210cc67336Smrg case " $new_libs " in 60220cc67336Smrg *" $deplib "*) ;; 60230cc67336Smrg *) new_libs="$deplib $new_libs" ;; 60240cc67336Smrg esac 60250cc67336Smrg ;; 60260cc67336Smrg esac 60270cc67336Smrg ;; 60280cc67336Smrg esac 60290cc67336Smrg done 60300cc67336Smrg tmp_libs= 60310cc67336Smrg for deplib in $new_libs; do 60320cc67336Smrg case $deplib in 60330cc67336Smrg -L*) 60340cc67336Smrg case " $tmp_libs " in 60350cc67336Smrg *" $deplib "*) ;; 60360cc67336Smrg *) tmp_libs="$tmp_libs $deplib" ;; 60370cc67336Smrg esac 60380cc67336Smrg ;; 60390cc67336Smrg *) tmp_libs="$tmp_libs $deplib" ;; 60400cc67336Smrg esac 60410cc67336Smrg done 60420cc67336Smrg eval $var=\"$tmp_libs\" 60430cc67336Smrg done # for var 60440cc67336Smrg fi 60450cc67336Smrg # Last step: remove runtime libs from dependency_libs 60460cc67336Smrg # (they stay in deplibs) 60470cc67336Smrg tmp_libs= 60480cc67336Smrg for i in $dependency_libs ; do 60490cc67336Smrg case " $predeps $postdeps $compiler_lib_search_path " in 60500cc67336Smrg *" $i "*) 60510cc67336Smrg i="" 60520cc67336Smrg ;; 60530cc67336Smrg esac 60540cc67336Smrg if test -n "$i" ; then 60550cc67336Smrg tmp_libs="$tmp_libs $i" 60560cc67336Smrg fi 60570cc67336Smrg done 60580cc67336Smrg dependency_libs=$tmp_libs 60590cc67336Smrg done # for pass 60600cc67336Smrg if test "$linkmode" = prog; then 60610cc67336Smrg dlfiles="$newdlfiles" 60620cc67336Smrg fi 60630cc67336Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 60640cc67336Smrg dlprefiles="$newdlprefiles" 60650cc67336Smrg fi 60660cc67336Smrg 60670cc67336Smrg case $linkmode in 60680cc67336Smrg oldlib) 60690cc67336Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 60700cc67336Smrg func_warning "\`-dlopen' is ignored for archives" 60710cc67336Smrg fi 60720cc67336Smrg 60730cc67336Smrg case " $deplibs" in 60740cc67336Smrg *\ -l* | *\ -L*) 60750cc67336Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 60760cc67336Smrg esac 60770cc67336Smrg 60780cc67336Smrg test -n "$rpath" && \ 60790cc67336Smrg func_warning "\`-rpath' is ignored for archives" 60800cc67336Smrg 60810cc67336Smrg test -n "$xrpath" && \ 60820cc67336Smrg func_warning "\`-R' is ignored for archives" 60830cc67336Smrg 60840cc67336Smrg test -n "$vinfo" && \ 60850cc67336Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 60860cc67336Smrg 60870cc67336Smrg test -n "$release" && \ 60880cc67336Smrg func_warning "\`-release' is ignored for archives" 60890cc67336Smrg 60900cc67336Smrg test -n "$export_symbols$export_symbols_regex" && \ 60910cc67336Smrg func_warning "\`-export-symbols' is ignored for archives" 60920cc67336Smrg 60930cc67336Smrg # Now set the variables for building old libraries. 60940cc67336Smrg build_libtool_libs=no 60950cc67336Smrg oldlibs="$output" 60960cc67336Smrg objs="$objs$old_deplibs" 60970cc67336Smrg ;; 60980cc67336Smrg 60990cc67336Smrg lib) 61000cc67336Smrg # Make sure we only generate libraries of the form `libNAME.la'. 61010cc67336Smrg case $outputname in 61020cc67336Smrg lib*) 61030cc67336Smrg func_stripname 'lib' '.la' "$outputname" 61040cc67336Smrg name=$func_stripname_result 61050cc67336Smrg eval shared_ext=\"$shrext_cmds\" 61060cc67336Smrg eval libname=\"$libname_spec\" 61070cc67336Smrg ;; 61080cc67336Smrg *) 61090cc67336Smrg test "$module" = no && \ 61100cc67336Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 61110cc67336Smrg 61120cc67336Smrg if test "$need_lib_prefix" != no; then 61130cc67336Smrg # Add the "lib" prefix for modules if required 61140cc67336Smrg func_stripname '' '.la' "$outputname" 61150cc67336Smrg name=$func_stripname_result 61160cc67336Smrg eval shared_ext=\"$shrext_cmds\" 61170cc67336Smrg eval libname=\"$libname_spec\" 61180cc67336Smrg else 61190cc67336Smrg func_stripname '' '.la' "$outputname" 61200cc67336Smrg libname=$func_stripname_result 61210cc67336Smrg fi 61220cc67336Smrg ;; 61230cc67336Smrg esac 61240cc67336Smrg 61250cc67336Smrg if test -n "$objs"; then 61260cc67336Smrg if test "$deplibs_check_method" != pass_all; then 61270cc67336Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 61280cc67336Smrg else 61290cc67336Smrg $ECHO 61300cc67336Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 61310cc67336Smrg $ECHO "*** objects $objs is not portable!" 61320cc67336Smrg libobjs="$libobjs $objs" 61330cc67336Smrg fi 61340cc67336Smrg fi 61350cc67336Smrg 61360cc67336Smrg test "$dlself" != no && \ 61370cc67336Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 61380cc67336Smrg 61390cc67336Smrg set dummy $rpath 61400cc67336Smrg shift 61410cc67336Smrg test "$#" -gt 1 && \ 61420cc67336Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 61430cc67336Smrg 61440cc67336Smrg install_libdir="$1" 61450cc67336Smrg 61460cc67336Smrg oldlibs= 61470cc67336Smrg if test -z "$rpath"; then 61480cc67336Smrg if test "$build_libtool_libs" = yes; then 61490cc67336Smrg # Building a libtool convenience library. 61500cc67336Smrg # Some compilers have problems with a `.al' extension so 61510cc67336Smrg # convenience libraries should have the same extension an 61520cc67336Smrg # archive normally would. 61530cc67336Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 61540cc67336Smrg build_libtool_libs=convenience 61550cc67336Smrg build_old_libs=yes 61560cc67336Smrg fi 61570cc67336Smrg 61580cc67336Smrg test -n "$vinfo" && \ 61590cc67336Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 61600cc67336Smrg 61610cc67336Smrg test -n "$release" && \ 61620cc67336Smrg func_warning "\`-release' is ignored for convenience libraries" 61630cc67336Smrg else 61640cc67336Smrg 61650cc67336Smrg # Parse the version information argument. 61660cc67336Smrg save_ifs="$IFS"; IFS=':' 61670cc67336Smrg set dummy $vinfo 0 0 0 61680cc67336Smrg shift 61690cc67336Smrg IFS="$save_ifs" 61700cc67336Smrg 61710cc67336Smrg test -n "$7" && \ 61720cc67336Smrg func_fatal_help "too many parameters to \`-version-info'" 61730cc67336Smrg 61740cc67336Smrg # convert absolute version numbers to libtool ages 61750cc67336Smrg # this retains compatibility with .la files and attempts 61760cc67336Smrg # to make the code below a bit more comprehensible 61770cc67336Smrg 61780cc67336Smrg case $vinfo_number in 61790cc67336Smrg yes) 61800cc67336Smrg number_major="$1" 61810cc67336Smrg number_minor="$2" 61820cc67336Smrg number_revision="$3" 61830cc67336Smrg # 61840cc67336Smrg # There are really only two kinds -- those that 61850cc67336Smrg # use the current revision as the major version 61860cc67336Smrg # and those that subtract age and use age as 61870cc67336Smrg # a minor version. But, then there is irix 61880cc67336Smrg # which has an extra 1 added just for fun 61890cc67336Smrg # 61900cc67336Smrg case $version_type in 61910cc67336Smrg darwin|linux|osf|windows|none) 61920cc67336Smrg func_arith $number_major + $number_minor 61930cc67336Smrg current=$func_arith_result 61940cc67336Smrg age="$number_minor" 61950cc67336Smrg revision="$number_revision" 61960cc67336Smrg ;; 61970cc67336Smrg freebsd-aout|freebsd-elf|sunos) 61980cc67336Smrg current="$number_major" 61990cc67336Smrg revision="$number_minor" 62000cc67336Smrg age="0" 62010cc67336Smrg ;; 62020cc67336Smrg irix|nonstopux) 62030cc67336Smrg func_arith $number_major + $number_minor 62040cc67336Smrg current=$func_arith_result 62050cc67336Smrg age="$number_minor" 62060cc67336Smrg revision="$number_minor" 62070cc67336Smrg lt_irix_increment=no 62080cc67336Smrg ;; 62090cc67336Smrg esac 62100cc67336Smrg ;; 62110cc67336Smrg no) 62120cc67336Smrg current="$1" 62130cc67336Smrg revision="$2" 62140cc67336Smrg age="$3" 62150cc67336Smrg ;; 62160cc67336Smrg esac 62170cc67336Smrg 62180cc67336Smrg # Check that each of the things are valid numbers. 62190cc67336Smrg case $current in 62200cc67336Smrg 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]) ;; 62210cc67336Smrg *) 62220cc67336Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 62230cc67336Smrg func_fatal_error "\`$vinfo' is not valid version information" 62240cc67336Smrg ;; 62250cc67336Smrg esac 62260cc67336Smrg 62270cc67336Smrg case $revision in 62280cc67336Smrg 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]) ;; 62290cc67336Smrg *) 62300cc67336Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 62310cc67336Smrg func_fatal_error "\`$vinfo' is not valid version information" 62320cc67336Smrg ;; 62330cc67336Smrg esac 62340cc67336Smrg 62350cc67336Smrg case $age in 62360cc67336Smrg 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]) ;; 62370cc67336Smrg *) 62380cc67336Smrg func_error "AGE \`$age' must be a nonnegative integer" 62390cc67336Smrg func_fatal_error "\`$vinfo' is not valid version information" 62400cc67336Smrg ;; 62410cc67336Smrg esac 62420cc67336Smrg 62430cc67336Smrg if test "$age" -gt "$current"; then 62440cc67336Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 62450cc67336Smrg func_fatal_error "\`$vinfo' is not valid version information" 62460cc67336Smrg fi 62470cc67336Smrg 62480cc67336Smrg # Calculate the version variables. 62490cc67336Smrg major= 62500cc67336Smrg versuffix= 62510cc67336Smrg verstring= 62520cc67336Smrg case $version_type in 62530cc67336Smrg none) ;; 62540cc67336Smrg 62550cc67336Smrg darwin) 62560cc67336Smrg # Like Linux, but with the current version available in 62570cc67336Smrg # verstring for coding it into the library header 62580cc67336Smrg func_arith $current - $age 62590cc67336Smrg major=.$func_arith_result 62600cc67336Smrg versuffix="$major.$age.$revision" 62610cc67336Smrg # Darwin ld doesn't like 0 for these options... 62620cc67336Smrg func_arith $current + 1 62630cc67336Smrg minor_current=$func_arith_result 62640cc67336Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 62650cc67336Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 62660cc67336Smrg ;; 62670cc67336Smrg 62680cc67336Smrg freebsd-aout) 62690cc67336Smrg major=".$current" 62700cc67336Smrg versuffix=".$current.$revision"; 62710cc67336Smrg ;; 62720cc67336Smrg 62730cc67336Smrg freebsd-elf) 62740cc67336Smrg major=".$current" 62750cc67336Smrg versuffix=".$current" 62760cc67336Smrg ;; 62770cc67336Smrg 62780cc67336Smrg irix | nonstopux) 62790cc67336Smrg if test "X$lt_irix_increment" = "Xno"; then 62800cc67336Smrg func_arith $current - $age 62810cc67336Smrg else 62820cc67336Smrg func_arith $current - $age + 1 62830cc67336Smrg fi 62840cc67336Smrg major=$func_arith_result 62850cc67336Smrg 62860cc67336Smrg case $version_type in 62870cc67336Smrg nonstopux) verstring_prefix=nonstopux ;; 62880cc67336Smrg *) verstring_prefix=sgi ;; 62890cc67336Smrg esac 62900cc67336Smrg verstring="$verstring_prefix$major.$revision" 62910cc67336Smrg 62920cc67336Smrg # Add in all the interfaces that we are compatible with. 62930cc67336Smrg loop=$revision 62940cc67336Smrg while test "$loop" -ne 0; do 62950cc67336Smrg func_arith $revision - $loop 62960cc67336Smrg iface=$func_arith_result 62970cc67336Smrg func_arith $loop - 1 62980cc67336Smrg loop=$func_arith_result 62990cc67336Smrg verstring="$verstring_prefix$major.$iface:$verstring" 63000cc67336Smrg done 63010cc67336Smrg 63020cc67336Smrg # Before this point, $major must not contain `.'. 63030cc67336Smrg major=.$major 63040cc67336Smrg versuffix="$major.$revision" 63050cc67336Smrg ;; 63060cc67336Smrg 63070cc67336Smrg linux) 63080cc67336Smrg func_arith $current - $age 63090cc67336Smrg major=.$func_arith_result 63100cc67336Smrg versuffix="$major.$age.$revision" 63110cc67336Smrg ;; 63120cc67336Smrg 63130cc67336Smrg osf) 63140cc67336Smrg func_arith $current - $age 63150cc67336Smrg major=.$func_arith_result 63160cc67336Smrg versuffix=".$current.$age.$revision" 63170cc67336Smrg verstring="$current.$age.$revision" 63180cc67336Smrg 63190cc67336Smrg # Add in all the interfaces that we are compatible with. 63200cc67336Smrg loop=$age 63210cc67336Smrg while test "$loop" -ne 0; do 63220cc67336Smrg func_arith $current - $loop 63230cc67336Smrg iface=$func_arith_result 63240cc67336Smrg func_arith $loop - 1 63250cc67336Smrg loop=$func_arith_result 63260cc67336Smrg verstring="$verstring:${iface}.0" 63270cc67336Smrg done 63280cc67336Smrg 63290cc67336Smrg # Make executables depend on our current version. 63300cc67336Smrg verstring="$verstring:${current}.0" 63310cc67336Smrg ;; 63320cc67336Smrg 63330cc67336Smrg qnx) 63340cc67336Smrg major=".$current" 63350cc67336Smrg versuffix=".$current" 63360cc67336Smrg ;; 63370cc67336Smrg 63380cc67336Smrg sunos) 63390cc67336Smrg major=".$current" 63400cc67336Smrg versuffix=".$current.$revision" 63410cc67336Smrg ;; 63420cc67336Smrg 63430cc67336Smrg windows) 63440cc67336Smrg # Use '-' rather than '.', since we only want one 63450cc67336Smrg # extension on DOS 8.3 filesystems. 63460cc67336Smrg func_arith $current - $age 63470cc67336Smrg major=$func_arith_result 63480cc67336Smrg versuffix="-$major" 63490cc67336Smrg ;; 63500cc67336Smrg 63510cc67336Smrg *) 63520cc67336Smrg func_fatal_configuration "unknown library version type \`$version_type'" 63530cc67336Smrg ;; 63540cc67336Smrg esac 63550cc67336Smrg 63560cc67336Smrg # Clear the version info if we defaulted, and they specified a release. 63570cc67336Smrg if test -z "$vinfo" && test -n "$release"; then 63580cc67336Smrg major= 63590cc67336Smrg case $version_type in 63600cc67336Smrg darwin) 63610cc67336Smrg # we can't check for "0.0" in archive_cmds due to quoting 63620cc67336Smrg # problems, so we reset it completely 63630cc67336Smrg verstring= 63640cc67336Smrg ;; 63650cc67336Smrg *) 63660cc67336Smrg verstring="0.0" 63670cc67336Smrg ;; 63680cc67336Smrg esac 63690cc67336Smrg if test "$need_version" = no; then 63700cc67336Smrg versuffix= 63710cc67336Smrg else 63720cc67336Smrg versuffix=".0.0" 63730cc67336Smrg fi 63740cc67336Smrg fi 63750cc67336Smrg 63760cc67336Smrg # Remove version info from name if versioning should be avoided 63770cc67336Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 63780cc67336Smrg major= 63790cc67336Smrg versuffix= 63800cc67336Smrg verstring="" 63810cc67336Smrg fi 63820cc67336Smrg 63830cc67336Smrg # Check to see if the archive will have undefined symbols. 63840cc67336Smrg if test "$allow_undefined" = yes; then 63850cc67336Smrg if test "$allow_undefined_flag" = unsupported; then 63860cc67336Smrg func_warning "undefined symbols not allowed in $host shared libraries" 63870cc67336Smrg build_libtool_libs=no 63880cc67336Smrg build_old_libs=yes 63890cc67336Smrg fi 63900cc67336Smrg else 63910cc67336Smrg # Don't allow undefined symbols. 63920cc67336Smrg allow_undefined_flag="$no_undefined_flag" 63930cc67336Smrg fi 63940cc67336Smrg 63950cc67336Smrg fi 63960cc67336Smrg 63970cc67336Smrg func_generate_dlsyms "$libname" "$libname" "yes" 63980cc67336Smrg libobjs="$libobjs $symfileobj" 63990cc67336Smrg test "X$libobjs" = "X " && libobjs= 64000cc67336Smrg 64010cc67336Smrg if test "$mode" != relink; then 64020cc67336Smrg # Remove our outputs, but don't remove object files since they 64030cc67336Smrg # may have been created when compiling PIC objects. 64040cc67336Smrg removelist= 64050cc67336Smrg tempremovelist=`$ECHO "$output_objdir/*"` 64060cc67336Smrg for p in $tempremovelist; do 64070cc67336Smrg case $p in 64080cc67336Smrg *.$objext | *.gcno) 64090cc67336Smrg ;; 64100cc67336Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 64110cc67336Smrg if test "X$precious_files_regex" != "X"; then 64120cc67336Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 64130cc67336Smrg then 64140cc67336Smrg continue 64150cc67336Smrg fi 64160cc67336Smrg fi 64170cc67336Smrg removelist="$removelist $p" 64180cc67336Smrg ;; 64190cc67336Smrg *) ;; 64200cc67336Smrg esac 64210cc67336Smrg done 64220cc67336Smrg test -n "$removelist" && \ 64230cc67336Smrg func_show_eval "${RM}r \$removelist" 64240cc67336Smrg fi 64250cc67336Smrg 64260cc67336Smrg # Now set the variables for building old libraries. 64270cc67336Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 64280cc67336Smrg oldlibs="$oldlibs $output_objdir/$libname.$libext" 64290cc67336Smrg 64300cc67336Smrg # Transform .lo files to .o files. 64310cc67336Smrg oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` 64320cc67336Smrg fi 64330cc67336Smrg 64340cc67336Smrg # Eliminate all temporary directories. 64350cc67336Smrg #for path in $notinst_path; do 64360cc67336Smrg # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"` 64370cc67336Smrg # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"` 64380cc67336Smrg # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"` 64390cc67336Smrg #done 64400cc67336Smrg 64410cc67336Smrg if test -n "$xrpath"; then 64420cc67336Smrg # If the user specified any rpath flags, then add them. 64430cc67336Smrg temp_xrpath= 64440cc67336Smrg for libdir in $xrpath; do 64450cc67336Smrg temp_xrpath="$temp_xrpath -R$libdir" 64460cc67336Smrg case "$finalize_rpath " in 64470cc67336Smrg *" $libdir "*) ;; 64480cc67336Smrg *) finalize_rpath="$finalize_rpath $libdir" ;; 64490cc67336Smrg esac 64500cc67336Smrg done 64510cc67336Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 64520cc67336Smrg dependency_libs="$temp_xrpath $dependency_libs" 64530cc67336Smrg fi 64540cc67336Smrg fi 64550cc67336Smrg 64560cc67336Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 64570cc67336Smrg old_dlfiles="$dlfiles" 64580cc67336Smrg dlfiles= 64590cc67336Smrg for lib in $old_dlfiles; do 64600cc67336Smrg case " $dlprefiles $dlfiles " in 64610cc67336Smrg *" $lib "*) ;; 64620cc67336Smrg *) dlfiles="$dlfiles $lib" ;; 64630cc67336Smrg esac 64640cc67336Smrg done 64650cc67336Smrg 64660cc67336Smrg # Make sure dlprefiles contains only unique files 64670cc67336Smrg old_dlprefiles="$dlprefiles" 64680cc67336Smrg dlprefiles= 64690cc67336Smrg for lib in $old_dlprefiles; do 64700cc67336Smrg case "$dlprefiles " in 64710cc67336Smrg *" $lib "*) ;; 64720cc67336Smrg *) dlprefiles="$dlprefiles $lib" ;; 64730cc67336Smrg esac 64740cc67336Smrg done 64750cc67336Smrg 64760cc67336Smrg if test "$build_libtool_libs" = yes; then 64770cc67336Smrg if test -n "$rpath"; then 64780cc67336Smrg case $host in 64790cc67336Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*) 64800cc67336Smrg # these systems don't actually have a c library (as such)! 64810cc67336Smrg ;; 64820cc67336Smrg *-*-rhapsody* | *-*-darwin1.[012]) 64830cc67336Smrg # Rhapsody C library is in the System framework 64840cc67336Smrg deplibs="$deplibs System.ltframework" 64850cc67336Smrg ;; 64860cc67336Smrg *-*-netbsd*) 64870cc67336Smrg # Don't link with libc until the a.out ld.so is fixed. 64880cc67336Smrg ;; 64890cc67336Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 64900cc67336Smrg # Do not include libc due to us having libc/libc_r. 64910cc67336Smrg ;; 64920cc67336Smrg *-*-sco3.2v5* | *-*-sco5v6*) 64930cc67336Smrg # Causes problems with __ctype 64940cc67336Smrg ;; 64950cc67336Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 64960cc67336Smrg # Compiler inserts libc in the correct place for threads to work 64970cc67336Smrg ;; 64980cc67336Smrg *) 64990cc67336Smrg # Add libc to deplibs on all other systems if necessary. 65000cc67336Smrg if test "$build_libtool_need_lc" = "yes"; then 65010cc67336Smrg deplibs="$deplibs -lc" 65020cc67336Smrg fi 65030cc67336Smrg ;; 65040cc67336Smrg esac 65050cc67336Smrg fi 65060cc67336Smrg 65070cc67336Smrg # Transform deplibs into only deplibs that can be linked in shared. 65080cc67336Smrg name_save=$name 65090cc67336Smrg libname_save=$libname 65100cc67336Smrg release_save=$release 65110cc67336Smrg versuffix_save=$versuffix 65120cc67336Smrg major_save=$major 65130cc67336Smrg # I'm not sure if I'm treating the release correctly. I think 65140cc67336Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 65150cc67336Smrg # add it in twice. Is that correct? 65160cc67336Smrg release="" 65170cc67336Smrg versuffix="" 65180cc67336Smrg major="" 65190cc67336Smrg newdeplibs= 65200cc67336Smrg droppeddeps=no 65210cc67336Smrg case $deplibs_check_method in 65220cc67336Smrg pass_all) 65230cc67336Smrg # Don't check for shared/static. Everything works. 65240cc67336Smrg # This might be a little naive. We might want to check 65250cc67336Smrg # whether the library exists or not. But this is on 65260cc67336Smrg # osf3 & osf4 and I'm not really sure... Just 65270cc67336Smrg # implementing what was already the behavior. 65280cc67336Smrg newdeplibs=$deplibs 65290cc67336Smrg ;; 65300cc67336Smrg test_compile) 65310cc67336Smrg # This code stresses the "libraries are programs" paradigm to its 65320cc67336Smrg # limits. Maybe even breaks it. We compile a program, linking it 65330cc67336Smrg # against the deplibs as a proxy for the library. Then we can check 65340cc67336Smrg # whether they linked in statically or dynamically with ldd. 65350cc67336Smrg $opt_dry_run || $RM conftest.c 65360cc67336Smrg cat > conftest.c <<EOF 65370cc67336Smrg int main() { return 0; } 65380cc67336SmrgEOF 65390cc67336Smrg $opt_dry_run || $RM conftest 65400cc67336Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 65410cc67336Smrg ldd_output=`ldd conftest` 65420cc67336Smrg for i in $deplibs; do 65430cc67336Smrg case $i in 65440cc67336Smrg -l*) 65450cc67336Smrg func_stripname -l '' "$i" 65460cc67336Smrg name=$func_stripname_result 65470cc67336Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 65480cc67336Smrg case " $predeps $postdeps " in 65490cc67336Smrg *" $i "*) 65500cc67336Smrg newdeplibs="$newdeplibs $i" 65510cc67336Smrg i="" 65520cc67336Smrg ;; 65530cc67336Smrg esac 65540cc67336Smrg fi 65550cc67336Smrg if test -n "$i" ; then 65560cc67336Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 65570cc67336Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 65580cc67336Smrg set dummy $deplib_matches; shift 65590cc67336Smrg deplib_match=$1 65600cc67336Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 65610cc67336Smrg newdeplibs="$newdeplibs $i" 65620cc67336Smrg else 65630cc67336Smrg droppeddeps=yes 65640cc67336Smrg $ECHO 65650cc67336Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 65660cc67336Smrg $ECHO "*** I have the capability to make that library automatically link in when" 65670cc67336Smrg $ECHO "*** you link to this library. But I can only do this if you have a" 65680cc67336Smrg $ECHO "*** shared version of the library, which I believe you do not have" 65690cc67336Smrg $ECHO "*** because a test_compile did reveal that the linker did not use it for" 65700cc67336Smrg $ECHO "*** its dynamic dependency list that programs get resolved with at runtime." 65710cc67336Smrg fi 65720cc67336Smrg fi 65730cc67336Smrg ;; 65740cc67336Smrg *) 65750cc67336Smrg newdeplibs="$newdeplibs $i" 65760cc67336Smrg ;; 65770cc67336Smrg esac 65780cc67336Smrg done 65790cc67336Smrg else 65800cc67336Smrg # Error occurred in the first compile. Let's try to salvage 65810cc67336Smrg # the situation: Compile a separate program for each library. 65820cc67336Smrg for i in $deplibs; do 65830cc67336Smrg case $i in 65840cc67336Smrg -l*) 65850cc67336Smrg func_stripname -l '' "$i" 65860cc67336Smrg name=$func_stripname_result 65870cc67336Smrg $opt_dry_run || $RM conftest 65880cc67336Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 65890cc67336Smrg ldd_output=`ldd conftest` 65900cc67336Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 65910cc67336Smrg case " $predeps $postdeps " in 65920cc67336Smrg *" $i "*) 65930cc67336Smrg newdeplibs="$newdeplibs $i" 65940cc67336Smrg i="" 65950cc67336Smrg ;; 65960cc67336Smrg esac 65970cc67336Smrg fi 65980cc67336Smrg if test -n "$i" ; then 65990cc67336Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 66000cc67336Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 66010cc67336Smrg set dummy $deplib_matches; shift 66020cc67336Smrg deplib_match=$1 66030cc67336Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 66040cc67336Smrg newdeplibs="$newdeplibs $i" 66050cc67336Smrg else 66060cc67336Smrg droppeddeps=yes 66070cc67336Smrg $ECHO 66080cc67336Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 66090cc67336Smrg $ECHO "*** I have the capability to make that library automatically link in when" 66100cc67336Smrg $ECHO "*** you link to this library. But I can only do this if you have a" 66110cc67336Smrg $ECHO "*** shared version of the library, which you do not appear to have" 66120cc67336Smrg $ECHO "*** because a test_compile did reveal that the linker did not use this one" 66130cc67336Smrg $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime." 66140cc67336Smrg fi 66150cc67336Smrg fi 66160cc67336Smrg else 66170cc67336Smrg droppeddeps=yes 66180cc67336Smrg $ECHO 66190cc67336Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 66200cc67336Smrg $ECHO "*** make it link in! You will probably need to install it or some" 66210cc67336Smrg $ECHO "*** library that it depends on before this library will be fully" 66220cc67336Smrg $ECHO "*** functional. Installing it before continuing would be even better." 66230cc67336Smrg fi 66240cc67336Smrg ;; 66250cc67336Smrg *) 66260cc67336Smrg newdeplibs="$newdeplibs $i" 66270cc67336Smrg ;; 66280cc67336Smrg esac 66290cc67336Smrg done 66300cc67336Smrg fi 66310cc67336Smrg ;; 66320cc67336Smrg file_magic*) 66330cc67336Smrg set dummy $deplibs_check_method; shift 66340cc67336Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 66350cc67336Smrg for a_deplib in $deplibs; do 66360cc67336Smrg case $a_deplib in 66370cc67336Smrg -l*) 66380cc67336Smrg func_stripname -l '' "$a_deplib" 66390cc67336Smrg name=$func_stripname_result 66400cc67336Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 66410cc67336Smrg case " $predeps $postdeps " in 66420cc67336Smrg *" $a_deplib "*) 66430cc67336Smrg newdeplibs="$newdeplibs $a_deplib" 66440cc67336Smrg a_deplib="" 66450cc67336Smrg ;; 66460cc67336Smrg esac 66470cc67336Smrg fi 66480cc67336Smrg if test -n "$a_deplib" ; then 66490cc67336Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 66500cc67336Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 66510cc67336Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 66520cc67336Smrg for potent_lib in $potential_libs; do 66530cc67336Smrg # Follow soft links. 66540cc67336Smrg if ls -lLd "$potent_lib" 2>/dev/null | 66550cc67336Smrg $GREP " -> " >/dev/null; then 66560cc67336Smrg continue 66570cc67336Smrg fi 66580cc67336Smrg # The statement above tries to avoid entering an 66590cc67336Smrg # endless loop below, in case of cyclic links. 66600cc67336Smrg # We might still enter an endless loop, since a link 66610cc67336Smrg # loop can be closed while we follow links, 66620cc67336Smrg # but so what? 66630cc67336Smrg potlib="$potent_lib" 66640cc67336Smrg while test -h "$potlib" 2>/dev/null; do 66650cc67336Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 66660cc67336Smrg case $potliblink in 66670cc67336Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 66680cc67336Smrg *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; 66690cc67336Smrg esac 66700cc67336Smrg done 66710cc67336Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 66720cc67336Smrg $SED -e 10q | 66730cc67336Smrg $EGREP "$file_magic_regex" > /dev/null; then 66740cc67336Smrg newdeplibs="$newdeplibs $a_deplib" 66750cc67336Smrg a_deplib="" 66760cc67336Smrg break 2 66770cc67336Smrg fi 66780cc67336Smrg done 66790cc67336Smrg done 66800cc67336Smrg fi 66810cc67336Smrg if test -n "$a_deplib" ; then 66820cc67336Smrg droppeddeps=yes 66830cc67336Smrg $ECHO 66840cc67336Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 66850cc67336Smrg $ECHO "*** I have the capability to make that library automatically link in when" 66860cc67336Smrg $ECHO "*** you link to this library. But I can only do this if you have a" 66870cc67336Smrg $ECHO "*** shared version of the library, which you do not appear to have" 66880cc67336Smrg $ECHO "*** because I did check the linker path looking for a file starting" 66890cc67336Smrg if test -z "$potlib" ; then 66900cc67336Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 66910cc67336Smrg else 66920cc67336Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 66930cc67336Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 66940cc67336Smrg fi 66950cc67336Smrg fi 66960cc67336Smrg ;; 66970cc67336Smrg *) 66980cc67336Smrg # Add a -L argument. 66990cc67336Smrg newdeplibs="$newdeplibs $a_deplib" 67000cc67336Smrg ;; 67010cc67336Smrg esac 67020cc67336Smrg done # Gone through all deplibs. 67030cc67336Smrg ;; 67040cc67336Smrg match_pattern*) 67050cc67336Smrg set dummy $deplibs_check_method; shift 67060cc67336Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 67070cc67336Smrg for a_deplib in $deplibs; do 67080cc67336Smrg case $a_deplib in 67090cc67336Smrg -l*) 67100cc67336Smrg func_stripname -l '' "$a_deplib" 67110cc67336Smrg name=$func_stripname_result 67120cc67336Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 67130cc67336Smrg case " $predeps $postdeps " in 67140cc67336Smrg *" $a_deplib "*) 67150cc67336Smrg newdeplibs="$newdeplibs $a_deplib" 67160cc67336Smrg a_deplib="" 67170cc67336Smrg ;; 67180cc67336Smrg esac 67190cc67336Smrg fi 67200cc67336Smrg if test -n "$a_deplib" ; then 67210cc67336Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 67220cc67336Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 67230cc67336Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 67240cc67336Smrg for potent_lib in $potential_libs; do 67250cc67336Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 67260cc67336Smrg if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \ 67270cc67336Smrg $EGREP "$match_pattern_regex" > /dev/null; then 67280cc67336Smrg newdeplibs="$newdeplibs $a_deplib" 67290cc67336Smrg a_deplib="" 67300cc67336Smrg break 2 67310cc67336Smrg fi 67320cc67336Smrg done 67330cc67336Smrg done 67340cc67336Smrg fi 67350cc67336Smrg if test -n "$a_deplib" ; then 67360cc67336Smrg droppeddeps=yes 67370cc67336Smrg $ECHO 67380cc67336Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 67390cc67336Smrg $ECHO "*** I have the capability to make that library automatically link in when" 67400cc67336Smrg $ECHO "*** you link to this library. But I can only do this if you have a" 67410cc67336Smrg $ECHO "*** shared version of the library, which you do not appear to have" 67420cc67336Smrg $ECHO "*** because I did check the linker path looking for a file starting" 67430cc67336Smrg if test -z "$potlib" ; then 67440cc67336Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 67450cc67336Smrg else 67460cc67336Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 67470cc67336Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 67480cc67336Smrg fi 67490cc67336Smrg fi 67500cc67336Smrg ;; 67510cc67336Smrg *) 67520cc67336Smrg # Add a -L argument. 67530cc67336Smrg newdeplibs="$newdeplibs $a_deplib" 67540cc67336Smrg ;; 67550cc67336Smrg esac 67560cc67336Smrg done # Gone through all deplibs. 67570cc67336Smrg ;; 67580cc67336Smrg none | unknown | *) 67590cc67336Smrg newdeplibs="" 67600cc67336Smrg tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \ 67610cc67336Smrg -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'` 67620cc67336Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 67630cc67336Smrg for i in $predeps $postdeps ; do 67640cc67336Smrg # can't use Xsed below, because $i might contain '/' 67650cc67336Smrg tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"` 67660cc67336Smrg done 67670cc67336Smrg fi 67680cc67336Smrg if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' | 67690cc67336Smrg $GREP . >/dev/null; then 67700cc67336Smrg $ECHO 67710cc67336Smrg if test "X$deplibs_check_method" = "Xnone"; then 67720cc67336Smrg $ECHO "*** Warning: inter-library dependencies are not supported in this platform." 67730cc67336Smrg else 67740cc67336Smrg $ECHO "*** Warning: inter-library dependencies are not known to be supported." 67750cc67336Smrg fi 67760cc67336Smrg $ECHO "*** All declared inter-library dependencies are being dropped." 67770cc67336Smrg droppeddeps=yes 67780cc67336Smrg fi 67790cc67336Smrg ;; 67800cc67336Smrg esac 67810cc67336Smrg versuffix=$versuffix_save 67820cc67336Smrg major=$major_save 67830cc67336Smrg release=$release_save 67840cc67336Smrg libname=$libname_save 67850cc67336Smrg name=$name_save 67860cc67336Smrg 67870cc67336Smrg case $host in 67880cc67336Smrg *-*-rhapsody* | *-*-darwin1.[012]) 67890cc67336Smrg # On Rhapsody replace the C library with the System framework 67900cc67336Smrg newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'` 67910cc67336Smrg ;; 67920cc67336Smrg esac 67930cc67336Smrg 67940cc67336Smrg if test "$droppeddeps" = yes; then 67950cc67336Smrg if test "$module" = yes; then 67960cc67336Smrg $ECHO 67970cc67336Smrg $ECHO "*** Warning: libtool could not satisfy all declared inter-library" 67980cc67336Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 67990cc67336Smrg $ECHO "*** a static module, that should work as long as the dlopening" 68000cc67336Smrg $ECHO "*** application is linked with the -dlopen flag." 68010cc67336Smrg if test -z "$global_symbol_pipe"; then 68020cc67336Smrg $ECHO 68030cc67336Smrg $ECHO "*** However, this would only work if libtool was able to extract symbol" 68040cc67336Smrg $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" 68050cc67336Smrg $ECHO "*** not find such a program. So, this module is probably useless." 68060cc67336Smrg $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." 68070cc67336Smrg fi 68080cc67336Smrg if test "$build_old_libs" = no; then 68090cc67336Smrg oldlibs="$output_objdir/$libname.$libext" 68100cc67336Smrg build_libtool_libs=module 68110cc67336Smrg build_old_libs=yes 68120cc67336Smrg else 68130cc67336Smrg build_libtool_libs=no 68140cc67336Smrg fi 68150cc67336Smrg else 68160cc67336Smrg $ECHO "*** The inter-library dependencies that have been dropped here will be" 68170cc67336Smrg $ECHO "*** automatically added whenever a program is linked with this library" 68180cc67336Smrg $ECHO "*** or is declared to -dlopen it." 68190cc67336Smrg 68200cc67336Smrg if test "$allow_undefined" = no; then 68210cc67336Smrg $ECHO 68220cc67336Smrg $ECHO "*** Since this library must not contain undefined symbols," 68230cc67336Smrg $ECHO "*** because either the platform does not support them or" 68240cc67336Smrg $ECHO "*** it was explicitly requested with -no-undefined," 68250cc67336Smrg $ECHO "*** libtool will only create a static version of it." 68260cc67336Smrg if test "$build_old_libs" = no; then 68270cc67336Smrg oldlibs="$output_objdir/$libname.$libext" 68280cc67336Smrg build_libtool_libs=module 68290cc67336Smrg build_old_libs=yes 68300cc67336Smrg else 68310cc67336Smrg build_libtool_libs=no 68320cc67336Smrg fi 68330cc67336Smrg fi 68340cc67336Smrg fi 68350cc67336Smrg fi 68360cc67336Smrg # Done checking deplibs! 68370cc67336Smrg deplibs=$newdeplibs 68380cc67336Smrg fi 68390cc67336Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 68400cc67336Smrg case $host in 68410cc67336Smrg *-*-darwin*) 68420cc67336Smrg newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 68430cc67336Smrg new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 68440cc67336Smrg deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 68450cc67336Smrg ;; 68460cc67336Smrg esac 68470cc67336Smrg 68480cc67336Smrg # move library search paths that coincide with paths to not yet 68490cc67336Smrg # installed libraries to the beginning of the library search list 68500cc67336Smrg new_libs= 68510cc67336Smrg for path in $notinst_path; do 68520cc67336Smrg case " $new_libs " in 68530cc67336Smrg *" -L$path/$objdir "*) ;; 68540cc67336Smrg *) 68550cc67336Smrg case " $deplibs " in 68560cc67336Smrg *" -L$path/$objdir "*) 68570cc67336Smrg new_libs="$new_libs -L$path/$objdir" ;; 68580cc67336Smrg esac 68590cc67336Smrg ;; 68600cc67336Smrg esac 68610cc67336Smrg done 68620cc67336Smrg for deplib in $deplibs; do 68630cc67336Smrg case $deplib in 68640cc67336Smrg -L*) 68650cc67336Smrg case " $new_libs " in 68660cc67336Smrg *" $deplib "*) ;; 68670cc67336Smrg *) new_libs="$new_libs $deplib" ;; 68680cc67336Smrg esac 68690cc67336Smrg ;; 68700cc67336Smrg *) new_libs="$new_libs $deplib" ;; 68710cc67336Smrg esac 68720cc67336Smrg done 68730cc67336Smrg deplibs="$new_libs" 68740cc67336Smrg 68750cc67336Smrg # All the library-specific variables (install_libdir is set above). 68760cc67336Smrg library_names= 68770cc67336Smrg old_library= 68780cc67336Smrg dlname= 68790cc67336Smrg 68800cc67336Smrg # Test again, we may have decided not to build it any more 68810cc67336Smrg if test "$build_libtool_libs" = yes; then 68820cc67336Smrg if test "$hardcode_into_libs" = yes; then 68830cc67336Smrg # Hardcode the library paths 68840cc67336Smrg hardcode_libdirs= 68850cc67336Smrg dep_rpath= 68860cc67336Smrg rpath="$finalize_rpath" 68870cc67336Smrg test "$mode" != relink && rpath="$compile_rpath$rpath" 68880cc67336Smrg for libdir in $rpath; do 68890cc67336Smrg if test -n "$hardcode_libdir_flag_spec"; then 68900cc67336Smrg if test -n "$hardcode_libdir_separator"; then 68910cc67336Smrg if test -z "$hardcode_libdirs"; then 68920cc67336Smrg hardcode_libdirs="$libdir" 68930cc67336Smrg else 68940cc67336Smrg # Just accumulate the unique libdirs. 68950cc67336Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 68960cc67336Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 68970cc67336Smrg ;; 68980cc67336Smrg *) 68990cc67336Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 69000cc67336Smrg ;; 69010cc67336Smrg esac 69020cc67336Smrg fi 69030cc67336Smrg else 69040cc67336Smrg eval flag=\"$hardcode_libdir_flag_spec\" 69050cc67336Smrg dep_rpath="$dep_rpath $flag" 69060cc67336Smrg fi 69070cc67336Smrg elif test -n "$runpath_var"; then 69080cc67336Smrg case "$perm_rpath " in 69090cc67336Smrg *" $libdir "*) ;; 69100cc67336Smrg *) perm_rpath="$perm_rpath $libdir" ;; 69110cc67336Smrg esac 69120cc67336Smrg fi 69130cc67336Smrg done 69140cc67336Smrg # Substitute the hardcoded libdirs into the rpath. 69150cc67336Smrg if test -n "$hardcode_libdir_separator" && 69160cc67336Smrg test -n "$hardcode_libdirs"; then 69170cc67336Smrg libdir="$hardcode_libdirs" 69180cc67336Smrg if test -n "$hardcode_libdir_flag_spec_ld"; then 69190cc67336Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 69200cc67336Smrg else 69210cc67336Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec\" 69220cc67336Smrg fi 69230cc67336Smrg fi 69240cc67336Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 69250cc67336Smrg # We should set the runpath_var. 69260cc67336Smrg rpath= 69270cc67336Smrg for dir in $perm_rpath; do 69280cc67336Smrg rpath="$rpath$dir:" 69290cc67336Smrg done 69300cc67336Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 69310cc67336Smrg fi 69320cc67336Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 69330cc67336Smrg fi 6934301ea0f4Smrg 69350cc67336Smrg shlibpath="$finalize_shlibpath" 69360cc67336Smrg test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 69370cc67336Smrg if test -n "$shlibpath"; then 69380cc67336Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 69390cc67336Smrg fi 6940301ea0f4Smrg 69410cc67336Smrg # Get the real and link names of the library. 69420cc67336Smrg eval shared_ext=\"$shrext_cmds\" 69430cc67336Smrg eval library_names=\"$library_names_spec\" 69440cc67336Smrg set dummy $library_names 69450cc67336Smrg shift 69460cc67336Smrg realname="$1" 69470cc67336Smrg shift 6948301ea0f4Smrg 69490cc67336Smrg if test -n "$soname_spec"; then 69500cc67336Smrg eval soname=\"$soname_spec\" 69510cc67336Smrg else 69520cc67336Smrg soname="$realname" 69530cc67336Smrg fi 69540cc67336Smrg if test -z "$dlname"; then 69550cc67336Smrg dlname=$soname 69560cc67336Smrg fi 6957301ea0f4Smrg 69580cc67336Smrg lib="$output_objdir/$realname" 69590cc67336Smrg linknames= 69600cc67336Smrg for link 69610cc67336Smrg do 69620cc67336Smrg linknames="$linknames $link" 69630cc67336Smrg done 6964301ea0f4Smrg 69650cc67336Smrg # Use standard objects if they are pic 69660cc67336Smrg test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` 69670cc67336Smrg test "X$libobjs" = "X " && libobjs= 6968301ea0f4Smrg 69690cc67336Smrg delfiles= 69700cc67336Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 69710cc67336Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 69720cc67336Smrg export_symbols="$output_objdir/$libname.uexp" 69730cc67336Smrg delfiles="$delfiles $export_symbols" 69740cc67336Smrg fi 6975301ea0f4Smrg 69760cc67336Smrg orig_export_symbols= 69770cc67336Smrg case $host_os in 69780cc67336Smrg cygwin* | mingw* | cegcc*) 69790cc67336Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 69800cc67336Smrg # exporting using user supplied symfile 69810cc67336Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 69820cc67336Smrg # and it's NOT already a .def file. Must figure out 69830cc67336Smrg # which of the given symbols are data symbols and tag 69840cc67336Smrg # them as such. So, trigger use of export_symbols_cmds. 69850cc67336Smrg # export_symbols gets reassigned inside the "prepare 69860cc67336Smrg # the list of exported symbols" if statement, so the 69870cc67336Smrg # include_expsyms logic still works. 69880cc67336Smrg orig_export_symbols="$export_symbols" 69890cc67336Smrg export_symbols= 69900cc67336Smrg always_export_symbols=yes 69910cc67336Smrg fi 69920cc67336Smrg fi 69930cc67336Smrg ;; 69940cc67336Smrg esac 6995301ea0f4Smrg 69960cc67336Smrg # Prepare the list of exported symbols 69970cc67336Smrg if test -z "$export_symbols"; then 69980cc67336Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 69990cc67336Smrg func_verbose "generating symbol list for \`$libname.la'" 70000cc67336Smrg export_symbols="$output_objdir/$libname.exp" 70010cc67336Smrg $opt_dry_run || $RM $export_symbols 70020cc67336Smrg cmds=$export_symbols_cmds 70030cc67336Smrg save_ifs="$IFS"; IFS='~' 70040cc67336Smrg for cmd in $cmds; do 70050cc67336Smrg IFS="$save_ifs" 70060cc67336Smrg eval cmd=\"$cmd\" 70070cc67336Smrg func_len " $cmd" 70080cc67336Smrg len=$func_len_result 70090cc67336Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 70100cc67336Smrg func_show_eval "$cmd" 'exit $?' 70110cc67336Smrg skipped_export=false 70120cc67336Smrg else 70130cc67336Smrg # The command line is too long to execute in one step. 70140cc67336Smrg func_verbose "using reloadable object file for export list..." 70150cc67336Smrg skipped_export=: 70160cc67336Smrg # Break out early, otherwise skipped_export may be 70170cc67336Smrg # set to false by a later but shorter cmd. 70180cc67336Smrg break 70190cc67336Smrg fi 70200cc67336Smrg done 70210cc67336Smrg IFS="$save_ifs" 70220cc67336Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 70230cc67336Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 70240cc67336Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 70250cc67336Smrg fi 70260cc67336Smrg fi 70270cc67336Smrg fi 7028301ea0f4Smrg 70290cc67336Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 70300cc67336Smrg tmp_export_symbols="$export_symbols" 70310cc67336Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 70320cc67336Smrg $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' 70330cc67336Smrg fi 7034301ea0f4Smrg 70350cc67336Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 70360cc67336Smrg # The given exports_symbols file has to be filtered, so filter it. 70370cc67336Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 70380cc67336Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 70390cc67336Smrg # 's' commands which not all seds can handle. GNU sed should be fine 70400cc67336Smrg # though. Also, the filter scales superlinearly with the number of 70410cc67336Smrg # global variables. join(1) would be nice here, but unfortunately 70420cc67336Smrg # isn't a blessed tool. 70430cc67336Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 70440cc67336Smrg delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" 70450cc67336Smrg export_symbols=$output_objdir/$libname.def 70460cc67336Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 7047301ea0f4Smrg fi 7048301ea0f4Smrg 70490cc67336Smrg tmp_deplibs= 70500cc67336Smrg for test_deplib in $deplibs; do 70510cc67336Smrg case " $convenience " in 70520cc67336Smrg *" $test_deplib "*) ;; 70530cc67336Smrg *) 70540cc67336Smrg tmp_deplibs="$tmp_deplibs $test_deplib" 70550cc67336Smrg ;; 70560cc67336Smrg esac 70570cc67336Smrg done 70580cc67336Smrg deplibs="$tmp_deplibs" 7059301ea0f4Smrg 70600cc67336Smrg if test -n "$convenience"; then 70610cc67336Smrg if test -n "$whole_archive_flag_spec" && 70620cc67336Smrg test "$compiler_needs_object" = yes && 70630cc67336Smrg test -z "$libobjs"; then 70640cc67336Smrg # extract the archives, so we have objects to list. 70650cc67336Smrg # TODO: could optimize this to just extract one archive. 70660cc67336Smrg whole_archive_flag_spec= 70670cc67336Smrg fi 70680cc67336Smrg if test -n "$whole_archive_flag_spec"; then 70690cc67336Smrg save_libobjs=$libobjs 70700cc67336Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 70710cc67336Smrg test "X$libobjs" = "X " && libobjs= 70720cc67336Smrg else 70730cc67336Smrg gentop="$output_objdir/${outputname}x" 70740cc67336Smrg generated="$generated $gentop" 7075301ea0f4Smrg 70760cc67336Smrg func_extract_archives $gentop $convenience 70770cc67336Smrg libobjs="$libobjs $func_extract_archives_result" 70780cc67336Smrg test "X$libobjs" = "X " && libobjs= 70790cc67336Smrg fi 70800cc67336Smrg fi 7081301ea0f4Smrg 70820cc67336Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 70830cc67336Smrg eval flag=\"$thread_safe_flag_spec\" 70840cc67336Smrg linker_flags="$linker_flags $flag" 70850cc67336Smrg fi 7086301ea0f4Smrg 70870cc67336Smrg # Make a backup of the uninstalled library when relinking 70880cc67336Smrg if test "$mode" = relink; then 70890cc67336Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 7090301ea0f4Smrg fi 7091301ea0f4Smrg 70920cc67336Smrg # Do each of the archive commands. 70930cc67336Smrg if test "$module" = yes && test -n "$module_cmds" ; then 70940cc67336Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 70950cc67336Smrg eval test_cmds=\"$module_expsym_cmds\" 70960cc67336Smrg cmds=$module_expsym_cmds 70970cc67336Smrg else 70980cc67336Smrg eval test_cmds=\"$module_cmds\" 70990cc67336Smrg cmds=$module_cmds 71000cc67336Smrg fi 71010cc67336Smrg else 71020cc67336Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 71030cc67336Smrg eval test_cmds=\"$archive_expsym_cmds\" 71040cc67336Smrg cmds=$archive_expsym_cmds 71050cc67336Smrg else 71060cc67336Smrg eval test_cmds=\"$archive_cmds\" 71070cc67336Smrg cmds=$archive_cmds 71080cc67336Smrg fi 7109301ea0f4Smrg fi 7110301ea0f4Smrg 71110cc67336Smrg if test "X$skipped_export" != "X:" && 71120cc67336Smrg func_len " $test_cmds" && 71130cc67336Smrg len=$func_len_result && 71140cc67336Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 71150cc67336Smrg : 71160cc67336Smrg else 71170cc67336Smrg # The command line is too long to link in one step, link piecewise 71180cc67336Smrg # or, if using GNU ld and skipped_export is not :, use a linker 71190cc67336Smrg # script. 7120301ea0f4Smrg 71210cc67336Smrg # Save the value of $output and $libobjs because we want to 71220cc67336Smrg # use them later. If we have whole_archive_flag_spec, we 71230cc67336Smrg # want to use save_libobjs as it was before 71240cc67336Smrg # whole_archive_flag_spec was expanded, because we can't 71250cc67336Smrg # assume the linker understands whole_archive_flag_spec. 71260cc67336Smrg # This may have to be revisited, in case too many 71270cc67336Smrg # convenience libraries get linked in and end up exceeding 71280cc67336Smrg # the spec. 71290cc67336Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 71300cc67336Smrg save_libobjs=$libobjs 71310cc67336Smrg fi 71320cc67336Smrg save_output=$output 71330cc67336Smrg output_la=`$ECHO "X$output" | $Xsed -e "$basename"` 7134301ea0f4Smrg 71350cc67336Smrg # Clear the reloadable object creation command queue and 71360cc67336Smrg # initialize k to one. 71370cc67336Smrg test_cmds= 71380cc67336Smrg concat_cmds= 71390cc67336Smrg objlist= 71400cc67336Smrg last_robj= 71410cc67336Smrg k=1 7142301ea0f4Smrg 71430cc67336Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 71440cc67336Smrg output=${output_objdir}/${output_la}.lnkscript 71450cc67336Smrg func_verbose "creating GNU ld script: $output" 71460cc67336Smrg $ECHO 'INPUT (' > $output 71470cc67336Smrg for obj in $save_libobjs 71480cc67336Smrg do 71490cc67336Smrg $ECHO "$obj" >> $output 71500cc67336Smrg done 71510cc67336Smrg $ECHO ')' >> $output 71520cc67336Smrg delfiles="$delfiles $output" 71530cc67336Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 71540cc67336Smrg output=${output_objdir}/${output_la}.lnk 71550cc67336Smrg func_verbose "creating linker input file list: $output" 71560cc67336Smrg : > $output 71570cc67336Smrg set x $save_libobjs 71580cc67336Smrg shift 71590cc67336Smrg firstobj= 71600cc67336Smrg if test "$compiler_needs_object" = yes; then 71610cc67336Smrg firstobj="$1 " 71620cc67336Smrg shift 71630cc67336Smrg fi 71640cc67336Smrg for obj 71650cc67336Smrg do 71660cc67336Smrg $ECHO "$obj" >> $output 71670cc67336Smrg done 71680cc67336Smrg delfiles="$delfiles $output" 71690cc67336Smrg output=$firstobj\"$file_list_spec$output\" 71700cc67336Smrg else 71710cc67336Smrg if test -n "$save_libobjs"; then 71720cc67336Smrg func_verbose "creating reloadable object files..." 71730cc67336Smrg output=$output_objdir/$output_la-${k}.$objext 71740cc67336Smrg eval test_cmds=\"$reload_cmds\" 71750cc67336Smrg func_len " $test_cmds" 71760cc67336Smrg len0=$func_len_result 71770cc67336Smrg len=$len0 71780cc67336Smrg 71790cc67336Smrg # Loop over the list of objects to be linked. 71800cc67336Smrg for obj in $save_libobjs 71810cc67336Smrg do 71820cc67336Smrg func_len " $obj" 71830cc67336Smrg func_arith $len + $func_len_result 71840cc67336Smrg len=$func_arith_result 71850cc67336Smrg if test "X$objlist" = X || 71860cc67336Smrg test "$len" -lt "$max_cmd_len"; then 71870cc67336Smrg func_append objlist " $obj" 71880cc67336Smrg else 71890cc67336Smrg # The command $test_cmds is almost too long, add a 71900cc67336Smrg # command to the queue. 71910cc67336Smrg if test "$k" -eq 1 ; then 71920cc67336Smrg # The first file doesn't have a previous command to add. 71930cc67336Smrg eval concat_cmds=\"$reload_cmds $objlist $last_robj\" 71940cc67336Smrg else 71950cc67336Smrg # All subsequent reloadable object files will link in 71960cc67336Smrg # the last one created. 71970cc67336Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\" 71980cc67336Smrg fi 71990cc67336Smrg last_robj=$output_objdir/$output_la-${k}.$objext 72000cc67336Smrg func_arith $k + 1 72010cc67336Smrg k=$func_arith_result 72020cc67336Smrg output=$output_objdir/$output_la-${k}.$objext 72030cc67336Smrg objlist=$obj 72040cc67336Smrg func_len " $last_robj" 72050cc67336Smrg func_arith $len0 + $func_len_result 72060cc67336Smrg len=$func_arith_result 72070cc67336Smrg fi 72080cc67336Smrg done 72090cc67336Smrg # Handle the remaining objects by creating one last 72100cc67336Smrg # reloadable object file. All subsequent reloadable object 72110cc67336Smrg # files will link in the last one created. 72120cc67336Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 72130cc67336Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" 72140cc67336Smrg if test -n "$last_robj"; then 72150cc67336Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 72160cc67336Smrg fi 72170cc67336Smrg delfiles="$delfiles $output" 7218301ea0f4Smrg 72190cc67336Smrg else 72200cc67336Smrg output= 72210cc67336Smrg fi 7222301ea0f4Smrg 72230cc67336Smrg if ${skipped_export-false}; then 72240cc67336Smrg func_verbose "generating symbol list for \`$libname.la'" 72250cc67336Smrg export_symbols="$output_objdir/$libname.exp" 72260cc67336Smrg $opt_dry_run || $RM $export_symbols 72270cc67336Smrg libobjs=$output 72280cc67336Smrg # Append the command to create the export file. 72290cc67336Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 72300cc67336Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 72310cc67336Smrg if test -n "$last_robj"; then 72320cc67336Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 72330cc67336Smrg fi 72340cc67336Smrg fi 7235301ea0f4Smrg 72360cc67336Smrg test -n "$save_libobjs" && 72370cc67336Smrg func_verbose "creating a temporary reloadable object file: $output" 7238301ea0f4Smrg 72390cc67336Smrg # Loop through the commands generated above and execute them. 72400cc67336Smrg save_ifs="$IFS"; IFS='~' 72410cc67336Smrg for cmd in $concat_cmds; do 72420cc67336Smrg IFS="$save_ifs" 72430cc67336Smrg $opt_silent || { 72440cc67336Smrg func_quote_for_expand "$cmd" 72450cc67336Smrg eval "func_echo $func_quote_for_expand_result" 72460cc67336Smrg } 72470cc67336Smrg $opt_dry_run || eval "$cmd" || { 72480cc67336Smrg lt_exit=$? 72490cc67336Smrg 72500cc67336Smrg # Restore the uninstalled library and exit 72510cc67336Smrg if test "$mode" = relink; then 72520cc67336Smrg ( cd "$output_objdir" && \ 72530cc67336Smrg $RM "${realname}T" && \ 72540cc67336Smrg $MV "${realname}U" "$realname" ) 72550cc67336Smrg fi 7256301ea0f4Smrg 72570cc67336Smrg exit $lt_exit 72580cc67336Smrg } 72590cc67336Smrg done 72600cc67336Smrg IFS="$save_ifs" 72610cc67336Smrg 72620cc67336Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 72630cc67336Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 72640cc67336Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 7265301ea0f4Smrg fi 7266301ea0f4Smrg fi 7267301ea0f4Smrg 72680cc67336Smrg if ${skipped_export-false}; then 72690cc67336Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 72700cc67336Smrg tmp_export_symbols="$export_symbols" 72710cc67336Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 72720cc67336Smrg $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' 72730cc67336Smrg fi 7274301ea0f4Smrg 72750cc67336Smrg if test -n "$orig_export_symbols"; then 72760cc67336Smrg # The given exports_symbols file has to be filtered, so filter it. 72770cc67336Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 72780cc67336Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 72790cc67336Smrg # 's' commands which not all seds can handle. GNU sed should be fine 72800cc67336Smrg # though. Also, the filter scales superlinearly with the number of 72810cc67336Smrg # global variables. join(1) would be nice here, but unfortunately 72820cc67336Smrg # isn't a blessed tool. 72830cc67336Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 72840cc67336Smrg delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" 72850cc67336Smrg export_symbols=$output_objdir/$libname.def 72860cc67336Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 72870cc67336Smrg fi 72880cc67336Smrg fi 7289301ea0f4Smrg 72900cc67336Smrg libobjs=$output 72910cc67336Smrg # Restore the value of output. 72920cc67336Smrg output=$save_output 7293301ea0f4Smrg 72940cc67336Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 72950cc67336Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 72960cc67336Smrg test "X$libobjs" = "X " && libobjs= 72970cc67336Smrg fi 72980cc67336Smrg # Expand the library linking commands again to reset the 72990cc67336Smrg # value of $libobjs for piecewise linking. 73000cc67336Smrg 73010cc67336Smrg # Do each of the archive commands. 73020cc67336Smrg if test "$module" = yes && test -n "$module_cmds" ; then 73030cc67336Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 73040cc67336Smrg cmds=$module_expsym_cmds 7305301ea0f4Smrg else 73060cc67336Smrg cmds=$module_cmds 7307301ea0f4Smrg fi 7308301ea0f4Smrg else 73090cc67336Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 73100cc67336Smrg cmds=$archive_expsym_cmds 73110cc67336Smrg else 73120cc67336Smrg cmds=$archive_cmds 73130cc67336Smrg fi 7314301ea0f4Smrg fi 7315301ea0f4Smrg fi 7316301ea0f4Smrg 73170cc67336Smrg if test -n "$delfiles"; then 73180cc67336Smrg # Append the command to remove temporary files to $cmds. 73190cc67336Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 73200cc67336Smrg fi 7321301ea0f4Smrg 73220cc67336Smrg # Add any objects from preloaded convenience libraries 73230cc67336Smrg if test -n "$dlprefiles"; then 73240cc67336Smrg gentop="$output_objdir/${outputname}x" 73250cc67336Smrg generated="$generated $gentop" 7326301ea0f4Smrg 73270cc67336Smrg func_extract_archives $gentop $dlprefiles 73280cc67336Smrg libobjs="$libobjs $func_extract_archives_result" 73290cc67336Smrg test "X$libobjs" = "X " && libobjs= 7330301ea0f4Smrg fi 7331301ea0f4Smrg 73320cc67336Smrg save_ifs="$IFS"; IFS='~' 73330cc67336Smrg for cmd in $cmds; do 73340cc67336Smrg IFS="$save_ifs" 73350cc67336Smrg eval cmd=\"$cmd\" 73360cc67336Smrg $opt_silent || { 73370cc67336Smrg func_quote_for_expand "$cmd" 73380cc67336Smrg eval "func_echo $func_quote_for_expand_result" 73390cc67336Smrg } 73400cc67336Smrg $opt_dry_run || eval "$cmd" || { 73410cc67336Smrg lt_exit=$? 7342301ea0f4Smrg 73430cc67336Smrg # Restore the uninstalled library and exit 73440cc67336Smrg if test "$mode" = relink; then 73450cc67336Smrg ( cd "$output_objdir" && \ 73460cc67336Smrg $RM "${realname}T" && \ 73470cc67336Smrg $MV "${realname}U" "$realname" ) 73480cc67336Smrg fi 73490cc67336Smrg 73500cc67336Smrg exit $lt_exit 73510cc67336Smrg } 73520cc67336Smrg done 73530cc67336Smrg IFS="$save_ifs" 73540cc67336Smrg 73550cc67336Smrg # Restore the uninstalled library and exit 73560cc67336Smrg if test "$mode" = relink; then 73570cc67336Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 73580cc67336Smrg 73590cc67336Smrg if test -n "$convenience"; then 73600cc67336Smrg if test -z "$whole_archive_flag_spec"; then 73610cc67336Smrg func_show_eval '${RM}r "$gentop"' 7362301ea0f4Smrg fi 7363301ea0f4Smrg fi 7364301ea0f4Smrg 73650cc67336Smrg exit $EXIT_SUCCESS 73660cc67336Smrg fi 7367301ea0f4Smrg 73680cc67336Smrg # Create links to the real library. 73690cc67336Smrg for linkname in $linknames; do 73700cc67336Smrg if test "$realname" != "$linkname"; then 73710cc67336Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 73720cc67336Smrg fi 73730cc67336Smrg done 73740cc67336Smrg 73750cc67336Smrg # If -module or -export-dynamic was specified, set the dlname. 73760cc67336Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 73770cc67336Smrg # On all known operating systems, these are identical. 73780cc67336Smrg dlname="$soname" 73790cc67336Smrg fi 73800cc67336Smrg fi 73810cc67336Smrg ;; 73820cc67336Smrg 73830cc67336Smrg obj) 73840cc67336Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 73850cc67336Smrg func_warning "\`-dlopen' is ignored for objects" 73860cc67336Smrg fi 73870cc67336Smrg 73880cc67336Smrg case " $deplibs" in 73890cc67336Smrg *\ -l* | *\ -L*) 73900cc67336Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 73910cc67336Smrg esac 73920cc67336Smrg 73930cc67336Smrg test -n "$rpath" && \ 73940cc67336Smrg func_warning "\`-rpath' is ignored for objects" 73950cc67336Smrg 73960cc67336Smrg test -n "$xrpath" && \ 73970cc67336Smrg func_warning "\`-R' is ignored for objects" 73980cc67336Smrg 73990cc67336Smrg test -n "$vinfo" && \ 74000cc67336Smrg func_warning "\`-version-info' is ignored for objects" 74010cc67336Smrg 74020cc67336Smrg test -n "$release" && \ 74030cc67336Smrg func_warning "\`-release' is ignored for objects" 74040cc67336Smrg 74050cc67336Smrg case $output in 74060cc67336Smrg *.lo) 74070cc67336Smrg test -n "$objs$old_deplibs" && \ 74080cc67336Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 74090cc67336Smrg 74100cc67336Smrg libobj=$output 74110cc67336Smrg func_lo2o "$libobj" 74120cc67336Smrg obj=$func_lo2o_result 74130cc67336Smrg ;; 74140cc67336Smrg *) 74150cc67336Smrg libobj= 74160cc67336Smrg obj="$output" 74170cc67336Smrg ;; 74180cc67336Smrg esac 74190cc67336Smrg 74200cc67336Smrg # Delete the old objects. 74210cc67336Smrg $opt_dry_run || $RM $obj $libobj 74220cc67336Smrg 74230cc67336Smrg # Objects from convenience libraries. This assumes 74240cc67336Smrg # single-version convenience libraries. Whenever we create 74250cc67336Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 74260cc67336Smrg # the extraction. 74270cc67336Smrg reload_conv_objs= 74280cc67336Smrg gentop= 74290cc67336Smrg # reload_cmds runs $LD directly, so let us get rid of 74300cc67336Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 74310cc67336Smrg # turning comma into space.. 74320cc67336Smrg wl= 74330cc67336Smrg 74340cc67336Smrg if test -n "$convenience"; then 74350cc67336Smrg if test -n "$whole_archive_flag_spec"; then 74360cc67336Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 74370cc67336Smrg reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` 74380cc67336Smrg else 74390cc67336Smrg gentop="$output_objdir/${obj}x" 74400cc67336Smrg generated="$generated $gentop" 74410cc67336Smrg 74420cc67336Smrg func_extract_archives $gentop $convenience 74430cc67336Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 74440cc67336Smrg fi 74450cc67336Smrg fi 7446301ea0f4Smrg 74470cc67336Smrg # Create the old-style object. 74480cc67336Smrg reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 7449301ea0f4Smrg 74500cc67336Smrg output="$obj" 74510cc67336Smrg func_execute_cmds "$reload_cmds" 'exit $?' 7452301ea0f4Smrg 74530cc67336Smrg # Exit if we aren't doing a library object file. 74540cc67336Smrg if test -z "$libobj"; then 74550cc67336Smrg if test -n "$gentop"; then 74560cc67336Smrg func_show_eval '${RM}r "$gentop"' 74570cc67336Smrg fi 7458301ea0f4Smrg 74590cc67336Smrg exit $EXIT_SUCCESS 74600cc67336Smrg fi 7461301ea0f4Smrg 74620cc67336Smrg if test "$build_libtool_libs" != yes; then 74630cc67336Smrg if test -n "$gentop"; then 74640cc67336Smrg func_show_eval '${RM}r "$gentop"' 74650cc67336Smrg fi 7466301ea0f4Smrg 74670cc67336Smrg # Create an invalid libtool object if no PIC, so that we don't 74680cc67336Smrg # accidentally link it into a program. 74690cc67336Smrg # $show "echo timestamp > $libobj" 74700cc67336Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 74710cc67336Smrg exit $EXIT_SUCCESS 74720cc67336Smrg fi 7473301ea0f4Smrg 74740cc67336Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 74750cc67336Smrg # Only do commands if we really have different PIC objects. 74760cc67336Smrg reload_objs="$libobjs $reload_conv_objs" 74770cc67336Smrg output="$libobj" 74780cc67336Smrg func_execute_cmds "$reload_cmds" 'exit $?' 7479301ea0f4Smrg fi 7480301ea0f4Smrg 74810cc67336Smrg if test -n "$gentop"; then 74820cc67336Smrg func_show_eval '${RM}r "$gentop"' 74830cc67336Smrg fi 7484301ea0f4Smrg 74850cc67336Smrg exit $EXIT_SUCCESS 74860cc67336Smrg ;; 7487301ea0f4Smrg 74880cc67336Smrg prog) 74890cc67336Smrg case $host in 74900cc67336Smrg *cygwin*) func_stripname '' '.exe' "$output" 74910cc67336Smrg output=$func_stripname_result.exe;; 7492301ea0f4Smrg esac 74930cc67336Smrg test -n "$vinfo" && \ 74940cc67336Smrg func_warning "\`-version-info' is ignored for programs" 7495301ea0f4Smrg 74960cc67336Smrg test -n "$release" && \ 74970cc67336Smrg func_warning "\`-release' is ignored for programs" 7498301ea0f4Smrg 74990cc67336Smrg test "$preload" = yes \ 75000cc67336Smrg && test "$dlopen_support" = unknown \ 75010cc67336Smrg && test "$dlopen_self" = unknown \ 75020cc67336Smrg && test "$dlopen_self_static" = unknown && \ 75030cc67336Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 7504301ea0f4Smrg 75050cc67336Smrg case $host in 75060cc67336Smrg *-*-rhapsody* | *-*-darwin1.[012]) 75070cc67336Smrg # On Rhapsody replace the C library is the System framework 75080cc67336Smrg compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` 75090cc67336Smrg finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` 7510301ea0f4Smrg ;; 7511301ea0f4Smrg esac 7512301ea0f4Smrg 75130cc67336Smrg case $host in 75140cc67336Smrg *-*-darwin*) 75150cc67336Smrg # Don't allow lazy linking, it breaks C++ global constructors 75160cc67336Smrg # But is supposedly fixed on 10.4 or later (yay!). 75170cc67336Smrg if test "$tagname" = CXX ; then 75180cc67336Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 75190cc67336Smrg 10.[0123]) 75200cc67336Smrg compile_command="$compile_command ${wl}-bind_at_load" 75210cc67336Smrg finalize_command="$finalize_command ${wl}-bind_at_load" 75220cc67336Smrg ;; 75230cc67336Smrg esac 75240cc67336Smrg fi 75250cc67336Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 75260cc67336Smrg compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 75270cc67336Smrg finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 7528301ea0f4Smrg ;; 7529301ea0f4Smrg esac 7530301ea0f4Smrg 7531301ea0f4Smrg 75320cc67336Smrg # move library search paths that coincide with paths to not yet 75330cc67336Smrg # installed libraries to the beginning of the library search list 75340cc67336Smrg new_libs= 75350cc67336Smrg for path in $notinst_path; do 75360cc67336Smrg case " $new_libs " in 75370cc67336Smrg *" -L$path/$objdir "*) ;; 7538301ea0f4Smrg *) 75390cc67336Smrg case " $compile_deplibs " in 75400cc67336Smrg *" -L$path/$objdir "*) 75410cc67336Smrg new_libs="$new_libs -L$path/$objdir" ;; 75420cc67336Smrg esac 7543301ea0f4Smrg ;; 7544301ea0f4Smrg esac 7545301ea0f4Smrg done 75460cc67336Smrg for deplib in $compile_deplibs; do 75470cc67336Smrg case $deplib in 75480cc67336Smrg -L*) 75490cc67336Smrg case " $new_libs " in 75500cc67336Smrg *" $deplib "*) ;; 75510cc67336Smrg *) new_libs="$new_libs $deplib" ;; 75520cc67336Smrg esac 75530cc67336Smrg ;; 75540cc67336Smrg *) new_libs="$new_libs $deplib" ;; 75550cc67336Smrg esac 75560cc67336Smrg done 75570cc67336Smrg compile_deplibs="$new_libs" 7558301ea0f4Smrg 7559301ea0f4Smrg 75600cc67336Smrg compile_command="$compile_command $compile_deplibs" 75610cc67336Smrg finalize_command="$finalize_command $finalize_deplibs" 7562301ea0f4Smrg 75630cc67336Smrg if test -n "$rpath$xrpath"; then 75640cc67336Smrg # If the user specified any rpath flags, then add them. 75650cc67336Smrg for libdir in $rpath $xrpath; do 75660cc67336Smrg # This is the magic to use -rpath. 75670cc67336Smrg case "$finalize_rpath " in 75680cc67336Smrg *" $libdir "*) ;; 75690cc67336Smrg *) finalize_rpath="$finalize_rpath $libdir" ;; 75700cc67336Smrg esac 75710cc67336Smrg done 75720cc67336Smrg fi 7573301ea0f4Smrg 75740cc67336Smrg # Now hardcode the library paths 75750cc67336Smrg rpath= 75760cc67336Smrg hardcode_libdirs= 75770cc67336Smrg for libdir in $compile_rpath $finalize_rpath; do 75780cc67336Smrg if test -n "$hardcode_libdir_flag_spec"; then 75790cc67336Smrg if test -n "$hardcode_libdir_separator"; then 75800cc67336Smrg if test -z "$hardcode_libdirs"; then 75810cc67336Smrg hardcode_libdirs="$libdir" 75820cc67336Smrg else 75830cc67336Smrg # Just accumulate the unique libdirs. 75840cc67336Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 75850cc67336Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 75860cc67336Smrg ;; 75870cc67336Smrg *) 75880cc67336Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 75890cc67336Smrg ;; 75900cc67336Smrg esac 75910cc67336Smrg fi 75920cc67336Smrg else 75930cc67336Smrg eval flag=\"$hardcode_libdir_flag_spec\" 75940cc67336Smrg rpath="$rpath $flag" 75950cc67336Smrg fi 75960cc67336Smrg elif test -n "$runpath_var"; then 75970cc67336Smrg case "$perm_rpath " in 7598301ea0f4Smrg *" $libdir "*) ;; 75990cc67336Smrg *) perm_rpath="$perm_rpath $libdir" ;; 7600301ea0f4Smrg esac 76010cc67336Smrg fi 76020cc67336Smrg case $host in 76030cc67336Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 76040cc67336Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 76050cc67336Smrg case :$dllsearchpath: in 76060cc67336Smrg *":$libdir:"*) ;; 76070cc67336Smrg ::) dllsearchpath=$libdir;; 76080cc67336Smrg *) dllsearchpath="$dllsearchpath:$libdir";; 76090cc67336Smrg esac 76100cc67336Smrg case :$dllsearchpath: in 76110cc67336Smrg *":$testbindir:"*) ;; 76120cc67336Smrg ::) dllsearchpath=$testbindir;; 76130cc67336Smrg *) dllsearchpath="$dllsearchpath:$testbindir";; 76140cc67336Smrg esac 76150cc67336Smrg ;; 76160cc67336Smrg esac 76170cc67336Smrg done 76180cc67336Smrg # Substitute the hardcoded libdirs into the rpath. 76190cc67336Smrg if test -n "$hardcode_libdir_separator" && 76200cc67336Smrg test -n "$hardcode_libdirs"; then 76210cc67336Smrg libdir="$hardcode_libdirs" 76220cc67336Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 76230cc67336Smrg fi 76240cc67336Smrg compile_rpath="$rpath" 76250cc67336Smrg 76260cc67336Smrg rpath= 76270cc67336Smrg hardcode_libdirs= 76280cc67336Smrg for libdir in $finalize_rpath; do 76290cc67336Smrg if test -n "$hardcode_libdir_flag_spec"; then 76300cc67336Smrg if test -n "$hardcode_libdir_separator"; then 76310cc67336Smrg if test -z "$hardcode_libdirs"; then 76320cc67336Smrg hardcode_libdirs="$libdir" 76330cc67336Smrg else 76340cc67336Smrg # Just accumulate the unique libdirs. 76350cc67336Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 76360cc67336Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 76370cc67336Smrg ;; 76380cc67336Smrg *) 76390cc67336Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 76400cc67336Smrg ;; 76410cc67336Smrg esac 76420cc67336Smrg fi 76430cc67336Smrg else 76440cc67336Smrg eval flag=\"$hardcode_libdir_flag_spec\" 76450cc67336Smrg rpath="$rpath $flag" 76460cc67336Smrg fi 76470cc67336Smrg elif test -n "$runpath_var"; then 76480cc67336Smrg case "$finalize_perm_rpath " in 7649301ea0f4Smrg *" $libdir "*) ;; 76500cc67336Smrg *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; 7651301ea0f4Smrg esac 7652301ea0f4Smrg fi 76530cc67336Smrg done 76540cc67336Smrg # Substitute the hardcoded libdirs into the rpath. 76550cc67336Smrg if test -n "$hardcode_libdir_separator" && 76560cc67336Smrg test -n "$hardcode_libdirs"; then 76570cc67336Smrg libdir="$hardcode_libdirs" 76580cc67336Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 76590cc67336Smrg fi 76600cc67336Smrg finalize_rpath="$rpath" 7661301ea0f4Smrg 76620cc67336Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 76630cc67336Smrg # Transform all the library objects into standard objects. 76640cc67336Smrg compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` 76650cc67336Smrg finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` 76660cc67336Smrg fi 7667301ea0f4Smrg 76680cc67336Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 7669301ea0f4Smrg 76700cc67336Smrg # template prelinking step 76710cc67336Smrg if test -n "$prelink_cmds"; then 76720cc67336Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 76730cc67336Smrg fi 7674301ea0f4Smrg 76750cc67336Smrg wrappers_required=yes 76760cc67336Smrg case $host in 76770cc67336Smrg *cygwin* | *mingw* ) 76780cc67336Smrg if test "$build_libtool_libs" != yes; then 76790cc67336Smrg wrappers_required=no 76800cc67336Smrg fi 76810cc67336Smrg ;; 76820cc67336Smrg *cegcc) 76830cc67336Smrg # Disable wrappers for cegcc, we are cross compiling anyway. 76840cc67336Smrg wrappers_required=no 76850cc67336Smrg ;; 76860cc67336Smrg *) 76870cc67336Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 76880cc67336Smrg wrappers_required=no 76890cc67336Smrg fi 76900cc67336Smrg ;; 76910cc67336Smrg esac 76920cc67336Smrg if test "$wrappers_required" = no; then 76930cc67336Smrg # Replace the output file specification. 76940cc67336Smrg compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` 76950cc67336Smrg link_command="$compile_command$compile_rpath" 7696301ea0f4Smrg 76970cc67336Smrg # We have no uninstalled library dependencies, so finalize right now. 76980cc67336Smrg exit_status=0 76990cc67336Smrg func_show_eval "$link_command" 'exit_status=$?' 7700301ea0f4Smrg 77010cc67336Smrg # Delete the generated files. 77020cc67336Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 77030cc67336Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 77040cc67336Smrg fi 7705301ea0f4Smrg 77060cc67336Smrg exit $exit_status 77070cc67336Smrg fi 7708301ea0f4Smrg 77090cc67336Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 77100cc67336Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 77110cc67336Smrg fi 77120cc67336Smrg if test -n "$finalize_shlibpath"; then 77130cc67336Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 77140cc67336Smrg fi 7715301ea0f4Smrg 77160cc67336Smrg compile_var= 77170cc67336Smrg finalize_var= 77180cc67336Smrg if test -n "$runpath_var"; then 77190cc67336Smrg if test -n "$perm_rpath"; then 77200cc67336Smrg # We should set the runpath_var. 77210cc67336Smrg rpath= 77220cc67336Smrg for dir in $perm_rpath; do 77230cc67336Smrg rpath="$rpath$dir:" 7724301ea0f4Smrg done 77250cc67336Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 7726301ea0f4Smrg fi 77270cc67336Smrg if test -n "$finalize_perm_rpath"; then 77280cc67336Smrg # We should set the runpath_var. 77290cc67336Smrg rpath= 77300cc67336Smrg for dir in $finalize_perm_rpath; do 77310cc67336Smrg rpath="$rpath$dir:" 77320cc67336Smrg done 77330cc67336Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 77340cc67336Smrg fi 77350cc67336Smrg fi 7736301ea0f4Smrg 77370cc67336Smrg if test "$no_install" = yes; then 77380cc67336Smrg # We don't need to create a wrapper script. 77390cc67336Smrg link_command="$compile_var$compile_command$compile_rpath" 77400cc67336Smrg # Replace the output file specification. 77410cc67336Smrg link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` 77420cc67336Smrg # Delete the old output file. 77430cc67336Smrg $opt_dry_run || $RM $output 77440cc67336Smrg # Link the executable and exit 77450cc67336Smrg func_show_eval "$link_command" 'exit $?' 77460cc67336Smrg exit $EXIT_SUCCESS 77470cc67336Smrg fi 7748301ea0f4Smrg 77490cc67336Smrg if test "$hardcode_action" = relink; then 77500cc67336Smrg # Fast installation is not supported 77510cc67336Smrg link_command="$compile_var$compile_command$compile_rpath" 77520cc67336Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 7753301ea0f4Smrg 77540cc67336Smrg func_warning "this platform does not like uninstalled shared libraries" 77550cc67336Smrg func_warning "\`$output' will be relinked during installation" 77560cc67336Smrg else 77570cc67336Smrg if test "$fast_install" != no; then 77580cc67336Smrg link_command="$finalize_var$compile_command$finalize_rpath" 77590cc67336Smrg if test "$fast_install" = yes; then 77600cc67336Smrg relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` 77610cc67336Smrg else 77620cc67336Smrg # fast_install is set to needless 77630cc67336Smrg relink_command= 77640cc67336Smrg fi 7765301ea0f4Smrg else 77660cc67336Smrg link_command="$compile_var$compile_command$compile_rpath" 77670cc67336Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 7768301ea0f4Smrg fi 77690cc67336Smrg fi 7770301ea0f4Smrg 77710cc67336Smrg # Replace the output file specification. 77720cc67336Smrg link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 7773301ea0f4Smrg 77740cc67336Smrg # Delete the old output files. 77750cc67336Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 7776301ea0f4Smrg 77770cc67336Smrg func_show_eval "$link_command" 'exit $?' 7778301ea0f4Smrg 77790cc67336Smrg # Now create the wrapper script. 77800cc67336Smrg func_verbose "creating $output" 7781301ea0f4Smrg 77820cc67336Smrg # Quote the relink command for shipping. 77830cc67336Smrg if test -n "$relink_command"; then 77840cc67336Smrg # Preserve any variables that may affect compiler behavior 77850cc67336Smrg for var in $variables_saved_for_relink; do 77860cc67336Smrg if eval test -z \"\${$var+set}\"; then 77870cc67336Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 77880cc67336Smrg elif eval var_value=\$$var; test -z "$var_value"; then 77890cc67336Smrg relink_command="$var=; export $var; $relink_command" 77900cc67336Smrg else 77910cc67336Smrg func_quote_for_eval "$var_value" 77920cc67336Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 77930cc67336Smrg fi 77940cc67336Smrg done 77950cc67336Smrg relink_command="(cd `pwd`; $relink_command)" 77960cc67336Smrg relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` 77970cc67336Smrg fi 7798301ea0f4Smrg 77990cc67336Smrg # Quote $ECHO for shipping. 78000cc67336Smrg if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then 78010cc67336Smrg case $progpath in 78020cc67336Smrg [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; 78030cc67336Smrg *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; 7804301ea0f4Smrg esac 78050cc67336Smrg qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"` 78060cc67336Smrg else 78070cc67336Smrg qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"` 78080cc67336Smrg fi 7809301ea0f4Smrg 78100cc67336Smrg # Only actually do things if not in dry run mode. 78110cc67336Smrg $opt_dry_run || { 78120cc67336Smrg # win32 will think the script is a binary if it has 78130cc67336Smrg # a .exe suffix, so we strip it off here. 78140cc67336Smrg case $output in 78150cc67336Smrg *.exe) func_stripname '' '.exe' "$output" 78160cc67336Smrg output=$func_stripname_result ;; 78170cc67336Smrg esac 78180cc67336Smrg # test for cygwin because mv fails w/o .exe extensions 7819301ea0f4Smrg case $host in 78200cc67336Smrg *cygwin*) 78210cc67336Smrg exeext=.exe 78220cc67336Smrg func_stripname '' '.exe' "$outputname" 78230cc67336Smrg outputname=$func_stripname_result ;; 78240cc67336Smrg *) exeext= ;; 7825301ea0f4Smrg esac 78260cc67336Smrg case $host in 78270cc67336Smrg *cygwin* | *mingw* ) 78280cc67336Smrg func_dirname_and_basename "$output" "" "." 78290cc67336Smrg output_name=$func_basename_result 78300cc67336Smrg output_path=$func_dirname_result 78310cc67336Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 78320cc67336Smrg cwrapper="$output_path/$output_name.exe" 78330cc67336Smrg $RM $cwrappersource $cwrapper 78340cc67336Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 78350cc67336Smrg 78360cc67336Smrg func_emit_cwrapperexe_src > $cwrappersource 78370cc67336Smrg 78380cc67336Smrg # The wrapper executable is built using the $host compiler, 78390cc67336Smrg # because it contains $host paths and files. If cross- 78400cc67336Smrg # compiling, it, like the target executable, must be 78410cc67336Smrg # executed on the $host or under an emulation environment. 78420cc67336Smrg $opt_dry_run || { 78430cc67336Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 78440cc67336Smrg $STRIP $cwrapper 78450cc67336Smrg } 7846301ea0f4Smrg 78470cc67336Smrg # Now, create the wrapper script for func_source use: 78480cc67336Smrg func_ltwrapper_scriptname $cwrapper 78490cc67336Smrg $RM $func_ltwrapper_scriptname_result 78500cc67336Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 78510cc67336Smrg $opt_dry_run || { 78520cc67336Smrg # note: this script will not be executed, so do not chmod. 78530cc67336Smrg if test "x$build" = "x$host" ; then 78540cc67336Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 7855301ea0f4Smrg else 78560cc67336Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 7857301ea0f4Smrg fi 78580cc67336Smrg } 78590cc67336Smrg ;; 78600cc67336Smrg * ) 78610cc67336Smrg $RM $output 78620cc67336Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 7863301ea0f4Smrg 78640cc67336Smrg func_emit_wrapper no > $output 78650cc67336Smrg chmod +x $output 7866301ea0f4Smrg ;; 7867301ea0f4Smrg esac 78680cc67336Smrg } 78690cc67336Smrg exit $EXIT_SUCCESS 78700cc67336Smrg ;; 78710cc67336Smrg esac 7872301ea0f4Smrg 78730cc67336Smrg # See if we need to build an old-fashioned archive. 78740cc67336Smrg for oldlib in $oldlibs; do 7875301ea0f4Smrg 78760cc67336Smrg if test "$build_libtool_libs" = convenience; then 78770cc67336Smrg oldobjs="$libobjs_save $symfileobj" 78780cc67336Smrg addlibs="$convenience" 78790cc67336Smrg build_libtool_libs=no 78800cc67336Smrg else 78810cc67336Smrg if test "$build_libtool_libs" = module; then 78820cc67336Smrg oldobjs="$libobjs_save" 78830cc67336Smrg build_libtool_libs=no 78840cc67336Smrg else 78850cc67336Smrg oldobjs="$old_deplibs $non_pic_objects" 78860cc67336Smrg if test "$preload" = yes && test -f "$symfileobj"; then 78870cc67336Smrg oldobjs="$oldobjs $symfileobj" 78880cc67336Smrg fi 78890cc67336Smrg fi 78900cc67336Smrg addlibs="$old_convenience" 7891301ea0f4Smrg fi 7892301ea0f4Smrg 78930cc67336Smrg if test -n "$addlibs"; then 78940cc67336Smrg gentop="$output_objdir/${outputname}x" 78950cc67336Smrg generated="$generated $gentop" 7896301ea0f4Smrg 78970cc67336Smrg func_extract_archives $gentop $addlibs 78980cc67336Smrg oldobjs="$oldobjs $func_extract_archives_result" 78990cc67336Smrg fi 7900301ea0f4Smrg 79010cc67336Smrg # Do each command in the archive commands. 79020cc67336Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 79030cc67336Smrg cmds=$old_archive_from_new_cmds 79040cc67336Smrg else 7905301ea0f4Smrg 79060cc67336Smrg # Add any objects from preloaded convenience libraries 79070cc67336Smrg if test -n "$dlprefiles"; then 79080cc67336Smrg gentop="$output_objdir/${outputname}x" 79090cc67336Smrg generated="$generated $gentop" 7910301ea0f4Smrg 79110cc67336Smrg func_extract_archives $gentop $dlprefiles 79120cc67336Smrg oldobjs="$oldobjs $func_extract_archives_result" 79130cc67336Smrg fi 7914301ea0f4Smrg 79150cc67336Smrg # POSIX demands no paths to be encoded in archives. We have 79160cc67336Smrg # to avoid creating archives with duplicate basenames if we 79170cc67336Smrg # might have to extract them afterwards, e.g., when creating a 79180cc67336Smrg # static archive out of a convenience library, or when linking 79190cc67336Smrg # the entirety of a libtool archive into another (currently 79200cc67336Smrg # not supported by libtool). 79210cc67336Smrg if (for obj in $oldobjs 79220cc67336Smrg do 79230cc67336Smrg func_basename "$obj" 79240cc67336Smrg $ECHO "$func_basename_result" 79250cc67336Smrg done | sort | sort -uc >/dev/null 2>&1); then 79260cc67336Smrg : 79270cc67336Smrg else 79280cc67336Smrg $ECHO "copying selected object files to avoid basename conflicts..." 79290cc67336Smrg gentop="$output_objdir/${outputname}x" 79300cc67336Smrg generated="$generated $gentop" 79310cc67336Smrg func_mkdir_p "$gentop" 79320cc67336Smrg save_oldobjs=$oldobjs 79330cc67336Smrg oldobjs= 79340cc67336Smrg counter=1 79350cc67336Smrg for obj in $save_oldobjs 79360cc67336Smrg do 79370cc67336Smrg func_basename "$obj" 79380cc67336Smrg objbase="$func_basename_result" 79390cc67336Smrg case " $oldobjs " in 79400cc67336Smrg " ") oldobjs=$obj ;; 79410cc67336Smrg *[\ /]"$objbase "*) 79420cc67336Smrg while :; do 79430cc67336Smrg # Make sure we don't pick an alternate name that also 79440cc67336Smrg # overlaps. 79450cc67336Smrg newobj=lt$counter-$objbase 79460cc67336Smrg func_arith $counter + 1 79470cc67336Smrg counter=$func_arith_result 79480cc67336Smrg case " $oldobjs " in 79490cc67336Smrg *[\ /]"$newobj "*) ;; 79500cc67336Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 79510cc67336Smrg esac 79520cc67336Smrg done 79530cc67336Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 79540cc67336Smrg oldobjs="$oldobjs $gentop/$newobj" 79550cc67336Smrg ;; 79560cc67336Smrg *) oldobjs="$oldobjs $obj" ;; 79570cc67336Smrg esac 7958301ea0f4Smrg done 7959301ea0f4Smrg fi 79600cc67336Smrg eval cmds=\"$old_archive_cmds\" 7961301ea0f4Smrg 79620cc67336Smrg func_len " $cmds" 79630cc67336Smrg len=$func_len_result 79640cc67336Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 79650cc67336Smrg cmds=$old_archive_cmds 79660cc67336Smrg else 79670cc67336Smrg # the command line is too long to link in one step, link in parts 79680cc67336Smrg func_verbose "using piecewise archive linking..." 79690cc67336Smrg save_RANLIB=$RANLIB 79700cc67336Smrg RANLIB=: 79710cc67336Smrg objlist= 79720cc67336Smrg concat_cmds= 79730cc67336Smrg save_oldobjs=$oldobjs 79740cc67336Smrg oldobjs= 79750cc67336Smrg # Is there a better way of finding the last object in the list? 79760cc67336Smrg for obj in $save_oldobjs 79770cc67336Smrg do 79780cc67336Smrg last_oldobj=$obj 79790cc67336Smrg done 79800cc67336Smrg eval test_cmds=\"$old_archive_cmds\" 79810cc67336Smrg func_len " $test_cmds" 79820cc67336Smrg len0=$func_len_result 79830cc67336Smrg len=$len0 79840cc67336Smrg for obj in $save_oldobjs 79850cc67336Smrg do 79860cc67336Smrg func_len " $obj" 79870cc67336Smrg func_arith $len + $func_len_result 79880cc67336Smrg len=$func_arith_result 79890cc67336Smrg func_append objlist " $obj" 79900cc67336Smrg if test "$len" -lt "$max_cmd_len"; then 79910cc67336Smrg : 79920cc67336Smrg else 79930cc67336Smrg # the above command should be used before it gets too long 79940cc67336Smrg oldobjs=$objlist 79950cc67336Smrg if test "$obj" = "$last_oldobj" ; then 79960cc67336Smrg RANLIB=$save_RANLIB 79970cc67336Smrg fi 79980cc67336Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 79990cc67336Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 80000cc67336Smrg objlist= 80010cc67336Smrg len=$len0 80020cc67336Smrg fi 80030cc67336Smrg done 80040cc67336Smrg RANLIB=$save_RANLIB 80050cc67336Smrg oldobjs=$objlist 80060cc67336Smrg if test "X$oldobjs" = "X" ; then 80070cc67336Smrg eval cmds=\"\$concat_cmds\" 80080cc67336Smrg else 80090cc67336Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 80100cc67336Smrg fi 80110cc67336Smrg fi 80120cc67336Smrg fi 80130cc67336Smrg func_execute_cmds "$cmds" 'exit $?' 8014301ea0f4Smrg done 8015301ea0f4Smrg 80160cc67336Smrg test -n "$generated" && \ 80170cc67336Smrg func_show_eval "${RM}r$generated" 8018301ea0f4Smrg 80190cc67336Smrg # Now create the libtool archive. 80200cc67336Smrg case $output in 80210cc67336Smrg *.la) 80220cc67336Smrg old_library= 80230cc67336Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 80240cc67336Smrg func_verbose "creating $output" 8025301ea0f4Smrg 80260cc67336Smrg # Preserve any variables that may affect compiler behavior 80270cc67336Smrg for var in $variables_saved_for_relink; do 80280cc67336Smrg if eval test -z \"\${$var+set}\"; then 80290cc67336Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 80300cc67336Smrg elif eval var_value=\$$var; test -z "$var_value"; then 80310cc67336Smrg relink_command="$var=; export $var; $relink_command" 8032301ea0f4Smrg else 80330cc67336Smrg func_quote_for_eval "$var_value" 80340cc67336Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 8035301ea0f4Smrg fi 80360cc67336Smrg done 80370cc67336Smrg # Quote the link command for shipping. 80380cc67336Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 80390cc67336Smrg relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` 80400cc67336Smrg if test "$hardcode_automatic" = yes ; then 80410cc67336Smrg relink_command= 80420cc67336Smrg fi 8043301ea0f4Smrg 80440cc67336Smrg # Only create the output if not a dry run. 80450cc67336Smrg $opt_dry_run || { 80460cc67336Smrg for installed in no yes; do 80470cc67336Smrg if test "$installed" = yes; then 80480cc67336Smrg if test -z "$install_libdir"; then 80490cc67336Smrg break 80500cc67336Smrg fi 80510cc67336Smrg output="$output_objdir/$outputname"i 80520cc67336Smrg # Replace all uninstalled libtool libraries with the installed ones 80530cc67336Smrg newdependency_libs= 80540cc67336Smrg for deplib in $dependency_libs; do 80550cc67336Smrg case $deplib in 80560cc67336Smrg *.la) 80570cc67336Smrg func_basename "$deplib" 80580cc67336Smrg name="$func_basename_result" 80590cc67336Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 80600cc67336Smrg test -z "$libdir" && \ 80610cc67336Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 80620cc67336Smrg newdependency_libs="$newdependency_libs $libdir/$name" 80630cc67336Smrg ;; 80640cc67336Smrg *) newdependency_libs="$newdependency_libs $deplib" ;; 80650cc67336Smrg esac 80660cc67336Smrg done 80670cc67336Smrg dependency_libs="$newdependency_libs" 80680cc67336Smrg newdlfiles= 80690cc67336Smrg 80700cc67336Smrg for lib in $dlfiles; do 80710cc67336Smrg case $lib in 80720cc67336Smrg *.la) 80730cc67336Smrg func_basename "$lib" 80740cc67336Smrg name="$func_basename_result" 80750cc67336Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 80760cc67336Smrg test -z "$libdir" && \ 80770cc67336Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 80780cc67336Smrg newdlfiles="$newdlfiles $libdir/$name" 80790cc67336Smrg ;; 80800cc67336Smrg *) newdlfiles="$newdlfiles $lib" ;; 80810cc67336Smrg esac 80820cc67336Smrg done 80830cc67336Smrg dlfiles="$newdlfiles" 80840cc67336Smrg newdlprefiles= 80850cc67336Smrg for lib in $dlprefiles; do 80860cc67336Smrg case $lib in 80870cc67336Smrg *.la) 80880cc67336Smrg # Only pass preopened files to the pseudo-archive (for 80890cc67336Smrg # eventual linking with the app. that links it) if we 80900cc67336Smrg # didn't already link the preopened objects directly into 80910cc67336Smrg # the library: 80920cc67336Smrg func_basename "$lib" 80930cc67336Smrg name="$func_basename_result" 80940cc67336Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 80950cc67336Smrg test -z "$libdir" && \ 80960cc67336Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 80970cc67336Smrg newdlprefiles="$newdlprefiles $libdir/$name" 80980cc67336Smrg ;; 80990cc67336Smrg esac 81000cc67336Smrg done 81010cc67336Smrg dlprefiles="$newdlprefiles" 81020cc67336Smrg else 81030cc67336Smrg newdlfiles= 81040cc67336Smrg for lib in $dlfiles; do 81050cc67336Smrg case $lib in 81060cc67336Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 81070cc67336Smrg *) abs=`pwd`"/$lib" ;; 81080cc67336Smrg esac 81090cc67336Smrg newdlfiles="$newdlfiles $abs" 81100cc67336Smrg done 81110cc67336Smrg dlfiles="$newdlfiles" 81120cc67336Smrg newdlprefiles= 81130cc67336Smrg for lib in $dlprefiles; do 81140cc67336Smrg case $lib in 81150cc67336Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 81160cc67336Smrg *) abs=`pwd`"/$lib" ;; 81170cc67336Smrg esac 81180cc67336Smrg newdlprefiles="$newdlprefiles $abs" 81190cc67336Smrg done 81200cc67336Smrg dlprefiles="$newdlprefiles" 81210cc67336Smrg fi 81220cc67336Smrg $RM $output 81230cc67336Smrg # place dlname in correct position for cygwin 81240cc67336Smrg tdlname=$dlname 81250cc67336Smrg case $host,$output,$installed,$module,$dlname in 81260cc67336Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; 81270cc67336Smrg esac 81280cc67336Smrg $ECHO > $output "\ 81290cc67336Smrg# $outputname - a libtool library file 81300cc67336Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 81310cc67336Smrg# 81320cc67336Smrg# Please DO NOT delete this file! 81330cc67336Smrg# It is necessary for linking the library. 8134301ea0f4Smrg 81350cc67336Smrg# The name that we can dlopen(3). 81360cc67336Smrgdlname='$tdlname' 8137301ea0f4Smrg 81380cc67336Smrg# Names of this library. 81390cc67336Smrglibrary_names='$library_names' 8140301ea0f4Smrg 81410cc67336Smrg# The name of the static archive. 81420cc67336Smrgold_library='$old_library' 8143301ea0f4Smrg 81440cc67336Smrg# Linker flags that can not go in dependency_libs. 81450cc67336Smrginherited_linker_flags='$new_inherited_linker_flags' 8146301ea0f4Smrg 81470cc67336Smrg# Libraries that this one depends upon. 81480cc67336Smrgdependency_libs='$dependency_libs' 8149301ea0f4Smrg 81500cc67336Smrg# Names of additional weak libraries provided by this library 81510cc67336Smrgweak_library_names='$weak_libs' 8152301ea0f4Smrg 81530cc67336Smrg# Version information for $libname. 81540cc67336Smrgcurrent=$current 81550cc67336Smrgage=$age 81560cc67336Smrgrevision=$revision 8157301ea0f4Smrg 81580cc67336Smrg# Is this an already installed library? 81590cc67336Smrginstalled=$installed 8160301ea0f4Smrg 81610cc67336Smrg# Should we warn about portability when linking against -modules? 81620cc67336Smrgshouldnotlink=$module 8163301ea0f4Smrg 81640cc67336Smrg# Files to dlopen/dlpreopen 81650cc67336Smrgdlopen='$dlfiles' 81660cc67336Smrgdlpreopen='$dlprefiles' 8167301ea0f4Smrg 81680cc67336Smrg# Directory that this library needs to be installed in: 81690cc67336Smrglibdir='$install_libdir'" 81700cc67336Smrg if test "$installed" = no && test "$need_relink" = yes; then 81710cc67336Smrg $ECHO >> $output "\ 81720cc67336Smrgrelink_command=\"$relink_command\"" 81730cc67336Smrg fi 81740cc67336Smrg done 81750cc67336Smrg } 8176301ea0f4Smrg 81770cc67336Smrg # Do a symbolic link so that the libtool archive can be found in 81780cc67336Smrg # LD_LIBRARY_PATH before the program is installed. 81790cc67336Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 81800cc67336Smrg ;; 81810cc67336Smrg esac 81820cc67336Smrg exit $EXIT_SUCCESS 81830cc67336Smrg} 8184301ea0f4Smrg 81850cc67336Smrg{ test "$mode" = link || test "$mode" = relink; } && 81860cc67336Smrg func_mode_link ${1+"$@"} 8187301ea0f4Smrg 8188301ea0f4Smrg 81890cc67336Smrg# func_mode_uninstall arg... 81900cc67336Smrgfunc_mode_uninstall () 81910cc67336Smrg{ 81920cc67336Smrg $opt_debug 81930cc67336Smrg RM="$nonopt" 8194301ea0f4Smrg files= 8195301ea0f4Smrg rmforce= 8196301ea0f4Smrg exit_status=0 8197301ea0f4Smrg 8198301ea0f4Smrg # This variable tells wrapper scripts just to set variables rather 8199301ea0f4Smrg # than running their programs. 8200301ea0f4Smrg libtool_install_magic="$magic" 8201301ea0f4Smrg 8202301ea0f4Smrg for arg 8203301ea0f4Smrg do 8204301ea0f4Smrg case $arg in 82050cc67336Smrg -f) RM="$RM $arg"; rmforce=yes ;; 82060cc67336Smrg -*) RM="$RM $arg" ;; 8207301ea0f4Smrg *) files="$files $arg" ;; 8208301ea0f4Smrg esac 8209301ea0f4Smrg done 8210301ea0f4Smrg 82110cc67336Smrg test -z "$RM" && \ 82120cc67336Smrg func_fatal_help "you must specify an RM program" 8213301ea0f4Smrg 8214301ea0f4Smrg rmdirs= 8215301ea0f4Smrg 8216301ea0f4Smrg origobjdir="$objdir" 8217301ea0f4Smrg for file in $files; do 82180cc67336Smrg func_dirname "$file" "" "." 82190cc67336Smrg dir="$func_dirname_result" 82200cc67336Smrg if test "X$dir" = X.; then 8221301ea0f4Smrg objdir="$origobjdir" 8222301ea0f4Smrg else 8223301ea0f4Smrg objdir="$dir/$origobjdir" 8224301ea0f4Smrg fi 82250cc67336Smrg func_basename "$file" 82260cc67336Smrg name="$func_basename_result" 8227301ea0f4Smrg test "$mode" = uninstall && objdir="$dir" 8228301ea0f4Smrg 8229301ea0f4Smrg # Remember objdir for removal later, being careful to avoid duplicates 8230301ea0f4Smrg if test "$mode" = clean; then 8231301ea0f4Smrg case " $rmdirs " in 8232301ea0f4Smrg *" $objdir "*) ;; 8233301ea0f4Smrg *) rmdirs="$rmdirs $objdir" ;; 8234301ea0f4Smrg esac 8235301ea0f4Smrg fi 8236301ea0f4Smrg 8237301ea0f4Smrg # Don't error if the file doesn't exist and rm -f was used. 82380cc67336Smrg if { test -L "$file"; } >/dev/null 2>&1 || 82390cc67336Smrg { test -h "$file"; } >/dev/null 2>&1 || 82400cc67336Smrg test -f "$file"; then 8241301ea0f4Smrg : 8242301ea0f4Smrg elif test -d "$file"; then 8243301ea0f4Smrg exit_status=1 8244301ea0f4Smrg continue 8245301ea0f4Smrg elif test "$rmforce" = yes; then 8246301ea0f4Smrg continue 8247301ea0f4Smrg fi 8248301ea0f4Smrg 8249301ea0f4Smrg rmfiles="$file" 8250301ea0f4Smrg 8251301ea0f4Smrg case $name in 8252301ea0f4Smrg *.la) 8253301ea0f4Smrg # Possibly a libtool archive, so verify it. 82540cc67336Smrg if func_lalib_p "$file"; then 82550cc67336Smrg func_source $dir/$name 8256301ea0f4Smrg 8257301ea0f4Smrg # Delete the libtool libraries and symlinks. 8258301ea0f4Smrg for n in $library_names; do 8259301ea0f4Smrg rmfiles="$rmfiles $objdir/$n" 8260301ea0f4Smrg done 8261301ea0f4Smrg test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" 8262301ea0f4Smrg 8263301ea0f4Smrg case "$mode" in 8264301ea0f4Smrg clean) 8265301ea0f4Smrg case " $library_names " in 8266301ea0f4Smrg # " " in the beginning catches empty $dlname 8267301ea0f4Smrg *" $dlname "*) ;; 8268301ea0f4Smrg *) rmfiles="$rmfiles $objdir/$dlname" ;; 8269301ea0f4Smrg esac 82700cc67336Smrg test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" 8271301ea0f4Smrg ;; 8272301ea0f4Smrg uninstall) 8273301ea0f4Smrg if test -n "$library_names"; then 8274301ea0f4Smrg # Do each command in the postuninstall commands. 82750cc67336Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 8276301ea0f4Smrg fi 8277301ea0f4Smrg 8278301ea0f4Smrg if test -n "$old_library"; then 8279301ea0f4Smrg # Do each command in the old_postuninstall commands. 82800cc67336Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 8281301ea0f4Smrg fi 8282301ea0f4Smrg # FIXME: should reinstall the best remaining shared library. 8283301ea0f4Smrg ;; 8284301ea0f4Smrg esac 8285301ea0f4Smrg fi 8286301ea0f4Smrg ;; 8287301ea0f4Smrg 8288301ea0f4Smrg *.lo) 8289301ea0f4Smrg # Possibly a libtool object, so verify it. 82900cc67336Smrg if func_lalib_p "$file"; then 8291301ea0f4Smrg 8292301ea0f4Smrg # Read the .lo file 82930cc67336Smrg func_source $dir/$name 8294301ea0f4Smrg 8295301ea0f4Smrg # Add PIC object to the list of files to remove. 82960cc67336Smrg if test -n "$pic_object" && 82970cc67336Smrg test "$pic_object" != none; then 8298301ea0f4Smrg rmfiles="$rmfiles $dir/$pic_object" 8299301ea0f4Smrg fi 8300301ea0f4Smrg 8301301ea0f4Smrg # Add non-PIC object to the list of files to remove. 83020cc67336Smrg if test -n "$non_pic_object" && 83030cc67336Smrg test "$non_pic_object" != none; then 8304301ea0f4Smrg rmfiles="$rmfiles $dir/$non_pic_object" 8305301ea0f4Smrg fi 8306301ea0f4Smrg fi 8307301ea0f4Smrg ;; 8308301ea0f4Smrg 8309301ea0f4Smrg *) 8310301ea0f4Smrg if test "$mode" = clean ; then 8311301ea0f4Smrg noexename=$name 8312301ea0f4Smrg case $file in 8313301ea0f4Smrg *.exe) 83140cc67336Smrg func_stripname '' '.exe' "$file" 83150cc67336Smrg file=$func_stripname_result 83160cc67336Smrg func_stripname '' '.exe' "$name" 83170cc67336Smrg noexename=$func_stripname_result 8318301ea0f4Smrg # $file with .exe has already been added to rmfiles, 8319301ea0f4Smrg # add $file without .exe 8320301ea0f4Smrg rmfiles="$rmfiles $file" 8321301ea0f4Smrg ;; 8322301ea0f4Smrg esac 8323301ea0f4Smrg # Do a test to see if this is a libtool program. 83240cc67336Smrg if func_ltwrapper_p "$file"; then 83250cc67336Smrg if func_ltwrapper_executable_p "$file"; then 83260cc67336Smrg func_ltwrapper_scriptname "$file" 83270cc67336Smrg relink_command= 83280cc67336Smrg func_source $func_ltwrapper_scriptname_result 83290cc67336Smrg rmfiles="$rmfiles $func_ltwrapper_scriptname_result" 83300cc67336Smrg else 83310cc67336Smrg relink_command= 83320cc67336Smrg func_source $dir/$noexename 83330cc67336Smrg fi 8334301ea0f4Smrg 8335301ea0f4Smrg # note $name still contains .exe if it was in $file originally 8336301ea0f4Smrg # as does the version of $file that was added into $rmfiles 8337301ea0f4Smrg rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" 8338301ea0f4Smrg if test "$fast_install" = yes && test -n "$relink_command"; then 8339301ea0f4Smrg rmfiles="$rmfiles $objdir/lt-$name" 8340301ea0f4Smrg fi 8341301ea0f4Smrg if test "X$noexename" != "X$name" ; then 8342301ea0f4Smrg rmfiles="$rmfiles $objdir/lt-${noexename}.c" 8343301ea0f4Smrg fi 8344301ea0f4Smrg fi 8345301ea0f4Smrg fi 8346301ea0f4Smrg ;; 8347301ea0f4Smrg esac 83480cc67336Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 8349301ea0f4Smrg done 8350301ea0f4Smrg objdir="$origobjdir" 8351301ea0f4Smrg 8352301ea0f4Smrg # Try to remove the ${objdir}s in the directories where we deleted files 8353301ea0f4Smrg for dir in $rmdirs; do 8354301ea0f4Smrg if test -d "$dir"; then 83550cc67336Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 8356301ea0f4Smrg fi 8357301ea0f4Smrg done 8358301ea0f4Smrg 8359301ea0f4Smrg exit $exit_status 83600cc67336Smrg} 8361301ea0f4Smrg 83620cc67336Smrg{ test "$mode" = uninstall || test "$mode" = clean; } && 83630cc67336Smrg func_mode_uninstall ${1+"$@"} 8364301ea0f4Smrg 83650cc67336Smrgtest -z "$mode" && { 83660cc67336Smrg help="$generic_help" 83670cc67336Smrg func_fatal_help "you must specify a MODE" 83680cc67336Smrg} 83690cc67336Smrg 83700cc67336Smrgtest -z "$exec_cmd" && \ 83710cc67336Smrg func_fatal_help "invalid operation mode \`$mode'" 8372301ea0f4Smrg 8373301ea0f4Smrgif test -n "$exec_cmd"; then 83740cc67336Smrg eval exec "$exec_cmd" 8375301ea0f4Smrg exit $EXIT_FAILURE 8376301ea0f4Smrgfi 8377301ea0f4Smrg 83780cc67336Smrgexit $exit_status 8379301ea0f4Smrg 8380301ea0f4Smrg 8381301ea0f4Smrg# The TAGs below are defined such that we never get into a situation 8382301ea0f4Smrg# in which we disable both kinds of libraries. Given conflicting 8383301ea0f4Smrg# choices, we go for a static library, that is the most portable, 8384301ea0f4Smrg# since we can't tell whether shared libraries were disabled because 8385301ea0f4Smrg# the user asked for that or because the platform doesn't support 8386301ea0f4Smrg# them. This is particularly important on AIX, because we don't 8387301ea0f4Smrg# support having both static and shared libraries enabled at the same 8388301ea0f4Smrg# time on that platform, so we default to a shared-only configuration. 8389301ea0f4Smrg# If a disable-shared tag is given, we'll fallback to a static-only 8390301ea0f4Smrg# configuration. But we'll never go from static-only to shared-only. 8391301ea0f4Smrg 8392301ea0f4Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 83930cc67336Smrgbuild_libtool_libs=no 83940cc67336Smrgbuild_old_libs=yes 8395301ea0f4Smrg# ### END LIBTOOL TAG CONFIG: disable-shared 8396301ea0f4Smrg 8397301ea0f4Smrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 83980cc67336Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 8399301ea0f4Smrg# ### END LIBTOOL TAG CONFIG: disable-static 8400301ea0f4Smrg 8401301ea0f4Smrg# Local Variables: 8402301ea0f4Smrg# mode:shell-script 8403301ea0f4Smrg# sh-indentation:2 8404301ea0f4Smrg# End: 84050cc67336Smrg# vi:sw=2 84060cc67336Smrg 8407