ltmain.sh revision 5ffd6003
15ffd6003Smrg# Generated from ltmain.m4sh. 25ffd6003Smrg 35ffd6003Smrg# ltmain.sh (GNU libtool) 2.2.6b 45ffd6003Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 55ffd6003Smrg 65ffd6003Smrg# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc. 75ffd6003Smrg# This is free software; see the source for copying conditions. There is NO 85ffd6003Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 95ffd6003Smrg 105ffd6003Smrg# GNU Libtool is free software; you can redistribute it and/or modify 11145b7b3cSmrg# it under the terms of the GNU General Public License as published by 12145b7b3cSmrg# the Free Software Foundation; either version 2 of the License, or 13145b7b3cSmrg# (at your option) any later version. 14145b7b3cSmrg# 155ffd6003Smrg# As a special exception to the GNU General Public License, 165ffd6003Smrg# if you distribute this file as part of a program or library that 175ffd6003Smrg# is built using GNU Libtool, you may include this file under the 185ffd6003Smrg# same distribution terms that you use for the rest of that program. 195ffd6003Smrg# 205ffd6003Smrg# GNU Libtool is distributed in the hope that it will be useful, but 21145b7b3cSmrg# WITHOUT ANY WARRANTY; without even the implied warranty of 22145b7b3cSmrg# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23145b7b3cSmrg# General Public License for more details. 24145b7b3cSmrg# 25145b7b3cSmrg# You should have received a copy of the GNU General Public License 265ffd6003Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 275ffd6003Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 285ffd6003Smrg# or obtained by writing to the Free Software Foundation, Inc., 295ffd6003Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30145b7b3cSmrg 315ffd6003Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 325ffd6003Smrg# 335ffd6003Smrg# Provide generalized library-building support services. 345ffd6003Smrg# 355ffd6003Smrg# --config show all configuration variables 365ffd6003Smrg# --debug enable verbose shell tracing 375ffd6003Smrg# -n, --dry-run display commands without modifying any files 385ffd6003Smrg# --features display basic configuration information and exit 395ffd6003Smrg# --mode=MODE use operation mode MODE 405ffd6003Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 415ffd6003Smrg# --quiet, --silent don't print informational messages 425ffd6003Smrg# --tag=TAG use configuration variables from tag TAG 435ffd6003Smrg# -v, --verbose print informational messages (default) 445ffd6003Smrg# --version print version information 455ffd6003Smrg# -h, --help print short or long help message 465ffd6003Smrg# 475ffd6003Smrg# MODE must be one of the following: 485ffd6003Smrg# 495ffd6003Smrg# clean remove files from the build directory 505ffd6003Smrg# compile compile a source file into a libtool object 515ffd6003Smrg# execute automatically set library path, then run a program 525ffd6003Smrg# finish complete the installation of libtool libraries 535ffd6003Smrg# install install libraries or executables 545ffd6003Smrg# link create a library or an executable 555ffd6003Smrg# uninstall remove libraries from an installed directory 565ffd6003Smrg# 575ffd6003Smrg# MODE-ARGS vary depending on the MODE. 585ffd6003Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 595ffd6003Smrg# 605ffd6003Smrg# When reporting a bug, please describe a test case to reproduce it and 615ffd6003Smrg# include the following information: 625ffd6003Smrg# 635ffd6003Smrg# host-triplet: $host 645ffd6003Smrg# shell: $SHELL 655ffd6003Smrg# compiler: $LTCC 665ffd6003Smrg# compiler flags: $LTCFLAGS 675ffd6003Smrg# linker: $LD (gnu? $with_gnu_ld) 685ffd6003Smrg# $progname: (GNU libtool) 2.2.6b Debian-2.2.6b-2 695ffd6003Smrg# automake: $automake_version 705ffd6003Smrg# autoconf: $autoconf_version 715ffd6003Smrg# 725ffd6003Smrg# Report bugs to <bug-libtool@gnu.org>. 73145b7b3cSmrg 74145b7b3cSmrgPROGRAM=ltmain.sh 75145b7b3cSmrgPACKAGE=libtool 765ffd6003SmrgVERSION="2.2.6b Debian-2.2.6b-2" 775ffd6003SmrgTIMESTAMP="" 785ffd6003Smrgpackage_revision=1.3017 79578741aaSmrg 805ffd6003Smrg# Be Bourne compatible 81578741aaSmrgif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 82578741aaSmrg emulate sh 83578741aaSmrg NULLCMD=: 84578741aaSmrg # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 85578741aaSmrg # is contrary to our usage. Disable this feature. 86578741aaSmrg alias -g '${1+"$@"}'='"$@"' 87145b7b3cSmrg setopt NO_GLOB_SUBST 88578741aaSmrgelse 89578741aaSmrg case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 90145b7b3cSmrgfi 91578741aaSmrgBIN_SH=xpg4; export BIN_SH # for Tru64 92578741aaSmrgDUALCASE=1; export DUALCASE # for MKS sh 93145b7b3cSmrg 945ffd6003Smrg# NLS nuisances: We save the old values to restore during execute mode. 95145b7b3cSmrg# Only set LANG and LC_ALL to C if already set. 96145b7b3cSmrg# These must not be set unconditionally because not all systems understand 97145b7b3cSmrg# e.g. LANG=C (notably SCO). 985ffd6003Smrglt_user_locale= 995ffd6003Smrglt_safe_locale= 100578741aaSmrgfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 101578741aaSmrgdo 102578741aaSmrg eval "if test \"\${$lt_var+set}\" = set; then 1035ffd6003Smrg save_$lt_var=\$$lt_var 1045ffd6003Smrg $lt_var=C 105578741aaSmrg export $lt_var 1065ffd6003Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 1075ffd6003Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 108578741aaSmrg fi" 109578741aaSmrgdone 110578741aaSmrg 1115ffd6003Smrg$lt_unset CDPATH 1125ffd6003Smrg 1135ffd6003Smrg 1145ffd6003Smrg 1155ffd6003Smrg 1165ffd6003Smrg 1175ffd6003Smrg: ${CP="cp -f"} 1185ffd6003Smrg: ${ECHO="echo"} 1195ffd6003Smrg: ${EGREP="/bin/grep -E"} 1205ffd6003Smrg: ${FGREP="/bin/grep -F"} 1215ffd6003Smrg: ${GREP="/bin/grep"} 1225ffd6003Smrg: ${LN_S="ln -s"} 1235ffd6003Smrg: ${MAKE="make"} 1245ffd6003Smrg: ${MKDIR="mkdir"} 1255ffd6003Smrg: ${MV="mv -f"} 1265ffd6003Smrg: ${RM="rm -f"} 1275ffd6003Smrg: ${SED="/bin/sed"} 1285ffd6003Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 1295ffd6003Smrg: ${Xsed="$SED -e 1s/^X//"} 1305ffd6003Smrg 1315ffd6003Smrg# Global variables: 1325ffd6003SmrgEXIT_SUCCESS=0 1335ffd6003SmrgEXIT_FAILURE=1 1345ffd6003SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 1355ffd6003SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 1365ffd6003Smrg 1375ffd6003Smrgexit_status=$EXIT_SUCCESS 138145b7b3cSmrg 139145b7b3cSmrg# Make sure IFS has a sensible default 140145b7b3cSmrglt_nl=' 141145b7b3cSmrg' 142145b7b3cSmrgIFS=" $lt_nl" 143145b7b3cSmrg 1445ffd6003Smrgdirname="s,/[^/]*$,," 1455ffd6003Smrgbasename="s,^.*/,," 1465ffd6003Smrg 1475ffd6003Smrg# func_dirname_and_basename file append nondir_replacement 1485ffd6003Smrg# perform func_basename and func_dirname in a single function 1495ffd6003Smrg# call: 1505ffd6003Smrg# dirname: Compute the dirname of FILE. If nonempty, 1515ffd6003Smrg# add APPEND to the result, otherwise set result 1525ffd6003Smrg# to NONDIR_REPLACEMENT. 1535ffd6003Smrg# value returned in "$func_dirname_result" 1545ffd6003Smrg# basename: Compute filename of FILE. 1555ffd6003Smrg# value retuned in "$func_basename_result" 1565ffd6003Smrg# Implementation must be kept synchronized with func_dirname 1575ffd6003Smrg# and func_basename. For efficiency, we do not delegate to 1585ffd6003Smrg# those functions but instead duplicate the functionality here. 1595ffd6003Smrgfunc_dirname_and_basename () 1605ffd6003Smrg{ 1615ffd6003Smrg # Extract subdirectory from the argument. 1625ffd6003Smrg func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"` 1635ffd6003Smrg if test "X$func_dirname_result" = "X${1}"; then 1645ffd6003Smrg func_dirname_result="${3}" 1655ffd6003Smrg else 1665ffd6003Smrg func_dirname_result="$func_dirname_result${2}" 1675ffd6003Smrg fi 1685ffd6003Smrg func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"` 1695ffd6003Smrg} 170145b7b3cSmrg 1715ffd6003Smrg# Generated shell functions inserted here. 1725ffd6003Smrg 1735ffd6003Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 1745ffd6003Smrg# is ksh but when the shell is invoked as "sh" and the current value of 1755ffd6003Smrg# the _XPG environment variable is not equal to 1 (one), the special 1765ffd6003Smrg# positional parameter $0, within a function call, is the name of the 1775ffd6003Smrg# function. 1785ffd6003Smrgprogpath="$0" 1795ffd6003Smrg 1805ffd6003Smrg# The name of this program: 1815ffd6003Smrg# In the unlikely event $progname began with a '-', it would play havoc with 1825ffd6003Smrg# func_echo (imagine progname=-n), so we prepend ./ in that case: 1835ffd6003Smrgfunc_dirname_and_basename "$progpath" 1845ffd6003Smrgprogname=$func_basename_result 1855ffd6003Smrgcase $progname in 1865ffd6003Smrg -*) progname=./$progname ;; 1875ffd6003Smrgesac 1885ffd6003Smrg 1895ffd6003Smrg# Make sure we have an absolute path for reexecution: 1905ffd6003Smrgcase $progpath in 1915ffd6003Smrg [\\/]*|[A-Za-z]:\\*) ;; 1925ffd6003Smrg *[\\/]*) 1935ffd6003Smrg progdir=$func_dirname_result 1945ffd6003Smrg progdir=`cd "$progdir" && pwd` 1955ffd6003Smrg progpath="$progdir/$progname" 1965ffd6003Smrg ;; 1975ffd6003Smrg *) 1985ffd6003Smrg save_IFS="$IFS" 1995ffd6003Smrg IFS=: 2005ffd6003Smrg for progdir in $PATH; do 2015ffd6003Smrg IFS="$save_IFS" 2025ffd6003Smrg test -x "$progdir/$progname" && break 2035ffd6003Smrg done 2045ffd6003Smrg IFS="$save_IFS" 2055ffd6003Smrg test -n "$progdir" || progdir=`pwd` 2065ffd6003Smrg progpath="$progdir/$progname" 2075ffd6003Smrg ;; 2085ffd6003Smrgesac 2095ffd6003Smrg 2105ffd6003Smrg# Sed substitution that helps us do robust quoting. It backslashifies 2115ffd6003Smrg# metacharacters that are still active within double-quoted strings. 2125ffd6003SmrgXsed="${SED}"' -e 1s/^X//' 2135ffd6003Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 2145ffd6003Smrg 2155ffd6003Smrg# Same as above, but do not quote variable references. 2165ffd6003Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 2175ffd6003Smrg 2185ffd6003Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 2195ffd6003Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 2205ffd6003Smrg# in input to double_quote_subst, that '$' was protected from expansion. 2215ffd6003Smrg# Since each input `\' is now two `\'s, look for any number of runs of 2225ffd6003Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 2235ffd6003Smrgbs='\\' 2245ffd6003Smrgbs2='\\\\' 2255ffd6003Smrgbs4='\\\\\\\\' 2265ffd6003Smrgdollar='\$' 2275ffd6003Smrgsed_double_backslash="\ 2285ffd6003Smrg s/$bs4/&\\ 2295ffd6003Smrg/g 2305ffd6003Smrg s/^$bs2$dollar/$bs&/ 2315ffd6003Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 2325ffd6003Smrg s/\n//g" 2335ffd6003Smrg 2345ffd6003Smrg# Standard options: 2355ffd6003Smrgopt_dry_run=false 2365ffd6003Smrgopt_help=false 2375ffd6003Smrgopt_quiet=false 2385ffd6003Smrgopt_verbose=false 2395ffd6003Smrgopt_warning=: 2405ffd6003Smrg 2415ffd6003Smrg# func_echo arg... 2425ffd6003Smrg# Echo program name prefixed message, along with the current mode 2435ffd6003Smrg# name if it has been set yet. 2445ffd6003Smrgfunc_echo () 2455ffd6003Smrg{ 2465ffd6003Smrg $ECHO "$progname${mode+: }$mode: $*" 2475ffd6003Smrg} 2485ffd6003Smrg 2495ffd6003Smrg# func_verbose arg... 2505ffd6003Smrg# Echo program name prefixed message in verbose mode only. 2515ffd6003Smrgfunc_verbose () 2525ffd6003Smrg{ 2535ffd6003Smrg $opt_verbose && func_echo ${1+"$@"} 2545ffd6003Smrg 2555ffd6003Smrg # A bug in bash halts the script if the last line of a function 2565ffd6003Smrg # fails when set -e is in force, so we need another command to 2575ffd6003Smrg # work around that: 2585ffd6003Smrg : 2595ffd6003Smrg} 2605ffd6003Smrg 2615ffd6003Smrg# func_error arg... 2625ffd6003Smrg# Echo program name prefixed message to standard error. 2635ffd6003Smrgfunc_error () 2645ffd6003Smrg{ 2655ffd6003Smrg $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2 2665ffd6003Smrg} 2675ffd6003Smrg 2685ffd6003Smrg# func_warning arg... 2695ffd6003Smrg# Echo program name prefixed warning message to standard error. 2705ffd6003Smrgfunc_warning () 2715ffd6003Smrg{ 2725ffd6003Smrg $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2 2735ffd6003Smrg 2745ffd6003Smrg # bash bug again: 2755ffd6003Smrg : 2765ffd6003Smrg} 2775ffd6003Smrg 2785ffd6003Smrg# func_fatal_error arg... 2795ffd6003Smrg# Echo program name prefixed message to standard error, and exit. 2805ffd6003Smrgfunc_fatal_error () 2815ffd6003Smrg{ 2825ffd6003Smrg func_error ${1+"$@"} 2835ffd6003Smrg exit $EXIT_FAILURE 2845ffd6003Smrg} 2855ffd6003Smrg 2865ffd6003Smrg# func_fatal_help arg... 2875ffd6003Smrg# Echo program name prefixed message to standard error, followed by 2885ffd6003Smrg# a help hint, and exit. 2895ffd6003Smrgfunc_fatal_help () 2905ffd6003Smrg{ 2915ffd6003Smrg func_error ${1+"$@"} 2925ffd6003Smrg func_fatal_error "$help" 2935ffd6003Smrg} 2945ffd6003Smrghelp="Try \`$progname --help' for more information." ## default 2955ffd6003Smrg 2965ffd6003Smrg 2975ffd6003Smrg# func_grep expression filename 2985ffd6003Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 2995ffd6003Smrgfunc_grep () 3005ffd6003Smrg{ 3015ffd6003Smrg $GREP "$1" "$2" >/dev/null 2>&1 3025ffd6003Smrg} 3035ffd6003Smrg 3045ffd6003Smrg 3055ffd6003Smrg# func_mkdir_p directory-path 3065ffd6003Smrg# Make sure the entire path to DIRECTORY-PATH is available. 3075ffd6003Smrgfunc_mkdir_p () 3085ffd6003Smrg{ 3095ffd6003Smrg my_directory_path="$1" 3105ffd6003Smrg my_dir_list= 3115ffd6003Smrg 3125ffd6003Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 3135ffd6003Smrg 3145ffd6003Smrg # Protect directory names starting with `-' 3155ffd6003Smrg case $my_directory_path in 3165ffd6003Smrg -*) my_directory_path="./$my_directory_path" ;; 3175ffd6003Smrg esac 3185ffd6003Smrg 3195ffd6003Smrg # While some portion of DIR does not yet exist... 3205ffd6003Smrg while test ! -d "$my_directory_path"; do 3215ffd6003Smrg # ...make a list in topmost first order. Use a colon delimited 3225ffd6003Smrg # list incase some portion of path contains whitespace. 3235ffd6003Smrg my_dir_list="$my_directory_path:$my_dir_list" 3245ffd6003Smrg 3255ffd6003Smrg # If the last portion added has no slash in it, the list is done 3265ffd6003Smrg case $my_directory_path in */*) ;; *) break ;; esac 3275ffd6003Smrg 3285ffd6003Smrg # ...otherwise throw away the child directory and loop 3295ffd6003Smrg my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"` 3305ffd6003Smrg done 3315ffd6003Smrg my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'` 3325ffd6003Smrg 3335ffd6003Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 3345ffd6003Smrg for my_dir in $my_dir_list; do 3355ffd6003Smrg IFS="$save_mkdir_p_IFS" 3365ffd6003Smrg # mkdir can fail with a `File exist' error if two processes 3375ffd6003Smrg # try to create one of the directories concurrently. Don't 3385ffd6003Smrg # stop in that case! 3395ffd6003Smrg $MKDIR "$my_dir" 2>/dev/null || : 3405ffd6003Smrg done 3415ffd6003Smrg IFS="$save_mkdir_p_IFS" 3425ffd6003Smrg 3435ffd6003Smrg # Bail out if we (or some other process) failed to create a directory. 3445ffd6003Smrg test -d "$my_directory_path" || \ 3455ffd6003Smrg func_fatal_error "Failed to create \`$1'" 3465ffd6003Smrg fi 3475ffd6003Smrg} 348145b7b3cSmrg 349145b7b3cSmrg 350145b7b3cSmrg# func_mktempdir [string] 351145b7b3cSmrg# Make a temporary directory that won't clash with other running 352145b7b3cSmrg# libtool processes, and avoids race conditions if possible. If 353145b7b3cSmrg# given, STRING is the basename for that directory. 354145b7b3cSmrgfunc_mktempdir () 355145b7b3cSmrg{ 356145b7b3cSmrg my_template="${TMPDIR-/tmp}/${1-$progname}" 357145b7b3cSmrg 3585ffd6003Smrg if test "$opt_dry_run" = ":"; then 359145b7b3cSmrg # Return a directory name, but don't create it in dry-run mode 360145b7b3cSmrg my_tmpdir="${my_template}-$$" 361145b7b3cSmrg else 362145b7b3cSmrg 363145b7b3cSmrg # If mktemp works, use that first and foremost 364145b7b3cSmrg my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 365145b7b3cSmrg 366145b7b3cSmrg if test ! -d "$my_tmpdir"; then 3675ffd6003Smrg # Failing that, at least try and use $RANDOM to avoid a race 3685ffd6003Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 369145b7b3cSmrg 3705ffd6003Smrg save_mktempdir_umask=`umask` 3715ffd6003Smrg umask 0077 3725ffd6003Smrg $MKDIR "$my_tmpdir" 3735ffd6003Smrg umask $save_mktempdir_umask 374145b7b3cSmrg fi 375145b7b3cSmrg 376145b7b3cSmrg # If we're not in dry-run mode, bomb out on failure 3775ffd6003Smrg test -d "$my_tmpdir" || \ 3785ffd6003Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 379145b7b3cSmrg fi 380145b7b3cSmrg 3815ffd6003Smrg $ECHO "X$my_tmpdir" | $Xsed 382145b7b3cSmrg} 383145b7b3cSmrg 384145b7b3cSmrg 3855ffd6003Smrg# func_quote_for_eval arg 3865ffd6003Smrg# Aesthetically quote ARG to be evaled later. 3875ffd6003Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 3885ffd6003Smrg# is double-quoted, suitable for a subsequent eval, whereas 3895ffd6003Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 3905ffd6003Smrg# which are still active within double quotes backslashified. 3915ffd6003Smrgfunc_quote_for_eval () 392145b7b3cSmrg{ 3935ffd6003Smrg case $1 in 3945ffd6003Smrg *[\\\`\"\$]*) 3955ffd6003Smrg func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;; 3965ffd6003Smrg *) 3975ffd6003Smrg func_quote_for_eval_unquoted_result="$1" ;; 3985ffd6003Smrg esac 3995ffd6003Smrg 4005ffd6003Smrg case $func_quote_for_eval_unquoted_result in 4015ffd6003Smrg # Double-quote args containing shell metacharacters to delay 4025ffd6003Smrg # word splitting, command substitution and and variable 4035ffd6003Smrg # expansion for a subsequent eval. 4045ffd6003Smrg # Many Bourne shells cannot handle close brackets correctly 4055ffd6003Smrg # in scan sets, so we specify it separately. 4065ffd6003Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 4075ffd6003Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 4085ffd6003Smrg ;; 4095ffd6003Smrg *) 4105ffd6003Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 411145b7b3cSmrg esac 412145b7b3cSmrg} 413145b7b3cSmrg 414145b7b3cSmrg 4155ffd6003Smrg# func_quote_for_expand arg 4165ffd6003Smrg# Aesthetically quote ARG to be evaled later; same as above, 4175ffd6003Smrg# but do not quote variable references. 4185ffd6003Smrgfunc_quote_for_expand () 419145b7b3cSmrg{ 4205ffd6003Smrg case $1 in 4215ffd6003Smrg *[\\\`\"]*) 4225ffd6003Smrg my_arg=`$ECHO "X$1" | $Xsed \ 4235ffd6003Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 424145b7b3cSmrg *) 4255ffd6003Smrg my_arg="$1" ;; 4265ffd6003Smrg esac 4275ffd6003Smrg 4285ffd6003Smrg case $my_arg in 4295ffd6003Smrg # Double-quote args containing shell metacharacters to delay 4305ffd6003Smrg # word splitting and command substitution for a subsequent eval. 4315ffd6003Smrg # Many Bourne shells cannot handle close brackets correctly 4325ffd6003Smrg # in scan sets, so we specify it separately. 4335ffd6003Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 4345ffd6003Smrg my_arg="\"$my_arg\"" 4355ffd6003Smrg ;; 4365ffd6003Smrg esac 4375ffd6003Smrg 4385ffd6003Smrg func_quote_for_expand_result="$my_arg" 439145b7b3cSmrg} 440145b7b3cSmrg 441145b7b3cSmrg 4425ffd6003Smrg# func_show_eval cmd [fail_exp] 4435ffd6003Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 4445ffd6003Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 4455ffd6003Smrg# is given, then evaluate it. 4465ffd6003Smrgfunc_show_eval () 447145b7b3cSmrg{ 4485ffd6003Smrg my_cmd="$1" 4495ffd6003Smrg my_fail_exp="${2-:}" 450145b7b3cSmrg 4515ffd6003Smrg ${opt_silent-false} || { 4525ffd6003Smrg func_quote_for_expand "$my_cmd" 4535ffd6003Smrg eval "func_echo $func_quote_for_expand_result" 4545ffd6003Smrg } 4555ffd6003Smrg 4565ffd6003Smrg if ${opt_dry_run-false}; then :; else 4575ffd6003Smrg eval "$my_cmd" 4585ffd6003Smrg my_status=$? 4595ffd6003Smrg if test "$my_status" -eq 0; then :; else 4605ffd6003Smrg eval "(exit $my_status); $my_fail_exp" 4615ffd6003Smrg fi 462145b7b3cSmrg fi 463145b7b3cSmrg} 464145b7b3cSmrg 4655ffd6003Smrg 4665ffd6003Smrg# func_show_eval_locale cmd [fail_exp] 4675ffd6003Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 4685ffd6003Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 4695ffd6003Smrg# is given, then evaluate it. Use the saved locale for evaluation. 4705ffd6003Smrgfunc_show_eval_locale () 471145b7b3cSmrg{ 4725ffd6003Smrg my_cmd="$1" 4735ffd6003Smrg my_fail_exp="${2-:}" 4745ffd6003Smrg 4755ffd6003Smrg ${opt_silent-false} || { 4765ffd6003Smrg func_quote_for_expand "$my_cmd" 4775ffd6003Smrg eval "func_echo $func_quote_for_expand_result" 4785ffd6003Smrg } 4795ffd6003Smrg 4805ffd6003Smrg if ${opt_dry_run-false}; then :; else 4815ffd6003Smrg eval "$lt_user_locale 4825ffd6003Smrg $my_cmd" 4835ffd6003Smrg my_status=$? 4845ffd6003Smrg eval "$lt_safe_locale" 4855ffd6003Smrg if test "$my_status" -eq 0; then :; else 4865ffd6003Smrg eval "(exit $my_status); $my_fail_exp" 4875ffd6003Smrg fi 488145b7b3cSmrg fi 4895ffd6003Smrg} 490145b7b3cSmrg 491145b7b3cSmrg 4925ffd6003Smrg 4935ffd6003Smrg 4945ffd6003Smrg 4955ffd6003Smrg# func_version 4965ffd6003Smrg# Echo version message to standard output and exit. 4975ffd6003Smrgfunc_version () 4985ffd6003Smrg{ 4995ffd6003Smrg $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / { 5005ffd6003Smrg s/^# // 5015ffd6003Smrg s/^# *$// 5025ffd6003Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 5035ffd6003Smrg p 5045ffd6003Smrg }' < "$progpath" 5055ffd6003Smrg exit $? 5065ffd6003Smrg} 5075ffd6003Smrg 5085ffd6003Smrg# func_usage 5095ffd6003Smrg# Echo short help message to standard output and exit. 5105ffd6003Smrgfunc_usage () 5115ffd6003Smrg{ 5125ffd6003Smrg $SED -n '/^# Usage:/,/# -h/ { 5135ffd6003Smrg s/^# // 5145ffd6003Smrg s/^# *$// 5155ffd6003Smrg s/\$progname/'$progname'/ 5165ffd6003Smrg p 5175ffd6003Smrg }' < "$progpath" 5185ffd6003Smrg $ECHO 5195ffd6003Smrg $ECHO "run \`$progname --help | more' for full usage" 5205ffd6003Smrg exit $? 5215ffd6003Smrg} 5225ffd6003Smrg 5235ffd6003Smrg# func_help 5245ffd6003Smrg# Echo long help message to standard output and exit. 5255ffd6003Smrgfunc_help () 5265ffd6003Smrg{ 5275ffd6003Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 5285ffd6003Smrg s/^# // 5295ffd6003Smrg s/^# *$// 5305ffd6003Smrg s*\$progname*'$progname'* 5315ffd6003Smrg s*\$host*'"$host"'* 5325ffd6003Smrg s*\$SHELL*'"$SHELL"'* 5335ffd6003Smrg s*\$LTCC*'"$LTCC"'* 5345ffd6003Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 5355ffd6003Smrg s*\$LD*'"$LD"'* 5365ffd6003Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 5375ffd6003Smrg s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 5385ffd6003Smrg s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 5395ffd6003Smrg p 5405ffd6003Smrg }' < "$progpath" 5415ffd6003Smrg exit $? 5425ffd6003Smrg} 5435ffd6003Smrg 5445ffd6003Smrg# func_missing_arg argname 5455ffd6003Smrg# Echo program name prefixed message to standard error and set global 5465ffd6003Smrg# exit_cmd. 5475ffd6003Smrgfunc_missing_arg () 5485ffd6003Smrg{ 5495ffd6003Smrg func_error "missing argument for $1" 5505ffd6003Smrg exit_cmd=exit 551145b7b3cSmrg} 552145b7b3cSmrg 5535ffd6003Smrgexit_cmd=: 554145b7b3cSmrg 555145b7b3cSmrg 5565ffd6003Smrg 5575ffd6003Smrg 5585ffd6003Smrg 5595ffd6003Smrg# Check that we have a working $ECHO. 5605ffd6003Smrgif test "X$1" = X--no-reexec; then 5615ffd6003Smrg # Discard the --no-reexec flag, and continue. 562145b7b3cSmrg shift 5635ffd6003Smrgelif test "X$1" = X--fallback-echo; then 5645ffd6003Smrg # Avoid inline document here, it may be left over 5655ffd6003Smrg : 5665ffd6003Smrgelif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then 5675ffd6003Smrg # Yippee, $ECHO works! 5685ffd6003Smrg : 5695ffd6003Smrgelse 5705ffd6003Smrg # Restart under the correct shell, and then maybe $ECHO will work. 5715ffd6003Smrg exec $SHELL "$progpath" --no-reexec ${1+"$@"} 5725ffd6003Smrgfi 573145b7b3cSmrg 5745ffd6003Smrgif test "X$1" = X--fallback-echo; then 5755ffd6003Smrg # used as fallback echo 5765ffd6003Smrg shift 5775ffd6003Smrg cat <<EOF 5785ffd6003Smrg$* 5795ffd6003SmrgEOF 5805ffd6003Smrg exit $EXIT_SUCCESS 5815ffd6003Smrgfi 582145b7b3cSmrg 5835ffd6003Smrgmagic="%%%MAGIC variable%%%" 5845ffd6003Smrgmagic_exe="%%%MAGIC EXE variable%%%" 585145b7b3cSmrg 5865ffd6003Smrg# Global variables. 5875ffd6003Smrg# $mode is unset 5885ffd6003Smrgnonopt= 5895ffd6003Smrgexecute_dlfiles= 5905ffd6003Smrgpreserve_args= 5915ffd6003Smrglo2o="s/\\.lo\$/.${objext}/" 5925ffd6003Smrgo2lo="s/\\.${objext}\$/.lo/" 5935ffd6003Smrgextracted_archives= 5945ffd6003Smrgextracted_serial=0 595145b7b3cSmrg 5965ffd6003Smrgopt_dry_run=false 5975ffd6003Smrgopt_duplicate_deps=false 5985ffd6003Smrgopt_silent=false 5995ffd6003Smrgopt_debug=: 600145b7b3cSmrg 6015ffd6003Smrg# If this variable is set in any of the actions, the command in it 6025ffd6003Smrg# will be execed at the end. This prevents here-documents from being 6035ffd6003Smrg# left over by shells. 6045ffd6003Smrgexec_cmd= 6055ffd6003Smrg 6065ffd6003Smrg# func_fatal_configuration arg... 6075ffd6003Smrg# Echo program name prefixed message to standard error, followed by 6085ffd6003Smrg# a configuration failure hint, and exit. 6095ffd6003Smrgfunc_fatal_configuration () 6105ffd6003Smrg{ 6115ffd6003Smrg func_error ${1+"$@"} 6125ffd6003Smrg func_error "See the $PACKAGE documentation for more information." 6135ffd6003Smrg func_fatal_error "Fatal configuration error." 6145ffd6003Smrg} 615145b7b3cSmrg 616578741aaSmrg 6175ffd6003Smrg# func_config 6185ffd6003Smrg# Display the configuration for all the tags in this script. 6195ffd6003Smrgfunc_config () 6205ffd6003Smrg{ 6215ffd6003Smrg re_begincf='^# ### BEGIN LIBTOOL' 6225ffd6003Smrg re_endcf='^# ### END LIBTOOL' 6235ffd6003Smrg 6245ffd6003Smrg # Default configuration. 6255ffd6003Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 626145b7b3cSmrg 627145b7b3cSmrg # Now print the configurations for the tags. 628145b7b3cSmrg for tagname in $taglist; do 6295ffd6003Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 630145b7b3cSmrg done 631145b7b3cSmrg 6325ffd6003Smrg exit $? 6335ffd6003Smrg} 634145b7b3cSmrg 6355ffd6003Smrg# func_features 6365ffd6003Smrg# Display the features supported by this script. 6375ffd6003Smrgfunc_features () 6385ffd6003Smrg{ 6395ffd6003Smrg $ECHO "host: $host" 640145b7b3cSmrg if test "$build_libtool_libs" = yes; then 6415ffd6003Smrg $ECHO "enable shared libraries" 642145b7b3cSmrg else 6435ffd6003Smrg $ECHO "disable shared libraries" 644145b7b3cSmrg fi 645145b7b3cSmrg if test "$build_old_libs" = yes; then 6465ffd6003Smrg $ECHO "enable static libraries" 647145b7b3cSmrg else 6485ffd6003Smrg $ECHO "disable static libraries" 649145b7b3cSmrg fi 6505ffd6003Smrg 651145b7b3cSmrg exit $? 6525ffd6003Smrg} 653145b7b3cSmrg 6545ffd6003Smrg# func_enable_tag tagname 6555ffd6003Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 6565ffd6003Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 6575ffd6003Smrg# variable here. 6585ffd6003Smrgfunc_enable_tag () 6595ffd6003Smrg{ 6605ffd6003Smrg # Global variable: 6615ffd6003Smrg tagname="$1" 662145b7b3cSmrg 6635ffd6003Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 6645ffd6003Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 6655ffd6003Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 666145b7b3cSmrg 6675ffd6003Smrg # Validate tagname. 6685ffd6003Smrg case $tagname in 6695ffd6003Smrg *[!-_A-Za-z0-9,/]*) 6705ffd6003Smrg func_fatal_error "invalid tag name: $tagname" 6715ffd6003Smrg ;; 6725ffd6003Smrg esac 673145b7b3cSmrg 6745ffd6003Smrg # Don't test for the "default" C tag, as we know it's 6755ffd6003Smrg # there but not specially marked. 6765ffd6003Smrg case $tagname in 6775ffd6003Smrg CC) ;; 6785ffd6003Smrg *) 6795ffd6003Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 6805ffd6003Smrg taglist="$taglist $tagname" 6815ffd6003Smrg 6825ffd6003Smrg # Evaluate the configuration. Be careful to quote the path 6835ffd6003Smrg # and the sed script, to avoid splitting on whitespace, but 6845ffd6003Smrg # also don't use non-portable quotes within backquotes within 6855ffd6003Smrg # quotes we have to do it in 2 steps: 6865ffd6003Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 6875ffd6003Smrg eval "$extractedcf" 6885ffd6003Smrg else 6895ffd6003Smrg func_error "ignoring unknown tag $tagname" 6905ffd6003Smrg fi 6915ffd6003Smrg ;; 6925ffd6003Smrg esac 6935ffd6003Smrg} 6945ffd6003Smrg 6955ffd6003Smrg# Parse options once, thoroughly. This comes as soon as possible in 6965ffd6003Smrg# the script to make things like `libtool --version' happen quickly. 6975ffd6003Smrg{ 698145b7b3cSmrg 6995ffd6003Smrg # Shorthand for --mode=foo, only valid as the first argument 7005ffd6003Smrg case $1 in 7015ffd6003Smrg clean|clea|cle|cl) 7025ffd6003Smrg shift; set dummy --mode clean ${1+"$@"}; shift 703145b7b3cSmrg ;; 7045ffd6003Smrg compile|compil|compi|comp|com|co|c) 7055ffd6003Smrg shift; set dummy --mode compile ${1+"$@"}; shift 706145b7b3cSmrg ;; 7075ffd6003Smrg execute|execut|execu|exec|exe|ex|e) 7085ffd6003Smrg shift; set dummy --mode execute ${1+"$@"}; shift 709145b7b3cSmrg ;; 7105ffd6003Smrg finish|finis|fini|fin|fi|f) 7115ffd6003Smrg shift; set dummy --mode finish ${1+"$@"}; shift 712145b7b3cSmrg ;; 7135ffd6003Smrg install|instal|insta|inst|ins|in|i) 7145ffd6003Smrg shift; set dummy --mode install ${1+"$@"}; shift 7155ffd6003Smrg ;; 7165ffd6003Smrg link|lin|li|l) 7175ffd6003Smrg shift; set dummy --mode link ${1+"$@"}; shift 7185ffd6003Smrg ;; 7195ffd6003Smrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 7205ffd6003Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 721145b7b3cSmrg ;; 722145b7b3cSmrg esac 723145b7b3cSmrg 7245ffd6003Smrg # Parse non-mode specific arguments: 7255ffd6003Smrg while test "$#" -gt 0; do 7265ffd6003Smrg opt="$1" 7275ffd6003Smrg shift 728145b7b3cSmrg 7295ffd6003Smrg case $opt in 7305ffd6003Smrg --config) func_config ;; 731145b7b3cSmrg 7325ffd6003Smrg --debug) preserve_args="$preserve_args $opt" 7335ffd6003Smrg func_echo "enabling shell trace mode" 7345ffd6003Smrg opt_debug='set -x' 7355ffd6003Smrg $opt_debug 7365ffd6003Smrg ;; 737145b7b3cSmrg 7385ffd6003Smrg -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break 7395ffd6003Smrg execute_dlfiles="$execute_dlfiles $1" 7405ffd6003Smrg shift 7415ffd6003Smrg ;; 742145b7b3cSmrg 7435ffd6003Smrg --dry-run | -n) opt_dry_run=: ;; 7445ffd6003Smrg --features) func_features ;; 7455ffd6003Smrg --finish) mode="finish" ;; 7465ffd6003Smrg 7475ffd6003Smrg --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break 7485ffd6003Smrg case $1 in 7495ffd6003Smrg # Valid mode arguments: 7505ffd6003Smrg clean) ;; 7515ffd6003Smrg compile) ;; 7525ffd6003Smrg execute) ;; 7535ffd6003Smrg finish) ;; 7545ffd6003Smrg install) ;; 7555ffd6003Smrg link) ;; 7565ffd6003Smrg relink) ;; 7575ffd6003Smrg uninstall) ;; 7585ffd6003Smrg 7595ffd6003Smrg # Catch anything else as an error 7605ffd6003Smrg *) func_error "invalid argument for $opt" 7615ffd6003Smrg exit_cmd=exit 7625ffd6003Smrg break 7635ffd6003Smrg ;; 7645ffd6003Smrg esac 7655ffd6003Smrg 7665ffd6003Smrg mode="$1" 7675ffd6003Smrg shift 7685ffd6003Smrg ;; 7695ffd6003Smrg 7705ffd6003Smrg --preserve-dup-deps) 7715ffd6003Smrg opt_duplicate_deps=: ;; 7725ffd6003Smrg 7735ffd6003Smrg --quiet|--silent) preserve_args="$preserve_args $opt" 7745ffd6003Smrg opt_silent=: 7755ffd6003Smrg ;; 7765ffd6003Smrg 7775ffd6003Smrg --verbose| -v) preserve_args="$preserve_args $opt" 7785ffd6003Smrg opt_silent=false 7795ffd6003Smrg ;; 7805ffd6003Smrg 7815ffd6003Smrg --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break 7825ffd6003Smrg preserve_args="$preserve_args $opt $1" 7835ffd6003Smrg func_enable_tag "$1" # tagname is set here 7845ffd6003Smrg shift 7855ffd6003Smrg ;; 7865ffd6003Smrg 7875ffd6003Smrg # Separate optargs to long options: 7885ffd6003Smrg -dlopen=*|--mode=*|--tag=*) 7895ffd6003Smrg func_opt_split "$opt" 7905ffd6003Smrg set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"} 7915ffd6003Smrg shift 7925ffd6003Smrg ;; 7935ffd6003Smrg 7945ffd6003Smrg -\?|-h) func_usage ;; 7955ffd6003Smrg --help) opt_help=: ;; 7965ffd6003Smrg --version) func_version ;; 7975ffd6003Smrg 7985ffd6003Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 7995ffd6003Smrg 8005ffd6003Smrg *) nonopt="$opt" 8015ffd6003Smrg break 8025ffd6003Smrg ;; 8035ffd6003Smrg esac 8045ffd6003Smrg done 8055ffd6003Smrg 8065ffd6003Smrg 8075ffd6003Smrg case $host in 8085ffd6003Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 8095ffd6003Smrg # don't eliminate duplications in $postdeps and $predeps 8105ffd6003Smrg opt_duplicate_compiler_generated_deps=: 811145b7b3cSmrg ;; 812145b7b3cSmrg *) 8135ffd6003Smrg opt_duplicate_compiler_generated_deps=$opt_duplicate_deps 8145ffd6003Smrg ;; 8155ffd6003Smrg esac 816145b7b3cSmrg 8175ffd6003Smrg # Having warned about all mis-specified options, bail out if 8185ffd6003Smrg # anything was wrong. 8195ffd6003Smrg $exit_cmd $EXIT_FAILURE 8205ffd6003Smrg} 8215ffd6003Smrg 8225ffd6003Smrg# func_check_version_match 8235ffd6003Smrg# Ensure that we are using m4 macros, and libtool script from the same 8245ffd6003Smrg# release of libtool. 8255ffd6003Smrgfunc_check_version_match () 8265ffd6003Smrg{ 8275ffd6003Smrg if test "$package_revision" != "$macro_revision"; then 8285ffd6003Smrg if test "$VERSION" != "$macro_version"; then 8295ffd6003Smrg if test -z "$macro_version"; then 8305ffd6003Smrg cat >&2 <<_LT_EOF 8315ffd6003Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 8325ffd6003Smrg$progname: definition of this LT_INIT comes from an older release. 8335ffd6003Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 8345ffd6003Smrg$progname: and run autoconf again. 8355ffd6003Smrg_LT_EOF 8365ffd6003Smrg else 8375ffd6003Smrg cat >&2 <<_LT_EOF 8385ffd6003Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 8395ffd6003Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 8405ffd6003Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 8415ffd6003Smrg$progname: and run autoconf again. 8425ffd6003Smrg_LT_EOF 843145b7b3cSmrg fi 8445ffd6003Smrg else 8455ffd6003Smrg cat >&2 <<_LT_EOF 8465ffd6003Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 8475ffd6003Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 8485ffd6003Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 8495ffd6003Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 8505ffd6003Smrg_LT_EOF 8515ffd6003Smrg fi 8525ffd6003Smrg 8535ffd6003Smrg exit $EXIT_MISMATCH 8545ffd6003Smrg fi 8555ffd6003Smrg} 8565ffd6003Smrg 8575ffd6003Smrg 8585ffd6003Smrg## ----------- ## 8595ffd6003Smrg## Main. ## 8605ffd6003Smrg## ----------- ## 8615ffd6003Smrg 8625ffd6003Smrg$opt_help || { 8635ffd6003Smrg # Sanity checks first: 8645ffd6003Smrg func_check_version_match 8655ffd6003Smrg 8665ffd6003Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 8675ffd6003Smrg func_fatal_configuration "not configured to build any kind of library" 868145b7b3cSmrg fi 869145b7b3cSmrg 8705ffd6003Smrg test -z "$mode" && func_fatal_error "error: you must specify a MODE." 8715ffd6003Smrg 8725ffd6003Smrg 8735ffd6003Smrg # Darwin sucks 8745ffd6003Smrg eval std_shrext=\"$shrext_cmds\" 8755ffd6003Smrg 8765ffd6003Smrg 877145b7b3cSmrg # Only execute mode is allowed to have -dlopen flags. 878145b7b3cSmrg if test -n "$execute_dlfiles" && test "$mode" != execute; then 8795ffd6003Smrg func_error "unrecognized option \`-dlopen'" 8805ffd6003Smrg $ECHO "$help" 1>&2 881145b7b3cSmrg exit $EXIT_FAILURE 882145b7b3cSmrg fi 883145b7b3cSmrg 884145b7b3cSmrg # Change the help message to a mode-specific one. 885145b7b3cSmrg generic_help="$help" 8865ffd6003Smrg help="Try \`$progname --help --mode=$mode' for more information." 8875ffd6003Smrg} 888145b7b3cSmrg 889145b7b3cSmrg 8905ffd6003Smrg# func_lalib_p file 8915ffd6003Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 8925ffd6003Smrg# This function is only a basic sanity check; it will hardly flush out 8935ffd6003Smrg# determined imposters. 8945ffd6003Smrgfunc_lalib_p () 8955ffd6003Smrg{ 8965ffd6003Smrg test -f "$1" && 8975ffd6003Smrg $SED -e 4q "$1" 2>/dev/null \ 8985ffd6003Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 8995ffd6003Smrg} 900145b7b3cSmrg 9015ffd6003Smrg# func_lalib_unsafe_p file 9025ffd6003Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 9035ffd6003Smrg# This function implements the same check as func_lalib_p without 9045ffd6003Smrg# resorting to external programs. To this end, it redirects stdin and 9055ffd6003Smrg# closes it afterwards, without saving the original file descriptor. 9065ffd6003Smrg# As a safety measure, use it only where a negative result would be 9075ffd6003Smrg# fatal anyway. Works if `file' does not exist. 9085ffd6003Smrgfunc_lalib_unsafe_p () 9095ffd6003Smrg{ 9105ffd6003Smrg lalib_p=no 9115ffd6003Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 9125ffd6003Smrg for lalib_p_l in 1 2 3 4 9135ffd6003Smrg do 9145ffd6003Smrg read lalib_p_line 9155ffd6003Smrg case "$lalib_p_line" in 9165ffd6003Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 9175ffd6003Smrg esac 9185ffd6003Smrg done 9195ffd6003Smrg exec 0<&5 5<&- 9205ffd6003Smrg fi 9215ffd6003Smrg test "$lalib_p" = yes 9225ffd6003Smrg} 923145b7b3cSmrg 9245ffd6003Smrg# func_ltwrapper_script_p file 9255ffd6003Smrg# True iff FILE is a libtool wrapper script 9265ffd6003Smrg# This function is only a basic sanity check; it will hardly flush out 9275ffd6003Smrg# determined imposters. 9285ffd6003Smrgfunc_ltwrapper_script_p () 9295ffd6003Smrg{ 9305ffd6003Smrg func_lalib_p "$1" 9315ffd6003Smrg} 932145b7b3cSmrg 9335ffd6003Smrg# func_ltwrapper_executable_p file 9345ffd6003Smrg# True iff FILE is a libtool wrapper executable 9355ffd6003Smrg# This function is only a basic sanity check; it will hardly flush out 9365ffd6003Smrg# determined imposters. 9375ffd6003Smrgfunc_ltwrapper_executable_p () 9385ffd6003Smrg{ 9395ffd6003Smrg func_ltwrapper_exec_suffix= 9405ffd6003Smrg case $1 in 9415ffd6003Smrg *.exe) ;; 9425ffd6003Smrg *) func_ltwrapper_exec_suffix=.exe ;; 9435ffd6003Smrg esac 9445ffd6003Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 9455ffd6003Smrg} 946145b7b3cSmrg 9475ffd6003Smrg# func_ltwrapper_scriptname file 9485ffd6003Smrg# Assumes file is an ltwrapper_executable 9495ffd6003Smrg# uses $file to determine the appropriate filename for a 9505ffd6003Smrg# temporary ltwrapper_script. 9515ffd6003Smrgfunc_ltwrapper_scriptname () 9525ffd6003Smrg{ 9535ffd6003Smrg func_ltwrapper_scriptname_result="" 9545ffd6003Smrg if func_ltwrapper_executable_p "$1"; then 9555ffd6003Smrg func_dirname_and_basename "$1" "" "." 9565ffd6003Smrg func_stripname '' '.exe' "$func_basename_result" 9575ffd6003Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 9585ffd6003Smrg fi 9595ffd6003Smrg} 9605ffd6003Smrg 9615ffd6003Smrg# func_ltwrapper_p file 9625ffd6003Smrg# True iff FILE is a libtool wrapper script or wrapper executable 9635ffd6003Smrg# This function is only a basic sanity check; it will hardly flush out 9645ffd6003Smrg# determined imposters. 9655ffd6003Smrgfunc_ltwrapper_p () 9665ffd6003Smrg{ 9675ffd6003Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 9685ffd6003Smrg} 9695ffd6003Smrg 9705ffd6003Smrg 9715ffd6003Smrg# func_execute_cmds commands fail_cmd 9725ffd6003Smrg# Execute tilde-delimited COMMANDS. 9735ffd6003Smrg# If FAIL_CMD is given, eval that upon failure. 9745ffd6003Smrg# FAIL_CMD may read-access the current command in variable CMD! 9755ffd6003Smrgfunc_execute_cmds () 9765ffd6003Smrg{ 9775ffd6003Smrg $opt_debug 9785ffd6003Smrg save_ifs=$IFS; IFS='~' 9795ffd6003Smrg for cmd in $1; do 9805ffd6003Smrg IFS=$save_ifs 9815ffd6003Smrg eval cmd=\"$cmd\" 9825ffd6003Smrg func_show_eval "$cmd" "${2-:}" 9835ffd6003Smrg done 9845ffd6003Smrg IFS=$save_ifs 9855ffd6003Smrg} 9865ffd6003Smrg 9875ffd6003Smrg 9885ffd6003Smrg# func_source file 9895ffd6003Smrg# Source FILE, adding directory component if necessary. 9905ffd6003Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 9915ffd6003Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 9925ffd6003Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 9935ffd6003Smrg# `FILE.' does not work on cygwin managed mounts. 9945ffd6003Smrgfunc_source () 9955ffd6003Smrg{ 9965ffd6003Smrg $opt_debug 9975ffd6003Smrg case $1 in 9985ffd6003Smrg */* | *\\*) . "$1" ;; 9995ffd6003Smrg *) . "./$1" ;; 10005ffd6003Smrg esac 10015ffd6003Smrg} 10025ffd6003Smrg 10035ffd6003Smrg 10045ffd6003Smrg# func_infer_tag arg 10055ffd6003Smrg# Infer tagged configuration to use if any are available and 10065ffd6003Smrg# if one wasn't chosen via the "--tag" command line option. 10075ffd6003Smrg# Only attempt this if the compiler in the base compile 10085ffd6003Smrg# command doesn't match the default compiler. 10095ffd6003Smrg# arg is usually of the form 'gcc ...' 10105ffd6003Smrgfunc_infer_tag () 10115ffd6003Smrg{ 10125ffd6003Smrg $opt_debug 10135ffd6003Smrg if test -n "$available_tags" && test -z "$tagname"; then 10145ffd6003Smrg CC_quoted= 10155ffd6003Smrg for arg in $CC; do 10165ffd6003Smrg func_quote_for_eval "$arg" 10175ffd6003Smrg CC_quoted="$CC_quoted $func_quote_for_eval_result" 10185ffd6003Smrg done 10195ffd6003Smrg case $@ in 10205ffd6003Smrg # Blanks in the command may have been stripped by the calling shell, 10215ffd6003Smrg # but not from the CC environment variable when configure was run. 10225ffd6003Smrg " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;; 10235ffd6003Smrg # Blanks at the start of $base_compile will cause this to fail 10245ffd6003Smrg # if we don't check for them as well. 10255ffd6003Smrg *) 10265ffd6003Smrg for z in $available_tags; do 10275ffd6003Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 10285ffd6003Smrg # Evaluate the configuration. 10295ffd6003Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 10305ffd6003Smrg CC_quoted= 10315ffd6003Smrg for arg in $CC; do 10325ffd6003Smrg # Double-quote args containing other shell metacharacters. 10335ffd6003Smrg func_quote_for_eval "$arg" 10345ffd6003Smrg CC_quoted="$CC_quoted $func_quote_for_eval_result" 10355ffd6003Smrg done 10365ffd6003Smrg case "$@ " in 10375ffd6003Smrg " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) 10385ffd6003Smrg # The compiler in the base compile command matches 10395ffd6003Smrg # the one in the tagged configuration. 10405ffd6003Smrg # Assume this is the tagged configuration we want. 10415ffd6003Smrg tagname=$z 10425ffd6003Smrg break 10435ffd6003Smrg ;; 10445ffd6003Smrg esac 10455ffd6003Smrg fi 10465ffd6003Smrg done 10475ffd6003Smrg # If $tagname still isn't set, then no tagged configuration 10485ffd6003Smrg # was found and let the user know that the "--tag" command 10495ffd6003Smrg # line option must be used. 10505ffd6003Smrg if test -z "$tagname"; then 10515ffd6003Smrg func_echo "unable to infer tagged configuration" 10525ffd6003Smrg func_fatal_error "specify a tag with \`--tag'" 10535ffd6003Smrg# else 10545ffd6003Smrg# func_verbose "using $tagname tagged configuration" 10555ffd6003Smrg fi 10565ffd6003Smrg ;; 10575ffd6003Smrg esac 10585ffd6003Smrg fi 10595ffd6003Smrg} 10605ffd6003Smrg 10615ffd6003Smrg 10625ffd6003Smrg 10635ffd6003Smrg# func_write_libtool_object output_name pic_name nonpic_name 10645ffd6003Smrg# Create a libtool object file (analogous to a ".la" file), 10655ffd6003Smrg# but don't create it if we're doing a dry run. 10665ffd6003Smrgfunc_write_libtool_object () 10675ffd6003Smrg{ 10685ffd6003Smrg write_libobj=${1} 10695ffd6003Smrg if test "$build_libtool_libs" = yes; then 10705ffd6003Smrg write_lobj=\'${2}\' 10715ffd6003Smrg else 10725ffd6003Smrg write_lobj=none 10735ffd6003Smrg fi 10745ffd6003Smrg 10755ffd6003Smrg if test "$build_old_libs" = yes; then 10765ffd6003Smrg write_oldobj=\'${3}\' 10775ffd6003Smrg else 10785ffd6003Smrg write_oldobj=none 10795ffd6003Smrg fi 10805ffd6003Smrg 10815ffd6003Smrg $opt_dry_run || { 10825ffd6003Smrg cat >${write_libobj}T <<EOF 10835ffd6003Smrg# $write_libobj - a libtool object file 10845ffd6003Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 10855ffd6003Smrg# 10865ffd6003Smrg# Please DO NOT delete this file! 10875ffd6003Smrg# It is necessary for linking the library. 10885ffd6003Smrg 10895ffd6003Smrg# Name of the PIC object. 10905ffd6003Smrgpic_object=$write_lobj 10915ffd6003Smrg 10925ffd6003Smrg# Name of the non-PIC object 10935ffd6003Smrgnon_pic_object=$write_oldobj 10945ffd6003Smrg 10955ffd6003SmrgEOF 10965ffd6003Smrg $MV "${write_libobj}T" "${write_libobj}" 10975ffd6003Smrg } 10985ffd6003Smrg} 10995ffd6003Smrg 11005ffd6003Smrg# func_mode_compile arg... 11015ffd6003Smrgfunc_mode_compile () 11025ffd6003Smrg{ 11035ffd6003Smrg $opt_debug 11045ffd6003Smrg # Get the compilation command and the source file. 11055ffd6003Smrg base_compile= 11065ffd6003Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 11075ffd6003Smrg suppress_opt=yes 11085ffd6003Smrg suppress_output= 11095ffd6003Smrg arg_mode=normal 11105ffd6003Smrg libobj= 11115ffd6003Smrg later= 11125ffd6003Smrg pie_flag= 11135ffd6003Smrg 11145ffd6003Smrg for arg 11155ffd6003Smrg do 11165ffd6003Smrg case $arg_mode in 11175ffd6003Smrg arg ) 11185ffd6003Smrg # do not "continue". Instead, add this to base_compile 11195ffd6003Smrg lastarg="$arg" 11205ffd6003Smrg arg_mode=normal 11215ffd6003Smrg ;; 11225ffd6003Smrg 11235ffd6003Smrg target ) 11245ffd6003Smrg libobj="$arg" 11255ffd6003Smrg arg_mode=normal 11265ffd6003Smrg continue 11275ffd6003Smrg ;; 11285ffd6003Smrg 11295ffd6003Smrg normal ) 11305ffd6003Smrg # Accept any command-line options. 11315ffd6003Smrg case $arg in 11325ffd6003Smrg -o) 11335ffd6003Smrg test -n "$libobj" && \ 11345ffd6003Smrg func_fatal_error "you cannot specify \`-o' more than once" 11355ffd6003Smrg arg_mode=target 11365ffd6003Smrg continue 11375ffd6003Smrg ;; 11385ffd6003Smrg 11395ffd6003Smrg -pie | -fpie | -fPIE) 11405ffd6003Smrg pie_flag="$pie_flag $arg" 11415ffd6003Smrg continue 11425ffd6003Smrg ;; 11435ffd6003Smrg 11445ffd6003Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 11455ffd6003Smrg later="$later $arg" 11465ffd6003Smrg continue 11475ffd6003Smrg ;; 11485ffd6003Smrg 11495ffd6003Smrg -no-suppress) 1150145b7b3cSmrg suppress_opt=no 1151145b7b3cSmrg continue 1152145b7b3cSmrg ;; 1153145b7b3cSmrg 1154145b7b3cSmrg -Xcompiler) 1155145b7b3cSmrg arg_mode=arg # the next one goes into the "base_compile" arg list 1156145b7b3cSmrg continue # The current "srcfile" will either be retained or 1157145b7b3cSmrg ;; # replaced later. I would guess that would be a bug. 1158145b7b3cSmrg 1159145b7b3cSmrg -Wc,*) 11605ffd6003Smrg func_stripname '-Wc,' '' "$arg" 11615ffd6003Smrg args=$func_stripname_result 1162145b7b3cSmrg lastarg= 1163145b7b3cSmrg save_ifs="$IFS"; IFS=',' 11645ffd6003Smrg for arg in $args; do 1165145b7b3cSmrg IFS="$save_ifs" 11665ffd6003Smrg func_quote_for_eval "$arg" 11675ffd6003Smrg lastarg="$lastarg $func_quote_for_eval_result" 1168145b7b3cSmrg done 1169145b7b3cSmrg IFS="$save_ifs" 11705ffd6003Smrg func_stripname ' ' '' "$lastarg" 11715ffd6003Smrg lastarg=$func_stripname_result 1172145b7b3cSmrg 1173145b7b3cSmrg # Add the arguments to base_compile. 1174145b7b3cSmrg base_compile="$base_compile $lastarg" 1175145b7b3cSmrg continue 1176145b7b3cSmrg ;; 1177145b7b3cSmrg 11785ffd6003Smrg *) 1179145b7b3cSmrg # Accept the current argument as the source file. 1180145b7b3cSmrg # The previous "srcfile" becomes the current argument. 1181145b7b3cSmrg # 1182145b7b3cSmrg lastarg="$srcfile" 1183145b7b3cSmrg srcfile="$arg" 1184145b7b3cSmrg ;; 1185145b7b3cSmrg esac # case $arg 1186145b7b3cSmrg ;; 1187145b7b3cSmrg esac # case $arg_mode 1188145b7b3cSmrg 1189145b7b3cSmrg # Aesthetically quote the previous argument. 11905ffd6003Smrg func_quote_for_eval "$lastarg" 11915ffd6003Smrg base_compile="$base_compile $func_quote_for_eval_result" 1192145b7b3cSmrg done # for arg 1193145b7b3cSmrg 1194145b7b3cSmrg case $arg_mode in 1195145b7b3cSmrg arg) 11965ffd6003Smrg func_fatal_error "you must specify an argument for -Xcompile" 1197145b7b3cSmrg ;; 1198145b7b3cSmrg target) 11995ffd6003Smrg func_fatal_error "you must specify a target with \`-o'" 1200145b7b3cSmrg ;; 1201145b7b3cSmrg *) 1202145b7b3cSmrg # Get the name of the library object. 12035ffd6003Smrg test -z "$libobj" && { 12045ffd6003Smrg func_basename "$srcfile" 12055ffd6003Smrg libobj="$func_basename_result" 12065ffd6003Smrg } 1207145b7b3cSmrg ;; 1208145b7b3cSmrg esac 1209145b7b3cSmrg 1210145b7b3cSmrg # Recognize several different file suffixes. 1211145b7b3cSmrg # If the user specifies -o file.o, it is replaced with file.lo 1212145b7b3cSmrg case $libobj in 12135ffd6003Smrg *.[cCFSifmso] | \ 12145ffd6003Smrg *.ada | *.adb | *.ads | *.asm | \ 12155ffd6003Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 12165ffd6003Smrg *.[fF][09]? | *.for | *.java | *.obj | *.sx) 12175ffd6003Smrg func_xform "$libobj" 12185ffd6003Smrg libobj=$func_xform_result 12195ffd6003Smrg ;; 1220145b7b3cSmrg esac 1221145b7b3cSmrg 1222145b7b3cSmrg case $libobj in 12235ffd6003Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 1224145b7b3cSmrg *) 12255ffd6003Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 1226145b7b3cSmrg ;; 1227145b7b3cSmrg esac 1228145b7b3cSmrg 1229145b7b3cSmrg func_infer_tag $base_compile 1230145b7b3cSmrg 1231145b7b3cSmrg for arg in $later; do 1232145b7b3cSmrg case $arg in 12335ffd6003Smrg -shared) 12345ffd6003Smrg test "$build_libtool_libs" != yes && \ 12355ffd6003Smrg func_fatal_configuration "can not build a shared library" 12365ffd6003Smrg build_old_libs=no 12375ffd6003Smrg continue 12385ffd6003Smrg ;; 12395ffd6003Smrg 1240145b7b3cSmrg -static) 12415ffd6003Smrg build_libtool_libs=no 1242145b7b3cSmrg build_old_libs=yes 1243145b7b3cSmrg continue 1244145b7b3cSmrg ;; 1245145b7b3cSmrg 1246145b7b3cSmrg -prefer-pic) 1247145b7b3cSmrg pic_mode=yes 1248145b7b3cSmrg continue 1249145b7b3cSmrg ;; 1250145b7b3cSmrg 1251145b7b3cSmrg -prefer-non-pic) 1252145b7b3cSmrg pic_mode=no 1253145b7b3cSmrg continue 1254145b7b3cSmrg ;; 1255145b7b3cSmrg esac 1256145b7b3cSmrg done 1257145b7b3cSmrg 12585ffd6003Smrg func_quote_for_eval "$libobj" 12595ffd6003Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 12605ffd6003Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 12615ffd6003Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 12625ffd6003Smrg func_dirname_and_basename "$obj" "/" "" 12635ffd6003Smrg objname="$func_basename_result" 12645ffd6003Smrg xdir="$func_dirname_result" 1265145b7b3cSmrg lobj=${xdir}$objdir/$objname 1266145b7b3cSmrg 12675ffd6003Smrg test -z "$base_compile" && \ 12685ffd6003Smrg func_fatal_help "you must specify a compilation command" 1269145b7b3cSmrg 1270145b7b3cSmrg # Delete any leftover library objects. 1271145b7b3cSmrg if test "$build_old_libs" = yes; then 1272145b7b3cSmrg removelist="$obj $lobj $libobj ${libobj}T" 1273145b7b3cSmrg else 1274145b7b3cSmrg removelist="$lobj $libobj ${libobj}T" 1275145b7b3cSmrg fi 1276145b7b3cSmrg 1277145b7b3cSmrg # On Cygwin there's no "real" PIC flag so we must build both object types 1278145b7b3cSmrg case $host_os in 12795ffd6003Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 1280145b7b3cSmrg pic_mode=default 1281145b7b3cSmrg ;; 1282145b7b3cSmrg esac 1283145b7b3cSmrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 1284145b7b3cSmrg # non-PIC code in shared libraries is not supported 1285145b7b3cSmrg pic_mode=default 1286145b7b3cSmrg fi 1287145b7b3cSmrg 1288145b7b3cSmrg # Calculate the filename of the output object if compiler does 1289145b7b3cSmrg # not support -o with -c 1290145b7b3cSmrg if test "$compiler_c_o" = no; then 12915ffd6003Smrg output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext} 1292145b7b3cSmrg lockfile="$output_obj.lock" 1293145b7b3cSmrg else 1294145b7b3cSmrg output_obj= 1295145b7b3cSmrg need_locks=no 1296145b7b3cSmrg lockfile= 1297145b7b3cSmrg fi 1298145b7b3cSmrg 1299145b7b3cSmrg # Lock this critical section if it is needed 1300145b7b3cSmrg # We use this script file to make the link, it avoids creating a new file 1301145b7b3cSmrg if test "$need_locks" = yes; then 13025ffd6003Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 13035ffd6003Smrg func_echo "Waiting for $lockfile to be removed" 1304145b7b3cSmrg sleep 2 1305145b7b3cSmrg done 1306145b7b3cSmrg elif test "$need_locks" = warn; then 1307145b7b3cSmrg if test -f "$lockfile"; then 13085ffd6003Smrg $ECHO "\ 1309145b7b3cSmrg*** ERROR, $lockfile exists and contains: 1310145b7b3cSmrg`cat $lockfile 2>/dev/null` 1311145b7b3cSmrg 1312145b7b3cSmrgThis indicates that another process is trying to use the same 1313145b7b3cSmrgtemporary object file, and libtool could not work around it because 1314145b7b3cSmrgyour compiler does not support \`-c' and \`-o' together. If you 1315145b7b3cSmrgrepeat this compilation, it may succeed, by chance, but you had better 1316145b7b3cSmrgavoid parallel builds (make -j) in this platform, or get a better 1317145b7b3cSmrgcompiler." 1318145b7b3cSmrg 13195ffd6003Smrg $opt_dry_run || $RM $removelist 1320145b7b3cSmrg exit $EXIT_FAILURE 1321145b7b3cSmrg fi 13225ffd6003Smrg removelist="$removelist $output_obj" 13235ffd6003Smrg $ECHO "$srcfile" > "$lockfile" 1324145b7b3cSmrg fi 1325145b7b3cSmrg 13265ffd6003Smrg $opt_dry_run || $RM $removelist 13275ffd6003Smrg removelist="$removelist $lockfile" 13285ffd6003Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 13295ffd6003Smrg 1330145b7b3cSmrg if test -n "$fix_srcfile_path"; then 1331145b7b3cSmrg eval srcfile=\"$fix_srcfile_path\" 1332145b7b3cSmrg fi 13335ffd6003Smrg func_quote_for_eval "$srcfile" 13345ffd6003Smrg qsrcfile=$func_quote_for_eval_result 1335145b7b3cSmrg 1336145b7b3cSmrg # Only build a PIC object if we are building libtool libraries. 1337145b7b3cSmrg if test "$build_libtool_libs" = yes; then 1338145b7b3cSmrg # Without this assignment, base_compile gets emptied. 1339145b7b3cSmrg fbsd_hideous_sh_bug=$base_compile 1340145b7b3cSmrg 1341145b7b3cSmrg if test "$pic_mode" != no; then 1342145b7b3cSmrg command="$base_compile $qsrcfile $pic_flag" 1343145b7b3cSmrg else 1344145b7b3cSmrg # Don't build PIC code 1345145b7b3cSmrg command="$base_compile $qsrcfile" 1346145b7b3cSmrg fi 1347145b7b3cSmrg 13485ffd6003Smrg func_mkdir_p "$xdir$objdir" 1349145b7b3cSmrg 1350145b7b3cSmrg if test -z "$output_obj"; then 1351145b7b3cSmrg # Place PIC objects in $objdir 1352145b7b3cSmrg command="$command -o $lobj" 1353145b7b3cSmrg fi 1354145b7b3cSmrg 13555ffd6003Smrg func_show_eval_locale "$command" \ 13565ffd6003Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 1357145b7b3cSmrg 1358145b7b3cSmrg if test "$need_locks" = warn && 1359145b7b3cSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 13605ffd6003Smrg $ECHO "\ 1361145b7b3cSmrg*** ERROR, $lockfile contains: 1362145b7b3cSmrg`cat $lockfile 2>/dev/null` 1363145b7b3cSmrg 1364145b7b3cSmrgbut it should contain: 1365145b7b3cSmrg$srcfile 1366145b7b3cSmrg 1367145b7b3cSmrgThis indicates that another process is trying to use the same 1368145b7b3cSmrgtemporary object file, and libtool could not work around it because 1369145b7b3cSmrgyour compiler does not support \`-c' and \`-o' together. If you 1370145b7b3cSmrgrepeat this compilation, it may succeed, by chance, but you had better 1371145b7b3cSmrgavoid parallel builds (make -j) in this platform, or get a better 1372145b7b3cSmrgcompiler." 1373145b7b3cSmrg 13745ffd6003Smrg $opt_dry_run || $RM $removelist 1375145b7b3cSmrg exit $EXIT_FAILURE 1376145b7b3cSmrg fi 1377145b7b3cSmrg 1378145b7b3cSmrg # Just move the object if needed, then go on to compile the next one 1379145b7b3cSmrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 13805ffd6003Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 13815ffd6003Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 1382145b7b3cSmrg fi 1383145b7b3cSmrg 1384145b7b3cSmrg # Allow error messages only from the first compilation. 1385145b7b3cSmrg if test "$suppress_opt" = yes; then 13865ffd6003Smrg suppress_output=' >/dev/null 2>&1' 1387145b7b3cSmrg fi 1388145b7b3cSmrg fi 1389145b7b3cSmrg 1390145b7b3cSmrg # Only build a position-dependent object if we build old libraries. 1391145b7b3cSmrg if test "$build_old_libs" = yes; then 1392145b7b3cSmrg if test "$pic_mode" != yes; then 1393145b7b3cSmrg # Don't build PIC code 13945ffd6003Smrg command="$base_compile $qsrcfile$pie_flag" 1395145b7b3cSmrg else 1396145b7b3cSmrg command="$base_compile $qsrcfile $pic_flag" 1397145b7b3cSmrg fi 1398145b7b3cSmrg if test "$compiler_c_o" = yes; then 1399145b7b3cSmrg command="$command -o $obj" 1400145b7b3cSmrg fi 1401145b7b3cSmrg 1402145b7b3cSmrg # Suppress compiler output if we already did a PIC compilation. 1403145b7b3cSmrg command="$command$suppress_output" 14045ffd6003Smrg func_show_eval_locale "$command" \ 14055ffd6003Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1406145b7b3cSmrg 1407145b7b3cSmrg if test "$need_locks" = warn && 1408145b7b3cSmrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 14095ffd6003Smrg $ECHO "\ 1410145b7b3cSmrg*** ERROR, $lockfile contains: 1411145b7b3cSmrg`cat $lockfile 2>/dev/null` 1412145b7b3cSmrg 1413145b7b3cSmrgbut it should contain: 1414145b7b3cSmrg$srcfile 1415145b7b3cSmrg 1416145b7b3cSmrgThis indicates that another process is trying to use the same 1417145b7b3cSmrgtemporary object file, and libtool could not work around it because 1418145b7b3cSmrgyour compiler does not support \`-c' and \`-o' together. If you 1419145b7b3cSmrgrepeat this compilation, it may succeed, by chance, but you had better 1420145b7b3cSmrgavoid parallel builds (make -j) in this platform, or get a better 1421145b7b3cSmrgcompiler." 1422145b7b3cSmrg 14235ffd6003Smrg $opt_dry_run || $RM $removelist 1424145b7b3cSmrg exit $EXIT_FAILURE 1425145b7b3cSmrg fi 1426145b7b3cSmrg 1427145b7b3cSmrg # Just move the object if needed 1428145b7b3cSmrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 14295ffd6003Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 14305ffd6003Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 1431145b7b3cSmrg fi 1432145b7b3cSmrg fi 1433145b7b3cSmrg 14345ffd6003Smrg $opt_dry_run || { 14355ffd6003Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 1436145b7b3cSmrg 14375ffd6003Smrg # Unlock the critical section if it was locked 14385ffd6003Smrg if test "$need_locks" != no; then 14395ffd6003Smrg removelist=$lockfile 14405ffd6003Smrg $RM "$lockfile" 14415ffd6003Smrg fi 14425ffd6003Smrg } 1443145b7b3cSmrg 1444145b7b3cSmrg exit $EXIT_SUCCESS 14455ffd6003Smrg} 1446145b7b3cSmrg 14475ffd6003Smrg$opt_help || { 14485ffd6003Smrgtest "$mode" = compile && func_mode_compile ${1+"$@"} 14495ffd6003Smrg} 1450145b7b3cSmrg 14515ffd6003Smrgfunc_mode_help () 14525ffd6003Smrg{ 14535ffd6003Smrg # We need to display help for each of the modes. 14545ffd6003Smrg case $mode in 14555ffd6003Smrg "") 14565ffd6003Smrg # Generic help is extracted from the usage comments 14575ffd6003Smrg # at the start of this file. 14585ffd6003Smrg func_help 14595ffd6003Smrg ;; 1460145b7b3cSmrg 14615ffd6003Smrg clean) 14625ffd6003Smrg $ECHO \ 14635ffd6003Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 1464145b7b3cSmrg 14655ffd6003SmrgRemove files from the build directory. 1466145b7b3cSmrg 14675ffd6003SmrgRM is the name of the program to use to delete files associated with each FILE 14685ffd6003Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 14695ffd6003Smrgto RM. 1470145b7b3cSmrg 14715ffd6003SmrgIf FILE is a libtool library, object or program, all the files associated 14725ffd6003Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 14735ffd6003Smrg ;; 1474145b7b3cSmrg 14755ffd6003Smrg compile) 14765ffd6003Smrg $ECHO \ 14775ffd6003Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 1478145b7b3cSmrg 14795ffd6003SmrgCompile a source file into a libtool library object. 1480145b7b3cSmrg 14815ffd6003SmrgThis mode accepts the following additional options: 1482145b7b3cSmrg 14835ffd6003Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 14845ffd6003Smrg -no-suppress do not suppress compiler output for multiple passes 14855ffd6003Smrg -prefer-pic try to building PIC objects only 14865ffd6003Smrg -prefer-non-pic try to building non-PIC objects only 14875ffd6003Smrg -shared do not build a \`.o' file suitable for static linking 14885ffd6003Smrg -static only build a \`.o' file suitable for static linking 1489145b7b3cSmrg 14905ffd6003SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 14915ffd6003Smrgfrom the given SOURCEFILE. 1492145b7b3cSmrg 14935ffd6003SmrgThe output file name is determined by removing the directory component from 14945ffd6003SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 14955ffd6003Smrglibrary object suffix, \`.lo'." 14965ffd6003Smrg ;; 1497145b7b3cSmrg 14985ffd6003Smrg execute) 14995ffd6003Smrg $ECHO \ 15005ffd6003Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 1501145b7b3cSmrg 15025ffd6003SmrgAutomatically set library path, then run a program. 1503145b7b3cSmrg 15045ffd6003SmrgThis mode accepts the following additional options: 1505145b7b3cSmrg 15065ffd6003Smrg -dlopen FILE add the directory containing FILE to the library path 1507145b7b3cSmrg 15085ffd6003SmrgThis mode sets the library path environment variable according to \`-dlopen' 15095ffd6003Smrgflags. 1510145b7b3cSmrg 15115ffd6003SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 15125ffd6003Smrginto their corresponding uninstalled binary, and any of their required library 15135ffd6003Smrgdirectories are added to the library path. 1514145b7b3cSmrg 15155ffd6003SmrgThen, COMMAND is executed, with ARGS as arguments." 15165ffd6003Smrg ;; 1517145b7b3cSmrg 15185ffd6003Smrg finish) 15195ffd6003Smrg $ECHO \ 15205ffd6003Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 1521145b7b3cSmrg 15225ffd6003SmrgComplete the installation of libtool libraries. 1523145b7b3cSmrg 15245ffd6003SmrgEach LIBDIR is a directory that contains libtool libraries. 1525145b7b3cSmrg 15265ffd6003SmrgThe commands that this mode executes may require superuser privileges. Use 15275ffd6003Smrgthe \`--dry-run' option if you just want to see what would be executed." 15285ffd6003Smrg ;; 1529145b7b3cSmrg 15305ffd6003Smrg install) 15315ffd6003Smrg $ECHO \ 15325ffd6003Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 1533145b7b3cSmrg 15345ffd6003SmrgInstall executables or libraries. 1535145b7b3cSmrg 15365ffd6003SmrgINSTALL-COMMAND is the installation command. The first component should be 15375ffd6003Smrgeither the \`install' or \`cp' program. 1538145b7b3cSmrg 15395ffd6003SmrgThe following components of INSTALL-COMMAND are treated specially: 1540145b7b3cSmrg 15415ffd6003Smrg -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation 1542145b7b3cSmrg 15435ffd6003SmrgThe rest of the components are interpreted as arguments to that command (only 15445ffd6003SmrgBSD-compatible install options are recognized)." 15455ffd6003Smrg ;; 1546145b7b3cSmrg 15475ffd6003Smrg link) 15485ffd6003Smrg $ECHO \ 15495ffd6003Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 1550145b7b3cSmrg 15515ffd6003SmrgLink object files or libraries together to form another library, or to 15525ffd6003Smrgcreate an executable program. 1553145b7b3cSmrg 15545ffd6003SmrgLINK-COMMAND is a command using the C compiler that you would use to create 15555ffd6003Smrga program from several object files. 1556145b7b3cSmrg 15575ffd6003SmrgThe following components of LINK-COMMAND are treated specially: 1558145b7b3cSmrg 15595ffd6003Smrg -all-static do not do any dynamic linking at all 15605ffd6003Smrg -avoid-version do not add a version suffix if possible 15615ffd6003Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 15625ffd6003Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 15635ffd6003Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 15645ffd6003Smrg -export-symbols SYMFILE 15655ffd6003Smrg try to export only the symbols listed in SYMFILE 15665ffd6003Smrg -export-symbols-regex REGEX 15675ffd6003Smrg try to export only the symbols matching REGEX 15685ffd6003Smrg -LLIBDIR search LIBDIR for required installed libraries 15695ffd6003Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 15705ffd6003Smrg -module build a library that can dlopened 15715ffd6003Smrg -no-fast-install disable the fast-install mode 15725ffd6003Smrg -no-install link a not-installable executable 15735ffd6003Smrg -no-undefined declare that a library does not refer to external symbols 15745ffd6003Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 15755ffd6003Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 15765ffd6003Smrg -precious-files-regex REGEX 15775ffd6003Smrg don't remove output files matching REGEX 15785ffd6003Smrg -release RELEASE specify package release information 15795ffd6003Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 15805ffd6003Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 15815ffd6003Smrg -shared only do dynamic linking of libtool libraries 15825ffd6003Smrg -shrext SUFFIX override the standard shared library file extension 15835ffd6003Smrg -static do not do any dynamic linking of uninstalled libtool libraries 15845ffd6003Smrg -static-libtool-libs 15855ffd6003Smrg do not do any dynamic linking of libtool libraries 15865ffd6003Smrg -version-info CURRENT[:REVISION[:AGE]] 15875ffd6003Smrg specify library version info [each variable defaults to 0] 15885ffd6003Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 1589145b7b3cSmrg 15905ffd6003SmrgAll other options (arguments beginning with \`-') are ignored. 1591145b7b3cSmrg 15925ffd6003SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 15935ffd6003Smrgtreated as uninstalled libtool libraries, other files are standard or library 15945ffd6003Smrgobject files. 1595578741aaSmrg 15965ffd6003SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 15975ffd6003Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 15985ffd6003Smrgrequired, except when creating a convenience library. 1599145b7b3cSmrg 16005ffd6003SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 16015ffd6003Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 1602145b7b3cSmrg 16035ffd6003SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 16045ffd6003Smrgis created, otherwise an executable program is created." 1605145b7b3cSmrg ;; 1606145b7b3cSmrg 16075ffd6003Smrg uninstall) 16085ffd6003Smrg $ECHO \ 16095ffd6003Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 1610145b7b3cSmrg 16115ffd6003SmrgRemove libraries from an installation directory. 1612145b7b3cSmrg 16135ffd6003SmrgRM is the name of the program to use to delete files associated with each FILE 16145ffd6003Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 16155ffd6003Smrgto RM. 1616145b7b3cSmrg 16175ffd6003SmrgIf FILE is a libtool library, all the files associated with it are deleted. 16185ffd6003SmrgOtherwise, only FILE itself is deleted using RM." 16195ffd6003Smrg ;; 1620145b7b3cSmrg 16215ffd6003Smrg *) 16225ffd6003Smrg func_fatal_help "invalid operation mode \`$mode'" 16235ffd6003Smrg ;; 16245ffd6003Smrg esac 1625145b7b3cSmrg 16265ffd6003Smrg $ECHO 16275ffd6003Smrg $ECHO "Try \`$progname --help' for more information about other modes." 1628145b7b3cSmrg 16295ffd6003Smrg exit $? 16305ffd6003Smrg} 1631145b7b3cSmrg 16325ffd6003Smrg # Now that we've collected a possible --mode arg, show help if necessary 16335ffd6003Smrg $opt_help && func_mode_help 1634145b7b3cSmrg 1635145b7b3cSmrg 16365ffd6003Smrg# func_mode_execute arg... 16375ffd6003Smrgfunc_mode_execute () 16385ffd6003Smrg{ 16395ffd6003Smrg $opt_debug 16405ffd6003Smrg # The first argument is the command name. 16415ffd6003Smrg cmd="$nonopt" 16425ffd6003Smrg test -z "$cmd" && \ 16435ffd6003Smrg func_fatal_help "you must specify a COMMAND" 1644145b7b3cSmrg 16455ffd6003Smrg # Handle -dlopen flags immediately. 16465ffd6003Smrg for file in $execute_dlfiles; do 16475ffd6003Smrg test -f "$file" \ 16485ffd6003Smrg || func_fatal_help "\`$file' is not a file" 1649145b7b3cSmrg 16505ffd6003Smrg dir= 16515ffd6003Smrg case $file in 16525ffd6003Smrg *.la) 16535ffd6003Smrg # Check to see that this really is a libtool archive. 16545ffd6003Smrg func_lalib_unsafe_p "$file" \ 16555ffd6003Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 1656145b7b3cSmrg 16575ffd6003Smrg # Read the libtool library. 16585ffd6003Smrg dlname= 16595ffd6003Smrg library_names= 16605ffd6003Smrg func_source "$file" 1661145b7b3cSmrg 16625ffd6003Smrg # Skip this library if it cannot be dlopened. 16635ffd6003Smrg if test -z "$dlname"; then 16645ffd6003Smrg # Warn if it was a shared library. 16655ffd6003Smrg test -n "$library_names" && \ 16665ffd6003Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 16675ffd6003Smrg continue 16685ffd6003Smrg fi 1669145b7b3cSmrg 16705ffd6003Smrg func_dirname "$file" "" "." 16715ffd6003Smrg dir="$func_dirname_result" 1672145b7b3cSmrg 16735ffd6003Smrg if test -f "$dir/$objdir/$dlname"; then 16745ffd6003Smrg dir="$dir/$objdir" 16755ffd6003Smrg else 16765ffd6003Smrg if test ! -f "$dir/$dlname"; then 16775ffd6003Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 16785ffd6003Smrg fi 16795ffd6003Smrg fi 1680145b7b3cSmrg ;; 1681145b7b3cSmrg 16825ffd6003Smrg *.lo) 16835ffd6003Smrg # Just add the directory containing the .lo file. 16845ffd6003Smrg func_dirname "$file" "" "." 16855ffd6003Smrg dir="$func_dirname_result" 1686145b7b3cSmrg ;; 1687145b7b3cSmrg 16885ffd6003Smrg *) 16895ffd6003Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 1690145b7b3cSmrg continue 1691145b7b3cSmrg ;; 16925ffd6003Smrg esac 1693145b7b3cSmrg 16945ffd6003Smrg # Get the absolute pathname. 16955ffd6003Smrg absdir=`cd "$dir" && pwd` 16965ffd6003Smrg test -n "$absdir" && dir="$absdir" 1697145b7b3cSmrg 16985ffd6003Smrg # Now add the directory to shlibpath_var. 16995ffd6003Smrg if eval "test -z \"\$$shlibpath_var\""; then 17005ffd6003Smrg eval "$shlibpath_var=\"\$dir\"" 17015ffd6003Smrg else 17025ffd6003Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 17035ffd6003Smrg fi 17045ffd6003Smrg done 1705145b7b3cSmrg 17065ffd6003Smrg # This variable tells wrapper scripts just to set shlibpath_var 17075ffd6003Smrg # rather than running their programs. 17085ffd6003Smrg libtool_execute_magic="$magic" 1709145b7b3cSmrg 17105ffd6003Smrg # Check if any of the arguments is a wrapper script. 17115ffd6003Smrg args= 17125ffd6003Smrg for file 17135ffd6003Smrg do 17145ffd6003Smrg case $file in 17155ffd6003Smrg -*) ;; 17165ffd6003Smrg *) 17175ffd6003Smrg # Do a test to see if this is really a libtool program. 17185ffd6003Smrg if func_ltwrapper_script_p "$file"; then 17195ffd6003Smrg func_source "$file" 17205ffd6003Smrg # Transform arg to wrapped name. 17215ffd6003Smrg file="$progdir/$program" 17225ffd6003Smrg elif func_ltwrapper_executable_p "$file"; then 17235ffd6003Smrg func_ltwrapper_scriptname "$file" 17245ffd6003Smrg func_source "$func_ltwrapper_scriptname_result" 17255ffd6003Smrg # Transform arg to wrapped name. 17265ffd6003Smrg file="$progdir/$program" 17275ffd6003Smrg fi 17285ffd6003Smrg ;; 17295ffd6003Smrg esac 17305ffd6003Smrg # Quote arguments (to preserve shell metacharacters). 17315ffd6003Smrg func_quote_for_eval "$file" 17325ffd6003Smrg args="$args $func_quote_for_eval_result" 17335ffd6003Smrg done 1734145b7b3cSmrg 17355ffd6003Smrg if test "X$opt_dry_run" = Xfalse; then 17365ffd6003Smrg if test -n "$shlibpath_var"; then 17375ffd6003Smrg # Export the shlibpath_var. 17385ffd6003Smrg eval "export $shlibpath_var" 17395ffd6003Smrg fi 1740145b7b3cSmrg 17415ffd6003Smrg # Restore saved environment variables 17425ffd6003Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 17435ffd6003Smrg do 17445ffd6003Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 17455ffd6003Smrg $lt_var=\$save_$lt_var; export $lt_var 1746145b7b3cSmrg else 17475ffd6003Smrg $lt_unset $lt_var 17485ffd6003Smrg fi" 17495ffd6003Smrg done 1750145b7b3cSmrg 17515ffd6003Smrg # Now prepare to actually exec the command. 17525ffd6003Smrg exec_cmd="\$cmd$args" 17535ffd6003Smrg else 17545ffd6003Smrg # Display what would be done. 17555ffd6003Smrg if test -n "$shlibpath_var"; then 17565ffd6003Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 17575ffd6003Smrg $ECHO "export $shlibpath_var" 17585ffd6003Smrg fi 17595ffd6003Smrg $ECHO "$cmd$args" 17605ffd6003Smrg exit $EXIT_SUCCESS 17615ffd6003Smrg fi 17625ffd6003Smrg} 1763145b7b3cSmrg 17645ffd6003Smrgtest "$mode" = execute && func_mode_execute ${1+"$@"} 1765145b7b3cSmrg 1766145b7b3cSmrg 17675ffd6003Smrg# func_mode_finish arg... 17685ffd6003Smrgfunc_mode_finish () 17695ffd6003Smrg{ 17705ffd6003Smrg $opt_debug 17715ffd6003Smrg libdirs="$nonopt" 17725ffd6003Smrg admincmds= 1773145b7b3cSmrg 17745ffd6003Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 17755ffd6003Smrg for dir 17765ffd6003Smrg do 17775ffd6003Smrg libdirs="$libdirs $dir" 17785ffd6003Smrg done 1779145b7b3cSmrg 17805ffd6003Smrg for libdir in $libdirs; do 17815ffd6003Smrg if test -n "$finish_cmds"; then 17825ffd6003Smrg # Do each command in the finish commands. 17835ffd6003Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 17845ffd6003Smrg'"$cmd"'"' 1785145b7b3cSmrg fi 17865ffd6003Smrg if test -n "$finish_eval"; then 17875ffd6003Smrg # Do the single finish_eval. 17885ffd6003Smrg eval cmds=\"$finish_eval\" 17895ffd6003Smrg $opt_dry_run || eval "$cmds" || admincmds="$admincmds 17905ffd6003Smrg $cmds" 17915ffd6003Smrg fi 17925ffd6003Smrg done 17935ffd6003Smrg fi 1794145b7b3cSmrg 17955ffd6003Smrg # Exit here if they wanted silent mode. 17965ffd6003Smrg $opt_silent && exit $EXIT_SUCCESS 1797145b7b3cSmrg 17985ffd6003Smrg $ECHO "X----------------------------------------------------------------------" | $Xsed 17995ffd6003Smrg $ECHO "Libraries have been installed in:" 18005ffd6003Smrg for libdir in $libdirs; do 18015ffd6003Smrg $ECHO " $libdir" 18025ffd6003Smrg done 18035ffd6003Smrg $ECHO 18045ffd6003Smrg $ECHO "If you ever happen to want to link against installed libraries" 18055ffd6003Smrg $ECHO "in a given directory, LIBDIR, you must either use libtool, and" 18065ffd6003Smrg $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'" 18075ffd6003Smrg $ECHO "flag during linking and do at least one of the following:" 18085ffd6003Smrg if test -n "$shlibpath_var"; then 18095ffd6003Smrg $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable" 18105ffd6003Smrg $ECHO " during execution" 18115ffd6003Smrg fi 18125ffd6003Smrg if test -n "$runpath_var"; then 18135ffd6003Smrg $ECHO " - add LIBDIR to the \`$runpath_var' environment variable" 18145ffd6003Smrg $ECHO " during linking" 18155ffd6003Smrg fi 18165ffd6003Smrg if test -n "$hardcode_libdir_flag_spec"; then 18175ffd6003Smrg libdir=LIBDIR 18185ffd6003Smrg eval flag=\"$hardcode_libdir_flag_spec\" 18195ffd6003Smrg 18205ffd6003Smrg $ECHO " - use the \`$flag' linker flag" 18215ffd6003Smrg fi 18225ffd6003Smrg if test -n "$admincmds"; then 18235ffd6003Smrg $ECHO " - have your system administrator run these commands:$admincmds" 18245ffd6003Smrg fi 18255ffd6003Smrg if test -f /etc/ld.so.conf; then 18265ffd6003Smrg $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 18275ffd6003Smrg fi 18285ffd6003Smrg $ECHO 18295ffd6003Smrg 18305ffd6003Smrg $ECHO "See any operating system documentation about shared libraries for" 18315ffd6003Smrg case $host in 18325ffd6003Smrg solaris2.[6789]|solaris2.1[0-9]) 18335ffd6003Smrg $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual" 18345ffd6003Smrg $ECHO "pages." 18355ffd6003Smrg ;; 18365ffd6003Smrg *) 18375ffd6003Smrg $ECHO "more information, such as the ld(1) and ld.so(8) manual pages." 18385ffd6003Smrg ;; 18395ffd6003Smrg esac 18405ffd6003Smrg $ECHO "X----------------------------------------------------------------------" | $Xsed 18415ffd6003Smrg exit $EXIT_SUCCESS 18425ffd6003Smrg} 18435ffd6003Smrg 18445ffd6003Smrgtest "$mode" = finish && func_mode_finish ${1+"$@"} 18455ffd6003Smrg 18465ffd6003Smrg 18475ffd6003Smrg# func_mode_install arg... 18485ffd6003Smrgfunc_mode_install () 18495ffd6003Smrg{ 18505ffd6003Smrg $opt_debug 18515ffd6003Smrg # There may be an optional sh(1) argument at the beginning of 18525ffd6003Smrg # install_prog (especially on Windows NT). 18535ffd6003Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 18545ffd6003Smrg # Allow the use of GNU shtool's install command. 18555ffd6003Smrg $ECHO "X$nonopt" | $GREP shtool >/dev/null; then 18565ffd6003Smrg # Aesthetically quote it. 18575ffd6003Smrg func_quote_for_eval "$nonopt" 18585ffd6003Smrg install_prog="$func_quote_for_eval_result " 18595ffd6003Smrg arg=$1 18605ffd6003Smrg shift 18615ffd6003Smrg else 18625ffd6003Smrg install_prog= 18635ffd6003Smrg arg=$nonopt 18645ffd6003Smrg fi 18655ffd6003Smrg 18665ffd6003Smrg # The real first argument should be the name of the installation program. 18675ffd6003Smrg # Aesthetically quote it. 18685ffd6003Smrg func_quote_for_eval "$arg" 18695ffd6003Smrg install_prog="$install_prog$func_quote_for_eval_result" 18705ffd6003Smrg 18715ffd6003Smrg # We need to accept at least all the BSD install flags. 18725ffd6003Smrg dest= 18735ffd6003Smrg files= 18745ffd6003Smrg opts= 18755ffd6003Smrg prev= 18765ffd6003Smrg install_type= 18775ffd6003Smrg isdir=no 18785ffd6003Smrg stripme= 18795ffd6003Smrg for arg 18805ffd6003Smrg do 18815ffd6003Smrg if test -n "$dest"; then 18825ffd6003Smrg files="$files $dest" 18835ffd6003Smrg dest=$arg 18845ffd6003Smrg continue 18855ffd6003Smrg fi 18865ffd6003Smrg 18875ffd6003Smrg case $arg in 18885ffd6003Smrg -d) isdir=yes ;; 18895ffd6003Smrg -f) 18905ffd6003Smrg case " $install_prog " in 18915ffd6003Smrg *[\\\ /]cp\ *) ;; 18925ffd6003Smrg *) prev=$arg ;; 18935ffd6003Smrg esac 18945ffd6003Smrg ;; 18955ffd6003Smrg -g | -m | -o) 18965ffd6003Smrg prev=$arg 18975ffd6003Smrg ;; 18985ffd6003Smrg -s) 18995ffd6003Smrg stripme=" -s" 19005ffd6003Smrg continue 19015ffd6003Smrg ;; 19025ffd6003Smrg -*) 19035ffd6003Smrg ;; 19045ffd6003Smrg *) 19055ffd6003Smrg # If the previous option needed an argument, then skip it. 19065ffd6003Smrg if test -n "$prev"; then 1907145b7b3cSmrg prev= 1908145b7b3cSmrg else 19095ffd6003Smrg dest=$arg 19105ffd6003Smrg continue 1911145b7b3cSmrg fi 1912145b7b3cSmrg ;; 19135ffd6003Smrg esac 1914145b7b3cSmrg 19155ffd6003Smrg # Aesthetically quote the argument. 19165ffd6003Smrg func_quote_for_eval "$arg" 19175ffd6003Smrg install_prog="$install_prog $func_quote_for_eval_result" 19185ffd6003Smrg done 1919145b7b3cSmrg 19205ffd6003Smrg test -z "$install_prog" && \ 19215ffd6003Smrg func_fatal_help "you must specify an install program" 1922145b7b3cSmrg 19235ffd6003Smrg test -n "$prev" && \ 19245ffd6003Smrg func_fatal_help "the \`$prev' option requires an argument" 1925145b7b3cSmrg 19265ffd6003Smrg if test -z "$files"; then 19275ffd6003Smrg if test -z "$dest"; then 19285ffd6003Smrg func_fatal_help "no file or destination specified" 19295ffd6003Smrg else 19305ffd6003Smrg func_fatal_help "you must specify a destination" 19315ffd6003Smrg fi 1932145b7b3cSmrg fi 1933145b7b3cSmrg 19345ffd6003Smrg # Strip any trailing slash from the destination. 19355ffd6003Smrg func_stripname '' '/' "$dest" 19365ffd6003Smrg dest=$func_stripname_result 1937145b7b3cSmrg 19385ffd6003Smrg # Check to see that the destination is a directory. 19395ffd6003Smrg test -d "$dest" && isdir=yes 19405ffd6003Smrg if test "$isdir" = yes; then 19415ffd6003Smrg destdir="$dest" 19425ffd6003Smrg destname= 1943145b7b3cSmrg else 19445ffd6003Smrg func_dirname_and_basename "$dest" "" "." 19455ffd6003Smrg destdir="$func_dirname_result" 19465ffd6003Smrg destname="$func_basename_result" 1947145b7b3cSmrg 19485ffd6003Smrg # Not a directory, so check to see that there is only one file specified. 19495ffd6003Smrg set dummy $files; shift 19505ffd6003Smrg test "$#" -gt 1 && \ 19515ffd6003Smrg func_fatal_help "\`$dest' is not a directory" 1952145b7b3cSmrg fi 19535ffd6003Smrg case $destdir in 19545ffd6003Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 1955145b7b3cSmrg *) 19565ffd6003Smrg for file in $files; do 19575ffd6003Smrg case $file in 19585ffd6003Smrg *.lo) ;; 19595ffd6003Smrg *) 19605ffd6003Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 19615ffd6003Smrg ;; 19625ffd6003Smrg esac 19635ffd6003Smrg done 1964145b7b3cSmrg ;; 1965145b7b3cSmrg esac 1966145b7b3cSmrg 19675ffd6003Smrg # This variable tells wrapper scripts just to set variables rather 19685ffd6003Smrg # than running their programs. 19695ffd6003Smrg libtool_install_magic="$magic" 1970145b7b3cSmrg 19715ffd6003Smrg staticlibs= 19725ffd6003Smrg future_libdirs= 19735ffd6003Smrg current_libdirs= 19745ffd6003Smrg for file in $files; do 1975145b7b3cSmrg 19765ffd6003Smrg # Do each installation. 19775ffd6003Smrg case $file in 19785ffd6003Smrg *.$libext) 19795ffd6003Smrg # Do the static libraries later. 19805ffd6003Smrg staticlibs="$staticlibs $file" 19815ffd6003Smrg ;; 19825ffd6003Smrg 19835ffd6003Smrg *.la) 19845ffd6003Smrg # Check to see that this really is a libtool archive. 19855ffd6003Smrg func_lalib_unsafe_p "$file" \ 19865ffd6003Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 19875ffd6003Smrg 19885ffd6003Smrg library_names= 19895ffd6003Smrg old_library= 19905ffd6003Smrg relink_command= 19915ffd6003Smrg func_source "$file" 19925ffd6003Smrg 19935ffd6003Smrg # Add the libdir to current_libdirs if it is the destination. 19945ffd6003Smrg if test "X$destdir" = "X$libdir"; then 19955ffd6003Smrg case "$current_libdirs " in 19965ffd6003Smrg *" $libdir "*) ;; 19975ffd6003Smrg *) current_libdirs="$current_libdirs $libdir" ;; 1998145b7b3cSmrg esac 19995ffd6003Smrg else 20005ffd6003Smrg # Note the libdir as a future libdir. 20015ffd6003Smrg case "$future_libdirs " in 20025ffd6003Smrg *" $libdir "*) ;; 20035ffd6003Smrg *) future_libdirs="$future_libdirs $libdir" ;; 20045ffd6003Smrg esac 20055ffd6003Smrg fi 2006145b7b3cSmrg 20075ffd6003Smrg func_dirname "$file" "/" "" 20085ffd6003Smrg dir="$func_dirname_result" 20095ffd6003Smrg dir="$dir$objdir" 20105ffd6003Smrg 20115ffd6003Smrg if test -n "$relink_command"; then 20125ffd6003Smrg # Determine the prefix the user has applied to our future dir. 20135ffd6003Smrg inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"` 20145ffd6003Smrg 20155ffd6003Smrg # Don't allow the user to place us outside of our expected 20165ffd6003Smrg # location b/c this prevents finding dependent libraries that 20175ffd6003Smrg # are installed to the same prefix. 20185ffd6003Smrg # At present, this check doesn't affect windows .dll's that 20195ffd6003Smrg # are installed into $libdir/../bin (currently, that works fine) 20205ffd6003Smrg # but it's something to keep an eye on. 20215ffd6003Smrg test "$inst_prefix_dir" = "$destdir" && \ 20225ffd6003Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 20235ffd6003Smrg 20245ffd6003Smrg if test -n "$inst_prefix_dir"; then 20255ffd6003Smrg # Stick the inst_prefix_dir data into the link command. 20265ffd6003Smrg relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 20275ffd6003Smrg else 20285ffd6003Smrg relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"` 20295ffd6003Smrg fi 20305ffd6003Smrg 20315ffd6003Smrg func_warning "relinking \`$file'" 20325ffd6003Smrg func_show_eval "$relink_command" \ 20335ffd6003Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 20345ffd6003Smrg fi 20355ffd6003Smrg 20365ffd6003Smrg # See the names of the shared library. 20375ffd6003Smrg set dummy $library_names; shift 20385ffd6003Smrg if test -n "$1"; then 20395ffd6003Smrg realname="$1" 20405ffd6003Smrg shift 20415ffd6003Smrg 20425ffd6003Smrg srcname="$realname" 20435ffd6003Smrg test -n "$relink_command" && srcname="$realname"T 20445ffd6003Smrg 20455ffd6003Smrg # Install the shared library and build the symlinks. 20465ffd6003Smrg func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \ 20475ffd6003Smrg 'exit $?' 20485ffd6003Smrg tstripme="$stripme" 20495ffd6003Smrg case $host_os in 20505ffd6003Smrg cygwin* | mingw* | pw32* | cegcc*) 20515ffd6003Smrg case $realname in 20525ffd6003Smrg *.dll.a) 20535ffd6003Smrg tstripme="" 20545ffd6003Smrg ;; 20555ffd6003Smrg esac 2056145b7b3cSmrg ;; 2057145b7b3cSmrg esac 20585ffd6003Smrg if test -n "$tstripme" && test -n "$striplib"; then 20595ffd6003Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 2060578741aaSmrg fi 20615ffd6003Smrg 20625ffd6003Smrg if test "$#" -gt 0; then 20635ffd6003Smrg # Delete the old symlinks, and create new ones. 20645ffd6003Smrg # Try `ln -sf' first, because the `ln' binary might depend on 20655ffd6003Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 20665ffd6003Smrg # so we also need to try rm && ln -s. 20675ffd6003Smrg for linkname 20685ffd6003Smrg do 20695ffd6003Smrg test "$linkname" != "$realname" \ 20705ffd6003Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 2071145b7b3cSmrg done 2072145b7b3cSmrg fi 2073145b7b3cSmrg 20745ffd6003Smrg # Do each command in the postinstall commands. 20755ffd6003Smrg lib="$destdir/$realname" 20765ffd6003Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 2077145b7b3cSmrg fi 2078145b7b3cSmrg 20795ffd6003Smrg # Install the pseudo-library for information purposes. 20805ffd6003Smrg func_basename "$file" 20815ffd6003Smrg name="$func_basename_result" 20825ffd6003Smrg instname="$dir/$name"i 20835ffd6003Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 2084145b7b3cSmrg 20855ffd6003Smrg # Maybe install the static library, too. 20865ffd6003Smrg test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library" 20875ffd6003Smrg ;; 2088145b7b3cSmrg 20895ffd6003Smrg *.lo) 20905ffd6003Smrg # Install (i.e. copy) a libtool object. 2091145b7b3cSmrg 20925ffd6003Smrg # Figure out destination file name, if it wasn't already specified. 20935ffd6003Smrg if test -n "$destname"; then 20945ffd6003Smrg destfile="$destdir/$destname" 20955ffd6003Smrg else 20965ffd6003Smrg func_basename "$file" 20975ffd6003Smrg destfile="$func_basename_result" 20985ffd6003Smrg destfile="$destdir/$destfile" 20995ffd6003Smrg fi 21005ffd6003Smrg 21015ffd6003Smrg # Deduce the name of the destination old-style object file. 21025ffd6003Smrg case $destfile in 21035ffd6003Smrg *.lo) 21045ffd6003Smrg func_lo2o "$destfile" 21055ffd6003Smrg staticdest=$func_lo2o_result 21065ffd6003Smrg ;; 21075ffd6003Smrg *.$objext) 21085ffd6003Smrg staticdest="$destfile" 21095ffd6003Smrg destfile= 21105ffd6003Smrg ;; 21115ffd6003Smrg *) 21125ffd6003Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 21135ffd6003Smrg ;; 2114145b7b3cSmrg esac 2115145b7b3cSmrg 21165ffd6003Smrg # Install the libtool object if requested. 21175ffd6003Smrg test -n "$destfile" && \ 21185ffd6003Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 21195ffd6003Smrg 21205ffd6003Smrg # Install the old object if enabled. 21215ffd6003Smrg if test "$build_old_libs" = yes; then 21225ffd6003Smrg # Deduce the name of the old-style object file. 21235ffd6003Smrg func_lo2o "$file" 21245ffd6003Smrg staticobj=$func_lo2o_result 21255ffd6003Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 2126145b7b3cSmrg fi 21275ffd6003Smrg exit $EXIT_SUCCESS 21285ffd6003Smrg ;; 2129145b7b3cSmrg 21305ffd6003Smrg *) 21315ffd6003Smrg # Figure out destination file name, if it wasn't already specified. 21325ffd6003Smrg if test -n "$destname"; then 21335ffd6003Smrg destfile="$destdir/$destname" 21345ffd6003Smrg else 21355ffd6003Smrg func_basename "$file" 21365ffd6003Smrg destfile="$func_basename_result" 21375ffd6003Smrg destfile="$destdir/$destfile" 21385ffd6003Smrg fi 2139145b7b3cSmrg 21405ffd6003Smrg # If the file is missing, and there is a .exe on the end, strip it 21415ffd6003Smrg # because it is most likely a libtool script we actually want to 21425ffd6003Smrg # install 21435ffd6003Smrg stripped_ext="" 21445ffd6003Smrg case $file in 21455ffd6003Smrg *.exe) 21465ffd6003Smrg if test ! -f "$file"; then 21475ffd6003Smrg func_stripname '' '.exe' "$file" 21485ffd6003Smrg file=$func_stripname_result 21495ffd6003Smrg stripped_ext=".exe" 21505ffd6003Smrg fi 21515ffd6003Smrg ;; 21525ffd6003Smrg esac 2153145b7b3cSmrg 21545ffd6003Smrg # Do a test to see if this is really a libtool program. 21555ffd6003Smrg case $host in 21565ffd6003Smrg *cygwin* | *mingw*) 21575ffd6003Smrg if func_ltwrapper_executable_p "$file"; then 21585ffd6003Smrg func_ltwrapper_scriptname "$file" 21595ffd6003Smrg wrapper=$func_ltwrapper_scriptname_result 21605ffd6003Smrg else 21615ffd6003Smrg func_stripname '' '.exe' "$file" 21625ffd6003Smrg wrapper=$func_stripname_result 21635ffd6003Smrg fi 21645ffd6003Smrg ;; 21655ffd6003Smrg *) 21665ffd6003Smrg wrapper=$file 21675ffd6003Smrg ;; 21685ffd6003Smrg esac 21695ffd6003Smrg if func_ltwrapper_script_p "$wrapper"; then 21705ffd6003Smrg notinst_deplibs= 21715ffd6003Smrg relink_command= 2172145b7b3cSmrg 21735ffd6003Smrg func_source "$wrapper" 21745ffd6003Smrg 21755ffd6003Smrg # Check the variables that should have been set. 21765ffd6003Smrg test -z "$generated_by_libtool_version" && \ 21775ffd6003Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 21785ffd6003Smrg 21795ffd6003Smrg finalize=yes 21805ffd6003Smrg for lib in $notinst_deplibs; do 21815ffd6003Smrg # Check to see that each library is installed. 21825ffd6003Smrg libdir= 21835ffd6003Smrg if test -f "$lib"; then 21845ffd6003Smrg func_source "$lib" 21855ffd6003Smrg fi 21865ffd6003Smrg libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test 21875ffd6003Smrg if test -n "$libdir" && test ! -f "$libfile"; then 21885ffd6003Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 21895ffd6003Smrg finalize=no 21905ffd6003Smrg fi 21915ffd6003Smrg done 21925ffd6003Smrg 21935ffd6003Smrg relink_command= 21945ffd6003Smrg func_source "$wrapper" 21955ffd6003Smrg 21965ffd6003Smrg outputname= 21975ffd6003Smrg if test "$fast_install" = no && test -n "$relink_command"; then 21985ffd6003Smrg $opt_dry_run || { 21995ffd6003Smrg if test "$finalize" = yes; then 22005ffd6003Smrg tmpdir=`func_mktempdir` 22015ffd6003Smrg func_basename "$file$stripped_ext" 22025ffd6003Smrg file="$func_basename_result" 22035ffd6003Smrg outputname="$tmpdir/$file" 22045ffd6003Smrg # Replace the output file specification. 22055ffd6003Smrg relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'` 22065ffd6003Smrg 22075ffd6003Smrg $opt_silent || { 22085ffd6003Smrg func_quote_for_expand "$relink_command" 22095ffd6003Smrg eval "func_echo $func_quote_for_expand_result" 22105ffd6003Smrg } 22115ffd6003Smrg if eval "$relink_command"; then : 22125ffd6003Smrg else 22135ffd6003Smrg func_error "error: relink \`$file' with the above command before installing it" 22145ffd6003Smrg $opt_dry_run || ${RM}r "$tmpdir" 22155ffd6003Smrg continue 22165ffd6003Smrg fi 22175ffd6003Smrg file="$outputname" 22185ffd6003Smrg else 22195ffd6003Smrg func_warning "cannot relink \`$file'" 22205ffd6003Smrg fi 22215ffd6003Smrg } 2222145b7b3cSmrg else 22235ffd6003Smrg # Install the binary that we compiled earlier. 22245ffd6003Smrg file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"` 2225145b7b3cSmrg fi 22265ffd6003Smrg fi 2227145b7b3cSmrg 22285ffd6003Smrg # remove .exe since cygwin /usr/bin/install will append another 22295ffd6003Smrg # one anyway 22305ffd6003Smrg case $install_prog,$host in 22315ffd6003Smrg */usr/bin/install*,*cygwin*) 22325ffd6003Smrg case $file:$destfile in 22335ffd6003Smrg *.exe:*.exe) 22345ffd6003Smrg # this is ok 22355ffd6003Smrg ;; 22365ffd6003Smrg *.exe:*) 22375ffd6003Smrg destfile=$destfile.exe 22385ffd6003Smrg ;; 22395ffd6003Smrg *:*.exe) 22405ffd6003Smrg func_stripname '' '.exe' "$destfile" 22415ffd6003Smrg destfile=$func_stripname_result 22425ffd6003Smrg ;; 22435ffd6003Smrg esac 2244145b7b3cSmrg ;; 2245145b7b3cSmrg esac 22465ffd6003Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 22475ffd6003Smrg $opt_dry_run || if test -n "$outputname"; then 22485ffd6003Smrg ${RM}r "$tmpdir" 22495ffd6003Smrg fi 22505ffd6003Smrg ;; 22515ffd6003Smrg esac 22525ffd6003Smrg done 2253145b7b3cSmrg 22545ffd6003Smrg for file in $staticlibs; do 22555ffd6003Smrg func_basename "$file" 22565ffd6003Smrg name="$func_basename_result" 22575ffd6003Smrg 22585ffd6003Smrg # Set up the ranlib parameters. 22595ffd6003Smrg oldlib="$destdir/$name" 22605ffd6003Smrg 22615ffd6003Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 22625ffd6003Smrg 22635ffd6003Smrg if test -n "$stripme" && test -n "$old_striplib"; then 22645ffd6003Smrg func_show_eval "$old_striplib $oldlib" 'exit $?' 22655ffd6003Smrg fi 22665ffd6003Smrg 22675ffd6003Smrg # Do each command in the postinstall commands. 22685ffd6003Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 22695ffd6003Smrg done 22705ffd6003Smrg 22715ffd6003Smrg test -n "$future_libdirs" && \ 22725ffd6003Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 22735ffd6003Smrg 22745ffd6003Smrg if test -n "$current_libdirs"; then 22755ffd6003Smrg # Maybe just do a dry run. 22765ffd6003Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 22775ffd6003Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 22785ffd6003Smrg else 22795ffd6003Smrg exit $EXIT_SUCCESS 22805ffd6003Smrg fi 22815ffd6003Smrg} 22825ffd6003Smrg 22835ffd6003Smrgtest "$mode" = install && func_mode_install ${1+"$@"} 22845ffd6003Smrg 22855ffd6003Smrg 22865ffd6003Smrg# func_generate_dlsyms outputname originator pic_p 22875ffd6003Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 22885ffd6003Smrg# a dlpreopen symbol table. 22895ffd6003Smrgfunc_generate_dlsyms () 22905ffd6003Smrg{ 22915ffd6003Smrg $opt_debug 22925ffd6003Smrg my_outputname="$1" 22935ffd6003Smrg my_originator="$2" 22945ffd6003Smrg my_pic_p="${3-no}" 22955ffd6003Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 22965ffd6003Smrg my_dlsyms= 22975ffd6003Smrg 22985ffd6003Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 22995ffd6003Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 23005ffd6003Smrg my_dlsyms="${my_outputname}S.c" 23015ffd6003Smrg else 23025ffd6003Smrg func_error "not configured to extract global symbols from dlpreopened files" 23035ffd6003Smrg fi 23045ffd6003Smrg fi 23055ffd6003Smrg 23065ffd6003Smrg if test -n "$my_dlsyms"; then 23075ffd6003Smrg case $my_dlsyms in 23085ffd6003Smrg "") ;; 23095ffd6003Smrg *.c) 23105ffd6003Smrg # Discover the nlist of each of the dlfiles. 23115ffd6003Smrg nlist="$output_objdir/${my_outputname}.nm" 23125ffd6003Smrg 23135ffd6003Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 23145ffd6003Smrg 23155ffd6003Smrg # Parse the name list into a source file. 23165ffd6003Smrg func_verbose "creating $output_objdir/$my_dlsyms" 23175ffd6003Smrg 23185ffd6003Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 23195ffd6003Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 23205ffd6003Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 23215ffd6003Smrg 23225ffd6003Smrg#ifdef __cplusplus 23235ffd6003Smrgextern \"C\" { 23245ffd6003Smrg#endif 23255ffd6003Smrg 23265ffd6003Smrg/* External symbol declarations for the compiler. */\ 23275ffd6003Smrg" 23285ffd6003Smrg 23295ffd6003Smrg if test "$dlself" = yes; then 23305ffd6003Smrg func_verbose "generating symbol list for \`$output'" 23315ffd6003Smrg 23325ffd6003Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 23335ffd6003Smrg 23345ffd6003Smrg # Add our own program objects to the symbol list. 23355ffd6003Smrg progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` 23365ffd6003Smrg for progfile in $progfiles; do 23375ffd6003Smrg func_verbose "extracting global C symbols from \`$progfile'" 23385ffd6003Smrg $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'" 23395ffd6003Smrg done 23405ffd6003Smrg 23415ffd6003Smrg if test -n "$exclude_expsyms"; then 23425ffd6003Smrg $opt_dry_run || { 23435ffd6003Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 23445ffd6003Smrg eval '$MV "$nlist"T "$nlist"' 23455ffd6003Smrg } 2346145b7b3cSmrg fi 23475ffd6003Smrg 23485ffd6003Smrg if test -n "$export_symbols_regex"; then 23495ffd6003Smrg $opt_dry_run || { 23505ffd6003Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 23515ffd6003Smrg eval '$MV "$nlist"T "$nlist"' 23525ffd6003Smrg } 23535ffd6003Smrg fi 23545ffd6003Smrg 23555ffd6003Smrg # Prepare the list of exported symbols 23565ffd6003Smrg if test -z "$export_symbols"; then 23575ffd6003Smrg export_symbols="$output_objdir/$outputname.exp" 23585ffd6003Smrg $opt_dry_run || { 23595ffd6003Smrg $RM $export_symbols 23605ffd6003Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 23615ffd6003Smrg case $host in 23625ffd6003Smrg *cygwin* | *mingw* | *cegcc* ) 23635ffd6003Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 23645ffd6003Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 23655ffd6003Smrg ;; 23665ffd6003Smrg esac 23675ffd6003Smrg } 2368145b7b3cSmrg else 23695ffd6003Smrg $opt_dry_run || { 23705ffd6003Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 23715ffd6003Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 23725ffd6003Smrg eval '$MV "$nlist"T "$nlist"' 23735ffd6003Smrg case $host in 23745ffd6003Smrg *cygwin | *mingw* | *cegcc* ) 23755ffd6003Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 23765ffd6003Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 23775ffd6003Smrg ;; 23785ffd6003Smrg esac 23795ffd6003Smrg } 2380145b7b3cSmrg fi 23815ffd6003Smrg fi 2382145b7b3cSmrg 23835ffd6003Smrg for dlprefile in $dlprefiles; do 23845ffd6003Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 23855ffd6003Smrg func_basename "$dlprefile" 23865ffd6003Smrg name="$func_basename_result" 23875ffd6003Smrg $opt_dry_run || { 23885ffd6003Smrg eval '$ECHO ": $name " >> "$nlist"' 23895ffd6003Smrg eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'" 23905ffd6003Smrg } 23915ffd6003Smrg done 23925ffd6003Smrg 23935ffd6003Smrg $opt_dry_run || { 23945ffd6003Smrg # Make sure we have at least an empty file. 23955ffd6003Smrg test -f "$nlist" || : > "$nlist" 23965ffd6003Smrg 23975ffd6003Smrg if test -n "$exclude_expsyms"; then 23985ffd6003Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 23995ffd6003Smrg $MV "$nlist"T "$nlist" 2400145b7b3cSmrg fi 24015ffd6003Smrg 24025ffd6003Smrg # Try sorting and uniquifying the output. 24035ffd6003Smrg if $GREP -v "^: " < "$nlist" | 24045ffd6003Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 24055ffd6003Smrg sort -k 3 24065ffd6003Smrg else 24075ffd6003Smrg sort +2 24085ffd6003Smrg fi | 24095ffd6003Smrg uniq > "$nlist"S; then 24105ffd6003Smrg : 2411145b7b3cSmrg else 24125ffd6003Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 2413145b7b3cSmrg fi 2414145b7b3cSmrg 24155ffd6003Smrg if test -f "$nlist"S; then 24165ffd6003Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 2417145b7b3cSmrg else 24185ffd6003Smrg $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms" 2419145b7b3cSmrg fi 2420145b7b3cSmrg 24215ffd6003Smrg $ECHO >> "$output_objdir/$my_dlsyms" "\ 2422145b7b3cSmrg 24235ffd6003Smrg/* The mapping between symbol names and symbols. */ 24245ffd6003Smrgtypedef struct { 24255ffd6003Smrg const char *name; 24265ffd6003Smrg void *address; 24275ffd6003Smrg} lt_dlsymlist; 24285ffd6003Smrg" 24295ffd6003Smrg case $host in 24305ffd6003Smrg *cygwin* | *mingw* | *cegcc* ) 24315ffd6003Smrg $ECHO >> "$output_objdir/$my_dlsyms" "\ 24325ffd6003Smrg/* DATA imports from DLLs on WIN32 con't be const, because 24335ffd6003Smrg runtime relocations are performed -- see ld's documentation 24345ffd6003Smrg on pseudo-relocs. */" 24355ffd6003Smrg lt_dlsym_const= ;; 24365ffd6003Smrg *osf5*) 24375ffd6003Smrg echo >> "$output_objdir/$my_dlsyms" "\ 24385ffd6003Smrg/* This system does not cope well with relocations in const data */" 24395ffd6003Smrg lt_dlsym_const= ;; 24405ffd6003Smrg *) 24415ffd6003Smrg lt_dlsym_const=const ;; 24425ffd6003Smrg esac 2443145b7b3cSmrg 24445ffd6003Smrg $ECHO >> "$output_objdir/$my_dlsyms" "\ 24455ffd6003Smrgextern $lt_dlsym_const lt_dlsymlist 24465ffd6003Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 24475ffd6003Smrg$lt_dlsym_const lt_dlsymlist 24485ffd6003Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 24495ffd6003Smrg{\ 24505ffd6003Smrg { \"$my_originator\", (void *) 0 }," 2451145b7b3cSmrg 24525ffd6003Smrg case $need_lib_prefix in 24535ffd6003Smrg no) 24545ffd6003Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 24555ffd6003Smrg ;; 24565ffd6003Smrg *) 24575ffd6003Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 24585ffd6003Smrg ;; 24595ffd6003Smrg esac 24605ffd6003Smrg $ECHO >> "$output_objdir/$my_dlsyms" "\ 24615ffd6003Smrg {0, (void *) 0} 24625ffd6003Smrg}; 2463145b7b3cSmrg 24645ffd6003Smrg/* This works around a problem in FreeBSD linker */ 24655ffd6003Smrg#ifdef FREEBSD_WORKAROUND 24665ffd6003Smrgstatic const void *lt_preloaded_setup() { 24675ffd6003Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 24685ffd6003Smrg} 24695ffd6003Smrg#endif 24705ffd6003Smrg 24715ffd6003Smrg#ifdef __cplusplus 24725ffd6003Smrg} 24735ffd6003Smrg#endif\ 24745ffd6003Smrg" 24755ffd6003Smrg } # !$opt_dry_run 24765ffd6003Smrg 24775ffd6003Smrg pic_flag_for_symtable= 24785ffd6003Smrg case "$compile_command " in 24795ffd6003Smrg *" -static "*) ;; 24805ffd6003Smrg *) 24815ffd6003Smrg case $host in 24825ffd6003Smrg # compiling the symbol table file with pic_flag works around 24835ffd6003Smrg # a FreeBSD bug that causes programs to crash when -lm is 24845ffd6003Smrg # linked before any other PIC object. But we must not use 24855ffd6003Smrg # pic_flag when linking with -static. The problem exists in 24865ffd6003Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 24875ffd6003Smrg *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 24885ffd6003Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 24895ffd6003Smrg *-*-hpux*) 24905ffd6003Smrg pic_flag_for_symtable=" $pic_flag" ;; 24915ffd6003Smrg *) 24925ffd6003Smrg if test "X$my_pic_p" != Xno; then 24935ffd6003Smrg pic_flag_for_symtable=" $pic_flag" 2494145b7b3cSmrg fi 24955ffd6003Smrg ;; 24965ffd6003Smrg esac 24975ffd6003Smrg ;; 24985ffd6003Smrg esac 24995ffd6003Smrg symtab_cflags= 25005ffd6003Smrg for arg in $LTCFLAGS; do 25015ffd6003Smrg case $arg in 25025ffd6003Smrg -pie | -fpie | -fPIE) ;; 25035ffd6003Smrg *) symtab_cflags="$symtab_cflags $arg" ;; 25045ffd6003Smrg esac 25055ffd6003Smrg done 2506145b7b3cSmrg 25075ffd6003Smrg # Now compile the dynamic symbol file. 25085ffd6003Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 2509145b7b3cSmrg 25105ffd6003Smrg # Clean up the generated files. 25115ffd6003Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 2512145b7b3cSmrg 25135ffd6003Smrg # Transform the symbol file into the correct name. 25145ffd6003Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 25155ffd6003Smrg case $host in 25165ffd6003Smrg *cygwin* | *mingw* | *cegcc* ) 25175ffd6003Smrg if test -f "$output_objdir/$my_outputname.def"; then 25185ffd6003Smrg compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 25195ffd6003Smrg finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 25205ffd6003Smrg else 25215ffd6003Smrg compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` 25225ffd6003Smrg finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` 2523145b7b3cSmrg fi 25245ffd6003Smrg ;; 25255ffd6003Smrg *) 25265ffd6003Smrg compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` 25275ffd6003Smrg finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"` 25285ffd6003Smrg ;; 25295ffd6003Smrg esac 25305ffd6003Smrg ;; 25315ffd6003Smrg *) 25325ffd6003Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 25335ffd6003Smrg ;; 25345ffd6003Smrg esac 25355ffd6003Smrg else 25365ffd6003Smrg # We keep going just in case the user didn't refer to 25375ffd6003Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 25385ffd6003Smrg # really was required. 2539145b7b3cSmrg 25405ffd6003Smrg # Nullify the symbol file. 25415ffd6003Smrg compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"` 25425ffd6003Smrg finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"` 25435ffd6003Smrg fi 25445ffd6003Smrg} 2545145b7b3cSmrg 25465ffd6003Smrg# func_win32_libid arg 25475ffd6003Smrg# return the library type of file 'arg' 25485ffd6003Smrg# 25495ffd6003Smrg# Need a lot of goo to handle *both* DLLs and import libs 25505ffd6003Smrg# Has to be a shell function in order to 'eat' the argument 25515ffd6003Smrg# that is supplied when $file_magic_command is called. 25525ffd6003Smrgfunc_win32_libid () 25535ffd6003Smrg{ 25545ffd6003Smrg $opt_debug 25555ffd6003Smrg win32_libid_type="unknown" 25565ffd6003Smrg win32_fileres=`file -L $1 2>/dev/null` 25575ffd6003Smrg case $win32_fileres in 25585ffd6003Smrg *ar\ archive\ import\ library*) # definitely import 25595ffd6003Smrg win32_libid_type="x86 archive import" 25605ffd6003Smrg ;; 25615ffd6003Smrg *ar\ archive*) # could be an import, or static 25625ffd6003Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 25635ffd6003Smrg $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then 25645ffd6003Smrg win32_nmres=`eval $NM -f posix -A $1 | 25655ffd6003Smrg $SED -n -e ' 25665ffd6003Smrg 1,100{ 25675ffd6003Smrg / I /{ 25685ffd6003Smrg s,.*,import, 25695ffd6003Smrg p 25705ffd6003Smrg q 25715ffd6003Smrg } 25725ffd6003Smrg }'` 25735ffd6003Smrg case $win32_nmres in 25745ffd6003Smrg import*) win32_libid_type="x86 archive import";; 25755ffd6003Smrg *) win32_libid_type="x86 archive static";; 25765ffd6003Smrg esac 25775ffd6003Smrg fi 25785ffd6003Smrg ;; 25795ffd6003Smrg *DLL*) 25805ffd6003Smrg win32_libid_type="x86 DLL" 25815ffd6003Smrg ;; 25825ffd6003Smrg *executable*) # but shell scripts are "executable" too... 25835ffd6003Smrg case $win32_fileres in 25845ffd6003Smrg *MS\ Windows\ PE\ Intel*) 25855ffd6003Smrg win32_libid_type="x86 DLL" 25865ffd6003Smrg ;; 25875ffd6003Smrg esac 25885ffd6003Smrg ;; 25895ffd6003Smrg esac 25905ffd6003Smrg $ECHO "$win32_libid_type" 25915ffd6003Smrg} 2592145b7b3cSmrg 2593145b7b3cSmrg 2594145b7b3cSmrg 25955ffd6003Smrg# func_extract_an_archive dir oldlib 25965ffd6003Smrgfunc_extract_an_archive () 25975ffd6003Smrg{ 25985ffd6003Smrg $opt_debug 25995ffd6003Smrg f_ex_an_ar_dir="$1"; shift 26005ffd6003Smrg f_ex_an_ar_oldlib="$1" 26015ffd6003Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?' 26025ffd6003Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 26035ffd6003Smrg : 26045ffd6003Smrg else 26055ffd6003Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 26065ffd6003Smrg fi 26075ffd6003Smrg} 2608145b7b3cSmrg 2609145b7b3cSmrg 26105ffd6003Smrg# func_extract_archives gentop oldlib ... 26115ffd6003Smrgfunc_extract_archives () 26125ffd6003Smrg{ 26135ffd6003Smrg $opt_debug 26145ffd6003Smrg my_gentop="$1"; shift 26155ffd6003Smrg my_oldlibs=${1+"$@"} 26165ffd6003Smrg my_oldobjs="" 26175ffd6003Smrg my_xlib="" 26185ffd6003Smrg my_xabs="" 26195ffd6003Smrg my_xdir="" 2620145b7b3cSmrg 26215ffd6003Smrg for my_xlib in $my_oldlibs; do 26225ffd6003Smrg # Extract the objects. 26235ffd6003Smrg case $my_xlib in 26245ffd6003Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 26255ffd6003Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 26265ffd6003Smrg esac 26275ffd6003Smrg func_basename "$my_xlib" 26285ffd6003Smrg my_xlib="$func_basename_result" 26295ffd6003Smrg my_xlib_u=$my_xlib 26305ffd6003Smrg while :; do 26315ffd6003Smrg case " $extracted_archives " in 26325ffd6003Smrg *" $my_xlib_u "*) 26335ffd6003Smrg func_arith $extracted_serial + 1 26345ffd6003Smrg extracted_serial=$func_arith_result 26355ffd6003Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 26365ffd6003Smrg *) break ;; 26375ffd6003Smrg esac 26385ffd6003Smrg done 26395ffd6003Smrg extracted_archives="$extracted_archives $my_xlib_u" 26405ffd6003Smrg my_xdir="$my_gentop/$my_xlib_u" 2641145b7b3cSmrg 26425ffd6003Smrg func_mkdir_p "$my_xdir" 2643145b7b3cSmrg 26445ffd6003Smrg case $host in 26455ffd6003Smrg *-darwin*) 26465ffd6003Smrg func_verbose "Extracting $my_xabs" 26475ffd6003Smrg # Do not bother doing anything if just a dry run 26485ffd6003Smrg $opt_dry_run || { 26495ffd6003Smrg darwin_orig_dir=`pwd` 26505ffd6003Smrg cd $my_xdir || exit $? 26515ffd6003Smrg darwin_archive=$my_xabs 26525ffd6003Smrg darwin_curdir=`pwd` 26535ffd6003Smrg darwin_base_archive=`basename "$darwin_archive"` 26545ffd6003Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 26555ffd6003Smrg if test -n "$darwin_arches"; then 26565ffd6003Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 26575ffd6003Smrg darwin_arch= 26585ffd6003Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 26595ffd6003Smrg for darwin_arch in $darwin_arches ; do 26605ffd6003Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 26615ffd6003Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 26625ffd6003Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 26635ffd6003Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 26645ffd6003Smrg cd "$darwin_curdir" 26655ffd6003Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 26665ffd6003Smrg done # $darwin_arches 26675ffd6003Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 26685ffd6003Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 26695ffd6003Smrg darwin_file= 26705ffd6003Smrg darwin_files= 26715ffd6003Smrg for darwin_file in $darwin_filelist; do 26725ffd6003Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP` 26735ffd6003Smrg $LIPO -create -output "$darwin_file" $darwin_files 26745ffd6003Smrg done # $darwin_filelist 26755ffd6003Smrg $RM -rf unfat-$$ 26765ffd6003Smrg cd "$darwin_orig_dir" 2677145b7b3cSmrg else 26785ffd6003Smrg cd $darwin_orig_dir 26795ffd6003Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 26805ffd6003Smrg fi # $darwin_arches 26815ffd6003Smrg } # !$opt_dry_run 26825ffd6003Smrg ;; 26835ffd6003Smrg *) 26845ffd6003Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 26855ffd6003Smrg ;; 26865ffd6003Smrg esac 26875ffd6003Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP` 26885ffd6003Smrg done 2689145b7b3cSmrg 26905ffd6003Smrg func_extract_archives_result="$my_oldobjs" 26915ffd6003Smrg} 2692145b7b3cSmrg 2693145b7b3cSmrg 2694145b7b3cSmrg 26955ffd6003Smrg# func_emit_wrapper_part1 [arg=no] 26965ffd6003Smrg# 26975ffd6003Smrg# Emit the first part of a libtool wrapper script on stdout. 26985ffd6003Smrg# For more information, see the description associated with 26995ffd6003Smrg# func_emit_wrapper(), below. 27005ffd6003Smrgfunc_emit_wrapper_part1 () 27015ffd6003Smrg{ 27025ffd6003Smrg func_emit_wrapper_part1_arg1=no 27035ffd6003Smrg if test -n "$1" ; then 27045ffd6003Smrg func_emit_wrapper_part1_arg1=$1 2705145b7b3cSmrg fi 2706145b7b3cSmrg 27075ffd6003Smrg $ECHO "\ 27085ffd6003Smrg#! $SHELL 2709145b7b3cSmrg 27105ffd6003Smrg# $output - temporary wrapper script for $objdir/$outputname 27115ffd6003Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 27125ffd6003Smrg# 27135ffd6003Smrg# The $output program cannot be directly executed until all the libtool 27145ffd6003Smrg# libraries that it depends on are installed. 27155ffd6003Smrg# 27165ffd6003Smrg# This wrapper script should never be moved out of the build directory. 27175ffd6003Smrg# If it is, it will not operate correctly. 2718145b7b3cSmrg 27195ffd6003Smrg# Sed substitution that helps us do robust quoting. It backslashifies 27205ffd6003Smrg# metacharacters that are still active within double-quoted strings. 27215ffd6003SmrgXsed='${SED} -e 1s/^X//' 27225ffd6003Smrgsed_quote_subst='$sed_quote_subst' 2723145b7b3cSmrg 27245ffd6003Smrg# Be Bourne compatible 27255ffd6003Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 27265ffd6003Smrg emulate sh 27275ffd6003Smrg NULLCMD=: 27285ffd6003Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 27295ffd6003Smrg # is contrary to our usage. Disable this feature. 27305ffd6003Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 27315ffd6003Smrg setopt NO_GLOB_SUBST 27325ffd6003Smrgelse 27335ffd6003Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 27345ffd6003Smrgfi 27355ffd6003SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 27365ffd6003SmrgDUALCASE=1; export DUALCASE # for MKS sh 2737145b7b3cSmrg 27385ffd6003Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 27395ffd6003Smrg# if CDPATH is set. 27405ffd6003Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 2741145b7b3cSmrg 27425ffd6003Smrgrelink_command=\"$relink_command\" 2743145b7b3cSmrg 27445ffd6003Smrg# This environment variable determines our operation mode. 27455ffd6003Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 27465ffd6003Smrg # install mode needs the following variables: 27475ffd6003Smrg generated_by_libtool_version='$macro_version' 27485ffd6003Smrg notinst_deplibs='$notinst_deplibs' 27495ffd6003Smrgelse 27505ffd6003Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 27515ffd6003Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 27525ffd6003Smrg ECHO=\"$qecho\" 27535ffd6003Smrg file=\"\$0\" 27545ffd6003Smrg # Make sure echo works. 27555ffd6003Smrg if test \"X\$1\" = X--no-reexec; then 27565ffd6003Smrg # Discard the --no-reexec flag, and continue. 27575ffd6003Smrg shift 27585ffd6003Smrg elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then 27595ffd6003Smrg # Yippee, \$ECHO works! 27605ffd6003Smrg : 27615ffd6003Smrg else 27625ffd6003Smrg # Restart under the correct shell, and then maybe \$ECHO will work. 27635ffd6003Smrg exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"} 27645ffd6003Smrg fi 27655ffd6003Smrg fi\ 27665ffd6003Smrg" 27675ffd6003Smrg $ECHO "\ 2768145b7b3cSmrg 27695ffd6003Smrg # Find the directory that this script lives in. 27705ffd6003Smrg thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\` 27715ffd6003Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 2772145b7b3cSmrg 27735ffd6003Smrg # Follow symbolic links until we get to the real thisdir. 27745ffd6003Smrg file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\` 27755ffd6003Smrg while test -n \"\$file\"; do 27765ffd6003Smrg destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\` 2777145b7b3cSmrg 27785ffd6003Smrg # If there was a directory component, then change thisdir. 27795ffd6003Smrg if test \"x\$destdir\" != \"x\$file\"; then 27805ffd6003Smrg case \"\$destdir\" in 27815ffd6003Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 27825ffd6003Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 2783145b7b3cSmrg esac 27845ffd6003Smrg fi 2785145b7b3cSmrg 27865ffd6003Smrg file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\` 27875ffd6003Smrg file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\` 27885ffd6003Smrg done 27895ffd6003Smrg" 27905ffd6003Smrg} 27915ffd6003Smrg# end: func_emit_wrapper_part1 27925ffd6003Smrg 27935ffd6003Smrg# func_emit_wrapper_part2 [arg=no] 27945ffd6003Smrg# 27955ffd6003Smrg# Emit the second part of a libtool wrapper script on stdout. 27965ffd6003Smrg# For more information, see the description associated with 27975ffd6003Smrg# func_emit_wrapper(), below. 27985ffd6003Smrgfunc_emit_wrapper_part2 () 27995ffd6003Smrg{ 28005ffd6003Smrg func_emit_wrapper_part2_arg1=no 28015ffd6003Smrg if test -n "$1" ; then 28025ffd6003Smrg func_emit_wrapper_part2_arg1=$1 2803145b7b3cSmrg fi 2804145b7b3cSmrg 28055ffd6003Smrg $ECHO "\ 2806145b7b3cSmrg 28075ffd6003Smrg # Usually 'no', except on cygwin/mingw when embedded into 28085ffd6003Smrg # the cwrapper. 28095ffd6003Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1 28105ffd6003Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 28115ffd6003Smrg # special case for '.' 28125ffd6003Smrg if test \"\$thisdir\" = \".\"; then 28135ffd6003Smrg thisdir=\`pwd\` 28145ffd6003Smrg fi 28155ffd6003Smrg # remove .libs from thisdir 28165ffd6003Smrg case \"\$thisdir\" in 28175ffd6003Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;; 28185ffd6003Smrg $objdir ) thisdir=. ;; 28195ffd6003Smrg esac 28205ffd6003Smrg fi 28215ffd6003Smrg 28225ffd6003Smrg # Try to get the absolute directory name. 28235ffd6003Smrg absdir=\`cd \"\$thisdir\" && pwd\` 28245ffd6003Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 28255ffd6003Smrg" 28265ffd6003Smrg 28275ffd6003Smrg if test "$fast_install" = yes; then 28285ffd6003Smrg $ECHO "\ 28295ffd6003Smrg program=lt-'$outputname'$exeext 28305ffd6003Smrg progdir=\"\$thisdir/$objdir\" 28315ffd6003Smrg 28325ffd6003Smrg if test ! -f \"\$progdir/\$program\" || 28335ffd6003Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 28345ffd6003Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 28355ffd6003Smrg 28365ffd6003Smrg file=\"\$\$-\$program\" 28375ffd6003Smrg 28385ffd6003Smrg if test ! -d \"\$progdir\"; then 28395ffd6003Smrg $MKDIR \"\$progdir\" 28405ffd6003Smrg else 28415ffd6003Smrg $RM \"\$progdir/\$file\" 28425ffd6003Smrg fi" 28435ffd6003Smrg 28445ffd6003Smrg $ECHO "\ 28455ffd6003Smrg 28465ffd6003Smrg # relink executable if necessary 28475ffd6003Smrg if test -n \"\$relink_command\"; then 28485ffd6003Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 28495ffd6003Smrg else 28505ffd6003Smrg $ECHO \"\$relink_command_output\" >&2 28515ffd6003Smrg $RM \"\$progdir/\$file\" 28525ffd6003Smrg exit 1 2853145b7b3cSmrg fi 28545ffd6003Smrg fi 2855145b7b3cSmrg 28565ffd6003Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 28575ffd6003Smrg { $RM \"\$progdir/\$program\"; 28585ffd6003Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 28595ffd6003Smrg $RM \"\$progdir/\$file\" 28605ffd6003Smrg fi" 28615ffd6003Smrg else 28625ffd6003Smrg $ECHO "\ 28635ffd6003Smrg program='$outputname' 28645ffd6003Smrg progdir=\"\$thisdir/$objdir\" 28655ffd6003Smrg" 2866145b7b3cSmrg fi 2867145b7b3cSmrg 28685ffd6003Smrg $ECHO "\ 2869145b7b3cSmrg 28705ffd6003Smrg if test -f \"\$progdir/\$program\"; then" 2871145b7b3cSmrg 28725ffd6003Smrg # Export our shlibpath_var if we have one. 28735ffd6003Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 28745ffd6003Smrg $ECHO "\ 28755ffd6003Smrg # Add our own library path to $shlibpath_var 28765ffd6003Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 2877145b7b3cSmrg 28785ffd6003Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 28795ffd6003Smrg # The second colon is a workaround for a bug in BeOS R4 sed 28805ffd6003Smrg $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\` 28815ffd6003Smrg 28825ffd6003Smrg export $shlibpath_var 28835ffd6003Smrg" 2884145b7b3cSmrg fi 2885145b7b3cSmrg 28865ffd6003Smrg # fixup the dll searchpath if we need to. 28875ffd6003Smrg if test -n "$dllsearchpath"; then 28885ffd6003Smrg $ECHO "\ 28895ffd6003Smrg # Add the dll search path components to the executable PATH 28905ffd6003Smrg PATH=$dllsearchpath:\$PATH 28915ffd6003Smrg" 28925ffd6003Smrg fi 2893145b7b3cSmrg 28945ffd6003Smrg $ECHO "\ 28955ffd6003Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 28965ffd6003Smrg # Run the actual program with our arguments. 28975ffd6003Smrg" 28985ffd6003Smrg case $host in 28995ffd6003Smrg # Backslashes separate directories on plain windows 29005ffd6003Smrg *-*-mingw | *-*-os2* | *-cegcc*) 29015ffd6003Smrg $ECHO "\ 29025ffd6003Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 29035ffd6003Smrg" 2904145b7b3cSmrg ;; 2905145b7b3cSmrg 2906145b7b3cSmrg *) 29075ffd6003Smrg $ECHO "\ 29085ffd6003Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 29095ffd6003Smrg" 2910145b7b3cSmrg ;; 2911145b7b3cSmrg esac 29125ffd6003Smrg $ECHO "\ 29135ffd6003Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 29145ffd6003Smrg exit 1 29155ffd6003Smrg fi 29165ffd6003Smrg else 29175ffd6003Smrg # The program doesn't exist. 29185ffd6003Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 29195ffd6003Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 29205ffd6003Smrg $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 29215ffd6003Smrg exit 1 29225ffd6003Smrg fi 29235ffd6003Smrgfi\ 29245ffd6003Smrg" 29255ffd6003Smrg} 29265ffd6003Smrg# end: func_emit_wrapper_part2 2927145b7b3cSmrg 2928145b7b3cSmrg 29295ffd6003Smrg# func_emit_wrapper [arg=no] 29305ffd6003Smrg# 29315ffd6003Smrg# Emit a libtool wrapper script on stdout. 29325ffd6003Smrg# Don't directly open a file because we may want to 29335ffd6003Smrg# incorporate the script contents within a cygwin/mingw 29345ffd6003Smrg# wrapper executable. Must ONLY be called from within 29355ffd6003Smrg# func_mode_link because it depends on a number of variables 29365ffd6003Smrg# set therein. 29375ffd6003Smrg# 29385ffd6003Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 29395ffd6003Smrg# variable will take. If 'yes', then the emitted script 29405ffd6003Smrg# will assume that the directory in which it is stored is 29415ffd6003Smrg# the $objdir directory. This is a cygwin/mingw-specific 29425ffd6003Smrg# behavior. 29435ffd6003Smrgfunc_emit_wrapper () 29445ffd6003Smrg{ 29455ffd6003Smrg func_emit_wrapper_arg1=no 29465ffd6003Smrg if test -n "$1" ; then 29475ffd6003Smrg func_emit_wrapper_arg1=$1 2948145b7b3cSmrg fi 2949145b7b3cSmrg 29505ffd6003Smrg # split this up so that func_emit_cwrapperexe_src 29515ffd6003Smrg # can call each part independently. 29525ffd6003Smrg func_emit_wrapper_part1 "${func_emit_wrapper_arg1}" 29535ffd6003Smrg func_emit_wrapper_part2 "${func_emit_wrapper_arg1}" 29545ffd6003Smrg} 2955145b7b3cSmrg 2956145b7b3cSmrg 29575ffd6003Smrg# func_to_host_path arg 29585ffd6003Smrg# 29595ffd6003Smrg# Convert paths to host format when used with build tools. 29605ffd6003Smrg# Intended for use with "native" mingw (where libtool itself 29615ffd6003Smrg# is running under the msys shell), or in the following cross- 29625ffd6003Smrg# build environments: 29635ffd6003Smrg# $build $host 29645ffd6003Smrg# mingw (msys) mingw [e.g. native] 29655ffd6003Smrg# cygwin mingw 29665ffd6003Smrg# *nix + wine mingw 29675ffd6003Smrg# where wine is equipped with the `winepath' executable. 29685ffd6003Smrg# In the native mingw case, the (msys) shell automatically 29695ffd6003Smrg# converts paths for any non-msys applications it launches, 29705ffd6003Smrg# but that facility isn't available from inside the cwrapper. 29715ffd6003Smrg# Similar accommodations are necessary for $host mingw and 29725ffd6003Smrg# $build cygwin. Calling this function does no harm for other 29735ffd6003Smrg# $host/$build combinations not listed above. 29745ffd6003Smrg# 29755ffd6003Smrg# ARG is the path (on $build) that should be converted to 29765ffd6003Smrg# the proper representation for $host. The result is stored 29775ffd6003Smrg# in $func_to_host_path_result. 29785ffd6003Smrgfunc_to_host_path () 29795ffd6003Smrg{ 29805ffd6003Smrg func_to_host_path_result="$1" 29815ffd6003Smrg if test -n "$1" ; then 29825ffd6003Smrg case $host in 29835ffd6003Smrg *mingw* ) 29845ffd6003Smrg lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 29855ffd6003Smrg case $build in 29865ffd6003Smrg *mingw* ) # actually, msys 29875ffd6003Smrg # awkward: cmd appends spaces to result 29885ffd6003Smrg lt_sed_strip_trailing_spaces="s/[ ]*\$//" 29895ffd6003Smrg func_to_host_path_tmp1=`( cmd //c echo "$1" |\ 29905ffd6003Smrg $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` 29915ffd6003Smrg func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ 29925ffd6003Smrg $SED -e "$lt_sed_naive_backslashify"` 29935ffd6003Smrg ;; 29945ffd6003Smrg *cygwin* ) 29955ffd6003Smrg func_to_host_path_tmp1=`cygpath -w "$1"` 29965ffd6003Smrg func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ 29975ffd6003Smrg $SED -e "$lt_sed_naive_backslashify"` 29985ffd6003Smrg ;; 29995ffd6003Smrg * ) 30005ffd6003Smrg # Unfortunately, winepath does not exit with a non-zero 30015ffd6003Smrg # error code, so we are forced to check the contents of 30025ffd6003Smrg # stdout. On the other hand, if the command is not 30035ffd6003Smrg # found, the shell will set an exit code of 127 and print 30045ffd6003Smrg # *an error message* to stdout. So we must check for both 30055ffd6003Smrg # error code of zero AND non-empty stdout, which explains 30065ffd6003Smrg # the odd construction: 30075ffd6003Smrg func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null` 30085ffd6003Smrg if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then 30095ffd6003Smrg func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\ 30105ffd6003Smrg $SED -e "$lt_sed_naive_backslashify"` 30115ffd6003Smrg else 30125ffd6003Smrg # Allow warning below. 30135ffd6003Smrg func_to_host_path_result="" 30145ffd6003Smrg fi 30155ffd6003Smrg ;; 30165ffd6003Smrg esac 30175ffd6003Smrg if test -z "$func_to_host_path_result" ; then 30185ffd6003Smrg func_error "Could not determine host path corresponding to" 30195ffd6003Smrg func_error " '$1'" 30205ffd6003Smrg func_error "Continuing, but uninstalled executables may not work." 30215ffd6003Smrg # Fallback: 30225ffd6003Smrg func_to_host_path_result="$1" 30235ffd6003Smrg fi 30245ffd6003Smrg ;; 30255ffd6003Smrg esac 30265ffd6003Smrg fi 30275ffd6003Smrg} 30285ffd6003Smrg# end: func_to_host_path 3029145b7b3cSmrg 30305ffd6003Smrg# func_to_host_pathlist arg 30315ffd6003Smrg# 30325ffd6003Smrg# Convert pathlists to host format when used with build tools. 30335ffd6003Smrg# See func_to_host_path(), above. This function supports the 30345ffd6003Smrg# following $build/$host combinations (but does no harm for 30355ffd6003Smrg# combinations not listed here): 30365ffd6003Smrg# $build $host 30375ffd6003Smrg# mingw (msys) mingw [e.g. native] 30385ffd6003Smrg# cygwin mingw 30395ffd6003Smrg# *nix + wine mingw 30405ffd6003Smrg# 30415ffd6003Smrg# Path separators are also converted from $build format to 30425ffd6003Smrg# $host format. If ARG begins or ends with a path separator 30435ffd6003Smrg# character, it is preserved (but converted to $host format) 30445ffd6003Smrg# on output. 30455ffd6003Smrg# 30465ffd6003Smrg# ARG is a pathlist (on $build) that should be converted to 30475ffd6003Smrg# the proper representation on $host. The result is stored 30485ffd6003Smrg# in $func_to_host_pathlist_result. 30495ffd6003Smrgfunc_to_host_pathlist () 30505ffd6003Smrg{ 30515ffd6003Smrg func_to_host_pathlist_result="$1" 30525ffd6003Smrg if test -n "$1" ; then 30535ffd6003Smrg case $host in 30545ffd6003Smrg *mingw* ) 30555ffd6003Smrg lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 30565ffd6003Smrg # Remove leading and trailing path separator characters from 30575ffd6003Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 30585ffd6003Smrg # into '.;' and ';.', and winepath ignores them completely. 30595ffd6003Smrg func_to_host_pathlist_tmp2="$1" 30605ffd6003Smrg # Once set for this call, this variable should not be 30615ffd6003Smrg # reassigned. It is used in tha fallback case. 30625ffd6003Smrg func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\ 30635ffd6003Smrg $SED -e 's|^:*||' -e 's|:*$||'` 30645ffd6003Smrg case $build in 30655ffd6003Smrg *mingw* ) # Actually, msys. 30665ffd6003Smrg # Awkward: cmd appends spaces to result. 30675ffd6003Smrg lt_sed_strip_trailing_spaces="s/[ ]*\$//" 30685ffd6003Smrg func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\ 30695ffd6003Smrg $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""` 30705ffd6003Smrg func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ 30715ffd6003Smrg $SED -e "$lt_sed_naive_backslashify"` 30725ffd6003Smrg ;; 30735ffd6003Smrg *cygwin* ) 30745ffd6003Smrg func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"` 30755ffd6003Smrg func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\ 30765ffd6003Smrg $SED -e "$lt_sed_naive_backslashify"` 30775ffd6003Smrg ;; 30785ffd6003Smrg * ) 30795ffd6003Smrg # unfortunately, winepath doesn't convert pathlists 30805ffd6003Smrg func_to_host_pathlist_result="" 30815ffd6003Smrg func_to_host_pathlist_oldIFS=$IFS 30825ffd6003Smrg IFS=: 30835ffd6003Smrg for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do 30845ffd6003Smrg IFS=$func_to_host_pathlist_oldIFS 30855ffd6003Smrg if test -n "$func_to_host_pathlist_f" ; then 30865ffd6003Smrg func_to_host_path "$func_to_host_pathlist_f" 30875ffd6003Smrg if test -n "$func_to_host_path_result" ; then 30885ffd6003Smrg if test -z "$func_to_host_pathlist_result" ; then 30895ffd6003Smrg func_to_host_pathlist_result="$func_to_host_path_result" 30905ffd6003Smrg else 30915ffd6003Smrg func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result" 30925ffd6003Smrg fi 30935ffd6003Smrg fi 30945ffd6003Smrg fi 30955ffd6003Smrg IFS=: 30965ffd6003Smrg done 30975ffd6003Smrg IFS=$func_to_host_pathlist_oldIFS 30985ffd6003Smrg ;; 30995ffd6003Smrg esac 31005ffd6003Smrg if test -z "$func_to_host_pathlist_result" ; then 31015ffd6003Smrg func_error "Could not determine the host path(s) corresponding to" 31025ffd6003Smrg func_error " '$1'" 31035ffd6003Smrg func_error "Continuing, but uninstalled executables may not work." 31045ffd6003Smrg # Fallback. This may break if $1 contains DOS-style drive 31055ffd6003Smrg # specifications. The fix is not to complicate the expression 31065ffd6003Smrg # below, but for the user to provide a working wine installation 31075ffd6003Smrg # with winepath so that path translation in the cross-to-mingw 31085ffd6003Smrg # case works properly. 31095ffd6003Smrg lt_replace_pathsep_nix_to_dos="s|:|;|g" 31105ffd6003Smrg func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\ 31115ffd6003Smrg $SED -e "$lt_replace_pathsep_nix_to_dos"` 31125ffd6003Smrg fi 31135ffd6003Smrg # Now, add the leading and trailing path separators back 31145ffd6003Smrg case "$1" in 31155ffd6003Smrg :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result" 31165ffd6003Smrg ;; 31175ffd6003Smrg esac 31185ffd6003Smrg case "$1" in 31195ffd6003Smrg *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;" 31205ffd6003Smrg ;; 31215ffd6003Smrg esac 31225ffd6003Smrg ;; 31235ffd6003Smrg esac 31245ffd6003Smrg fi 31255ffd6003Smrg} 31265ffd6003Smrg# end: func_to_host_pathlist 3127145b7b3cSmrg 31285ffd6003Smrg# func_emit_cwrapperexe_src 31295ffd6003Smrg# emit the source code for a wrapper executable on stdout 31305ffd6003Smrg# Must ONLY be called from within func_mode_link because 31315ffd6003Smrg# it depends on a number of variable set therein. 31325ffd6003Smrgfunc_emit_cwrapperexe_src () 31335ffd6003Smrg{ 31345ffd6003Smrg cat <<EOF 3135145b7b3cSmrg 31365ffd6003Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 31375ffd6003Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3138145b7b3cSmrg 31395ffd6003Smrg The $output program cannot be directly executed until all the libtool 31405ffd6003Smrg libraries that it depends on are installed. 3141145b7b3cSmrg 31425ffd6003Smrg This wrapper executable should never be moved out of the build directory. 31435ffd6003Smrg If it is, it will not operate correctly. 3144145b7b3cSmrg 31455ffd6003Smrg Currently, it simply execs the wrapper *script* "$SHELL $output", 31465ffd6003Smrg but could eventually absorb all of the scripts functionality and 31475ffd6003Smrg exec $objdir/$outputname directly. 31485ffd6003Smrg*/ 31495ffd6003SmrgEOF 31505ffd6003Smrg cat <<"EOF" 31515ffd6003Smrg#include <stdio.h> 31525ffd6003Smrg#include <stdlib.h> 31535ffd6003Smrg#ifdef _MSC_VER 31545ffd6003Smrg# include <direct.h> 31555ffd6003Smrg# include <process.h> 31565ffd6003Smrg# include <io.h> 31575ffd6003Smrg# define setmode _setmode 31585ffd6003Smrg#else 31595ffd6003Smrg# include <unistd.h> 31605ffd6003Smrg# include <stdint.h> 31615ffd6003Smrg# ifdef __CYGWIN__ 31625ffd6003Smrg# include <io.h> 31635ffd6003Smrg# define HAVE_SETENV 31645ffd6003Smrg# ifdef __STRICT_ANSI__ 31655ffd6003Smrgchar *realpath (const char *, char *); 31665ffd6003Smrgint putenv (char *); 31675ffd6003Smrgint setenv (const char *, const char *, int); 31685ffd6003Smrg# endif 31695ffd6003Smrg# endif 31705ffd6003Smrg#endif 31715ffd6003Smrg#include <malloc.h> 31725ffd6003Smrg#include <stdarg.h> 31735ffd6003Smrg#include <assert.h> 31745ffd6003Smrg#include <string.h> 31755ffd6003Smrg#include <ctype.h> 31765ffd6003Smrg#include <errno.h> 31775ffd6003Smrg#include <fcntl.h> 31785ffd6003Smrg#include <sys/stat.h> 3179145b7b3cSmrg 31805ffd6003Smrg#if defined(PATH_MAX) 31815ffd6003Smrg# define LT_PATHMAX PATH_MAX 31825ffd6003Smrg#elif defined(MAXPATHLEN) 31835ffd6003Smrg# define LT_PATHMAX MAXPATHLEN 31845ffd6003Smrg#else 31855ffd6003Smrg# define LT_PATHMAX 1024 31865ffd6003Smrg#endif 3187145b7b3cSmrg 31885ffd6003Smrg#ifndef S_IXOTH 31895ffd6003Smrg# define S_IXOTH 0 31905ffd6003Smrg#endif 31915ffd6003Smrg#ifndef S_IXGRP 31925ffd6003Smrg# define S_IXGRP 0 31935ffd6003Smrg#endif 3194145b7b3cSmrg 31955ffd6003Smrg#ifdef _MSC_VER 31965ffd6003Smrg# define S_IXUSR _S_IEXEC 31975ffd6003Smrg# define stat _stat 31985ffd6003Smrg# ifndef _INTPTR_T_DEFINED 31995ffd6003Smrg# define intptr_t int 32005ffd6003Smrg# endif 32015ffd6003Smrg#endif 3202145b7b3cSmrg 32035ffd6003Smrg#ifndef DIR_SEPARATOR 32045ffd6003Smrg# define DIR_SEPARATOR '/' 32055ffd6003Smrg# define PATH_SEPARATOR ':' 32065ffd6003Smrg#endif 3207145b7b3cSmrg 32085ffd6003Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 32095ffd6003Smrg defined (__OS2__) 32105ffd6003Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 32115ffd6003Smrg# define FOPEN_WB "wb" 32125ffd6003Smrg# ifndef DIR_SEPARATOR_2 32135ffd6003Smrg# define DIR_SEPARATOR_2 '\\' 32145ffd6003Smrg# endif 32155ffd6003Smrg# ifndef PATH_SEPARATOR_2 32165ffd6003Smrg# define PATH_SEPARATOR_2 ';' 32175ffd6003Smrg# endif 32185ffd6003Smrg#endif 3219145b7b3cSmrg 32205ffd6003Smrg#ifndef DIR_SEPARATOR_2 32215ffd6003Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 32225ffd6003Smrg#else /* DIR_SEPARATOR_2 */ 32235ffd6003Smrg# define IS_DIR_SEPARATOR(ch) \ 32245ffd6003Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 32255ffd6003Smrg#endif /* DIR_SEPARATOR_2 */ 3226145b7b3cSmrg 32275ffd6003Smrg#ifndef PATH_SEPARATOR_2 32285ffd6003Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 32295ffd6003Smrg#else /* PATH_SEPARATOR_2 */ 32305ffd6003Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 32315ffd6003Smrg#endif /* PATH_SEPARATOR_2 */ 3232145b7b3cSmrg 32335ffd6003Smrg#ifdef __CYGWIN__ 32345ffd6003Smrg# define FOPEN_WB "wb" 32355ffd6003Smrg#endif 3236145b7b3cSmrg 32375ffd6003Smrg#ifndef FOPEN_WB 32385ffd6003Smrg# define FOPEN_WB "w" 32395ffd6003Smrg#endif 32405ffd6003Smrg#ifndef _O_BINARY 32415ffd6003Smrg# define _O_BINARY 0 32425ffd6003Smrg#endif 3243145b7b3cSmrg 32445ffd6003Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 32455ffd6003Smrg#define XFREE(stale) do { \ 32465ffd6003Smrg if (stale) { free ((void *) stale); stale = 0; } \ 32475ffd6003Smrg} while (0) 3248145b7b3cSmrg 32495ffd6003Smrg#undef LTWRAPPER_DEBUGPRINTF 32505ffd6003Smrg#if defined DEBUGWRAPPER 32515ffd6003Smrg# define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args 32525ffd6003Smrgstatic void 32535ffd6003Smrgltwrapper_debugprintf (const char *fmt, ...) 32545ffd6003Smrg{ 32555ffd6003Smrg va_list args; 32565ffd6003Smrg va_start (args, fmt); 32575ffd6003Smrg (void) vfprintf (stderr, fmt, args); 32585ffd6003Smrg va_end (args); 32595ffd6003Smrg} 32605ffd6003Smrg#else 32615ffd6003Smrg# define LTWRAPPER_DEBUGPRINTF(args) 32625ffd6003Smrg#endif 3263145b7b3cSmrg 32645ffd6003Smrgconst char *program_name = NULL; 3265145b7b3cSmrg 32665ffd6003Smrgvoid *xmalloc (size_t num); 32675ffd6003Smrgchar *xstrdup (const char *string); 32685ffd6003Smrgconst char *base_name (const char *name); 32695ffd6003Smrgchar *find_executable (const char *wrapper); 32705ffd6003Smrgchar *chase_symlinks (const char *pathspec); 32715ffd6003Smrgint make_executable (const char *path); 32725ffd6003Smrgint check_executable (const char *path); 32735ffd6003Smrgchar *strendzap (char *str, const char *pat); 32745ffd6003Smrgvoid lt_fatal (const char *message, ...); 32755ffd6003Smrgvoid lt_setenv (const char *name, const char *value); 32765ffd6003Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 32775ffd6003Smrgvoid lt_opt_process_env_set (const char *arg); 32785ffd6003Smrgvoid lt_opt_process_env_prepend (const char *arg); 32795ffd6003Smrgvoid lt_opt_process_env_append (const char *arg); 32805ffd6003Smrgint lt_split_name_value (const char *arg, char** name, char** value); 32815ffd6003Smrgvoid lt_update_exe_path (const char *name, const char *value); 32825ffd6003Smrgvoid lt_update_lib_path (const char *name, const char *value); 32835ffd6003Smrg 32845ffd6003Smrgstatic const char *script_text_part1 = 32855ffd6003SmrgEOF 3286145b7b3cSmrg 32875ffd6003Smrg func_emit_wrapper_part1 yes | 32885ffd6003Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 32895ffd6003Smrg -e 's/^/ "/' -e 's/$/\\n"/' 32905ffd6003Smrg echo ";" 32915ffd6003Smrg cat <<EOF 3292145b7b3cSmrg 32935ffd6003Smrgstatic const char *script_text_part2 = 32945ffd6003SmrgEOF 32955ffd6003Smrg func_emit_wrapper_part2 yes | 32965ffd6003Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 32975ffd6003Smrg -e 's/^/ "/' -e 's/$/\\n"/' 32985ffd6003Smrg echo ";" 32995ffd6003Smrg 33005ffd6003Smrg cat <<EOF 33015ffd6003Smrgconst char * MAGIC_EXE = "$magic_exe"; 33025ffd6003Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 33035ffd6003SmrgEOF 3304145b7b3cSmrg 33055ffd6003Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 33065ffd6003Smrg func_to_host_pathlist "$temp_rpath" 33075ffd6003Smrg cat <<EOF 33085ffd6003Smrgconst char * LIB_PATH_VALUE = "$func_to_host_pathlist_result"; 33095ffd6003SmrgEOF 33105ffd6003Smrg else 33115ffd6003Smrg cat <<"EOF" 33125ffd6003Smrgconst char * LIB_PATH_VALUE = ""; 33135ffd6003SmrgEOF 3314145b7b3cSmrg fi 3315145b7b3cSmrg 33165ffd6003Smrg if test -n "$dllsearchpath"; then 33175ffd6003Smrg func_to_host_pathlist "$dllsearchpath:" 33185ffd6003Smrg cat <<EOF 33195ffd6003Smrgconst char * EXE_PATH_VARNAME = "PATH"; 33205ffd6003Smrgconst char * EXE_PATH_VALUE = "$func_to_host_pathlist_result"; 3321145b7b3cSmrgEOF 3322145b7b3cSmrg else 33235ffd6003Smrg cat <<"EOF" 33245ffd6003Smrgconst char * EXE_PATH_VARNAME = ""; 33255ffd6003Smrgconst char * EXE_PATH_VALUE = ""; 33265ffd6003SmrgEOF 3327145b7b3cSmrg fi 33285ffd6003Smrg 33295ffd6003Smrg if test "$fast_install" = yes; then 33305ffd6003Smrg cat <<EOF 33315ffd6003Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 33325ffd6003SmrgEOF 3333145b7b3cSmrg else 33345ffd6003Smrg cat <<EOF 33355ffd6003Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 33365ffd6003SmrgEOF 3337145b7b3cSmrg fi 3338145b7b3cSmrg 3339145b7b3cSmrg 33405ffd6003Smrg cat <<"EOF" 3341145b7b3cSmrg 33425ffd6003Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 33435ffd6003Smrg#define LTWRAPPER_OPTION_PREFIX_LENGTH 5 3344145b7b3cSmrg 33455ffd6003Smrgstatic const size_t opt_prefix_len = LTWRAPPER_OPTION_PREFIX_LENGTH; 33465ffd6003Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 3347145b7b3cSmrg 33485ffd6003Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 3349145b7b3cSmrg 33505ffd6003Smrgstatic const size_t env_set_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 7; 33515ffd6003Smrgstatic const char *env_set_opt = LTWRAPPER_OPTION_PREFIX "env-set"; 33525ffd6003Smrg /* argument is putenv-style "foo=bar", value of foo is set to bar */ 3353145b7b3cSmrg 33545ffd6003Smrgstatic const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11; 33555ffd6003Smrgstatic const char *env_prepend_opt = LTWRAPPER_OPTION_PREFIX "env-prepend"; 33565ffd6003Smrg /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */ 3357145b7b3cSmrg 33585ffd6003Smrgstatic const size_t env_append_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 10; 33595ffd6003Smrgstatic const char *env_append_opt = LTWRAPPER_OPTION_PREFIX "env-append"; 33605ffd6003Smrg /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */ 3361145b7b3cSmrg 33625ffd6003Smrgint 33635ffd6003Smrgmain (int argc, char *argv[]) 33645ffd6003Smrg{ 33655ffd6003Smrg char **newargz; 33665ffd6003Smrg int newargc; 33675ffd6003Smrg char *tmp_pathspec; 33685ffd6003Smrg char *actual_cwrapper_path; 33695ffd6003Smrg char *actual_cwrapper_name; 33705ffd6003Smrg char *target_name; 33715ffd6003Smrg char *lt_argv_zero; 33725ffd6003Smrg intptr_t rval = 127; 3373145b7b3cSmrg 33745ffd6003Smrg int i; 3375145b7b3cSmrg 33765ffd6003Smrg program_name = (char *) xstrdup (base_name (argv[0])); 33775ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(main) argv[0] : %s\n", argv[0])); 33785ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name)); 3379145b7b3cSmrg 33805ffd6003Smrg /* very simple arg parsing; don't want to rely on getopt */ 33815ffd6003Smrg for (i = 1; i < argc; i++) 33825ffd6003Smrg { 33835ffd6003Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 33845ffd6003Smrg { 33855ffd6003SmrgEOF 33865ffd6003Smrg case "$host" in 33875ffd6003Smrg *mingw* | *cygwin* ) 33885ffd6003Smrg # make stdout use "unix" line endings 33895ffd6003Smrg echo " setmode(1,_O_BINARY);" 33905ffd6003Smrg ;; 33915ffd6003Smrg esac 3392145b7b3cSmrg 33935ffd6003Smrg cat <<"EOF" 33945ffd6003Smrg printf ("%s", script_text_part1); 33955ffd6003Smrg printf ("%s", script_text_part2); 33965ffd6003Smrg return 0; 33975ffd6003Smrg } 33985ffd6003Smrg } 3399145b7b3cSmrg 34005ffd6003Smrg newargz = XMALLOC (char *, argc + 1); 34015ffd6003Smrg tmp_pathspec = find_executable (argv[0]); 34025ffd6003Smrg if (tmp_pathspec == NULL) 34035ffd6003Smrg lt_fatal ("Couldn't find %s", argv[0]); 34045ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n", 34055ffd6003Smrg tmp_pathspec)); 34065ffd6003Smrg 34075ffd6003Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 34085ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n", 34095ffd6003Smrg actual_cwrapper_path)); 34105ffd6003Smrg XFREE (tmp_pathspec); 34115ffd6003Smrg 34125ffd6003Smrg actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path)); 34135ffd6003Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 34145ffd6003Smrg 34155ffd6003Smrg /* wrapper name transforms */ 34165ffd6003Smrg strendzap (actual_cwrapper_name, ".exe"); 34175ffd6003Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 34185ffd6003Smrg XFREE (actual_cwrapper_name); 34195ffd6003Smrg actual_cwrapper_name = tmp_pathspec; 34205ffd6003Smrg tmp_pathspec = 0; 34215ffd6003Smrg 34225ffd6003Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 34235ffd6003Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 34245ffd6003Smrg strendzap (target_name, ".exe"); 34255ffd6003Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 34265ffd6003Smrg XFREE (target_name); 34275ffd6003Smrg target_name = tmp_pathspec; 34285ffd6003Smrg tmp_pathspec = 0; 34295ffd6003Smrg 34305ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n", 34315ffd6003Smrg target_name)); 34325ffd6003SmrgEOF 3433145b7b3cSmrg 34345ffd6003Smrg cat <<EOF 34355ffd6003Smrg newargz[0] = 34365ffd6003Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 34375ffd6003Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 34385ffd6003Smrg strcpy (newargz[0], actual_cwrapper_path); 34395ffd6003Smrg strcat (newargz[0], "$objdir"); 34405ffd6003Smrg strcat (newargz[0], "/"); 34415ffd6003SmrgEOF 3442145b7b3cSmrg 34435ffd6003Smrg cat <<"EOF" 34445ffd6003Smrg /* stop here, and copy so we don't have to do this twice */ 34455ffd6003Smrg tmp_pathspec = xstrdup (newargz[0]); 3446145b7b3cSmrg 34475ffd6003Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 34485ffd6003Smrg strcat (newargz[0], actual_cwrapper_name); 3449145b7b3cSmrg 34505ffd6003Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 34515ffd6003Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 34525ffd6003Smrg XFREE (tmp_pathspec); 34535ffd6003Smrg tmp_pathspec = NULL; 34545ffd6003SmrgEOF 3455145b7b3cSmrg 34565ffd6003Smrg case $host_os in 34575ffd6003Smrg mingw*) 34585ffd6003Smrg cat <<"EOF" 34595ffd6003Smrg { 34605ffd6003Smrg char* p; 34615ffd6003Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 34625ffd6003Smrg { 34635ffd6003Smrg *p = '/'; 34645ffd6003Smrg } 34655ffd6003Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 34665ffd6003Smrg { 34675ffd6003Smrg *p = '/'; 34685ffd6003Smrg } 34695ffd6003Smrg } 34705ffd6003SmrgEOF 34715ffd6003Smrg ;; 34725ffd6003Smrg esac 3473145b7b3cSmrg 34745ffd6003Smrg cat <<"EOF" 34755ffd6003Smrg XFREE (target_name); 34765ffd6003Smrg XFREE (actual_cwrapper_path); 34775ffd6003Smrg XFREE (actual_cwrapper_name); 3478145b7b3cSmrg 34795ffd6003Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 34805ffd6003Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 34815ffd6003Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 34825ffd6003Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 3483145b7b3cSmrg 34845ffd6003Smrg newargc=0; 34855ffd6003Smrg for (i = 1; i < argc; i++) 34865ffd6003Smrg { 34875ffd6003Smrg if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0) 34885ffd6003Smrg { 34895ffd6003Smrg if (argv[i][env_set_opt_len] == '=') 34905ffd6003Smrg { 34915ffd6003Smrg const char *p = argv[i] + env_set_opt_len + 1; 34925ffd6003Smrg lt_opt_process_env_set (p); 34935ffd6003Smrg } 34945ffd6003Smrg else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc) 34955ffd6003Smrg { 34965ffd6003Smrg lt_opt_process_env_set (argv[++i]); /* don't copy */ 34975ffd6003Smrg } 34985ffd6003Smrg else 34995ffd6003Smrg lt_fatal ("%s missing required argument", env_set_opt); 35005ffd6003Smrg continue; 35015ffd6003Smrg } 35025ffd6003Smrg if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0) 35035ffd6003Smrg { 35045ffd6003Smrg if (argv[i][env_prepend_opt_len] == '=') 35055ffd6003Smrg { 35065ffd6003Smrg const char *p = argv[i] + env_prepend_opt_len + 1; 35075ffd6003Smrg lt_opt_process_env_prepend (p); 35085ffd6003Smrg } 35095ffd6003Smrg else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc) 35105ffd6003Smrg { 35115ffd6003Smrg lt_opt_process_env_prepend (argv[++i]); /* don't copy */ 35125ffd6003Smrg } 35135ffd6003Smrg else 35145ffd6003Smrg lt_fatal ("%s missing required argument", env_prepend_opt); 35155ffd6003Smrg continue; 35165ffd6003Smrg } 35175ffd6003Smrg if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0) 35185ffd6003Smrg { 35195ffd6003Smrg if (argv[i][env_append_opt_len] == '=') 35205ffd6003Smrg { 35215ffd6003Smrg const char *p = argv[i] + env_append_opt_len + 1; 35225ffd6003Smrg lt_opt_process_env_append (p); 35235ffd6003Smrg } 35245ffd6003Smrg else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc) 35255ffd6003Smrg { 35265ffd6003Smrg lt_opt_process_env_append (argv[++i]); /* don't copy */ 35275ffd6003Smrg } 35285ffd6003Smrg else 35295ffd6003Smrg lt_fatal ("%s missing required argument", env_append_opt); 35305ffd6003Smrg continue; 35315ffd6003Smrg } 35325ffd6003Smrg if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0) 35335ffd6003Smrg { 35345ffd6003Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 35355ffd6003Smrg namespace, but it is not one of the ones we know about and 35365ffd6003Smrg have already dealt with, above (inluding dump-script), then 35375ffd6003Smrg report an error. Otherwise, targets might begin to believe 35385ffd6003Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 35395ffd6003Smrg namespace. The first time any user complains about this, we'll 35405ffd6003Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 35415ffd6003Smrg or a configure.ac-settable value. 35425ffd6003Smrg */ 35435ffd6003Smrg lt_fatal ("Unrecognized option in %s namespace: '%s'", 35445ffd6003Smrg ltwrapper_option_prefix, argv[i]); 35455ffd6003Smrg } 35465ffd6003Smrg /* otherwise ... */ 35475ffd6003Smrg newargz[++newargc] = xstrdup (argv[i]); 35485ffd6003Smrg } 35495ffd6003Smrg newargz[++newargc] = NULL; 3550145b7b3cSmrg 35515ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>"))); 35525ffd6003Smrg for (i = 0; i < newargc; i++) 35535ffd6003Smrg { 35545ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>"))); 35555ffd6003Smrg } 3556145b7b3cSmrg 35575ffd6003SmrgEOF 3558145b7b3cSmrg 35595ffd6003Smrg case $host_os in 35605ffd6003Smrg mingw*) 35615ffd6003Smrg cat <<"EOF" 35625ffd6003Smrg /* execv doesn't actually work on mingw as expected on unix */ 35635ffd6003Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 35645ffd6003Smrg if (rval == -1) 35655ffd6003Smrg { 35665ffd6003Smrg /* failed to start process */ 35675ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno)); 35685ffd6003Smrg return 127; 35695ffd6003Smrg } 35705ffd6003Smrg return rval; 35715ffd6003SmrgEOF 35725ffd6003Smrg ;; 35735ffd6003Smrg *) 35745ffd6003Smrg cat <<"EOF" 35755ffd6003Smrg execv (lt_argv_zero, newargz); 35765ffd6003Smrg return rval; /* =127, but avoids unused variable warning */ 35775ffd6003SmrgEOF 35785ffd6003Smrg ;; 35795ffd6003Smrg esac 3580145b7b3cSmrg 35815ffd6003Smrg cat <<"EOF" 35825ffd6003Smrg} 3583145b7b3cSmrg 35845ffd6003Smrgvoid * 35855ffd6003Smrgxmalloc (size_t num) 35865ffd6003Smrg{ 35875ffd6003Smrg void *p = (void *) malloc (num); 35885ffd6003Smrg if (!p) 35895ffd6003Smrg lt_fatal ("Memory exhausted"); 3590145b7b3cSmrg 35915ffd6003Smrg return p; 35925ffd6003Smrg} 3593145b7b3cSmrg 35945ffd6003Smrgchar * 35955ffd6003Smrgxstrdup (const char *string) 35965ffd6003Smrg{ 35975ffd6003Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 35985ffd6003Smrg string) : NULL; 35995ffd6003Smrg} 3600145b7b3cSmrg 36015ffd6003Smrgconst char * 36025ffd6003Smrgbase_name (const char *name) 36035ffd6003Smrg{ 36045ffd6003Smrg const char *base; 3605145b7b3cSmrg 36065ffd6003Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 36075ffd6003Smrg /* Skip over the disk name in MSDOS pathnames. */ 36085ffd6003Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 36095ffd6003Smrg name += 2; 36105ffd6003Smrg#endif 3611145b7b3cSmrg 36125ffd6003Smrg for (base = name; *name; name++) 36135ffd6003Smrg if (IS_DIR_SEPARATOR (*name)) 36145ffd6003Smrg base = name + 1; 36155ffd6003Smrg return base; 36165ffd6003Smrg} 3617145b7b3cSmrg 36185ffd6003Smrgint 36195ffd6003Smrgcheck_executable (const char *path) 36205ffd6003Smrg{ 36215ffd6003Smrg struct stat st; 3622145b7b3cSmrg 36235ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n", 36245ffd6003Smrg path ? (*path ? path : "EMPTY!") : "NULL!")); 36255ffd6003Smrg if ((!path) || (!*path)) 36265ffd6003Smrg return 0; 3627145b7b3cSmrg 36285ffd6003Smrg if ((stat (path, &st) >= 0) 36295ffd6003Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 36305ffd6003Smrg return 1; 36315ffd6003Smrg else 36325ffd6003Smrg return 0; 36335ffd6003Smrg} 3634145b7b3cSmrg 36355ffd6003Smrgint 36365ffd6003Smrgmake_executable (const char *path) 36375ffd6003Smrg{ 36385ffd6003Smrg int rval = 0; 36395ffd6003Smrg struct stat st; 3640145b7b3cSmrg 36415ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n", 36425ffd6003Smrg path ? (*path ? path : "EMPTY!") : "NULL!")); 36435ffd6003Smrg if ((!path) || (!*path)) 36445ffd6003Smrg return 0; 3645145b7b3cSmrg 36465ffd6003Smrg if (stat (path, &st) >= 0) 36475ffd6003Smrg { 36485ffd6003Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 36495ffd6003Smrg } 36505ffd6003Smrg return rval; 36515ffd6003Smrg} 3652145b7b3cSmrg 36535ffd6003Smrg/* Searches for the full path of the wrapper. Returns 36545ffd6003Smrg newly allocated full path name if found, NULL otherwise 36555ffd6003Smrg Does not chase symlinks, even on platforms that support them. 36565ffd6003Smrg*/ 36575ffd6003Smrgchar * 36585ffd6003Smrgfind_executable (const char *wrapper) 36595ffd6003Smrg{ 36605ffd6003Smrg int has_slash = 0; 36615ffd6003Smrg const char *p; 36625ffd6003Smrg const char *p_next; 36635ffd6003Smrg /* static buffer for getcwd */ 36645ffd6003Smrg char tmp[LT_PATHMAX + 1]; 36655ffd6003Smrg int tmp_len; 36665ffd6003Smrg char *concat_name; 3667145b7b3cSmrg 36685ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n", 36695ffd6003Smrg wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!")); 3670145b7b3cSmrg 36715ffd6003Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 36725ffd6003Smrg return NULL; 3673145b7b3cSmrg 36745ffd6003Smrg /* Absolute path? */ 36755ffd6003Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 36765ffd6003Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 36775ffd6003Smrg { 36785ffd6003Smrg concat_name = xstrdup (wrapper); 36795ffd6003Smrg if (check_executable (concat_name)) 36805ffd6003Smrg return concat_name; 36815ffd6003Smrg XFREE (concat_name); 36825ffd6003Smrg } 36835ffd6003Smrg else 36845ffd6003Smrg { 36855ffd6003Smrg#endif 36865ffd6003Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 36875ffd6003Smrg { 36885ffd6003Smrg concat_name = xstrdup (wrapper); 36895ffd6003Smrg if (check_executable (concat_name)) 36905ffd6003Smrg return concat_name; 36915ffd6003Smrg XFREE (concat_name); 36925ffd6003Smrg } 36935ffd6003Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 36945ffd6003Smrg } 36955ffd6003Smrg#endif 3696145b7b3cSmrg 36975ffd6003Smrg for (p = wrapper; *p; p++) 36985ffd6003Smrg if (*p == '/') 36995ffd6003Smrg { 37005ffd6003Smrg has_slash = 1; 37015ffd6003Smrg break; 37025ffd6003Smrg } 37035ffd6003Smrg if (!has_slash) 37045ffd6003Smrg { 37055ffd6003Smrg /* no slashes; search PATH */ 37065ffd6003Smrg const char *path = getenv ("PATH"); 37075ffd6003Smrg if (path != NULL) 37085ffd6003Smrg { 37095ffd6003Smrg for (p = path; *p; p = p_next) 37105ffd6003Smrg { 37115ffd6003Smrg const char *q; 37125ffd6003Smrg size_t p_len; 37135ffd6003Smrg for (q = p; *q; q++) 37145ffd6003Smrg if (IS_PATH_SEPARATOR (*q)) 37155ffd6003Smrg break; 37165ffd6003Smrg p_len = q - p; 37175ffd6003Smrg p_next = (*q == '\0' ? q : q + 1); 37185ffd6003Smrg if (p_len == 0) 37195ffd6003Smrg { 37205ffd6003Smrg /* empty path: current directory */ 37215ffd6003Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 37225ffd6003Smrg lt_fatal ("getcwd failed"); 37235ffd6003Smrg tmp_len = strlen (tmp); 37245ffd6003Smrg concat_name = 37255ffd6003Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 37265ffd6003Smrg memcpy (concat_name, tmp, tmp_len); 37275ffd6003Smrg concat_name[tmp_len] = '/'; 37285ffd6003Smrg strcpy (concat_name + tmp_len + 1, wrapper); 37295ffd6003Smrg } 37305ffd6003Smrg else 37315ffd6003Smrg { 37325ffd6003Smrg concat_name = 37335ffd6003Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 37345ffd6003Smrg memcpy (concat_name, p, p_len); 37355ffd6003Smrg concat_name[p_len] = '/'; 37365ffd6003Smrg strcpy (concat_name + p_len + 1, wrapper); 37375ffd6003Smrg } 37385ffd6003Smrg if (check_executable (concat_name)) 37395ffd6003Smrg return concat_name; 37405ffd6003Smrg XFREE (concat_name); 37415ffd6003Smrg } 37425ffd6003Smrg } 37435ffd6003Smrg /* not found in PATH; assume curdir */ 37445ffd6003Smrg } 37455ffd6003Smrg /* Relative path | not found in path: prepend cwd */ 37465ffd6003Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 37475ffd6003Smrg lt_fatal ("getcwd failed"); 37485ffd6003Smrg tmp_len = strlen (tmp); 37495ffd6003Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 37505ffd6003Smrg memcpy (concat_name, tmp, tmp_len); 37515ffd6003Smrg concat_name[tmp_len] = '/'; 37525ffd6003Smrg strcpy (concat_name + tmp_len + 1, wrapper); 3753145b7b3cSmrg 37545ffd6003Smrg if (check_executable (concat_name)) 37555ffd6003Smrg return concat_name; 37565ffd6003Smrg XFREE (concat_name); 37575ffd6003Smrg return NULL; 37585ffd6003Smrg} 3759145b7b3cSmrg 37605ffd6003Smrgchar * 37615ffd6003Smrgchase_symlinks (const char *pathspec) 37625ffd6003Smrg{ 37635ffd6003Smrg#ifndef S_ISLNK 37645ffd6003Smrg return xstrdup (pathspec); 37655ffd6003Smrg#else 37665ffd6003Smrg char buf[LT_PATHMAX]; 37675ffd6003Smrg struct stat s; 37685ffd6003Smrg char *tmp_pathspec = xstrdup (pathspec); 37695ffd6003Smrg char *p; 37705ffd6003Smrg int has_symlinks = 0; 37715ffd6003Smrg while (strlen (tmp_pathspec) && !has_symlinks) 37725ffd6003Smrg { 37735ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n", 37745ffd6003Smrg tmp_pathspec)); 37755ffd6003Smrg if (lstat (tmp_pathspec, &s) == 0) 37765ffd6003Smrg { 37775ffd6003Smrg if (S_ISLNK (s.st_mode) != 0) 37785ffd6003Smrg { 37795ffd6003Smrg has_symlinks = 1; 37805ffd6003Smrg break; 37815ffd6003Smrg } 3782145b7b3cSmrg 37835ffd6003Smrg /* search backwards for last DIR_SEPARATOR */ 37845ffd6003Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 37855ffd6003Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 37865ffd6003Smrg p--; 37875ffd6003Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 37885ffd6003Smrg { 37895ffd6003Smrg /* no more DIR_SEPARATORS left */ 37905ffd6003Smrg break; 37915ffd6003Smrg } 37925ffd6003Smrg *p = '\0'; 37935ffd6003Smrg } 37945ffd6003Smrg else 37955ffd6003Smrg { 37965ffd6003Smrg char *errstr = strerror (errno); 37975ffd6003Smrg lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr); 37985ffd6003Smrg } 37995ffd6003Smrg } 38005ffd6003Smrg XFREE (tmp_pathspec); 3801145b7b3cSmrg 38025ffd6003Smrg if (!has_symlinks) 38035ffd6003Smrg { 38045ffd6003Smrg return xstrdup (pathspec); 38055ffd6003Smrg } 3806145b7b3cSmrg 38075ffd6003Smrg tmp_pathspec = realpath (pathspec, buf); 38085ffd6003Smrg if (tmp_pathspec == 0) 38095ffd6003Smrg { 38105ffd6003Smrg lt_fatal ("Could not follow symlinks for %s", pathspec); 38115ffd6003Smrg } 38125ffd6003Smrg return xstrdup (tmp_pathspec); 38135ffd6003Smrg#endif 38145ffd6003Smrg} 3815145b7b3cSmrg 38165ffd6003Smrgchar * 38175ffd6003Smrgstrendzap (char *str, const char *pat) 38185ffd6003Smrg{ 38195ffd6003Smrg size_t len, patlen; 3820145b7b3cSmrg 38215ffd6003Smrg assert (str != NULL); 38225ffd6003Smrg assert (pat != NULL); 3823145b7b3cSmrg 38245ffd6003Smrg len = strlen (str); 38255ffd6003Smrg patlen = strlen (pat); 3826145b7b3cSmrg 38275ffd6003Smrg if (patlen <= len) 38285ffd6003Smrg { 38295ffd6003Smrg str += len - patlen; 38305ffd6003Smrg if (strcmp (str, pat) == 0) 38315ffd6003Smrg *str = '\0'; 38325ffd6003Smrg } 38335ffd6003Smrg return str; 38345ffd6003Smrg} 3835145b7b3cSmrg 38365ffd6003Smrgstatic void 38375ffd6003Smrglt_error_core (int exit_status, const char *mode, 38385ffd6003Smrg const char *message, va_list ap) 38395ffd6003Smrg{ 38405ffd6003Smrg fprintf (stderr, "%s: %s: ", program_name, mode); 38415ffd6003Smrg vfprintf (stderr, message, ap); 38425ffd6003Smrg fprintf (stderr, ".\n"); 3843145b7b3cSmrg 38445ffd6003Smrg if (exit_status >= 0) 38455ffd6003Smrg exit (exit_status); 38465ffd6003Smrg} 3847145b7b3cSmrg 38485ffd6003Smrgvoid 38495ffd6003Smrglt_fatal (const char *message, ...) 38505ffd6003Smrg{ 38515ffd6003Smrg va_list ap; 38525ffd6003Smrg va_start (ap, message); 38535ffd6003Smrg lt_error_core (EXIT_FAILURE, "FATAL", message, ap); 38545ffd6003Smrg va_end (ap); 38555ffd6003Smrg} 3856145b7b3cSmrg 38575ffd6003Smrgvoid 38585ffd6003Smrglt_setenv (const char *name, const char *value) 38595ffd6003Smrg{ 38605ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n", 38615ffd6003Smrg (name ? name : "<NULL>"), 38625ffd6003Smrg (value ? value : "<NULL>"))); 38635ffd6003Smrg { 38645ffd6003Smrg#ifdef HAVE_SETENV 38655ffd6003Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 38665ffd6003Smrg char *str = xstrdup (value); 38675ffd6003Smrg setenv (name, str, 1); 38685ffd6003Smrg#else 38695ffd6003Smrg int len = strlen (name) + 1 + strlen (value) + 1; 38705ffd6003Smrg char *str = XMALLOC (char, len); 38715ffd6003Smrg sprintf (str, "%s=%s", name, value); 38725ffd6003Smrg if (putenv (str) != EXIT_SUCCESS) 38735ffd6003Smrg { 38745ffd6003Smrg XFREE (str); 38755ffd6003Smrg } 38765ffd6003Smrg#endif 38775ffd6003Smrg } 38785ffd6003Smrg} 3879145b7b3cSmrg 38805ffd6003Smrgchar * 38815ffd6003Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 38825ffd6003Smrg{ 38835ffd6003Smrg char *new_value; 38845ffd6003Smrg if (orig_value && *orig_value) 38855ffd6003Smrg { 38865ffd6003Smrg int orig_value_len = strlen (orig_value); 38875ffd6003Smrg int add_len = strlen (add); 38885ffd6003Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 38895ffd6003Smrg if (to_end) 38905ffd6003Smrg { 38915ffd6003Smrg strcpy (new_value, orig_value); 38925ffd6003Smrg strcpy (new_value + orig_value_len, add); 38935ffd6003Smrg } 38945ffd6003Smrg else 38955ffd6003Smrg { 38965ffd6003Smrg strcpy (new_value, add); 38975ffd6003Smrg strcpy (new_value + add_len, orig_value); 38985ffd6003Smrg } 38995ffd6003Smrg } 39005ffd6003Smrg else 39015ffd6003Smrg { 39025ffd6003Smrg new_value = xstrdup (add); 39035ffd6003Smrg } 39045ffd6003Smrg return new_value; 39055ffd6003Smrg} 3906145b7b3cSmrg 39075ffd6003Smrgint 39085ffd6003Smrglt_split_name_value (const char *arg, char** name, char** value) 39095ffd6003Smrg{ 39105ffd6003Smrg const char *p; 39115ffd6003Smrg int len; 39125ffd6003Smrg if (!arg || !*arg) 39135ffd6003Smrg return 1; 3914145b7b3cSmrg 39155ffd6003Smrg p = strchr (arg, (int)'='); 3916145b7b3cSmrg 39175ffd6003Smrg if (!p) 39185ffd6003Smrg return 1; 3919145b7b3cSmrg 39205ffd6003Smrg *value = xstrdup (++p); 3921145b7b3cSmrg 39225ffd6003Smrg len = strlen (arg) - strlen (*value); 39235ffd6003Smrg *name = XMALLOC (char, len); 39245ffd6003Smrg strncpy (*name, arg, len-1); 39255ffd6003Smrg (*name)[len - 1] = '\0'; 3926145b7b3cSmrg 39275ffd6003Smrg return 0; 39285ffd6003Smrg} 3929145b7b3cSmrg 39305ffd6003Smrgvoid 39315ffd6003Smrglt_opt_process_env_set (const char *arg) 39325ffd6003Smrg{ 39335ffd6003Smrg char *name = NULL; 39345ffd6003Smrg char *value = NULL; 3935145b7b3cSmrg 39365ffd6003Smrg if (lt_split_name_value (arg, &name, &value) != 0) 39375ffd6003Smrg { 39385ffd6003Smrg XFREE (name); 39395ffd6003Smrg XFREE (value); 39405ffd6003Smrg lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg); 39415ffd6003Smrg } 3942145b7b3cSmrg 39435ffd6003Smrg lt_setenv (name, value); 39445ffd6003Smrg XFREE (name); 39455ffd6003Smrg XFREE (value); 39465ffd6003Smrg} 3947145b7b3cSmrg 39485ffd6003Smrgvoid 39495ffd6003Smrglt_opt_process_env_prepend (const char *arg) 39505ffd6003Smrg{ 39515ffd6003Smrg char *name = NULL; 39525ffd6003Smrg char *value = NULL; 39535ffd6003Smrg char *new_value = NULL; 3954145b7b3cSmrg 39555ffd6003Smrg if (lt_split_name_value (arg, &name, &value) != 0) 39565ffd6003Smrg { 39575ffd6003Smrg XFREE (name); 39585ffd6003Smrg XFREE (value); 39595ffd6003Smrg lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg); 39605ffd6003Smrg } 3961145b7b3cSmrg 39625ffd6003Smrg new_value = lt_extend_str (getenv (name), value, 0); 39635ffd6003Smrg lt_setenv (name, new_value); 39645ffd6003Smrg XFREE (new_value); 39655ffd6003Smrg XFREE (name); 39665ffd6003Smrg XFREE (value); 39675ffd6003Smrg} 3968145b7b3cSmrg 39695ffd6003Smrgvoid 39705ffd6003Smrglt_opt_process_env_append (const char *arg) 39715ffd6003Smrg{ 39725ffd6003Smrg char *name = NULL; 39735ffd6003Smrg char *value = NULL; 39745ffd6003Smrg char *new_value = NULL; 3975145b7b3cSmrg 39765ffd6003Smrg if (lt_split_name_value (arg, &name, &value) != 0) 39775ffd6003Smrg { 39785ffd6003Smrg XFREE (name); 39795ffd6003Smrg XFREE (value); 39805ffd6003Smrg lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg); 39815ffd6003Smrg } 3982145b7b3cSmrg 39835ffd6003Smrg new_value = lt_extend_str (getenv (name), value, 1); 39845ffd6003Smrg lt_setenv (name, new_value); 39855ffd6003Smrg XFREE (new_value); 39865ffd6003Smrg XFREE (name); 39875ffd6003Smrg XFREE (value); 39885ffd6003Smrg} 3989145b7b3cSmrg 39905ffd6003Smrgvoid 39915ffd6003Smrglt_update_exe_path (const char *name, const char *value) 39925ffd6003Smrg{ 39935ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 39945ffd6003Smrg (name ? name : "<NULL>"), 39955ffd6003Smrg (value ? value : "<NULL>"))); 3996145b7b3cSmrg 39975ffd6003Smrg if (name && *name && value && *value) 39985ffd6003Smrg { 39995ffd6003Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 40005ffd6003Smrg /* some systems can't cope with a ':'-terminated path #' */ 40015ffd6003Smrg int len = strlen (new_value); 40025ffd6003Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 40035ffd6003Smrg { 40045ffd6003Smrg new_value[len-1] = '\0'; 40055ffd6003Smrg } 40065ffd6003Smrg lt_setenv (name, new_value); 40075ffd6003Smrg XFREE (new_value); 40085ffd6003Smrg } 40095ffd6003Smrg} 4010145b7b3cSmrg 40115ffd6003Smrgvoid 40125ffd6003Smrglt_update_lib_path (const char *name, const char *value) 40135ffd6003Smrg{ 40145ffd6003Smrg LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 40155ffd6003Smrg (name ? name : "<NULL>"), 40165ffd6003Smrg (value ? value : "<NULL>"))); 4017145b7b3cSmrg 40185ffd6003Smrg if (name && *name && value && *value) 40195ffd6003Smrg { 40205ffd6003Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 40215ffd6003Smrg lt_setenv (name, new_value); 40225ffd6003Smrg XFREE (new_value); 40235ffd6003Smrg } 40245ffd6003Smrg} 4025145b7b3cSmrg 4026145b7b3cSmrg 40275ffd6003SmrgEOF 40285ffd6003Smrg} 40295ffd6003Smrg# end: func_emit_cwrapperexe_src 4030145b7b3cSmrg 40315ffd6003Smrg# func_mode_link arg... 40325ffd6003Smrgfunc_mode_link () 40335ffd6003Smrg{ 40345ffd6003Smrg $opt_debug 40355ffd6003Smrg case $host in 40365ffd6003Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 40375ffd6003Smrg # It is impossible to link a dll without this setting, and 40385ffd6003Smrg # we shouldn't force the makefile maintainer to figure out 40395ffd6003Smrg # which system we are compiling for in order to pass an extra 40405ffd6003Smrg # flag for every libtool invocation. 40415ffd6003Smrg # allow_undefined=no 4042145b7b3cSmrg 40435ffd6003Smrg # FIXME: Unfortunately, there are problems with the above when trying 40445ffd6003Smrg # to make a dll which has undefined symbols, in which case not 40455ffd6003Smrg # even a static library is built. For now, we need to specify 40465ffd6003Smrg # -no-undefined on the libtool link line when we can be certain 40475ffd6003Smrg # that all symbols are satisfied, otherwise we get a static library. 40485ffd6003Smrg allow_undefined=yes 40495ffd6003Smrg ;; 40505ffd6003Smrg *) 40515ffd6003Smrg allow_undefined=yes 40525ffd6003Smrg ;; 40535ffd6003Smrg esac 40545ffd6003Smrg libtool_args=$nonopt 40555ffd6003Smrg base_compile="$nonopt $@" 40565ffd6003Smrg compile_command=$nonopt 40575ffd6003Smrg finalize_command=$nonopt 4058145b7b3cSmrg 40595ffd6003Smrg compile_rpath= 40605ffd6003Smrg finalize_rpath= 40615ffd6003Smrg compile_shlibpath= 40625ffd6003Smrg finalize_shlibpath= 40635ffd6003Smrg convenience= 40645ffd6003Smrg old_convenience= 40655ffd6003Smrg deplibs= 40665ffd6003Smrg old_deplibs= 40675ffd6003Smrg compiler_flags= 40685ffd6003Smrg linker_flags= 40695ffd6003Smrg dllsearchpath= 40705ffd6003Smrg lib_search_path=`pwd` 40715ffd6003Smrg inst_prefix_dir= 40725ffd6003Smrg new_inherited_linker_flags= 4073145b7b3cSmrg 40745ffd6003Smrg avoid_version=no 40755ffd6003Smrg dlfiles= 40765ffd6003Smrg dlprefiles= 40775ffd6003Smrg dlself=no 40785ffd6003Smrg export_dynamic=no 40795ffd6003Smrg export_symbols= 40805ffd6003Smrg export_symbols_regex= 40815ffd6003Smrg generated= 40825ffd6003Smrg libobjs= 40835ffd6003Smrg ltlibs= 40845ffd6003Smrg module=no 40855ffd6003Smrg no_install=no 40865ffd6003Smrg objs= 40875ffd6003Smrg non_pic_objects= 40885ffd6003Smrg precious_files_regex= 40895ffd6003Smrg prefer_static_libs=no 40905ffd6003Smrg preload=no 40915ffd6003Smrg prev= 40925ffd6003Smrg prevarg= 40935ffd6003Smrg release= 40945ffd6003Smrg rpath= 40955ffd6003Smrg xrpath= 40965ffd6003Smrg perm_rpath= 40975ffd6003Smrg temp_rpath= 40985ffd6003Smrg thread_safe=no 40995ffd6003Smrg vinfo= 41005ffd6003Smrg vinfo_number=no 41015ffd6003Smrg weak_libs= 41025ffd6003Smrg single_module="${wl}-single_module" 41035ffd6003Smrg func_infer_tag $base_compile 41045ffd6003Smrg 41055ffd6003Smrg # We need to know -static, to get the right output filenames. 41065ffd6003Smrg for arg 41075ffd6003Smrg do 41085ffd6003Smrg case $arg in 41095ffd6003Smrg -shared) 41105ffd6003Smrg test "$build_libtool_libs" != yes && \ 41115ffd6003Smrg func_fatal_configuration "can not build a shared library" 41125ffd6003Smrg build_old_libs=no 41135ffd6003Smrg break 41145ffd6003Smrg ;; 41155ffd6003Smrg -all-static | -static | -static-libtool-libs) 41165ffd6003Smrg case $arg in 41175ffd6003Smrg -all-static) 41185ffd6003Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 41195ffd6003Smrg func_warning "complete static linking is impossible in this configuration" 41205ffd6003Smrg fi 41215ffd6003Smrg if test -n "$link_static_flag"; then 41225ffd6003Smrg dlopen_self=$dlopen_self_static 41235ffd6003Smrg fi 41245ffd6003Smrg prefer_static_libs=yes 41255ffd6003Smrg ;; 41265ffd6003Smrg -static) 41275ffd6003Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 41285ffd6003Smrg dlopen_self=$dlopen_self_static 4129145b7b3cSmrg fi 41305ffd6003Smrg prefer_static_libs=built 41315ffd6003Smrg ;; 41325ffd6003Smrg -static-libtool-libs) 41335ffd6003Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 41345ffd6003Smrg dlopen_self=$dlopen_self_static 41355ffd6003Smrg fi 41365ffd6003Smrg prefer_static_libs=yes 41375ffd6003Smrg ;; 41385ffd6003Smrg esac 41395ffd6003Smrg build_libtool_libs=no 41405ffd6003Smrg build_old_libs=yes 41415ffd6003Smrg break 41425ffd6003Smrg ;; 41435ffd6003Smrg esac 41445ffd6003Smrg done 4145145b7b3cSmrg 41465ffd6003Smrg # See if our shared archives depend on static archives. 41475ffd6003Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 4148145b7b3cSmrg 41495ffd6003Smrg # Go through the arguments, transforming them on the way. 41505ffd6003Smrg while test "$#" -gt 0; do 41515ffd6003Smrg arg="$1" 41525ffd6003Smrg shift 41535ffd6003Smrg func_quote_for_eval "$arg" 41545ffd6003Smrg qarg=$func_quote_for_eval_unquoted_result 41555ffd6003Smrg func_append libtool_args " $func_quote_for_eval_result" 4156145b7b3cSmrg 41575ffd6003Smrg # If the previous option needs an argument, assign it. 41585ffd6003Smrg if test -n "$prev"; then 41595ffd6003Smrg case $prev in 41605ffd6003Smrg output) 41615ffd6003Smrg func_append compile_command " @OUTPUT@" 41625ffd6003Smrg func_append finalize_command " @OUTPUT@" 41635ffd6003Smrg ;; 41645ffd6003Smrg esac 4165145b7b3cSmrg 41665ffd6003Smrg case $prev in 41675ffd6003Smrg dlfiles|dlprefiles) 41685ffd6003Smrg if test "$preload" = no; then 41695ffd6003Smrg # Add the symbol object into the linking commands. 41705ffd6003Smrg func_append compile_command " @SYMFILE@" 41715ffd6003Smrg func_append finalize_command " @SYMFILE@" 41725ffd6003Smrg preload=yes 41735ffd6003Smrg fi 41745ffd6003Smrg case $arg in 41755ffd6003Smrg *.la | *.lo) ;; # We handle these cases below. 41765ffd6003Smrg force) 41775ffd6003Smrg if test "$dlself" = no; then 41785ffd6003Smrg dlself=needless 41795ffd6003Smrg export_dynamic=yes 41805ffd6003Smrg fi 41815ffd6003Smrg prev= 41825ffd6003Smrg continue 41835ffd6003Smrg ;; 41845ffd6003Smrg self) 41855ffd6003Smrg if test "$prev" = dlprefiles; then 41865ffd6003Smrg dlself=yes 41875ffd6003Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 41885ffd6003Smrg dlself=yes 4189145b7b3cSmrg else 41905ffd6003Smrg dlself=needless 41915ffd6003Smrg export_dynamic=yes 4192145b7b3cSmrg fi 41935ffd6003Smrg prev= 41945ffd6003Smrg continue 41955ffd6003Smrg ;; 41965ffd6003Smrg *) 41975ffd6003Smrg if test "$prev" = dlfiles; then 41985ffd6003Smrg dlfiles="$dlfiles $arg" 4199145b7b3cSmrg else 42005ffd6003Smrg dlprefiles="$dlprefiles $arg" 4201145b7b3cSmrg fi 42025ffd6003Smrg prev= 42035ffd6003Smrg continue 42045ffd6003Smrg ;; 42055ffd6003Smrg esac 42065ffd6003Smrg ;; 42075ffd6003Smrg expsyms) 42085ffd6003Smrg export_symbols="$arg" 42095ffd6003Smrg test -f "$arg" \ 42105ffd6003Smrg || func_fatal_error "symbol file \`$arg' does not exist" 42115ffd6003Smrg prev= 42125ffd6003Smrg continue 42135ffd6003Smrg ;; 42145ffd6003Smrg expsyms_regex) 42155ffd6003Smrg export_symbols_regex="$arg" 42165ffd6003Smrg prev= 42175ffd6003Smrg continue 42185ffd6003Smrg ;; 42195ffd6003Smrg framework) 42205ffd6003Smrg case $host in 42215ffd6003Smrg *-*-darwin*) 42225ffd6003Smrg case "$deplibs " in 42235ffd6003Smrg *" $qarg.ltframework "*) ;; 42245ffd6003Smrg *) deplibs="$deplibs $qarg.ltframework" # this is fixed later 42255ffd6003Smrg ;; 42265ffd6003Smrg esac 4227145b7b3cSmrg ;; 42285ffd6003Smrg esac 42295ffd6003Smrg prev= 42305ffd6003Smrg continue 42315ffd6003Smrg ;; 42325ffd6003Smrg inst_prefix) 42335ffd6003Smrg inst_prefix_dir="$arg" 42345ffd6003Smrg prev= 42355ffd6003Smrg continue 42365ffd6003Smrg ;; 42375ffd6003Smrg objectlist) 42385ffd6003Smrg if test -f "$arg"; then 42395ffd6003Smrg save_arg=$arg 42405ffd6003Smrg moreargs= 42415ffd6003Smrg for fil in `cat "$save_arg"` 42425ffd6003Smrg do 42435ffd6003Smrg# moreargs="$moreargs $fil" 42445ffd6003Smrg arg=$fil 42455ffd6003Smrg # A libtool-controlled object. 4246145b7b3cSmrg 42475ffd6003Smrg # Check to see that this really is a libtool object. 42485ffd6003Smrg if func_lalib_unsafe_p "$arg"; then 42495ffd6003Smrg pic_object= 42505ffd6003Smrg non_pic_object= 4251145b7b3cSmrg 42525ffd6003Smrg # Read the .lo file 42535ffd6003Smrg func_source "$arg" 4254145b7b3cSmrg 42555ffd6003Smrg if test -z "$pic_object" || 42565ffd6003Smrg test -z "$non_pic_object" || 42575ffd6003Smrg test "$pic_object" = none && 42585ffd6003Smrg test "$non_pic_object" = none; then 42595ffd6003Smrg func_fatal_error "cannot find name of object for \`$arg'" 42605ffd6003Smrg fi 4261145b7b3cSmrg 42625ffd6003Smrg # Extract subdirectory from the argument. 42635ffd6003Smrg func_dirname "$arg" "/" "" 42645ffd6003Smrg xdir="$func_dirname_result" 4265145b7b3cSmrg 42665ffd6003Smrg if test "$pic_object" != none; then 42675ffd6003Smrg # Prepend the subdirectory the object is found in. 42685ffd6003Smrg pic_object="$xdir$pic_object" 4269145b7b3cSmrg 42705ffd6003Smrg if test "$prev" = dlfiles; then 42715ffd6003Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 42725ffd6003Smrg dlfiles="$dlfiles $pic_object" 42735ffd6003Smrg prev= 42745ffd6003Smrg continue 42755ffd6003Smrg else 42765ffd6003Smrg # If libtool objects are unsupported, then we need to preload. 42775ffd6003Smrg prev=dlprefiles 42785ffd6003Smrg fi 42795ffd6003Smrg fi 4280145b7b3cSmrg 42815ffd6003Smrg # CHECK ME: I think I busted this. -Ossama 42825ffd6003Smrg if test "$prev" = dlprefiles; then 42835ffd6003Smrg # Preload the old-style object. 42845ffd6003Smrg dlprefiles="$dlprefiles $pic_object" 42855ffd6003Smrg prev= 42865ffd6003Smrg fi 4287145b7b3cSmrg 42885ffd6003Smrg # A PIC object. 42895ffd6003Smrg func_append libobjs " $pic_object" 42905ffd6003Smrg arg="$pic_object" 42915ffd6003Smrg fi 4292145b7b3cSmrg 42935ffd6003Smrg # Non-PIC object. 42945ffd6003Smrg if test "$non_pic_object" != none; then 42955ffd6003Smrg # Prepend the subdirectory the object is found in. 42965ffd6003Smrg non_pic_object="$xdir$non_pic_object" 4297145b7b3cSmrg 42985ffd6003Smrg # A standard non-PIC object 42995ffd6003Smrg func_append non_pic_objects " $non_pic_object" 43005ffd6003Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 43015ffd6003Smrg arg="$non_pic_object" 43025ffd6003Smrg fi 43035ffd6003Smrg else 43045ffd6003Smrg # If the PIC object exists, use it instead. 43055ffd6003Smrg # $xdir was prepended to $pic_object above. 43065ffd6003Smrg non_pic_object="$pic_object" 43075ffd6003Smrg func_append non_pic_objects " $non_pic_object" 43085ffd6003Smrg fi 43095ffd6003Smrg else 43105ffd6003Smrg # Only an error if not doing a dry-run. 43115ffd6003Smrg if $opt_dry_run; then 43125ffd6003Smrg # Extract subdirectory from the argument. 43135ffd6003Smrg func_dirname "$arg" "/" "" 43145ffd6003Smrg xdir="$func_dirname_result" 43155ffd6003Smrg 43165ffd6003Smrg func_lo2o "$arg" 43175ffd6003Smrg pic_object=$xdir$objdir/$func_lo2o_result 43185ffd6003Smrg non_pic_object=$xdir$func_lo2o_result 43195ffd6003Smrg func_append libobjs " $pic_object" 43205ffd6003Smrg func_append non_pic_objects " $non_pic_object" 43215ffd6003Smrg else 43225ffd6003Smrg func_fatal_error "\`$arg' is not a valid libtool object" 43235ffd6003Smrg fi 43245ffd6003Smrg fi 43255ffd6003Smrg done 43265ffd6003Smrg else 43275ffd6003Smrg func_fatal_error "link input file \`$arg' does not exist" 43285ffd6003Smrg fi 43295ffd6003Smrg arg=$save_arg 43305ffd6003Smrg prev= 43315ffd6003Smrg continue 43325ffd6003Smrg ;; 43335ffd6003Smrg precious_regex) 43345ffd6003Smrg precious_files_regex="$arg" 43355ffd6003Smrg prev= 43365ffd6003Smrg continue 43375ffd6003Smrg ;; 43385ffd6003Smrg release) 43395ffd6003Smrg release="-$arg" 43405ffd6003Smrg prev= 43415ffd6003Smrg continue 43425ffd6003Smrg ;; 43435ffd6003Smrg rpath | xrpath) 43445ffd6003Smrg # We need an absolute path. 43455ffd6003Smrg case $arg in 43465ffd6003Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 43475ffd6003Smrg *) 43485ffd6003Smrg func_fatal_error "only absolute run-paths are allowed" 43495ffd6003Smrg ;; 43505ffd6003Smrg esac 43515ffd6003Smrg if test "$prev" = rpath; then 43525ffd6003Smrg case "$rpath " in 43535ffd6003Smrg *" $arg "*) ;; 43545ffd6003Smrg *) rpath="$rpath $arg" ;; 43555ffd6003Smrg esac 43565ffd6003Smrg else 43575ffd6003Smrg case "$xrpath " in 43585ffd6003Smrg *" $arg "*) ;; 43595ffd6003Smrg *) xrpath="$xrpath $arg" ;; 43605ffd6003Smrg esac 43615ffd6003Smrg fi 43625ffd6003Smrg prev= 43635ffd6003Smrg continue 43645ffd6003Smrg ;; 43655ffd6003Smrg shrext) 43665ffd6003Smrg shrext_cmds="$arg" 43675ffd6003Smrg prev= 43685ffd6003Smrg continue 43695ffd6003Smrg ;; 43705ffd6003Smrg weak) 43715ffd6003Smrg weak_libs="$weak_libs $arg" 43725ffd6003Smrg prev= 43735ffd6003Smrg continue 43745ffd6003Smrg ;; 43755ffd6003Smrg xcclinker) 43765ffd6003Smrg linker_flags="$linker_flags $qarg" 43775ffd6003Smrg compiler_flags="$compiler_flags $qarg" 43785ffd6003Smrg prev= 43795ffd6003Smrg func_append compile_command " $qarg" 43805ffd6003Smrg func_append finalize_command " $qarg" 43815ffd6003Smrg continue 43825ffd6003Smrg ;; 43835ffd6003Smrg xcompiler) 43845ffd6003Smrg compiler_flags="$compiler_flags $qarg" 43855ffd6003Smrg prev= 43865ffd6003Smrg func_append compile_command " $qarg" 43875ffd6003Smrg func_append finalize_command " $qarg" 43885ffd6003Smrg continue 43895ffd6003Smrg ;; 43905ffd6003Smrg xlinker) 43915ffd6003Smrg linker_flags="$linker_flags $qarg" 43925ffd6003Smrg compiler_flags="$compiler_flags $wl$qarg" 43935ffd6003Smrg prev= 43945ffd6003Smrg func_append compile_command " $wl$qarg" 43955ffd6003Smrg func_append finalize_command " $wl$qarg" 43965ffd6003Smrg continue 4397145b7b3cSmrg ;; 4398145b7b3cSmrg *) 43995ffd6003Smrg eval "$prev=\"\$arg\"" 44005ffd6003Smrg prev= 44015ffd6003Smrg continue 4402145b7b3cSmrg ;; 4403145b7b3cSmrg esac 44045ffd6003Smrg fi # test -n "$prev" 4405145b7b3cSmrg 44065ffd6003Smrg prevarg="$arg" 4407145b7b3cSmrg 44085ffd6003Smrg case $arg in 44095ffd6003Smrg -all-static) 44105ffd6003Smrg if test -n "$link_static_flag"; then 44115ffd6003Smrg # See comment for -static flag below, for more details. 44125ffd6003Smrg func_append compile_command " $link_static_flag" 44135ffd6003Smrg func_append finalize_command " $link_static_flag" 4414145b7b3cSmrg fi 44155ffd6003Smrg continue 44165ffd6003Smrg ;; 4417145b7b3cSmrg 44185ffd6003Smrg -allow-undefined) 44195ffd6003Smrg # FIXME: remove this flag sometime in the future. 44205ffd6003Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 44215ffd6003Smrg ;; 4422145b7b3cSmrg 44235ffd6003Smrg -avoid-version) 44245ffd6003Smrg avoid_version=yes 44255ffd6003Smrg continue 44265ffd6003Smrg ;; 4427145b7b3cSmrg 44285ffd6003Smrg -dlopen) 44295ffd6003Smrg prev=dlfiles 44305ffd6003Smrg continue 44315ffd6003Smrg ;; 4432145b7b3cSmrg 44335ffd6003Smrg -dlpreopen) 44345ffd6003Smrg prev=dlprefiles 44355ffd6003Smrg continue 44365ffd6003Smrg ;; 4437145b7b3cSmrg 44385ffd6003Smrg -export-dynamic) 44395ffd6003Smrg export_dynamic=yes 44405ffd6003Smrg continue 44415ffd6003Smrg ;; 4442145b7b3cSmrg 44435ffd6003Smrg -export-symbols | -export-symbols-regex) 44445ffd6003Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 44455ffd6003Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 44465ffd6003Smrg fi 44475ffd6003Smrg if test "X$arg" = "X-export-symbols"; then 44485ffd6003Smrg prev=expsyms 4449145b7b3cSmrg else 44505ffd6003Smrg prev=expsyms_regex 4451145b7b3cSmrg fi 44525ffd6003Smrg continue 44535ffd6003Smrg ;; 4454145b7b3cSmrg 44555ffd6003Smrg -framework) 44565ffd6003Smrg prev=framework 44575ffd6003Smrg continue 44585ffd6003Smrg ;; 4459145b7b3cSmrg 44605ffd6003Smrg -inst-prefix-dir) 44615ffd6003Smrg prev=inst_prefix 44625ffd6003Smrg continue 44635ffd6003Smrg ;; 4464145b7b3cSmrg 44655ffd6003Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 44665ffd6003Smrg # so, if we see these flags be careful not to treat them like -L 44675ffd6003Smrg -L[A-Z][A-Z]*:*) 44685ffd6003Smrg case $with_gcc/$host in 44695ffd6003Smrg no/*-*-irix* | /*-*-irix*) 44705ffd6003Smrg func_append compile_command " $arg" 44715ffd6003Smrg func_append finalize_command " $arg" 44725ffd6003Smrg ;; 44735ffd6003Smrg esac 44745ffd6003Smrg continue 44755ffd6003Smrg ;; 4476145b7b3cSmrg 44775ffd6003Smrg -L*) 44785ffd6003Smrg func_stripname '-L' '' "$arg" 44795ffd6003Smrg dir=$func_stripname_result 44805ffd6003Smrg if test -z "$dir"; then 44815ffd6003Smrg if test "$#" -gt 0; then 44825ffd6003Smrg func_fatal_error "require no space between \`-L' and \`$1'" 4483145b7b3cSmrg else 44845ffd6003Smrg func_fatal_error "need path for \`-L' option" 4485145b7b3cSmrg fi 44865ffd6003Smrg fi 44875ffd6003Smrg # We need an absolute path. 44885ffd6003Smrg case $dir in 44895ffd6003Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 44905ffd6003Smrg *) 44915ffd6003Smrg absdir=`cd "$dir" && pwd` 44925ffd6003Smrg test -z "$absdir" && \ 44935ffd6003Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 44945ffd6003Smrg dir="$absdir" 44955ffd6003Smrg ;; 4496145b7b3cSmrg esac 44975ffd6003Smrg case "$deplibs " in 44985ffd6003Smrg *" -L$dir "*) ;; 44995ffd6003Smrg *) 45005ffd6003Smrg deplibs="$deplibs -L$dir" 45015ffd6003Smrg lib_search_path="$lib_search_path $dir" 45025ffd6003Smrg ;; 4503145b7b3cSmrg esac 4504145b7b3cSmrg case $host in 45055ffd6003Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 45065ffd6003Smrg testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'` 45075ffd6003Smrg case :$dllsearchpath: in 45085ffd6003Smrg *":$dir:"*) ;; 45095ffd6003Smrg ::) dllsearchpath=$dir;; 45105ffd6003Smrg *) dllsearchpath="$dllsearchpath:$dir";; 45115ffd6003Smrg esac 45125ffd6003Smrg case :$dllsearchpath: in 45135ffd6003Smrg *":$testbindir:"*) ;; 45145ffd6003Smrg ::) dllsearchpath=$testbindir;; 45155ffd6003Smrg *) dllsearchpath="$dllsearchpath:$testbindir";; 45165ffd6003Smrg esac 45175ffd6003Smrg ;; 4518145b7b3cSmrg esac 45195ffd6003Smrg continue 45205ffd6003Smrg ;; 4521145b7b3cSmrg 45225ffd6003Smrg -l*) 45235ffd6003Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 45245ffd6003Smrg case $host in 45255ffd6003Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*) 45265ffd6003Smrg # These systems don't actually have a C or math library (as such) 45275ffd6003Smrg continue 45285ffd6003Smrg ;; 45295ffd6003Smrg *-*-os2*) 45305ffd6003Smrg # These systems don't actually have a C library (as such) 45315ffd6003Smrg test "X$arg" = "X-lc" && continue 45325ffd6003Smrg ;; 45335ffd6003Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 45345ffd6003Smrg # Do not include libc due to us having libc/libc_r. 45355ffd6003Smrg test "X$arg" = "X-lc" && continue 45365ffd6003Smrg ;; 45375ffd6003Smrg *-*-rhapsody* | *-*-darwin1.[012]) 45385ffd6003Smrg # Rhapsody C and math libraries are in the System framework 45395ffd6003Smrg deplibs="$deplibs System.ltframework" 45405ffd6003Smrg continue 45415ffd6003Smrg ;; 45425ffd6003Smrg *-*-sco3.2v5* | *-*-sco5v6*) 45435ffd6003Smrg # Causes problems with __ctype 45445ffd6003Smrg test "X$arg" = "X-lc" && continue 45455ffd6003Smrg ;; 45465ffd6003Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 45475ffd6003Smrg # Compiler inserts libc in the correct place for threads to work 45485ffd6003Smrg test "X$arg" = "X-lc" && continue 45495ffd6003Smrg ;; 45505ffd6003Smrg esac 45515ffd6003Smrg elif test "X$arg" = "X-lc_r"; then 45525ffd6003Smrg case $host in 45535ffd6003Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 45545ffd6003Smrg # Do not include libc_r directly, use -pthread flag. 45555ffd6003Smrg continue 45565ffd6003Smrg ;; 45575ffd6003Smrg esac 45585ffd6003Smrg fi 45595ffd6003Smrg deplibs="$deplibs $arg" 45605ffd6003Smrg continue 45615ffd6003Smrg ;; 4562145b7b3cSmrg 45635ffd6003Smrg -module) 45645ffd6003Smrg module=yes 45655ffd6003Smrg continue 45665ffd6003Smrg ;; 4567145b7b3cSmrg 45685ffd6003Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 45695ffd6003Smrg # classes, name mangling, and exception handling. 45705ffd6003Smrg # Darwin uses the -arch flag to determine output architecture. 45715ffd6003Smrg -model|-arch|-isysroot) 45725ffd6003Smrg compiler_flags="$compiler_flags $arg" 45735ffd6003Smrg func_append compile_command " $arg" 45745ffd6003Smrg func_append finalize_command " $arg" 45755ffd6003Smrg prev=xcompiler 45765ffd6003Smrg continue 45775ffd6003Smrg ;; 4578145b7b3cSmrg 45795ffd6003Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 45805ffd6003Smrg compiler_flags="$compiler_flags $arg" 45815ffd6003Smrg func_append compile_command " $arg" 45825ffd6003Smrg func_append finalize_command " $arg" 45835ffd6003Smrg case "$new_inherited_linker_flags " in 45845ffd6003Smrg *" $arg "*) ;; 45855ffd6003Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;; 45865ffd6003Smrg esac 45875ffd6003Smrg continue 45885ffd6003Smrg ;; 4589145b7b3cSmrg 45905ffd6003Smrg -multi_module) 45915ffd6003Smrg single_module="${wl}-multi_module" 45925ffd6003Smrg continue 45935ffd6003Smrg ;; 4594145b7b3cSmrg 45955ffd6003Smrg -no-fast-install) 45965ffd6003Smrg fast_install=no 45975ffd6003Smrg continue 45985ffd6003Smrg ;; 4599145b7b3cSmrg 46005ffd6003Smrg -no-install) 46015ffd6003Smrg case $host in 46025ffd6003Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 46035ffd6003Smrg # The PATH hackery in wrapper scripts is required on Windows 46045ffd6003Smrg # and Darwin in order for the loader to find any dlls it needs. 46055ffd6003Smrg func_warning "\`-no-install' is ignored for $host" 46065ffd6003Smrg func_warning "assuming \`-no-fast-install' instead" 46075ffd6003Smrg fast_install=no 46085ffd6003Smrg ;; 46095ffd6003Smrg *) no_install=yes ;; 46105ffd6003Smrg esac 46115ffd6003Smrg continue 46125ffd6003Smrg ;; 4613145b7b3cSmrg 46145ffd6003Smrg -no-undefined) 46155ffd6003Smrg allow_undefined=no 46165ffd6003Smrg continue 46175ffd6003Smrg ;; 4618145b7b3cSmrg 46195ffd6003Smrg -objectlist) 46205ffd6003Smrg prev=objectlist 46215ffd6003Smrg continue 46225ffd6003Smrg ;; 4623145b7b3cSmrg 46245ffd6003Smrg -o) prev=output ;; 4625145b7b3cSmrg 46265ffd6003Smrg -precious-files-regex) 46275ffd6003Smrg prev=precious_regex 46285ffd6003Smrg continue 46295ffd6003Smrg ;; 4630145b7b3cSmrg 46315ffd6003Smrg -release) 46325ffd6003Smrg prev=release 46335ffd6003Smrg continue 46345ffd6003Smrg ;; 4635145b7b3cSmrg 46365ffd6003Smrg -rpath) 46375ffd6003Smrg prev=rpath 46385ffd6003Smrg continue 46395ffd6003Smrg ;; 4640145b7b3cSmrg 46415ffd6003Smrg -R) 46425ffd6003Smrg prev=xrpath 46435ffd6003Smrg continue 46445ffd6003Smrg ;; 4645145b7b3cSmrg 46465ffd6003Smrg -R*) 46475ffd6003Smrg func_stripname '-R' '' "$arg" 46485ffd6003Smrg dir=$func_stripname_result 46495ffd6003Smrg # We need an absolute path. 46505ffd6003Smrg case $dir in 46515ffd6003Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 46525ffd6003Smrg *) 46535ffd6003Smrg func_fatal_error "only absolute run-paths are allowed" 46545ffd6003Smrg ;; 46555ffd6003Smrg esac 46565ffd6003Smrg case "$xrpath " in 46575ffd6003Smrg *" $dir "*) ;; 46585ffd6003Smrg *) xrpath="$xrpath $dir" ;; 46595ffd6003Smrg esac 46605ffd6003Smrg continue 46615ffd6003Smrg ;; 4662145b7b3cSmrg 46635ffd6003Smrg -shared) 46645ffd6003Smrg # The effects of -shared are defined in a previous loop. 46655ffd6003Smrg continue 46665ffd6003Smrg ;; 4667145b7b3cSmrg 46685ffd6003Smrg -shrext) 46695ffd6003Smrg prev=shrext 46705ffd6003Smrg continue 46715ffd6003Smrg ;; 4672145b7b3cSmrg 46735ffd6003Smrg -static | -static-libtool-libs) 46745ffd6003Smrg # The effects of -static are defined in a previous loop. 46755ffd6003Smrg # We used to do the same as -all-static on platforms that 46765ffd6003Smrg # didn't have a PIC flag, but the assumption that the effects 46775ffd6003Smrg # would be equivalent was wrong. It would break on at least 46785ffd6003Smrg # Digital Unix and AIX. 46795ffd6003Smrg continue 46805ffd6003Smrg ;; 4681145b7b3cSmrg 46825ffd6003Smrg -thread-safe) 46835ffd6003Smrg thread_safe=yes 46845ffd6003Smrg continue 46855ffd6003Smrg ;; 4686145b7b3cSmrg 46875ffd6003Smrg -version-info) 46885ffd6003Smrg prev=vinfo 46895ffd6003Smrg continue 46905ffd6003Smrg ;; 4691145b7b3cSmrg 46925ffd6003Smrg -version-number) 46935ffd6003Smrg prev=vinfo 46945ffd6003Smrg vinfo_number=yes 46955ffd6003Smrg continue 46965ffd6003Smrg ;; 4697145b7b3cSmrg 46985ffd6003Smrg -weak) 46995ffd6003Smrg prev=weak 47005ffd6003Smrg continue 47015ffd6003Smrg ;; 4702145b7b3cSmrg 47035ffd6003Smrg -Wc,*) 47045ffd6003Smrg func_stripname '-Wc,' '' "$arg" 47055ffd6003Smrg args=$func_stripname_result 47065ffd6003Smrg arg= 47075ffd6003Smrg save_ifs="$IFS"; IFS=',' 47085ffd6003Smrg for flag in $args; do 47095ffd6003Smrg IFS="$save_ifs" 47105ffd6003Smrg func_quote_for_eval "$flag" 47115ffd6003Smrg arg="$arg $wl$func_quote_for_eval_result" 47125ffd6003Smrg compiler_flags="$compiler_flags $func_quote_for_eval_result" 47135ffd6003Smrg done 47145ffd6003Smrg IFS="$save_ifs" 47155ffd6003Smrg func_stripname ' ' '' "$arg" 47165ffd6003Smrg arg=$func_stripname_result 47175ffd6003Smrg ;; 4718145b7b3cSmrg 47195ffd6003Smrg -Wl,*) 47205ffd6003Smrg func_stripname '-Wl,' '' "$arg" 47215ffd6003Smrg args=$func_stripname_result 47225ffd6003Smrg arg= 47235ffd6003Smrg save_ifs="$IFS"; IFS=',' 47245ffd6003Smrg for flag in $args; do 47255ffd6003Smrg IFS="$save_ifs" 47265ffd6003Smrg func_quote_for_eval "$flag" 47275ffd6003Smrg arg="$arg $wl$func_quote_for_eval_result" 47285ffd6003Smrg compiler_flags="$compiler_flags $wl$func_quote_for_eval_result" 47295ffd6003Smrg linker_flags="$linker_flags $func_quote_for_eval_result" 47305ffd6003Smrg done 47315ffd6003Smrg IFS="$save_ifs" 47325ffd6003Smrg func_stripname ' ' '' "$arg" 47335ffd6003Smrg arg=$func_stripname_result 47345ffd6003Smrg ;; 4735145b7b3cSmrg 47365ffd6003Smrg -Xcompiler) 47375ffd6003Smrg prev=xcompiler 47385ffd6003Smrg continue 47395ffd6003Smrg ;; 4740145b7b3cSmrg 47415ffd6003Smrg -Xlinker) 47425ffd6003Smrg prev=xlinker 47435ffd6003Smrg continue 47445ffd6003Smrg ;; 4745145b7b3cSmrg 47465ffd6003Smrg -XCClinker) 47475ffd6003Smrg prev=xcclinker 47485ffd6003Smrg continue 47495ffd6003Smrg ;; 4750145b7b3cSmrg 47515ffd6003Smrg # -msg_* for osf cc 47525ffd6003Smrg -msg_*) 47535ffd6003Smrg func_quote_for_eval "$arg" 47545ffd6003Smrg arg="$func_quote_for_eval_result" 47555ffd6003Smrg ;; 4756145b7b3cSmrg 47575ffd6003Smrg # -64, -mips[0-9] enable 64-bit mode on the SGI compiler 47585ffd6003Smrg # -r[0-9][0-9]* specifies the processor on the SGI compiler 47595ffd6003Smrg # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler 47605ffd6003Smrg # +DA*, +DD* enable 64-bit mode on the HP compiler 47615ffd6003Smrg # -q* pass through compiler args for the IBM compiler 47625ffd6003Smrg # -m*, -t[45]*, -txscale* pass through architecture-specific 47635ffd6003Smrg # compiler args for GCC 47645ffd6003Smrg # -F/path gives path to uninstalled frameworks, gcc on darwin 47655ffd6003Smrg # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC 47665ffd6003Smrg # @file GCC response files 47675ffd6003Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 47685ffd6003Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*) 47695ffd6003Smrg func_quote_for_eval "$arg" 47705ffd6003Smrg arg="$func_quote_for_eval_result" 47715ffd6003Smrg func_append compile_command " $arg" 47725ffd6003Smrg func_append finalize_command " $arg" 47735ffd6003Smrg compiler_flags="$compiler_flags $arg" 47745ffd6003Smrg continue 47755ffd6003Smrg ;; 4776145b7b3cSmrg 47775ffd6003Smrg # Some other compiler flag. 47785ffd6003Smrg -* | +*) 47795ffd6003Smrg func_quote_for_eval "$arg" 47805ffd6003Smrg arg="$func_quote_for_eval_result" 47815ffd6003Smrg ;; 4782145b7b3cSmrg 47835ffd6003Smrg *.$objext) 47845ffd6003Smrg # A standard object. 47855ffd6003Smrg objs="$objs $arg" 47865ffd6003Smrg ;; 4787145b7b3cSmrg 47885ffd6003Smrg *.lo) 47895ffd6003Smrg # A libtool-controlled object. 4790145b7b3cSmrg 47915ffd6003Smrg # Check to see that this really is a libtool object. 47925ffd6003Smrg if func_lalib_unsafe_p "$arg"; then 47935ffd6003Smrg pic_object= 47945ffd6003Smrg non_pic_object= 4795145b7b3cSmrg 47965ffd6003Smrg # Read the .lo file 47975ffd6003Smrg func_source "$arg" 4798145b7b3cSmrg 47995ffd6003Smrg if test -z "$pic_object" || 48005ffd6003Smrg test -z "$non_pic_object" || 48015ffd6003Smrg test "$pic_object" = none && 48025ffd6003Smrg test "$non_pic_object" = none; then 48035ffd6003Smrg func_fatal_error "cannot find name of object for \`$arg'" 48045ffd6003Smrg fi 4805145b7b3cSmrg 48065ffd6003Smrg # Extract subdirectory from the argument. 48075ffd6003Smrg func_dirname "$arg" "/" "" 48085ffd6003Smrg xdir="$func_dirname_result" 4809145b7b3cSmrg 48105ffd6003Smrg if test "$pic_object" != none; then 48115ffd6003Smrg # Prepend the subdirectory the object is found in. 48125ffd6003Smrg pic_object="$xdir$pic_object" 4813145b7b3cSmrg 48145ffd6003Smrg if test "$prev" = dlfiles; then 48155ffd6003Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 48165ffd6003Smrg dlfiles="$dlfiles $pic_object" 48175ffd6003Smrg prev= 48185ffd6003Smrg continue 48195ffd6003Smrg else 48205ffd6003Smrg # If libtool objects are unsupported, then we need to preload. 48215ffd6003Smrg prev=dlprefiles 48225ffd6003Smrg fi 48235ffd6003Smrg fi 4824145b7b3cSmrg 48255ffd6003Smrg # CHECK ME: I think I busted this. -Ossama 48265ffd6003Smrg if test "$prev" = dlprefiles; then 48275ffd6003Smrg # Preload the old-style object. 48285ffd6003Smrg dlprefiles="$dlprefiles $pic_object" 48295ffd6003Smrg prev= 48305ffd6003Smrg fi 4831145b7b3cSmrg 48325ffd6003Smrg # A PIC object. 48335ffd6003Smrg func_append libobjs " $pic_object" 48345ffd6003Smrg arg="$pic_object" 48355ffd6003Smrg fi 4836145b7b3cSmrg 48375ffd6003Smrg # Non-PIC object. 48385ffd6003Smrg if test "$non_pic_object" != none; then 48395ffd6003Smrg # Prepend the subdirectory the object is found in. 48405ffd6003Smrg non_pic_object="$xdir$non_pic_object" 4841145b7b3cSmrg 48425ffd6003Smrg # A standard non-PIC object 48435ffd6003Smrg func_append non_pic_objects " $non_pic_object" 48445ffd6003Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 48455ffd6003Smrg arg="$non_pic_object" 48465ffd6003Smrg fi 48475ffd6003Smrg else 48485ffd6003Smrg # If the PIC object exists, use it instead. 48495ffd6003Smrg # $xdir was prepended to $pic_object above. 48505ffd6003Smrg non_pic_object="$pic_object" 48515ffd6003Smrg func_append non_pic_objects " $non_pic_object" 48525ffd6003Smrg fi 48535ffd6003Smrg else 48545ffd6003Smrg # Only an error if not doing a dry-run. 48555ffd6003Smrg if $opt_dry_run; then 48565ffd6003Smrg # Extract subdirectory from the argument. 48575ffd6003Smrg func_dirname "$arg" "/" "" 48585ffd6003Smrg xdir="$func_dirname_result" 48595ffd6003Smrg 48605ffd6003Smrg func_lo2o "$arg" 48615ffd6003Smrg pic_object=$xdir$objdir/$func_lo2o_result 48625ffd6003Smrg non_pic_object=$xdir$func_lo2o_result 48635ffd6003Smrg func_append libobjs " $pic_object" 48645ffd6003Smrg func_append non_pic_objects " $non_pic_object" 48655ffd6003Smrg else 48665ffd6003Smrg func_fatal_error "\`$arg' is not a valid libtool object" 48675ffd6003Smrg fi 48685ffd6003Smrg fi 48695ffd6003Smrg ;; 4870145b7b3cSmrg 48715ffd6003Smrg *.$libext) 48725ffd6003Smrg # An archive. 48735ffd6003Smrg deplibs="$deplibs $arg" 48745ffd6003Smrg old_deplibs="$old_deplibs $arg" 48755ffd6003Smrg continue 48765ffd6003Smrg ;; 4877578741aaSmrg 48785ffd6003Smrg *.la) 48795ffd6003Smrg # A libtool-controlled library. 4880145b7b3cSmrg 48815ffd6003Smrg if test "$prev" = dlfiles; then 48825ffd6003Smrg # This library was specified with -dlopen. 48835ffd6003Smrg dlfiles="$dlfiles $arg" 48845ffd6003Smrg prev= 48855ffd6003Smrg elif test "$prev" = dlprefiles; then 48865ffd6003Smrg # The library was specified with -dlpreopen. 48875ffd6003Smrg dlprefiles="$dlprefiles $arg" 48885ffd6003Smrg prev= 48895ffd6003Smrg else 48905ffd6003Smrg deplibs="$deplibs $arg" 48915ffd6003Smrg fi 48925ffd6003Smrg continue 48935ffd6003Smrg ;; 4894145b7b3cSmrg 48955ffd6003Smrg # Some other compiler argument. 48965ffd6003Smrg *) 48975ffd6003Smrg # Unknown arguments in both finalize_command and compile_command need 48985ffd6003Smrg # to be aesthetically quoted because they are evaled later. 48995ffd6003Smrg func_quote_for_eval "$arg" 49005ffd6003Smrg arg="$func_quote_for_eval_result" 49015ffd6003Smrg ;; 49025ffd6003Smrg esac # arg 4903145b7b3cSmrg 49045ffd6003Smrg # Now actually substitute the argument into the commands. 49055ffd6003Smrg if test -n "$arg"; then 49065ffd6003Smrg func_append compile_command " $arg" 49075ffd6003Smrg func_append finalize_command " $arg" 49085ffd6003Smrg fi 49095ffd6003Smrg done # argument parsing loop 4910145b7b3cSmrg 49115ffd6003Smrg test -n "$prev" && \ 49125ffd6003Smrg func_fatal_help "the \`$prevarg' option requires an argument" 4913145b7b3cSmrg 49145ffd6003Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 49155ffd6003Smrg eval arg=\"$export_dynamic_flag_spec\" 49165ffd6003Smrg func_append compile_command " $arg" 49175ffd6003Smrg func_append finalize_command " $arg" 4918145b7b3cSmrg fi 4919145b7b3cSmrg 49205ffd6003Smrg oldlibs= 49215ffd6003Smrg # calculate the name of the file, without its directory 49225ffd6003Smrg func_basename "$output" 49235ffd6003Smrg outputname="$func_basename_result" 49245ffd6003Smrg libobjs_save="$libobjs" 49255ffd6003Smrg 49265ffd6003Smrg if test -n "$shlibpath_var"; then 49275ffd6003Smrg # get the directories listed in $shlibpath_var 49285ffd6003Smrg eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\` 49295ffd6003Smrg else 49305ffd6003Smrg shlib_search_path= 49315ffd6003Smrg fi 49325ffd6003Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 49335ffd6003Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 49345ffd6003Smrg 49355ffd6003Smrg func_dirname "$output" "/" "" 49365ffd6003Smrg output_objdir="$func_dirname_result$objdir" 49375ffd6003Smrg # Create the object directory. 49385ffd6003Smrg func_mkdir_p "$output_objdir" 49395ffd6003Smrg 49405ffd6003Smrg # Determine the type of output 49415ffd6003Smrg case $output in 49425ffd6003Smrg "") 49435ffd6003Smrg func_fatal_help "you must specify an output file" 49445ffd6003Smrg ;; 49455ffd6003Smrg *.$libext) linkmode=oldlib ;; 49465ffd6003Smrg *.lo | *.$objext) linkmode=obj ;; 49475ffd6003Smrg *.la) linkmode=lib ;; 49485ffd6003Smrg *) linkmode=prog ;; # Anything else should be a program. 49495ffd6003Smrg esac 49505ffd6003Smrg 49515ffd6003Smrg specialdeplibs= 49525ffd6003Smrg 49535ffd6003Smrg libs= 49545ffd6003Smrg # Find all interdependent deplibs by searching for libraries 49555ffd6003Smrg # that are linked more than once (e.g. -la -lb -la) 49565ffd6003Smrg for deplib in $deplibs; do 49575ffd6003Smrg if $opt_duplicate_deps ; then 49585ffd6003Smrg case "$libs " in 49595ffd6003Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 49605ffd6003Smrg esac 49615ffd6003Smrg fi 49625ffd6003Smrg libs="$libs $deplib" 49635ffd6003Smrg done 49645ffd6003Smrg 49655ffd6003Smrg if test "$linkmode" = lib; then 49665ffd6003Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 49675ffd6003Smrg 49685ffd6003Smrg # Compute libraries that are listed more than once in $predeps 49695ffd6003Smrg # $postdeps and mark them as special (i.e., whose duplicates are 49705ffd6003Smrg # not to be eliminated). 49715ffd6003Smrg pre_post_deps= 49725ffd6003Smrg if $opt_duplicate_compiler_generated_deps; then 49735ffd6003Smrg for pre_post_dep in $predeps $postdeps; do 49745ffd6003Smrg case "$pre_post_deps " in 49755ffd6003Smrg *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;; 49765ffd6003Smrg esac 49775ffd6003Smrg pre_post_deps="$pre_post_deps $pre_post_dep" 49785ffd6003Smrg done 49795ffd6003Smrg fi 49805ffd6003Smrg pre_post_deps= 49815ffd6003Smrg fi 49825ffd6003Smrg 49835ffd6003Smrg deplibs= 49845ffd6003Smrg newdependency_libs= 49855ffd6003Smrg newlib_search_path= 49865ffd6003Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 49875ffd6003Smrg notinst_deplibs= # not-installed libtool libraries 49885ffd6003Smrg notinst_path= # paths that contain not-installed libtool libraries 49895ffd6003Smrg 49905ffd6003Smrg case $linkmode in 49915ffd6003Smrg lib) 49925ffd6003Smrg passes="conv dlpreopen link" 49935ffd6003Smrg for file in $dlfiles $dlprefiles; do 49945ffd6003Smrg case $file in 49955ffd6003Smrg *.la) ;; 49965ffd6003Smrg *) 49975ffd6003Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 49985ffd6003Smrg ;; 49995ffd6003Smrg esac 50005ffd6003Smrg done 50015ffd6003Smrg ;; 50025ffd6003Smrg prog) 50035ffd6003Smrg compile_deplibs= 50045ffd6003Smrg finalize_deplibs= 50055ffd6003Smrg alldeplibs=no 50065ffd6003Smrg newdlfiles= 50075ffd6003Smrg newdlprefiles= 50085ffd6003Smrg passes="conv scan dlopen dlpreopen link" 50095ffd6003Smrg ;; 50105ffd6003Smrg *) passes="conv" 50115ffd6003Smrg ;; 50125ffd6003Smrg esac 50135ffd6003Smrg 50145ffd6003Smrg for pass in $passes; do 50155ffd6003Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 50165ffd6003Smrg # so that -L comes before libs that need it for instance... 50175ffd6003Smrg if test "$linkmode,$pass" = "lib,link"; then 50185ffd6003Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 50195ffd6003Smrg ## order, and fix it there properly 50205ffd6003Smrg tmp_deplibs= 50215ffd6003Smrg for deplib in $deplibs; do 50225ffd6003Smrg tmp_deplibs="$deplib $tmp_deplibs" 50235ffd6003Smrg done 50245ffd6003Smrg deplibs="$tmp_deplibs" 50255ffd6003Smrg fi 50265ffd6003Smrg 50275ffd6003Smrg if test "$linkmode,$pass" = "lib,link" || 50285ffd6003Smrg test "$linkmode,$pass" = "prog,scan"; then 50295ffd6003Smrg libs="$deplibs" 50305ffd6003Smrg deplibs= 50315ffd6003Smrg fi 50325ffd6003Smrg if test "$linkmode" = prog; then 50335ffd6003Smrg case $pass in 50345ffd6003Smrg dlopen) libs="$dlfiles" ;; 50355ffd6003Smrg dlpreopen) libs="$dlprefiles" ;; 50365ffd6003Smrg link) 50375ffd6003Smrg libs="$deplibs %DEPLIBS%" 50385ffd6003Smrg test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" 50395ffd6003Smrg ;; 50405ffd6003Smrg esac 50415ffd6003Smrg fi 50425ffd6003Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 50435ffd6003Smrg # Collect and forward deplibs of preopened libtool libs 50445ffd6003Smrg for lib in $dlprefiles; do 50455ffd6003Smrg # Ignore non-libtool-libs 50465ffd6003Smrg dependency_libs= 50475ffd6003Smrg case $lib in 50485ffd6003Smrg *.la) func_source "$lib" ;; 50495ffd6003Smrg esac 50505ffd6003Smrg 50515ffd6003Smrg # Collect preopened libtool deplibs, except any this library 50525ffd6003Smrg # has declared as weak libs 50535ffd6003Smrg for deplib in $dependency_libs; do 50545ffd6003Smrg deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"` 50555ffd6003Smrg case " $weak_libs " in 50565ffd6003Smrg *" $deplib_base "*) ;; 50575ffd6003Smrg *) deplibs="$deplibs $deplib" ;; 50585ffd6003Smrg esac 50595ffd6003Smrg done 50605ffd6003Smrg done 50615ffd6003Smrg libs="$dlprefiles" 50625ffd6003Smrg fi 50635ffd6003Smrg if test "$pass" = dlopen; then 50645ffd6003Smrg # Collect dlpreopened libraries 50655ffd6003Smrg save_deplibs="$deplibs" 50665ffd6003Smrg deplibs= 50675ffd6003Smrg fi 50685ffd6003Smrg 50695ffd6003Smrg for deplib in $libs; do 50705ffd6003Smrg lib= 50715ffd6003Smrg found=no 50725ffd6003Smrg case $deplib in 50735ffd6003Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 50745ffd6003Smrg if test "$linkmode,$pass" = "prog,link"; then 50755ffd6003Smrg compile_deplibs="$deplib $compile_deplibs" 50765ffd6003Smrg finalize_deplibs="$deplib $finalize_deplibs" 50775ffd6003Smrg else 50785ffd6003Smrg compiler_flags="$compiler_flags $deplib" 50795ffd6003Smrg if test "$linkmode" = lib ; then 50805ffd6003Smrg case "$new_inherited_linker_flags " in 50815ffd6003Smrg *" $deplib "*) ;; 50825ffd6003Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; 50835ffd6003Smrg esac 50845ffd6003Smrg fi 50855ffd6003Smrg fi 50865ffd6003Smrg continue 50875ffd6003Smrg ;; 50885ffd6003Smrg -l*) 50895ffd6003Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 50905ffd6003Smrg func_warning "\`-l' is ignored for archives/objects" 50915ffd6003Smrg continue 50925ffd6003Smrg fi 50935ffd6003Smrg func_stripname '-l' '' "$deplib" 50945ffd6003Smrg name=$func_stripname_result 50955ffd6003Smrg if test "$linkmode" = lib; then 50965ffd6003Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 50975ffd6003Smrg else 50985ffd6003Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 50995ffd6003Smrg fi 51005ffd6003Smrg for searchdir in $searchdirs; do 51015ffd6003Smrg for search_ext in .la $std_shrext .so .a; do 51025ffd6003Smrg # Search the libtool library 51035ffd6003Smrg lib="$searchdir/lib${name}${search_ext}" 51045ffd6003Smrg if test -f "$lib"; then 51055ffd6003Smrg if test "$search_ext" = ".la"; then 51065ffd6003Smrg found=yes 51075ffd6003Smrg else 51085ffd6003Smrg found=no 51095ffd6003Smrg fi 51105ffd6003Smrg break 2 51115ffd6003Smrg fi 51125ffd6003Smrg done 51135ffd6003Smrg done 51145ffd6003Smrg if test "$found" != yes; then 51155ffd6003Smrg # deplib doesn't seem to be a libtool library 51165ffd6003Smrg if test "$linkmode,$pass" = "prog,link"; then 51175ffd6003Smrg compile_deplibs="$deplib $compile_deplibs" 51185ffd6003Smrg finalize_deplibs="$deplib $finalize_deplibs" 51195ffd6003Smrg else 51205ffd6003Smrg deplibs="$deplib $deplibs" 51215ffd6003Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 51225ffd6003Smrg fi 51235ffd6003Smrg continue 51245ffd6003Smrg else # deplib is a libtool library 51255ffd6003Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 51265ffd6003Smrg # We need to do some special things here, and not later. 51275ffd6003Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 51285ffd6003Smrg case " $predeps $postdeps " in 51295ffd6003Smrg *" $deplib "*) 51305ffd6003Smrg if func_lalib_p "$lib"; then 51315ffd6003Smrg library_names= 51325ffd6003Smrg old_library= 51335ffd6003Smrg func_source "$lib" 51345ffd6003Smrg for l in $old_library $library_names; do 51355ffd6003Smrg ll="$l" 51365ffd6003Smrg done 51375ffd6003Smrg if test "X$ll" = "X$old_library" ; then # only static version available 51385ffd6003Smrg found=no 51395ffd6003Smrg func_dirname "$lib" "" "." 51405ffd6003Smrg ladir="$func_dirname_result" 51415ffd6003Smrg lib=$ladir/$old_library 51425ffd6003Smrg if test "$linkmode,$pass" = "prog,link"; then 51435ffd6003Smrg compile_deplibs="$deplib $compile_deplibs" 51445ffd6003Smrg finalize_deplibs="$deplib $finalize_deplibs" 51455ffd6003Smrg else 51465ffd6003Smrg deplibs="$deplib $deplibs" 51475ffd6003Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 51485ffd6003Smrg fi 51495ffd6003Smrg continue 51505ffd6003Smrg fi 51515ffd6003Smrg fi 51525ffd6003Smrg ;; 51535ffd6003Smrg *) ;; 51545ffd6003Smrg esac 51555ffd6003Smrg fi 51565ffd6003Smrg fi 51575ffd6003Smrg ;; # -l 51585ffd6003Smrg *.ltframework) 51595ffd6003Smrg if test "$linkmode,$pass" = "prog,link"; then 51605ffd6003Smrg compile_deplibs="$deplib $compile_deplibs" 51615ffd6003Smrg finalize_deplibs="$deplib $finalize_deplibs" 51625ffd6003Smrg else 51635ffd6003Smrg deplibs="$deplib $deplibs" 51645ffd6003Smrg if test "$linkmode" = lib ; then 51655ffd6003Smrg case "$new_inherited_linker_flags " in 51665ffd6003Smrg *" $deplib "*) ;; 51675ffd6003Smrg * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;; 51685ffd6003Smrg esac 51695ffd6003Smrg fi 51705ffd6003Smrg fi 51715ffd6003Smrg continue 51725ffd6003Smrg ;; 51735ffd6003Smrg -L*) 51745ffd6003Smrg case $linkmode in 51755ffd6003Smrg lib) 51765ffd6003Smrg deplibs="$deplib $deplibs" 51775ffd6003Smrg test "$pass" = conv && continue 51785ffd6003Smrg newdependency_libs="$deplib $newdependency_libs" 51795ffd6003Smrg func_stripname '-L' '' "$deplib" 51805ffd6003Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 51815ffd6003Smrg ;; 51825ffd6003Smrg prog) 51835ffd6003Smrg if test "$pass" = conv; then 51845ffd6003Smrg deplibs="$deplib $deplibs" 51855ffd6003Smrg continue 51865ffd6003Smrg fi 51875ffd6003Smrg if test "$pass" = scan; then 51885ffd6003Smrg deplibs="$deplib $deplibs" 51895ffd6003Smrg else 51905ffd6003Smrg compile_deplibs="$deplib $compile_deplibs" 51915ffd6003Smrg finalize_deplibs="$deplib $finalize_deplibs" 51925ffd6003Smrg fi 51935ffd6003Smrg func_stripname '-L' '' "$deplib" 51945ffd6003Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 51955ffd6003Smrg ;; 51965ffd6003Smrg *) 51975ffd6003Smrg func_warning "\`-L' is ignored for archives/objects" 51985ffd6003Smrg ;; 51995ffd6003Smrg esac # linkmode 52005ffd6003Smrg continue 52015ffd6003Smrg ;; # -L 52025ffd6003Smrg -R*) 52035ffd6003Smrg if test "$pass" = link; then 52045ffd6003Smrg func_stripname '-R' '' "$deplib" 52055ffd6003Smrg dir=$func_stripname_result 52065ffd6003Smrg # Make sure the xrpath contains only unique directories. 52075ffd6003Smrg case "$xrpath " in 52085ffd6003Smrg *" $dir "*) ;; 52095ffd6003Smrg *) xrpath="$xrpath $dir" ;; 52105ffd6003Smrg esac 52115ffd6003Smrg fi 52125ffd6003Smrg deplibs="$deplib $deplibs" 52135ffd6003Smrg continue 52145ffd6003Smrg ;; 52155ffd6003Smrg *.la) lib="$deplib" ;; 52165ffd6003Smrg *.$libext) 52175ffd6003Smrg if test "$pass" = conv; then 52185ffd6003Smrg deplibs="$deplib $deplibs" 52195ffd6003Smrg continue 52205ffd6003Smrg fi 52215ffd6003Smrg case $linkmode in 52225ffd6003Smrg lib) 52235ffd6003Smrg # Linking convenience modules into shared libraries is allowed, 52245ffd6003Smrg # but linking other static libraries is non-portable. 52255ffd6003Smrg case " $dlpreconveniencelibs " in 52265ffd6003Smrg *" $deplib "*) ;; 52275ffd6003Smrg *) 52285ffd6003Smrg valid_a_lib=no 52295ffd6003Smrg case $deplibs_check_method in 52305ffd6003Smrg match_pattern*) 52315ffd6003Smrg set dummy $deplibs_check_method; shift 52325ffd6003Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 52335ffd6003Smrg if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \ 52345ffd6003Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 52355ffd6003Smrg valid_a_lib=yes 52365ffd6003Smrg fi 52375ffd6003Smrg ;; 52385ffd6003Smrg pass_all) 52395ffd6003Smrg valid_a_lib=yes 52405ffd6003Smrg ;; 52415ffd6003Smrg esac 52425ffd6003Smrg if test "$valid_a_lib" != yes; then 52435ffd6003Smrg $ECHO 52445ffd6003Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 52455ffd6003Smrg $ECHO "*** I have the capability to make that library automatically link in when" 52465ffd6003Smrg $ECHO "*** you link to this library. But I can only do this if you have a" 52475ffd6003Smrg $ECHO "*** shared version of the library, which you do not appear to have" 52485ffd6003Smrg $ECHO "*** because the file extensions .$libext of this argument makes me believe" 52495ffd6003Smrg $ECHO "*** that it is just a static archive that I should not use here." 52505ffd6003Smrg else 52515ffd6003Smrg $ECHO 52525ffd6003Smrg $ECHO "*** Warning: Linking the shared library $output against the" 52535ffd6003Smrg $ECHO "*** static library $deplib is not portable!" 52545ffd6003Smrg deplibs="$deplib $deplibs" 52555ffd6003Smrg fi 52565ffd6003Smrg ;; 52575ffd6003Smrg esac 52585ffd6003Smrg continue 52595ffd6003Smrg ;; 52605ffd6003Smrg prog) 52615ffd6003Smrg if test "$pass" != link; then 52625ffd6003Smrg deplibs="$deplib $deplibs" 52635ffd6003Smrg else 52645ffd6003Smrg compile_deplibs="$deplib $compile_deplibs" 52655ffd6003Smrg finalize_deplibs="$deplib $finalize_deplibs" 52665ffd6003Smrg fi 52675ffd6003Smrg continue 52685ffd6003Smrg ;; 52695ffd6003Smrg esac # linkmode 52705ffd6003Smrg ;; # *.$libext 52715ffd6003Smrg *.lo | *.$objext) 52725ffd6003Smrg if test "$pass" = conv; then 52735ffd6003Smrg deplibs="$deplib $deplibs" 52745ffd6003Smrg elif test "$linkmode" = prog; then 52755ffd6003Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 52765ffd6003Smrg # If there is no dlopen support or we're linking statically, 52775ffd6003Smrg # we need to preload. 52785ffd6003Smrg newdlprefiles="$newdlprefiles $deplib" 52795ffd6003Smrg compile_deplibs="$deplib $compile_deplibs" 52805ffd6003Smrg finalize_deplibs="$deplib $finalize_deplibs" 52815ffd6003Smrg else 52825ffd6003Smrg newdlfiles="$newdlfiles $deplib" 52835ffd6003Smrg fi 52845ffd6003Smrg fi 52855ffd6003Smrg continue 52865ffd6003Smrg ;; 52875ffd6003Smrg %DEPLIBS%) 52885ffd6003Smrg alldeplibs=yes 52895ffd6003Smrg continue 52905ffd6003Smrg ;; 52915ffd6003Smrg esac # case $deplib 52925ffd6003Smrg 52935ffd6003Smrg if test "$found" = yes || test -f "$lib"; then : 52945ffd6003Smrg else 52955ffd6003Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 52965ffd6003Smrg fi 52975ffd6003Smrg 52985ffd6003Smrg # Check to see that this really is a libtool archive. 52995ffd6003Smrg func_lalib_unsafe_p "$lib" \ 53005ffd6003Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 53015ffd6003Smrg 53025ffd6003Smrg func_dirname "$lib" "" "." 53035ffd6003Smrg ladir="$func_dirname_result" 53045ffd6003Smrg 53055ffd6003Smrg dlname= 53065ffd6003Smrg dlopen= 53075ffd6003Smrg dlpreopen= 53085ffd6003Smrg libdir= 53095ffd6003Smrg library_names= 53105ffd6003Smrg old_library= 53115ffd6003Smrg inherited_linker_flags= 53125ffd6003Smrg # If the library was installed with an old release of libtool, 53135ffd6003Smrg # it will not redefine variables installed, or shouldnotlink 53145ffd6003Smrg installed=yes 53155ffd6003Smrg shouldnotlink=no 53165ffd6003Smrg avoidtemprpath= 53175ffd6003Smrg 53185ffd6003Smrg 53195ffd6003Smrg # Read the .la file 53205ffd6003Smrg func_source "$lib" 53215ffd6003Smrg 53225ffd6003Smrg # Convert "-framework foo" to "foo.ltframework" 53235ffd6003Smrg if test -n "$inherited_linker_flags"; then 53245ffd6003Smrg tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'` 53255ffd6003Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 53265ffd6003Smrg case " $new_inherited_linker_flags " in 53275ffd6003Smrg *" $tmp_inherited_linker_flag "*) ;; 53285ffd6003Smrg *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";; 53295ffd6003Smrg esac 53305ffd6003Smrg done 53315ffd6003Smrg fi 53325ffd6003Smrg dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 53335ffd6003Smrg if test "$linkmode,$pass" = "lib,link" || 53345ffd6003Smrg test "$linkmode,$pass" = "prog,scan" || 53355ffd6003Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 53365ffd6003Smrg test -n "$dlopen" && dlfiles="$dlfiles $dlopen" 53375ffd6003Smrg test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen" 53385ffd6003Smrg fi 53395ffd6003Smrg 53405ffd6003Smrg if test "$pass" = conv; then 53415ffd6003Smrg # Only check for convenience libraries 53425ffd6003Smrg deplibs="$lib $deplibs" 53435ffd6003Smrg if test -z "$libdir"; then 53445ffd6003Smrg if test -z "$old_library"; then 53455ffd6003Smrg func_fatal_error "cannot find name of link library for \`$lib'" 53465ffd6003Smrg fi 53475ffd6003Smrg # It is a libtool convenience library, so add in its objects. 53485ffd6003Smrg convenience="$convenience $ladir/$objdir/$old_library" 53495ffd6003Smrg old_convenience="$old_convenience $ladir/$objdir/$old_library" 53505ffd6003Smrg tmp_libs= 53515ffd6003Smrg for deplib in $dependency_libs; do 53525ffd6003Smrg deplibs="$deplib $deplibs" 53535ffd6003Smrg if $opt_duplicate_deps ; then 53545ffd6003Smrg case "$tmp_libs " in 53555ffd6003Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 53565ffd6003Smrg esac 53575ffd6003Smrg fi 53585ffd6003Smrg tmp_libs="$tmp_libs $deplib" 53595ffd6003Smrg done 53605ffd6003Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 53615ffd6003Smrg func_fatal_error "\`$lib' is not a convenience library" 53625ffd6003Smrg fi 53635ffd6003Smrg continue 53645ffd6003Smrg fi # $pass = conv 53655ffd6003Smrg 53665ffd6003Smrg 53675ffd6003Smrg # Get the name of the library we link against. 53685ffd6003Smrg linklib= 53695ffd6003Smrg for l in $old_library $library_names; do 53705ffd6003Smrg linklib="$l" 53715ffd6003Smrg done 53725ffd6003Smrg if test -z "$linklib"; then 53735ffd6003Smrg func_fatal_error "cannot find name of link library for \`$lib'" 53745ffd6003Smrg fi 53755ffd6003Smrg 53765ffd6003Smrg # This library was specified with -dlopen. 53775ffd6003Smrg if test "$pass" = dlopen; then 53785ffd6003Smrg if test -z "$libdir"; then 53795ffd6003Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 53805ffd6003Smrg fi 53815ffd6003Smrg if test -z "$dlname" || 53825ffd6003Smrg test "$dlopen_support" != yes || 53835ffd6003Smrg test "$build_libtool_libs" = no; then 53845ffd6003Smrg # If there is no dlname, no dlopen support or we're linking 53855ffd6003Smrg # statically, we need to preload. We also need to preload any 53865ffd6003Smrg # dependent libraries so libltdl's deplib preloader doesn't 53875ffd6003Smrg # bomb out in the load deplibs phase. 53885ffd6003Smrg dlprefiles="$dlprefiles $lib $dependency_libs" 53895ffd6003Smrg else 53905ffd6003Smrg newdlfiles="$newdlfiles $lib" 53915ffd6003Smrg fi 53925ffd6003Smrg continue 53935ffd6003Smrg fi # $pass = dlopen 53945ffd6003Smrg 53955ffd6003Smrg # We need an absolute path. 53965ffd6003Smrg case $ladir in 53975ffd6003Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 53985ffd6003Smrg *) 53995ffd6003Smrg abs_ladir=`cd "$ladir" && pwd` 54005ffd6003Smrg if test -z "$abs_ladir"; then 54015ffd6003Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 54025ffd6003Smrg func_warning "passing it literally to the linker, although it might fail" 54035ffd6003Smrg abs_ladir="$ladir" 54045ffd6003Smrg fi 54055ffd6003Smrg ;; 54065ffd6003Smrg esac 54075ffd6003Smrg func_basename "$lib" 54085ffd6003Smrg laname="$func_basename_result" 54095ffd6003Smrg 54105ffd6003Smrg # Find the relevant object directory and library name. 54115ffd6003Smrg if test "X$installed" = Xyes; then 54125ffd6003Smrg if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 54135ffd6003Smrg func_warning "library \`$lib' was moved." 54145ffd6003Smrg dir="$ladir" 54155ffd6003Smrg absdir="$abs_ladir" 54165ffd6003Smrg libdir="$abs_ladir" 54175ffd6003Smrg else 54185ffd6003Smrg dir="$libdir" 54195ffd6003Smrg absdir="$libdir" 54205ffd6003Smrg fi 54215ffd6003Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 54225ffd6003Smrg else 54235ffd6003Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 54245ffd6003Smrg dir="$ladir" 54255ffd6003Smrg absdir="$abs_ladir" 54265ffd6003Smrg # Remove this search path later 54275ffd6003Smrg notinst_path="$notinst_path $abs_ladir" 54285ffd6003Smrg else 54295ffd6003Smrg dir="$ladir/$objdir" 54305ffd6003Smrg absdir="$abs_ladir/$objdir" 54315ffd6003Smrg # Remove this search path later 54325ffd6003Smrg notinst_path="$notinst_path $abs_ladir" 54335ffd6003Smrg fi 54345ffd6003Smrg fi # $installed = yes 54355ffd6003Smrg func_stripname 'lib' '.la' "$laname" 54365ffd6003Smrg name=$func_stripname_result 54375ffd6003Smrg 54385ffd6003Smrg # This library was specified with -dlpreopen. 54395ffd6003Smrg if test "$pass" = dlpreopen; then 54405ffd6003Smrg if test -z "$libdir" && test "$linkmode" = prog; then 54415ffd6003Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 54425ffd6003Smrg fi 54435ffd6003Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 54445ffd6003Smrg # are required to link). 54455ffd6003Smrg if test -n "$old_library"; then 54465ffd6003Smrg newdlprefiles="$newdlprefiles $dir/$old_library" 54475ffd6003Smrg # Keep a list of preopened convenience libraries to check 54485ffd6003Smrg # that they are being used correctly in the link pass. 54495ffd6003Smrg test -z "$libdir" && \ 54505ffd6003Smrg dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library" 54515ffd6003Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 54525ffd6003Smrg elif test -n "$dlname"; then 54535ffd6003Smrg newdlprefiles="$newdlprefiles $dir/$dlname" 54545ffd6003Smrg else 54555ffd6003Smrg newdlprefiles="$newdlprefiles $dir/$linklib" 54565ffd6003Smrg fi 54575ffd6003Smrg fi # $pass = dlpreopen 54585ffd6003Smrg 54595ffd6003Smrg if test -z "$libdir"; then 54605ffd6003Smrg # Link the convenience library 54615ffd6003Smrg if test "$linkmode" = lib; then 54625ffd6003Smrg deplibs="$dir/$old_library $deplibs" 54635ffd6003Smrg elif test "$linkmode,$pass" = "prog,link"; then 54645ffd6003Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 54655ffd6003Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 54665ffd6003Smrg else 54675ffd6003Smrg deplibs="$lib $deplibs" # used for prog,scan pass 54685ffd6003Smrg fi 54695ffd6003Smrg continue 54705ffd6003Smrg fi 54715ffd6003Smrg 54725ffd6003Smrg 54735ffd6003Smrg if test "$linkmode" = prog && test "$pass" != link; then 54745ffd6003Smrg newlib_search_path="$newlib_search_path $ladir" 54755ffd6003Smrg deplibs="$lib $deplibs" 54765ffd6003Smrg 54775ffd6003Smrg linkalldeplibs=no 54785ffd6003Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 54795ffd6003Smrg test "$build_libtool_libs" = no; then 54805ffd6003Smrg linkalldeplibs=yes 54815ffd6003Smrg fi 54825ffd6003Smrg 54835ffd6003Smrg tmp_libs= 54845ffd6003Smrg for deplib in $dependency_libs; do 54855ffd6003Smrg case $deplib in 54865ffd6003Smrg -L*) func_stripname '-L' '' "$deplib" 54875ffd6003Smrg newlib_search_path="$newlib_search_path $func_stripname_result" 54885ffd6003Smrg ;; 54895ffd6003Smrg esac 54905ffd6003Smrg # Need to link against all dependency_libs? 54915ffd6003Smrg if test "$linkalldeplibs" = yes; then 54925ffd6003Smrg deplibs="$deplib $deplibs" 54935ffd6003Smrg else 54945ffd6003Smrg # Need to hardcode shared library paths 54955ffd6003Smrg # or/and link against static libraries 54965ffd6003Smrg newdependency_libs="$deplib $newdependency_libs" 54975ffd6003Smrg fi 54985ffd6003Smrg if $opt_duplicate_deps ; then 54995ffd6003Smrg case "$tmp_libs " in 55005ffd6003Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 55015ffd6003Smrg esac 55025ffd6003Smrg fi 55035ffd6003Smrg tmp_libs="$tmp_libs $deplib" 55045ffd6003Smrg done # for deplib 55055ffd6003Smrg continue 55065ffd6003Smrg fi # $linkmode = prog... 55075ffd6003Smrg 55085ffd6003Smrg if test "$linkmode,$pass" = "prog,link"; then 55095ffd6003Smrg if test -n "$library_names" && 55105ffd6003Smrg { { test "$prefer_static_libs" = no || 55115ffd6003Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 55125ffd6003Smrg test -z "$old_library"; }; then 55135ffd6003Smrg # We need to hardcode the library path 55145ffd6003Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 55155ffd6003Smrg # Make sure the rpath contains only unique directories. 55165ffd6003Smrg case "$temp_rpath:" in 55175ffd6003Smrg *"$absdir:"*) ;; 55185ffd6003Smrg *) temp_rpath="$temp_rpath$absdir:" ;; 55195ffd6003Smrg esac 55205ffd6003Smrg fi 55215ffd6003Smrg 55225ffd6003Smrg # Hardcode the library path. 55235ffd6003Smrg # Skip directories that are in the system default run-time 55245ffd6003Smrg # search path. 55255ffd6003Smrg case " $sys_lib_dlsearch_path " in 55265ffd6003Smrg *" $absdir "*) ;; 55275ffd6003Smrg *) 55285ffd6003Smrg case "$compile_rpath " in 55295ffd6003Smrg *" $absdir "*) ;; 55305ffd6003Smrg *) compile_rpath="$compile_rpath $absdir" 55315ffd6003Smrg esac 55325ffd6003Smrg ;; 55335ffd6003Smrg esac 55345ffd6003Smrg case " $sys_lib_dlsearch_path " in 55355ffd6003Smrg *" $libdir "*) ;; 55365ffd6003Smrg *) 55375ffd6003Smrg case "$finalize_rpath " in 55385ffd6003Smrg *" $libdir "*) ;; 55395ffd6003Smrg *) finalize_rpath="$finalize_rpath $libdir" 55405ffd6003Smrg esac 55415ffd6003Smrg ;; 55425ffd6003Smrg esac 55435ffd6003Smrg fi # $linkmode,$pass = prog,link... 55445ffd6003Smrg 55455ffd6003Smrg if test "$alldeplibs" = yes && 55465ffd6003Smrg { test "$deplibs_check_method" = pass_all || 55475ffd6003Smrg { test "$build_libtool_libs" = yes && 55485ffd6003Smrg test -n "$library_names"; }; }; then 55495ffd6003Smrg # We only need to search for static libraries 55505ffd6003Smrg continue 55515ffd6003Smrg fi 55525ffd6003Smrg fi 55535ffd6003Smrg 55545ffd6003Smrg link_static=no # Whether the deplib will be linked statically 55555ffd6003Smrg use_static_libs=$prefer_static_libs 55565ffd6003Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 55575ffd6003Smrg use_static_libs=no 55585ffd6003Smrg fi 55595ffd6003Smrg if test -n "$library_names" && 55605ffd6003Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 55615ffd6003Smrg case $host in 55625ffd6003Smrg *cygwin* | *mingw* | *cegcc*) 55635ffd6003Smrg # No point in relinking DLLs because paths are not encoded 55645ffd6003Smrg notinst_deplibs="$notinst_deplibs $lib" 55655ffd6003Smrg need_relink=no 55665ffd6003Smrg ;; 55675ffd6003Smrg *) 55685ffd6003Smrg if test "$installed" = no; then 55695ffd6003Smrg notinst_deplibs="$notinst_deplibs $lib" 55705ffd6003Smrg need_relink=yes 55715ffd6003Smrg fi 55725ffd6003Smrg ;; 55735ffd6003Smrg esac 55745ffd6003Smrg # This is a shared library 55755ffd6003Smrg 55765ffd6003Smrg # Warn about portability, can't link against -module's on some 55775ffd6003Smrg # systems (darwin). Don't bleat about dlopened modules though! 55785ffd6003Smrg dlopenmodule="" 55795ffd6003Smrg for dlpremoduletest in $dlprefiles; do 55805ffd6003Smrg if test "X$dlpremoduletest" = "X$lib"; then 55815ffd6003Smrg dlopenmodule="$dlpremoduletest" 55825ffd6003Smrg break 55835ffd6003Smrg fi 55845ffd6003Smrg done 55855ffd6003Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 55865ffd6003Smrg $ECHO 55875ffd6003Smrg if test "$linkmode" = prog; then 55885ffd6003Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 55895ffd6003Smrg else 55905ffd6003Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 55915ffd6003Smrg fi 55925ffd6003Smrg $ECHO "*** $linklib is not portable!" 55935ffd6003Smrg fi 55945ffd6003Smrg if test "$linkmode" = lib && 55955ffd6003Smrg test "$hardcode_into_libs" = yes; then 55965ffd6003Smrg # Hardcode the library path. 55975ffd6003Smrg # Skip directories that are in the system default run-time 55985ffd6003Smrg # search path. 55995ffd6003Smrg case " $sys_lib_dlsearch_path " in 56005ffd6003Smrg *" $absdir "*) ;; 56015ffd6003Smrg *) 56025ffd6003Smrg case "$compile_rpath " in 56035ffd6003Smrg *" $absdir "*) ;; 56045ffd6003Smrg *) compile_rpath="$compile_rpath $absdir" 56055ffd6003Smrg esac 56065ffd6003Smrg ;; 56075ffd6003Smrg esac 56085ffd6003Smrg case " $sys_lib_dlsearch_path " in 56095ffd6003Smrg *" $libdir "*) ;; 56105ffd6003Smrg *) 56115ffd6003Smrg case "$finalize_rpath " in 56125ffd6003Smrg *" $libdir "*) ;; 56135ffd6003Smrg *) finalize_rpath="$finalize_rpath $libdir" 56145ffd6003Smrg esac 56155ffd6003Smrg ;; 56165ffd6003Smrg esac 56175ffd6003Smrg fi 56185ffd6003Smrg 56195ffd6003Smrg if test -n "$old_archive_from_expsyms_cmds"; then 56205ffd6003Smrg # figure out the soname 56215ffd6003Smrg set dummy $library_names 56225ffd6003Smrg shift 56235ffd6003Smrg realname="$1" 56245ffd6003Smrg shift 56255ffd6003Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 56265ffd6003Smrg # use dlname if we got it. it's perfectly good, no? 56275ffd6003Smrg if test -n "$dlname"; then 56285ffd6003Smrg soname="$dlname" 56295ffd6003Smrg elif test -n "$soname_spec"; then 56305ffd6003Smrg # bleh windows 56315ffd6003Smrg case $host in 56325ffd6003Smrg *cygwin* | mingw* | *cegcc*) 56335ffd6003Smrg func_arith $current - $age 56345ffd6003Smrg major=$func_arith_result 56355ffd6003Smrg versuffix="-$major" 56365ffd6003Smrg ;; 56375ffd6003Smrg esac 56385ffd6003Smrg eval soname=\"$soname_spec\" 56395ffd6003Smrg else 56405ffd6003Smrg soname="$realname" 56415ffd6003Smrg fi 56425ffd6003Smrg 56435ffd6003Smrg # Make a new name for the extract_expsyms_cmds to use 56445ffd6003Smrg soroot="$soname" 56455ffd6003Smrg func_basename "$soroot" 56465ffd6003Smrg soname="$func_basename_result" 56475ffd6003Smrg func_stripname 'lib' '.dll' "$soname" 56485ffd6003Smrg newlib=libimp-$func_stripname_result.a 56495ffd6003Smrg 56505ffd6003Smrg # If the library has no export list, then create one now 56515ffd6003Smrg if test -f "$output_objdir/$soname-def"; then : 56525ffd6003Smrg else 56535ffd6003Smrg func_verbose "extracting exported symbol list from \`$soname'" 56545ffd6003Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 56555ffd6003Smrg fi 56565ffd6003Smrg 56575ffd6003Smrg # Create $newlib 56585ffd6003Smrg if test -f "$output_objdir/$newlib"; then :; else 56595ffd6003Smrg func_verbose "generating import library for \`$soname'" 56605ffd6003Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 56615ffd6003Smrg fi 56625ffd6003Smrg # make sure the library variables are pointing to the new library 56635ffd6003Smrg dir=$output_objdir 56645ffd6003Smrg linklib=$newlib 56655ffd6003Smrg fi # test -n "$old_archive_from_expsyms_cmds" 56665ffd6003Smrg 56675ffd6003Smrg if test "$linkmode" = prog || test "$mode" != relink; then 56685ffd6003Smrg add_shlibpath= 56695ffd6003Smrg add_dir= 56705ffd6003Smrg add= 56715ffd6003Smrg lib_linked=yes 56725ffd6003Smrg case $hardcode_action in 56735ffd6003Smrg immediate | unsupported) 56745ffd6003Smrg if test "$hardcode_direct" = no; then 56755ffd6003Smrg add="$dir/$linklib" 56765ffd6003Smrg case $host in 56775ffd6003Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 56785ffd6003Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 56795ffd6003Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 56805ffd6003Smrg *-*-unixware7*) add_dir="-L$dir" ;; 56815ffd6003Smrg *-*-darwin* ) 56825ffd6003Smrg # if the lib is a (non-dlopened) module then we can not 56835ffd6003Smrg # link against it, someone is ignoring the earlier warnings 56845ffd6003Smrg if /usr/bin/file -L $add 2> /dev/null | 56855ffd6003Smrg $GREP ": [^:]* bundle" >/dev/null ; then 56865ffd6003Smrg if test "X$dlopenmodule" != "X$lib"; then 56875ffd6003Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 56885ffd6003Smrg if test -z "$old_library" ; then 56895ffd6003Smrg $ECHO 56905ffd6003Smrg $ECHO "*** And there doesn't seem to be a static archive available" 56915ffd6003Smrg $ECHO "*** The link will probably fail, sorry" 56925ffd6003Smrg else 56935ffd6003Smrg add="$dir/$old_library" 56945ffd6003Smrg fi 56955ffd6003Smrg elif test -n "$old_library"; then 56965ffd6003Smrg add="$dir/$old_library" 56975ffd6003Smrg fi 56985ffd6003Smrg fi 56995ffd6003Smrg esac 57005ffd6003Smrg elif test "$hardcode_minus_L" = no; then 57015ffd6003Smrg case $host in 57025ffd6003Smrg *-*-sunos*) add_shlibpath="$dir" ;; 57035ffd6003Smrg esac 57045ffd6003Smrg add_dir="-L$dir" 57055ffd6003Smrg add="-l$name" 57065ffd6003Smrg elif test "$hardcode_shlibpath_var" = no; then 57075ffd6003Smrg add_shlibpath="$dir" 57085ffd6003Smrg add="-l$name" 57095ffd6003Smrg else 57105ffd6003Smrg lib_linked=no 57115ffd6003Smrg fi 57125ffd6003Smrg ;; 57135ffd6003Smrg relink) 57145ffd6003Smrg if test "$hardcode_direct" = yes && 57155ffd6003Smrg test "$hardcode_direct_absolute" = no; then 57165ffd6003Smrg add="$dir/$linklib" 57175ffd6003Smrg elif test "$hardcode_minus_L" = yes; then 57185ffd6003Smrg add_dir="-L$dir" 57195ffd6003Smrg # Try looking first in the location we're being installed to. 57205ffd6003Smrg if test -n "$inst_prefix_dir"; then 57215ffd6003Smrg case $libdir in 57225ffd6003Smrg [\\/]*) 57235ffd6003Smrg add_dir="$add_dir -L$inst_prefix_dir$libdir" 57245ffd6003Smrg ;; 57255ffd6003Smrg esac 57265ffd6003Smrg fi 57275ffd6003Smrg add="-l$name" 57285ffd6003Smrg elif test "$hardcode_shlibpath_var" = yes; then 57295ffd6003Smrg add_shlibpath="$dir" 57305ffd6003Smrg add="-l$name" 57315ffd6003Smrg else 57325ffd6003Smrg lib_linked=no 57335ffd6003Smrg fi 57345ffd6003Smrg ;; 57355ffd6003Smrg *) lib_linked=no ;; 57365ffd6003Smrg esac 57375ffd6003Smrg 57385ffd6003Smrg if test "$lib_linked" != yes; then 57395ffd6003Smrg func_fatal_configuration "unsupported hardcode properties" 57405ffd6003Smrg fi 57415ffd6003Smrg 57425ffd6003Smrg if test -n "$add_shlibpath"; then 57435ffd6003Smrg case :$compile_shlibpath: in 57445ffd6003Smrg *":$add_shlibpath:"*) ;; 57455ffd6003Smrg *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;; 57465ffd6003Smrg esac 57475ffd6003Smrg fi 57485ffd6003Smrg if test "$linkmode" = prog; then 57495ffd6003Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 57505ffd6003Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 57515ffd6003Smrg else 57525ffd6003Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 57535ffd6003Smrg test -n "$add" && deplibs="$add $deplibs" 57545ffd6003Smrg if test "$hardcode_direct" != yes && 57555ffd6003Smrg test "$hardcode_minus_L" != yes && 57565ffd6003Smrg test "$hardcode_shlibpath_var" = yes; then 57575ffd6003Smrg case :$finalize_shlibpath: in 57585ffd6003Smrg *":$libdir:"*) ;; 57595ffd6003Smrg *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; 57605ffd6003Smrg esac 57615ffd6003Smrg fi 57625ffd6003Smrg fi 57635ffd6003Smrg fi 57645ffd6003Smrg 57655ffd6003Smrg if test "$linkmode" = prog || test "$mode" = relink; then 57665ffd6003Smrg add_shlibpath= 57675ffd6003Smrg add_dir= 57685ffd6003Smrg add= 57695ffd6003Smrg # Finalize command for both is simple: just hardcode it. 57705ffd6003Smrg if test "$hardcode_direct" = yes && 57715ffd6003Smrg test "$hardcode_direct_absolute" = no; then 57725ffd6003Smrg add="$libdir/$linklib" 57735ffd6003Smrg elif test "$hardcode_minus_L" = yes; then 57745ffd6003Smrg add_dir="-L$libdir" 57755ffd6003Smrg add="-l$name" 57765ffd6003Smrg elif test "$hardcode_shlibpath_var" = yes; then 57775ffd6003Smrg case :$finalize_shlibpath: in 57785ffd6003Smrg *":$libdir:"*) ;; 57795ffd6003Smrg *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;; 57805ffd6003Smrg esac 57815ffd6003Smrg add="-l$name" 57825ffd6003Smrg elif test "$hardcode_automatic" = yes; then 57835ffd6003Smrg if test -n "$inst_prefix_dir" && 57845ffd6003Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 57855ffd6003Smrg add="$inst_prefix_dir$libdir/$linklib" 57865ffd6003Smrg else 57875ffd6003Smrg add="$libdir/$linklib" 57885ffd6003Smrg fi 57895ffd6003Smrg else 57905ffd6003Smrg # We cannot seem to hardcode it, guess we'll fake it. 57915ffd6003Smrg add_dir="-L$libdir" 57925ffd6003Smrg # Try looking first in the location we're being installed to. 57935ffd6003Smrg if test -n "$inst_prefix_dir"; then 57945ffd6003Smrg case $libdir in 57955ffd6003Smrg [\\/]*) 57965ffd6003Smrg add_dir="$add_dir -L$inst_prefix_dir$libdir" 57975ffd6003Smrg ;; 57985ffd6003Smrg esac 57995ffd6003Smrg fi 58005ffd6003Smrg add="-l$name" 58015ffd6003Smrg fi 58025ffd6003Smrg 58035ffd6003Smrg if test "$linkmode" = prog; then 58045ffd6003Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 58055ffd6003Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 58065ffd6003Smrg else 58075ffd6003Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 58085ffd6003Smrg test -n "$add" && deplibs="$add $deplibs" 58095ffd6003Smrg fi 58105ffd6003Smrg fi 58115ffd6003Smrg elif test "$linkmode" = prog; then 58125ffd6003Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 58135ffd6003Smrg # is not unsupported. This is valid on all known static and 58145ffd6003Smrg # shared platforms. 58155ffd6003Smrg if test "$hardcode_direct" != unsupported; then 58165ffd6003Smrg test -n "$old_library" && linklib="$old_library" 58175ffd6003Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 58185ffd6003Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 58195ffd6003Smrg else 58205ffd6003Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 58215ffd6003Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 58225ffd6003Smrg fi 58235ffd6003Smrg elif test "$build_libtool_libs" = yes; then 58245ffd6003Smrg # Not a shared library 58255ffd6003Smrg if test "$deplibs_check_method" != pass_all; then 58265ffd6003Smrg # We're trying link a shared library against a static one 58275ffd6003Smrg # but the system doesn't support it. 58285ffd6003Smrg 58295ffd6003Smrg # Just print a warning and add the library to dependency_libs so 58305ffd6003Smrg # that the program can be linked against the static library. 58315ffd6003Smrg $ECHO 58325ffd6003Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 58335ffd6003Smrg $ECHO "*** I have the capability to make that library automatically link in when" 58345ffd6003Smrg $ECHO "*** you link to this library. But I can only do this if you have a" 58355ffd6003Smrg $ECHO "*** shared version of the library, which you do not appear to have." 58365ffd6003Smrg if test "$module" = yes; then 58375ffd6003Smrg $ECHO "*** But as you try to build a module library, libtool will still create " 58385ffd6003Smrg $ECHO "*** a static module, that should work as long as the dlopening application" 58395ffd6003Smrg $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime." 58405ffd6003Smrg if test -z "$global_symbol_pipe"; then 58415ffd6003Smrg $ECHO 58425ffd6003Smrg $ECHO "*** However, this would only work if libtool was able to extract symbol" 58435ffd6003Smrg $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" 58445ffd6003Smrg $ECHO "*** not find such a program. So, this module is probably useless." 58455ffd6003Smrg $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." 58465ffd6003Smrg fi 58475ffd6003Smrg if test "$build_old_libs" = no; then 58485ffd6003Smrg build_libtool_libs=module 58495ffd6003Smrg build_old_libs=yes 58505ffd6003Smrg else 58515ffd6003Smrg build_libtool_libs=no 58525ffd6003Smrg fi 58535ffd6003Smrg fi 58545ffd6003Smrg else 58555ffd6003Smrg deplibs="$dir/$old_library $deplibs" 58565ffd6003Smrg link_static=yes 58575ffd6003Smrg fi 58585ffd6003Smrg fi # link shared/static library? 58595ffd6003Smrg 58605ffd6003Smrg if test "$linkmode" = lib; then 58615ffd6003Smrg if test -n "$dependency_libs" && 58625ffd6003Smrg { test "$hardcode_into_libs" != yes || 58635ffd6003Smrg test "$build_old_libs" = yes || 58645ffd6003Smrg test "$link_static" = yes; }; then 58655ffd6003Smrg # Extract -R from dependency_libs 58665ffd6003Smrg temp_deplibs= 58675ffd6003Smrg for libdir in $dependency_libs; do 58685ffd6003Smrg case $libdir in 58695ffd6003Smrg -R*) func_stripname '-R' '' "$libdir" 58705ffd6003Smrg temp_xrpath=$func_stripname_result 58715ffd6003Smrg case " $xrpath " in 58725ffd6003Smrg *" $temp_xrpath "*) ;; 58735ffd6003Smrg *) xrpath="$xrpath $temp_xrpath";; 58745ffd6003Smrg esac;; 58755ffd6003Smrg *) temp_deplibs="$temp_deplibs $libdir";; 58765ffd6003Smrg esac 58775ffd6003Smrg done 58785ffd6003Smrg dependency_libs="$temp_deplibs" 58795ffd6003Smrg fi 58805ffd6003Smrg 58815ffd6003Smrg newlib_search_path="$newlib_search_path $absdir" 58825ffd6003Smrg # Link against this library 58835ffd6003Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 58845ffd6003Smrg # ... and its dependency_libs 58855ffd6003Smrg tmp_libs= 58865ffd6003Smrg for deplib in $dependency_libs; do 58875ffd6003Smrg newdependency_libs="$deplib $newdependency_libs" 58885ffd6003Smrg if $opt_duplicate_deps ; then 58895ffd6003Smrg case "$tmp_libs " in 58905ffd6003Smrg *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;; 58915ffd6003Smrg esac 58925ffd6003Smrg fi 58935ffd6003Smrg tmp_libs="$tmp_libs $deplib" 58945ffd6003Smrg done 58955ffd6003Smrg 58965ffd6003Smrg if test "$link_all_deplibs" != no; then 58975ffd6003Smrg # Add the search paths of all dependency libraries 58985ffd6003Smrg for deplib in $dependency_libs; do 58995ffd6003Smrg path= 59005ffd6003Smrg case $deplib in 59015ffd6003Smrg -L*) path="$deplib" ;; 59025ffd6003Smrg *.la) 59035ffd6003Smrg func_dirname "$deplib" "" "." 59045ffd6003Smrg dir="$func_dirname_result" 59055ffd6003Smrg # We need an absolute path. 59065ffd6003Smrg case $dir in 59075ffd6003Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 59085ffd6003Smrg *) 59095ffd6003Smrg absdir=`cd "$dir" && pwd` 59105ffd6003Smrg if test -z "$absdir"; then 59115ffd6003Smrg func_warning "cannot determine absolute directory name of \`$dir'" 59125ffd6003Smrg absdir="$dir" 59135ffd6003Smrg fi 59145ffd6003Smrg ;; 59155ffd6003Smrg esac 59165ffd6003Smrg if $GREP "^installed=no" $deplib > /dev/null; then 59175ffd6003Smrg case $host in 59185ffd6003Smrg *-*-darwin*) 59195ffd6003Smrg depdepl= 59205ffd6003Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 59215ffd6003Smrg if test -n "$deplibrary_names" ; then 59225ffd6003Smrg for tmp in $deplibrary_names ; do 59235ffd6003Smrg depdepl=$tmp 59245ffd6003Smrg done 59255ffd6003Smrg if test -f "$absdir/$objdir/$depdepl" ; then 59265ffd6003Smrg depdepl="$absdir/$objdir/$depdepl" 59275ffd6003Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 59285ffd6003Smrg if test -z "$darwin_install_name"; then 59295ffd6003Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 59305ffd6003Smrg fi 59315ffd6003Smrg compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 59325ffd6003Smrg linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}" 59335ffd6003Smrg path= 59345ffd6003Smrg fi 59355ffd6003Smrg fi 59365ffd6003Smrg ;; 59375ffd6003Smrg *) 59385ffd6003Smrg path="-L$absdir/$objdir" 59395ffd6003Smrg ;; 59405ffd6003Smrg esac 59415ffd6003Smrg else 59425ffd6003Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 59435ffd6003Smrg test -z "$libdir" && \ 59445ffd6003Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 59455ffd6003Smrg test "$absdir" != "$libdir" && \ 59465ffd6003Smrg func_warning "\`$deplib' seems to be moved" 59475ffd6003Smrg 59485ffd6003Smrg path="-L$absdir" 59495ffd6003Smrg fi 59505ffd6003Smrg ;; 59515ffd6003Smrg esac 59525ffd6003Smrg case " $deplibs " in 59535ffd6003Smrg *" $path "*) ;; 59545ffd6003Smrg *) deplibs="$path $deplibs" ;; 59555ffd6003Smrg esac 59565ffd6003Smrg done 59575ffd6003Smrg fi # link_all_deplibs != no 59585ffd6003Smrg fi # linkmode = lib 59595ffd6003Smrg done # for deplib in $libs 59605ffd6003Smrg if test "$pass" = link; then 59615ffd6003Smrg if test "$linkmode" = "prog"; then 59625ffd6003Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 59635ffd6003Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 59645ffd6003Smrg else 59655ffd6003Smrg compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 59665ffd6003Smrg fi 59675ffd6003Smrg fi 59685ffd6003Smrg dependency_libs="$newdependency_libs" 59695ffd6003Smrg if test "$pass" = dlpreopen; then 59705ffd6003Smrg # Link the dlpreopened libraries before other libraries 59715ffd6003Smrg for deplib in $save_deplibs; do 59725ffd6003Smrg deplibs="$deplib $deplibs" 59735ffd6003Smrg done 59745ffd6003Smrg fi 59755ffd6003Smrg if test "$pass" != dlopen; then 59765ffd6003Smrg if test "$pass" != conv; then 59775ffd6003Smrg # Make sure lib_search_path contains only unique directories. 59785ffd6003Smrg lib_search_path= 59795ffd6003Smrg for dir in $newlib_search_path; do 59805ffd6003Smrg case "$lib_search_path " in 59815ffd6003Smrg *" $dir "*) ;; 59825ffd6003Smrg *) lib_search_path="$lib_search_path $dir" ;; 59835ffd6003Smrg esac 59845ffd6003Smrg done 59855ffd6003Smrg newlib_search_path= 59865ffd6003Smrg fi 59875ffd6003Smrg 59885ffd6003Smrg if test "$linkmode,$pass" != "prog,link"; then 59895ffd6003Smrg vars="deplibs" 59905ffd6003Smrg else 59915ffd6003Smrg vars="compile_deplibs finalize_deplibs" 59925ffd6003Smrg fi 59935ffd6003Smrg for var in $vars dependency_libs; do 59945ffd6003Smrg # Add libraries to $var in reverse order 59955ffd6003Smrg eval tmp_libs=\"\$$var\" 59965ffd6003Smrg new_libs= 59975ffd6003Smrg for deplib in $tmp_libs; do 59985ffd6003Smrg # FIXME: Pedantically, this is the right thing to do, so 59995ffd6003Smrg # that some nasty dependency loop isn't accidentally 60005ffd6003Smrg # broken: 60015ffd6003Smrg #new_libs="$deplib $new_libs" 60025ffd6003Smrg # Pragmatically, this seems to cause very few problems in 60035ffd6003Smrg # practice: 60045ffd6003Smrg case $deplib in 60055ffd6003Smrg -L*) new_libs="$deplib $new_libs" ;; 60065ffd6003Smrg -R*) ;; 60075ffd6003Smrg *) 60085ffd6003Smrg # And here is the reason: when a library appears more 60095ffd6003Smrg # than once as an explicit dependence of a library, or 60105ffd6003Smrg # is implicitly linked in more than once by the 60115ffd6003Smrg # compiler, it is considered special, and multiple 60125ffd6003Smrg # occurrences thereof are not removed. Compare this 60135ffd6003Smrg # with having the same library being listed as a 60145ffd6003Smrg # dependency of multiple other libraries: in this case, 60155ffd6003Smrg # we know (pedantically, we assume) the library does not 60165ffd6003Smrg # need to be listed more than once, so we keep only the 60175ffd6003Smrg # last copy. This is not always right, but it is rare 60185ffd6003Smrg # enough that we require users that really mean to play 60195ffd6003Smrg # such unportable linking tricks to link the library 60205ffd6003Smrg # using -Wl,-lname, so that libtool does not consider it 60215ffd6003Smrg # for duplicate removal. 60225ffd6003Smrg case " $specialdeplibs " in 60235ffd6003Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 60245ffd6003Smrg *) 60255ffd6003Smrg case " $new_libs " in 60265ffd6003Smrg *" $deplib "*) ;; 60275ffd6003Smrg *) new_libs="$deplib $new_libs" ;; 60285ffd6003Smrg esac 60295ffd6003Smrg ;; 60305ffd6003Smrg esac 60315ffd6003Smrg ;; 60325ffd6003Smrg esac 60335ffd6003Smrg done 60345ffd6003Smrg tmp_libs= 60355ffd6003Smrg for deplib in $new_libs; do 60365ffd6003Smrg case $deplib in 60375ffd6003Smrg -L*) 60385ffd6003Smrg case " $tmp_libs " in 60395ffd6003Smrg *" $deplib "*) ;; 60405ffd6003Smrg *) tmp_libs="$tmp_libs $deplib" ;; 60415ffd6003Smrg esac 60425ffd6003Smrg ;; 60435ffd6003Smrg *) tmp_libs="$tmp_libs $deplib" ;; 60445ffd6003Smrg esac 60455ffd6003Smrg done 60465ffd6003Smrg eval $var=\"$tmp_libs\" 60475ffd6003Smrg done # for var 60485ffd6003Smrg fi 60495ffd6003Smrg # Last step: remove runtime libs from dependency_libs 60505ffd6003Smrg # (they stay in deplibs) 60515ffd6003Smrg tmp_libs= 60525ffd6003Smrg for i in $dependency_libs ; do 60535ffd6003Smrg case " $predeps $postdeps $compiler_lib_search_path " in 60545ffd6003Smrg *" $i "*) 60555ffd6003Smrg i="" 60565ffd6003Smrg ;; 60575ffd6003Smrg esac 60585ffd6003Smrg if test -n "$i" ; then 60595ffd6003Smrg tmp_libs="$tmp_libs $i" 60605ffd6003Smrg fi 60615ffd6003Smrg done 60625ffd6003Smrg dependency_libs=$tmp_libs 60635ffd6003Smrg done # for pass 60645ffd6003Smrg if test "$linkmode" = prog; then 60655ffd6003Smrg dlfiles="$newdlfiles" 60665ffd6003Smrg fi 60675ffd6003Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 60685ffd6003Smrg dlprefiles="$newdlprefiles" 60695ffd6003Smrg fi 60705ffd6003Smrg 60715ffd6003Smrg case $linkmode in 60725ffd6003Smrg oldlib) 60735ffd6003Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 60745ffd6003Smrg func_warning "\`-dlopen' is ignored for archives" 60755ffd6003Smrg fi 60765ffd6003Smrg 60775ffd6003Smrg case " $deplibs" in 60785ffd6003Smrg *\ -l* | *\ -L*) 60795ffd6003Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 60805ffd6003Smrg esac 60815ffd6003Smrg 60825ffd6003Smrg test -n "$rpath" && \ 60835ffd6003Smrg func_warning "\`-rpath' is ignored for archives" 60845ffd6003Smrg 60855ffd6003Smrg test -n "$xrpath" && \ 60865ffd6003Smrg func_warning "\`-R' is ignored for archives" 60875ffd6003Smrg 60885ffd6003Smrg test -n "$vinfo" && \ 60895ffd6003Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 60905ffd6003Smrg 60915ffd6003Smrg test -n "$release" && \ 60925ffd6003Smrg func_warning "\`-release' is ignored for archives" 60935ffd6003Smrg 60945ffd6003Smrg test -n "$export_symbols$export_symbols_regex" && \ 60955ffd6003Smrg func_warning "\`-export-symbols' is ignored for archives" 60965ffd6003Smrg 60975ffd6003Smrg # Now set the variables for building old libraries. 60985ffd6003Smrg build_libtool_libs=no 60995ffd6003Smrg oldlibs="$output" 61005ffd6003Smrg objs="$objs$old_deplibs" 61015ffd6003Smrg ;; 61025ffd6003Smrg 61035ffd6003Smrg lib) 61045ffd6003Smrg # Make sure we only generate libraries of the form `libNAME.la'. 61055ffd6003Smrg case $outputname in 61065ffd6003Smrg lib*) 61075ffd6003Smrg func_stripname 'lib' '.la' "$outputname" 61085ffd6003Smrg name=$func_stripname_result 61095ffd6003Smrg eval shared_ext=\"$shrext_cmds\" 61105ffd6003Smrg eval libname=\"$libname_spec\" 61115ffd6003Smrg ;; 61125ffd6003Smrg *) 61135ffd6003Smrg test "$module" = no && \ 61145ffd6003Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 61155ffd6003Smrg 61165ffd6003Smrg if test "$need_lib_prefix" != no; then 61175ffd6003Smrg # Add the "lib" prefix for modules if required 61185ffd6003Smrg func_stripname '' '.la' "$outputname" 61195ffd6003Smrg name=$func_stripname_result 61205ffd6003Smrg eval shared_ext=\"$shrext_cmds\" 61215ffd6003Smrg eval libname=\"$libname_spec\" 61225ffd6003Smrg else 61235ffd6003Smrg func_stripname '' '.la' "$outputname" 61245ffd6003Smrg libname=$func_stripname_result 61255ffd6003Smrg fi 61265ffd6003Smrg ;; 61275ffd6003Smrg esac 61285ffd6003Smrg 61295ffd6003Smrg if test -n "$objs"; then 61305ffd6003Smrg if test "$deplibs_check_method" != pass_all; then 61315ffd6003Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 61325ffd6003Smrg else 61335ffd6003Smrg $ECHO 61345ffd6003Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 61355ffd6003Smrg $ECHO "*** objects $objs is not portable!" 61365ffd6003Smrg libobjs="$libobjs $objs" 61375ffd6003Smrg fi 61385ffd6003Smrg fi 61395ffd6003Smrg 61405ffd6003Smrg test "$dlself" != no && \ 61415ffd6003Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 61425ffd6003Smrg 61435ffd6003Smrg set dummy $rpath 61445ffd6003Smrg shift 61455ffd6003Smrg test "$#" -gt 1 && \ 61465ffd6003Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 61475ffd6003Smrg 61485ffd6003Smrg install_libdir="$1" 61495ffd6003Smrg 61505ffd6003Smrg oldlibs= 61515ffd6003Smrg if test -z "$rpath"; then 61525ffd6003Smrg if test "$build_libtool_libs" = yes; then 61535ffd6003Smrg # Building a libtool convenience library. 61545ffd6003Smrg # Some compilers have problems with a `.al' extension so 61555ffd6003Smrg # convenience libraries should have the same extension an 61565ffd6003Smrg # archive normally would. 61575ffd6003Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 61585ffd6003Smrg build_libtool_libs=convenience 61595ffd6003Smrg build_old_libs=yes 61605ffd6003Smrg fi 61615ffd6003Smrg 61625ffd6003Smrg test -n "$vinfo" && \ 61635ffd6003Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 61645ffd6003Smrg 61655ffd6003Smrg test -n "$release" && \ 61665ffd6003Smrg func_warning "\`-release' is ignored for convenience libraries" 61675ffd6003Smrg else 61685ffd6003Smrg 61695ffd6003Smrg # Parse the version information argument. 61705ffd6003Smrg save_ifs="$IFS"; IFS=':' 61715ffd6003Smrg set dummy $vinfo 0 0 0 61725ffd6003Smrg shift 61735ffd6003Smrg IFS="$save_ifs" 61745ffd6003Smrg 61755ffd6003Smrg test -n "$7" && \ 61765ffd6003Smrg func_fatal_help "too many parameters to \`-version-info'" 61775ffd6003Smrg 61785ffd6003Smrg # convert absolute version numbers to libtool ages 61795ffd6003Smrg # this retains compatibility with .la files and attempts 61805ffd6003Smrg # to make the code below a bit more comprehensible 61815ffd6003Smrg 61825ffd6003Smrg case $vinfo_number in 61835ffd6003Smrg yes) 61845ffd6003Smrg number_major="$1" 61855ffd6003Smrg number_minor="$2" 61865ffd6003Smrg number_revision="$3" 61875ffd6003Smrg # 61885ffd6003Smrg # There are really only two kinds -- those that 61895ffd6003Smrg # use the current revision as the major version 61905ffd6003Smrg # and those that subtract age and use age as 61915ffd6003Smrg # a minor version. But, then there is irix 61925ffd6003Smrg # which has an extra 1 added just for fun 61935ffd6003Smrg # 61945ffd6003Smrg case $version_type in 61955ffd6003Smrg darwin|linux|osf|windows|none) 61965ffd6003Smrg func_arith $number_major + $number_minor 61975ffd6003Smrg current=$func_arith_result 61985ffd6003Smrg age="$number_minor" 61995ffd6003Smrg revision="$number_revision" 62005ffd6003Smrg ;; 62015ffd6003Smrg freebsd-aout|freebsd-elf|sunos) 62025ffd6003Smrg current="$number_major" 62035ffd6003Smrg revision="$number_minor" 62045ffd6003Smrg age="0" 62055ffd6003Smrg ;; 62065ffd6003Smrg irix|nonstopux) 62075ffd6003Smrg func_arith $number_major + $number_minor 62085ffd6003Smrg current=$func_arith_result 62095ffd6003Smrg age="$number_minor" 62105ffd6003Smrg revision="$number_minor" 62115ffd6003Smrg lt_irix_increment=no 62125ffd6003Smrg ;; 62135ffd6003Smrg *) 62145ffd6003Smrg func_fatal_configuration "$modename: unknown library version type \`$version_type'" 62155ffd6003Smrg ;; 62165ffd6003Smrg esac 62175ffd6003Smrg ;; 62185ffd6003Smrg no) 62195ffd6003Smrg current="$1" 62205ffd6003Smrg revision="$2" 62215ffd6003Smrg age="$3" 62225ffd6003Smrg ;; 62235ffd6003Smrg esac 62245ffd6003Smrg 62255ffd6003Smrg # Check that each of the things are valid numbers. 62265ffd6003Smrg case $current in 62275ffd6003Smrg 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]) ;; 62285ffd6003Smrg *) 62295ffd6003Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 62305ffd6003Smrg func_fatal_error "\`$vinfo' is not valid version information" 62315ffd6003Smrg ;; 62325ffd6003Smrg esac 62335ffd6003Smrg 62345ffd6003Smrg case $revision in 62355ffd6003Smrg 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]) ;; 62365ffd6003Smrg *) 62375ffd6003Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 62385ffd6003Smrg func_fatal_error "\`$vinfo' is not valid version information" 62395ffd6003Smrg ;; 62405ffd6003Smrg esac 62415ffd6003Smrg 62425ffd6003Smrg case $age in 62435ffd6003Smrg 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]) ;; 62445ffd6003Smrg *) 62455ffd6003Smrg func_error "AGE \`$age' must be a nonnegative integer" 62465ffd6003Smrg func_fatal_error "\`$vinfo' is not valid version information" 62475ffd6003Smrg ;; 62485ffd6003Smrg esac 62495ffd6003Smrg 62505ffd6003Smrg if test "$age" -gt "$current"; then 62515ffd6003Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 62525ffd6003Smrg func_fatal_error "\`$vinfo' is not valid version information" 62535ffd6003Smrg fi 62545ffd6003Smrg 62555ffd6003Smrg # Calculate the version variables. 62565ffd6003Smrg major= 62575ffd6003Smrg versuffix= 62585ffd6003Smrg verstring= 62595ffd6003Smrg case $version_type in 62605ffd6003Smrg none) ;; 62615ffd6003Smrg 62625ffd6003Smrg darwin) 62635ffd6003Smrg # Like Linux, but with the current version available in 62645ffd6003Smrg # verstring for coding it into the library header 62655ffd6003Smrg func_arith $current - $age 62665ffd6003Smrg major=.$func_arith_result 62675ffd6003Smrg versuffix="$major.$age.$revision" 62685ffd6003Smrg # Darwin ld doesn't like 0 for these options... 62695ffd6003Smrg func_arith $current + 1 62705ffd6003Smrg minor_current=$func_arith_result 62715ffd6003Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 62725ffd6003Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 62735ffd6003Smrg ;; 62745ffd6003Smrg 62755ffd6003Smrg freebsd-aout) 62765ffd6003Smrg major=".$current" 62775ffd6003Smrg versuffix=".$current.$revision"; 62785ffd6003Smrg ;; 62795ffd6003Smrg 62805ffd6003Smrg freebsd-elf) 62815ffd6003Smrg major=".$current" 62825ffd6003Smrg versuffix=".$current" 62835ffd6003Smrg ;; 62845ffd6003Smrg 62855ffd6003Smrg irix | nonstopux) 62865ffd6003Smrg if test "X$lt_irix_increment" = "Xno"; then 62875ffd6003Smrg func_arith $current - $age 62885ffd6003Smrg else 62895ffd6003Smrg func_arith $current - $age + 1 62905ffd6003Smrg fi 62915ffd6003Smrg major=$func_arith_result 62925ffd6003Smrg 62935ffd6003Smrg case $version_type in 62945ffd6003Smrg nonstopux) verstring_prefix=nonstopux ;; 62955ffd6003Smrg *) verstring_prefix=sgi ;; 62965ffd6003Smrg esac 62975ffd6003Smrg verstring="$verstring_prefix$major.$revision" 62985ffd6003Smrg 62995ffd6003Smrg # Add in all the interfaces that we are compatible with. 63005ffd6003Smrg loop=$revision 63015ffd6003Smrg while test "$loop" -ne 0; do 63025ffd6003Smrg func_arith $revision - $loop 63035ffd6003Smrg iface=$func_arith_result 63045ffd6003Smrg func_arith $loop - 1 63055ffd6003Smrg loop=$func_arith_result 63065ffd6003Smrg verstring="$verstring_prefix$major.$iface:$verstring" 63075ffd6003Smrg done 63085ffd6003Smrg 63095ffd6003Smrg # Before this point, $major must not contain `.'. 63105ffd6003Smrg major=.$major 63115ffd6003Smrg versuffix="$major.$revision" 63125ffd6003Smrg ;; 63135ffd6003Smrg 63145ffd6003Smrg linux) 63155ffd6003Smrg func_arith $current - $age 63165ffd6003Smrg major=.$func_arith_result 63175ffd6003Smrg versuffix="$major.$age.$revision" 63185ffd6003Smrg ;; 63195ffd6003Smrg 63205ffd6003Smrg osf) 63215ffd6003Smrg func_arith $current - $age 63225ffd6003Smrg major=.$func_arith_result 63235ffd6003Smrg versuffix=".$current.$age.$revision" 63245ffd6003Smrg verstring="$current.$age.$revision" 63255ffd6003Smrg 63265ffd6003Smrg # Add in all the interfaces that we are compatible with. 63275ffd6003Smrg loop=$age 63285ffd6003Smrg while test "$loop" -ne 0; do 63295ffd6003Smrg func_arith $current - $loop 63305ffd6003Smrg iface=$func_arith_result 63315ffd6003Smrg func_arith $loop - 1 63325ffd6003Smrg loop=$func_arith_result 63335ffd6003Smrg verstring="$verstring:${iface}.0" 63345ffd6003Smrg done 63355ffd6003Smrg 63365ffd6003Smrg # Make executables depend on our current version. 63375ffd6003Smrg verstring="$verstring:${current}.0" 63385ffd6003Smrg ;; 63395ffd6003Smrg 63405ffd6003Smrg qnx) 63415ffd6003Smrg major=".$current" 63425ffd6003Smrg versuffix=".$current" 63435ffd6003Smrg ;; 63445ffd6003Smrg 63455ffd6003Smrg sunos) 63465ffd6003Smrg major=".$current" 63475ffd6003Smrg versuffix=".$current.$revision" 63485ffd6003Smrg ;; 63495ffd6003Smrg 63505ffd6003Smrg windows) 63515ffd6003Smrg # Use '-' rather than '.', since we only want one 63525ffd6003Smrg # extension on DOS 8.3 filesystems. 63535ffd6003Smrg func_arith $current - $age 63545ffd6003Smrg major=$func_arith_result 63555ffd6003Smrg versuffix="-$major" 63565ffd6003Smrg ;; 63575ffd6003Smrg 63585ffd6003Smrg *) 63595ffd6003Smrg func_fatal_configuration "unknown library version type \`$version_type'" 63605ffd6003Smrg ;; 63615ffd6003Smrg esac 63625ffd6003Smrg 63635ffd6003Smrg # Clear the version info if we defaulted, and they specified a release. 63645ffd6003Smrg if test -z "$vinfo" && test -n "$release"; then 63655ffd6003Smrg major= 63665ffd6003Smrg case $version_type in 63675ffd6003Smrg darwin) 63685ffd6003Smrg # we can't check for "0.0" in archive_cmds due to quoting 63695ffd6003Smrg # problems, so we reset it completely 63705ffd6003Smrg verstring= 63715ffd6003Smrg ;; 63725ffd6003Smrg *) 63735ffd6003Smrg verstring="0.0" 63745ffd6003Smrg ;; 63755ffd6003Smrg esac 63765ffd6003Smrg if test "$need_version" = no; then 63775ffd6003Smrg versuffix= 63785ffd6003Smrg else 63795ffd6003Smrg versuffix=".0.0" 63805ffd6003Smrg fi 63815ffd6003Smrg fi 63825ffd6003Smrg 63835ffd6003Smrg # Remove version info from name if versioning should be avoided 63845ffd6003Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 63855ffd6003Smrg major= 63865ffd6003Smrg versuffix= 63875ffd6003Smrg verstring="" 63885ffd6003Smrg fi 63895ffd6003Smrg 63905ffd6003Smrg # Check to see if the archive will have undefined symbols. 63915ffd6003Smrg if test "$allow_undefined" = yes; then 63925ffd6003Smrg if test "$allow_undefined_flag" = unsupported; then 63935ffd6003Smrg func_warning "undefined symbols not allowed in $host shared libraries" 63945ffd6003Smrg build_libtool_libs=no 63955ffd6003Smrg build_old_libs=yes 63965ffd6003Smrg fi 63975ffd6003Smrg else 63985ffd6003Smrg # Don't allow undefined symbols. 63995ffd6003Smrg allow_undefined_flag="$no_undefined_flag" 64005ffd6003Smrg fi 64015ffd6003Smrg 64025ffd6003Smrg fi 64035ffd6003Smrg 64045ffd6003Smrg func_generate_dlsyms "$libname" "$libname" "yes" 64055ffd6003Smrg libobjs="$libobjs $symfileobj" 64065ffd6003Smrg test "X$libobjs" = "X " && libobjs= 64075ffd6003Smrg 64085ffd6003Smrg if test "$mode" != relink; then 64095ffd6003Smrg # Remove our outputs, but don't remove object files since they 64105ffd6003Smrg # may have been created when compiling PIC objects. 64115ffd6003Smrg removelist= 64125ffd6003Smrg tempremovelist=`$ECHO "$output_objdir/*"` 64135ffd6003Smrg for p in $tempremovelist; do 64145ffd6003Smrg case $p in 64155ffd6003Smrg *.$objext | *.gcno) 64165ffd6003Smrg ;; 64175ffd6003Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 64185ffd6003Smrg if test "X$precious_files_regex" != "X"; then 64195ffd6003Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 64205ffd6003Smrg then 64215ffd6003Smrg continue 64225ffd6003Smrg fi 64235ffd6003Smrg fi 64245ffd6003Smrg removelist="$removelist $p" 64255ffd6003Smrg ;; 64265ffd6003Smrg *) ;; 64275ffd6003Smrg esac 64285ffd6003Smrg done 64295ffd6003Smrg test -n "$removelist" && \ 64305ffd6003Smrg func_show_eval "${RM}r \$removelist" 64315ffd6003Smrg fi 64325ffd6003Smrg 64335ffd6003Smrg # Now set the variables for building old libraries. 64345ffd6003Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 64355ffd6003Smrg oldlibs="$oldlibs $output_objdir/$libname.$libext" 64365ffd6003Smrg 64375ffd6003Smrg # Transform .lo files to .o files. 64385ffd6003Smrg oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP` 64395ffd6003Smrg fi 64405ffd6003Smrg 64415ffd6003Smrg # Eliminate all temporary directories. 64425ffd6003Smrg #for path in $notinst_path; do 64435ffd6003Smrg # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"` 64445ffd6003Smrg # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"` 64455ffd6003Smrg # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"` 64465ffd6003Smrg #done 64475ffd6003Smrg 64485ffd6003Smrg if test -n "$xrpath"; then 64495ffd6003Smrg # If the user specified any rpath flags, then add them. 64505ffd6003Smrg temp_xrpath= 64515ffd6003Smrg for libdir in $xrpath; do 64525ffd6003Smrg temp_xrpath="$temp_xrpath -R$libdir" 64535ffd6003Smrg case "$finalize_rpath " in 64545ffd6003Smrg *" $libdir "*) ;; 64555ffd6003Smrg *) finalize_rpath="$finalize_rpath $libdir" ;; 64565ffd6003Smrg esac 64575ffd6003Smrg done 64585ffd6003Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 64595ffd6003Smrg dependency_libs="$temp_xrpath $dependency_libs" 64605ffd6003Smrg fi 64615ffd6003Smrg fi 64625ffd6003Smrg 64635ffd6003Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 64645ffd6003Smrg old_dlfiles="$dlfiles" 64655ffd6003Smrg dlfiles= 64665ffd6003Smrg for lib in $old_dlfiles; do 64675ffd6003Smrg case " $dlprefiles $dlfiles " in 64685ffd6003Smrg *" $lib "*) ;; 64695ffd6003Smrg *) dlfiles="$dlfiles $lib" ;; 64705ffd6003Smrg esac 64715ffd6003Smrg done 64725ffd6003Smrg 64735ffd6003Smrg # Make sure dlprefiles contains only unique files 64745ffd6003Smrg old_dlprefiles="$dlprefiles" 64755ffd6003Smrg dlprefiles= 64765ffd6003Smrg for lib in $old_dlprefiles; do 64775ffd6003Smrg case "$dlprefiles " in 64785ffd6003Smrg *" $lib "*) ;; 64795ffd6003Smrg *) dlprefiles="$dlprefiles $lib" ;; 64805ffd6003Smrg esac 64815ffd6003Smrg done 64825ffd6003Smrg 64835ffd6003Smrg if test "$build_libtool_libs" = yes; then 64845ffd6003Smrg if test -n "$rpath"; then 64855ffd6003Smrg case $host in 64865ffd6003Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*) 64875ffd6003Smrg # these systems don't actually have a c library (as such)! 64885ffd6003Smrg ;; 64895ffd6003Smrg *-*-rhapsody* | *-*-darwin1.[012]) 64905ffd6003Smrg # Rhapsody C library is in the System framework 64915ffd6003Smrg deplibs="$deplibs System.ltframework" 64925ffd6003Smrg ;; 64935ffd6003Smrg *-*-netbsd*) 64945ffd6003Smrg # Don't link with libc until the a.out ld.so is fixed. 64955ffd6003Smrg ;; 64965ffd6003Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 64975ffd6003Smrg # Do not include libc due to us having libc/libc_r. 64985ffd6003Smrg ;; 64995ffd6003Smrg *-*-sco3.2v5* | *-*-sco5v6*) 65005ffd6003Smrg # Causes problems with __ctype 65015ffd6003Smrg ;; 65025ffd6003Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 65035ffd6003Smrg # Compiler inserts libc in the correct place for threads to work 65045ffd6003Smrg ;; 65055ffd6003Smrg *) 65065ffd6003Smrg # Add libc to deplibs on all other systems if necessary. 65075ffd6003Smrg if test "$build_libtool_need_lc" = "yes"; then 65085ffd6003Smrg deplibs="$deplibs -lc" 65095ffd6003Smrg fi 65105ffd6003Smrg ;; 65115ffd6003Smrg esac 65125ffd6003Smrg fi 65135ffd6003Smrg 65145ffd6003Smrg # Transform deplibs into only deplibs that can be linked in shared. 65155ffd6003Smrg name_save=$name 65165ffd6003Smrg libname_save=$libname 65175ffd6003Smrg release_save=$release 65185ffd6003Smrg versuffix_save=$versuffix 65195ffd6003Smrg major_save=$major 65205ffd6003Smrg # I'm not sure if I'm treating the release correctly. I think 65215ffd6003Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 65225ffd6003Smrg # add it in twice. Is that correct? 65235ffd6003Smrg release="" 65245ffd6003Smrg versuffix="" 65255ffd6003Smrg major="" 65265ffd6003Smrg newdeplibs= 65275ffd6003Smrg droppeddeps=no 65285ffd6003Smrg case $deplibs_check_method in 65295ffd6003Smrg pass_all) 65305ffd6003Smrg # Don't check for shared/static. Everything works. 65315ffd6003Smrg # This might be a little naive. We might want to check 65325ffd6003Smrg # whether the library exists or not. But this is on 65335ffd6003Smrg # osf3 & osf4 and I'm not really sure... Just 65345ffd6003Smrg # implementing what was already the behavior. 65355ffd6003Smrg newdeplibs=$deplibs 65365ffd6003Smrg ;; 65375ffd6003Smrg test_compile) 65385ffd6003Smrg # This code stresses the "libraries are programs" paradigm to its 65395ffd6003Smrg # limits. Maybe even breaks it. We compile a program, linking it 65405ffd6003Smrg # against the deplibs as a proxy for the library. Then we can check 65415ffd6003Smrg # whether they linked in statically or dynamically with ldd. 65425ffd6003Smrg $opt_dry_run || $RM conftest.c 65435ffd6003Smrg cat > conftest.c <<EOF 65445ffd6003Smrg int main() { return 0; } 65455ffd6003SmrgEOF 65465ffd6003Smrg $opt_dry_run || $RM conftest 65475ffd6003Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 65485ffd6003Smrg ldd_output=`ldd conftest` 65495ffd6003Smrg for i in $deplibs; do 65505ffd6003Smrg case $i in 65515ffd6003Smrg -l*) 65525ffd6003Smrg func_stripname -l '' "$i" 65535ffd6003Smrg name=$func_stripname_result 65545ffd6003Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 65555ffd6003Smrg case " $predeps $postdeps " in 65565ffd6003Smrg *" $i "*) 65575ffd6003Smrg newdeplibs="$newdeplibs $i" 65585ffd6003Smrg i="" 65595ffd6003Smrg ;; 65605ffd6003Smrg esac 65615ffd6003Smrg fi 65625ffd6003Smrg if test -n "$i" ; then 65635ffd6003Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 65645ffd6003Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 65655ffd6003Smrg set dummy $deplib_matches; shift 65665ffd6003Smrg deplib_match=$1 65675ffd6003Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 65685ffd6003Smrg newdeplibs="$newdeplibs $i" 65695ffd6003Smrg else 65705ffd6003Smrg droppeddeps=yes 65715ffd6003Smrg $ECHO 65725ffd6003Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 65735ffd6003Smrg $ECHO "*** I have the capability to make that library automatically link in when" 65745ffd6003Smrg $ECHO "*** you link to this library. But I can only do this if you have a" 65755ffd6003Smrg $ECHO "*** shared version of the library, which I believe you do not have" 65765ffd6003Smrg $ECHO "*** because a test_compile did reveal that the linker did not use it for" 65775ffd6003Smrg $ECHO "*** its dynamic dependency list that programs get resolved with at runtime." 65785ffd6003Smrg fi 65795ffd6003Smrg fi 65805ffd6003Smrg ;; 65815ffd6003Smrg *) 65825ffd6003Smrg newdeplibs="$newdeplibs $i" 65835ffd6003Smrg ;; 65845ffd6003Smrg esac 65855ffd6003Smrg done 65865ffd6003Smrg else 65875ffd6003Smrg # Error occurred in the first compile. Let's try to salvage 65885ffd6003Smrg # the situation: Compile a separate program for each library. 65895ffd6003Smrg for i in $deplibs; do 65905ffd6003Smrg case $i in 65915ffd6003Smrg -l*) 65925ffd6003Smrg func_stripname -l '' "$i" 65935ffd6003Smrg name=$func_stripname_result 65945ffd6003Smrg $opt_dry_run || $RM conftest 65955ffd6003Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 65965ffd6003Smrg ldd_output=`ldd conftest` 65975ffd6003Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 65985ffd6003Smrg case " $predeps $postdeps " in 65995ffd6003Smrg *" $i "*) 66005ffd6003Smrg newdeplibs="$newdeplibs $i" 66015ffd6003Smrg i="" 66025ffd6003Smrg ;; 66035ffd6003Smrg esac 66045ffd6003Smrg fi 66055ffd6003Smrg if test -n "$i" ; then 66065ffd6003Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 66075ffd6003Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 66085ffd6003Smrg set dummy $deplib_matches; shift 66095ffd6003Smrg deplib_match=$1 66105ffd6003Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 66115ffd6003Smrg newdeplibs="$newdeplibs $i" 66125ffd6003Smrg else 66135ffd6003Smrg droppeddeps=yes 66145ffd6003Smrg $ECHO 66155ffd6003Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 66165ffd6003Smrg $ECHO "*** I have the capability to make that library automatically link in when" 66175ffd6003Smrg $ECHO "*** you link to this library. But I can only do this if you have a" 66185ffd6003Smrg $ECHO "*** shared version of the library, which you do not appear to have" 66195ffd6003Smrg $ECHO "*** because a test_compile did reveal that the linker did not use this one" 66205ffd6003Smrg $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime." 66215ffd6003Smrg fi 66225ffd6003Smrg fi 66235ffd6003Smrg else 66245ffd6003Smrg droppeddeps=yes 66255ffd6003Smrg $ECHO 66265ffd6003Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 66275ffd6003Smrg $ECHO "*** make it link in! You will probably need to install it or some" 66285ffd6003Smrg $ECHO "*** library that it depends on before this library will be fully" 66295ffd6003Smrg $ECHO "*** functional. Installing it before continuing would be even better." 66305ffd6003Smrg fi 66315ffd6003Smrg ;; 66325ffd6003Smrg *) 66335ffd6003Smrg newdeplibs="$newdeplibs $i" 66345ffd6003Smrg ;; 66355ffd6003Smrg esac 66365ffd6003Smrg done 66375ffd6003Smrg fi 66385ffd6003Smrg ;; 66395ffd6003Smrg file_magic*) 66405ffd6003Smrg set dummy $deplibs_check_method; shift 66415ffd6003Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 66425ffd6003Smrg for a_deplib in $deplibs; do 66435ffd6003Smrg case $a_deplib in 66445ffd6003Smrg -l*) 66455ffd6003Smrg func_stripname -l '' "$a_deplib" 66465ffd6003Smrg name=$func_stripname_result 66475ffd6003Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 66485ffd6003Smrg case " $predeps $postdeps " in 66495ffd6003Smrg *" $a_deplib "*) 66505ffd6003Smrg newdeplibs="$newdeplibs $a_deplib" 66515ffd6003Smrg a_deplib="" 66525ffd6003Smrg ;; 66535ffd6003Smrg esac 66545ffd6003Smrg fi 66555ffd6003Smrg if test -n "$a_deplib" ; then 66565ffd6003Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 66575ffd6003Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 66585ffd6003Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 66595ffd6003Smrg for potent_lib in $potential_libs; do 66605ffd6003Smrg # Follow soft links. 66615ffd6003Smrg if ls -lLd "$potent_lib" 2>/dev/null | 66625ffd6003Smrg $GREP " -> " >/dev/null; then 66635ffd6003Smrg continue 66645ffd6003Smrg fi 66655ffd6003Smrg # The statement above tries to avoid entering an 66665ffd6003Smrg # endless loop below, in case of cyclic links. 66675ffd6003Smrg # We might still enter an endless loop, since a link 66685ffd6003Smrg # loop can be closed while we follow links, 66695ffd6003Smrg # but so what? 66705ffd6003Smrg potlib="$potent_lib" 66715ffd6003Smrg while test -h "$potlib" 2>/dev/null; do 66725ffd6003Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 66735ffd6003Smrg case $potliblink in 66745ffd6003Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 66755ffd6003Smrg *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";; 66765ffd6003Smrg esac 66775ffd6003Smrg done 66785ffd6003Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 66795ffd6003Smrg $SED -e 10q | 66805ffd6003Smrg $EGREP "$file_magic_regex" > /dev/null; then 66815ffd6003Smrg newdeplibs="$newdeplibs $a_deplib" 66825ffd6003Smrg a_deplib="" 66835ffd6003Smrg break 2 66845ffd6003Smrg fi 66855ffd6003Smrg done 66865ffd6003Smrg done 66875ffd6003Smrg fi 66885ffd6003Smrg if test -n "$a_deplib" ; then 66895ffd6003Smrg droppeddeps=yes 66905ffd6003Smrg $ECHO 66915ffd6003Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 66925ffd6003Smrg $ECHO "*** I have the capability to make that library automatically link in when" 66935ffd6003Smrg $ECHO "*** you link to this library. But I can only do this if you have a" 66945ffd6003Smrg $ECHO "*** shared version of the library, which you do not appear to have" 66955ffd6003Smrg $ECHO "*** because I did check the linker path looking for a file starting" 66965ffd6003Smrg if test -z "$potlib" ; then 66975ffd6003Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 66985ffd6003Smrg else 66995ffd6003Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 67005ffd6003Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 67015ffd6003Smrg fi 67025ffd6003Smrg fi 67035ffd6003Smrg ;; 67045ffd6003Smrg *) 67055ffd6003Smrg # Add a -L argument. 67065ffd6003Smrg newdeplibs="$newdeplibs $a_deplib" 67075ffd6003Smrg ;; 67085ffd6003Smrg esac 67095ffd6003Smrg done # Gone through all deplibs. 67105ffd6003Smrg ;; 67115ffd6003Smrg match_pattern*) 67125ffd6003Smrg set dummy $deplibs_check_method; shift 67135ffd6003Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 67145ffd6003Smrg for a_deplib in $deplibs; do 67155ffd6003Smrg case $a_deplib in 67165ffd6003Smrg -l*) 67175ffd6003Smrg func_stripname -l '' "$a_deplib" 67185ffd6003Smrg name=$func_stripname_result 67195ffd6003Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 67205ffd6003Smrg case " $predeps $postdeps " in 67215ffd6003Smrg *" $a_deplib "*) 67225ffd6003Smrg newdeplibs="$newdeplibs $a_deplib" 67235ffd6003Smrg a_deplib="" 67245ffd6003Smrg ;; 67255ffd6003Smrg esac 67265ffd6003Smrg fi 67275ffd6003Smrg if test -n "$a_deplib" ; then 67285ffd6003Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 67295ffd6003Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 67305ffd6003Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 67315ffd6003Smrg for potent_lib in $potential_libs; do 67325ffd6003Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 67335ffd6003Smrg if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \ 67345ffd6003Smrg $EGREP "$match_pattern_regex" > /dev/null; then 67355ffd6003Smrg newdeplibs="$newdeplibs $a_deplib" 67365ffd6003Smrg a_deplib="" 67375ffd6003Smrg break 2 67385ffd6003Smrg fi 67395ffd6003Smrg done 67405ffd6003Smrg done 67415ffd6003Smrg fi 67425ffd6003Smrg if test -n "$a_deplib" ; then 67435ffd6003Smrg droppeddeps=yes 67445ffd6003Smrg $ECHO 67455ffd6003Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 67465ffd6003Smrg $ECHO "*** I have the capability to make that library automatically link in when" 67475ffd6003Smrg $ECHO "*** you link to this library. But I can only do this if you have a" 67485ffd6003Smrg $ECHO "*** shared version of the library, which you do not appear to have" 67495ffd6003Smrg $ECHO "*** because I did check the linker path looking for a file starting" 67505ffd6003Smrg if test -z "$potlib" ; then 67515ffd6003Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 67525ffd6003Smrg else 67535ffd6003Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 67545ffd6003Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 67555ffd6003Smrg fi 67565ffd6003Smrg fi 67575ffd6003Smrg ;; 67585ffd6003Smrg *) 67595ffd6003Smrg # Add a -L argument. 67605ffd6003Smrg newdeplibs="$newdeplibs $a_deplib" 67615ffd6003Smrg ;; 67625ffd6003Smrg esac 67635ffd6003Smrg done # Gone through all deplibs. 67645ffd6003Smrg ;; 67655ffd6003Smrg none | unknown | *) 67665ffd6003Smrg newdeplibs="" 67675ffd6003Smrg tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \ 67685ffd6003Smrg -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'` 67695ffd6003Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 67705ffd6003Smrg for i in $predeps $postdeps ; do 67715ffd6003Smrg # can't use Xsed below, because $i might contain '/' 67725ffd6003Smrg tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"` 67735ffd6003Smrg done 67745ffd6003Smrg fi 67755ffd6003Smrg if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' | 67765ffd6003Smrg $GREP . >/dev/null; then 67775ffd6003Smrg $ECHO 67785ffd6003Smrg if test "X$deplibs_check_method" = "Xnone"; then 67795ffd6003Smrg $ECHO "*** Warning: inter-library dependencies are not supported in this platform." 67805ffd6003Smrg else 67815ffd6003Smrg $ECHO "*** Warning: inter-library dependencies are not known to be supported." 67825ffd6003Smrg fi 67835ffd6003Smrg $ECHO "*** All declared inter-library dependencies are being dropped." 67845ffd6003Smrg droppeddeps=yes 67855ffd6003Smrg fi 67865ffd6003Smrg ;; 67875ffd6003Smrg esac 67885ffd6003Smrg versuffix=$versuffix_save 67895ffd6003Smrg major=$major_save 67905ffd6003Smrg release=$release_save 67915ffd6003Smrg libname=$libname_save 67925ffd6003Smrg name=$name_save 67935ffd6003Smrg 67945ffd6003Smrg case $host in 67955ffd6003Smrg *-*-rhapsody* | *-*-darwin1.[012]) 67965ffd6003Smrg # On Rhapsody replace the C library with the System framework 67975ffd6003Smrg newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'` 67985ffd6003Smrg ;; 67995ffd6003Smrg esac 68005ffd6003Smrg 68015ffd6003Smrg if test "$droppeddeps" = yes; then 68025ffd6003Smrg if test "$module" = yes; then 68035ffd6003Smrg $ECHO 68045ffd6003Smrg $ECHO "*** Warning: libtool could not satisfy all declared inter-library" 68055ffd6003Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 68065ffd6003Smrg $ECHO "*** a static module, that should work as long as the dlopening" 68075ffd6003Smrg $ECHO "*** application is linked with the -dlopen flag." 68085ffd6003Smrg if test -z "$global_symbol_pipe"; then 68095ffd6003Smrg $ECHO 68105ffd6003Smrg $ECHO "*** However, this would only work if libtool was able to extract symbol" 68115ffd6003Smrg $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could" 68125ffd6003Smrg $ECHO "*** not find such a program. So, this module is probably useless." 68135ffd6003Smrg $ECHO "*** \`nm' from GNU binutils and a full rebuild may help." 68145ffd6003Smrg fi 68155ffd6003Smrg if test "$build_old_libs" = no; then 68165ffd6003Smrg oldlibs="$output_objdir/$libname.$libext" 68175ffd6003Smrg build_libtool_libs=module 68185ffd6003Smrg build_old_libs=yes 68195ffd6003Smrg else 68205ffd6003Smrg build_libtool_libs=no 68215ffd6003Smrg fi 68225ffd6003Smrg else 68235ffd6003Smrg $ECHO "*** The inter-library dependencies that have been dropped here will be" 68245ffd6003Smrg $ECHO "*** automatically added whenever a program is linked with this library" 68255ffd6003Smrg $ECHO "*** or is declared to -dlopen it." 68265ffd6003Smrg 68275ffd6003Smrg if test "$allow_undefined" = no; then 68285ffd6003Smrg $ECHO 68295ffd6003Smrg $ECHO "*** Since this library must not contain undefined symbols," 68305ffd6003Smrg $ECHO "*** because either the platform does not support them or" 68315ffd6003Smrg $ECHO "*** it was explicitly requested with -no-undefined," 68325ffd6003Smrg $ECHO "*** libtool will only create a static version of it." 68335ffd6003Smrg if test "$build_old_libs" = no; then 68345ffd6003Smrg oldlibs="$output_objdir/$libname.$libext" 68355ffd6003Smrg build_libtool_libs=module 68365ffd6003Smrg build_old_libs=yes 68375ffd6003Smrg else 68385ffd6003Smrg build_libtool_libs=no 68395ffd6003Smrg fi 68405ffd6003Smrg fi 68415ffd6003Smrg fi 68425ffd6003Smrg fi 68435ffd6003Smrg # Done checking deplibs! 68445ffd6003Smrg deplibs=$newdeplibs 68455ffd6003Smrg fi 68465ffd6003Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 68475ffd6003Smrg case $host in 68485ffd6003Smrg *-*-darwin*) 68495ffd6003Smrg newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 68505ffd6003Smrg new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 68515ffd6003Smrg deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 68525ffd6003Smrg ;; 68535ffd6003Smrg esac 68545ffd6003Smrg 68555ffd6003Smrg # move library search paths that coincide with paths to not yet 68565ffd6003Smrg # installed libraries to the beginning of the library search list 68575ffd6003Smrg new_libs= 68585ffd6003Smrg for path in $notinst_path; do 68595ffd6003Smrg case " $new_libs " in 68605ffd6003Smrg *" -L$path/$objdir "*) ;; 68615ffd6003Smrg *) 68625ffd6003Smrg case " $deplibs " in 68635ffd6003Smrg *" -L$path/$objdir "*) 68645ffd6003Smrg new_libs="$new_libs -L$path/$objdir" ;; 68655ffd6003Smrg esac 68665ffd6003Smrg ;; 68675ffd6003Smrg esac 68685ffd6003Smrg done 68695ffd6003Smrg for deplib in $deplibs; do 68705ffd6003Smrg case $deplib in 68715ffd6003Smrg -L*) 68725ffd6003Smrg case " $new_libs " in 68735ffd6003Smrg *" $deplib "*) ;; 68745ffd6003Smrg *) new_libs="$new_libs $deplib" ;; 68755ffd6003Smrg esac 68765ffd6003Smrg ;; 68775ffd6003Smrg *) new_libs="$new_libs $deplib" ;; 68785ffd6003Smrg esac 68795ffd6003Smrg done 68805ffd6003Smrg deplibs="$new_libs" 68815ffd6003Smrg 68825ffd6003Smrg # All the library-specific variables (install_libdir is set above). 68835ffd6003Smrg library_names= 68845ffd6003Smrg old_library= 68855ffd6003Smrg dlname= 68865ffd6003Smrg 68875ffd6003Smrg # Test again, we may have decided not to build it any more 68885ffd6003Smrg if test "$build_libtool_libs" = yes; then 68895ffd6003Smrg if test "$hardcode_into_libs" = yes; then 68905ffd6003Smrg # Hardcode the library paths 68915ffd6003Smrg hardcode_libdirs= 68925ffd6003Smrg dep_rpath= 68935ffd6003Smrg rpath="$finalize_rpath" 68945ffd6003Smrg test "$mode" != relink && rpath="$compile_rpath$rpath" 68955ffd6003Smrg for libdir in $rpath; do 68965ffd6003Smrg if test -n "$hardcode_libdir_flag_spec"; then 68975ffd6003Smrg if test -n "$hardcode_libdir_separator"; then 68985ffd6003Smrg if test -z "$hardcode_libdirs"; then 68995ffd6003Smrg hardcode_libdirs="$libdir" 69005ffd6003Smrg else 69015ffd6003Smrg # Just accumulate the unique libdirs. 69025ffd6003Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 69035ffd6003Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 69045ffd6003Smrg ;; 69055ffd6003Smrg *) 69065ffd6003Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 69075ffd6003Smrg ;; 69085ffd6003Smrg esac 69095ffd6003Smrg fi 69105ffd6003Smrg else 69115ffd6003Smrg eval flag=\"$hardcode_libdir_flag_spec\" 69125ffd6003Smrg dep_rpath="$dep_rpath $flag" 69135ffd6003Smrg fi 69145ffd6003Smrg elif test -n "$runpath_var"; then 69155ffd6003Smrg case "$perm_rpath " in 69165ffd6003Smrg *" $libdir "*) ;; 69175ffd6003Smrg *) perm_rpath="$perm_rpath $libdir" ;; 69185ffd6003Smrg esac 69195ffd6003Smrg fi 69205ffd6003Smrg done 69215ffd6003Smrg # Substitute the hardcoded libdirs into the rpath. 69225ffd6003Smrg if test -n "$hardcode_libdir_separator" && 69235ffd6003Smrg test -n "$hardcode_libdirs"; then 69245ffd6003Smrg libdir="$hardcode_libdirs" 69255ffd6003Smrg if test -n "$hardcode_libdir_flag_spec_ld"; then 69265ffd6003Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 69275ffd6003Smrg else 69285ffd6003Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec\" 69295ffd6003Smrg fi 69305ffd6003Smrg fi 69315ffd6003Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 69325ffd6003Smrg # We should set the runpath_var. 69335ffd6003Smrg rpath= 69345ffd6003Smrg for dir in $perm_rpath; do 69355ffd6003Smrg rpath="$rpath$dir:" 69365ffd6003Smrg done 69375ffd6003Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 69385ffd6003Smrg fi 69395ffd6003Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 69405ffd6003Smrg fi 6941145b7b3cSmrg 69425ffd6003Smrg shlibpath="$finalize_shlibpath" 69435ffd6003Smrg test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 69445ffd6003Smrg if test -n "$shlibpath"; then 69455ffd6003Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 69465ffd6003Smrg fi 6947145b7b3cSmrg 69485ffd6003Smrg # Get the real and link names of the library. 69495ffd6003Smrg eval shared_ext=\"$shrext_cmds\" 69505ffd6003Smrg eval library_names=\"$library_names_spec\" 69515ffd6003Smrg set dummy $library_names 69525ffd6003Smrg shift 69535ffd6003Smrg realname="$1" 69545ffd6003Smrg shift 6955145b7b3cSmrg 69565ffd6003Smrg if test -n "$soname_spec"; then 69575ffd6003Smrg eval soname=\"$soname_spec\" 69585ffd6003Smrg else 69595ffd6003Smrg soname="$realname" 69605ffd6003Smrg fi 69615ffd6003Smrg if test -z "$dlname"; then 69625ffd6003Smrg dlname=$soname 69635ffd6003Smrg fi 6964145b7b3cSmrg 69655ffd6003Smrg lib="$output_objdir/$realname" 69665ffd6003Smrg linknames= 69675ffd6003Smrg for link 69685ffd6003Smrg do 69695ffd6003Smrg linknames="$linknames $link" 69705ffd6003Smrg done 6971145b7b3cSmrg 69725ffd6003Smrg # Use standard objects if they are pic 69735ffd6003Smrg test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` 69745ffd6003Smrg test "X$libobjs" = "X " && libobjs= 6975145b7b3cSmrg 69765ffd6003Smrg delfiles= 69775ffd6003Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 69785ffd6003Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 69795ffd6003Smrg export_symbols="$output_objdir/$libname.uexp" 69805ffd6003Smrg delfiles="$delfiles $export_symbols" 69815ffd6003Smrg fi 6982145b7b3cSmrg 69835ffd6003Smrg orig_export_symbols= 69845ffd6003Smrg case $host_os in 69855ffd6003Smrg cygwin* | mingw* | cegcc*) 69865ffd6003Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 69875ffd6003Smrg # exporting using user supplied symfile 69885ffd6003Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 69895ffd6003Smrg # and it's NOT already a .def file. Must figure out 69905ffd6003Smrg # which of the given symbols are data symbols and tag 69915ffd6003Smrg # them as such. So, trigger use of export_symbols_cmds. 69925ffd6003Smrg # export_symbols gets reassigned inside the "prepare 69935ffd6003Smrg # the list of exported symbols" if statement, so the 69945ffd6003Smrg # include_expsyms logic still works. 69955ffd6003Smrg orig_export_symbols="$export_symbols" 69965ffd6003Smrg export_symbols= 69975ffd6003Smrg always_export_symbols=yes 69985ffd6003Smrg fi 69995ffd6003Smrg fi 70005ffd6003Smrg ;; 70015ffd6003Smrg esac 7002145b7b3cSmrg 70035ffd6003Smrg # Prepare the list of exported symbols 70045ffd6003Smrg if test -z "$export_symbols"; then 70055ffd6003Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 70065ffd6003Smrg func_verbose "generating symbol list for \`$libname.la'" 70075ffd6003Smrg export_symbols="$output_objdir/$libname.exp" 70085ffd6003Smrg $opt_dry_run || $RM $export_symbols 70095ffd6003Smrg cmds=$export_symbols_cmds 70105ffd6003Smrg save_ifs="$IFS"; IFS='~' 70115ffd6003Smrg for cmd in $cmds; do 70125ffd6003Smrg IFS="$save_ifs" 70135ffd6003Smrg eval cmd=\"$cmd\" 70145ffd6003Smrg func_len " $cmd" 70155ffd6003Smrg len=$func_len_result 70165ffd6003Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 70175ffd6003Smrg func_show_eval "$cmd" 'exit $?' 70185ffd6003Smrg skipped_export=false 70195ffd6003Smrg else 70205ffd6003Smrg # The command line is too long to execute in one step. 70215ffd6003Smrg func_verbose "using reloadable object file for export list..." 70225ffd6003Smrg skipped_export=: 70235ffd6003Smrg # Break out early, otherwise skipped_export may be 70245ffd6003Smrg # set to false by a later but shorter cmd. 70255ffd6003Smrg break 70265ffd6003Smrg fi 70275ffd6003Smrg done 70285ffd6003Smrg IFS="$save_ifs" 70295ffd6003Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 70305ffd6003Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 70315ffd6003Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 70325ffd6003Smrg fi 70335ffd6003Smrg fi 7034145b7b3cSmrg fi 7035145b7b3cSmrg 70365ffd6003Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 70375ffd6003Smrg tmp_export_symbols="$export_symbols" 70385ffd6003Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 70395ffd6003Smrg $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' 70405ffd6003Smrg fi 7041145b7b3cSmrg 70425ffd6003Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 70435ffd6003Smrg # The given exports_symbols file has to be filtered, so filter it. 70445ffd6003Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 70455ffd6003Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 70465ffd6003Smrg # 's' commands which not all seds can handle. GNU sed should be fine 70475ffd6003Smrg # though. Also, the filter scales superlinearly with the number of 70485ffd6003Smrg # global variables. join(1) would be nice here, but unfortunately 70495ffd6003Smrg # isn't a blessed tool. 70505ffd6003Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 70515ffd6003Smrg delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" 70525ffd6003Smrg export_symbols=$output_objdir/$libname.def 70535ffd6003Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 70545ffd6003Smrg fi 7055145b7b3cSmrg 70565ffd6003Smrg tmp_deplibs= 70575ffd6003Smrg for test_deplib in $deplibs; do 70585ffd6003Smrg case " $convenience " in 70595ffd6003Smrg *" $test_deplib "*) ;; 70605ffd6003Smrg *) 70615ffd6003Smrg tmp_deplibs="$tmp_deplibs $test_deplib" 70625ffd6003Smrg ;; 70635ffd6003Smrg esac 70645ffd6003Smrg done 70655ffd6003Smrg deplibs="$tmp_deplibs" 7066145b7b3cSmrg 70675ffd6003Smrg if test -n "$convenience"; then 70685ffd6003Smrg if test -n "$whole_archive_flag_spec" && 70695ffd6003Smrg test "$compiler_needs_object" = yes && 70705ffd6003Smrg test -z "$libobjs"; then 70715ffd6003Smrg # extract the archives, so we have objects to list. 70725ffd6003Smrg # TODO: could optimize this to just extract one archive. 70735ffd6003Smrg whole_archive_flag_spec= 70745ffd6003Smrg fi 70755ffd6003Smrg if test -n "$whole_archive_flag_spec"; then 70765ffd6003Smrg save_libobjs=$libobjs 70775ffd6003Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 70785ffd6003Smrg test "X$libobjs" = "X " && libobjs= 70795ffd6003Smrg else 70805ffd6003Smrg gentop="$output_objdir/${outputname}x" 70815ffd6003Smrg generated="$generated $gentop" 7082145b7b3cSmrg 70835ffd6003Smrg func_extract_archives $gentop $convenience 70845ffd6003Smrg libobjs="$libobjs $func_extract_archives_result" 70855ffd6003Smrg test "X$libobjs" = "X " && libobjs= 70865ffd6003Smrg fi 7087145b7b3cSmrg fi 7088145b7b3cSmrg 70895ffd6003Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 70905ffd6003Smrg eval flag=\"$thread_safe_flag_spec\" 70915ffd6003Smrg linker_flags="$linker_flags $flag" 7092145b7b3cSmrg fi 7093145b7b3cSmrg 70945ffd6003Smrg # Make a backup of the uninstalled library when relinking 70955ffd6003Smrg if test "$mode" = relink; then 70965ffd6003Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 70975ffd6003Smrg fi 7098145b7b3cSmrg 70995ffd6003Smrg # Do each of the archive commands. 71005ffd6003Smrg if test "$module" = yes && test -n "$module_cmds" ; then 71015ffd6003Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 71025ffd6003Smrg eval test_cmds=\"$module_expsym_cmds\" 71035ffd6003Smrg cmds=$module_expsym_cmds 71045ffd6003Smrg else 71055ffd6003Smrg eval test_cmds=\"$module_cmds\" 71065ffd6003Smrg cmds=$module_cmds 71075ffd6003Smrg fi 7108145b7b3cSmrg else 71095ffd6003Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 71105ffd6003Smrg eval test_cmds=\"$archive_expsym_cmds\" 71115ffd6003Smrg cmds=$archive_expsym_cmds 71125ffd6003Smrg else 71135ffd6003Smrg eval test_cmds=\"$archive_cmds\" 71145ffd6003Smrg cmds=$archive_cmds 71155ffd6003Smrg fi 7116145b7b3cSmrg fi 7117145b7b3cSmrg 71185ffd6003Smrg if test "X$skipped_export" != "X:" && 71195ffd6003Smrg func_len " $test_cmds" && 71205ffd6003Smrg len=$func_len_result && 71215ffd6003Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 71225ffd6003Smrg : 71235ffd6003Smrg else 71245ffd6003Smrg # The command line is too long to link in one step, link piecewise 71255ffd6003Smrg # or, if using GNU ld and skipped_export is not :, use a linker 71265ffd6003Smrg # script. 7127145b7b3cSmrg 71285ffd6003Smrg # Save the value of $output and $libobjs because we want to 71295ffd6003Smrg # use them later. If we have whole_archive_flag_spec, we 71305ffd6003Smrg # want to use save_libobjs as it was before 71315ffd6003Smrg # whole_archive_flag_spec was expanded, because we can't 71325ffd6003Smrg # assume the linker understands whole_archive_flag_spec. 71335ffd6003Smrg # This may have to be revisited, in case too many 71345ffd6003Smrg # convenience libraries get linked in and end up exceeding 71355ffd6003Smrg # the spec. 71365ffd6003Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 71375ffd6003Smrg save_libobjs=$libobjs 71385ffd6003Smrg fi 71395ffd6003Smrg save_output=$output 71405ffd6003Smrg output_la=`$ECHO "X$output" | $Xsed -e "$basename"` 7141145b7b3cSmrg 71425ffd6003Smrg # Clear the reloadable object creation command queue and 71435ffd6003Smrg # initialize k to one. 71445ffd6003Smrg test_cmds= 71455ffd6003Smrg concat_cmds= 71465ffd6003Smrg objlist= 71475ffd6003Smrg last_robj= 71485ffd6003Smrg k=1 71495ffd6003Smrg 71505ffd6003Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 71515ffd6003Smrg output=${output_objdir}/${output_la}.lnkscript 71525ffd6003Smrg func_verbose "creating GNU ld script: $output" 71535ffd6003Smrg $ECHO 'INPUT (' > $output 71545ffd6003Smrg for obj in $save_libobjs 7155145b7b3cSmrg do 71565ffd6003Smrg $ECHO "$obj" >> $output 71575ffd6003Smrg done 71585ffd6003Smrg $ECHO ')' >> $output 71595ffd6003Smrg delfiles="$delfiles $output" 71605ffd6003Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 71615ffd6003Smrg output=${output_objdir}/${output_la}.lnk 71625ffd6003Smrg func_verbose "creating linker input file list: $output" 71635ffd6003Smrg : > $output 71645ffd6003Smrg set x $save_libobjs 71655ffd6003Smrg shift 71665ffd6003Smrg firstobj= 71675ffd6003Smrg if test "$compiler_needs_object" = yes; then 71685ffd6003Smrg firstobj="$1 " 71695ffd6003Smrg shift 71705ffd6003Smrg fi 71715ffd6003Smrg for obj 71725ffd6003Smrg do 71735ffd6003Smrg $ECHO "$obj" >> $output 71745ffd6003Smrg done 71755ffd6003Smrg delfiles="$delfiles $output" 71765ffd6003Smrg output=$firstobj\"$file_list_spec$output\" 71775ffd6003Smrg else 71785ffd6003Smrg if test -n "$save_libobjs"; then 71795ffd6003Smrg func_verbose "creating reloadable object files..." 71805ffd6003Smrg output=$output_objdir/$output_la-${k}.$objext 71815ffd6003Smrg eval test_cmds=\"$reload_cmds\" 71825ffd6003Smrg func_len " $test_cmds" 71835ffd6003Smrg len0=$func_len_result 71845ffd6003Smrg len=$len0 71855ffd6003Smrg 71865ffd6003Smrg # Loop over the list of objects to be linked. 71875ffd6003Smrg for obj in $save_libobjs 71885ffd6003Smrg do 71895ffd6003Smrg func_len " $obj" 71905ffd6003Smrg func_arith $len + $func_len_result 71915ffd6003Smrg len=$func_arith_result 71925ffd6003Smrg if test "X$objlist" = X || 71935ffd6003Smrg test "$len" -lt "$max_cmd_len"; then 71945ffd6003Smrg func_append objlist " $obj" 71955ffd6003Smrg else 71965ffd6003Smrg # The command $test_cmds is almost too long, add a 71975ffd6003Smrg # command to the queue. 71985ffd6003Smrg if test "$k" -eq 1 ; then 71995ffd6003Smrg # The first file doesn't have a previous command to add. 72005ffd6003Smrg eval concat_cmds=\"$reload_cmds $objlist $last_robj\" 72015ffd6003Smrg else 72025ffd6003Smrg # All subsequent reloadable object files will link in 72035ffd6003Smrg # the last one created. 72045ffd6003Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\" 72055ffd6003Smrg fi 72065ffd6003Smrg last_robj=$output_objdir/$output_la-${k}.$objext 72075ffd6003Smrg func_arith $k + 1 72085ffd6003Smrg k=$func_arith_result 72095ffd6003Smrg output=$output_objdir/$output_la-${k}.$objext 72105ffd6003Smrg objlist=$obj 72115ffd6003Smrg func_len " $last_robj" 72125ffd6003Smrg func_arith $len0 + $func_len_result 72135ffd6003Smrg len=$func_arith_result 72145ffd6003Smrg fi 72155ffd6003Smrg done 72165ffd6003Smrg # Handle the remaining objects by creating one last 72175ffd6003Smrg # reloadable object file. All subsequent reloadable object 72185ffd6003Smrg # files will link in the last one created. 72195ffd6003Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 72205ffd6003Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\" 72215ffd6003Smrg if test -n "$last_robj"; then 72225ffd6003Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 72235ffd6003Smrg fi 72245ffd6003Smrg delfiles="$delfiles $output" 7225145b7b3cSmrg 72265ffd6003Smrg else 72275ffd6003Smrg output= 72285ffd6003Smrg fi 7229145b7b3cSmrg 72305ffd6003Smrg if ${skipped_export-false}; then 72315ffd6003Smrg func_verbose "generating symbol list for \`$libname.la'" 72325ffd6003Smrg export_symbols="$output_objdir/$libname.exp" 72335ffd6003Smrg $opt_dry_run || $RM $export_symbols 72345ffd6003Smrg libobjs=$output 72355ffd6003Smrg # Append the command to create the export file. 72365ffd6003Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 72375ffd6003Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 72385ffd6003Smrg if test -n "$last_robj"; then 72395ffd6003Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 72405ffd6003Smrg fi 7241145b7b3cSmrg fi 7242145b7b3cSmrg 72435ffd6003Smrg test -n "$save_libobjs" && 72445ffd6003Smrg func_verbose "creating a temporary reloadable object file: $output" 7245145b7b3cSmrg 72465ffd6003Smrg # Loop through the commands generated above and execute them. 72475ffd6003Smrg save_ifs="$IFS"; IFS='~' 72485ffd6003Smrg for cmd in $concat_cmds; do 72495ffd6003Smrg IFS="$save_ifs" 72505ffd6003Smrg $opt_silent || { 72515ffd6003Smrg func_quote_for_expand "$cmd" 72525ffd6003Smrg eval "func_echo $func_quote_for_expand_result" 72535ffd6003Smrg } 72545ffd6003Smrg $opt_dry_run || eval "$cmd" || { 72555ffd6003Smrg lt_exit=$? 72565ffd6003Smrg 72575ffd6003Smrg # Restore the uninstalled library and exit 72585ffd6003Smrg if test "$mode" = relink; then 72595ffd6003Smrg ( cd "$output_objdir" && \ 72605ffd6003Smrg $RM "${realname}T" && \ 72615ffd6003Smrg $MV "${realname}U" "$realname" ) 72625ffd6003Smrg fi 7263145b7b3cSmrg 72645ffd6003Smrg exit $lt_exit 72655ffd6003Smrg } 72665ffd6003Smrg done 72675ffd6003Smrg IFS="$save_ifs" 7268145b7b3cSmrg 72695ffd6003Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 72705ffd6003Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 72715ffd6003Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 7272145b7b3cSmrg fi 7273145b7b3cSmrg fi 7274145b7b3cSmrg 72755ffd6003Smrg if ${skipped_export-false}; then 72765ffd6003Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 72775ffd6003Smrg tmp_export_symbols="$export_symbols" 72785ffd6003Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 72795ffd6003Smrg $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"' 72805ffd6003Smrg fi 7281145b7b3cSmrg 72825ffd6003Smrg if test -n "$orig_export_symbols"; then 72835ffd6003Smrg # The given exports_symbols file has to be filtered, so filter it. 72845ffd6003Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 72855ffd6003Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 72865ffd6003Smrg # 's' commands which not all seds can handle. GNU sed should be fine 72875ffd6003Smrg # though. Also, the filter scales superlinearly with the number of 72885ffd6003Smrg # global variables. join(1) would be nice here, but unfortunately 72895ffd6003Smrg # isn't a blessed tool. 72905ffd6003Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 72915ffd6003Smrg delfiles="$delfiles $export_symbols $output_objdir/$libname.filter" 72925ffd6003Smrg export_symbols=$output_objdir/$libname.def 72935ffd6003Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 72945ffd6003Smrg fi 72955ffd6003Smrg fi 7296145b7b3cSmrg 72975ffd6003Smrg libobjs=$output 72985ffd6003Smrg # Restore the value of output. 72995ffd6003Smrg output=$save_output 7300145b7b3cSmrg 73015ffd6003Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 73025ffd6003Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 73035ffd6003Smrg test "X$libobjs" = "X " && libobjs= 73045ffd6003Smrg fi 73055ffd6003Smrg # Expand the library linking commands again to reset the 73065ffd6003Smrg # value of $libobjs for piecewise linking. 7307145b7b3cSmrg 73085ffd6003Smrg # Do each of the archive commands. 73095ffd6003Smrg if test "$module" = yes && test -n "$module_cmds" ; then 73105ffd6003Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 73115ffd6003Smrg cmds=$module_expsym_cmds 73125ffd6003Smrg else 73135ffd6003Smrg cmds=$module_cmds 7314145b7b3cSmrg fi 7315145b7b3cSmrg else 73165ffd6003Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 73175ffd6003Smrg cmds=$archive_expsym_cmds 73185ffd6003Smrg else 73195ffd6003Smrg cmds=$archive_cmds 73205ffd6003Smrg fi 7321145b7b3cSmrg fi 73225ffd6003Smrg fi 7323145b7b3cSmrg 73245ffd6003Smrg if test -n "$delfiles"; then 73255ffd6003Smrg # Append the command to remove temporary files to $cmds. 73265ffd6003Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 73275ffd6003Smrg fi 7328145b7b3cSmrg 73295ffd6003Smrg # Add any objects from preloaded convenience libraries 73305ffd6003Smrg if test -n "$dlprefiles"; then 73315ffd6003Smrg gentop="$output_objdir/${outputname}x" 73325ffd6003Smrg generated="$generated $gentop" 7333145b7b3cSmrg 73345ffd6003Smrg func_extract_archives $gentop $dlprefiles 73355ffd6003Smrg libobjs="$libobjs $func_extract_archives_result" 73365ffd6003Smrg test "X$libobjs" = "X " && libobjs= 73375ffd6003Smrg fi 7338145b7b3cSmrg 73395ffd6003Smrg save_ifs="$IFS"; IFS='~' 73405ffd6003Smrg for cmd in $cmds; do 73415ffd6003Smrg IFS="$save_ifs" 73425ffd6003Smrg eval cmd=\"$cmd\" 73435ffd6003Smrg $opt_silent || { 73445ffd6003Smrg func_quote_for_expand "$cmd" 73455ffd6003Smrg eval "func_echo $func_quote_for_expand_result" 73465ffd6003Smrg } 73475ffd6003Smrg $opt_dry_run || eval "$cmd" || { 73485ffd6003Smrg lt_exit=$? 7349145b7b3cSmrg 73505ffd6003Smrg # Restore the uninstalled library and exit 73515ffd6003Smrg if test "$mode" = relink; then 73525ffd6003Smrg ( cd "$output_objdir" && \ 73535ffd6003Smrg $RM "${realname}T" && \ 73545ffd6003Smrg $MV "${realname}U" "$realname" ) 73555ffd6003Smrg fi 7356145b7b3cSmrg 73575ffd6003Smrg exit $lt_exit 73585ffd6003Smrg } 73595ffd6003Smrg done 73605ffd6003Smrg IFS="$save_ifs" 7361145b7b3cSmrg 73625ffd6003Smrg # Restore the uninstalled library and exit 73635ffd6003Smrg if test "$mode" = relink; then 73645ffd6003Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 7365145b7b3cSmrg 73665ffd6003Smrg if test -n "$convenience"; then 73675ffd6003Smrg if test -z "$whole_archive_flag_spec"; then 73685ffd6003Smrg func_show_eval '${RM}r "$gentop"' 73695ffd6003Smrg fi 73705ffd6003Smrg fi 7371145b7b3cSmrg 73725ffd6003Smrg exit $EXIT_SUCCESS 73735ffd6003Smrg fi 73745ffd6003Smrg 73755ffd6003Smrg # Create links to the real library. 73765ffd6003Smrg for linkname in $linknames; do 73775ffd6003Smrg if test "$realname" != "$linkname"; then 73785ffd6003Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 7379145b7b3cSmrg fi 7380145b7b3cSmrg done 7381145b7b3cSmrg 73825ffd6003Smrg # If -module or -export-dynamic was specified, set the dlname. 73835ffd6003Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 73845ffd6003Smrg # On all known operating systems, these are identical. 73855ffd6003Smrg dlname="$soname" 73865ffd6003Smrg fi 73875ffd6003Smrg fi 7388145b7b3cSmrg ;; 7389145b7b3cSmrg 73905ffd6003Smrg obj) 73915ffd6003Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 73925ffd6003Smrg func_warning "\`-dlopen' is ignored for objects" 73935ffd6003Smrg fi 7394145b7b3cSmrg 73955ffd6003Smrg case " $deplibs" in 73965ffd6003Smrg *\ -l* | *\ -L*) 73975ffd6003Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 7398145b7b3cSmrg esac 7399145b7b3cSmrg 74005ffd6003Smrg test -n "$rpath" && \ 74015ffd6003Smrg func_warning "\`-rpath' is ignored for objects" 74025ffd6003Smrg 74035ffd6003Smrg test -n "$xrpath" && \ 74045ffd6003Smrg func_warning "\`-R' is ignored for objects" 7405145b7b3cSmrg 74065ffd6003Smrg test -n "$vinfo" && \ 74075ffd6003Smrg func_warning "\`-version-info' is ignored for objects" 7408145b7b3cSmrg 74095ffd6003Smrg test -n "$release" && \ 74105ffd6003Smrg func_warning "\`-release' is ignored for objects" 74115ffd6003Smrg 74125ffd6003Smrg case $output in 74135ffd6003Smrg *.lo) 74145ffd6003Smrg test -n "$objs$old_deplibs" && \ 74155ffd6003Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 74165ffd6003Smrg 74175ffd6003Smrg libobj=$output 74185ffd6003Smrg func_lo2o "$libobj" 74195ffd6003Smrg obj=$func_lo2o_result 7420145b7b3cSmrg ;; 7421145b7b3cSmrg *) 74225ffd6003Smrg libobj= 74235ffd6003Smrg obj="$output" 7424145b7b3cSmrg ;; 7425145b7b3cSmrg esac 7426145b7b3cSmrg 74275ffd6003Smrg # Delete the old objects. 74285ffd6003Smrg $opt_dry_run || $RM $obj $libobj 7429145b7b3cSmrg 74305ffd6003Smrg # Objects from convenience libraries. This assumes 74315ffd6003Smrg # single-version convenience libraries. Whenever we create 74325ffd6003Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 74335ffd6003Smrg # the extraction. 74345ffd6003Smrg reload_conv_objs= 74355ffd6003Smrg gentop= 74365ffd6003Smrg # reload_cmds runs $LD directly, so let us get rid of 74375ffd6003Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 74385ffd6003Smrg # turning comma into space.. 74395ffd6003Smrg wl= 7440145b7b3cSmrg 74415ffd6003Smrg if test -n "$convenience"; then 74425ffd6003Smrg if test -n "$whole_archive_flag_spec"; then 74435ffd6003Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 74445ffd6003Smrg reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'` 74455ffd6003Smrg else 74465ffd6003Smrg gentop="$output_objdir/${obj}x" 74475ffd6003Smrg generated="$generated $gentop" 7448145b7b3cSmrg 74495ffd6003Smrg func_extract_archives $gentop $convenience 74505ffd6003Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 74515ffd6003Smrg fi 7452145b7b3cSmrg fi 7453145b7b3cSmrg 74545ffd6003Smrg # Create the old-style object. 74555ffd6003Smrg 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 7456145b7b3cSmrg 74575ffd6003Smrg output="$obj" 74585ffd6003Smrg func_execute_cmds "$reload_cmds" 'exit $?' 7459145b7b3cSmrg 74605ffd6003Smrg # Exit if we aren't doing a library object file. 74615ffd6003Smrg if test -z "$libobj"; then 74625ffd6003Smrg if test -n "$gentop"; then 74635ffd6003Smrg func_show_eval '${RM}r "$gentop"' 74645ffd6003Smrg fi 74655ffd6003Smrg 74665ffd6003Smrg exit $EXIT_SUCCESS 7467145b7b3cSmrg fi 74685ffd6003Smrg 74695ffd6003Smrg if test "$build_libtool_libs" != yes; then 74705ffd6003Smrg if test -n "$gentop"; then 74715ffd6003Smrg func_show_eval '${RM}r "$gentop"' 74725ffd6003Smrg fi 74735ffd6003Smrg 74745ffd6003Smrg # Create an invalid libtool object if no PIC, so that we don't 74755ffd6003Smrg # accidentally link it into a program. 74765ffd6003Smrg # $show "echo timestamp > $libobj" 74775ffd6003Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 74785ffd6003Smrg exit $EXIT_SUCCESS 74795ffd6003Smrg fi 74805ffd6003Smrg 74815ffd6003Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 74825ffd6003Smrg # Only do commands if we really have different PIC objects. 74835ffd6003Smrg reload_objs="$libobjs $reload_conv_objs" 74845ffd6003Smrg output="$libobj" 74855ffd6003Smrg func_execute_cmds "$reload_cmds" 'exit $?' 74865ffd6003Smrg fi 74875ffd6003Smrg 74885ffd6003Smrg if test -n "$gentop"; then 74895ffd6003Smrg func_show_eval '${RM}r "$gentop"' 74905ffd6003Smrg fi 74915ffd6003Smrg 74925ffd6003Smrg exit $EXIT_SUCCESS 7493145b7b3cSmrg ;; 7494145b7b3cSmrg 74955ffd6003Smrg prog) 74965ffd6003Smrg case $host in 74975ffd6003Smrg *cygwin*) func_stripname '' '.exe' "$output" 74985ffd6003Smrg output=$func_stripname_result.exe;; 74995ffd6003Smrg esac 75005ffd6003Smrg test -n "$vinfo" && \ 75015ffd6003Smrg func_warning "\`-version-info' is ignored for programs" 7502145b7b3cSmrg 75035ffd6003Smrg test -n "$release" && \ 75045ffd6003Smrg func_warning "\`-release' is ignored for programs" 7505145b7b3cSmrg 75065ffd6003Smrg test "$preload" = yes \ 75075ffd6003Smrg && test "$dlopen_support" = unknown \ 75085ffd6003Smrg && test "$dlopen_self" = unknown \ 75095ffd6003Smrg && test "$dlopen_self_static" = unknown && \ 75105ffd6003Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 75115ffd6003Smrg 75125ffd6003Smrg case $host in 75135ffd6003Smrg *-*-rhapsody* | *-*-darwin1.[012]) 75145ffd6003Smrg # On Rhapsody replace the C library is the System framework 75155ffd6003Smrg compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` 75165ffd6003Smrg finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'` 7517145b7b3cSmrg ;; 75185ffd6003Smrg esac 7519145b7b3cSmrg 75205ffd6003Smrg case $host in 75215ffd6003Smrg *-*-darwin*) 75225ffd6003Smrg # Don't allow lazy linking, it breaks C++ global constructors 75235ffd6003Smrg # But is supposedly fixed on 10.4 or later (yay!). 75245ffd6003Smrg if test "$tagname" = CXX ; then 75255ffd6003Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 75265ffd6003Smrg 10.[0123]) 75275ffd6003Smrg compile_command="$compile_command ${wl}-bind_at_load" 75285ffd6003Smrg finalize_command="$finalize_command ${wl}-bind_at_load" 75295ffd6003Smrg ;; 75305ffd6003Smrg esac 7531145b7b3cSmrg fi 75325ffd6003Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 75335ffd6003Smrg compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 75345ffd6003Smrg finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'` 75355ffd6003Smrg ;; 75365ffd6003Smrg esac 7537145b7b3cSmrg 7538145b7b3cSmrg 75395ffd6003Smrg # move library search paths that coincide with paths to not yet 75405ffd6003Smrg # installed libraries to the beginning of the library search list 75415ffd6003Smrg new_libs= 75425ffd6003Smrg for path in $notinst_path; do 75435ffd6003Smrg case " $new_libs " in 75445ffd6003Smrg *" -L$path/$objdir "*) ;; 75455ffd6003Smrg *) 75465ffd6003Smrg case " $compile_deplibs " in 75475ffd6003Smrg *" -L$path/$objdir "*) 75485ffd6003Smrg new_libs="$new_libs -L$path/$objdir" ;; 7549145b7b3cSmrg esac 75505ffd6003Smrg ;; 75515ffd6003Smrg esac 75525ffd6003Smrg done 75535ffd6003Smrg for deplib in $compile_deplibs; do 75545ffd6003Smrg case $deplib in 75555ffd6003Smrg -L*) 75565ffd6003Smrg case " $new_libs " in 75575ffd6003Smrg *" $deplib "*) ;; 75585ffd6003Smrg *) new_libs="$new_libs $deplib" ;; 7559145b7b3cSmrg esac 75605ffd6003Smrg ;; 75615ffd6003Smrg *) new_libs="$new_libs $deplib" ;; 75625ffd6003Smrg esac 75635ffd6003Smrg done 75645ffd6003Smrg compile_deplibs="$new_libs" 7565145b7b3cSmrg 7566145b7b3cSmrg 75675ffd6003Smrg compile_command="$compile_command $compile_deplibs" 75685ffd6003Smrg finalize_command="$finalize_command $finalize_deplibs" 7569145b7b3cSmrg 75705ffd6003Smrg if test -n "$rpath$xrpath"; then 75715ffd6003Smrg # If the user specified any rpath flags, then add them. 75725ffd6003Smrg for libdir in $rpath $xrpath; do 75735ffd6003Smrg # This is the magic to use -rpath. 75745ffd6003Smrg case "$finalize_rpath " in 75755ffd6003Smrg *" $libdir "*) ;; 75765ffd6003Smrg *) finalize_rpath="$finalize_rpath $libdir" ;; 75775ffd6003Smrg esac 75785ffd6003Smrg done 75795ffd6003Smrg fi 7580145b7b3cSmrg 75815ffd6003Smrg # Now hardcode the library paths 75825ffd6003Smrg rpath= 75835ffd6003Smrg hardcode_libdirs= 75845ffd6003Smrg for libdir in $compile_rpath $finalize_rpath; do 75855ffd6003Smrg if test -n "$hardcode_libdir_flag_spec"; then 75865ffd6003Smrg if test -n "$hardcode_libdir_separator"; then 75875ffd6003Smrg if test -z "$hardcode_libdirs"; then 75885ffd6003Smrg hardcode_libdirs="$libdir" 75895ffd6003Smrg else 75905ffd6003Smrg # Just accumulate the unique libdirs. 75915ffd6003Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 75925ffd6003Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 75935ffd6003Smrg ;; 75945ffd6003Smrg *) 75955ffd6003Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 75965ffd6003Smrg ;; 75975ffd6003Smrg esac 75985ffd6003Smrg fi 7599145b7b3cSmrg else 76005ffd6003Smrg eval flag=\"$hardcode_libdir_flag_spec\" 76015ffd6003Smrg rpath="$rpath $flag" 7602145b7b3cSmrg fi 76035ffd6003Smrg elif test -n "$runpath_var"; then 76045ffd6003Smrg case "$perm_rpath " in 76055ffd6003Smrg *" $libdir "*) ;; 76065ffd6003Smrg *) perm_rpath="$perm_rpath $libdir" ;; 76075ffd6003Smrg esac 76085ffd6003Smrg fi 76095ffd6003Smrg case $host in 76105ffd6003Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 76115ffd6003Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 76125ffd6003Smrg case :$dllsearchpath: in 76135ffd6003Smrg *":$libdir:"*) ;; 76145ffd6003Smrg ::) dllsearchpath=$libdir;; 76155ffd6003Smrg *) dllsearchpath="$dllsearchpath:$libdir";; 76165ffd6003Smrg esac 76175ffd6003Smrg case :$dllsearchpath: in 76185ffd6003Smrg *":$testbindir:"*) ;; 76195ffd6003Smrg ::) dllsearchpath=$testbindir;; 76205ffd6003Smrg *) dllsearchpath="$dllsearchpath:$testbindir";; 76215ffd6003Smrg esac 76225ffd6003Smrg ;; 76235ffd6003Smrg esac 76245ffd6003Smrg done 76255ffd6003Smrg # Substitute the hardcoded libdirs into the rpath. 76265ffd6003Smrg if test -n "$hardcode_libdir_separator" && 76275ffd6003Smrg test -n "$hardcode_libdirs"; then 76285ffd6003Smrg libdir="$hardcode_libdirs" 76295ffd6003Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 76305ffd6003Smrg fi 76315ffd6003Smrg compile_rpath="$rpath" 7632145b7b3cSmrg 76335ffd6003Smrg rpath= 76345ffd6003Smrg hardcode_libdirs= 76355ffd6003Smrg for libdir in $finalize_rpath; do 76365ffd6003Smrg if test -n "$hardcode_libdir_flag_spec"; then 76375ffd6003Smrg if test -n "$hardcode_libdir_separator"; then 76385ffd6003Smrg if test -z "$hardcode_libdirs"; then 76395ffd6003Smrg hardcode_libdirs="$libdir" 76405ffd6003Smrg else 76415ffd6003Smrg # Just accumulate the unique libdirs. 76425ffd6003Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 76435ffd6003Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 76445ffd6003Smrg ;; 76455ffd6003Smrg *) 76465ffd6003Smrg hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir" 76475ffd6003Smrg ;; 76485ffd6003Smrg esac 76495ffd6003Smrg fi 7650145b7b3cSmrg else 76515ffd6003Smrg eval flag=\"$hardcode_libdir_flag_spec\" 76525ffd6003Smrg rpath="$rpath $flag" 7653145b7b3cSmrg fi 76545ffd6003Smrg elif test -n "$runpath_var"; then 76555ffd6003Smrg case "$finalize_perm_rpath " in 76565ffd6003Smrg *" $libdir "*) ;; 76575ffd6003Smrg *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;; 76585ffd6003Smrg esac 7659145b7b3cSmrg fi 76605ffd6003Smrg done 76615ffd6003Smrg # Substitute the hardcoded libdirs into the rpath. 76625ffd6003Smrg if test -n "$hardcode_libdir_separator" && 76635ffd6003Smrg test -n "$hardcode_libdirs"; then 76645ffd6003Smrg libdir="$hardcode_libdirs" 76655ffd6003Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 76665ffd6003Smrg fi 76675ffd6003Smrg finalize_rpath="$rpath" 7668145b7b3cSmrg 76695ffd6003Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 76705ffd6003Smrg # Transform all the library objects into standard objects. 76715ffd6003Smrg compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` 76725ffd6003Smrg finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP` 76735ffd6003Smrg fi 7674145b7b3cSmrg 76755ffd6003Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 7676145b7b3cSmrg 76775ffd6003Smrg # template prelinking step 76785ffd6003Smrg if test -n "$prelink_cmds"; then 76795ffd6003Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 76805ffd6003Smrg fi 7681145b7b3cSmrg 76825ffd6003Smrg wrappers_required=yes 76835ffd6003Smrg case $host in 76845ffd6003Smrg *cygwin* | *mingw* ) 76855ffd6003Smrg if test "$build_libtool_libs" != yes; then 76865ffd6003Smrg wrappers_required=no 76875ffd6003Smrg fi 76885ffd6003Smrg ;; 76895ffd6003Smrg *cegcc) 76905ffd6003Smrg # Disable wrappers for cegcc, we are cross compiling anyway. 76915ffd6003Smrg wrappers_required=no 76925ffd6003Smrg ;; 76935ffd6003Smrg *) 76945ffd6003Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 76955ffd6003Smrg wrappers_required=no 76965ffd6003Smrg fi 76975ffd6003Smrg ;; 76985ffd6003Smrg esac 76995ffd6003Smrg if test "$wrappers_required" = no; then 77005ffd6003Smrg # Replace the output file specification. 77015ffd6003Smrg compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` 77025ffd6003Smrg link_command="$compile_command$compile_rpath" 7703145b7b3cSmrg 77045ffd6003Smrg # We have no uninstalled library dependencies, so finalize right now. 77055ffd6003Smrg exit_status=0 77065ffd6003Smrg func_show_eval "$link_command" 'exit_status=$?' 7707145b7b3cSmrg 77085ffd6003Smrg # Delete the generated files. 77095ffd6003Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 77105ffd6003Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 7711145b7b3cSmrg fi 7712145b7b3cSmrg 77135ffd6003Smrg exit $exit_status 77145ffd6003Smrg fi 7715145b7b3cSmrg 77165ffd6003Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 77175ffd6003Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 77185ffd6003Smrg fi 77195ffd6003Smrg if test -n "$finalize_shlibpath"; then 77205ffd6003Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 77215ffd6003Smrg fi 7722145b7b3cSmrg 77235ffd6003Smrg compile_var= 77245ffd6003Smrg finalize_var= 77255ffd6003Smrg if test -n "$runpath_var"; then 77265ffd6003Smrg if test -n "$perm_rpath"; then 77275ffd6003Smrg # We should set the runpath_var. 77285ffd6003Smrg rpath= 77295ffd6003Smrg for dir in $perm_rpath; do 77305ffd6003Smrg rpath="$rpath$dir:" 77315ffd6003Smrg done 77325ffd6003Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 7733145b7b3cSmrg fi 77345ffd6003Smrg if test -n "$finalize_perm_rpath"; then 77355ffd6003Smrg # We should set the runpath_var. 77365ffd6003Smrg rpath= 77375ffd6003Smrg for dir in $finalize_perm_rpath; do 77385ffd6003Smrg rpath="$rpath$dir:" 77395ffd6003Smrg done 77405ffd6003Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 7741145b7b3cSmrg fi 77425ffd6003Smrg fi 7743145b7b3cSmrg 77445ffd6003Smrg if test "$no_install" = yes; then 77455ffd6003Smrg # We don't need to create a wrapper script. 77465ffd6003Smrg link_command="$compile_var$compile_command$compile_rpath" 77475ffd6003Smrg # Replace the output file specification. 77485ffd6003Smrg link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'` 77495ffd6003Smrg # Delete the old output file. 77505ffd6003Smrg $opt_dry_run || $RM $output 77515ffd6003Smrg # Link the executable and exit 77525ffd6003Smrg func_show_eval "$link_command" 'exit $?' 7753145b7b3cSmrg exit $EXIT_SUCCESS 77545ffd6003Smrg fi 7755145b7b3cSmrg 77565ffd6003Smrg if test "$hardcode_action" = relink; then 77575ffd6003Smrg # Fast installation is not supported 77585ffd6003Smrg link_command="$compile_var$compile_command$compile_rpath" 77595ffd6003Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 77605ffd6003Smrg 77615ffd6003Smrg func_warning "this platform does not like uninstalled shared libraries" 77625ffd6003Smrg func_warning "\`$output' will be relinked during installation" 77635ffd6003Smrg else 77645ffd6003Smrg if test "$fast_install" != no; then 77655ffd6003Smrg link_command="$finalize_var$compile_command$finalize_rpath" 77665ffd6003Smrg if test "$fast_install" = yes; then 77675ffd6003Smrg relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'` 77685ffd6003Smrg else 77695ffd6003Smrg # fast_install is set to needless 77705ffd6003Smrg relink_command= 77715ffd6003Smrg fi 7772145b7b3cSmrg else 77735ffd6003Smrg link_command="$compile_var$compile_command$compile_rpath" 77745ffd6003Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 7775145b7b3cSmrg fi 77765ffd6003Smrg fi 7777145b7b3cSmrg 77785ffd6003Smrg # Replace the output file specification. 77795ffd6003Smrg link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 7780145b7b3cSmrg 77815ffd6003Smrg # Delete the old output files. 77825ffd6003Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 7783145b7b3cSmrg 77845ffd6003Smrg func_show_eval "$link_command" 'exit $?' 7785145b7b3cSmrg 77865ffd6003Smrg # Now create the wrapper script. 77875ffd6003Smrg func_verbose "creating $output" 7788145b7b3cSmrg 77895ffd6003Smrg # Quote the relink command for shipping. 77905ffd6003Smrg if test -n "$relink_command"; then 77915ffd6003Smrg # Preserve any variables that may affect compiler behavior 77925ffd6003Smrg for var in $variables_saved_for_relink; do 77935ffd6003Smrg if eval test -z \"\${$var+set}\"; then 77945ffd6003Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 77955ffd6003Smrg elif eval var_value=\$$var; test -z "$var_value"; then 77965ffd6003Smrg relink_command="$var=; export $var; $relink_command" 7797145b7b3cSmrg else 77985ffd6003Smrg func_quote_for_eval "$var_value" 77995ffd6003Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 7800145b7b3cSmrg fi 78015ffd6003Smrg done 78025ffd6003Smrg relink_command="(cd `pwd`; $relink_command)" 78035ffd6003Smrg relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` 78045ffd6003Smrg fi 7805145b7b3cSmrg 78065ffd6003Smrg # Quote $ECHO for shipping. 78075ffd6003Smrg if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then 78085ffd6003Smrg case $progpath in 78095ffd6003Smrg [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";; 78105ffd6003Smrg *) qecho="$SHELL `pwd`/$progpath --fallback-echo";; 78115ffd6003Smrg esac 78125ffd6003Smrg qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"` 78135ffd6003Smrg else 78145ffd6003Smrg qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"` 78155ffd6003Smrg fi 78165ffd6003Smrg 78175ffd6003Smrg # Only actually do things if not in dry run mode. 78185ffd6003Smrg $opt_dry_run || { 78195ffd6003Smrg # win32 will think the script is a binary if it has 78205ffd6003Smrg # a .exe suffix, so we strip it off here. 78215ffd6003Smrg case $output in 78225ffd6003Smrg *.exe) func_stripname '' '.exe' "$output" 78235ffd6003Smrg output=$func_stripname_result ;; 78245ffd6003Smrg esac 78255ffd6003Smrg # test for cygwin because mv fails w/o .exe extensions 78265ffd6003Smrg case $host in 78275ffd6003Smrg *cygwin*) 78285ffd6003Smrg exeext=.exe 78295ffd6003Smrg func_stripname '' '.exe' "$outputname" 78305ffd6003Smrg outputname=$func_stripname_result ;; 78315ffd6003Smrg *) exeext= ;; 7832145b7b3cSmrg esac 78335ffd6003Smrg case $host in 78345ffd6003Smrg *cygwin* | *mingw* ) 78355ffd6003Smrg func_dirname_and_basename "$output" "" "." 78365ffd6003Smrg output_name=$func_basename_result 78375ffd6003Smrg output_path=$func_dirname_result 78385ffd6003Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 78395ffd6003Smrg cwrapper="$output_path/$output_name.exe" 78405ffd6003Smrg $RM $cwrappersource $cwrapper 78415ffd6003Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 78425ffd6003Smrg 78435ffd6003Smrg func_emit_cwrapperexe_src > $cwrappersource 78445ffd6003Smrg 78455ffd6003Smrg # The wrapper executable is built using the $host compiler, 78465ffd6003Smrg # because it contains $host paths and files. If cross- 78475ffd6003Smrg # compiling, it, like the target executable, must be 78485ffd6003Smrg # executed on the $host or under an emulation environment. 78495ffd6003Smrg $opt_dry_run || { 78505ffd6003Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 78515ffd6003Smrg $STRIP $cwrapper 78525ffd6003Smrg } 7853145b7b3cSmrg 78545ffd6003Smrg # Now, create the wrapper script for func_source use: 78555ffd6003Smrg func_ltwrapper_scriptname $cwrapper 78565ffd6003Smrg $RM $func_ltwrapper_scriptname_result 78575ffd6003Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 78585ffd6003Smrg $opt_dry_run || { 78595ffd6003Smrg # note: this script will not be executed, so do not chmod. 78605ffd6003Smrg if test "x$build" = "x$host" ; then 78615ffd6003Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 78625ffd6003Smrg else 78635ffd6003Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 78645ffd6003Smrg fi 78655ffd6003Smrg } 78665ffd6003Smrg ;; 78675ffd6003Smrg * ) 78685ffd6003Smrg $RM $output 78695ffd6003Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 7870145b7b3cSmrg 78715ffd6003Smrg func_emit_wrapper no > $output 78725ffd6003Smrg chmod +x $output 78735ffd6003Smrg ;; 78745ffd6003Smrg esac 78755ffd6003Smrg } 78765ffd6003Smrg exit $EXIT_SUCCESS 78775ffd6003Smrg ;; 78785ffd6003Smrg esac 7879145b7b3cSmrg 78805ffd6003Smrg # See if we need to build an old-fashioned archive. 78815ffd6003Smrg for oldlib in $oldlibs; do 7882145b7b3cSmrg 78835ffd6003Smrg if test "$build_libtool_libs" = convenience; then 78845ffd6003Smrg oldobjs="$libobjs_save $symfileobj" 78855ffd6003Smrg addlibs="$convenience" 78865ffd6003Smrg build_libtool_libs=no 78875ffd6003Smrg else 78885ffd6003Smrg if test "$build_libtool_libs" = module; then 78895ffd6003Smrg oldobjs="$libobjs_save" 78905ffd6003Smrg build_libtool_libs=no 78915ffd6003Smrg else 78925ffd6003Smrg oldobjs="$old_deplibs $non_pic_objects" 78935ffd6003Smrg if test "$preload" = yes && test -f "$symfileobj"; then 78945ffd6003Smrg oldobjs="$oldobjs $symfileobj" 78955ffd6003Smrg fi 78965ffd6003Smrg fi 78975ffd6003Smrg addlibs="$old_convenience" 7898145b7b3cSmrg fi 7899145b7b3cSmrg 79005ffd6003Smrg if test -n "$addlibs"; then 79015ffd6003Smrg gentop="$output_objdir/${outputname}x" 79025ffd6003Smrg generated="$generated $gentop" 7903145b7b3cSmrg 79045ffd6003Smrg func_extract_archives $gentop $addlibs 79055ffd6003Smrg oldobjs="$oldobjs $func_extract_archives_result" 79065ffd6003Smrg fi 7907145b7b3cSmrg 79085ffd6003Smrg # Do each command in the archive commands. 79095ffd6003Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 79105ffd6003Smrg cmds=$old_archive_from_new_cmds 79115ffd6003Smrg else 7912145b7b3cSmrg 79135ffd6003Smrg # Add any objects from preloaded convenience libraries 79145ffd6003Smrg if test -n "$dlprefiles"; then 79155ffd6003Smrg gentop="$output_objdir/${outputname}x" 79165ffd6003Smrg generated="$generated $gentop" 7917145b7b3cSmrg 79185ffd6003Smrg func_extract_archives $gentop $dlprefiles 79195ffd6003Smrg oldobjs="$oldobjs $func_extract_archives_result" 79205ffd6003Smrg fi 7921145b7b3cSmrg 79225ffd6003Smrg # POSIX demands no paths to be encoded in archives. We have 79235ffd6003Smrg # to avoid creating archives with duplicate basenames if we 79245ffd6003Smrg # might have to extract them afterwards, e.g., when creating a 79255ffd6003Smrg # static archive out of a convenience library, or when linking 79265ffd6003Smrg # the entirety of a libtool archive into another (currently 79275ffd6003Smrg # not supported by libtool). 79285ffd6003Smrg if (for obj in $oldobjs 79295ffd6003Smrg do 79305ffd6003Smrg func_basename "$obj" 79315ffd6003Smrg $ECHO "$func_basename_result" 79325ffd6003Smrg done | sort | sort -uc >/dev/null 2>&1); then 79335ffd6003Smrg : 79345ffd6003Smrg else 79355ffd6003Smrg $ECHO "copying selected object files to avoid basename conflicts..." 79365ffd6003Smrg gentop="$output_objdir/${outputname}x" 79375ffd6003Smrg generated="$generated $gentop" 79385ffd6003Smrg func_mkdir_p "$gentop" 79395ffd6003Smrg save_oldobjs=$oldobjs 79405ffd6003Smrg oldobjs= 79415ffd6003Smrg counter=1 79425ffd6003Smrg for obj in $save_oldobjs 79435ffd6003Smrg do 79445ffd6003Smrg func_basename "$obj" 79455ffd6003Smrg objbase="$func_basename_result" 79465ffd6003Smrg case " $oldobjs " in 79475ffd6003Smrg " ") oldobjs=$obj ;; 79485ffd6003Smrg *[\ /]"$objbase "*) 79495ffd6003Smrg while :; do 79505ffd6003Smrg # Make sure we don't pick an alternate name that also 79515ffd6003Smrg # overlaps. 79525ffd6003Smrg newobj=lt$counter-$objbase 79535ffd6003Smrg func_arith $counter + 1 79545ffd6003Smrg counter=$func_arith_result 79555ffd6003Smrg case " $oldobjs " in 79565ffd6003Smrg *[\ /]"$newobj "*) ;; 79575ffd6003Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 79585ffd6003Smrg esac 79595ffd6003Smrg done 79605ffd6003Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 79615ffd6003Smrg oldobjs="$oldobjs $gentop/$newobj" 79625ffd6003Smrg ;; 79635ffd6003Smrg *) oldobjs="$oldobjs $obj" ;; 79645ffd6003Smrg esac 7965145b7b3cSmrg done 7966145b7b3cSmrg fi 79675ffd6003Smrg eval cmds=\"$old_archive_cmds\" 7968145b7b3cSmrg 79695ffd6003Smrg func_len " $cmds" 79705ffd6003Smrg len=$func_len_result 79715ffd6003Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 79725ffd6003Smrg cmds=$old_archive_cmds 79735ffd6003Smrg else 79745ffd6003Smrg # the command line is too long to link in one step, link in parts 79755ffd6003Smrg func_verbose "using piecewise archive linking..." 79765ffd6003Smrg save_RANLIB=$RANLIB 79775ffd6003Smrg RANLIB=: 79785ffd6003Smrg objlist= 79795ffd6003Smrg concat_cmds= 79805ffd6003Smrg save_oldobjs=$oldobjs 79815ffd6003Smrg oldobjs= 79825ffd6003Smrg # Is there a better way of finding the last object in the list? 79835ffd6003Smrg for obj in $save_oldobjs 79845ffd6003Smrg do 79855ffd6003Smrg last_oldobj=$obj 79865ffd6003Smrg done 79875ffd6003Smrg eval test_cmds=\"$old_archive_cmds\" 79885ffd6003Smrg func_len " $test_cmds" 79895ffd6003Smrg len0=$func_len_result 79905ffd6003Smrg len=$len0 79915ffd6003Smrg for obj in $save_oldobjs 79925ffd6003Smrg do 79935ffd6003Smrg func_len " $obj" 79945ffd6003Smrg func_arith $len + $func_len_result 79955ffd6003Smrg len=$func_arith_result 79965ffd6003Smrg func_append objlist " $obj" 79975ffd6003Smrg if test "$len" -lt "$max_cmd_len"; then 79985ffd6003Smrg : 79995ffd6003Smrg else 80005ffd6003Smrg # the above command should be used before it gets too long 80015ffd6003Smrg oldobjs=$objlist 80025ffd6003Smrg if test "$obj" = "$last_oldobj" ; then 80035ffd6003Smrg RANLIB=$save_RANLIB 80045ffd6003Smrg fi 80055ffd6003Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 80065ffd6003Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 80075ffd6003Smrg objlist= 80085ffd6003Smrg len=$len0 80095ffd6003Smrg fi 80105ffd6003Smrg done 80115ffd6003Smrg RANLIB=$save_RANLIB 80125ffd6003Smrg oldobjs=$objlist 80135ffd6003Smrg if test "X$oldobjs" = "X" ; then 80145ffd6003Smrg eval cmds=\"\$concat_cmds\" 80155ffd6003Smrg else 80165ffd6003Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 80175ffd6003Smrg fi 80185ffd6003Smrg fi 80195ffd6003Smrg fi 80205ffd6003Smrg func_execute_cmds "$cmds" 'exit $?' 8021145b7b3cSmrg done 8022145b7b3cSmrg 80235ffd6003Smrg test -n "$generated" && \ 80245ffd6003Smrg func_show_eval "${RM}r$generated" 8025145b7b3cSmrg 80265ffd6003Smrg # Now create the libtool archive. 80275ffd6003Smrg case $output in 80285ffd6003Smrg *.la) 80295ffd6003Smrg old_library= 80305ffd6003Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 80315ffd6003Smrg func_verbose "creating $output" 8032145b7b3cSmrg 80335ffd6003Smrg # Preserve any variables that may affect compiler behavior 80345ffd6003Smrg for var in $variables_saved_for_relink; do 80355ffd6003Smrg if eval test -z \"\${$var+set}\"; then 80365ffd6003Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 80375ffd6003Smrg elif eval var_value=\$$var; test -z "$var_value"; then 80385ffd6003Smrg relink_command="$var=; export $var; $relink_command" 8039145b7b3cSmrg else 80405ffd6003Smrg func_quote_for_eval "$var_value" 80415ffd6003Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 8042145b7b3cSmrg fi 80435ffd6003Smrg done 80445ffd6003Smrg # Quote the link command for shipping. 80455ffd6003Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 80465ffd6003Smrg relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"` 80475ffd6003Smrg if test "$hardcode_automatic" = yes ; then 80485ffd6003Smrg relink_command= 80495ffd6003Smrg fi 8050145b7b3cSmrg 80515ffd6003Smrg # Only create the output if not a dry run. 80525ffd6003Smrg $opt_dry_run || { 80535ffd6003Smrg for installed in no yes; do 80545ffd6003Smrg if test "$installed" = yes; then 80555ffd6003Smrg if test -z "$install_libdir"; then 80565ffd6003Smrg break 80575ffd6003Smrg fi 80585ffd6003Smrg output="$output_objdir/$outputname"i 80595ffd6003Smrg # Replace all uninstalled libtool libraries with the installed ones 80605ffd6003Smrg newdependency_libs= 80615ffd6003Smrg for deplib in $dependency_libs; do 80625ffd6003Smrg case $deplib in 80635ffd6003Smrg *.la) 80645ffd6003Smrg func_basename "$deplib" 80655ffd6003Smrg name="$func_basename_result" 80665ffd6003Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 80675ffd6003Smrg test -z "$libdir" && \ 80685ffd6003Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 80695ffd6003Smrg newdependency_libs="$newdependency_libs $libdir/$name" 80705ffd6003Smrg ;; 80715ffd6003Smrg *) newdependency_libs="$newdependency_libs $deplib" ;; 80725ffd6003Smrg esac 80735ffd6003Smrg done 80745ffd6003Smrg dependency_libs="$newdependency_libs" 80755ffd6003Smrg newdlfiles= 80765ffd6003Smrg 80775ffd6003Smrg for lib in $dlfiles; do 80785ffd6003Smrg case $lib in 80795ffd6003Smrg *.la) 80805ffd6003Smrg func_basename "$lib" 80815ffd6003Smrg name="$func_basename_result" 80825ffd6003Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 80835ffd6003Smrg test -z "$libdir" && \ 80845ffd6003Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 80855ffd6003Smrg newdlfiles="$newdlfiles $libdir/$name" 80865ffd6003Smrg ;; 80875ffd6003Smrg *) newdlfiles="$newdlfiles $lib" ;; 80885ffd6003Smrg esac 80895ffd6003Smrg done 80905ffd6003Smrg dlfiles="$newdlfiles" 80915ffd6003Smrg newdlprefiles= 80925ffd6003Smrg for lib in $dlprefiles; do 80935ffd6003Smrg case $lib in 80945ffd6003Smrg *.la) 80955ffd6003Smrg # Only pass preopened files to the pseudo-archive (for 80965ffd6003Smrg # eventual linking with the app. that links it) if we 80975ffd6003Smrg # didn't already link the preopened objects directly into 80985ffd6003Smrg # the library: 80995ffd6003Smrg func_basename "$lib" 81005ffd6003Smrg name="$func_basename_result" 81015ffd6003Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 81025ffd6003Smrg test -z "$libdir" && \ 81035ffd6003Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 81045ffd6003Smrg newdlprefiles="$newdlprefiles $libdir/$name" 81055ffd6003Smrg ;; 81065ffd6003Smrg esac 81075ffd6003Smrg done 81085ffd6003Smrg dlprefiles="$newdlprefiles" 81095ffd6003Smrg else 81105ffd6003Smrg newdlfiles= 81115ffd6003Smrg for lib in $dlfiles; do 81125ffd6003Smrg case $lib in 81135ffd6003Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 81145ffd6003Smrg *) abs=`pwd`"/$lib" ;; 81155ffd6003Smrg esac 81165ffd6003Smrg newdlfiles="$newdlfiles $abs" 81175ffd6003Smrg done 81185ffd6003Smrg dlfiles="$newdlfiles" 81195ffd6003Smrg newdlprefiles= 81205ffd6003Smrg for lib in $dlprefiles; do 81215ffd6003Smrg case $lib in 81225ffd6003Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 81235ffd6003Smrg *) abs=`pwd`"/$lib" ;; 81245ffd6003Smrg esac 81255ffd6003Smrg newdlprefiles="$newdlprefiles $abs" 81265ffd6003Smrg done 81275ffd6003Smrg dlprefiles="$newdlprefiles" 81285ffd6003Smrg fi 81295ffd6003Smrg $RM $output 81305ffd6003Smrg # place dlname in correct position for cygwin 81315ffd6003Smrg tdlname=$dlname 81325ffd6003Smrg case $host,$output,$installed,$module,$dlname in 81335ffd6003Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;; 81345ffd6003Smrg esac 81355ffd6003Smrg $ECHO > $output "\ 81365ffd6003Smrg# $outputname - a libtool library file 81375ffd6003Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 81385ffd6003Smrg# 81395ffd6003Smrg# Please DO NOT delete this file! 81405ffd6003Smrg# It is necessary for linking the library. 8141145b7b3cSmrg 81425ffd6003Smrg# The name that we can dlopen(3). 81435ffd6003Smrgdlname='$tdlname' 8144145b7b3cSmrg 81455ffd6003Smrg# Names of this library. 81465ffd6003Smrglibrary_names='$library_names' 8147145b7b3cSmrg 81485ffd6003Smrg# The name of the static archive. 81495ffd6003Smrgold_library='$old_library' 8150145b7b3cSmrg 81515ffd6003Smrg# Linker flags that can not go in dependency_libs. 81525ffd6003Smrginherited_linker_flags='$new_inherited_linker_flags' 8153145b7b3cSmrg 81545ffd6003Smrg# Libraries that this one depends upon. 81555ffd6003Smrgdependency_libs='$dependency_libs' 8156145b7b3cSmrg 81575ffd6003Smrg# Names of additional weak libraries provided by this library 81585ffd6003Smrgweak_library_names='$weak_libs' 8159145b7b3cSmrg 81605ffd6003Smrg# Version information for $libname. 81615ffd6003Smrgcurrent=$current 81625ffd6003Smrgage=$age 81635ffd6003Smrgrevision=$revision 8164145b7b3cSmrg 81655ffd6003Smrg# Is this an already installed library? 81665ffd6003Smrginstalled=$installed 8167145b7b3cSmrg 81685ffd6003Smrg# Should we warn about portability when linking against -modules? 81695ffd6003Smrgshouldnotlink=$module 8170145b7b3cSmrg 81715ffd6003Smrg# Files to dlopen/dlpreopen 81725ffd6003Smrgdlopen='$dlfiles' 81735ffd6003Smrgdlpreopen='$dlprefiles' 8174145b7b3cSmrg 81755ffd6003Smrg# Directory that this library needs to be installed in: 81765ffd6003Smrglibdir='$install_libdir'" 81775ffd6003Smrg if test "$installed" = no && test "$need_relink" = yes; then 81785ffd6003Smrg $ECHO >> $output "\ 81795ffd6003Smrgrelink_command=\"$relink_command\"" 81805ffd6003Smrg fi 81815ffd6003Smrg done 81825ffd6003Smrg } 8183145b7b3cSmrg 81845ffd6003Smrg # Do a symbolic link so that the libtool archive can be found in 81855ffd6003Smrg # LD_LIBRARY_PATH before the program is installed. 81865ffd6003Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 81875ffd6003Smrg ;; 81885ffd6003Smrg esac 81895ffd6003Smrg exit $EXIT_SUCCESS 81905ffd6003Smrg} 8191145b7b3cSmrg 81925ffd6003Smrg{ test "$mode" = link || test "$mode" = relink; } && 81935ffd6003Smrg func_mode_link ${1+"$@"} 8194145b7b3cSmrg 8195145b7b3cSmrg 81965ffd6003Smrg# func_mode_uninstall arg... 81975ffd6003Smrgfunc_mode_uninstall () 81985ffd6003Smrg{ 81995ffd6003Smrg $opt_debug 82005ffd6003Smrg RM="$nonopt" 8201145b7b3cSmrg files= 8202145b7b3cSmrg rmforce= 8203145b7b3cSmrg exit_status=0 8204145b7b3cSmrg 8205145b7b3cSmrg # This variable tells wrapper scripts just to set variables rather 8206145b7b3cSmrg # than running their programs. 8207145b7b3cSmrg libtool_install_magic="$magic" 8208145b7b3cSmrg 8209145b7b3cSmrg for arg 8210145b7b3cSmrg do 8211145b7b3cSmrg case $arg in 82125ffd6003Smrg -f) RM="$RM $arg"; rmforce=yes ;; 82135ffd6003Smrg -*) RM="$RM $arg" ;; 8214145b7b3cSmrg *) files="$files $arg" ;; 8215145b7b3cSmrg esac 8216145b7b3cSmrg done 8217145b7b3cSmrg 82185ffd6003Smrg test -z "$RM" && \ 82195ffd6003Smrg func_fatal_help "you must specify an RM program" 8220145b7b3cSmrg 8221145b7b3cSmrg rmdirs= 8222145b7b3cSmrg 8223145b7b3cSmrg origobjdir="$objdir" 8224145b7b3cSmrg for file in $files; do 82255ffd6003Smrg func_dirname "$file" "" "." 82265ffd6003Smrg dir="$func_dirname_result" 82275ffd6003Smrg if test "X$dir" = X.; then 8228145b7b3cSmrg objdir="$origobjdir" 8229145b7b3cSmrg else 8230145b7b3cSmrg objdir="$dir/$origobjdir" 8231145b7b3cSmrg fi 82325ffd6003Smrg func_basename "$file" 82335ffd6003Smrg name="$func_basename_result" 8234145b7b3cSmrg test "$mode" = uninstall && objdir="$dir" 8235145b7b3cSmrg 8236145b7b3cSmrg # Remember objdir for removal later, being careful to avoid duplicates 8237145b7b3cSmrg if test "$mode" = clean; then 8238145b7b3cSmrg case " $rmdirs " in 8239145b7b3cSmrg *" $objdir "*) ;; 8240145b7b3cSmrg *) rmdirs="$rmdirs $objdir" ;; 8241145b7b3cSmrg esac 8242145b7b3cSmrg fi 8243145b7b3cSmrg 8244145b7b3cSmrg # Don't error if the file doesn't exist and rm -f was used. 82455ffd6003Smrg if { test -L "$file"; } >/dev/null 2>&1 || 82465ffd6003Smrg { test -h "$file"; } >/dev/null 2>&1 || 82475ffd6003Smrg test -f "$file"; then 8248145b7b3cSmrg : 8249145b7b3cSmrg elif test -d "$file"; then 8250145b7b3cSmrg exit_status=1 8251145b7b3cSmrg continue 8252145b7b3cSmrg elif test "$rmforce" = yes; then 8253145b7b3cSmrg continue 8254145b7b3cSmrg fi 8255145b7b3cSmrg 8256145b7b3cSmrg rmfiles="$file" 8257145b7b3cSmrg 8258145b7b3cSmrg case $name in 8259145b7b3cSmrg *.la) 8260145b7b3cSmrg # Possibly a libtool archive, so verify it. 82615ffd6003Smrg if func_lalib_p "$file"; then 82625ffd6003Smrg func_source $dir/$name 8263145b7b3cSmrg 8264145b7b3cSmrg # Delete the libtool libraries and symlinks. 8265145b7b3cSmrg for n in $library_names; do 8266145b7b3cSmrg rmfiles="$rmfiles $objdir/$n" 8267145b7b3cSmrg done 8268145b7b3cSmrg test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library" 8269145b7b3cSmrg 8270145b7b3cSmrg case "$mode" in 8271145b7b3cSmrg clean) 8272145b7b3cSmrg case " $library_names " in 8273145b7b3cSmrg # " " in the beginning catches empty $dlname 8274145b7b3cSmrg *" $dlname "*) ;; 8275145b7b3cSmrg *) rmfiles="$rmfiles $objdir/$dlname" ;; 8276145b7b3cSmrg esac 82775ffd6003Smrg test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i" 8278145b7b3cSmrg ;; 8279145b7b3cSmrg uninstall) 8280145b7b3cSmrg if test -n "$library_names"; then 8281145b7b3cSmrg # Do each command in the postuninstall commands. 82825ffd6003Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 8283145b7b3cSmrg fi 8284145b7b3cSmrg 8285145b7b3cSmrg if test -n "$old_library"; then 8286145b7b3cSmrg # Do each command in the old_postuninstall commands. 82875ffd6003Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 8288145b7b3cSmrg fi 8289145b7b3cSmrg # FIXME: should reinstall the best remaining shared library. 8290145b7b3cSmrg ;; 8291145b7b3cSmrg esac 8292145b7b3cSmrg fi 8293145b7b3cSmrg ;; 8294145b7b3cSmrg 8295145b7b3cSmrg *.lo) 8296145b7b3cSmrg # Possibly a libtool object, so verify it. 82975ffd6003Smrg if func_lalib_p "$file"; then 8298145b7b3cSmrg 8299145b7b3cSmrg # Read the .lo file 83005ffd6003Smrg func_source $dir/$name 8301145b7b3cSmrg 8302145b7b3cSmrg # Add PIC object to the list of files to remove. 83035ffd6003Smrg if test -n "$pic_object" && 83045ffd6003Smrg test "$pic_object" != none; then 8305145b7b3cSmrg rmfiles="$rmfiles $dir/$pic_object" 8306145b7b3cSmrg fi 8307145b7b3cSmrg 8308145b7b3cSmrg # Add non-PIC object to the list of files to remove. 83095ffd6003Smrg if test -n "$non_pic_object" && 83105ffd6003Smrg test "$non_pic_object" != none; then 8311145b7b3cSmrg rmfiles="$rmfiles $dir/$non_pic_object" 8312145b7b3cSmrg fi 8313145b7b3cSmrg fi 8314145b7b3cSmrg ;; 8315145b7b3cSmrg 8316145b7b3cSmrg *) 8317145b7b3cSmrg if test "$mode" = clean ; then 8318145b7b3cSmrg noexename=$name 8319145b7b3cSmrg case $file in 8320145b7b3cSmrg *.exe) 83215ffd6003Smrg func_stripname '' '.exe' "$file" 83225ffd6003Smrg file=$func_stripname_result 83235ffd6003Smrg func_stripname '' '.exe' "$name" 83245ffd6003Smrg noexename=$func_stripname_result 8325145b7b3cSmrg # $file with .exe has already been added to rmfiles, 8326145b7b3cSmrg # add $file without .exe 8327145b7b3cSmrg rmfiles="$rmfiles $file" 8328145b7b3cSmrg ;; 8329145b7b3cSmrg esac 8330145b7b3cSmrg # Do a test to see if this is a libtool program. 83315ffd6003Smrg if func_ltwrapper_p "$file"; then 83325ffd6003Smrg if func_ltwrapper_executable_p "$file"; then 83335ffd6003Smrg func_ltwrapper_scriptname "$file" 83345ffd6003Smrg relink_command= 83355ffd6003Smrg func_source $func_ltwrapper_scriptname_result 83365ffd6003Smrg rmfiles="$rmfiles $func_ltwrapper_scriptname_result" 83375ffd6003Smrg else 83385ffd6003Smrg relink_command= 83395ffd6003Smrg func_source $dir/$noexename 83405ffd6003Smrg fi 8341145b7b3cSmrg 8342145b7b3cSmrg # note $name still contains .exe if it was in $file originally 8343145b7b3cSmrg # as does the version of $file that was added into $rmfiles 8344145b7b3cSmrg rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}" 8345145b7b3cSmrg if test "$fast_install" = yes && test -n "$relink_command"; then 8346145b7b3cSmrg rmfiles="$rmfiles $objdir/lt-$name" 8347145b7b3cSmrg fi 8348145b7b3cSmrg if test "X$noexename" != "X$name" ; then 8349145b7b3cSmrg rmfiles="$rmfiles $objdir/lt-${noexename}.c" 8350145b7b3cSmrg fi 8351145b7b3cSmrg fi 8352145b7b3cSmrg fi 8353145b7b3cSmrg ;; 8354145b7b3cSmrg esac 83555ffd6003Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 8356145b7b3cSmrg done 8357145b7b3cSmrg objdir="$origobjdir" 8358145b7b3cSmrg 8359145b7b3cSmrg # Try to remove the ${objdir}s in the directories where we deleted files 8360145b7b3cSmrg for dir in $rmdirs; do 8361145b7b3cSmrg if test -d "$dir"; then 83625ffd6003Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 8363145b7b3cSmrg fi 8364145b7b3cSmrg done 8365145b7b3cSmrg 8366145b7b3cSmrg exit $exit_status 83675ffd6003Smrg} 8368145b7b3cSmrg 83695ffd6003Smrg{ test "$mode" = uninstall || test "$mode" = clean; } && 83705ffd6003Smrg func_mode_uninstall ${1+"$@"} 8371145b7b3cSmrg 83725ffd6003Smrgtest -z "$mode" && { 83735ffd6003Smrg help="$generic_help" 83745ffd6003Smrg func_fatal_help "you must specify a MODE" 83755ffd6003Smrg} 83765ffd6003Smrg 83775ffd6003Smrgtest -z "$exec_cmd" && \ 83785ffd6003Smrg func_fatal_help "invalid operation mode \`$mode'" 8379145b7b3cSmrg 8380145b7b3cSmrgif test -n "$exec_cmd"; then 83815ffd6003Smrg eval exec "$exec_cmd" 8382145b7b3cSmrg exit $EXIT_FAILURE 8383145b7b3cSmrgfi 8384145b7b3cSmrg 83855ffd6003Smrgexit $exit_status 8386145b7b3cSmrg 8387145b7b3cSmrg 8388145b7b3cSmrg# The TAGs below are defined such that we never get into a situation 8389145b7b3cSmrg# in which we disable both kinds of libraries. Given conflicting 8390145b7b3cSmrg# choices, we go for a static library, that is the most portable, 8391145b7b3cSmrg# since we can't tell whether shared libraries were disabled because 8392145b7b3cSmrg# the user asked for that or because the platform doesn't support 8393145b7b3cSmrg# them. This is particularly important on AIX, because we don't 8394145b7b3cSmrg# support having both static and shared libraries enabled at the same 8395145b7b3cSmrg# time on that platform, so we default to a shared-only configuration. 8396145b7b3cSmrg# If a disable-shared tag is given, we'll fallback to a static-only 8397145b7b3cSmrg# configuration. But we'll never go from static-only to shared-only. 8398145b7b3cSmrg 8399145b7b3cSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 84005ffd6003Smrgbuild_libtool_libs=no 84015ffd6003Smrgbuild_old_libs=yes 8402145b7b3cSmrg# ### END LIBTOOL TAG CONFIG: disable-shared 8403145b7b3cSmrg 8404145b7b3cSmrg# ### BEGIN LIBTOOL TAG CONFIG: disable-static 84055ffd6003Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 8406145b7b3cSmrg# ### END LIBTOOL TAG CONFIG: disable-static 8407145b7b3cSmrg 8408145b7b3cSmrg# Local Variables: 8409145b7b3cSmrg# mode:shell-script 8410145b7b3cSmrg# sh-indentation:2 8411145b7b3cSmrg# End: 84125ffd6003Smrg# vi:sw=2 84135ffd6003Smrg 8414