ltmain.sh revision 54b44505
154b44505Smrg 254b44505Smrg# libtool (GNU libtool) 2.4 354b44505Smrg# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 454b44505Smrg 54a041c5bSmacallan# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 654b44505Smrg# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 754b44505Smrg# This is free software; see the source for copying conditions. There is NO 854b44505Smrg# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 954b44505Smrg 1054b44505Smrg# GNU Libtool is free software; you can redistribute it and/or modify 114a041c5bSmacallan# it under the terms of the GNU General Public License as published by 124a041c5bSmacallan# the Free Software Foundation; either version 2 of the License, or 134a041c5bSmacallan# (at your option) any later version. 144a041c5bSmacallan# 1554b44505Smrg# As a special exception to the GNU General Public License, 1654b44505Smrg# if you distribute this file as part of a program or library that 1754b44505Smrg# is built using GNU Libtool, you may include this file under the 1854b44505Smrg# same distribution terms that you use for the rest of that program. 1954b44505Smrg# 2054b44505Smrg# GNU Libtool is distributed in the hope that it will be useful, but 214a041c5bSmacallan# WITHOUT ANY WARRANTY; without even the implied warranty of 224a041c5bSmacallan# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 234a041c5bSmacallan# General Public License for more details. 244a041c5bSmacallan# 254a041c5bSmacallan# You should have received a copy of the GNU General Public License 2654b44505Smrg# along with GNU Libtool; see the file COPYING. If not, a copy 2754b44505Smrg# can be downloaded from http://www.gnu.org/licenses/gpl.html, 2854b44505Smrg# or obtained by writing to the Free Software Foundation, Inc., 2954b44505Smrg# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 304a041c5bSmacallan 3154b44505Smrg# Usage: $progname [OPTION]... [MODE-ARG]... 3254b44505Smrg# 3354b44505Smrg# Provide generalized library-building support services. 3454b44505Smrg# 3554b44505Smrg# --config show all configuration variables 3654b44505Smrg# --debug enable verbose shell tracing 3754b44505Smrg# -n, --dry-run display commands without modifying any files 3854b44505Smrg# --features display basic configuration information and exit 3954b44505Smrg# --mode=MODE use operation mode MODE 4054b44505Smrg# --preserve-dup-deps don't remove duplicate dependency libraries 4154b44505Smrg# --quiet, --silent don't print informational messages 4254b44505Smrg# --no-quiet, --no-silent 4354b44505Smrg# print informational messages (default) 4454b44505Smrg# --tag=TAG use configuration variables from tag TAG 4554b44505Smrg# -v, --verbose print more informational messages than default 4654b44505Smrg# --no-verbose don't print the extra informational messages 4754b44505Smrg# --version print version information 4854b44505Smrg# -h, --help, --help-all print short, long, or detailed help message 4954b44505Smrg# 5054b44505Smrg# MODE must be one of the following: 5154b44505Smrg# 5254b44505Smrg# clean remove files from the build directory 5354b44505Smrg# compile compile a source file into a libtool object 5454b44505Smrg# execute automatically set library path, then run a program 5554b44505Smrg# finish complete the installation of libtool libraries 5654b44505Smrg# install install libraries or executables 5754b44505Smrg# link create a library or an executable 5854b44505Smrg# uninstall remove libraries from an installed directory 5954b44505Smrg# 6054b44505Smrg# MODE-ARGS vary depending on the MODE. When passed as first option, 6154b44505Smrg# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 6254b44505Smrg# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 6354b44505Smrg# 6454b44505Smrg# When reporting a bug, please describe a test case to reproduce it and 6554b44505Smrg# include the following information: 6654b44505Smrg# 6754b44505Smrg# host-triplet: $host 6854b44505Smrg# shell: $SHELL 6954b44505Smrg# compiler: $LTCC 7054b44505Smrg# compiler flags: $LTCFLAGS 7154b44505Smrg# linker: $LD (gnu? $with_gnu_ld) 7254b44505Smrg# $progname: (GNU libtool) 2.4 7354b44505Smrg# automake: $automake_version 7454b44505Smrg# autoconf: $autoconf_version 7554b44505Smrg# 7654b44505Smrg# Report bugs to <bug-libtool@gnu.org>. 7754b44505Smrg# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 7854b44505Smrg# General help using GNU software: <http://www.gnu.org/gethelp/>. 794a041c5bSmacallan 8054b44505SmrgPROGRAM=libtool 814a041c5bSmacallanPACKAGE=libtool 8254b44505SmrgVERSION=2.4 8354b44505SmrgTIMESTAMP="" 8454b44505Smrgpackage_revision=1.3293 854a041c5bSmacallan 8654b44505Smrg# Be Bourne compatible 874a041c5bSmacallanif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 884a041c5bSmacallan emulate sh 894a041c5bSmacallan NULLCMD=: 904a041c5bSmacallan # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 914a041c5bSmacallan # is contrary to our usage. Disable this feature. 924a041c5bSmacallan alias -g '${1+"$@"}'='"$@"' 934a041c5bSmacallan setopt NO_GLOB_SUBST 944a041c5bSmacallanelse 954a041c5bSmacallan case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 964a041c5bSmacallanfi 974a041c5bSmacallanBIN_SH=xpg4; export BIN_SH # for Tru64 984a041c5bSmacallanDUALCASE=1; export DUALCASE # for MKS sh 994a041c5bSmacallan 10054b44505Smrg# A function that is used when there is no print builtin or printf. 10154b44505Smrgfunc_fallback_echo () 10254b44505Smrg{ 10354b44505Smrg eval 'cat <<_LTECHO_EOF 10454b44505Smrg$1 10554b44505Smrg_LTECHO_EOF' 10654b44505Smrg} 1074a041c5bSmacallan 10854b44505Smrg# NLS nuisances: We save the old values to restore during execute mode. 10954b44505Smrglt_user_locale= 11054b44505Smrglt_safe_locale= 1114a041c5bSmacallanfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 1124a041c5bSmacallando 1134a041c5bSmacallan eval "if test \"\${$lt_var+set}\" = set; then 11454b44505Smrg save_$lt_var=\$$lt_var 11554b44505Smrg $lt_var=C 1164a041c5bSmacallan export $lt_var 11754b44505Smrg lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 11854b44505Smrg lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 1194a041c5bSmacallan fi" 1204a041c5bSmacallandone 12154b44505SmrgLC_ALL=C 12254b44505SmrgLANGUAGE=C 12354b44505Smrgexport LANGUAGE LC_ALL 12454b44505Smrg 12554b44505Smrg$lt_unset CDPATH 1264a041c5bSmacallan 12754b44505Smrg 12854b44505Smrg# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 12954b44505Smrg# is ksh but when the shell is invoked as "sh" and the current value of 13054b44505Smrg# the _XPG environment variable is not equal to 1 (one), the special 13154b44505Smrg# positional parameter $0, within a function call, is the name of the 13254b44505Smrg# function. 13354b44505Smrgprogpath="$0" 13454b44505Smrg 13554b44505Smrg 13654b44505Smrg 13754b44505Smrg: ${CP="cp -f"} 13854b44505Smrgtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 13954b44505Smrg: ${EGREP="grep -E"} 14054b44505Smrg: ${FGREP="grep -F"} 14154b44505Smrg: ${GREP="grep"} 14254b44505Smrg: ${LN_S="ln -s"} 14354b44505Smrg: ${MAKE="make"} 14454b44505Smrg: ${MKDIR="mkdir"} 14554b44505Smrg: ${MV="mv -f"} 14654b44505Smrg: ${RM="rm -f"} 14754b44505Smrg: ${SED="sed"} 14854b44505Smrg: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 14954b44505Smrg: ${Xsed="$SED -e 1s/^X//"} 15054b44505Smrg 15154b44505Smrg# Global variables: 15254b44505SmrgEXIT_SUCCESS=0 15354b44505SmrgEXIT_FAILURE=1 15454b44505SmrgEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 15554b44505SmrgEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 15654b44505Smrg 15754b44505Smrgexit_status=$EXIT_SUCCESS 1584a041c5bSmacallan 1594a041c5bSmacallan# Make sure IFS has a sensible default 1604a041c5bSmacallanlt_nl=' 1614a041c5bSmacallan' 1624a041c5bSmacallanIFS=" $lt_nl" 1634a041c5bSmacallan 16454b44505Smrgdirname="s,/[^/]*$,," 16554b44505Smrgbasename="s,^.*/,," 1664a041c5bSmacallan 16754b44505Smrg# func_dirname file append nondir_replacement 16854b44505Smrg# Compute the dirname of FILE. If nonempty, add APPEND to the result, 16954b44505Smrg# otherwise set result to NONDIR_REPLACEMENT. 17054b44505Smrgfunc_dirname () 17154b44505Smrg{ 17254b44505Smrg func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 17354b44505Smrg if test "X$func_dirname_result" = "X${1}"; then 17454b44505Smrg func_dirname_result="${3}" 17554b44505Smrg else 17654b44505Smrg func_dirname_result="$func_dirname_result${2}" 17754b44505Smrg fi 17854b44505Smrg} # func_dirname may be replaced by extended shell implementation 17954b44505Smrg 18054b44505Smrg 18154b44505Smrg# func_basename file 18254b44505Smrgfunc_basename () 18354b44505Smrg{ 18454b44505Smrg func_basename_result=`$ECHO "${1}" | $SED "$basename"` 18554b44505Smrg} # func_basename may be replaced by extended shell implementation 18654b44505Smrg 18754b44505Smrg 18854b44505Smrg# func_dirname_and_basename file append nondir_replacement 18954b44505Smrg# perform func_basename and func_dirname in a single function 19054b44505Smrg# call: 19154b44505Smrg# dirname: Compute the dirname of FILE. If nonempty, 19254b44505Smrg# add APPEND to the result, otherwise set result 19354b44505Smrg# to NONDIR_REPLACEMENT. 19454b44505Smrg# value returned in "$func_dirname_result" 19554b44505Smrg# basename: Compute filename of FILE. 19654b44505Smrg# value retuned in "$func_basename_result" 19754b44505Smrg# Implementation must be kept synchronized with func_dirname 19854b44505Smrg# and func_basename. For efficiency, we do not delegate to 19954b44505Smrg# those functions but instead duplicate the functionality here. 20054b44505Smrgfunc_dirname_and_basename () 20154b44505Smrg{ 20254b44505Smrg # Extract subdirectory from the argument. 20354b44505Smrg func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 20454b44505Smrg if test "X$func_dirname_result" = "X${1}"; then 20554b44505Smrg func_dirname_result="${3}" 20654b44505Smrg else 20754b44505Smrg func_dirname_result="$func_dirname_result${2}" 20854b44505Smrg fi 20954b44505Smrg func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 21054b44505Smrg} # func_dirname_and_basename may be replaced by extended shell implementation 21154b44505Smrg 21254b44505Smrg 21354b44505Smrg# func_stripname prefix suffix name 21454b44505Smrg# strip PREFIX and SUFFIX off of NAME. 21554b44505Smrg# PREFIX and SUFFIX must not contain globbing or regex special 21654b44505Smrg# characters, hashes, percent signs, but SUFFIX may contain a leading 21754b44505Smrg# dot (in which case that matches only a dot). 21854b44505Smrg# func_strip_suffix prefix name 21954b44505Smrgfunc_stripname () 22054b44505Smrg{ 22154b44505Smrg case ${2} in 22254b44505Smrg .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 22354b44505Smrg *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 22454b44505Smrg esac 22554b44505Smrg} # func_stripname may be replaced by extended shell implementation 22654b44505Smrg 22754b44505Smrg 22854b44505Smrg# These SED scripts presuppose an absolute path with a trailing slash. 22954b44505Smrgpathcar='s,^/\([^/]*\).*$,\1,' 23054b44505Smrgpathcdr='s,^/[^/]*,,' 23154b44505Smrgremovedotparts=':dotsl 23254b44505Smrg s@/\./@/@g 23354b44505Smrg t dotsl 23454b44505Smrg s,/\.$,/,' 23554b44505Smrgcollapseslashes='s@/\{1,\}@/@g' 23654b44505Smrgfinalslash='s,/*$,/,' 23754b44505Smrg 23854b44505Smrg# func_normal_abspath PATH 23954b44505Smrg# Remove doubled-up and trailing slashes, "." path components, 24054b44505Smrg# and cancel out any ".." path components in PATH after making 24154b44505Smrg# it an absolute path. 24254b44505Smrg# value returned in "$func_normal_abspath_result" 24354b44505Smrgfunc_normal_abspath () 24454b44505Smrg{ 24554b44505Smrg # Start from root dir and reassemble the path. 24654b44505Smrg func_normal_abspath_result= 24754b44505Smrg func_normal_abspath_tpath=$1 24854b44505Smrg func_normal_abspath_altnamespace= 24954b44505Smrg case $func_normal_abspath_tpath in 25054b44505Smrg "") 25154b44505Smrg # Empty path, that just means $cwd. 25254b44505Smrg func_stripname '' '/' "`pwd`" 25354b44505Smrg func_normal_abspath_result=$func_stripname_result 25454b44505Smrg return 25554b44505Smrg ;; 25654b44505Smrg # The next three entries are used to spot a run of precisely 25754b44505Smrg # two leading slashes without using negated character classes; 25854b44505Smrg # we take advantage of case's first-match behaviour. 25954b44505Smrg ///*) 26054b44505Smrg # Unusual form of absolute path, do nothing. 26154b44505Smrg ;; 26254b44505Smrg //*) 26354b44505Smrg # Not necessarily an ordinary path; POSIX reserves leading '//' 26454b44505Smrg # and for example Cygwin uses it to access remote file shares 26554b44505Smrg # over CIFS/SMB, so we conserve a leading double slash if found. 26654b44505Smrg func_normal_abspath_altnamespace=/ 26754b44505Smrg ;; 26854b44505Smrg /*) 26954b44505Smrg # Absolute path, do nothing. 27054b44505Smrg ;; 27154b44505Smrg *) 27254b44505Smrg # Relative path, prepend $cwd. 27354b44505Smrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 27454b44505Smrg ;; 27554b44505Smrg esac 27654b44505Smrg # Cancel out all the simple stuff to save iterations. We also want 27754b44505Smrg # the path to end with a slash for ease of parsing, so make sure 27854b44505Smrg # there is one (and only one) here. 27954b44505Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 28054b44505Smrg -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 28154b44505Smrg while :; do 28254b44505Smrg # Processed it all yet? 28354b44505Smrg if test "$func_normal_abspath_tpath" = / ; then 28454b44505Smrg # If we ascended to the root using ".." the result may be empty now. 28554b44505Smrg if test -z "$func_normal_abspath_result" ; then 28654b44505Smrg func_normal_abspath_result=/ 28754b44505Smrg fi 28854b44505Smrg break 28954b44505Smrg fi 29054b44505Smrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 29154b44505Smrg -e "$pathcar"` 29254b44505Smrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 29354b44505Smrg -e "$pathcdr"` 29454b44505Smrg # Figure out what to do with it 29554b44505Smrg case $func_normal_abspath_tcomponent in 29654b44505Smrg "") 29754b44505Smrg # Trailing empty path component, ignore it. 29854b44505Smrg ;; 29954b44505Smrg ..) 30054b44505Smrg # Parent dir; strip last assembled component from result. 30154b44505Smrg func_dirname "$func_normal_abspath_result" 30254b44505Smrg func_normal_abspath_result=$func_dirname_result 30354b44505Smrg ;; 30454b44505Smrg *) 30554b44505Smrg # Actual path component, append it. 30654b44505Smrg func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 30754b44505Smrg ;; 30854b44505Smrg esac 30954b44505Smrg done 31054b44505Smrg # Restore leading double-slash if one was found on entry. 31154b44505Smrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 31254b44505Smrg} 31354b44505Smrg 31454b44505Smrg# func_relative_path SRCDIR DSTDIR 31554b44505Smrg# generates a relative path from SRCDIR to DSTDIR, with a trailing 31654b44505Smrg# slash if non-empty, suitable for immediately appending a filename 31754b44505Smrg# without needing to append a separator. 31854b44505Smrg# value returned in "$func_relative_path_result" 31954b44505Smrgfunc_relative_path () 32054b44505Smrg{ 32154b44505Smrg func_relative_path_result= 32254b44505Smrg func_normal_abspath "$1" 32354b44505Smrg func_relative_path_tlibdir=$func_normal_abspath_result 32454b44505Smrg func_normal_abspath "$2" 32554b44505Smrg func_relative_path_tbindir=$func_normal_abspath_result 32654b44505Smrg 32754b44505Smrg # Ascend the tree starting from libdir 32854b44505Smrg while :; do 32954b44505Smrg # check if we have found a prefix of bindir 33054b44505Smrg case $func_relative_path_tbindir in 33154b44505Smrg $func_relative_path_tlibdir) 33254b44505Smrg # found an exact match 33354b44505Smrg func_relative_path_tcancelled= 33454b44505Smrg break 33554b44505Smrg ;; 33654b44505Smrg $func_relative_path_tlibdir*) 33754b44505Smrg # found a matching prefix 33854b44505Smrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 33954b44505Smrg func_relative_path_tcancelled=$func_stripname_result 34054b44505Smrg if test -z "$func_relative_path_result"; then 34154b44505Smrg func_relative_path_result=. 34254b44505Smrg fi 34354b44505Smrg break 34454b44505Smrg ;; 34554b44505Smrg *) 34654b44505Smrg func_dirname $func_relative_path_tlibdir 34754b44505Smrg func_relative_path_tlibdir=${func_dirname_result} 34854b44505Smrg if test "x$func_relative_path_tlibdir" = x ; then 34954b44505Smrg # Have to descend all the way to the root! 35054b44505Smrg func_relative_path_result=../$func_relative_path_result 35154b44505Smrg func_relative_path_tcancelled=$func_relative_path_tbindir 35254b44505Smrg break 35354b44505Smrg fi 35454b44505Smrg func_relative_path_result=../$func_relative_path_result 35554b44505Smrg ;; 35654b44505Smrg esac 35754b44505Smrg done 35854b44505Smrg 35954b44505Smrg # Now calculate path; take care to avoid doubling-up slashes. 36054b44505Smrg func_stripname '' '/' "$func_relative_path_result" 36154b44505Smrg func_relative_path_result=$func_stripname_result 36254b44505Smrg func_stripname '/' '/' "$func_relative_path_tcancelled" 36354b44505Smrg if test "x$func_stripname_result" != x ; then 36454b44505Smrg func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 36554b44505Smrg fi 36654b44505Smrg 36754b44505Smrg # Normalisation. If bindir is libdir, return empty string, 36854b44505Smrg # else relative path ending with a slash; either way, target 36954b44505Smrg # file name can be directly appended. 37054b44505Smrg if test ! -z "$func_relative_path_result"; then 37154b44505Smrg func_stripname './' '' "$func_relative_path_result/" 37254b44505Smrg func_relative_path_result=$func_stripname_result 37354b44505Smrg fi 37454b44505Smrg} 37554b44505Smrg 37654b44505Smrg# The name of this program: 37754b44505Smrgfunc_dirname_and_basename "$progpath" 37854b44505Smrgprogname=$func_basename_result 37954b44505Smrg 38054b44505Smrg# Make sure we have an absolute path for reexecution: 38154b44505Smrgcase $progpath in 38254b44505Smrg [\\/]*|[A-Za-z]:\\*) ;; 38354b44505Smrg *[\\/]*) 38454b44505Smrg progdir=$func_dirname_result 38554b44505Smrg progdir=`cd "$progdir" && pwd` 38654b44505Smrg progpath="$progdir/$progname" 38754b44505Smrg ;; 38854b44505Smrg *) 38954b44505Smrg save_IFS="$IFS" 39054b44505Smrg IFS=: 39154b44505Smrg for progdir in $PATH; do 39254b44505Smrg IFS="$save_IFS" 39354b44505Smrg test -x "$progdir/$progname" && break 39454b44505Smrg done 39554b44505Smrg IFS="$save_IFS" 39654b44505Smrg test -n "$progdir" || progdir=`pwd` 39754b44505Smrg progpath="$progdir/$progname" 39854b44505Smrg ;; 39954b44505Smrgesac 40054b44505Smrg 40154b44505Smrg# Sed substitution that helps us do robust quoting. It backslashifies 40254b44505Smrg# metacharacters that are still active within double-quoted strings. 40354b44505SmrgXsed="${SED}"' -e 1s/^X//' 40454b44505Smrgsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 40554b44505Smrg 40654b44505Smrg# Same as above, but do not quote variable references. 40754b44505Smrgdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 40854b44505Smrg 40954b44505Smrg# Sed substitution that turns a string into a regex matching for the 41054b44505Smrg# string literally. 41154b44505Smrgsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 41254b44505Smrg 41354b44505Smrg# Sed substitution that converts a w32 file name or path 41454b44505Smrg# which contains forward slashes, into one that contains 41554b44505Smrg# (escaped) backslashes. A very naive implementation. 41654b44505Smrglt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 41754b44505Smrg 41854b44505Smrg# Re-`\' parameter expansions in output of double_quote_subst that were 41954b44505Smrg# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 42054b44505Smrg# in input to double_quote_subst, that '$' was protected from expansion. 42154b44505Smrg# Since each input `\' is now two `\'s, look for any number of runs of 42254b44505Smrg# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 42354b44505Smrgbs='\\' 42454b44505Smrgbs2='\\\\' 42554b44505Smrgbs4='\\\\\\\\' 42654b44505Smrgdollar='\$' 42754b44505Smrgsed_double_backslash="\ 42854b44505Smrg s/$bs4/&\\ 42954b44505Smrg/g 43054b44505Smrg s/^$bs2$dollar/$bs&/ 43154b44505Smrg s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 43254b44505Smrg s/\n//g" 43354b44505Smrg 43454b44505Smrg# Standard options: 43554b44505Smrgopt_dry_run=false 43654b44505Smrgopt_help=false 43754b44505Smrgopt_quiet=false 43854b44505Smrgopt_verbose=false 43954b44505Smrgopt_warning=: 44054b44505Smrg 44154b44505Smrg# func_echo arg... 44254b44505Smrg# Echo program name prefixed message, along with the current mode 44354b44505Smrg# name if it has been set yet. 44454b44505Smrgfunc_echo () 44554b44505Smrg{ 44654b44505Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 44754b44505Smrg} 44854b44505Smrg 44954b44505Smrg# func_verbose arg... 45054b44505Smrg# Echo program name prefixed message in verbose mode only. 45154b44505Smrgfunc_verbose () 45254b44505Smrg{ 45354b44505Smrg $opt_verbose && func_echo ${1+"$@"} 45454b44505Smrg 45554b44505Smrg # A bug in bash halts the script if the last line of a function 45654b44505Smrg # fails when set -e is in force, so we need another command to 45754b44505Smrg # work around that: 45854b44505Smrg : 45954b44505Smrg} 46054b44505Smrg 46154b44505Smrg# func_echo_all arg... 46254b44505Smrg# Invoke $ECHO with all args, space-separated. 46354b44505Smrgfunc_echo_all () 46454b44505Smrg{ 46554b44505Smrg $ECHO "$*" 46654b44505Smrg} 46754b44505Smrg 46854b44505Smrg# func_error arg... 46954b44505Smrg# Echo program name prefixed message to standard error. 47054b44505Smrgfunc_error () 47154b44505Smrg{ 47254b44505Smrg $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 47354b44505Smrg} 47454b44505Smrg 47554b44505Smrg# func_warning arg... 47654b44505Smrg# Echo program name prefixed warning message to standard error. 47754b44505Smrgfunc_warning () 47854b44505Smrg{ 47954b44505Smrg $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 48054b44505Smrg 48154b44505Smrg # bash bug again: 48254b44505Smrg : 48354b44505Smrg} 48454b44505Smrg 48554b44505Smrg# func_fatal_error arg... 48654b44505Smrg# Echo program name prefixed message to standard error, and exit. 48754b44505Smrgfunc_fatal_error () 48854b44505Smrg{ 48954b44505Smrg func_error ${1+"$@"} 49054b44505Smrg exit $EXIT_FAILURE 49154b44505Smrg} 49254b44505Smrg 49354b44505Smrg# func_fatal_help arg... 49454b44505Smrg# Echo program name prefixed message to standard error, followed by 49554b44505Smrg# a help hint, and exit. 49654b44505Smrgfunc_fatal_help () 49754b44505Smrg{ 49854b44505Smrg func_error ${1+"$@"} 49954b44505Smrg func_fatal_error "$help" 50054b44505Smrg} 50154b44505Smrghelp="Try \`$progname --help' for more information." ## default 50254b44505Smrg 50354b44505Smrg 50454b44505Smrg# func_grep expression filename 50554b44505Smrg# Check whether EXPRESSION matches any line of FILENAME, without output. 50654b44505Smrgfunc_grep () 50754b44505Smrg{ 50854b44505Smrg $GREP "$1" "$2" >/dev/null 2>&1 50954b44505Smrg} 51054b44505Smrg 51154b44505Smrg 51254b44505Smrg# func_mkdir_p directory-path 51354b44505Smrg# Make sure the entire path to DIRECTORY-PATH is available. 51454b44505Smrgfunc_mkdir_p () 51554b44505Smrg{ 51654b44505Smrg my_directory_path="$1" 51754b44505Smrg my_dir_list= 51854b44505Smrg 51954b44505Smrg if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 52054b44505Smrg 52154b44505Smrg # Protect directory names starting with `-' 52254b44505Smrg case $my_directory_path in 52354b44505Smrg -*) my_directory_path="./$my_directory_path" ;; 52454b44505Smrg esac 52554b44505Smrg 52654b44505Smrg # While some portion of DIR does not yet exist... 52754b44505Smrg while test ! -d "$my_directory_path"; do 52854b44505Smrg # ...make a list in topmost first order. Use a colon delimited 52954b44505Smrg # list incase some portion of path contains whitespace. 53054b44505Smrg my_dir_list="$my_directory_path:$my_dir_list" 53154b44505Smrg 53254b44505Smrg # If the last portion added has no slash in it, the list is done 53354b44505Smrg case $my_directory_path in */*) ;; *) break ;; esac 53454b44505Smrg 53554b44505Smrg # ...otherwise throw away the child directory and loop 53654b44505Smrg my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 53754b44505Smrg done 53854b44505Smrg my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 53954b44505Smrg 54054b44505Smrg save_mkdir_p_IFS="$IFS"; IFS=':' 54154b44505Smrg for my_dir in $my_dir_list; do 54254b44505Smrg IFS="$save_mkdir_p_IFS" 54354b44505Smrg # mkdir can fail with a `File exist' error if two processes 54454b44505Smrg # try to create one of the directories concurrently. Don't 54554b44505Smrg # stop in that case! 54654b44505Smrg $MKDIR "$my_dir" 2>/dev/null || : 54754b44505Smrg done 54854b44505Smrg IFS="$save_mkdir_p_IFS" 54954b44505Smrg 55054b44505Smrg # Bail out if we (or some other process) failed to create a directory. 55154b44505Smrg test -d "$my_directory_path" || \ 55254b44505Smrg func_fatal_error "Failed to create \`$1'" 55354b44505Smrg fi 55454b44505Smrg} 5554a041c5bSmacallan 5564a041c5bSmacallan 5574a041c5bSmacallan# func_mktempdir [string] 5584a041c5bSmacallan# Make a temporary directory that won't clash with other running 5594a041c5bSmacallan# libtool processes, and avoids race conditions if possible. If 5604a041c5bSmacallan# given, STRING is the basename for that directory. 5614a041c5bSmacallanfunc_mktempdir () 5624a041c5bSmacallan{ 5634a041c5bSmacallan my_template="${TMPDIR-/tmp}/${1-$progname}" 5644a041c5bSmacallan 56554b44505Smrg if test "$opt_dry_run" = ":"; then 5664a041c5bSmacallan # Return a directory name, but don't create it in dry-run mode 5674a041c5bSmacallan my_tmpdir="${my_template}-$$" 5684a041c5bSmacallan else 5694a041c5bSmacallan 5704a041c5bSmacallan # If mktemp works, use that first and foremost 5714a041c5bSmacallan my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 5724a041c5bSmacallan 5734a041c5bSmacallan if test ! -d "$my_tmpdir"; then 57454b44505Smrg # Failing that, at least try and use $RANDOM to avoid a race 57554b44505Smrg my_tmpdir="${my_template}-${RANDOM-0}$$" 5764a041c5bSmacallan 57754b44505Smrg save_mktempdir_umask=`umask` 57854b44505Smrg umask 0077 57954b44505Smrg $MKDIR "$my_tmpdir" 58054b44505Smrg umask $save_mktempdir_umask 5814a041c5bSmacallan fi 5824a041c5bSmacallan 5834a041c5bSmacallan # If we're not in dry-run mode, bomb out on failure 58454b44505Smrg test -d "$my_tmpdir" || \ 58554b44505Smrg func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 5864a041c5bSmacallan fi 5874a041c5bSmacallan 58854b44505Smrg $ECHO "$my_tmpdir" 5894a041c5bSmacallan} 5904a041c5bSmacallan 5914a041c5bSmacallan 59254b44505Smrg# func_quote_for_eval arg 59354b44505Smrg# Aesthetically quote ARG to be evaled later. 59454b44505Smrg# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 59554b44505Smrg# is double-quoted, suitable for a subsequent eval, whereas 59654b44505Smrg# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 59754b44505Smrg# which are still active within double quotes backslashified. 59854b44505Smrgfunc_quote_for_eval () 5994a041c5bSmacallan{ 60054b44505Smrg case $1 in 60154b44505Smrg *[\\\`\"\$]*) 60254b44505Smrg func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 60354b44505Smrg *) 60454b44505Smrg func_quote_for_eval_unquoted_result="$1" ;; 60554b44505Smrg esac 60654b44505Smrg 60754b44505Smrg case $func_quote_for_eval_unquoted_result in 60854b44505Smrg # Double-quote args containing shell metacharacters to delay 60954b44505Smrg # word splitting, command substitution and and variable 61054b44505Smrg # expansion for a subsequent eval. 61154b44505Smrg # Many Bourne shells cannot handle close brackets correctly 61254b44505Smrg # in scan sets, so we specify it separately. 61354b44505Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 61454b44505Smrg func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 61554b44505Smrg ;; 61654b44505Smrg *) 61754b44505Smrg func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 61854b44505Smrg esac 61954b44505Smrg} 62054b44505Smrg 62154b44505Smrg 62254b44505Smrg# func_quote_for_expand arg 62354b44505Smrg# Aesthetically quote ARG to be evaled later; same as above, 62454b44505Smrg# but do not quote variable references. 62554b44505Smrgfunc_quote_for_expand () 62654b44505Smrg{ 62754b44505Smrg case $1 in 62854b44505Smrg *[\\\`\"]*) 62954b44505Smrg my_arg=`$ECHO "$1" | $SED \ 63054b44505Smrg -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 63154b44505Smrg *) 63254b44505Smrg my_arg="$1" ;; 63354b44505Smrg esac 63454b44505Smrg 63554b44505Smrg case $my_arg in 63654b44505Smrg # Double-quote args containing shell metacharacters to delay 63754b44505Smrg # word splitting and command substitution for a subsequent eval. 63854b44505Smrg # Many Bourne shells cannot handle close brackets correctly 63954b44505Smrg # in scan sets, so we specify it separately. 64054b44505Smrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 64154b44505Smrg my_arg="\"$my_arg\"" 64254b44505Smrg ;; 64354b44505Smrg esac 64454b44505Smrg 64554b44505Smrg func_quote_for_expand_result="$my_arg" 64654b44505Smrg} 64754b44505Smrg 64854b44505Smrg 64954b44505Smrg# func_show_eval cmd [fail_exp] 65054b44505Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 65154b44505Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 65254b44505Smrg# is given, then evaluate it. 65354b44505Smrgfunc_show_eval () 65454b44505Smrg{ 65554b44505Smrg my_cmd="$1" 65654b44505Smrg my_fail_exp="${2-:}" 65754b44505Smrg 65854b44505Smrg ${opt_silent-false} || { 65954b44505Smrg func_quote_for_expand "$my_cmd" 66054b44505Smrg eval "func_echo $func_quote_for_expand_result" 66154b44505Smrg } 66254b44505Smrg 66354b44505Smrg if ${opt_dry_run-false}; then :; else 66454b44505Smrg eval "$my_cmd" 66554b44505Smrg my_status=$? 66654b44505Smrg if test "$my_status" -eq 0; then :; else 66754b44505Smrg eval "(exit $my_status); $my_fail_exp" 66854b44505Smrg fi 6694a041c5bSmacallan fi 67054b44505Smrg} 67154b44505Smrg 67254b44505Smrg 67354b44505Smrg# func_show_eval_locale cmd [fail_exp] 67454b44505Smrg# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 67554b44505Smrg# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 67654b44505Smrg# is given, then evaluate it. Use the saved locale for evaluation. 67754b44505Smrgfunc_show_eval_locale () 67854b44505Smrg{ 67954b44505Smrg my_cmd="$1" 68054b44505Smrg my_fail_exp="${2-:}" 68154b44505Smrg 68254b44505Smrg ${opt_silent-false} || { 68354b44505Smrg func_quote_for_expand "$my_cmd" 68454b44505Smrg eval "func_echo $func_quote_for_expand_result" 68554b44505Smrg } 68654b44505Smrg 68754b44505Smrg if ${opt_dry_run-false}; then :; else 68854b44505Smrg eval "$lt_user_locale 68954b44505Smrg $my_cmd" 69054b44505Smrg my_status=$? 69154b44505Smrg eval "$lt_safe_locale" 69254b44505Smrg if test "$my_status" -eq 0; then :; else 69354b44505Smrg eval "(exit $my_status); $my_fail_exp" 69454b44505Smrg fi 69554b44505Smrg fi 69654b44505Smrg} 69754b44505Smrg 69854b44505Smrg# func_tr_sh 69954b44505Smrg# Turn $1 into a string suitable for a shell variable name. 70054b44505Smrg# Result is stored in $func_tr_sh_result. All characters 70154b44505Smrg# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 70254b44505Smrg# if $1 begins with a digit, a '_' is prepended as well. 70354b44505Smrgfunc_tr_sh () 70454b44505Smrg{ 70554b44505Smrg case $1 in 70654b44505Smrg [0-9]* | *[!a-zA-Z0-9_]*) 70754b44505Smrg func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 7084a041c5bSmacallan ;; 70954b44505Smrg * ) 71054b44505Smrg func_tr_sh_result=$1 7114a041c5bSmacallan ;; 7124a041c5bSmacallan esac 7134a041c5bSmacallan} 7144a041c5bSmacallan 7154a041c5bSmacallan 71654b44505Smrg# func_version 71754b44505Smrg# Echo version message to standard output and exit. 71854b44505Smrgfunc_version () 7194a041c5bSmacallan{ 72054b44505Smrg $opt_debug 72154b44505Smrg 72254b44505Smrg $SED -n '/(C)/!b go 72354b44505Smrg :more 72454b44505Smrg /\./!{ 72554b44505Smrg N 72654b44505Smrg s/\n# / / 72754b44505Smrg b more 72854b44505Smrg } 72954b44505Smrg :go 73054b44505Smrg /^# '$PROGRAM' (GNU /,/# warranty; / { 73154b44505Smrg s/^# // 73254b44505Smrg s/^# *$// 73354b44505Smrg s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 73454b44505Smrg p 73554b44505Smrg }' < "$progpath" 73654b44505Smrg exit $? 7374a041c5bSmacallan} 7384a041c5bSmacallan 73954b44505Smrg# func_usage 74054b44505Smrg# Echo short help message to standard output and exit. 74154b44505Smrgfunc_usage () 7424a041c5bSmacallan{ 74354b44505Smrg $opt_debug 74454b44505Smrg 74554b44505Smrg $SED -n '/^# Usage:/,/^# *.*--help/ { 74654b44505Smrg s/^# // 74754b44505Smrg s/^# *$// 74854b44505Smrg s/\$progname/'$progname'/ 74954b44505Smrg p 75054b44505Smrg }' < "$progpath" 75154b44505Smrg echo 75254b44505Smrg $ECHO "run \`$progname --help | more' for full usage" 75354b44505Smrg exit $? 7544a041c5bSmacallan} 7554a041c5bSmacallan 75654b44505Smrg# func_help [NOEXIT] 75754b44505Smrg# Echo long help message to standard output and exit, 75854b44505Smrg# unless 'noexit' is passed as argument. 75954b44505Smrgfunc_help () 7604a041c5bSmacallan{ 76154b44505Smrg $opt_debug 76254b44505Smrg 76354b44505Smrg $SED -n '/^# Usage:/,/# Report bugs to/ { 76454b44505Smrg :print 76554b44505Smrg s/^# // 76654b44505Smrg s/^# *$// 76754b44505Smrg s*\$progname*'$progname'* 76854b44505Smrg s*\$host*'"$host"'* 76954b44505Smrg s*\$SHELL*'"$SHELL"'* 77054b44505Smrg s*\$LTCC*'"$LTCC"'* 77154b44505Smrg s*\$LTCFLAGS*'"$LTCFLAGS"'* 77254b44505Smrg s*\$LD*'"$LD"'* 77354b44505Smrg s/\$with_gnu_ld/'"$with_gnu_ld"'/ 77454b44505Smrg s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 77554b44505Smrg s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 77654b44505Smrg p 77754b44505Smrg d 77854b44505Smrg } 77954b44505Smrg /^# .* home page:/b print 78054b44505Smrg /^# General help using/b print 78154b44505Smrg ' < "$progpath" 78254b44505Smrg ret=$? 78354b44505Smrg if test -z "$1"; then 78454b44505Smrg exit $ret 7854a041c5bSmacallan fi 78654b44505Smrg} 7874a041c5bSmacallan 78854b44505Smrg# func_missing_arg argname 78954b44505Smrg# Echo program name prefixed message to standard error and set global 79054b44505Smrg# exit_cmd. 79154b44505Smrgfunc_missing_arg () 79254b44505Smrg{ 79354b44505Smrg $opt_debug 7944a041c5bSmacallan 79554b44505Smrg func_error "missing argument for $1." 79654b44505Smrg exit_cmd=exit 7974a041c5bSmacallan} 7984a041c5bSmacallan 7994a041c5bSmacallan 80054b44505Smrg# func_split_short_opt shortopt 80154b44505Smrg# Set func_split_short_opt_name and func_split_short_opt_arg shell 80254b44505Smrg# variables after splitting SHORTOPT after the 2nd character. 80354b44505Smrgfunc_split_short_opt () 80454b44505Smrg{ 80554b44505Smrg my_sed_short_opt='1s/^\(..\).*$/\1/;q' 80654b44505Smrg my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 80754b44505Smrg 80854b44505Smrg func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 80954b44505Smrg func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 81054b44505Smrg} # func_split_short_opt may be replaced by extended shell implementation 8114a041c5bSmacallan 8124a041c5bSmacallan 81354b44505Smrg# func_split_long_opt longopt 81454b44505Smrg# Set func_split_long_opt_name and func_split_long_opt_arg shell 81554b44505Smrg# variables after splitting LONGOPT at the `=' sign. 81654b44505Smrgfunc_split_long_opt () 81754b44505Smrg{ 81854b44505Smrg my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 81954b44505Smrg my_sed_long_arg='1s/^--[^=]*=//' 8204a041c5bSmacallan 82154b44505Smrg func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 82254b44505Smrg func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 82354b44505Smrg} # func_split_long_opt may be replaced by extended shell implementation 8244a041c5bSmacallan 82554b44505Smrgexit_cmd=: 8264a041c5bSmacallan 8274a041c5bSmacallan 8284a041c5bSmacallan 8294a041c5bSmacallan 8304a041c5bSmacallan 83154b44505Smrgmagic="%%%MAGIC variable%%%" 83254b44505Smrgmagic_exe="%%%MAGIC EXE variable%%%" 83354b44505Smrg 83454b44505Smrg# Global variables. 83554b44505Smrgnonopt= 83654b44505Smrgpreserve_args= 83754b44505Smrglo2o="s/\\.lo\$/.${objext}/" 83854b44505Smrgo2lo="s/\\.${objext}\$/.lo/" 83954b44505Smrgextracted_archives= 84054b44505Smrgextracted_serial=0 84154b44505Smrg 84254b44505Smrg# If this variable is set in any of the actions, the command in it 84354b44505Smrg# will be execed at the end. This prevents here-documents from being 84454b44505Smrg# left over by shells. 84554b44505Smrgexec_cmd= 84654b44505Smrg 84754b44505Smrg# func_append var value 84854b44505Smrg# Append VALUE to the end of shell variable VAR. 84954b44505Smrgfunc_append () 85054b44505Smrg{ 85154b44505Smrg eval "${1}=\$${1}\${2}" 85254b44505Smrg} # func_append may be replaced by extended shell implementation 85354b44505Smrg 85454b44505Smrg# func_append_quoted var value 85554b44505Smrg# Quote VALUE and append to the end of shell variable VAR, separated 85654b44505Smrg# by a space. 85754b44505Smrgfunc_append_quoted () 85854b44505Smrg{ 85954b44505Smrg func_quote_for_eval "${2}" 86054b44505Smrg eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 86154b44505Smrg} # func_append_quoted may be replaced by extended shell implementation 86254b44505Smrg 86354b44505Smrg 86454b44505Smrg# func_arith arithmetic-term... 86554b44505Smrgfunc_arith () 86654b44505Smrg{ 86754b44505Smrg func_arith_result=`expr "${@}"` 86854b44505Smrg} # func_arith may be replaced by extended shell implementation 86954b44505Smrg 87054b44505Smrg 87154b44505Smrg# func_len string 87254b44505Smrg# STRING may not start with a hyphen. 87354b44505Smrgfunc_len () 87454b44505Smrg{ 87554b44505Smrg func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 87654b44505Smrg} # func_len may be replaced by extended shell implementation 87754b44505Smrg 87854b44505Smrg 87954b44505Smrg# func_lo2o object 88054b44505Smrgfunc_lo2o () 88154b44505Smrg{ 88254b44505Smrg func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 88354b44505Smrg} # func_lo2o may be replaced by extended shell implementation 88454b44505Smrg 88554b44505Smrg 88654b44505Smrg# func_xform libobj-or-source 88754b44505Smrgfunc_xform () 88854b44505Smrg{ 88954b44505Smrg func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 89054b44505Smrg} # func_xform may be replaced by extended shell implementation 89154b44505Smrg 89254b44505Smrg 89354b44505Smrg# func_fatal_configuration arg... 89454b44505Smrg# Echo program name prefixed message to standard error, followed by 89554b44505Smrg# a configuration failure hint, and exit. 89654b44505Smrgfunc_fatal_configuration () 89754b44505Smrg{ 89854b44505Smrg func_error ${1+"$@"} 89954b44505Smrg func_error "See the $PACKAGE documentation for more information." 90054b44505Smrg func_fatal_error "Fatal configuration error." 90154b44505Smrg} 90254b44505Smrg 90354b44505Smrg 90454b44505Smrg# func_config 90554b44505Smrg# Display the configuration for all the tags in this script. 90654b44505Smrgfunc_config () 90754b44505Smrg{ 90854b44505Smrg re_begincf='^# ### BEGIN LIBTOOL' 90954b44505Smrg re_endcf='^# ### END LIBTOOL' 91054b44505Smrg 91154b44505Smrg # Default configuration. 91254b44505Smrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 91354b44505Smrg 9144a041c5bSmacallan # Now print the configurations for the tags. 9154a041c5bSmacallan for tagname in $taglist; do 91654b44505Smrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 9174a041c5bSmacallan done 9184a041c5bSmacallan 91954b44505Smrg exit $? 92054b44505Smrg} 9214a041c5bSmacallan 92254b44505Smrg# func_features 92354b44505Smrg# Display the features supported by this script. 92454b44505Smrgfunc_features () 92554b44505Smrg{ 92654b44505Smrg echo "host: $host" 9274a041c5bSmacallan if test "$build_libtool_libs" = yes; then 92854b44505Smrg echo "enable shared libraries" 9294a041c5bSmacallan else 93054b44505Smrg echo "disable shared libraries" 9314a041c5bSmacallan fi 9324a041c5bSmacallan if test "$build_old_libs" = yes; then 93354b44505Smrg echo "enable static libraries" 9344a041c5bSmacallan else 93554b44505Smrg echo "disable static libraries" 9364a041c5bSmacallan fi 9374a041c5bSmacallan 93854b44505Smrg exit $? 93954b44505Smrg} 9404a041c5bSmacallan 94154b44505Smrg# func_enable_tag tagname 94254b44505Smrg# Verify that TAGNAME is valid, and either flag an error and exit, or 94354b44505Smrg# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 94454b44505Smrg# variable here. 94554b44505Smrgfunc_enable_tag () 94654b44505Smrg{ 94754b44505Smrg # Global variable: 94854b44505Smrg tagname="$1" 9494a041c5bSmacallan 95054b44505Smrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 95154b44505Smrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 95254b44505Smrg sed_extractcf="/$re_begincf/,/$re_endcf/p" 9534a041c5bSmacallan 95454b44505Smrg # Validate tagname. 95554b44505Smrg case $tagname in 95654b44505Smrg *[!-_A-Za-z0-9,/]*) 95754b44505Smrg func_fatal_error "invalid tag name: $tagname" 95854b44505Smrg ;; 95954b44505Smrg esac 9604a041c5bSmacallan 96154b44505Smrg # Don't test for the "default" C tag, as we know it's 96254b44505Smrg # there but not specially marked. 96354b44505Smrg case $tagname in 96454b44505Smrg CC) ;; 96554b44505Smrg *) 96654b44505Smrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 96754b44505Smrg taglist="$taglist $tagname" 96854b44505Smrg 96954b44505Smrg # Evaluate the configuration. Be careful to quote the path 97054b44505Smrg # and the sed script, to avoid splitting on whitespace, but 97154b44505Smrg # also don't use non-portable quotes within backquotes within 97254b44505Smrg # quotes we have to do it in 2 steps: 97354b44505Smrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 97454b44505Smrg eval "$extractedcf" 97554b44505Smrg else 97654b44505Smrg func_error "ignoring unknown tag $tagname" 97754b44505Smrg fi 97854b44505Smrg ;; 97954b44505Smrg esac 98054b44505Smrg} 9814a041c5bSmacallan 98254b44505Smrg# func_check_version_match 98354b44505Smrg# Ensure that we are using m4 macros, and libtool script from the same 98454b44505Smrg# release of libtool. 98554b44505Smrgfunc_check_version_match () 98654b44505Smrg{ 98754b44505Smrg if test "$package_revision" != "$macro_revision"; then 98854b44505Smrg if test "$VERSION" != "$macro_version"; then 98954b44505Smrg if test -z "$macro_version"; then 99054b44505Smrg cat >&2 <<_LT_EOF 99154b44505Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99254b44505Smrg$progname: definition of this LT_INIT comes from an older release. 99354b44505Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 99454b44505Smrg$progname: and run autoconf again. 99554b44505Smrg_LT_EOF 99654b44505Smrg else 99754b44505Smrg cat >&2 <<_LT_EOF 99854b44505Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 99954b44505Smrg$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 100054b44505Smrg$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 100154b44505Smrg$progname: and run autoconf again. 100254b44505Smrg_LT_EOF 100354b44505Smrg fi 100454b44505Smrg else 100554b44505Smrg cat >&2 <<_LT_EOF 100654b44505Smrg$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 100754b44505Smrg$progname: but the definition of this LT_INIT comes from revision $macro_revision. 100854b44505Smrg$progname: You should recreate aclocal.m4 with macros from revision $package_revision 100954b44505Smrg$progname: of $PACKAGE $VERSION and run autoconf again. 101054b44505Smrg_LT_EOF 101154b44505Smrg fi 10124a041c5bSmacallan 101354b44505Smrg exit $EXIT_MISMATCH 101454b44505Smrg fi 101554b44505Smrg} 10164a041c5bSmacallan 10174a041c5bSmacallan 101854b44505Smrg# Shorthand for --mode=foo, only valid as the first argument 101954b44505Smrgcase $1 in 102054b44505Smrgclean|clea|cle|cl) 102154b44505Smrg shift; set dummy --mode clean ${1+"$@"}; shift 102254b44505Smrg ;; 102354b44505Smrgcompile|compil|compi|comp|com|co|c) 102454b44505Smrg shift; set dummy --mode compile ${1+"$@"}; shift 102554b44505Smrg ;; 102654b44505Smrgexecute|execut|execu|exec|exe|ex|e) 102754b44505Smrg shift; set dummy --mode execute ${1+"$@"}; shift 102854b44505Smrg ;; 102954b44505Smrgfinish|finis|fini|fin|fi|f) 103054b44505Smrg shift; set dummy --mode finish ${1+"$@"}; shift 10314a041c5bSmacallan ;; 103254b44505Smrginstall|instal|insta|inst|ins|in|i) 103354b44505Smrg shift; set dummy --mode install ${1+"$@"}; shift 10344a041c5bSmacallan ;; 103554b44505Smrglink|lin|li|l) 103654b44505Smrg shift; set dummy --mode link ${1+"$@"}; shift 103754b44505Smrg ;; 103854b44505Smrguninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 103954b44505Smrg shift; set dummy --mode uninstall ${1+"$@"}; shift 10404a041c5bSmacallan ;; 10414a041c5bSmacallanesac 10424a041c5bSmacallan 10434a041c5bSmacallan 10444a041c5bSmacallan 104554b44505Smrg# Option defaults: 104654b44505Smrgopt_debug=: 104754b44505Smrgopt_dry_run=false 104854b44505Smrgopt_config=false 104954b44505Smrgopt_preserve_dup_deps=false 105054b44505Smrgopt_features=false 105154b44505Smrgopt_finish=false 105254b44505Smrgopt_help=false 105354b44505Smrgopt_help_all=false 105454b44505Smrgopt_silent=: 105554b44505Smrgopt_verbose=: 105654b44505Smrgopt_silent=false 105754b44505Smrgopt_verbose=false 10584a041c5bSmacallan 105954b44505Smrg 106054b44505Smrg# Parse options once, thoroughly. This comes as soon as possible in the 106154b44505Smrg# script to make things like `--version' happen as quickly as we can. 106254b44505Smrg{ 106354b44505Smrg # this just eases exit handling 106454b44505Smrg while test $# -gt 0; do 106554b44505Smrg opt="$1" 106654b44505Smrg shift 106754b44505Smrg case $opt in 106854b44505Smrg --debug|-x) opt_debug='set -x' 106954b44505Smrg func_echo "enabling shell trace mode" 107054b44505Smrg $opt_debug 107154b44505Smrg ;; 107254b44505Smrg --dry-run|--dryrun|-n) 107354b44505Smrg opt_dry_run=: 107454b44505Smrg ;; 107554b44505Smrg --config) 107654b44505Smrg opt_config=: 107754b44505Smrgfunc_config 107854b44505Smrg ;; 107954b44505Smrg --dlopen|-dlopen) 108054b44505Smrg optarg="$1" 108154b44505Smrg opt_dlopen="${opt_dlopen+$opt_dlopen 108254b44505Smrg}$optarg" 108354b44505Smrg shift 108454b44505Smrg ;; 108554b44505Smrg --preserve-dup-deps) 108654b44505Smrg opt_preserve_dup_deps=: 108754b44505Smrg ;; 108854b44505Smrg --features) 108954b44505Smrg opt_features=: 109054b44505Smrgfunc_features 109154b44505Smrg ;; 109254b44505Smrg --finish) 109354b44505Smrg opt_finish=: 109454b44505Smrgset dummy --mode finish ${1+"$@"}; shift 109554b44505Smrg ;; 109654b44505Smrg --help) 109754b44505Smrg opt_help=: 109854b44505Smrg ;; 109954b44505Smrg --help-all) 110054b44505Smrg opt_help_all=: 110154b44505Smrgopt_help=': help-all' 110254b44505Smrg ;; 110354b44505Smrg --mode) 110454b44505Smrg test $# = 0 && func_missing_arg $opt && break 110554b44505Smrg optarg="$1" 110654b44505Smrg opt_mode="$optarg" 110754b44505Smrgcase $optarg in 110854b44505Smrg # Valid mode arguments: 110954b44505Smrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 111054b44505Smrg 111154b44505Smrg # Catch anything else as an error 111254b44505Smrg *) func_error "invalid argument for $opt" 111354b44505Smrg exit_cmd=exit 111454b44505Smrg break 111554b44505Smrg ;; 111654b44505Smrgesac 111754b44505Smrg shift 111854b44505Smrg ;; 111954b44505Smrg --no-silent|--no-quiet) 112054b44505Smrg opt_silent=false 112154b44505Smrgfunc_append preserve_args " $opt" 112254b44505Smrg ;; 112354b44505Smrg --no-verbose) 112454b44505Smrg opt_verbose=false 112554b44505Smrgfunc_append preserve_args " $opt" 112654b44505Smrg ;; 112754b44505Smrg --silent|--quiet) 112854b44505Smrg opt_silent=: 112954b44505Smrgfunc_append preserve_args " $opt" 113054b44505Smrg opt_verbose=false 113154b44505Smrg ;; 113254b44505Smrg --verbose|-v) 113354b44505Smrg opt_verbose=: 113454b44505Smrgfunc_append preserve_args " $opt" 113554b44505Smrgopt_silent=false 113654b44505Smrg ;; 113754b44505Smrg --tag) 113854b44505Smrg test $# = 0 && func_missing_arg $opt && break 113954b44505Smrg optarg="$1" 114054b44505Smrg opt_tag="$optarg" 114154b44505Smrgfunc_append preserve_args " $opt $optarg" 114254b44505Smrgfunc_enable_tag "$optarg" 114354b44505Smrg shift 114454b44505Smrg ;; 114554b44505Smrg 114654b44505Smrg -\?|-h) func_usage ;; 114754b44505Smrg --help) func_help ;; 114854b44505Smrg --version) func_version ;; 114954b44505Smrg 115054b44505Smrg # Separate optargs to long options: 115154b44505Smrg --*=*) 115254b44505Smrg func_split_long_opt "$opt" 115354b44505Smrg set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 115454b44505Smrg shift 115554b44505Smrg ;; 115654b44505Smrg 115754b44505Smrg # Separate non-argument short options: 115854b44505Smrg -\?*|-h*|-n*|-v*) 115954b44505Smrg func_split_short_opt "$opt" 116054b44505Smrg set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 116154b44505Smrg shift 116254b44505Smrg ;; 116354b44505Smrg 116454b44505Smrg --) break ;; 116554b44505Smrg -*) func_fatal_help "unrecognized option \`$opt'" ;; 116654b44505Smrg *) set dummy "$opt" ${1+"$@"}; shift; break ;; 11674a041c5bSmacallan esac 116854b44505Smrg done 11694a041c5bSmacallan 117054b44505Smrg # Validate options: 117154b44505Smrg 117254b44505Smrg # save first non-option argument 117354b44505Smrg if test "$#" -gt 0; then 117454b44505Smrg nonopt="$opt" 117554b44505Smrg shift 11764a041c5bSmacallan fi 11774a041c5bSmacallan 117854b44505Smrg # preserve --debug 117954b44505Smrg test "$opt_debug" = : || func_append preserve_args " --debug" 11804a041c5bSmacallan 118154b44505Smrg case $host in 118254b44505Smrg *cygwin* | *mingw* | *pw32* | *cegcc*) 118354b44505Smrg # don't eliminate duplications in $postdeps and $predeps 118454b44505Smrg opt_duplicate_compiler_generated_deps=: 118554b44505Smrg ;; 118654b44505Smrg *) 118754b44505Smrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 118854b44505Smrg ;; 118954b44505Smrg esac 11904a041c5bSmacallan 119154b44505Smrg $opt_help || { 119254b44505Smrg # Sanity checks first: 119354b44505Smrg func_check_version_match 11944a041c5bSmacallan 119554b44505Smrg if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 119654b44505Smrg func_fatal_configuration "not configured to build any kind of library" 119754b44505Smrg fi 11984a041c5bSmacallan 119954b44505Smrg # Darwin sucks 120054b44505Smrg eval std_shrext=\"$shrext_cmds\" 12014a041c5bSmacallan 120254b44505Smrg # Only execute mode is allowed to have -dlopen flags. 120354b44505Smrg if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 120454b44505Smrg func_error "unrecognized option \`-dlopen'" 120554b44505Smrg $ECHO "$help" 1>&2 120654b44505Smrg exit $EXIT_FAILURE 120754b44505Smrg fi 12084a041c5bSmacallan 120954b44505Smrg # Change the help message to a mode-specific one. 121054b44505Smrg generic_help="$help" 121154b44505Smrg help="Try \`$progname --help --mode=$opt_mode' for more information." 121254b44505Smrg } 12134a041c5bSmacallan 12144a041c5bSmacallan 121554b44505Smrg # Bail if the options were screwed 121654b44505Smrg $exit_cmd $EXIT_FAILURE 121754b44505Smrg} 12184a041c5bSmacallan 12194a041c5bSmacallan 12204a041c5bSmacallan 12214a041c5bSmacallan 122254b44505Smrg## ----------- ## 122354b44505Smrg## Main. ## 122454b44505Smrg## ----------- ## 12254a041c5bSmacallan 122654b44505Smrg# func_lalib_p file 122754b44505Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 122854b44505Smrg# This function is only a basic sanity check; it will hardly flush out 122954b44505Smrg# determined imposters. 123054b44505Smrgfunc_lalib_p () 123154b44505Smrg{ 123254b44505Smrg test -f "$1" && 123354b44505Smrg $SED -e 4q "$1" 2>/dev/null \ 123454b44505Smrg | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 123554b44505Smrg} 12364a041c5bSmacallan 123754b44505Smrg# func_lalib_unsafe_p file 123854b44505Smrg# True iff FILE is a libtool `.la' library or `.lo' object file. 123954b44505Smrg# This function implements the same check as func_lalib_p without 124054b44505Smrg# resorting to external programs. To this end, it redirects stdin and 124154b44505Smrg# closes it afterwards, without saving the original file descriptor. 124254b44505Smrg# As a safety measure, use it only where a negative result would be 124354b44505Smrg# fatal anyway. Works if `file' does not exist. 124454b44505Smrgfunc_lalib_unsafe_p () 124554b44505Smrg{ 124654b44505Smrg lalib_p=no 124754b44505Smrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 124854b44505Smrg for lalib_p_l in 1 2 3 4 124954b44505Smrg do 125054b44505Smrg read lalib_p_line 125154b44505Smrg case "$lalib_p_line" in 125254b44505Smrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 125354b44505Smrg esac 125454b44505Smrg done 125554b44505Smrg exec 0<&5 5<&- 125654b44505Smrg fi 125754b44505Smrg test "$lalib_p" = yes 125854b44505Smrg} 12594a041c5bSmacallan 126054b44505Smrg# func_ltwrapper_script_p file 126154b44505Smrg# True iff FILE is a libtool wrapper script 126254b44505Smrg# This function is only a basic sanity check; it will hardly flush out 126354b44505Smrg# determined imposters. 126454b44505Smrgfunc_ltwrapper_script_p () 126554b44505Smrg{ 126654b44505Smrg func_lalib_p "$1" 126754b44505Smrg} 12684a041c5bSmacallan 126954b44505Smrg# func_ltwrapper_executable_p file 127054b44505Smrg# True iff FILE is a libtool wrapper executable 127154b44505Smrg# This function is only a basic sanity check; it will hardly flush out 127254b44505Smrg# determined imposters. 127354b44505Smrgfunc_ltwrapper_executable_p () 127454b44505Smrg{ 127554b44505Smrg func_ltwrapper_exec_suffix= 127654b44505Smrg case $1 in 127754b44505Smrg *.exe) ;; 127854b44505Smrg *) func_ltwrapper_exec_suffix=.exe ;; 12794a041c5bSmacallan esac 128054b44505Smrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 128154b44505Smrg} 12824a041c5bSmacallan 128354b44505Smrg# func_ltwrapper_scriptname file 128454b44505Smrg# Assumes file is an ltwrapper_executable 128554b44505Smrg# uses $file to determine the appropriate filename for a 128654b44505Smrg# temporary ltwrapper_script. 128754b44505Smrgfunc_ltwrapper_scriptname () 128854b44505Smrg{ 128954b44505Smrg func_dirname_and_basename "$1" "" "." 129054b44505Smrg func_stripname '' '.exe' "$func_basename_result" 129154b44505Smrg func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 129254b44505Smrg} 12934a041c5bSmacallan 129454b44505Smrg# func_ltwrapper_p file 129554b44505Smrg# True iff FILE is a libtool wrapper script or wrapper executable 129654b44505Smrg# This function is only a basic sanity check; it will hardly flush out 129754b44505Smrg# determined imposters. 129854b44505Smrgfunc_ltwrapper_p () 129954b44505Smrg{ 130054b44505Smrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 130154b44505Smrg} 13024a041c5bSmacallan 13034a041c5bSmacallan 130454b44505Smrg# func_execute_cmds commands fail_cmd 130554b44505Smrg# Execute tilde-delimited COMMANDS. 130654b44505Smrg# If FAIL_CMD is given, eval that upon failure. 130754b44505Smrg# FAIL_CMD may read-access the current command in variable CMD! 130854b44505Smrgfunc_execute_cmds () 130954b44505Smrg{ 131054b44505Smrg $opt_debug 131154b44505Smrg save_ifs=$IFS; IFS='~' 131254b44505Smrg for cmd in $1; do 131354b44505Smrg IFS=$save_ifs 131454b44505Smrg eval cmd=\"$cmd\" 131554b44505Smrg func_show_eval "$cmd" "${2-:}" 13164a041c5bSmacallan done 131754b44505Smrg IFS=$save_ifs 131854b44505Smrg} 13194a041c5bSmacallan 13204a041c5bSmacallan 132154b44505Smrg# func_source file 132254b44505Smrg# Source FILE, adding directory component if necessary. 132354b44505Smrg# Note that it is not necessary on cygwin/mingw to append a dot to 132454b44505Smrg# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 132554b44505Smrg# behavior happens only for exec(3), not for open(2)! Also, sourcing 132654b44505Smrg# `FILE.' does not work on cygwin managed mounts. 132754b44505Smrgfunc_source () 132854b44505Smrg{ 132954b44505Smrg $opt_debug 133054b44505Smrg case $1 in 133154b44505Smrg */* | *\\*) . "$1" ;; 133254b44505Smrg *) . "./$1" ;; 133354b44505Smrg esac 133454b44505Smrg} 13354a041c5bSmacallan 13364a041c5bSmacallan 133754b44505Smrg# func_resolve_sysroot PATH 133854b44505Smrg# Replace a leading = in PATH with a sysroot. Store the result into 133954b44505Smrg# func_resolve_sysroot_result 134054b44505Smrgfunc_resolve_sysroot () 134154b44505Smrg{ 134254b44505Smrg func_resolve_sysroot_result=$1 134354b44505Smrg case $func_resolve_sysroot_result in 134454b44505Smrg =*) 134554b44505Smrg func_stripname '=' '' "$func_resolve_sysroot_result" 134654b44505Smrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 134754b44505Smrg ;; 134854b44505Smrg esac 134954b44505Smrg} 13504a041c5bSmacallan 135154b44505Smrg# func_replace_sysroot PATH 135254b44505Smrg# If PATH begins with the sysroot, replace it with = and 135354b44505Smrg# store the result into func_replace_sysroot_result. 135454b44505Smrgfunc_replace_sysroot () 135554b44505Smrg{ 135654b44505Smrg case "$lt_sysroot:$1" in 135754b44505Smrg ?*:"$lt_sysroot"*) 135854b44505Smrg func_stripname "$lt_sysroot" '' "$1" 135954b44505Smrg func_replace_sysroot_result="=$func_stripname_result" 136054b44505Smrg ;; 136154b44505Smrg *) 136254b44505Smrg # Including no sysroot. 136354b44505Smrg func_replace_sysroot_result=$1 136454b44505Smrg ;; 136554b44505Smrg esac 136654b44505Smrg} 13674a041c5bSmacallan 136854b44505Smrg# func_infer_tag arg 136954b44505Smrg# Infer tagged configuration to use if any are available and 137054b44505Smrg# if one wasn't chosen via the "--tag" command line option. 137154b44505Smrg# Only attempt this if the compiler in the base compile 137254b44505Smrg# command doesn't match the default compiler. 137354b44505Smrg# arg is usually of the form 'gcc ...' 137454b44505Smrgfunc_infer_tag () 137554b44505Smrg{ 137654b44505Smrg $opt_debug 137754b44505Smrg if test -n "$available_tags" && test -z "$tagname"; then 137854b44505Smrg CC_quoted= 137954b44505Smrg for arg in $CC; do 138054b44505Smrg func_append_quoted CC_quoted "$arg" 138154b44505Smrg done 138254b44505Smrg CC_expanded=`func_echo_all $CC` 138354b44505Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 138454b44505Smrg case $@ in 138554b44505Smrg # Blanks in the command may have been stripped by the calling shell, 138654b44505Smrg # but not from the CC environment variable when configure was run. 138754b44505Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 138854b44505Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 138954b44505Smrg # Blanks at the start of $base_compile will cause this to fail 139054b44505Smrg # if we don't check for them as well. 139154b44505Smrg *) 139254b44505Smrg for z in $available_tags; do 139354b44505Smrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 139454b44505Smrg # Evaluate the configuration. 139554b44505Smrg eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 139654b44505Smrg CC_quoted= 139754b44505Smrg for arg in $CC; do 139854b44505Smrg # Double-quote args containing other shell metacharacters. 139954b44505Smrg func_append_quoted CC_quoted "$arg" 140054b44505Smrg done 140154b44505Smrg CC_expanded=`func_echo_all $CC` 140254b44505Smrg CC_quoted_expanded=`func_echo_all $CC_quoted` 140354b44505Smrg case "$@ " in 140454b44505Smrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 140554b44505Smrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 140654b44505Smrg # The compiler in the base compile command matches 140754b44505Smrg # the one in the tagged configuration. 140854b44505Smrg # Assume this is the tagged configuration we want. 140954b44505Smrg tagname=$z 141054b44505Smrg break 141154b44505Smrg ;; 141254b44505Smrg esac 141354b44505Smrg fi 141454b44505Smrg done 141554b44505Smrg # If $tagname still isn't set, then no tagged configuration 141654b44505Smrg # was found and let the user know that the "--tag" command 141754b44505Smrg # line option must be used. 141854b44505Smrg if test -z "$tagname"; then 141954b44505Smrg func_echo "unable to infer tagged configuration" 142054b44505Smrg func_fatal_error "specify a tag with \`--tag'" 142154b44505Smrg# else 142254b44505Smrg# func_verbose "using $tagname tagged configuration" 142354b44505Smrg fi 142454b44505Smrg ;; 142554b44505Smrg esac 14264a041c5bSmacallan fi 142754b44505Smrg} 14284a041c5bSmacallan 14294a041c5bSmacallan 14304a041c5bSmacallan 143154b44505Smrg# func_write_libtool_object output_name pic_name nonpic_name 143254b44505Smrg# Create a libtool object file (analogous to a ".la" file), 143354b44505Smrg# but don't create it if we're doing a dry run. 143454b44505Smrgfunc_write_libtool_object () 143554b44505Smrg{ 143654b44505Smrg write_libobj=${1} 143754b44505Smrg if test "$build_libtool_libs" = yes; then 143854b44505Smrg write_lobj=\'${2}\' 143954b44505Smrg else 144054b44505Smrg write_lobj=none 14414a041c5bSmacallan fi 14424a041c5bSmacallan 144354b44505Smrg if test "$build_old_libs" = yes; then 144454b44505Smrg write_oldobj=\'${3}\' 144554b44505Smrg else 144654b44505Smrg write_oldobj=none 14474a041c5bSmacallan fi 14484a041c5bSmacallan 144954b44505Smrg $opt_dry_run || { 145054b44505Smrg cat >${write_libobj}T <<EOF 145154b44505Smrg# $write_libobj - a libtool object file 145254b44505Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 14534a041c5bSmacallan# 14544a041c5bSmacallan# Please DO NOT delete this file! 14554a041c5bSmacallan# It is necessary for linking the library. 14564a041c5bSmacallan 14574a041c5bSmacallan# Name of the PIC object. 145854b44505Smrgpic_object=$write_lobj 14594a041c5bSmacallan 146054b44505Smrg# Name of the non-PIC object 146154b44505Smrgnon_pic_object=$write_oldobj 14624a041c5bSmacallan 146354b44505SmrgEOF 146454b44505Smrg $MV "${write_libobj}T" "${write_libobj}" 146554b44505Smrg } 146654b44505Smrg} 14674a041c5bSmacallan 14684a041c5bSmacallan 146954b44505Smrg################################################## 147054b44505Smrg# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 147154b44505Smrg################################################## 14724a041c5bSmacallan 147354b44505Smrg# func_convert_core_file_wine_to_w32 ARG 147454b44505Smrg# Helper function used by file name conversion functions when $build is *nix, 147554b44505Smrg# and $host is mingw, cygwin, or some other w32 environment. Relies on a 147654b44505Smrg# correctly configured wine environment available, with the winepath program 147754b44505Smrg# in $build's $PATH. 147854b44505Smrg# 147954b44505Smrg# ARG is the $build file name to be converted to w32 format. 148054b44505Smrg# Result is available in $func_convert_core_file_wine_to_w32_result, and will 148154b44505Smrg# be empty on error (or when ARG is empty) 148254b44505Smrgfunc_convert_core_file_wine_to_w32 () 148354b44505Smrg{ 148454b44505Smrg $opt_debug 148554b44505Smrg func_convert_core_file_wine_to_w32_result="$1" 148654b44505Smrg if test -n "$1"; then 148754b44505Smrg # Unfortunately, winepath does not exit with a non-zero error code, so we 148854b44505Smrg # are forced to check the contents of stdout. On the other hand, if the 148954b44505Smrg # command is not found, the shell will set an exit code of 127 and print 149054b44505Smrg # *an error message* to stdout. So we must check for both error code of 149154b44505Smrg # zero AND non-empty stdout, which explains the odd construction: 149254b44505Smrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 149354b44505Smrg if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 149454b44505Smrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 149554b44505Smrg $SED -e "$lt_sed_naive_backslashify"` 149654b44505Smrg else 149754b44505Smrg func_convert_core_file_wine_to_w32_result= 149854b44505Smrg fi 149954b44505Smrg fi 150054b44505Smrg} 150154b44505Smrg# end: func_convert_core_file_wine_to_w32 15024a041c5bSmacallan 150354b44505Smrg 150454b44505Smrg# func_convert_core_path_wine_to_w32 ARG 150554b44505Smrg# Helper function used by path conversion functions when $build is *nix, and 150654b44505Smrg# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 150754b44505Smrg# configured wine environment available, with the winepath program in $build's 150854b44505Smrg# $PATH. Assumes ARG has no leading or trailing path separator characters. 150954b44505Smrg# 151054b44505Smrg# ARG is path to be converted from $build format to win32. 151154b44505Smrg# Result is available in $func_convert_core_path_wine_to_w32_result. 151254b44505Smrg# Unconvertible file (directory) names in ARG are skipped; if no directory names 151354b44505Smrg# are convertible, then the result may be empty. 151454b44505Smrgfunc_convert_core_path_wine_to_w32 () 151554b44505Smrg{ 151654b44505Smrg $opt_debug 151754b44505Smrg # unfortunately, winepath doesn't convert paths, only file names 151854b44505Smrg func_convert_core_path_wine_to_w32_result="" 151954b44505Smrg if test -n "$1"; then 152054b44505Smrg oldIFS=$IFS 152154b44505Smrg IFS=: 152254b44505Smrg for func_convert_core_path_wine_to_w32_f in $1; do 152354b44505Smrg IFS=$oldIFS 152454b44505Smrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 152554b44505Smrg if test -n "$func_convert_core_file_wine_to_w32_result" ; then 152654b44505Smrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 152754b44505Smrg func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 152854b44505Smrg else 152954b44505Smrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 153054b44505Smrg fi 15314a041c5bSmacallan fi 153254b44505Smrg done 153354b44505Smrg IFS=$oldIFS 153454b44505Smrg fi 153554b44505Smrg} 153654b44505Smrg# end: func_convert_core_path_wine_to_w32 153754b44505Smrg 153854b44505Smrg 153954b44505Smrg# func_cygpath ARGS... 154054b44505Smrg# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 154154b44505Smrg# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 154254b44505Smrg# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 154354b44505Smrg# (2), returns the Cygwin file name or path in func_cygpath_result (input 154454b44505Smrg# file name or path is assumed to be in w32 format, as previously converted 154554b44505Smrg# from $build's *nix or MSYS format). In case (3), returns the w32 file name 154654b44505Smrg# or path in func_cygpath_result (input file name or path is assumed to be in 154754b44505Smrg# Cygwin format). Returns an empty string on error. 154854b44505Smrg# 154954b44505Smrg# ARGS are passed to cygpath, with the last one being the file name or path to 155054b44505Smrg# be converted. 155154b44505Smrg# 155254b44505Smrg# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 155354b44505Smrg# environment variable; do not put it in $PATH. 155454b44505Smrgfunc_cygpath () 155554b44505Smrg{ 155654b44505Smrg $opt_debug 155754b44505Smrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 155854b44505Smrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 155954b44505Smrg if test "$?" -ne 0; then 156054b44505Smrg # on failure, ensure result is empty 156154b44505Smrg func_cygpath_result= 156254b44505Smrg fi 156354b44505Smrg else 156454b44505Smrg func_cygpath_result= 156554b44505Smrg func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 156654b44505Smrg fi 156754b44505Smrg} 156854b44505Smrg#end: func_cygpath 15694a041c5bSmacallan 15704a041c5bSmacallan 157154b44505Smrg# func_convert_core_msys_to_w32 ARG 157254b44505Smrg# Convert file name or path ARG from MSYS format to w32 format. Return 157354b44505Smrg# result in func_convert_core_msys_to_w32_result. 157454b44505Smrgfunc_convert_core_msys_to_w32 () 157554b44505Smrg{ 157654b44505Smrg $opt_debug 157754b44505Smrg # awkward: cmd appends spaces to result 157854b44505Smrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 157954b44505Smrg $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 158054b44505Smrg} 158154b44505Smrg#end: func_convert_core_msys_to_w32 15824a041c5bSmacallan 15834a041c5bSmacallan 158454b44505Smrg# func_convert_file_check ARG1 ARG2 158554b44505Smrg# Verify that ARG1 (a file name in $build format) was converted to $host 158654b44505Smrg# format in ARG2. Otherwise, emit an error message, but continue (resetting 158754b44505Smrg# func_to_host_file_result to ARG1). 158854b44505Smrgfunc_convert_file_check () 158954b44505Smrg{ 159054b44505Smrg $opt_debug 159154b44505Smrg if test -z "$2" && test -n "$1" ; then 159254b44505Smrg func_error "Could not determine host file name corresponding to" 159354b44505Smrg func_error " \`$1'" 159454b44505Smrg func_error "Continuing, but uninstalled executables may not work." 159554b44505Smrg # Fallback: 159654b44505Smrg func_to_host_file_result="$1" 159754b44505Smrg fi 159854b44505Smrg} 159954b44505Smrg# end func_convert_file_check 16004a041c5bSmacallan 16014a041c5bSmacallan 160254b44505Smrg# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 160354b44505Smrg# Verify that FROM_PATH (a path in $build format) was converted to $host 160454b44505Smrg# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 160554b44505Smrg# func_to_host_file_result to a simplistic fallback value (see below). 160654b44505Smrgfunc_convert_path_check () 160754b44505Smrg{ 160854b44505Smrg $opt_debug 160954b44505Smrg if test -z "$4" && test -n "$3"; then 161054b44505Smrg func_error "Could not determine the host path corresponding to" 161154b44505Smrg func_error " \`$3'" 161254b44505Smrg func_error "Continuing, but uninstalled executables may not work." 161354b44505Smrg # Fallback. This is a deliberately simplistic "conversion" and 161454b44505Smrg # should not be "improved". See libtool.info. 161554b44505Smrg if test "x$1" != "x$2"; then 161654b44505Smrg lt_replace_pathsep_chars="s|$1|$2|g" 161754b44505Smrg func_to_host_path_result=`echo "$3" | 161854b44505Smrg $SED -e "$lt_replace_pathsep_chars"` 161954b44505Smrg else 162054b44505Smrg func_to_host_path_result="$3" 162154b44505Smrg fi 162254b44505Smrg fi 162354b44505Smrg} 162454b44505Smrg# end func_convert_path_check 16254a041c5bSmacallan 16264a041c5bSmacallan 162754b44505Smrg# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 162854b44505Smrg# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 162954b44505Smrg# and appending REPL if ORIG matches BACKPAT. 163054b44505Smrgfunc_convert_path_front_back_pathsep () 163154b44505Smrg{ 163254b44505Smrg $opt_debug 163354b44505Smrg case $4 in 163454b44505Smrg $1 ) func_to_host_path_result="$3$func_to_host_path_result" 163554b44505Smrg ;; 163654b44505Smrg esac 163754b44505Smrg case $4 in 163854b44505Smrg $2 ) func_append func_to_host_path_result "$3" 163954b44505Smrg ;; 164054b44505Smrg esac 164154b44505Smrg} 164254b44505Smrg# end func_convert_path_front_back_pathsep 16434a041c5bSmacallan 16444a041c5bSmacallan 164554b44505Smrg################################################## 164654b44505Smrg# $build to $host FILE NAME CONVERSION FUNCTIONS # 164754b44505Smrg################################################## 164854b44505Smrg# invoked via `$to_host_file_cmd ARG' 164954b44505Smrg# 165054b44505Smrg# In each case, ARG is the path to be converted from $build to $host format. 165154b44505Smrg# Result will be available in $func_to_host_file_result. 16524a041c5bSmacallan 16534a041c5bSmacallan 165454b44505Smrg# func_to_host_file ARG 165554b44505Smrg# Converts the file name ARG from $build format to $host format. Return result 165654b44505Smrg# in func_to_host_file_result. 165754b44505Smrgfunc_to_host_file () 165854b44505Smrg{ 165954b44505Smrg $opt_debug 166054b44505Smrg $to_host_file_cmd "$1" 166154b44505Smrg} 166254b44505Smrg# end func_to_host_file 16634a041c5bSmacallan 16644a041c5bSmacallan 166554b44505Smrg# func_to_tool_file ARG LAZY 166654b44505Smrg# converts the file name ARG from $build format to toolchain format. Return 166754b44505Smrg# result in func_to_tool_file_result. If the conversion in use is listed 166854b44505Smrg# in (the comma separated) LAZY, no conversion takes place. 166954b44505Smrgfunc_to_tool_file () 167054b44505Smrg{ 167154b44505Smrg $opt_debug 167254b44505Smrg case ,$2, in 167354b44505Smrg *,"$to_tool_file_cmd",*) 167454b44505Smrg func_to_tool_file_result=$1 167554b44505Smrg ;; 167654b44505Smrg *) 167754b44505Smrg $to_tool_file_cmd "$1" 167854b44505Smrg func_to_tool_file_result=$func_to_host_file_result 167954b44505Smrg ;; 168054b44505Smrg esac 168154b44505Smrg} 168254b44505Smrg# end func_to_tool_file 16834a041c5bSmacallan 16844a041c5bSmacallan 168554b44505Smrg# func_convert_file_noop ARG 168654b44505Smrg# Copy ARG to func_to_host_file_result. 168754b44505Smrgfunc_convert_file_noop () 168854b44505Smrg{ 168954b44505Smrg func_to_host_file_result="$1" 169054b44505Smrg} 169154b44505Smrg# end func_convert_file_noop 16924a041c5bSmacallan 16934a041c5bSmacallan 169454b44505Smrg# func_convert_file_msys_to_w32 ARG 169554b44505Smrg# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 169654b44505Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 169754b44505Smrg# func_to_host_file_result. 169854b44505Smrgfunc_convert_file_msys_to_w32 () 169954b44505Smrg{ 170054b44505Smrg $opt_debug 170154b44505Smrg func_to_host_file_result="$1" 170254b44505Smrg if test -n "$1"; then 170354b44505Smrg func_convert_core_msys_to_w32 "$1" 170454b44505Smrg func_to_host_file_result="$func_convert_core_msys_to_w32_result" 170554b44505Smrg fi 170654b44505Smrg func_convert_file_check "$1" "$func_to_host_file_result" 170754b44505Smrg} 170854b44505Smrg# end func_convert_file_msys_to_w32 17094a041c5bSmacallan 17104a041c5bSmacallan 171154b44505Smrg# func_convert_file_cygwin_to_w32 ARG 171254b44505Smrg# Convert file name ARG from Cygwin to w32 format. Returns result in 171354b44505Smrg# func_to_host_file_result. 171454b44505Smrgfunc_convert_file_cygwin_to_w32 () 171554b44505Smrg{ 171654b44505Smrg $opt_debug 171754b44505Smrg func_to_host_file_result="$1" 171854b44505Smrg if test -n "$1"; then 171954b44505Smrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 172054b44505Smrg # LT_CYGPATH in this case. 172154b44505Smrg func_to_host_file_result=`cygpath -m "$1"` 172254b44505Smrg fi 172354b44505Smrg func_convert_file_check "$1" "$func_to_host_file_result" 172454b44505Smrg} 172554b44505Smrg# end func_convert_file_cygwin_to_w32 17264a041c5bSmacallan 17274a041c5bSmacallan 172854b44505Smrg# func_convert_file_nix_to_w32 ARG 172954b44505Smrg# Convert file name ARG from *nix to w32 format. Requires a wine environment 173054b44505Smrg# and a working winepath. Returns result in func_to_host_file_result. 173154b44505Smrgfunc_convert_file_nix_to_w32 () 173254b44505Smrg{ 173354b44505Smrg $opt_debug 173454b44505Smrg func_to_host_file_result="$1" 173554b44505Smrg if test -n "$1"; then 173654b44505Smrg func_convert_core_file_wine_to_w32 "$1" 173754b44505Smrg func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 173854b44505Smrg fi 173954b44505Smrg func_convert_file_check "$1" "$func_to_host_file_result" 174054b44505Smrg} 174154b44505Smrg# end func_convert_file_nix_to_w32 17424a041c5bSmacallan 17434a041c5bSmacallan 174454b44505Smrg# func_convert_file_msys_to_cygwin ARG 174554b44505Smrg# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 174654b44505Smrg# Returns result in func_to_host_file_result. 174754b44505Smrgfunc_convert_file_msys_to_cygwin () 174854b44505Smrg{ 174954b44505Smrg $opt_debug 175054b44505Smrg func_to_host_file_result="$1" 175154b44505Smrg if test -n "$1"; then 175254b44505Smrg func_convert_core_msys_to_w32 "$1" 175354b44505Smrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 175454b44505Smrg func_to_host_file_result="$func_cygpath_result" 175554b44505Smrg fi 175654b44505Smrg func_convert_file_check "$1" "$func_to_host_file_result" 175754b44505Smrg} 175854b44505Smrg# end func_convert_file_msys_to_cygwin 17594a041c5bSmacallan 17604a041c5bSmacallan 176154b44505Smrg# func_convert_file_nix_to_cygwin ARG 176254b44505Smrg# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 176354b44505Smrg# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 176454b44505Smrg# in func_to_host_file_result. 176554b44505Smrgfunc_convert_file_nix_to_cygwin () 176654b44505Smrg{ 176754b44505Smrg $opt_debug 176854b44505Smrg func_to_host_file_result="$1" 176954b44505Smrg if test -n "$1"; then 177054b44505Smrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 177154b44505Smrg func_convert_core_file_wine_to_w32 "$1" 177254b44505Smrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 177354b44505Smrg func_to_host_file_result="$func_cygpath_result" 177454b44505Smrg fi 177554b44505Smrg func_convert_file_check "$1" "$func_to_host_file_result" 177654b44505Smrg} 177754b44505Smrg# end func_convert_file_nix_to_cygwin 17784a041c5bSmacallan 17794a041c5bSmacallan 178054b44505Smrg############################################# 178154b44505Smrg# $build to $host PATH CONVERSION FUNCTIONS # 178254b44505Smrg############################################# 178354b44505Smrg# invoked via `$to_host_path_cmd ARG' 178454b44505Smrg# 178554b44505Smrg# In each case, ARG is the path to be converted from $build to $host format. 178654b44505Smrg# The result will be available in $func_to_host_path_result. 178754b44505Smrg# 178854b44505Smrg# Path separators are also converted from $build format to $host format. If 178954b44505Smrg# ARG begins or ends with a path separator character, it is preserved (but 179054b44505Smrg# converted to $host format) on output. 179154b44505Smrg# 179254b44505Smrg# All path conversion functions are named using the following convention: 179354b44505Smrg# file name conversion function : func_convert_file_X_to_Y () 179454b44505Smrg# path conversion function : func_convert_path_X_to_Y () 179554b44505Smrg# where, for any given $build/$host combination the 'X_to_Y' value is the 179654b44505Smrg# same. If conversion functions are added for new $build/$host combinations, 179754b44505Smrg# the two new functions must follow this pattern, or func_init_to_host_path_cmd 179854b44505Smrg# will break. 179954b44505Smrg 180054b44505Smrg 180154b44505Smrg# func_init_to_host_path_cmd 180254b44505Smrg# Ensures that function "pointer" variable $to_host_path_cmd is set to the 180354b44505Smrg# appropriate value, based on the value of $to_host_file_cmd. 180454b44505Smrgto_host_path_cmd= 180554b44505Smrgfunc_init_to_host_path_cmd () 180654b44505Smrg{ 180754b44505Smrg $opt_debug 180854b44505Smrg if test -z "$to_host_path_cmd"; then 180954b44505Smrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 181054b44505Smrg to_host_path_cmd="func_convert_path_${func_stripname_result}" 181154b44505Smrg fi 181254b44505Smrg} 18134a041c5bSmacallan 18144a041c5bSmacallan 181554b44505Smrg# func_to_host_path ARG 181654b44505Smrg# Converts the path ARG from $build format to $host format. Return result 181754b44505Smrg# in func_to_host_path_result. 181854b44505Smrgfunc_to_host_path () 181954b44505Smrg{ 182054b44505Smrg $opt_debug 182154b44505Smrg func_init_to_host_path_cmd 182254b44505Smrg $to_host_path_cmd "$1" 182354b44505Smrg} 182454b44505Smrg# end func_to_host_path 18254a041c5bSmacallan 18264a041c5bSmacallan 182754b44505Smrg# func_convert_path_noop ARG 182854b44505Smrg# Copy ARG to func_to_host_path_result. 182954b44505Smrgfunc_convert_path_noop () 183054b44505Smrg{ 183154b44505Smrg func_to_host_path_result="$1" 183254b44505Smrg} 183354b44505Smrg# end func_convert_path_noop 18344a041c5bSmacallan 18354a041c5bSmacallan 183654b44505Smrg# func_convert_path_msys_to_w32 ARG 183754b44505Smrg# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 183854b44505Smrg# conversion to w32 is not available inside the cwrapper. Returns result in 183954b44505Smrg# func_to_host_path_result. 184054b44505Smrgfunc_convert_path_msys_to_w32 () 184154b44505Smrg{ 184254b44505Smrg $opt_debug 184354b44505Smrg func_to_host_path_result="$1" 184454b44505Smrg if test -n "$1"; then 184554b44505Smrg # Remove leading and trailing path separator characters from ARG. MSYS 184654b44505Smrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 184754b44505Smrg # and winepath ignores them completely. 184854b44505Smrg func_stripname : : "$1" 184954b44505Smrg func_to_host_path_tmp1=$func_stripname_result 185054b44505Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 185154b44505Smrg func_to_host_path_result="$func_convert_core_msys_to_w32_result" 185254b44505Smrg func_convert_path_check : ";" \ 185354b44505Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 185454b44505Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 185554b44505Smrg fi 185654b44505Smrg} 185754b44505Smrg# end func_convert_path_msys_to_w32 18584a041c5bSmacallan 18594a041c5bSmacallan 186054b44505Smrg# func_convert_path_cygwin_to_w32 ARG 186154b44505Smrg# Convert path ARG from Cygwin to w32 format. Returns result in 186254b44505Smrg# func_to_host_file_result. 186354b44505Smrgfunc_convert_path_cygwin_to_w32 () 186454b44505Smrg{ 186554b44505Smrg $opt_debug 186654b44505Smrg func_to_host_path_result="$1" 186754b44505Smrg if test -n "$1"; then 186854b44505Smrg # See func_convert_path_msys_to_w32: 186954b44505Smrg func_stripname : : "$1" 187054b44505Smrg func_to_host_path_tmp1=$func_stripname_result 187154b44505Smrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 187254b44505Smrg func_convert_path_check : ";" \ 187354b44505Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 187454b44505Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 187554b44505Smrg fi 187654b44505Smrg} 187754b44505Smrg# end func_convert_path_cygwin_to_w32 18784a041c5bSmacallan 18794a041c5bSmacallan 188054b44505Smrg# func_convert_path_nix_to_w32 ARG 188154b44505Smrg# Convert path ARG from *nix to w32 format. Requires a wine environment and 188254b44505Smrg# a working winepath. Returns result in func_to_host_file_result. 188354b44505Smrgfunc_convert_path_nix_to_w32 () 188454b44505Smrg{ 188554b44505Smrg $opt_debug 188654b44505Smrg func_to_host_path_result="$1" 188754b44505Smrg if test -n "$1"; then 188854b44505Smrg # See func_convert_path_msys_to_w32: 188954b44505Smrg func_stripname : : "$1" 189054b44505Smrg func_to_host_path_tmp1=$func_stripname_result 189154b44505Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 189254b44505Smrg func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 189354b44505Smrg func_convert_path_check : ";" \ 189454b44505Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 189554b44505Smrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 189654b44505Smrg fi 189754b44505Smrg} 189854b44505Smrg# end func_convert_path_nix_to_w32 18994a041c5bSmacallan 19004a041c5bSmacallan 190154b44505Smrg# func_convert_path_msys_to_cygwin ARG 190254b44505Smrg# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 190354b44505Smrg# Returns result in func_to_host_file_result. 190454b44505Smrgfunc_convert_path_msys_to_cygwin () 190554b44505Smrg{ 190654b44505Smrg $opt_debug 190754b44505Smrg func_to_host_path_result="$1" 190854b44505Smrg if test -n "$1"; then 190954b44505Smrg # See func_convert_path_msys_to_w32: 191054b44505Smrg func_stripname : : "$1" 191154b44505Smrg func_to_host_path_tmp1=$func_stripname_result 191254b44505Smrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 191354b44505Smrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 191454b44505Smrg func_to_host_path_result="$func_cygpath_result" 191554b44505Smrg func_convert_path_check : : \ 191654b44505Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 191754b44505Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 191854b44505Smrg fi 191954b44505Smrg} 192054b44505Smrg# end func_convert_path_msys_to_cygwin 19214a041c5bSmacallan 19224a041c5bSmacallan 192354b44505Smrg# func_convert_path_nix_to_cygwin ARG 192454b44505Smrg# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 192554b44505Smrg# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 192654b44505Smrg# func_to_host_file_result. 192754b44505Smrgfunc_convert_path_nix_to_cygwin () 192854b44505Smrg{ 192954b44505Smrg $opt_debug 193054b44505Smrg func_to_host_path_result="$1" 193154b44505Smrg if test -n "$1"; then 193254b44505Smrg # Remove leading and trailing path separator characters from 193354b44505Smrg # ARG. msys behavior is inconsistent here, cygpath turns them 193454b44505Smrg # into '.;' and ';.', and winepath ignores them completely. 193554b44505Smrg func_stripname : : "$1" 193654b44505Smrg func_to_host_path_tmp1=$func_stripname_result 193754b44505Smrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 193854b44505Smrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 193954b44505Smrg func_to_host_path_result="$func_cygpath_result" 194054b44505Smrg func_convert_path_check : : \ 194154b44505Smrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 194254b44505Smrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 194354b44505Smrg fi 194454b44505Smrg} 194554b44505Smrg# end func_convert_path_nix_to_cygwin 19464a041c5bSmacallan 19474a041c5bSmacallan 194854b44505Smrg# func_mode_compile arg... 194954b44505Smrgfunc_mode_compile () 195054b44505Smrg{ 195154b44505Smrg $opt_debug 195254b44505Smrg # Get the compilation command and the source file. 195354b44505Smrg base_compile= 195454b44505Smrg srcfile="$nonopt" # always keep a non-empty value in "srcfile" 195554b44505Smrg suppress_opt=yes 195654b44505Smrg suppress_output= 195754b44505Smrg arg_mode=normal 195854b44505Smrg libobj= 195954b44505Smrg later= 196054b44505Smrg pie_flag= 196154b44505Smrg 196254b44505Smrg for arg 196354b44505Smrg do 196454b44505Smrg case $arg_mode in 196554b44505Smrg arg ) 196654b44505Smrg # do not "continue". Instead, add this to base_compile 196754b44505Smrg lastarg="$arg" 196854b44505Smrg arg_mode=normal 196954b44505Smrg ;; 197054b44505Smrg 197154b44505Smrg target ) 197254b44505Smrg libobj="$arg" 197354b44505Smrg arg_mode=normal 197454b44505Smrg continue 197554b44505Smrg ;; 197654b44505Smrg 197754b44505Smrg normal ) 197854b44505Smrg # Accept any command-line options. 197954b44505Smrg case $arg in 198054b44505Smrg -o) 198154b44505Smrg test -n "$libobj" && \ 198254b44505Smrg func_fatal_error "you cannot specify \`-o' more than once" 198354b44505Smrg arg_mode=target 19844a041c5bSmacallan continue 19854a041c5bSmacallan ;; 198654b44505Smrg 198754b44505Smrg -pie | -fpie | -fPIE) 198854b44505Smrg func_append pie_flag " $arg" 19894a041c5bSmacallan continue 19904a041c5bSmacallan ;; 199154b44505Smrg 199254b44505Smrg -shared | -static | -prefer-pic | -prefer-non-pic) 199354b44505Smrg func_append later " $arg" 19944a041c5bSmacallan continue 19954a041c5bSmacallan ;; 199654b44505Smrg 199754b44505Smrg -no-suppress) 199854b44505Smrg suppress_opt=no 19994a041c5bSmacallan continue 20004a041c5bSmacallan ;; 20014a041c5bSmacallan 200254b44505Smrg -Xcompiler) 200354b44505Smrg arg_mode=arg # the next one goes into the "base_compile" arg list 200454b44505Smrg continue # The current "srcfile" will either be retained or 200554b44505Smrg ;; # replaced later. I would guess that would be a bug. 20064a041c5bSmacallan 200754b44505Smrg -Wc,*) 200854b44505Smrg func_stripname '-Wc,' '' "$arg" 200954b44505Smrg args=$func_stripname_result 201054b44505Smrg lastarg= 201154b44505Smrg save_ifs="$IFS"; IFS=',' 201254b44505Smrg for arg in $args; do 201354b44505Smrg IFS="$save_ifs" 201454b44505Smrg func_append_quoted lastarg "$arg" 201554b44505Smrg done 201654b44505Smrg IFS="$save_ifs" 201754b44505Smrg func_stripname ' ' '' "$lastarg" 201854b44505Smrg lastarg=$func_stripname_result 20194a041c5bSmacallan 202054b44505Smrg # Add the arguments to base_compile. 202154b44505Smrg func_append base_compile " $lastarg" 202254b44505Smrg continue 202354b44505Smrg ;; 20244a041c5bSmacallan 202554b44505Smrg *) 202654b44505Smrg # Accept the current argument as the source file. 202754b44505Smrg # The previous "srcfile" becomes the current argument. 202854b44505Smrg # 202954b44505Smrg lastarg="$srcfile" 203054b44505Smrg srcfile="$arg" 203154b44505Smrg ;; 203254b44505Smrg esac # case $arg 20334a041c5bSmacallan ;; 203454b44505Smrg esac # case $arg_mode 20354a041c5bSmacallan 203654b44505Smrg # Aesthetically quote the previous argument. 203754b44505Smrg func_append_quoted base_compile "$lastarg" 203854b44505Smrg done # for arg 20394a041c5bSmacallan 204054b44505Smrg case $arg_mode in 204154b44505Smrg arg) 204254b44505Smrg func_fatal_error "you must specify an argument for -Xcompile" 204354b44505Smrg ;; 204454b44505Smrg target) 204554b44505Smrg func_fatal_error "you must specify a target with \`-o'" 204654b44505Smrg ;; 204754b44505Smrg *) 204854b44505Smrg # Get the name of the library object. 204954b44505Smrg test -z "$libobj" && { 205054b44505Smrg func_basename "$srcfile" 205154b44505Smrg libobj="$func_basename_result" 205254b44505Smrg } 205354b44505Smrg ;; 205454b44505Smrg esac 20554a041c5bSmacallan 205654b44505Smrg # Recognize several different file suffixes. 205754b44505Smrg # If the user specifies -o file.o, it is replaced with file.lo 205854b44505Smrg case $libobj in 205954b44505Smrg *.[cCFSifmso] | \ 206054b44505Smrg *.ada | *.adb | *.ads | *.asm | \ 206154b44505Smrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 206254b44505Smrg *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) 206354b44505Smrg func_xform "$libobj" 206454b44505Smrg libobj=$func_xform_result 206554b44505Smrg ;; 206654b44505Smrg esac 20674a041c5bSmacallan 206854b44505Smrg case $libobj in 206954b44505Smrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 207054b44505Smrg *) 207154b44505Smrg func_fatal_error "cannot determine name of library object from \`$libobj'" 207254b44505Smrg ;; 207354b44505Smrg esac 20744a041c5bSmacallan 207554b44505Smrg func_infer_tag $base_compile 20764a041c5bSmacallan 207754b44505Smrg for arg in $later; do 207854b44505Smrg case $arg in 207954b44505Smrg -shared) 208054b44505Smrg test "$build_libtool_libs" != yes && \ 208154b44505Smrg func_fatal_configuration "can not build a shared library" 208254b44505Smrg build_old_libs=no 20834a041c5bSmacallan continue 20844a041c5bSmacallan ;; 20854a041c5bSmacallan 208654b44505Smrg -static) 208754b44505Smrg build_libtool_libs=no 208854b44505Smrg build_old_libs=yes 20894a041c5bSmacallan continue 20904a041c5bSmacallan ;; 20914a041c5bSmacallan 209254b44505Smrg -prefer-pic) 209354b44505Smrg pic_mode=yes 20944a041c5bSmacallan continue 20954a041c5bSmacallan ;; 20964a041c5bSmacallan 209754b44505Smrg -prefer-non-pic) 209854b44505Smrg pic_mode=no 20994a041c5bSmacallan continue 21004a041c5bSmacallan ;; 210154b44505Smrg esac 210254b44505Smrg done 21034a041c5bSmacallan 210454b44505Smrg func_quote_for_eval "$libobj" 210554b44505Smrg test "X$libobj" != "X$func_quote_for_eval_result" \ 210654b44505Smrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 210754b44505Smrg && func_warning "libobj name \`$libobj' may not contain shell special characters." 210854b44505Smrg func_dirname_and_basename "$obj" "/" "" 210954b44505Smrg objname="$func_basename_result" 211054b44505Smrg xdir="$func_dirname_result" 211154b44505Smrg lobj=${xdir}$objdir/$objname 21124a041c5bSmacallan 211354b44505Smrg test -z "$base_compile" && \ 211454b44505Smrg func_fatal_help "you must specify a compilation command" 21154a041c5bSmacallan 211654b44505Smrg # Delete any leftover library objects. 211754b44505Smrg if test "$build_old_libs" = yes; then 211854b44505Smrg removelist="$obj $lobj $libobj ${libobj}T" 211954b44505Smrg else 212054b44505Smrg removelist="$lobj $libobj ${libobj}T" 212154b44505Smrg fi 21224a041c5bSmacallan 212354b44505Smrg # On Cygwin there's no "real" PIC flag so we must build both object types 212454b44505Smrg case $host_os in 212554b44505Smrg cygwin* | mingw* | pw32* | os2* | cegcc*) 212654b44505Smrg pic_mode=default 212754b44505Smrg ;; 212854b44505Smrg esac 212954b44505Smrg if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 213054b44505Smrg # non-PIC code in shared libraries is not supported 213154b44505Smrg pic_mode=default 213254b44505Smrg fi 21334a041c5bSmacallan 213454b44505Smrg # Calculate the filename of the output object if compiler does 213554b44505Smrg # not support -o with -c 213654b44505Smrg if test "$compiler_c_o" = no; then 213754b44505Smrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 213854b44505Smrg lockfile="$output_obj.lock" 213954b44505Smrg else 214054b44505Smrg output_obj= 214154b44505Smrg need_locks=no 214254b44505Smrg lockfile= 214354b44505Smrg fi 21444a041c5bSmacallan 214554b44505Smrg # Lock this critical section if it is needed 214654b44505Smrg # We use this script file to make the link, it avoids creating a new file 214754b44505Smrg if test "$need_locks" = yes; then 214854b44505Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 214954b44505Smrg func_echo "Waiting for $lockfile to be removed" 215054b44505Smrg sleep 2 215154b44505Smrg done 215254b44505Smrg elif test "$need_locks" = warn; then 215354b44505Smrg if test -f "$lockfile"; then 215454b44505Smrg $ECHO "\ 215554b44505Smrg*** ERROR, $lockfile exists and contains: 215654b44505Smrg`cat $lockfile 2>/dev/null` 21574a041c5bSmacallan 215854b44505SmrgThis indicates that another process is trying to use the same 215954b44505Smrgtemporary object file, and libtool could not work around it because 216054b44505Smrgyour compiler does not support \`-c' and \`-o' together. If you 216154b44505Smrgrepeat this compilation, it may succeed, by chance, but you had better 216254b44505Smrgavoid parallel builds (make -j) in this platform, or get a better 216354b44505Smrgcompiler." 21644a041c5bSmacallan 216554b44505Smrg $opt_dry_run || $RM $removelist 216654b44505Smrg exit $EXIT_FAILURE 216754b44505Smrg fi 216854b44505Smrg func_append removelist " $output_obj" 216954b44505Smrg $ECHO "$srcfile" > "$lockfile" 217054b44505Smrg fi 21714a041c5bSmacallan 217254b44505Smrg $opt_dry_run || $RM $removelist 217354b44505Smrg func_append removelist " $lockfile" 217454b44505Smrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 21754a041c5bSmacallan 217654b44505Smrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 217754b44505Smrg srcfile=$func_to_tool_file_result 217854b44505Smrg func_quote_for_eval "$srcfile" 217954b44505Smrg qsrcfile=$func_quote_for_eval_result 21804a041c5bSmacallan 218154b44505Smrg # Only build a PIC object if we are building libtool libraries. 218254b44505Smrg if test "$build_libtool_libs" = yes; then 218354b44505Smrg # Without this assignment, base_compile gets emptied. 218454b44505Smrg fbsd_hideous_sh_bug=$base_compile 21854a041c5bSmacallan 218654b44505Smrg if test "$pic_mode" != no; then 218754b44505Smrg command="$base_compile $qsrcfile $pic_flag" 218854b44505Smrg else 218954b44505Smrg # Don't build PIC code 219054b44505Smrg command="$base_compile $qsrcfile" 219154b44505Smrg fi 21924a041c5bSmacallan 219354b44505Smrg func_mkdir_p "$xdir$objdir" 21944a041c5bSmacallan 219554b44505Smrg if test -z "$output_obj"; then 219654b44505Smrg # Place PIC objects in $objdir 219754b44505Smrg func_append command " -o $lobj" 219854b44505Smrg fi 21994a041c5bSmacallan 220054b44505Smrg func_show_eval_locale "$command" \ 220154b44505Smrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 22024a041c5bSmacallan 220354b44505Smrg if test "$need_locks" = warn && 220454b44505Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 220554b44505Smrg $ECHO "\ 220654b44505Smrg*** ERROR, $lockfile contains: 220754b44505Smrg`cat $lockfile 2>/dev/null` 22084a041c5bSmacallan 220954b44505Smrgbut it should contain: 221054b44505Smrg$srcfile 22114a041c5bSmacallan 221254b44505SmrgThis indicates that another process is trying to use the same 221354b44505Smrgtemporary object file, and libtool could not work around it because 221454b44505Smrgyour compiler does not support \`-c' and \`-o' together. If you 221554b44505Smrgrepeat this compilation, it may succeed, by chance, but you had better 221654b44505Smrgavoid parallel builds (make -j) in this platform, or get a better 221754b44505Smrgcompiler." 22184a041c5bSmacallan 221954b44505Smrg $opt_dry_run || $RM $removelist 222054b44505Smrg exit $EXIT_FAILURE 222154b44505Smrg fi 22224a041c5bSmacallan 222354b44505Smrg # Just move the object if needed, then go on to compile the next one 222454b44505Smrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 222554b44505Smrg func_show_eval '$MV "$output_obj" "$lobj"' \ 222654b44505Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 222754b44505Smrg fi 22284a041c5bSmacallan 222954b44505Smrg # Allow error messages only from the first compilation. 223054b44505Smrg if test "$suppress_opt" = yes; then 223154b44505Smrg suppress_output=' >/dev/null 2>&1' 223254b44505Smrg fi 223354b44505Smrg fi 22344a041c5bSmacallan 223554b44505Smrg # Only build a position-dependent object if we build old libraries. 223654b44505Smrg if test "$build_old_libs" = yes; then 223754b44505Smrg if test "$pic_mode" != yes; then 223854b44505Smrg # Don't build PIC code 223954b44505Smrg command="$base_compile $qsrcfile$pie_flag" 224054b44505Smrg else 224154b44505Smrg command="$base_compile $qsrcfile $pic_flag" 224254b44505Smrg fi 224354b44505Smrg if test "$compiler_c_o" = yes; then 224454b44505Smrg func_append command " -o $obj" 224554b44505Smrg fi 22464a041c5bSmacallan 224754b44505Smrg # Suppress compiler output if we already did a PIC compilation. 224854b44505Smrg func_append command "$suppress_output" 224954b44505Smrg func_show_eval_locale "$command" \ 225054b44505Smrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 22514a041c5bSmacallan 225254b44505Smrg if test "$need_locks" = warn && 225354b44505Smrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 225454b44505Smrg $ECHO "\ 225554b44505Smrg*** ERROR, $lockfile contains: 225654b44505Smrg`cat $lockfile 2>/dev/null` 22574a041c5bSmacallan 225854b44505Smrgbut it should contain: 225954b44505Smrg$srcfile 22604a041c5bSmacallan 226154b44505SmrgThis indicates that another process is trying to use the same 226254b44505Smrgtemporary object file, and libtool could not work around it because 226354b44505Smrgyour compiler does not support \`-c' and \`-o' together. If you 226454b44505Smrgrepeat this compilation, it may succeed, by chance, but you had better 226554b44505Smrgavoid parallel builds (make -j) in this platform, or get a better 226654b44505Smrgcompiler." 22674a041c5bSmacallan 226854b44505Smrg $opt_dry_run || $RM $removelist 226954b44505Smrg exit $EXIT_FAILURE 227054b44505Smrg fi 22714a041c5bSmacallan 227254b44505Smrg # Just move the object if needed 227354b44505Smrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 227454b44505Smrg func_show_eval '$MV "$output_obj" "$obj"' \ 227554b44505Smrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 227654b44505Smrg fi 227754b44505Smrg fi 22784a041c5bSmacallan 227954b44505Smrg $opt_dry_run || { 228054b44505Smrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 22814a041c5bSmacallan 228254b44505Smrg # Unlock the critical section if it was locked 228354b44505Smrg if test "$need_locks" != no; then 228454b44505Smrg removelist=$lockfile 228554b44505Smrg $RM "$lockfile" 228654b44505Smrg fi 228754b44505Smrg } 22884a041c5bSmacallan 228954b44505Smrg exit $EXIT_SUCCESS 229054b44505Smrg} 22914a041c5bSmacallan 229254b44505Smrg$opt_help || { 229354b44505Smrg test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 229454b44505Smrg} 22954a041c5bSmacallan 229654b44505Smrgfunc_mode_help () 229754b44505Smrg{ 229854b44505Smrg # We need to display help for each of the modes. 229954b44505Smrg case $opt_mode in 230054b44505Smrg "") 230154b44505Smrg # Generic help is extracted from the usage comments 230254b44505Smrg # at the start of this file. 230354b44505Smrg func_help 230454b44505Smrg ;; 23054a041c5bSmacallan 230654b44505Smrg clean) 230754b44505Smrg $ECHO \ 230854b44505Smrg"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 23094a041c5bSmacallan 231054b44505SmrgRemove files from the build directory. 23114a041c5bSmacallan 231254b44505SmrgRM is the name of the program to use to delete files associated with each FILE 231354b44505Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 231454b44505Smrgto RM. 23154a041c5bSmacallan 231654b44505SmrgIf FILE is a libtool library, object or program, all the files associated 231754b44505Smrgwith it are deleted. Otherwise, only FILE itself is deleted using RM." 231854b44505Smrg ;; 23194a041c5bSmacallan 232054b44505Smrg compile) 232154b44505Smrg $ECHO \ 232254b44505Smrg"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 23234a041c5bSmacallan 232454b44505SmrgCompile a source file into a libtool library object. 23254a041c5bSmacallan 232654b44505SmrgThis mode accepts the following additional options: 23274a041c5bSmacallan 232854b44505Smrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 232954b44505Smrg -no-suppress do not suppress compiler output for multiple passes 233054b44505Smrg -prefer-pic try to build PIC objects only 233154b44505Smrg -prefer-non-pic try to build non-PIC objects only 233254b44505Smrg -shared do not build a \`.o' file suitable for static linking 233354b44505Smrg -static only build a \`.o' file suitable for static linking 233454b44505Smrg -Wc,FLAG pass FLAG directly to the compiler 23354a041c5bSmacallan 233654b44505SmrgCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 233754b44505Smrgfrom the given SOURCEFILE. 23384a041c5bSmacallan 233954b44505SmrgThe output file name is determined by removing the directory component from 234054b44505SmrgSOURCEFILE, then substituting the C source code suffix \`.c' with the 234154b44505Smrglibrary object suffix, \`.lo'." 234254b44505Smrg ;; 23434a041c5bSmacallan 234454b44505Smrg execute) 234554b44505Smrg $ECHO \ 234654b44505Smrg"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 23474a041c5bSmacallan 234854b44505SmrgAutomatically set library path, then run a program. 23494a041c5bSmacallan 235054b44505SmrgThis mode accepts the following additional options: 23514a041c5bSmacallan 235254b44505Smrg -dlopen FILE add the directory containing FILE to the library path 23534a041c5bSmacallan 235454b44505SmrgThis mode sets the library path environment variable according to \`-dlopen' 235554b44505Smrgflags. 23564a041c5bSmacallan 235754b44505SmrgIf any of the ARGS are libtool executable wrappers, then they are translated 235854b44505Smrginto their corresponding uninstalled binary, and any of their required library 235954b44505Smrgdirectories are added to the library path. 23604a041c5bSmacallan 236154b44505SmrgThen, COMMAND is executed, with ARGS as arguments." 236254b44505Smrg ;; 23634a041c5bSmacallan 236454b44505Smrg finish) 236554b44505Smrg $ECHO \ 236654b44505Smrg"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 23674a041c5bSmacallan 236854b44505SmrgComplete the installation of libtool libraries. 236954b44505Smrg 237054b44505SmrgEach LIBDIR is a directory that contains libtool libraries. 237154b44505Smrg 237254b44505SmrgThe commands that this mode executes may require superuser privileges. Use 237354b44505Smrgthe \`--dry-run' option if you just want to see what would be executed." 237454b44505Smrg ;; 237554b44505Smrg 237654b44505Smrg install) 237754b44505Smrg $ECHO \ 237854b44505Smrg"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 237954b44505Smrg 238054b44505SmrgInstall executables or libraries. 238154b44505Smrg 238254b44505SmrgINSTALL-COMMAND is the installation command. The first component should be 238354b44505Smrgeither the \`install' or \`cp' program. 238454b44505Smrg 238554b44505SmrgThe following components of INSTALL-COMMAND are treated specially: 238654b44505Smrg 238754b44505Smrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 238854b44505Smrg 238954b44505SmrgThe rest of the components are interpreted as arguments to that command (only 239054b44505SmrgBSD-compatible install options are recognized)." 239154b44505Smrg ;; 239254b44505Smrg 239354b44505Smrg link) 239454b44505Smrg $ECHO \ 239554b44505Smrg"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 239654b44505Smrg 239754b44505SmrgLink object files or libraries together to form another library, or to 239854b44505Smrgcreate an executable program. 239954b44505Smrg 240054b44505SmrgLINK-COMMAND is a command using the C compiler that you would use to create 240154b44505Smrga program from several object files. 240254b44505Smrg 240354b44505SmrgThe following components of LINK-COMMAND are treated specially: 240454b44505Smrg 240554b44505Smrg -all-static do not do any dynamic linking at all 240654b44505Smrg -avoid-version do not add a version suffix if possible 240754b44505Smrg -bindir BINDIR specify path to binaries directory (for systems where 240854b44505Smrg libraries must be found in the PATH setting at runtime) 240954b44505Smrg -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 241054b44505Smrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 241154b44505Smrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 241254b44505Smrg -export-symbols SYMFILE 241354b44505Smrg try to export only the symbols listed in SYMFILE 241454b44505Smrg -export-symbols-regex REGEX 241554b44505Smrg try to export only the symbols matching REGEX 241654b44505Smrg -LLIBDIR search LIBDIR for required installed libraries 241754b44505Smrg -lNAME OUTPUT-FILE requires the installed library libNAME 241854b44505Smrg -module build a library that can dlopened 241954b44505Smrg -no-fast-install disable the fast-install mode 242054b44505Smrg -no-install link a not-installable executable 242154b44505Smrg -no-undefined declare that a library does not refer to external symbols 242254b44505Smrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 242354b44505Smrg -objectlist FILE Use a list of object files found in FILE to specify objects 242454b44505Smrg -precious-files-regex REGEX 242554b44505Smrg don't remove output files matching REGEX 242654b44505Smrg -release RELEASE specify package release information 242754b44505Smrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 242854b44505Smrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 242954b44505Smrg -shared only do dynamic linking of libtool libraries 243054b44505Smrg -shrext SUFFIX override the standard shared library file extension 243154b44505Smrg -static do not do any dynamic linking of uninstalled libtool libraries 243254b44505Smrg -static-libtool-libs 243354b44505Smrg do not do any dynamic linking of libtool libraries 243454b44505Smrg -version-info CURRENT[:REVISION[:AGE]] 243554b44505Smrg specify library version info [each variable defaults to 0] 243654b44505Smrg -weak LIBNAME declare that the target provides the LIBNAME interface 243754b44505Smrg -Wc,FLAG 243854b44505Smrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 243954b44505Smrg -Wl,FLAG 244054b44505Smrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 244154b44505Smrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 244254b44505Smrg 244354b44505SmrgAll other options (arguments beginning with \`-') are ignored. 244454b44505Smrg 244554b44505SmrgEvery other argument is treated as a filename. Files ending in \`.la' are 244654b44505Smrgtreated as uninstalled libtool libraries, other files are standard or library 244754b44505Smrgobject files. 244854b44505Smrg 244954b44505SmrgIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 245054b44505Smrgonly library objects (\`.lo' files) may be specified, and \`-rpath' is 245154b44505Smrgrequired, except when creating a convenience library. 245254b44505Smrg 245354b44505SmrgIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 245454b44505Smrgusing \`ar' and \`ranlib', or on Windows using \`lib'. 245554b44505Smrg 245654b44505SmrgIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 245754b44505Smrgis created, otherwise an executable program is created." 245854b44505Smrg ;; 245954b44505Smrg 246054b44505Smrg uninstall) 246154b44505Smrg $ECHO \ 246254b44505Smrg"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 246354b44505Smrg 246454b44505SmrgRemove libraries from an installation directory. 246554b44505Smrg 246654b44505SmrgRM is the name of the program to use to delete files associated with each FILE 246754b44505Smrg(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 246854b44505Smrgto RM. 246954b44505Smrg 247054b44505SmrgIf FILE is a libtool library, all the files associated with it are deleted. 247154b44505SmrgOtherwise, only FILE itself is deleted using RM." 247254b44505Smrg ;; 247354b44505Smrg 247454b44505Smrg *) 247554b44505Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 247654b44505Smrg ;; 24774a041c5bSmacallan esac 24784a041c5bSmacallan 247954b44505Smrg echo 248054b44505Smrg $ECHO "Try \`$progname --help' for more information about other modes." 248154b44505Smrg} 24824a041c5bSmacallan 248354b44505Smrg# Now that we've collected a possible --mode arg, show help if necessary 248454b44505Smrgif $opt_help; then 248554b44505Smrg if test "$opt_help" = :; then 248654b44505Smrg func_mode_help 248754b44505Smrg else 248854b44505Smrg { 248954b44505Smrg func_help noexit 249054b44505Smrg for opt_mode in compile link execute install finish uninstall clean; do 249154b44505Smrg func_mode_help 249254b44505Smrg done 249354b44505Smrg } | sed -n '1p; 2,$s/^Usage:/ or: /p' 249454b44505Smrg { 249554b44505Smrg func_help noexit 249654b44505Smrg for opt_mode in compile link execute install finish uninstall clean; do 249754b44505Smrg echo 249854b44505Smrg func_mode_help 249954b44505Smrg done 250054b44505Smrg } | 250154b44505Smrg sed '1d 250254b44505Smrg /^When reporting/,/^Report/{ 250354b44505Smrg H 250454b44505Smrg d 250554b44505Smrg } 250654b44505Smrg $x 250754b44505Smrg /information about other modes/d 250854b44505Smrg /more detailed .*MODE/d 250954b44505Smrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 251054b44505Smrg fi 251154b44505Smrg exit $? 251254b44505Smrgfi 25134a041c5bSmacallan 25144a041c5bSmacallan 251554b44505Smrg# func_mode_execute arg... 251654b44505Smrgfunc_mode_execute () 251754b44505Smrg{ 251854b44505Smrg $opt_debug 251954b44505Smrg # The first argument is the command name. 252054b44505Smrg cmd="$nonopt" 252154b44505Smrg test -z "$cmd" && \ 252254b44505Smrg func_fatal_help "you must specify a COMMAND" 252354b44505Smrg 252454b44505Smrg # Handle -dlopen flags immediately. 252554b44505Smrg for file in $opt_dlopen; do 252654b44505Smrg test -f "$file" \ 252754b44505Smrg || func_fatal_help "\`$file' is not a file" 252854b44505Smrg 252954b44505Smrg dir= 253054b44505Smrg case $file in 253154b44505Smrg *.la) 253254b44505Smrg func_resolve_sysroot "$file" 253354b44505Smrg file=$func_resolve_sysroot_result 253454b44505Smrg 253554b44505Smrg # Check to see that this really is a libtool archive. 253654b44505Smrg func_lalib_unsafe_p "$file" \ 253754b44505Smrg || func_fatal_help "\`$lib' is not a valid libtool archive" 253854b44505Smrg 253954b44505Smrg # Read the libtool library. 254054b44505Smrg dlname= 254154b44505Smrg library_names= 254254b44505Smrg func_source "$file" 254354b44505Smrg 254454b44505Smrg # Skip this library if it cannot be dlopened. 254554b44505Smrg if test -z "$dlname"; then 254654b44505Smrg # Warn if it was a shared library. 254754b44505Smrg test -n "$library_names" && \ 254854b44505Smrg func_warning "\`$file' was not linked with \`-export-dynamic'" 254954b44505Smrg continue 255054b44505Smrg fi 255154b44505Smrg 255254b44505Smrg func_dirname "$file" "" "." 255354b44505Smrg dir="$func_dirname_result" 255454b44505Smrg 255554b44505Smrg if test -f "$dir/$objdir/$dlname"; then 255654b44505Smrg func_append dir "/$objdir" 255754b44505Smrg else 255854b44505Smrg if test ! -f "$dir/$dlname"; then 255954b44505Smrg func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 256054b44505Smrg fi 256154b44505Smrg fi 25624a041c5bSmacallan ;; 256354b44505Smrg 256454b44505Smrg *.lo) 256554b44505Smrg # Just add the directory containing the .lo file. 256654b44505Smrg func_dirname "$file" "" "." 256754b44505Smrg dir="$func_dirname_result" 25684a041c5bSmacallan ;; 256954b44505Smrg 257054b44505Smrg *) 257154b44505Smrg func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 257254b44505Smrg continue 25734a041c5bSmacallan ;; 257454b44505Smrg esac 257554b44505Smrg 257654b44505Smrg # Get the absolute pathname. 257754b44505Smrg absdir=`cd "$dir" && pwd` 257854b44505Smrg test -n "$absdir" && dir="$absdir" 257954b44505Smrg 258054b44505Smrg # Now add the directory to shlibpath_var. 258154b44505Smrg if eval "test -z \"\$$shlibpath_var\""; then 258254b44505Smrg eval "$shlibpath_var=\"\$dir\"" 258354b44505Smrg else 258454b44505Smrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 25854a041c5bSmacallan fi 258654b44505Smrg done 258754b44505Smrg 258854b44505Smrg # This variable tells wrapper scripts just to set shlibpath_var 258954b44505Smrg # rather than running their programs. 259054b44505Smrg libtool_execute_magic="$magic" 259154b44505Smrg 259254b44505Smrg # Check if any of the arguments is a wrapper script. 259354b44505Smrg args= 259454b44505Smrg for file 259554b44505Smrg do 259654b44505Smrg case $file in 259754b44505Smrg -* | *.la | *.lo ) ;; 259854b44505Smrg *) 259954b44505Smrg # Do a test to see if this is really a libtool program. 260054b44505Smrg if func_ltwrapper_script_p "$file"; then 260154b44505Smrg func_source "$file" 260254b44505Smrg # Transform arg to wrapped name. 260354b44505Smrg file="$progdir/$program" 260454b44505Smrg elif func_ltwrapper_executable_p "$file"; then 260554b44505Smrg func_ltwrapper_scriptname "$file" 260654b44505Smrg func_source "$func_ltwrapper_scriptname_result" 260754b44505Smrg # Transform arg to wrapped name. 260854b44505Smrg file="$progdir/$program" 260954b44505Smrg fi 261054b44505Smrg ;; 261154b44505Smrg esac 261254b44505Smrg # Quote arguments (to preserve shell metacharacters). 261354b44505Smrg func_append_quoted args "$file" 261454b44505Smrg done 261554b44505Smrg 261654b44505Smrg if test "X$opt_dry_run" = Xfalse; then 261754b44505Smrg if test -n "$shlibpath_var"; then 261854b44505Smrg # Export the shlibpath_var. 261954b44505Smrg eval "export $shlibpath_var" 26204a041c5bSmacallan fi 262154b44505Smrg 262254b44505Smrg # Restore saved environment variables 262354b44505Smrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 262454b44505Smrg do 262554b44505Smrg eval "if test \"\${save_$lt_var+set}\" = set; then 262654b44505Smrg $lt_var=\$save_$lt_var; export $lt_var 262754b44505Smrg else 262854b44505Smrg $lt_unset $lt_var 262954b44505Smrg fi" 263054b44505Smrg done 263154b44505Smrg 263254b44505Smrg # Now prepare to actually exec the command. 263354b44505Smrg exec_cmd="\$cmd$args" 263454b44505Smrg else 263554b44505Smrg # Display what would be done. 263654b44505Smrg if test -n "$shlibpath_var"; then 263754b44505Smrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 263854b44505Smrg echo "export $shlibpath_var" 26394a041c5bSmacallan fi 264054b44505Smrg $ECHO "$cmd$args" 264154b44505Smrg exit $EXIT_SUCCESS 264254b44505Smrg fi 264354b44505Smrg} 26444a041c5bSmacallan 264554b44505Smrgtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 26464a041c5bSmacallan 26474a041c5bSmacallan 264854b44505Smrg# func_mode_finish arg... 264954b44505Smrgfunc_mode_finish () 265054b44505Smrg{ 265154b44505Smrg $opt_debug 265254b44505Smrg libs= 265354b44505Smrg libdirs= 265454b44505Smrg admincmds= 26554a041c5bSmacallan 265654b44505Smrg for opt in "$nonopt" ${1+"$@"} 265754b44505Smrg do 265854b44505Smrg if test -d "$opt"; then 265954b44505Smrg func_append libdirs " $opt" 26604a041c5bSmacallan 266154b44505Smrg elif test -f "$opt"; then 266254b44505Smrg if func_lalib_unsafe_p "$opt"; then 266354b44505Smrg func_append libs " $opt" 266454b44505Smrg else 266554b44505Smrg func_warning "\`$opt' is not a valid libtool archive" 26664a041c5bSmacallan fi 26674a041c5bSmacallan 266854b44505Smrg else 266954b44505Smrg func_fatal_error "invalid argument \`$opt'" 267054b44505Smrg fi 267154b44505Smrg done 26724a041c5bSmacallan 267354b44505Smrg if test -n "$libs"; then 267454b44505Smrg if test -n "$lt_sysroot"; then 267554b44505Smrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 267654b44505Smrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 267754b44505Smrg else 267854b44505Smrg sysroot_cmd= 267954b44505Smrg fi 26804a041c5bSmacallan 268154b44505Smrg # Remove sysroot references 268254b44505Smrg if $opt_dry_run; then 268354b44505Smrg for lib in $libs; do 268454b44505Smrg echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 268554b44505Smrg done 268654b44505Smrg else 268754b44505Smrg tmpdir=`func_mktempdir` 268854b44505Smrg for lib in $libs; do 268954b44505Smrg sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 269054b44505Smrg > $tmpdir/tmp-la 269154b44505Smrg mv -f $tmpdir/tmp-la $lib 26924a041c5bSmacallan done 269354b44505Smrg ${RM}r "$tmpdir" 269454b44505Smrg fi 269554b44505Smrg fi 269654b44505Smrg 269754b44505Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 269854b44505Smrg for libdir in $libdirs; do 269954b44505Smrg if test -n "$finish_cmds"; then 270054b44505Smrg # Do each command in the finish commands. 270154b44505Smrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 270254b44505Smrg'"$cmd"'"' 27034a041c5bSmacallan fi 270454b44505Smrg if test -n "$finish_eval"; then 270554b44505Smrg # Do the single finish_eval. 270654b44505Smrg eval cmds=\"$finish_eval\" 270754b44505Smrg $opt_dry_run || eval "$cmds" || func_append admincmds " 270854b44505Smrg $cmds" 270954b44505Smrg fi 271054b44505Smrg done 271154b44505Smrg fi 27124a041c5bSmacallan 271354b44505Smrg # Exit here if they wanted silent mode. 271454b44505Smrg $opt_silent && exit $EXIT_SUCCESS 27154a041c5bSmacallan 271654b44505Smrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 271754b44505Smrg echo "----------------------------------------------------------------------" 271854b44505Smrg echo "Libraries have been installed in:" 271954b44505Smrg for libdir in $libdirs; do 272054b44505Smrg $ECHO " $libdir" 272154b44505Smrg done 272254b44505Smrg echo 272354b44505Smrg echo "If you ever happen to want to link against installed libraries" 272454b44505Smrg echo "in a given directory, LIBDIR, you must either use libtool, and" 272554b44505Smrg echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 272654b44505Smrg echo "flag during linking and do at least one of the following:" 272754b44505Smrg if test -n "$shlibpath_var"; then 272854b44505Smrg echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 272954b44505Smrg echo " during execution" 273054b44505Smrg fi 273154b44505Smrg if test -n "$runpath_var"; then 273254b44505Smrg echo " - add LIBDIR to the \`$runpath_var' environment variable" 273354b44505Smrg echo " during linking" 273454b44505Smrg fi 273554b44505Smrg if test -n "$hardcode_libdir_flag_spec"; then 273654b44505Smrg libdir=LIBDIR 273754b44505Smrg eval flag=\"$hardcode_libdir_flag_spec\" 273854b44505Smrg 273954b44505Smrg $ECHO " - use the \`$flag' linker flag" 274054b44505Smrg fi 274154b44505Smrg if test -n "$admincmds"; then 274254b44505Smrg $ECHO " - have your system administrator run these commands:$admincmds" 274354b44505Smrg fi 274454b44505Smrg if test -f /etc/ld.so.conf; then 274554b44505Smrg echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 274654b44505Smrg fi 274754b44505Smrg echo 274854b44505Smrg 274954b44505Smrg echo "See any operating system documentation about shared libraries for" 275054b44505Smrg case $host in 275154b44505Smrg solaris2.[6789]|solaris2.1[0-9]) 275254b44505Smrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 275354b44505Smrg echo "pages." 275454b44505Smrg ;; 27554a041c5bSmacallan *) 275654b44505Smrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 27574a041c5bSmacallan ;; 275854b44505Smrg esac 275954b44505Smrg echo "----------------------------------------------------------------------" 276054b44505Smrg fi 276154b44505Smrg exit $EXIT_SUCCESS 276254b44505Smrg} 27634a041c5bSmacallan 276454b44505Smrgtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 27654a041c5bSmacallan 276654b44505Smrg 276754b44505Smrg# func_mode_install arg... 276854b44505Smrgfunc_mode_install () 276954b44505Smrg{ 277054b44505Smrg $opt_debug 277154b44505Smrg # There may be an optional sh(1) argument at the beginning of 277254b44505Smrg # install_prog (especially on Windows NT). 277354b44505Smrg if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 277454b44505Smrg # Allow the use of GNU shtool's install command. 277554b44505Smrg case $nonopt in *shtool*) :;; *) false;; esac; then 277654b44505Smrg # Aesthetically quote it. 277754b44505Smrg func_quote_for_eval "$nonopt" 277854b44505Smrg install_prog="$func_quote_for_eval_result " 277954b44505Smrg arg=$1 278054b44505Smrg shift 278154b44505Smrg else 278254b44505Smrg install_prog= 278354b44505Smrg arg=$nonopt 278454b44505Smrg fi 278554b44505Smrg 278654b44505Smrg # The real first argument should be the name of the installation program. 278754b44505Smrg # Aesthetically quote it. 278854b44505Smrg func_quote_for_eval "$arg" 278954b44505Smrg func_append install_prog "$func_quote_for_eval_result" 279054b44505Smrg install_shared_prog=$install_prog 279154b44505Smrg case " $install_prog " in 279254b44505Smrg *[\\\ /]cp\ *) install_cp=: ;; 279354b44505Smrg *) install_cp=false ;; 279454b44505Smrg esac 279554b44505Smrg 279654b44505Smrg # We need to accept at least all the BSD install flags. 279754b44505Smrg dest= 279854b44505Smrg files= 279954b44505Smrg opts= 280054b44505Smrg prev= 280154b44505Smrg install_type= 280254b44505Smrg isdir=no 280354b44505Smrg stripme= 280454b44505Smrg no_mode=: 280554b44505Smrg for arg 280654b44505Smrg do 280754b44505Smrg arg2= 280854b44505Smrg if test -n "$dest"; then 280954b44505Smrg func_append files " $dest" 281054b44505Smrg dest=$arg 281154b44505Smrg continue 281254b44505Smrg fi 281354b44505Smrg 281454b44505Smrg case $arg in 281554b44505Smrg -d) isdir=yes ;; 281654b44505Smrg -f) 281754b44505Smrg if $install_cp; then :; else 281854b44505Smrg prev=$arg 281954b44505Smrg fi 282054b44505Smrg ;; 282154b44505Smrg -g | -m | -o) 282254b44505Smrg prev=$arg 282354b44505Smrg ;; 282454b44505Smrg -s) 282554b44505Smrg stripme=" -s" 282654b44505Smrg continue 282754b44505Smrg ;; 282854b44505Smrg -*) 282954b44505Smrg ;; 283054b44505Smrg *) 283154b44505Smrg # If the previous option needed an argument, then skip it. 283254b44505Smrg if test -n "$prev"; then 283354b44505Smrg if test "x$prev" = x-m && test -n "$install_override_mode"; then 283454b44505Smrg arg2=$install_override_mode 283554b44505Smrg no_mode=false 28364a041c5bSmacallan fi 283754b44505Smrg prev= 283854b44505Smrg else 283954b44505Smrg dest=$arg 28404a041c5bSmacallan continue 28414a041c5bSmacallan fi 284254b44505Smrg ;; 284354b44505Smrg esac 28444a041c5bSmacallan 284554b44505Smrg # Aesthetically quote the argument. 284654b44505Smrg func_quote_for_eval "$arg" 284754b44505Smrg func_append install_prog " $func_quote_for_eval_result" 284854b44505Smrg if test -n "$arg2"; then 284954b44505Smrg func_quote_for_eval "$arg2" 285054b44505Smrg fi 285154b44505Smrg func_append install_shared_prog " $func_quote_for_eval_result" 285254b44505Smrg done 28534a041c5bSmacallan 285454b44505Smrg test -z "$install_prog" && \ 285554b44505Smrg func_fatal_help "you must specify an install program" 28564a041c5bSmacallan 285754b44505Smrg test -n "$prev" && \ 285854b44505Smrg func_fatal_help "the \`$prev' option requires an argument" 28594a041c5bSmacallan 286054b44505Smrg if test -n "$install_override_mode" && $no_mode; then 286154b44505Smrg if $install_cp; then :; else 286254b44505Smrg func_quote_for_eval "$install_override_mode" 286354b44505Smrg func_append install_shared_prog " -m $func_quote_for_eval_result" 286454b44505Smrg fi 286554b44505Smrg fi 28664a041c5bSmacallan 286754b44505Smrg if test -z "$files"; then 286854b44505Smrg if test -z "$dest"; then 286954b44505Smrg func_fatal_help "no file or destination specified" 287054b44505Smrg else 287154b44505Smrg func_fatal_help "you must specify a destination" 287254b44505Smrg fi 287354b44505Smrg fi 28744a041c5bSmacallan 287554b44505Smrg # Strip any trailing slash from the destination. 287654b44505Smrg func_stripname '' '/' "$dest" 287754b44505Smrg dest=$func_stripname_result 28784a041c5bSmacallan 287954b44505Smrg # Check to see that the destination is a directory. 288054b44505Smrg test -d "$dest" && isdir=yes 288154b44505Smrg if test "$isdir" = yes; then 288254b44505Smrg destdir="$dest" 288354b44505Smrg destname= 288454b44505Smrg else 288554b44505Smrg func_dirname_and_basename "$dest" "" "." 288654b44505Smrg destdir="$func_dirname_result" 288754b44505Smrg destname="$func_basename_result" 28884a041c5bSmacallan 288954b44505Smrg # Not a directory, so check to see that there is only one file specified. 289054b44505Smrg set dummy $files; shift 289154b44505Smrg test "$#" -gt 1 && \ 289254b44505Smrg func_fatal_help "\`$dest' is not a directory" 289354b44505Smrg fi 289454b44505Smrg case $destdir in 289554b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 289654b44505Smrg *) 289754b44505Smrg for file in $files; do 289854b44505Smrg case $file in 289954b44505Smrg *.lo) ;; 290054b44505Smrg *) 290154b44505Smrg func_fatal_help "\`$destdir' must be an absolute directory name" 290254b44505Smrg ;; 290354b44505Smrg esac 290454b44505Smrg done 290554b44505Smrg ;; 290654b44505Smrg esac 29074a041c5bSmacallan 290854b44505Smrg # This variable tells wrapper scripts just to set variables rather 290954b44505Smrg # than running their programs. 291054b44505Smrg libtool_install_magic="$magic" 29114a041c5bSmacallan 291254b44505Smrg staticlibs= 291354b44505Smrg future_libdirs= 291454b44505Smrg current_libdirs= 291554b44505Smrg for file in $files; do 29164a041c5bSmacallan 291754b44505Smrg # Do each installation. 291854b44505Smrg case $file in 291954b44505Smrg *.$libext) 292054b44505Smrg # Do the static libraries later. 292154b44505Smrg func_append staticlibs " $file" 292254b44505Smrg ;; 29234a041c5bSmacallan 292454b44505Smrg *.la) 292554b44505Smrg func_resolve_sysroot "$file" 292654b44505Smrg file=$func_resolve_sysroot_result 29274a041c5bSmacallan 292854b44505Smrg # Check to see that this really is a libtool archive. 292954b44505Smrg func_lalib_unsafe_p "$file" \ 293054b44505Smrg || func_fatal_help "\`$file' is not a valid libtool archive" 29314a041c5bSmacallan 293254b44505Smrg library_names= 293354b44505Smrg old_library= 293454b44505Smrg relink_command= 293554b44505Smrg func_source "$file" 29364a041c5bSmacallan 293754b44505Smrg # Add the libdir to current_libdirs if it is the destination. 293854b44505Smrg if test "X$destdir" = "X$libdir"; then 293954b44505Smrg case "$current_libdirs " in 294054b44505Smrg *" $libdir "*) ;; 294154b44505Smrg *) func_append current_libdirs " $libdir" ;; 294254b44505Smrg esac 294354b44505Smrg else 294454b44505Smrg # Note the libdir as a future libdir. 294554b44505Smrg case "$future_libdirs " in 294654b44505Smrg *" $libdir "*) ;; 294754b44505Smrg *) func_append future_libdirs " $libdir" ;; 294854b44505Smrg esac 294954b44505Smrg fi 29504a041c5bSmacallan 295154b44505Smrg func_dirname "$file" "/" "" 295254b44505Smrg dir="$func_dirname_result" 295354b44505Smrg func_append dir "$objdir" 29544a041c5bSmacallan 295554b44505Smrg if test -n "$relink_command"; then 295654b44505Smrg # Determine the prefix the user has applied to our future dir. 295754b44505Smrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 29584a041c5bSmacallan 295954b44505Smrg # Don't allow the user to place us outside of our expected 296054b44505Smrg # location b/c this prevents finding dependent libraries that 296154b44505Smrg # are installed to the same prefix. 296254b44505Smrg # At present, this check doesn't affect windows .dll's that 296354b44505Smrg # are installed into $libdir/../bin (currently, that works fine) 296454b44505Smrg # but it's something to keep an eye on. 296554b44505Smrg test "$inst_prefix_dir" = "$destdir" && \ 296654b44505Smrg func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 296754b44505Smrg 296854b44505Smrg if test -n "$inst_prefix_dir"; then 296954b44505Smrg # Stick the inst_prefix_dir data into the link command. 297054b44505Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 29714a041c5bSmacallan else 297254b44505Smrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 29734a041c5bSmacallan fi 29744a041c5bSmacallan 297554b44505Smrg func_warning "relinking \`$file'" 297654b44505Smrg func_show_eval "$relink_command" \ 297754b44505Smrg 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 297854b44505Smrg fi 297954b44505Smrg 298054b44505Smrg # See the names of the shared library. 298154b44505Smrg set dummy $library_names; shift 298254b44505Smrg if test -n "$1"; then 298354b44505Smrg realname="$1" 298454b44505Smrg shift 298554b44505Smrg 298654b44505Smrg srcname="$realname" 298754b44505Smrg test -n "$relink_command" && srcname="$realname"T 298854b44505Smrg 298954b44505Smrg # Install the shared library and build the symlinks. 299054b44505Smrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 299154b44505Smrg 'exit $?' 299254b44505Smrg tstripme="$stripme" 299354b44505Smrg case $host_os in 299454b44505Smrg cygwin* | mingw* | pw32* | cegcc*) 299554b44505Smrg case $realname in 299654b44505Smrg *.dll.a) 299754b44505Smrg tstripme="" 299854b44505Smrg ;; 299954b44505Smrg esac 300054b44505Smrg ;; 300154b44505Smrg esac 300254b44505Smrg if test -n "$tstripme" && test -n "$striplib"; then 300354b44505Smrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 30044a041c5bSmacallan fi 30054a041c5bSmacallan 300654b44505Smrg if test "$#" -gt 0; then 300754b44505Smrg # Delete the old symlinks, and create new ones. 300854b44505Smrg # Try `ln -sf' first, because the `ln' binary might depend on 300954b44505Smrg # the symlink we replace! Solaris /bin/ln does not understand -f, 301054b44505Smrg # so we also need to try rm && ln -s. 301154b44505Smrg for linkname 301254b44505Smrg do 301354b44505Smrg test "$linkname" != "$realname" \ 301454b44505Smrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 30154a041c5bSmacallan done 30164a041c5bSmacallan fi 30174a041c5bSmacallan 301854b44505Smrg # Do each command in the postinstall commands. 301954b44505Smrg lib="$destdir/$realname" 302054b44505Smrg func_execute_cmds "$postinstall_cmds" 'exit $?' 302154b44505Smrg fi 30224a041c5bSmacallan 302354b44505Smrg # Install the pseudo-library for information purposes. 302454b44505Smrg func_basename "$file" 302554b44505Smrg name="$func_basename_result" 302654b44505Smrg instname="$dir/$name"i 302754b44505Smrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 30284a041c5bSmacallan 302954b44505Smrg # Maybe install the static library, too. 303054b44505Smrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 303154b44505Smrg ;; 303254b44505Smrg 303354b44505Smrg *.lo) 303454b44505Smrg # Install (i.e. copy) a libtool object. 303554b44505Smrg 303654b44505Smrg # Figure out destination file name, if it wasn't already specified. 303754b44505Smrg if test -n "$destname"; then 303854b44505Smrg destfile="$destdir/$destname" 30394a041c5bSmacallan else 304054b44505Smrg func_basename "$file" 304154b44505Smrg destfile="$func_basename_result" 304254b44505Smrg destfile="$destdir/$destfile" 30434a041c5bSmacallan fi 304454b44505Smrg 304554b44505Smrg # Deduce the name of the destination old-style object file. 304654b44505Smrg case $destfile in 304754b44505Smrg *.lo) 304854b44505Smrg func_lo2o "$destfile" 304954b44505Smrg staticdest=$func_lo2o_result 305054b44505Smrg ;; 305154b44505Smrg *.$objext) 305254b44505Smrg staticdest="$destfile" 305354b44505Smrg destfile= 305454b44505Smrg ;; 305554b44505Smrg *) 305654b44505Smrg func_fatal_help "cannot copy a libtool object to \`$destfile'" 30574a041c5bSmacallan ;; 30584a041c5bSmacallan esac 30594a041c5bSmacallan 306054b44505Smrg # Install the libtool object if requested. 306154b44505Smrg test -n "$destfile" && \ 306254b44505Smrg func_show_eval "$install_prog $file $destfile" 'exit $?' 30634a041c5bSmacallan 306454b44505Smrg # Install the old object if enabled. 306554b44505Smrg if test "$build_old_libs" = yes; then 306654b44505Smrg # Deduce the name of the old-style object file. 306754b44505Smrg func_lo2o "$file" 306854b44505Smrg staticobj=$func_lo2o_result 306954b44505Smrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 307054b44505Smrg fi 307154b44505Smrg exit $EXIT_SUCCESS 307254b44505Smrg ;; 30734a041c5bSmacallan 307454b44505Smrg *) 307554b44505Smrg # Figure out destination file name, if it wasn't already specified. 307654b44505Smrg if test -n "$destname"; then 307754b44505Smrg destfile="$destdir/$destname" 307854b44505Smrg else 307954b44505Smrg func_basename "$file" 308054b44505Smrg destfile="$func_basename_result" 308154b44505Smrg destfile="$destdir/$destfile" 308254b44505Smrg fi 30834a041c5bSmacallan 308454b44505Smrg # If the file is missing, and there is a .exe on the end, strip it 308554b44505Smrg # because it is most likely a libtool script we actually want to 308654b44505Smrg # install 308754b44505Smrg stripped_ext="" 308854b44505Smrg case $file in 308954b44505Smrg *.exe) 309054b44505Smrg if test ! -f "$file"; then 309154b44505Smrg func_stripname '' '.exe' "$file" 309254b44505Smrg file=$func_stripname_result 309354b44505Smrg stripped_ext=".exe" 309454b44505Smrg fi 309554b44505Smrg ;; 309654b44505Smrg esac 30974a041c5bSmacallan 309854b44505Smrg # Do a test to see if this is really a libtool program. 309954b44505Smrg case $host in 310054b44505Smrg *cygwin* | *mingw*) 310154b44505Smrg if func_ltwrapper_executable_p "$file"; then 310254b44505Smrg func_ltwrapper_scriptname "$file" 310354b44505Smrg wrapper=$func_ltwrapper_scriptname_result 310454b44505Smrg else 310554b44505Smrg func_stripname '' '.exe' "$file" 310654b44505Smrg wrapper=$func_stripname_result 310754b44505Smrg fi 310854b44505Smrg ;; 310954b44505Smrg *) 311054b44505Smrg wrapper=$file 311154b44505Smrg ;; 311254b44505Smrg esac 311354b44505Smrg if func_ltwrapper_script_p "$wrapper"; then 311454b44505Smrg notinst_deplibs= 311554b44505Smrg relink_command= 31164a041c5bSmacallan 311754b44505Smrg func_source "$wrapper" 31184a041c5bSmacallan 311954b44505Smrg # Check the variables that should have been set. 312054b44505Smrg test -z "$generated_by_libtool_version" && \ 312154b44505Smrg func_fatal_error "invalid libtool wrapper script \`$wrapper'" 31224a041c5bSmacallan 312354b44505Smrg finalize=yes 312454b44505Smrg for lib in $notinst_deplibs; do 312554b44505Smrg # Check to see that each library is installed. 312654b44505Smrg libdir= 312754b44505Smrg if test -f "$lib"; then 312854b44505Smrg func_source "$lib" 312954b44505Smrg fi 313054b44505Smrg libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 313154b44505Smrg if test -n "$libdir" && test ! -f "$libfile"; then 313254b44505Smrg func_warning "\`$lib' has not been installed in \`$libdir'" 313354b44505Smrg finalize=no 313454b44505Smrg fi 313554b44505Smrg done 31364a041c5bSmacallan 313754b44505Smrg relink_command= 313854b44505Smrg func_source "$wrapper" 313954b44505Smrg 314054b44505Smrg outputname= 314154b44505Smrg if test "$fast_install" = no && test -n "$relink_command"; then 314254b44505Smrg $opt_dry_run || { 314354b44505Smrg if test "$finalize" = yes; then 314454b44505Smrg tmpdir=`func_mktempdir` 314554b44505Smrg func_basename "$file$stripped_ext" 314654b44505Smrg file="$func_basename_result" 314754b44505Smrg outputname="$tmpdir/$file" 314854b44505Smrg # Replace the output file specification. 314954b44505Smrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 315054b44505Smrg 315154b44505Smrg $opt_silent || { 315254b44505Smrg func_quote_for_expand "$relink_command" 315354b44505Smrg eval "func_echo $func_quote_for_expand_result" 315454b44505Smrg } 315554b44505Smrg if eval "$relink_command"; then : 315654b44505Smrg else 315754b44505Smrg func_error "error: relink \`$file' with the above command before installing it" 315854b44505Smrg $opt_dry_run || ${RM}r "$tmpdir" 315954b44505Smrg continue 316054b44505Smrg fi 316154b44505Smrg file="$outputname" 316254b44505Smrg else 316354b44505Smrg func_warning "cannot relink \`$file'" 316454b44505Smrg fi 316554b44505Smrg } 316654b44505Smrg else 316754b44505Smrg # Install the binary that we compiled earlier. 316854b44505Smrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 316954b44505Smrg fi 31704a041c5bSmacallan fi 317154b44505Smrg 317254b44505Smrg # remove .exe since cygwin /usr/bin/install will append another 317354b44505Smrg # one anyway 317454b44505Smrg case $install_prog,$host in 317554b44505Smrg */usr/bin/install*,*cygwin*) 317654b44505Smrg case $file:$destfile in 317754b44505Smrg *.exe:*.exe) 317854b44505Smrg # this is ok 317954b44505Smrg ;; 318054b44505Smrg *.exe:*) 318154b44505Smrg destfile=$destfile.exe 318254b44505Smrg ;; 318354b44505Smrg *:*.exe) 318454b44505Smrg func_stripname '' '.exe' "$destfile" 318554b44505Smrg destfile=$func_stripname_result 318654b44505Smrg ;; 318754b44505Smrg esac 318854b44505Smrg ;; 318954b44505Smrg esac 319054b44505Smrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 319154b44505Smrg $opt_dry_run || if test -n "$outputname"; then 319254b44505Smrg ${RM}r "$tmpdir" 31934a041c5bSmacallan fi 31944a041c5bSmacallan ;; 31954a041c5bSmacallan esac 319654b44505Smrg done 31974a041c5bSmacallan 319854b44505Smrg for file in $staticlibs; do 319954b44505Smrg func_basename "$file" 320054b44505Smrg name="$func_basename_result" 32014a041c5bSmacallan 320254b44505Smrg # Set up the ranlib parameters. 320354b44505Smrg oldlib="$destdir/$name" 32044a041c5bSmacallan 320554b44505Smrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 320654b44505Smrg 320754b44505Smrg if test -n "$stripme" && test -n "$old_striplib"; then 320854b44505Smrg func_show_eval "$old_striplib $oldlib" 'exit $?' 32094a041c5bSmacallan fi 32104a041c5bSmacallan 321154b44505Smrg # Do each command in the postinstall commands. 321254b44505Smrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 321354b44505Smrg done 32144a041c5bSmacallan 321554b44505Smrg test -n "$future_libdirs" && \ 321654b44505Smrg func_warning "remember to run \`$progname --finish$future_libdirs'" 32174a041c5bSmacallan 321854b44505Smrg if test -n "$current_libdirs"; then 321954b44505Smrg # Maybe just do a dry run. 322054b44505Smrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 322154b44505Smrg exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 322254b44505Smrg else 322354b44505Smrg exit $EXIT_SUCCESS 322454b44505Smrg fi 322554b44505Smrg} 32264a041c5bSmacallan 322754b44505Smrgtest "$opt_mode" = install && func_mode_install ${1+"$@"} 32284a041c5bSmacallan 32294a041c5bSmacallan 323054b44505Smrg# func_generate_dlsyms outputname originator pic_p 323154b44505Smrg# Extract symbols from dlprefiles and create ${outputname}S.o with 323254b44505Smrg# a dlpreopen symbol table. 323354b44505Smrgfunc_generate_dlsyms () 323454b44505Smrg{ 323554b44505Smrg $opt_debug 323654b44505Smrg my_outputname="$1" 323754b44505Smrg my_originator="$2" 323854b44505Smrg my_pic_p="${3-no}" 323954b44505Smrg my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 324054b44505Smrg my_dlsyms= 324154b44505Smrg 324254b44505Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 324354b44505Smrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 324454b44505Smrg my_dlsyms="${my_outputname}S.c" 324554b44505Smrg else 324654b44505Smrg func_error "not configured to extract global symbols from dlpreopened files" 324754b44505Smrg fi 324854b44505Smrg fi 32494a041c5bSmacallan 325054b44505Smrg if test -n "$my_dlsyms"; then 325154b44505Smrg case $my_dlsyms in 325254b44505Smrg "") ;; 325354b44505Smrg *.c) 325454b44505Smrg # Discover the nlist of each of the dlfiles. 325554b44505Smrg nlist="$output_objdir/${my_outputname}.nm" 32564a041c5bSmacallan 325754b44505Smrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 32584a041c5bSmacallan 325954b44505Smrg # Parse the name list into a source file. 326054b44505Smrg func_verbose "creating $output_objdir/$my_dlsyms" 32614a041c5bSmacallan 326254b44505Smrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 326354b44505Smrg/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 326454b44505Smrg/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 32654a041c5bSmacallan 326654b44505Smrg#ifdef __cplusplus 326754b44505Smrgextern \"C\" { 326854b44505Smrg#endif 32694a041c5bSmacallan 327054b44505Smrg#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 327154b44505Smrg#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 327254b44505Smrg#endif 32734a041c5bSmacallan 327454b44505Smrg/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 327554b44505Smrg#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 327654b44505Smrg/* DATA imports from DLLs on WIN32 con't be const, because runtime 327754b44505Smrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 327854b44505Smrg# define LT_DLSYM_CONST 327954b44505Smrg#elif defined(__osf__) 328054b44505Smrg/* This system does not cope well with relocations in const data. */ 328154b44505Smrg# define LT_DLSYM_CONST 328254b44505Smrg#else 328354b44505Smrg# define LT_DLSYM_CONST const 328454b44505Smrg#endif 32854a041c5bSmacallan 328654b44505Smrg/* External symbol declarations for the compiler. */\ 328754b44505Smrg" 32884a041c5bSmacallan 328954b44505Smrg if test "$dlself" = yes; then 329054b44505Smrg func_verbose "generating symbol list for \`$output'" 32914a041c5bSmacallan 329254b44505Smrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 32934a041c5bSmacallan 329454b44505Smrg # Add our own program objects to the symbol list. 329554b44505Smrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 329654b44505Smrg for progfile in $progfiles; do 329754b44505Smrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 329854b44505Smrg func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 329954b44505Smrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 33004a041c5bSmacallan done 33014a041c5bSmacallan 330254b44505Smrg if test -n "$exclude_expsyms"; then 330354b44505Smrg $opt_dry_run || { 330454b44505Smrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 330554b44505Smrg eval '$MV "$nlist"T "$nlist"' 330654b44505Smrg } 330754b44505Smrg fi 33084a041c5bSmacallan 330954b44505Smrg if test -n "$export_symbols_regex"; then 331054b44505Smrg $opt_dry_run || { 331154b44505Smrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 331254b44505Smrg eval '$MV "$nlist"T "$nlist"' 331354b44505Smrg } 331454b44505Smrg fi 33154a041c5bSmacallan 331654b44505Smrg # Prepare the list of exported symbols 331754b44505Smrg if test -z "$export_symbols"; then 331854b44505Smrg export_symbols="$output_objdir/$outputname.exp" 331954b44505Smrg $opt_dry_run || { 332054b44505Smrg $RM $export_symbols 332154b44505Smrg eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 332254b44505Smrg case $host in 332354b44505Smrg *cygwin* | *mingw* | *cegcc* ) 332454b44505Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 332554b44505Smrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 332654b44505Smrg ;; 332754b44505Smrg esac 332854b44505Smrg } 332954b44505Smrg else 333054b44505Smrg $opt_dry_run || { 333154b44505Smrg eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 333254b44505Smrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 333354b44505Smrg eval '$MV "$nlist"T "$nlist"' 333454b44505Smrg case $host in 333554b44505Smrg *cygwin* | *mingw* | *cegcc* ) 333654b44505Smrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 333754b44505Smrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 333854b44505Smrg ;; 333954b44505Smrg esac 334054b44505Smrg } 334154b44505Smrg fi 334254b44505Smrg fi 33434a041c5bSmacallan 334454b44505Smrg for dlprefile in $dlprefiles; do 334554b44505Smrg func_verbose "extracting global C symbols from \`$dlprefile'" 334654b44505Smrg func_basename "$dlprefile" 334754b44505Smrg name="$func_basename_result" 334854b44505Smrg case $host in 334954b44505Smrg *cygwin* | *mingw* | *cegcc* ) 335054b44505Smrg # if an import library, we need to obtain dlname 335154b44505Smrg if func_win32_import_lib_p "$dlprefile"; then 335254b44505Smrg func_tr_sh "$dlprefile" 335354b44505Smrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 335454b44505Smrg dlprefile_dlbasename="" 335554b44505Smrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 335654b44505Smrg # Use subshell, to avoid clobbering current variable values 335754b44505Smrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 335854b44505Smrg if test -n "$dlprefile_dlname" ; then 335954b44505Smrg func_basename "$dlprefile_dlname" 336054b44505Smrg dlprefile_dlbasename="$func_basename_result" 336154b44505Smrg else 336254b44505Smrg # no lafile. user explicitly requested -dlpreopen <import library>. 336354b44505Smrg $sharedlib_from_linklib_cmd "$dlprefile" 336454b44505Smrg dlprefile_dlbasename=$sharedlib_from_linklib_result 336554b44505Smrg fi 336654b44505Smrg fi 336754b44505Smrg $opt_dry_run || { 336854b44505Smrg if test -n "$dlprefile_dlbasename" ; then 336954b44505Smrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 337054b44505Smrg else 337154b44505Smrg func_warning "Could not compute DLL name from $name" 337254b44505Smrg eval '$ECHO ": $name " >> "$nlist"' 337354b44505Smrg fi 337454b44505Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 337554b44505Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 337654b44505Smrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 337754b44505Smrg } 337854b44505Smrg else # not an import lib 337954b44505Smrg $opt_dry_run || { 338054b44505Smrg eval '$ECHO ": $name " >> "$nlist"' 338154b44505Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 338254b44505Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 338354b44505Smrg } 338454b44505Smrg fi 338554b44505Smrg ;; 338654b44505Smrg *) 338754b44505Smrg $opt_dry_run || { 338854b44505Smrg eval '$ECHO ": $name " >> "$nlist"' 338954b44505Smrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 339054b44505Smrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 339154b44505Smrg } 339254b44505Smrg ;; 339354b44505Smrg esac 339454b44505Smrg done 33954a041c5bSmacallan 339654b44505Smrg $opt_dry_run || { 339754b44505Smrg # Make sure we have at least an empty file. 339854b44505Smrg test -f "$nlist" || : > "$nlist" 33994a041c5bSmacallan 340054b44505Smrg if test -n "$exclude_expsyms"; then 340154b44505Smrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 340254b44505Smrg $MV "$nlist"T "$nlist" 340354b44505Smrg fi 34044a041c5bSmacallan 340554b44505Smrg # Try sorting and uniquifying the output. 340654b44505Smrg if $GREP -v "^: " < "$nlist" | 340754b44505Smrg if sort -k 3 </dev/null >/dev/null 2>&1; then 340854b44505Smrg sort -k 3 340954b44505Smrg else 341054b44505Smrg sort +2 341154b44505Smrg fi | 341254b44505Smrg uniq > "$nlist"S; then 341354b44505Smrg : 341454b44505Smrg else 341554b44505Smrg $GREP -v "^: " < "$nlist" > "$nlist"S 341654b44505Smrg fi 34174a041c5bSmacallan 341854b44505Smrg if test -f "$nlist"S; then 341954b44505Smrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 342054b44505Smrg else 342154b44505Smrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 342254b44505Smrg fi 34234a041c5bSmacallan 342454b44505Smrg echo >> "$output_objdir/$my_dlsyms" "\ 342554b44505Smrg 342654b44505Smrg/* The mapping between symbol names and symbols. */ 342754b44505Smrgtypedef struct { 342854b44505Smrg const char *name; 342954b44505Smrg void *address; 343054b44505Smrg} lt_dlsymlist; 343154b44505Smrgextern LT_DLSYM_CONST lt_dlsymlist 343254b44505Smrglt_${my_prefix}_LTX_preloaded_symbols[]; 343354b44505SmrgLT_DLSYM_CONST lt_dlsymlist 343454b44505Smrglt_${my_prefix}_LTX_preloaded_symbols[] = 343554b44505Smrg{\ 343654b44505Smrg { \"$my_originator\", (void *) 0 }," 343754b44505Smrg 343854b44505Smrg case $need_lib_prefix in 343954b44505Smrg no) 344054b44505Smrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 34414a041c5bSmacallan ;; 34424a041c5bSmacallan *) 344354b44505Smrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 34444a041c5bSmacallan ;; 34454a041c5bSmacallan esac 344654b44505Smrg echo >> "$output_objdir/$my_dlsyms" "\ 344754b44505Smrg {0, (void *) 0} 344854b44505Smrg}; 34494a041c5bSmacallan 345054b44505Smrg/* This works around a problem in FreeBSD linker */ 345154b44505Smrg#ifdef FREEBSD_WORKAROUND 345254b44505Smrgstatic const void *lt_preloaded_setup() { 345354b44505Smrg return lt_${my_prefix}_LTX_preloaded_symbols; 345454b44505Smrg} 345554b44505Smrg#endif 34564a041c5bSmacallan 345754b44505Smrg#ifdef __cplusplus 345854b44505Smrg} 345954b44505Smrg#endif\ 346054b44505Smrg" 346154b44505Smrg } # !$opt_dry_run 34624a041c5bSmacallan 346354b44505Smrg pic_flag_for_symtable= 346454b44505Smrg case "$compile_command " in 346554b44505Smrg *" -static "*) ;; 346654b44505Smrg *) 346754b44505Smrg case $host in 346854b44505Smrg # compiling the symbol table file with pic_flag works around 346954b44505Smrg # a FreeBSD bug that causes programs to crash when -lm is 347054b44505Smrg # linked before any other PIC object. But we must not use 347154b44505Smrg # pic_flag when linking with -static. The problem exists in 347254b44505Smrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 347354b44505Smrg *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 347454b44505Smrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 347554b44505Smrg *-*-hpux*) 347654b44505Smrg pic_flag_for_symtable=" $pic_flag" ;; 347754b44505Smrg *) 347854b44505Smrg if test "X$my_pic_p" != Xno; then 347954b44505Smrg pic_flag_for_symtable=" $pic_flag" 348054b44505Smrg fi 348154b44505Smrg ;; 348254b44505Smrg esac 348354b44505Smrg ;; 348454b44505Smrg esac 348554b44505Smrg symtab_cflags= 348654b44505Smrg for arg in $LTCFLAGS; do 348754b44505Smrg case $arg in 348854b44505Smrg -pie | -fpie | -fPIE) ;; 348954b44505Smrg *) func_append symtab_cflags " $arg" ;; 34904a041c5bSmacallan esac 34914a041c5bSmacallan done 34924a041c5bSmacallan 349354b44505Smrg # Now compile the dynamic symbol file. 349454b44505Smrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 34954a041c5bSmacallan 349654b44505Smrg # Clean up the generated files. 349754b44505Smrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 34984a041c5bSmacallan 349954b44505Smrg # Transform the symbol file into the correct name. 350054b44505Smrg symfileobj="$output_objdir/${my_outputname}S.$objext" 350154b44505Smrg case $host in 350254b44505Smrg *cygwin* | *mingw* | *cegcc* ) 350354b44505Smrg if test -f "$output_objdir/$my_outputname.def"; then 350454b44505Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350554b44505Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 350654b44505Smrg else 350754b44505Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 350854b44505Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 350954b44505Smrg fi 351054b44505Smrg ;; 351154b44505Smrg *) 351254b44505Smrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351354b44505Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 351454b44505Smrg ;; 351554b44505Smrg esac 351654b44505Smrg ;; 351754b44505Smrg *) 351854b44505Smrg func_fatal_error "unknown suffix for \`$my_dlsyms'" 351954b44505Smrg ;; 352054b44505Smrg esac 352154b44505Smrg else 352254b44505Smrg # We keep going just in case the user didn't refer to 352354b44505Smrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 352454b44505Smrg # really was required. 35254a041c5bSmacallan 352654b44505Smrg # Nullify the symbol file. 352754b44505Smrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 352854b44505Smrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 352954b44505Smrg fi 353054b44505Smrg} 35314a041c5bSmacallan 353254b44505Smrg# func_win32_libid arg 353354b44505Smrg# return the library type of file 'arg' 353454b44505Smrg# 353554b44505Smrg# Need a lot of goo to handle *both* DLLs and import libs 353654b44505Smrg# Has to be a shell function in order to 'eat' the argument 353754b44505Smrg# that is supplied when $file_magic_command is called. 353854b44505Smrg# Despite the name, also deal with 64 bit binaries. 353954b44505Smrgfunc_win32_libid () 354054b44505Smrg{ 354154b44505Smrg $opt_debug 354254b44505Smrg win32_libid_type="unknown" 354354b44505Smrg win32_fileres=`file -L $1 2>/dev/null` 354454b44505Smrg case $win32_fileres in 354554b44505Smrg *ar\ archive\ import\ library*) # definitely import 354654b44505Smrg win32_libid_type="x86 archive import" 354754b44505Smrg ;; 354854b44505Smrg *ar\ archive*) # could be an import, or static 354954b44505Smrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 355054b44505Smrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 355154b44505Smrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 355254b44505Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 355354b44505Smrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 355454b44505Smrg $SED -n -e ' 355554b44505Smrg 1,100{ 355654b44505Smrg / I /{ 355754b44505Smrg s,.*,import, 355854b44505Smrg p 355954b44505Smrg q 356054b44505Smrg } 356154b44505Smrg }'` 356254b44505Smrg case $win32_nmres in 356354b44505Smrg import*) win32_libid_type="x86 archive import";; 356454b44505Smrg *) win32_libid_type="x86 archive static";; 356554b44505Smrg esac 356654b44505Smrg fi 356754b44505Smrg ;; 356854b44505Smrg *DLL*) 356954b44505Smrg win32_libid_type="x86 DLL" 357054b44505Smrg ;; 357154b44505Smrg *executable*) # but shell scripts are "executable" too... 357254b44505Smrg case $win32_fileres in 357354b44505Smrg *MS\ Windows\ PE\ Intel*) 357454b44505Smrg win32_libid_type="x86 DLL" 357554b44505Smrg ;; 357654b44505Smrg esac 357754b44505Smrg ;; 357854b44505Smrg esac 357954b44505Smrg $ECHO "$win32_libid_type" 358054b44505Smrg} 358154b44505Smrg 358254b44505Smrg# func_cygming_dll_for_implib ARG 358354b44505Smrg# 358454b44505Smrg# Platform-specific function to extract the 358554b44505Smrg# name of the DLL associated with the specified 358654b44505Smrg# import library ARG. 358754b44505Smrg# Invoked by eval'ing the libtool variable 358854b44505Smrg# $sharedlib_from_linklib_cmd 358954b44505Smrg# Result is available in the variable 359054b44505Smrg# $sharedlib_from_linklib_result 359154b44505Smrgfunc_cygming_dll_for_implib () 359254b44505Smrg{ 359354b44505Smrg $opt_debug 359454b44505Smrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 359554b44505Smrg} 359654b44505Smrg 359754b44505Smrg# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 359854b44505Smrg# 359954b44505Smrg# The is the core of a fallback implementation of a 360054b44505Smrg# platform-specific function to extract the name of the 360154b44505Smrg# DLL associated with the specified import library LIBNAME. 360254b44505Smrg# 360354b44505Smrg# SECTION_NAME is either .idata$6 or .idata$7, depending 360454b44505Smrg# on the platform and compiler that created the implib. 360554b44505Smrg# 360654b44505Smrg# Echos the name of the DLL associated with the 360754b44505Smrg# specified import library. 360854b44505Smrgfunc_cygming_dll_for_implib_fallback_core () 360954b44505Smrg{ 361054b44505Smrg $opt_debug 361154b44505Smrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 361254b44505Smrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 361354b44505Smrg $SED '/^Contents of section '"$match_literal"':/{ 361454b44505Smrg # Place marker at beginning of archive member dllname section 361554b44505Smrg s/.*/====MARK====/ 361654b44505Smrg p 361754b44505Smrg d 361854b44505Smrg } 361954b44505Smrg # These lines can sometimes be longer than 43 characters, but 362054b44505Smrg # are always uninteresting 362154b44505Smrg /:[ ]*file format pe[i]\{,1\}-/d 362254b44505Smrg /^In archive [^:]*:/d 362354b44505Smrg # Ensure marker is printed 362454b44505Smrg /^====MARK====/p 362554b44505Smrg # Remove all lines with less than 43 characters 362654b44505Smrg /^.\{43\}/!d 362754b44505Smrg # From remaining lines, remove first 43 characters 362854b44505Smrg s/^.\{43\}//' | 362954b44505Smrg $SED -n ' 363054b44505Smrg # Join marker and all lines until next marker into a single line 363154b44505Smrg /^====MARK====/ b para 363254b44505Smrg H 363354b44505Smrg $ b para 363454b44505Smrg b 363554b44505Smrg :para 363654b44505Smrg x 363754b44505Smrg s/\n//g 363854b44505Smrg # Remove the marker 363954b44505Smrg s/^====MARK====// 364054b44505Smrg # Remove trailing dots and whitespace 364154b44505Smrg s/[\. \t]*$// 364254b44505Smrg # Print 364354b44505Smrg /./p' | 364454b44505Smrg # we now have a list, one entry per line, of the stringified 364554b44505Smrg # contents of the appropriate section of all members of the 364654b44505Smrg # archive which possess that section. Heuristic: eliminate 364754b44505Smrg # all those which have a first or second character that is 364854b44505Smrg # a '.' (that is, objdump's representation of an unprintable 364954b44505Smrg # character.) This should work for all archives with less than 365054b44505Smrg # 0x302f exports -- but will fail for DLLs whose name actually 365154b44505Smrg # begins with a literal '.' or a single character followed by 365254b44505Smrg # a '.'. 365354b44505Smrg # 365454b44505Smrg # Of those that remain, print the first one. 365554b44505Smrg $SED -e '/^\./d;/^.\./d;q' 365654b44505Smrg} 365754b44505Smrg 365854b44505Smrg# func_cygming_gnu_implib_p ARG 365954b44505Smrg# This predicate returns with zero status (TRUE) if 366054b44505Smrg# ARG is a GNU/binutils-style import library. Returns 366154b44505Smrg# with nonzero status (FALSE) otherwise. 366254b44505Smrgfunc_cygming_gnu_implib_p () 366354b44505Smrg{ 366454b44505Smrg $opt_debug 366554b44505Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 366654b44505Smrg func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'` 366754b44505Smrg test -n "$func_cygming_gnu_implib_tmp" 366854b44505Smrg} 366954b44505Smrg 367054b44505Smrg# func_cygming_ms_implib_p ARG 367154b44505Smrg# This predicate returns with zero status (TRUE) if 367254b44505Smrg# ARG is an MS-style import library. Returns 367354b44505Smrg# with nonzero status (FALSE) otherwise. 367454b44505Smrgfunc_cygming_ms_implib_p () 367554b44505Smrg{ 367654b44505Smrg $opt_debug 367754b44505Smrg func_to_tool_file "$1" func_convert_file_msys_to_w32 367854b44505Smrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 367954b44505Smrg test -n "$func_cygming_ms_implib_tmp" 368054b44505Smrg} 368154b44505Smrg 368254b44505Smrg# func_cygming_dll_for_implib_fallback ARG 368354b44505Smrg# Platform-specific function to extract the 368454b44505Smrg# name of the DLL associated with the specified 368554b44505Smrg# import library ARG. 368654b44505Smrg# 368754b44505Smrg# This fallback implementation is for use when $DLLTOOL 368854b44505Smrg# does not support the --identify-strict option. 368954b44505Smrg# Invoked by eval'ing the libtool variable 369054b44505Smrg# $sharedlib_from_linklib_cmd 369154b44505Smrg# Result is available in the variable 369254b44505Smrg# $sharedlib_from_linklib_result 369354b44505Smrgfunc_cygming_dll_for_implib_fallback () 369454b44505Smrg{ 369554b44505Smrg $opt_debug 369654b44505Smrg if func_cygming_gnu_implib_p "$1" ; then 369754b44505Smrg # binutils import library 369854b44505Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 369954b44505Smrg elif func_cygming_ms_implib_p "$1" ; then 370054b44505Smrg # ms-generated import library 370154b44505Smrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 370254b44505Smrg else 370354b44505Smrg # unknown 370454b44505Smrg sharedlib_from_linklib_result="" 370554b44505Smrg fi 370654b44505Smrg} 370754b44505Smrg 370854b44505Smrg 370954b44505Smrg# func_extract_an_archive dir oldlib 371054b44505Smrgfunc_extract_an_archive () 371154b44505Smrg{ 371254b44505Smrg $opt_debug 371354b44505Smrg f_ex_an_ar_dir="$1"; shift 371454b44505Smrg f_ex_an_ar_oldlib="$1" 371554b44505Smrg if test "$lock_old_archive_extraction" = yes; then 371654b44505Smrg lockfile=$f_ex_an_ar_oldlib.lock 371754b44505Smrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 371854b44505Smrg func_echo "Waiting for $lockfile to be removed" 371954b44505Smrg sleep 2 37204a041c5bSmacallan done 372154b44505Smrg fi 372254b44505Smrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 372354b44505Smrg 'stat=$?; rm -f "$lockfile"; exit $stat' 372454b44505Smrg if test "$lock_old_archive_extraction" = yes; then 372554b44505Smrg $opt_dry_run || rm -f "$lockfile" 372654b44505Smrg fi 372754b44505Smrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 372854b44505Smrg : 372954b44505Smrg else 373054b44505Smrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 373154b44505Smrg fi 373254b44505Smrg} 37334a041c5bSmacallan 373454b44505Smrg 373554b44505Smrg# func_extract_archives gentop oldlib ... 373654b44505Smrgfunc_extract_archives () 373754b44505Smrg{ 373854b44505Smrg $opt_debug 373954b44505Smrg my_gentop="$1"; shift 374054b44505Smrg my_oldlibs=${1+"$@"} 374154b44505Smrg my_oldobjs="" 374254b44505Smrg my_xlib="" 374354b44505Smrg my_xabs="" 374454b44505Smrg my_xdir="" 374554b44505Smrg 374654b44505Smrg for my_xlib in $my_oldlibs; do 374754b44505Smrg # Extract the objects. 374854b44505Smrg case $my_xlib in 374954b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 375054b44505Smrg *) my_xabs=`pwd`"/$my_xlib" ;; 375154b44505Smrg esac 375254b44505Smrg func_basename "$my_xlib" 375354b44505Smrg my_xlib="$func_basename_result" 375454b44505Smrg my_xlib_u=$my_xlib 375554b44505Smrg while :; do 375654b44505Smrg case " $extracted_archives " in 375754b44505Smrg *" $my_xlib_u "*) 375854b44505Smrg func_arith $extracted_serial + 1 375954b44505Smrg extracted_serial=$func_arith_result 376054b44505Smrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 376154b44505Smrg *) break ;; 37624a041c5bSmacallan esac 37634a041c5bSmacallan done 376454b44505Smrg extracted_archives="$extracted_archives $my_xlib_u" 376554b44505Smrg my_xdir="$my_gentop/$my_xlib_u" 37664a041c5bSmacallan 376754b44505Smrg func_mkdir_p "$my_xdir" 37684a041c5bSmacallan 376954b44505Smrg case $host in 377054b44505Smrg *-darwin*) 377154b44505Smrg func_verbose "Extracting $my_xabs" 377254b44505Smrg # Do not bother doing anything if just a dry run 377354b44505Smrg $opt_dry_run || { 377454b44505Smrg darwin_orig_dir=`pwd` 377554b44505Smrg cd $my_xdir || exit $? 377654b44505Smrg darwin_archive=$my_xabs 377754b44505Smrg darwin_curdir=`pwd` 377854b44505Smrg darwin_base_archive=`basename "$darwin_archive"` 377954b44505Smrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 378054b44505Smrg if test -n "$darwin_arches"; then 378154b44505Smrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 378254b44505Smrg darwin_arch= 378354b44505Smrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 378454b44505Smrg for darwin_arch in $darwin_arches ; do 378554b44505Smrg func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 378654b44505Smrg $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 378754b44505Smrg cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 378854b44505Smrg func_extract_an_archive "`pwd`" "${darwin_base_archive}" 378954b44505Smrg cd "$darwin_curdir" 379054b44505Smrg $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 379154b44505Smrg done # $darwin_arches 379254b44505Smrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 379354b44505Smrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 379454b44505Smrg darwin_file= 379554b44505Smrg darwin_files= 379654b44505Smrg for darwin_file in $darwin_filelist; do 379754b44505Smrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 379854b44505Smrg $LIPO -create -output "$darwin_file" $darwin_files 379954b44505Smrg done # $darwin_filelist 380054b44505Smrg $RM -rf unfat-$$ 380154b44505Smrg cd "$darwin_orig_dir" 38024a041c5bSmacallan else 380354b44505Smrg cd $darwin_orig_dir 380454b44505Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 380554b44505Smrg fi # $darwin_arches 380654b44505Smrg } # !$opt_dry_run 380754b44505Smrg ;; 380854b44505Smrg *) 380954b44505Smrg func_extract_an_archive "$my_xdir" "$my_xabs" 381054b44505Smrg ;; 381154b44505Smrg esac 381254b44505Smrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 381354b44505Smrg done 38144a041c5bSmacallan 381554b44505Smrg func_extract_archives_result="$my_oldobjs" 381654b44505Smrg} 38174a041c5bSmacallan 38184a041c5bSmacallan 381954b44505Smrg# func_emit_wrapper [arg=no] 382054b44505Smrg# 382154b44505Smrg# Emit a libtool wrapper script on stdout. 382254b44505Smrg# Don't directly open a file because we may want to 382354b44505Smrg# incorporate the script contents within a cygwin/mingw 382454b44505Smrg# wrapper executable. Must ONLY be called from within 382554b44505Smrg# func_mode_link because it depends on a number of variables 382654b44505Smrg# set therein. 382754b44505Smrg# 382854b44505Smrg# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 382954b44505Smrg# variable will take. If 'yes', then the emitted script 383054b44505Smrg# will assume that the directory in which it is stored is 383154b44505Smrg# the $objdir directory. This is a cygwin/mingw-specific 383254b44505Smrg# behavior. 383354b44505Smrgfunc_emit_wrapper () 383454b44505Smrg{ 383554b44505Smrg func_emit_wrapper_arg1=${1-no} 38364a041c5bSmacallan 383754b44505Smrg $ECHO "\ 383854b44505Smrg#! $SHELL 38394a041c5bSmacallan 384054b44505Smrg# $output - temporary wrapper script for $objdir/$outputname 384154b44505Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 384254b44505Smrg# 384354b44505Smrg# The $output program cannot be directly executed until all the libtool 384454b44505Smrg# libraries that it depends on are installed. 384554b44505Smrg# 384654b44505Smrg# This wrapper script should never be moved out of the build directory. 384754b44505Smrg# If it is, it will not operate correctly. 38484a041c5bSmacallan 384954b44505Smrg# Sed substitution that helps us do robust quoting. It backslashifies 385054b44505Smrg# metacharacters that are still active within double-quoted strings. 385154b44505Smrgsed_quote_subst='$sed_quote_subst' 38524a041c5bSmacallan 385354b44505Smrg# Be Bourne compatible 385454b44505Smrgif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 385554b44505Smrg emulate sh 385654b44505Smrg NULLCMD=: 385754b44505Smrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 385854b44505Smrg # is contrary to our usage. Disable this feature. 385954b44505Smrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 386054b44505Smrg setopt NO_GLOB_SUBST 386154b44505Smrgelse 386254b44505Smrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 386354b44505Smrgfi 386454b44505SmrgBIN_SH=xpg4; export BIN_SH # for Tru64 386554b44505SmrgDUALCASE=1; export DUALCASE # for MKS sh 38664a041c5bSmacallan 386754b44505Smrg# The HP-UX ksh and POSIX shell print the target directory to stdout 386854b44505Smrg# if CDPATH is set. 386954b44505Smrg(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 38704a041c5bSmacallan 387154b44505Smrgrelink_command=\"$relink_command\" 38724a041c5bSmacallan 387354b44505Smrg# This environment variable determines our operation mode. 387454b44505Smrgif test \"\$libtool_install_magic\" = \"$magic\"; then 387554b44505Smrg # install mode needs the following variables: 387654b44505Smrg generated_by_libtool_version='$macro_version' 387754b44505Smrg notinst_deplibs='$notinst_deplibs' 387854b44505Smrgelse 387954b44505Smrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 388054b44505Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 388154b44505Smrg file=\"\$0\"" 38824a041c5bSmacallan 388354b44505Smrg qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 388454b44505Smrg $ECHO "\ 38854a041c5bSmacallan 388654b44505Smrg# A function that is used when there is no print builtin or printf. 388754b44505Smrgfunc_fallback_echo () 388854b44505Smrg{ 388954b44505Smrg eval 'cat <<_LTECHO_EOF 389054b44505Smrg\$1 389154b44505Smrg_LTECHO_EOF' 389254b44505Smrg} 389354b44505Smrg ECHO=\"$qECHO\" 389454b44505Smrg fi 38954a041c5bSmacallan 389654b44505Smrg# Very basic option parsing. These options are (a) specific to 389754b44505Smrg# the libtool wrapper, (b) are identical between the wrapper 389854b44505Smrg# /script/ and the wrapper /executable/ which is used only on 389954b44505Smrg# windows platforms, and (c) all begin with the string "--lt-" 390054b44505Smrg# (application programs are unlikely to have options which match 390154b44505Smrg# this pattern). 390254b44505Smrg# 390354b44505Smrg# There are only two supported options: --lt-debug and 390454b44505Smrg# --lt-dump-script. There is, deliberately, no --lt-help. 390554b44505Smrg# 390654b44505Smrg# The first argument to this parsing function should be the 390754b44505Smrg# script's $0 value, followed by "$@". 390854b44505Smrglt_option_debug= 390954b44505Smrgfunc_parse_lt_options () 391054b44505Smrg{ 391154b44505Smrg lt_script_arg0=\$0 391254b44505Smrg shift 391354b44505Smrg for lt_opt 391454b44505Smrg do 391554b44505Smrg case \"\$lt_opt\" in 391654b44505Smrg --lt-debug) lt_option_debug=1 ;; 391754b44505Smrg --lt-dump-script) 391854b44505Smrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 391954b44505Smrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 392054b44505Smrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 392154b44505Smrg cat \"\$lt_dump_D/\$lt_dump_F\" 392254b44505Smrg exit 0 392354b44505Smrg ;; 392454b44505Smrg --lt-*) 392554b44505Smrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 392654b44505Smrg exit 1 392754b44505Smrg ;; 392854b44505Smrg esac 392954b44505Smrg done 39304a041c5bSmacallan 393154b44505Smrg # Print the debug banner immediately: 393254b44505Smrg if test -n \"\$lt_option_debug\"; then 393354b44505Smrg echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 393454b44505Smrg fi 393554b44505Smrg} 39364a041c5bSmacallan 393754b44505Smrg# Used when --lt-debug. Prints its arguments to stdout 393854b44505Smrg# (redirection is the responsibility of the caller) 393954b44505Smrgfunc_lt_dump_args () 394054b44505Smrg{ 394154b44505Smrg lt_dump_args_N=1; 394254b44505Smrg for lt_arg 394354b44505Smrg do 394454b44505Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 394554b44505Smrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 394654b44505Smrg done 394754b44505Smrg} 39484a041c5bSmacallan 394954b44505Smrg# Core function for launching the target application 395054b44505Smrgfunc_exec_program_core () 395154b44505Smrg{ 395254b44505Smrg" 395354b44505Smrg case $host in 395454b44505Smrg # Backslashes separate directories on plain windows 395554b44505Smrg *-*-mingw | *-*-os2* | *-cegcc*) 395654b44505Smrg $ECHO "\ 395754b44505Smrg if test -n \"\$lt_option_debug\"; then 395854b44505Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 395954b44505Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 396054b44505Smrg fi 396154b44505Smrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 396254b44505Smrg" 396354b44505Smrg ;; 39644a041c5bSmacallan 396554b44505Smrg *) 396654b44505Smrg $ECHO "\ 396754b44505Smrg if test -n \"\$lt_option_debug\"; then 396854b44505Smrg \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 396954b44505Smrg func_lt_dump_args \${1+\"\$@\"} 1>&2 397054b44505Smrg fi 397154b44505Smrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 397254b44505Smrg" 397354b44505Smrg ;; 397454b44505Smrg esac 397554b44505Smrg $ECHO "\ 397654b44505Smrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 397754b44505Smrg exit 1 397854b44505Smrg} 39794a041c5bSmacallan 398054b44505Smrg# A function to encapsulate launching the target application 398154b44505Smrg# Strips options in the --lt-* namespace from \$@ and 398254b44505Smrg# launches target application with the remaining arguments. 398354b44505Smrgfunc_exec_program () 398454b44505Smrg{ 398554b44505Smrg for lt_wr_arg 398654b44505Smrg do 398754b44505Smrg case \$lt_wr_arg in 398854b44505Smrg --lt-*) ;; 398954b44505Smrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 399054b44505Smrg esac 399154b44505Smrg shift 399254b44505Smrg done 399354b44505Smrg func_exec_program_core \${1+\"\$@\"} 399454b44505Smrg} 39954a041c5bSmacallan 399654b44505Smrg # Parse options 399754b44505Smrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 39984a041c5bSmacallan 399954b44505Smrg # Find the directory that this script lives in. 400054b44505Smrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 400154b44505Smrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 40024a041c5bSmacallan 400354b44505Smrg # Follow symbolic links until we get to the real thisdir. 400454b44505Smrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 400554b44505Smrg while test -n \"\$file\"; do 400654b44505Smrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 40074a041c5bSmacallan 400854b44505Smrg # If there was a directory component, then change thisdir. 400954b44505Smrg if test \"x\$destdir\" != \"x\$file\"; then 401054b44505Smrg case \"\$destdir\" in 401154b44505Smrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 401254b44505Smrg *) thisdir=\"\$thisdir/\$destdir\" ;; 401354b44505Smrg esac 401454b44505Smrg fi 40154a041c5bSmacallan 401654b44505Smrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 401754b44505Smrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 401854b44505Smrg done 40194a041c5bSmacallan 402054b44505Smrg # Usually 'no', except on cygwin/mingw when embedded into 402154b44505Smrg # the cwrapper. 402254b44505Smrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 402354b44505Smrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 402454b44505Smrg # special case for '.' 402554b44505Smrg if test \"\$thisdir\" = \".\"; then 402654b44505Smrg thisdir=\`pwd\` 402754b44505Smrg fi 402854b44505Smrg # remove .libs from thisdir 402954b44505Smrg case \"\$thisdir\" in 403054b44505Smrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 403154b44505Smrg $objdir ) thisdir=. ;; 403254b44505Smrg esac 403354b44505Smrg fi 40344a041c5bSmacallan 403554b44505Smrg # Try to get the absolute directory name. 403654b44505Smrg absdir=\`cd \"\$thisdir\" && pwd\` 403754b44505Smrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 403854b44505Smrg" 40394a041c5bSmacallan 404054b44505Smrg if test "$fast_install" = yes; then 404154b44505Smrg $ECHO "\ 404254b44505Smrg program=lt-'$outputname'$exeext 404354b44505Smrg progdir=\"\$thisdir/$objdir\" 40444a041c5bSmacallan 404554b44505Smrg if test ! -f \"\$progdir/\$program\" || 404654b44505Smrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 404754b44505Smrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 40484a041c5bSmacallan 404954b44505Smrg file=\"\$\$-\$program\" 40504a041c5bSmacallan 405154b44505Smrg if test ! -d \"\$progdir\"; then 405254b44505Smrg $MKDIR \"\$progdir\" 405354b44505Smrg else 405454b44505Smrg $RM \"\$progdir/\$file\" 405554b44505Smrg fi" 40564a041c5bSmacallan 405754b44505Smrg $ECHO "\ 40584a041c5bSmacallan 405954b44505Smrg # relink executable if necessary 406054b44505Smrg if test -n \"\$relink_command\"; then 406154b44505Smrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 406254b44505Smrg else 406354b44505Smrg $ECHO \"\$relink_command_output\" >&2 406454b44505Smrg $RM \"\$progdir/\$file\" 406554b44505Smrg exit 1 406654b44505Smrg fi 406754b44505Smrg fi 40684a041c5bSmacallan 406954b44505Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 407054b44505Smrg { $RM \"\$progdir/\$program\"; 407154b44505Smrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 407254b44505Smrg $RM \"\$progdir/\$file\" 407354b44505Smrg fi" 407454b44505Smrg else 407554b44505Smrg $ECHO "\ 407654b44505Smrg program='$outputname' 407754b44505Smrg progdir=\"\$thisdir/$objdir\" 407854b44505Smrg" 40794a041c5bSmacallan fi 40804a041c5bSmacallan 408154b44505Smrg $ECHO "\ 40824a041c5bSmacallan 408354b44505Smrg if test -f \"\$progdir/\$program\"; then" 40844a041c5bSmacallan 408554b44505Smrg # fixup the dll searchpath if we need to. 408654b44505Smrg # 408754b44505Smrg # Fix the DLL searchpath if we need to. Do this before prepending 408854b44505Smrg # to shlibpath, because on Windows, both are PATH and uninstalled 408954b44505Smrg # libraries must come first. 409054b44505Smrg if test -n "$dllsearchpath"; then 409154b44505Smrg $ECHO "\ 409254b44505Smrg # Add the dll search path components to the executable PATH 409354b44505Smrg PATH=$dllsearchpath:\$PATH 409454b44505Smrg" 409554b44505Smrg fi 40964a041c5bSmacallan 409754b44505Smrg # Export our shlibpath_var if we have one. 409854b44505Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 409954b44505Smrg $ECHO "\ 410054b44505Smrg # Add our own library path to $shlibpath_var 410154b44505Smrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 41024a041c5bSmacallan 410354b44505Smrg # Some systems cannot cope with colon-terminated $shlibpath_var 410454b44505Smrg # The second colon is a workaround for a bug in BeOS R4 sed 410554b44505Smrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 41064a041c5bSmacallan 410754b44505Smrg export $shlibpath_var 410854b44505Smrg" 410954b44505Smrg fi 41104a041c5bSmacallan 411154b44505Smrg $ECHO "\ 411254b44505Smrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 411354b44505Smrg # Run the actual program with our arguments. 411454b44505Smrg func_exec_program \${1+\"\$@\"} 411554b44505Smrg fi 411654b44505Smrg else 411754b44505Smrg # The program doesn't exist. 411854b44505Smrg \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 411954b44505Smrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 412054b44505Smrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 412154b44505Smrg exit 1 412254b44505Smrg fi 412354b44505Smrgfi\ 412454b44505Smrg" 412554b44505Smrg} 41264a041c5bSmacallan 41274a041c5bSmacallan 412854b44505Smrg# func_emit_cwrapperexe_src 412954b44505Smrg# emit the source code for a wrapper executable on stdout 413054b44505Smrg# Must ONLY be called from within func_mode_link because 413154b44505Smrg# it depends on a number of variable set therein. 413254b44505Smrgfunc_emit_cwrapperexe_src () 413354b44505Smrg{ 413454b44505Smrg cat <<EOF 41354a041c5bSmacallan 413654b44505Smrg/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 413754b44505Smrg Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 41384a041c5bSmacallan 413954b44505Smrg The $output program cannot be directly executed until all the libtool 414054b44505Smrg libraries that it depends on are installed. 41414a041c5bSmacallan 414254b44505Smrg This wrapper executable should never be moved out of the build directory. 414354b44505Smrg If it is, it will not operate correctly. 414454b44505Smrg*/ 414554b44505SmrgEOF 414654b44505Smrg cat <<"EOF" 414754b44505Smrg#ifdef _MSC_VER 414854b44505Smrg# define _CRT_SECURE_NO_DEPRECATE 1 414954b44505Smrg#endif 415054b44505Smrg#include <stdio.h> 415154b44505Smrg#include <stdlib.h> 415254b44505Smrg#ifdef _MSC_VER 415354b44505Smrg# include <direct.h> 415454b44505Smrg# include <process.h> 415554b44505Smrg# include <io.h> 415654b44505Smrg#else 415754b44505Smrg# include <unistd.h> 415854b44505Smrg# include <stdint.h> 415954b44505Smrg# ifdef __CYGWIN__ 416054b44505Smrg# include <io.h> 416154b44505Smrg# endif 416254b44505Smrg#endif 416354b44505Smrg#include <malloc.h> 416454b44505Smrg#include <stdarg.h> 416554b44505Smrg#include <assert.h> 416654b44505Smrg#include <string.h> 416754b44505Smrg#include <ctype.h> 416854b44505Smrg#include <errno.h> 416954b44505Smrg#include <fcntl.h> 417054b44505Smrg#include <sys/stat.h> 41714a041c5bSmacallan 417254b44505Smrg/* declarations of non-ANSI functions */ 417354b44505Smrg#if defined(__MINGW32__) 417454b44505Smrg# ifdef __STRICT_ANSI__ 417554b44505Smrgint _putenv (const char *); 417654b44505Smrg# endif 417754b44505Smrg#elif defined(__CYGWIN__) 417854b44505Smrg# ifdef __STRICT_ANSI__ 417954b44505Smrgchar *realpath (const char *, char *); 418054b44505Smrgint putenv (char *); 418154b44505Smrgint setenv (const char *, const char *, int); 418254b44505Smrg# endif 418354b44505Smrg/* #elif defined (other platforms) ... */ 418454b44505Smrg#endif 41854a041c5bSmacallan 418654b44505Smrg/* portability defines, excluding path handling macros */ 418754b44505Smrg#if defined(_MSC_VER) 418854b44505Smrg# define setmode _setmode 418954b44505Smrg# define stat _stat 419054b44505Smrg# define chmod _chmod 419154b44505Smrg# define getcwd _getcwd 419254b44505Smrg# define putenv _putenv 419354b44505Smrg# define S_IXUSR _S_IEXEC 419454b44505Smrg# ifndef _INTPTR_T_DEFINED 419554b44505Smrg# define _INTPTR_T_DEFINED 419654b44505Smrg# define intptr_t int 419754b44505Smrg# endif 419854b44505Smrg#elif defined(__MINGW32__) 419954b44505Smrg# define setmode _setmode 420054b44505Smrg# define stat _stat 420154b44505Smrg# define chmod _chmod 420254b44505Smrg# define getcwd _getcwd 420354b44505Smrg# define putenv _putenv 420454b44505Smrg#elif defined(__CYGWIN__) 420554b44505Smrg# define HAVE_SETENV 420654b44505Smrg# define FOPEN_WB "wb" 420754b44505Smrg/* #elif defined (other platforms) ... */ 420854b44505Smrg#endif 42094a041c5bSmacallan 421054b44505Smrg#if defined(PATH_MAX) 421154b44505Smrg# define LT_PATHMAX PATH_MAX 421254b44505Smrg#elif defined(MAXPATHLEN) 421354b44505Smrg# define LT_PATHMAX MAXPATHLEN 421454b44505Smrg#else 421554b44505Smrg# define LT_PATHMAX 1024 421654b44505Smrg#endif 42174a041c5bSmacallan 421854b44505Smrg#ifndef S_IXOTH 421954b44505Smrg# define S_IXOTH 0 422054b44505Smrg#endif 422154b44505Smrg#ifndef S_IXGRP 422254b44505Smrg# define S_IXGRP 0 422354b44505Smrg#endif 42244a041c5bSmacallan 422554b44505Smrg/* path handling portability macros */ 422654b44505Smrg#ifndef DIR_SEPARATOR 422754b44505Smrg# define DIR_SEPARATOR '/' 422854b44505Smrg# define PATH_SEPARATOR ':' 422954b44505Smrg#endif 42304a041c5bSmacallan 423154b44505Smrg#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 423254b44505Smrg defined (__OS2__) 423354b44505Smrg# define HAVE_DOS_BASED_FILE_SYSTEM 423454b44505Smrg# define FOPEN_WB "wb" 423554b44505Smrg# ifndef DIR_SEPARATOR_2 423654b44505Smrg# define DIR_SEPARATOR_2 '\\' 423754b44505Smrg# endif 423854b44505Smrg# ifndef PATH_SEPARATOR_2 423954b44505Smrg# define PATH_SEPARATOR_2 ';' 424054b44505Smrg# endif 424154b44505Smrg#endif 42424a041c5bSmacallan 424354b44505Smrg#ifndef DIR_SEPARATOR_2 424454b44505Smrg# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 424554b44505Smrg#else /* DIR_SEPARATOR_2 */ 424654b44505Smrg# define IS_DIR_SEPARATOR(ch) \ 424754b44505Smrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 424854b44505Smrg#endif /* DIR_SEPARATOR_2 */ 42494a041c5bSmacallan 425054b44505Smrg#ifndef PATH_SEPARATOR_2 425154b44505Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 425254b44505Smrg#else /* PATH_SEPARATOR_2 */ 425354b44505Smrg# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 425454b44505Smrg#endif /* PATH_SEPARATOR_2 */ 42554a041c5bSmacallan 425654b44505Smrg#ifndef FOPEN_WB 425754b44505Smrg# define FOPEN_WB "w" 425854b44505Smrg#endif 425954b44505Smrg#ifndef _O_BINARY 426054b44505Smrg# define _O_BINARY 0 426154b44505Smrg#endif 42624a041c5bSmacallan 426354b44505Smrg#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 426454b44505Smrg#define XFREE(stale) do { \ 426554b44505Smrg if (stale) { free ((void *) stale); stale = 0; } \ 426654b44505Smrg} while (0) 42674a041c5bSmacallan 426854b44505Smrg#if defined(LT_DEBUGWRAPPER) 426954b44505Smrgstatic int lt_debug = 1; 427054b44505Smrg#else 427154b44505Smrgstatic int lt_debug = 0; 427254b44505Smrg#endif 42734a041c5bSmacallan 427454b44505Smrgconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 427554b44505Smrg 427654b44505Smrgvoid *xmalloc (size_t num); 427754b44505Smrgchar *xstrdup (const char *string); 427854b44505Smrgconst char *base_name (const char *name); 427954b44505Smrgchar *find_executable (const char *wrapper); 428054b44505Smrgchar *chase_symlinks (const char *pathspec); 428154b44505Smrgint make_executable (const char *path); 428254b44505Smrgint check_executable (const char *path); 428354b44505Smrgchar *strendzap (char *str, const char *pat); 428454b44505Smrgvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 428554b44505Smrgvoid lt_fatal (const char *file, int line, const char *message, ...); 428654b44505Smrgstatic const char *nonnull (const char *s); 428754b44505Smrgstatic const char *nonempty (const char *s); 428854b44505Smrgvoid lt_setenv (const char *name, const char *value); 428954b44505Smrgchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 429054b44505Smrgvoid lt_update_exe_path (const char *name, const char *value); 429154b44505Smrgvoid lt_update_lib_path (const char *name, const char *value); 429254b44505Smrgchar **prepare_spawn (char **argv); 429354b44505Smrgvoid lt_dump_script (FILE *f); 429454b44505SmrgEOF 42954a041c5bSmacallan 429654b44505Smrg cat <<EOF 429754b44505Smrgvolatile const char * MAGIC_EXE = "$magic_exe"; 429854b44505Smrgconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 429954b44505SmrgEOF 43004a041c5bSmacallan 430154b44505Smrg if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 430254b44505Smrg func_to_host_path "$temp_rpath" 430354b44505Smrg cat <<EOF 430454b44505Smrgconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 430554b44505SmrgEOF 430654b44505Smrg else 430754b44505Smrg cat <<"EOF" 430854b44505Smrgconst char * LIB_PATH_VALUE = ""; 430954b44505SmrgEOF 431054b44505Smrg fi 43114a041c5bSmacallan 431254b44505Smrg if test -n "$dllsearchpath"; then 431354b44505Smrg func_to_host_path "$dllsearchpath:" 431454b44505Smrg cat <<EOF 431554b44505Smrgconst char * EXE_PATH_VARNAME = "PATH"; 431654b44505Smrgconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 431754b44505SmrgEOF 431854b44505Smrg else 431954b44505Smrg cat <<"EOF" 432054b44505Smrgconst char * EXE_PATH_VARNAME = ""; 432154b44505Smrgconst char * EXE_PATH_VALUE = ""; 432254b44505SmrgEOF 432354b44505Smrg fi 43244a041c5bSmacallan 432554b44505Smrg if test "$fast_install" = yes; then 432654b44505Smrg cat <<EOF 432754b44505Smrgconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 432854b44505SmrgEOF 432954b44505Smrg else 433054b44505Smrg cat <<EOF 433154b44505Smrgconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 433254b44505SmrgEOF 433354b44505Smrg fi 43344a041c5bSmacallan 43354a041c5bSmacallan 433654b44505Smrg cat <<"EOF" 43374a041c5bSmacallan 433854b44505Smrg#define LTWRAPPER_OPTION_PREFIX "--lt-" 43394a041c5bSmacallan 434054b44505Smrgstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 434154b44505Smrgstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 434254b44505Smrgstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 434354b44505Smrg 434454b44505Smrgint 434554b44505Smrgmain (int argc, char *argv[]) 434654b44505Smrg{ 434754b44505Smrg char **newargz; 434854b44505Smrg int newargc; 434954b44505Smrg char *tmp_pathspec; 435054b44505Smrg char *actual_cwrapper_path; 435154b44505Smrg char *actual_cwrapper_name; 435254b44505Smrg char *target_name; 435354b44505Smrg char *lt_argv_zero; 435454b44505Smrg intptr_t rval = 127; 435554b44505Smrg 435654b44505Smrg int i; 435754b44505Smrg 435854b44505Smrg program_name = (char *) xstrdup (base_name (argv[0])); 435954b44505Smrg newargz = XMALLOC (char *, argc + 1); 436054b44505Smrg 436154b44505Smrg /* very simple arg parsing; don't want to rely on getopt 436254b44505Smrg * also, copy all non cwrapper options to newargz, except 436354b44505Smrg * argz[0], which is handled differently 436454b44505Smrg */ 436554b44505Smrg newargc=0; 436654b44505Smrg for (i = 1; i < argc; i++) 436754b44505Smrg { 436854b44505Smrg if (strcmp (argv[i], dumpscript_opt) == 0) 436954b44505Smrg { 437054b44505SmrgEOF 437154b44505Smrg case "$host" in 437254b44505Smrg *mingw* | *cygwin* ) 437354b44505Smrg # make stdout use "unix" line endings 437454b44505Smrg echo " setmode(1,_O_BINARY);" 43754a041c5bSmacallan ;; 43764a041c5bSmacallan esac 43774a041c5bSmacallan 437854b44505Smrg cat <<"EOF" 437954b44505Smrg lt_dump_script (stdout); 438054b44505Smrg return 0; 438154b44505Smrg } 438254b44505Smrg if (strcmp (argv[i], debug_opt) == 0) 438354b44505Smrg { 438454b44505Smrg lt_debug = 1; 438554b44505Smrg continue; 438654b44505Smrg } 438754b44505Smrg if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 438854b44505Smrg { 438954b44505Smrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 439054b44505Smrg namespace, but it is not one of the ones we know about and 439154b44505Smrg have already dealt with, above (inluding dump-script), then 439254b44505Smrg report an error. Otherwise, targets might begin to believe 439354b44505Smrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 439454b44505Smrg namespace. The first time any user complains about this, we'll 439554b44505Smrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 439654b44505Smrg or a configure.ac-settable value. 439754b44505Smrg */ 439854b44505Smrg lt_fatal (__FILE__, __LINE__, 439954b44505Smrg "unrecognized %s option: '%s'", 440054b44505Smrg ltwrapper_option_prefix, argv[i]); 440154b44505Smrg } 440254b44505Smrg /* otherwise ... */ 440354b44505Smrg newargz[++newargc] = xstrdup (argv[i]); 440454b44505Smrg } 440554b44505Smrg newargz[++newargc] = NULL; 44064a041c5bSmacallan 440754b44505SmrgEOF 440854b44505Smrg cat <<EOF 440954b44505Smrg /* The GNU banner must be the first non-error debug message */ 441054b44505Smrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 441154b44505SmrgEOF 441254b44505Smrg cat <<"EOF" 441354b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 441454b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 441554b44505Smrg 441654b44505Smrg tmp_pathspec = find_executable (argv[0]); 441754b44505Smrg if (tmp_pathspec == NULL) 441854b44505Smrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 441954b44505Smrg lt_debugprintf (__FILE__, __LINE__, 442054b44505Smrg "(main) found exe (before symlink chase) at: %s\n", 442154b44505Smrg tmp_pathspec); 442254b44505Smrg 442354b44505Smrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 442454b44505Smrg lt_debugprintf (__FILE__, __LINE__, 442554b44505Smrg "(main) found exe (after symlink chase) at: %s\n", 442654b44505Smrg actual_cwrapper_path); 442754b44505Smrg XFREE (tmp_pathspec); 442854b44505Smrg 442954b44505Smrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 443054b44505Smrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 443154b44505Smrg 443254b44505Smrg /* wrapper name transforms */ 443354b44505Smrg strendzap (actual_cwrapper_name, ".exe"); 443454b44505Smrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 443554b44505Smrg XFREE (actual_cwrapper_name); 443654b44505Smrg actual_cwrapper_name = tmp_pathspec; 443754b44505Smrg tmp_pathspec = 0; 443854b44505Smrg 443954b44505Smrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 444054b44505Smrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 444154b44505Smrg strendzap (target_name, ".exe"); 444254b44505Smrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 444354b44505Smrg XFREE (target_name); 444454b44505Smrg target_name = tmp_pathspec; 444554b44505Smrg tmp_pathspec = 0; 444654b44505Smrg 444754b44505Smrg lt_debugprintf (__FILE__, __LINE__, 444854b44505Smrg "(main) libtool target name: %s\n", 444954b44505Smrg target_name); 445054b44505SmrgEOF 44514a041c5bSmacallan 445254b44505Smrg cat <<EOF 445354b44505Smrg newargz[0] = 445454b44505Smrg XMALLOC (char, (strlen (actual_cwrapper_path) + 445554b44505Smrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 445654b44505Smrg strcpy (newargz[0], actual_cwrapper_path); 445754b44505Smrg strcat (newargz[0], "$objdir"); 445854b44505Smrg strcat (newargz[0], "/"); 445954b44505SmrgEOF 44604a041c5bSmacallan 446154b44505Smrg cat <<"EOF" 446254b44505Smrg /* stop here, and copy so we don't have to do this twice */ 446354b44505Smrg tmp_pathspec = xstrdup (newargz[0]); 44644a041c5bSmacallan 446554b44505Smrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 446654b44505Smrg strcat (newargz[0], actual_cwrapper_name); 44674a041c5bSmacallan 446854b44505Smrg /* DO want the lt- prefix here if it exists, so use target_name */ 446954b44505Smrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 447054b44505Smrg XFREE (tmp_pathspec); 447154b44505Smrg tmp_pathspec = NULL; 447254b44505SmrgEOF 44734a041c5bSmacallan 447454b44505Smrg case $host_os in 447554b44505Smrg mingw*) 447654b44505Smrg cat <<"EOF" 447754b44505Smrg { 447854b44505Smrg char* p; 447954b44505Smrg while ((p = strchr (newargz[0], '\\')) != NULL) 448054b44505Smrg { 448154b44505Smrg *p = '/'; 448254b44505Smrg } 448354b44505Smrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 448454b44505Smrg { 448554b44505Smrg *p = '/'; 448654b44505Smrg } 448754b44505Smrg } 448854b44505SmrgEOF 448954b44505Smrg ;; 449054b44505Smrg esac 44914a041c5bSmacallan 449254b44505Smrg cat <<"EOF" 449354b44505Smrg XFREE (target_name); 449454b44505Smrg XFREE (actual_cwrapper_path); 449554b44505Smrg XFREE (actual_cwrapper_name); 449654b44505Smrg 449754b44505Smrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 449854b44505Smrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 449954b44505Smrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 450054b44505Smrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 450154b44505Smrg because on Windows, both *_VARNAMEs are PATH but uninstalled 450254b44505Smrg libraries must come first. */ 450354b44505Smrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 450454b44505Smrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 450554b44505Smrg 450654b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 450754b44505Smrg nonnull (lt_argv_zero)); 450854b44505Smrg for (i = 0; i < newargc; i++) 450954b44505Smrg { 451054b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 451154b44505Smrg i, nonnull (newargz[i])); 451254b44505Smrg } 45134a041c5bSmacallan 451454b44505SmrgEOF 45154a041c5bSmacallan 451654b44505Smrg case $host_os in 451754b44505Smrg mingw*) 451854b44505Smrg cat <<"EOF" 451954b44505Smrg /* execv doesn't actually work on mingw as expected on unix */ 452054b44505Smrg newargz = prepare_spawn (newargz); 452154b44505Smrg rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 452254b44505Smrg if (rval == -1) 452354b44505Smrg { 452454b44505Smrg /* failed to start process */ 452554b44505Smrg lt_debugprintf (__FILE__, __LINE__, 452654b44505Smrg "(main) failed to launch target \"%s\": %s\n", 452754b44505Smrg lt_argv_zero, nonnull (strerror (errno))); 452854b44505Smrg return 127; 452954b44505Smrg } 453054b44505Smrg return rval; 453154b44505SmrgEOF 453254b44505Smrg ;; 453354b44505Smrg *) 453454b44505Smrg cat <<"EOF" 453554b44505Smrg execv (lt_argv_zero, newargz); 453654b44505Smrg return rval; /* =127, but avoids unused variable warning */ 453754b44505SmrgEOF 453854b44505Smrg ;; 453954b44505Smrg esac 45404a041c5bSmacallan 454154b44505Smrg cat <<"EOF" 454254b44505Smrg} 45434a041c5bSmacallan 454454b44505Smrgvoid * 454554b44505Smrgxmalloc (size_t num) 454654b44505Smrg{ 454754b44505Smrg void *p = (void *) malloc (num); 454854b44505Smrg if (!p) 454954b44505Smrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 45504a041c5bSmacallan 455154b44505Smrg return p; 455254b44505Smrg} 45534a041c5bSmacallan 455454b44505Smrgchar * 455554b44505Smrgxstrdup (const char *string) 455654b44505Smrg{ 455754b44505Smrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 455854b44505Smrg string) : NULL; 455954b44505Smrg} 45604a041c5bSmacallan 456154b44505Smrgconst char * 456254b44505Smrgbase_name (const char *name) 456354b44505Smrg{ 456454b44505Smrg const char *base; 45654a041c5bSmacallan 456654b44505Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 456754b44505Smrg /* Skip over the disk name in MSDOS pathnames. */ 456854b44505Smrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 456954b44505Smrg name += 2; 457054b44505Smrg#endif 45714a041c5bSmacallan 457254b44505Smrg for (base = name; *name; name++) 457354b44505Smrg if (IS_DIR_SEPARATOR (*name)) 457454b44505Smrg base = name + 1; 457554b44505Smrg return base; 457654b44505Smrg} 45774a041c5bSmacallan 457854b44505Smrgint 457954b44505Smrgcheck_executable (const char *path) 458054b44505Smrg{ 458154b44505Smrg struct stat st; 45824a041c5bSmacallan 458354b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 458454b44505Smrg nonempty (path)); 458554b44505Smrg if ((!path) || (!*path)) 458654b44505Smrg return 0; 45874a041c5bSmacallan 458854b44505Smrg if ((stat (path, &st) >= 0) 458954b44505Smrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 459054b44505Smrg return 1; 459154b44505Smrg else 459254b44505Smrg return 0; 459354b44505Smrg} 45944a041c5bSmacallan 459554b44505Smrgint 459654b44505Smrgmake_executable (const char *path) 459754b44505Smrg{ 459854b44505Smrg int rval = 0; 459954b44505Smrg struct stat st; 46004a041c5bSmacallan 460154b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 460254b44505Smrg nonempty (path)); 460354b44505Smrg if ((!path) || (!*path)) 460454b44505Smrg return 0; 46054a041c5bSmacallan 460654b44505Smrg if (stat (path, &st) >= 0) 460754b44505Smrg { 460854b44505Smrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 460954b44505Smrg } 461054b44505Smrg return rval; 461154b44505Smrg} 46124a041c5bSmacallan 461354b44505Smrg/* Searches for the full path of the wrapper. Returns 461454b44505Smrg newly allocated full path name if found, NULL otherwise 461554b44505Smrg Does not chase symlinks, even on platforms that support them. 461654b44505Smrg*/ 461754b44505Smrgchar * 461854b44505Smrgfind_executable (const char *wrapper) 461954b44505Smrg{ 462054b44505Smrg int has_slash = 0; 462154b44505Smrg const char *p; 462254b44505Smrg const char *p_next; 462354b44505Smrg /* static buffer for getcwd */ 462454b44505Smrg char tmp[LT_PATHMAX + 1]; 462554b44505Smrg int tmp_len; 462654b44505Smrg char *concat_name; 46274a041c5bSmacallan 462854b44505Smrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 462954b44505Smrg nonempty (wrapper)); 46304a041c5bSmacallan 463154b44505Smrg if ((wrapper == NULL) || (*wrapper == '\0')) 463254b44505Smrg return NULL; 46334a041c5bSmacallan 463454b44505Smrg /* Absolute path? */ 463554b44505Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 463654b44505Smrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 463754b44505Smrg { 463854b44505Smrg concat_name = xstrdup (wrapper); 463954b44505Smrg if (check_executable (concat_name)) 464054b44505Smrg return concat_name; 464154b44505Smrg XFREE (concat_name); 464254b44505Smrg } 464354b44505Smrg else 464454b44505Smrg { 464554b44505Smrg#endif 464654b44505Smrg if (IS_DIR_SEPARATOR (wrapper[0])) 464754b44505Smrg { 464854b44505Smrg concat_name = xstrdup (wrapper); 464954b44505Smrg if (check_executable (concat_name)) 465054b44505Smrg return concat_name; 465154b44505Smrg XFREE (concat_name); 465254b44505Smrg } 465354b44505Smrg#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 465454b44505Smrg } 465554b44505Smrg#endif 46564a041c5bSmacallan 465754b44505Smrg for (p = wrapper; *p; p++) 465854b44505Smrg if (*p == '/') 465954b44505Smrg { 466054b44505Smrg has_slash = 1; 466154b44505Smrg break; 466254b44505Smrg } 466354b44505Smrg if (!has_slash) 466454b44505Smrg { 466554b44505Smrg /* no slashes; search PATH */ 466654b44505Smrg const char *path = getenv ("PATH"); 466754b44505Smrg if (path != NULL) 466854b44505Smrg { 466954b44505Smrg for (p = path; *p; p = p_next) 467054b44505Smrg { 467154b44505Smrg const char *q; 467254b44505Smrg size_t p_len; 467354b44505Smrg for (q = p; *q; q++) 467454b44505Smrg if (IS_PATH_SEPARATOR (*q)) 467554b44505Smrg break; 467654b44505Smrg p_len = q - p; 467754b44505Smrg p_next = (*q == '\0' ? q : q + 1); 467854b44505Smrg if (p_len == 0) 467954b44505Smrg { 468054b44505Smrg /* empty path: current directory */ 468154b44505Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 468254b44505Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 468354b44505Smrg nonnull (strerror (errno))); 468454b44505Smrg tmp_len = strlen (tmp); 468554b44505Smrg concat_name = 468654b44505Smrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 468754b44505Smrg memcpy (concat_name, tmp, tmp_len); 468854b44505Smrg concat_name[tmp_len] = '/'; 468954b44505Smrg strcpy (concat_name + tmp_len + 1, wrapper); 469054b44505Smrg } 469154b44505Smrg else 469254b44505Smrg { 469354b44505Smrg concat_name = 469454b44505Smrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 469554b44505Smrg memcpy (concat_name, p, p_len); 469654b44505Smrg concat_name[p_len] = '/'; 469754b44505Smrg strcpy (concat_name + p_len + 1, wrapper); 469854b44505Smrg } 469954b44505Smrg if (check_executable (concat_name)) 470054b44505Smrg return concat_name; 470154b44505Smrg XFREE (concat_name); 470254b44505Smrg } 470354b44505Smrg } 470454b44505Smrg /* not found in PATH; assume curdir */ 470554b44505Smrg } 470654b44505Smrg /* Relative path | not found in path: prepend cwd */ 470754b44505Smrg if (getcwd (tmp, LT_PATHMAX) == NULL) 470854b44505Smrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 470954b44505Smrg nonnull (strerror (errno))); 471054b44505Smrg tmp_len = strlen (tmp); 471154b44505Smrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 471254b44505Smrg memcpy (concat_name, tmp, tmp_len); 471354b44505Smrg concat_name[tmp_len] = '/'; 471454b44505Smrg strcpy (concat_name + tmp_len + 1, wrapper); 471554b44505Smrg 471654b44505Smrg if (check_executable (concat_name)) 471754b44505Smrg return concat_name; 471854b44505Smrg XFREE (concat_name); 471954b44505Smrg return NULL; 47204a041c5bSmacallan} 47214a041c5bSmacallan 472254b44505Smrgchar * 472354b44505Smrgchase_symlinks (const char *pathspec) 472454b44505Smrg{ 472554b44505Smrg#ifndef S_ISLNK 472654b44505Smrg return xstrdup (pathspec); 472754b44505Smrg#else 472854b44505Smrg char buf[LT_PATHMAX]; 472954b44505Smrg struct stat s; 473054b44505Smrg char *tmp_pathspec = xstrdup (pathspec); 473154b44505Smrg char *p; 473254b44505Smrg int has_symlinks = 0; 473354b44505Smrg while (strlen (tmp_pathspec) && !has_symlinks) 473454b44505Smrg { 473554b44505Smrg lt_debugprintf (__FILE__, __LINE__, 473654b44505Smrg "checking path component for symlinks: %s\n", 473754b44505Smrg tmp_pathspec); 473854b44505Smrg if (lstat (tmp_pathspec, &s) == 0) 473954b44505Smrg { 474054b44505Smrg if (S_ISLNK (s.st_mode) != 0) 474154b44505Smrg { 474254b44505Smrg has_symlinks = 1; 474354b44505Smrg break; 474454b44505Smrg } 47454a041c5bSmacallan 474654b44505Smrg /* search backwards for last DIR_SEPARATOR */ 474754b44505Smrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 474854b44505Smrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 474954b44505Smrg p--; 475054b44505Smrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 475154b44505Smrg { 475254b44505Smrg /* no more DIR_SEPARATORS left */ 475354b44505Smrg break; 475454b44505Smrg } 475554b44505Smrg *p = '\0'; 475654b44505Smrg } 475754b44505Smrg else 475854b44505Smrg { 475954b44505Smrg lt_fatal (__FILE__, __LINE__, 476054b44505Smrg "error accessing file \"%s\": %s", 476154b44505Smrg tmp_pathspec, nonnull (strerror (errno))); 476254b44505Smrg } 476354b44505Smrg } 476454b44505Smrg XFREE (tmp_pathspec); 47654a041c5bSmacallan 476654b44505Smrg if (!has_symlinks) 476754b44505Smrg { 476854b44505Smrg return xstrdup (pathspec); 476954b44505Smrg } 47704a041c5bSmacallan 477154b44505Smrg tmp_pathspec = realpath (pathspec, buf); 477254b44505Smrg if (tmp_pathspec == 0) 477354b44505Smrg { 477454b44505Smrg lt_fatal (__FILE__, __LINE__, 477554b44505Smrg "could not follow symlinks for %s", pathspec); 477654b44505Smrg } 477754b44505Smrg return xstrdup (tmp_pathspec); 477854b44505Smrg#endif 47794a041c5bSmacallan} 47804a041c5bSmacallan 478154b44505Smrgchar * 478254b44505Smrgstrendzap (char *str, const char *pat) 478354b44505Smrg{ 478454b44505Smrg size_t len, patlen; 47854a041c5bSmacallan 478654b44505Smrg assert (str != NULL); 478754b44505Smrg assert (pat != NULL); 47884a041c5bSmacallan 478954b44505Smrg len = strlen (str); 479054b44505Smrg patlen = strlen (pat); 47914a041c5bSmacallan 479254b44505Smrg if (patlen <= len) 479354b44505Smrg { 479454b44505Smrg str += len - patlen; 479554b44505Smrg if (strcmp (str, pat) == 0) 479654b44505Smrg *str = '\0'; 479754b44505Smrg } 479854b44505Smrg return str; 479954b44505Smrg} 48004a041c5bSmacallan 480154b44505Smrgvoid 480254b44505Smrglt_debugprintf (const char *file, int line, const char *fmt, ...) 480354b44505Smrg{ 480454b44505Smrg va_list args; 480554b44505Smrg if (lt_debug) 480654b44505Smrg { 480754b44505Smrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 480854b44505Smrg va_start (args, fmt); 480954b44505Smrg (void) vfprintf (stderr, fmt, args); 481054b44505Smrg va_end (args); 481154b44505Smrg } 481254b44505Smrg} 48134a041c5bSmacallan 481454b44505Smrgstatic void 481554b44505Smrglt_error_core (int exit_status, const char *file, 481654b44505Smrg int line, const char *mode, 481754b44505Smrg const char *message, va_list ap) 481854b44505Smrg{ 481954b44505Smrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 482054b44505Smrg vfprintf (stderr, message, ap); 482154b44505Smrg fprintf (stderr, ".\n"); 48224a041c5bSmacallan 482354b44505Smrg if (exit_status >= 0) 482454b44505Smrg exit (exit_status); 482554b44505Smrg} 48264a041c5bSmacallan 482754b44505Smrgvoid 482854b44505Smrglt_fatal (const char *file, int line, const char *message, ...) 482954b44505Smrg{ 483054b44505Smrg va_list ap; 483154b44505Smrg va_start (ap, message); 483254b44505Smrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 483354b44505Smrg va_end (ap); 483454b44505Smrg} 48354a041c5bSmacallan 483654b44505Smrgstatic const char * 483754b44505Smrgnonnull (const char *s) 483854b44505Smrg{ 483954b44505Smrg return s ? s : "(null)"; 484054b44505Smrg} 48414a041c5bSmacallan 484254b44505Smrgstatic const char * 484354b44505Smrgnonempty (const char *s) 484454b44505Smrg{ 484554b44505Smrg return (s && !*s) ? "(empty)" : nonnull (s); 484654b44505Smrg} 48474a041c5bSmacallan 484854b44505Smrgvoid 484954b44505Smrglt_setenv (const char *name, const char *value) 485054b44505Smrg{ 485154b44505Smrg lt_debugprintf (__FILE__, __LINE__, 485254b44505Smrg "(lt_setenv) setting '%s' to '%s'\n", 485354b44505Smrg nonnull (name), nonnull (value)); 485454b44505Smrg { 485554b44505Smrg#ifdef HAVE_SETENV 485654b44505Smrg /* always make a copy, for consistency with !HAVE_SETENV */ 485754b44505Smrg char *str = xstrdup (value); 485854b44505Smrg setenv (name, str, 1); 48594a041c5bSmacallan#else 486054b44505Smrg int len = strlen (name) + 1 + strlen (value) + 1; 486154b44505Smrg char *str = XMALLOC (char, len); 486254b44505Smrg sprintf (str, "%s=%s", name, value); 486354b44505Smrg if (putenv (str) != EXIT_SUCCESS) 486454b44505Smrg { 486554b44505Smrg XFREE (str); 486654b44505Smrg } 48674a041c5bSmacallan#endif 486854b44505Smrg } 486954b44505Smrg} 48704a041c5bSmacallan 487154b44505Smrgchar * 487254b44505Smrglt_extend_str (const char *orig_value, const char *add, int to_end) 487354b44505Smrg{ 487454b44505Smrg char *new_value; 487554b44505Smrg if (orig_value && *orig_value) 487654b44505Smrg { 487754b44505Smrg int orig_value_len = strlen (orig_value); 487854b44505Smrg int add_len = strlen (add); 487954b44505Smrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 488054b44505Smrg if (to_end) 488154b44505Smrg { 488254b44505Smrg strcpy (new_value, orig_value); 488354b44505Smrg strcpy (new_value + orig_value_len, add); 488454b44505Smrg } 488554b44505Smrg else 488654b44505Smrg { 488754b44505Smrg strcpy (new_value, add); 488854b44505Smrg strcpy (new_value + add_len, orig_value); 488954b44505Smrg } 489054b44505Smrg } 489154b44505Smrg else 489254b44505Smrg { 489354b44505Smrg new_value = xstrdup (add); 489454b44505Smrg } 489554b44505Smrg return new_value; 489654b44505Smrg} 48974a041c5bSmacallan 489854b44505Smrgvoid 489954b44505Smrglt_update_exe_path (const char *name, const char *value) 490054b44505Smrg{ 490154b44505Smrg lt_debugprintf (__FILE__, __LINE__, 490254b44505Smrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 490354b44505Smrg nonnull (name), nonnull (value)); 49044a041c5bSmacallan 490554b44505Smrg if (name && *name && value && *value) 490654b44505Smrg { 490754b44505Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 490854b44505Smrg /* some systems can't cope with a ':'-terminated path #' */ 490954b44505Smrg int len = strlen (new_value); 491054b44505Smrg while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 491154b44505Smrg { 491254b44505Smrg new_value[len-1] = '\0'; 491354b44505Smrg } 491454b44505Smrg lt_setenv (name, new_value); 491554b44505Smrg XFREE (new_value); 491654b44505Smrg } 491754b44505Smrg} 49184a041c5bSmacallan 491954b44505Smrgvoid 492054b44505Smrglt_update_lib_path (const char *name, const char *value) 49214a041c5bSmacallan{ 492254b44505Smrg lt_debugprintf (__FILE__, __LINE__, 492354b44505Smrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 492454b44505Smrg nonnull (name), nonnull (value)); 49254a041c5bSmacallan 492654b44505Smrg if (name && *name && value && *value) 492754b44505Smrg { 492854b44505Smrg char *new_value = lt_extend_str (getenv (name), value, 0); 492954b44505Smrg lt_setenv (name, new_value); 493054b44505Smrg XFREE (new_value); 493154b44505Smrg } 493254b44505Smrg} 49334a041c5bSmacallan 49344a041c5bSmacallanEOF 493554b44505Smrg case $host_os in 493654b44505Smrg mingw*) 493754b44505Smrg cat <<"EOF" 493854b44505Smrg 493954b44505Smrg/* Prepares an argument vector before calling spawn(). 494054b44505Smrg Note that spawn() does not by itself call the command interpreter 494154b44505Smrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 494254b44505Smrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 494354b44505Smrg GetVersionEx(&v); 494454b44505Smrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 494554b44505Smrg }) ? "cmd.exe" : "command.com"). 494654b44505Smrg Instead it simply concatenates the arguments, separated by ' ', and calls 494754b44505Smrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 494854b44505Smrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 494954b44505Smrg special way: 495054b44505Smrg - Space and tab are interpreted as delimiters. They are not treated as 495154b44505Smrg delimiters if they are surrounded by double quotes: "...". 495254b44505Smrg - Unescaped double quotes are removed from the input. Their only effect is 495354b44505Smrg that within double quotes, space and tab are treated like normal 495454b44505Smrg characters. 495554b44505Smrg - Backslashes not followed by double quotes are not special. 495654b44505Smrg - But 2*n+1 backslashes followed by a double quote become 495754b44505Smrg n backslashes followed by a double quote (n >= 0): 495854b44505Smrg \" -> " 495954b44505Smrg \\\" -> \" 496054b44505Smrg \\\\\" -> \\" 496154b44505Smrg */ 496254b44505Smrg#define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" 496354b44505Smrg#define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037" 496454b44505Smrgchar ** 496554b44505Smrgprepare_spawn (char **argv) 496654b44505Smrg{ 496754b44505Smrg size_t argc; 496854b44505Smrg char **new_argv; 496954b44505Smrg size_t i; 49704a041c5bSmacallan 497154b44505Smrg /* Count number of arguments. */ 497254b44505Smrg for (argc = 0; argv[argc] != NULL; argc++) 49734a041c5bSmacallan ; 49744a041c5bSmacallan 497554b44505Smrg /* Allocate new argument vector. */ 497654b44505Smrg new_argv = XMALLOC (char *, argc + 1); 49774a041c5bSmacallan 497854b44505Smrg /* Put quoted arguments into the new argument vector. */ 497954b44505Smrg for (i = 0; i < argc; i++) 498054b44505Smrg { 498154b44505Smrg const char *string = argv[i]; 498254b44505Smrg 498354b44505Smrg if (string[0] == '\0') 498454b44505Smrg new_argv[i] = xstrdup ("\"\""); 498554b44505Smrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 498654b44505Smrg { 498754b44505Smrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 498854b44505Smrg size_t length; 498954b44505Smrg unsigned int backslashes; 499054b44505Smrg const char *s; 499154b44505Smrg char *quoted_string; 499254b44505Smrg char *p; 499354b44505Smrg 499454b44505Smrg length = 0; 499554b44505Smrg backslashes = 0; 499654b44505Smrg if (quote_around) 499754b44505Smrg length++; 499854b44505Smrg for (s = string; *s != '\0'; s++) 499954b44505Smrg { 500054b44505Smrg char c = *s; 500154b44505Smrg if (c == '"') 500254b44505Smrg length += backslashes + 1; 500354b44505Smrg length++; 500454b44505Smrg if (c == '\\') 500554b44505Smrg backslashes++; 500654b44505Smrg else 500754b44505Smrg backslashes = 0; 500854b44505Smrg } 500954b44505Smrg if (quote_around) 501054b44505Smrg length += backslashes + 1; 501154b44505Smrg 501254b44505Smrg quoted_string = XMALLOC (char, length + 1); 501354b44505Smrg 501454b44505Smrg p = quoted_string; 501554b44505Smrg backslashes = 0; 501654b44505Smrg if (quote_around) 501754b44505Smrg *p++ = '"'; 501854b44505Smrg for (s = string; *s != '\0'; s++) 501954b44505Smrg { 502054b44505Smrg char c = *s; 502154b44505Smrg if (c == '"') 502254b44505Smrg { 502354b44505Smrg unsigned int j; 502454b44505Smrg for (j = backslashes + 1; j > 0; j--) 502554b44505Smrg *p++ = '\\'; 502654b44505Smrg } 502754b44505Smrg *p++ = c; 502854b44505Smrg if (c == '\\') 502954b44505Smrg backslashes++; 503054b44505Smrg else 503154b44505Smrg backslashes = 0; 503254b44505Smrg } 503354b44505Smrg if (quote_around) 503454b44505Smrg { 503554b44505Smrg unsigned int j; 503654b44505Smrg for (j = backslashes; j > 0; j--) 503754b44505Smrg *p++ = '\\'; 503854b44505Smrg *p++ = '"'; 503954b44505Smrg } 504054b44505Smrg *p = '\0'; 504154b44505Smrg 504254b44505Smrg new_argv[i] = quoted_string; 504354b44505Smrg } 504454b44505Smrg else 504554b44505Smrg new_argv[i] = (char *) string; 504654b44505Smrg } 504754b44505Smrg new_argv[argc] = NULL; 50484a041c5bSmacallan 504954b44505Smrg return new_argv; 50504a041c5bSmacallan} 505154b44505SmrgEOF 505254b44505Smrg ;; 505354b44505Smrg esac 50544a041c5bSmacallan 505554b44505Smrg cat <<"EOF" 505654b44505Smrgvoid lt_dump_script (FILE* f) 50574a041c5bSmacallan{ 505854b44505SmrgEOF 505954b44505Smrg func_emit_wrapper yes | 506054b44505Smrg $SED -e 's/\([\\"]\)/\\\1/g' \ 506154b44505Smrg -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' 50624a041c5bSmacallan 506354b44505Smrg cat <<"EOF" 50644a041c5bSmacallan} 506554b44505SmrgEOF 50664a041c5bSmacallan} 506754b44505Smrg# end: func_emit_cwrapperexe_src 50684a041c5bSmacallan 506954b44505Smrg# func_win32_import_lib_p ARG 507054b44505Smrg# True if ARG is an import lib, as indicated by $file_magic_cmd 507154b44505Smrgfunc_win32_import_lib_p () 50724a041c5bSmacallan{ 507354b44505Smrg $opt_debug 507454b44505Smrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 507554b44505Smrg *import*) : ;; 507654b44505Smrg *) false ;; 507754b44505Smrg esac 50784a041c5bSmacallan} 50794a041c5bSmacallan 508054b44505Smrg# func_mode_link arg... 508154b44505Smrgfunc_mode_link () 50824a041c5bSmacallan{ 508354b44505Smrg $opt_debug 508454b44505Smrg case $host in 508554b44505Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 508654b44505Smrg # It is impossible to link a dll without this setting, and 508754b44505Smrg # we shouldn't force the makefile maintainer to figure out 508854b44505Smrg # which system we are compiling for in order to pass an extra 508954b44505Smrg # flag for every libtool invocation. 509054b44505Smrg # allow_undefined=no 50914a041c5bSmacallan 509254b44505Smrg # FIXME: Unfortunately, there are problems with the above when trying 509354b44505Smrg # to make a dll which has undefined symbols, in which case not 509454b44505Smrg # even a static library is built. For now, we need to specify 509554b44505Smrg # -no-undefined on the libtool link line when we can be certain 509654b44505Smrg # that all symbols are satisfied, otherwise we get a static library. 509754b44505Smrg allow_undefined=yes 509854b44505Smrg ;; 509954b44505Smrg *) 510054b44505Smrg allow_undefined=yes 510154b44505Smrg ;; 510254b44505Smrg esac 510354b44505Smrg libtool_args=$nonopt 510454b44505Smrg base_compile="$nonopt $@" 510554b44505Smrg compile_command=$nonopt 510654b44505Smrg finalize_command=$nonopt 51074a041c5bSmacallan 510854b44505Smrg compile_rpath= 510954b44505Smrg finalize_rpath= 511054b44505Smrg compile_shlibpath= 511154b44505Smrg finalize_shlibpath= 511254b44505Smrg convenience= 511354b44505Smrg old_convenience= 511454b44505Smrg deplibs= 511554b44505Smrg old_deplibs= 511654b44505Smrg compiler_flags= 511754b44505Smrg linker_flags= 511854b44505Smrg dllsearchpath= 511954b44505Smrg lib_search_path=`pwd` 512054b44505Smrg inst_prefix_dir= 512154b44505Smrg new_inherited_linker_flags= 51224a041c5bSmacallan 512354b44505Smrg avoid_version=no 512454b44505Smrg bindir= 512554b44505Smrg dlfiles= 512654b44505Smrg dlprefiles= 512754b44505Smrg dlself=no 512854b44505Smrg export_dynamic=no 512954b44505Smrg export_symbols= 513054b44505Smrg export_symbols_regex= 513154b44505Smrg generated= 513254b44505Smrg libobjs= 513354b44505Smrg ltlibs= 513454b44505Smrg module=no 513554b44505Smrg no_install=no 513654b44505Smrg objs= 513754b44505Smrg non_pic_objects= 513854b44505Smrg precious_files_regex= 513954b44505Smrg prefer_static_libs=no 514054b44505Smrg preload=no 514154b44505Smrg prev= 514254b44505Smrg prevarg= 514354b44505Smrg release= 514454b44505Smrg rpath= 514554b44505Smrg xrpath= 514654b44505Smrg perm_rpath= 514754b44505Smrg temp_rpath= 514854b44505Smrg thread_safe=no 514954b44505Smrg vinfo= 515054b44505Smrg vinfo_number=no 515154b44505Smrg weak_libs= 515254b44505Smrg single_module="${wl}-single_module" 515354b44505Smrg func_infer_tag $base_compile 51544a041c5bSmacallan 515554b44505Smrg # We need to know -static, to get the right output filenames. 515654b44505Smrg for arg 515754b44505Smrg do 515854b44505Smrg case $arg in 515954b44505Smrg -shared) 516054b44505Smrg test "$build_libtool_libs" != yes && \ 516154b44505Smrg func_fatal_configuration "can not build a shared library" 516254b44505Smrg build_old_libs=no 516354b44505Smrg break 516454b44505Smrg ;; 516554b44505Smrg -all-static | -static | -static-libtool-libs) 516654b44505Smrg case $arg in 516754b44505Smrg -all-static) 516854b44505Smrg if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 516954b44505Smrg func_warning "complete static linking is impossible in this configuration" 517054b44505Smrg fi 517154b44505Smrg if test -n "$link_static_flag"; then 517254b44505Smrg dlopen_self=$dlopen_self_static 517354b44505Smrg fi 517454b44505Smrg prefer_static_libs=yes 517554b44505Smrg ;; 517654b44505Smrg -static) 517754b44505Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 517854b44505Smrg dlopen_self=$dlopen_self_static 517954b44505Smrg fi 518054b44505Smrg prefer_static_libs=built 518154b44505Smrg ;; 518254b44505Smrg -static-libtool-libs) 518354b44505Smrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 518454b44505Smrg dlopen_self=$dlopen_self_static 518554b44505Smrg fi 518654b44505Smrg prefer_static_libs=yes 518754b44505Smrg ;; 518854b44505Smrg esac 518954b44505Smrg build_libtool_libs=no 519054b44505Smrg build_old_libs=yes 519154b44505Smrg break 519254b44505Smrg ;; 519354b44505Smrg esac 519454b44505Smrg done 51954a041c5bSmacallan 519654b44505Smrg # See if our shared archives depend on static archives. 519754b44505Smrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 51984a041c5bSmacallan 519954b44505Smrg # Go through the arguments, transforming them on the way. 520054b44505Smrg while test "$#" -gt 0; do 520154b44505Smrg arg="$1" 520254b44505Smrg shift 520354b44505Smrg func_quote_for_eval "$arg" 520454b44505Smrg qarg=$func_quote_for_eval_unquoted_result 520554b44505Smrg func_append libtool_args " $func_quote_for_eval_result" 52064a041c5bSmacallan 520754b44505Smrg # If the previous option needs an argument, assign it. 520854b44505Smrg if test -n "$prev"; then 520954b44505Smrg case $prev in 521054b44505Smrg output) 521154b44505Smrg func_append compile_command " @OUTPUT@" 521254b44505Smrg func_append finalize_command " @OUTPUT@" 521354b44505Smrg ;; 521454b44505Smrg esac 52154a041c5bSmacallan 521654b44505Smrg case $prev in 521754b44505Smrg bindir) 521854b44505Smrg bindir="$arg" 521954b44505Smrg prev= 522054b44505Smrg continue 522154b44505Smrg ;; 522254b44505Smrg dlfiles|dlprefiles) 522354b44505Smrg if test "$preload" = no; then 522454b44505Smrg # Add the symbol object into the linking commands. 522554b44505Smrg func_append compile_command " @SYMFILE@" 522654b44505Smrg func_append finalize_command " @SYMFILE@" 522754b44505Smrg preload=yes 522854b44505Smrg fi 522954b44505Smrg case $arg in 523054b44505Smrg *.la | *.lo) ;; # We handle these cases below. 523154b44505Smrg force) 523254b44505Smrg if test "$dlself" = no; then 523354b44505Smrg dlself=needless 523454b44505Smrg export_dynamic=yes 523554b44505Smrg fi 523654b44505Smrg prev= 523754b44505Smrg continue 523854b44505Smrg ;; 523954b44505Smrg self) 524054b44505Smrg if test "$prev" = dlprefiles; then 524154b44505Smrg dlself=yes 524254b44505Smrg elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 524354b44505Smrg dlself=yes 524454b44505Smrg else 524554b44505Smrg dlself=needless 524654b44505Smrg export_dynamic=yes 524754b44505Smrg fi 524854b44505Smrg prev= 524954b44505Smrg continue 525054b44505Smrg ;; 525154b44505Smrg *) 525254b44505Smrg if test "$prev" = dlfiles; then 525354b44505Smrg func_append dlfiles " $arg" 525454b44505Smrg else 525554b44505Smrg func_append dlprefiles " $arg" 525654b44505Smrg fi 525754b44505Smrg prev= 525854b44505Smrg continue 525954b44505Smrg ;; 526054b44505Smrg esac 526154b44505Smrg ;; 526254b44505Smrg expsyms) 526354b44505Smrg export_symbols="$arg" 526454b44505Smrg test -f "$arg" \ 526554b44505Smrg || func_fatal_error "symbol file \`$arg' does not exist" 526654b44505Smrg prev= 526754b44505Smrg continue 526854b44505Smrg ;; 526954b44505Smrg expsyms_regex) 527054b44505Smrg export_symbols_regex="$arg" 527154b44505Smrg prev= 527254b44505Smrg continue 527354b44505Smrg ;; 527454b44505Smrg framework) 527554b44505Smrg case $host in 527654b44505Smrg *-*-darwin*) 527754b44505Smrg case "$deplibs " in 527854b44505Smrg *" $qarg.ltframework "*) ;; 527954b44505Smrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 528054b44505Smrg ;; 528154b44505Smrg esac 528254b44505Smrg ;; 528354b44505Smrg esac 528454b44505Smrg prev= 528554b44505Smrg continue 528654b44505Smrg ;; 528754b44505Smrg inst_prefix) 528854b44505Smrg inst_prefix_dir="$arg" 528954b44505Smrg prev= 529054b44505Smrg continue 529154b44505Smrg ;; 529254b44505Smrg objectlist) 529354b44505Smrg if test -f "$arg"; then 529454b44505Smrg save_arg=$arg 529554b44505Smrg moreargs= 529654b44505Smrg for fil in `cat "$save_arg"` 529754b44505Smrg do 529854b44505Smrg# func_append moreargs " $fil" 529954b44505Smrg arg=$fil 530054b44505Smrg # A libtool-controlled object. 53014a041c5bSmacallan 530254b44505Smrg # Check to see that this really is a libtool object. 530354b44505Smrg if func_lalib_unsafe_p "$arg"; then 530454b44505Smrg pic_object= 530554b44505Smrg non_pic_object= 53064a041c5bSmacallan 530754b44505Smrg # Read the .lo file 530854b44505Smrg func_source "$arg" 53094a041c5bSmacallan 531054b44505Smrg if test -z "$pic_object" || 531154b44505Smrg test -z "$non_pic_object" || 531254b44505Smrg test "$pic_object" = none && 531354b44505Smrg test "$non_pic_object" = none; then 531454b44505Smrg func_fatal_error "cannot find name of object for \`$arg'" 531554b44505Smrg fi 53164a041c5bSmacallan 531754b44505Smrg # Extract subdirectory from the argument. 531854b44505Smrg func_dirname "$arg" "/" "" 531954b44505Smrg xdir="$func_dirname_result" 53204a041c5bSmacallan 532154b44505Smrg if test "$pic_object" != none; then 532254b44505Smrg # Prepend the subdirectory the object is found in. 532354b44505Smrg pic_object="$xdir$pic_object" 53244a041c5bSmacallan 532554b44505Smrg if test "$prev" = dlfiles; then 532654b44505Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 532754b44505Smrg func_append dlfiles " $pic_object" 532854b44505Smrg prev= 532954b44505Smrg continue 533054b44505Smrg else 533154b44505Smrg # If libtool objects are unsupported, then we need to preload. 533254b44505Smrg prev=dlprefiles 533354b44505Smrg fi 533454b44505Smrg fi 53354a041c5bSmacallan 533654b44505Smrg # CHECK ME: I think I busted this. -Ossama 533754b44505Smrg if test "$prev" = dlprefiles; then 533854b44505Smrg # Preload the old-style object. 533954b44505Smrg func_append dlprefiles " $pic_object" 534054b44505Smrg prev= 534154b44505Smrg fi 53424a041c5bSmacallan 534354b44505Smrg # A PIC object. 534454b44505Smrg func_append libobjs " $pic_object" 534554b44505Smrg arg="$pic_object" 534654b44505Smrg fi 53474a041c5bSmacallan 534854b44505Smrg # Non-PIC object. 534954b44505Smrg if test "$non_pic_object" != none; then 535054b44505Smrg # Prepend the subdirectory the object is found in. 535154b44505Smrg non_pic_object="$xdir$non_pic_object" 53524a041c5bSmacallan 535354b44505Smrg # A standard non-PIC object 535454b44505Smrg func_append non_pic_objects " $non_pic_object" 535554b44505Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 535654b44505Smrg arg="$non_pic_object" 535754b44505Smrg fi 535854b44505Smrg else 535954b44505Smrg # If the PIC object exists, use it instead. 536054b44505Smrg # $xdir was prepended to $pic_object above. 536154b44505Smrg non_pic_object="$pic_object" 536254b44505Smrg func_append non_pic_objects " $non_pic_object" 536354b44505Smrg fi 536454b44505Smrg else 536554b44505Smrg # Only an error if not doing a dry-run. 536654b44505Smrg if $opt_dry_run; then 536754b44505Smrg # Extract subdirectory from the argument. 536854b44505Smrg func_dirname "$arg" "/" "" 536954b44505Smrg xdir="$func_dirname_result" 537054b44505Smrg 537154b44505Smrg func_lo2o "$arg" 537254b44505Smrg pic_object=$xdir$objdir/$func_lo2o_result 537354b44505Smrg non_pic_object=$xdir$func_lo2o_result 537454b44505Smrg func_append libobjs " $pic_object" 537554b44505Smrg func_append non_pic_objects " $non_pic_object" 537654b44505Smrg else 537754b44505Smrg func_fatal_error "\`$arg' is not a valid libtool object" 537854b44505Smrg fi 537954b44505Smrg fi 538054b44505Smrg done 538154b44505Smrg else 538254b44505Smrg func_fatal_error "link input file \`$arg' does not exist" 538354b44505Smrg fi 538454b44505Smrg arg=$save_arg 538554b44505Smrg prev= 538654b44505Smrg continue 538754b44505Smrg ;; 538854b44505Smrg precious_regex) 538954b44505Smrg precious_files_regex="$arg" 539054b44505Smrg prev= 539154b44505Smrg continue 539254b44505Smrg ;; 539354b44505Smrg release) 539454b44505Smrg release="-$arg" 539554b44505Smrg prev= 539654b44505Smrg continue 539754b44505Smrg ;; 539854b44505Smrg rpath | xrpath) 539954b44505Smrg # We need an absolute path. 540054b44505Smrg case $arg in 540154b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 540254b44505Smrg *) 540354b44505Smrg func_fatal_error "only absolute run-paths are allowed" 540454b44505Smrg ;; 540554b44505Smrg esac 540654b44505Smrg if test "$prev" = rpath; then 540754b44505Smrg case "$rpath " in 540854b44505Smrg *" $arg "*) ;; 540954b44505Smrg *) func_append rpath " $arg" ;; 541054b44505Smrg esac 541154b44505Smrg else 541254b44505Smrg case "$xrpath " in 541354b44505Smrg *" $arg "*) ;; 541454b44505Smrg *) func_append xrpath " $arg" ;; 541554b44505Smrg esac 541654b44505Smrg fi 541754b44505Smrg prev= 541854b44505Smrg continue 541954b44505Smrg ;; 542054b44505Smrg shrext) 542154b44505Smrg shrext_cmds="$arg" 542254b44505Smrg prev= 542354b44505Smrg continue 542454b44505Smrg ;; 542554b44505Smrg weak) 542654b44505Smrg func_append weak_libs " $arg" 542754b44505Smrg prev= 542854b44505Smrg continue 542954b44505Smrg ;; 543054b44505Smrg xcclinker) 543154b44505Smrg func_append linker_flags " $qarg" 543254b44505Smrg func_append compiler_flags " $qarg" 543354b44505Smrg prev= 543454b44505Smrg func_append compile_command " $qarg" 543554b44505Smrg func_append finalize_command " $qarg" 543654b44505Smrg continue 543754b44505Smrg ;; 543854b44505Smrg xcompiler) 543954b44505Smrg func_append compiler_flags " $qarg" 544054b44505Smrg prev= 544154b44505Smrg func_append compile_command " $qarg" 544254b44505Smrg func_append finalize_command " $qarg" 544354b44505Smrg continue 544454b44505Smrg ;; 544554b44505Smrg xlinker) 544654b44505Smrg func_append linker_flags " $qarg" 544754b44505Smrg func_append compiler_flags " $wl$qarg" 544854b44505Smrg prev= 544954b44505Smrg func_append compile_command " $wl$qarg" 545054b44505Smrg func_append finalize_command " $wl$qarg" 545154b44505Smrg continue 545254b44505Smrg ;; 545354b44505Smrg *) 545454b44505Smrg eval "$prev=\"\$arg\"" 545554b44505Smrg prev= 545654b44505Smrg continue 545754b44505Smrg ;; 545854b44505Smrg esac 545954b44505Smrg fi # test -n "$prev" 54604a041c5bSmacallan 546154b44505Smrg prevarg="$arg" 54624a041c5bSmacallan 546354b44505Smrg case $arg in 546454b44505Smrg -all-static) 546554b44505Smrg if test -n "$link_static_flag"; then 546654b44505Smrg # See comment for -static flag below, for more details. 546754b44505Smrg func_append compile_command " $link_static_flag" 546854b44505Smrg func_append finalize_command " $link_static_flag" 546954b44505Smrg fi 547054b44505Smrg continue 547154b44505Smrg ;; 54724a041c5bSmacallan 547354b44505Smrg -allow-undefined) 547454b44505Smrg # FIXME: remove this flag sometime in the future. 547554b44505Smrg func_fatal_error "\`-allow-undefined' must not be used because it is the default" 547654b44505Smrg ;; 54774a041c5bSmacallan 547854b44505Smrg -avoid-version) 547954b44505Smrg avoid_version=yes 548054b44505Smrg continue 548154b44505Smrg ;; 54824a041c5bSmacallan 548354b44505Smrg -bindir) 548454b44505Smrg prev=bindir 548554b44505Smrg continue 548654b44505Smrg ;; 548754b44505Smrg 548854b44505Smrg -dlopen) 548954b44505Smrg prev=dlfiles 549054b44505Smrg continue 549154b44505Smrg ;; 549254b44505Smrg 549354b44505Smrg -dlpreopen) 549454b44505Smrg prev=dlprefiles 549554b44505Smrg continue 549654b44505Smrg ;; 549754b44505Smrg 549854b44505Smrg -export-dynamic) 549954b44505Smrg export_dynamic=yes 550054b44505Smrg continue 550154b44505Smrg ;; 550254b44505Smrg 550354b44505Smrg -export-symbols | -export-symbols-regex) 550454b44505Smrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 550554b44505Smrg func_fatal_error "more than one -exported-symbols argument is not allowed" 550654b44505Smrg fi 550754b44505Smrg if test "X$arg" = "X-export-symbols"; then 550854b44505Smrg prev=expsyms 550954b44505Smrg else 551054b44505Smrg prev=expsyms_regex 551154b44505Smrg fi 551254b44505Smrg continue 551354b44505Smrg ;; 551454b44505Smrg 551554b44505Smrg -framework) 551654b44505Smrg prev=framework 551754b44505Smrg continue 551854b44505Smrg ;; 551954b44505Smrg 552054b44505Smrg -inst-prefix-dir) 552154b44505Smrg prev=inst_prefix 552254b44505Smrg continue 552354b44505Smrg ;; 552454b44505Smrg 552554b44505Smrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 552654b44505Smrg # so, if we see these flags be careful not to treat them like -L 552754b44505Smrg -L[A-Z][A-Z]*:*) 552854b44505Smrg case $with_gcc/$host in 552954b44505Smrg no/*-*-irix* | /*-*-irix*) 553054b44505Smrg func_append compile_command " $arg" 553154b44505Smrg func_append finalize_command " $arg" 553254b44505Smrg ;; 553354b44505Smrg esac 553454b44505Smrg continue 553554b44505Smrg ;; 553654b44505Smrg 553754b44505Smrg -L*) 553854b44505Smrg func_stripname "-L" '' "$arg" 553954b44505Smrg if test -z "$func_stripname_result"; then 554054b44505Smrg if test "$#" -gt 0; then 554154b44505Smrg func_fatal_error "require no space between \`-L' and \`$1'" 554254b44505Smrg else 554354b44505Smrg func_fatal_error "need path for \`-L' option" 554454b44505Smrg fi 554554b44505Smrg fi 554654b44505Smrg func_resolve_sysroot "$func_stripname_result" 554754b44505Smrg dir=$func_resolve_sysroot_result 554854b44505Smrg # We need an absolute path. 554954b44505Smrg case $dir in 555054b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 555154b44505Smrg *) 555254b44505Smrg absdir=`cd "$dir" && pwd` 555354b44505Smrg test -z "$absdir" && \ 555454b44505Smrg func_fatal_error "cannot determine absolute directory name of \`$dir'" 555554b44505Smrg dir="$absdir" 555654b44505Smrg ;; 555754b44505Smrg esac 555854b44505Smrg case "$deplibs " in 555954b44505Smrg *" -L$dir "* | *" $arg "*) 556054b44505Smrg # Will only happen for absolute or sysroot arguments 556154b44505Smrg ;; 556254b44505Smrg *) 556354b44505Smrg # Preserve sysroot, but never include relative directories 556454b44505Smrg case $dir in 556554b44505Smrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 556654b44505Smrg *) func_append deplibs " -L$dir" ;; 556754b44505Smrg esac 556854b44505Smrg func_append lib_search_path " $dir" 556954b44505Smrg ;; 557054b44505Smrg esac 557154b44505Smrg case $host in 557254b44505Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 557354b44505Smrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 557454b44505Smrg case :$dllsearchpath: in 557554b44505Smrg *":$dir:"*) ;; 557654b44505Smrg ::) dllsearchpath=$dir;; 557754b44505Smrg *) func_append dllsearchpath ":$dir";; 557854b44505Smrg esac 557954b44505Smrg case :$dllsearchpath: in 558054b44505Smrg *":$testbindir:"*) ;; 558154b44505Smrg ::) dllsearchpath=$testbindir;; 558254b44505Smrg *) func_append dllsearchpath ":$testbindir";; 558354b44505Smrg esac 558454b44505Smrg ;; 558554b44505Smrg esac 558654b44505Smrg continue 558754b44505Smrg ;; 558854b44505Smrg 558954b44505Smrg -l*) 559054b44505Smrg if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 559154b44505Smrg case $host in 559254b44505Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 559354b44505Smrg # These systems don't actually have a C or math library (as such) 559454b44505Smrg continue 559554b44505Smrg ;; 559654b44505Smrg *-*-os2*) 559754b44505Smrg # These systems don't actually have a C library (as such) 559854b44505Smrg test "X$arg" = "X-lc" && continue 559954b44505Smrg ;; 560054b44505Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 560154b44505Smrg # Do not include libc due to us having libc/libc_r. 560254b44505Smrg test "X$arg" = "X-lc" && continue 560354b44505Smrg ;; 560454b44505Smrg *-*-rhapsody* | *-*-darwin1.[012]) 560554b44505Smrg # Rhapsody C and math libraries are in the System framework 560654b44505Smrg func_append deplibs " System.ltframework" 560754b44505Smrg continue 560854b44505Smrg ;; 560954b44505Smrg *-*-sco3.2v5* | *-*-sco5v6*) 561054b44505Smrg # Causes problems with __ctype 561154b44505Smrg test "X$arg" = "X-lc" && continue 561254b44505Smrg ;; 561354b44505Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 561454b44505Smrg # Compiler inserts libc in the correct place for threads to work 561554b44505Smrg test "X$arg" = "X-lc" && continue 561654b44505Smrg ;; 561754b44505Smrg esac 561854b44505Smrg elif test "X$arg" = "X-lc_r"; then 561954b44505Smrg case $host in 562054b44505Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 562154b44505Smrg # Do not include libc_r directly, use -pthread flag. 562254b44505Smrg continue 562354b44505Smrg ;; 562454b44505Smrg esac 562554b44505Smrg fi 562654b44505Smrg func_append deplibs " $arg" 562754b44505Smrg continue 562854b44505Smrg ;; 562954b44505Smrg 563054b44505Smrg -module) 563154b44505Smrg module=yes 563254b44505Smrg continue 563354b44505Smrg ;; 563454b44505Smrg 563554b44505Smrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 563654b44505Smrg # classes, name mangling, and exception handling. 563754b44505Smrg # Darwin uses the -arch flag to determine output architecture. 563854b44505Smrg -model|-arch|-isysroot|--sysroot) 563954b44505Smrg func_append compiler_flags " $arg" 564054b44505Smrg func_append compile_command " $arg" 564154b44505Smrg func_append finalize_command " $arg" 564254b44505Smrg prev=xcompiler 564354b44505Smrg continue 564454b44505Smrg ;; 564554b44505Smrg 564654b44505Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 564754b44505Smrg func_append compiler_flags " $arg" 564854b44505Smrg func_append compile_command " $arg" 564954b44505Smrg func_append finalize_command " $arg" 565054b44505Smrg case "$new_inherited_linker_flags " in 565154b44505Smrg *" $arg "*) ;; 565254b44505Smrg * ) func_append new_inherited_linker_flags " $arg" ;; 565354b44505Smrg esac 565454b44505Smrg continue 565554b44505Smrg ;; 565654b44505Smrg 565754b44505Smrg -multi_module) 565854b44505Smrg single_module="${wl}-multi_module" 565954b44505Smrg continue 566054b44505Smrg ;; 566154b44505Smrg 566254b44505Smrg -no-fast-install) 566354b44505Smrg fast_install=no 566454b44505Smrg continue 566554b44505Smrg ;; 566654b44505Smrg 566754b44505Smrg -no-install) 566854b44505Smrg case $host in 566954b44505Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 567054b44505Smrg # The PATH hackery in wrapper scripts is required on Windows 567154b44505Smrg # and Darwin in order for the loader to find any dlls it needs. 567254b44505Smrg func_warning "\`-no-install' is ignored for $host" 567354b44505Smrg func_warning "assuming \`-no-fast-install' instead" 567454b44505Smrg fast_install=no 567554b44505Smrg ;; 567654b44505Smrg *) no_install=yes ;; 567754b44505Smrg esac 567854b44505Smrg continue 567954b44505Smrg ;; 568054b44505Smrg 568154b44505Smrg -no-undefined) 568254b44505Smrg allow_undefined=no 568354b44505Smrg continue 568454b44505Smrg ;; 568554b44505Smrg 568654b44505Smrg -objectlist) 568754b44505Smrg prev=objectlist 568854b44505Smrg continue 568954b44505Smrg ;; 569054b44505Smrg 569154b44505Smrg -o) prev=output ;; 569254b44505Smrg 569354b44505Smrg -precious-files-regex) 569454b44505Smrg prev=precious_regex 569554b44505Smrg continue 569654b44505Smrg ;; 569754b44505Smrg 569854b44505Smrg -release) 569954b44505Smrg prev=release 570054b44505Smrg continue 570154b44505Smrg ;; 570254b44505Smrg 570354b44505Smrg -rpath) 570454b44505Smrg prev=rpath 570554b44505Smrg continue 570654b44505Smrg ;; 570754b44505Smrg 570854b44505Smrg -R) 570954b44505Smrg prev=xrpath 571054b44505Smrg continue 571154b44505Smrg ;; 571254b44505Smrg 571354b44505Smrg -R*) 571454b44505Smrg func_stripname '-R' '' "$arg" 571554b44505Smrg dir=$func_stripname_result 571654b44505Smrg # We need an absolute path. 571754b44505Smrg case $dir in 571854b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) ;; 571954b44505Smrg =*) 572054b44505Smrg func_stripname '=' '' "$dir" 572154b44505Smrg dir=$lt_sysroot$func_stripname_result 572254b44505Smrg ;; 572354b44505Smrg *) 572454b44505Smrg func_fatal_error "only absolute run-paths are allowed" 572554b44505Smrg ;; 572654b44505Smrg esac 572754b44505Smrg case "$xrpath " in 572854b44505Smrg *" $dir "*) ;; 572954b44505Smrg *) func_append xrpath " $dir" ;; 573054b44505Smrg esac 573154b44505Smrg continue 573254b44505Smrg ;; 573354b44505Smrg 573454b44505Smrg -shared) 573554b44505Smrg # The effects of -shared are defined in a previous loop. 573654b44505Smrg continue 573754b44505Smrg ;; 573854b44505Smrg 573954b44505Smrg -shrext) 574054b44505Smrg prev=shrext 574154b44505Smrg continue 574254b44505Smrg ;; 574354b44505Smrg 574454b44505Smrg -static | -static-libtool-libs) 574554b44505Smrg # The effects of -static are defined in a previous loop. 574654b44505Smrg # We used to do the same as -all-static on platforms that 574754b44505Smrg # didn't have a PIC flag, but the assumption that the effects 574854b44505Smrg # would be equivalent was wrong. It would break on at least 574954b44505Smrg # Digital Unix and AIX. 575054b44505Smrg continue 575154b44505Smrg ;; 575254b44505Smrg 575354b44505Smrg -thread-safe) 575454b44505Smrg thread_safe=yes 575554b44505Smrg continue 575654b44505Smrg ;; 575754b44505Smrg 575854b44505Smrg -version-info) 575954b44505Smrg prev=vinfo 576054b44505Smrg continue 576154b44505Smrg ;; 576254b44505Smrg 576354b44505Smrg -version-number) 576454b44505Smrg prev=vinfo 576554b44505Smrg vinfo_number=yes 576654b44505Smrg continue 576754b44505Smrg ;; 576854b44505Smrg 576954b44505Smrg -weak) 577054b44505Smrg prev=weak 577154b44505Smrg continue 577254b44505Smrg ;; 577354b44505Smrg 577454b44505Smrg -Wc,*) 577554b44505Smrg func_stripname '-Wc,' '' "$arg" 577654b44505Smrg args=$func_stripname_result 577754b44505Smrg arg= 577854b44505Smrg save_ifs="$IFS"; IFS=',' 577954b44505Smrg for flag in $args; do 578054b44505Smrg IFS="$save_ifs" 578154b44505Smrg func_quote_for_eval "$flag" 578254b44505Smrg func_append arg " $func_quote_for_eval_result" 578354b44505Smrg func_append compiler_flags " $func_quote_for_eval_result" 578454b44505Smrg done 578554b44505Smrg IFS="$save_ifs" 578654b44505Smrg func_stripname ' ' '' "$arg" 578754b44505Smrg arg=$func_stripname_result 578854b44505Smrg ;; 578954b44505Smrg 579054b44505Smrg -Wl,*) 579154b44505Smrg func_stripname '-Wl,' '' "$arg" 579254b44505Smrg args=$func_stripname_result 579354b44505Smrg arg= 579454b44505Smrg save_ifs="$IFS"; IFS=',' 579554b44505Smrg for flag in $args; do 579654b44505Smrg IFS="$save_ifs" 579754b44505Smrg func_quote_for_eval "$flag" 579854b44505Smrg func_append arg " $wl$func_quote_for_eval_result" 579954b44505Smrg func_append compiler_flags " $wl$func_quote_for_eval_result" 580054b44505Smrg func_append linker_flags " $func_quote_for_eval_result" 580154b44505Smrg done 580254b44505Smrg IFS="$save_ifs" 580354b44505Smrg func_stripname ' ' '' "$arg" 580454b44505Smrg arg=$func_stripname_result 580554b44505Smrg ;; 580654b44505Smrg 580754b44505Smrg -Xcompiler) 580854b44505Smrg prev=xcompiler 580954b44505Smrg continue 581054b44505Smrg ;; 581154b44505Smrg 581254b44505Smrg -Xlinker) 581354b44505Smrg prev=xlinker 581454b44505Smrg continue 581554b44505Smrg ;; 581654b44505Smrg 581754b44505Smrg -XCClinker) 581854b44505Smrg prev=xcclinker 581954b44505Smrg continue 582054b44505Smrg ;; 582154b44505Smrg 582254b44505Smrg # -msg_* for osf cc 582354b44505Smrg -msg_*) 582454b44505Smrg func_quote_for_eval "$arg" 582554b44505Smrg arg="$func_quote_for_eval_result" 582654b44505Smrg ;; 582754b44505Smrg 582854b44505Smrg # Flags to be passed through unchanged, with rationale: 582954b44505Smrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 583054b44505Smrg # -r[0-9][0-9]* specify processor for the SGI compiler 583154b44505Smrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 583254b44505Smrg # +DA*, +DD* enable 64-bit mode for the HP compiler 583354b44505Smrg # -q* compiler args for the IBM compiler 583454b44505Smrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 583554b44505Smrg # -F/path path to uninstalled frameworks, gcc on darwin 583654b44505Smrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 583754b44505Smrg # @file GCC response files 583854b44505Smrg # -tp=* Portland pgcc target processor selection 583954b44505Smrg # --sysroot=* for sysroot support 584054b44505Smrg # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 584154b44505Smrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 584254b44505Smrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 584354b44505Smrg -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 584454b44505Smrg func_quote_for_eval "$arg" 584554b44505Smrg arg="$func_quote_for_eval_result" 584654b44505Smrg func_append compile_command " $arg" 584754b44505Smrg func_append finalize_command " $arg" 584854b44505Smrg func_append compiler_flags " $arg" 584954b44505Smrg continue 585054b44505Smrg ;; 585154b44505Smrg 585254b44505Smrg # Some other compiler flag. 585354b44505Smrg -* | +*) 585454b44505Smrg func_quote_for_eval "$arg" 585554b44505Smrg arg="$func_quote_for_eval_result" 585654b44505Smrg ;; 585754b44505Smrg 585854b44505Smrg *.$objext) 585954b44505Smrg # A standard object. 586054b44505Smrg func_append objs " $arg" 586154b44505Smrg ;; 586254b44505Smrg 586354b44505Smrg *.lo) 586454b44505Smrg # A libtool-controlled object. 586554b44505Smrg 586654b44505Smrg # Check to see that this really is a libtool object. 586754b44505Smrg if func_lalib_unsafe_p "$arg"; then 586854b44505Smrg pic_object= 586954b44505Smrg non_pic_object= 587054b44505Smrg 587154b44505Smrg # Read the .lo file 587254b44505Smrg func_source "$arg" 587354b44505Smrg 587454b44505Smrg if test -z "$pic_object" || 587554b44505Smrg test -z "$non_pic_object" || 587654b44505Smrg test "$pic_object" = none && 587754b44505Smrg test "$non_pic_object" = none; then 587854b44505Smrg func_fatal_error "cannot find name of object for \`$arg'" 587954b44505Smrg fi 588054b44505Smrg 588154b44505Smrg # Extract subdirectory from the argument. 588254b44505Smrg func_dirname "$arg" "/" "" 588354b44505Smrg xdir="$func_dirname_result" 588454b44505Smrg 588554b44505Smrg if test "$pic_object" != none; then 588654b44505Smrg # Prepend the subdirectory the object is found in. 588754b44505Smrg pic_object="$xdir$pic_object" 588854b44505Smrg 588954b44505Smrg if test "$prev" = dlfiles; then 589054b44505Smrg if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 589154b44505Smrg func_append dlfiles " $pic_object" 589254b44505Smrg prev= 589354b44505Smrg continue 589454b44505Smrg else 589554b44505Smrg # If libtool objects are unsupported, then we need to preload. 589654b44505Smrg prev=dlprefiles 589754b44505Smrg fi 589854b44505Smrg fi 589954b44505Smrg 590054b44505Smrg # CHECK ME: I think I busted this. -Ossama 590154b44505Smrg if test "$prev" = dlprefiles; then 590254b44505Smrg # Preload the old-style object. 590354b44505Smrg func_append dlprefiles " $pic_object" 590454b44505Smrg prev= 590554b44505Smrg fi 590654b44505Smrg 590754b44505Smrg # A PIC object. 590854b44505Smrg func_append libobjs " $pic_object" 590954b44505Smrg arg="$pic_object" 591054b44505Smrg fi 591154b44505Smrg 591254b44505Smrg # Non-PIC object. 591354b44505Smrg if test "$non_pic_object" != none; then 591454b44505Smrg # Prepend the subdirectory the object is found in. 591554b44505Smrg non_pic_object="$xdir$non_pic_object" 591654b44505Smrg 591754b44505Smrg # A standard non-PIC object 591854b44505Smrg func_append non_pic_objects " $non_pic_object" 591954b44505Smrg if test -z "$pic_object" || test "$pic_object" = none ; then 592054b44505Smrg arg="$non_pic_object" 592154b44505Smrg fi 592254b44505Smrg else 592354b44505Smrg # If the PIC object exists, use it instead. 592454b44505Smrg # $xdir was prepended to $pic_object above. 592554b44505Smrg non_pic_object="$pic_object" 592654b44505Smrg func_append non_pic_objects " $non_pic_object" 592754b44505Smrg fi 592854b44505Smrg else 592954b44505Smrg # Only an error if not doing a dry-run. 593054b44505Smrg if $opt_dry_run; then 593154b44505Smrg # Extract subdirectory from the argument. 593254b44505Smrg func_dirname "$arg" "/" "" 593354b44505Smrg xdir="$func_dirname_result" 593454b44505Smrg 593554b44505Smrg func_lo2o "$arg" 593654b44505Smrg pic_object=$xdir$objdir/$func_lo2o_result 593754b44505Smrg non_pic_object=$xdir$func_lo2o_result 593854b44505Smrg func_append libobjs " $pic_object" 593954b44505Smrg func_append non_pic_objects " $non_pic_object" 594054b44505Smrg else 594154b44505Smrg func_fatal_error "\`$arg' is not a valid libtool object" 594254b44505Smrg fi 594354b44505Smrg fi 594454b44505Smrg ;; 594554b44505Smrg 594654b44505Smrg *.$libext) 594754b44505Smrg # An archive. 594854b44505Smrg func_append deplibs " $arg" 594954b44505Smrg func_append old_deplibs " $arg" 595054b44505Smrg continue 595154b44505Smrg ;; 595254b44505Smrg 595354b44505Smrg *.la) 595454b44505Smrg # A libtool-controlled library. 595554b44505Smrg 595654b44505Smrg func_resolve_sysroot "$arg" 595754b44505Smrg if test "$prev" = dlfiles; then 595854b44505Smrg # This library was specified with -dlopen. 595954b44505Smrg func_append dlfiles " $func_resolve_sysroot_result" 596054b44505Smrg prev= 596154b44505Smrg elif test "$prev" = dlprefiles; then 596254b44505Smrg # The library was specified with -dlpreopen. 596354b44505Smrg func_append dlprefiles " $func_resolve_sysroot_result" 596454b44505Smrg prev= 596554b44505Smrg else 596654b44505Smrg func_append deplibs " $func_resolve_sysroot_result" 596754b44505Smrg fi 596854b44505Smrg continue 596954b44505Smrg ;; 597054b44505Smrg 597154b44505Smrg # Some other compiler argument. 597254b44505Smrg *) 597354b44505Smrg # Unknown arguments in both finalize_command and compile_command need 597454b44505Smrg # to be aesthetically quoted because they are evaled later. 597554b44505Smrg func_quote_for_eval "$arg" 597654b44505Smrg arg="$func_quote_for_eval_result" 597754b44505Smrg ;; 597854b44505Smrg esac # arg 597954b44505Smrg 598054b44505Smrg # Now actually substitute the argument into the commands. 598154b44505Smrg if test -n "$arg"; then 598254b44505Smrg func_append compile_command " $arg" 598354b44505Smrg func_append finalize_command " $arg" 598454b44505Smrg fi 598554b44505Smrg done # argument parsing loop 598654b44505Smrg 598754b44505Smrg test -n "$prev" && \ 598854b44505Smrg func_fatal_help "the \`$prevarg' option requires an argument" 598954b44505Smrg 599054b44505Smrg if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 599154b44505Smrg eval arg=\"$export_dynamic_flag_spec\" 599254b44505Smrg func_append compile_command " $arg" 599354b44505Smrg func_append finalize_command " $arg" 599454b44505Smrg fi 599554b44505Smrg 599654b44505Smrg oldlibs= 599754b44505Smrg # calculate the name of the file, without its directory 599854b44505Smrg func_basename "$output" 599954b44505Smrg outputname="$func_basename_result" 600054b44505Smrg libobjs_save="$libobjs" 600154b44505Smrg 600254b44505Smrg if test -n "$shlibpath_var"; then 600354b44505Smrg # get the directories listed in $shlibpath_var 600454b44505Smrg eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 600554b44505Smrg else 600654b44505Smrg shlib_search_path= 600754b44505Smrg fi 600854b44505Smrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 600954b44505Smrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 601054b44505Smrg 601154b44505Smrg func_dirname "$output" "/" "" 601254b44505Smrg output_objdir="$func_dirname_result$objdir" 601354b44505Smrg func_to_tool_file "$output_objdir/" 601454b44505Smrg tool_output_objdir=$func_to_tool_file_result 601554b44505Smrg # Create the object directory. 601654b44505Smrg func_mkdir_p "$output_objdir" 601754b44505Smrg 601854b44505Smrg # Determine the type of output 601954b44505Smrg case $output in 602054b44505Smrg "") 602154b44505Smrg func_fatal_help "you must specify an output file" 602254b44505Smrg ;; 602354b44505Smrg *.$libext) linkmode=oldlib ;; 602454b44505Smrg *.lo | *.$objext) linkmode=obj ;; 602554b44505Smrg *.la) linkmode=lib ;; 602654b44505Smrg *) linkmode=prog ;; # Anything else should be a program. 602754b44505Smrg esac 602854b44505Smrg 602954b44505Smrg specialdeplibs= 603054b44505Smrg 603154b44505Smrg libs= 603254b44505Smrg # Find all interdependent deplibs by searching for libraries 603354b44505Smrg # that are linked more than once (e.g. -la -lb -la) 603454b44505Smrg for deplib in $deplibs; do 603554b44505Smrg if $opt_preserve_dup_deps ; then 603654b44505Smrg case "$libs " in 603754b44505Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 603854b44505Smrg esac 603954b44505Smrg fi 604054b44505Smrg func_append libs " $deplib" 604154b44505Smrg done 604254b44505Smrg 604354b44505Smrg if test "$linkmode" = lib; then 604454b44505Smrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 604554b44505Smrg 604654b44505Smrg # Compute libraries that are listed more than once in $predeps 604754b44505Smrg # $postdeps and mark them as special (i.e., whose duplicates are 604854b44505Smrg # not to be eliminated). 604954b44505Smrg pre_post_deps= 605054b44505Smrg if $opt_duplicate_compiler_generated_deps; then 605154b44505Smrg for pre_post_dep in $predeps $postdeps; do 605254b44505Smrg case "$pre_post_deps " in 605354b44505Smrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 605454b44505Smrg esac 605554b44505Smrg func_append pre_post_deps " $pre_post_dep" 605654b44505Smrg done 605754b44505Smrg fi 605854b44505Smrg pre_post_deps= 605954b44505Smrg fi 606054b44505Smrg 606154b44505Smrg deplibs= 606254b44505Smrg newdependency_libs= 606354b44505Smrg newlib_search_path= 606454b44505Smrg need_relink=no # whether we're linking any uninstalled libtool libraries 606554b44505Smrg notinst_deplibs= # not-installed libtool libraries 606654b44505Smrg notinst_path= # paths that contain not-installed libtool libraries 606754b44505Smrg 606854b44505Smrg case $linkmode in 606954b44505Smrg lib) 607054b44505Smrg passes="conv dlpreopen link" 607154b44505Smrg for file in $dlfiles $dlprefiles; do 607254b44505Smrg case $file in 607354b44505Smrg *.la) ;; 607454b44505Smrg *) 607554b44505Smrg func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 607654b44505Smrg ;; 607754b44505Smrg esac 607854b44505Smrg done 607954b44505Smrg ;; 608054b44505Smrg prog) 608154b44505Smrg compile_deplibs= 608254b44505Smrg finalize_deplibs= 608354b44505Smrg alldeplibs=no 608454b44505Smrg newdlfiles= 608554b44505Smrg newdlprefiles= 608654b44505Smrg passes="conv scan dlopen dlpreopen link" 608754b44505Smrg ;; 608854b44505Smrg *) passes="conv" 608954b44505Smrg ;; 609054b44505Smrg esac 609154b44505Smrg 609254b44505Smrg for pass in $passes; do 609354b44505Smrg # The preopen pass in lib mode reverses $deplibs; put it back here 609454b44505Smrg # so that -L comes before libs that need it for instance... 609554b44505Smrg if test "$linkmode,$pass" = "lib,link"; then 609654b44505Smrg ## FIXME: Find the place where the list is rebuilt in the wrong 609754b44505Smrg ## order, and fix it there properly 609854b44505Smrg tmp_deplibs= 609954b44505Smrg for deplib in $deplibs; do 610054b44505Smrg tmp_deplibs="$deplib $tmp_deplibs" 610154b44505Smrg done 610254b44505Smrg deplibs="$tmp_deplibs" 610354b44505Smrg fi 610454b44505Smrg 610554b44505Smrg if test "$linkmode,$pass" = "lib,link" || 610654b44505Smrg test "$linkmode,$pass" = "prog,scan"; then 610754b44505Smrg libs="$deplibs" 610854b44505Smrg deplibs= 610954b44505Smrg fi 611054b44505Smrg if test "$linkmode" = prog; then 611154b44505Smrg case $pass in 611254b44505Smrg dlopen) libs="$dlfiles" ;; 611354b44505Smrg dlpreopen) libs="$dlprefiles" ;; 611454b44505Smrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 611554b44505Smrg esac 611654b44505Smrg fi 611754b44505Smrg if test "$linkmode,$pass" = "lib,dlpreopen"; then 611854b44505Smrg # Collect and forward deplibs of preopened libtool libs 611954b44505Smrg for lib in $dlprefiles; do 612054b44505Smrg # Ignore non-libtool-libs 612154b44505Smrg dependency_libs= 612254b44505Smrg func_resolve_sysroot "$lib" 612354b44505Smrg case $lib in 612454b44505Smrg *.la) func_source "$func_resolve_sysroot_result" ;; 612554b44505Smrg esac 612654b44505Smrg 612754b44505Smrg # Collect preopened libtool deplibs, except any this library 612854b44505Smrg # has declared as weak libs 612954b44505Smrg for deplib in $dependency_libs; do 613054b44505Smrg func_basename "$deplib" 613154b44505Smrg deplib_base=$func_basename_result 613254b44505Smrg case " $weak_libs " in 613354b44505Smrg *" $deplib_base "*) ;; 613454b44505Smrg *) func_append deplibs " $deplib" ;; 613554b44505Smrg esac 613654b44505Smrg done 613754b44505Smrg done 613854b44505Smrg libs="$dlprefiles" 613954b44505Smrg fi 614054b44505Smrg if test "$pass" = dlopen; then 614154b44505Smrg # Collect dlpreopened libraries 614254b44505Smrg save_deplibs="$deplibs" 614354b44505Smrg deplibs= 614454b44505Smrg fi 614554b44505Smrg 614654b44505Smrg for deplib in $libs; do 614754b44505Smrg lib= 614854b44505Smrg found=no 614954b44505Smrg case $deplib in 615054b44505Smrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 615154b44505Smrg if test "$linkmode,$pass" = "prog,link"; then 615254b44505Smrg compile_deplibs="$deplib $compile_deplibs" 615354b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 615454b44505Smrg else 615554b44505Smrg func_append compiler_flags " $deplib" 615654b44505Smrg if test "$linkmode" = lib ; then 615754b44505Smrg case "$new_inherited_linker_flags " in 615854b44505Smrg *" $deplib "*) ;; 615954b44505Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 616054b44505Smrg esac 616154b44505Smrg fi 616254b44505Smrg fi 616354b44505Smrg continue 616454b44505Smrg ;; 616554b44505Smrg -l*) 616654b44505Smrg if test "$linkmode" != lib && test "$linkmode" != prog; then 616754b44505Smrg func_warning "\`-l' is ignored for archives/objects" 616854b44505Smrg continue 616954b44505Smrg fi 617054b44505Smrg func_stripname '-l' '' "$deplib" 617154b44505Smrg name=$func_stripname_result 617254b44505Smrg if test "$linkmode" = lib; then 617354b44505Smrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 617454b44505Smrg else 617554b44505Smrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 617654b44505Smrg fi 617754b44505Smrg for searchdir in $searchdirs; do 617854b44505Smrg for search_ext in .la $std_shrext .so .a; do 617954b44505Smrg # Search the libtool library 618054b44505Smrg lib="$searchdir/lib${name}${search_ext}" 618154b44505Smrg if test -f "$lib"; then 618254b44505Smrg if test "$search_ext" = ".la"; then 618354b44505Smrg found=yes 618454b44505Smrg else 618554b44505Smrg found=no 618654b44505Smrg fi 618754b44505Smrg break 2 618854b44505Smrg fi 618954b44505Smrg done 619054b44505Smrg done 619154b44505Smrg if test "$found" != yes; then 619254b44505Smrg # deplib doesn't seem to be a libtool library 619354b44505Smrg if test "$linkmode,$pass" = "prog,link"; then 619454b44505Smrg compile_deplibs="$deplib $compile_deplibs" 619554b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 619654b44505Smrg else 619754b44505Smrg deplibs="$deplib $deplibs" 619854b44505Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 619954b44505Smrg fi 620054b44505Smrg continue 620154b44505Smrg else # deplib is a libtool library 620254b44505Smrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 620354b44505Smrg # We need to do some special things here, and not later. 620454b44505Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 620554b44505Smrg case " $predeps $postdeps " in 620654b44505Smrg *" $deplib "*) 620754b44505Smrg if func_lalib_p "$lib"; then 620854b44505Smrg library_names= 620954b44505Smrg old_library= 621054b44505Smrg func_source "$lib" 621154b44505Smrg for l in $old_library $library_names; do 621254b44505Smrg ll="$l" 621354b44505Smrg done 621454b44505Smrg if test "X$ll" = "X$old_library" ; then # only static version available 621554b44505Smrg found=no 621654b44505Smrg func_dirname "$lib" "" "." 621754b44505Smrg ladir="$func_dirname_result" 621854b44505Smrg lib=$ladir/$old_library 621954b44505Smrg if test "$linkmode,$pass" = "prog,link"; then 622054b44505Smrg compile_deplibs="$deplib $compile_deplibs" 622154b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 622254b44505Smrg else 622354b44505Smrg deplibs="$deplib $deplibs" 622454b44505Smrg test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 622554b44505Smrg fi 622654b44505Smrg continue 622754b44505Smrg fi 622854b44505Smrg fi 622954b44505Smrg ;; 623054b44505Smrg *) ;; 623154b44505Smrg esac 623254b44505Smrg fi 623354b44505Smrg fi 623454b44505Smrg ;; # -l 623554b44505Smrg *.ltframework) 623654b44505Smrg if test "$linkmode,$pass" = "prog,link"; then 623754b44505Smrg compile_deplibs="$deplib $compile_deplibs" 623854b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 623954b44505Smrg else 624054b44505Smrg deplibs="$deplib $deplibs" 624154b44505Smrg if test "$linkmode" = lib ; then 624254b44505Smrg case "$new_inherited_linker_flags " in 624354b44505Smrg *" $deplib "*) ;; 624454b44505Smrg * ) func_append new_inherited_linker_flags " $deplib" ;; 624554b44505Smrg esac 624654b44505Smrg fi 624754b44505Smrg fi 624854b44505Smrg continue 624954b44505Smrg ;; 625054b44505Smrg -L*) 625154b44505Smrg case $linkmode in 625254b44505Smrg lib) 625354b44505Smrg deplibs="$deplib $deplibs" 625454b44505Smrg test "$pass" = conv && continue 625554b44505Smrg newdependency_libs="$deplib $newdependency_libs" 625654b44505Smrg func_stripname '-L' '' "$deplib" 625754b44505Smrg func_resolve_sysroot "$func_stripname_result" 625854b44505Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 625954b44505Smrg ;; 626054b44505Smrg prog) 626154b44505Smrg if test "$pass" = conv; then 626254b44505Smrg deplibs="$deplib $deplibs" 626354b44505Smrg continue 626454b44505Smrg fi 626554b44505Smrg if test "$pass" = scan; then 626654b44505Smrg deplibs="$deplib $deplibs" 626754b44505Smrg else 626854b44505Smrg compile_deplibs="$deplib $compile_deplibs" 626954b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 627054b44505Smrg fi 627154b44505Smrg func_stripname '-L' '' "$deplib" 627254b44505Smrg func_resolve_sysroot "$func_stripname_result" 627354b44505Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 627454b44505Smrg ;; 627554b44505Smrg *) 627654b44505Smrg func_warning "\`-L' is ignored for archives/objects" 627754b44505Smrg ;; 627854b44505Smrg esac # linkmode 627954b44505Smrg continue 628054b44505Smrg ;; # -L 628154b44505Smrg -R*) 628254b44505Smrg if test "$pass" = link; then 628354b44505Smrg func_stripname '-R' '' "$deplib" 628454b44505Smrg func_resolve_sysroot "$func_stripname_result" 628554b44505Smrg dir=$func_resolve_sysroot_result 628654b44505Smrg # Make sure the xrpath contains only unique directories. 628754b44505Smrg case "$xrpath " in 628854b44505Smrg *" $dir "*) ;; 628954b44505Smrg *) func_append xrpath " $dir" ;; 629054b44505Smrg esac 629154b44505Smrg fi 629254b44505Smrg deplibs="$deplib $deplibs" 629354b44505Smrg continue 629454b44505Smrg ;; 629554b44505Smrg *.la) 629654b44505Smrg func_resolve_sysroot "$deplib" 629754b44505Smrg lib=$func_resolve_sysroot_result 629854b44505Smrg ;; 629954b44505Smrg *.$libext) 630054b44505Smrg if test "$pass" = conv; then 630154b44505Smrg deplibs="$deplib $deplibs" 630254b44505Smrg continue 630354b44505Smrg fi 630454b44505Smrg case $linkmode in 630554b44505Smrg lib) 630654b44505Smrg # Linking convenience modules into shared libraries is allowed, 630754b44505Smrg # but linking other static libraries is non-portable. 630854b44505Smrg case " $dlpreconveniencelibs " in 630954b44505Smrg *" $deplib "*) ;; 631054b44505Smrg *) 631154b44505Smrg valid_a_lib=no 631254b44505Smrg case $deplibs_check_method in 631354b44505Smrg match_pattern*) 631454b44505Smrg set dummy $deplibs_check_method; shift 631554b44505Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 631654b44505Smrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 631754b44505Smrg | $EGREP "$match_pattern_regex" > /dev/null; then 631854b44505Smrg valid_a_lib=yes 631954b44505Smrg fi 632054b44505Smrg ;; 632154b44505Smrg pass_all) 632254b44505Smrg valid_a_lib=yes 632354b44505Smrg ;; 632454b44505Smrg esac 632554b44505Smrg if test "$valid_a_lib" != yes; then 632654b44505Smrg echo 632754b44505Smrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 632854b44505Smrg echo "*** I have the capability to make that library automatically link in when" 632954b44505Smrg echo "*** you link to this library. But I can only do this if you have a" 633054b44505Smrg echo "*** shared version of the library, which you do not appear to have" 633154b44505Smrg echo "*** because the file extensions .$libext of this argument makes me believe" 633254b44505Smrg echo "*** that it is just a static archive that I should not use here." 633354b44505Smrg else 633454b44505Smrg echo 633554b44505Smrg $ECHO "*** Warning: Linking the shared library $output against the" 633654b44505Smrg $ECHO "*** static library $deplib is not portable!" 633754b44505Smrg deplibs="$deplib $deplibs" 633854b44505Smrg fi 633954b44505Smrg ;; 634054b44505Smrg esac 634154b44505Smrg continue 634254b44505Smrg ;; 634354b44505Smrg prog) 634454b44505Smrg if test "$pass" != link; then 634554b44505Smrg deplibs="$deplib $deplibs" 634654b44505Smrg else 634754b44505Smrg compile_deplibs="$deplib $compile_deplibs" 634854b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 634954b44505Smrg fi 635054b44505Smrg continue 635154b44505Smrg ;; 635254b44505Smrg esac # linkmode 635354b44505Smrg ;; # *.$libext 635454b44505Smrg *.lo | *.$objext) 635554b44505Smrg if test "$pass" = conv; then 635654b44505Smrg deplibs="$deplib $deplibs" 635754b44505Smrg elif test "$linkmode" = prog; then 635854b44505Smrg if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 635954b44505Smrg # If there is no dlopen support or we're linking statically, 636054b44505Smrg # we need to preload. 636154b44505Smrg func_append newdlprefiles " $deplib" 636254b44505Smrg compile_deplibs="$deplib $compile_deplibs" 636354b44505Smrg finalize_deplibs="$deplib $finalize_deplibs" 636454b44505Smrg else 636554b44505Smrg func_append newdlfiles " $deplib" 636654b44505Smrg fi 636754b44505Smrg fi 636854b44505Smrg continue 636954b44505Smrg ;; 637054b44505Smrg %DEPLIBS%) 637154b44505Smrg alldeplibs=yes 637254b44505Smrg continue 637354b44505Smrg ;; 637454b44505Smrg esac # case $deplib 637554b44505Smrg 637654b44505Smrg if test "$found" = yes || test -f "$lib"; then : 637754b44505Smrg else 637854b44505Smrg func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 637954b44505Smrg fi 638054b44505Smrg 638154b44505Smrg # Check to see that this really is a libtool archive. 638254b44505Smrg func_lalib_unsafe_p "$lib" \ 638354b44505Smrg || func_fatal_error "\`$lib' is not a valid libtool archive" 638454b44505Smrg 638554b44505Smrg func_dirname "$lib" "" "." 638654b44505Smrg ladir="$func_dirname_result" 638754b44505Smrg 638854b44505Smrg dlname= 638954b44505Smrg dlopen= 639054b44505Smrg dlpreopen= 639154b44505Smrg libdir= 639254b44505Smrg library_names= 639354b44505Smrg old_library= 639454b44505Smrg inherited_linker_flags= 639554b44505Smrg # If the library was installed with an old release of libtool, 639654b44505Smrg # it will not redefine variables installed, or shouldnotlink 639754b44505Smrg installed=yes 639854b44505Smrg shouldnotlink=no 639954b44505Smrg avoidtemprpath= 640054b44505Smrg 640154b44505Smrg 640254b44505Smrg # Read the .la file 640354b44505Smrg func_source "$lib" 640454b44505Smrg 640554b44505Smrg # Convert "-framework foo" to "foo.ltframework" 640654b44505Smrg if test -n "$inherited_linker_flags"; then 640754b44505Smrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 640854b44505Smrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 640954b44505Smrg case " $new_inherited_linker_flags " in 641054b44505Smrg *" $tmp_inherited_linker_flag "*) ;; 641154b44505Smrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 641254b44505Smrg esac 641354b44505Smrg done 641454b44505Smrg fi 641554b44505Smrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 641654b44505Smrg if test "$linkmode,$pass" = "lib,link" || 641754b44505Smrg test "$linkmode,$pass" = "prog,scan" || 641854b44505Smrg { test "$linkmode" != prog && test "$linkmode" != lib; }; then 641954b44505Smrg test -n "$dlopen" && func_append dlfiles " $dlopen" 642054b44505Smrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 642154b44505Smrg fi 642254b44505Smrg 642354b44505Smrg if test "$pass" = conv; then 642454b44505Smrg # Only check for convenience libraries 642554b44505Smrg deplibs="$lib $deplibs" 642654b44505Smrg if test -z "$libdir"; then 642754b44505Smrg if test -z "$old_library"; then 642854b44505Smrg func_fatal_error "cannot find name of link library for \`$lib'" 642954b44505Smrg fi 643054b44505Smrg # It is a libtool convenience library, so add in its objects. 643154b44505Smrg func_append convenience " $ladir/$objdir/$old_library" 643254b44505Smrg func_append old_convenience " $ladir/$objdir/$old_library" 643354b44505Smrg elif test "$linkmode" != prog && test "$linkmode" != lib; then 643454b44505Smrg func_fatal_error "\`$lib' is not a convenience library" 643554b44505Smrg fi 643654b44505Smrg tmp_libs= 643754b44505Smrg for deplib in $dependency_libs; do 643854b44505Smrg deplibs="$deplib $deplibs" 643954b44505Smrg if $opt_preserve_dup_deps ; then 644054b44505Smrg case "$tmp_libs " in 644154b44505Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 644254b44505Smrg esac 644354b44505Smrg fi 644454b44505Smrg func_append tmp_libs " $deplib" 644554b44505Smrg done 644654b44505Smrg continue 644754b44505Smrg fi # $pass = conv 644854b44505Smrg 644954b44505Smrg 645054b44505Smrg # Get the name of the library we link against. 645154b44505Smrg linklib= 645254b44505Smrg if test -n "$old_library" && 645354b44505Smrg { test "$prefer_static_libs" = yes || 645454b44505Smrg test "$prefer_static_libs,$installed" = "built,no"; }; then 645554b44505Smrg linklib=$old_library 645654b44505Smrg else 645754b44505Smrg for l in $old_library $library_names; do 645854b44505Smrg linklib="$l" 645954b44505Smrg done 646054b44505Smrg fi 646154b44505Smrg if test -z "$linklib"; then 646254b44505Smrg func_fatal_error "cannot find name of link library for \`$lib'" 646354b44505Smrg fi 646454b44505Smrg 646554b44505Smrg # This library was specified with -dlopen. 646654b44505Smrg if test "$pass" = dlopen; then 646754b44505Smrg if test -z "$libdir"; then 646854b44505Smrg func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 646954b44505Smrg fi 647054b44505Smrg if test -z "$dlname" || 647154b44505Smrg test "$dlopen_support" != yes || 647254b44505Smrg test "$build_libtool_libs" = no; then 647354b44505Smrg # If there is no dlname, no dlopen support or we're linking 647454b44505Smrg # statically, we need to preload. We also need to preload any 647554b44505Smrg # dependent libraries so libltdl's deplib preloader doesn't 647654b44505Smrg # bomb out in the load deplibs phase. 647754b44505Smrg func_append dlprefiles " $lib $dependency_libs" 647854b44505Smrg else 647954b44505Smrg func_append newdlfiles " $lib" 648054b44505Smrg fi 648154b44505Smrg continue 648254b44505Smrg fi # $pass = dlopen 648354b44505Smrg 648454b44505Smrg # We need an absolute path. 648554b44505Smrg case $ladir in 648654b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 648754b44505Smrg *) 648854b44505Smrg abs_ladir=`cd "$ladir" && pwd` 648954b44505Smrg if test -z "$abs_ladir"; then 649054b44505Smrg func_warning "cannot determine absolute directory name of \`$ladir'" 649154b44505Smrg func_warning "passing it literally to the linker, although it might fail" 649254b44505Smrg abs_ladir="$ladir" 649354b44505Smrg fi 649454b44505Smrg ;; 649554b44505Smrg esac 649654b44505Smrg func_basename "$lib" 649754b44505Smrg laname="$func_basename_result" 649854b44505Smrg 649954b44505Smrg # Find the relevant object directory and library name. 650054b44505Smrg if test "X$installed" = Xyes; then 650154b44505Smrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 650254b44505Smrg func_warning "library \`$lib' was moved." 650354b44505Smrg dir="$ladir" 650454b44505Smrg absdir="$abs_ladir" 650554b44505Smrg libdir="$abs_ladir" 650654b44505Smrg else 650754b44505Smrg dir="$lt_sysroot$libdir" 650854b44505Smrg absdir="$lt_sysroot$libdir" 650954b44505Smrg fi 651054b44505Smrg test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 651154b44505Smrg else 651254b44505Smrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 651354b44505Smrg dir="$ladir" 651454b44505Smrg absdir="$abs_ladir" 651554b44505Smrg # Remove this search path later 651654b44505Smrg func_append notinst_path " $abs_ladir" 651754b44505Smrg else 651854b44505Smrg dir="$ladir/$objdir" 651954b44505Smrg absdir="$abs_ladir/$objdir" 652054b44505Smrg # Remove this search path later 652154b44505Smrg func_append notinst_path " $abs_ladir" 652254b44505Smrg fi 652354b44505Smrg fi # $installed = yes 652454b44505Smrg func_stripname 'lib' '.la' "$laname" 652554b44505Smrg name=$func_stripname_result 652654b44505Smrg 652754b44505Smrg # This library was specified with -dlpreopen. 652854b44505Smrg if test "$pass" = dlpreopen; then 652954b44505Smrg if test -z "$libdir" && test "$linkmode" = prog; then 653054b44505Smrg func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 653154b44505Smrg fi 653254b44505Smrg case "$host" in 653354b44505Smrg # special handling for platforms with PE-DLLs. 653454b44505Smrg *cygwin* | *mingw* | *cegcc* ) 653554b44505Smrg # Linker will automatically link against shared library if both 653654b44505Smrg # static and shared are present. Therefore, ensure we extract 653754b44505Smrg # symbols from the import library if a shared library is present 653854b44505Smrg # (otherwise, the dlopen module name will be incorrect). We do 653954b44505Smrg # this by putting the import library name into $newdlprefiles. 654054b44505Smrg # We recover the dlopen module name by 'saving' the la file 654154b44505Smrg # name in a special purpose variable, and (later) extracting the 654254b44505Smrg # dlname from the la file. 654354b44505Smrg if test -n "$dlname"; then 654454b44505Smrg func_tr_sh "$dir/$linklib" 654554b44505Smrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 654654b44505Smrg func_append newdlprefiles " $dir/$linklib" 654754b44505Smrg else 654854b44505Smrg func_append newdlprefiles " $dir/$old_library" 654954b44505Smrg # Keep a list of preopened convenience libraries to check 655054b44505Smrg # that they are being used correctly in the link pass. 655154b44505Smrg test -z "$libdir" && \ 655254b44505Smrg func_append dlpreconveniencelibs " $dir/$old_library" 655354b44505Smrg fi 655454b44505Smrg ;; 655554b44505Smrg * ) 655654b44505Smrg # Prefer using a static library (so that no silly _DYNAMIC symbols 655754b44505Smrg # are required to link). 655854b44505Smrg if test -n "$old_library"; then 655954b44505Smrg func_append newdlprefiles " $dir/$old_library" 656054b44505Smrg # Keep a list of preopened convenience libraries to check 656154b44505Smrg # that they are being used correctly in the link pass. 656254b44505Smrg test -z "$libdir" && \ 656354b44505Smrg func_append dlpreconveniencelibs " $dir/$old_library" 656454b44505Smrg # Otherwise, use the dlname, so that lt_dlopen finds it. 656554b44505Smrg elif test -n "$dlname"; then 656654b44505Smrg func_append newdlprefiles " $dir/$dlname" 656754b44505Smrg else 656854b44505Smrg func_append newdlprefiles " $dir/$linklib" 656954b44505Smrg fi 657054b44505Smrg ;; 657154b44505Smrg esac 657254b44505Smrg fi # $pass = dlpreopen 657354b44505Smrg 657454b44505Smrg if test -z "$libdir"; then 657554b44505Smrg # Link the convenience library 657654b44505Smrg if test "$linkmode" = lib; then 657754b44505Smrg deplibs="$dir/$old_library $deplibs" 657854b44505Smrg elif test "$linkmode,$pass" = "prog,link"; then 657954b44505Smrg compile_deplibs="$dir/$old_library $compile_deplibs" 658054b44505Smrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 658154b44505Smrg else 658254b44505Smrg deplibs="$lib $deplibs" # used for prog,scan pass 658354b44505Smrg fi 658454b44505Smrg continue 658554b44505Smrg fi 658654b44505Smrg 658754b44505Smrg 658854b44505Smrg if test "$linkmode" = prog && test "$pass" != link; then 658954b44505Smrg func_append newlib_search_path " $ladir" 659054b44505Smrg deplibs="$lib $deplibs" 659154b44505Smrg 659254b44505Smrg linkalldeplibs=no 659354b44505Smrg if test "$link_all_deplibs" != no || test -z "$library_names" || 659454b44505Smrg test "$build_libtool_libs" = no; then 659554b44505Smrg linkalldeplibs=yes 659654b44505Smrg fi 659754b44505Smrg 659854b44505Smrg tmp_libs= 659954b44505Smrg for deplib in $dependency_libs; do 660054b44505Smrg case $deplib in 660154b44505Smrg -L*) func_stripname '-L' '' "$deplib" 660254b44505Smrg func_resolve_sysroot "$func_stripname_result" 660354b44505Smrg func_append newlib_search_path " $func_resolve_sysroot_result" 660454b44505Smrg ;; 660554b44505Smrg esac 660654b44505Smrg # Need to link against all dependency_libs? 660754b44505Smrg if test "$linkalldeplibs" = yes; then 660854b44505Smrg deplibs="$deplib $deplibs" 660954b44505Smrg else 661054b44505Smrg # Need to hardcode shared library paths 661154b44505Smrg # or/and link against static libraries 661254b44505Smrg newdependency_libs="$deplib $newdependency_libs" 661354b44505Smrg fi 661454b44505Smrg if $opt_preserve_dup_deps ; then 661554b44505Smrg case "$tmp_libs " in 661654b44505Smrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 661754b44505Smrg esac 661854b44505Smrg fi 661954b44505Smrg func_append tmp_libs " $deplib" 662054b44505Smrg done # for deplib 662154b44505Smrg continue 662254b44505Smrg fi # $linkmode = prog... 662354b44505Smrg 662454b44505Smrg if test "$linkmode,$pass" = "prog,link"; then 662554b44505Smrg if test -n "$library_names" && 662654b44505Smrg { { test "$prefer_static_libs" = no || 662754b44505Smrg test "$prefer_static_libs,$installed" = "built,yes"; } || 662854b44505Smrg test -z "$old_library"; }; then 662954b44505Smrg # We need to hardcode the library path 663054b44505Smrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 663154b44505Smrg # Make sure the rpath contains only unique directories. 663254b44505Smrg case "$temp_rpath:" in 663354b44505Smrg *"$absdir:"*) ;; 663454b44505Smrg *) func_append temp_rpath "$absdir:" ;; 663554b44505Smrg esac 663654b44505Smrg fi 663754b44505Smrg 663854b44505Smrg # Hardcode the library path. 663954b44505Smrg # Skip directories that are in the system default run-time 664054b44505Smrg # search path. 664154b44505Smrg case " $sys_lib_dlsearch_path " in 664254b44505Smrg *" $absdir "*) ;; 664354b44505Smrg *) 664454b44505Smrg case "$compile_rpath " in 664554b44505Smrg *" $absdir "*) ;; 664654b44505Smrg *) func_append compile_rpath " $absdir" ;; 664754b44505Smrg esac 664854b44505Smrg ;; 664954b44505Smrg esac 665054b44505Smrg case " $sys_lib_dlsearch_path " in 665154b44505Smrg *" $libdir "*) ;; 665254b44505Smrg *) 665354b44505Smrg case "$finalize_rpath " in 665454b44505Smrg *" $libdir "*) ;; 665554b44505Smrg *) func_append finalize_rpath " $libdir" ;; 665654b44505Smrg esac 665754b44505Smrg ;; 665854b44505Smrg esac 665954b44505Smrg fi # $linkmode,$pass = prog,link... 666054b44505Smrg 666154b44505Smrg if test "$alldeplibs" = yes && 666254b44505Smrg { test "$deplibs_check_method" = pass_all || 666354b44505Smrg { test "$build_libtool_libs" = yes && 666454b44505Smrg test -n "$library_names"; }; }; then 666554b44505Smrg # We only need to search for static libraries 666654b44505Smrg continue 666754b44505Smrg fi 666854b44505Smrg fi 666954b44505Smrg 667054b44505Smrg link_static=no # Whether the deplib will be linked statically 667154b44505Smrg use_static_libs=$prefer_static_libs 667254b44505Smrg if test "$use_static_libs" = built && test "$installed" = yes; then 667354b44505Smrg use_static_libs=no 667454b44505Smrg fi 667554b44505Smrg if test -n "$library_names" && 667654b44505Smrg { test "$use_static_libs" = no || test -z "$old_library"; }; then 667754b44505Smrg case $host in 667854b44505Smrg *cygwin* | *mingw* | *cegcc*) 667954b44505Smrg # No point in relinking DLLs because paths are not encoded 668054b44505Smrg func_append notinst_deplibs " $lib" 668154b44505Smrg need_relink=no 668254b44505Smrg ;; 668354b44505Smrg *) 668454b44505Smrg if test "$installed" = no; then 668554b44505Smrg func_append notinst_deplibs " $lib" 668654b44505Smrg need_relink=yes 668754b44505Smrg fi 668854b44505Smrg ;; 668954b44505Smrg esac 669054b44505Smrg # This is a shared library 669154b44505Smrg 669254b44505Smrg # Warn about portability, can't link against -module's on some 669354b44505Smrg # systems (darwin). Don't bleat about dlopened modules though! 669454b44505Smrg dlopenmodule="" 669554b44505Smrg for dlpremoduletest in $dlprefiles; do 669654b44505Smrg if test "X$dlpremoduletest" = "X$lib"; then 669754b44505Smrg dlopenmodule="$dlpremoduletest" 669854b44505Smrg break 669954b44505Smrg fi 670054b44505Smrg done 670154b44505Smrg if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 670254b44505Smrg echo 670354b44505Smrg if test "$linkmode" = prog; then 670454b44505Smrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 670554b44505Smrg else 670654b44505Smrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 670754b44505Smrg fi 670854b44505Smrg $ECHO "*** $linklib is not portable!" 670954b44505Smrg fi 671054b44505Smrg if test "$linkmode" = lib && 671154b44505Smrg test "$hardcode_into_libs" = yes; then 671254b44505Smrg # Hardcode the library path. 671354b44505Smrg # Skip directories that are in the system default run-time 671454b44505Smrg # search path. 671554b44505Smrg case " $sys_lib_dlsearch_path " in 671654b44505Smrg *" $absdir "*) ;; 671754b44505Smrg *) 671854b44505Smrg case "$compile_rpath " in 671954b44505Smrg *" $absdir "*) ;; 672054b44505Smrg *) func_append compile_rpath " $absdir" ;; 672154b44505Smrg esac 672254b44505Smrg ;; 672354b44505Smrg esac 672454b44505Smrg case " $sys_lib_dlsearch_path " in 672554b44505Smrg *" $libdir "*) ;; 672654b44505Smrg *) 672754b44505Smrg case "$finalize_rpath " in 672854b44505Smrg *" $libdir "*) ;; 672954b44505Smrg *) func_append finalize_rpath " $libdir" ;; 673054b44505Smrg esac 673154b44505Smrg ;; 673254b44505Smrg esac 673354b44505Smrg fi 673454b44505Smrg 673554b44505Smrg if test -n "$old_archive_from_expsyms_cmds"; then 673654b44505Smrg # figure out the soname 673754b44505Smrg set dummy $library_names 673854b44505Smrg shift 673954b44505Smrg realname="$1" 674054b44505Smrg shift 674154b44505Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 674254b44505Smrg # use dlname if we got it. it's perfectly good, no? 674354b44505Smrg if test -n "$dlname"; then 674454b44505Smrg soname="$dlname" 674554b44505Smrg elif test -n "$soname_spec"; then 674654b44505Smrg # bleh windows 674754b44505Smrg case $host in 674854b44505Smrg *cygwin* | mingw* | *cegcc*) 674954b44505Smrg func_arith $current - $age 675054b44505Smrg major=$func_arith_result 675154b44505Smrg versuffix="-$major" 675254b44505Smrg ;; 675354b44505Smrg esac 675454b44505Smrg eval soname=\"$soname_spec\" 675554b44505Smrg else 675654b44505Smrg soname="$realname" 675754b44505Smrg fi 675854b44505Smrg 675954b44505Smrg # Make a new name for the extract_expsyms_cmds to use 676054b44505Smrg soroot="$soname" 676154b44505Smrg func_basename "$soroot" 676254b44505Smrg soname="$func_basename_result" 676354b44505Smrg func_stripname 'lib' '.dll' "$soname" 676454b44505Smrg newlib=libimp-$func_stripname_result.a 676554b44505Smrg 676654b44505Smrg # If the library has no export list, then create one now 676754b44505Smrg if test -f "$output_objdir/$soname-def"; then : 676854b44505Smrg else 676954b44505Smrg func_verbose "extracting exported symbol list from \`$soname'" 677054b44505Smrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 677154b44505Smrg fi 677254b44505Smrg 677354b44505Smrg # Create $newlib 677454b44505Smrg if test -f "$output_objdir/$newlib"; then :; else 677554b44505Smrg func_verbose "generating import library for \`$soname'" 677654b44505Smrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 677754b44505Smrg fi 677854b44505Smrg # make sure the library variables are pointing to the new library 677954b44505Smrg dir=$output_objdir 678054b44505Smrg linklib=$newlib 678154b44505Smrg fi # test -n "$old_archive_from_expsyms_cmds" 678254b44505Smrg 678354b44505Smrg if test "$linkmode" = prog || test "$opt_mode" != relink; then 678454b44505Smrg add_shlibpath= 678554b44505Smrg add_dir= 678654b44505Smrg add= 678754b44505Smrg lib_linked=yes 678854b44505Smrg case $hardcode_action in 678954b44505Smrg immediate | unsupported) 679054b44505Smrg if test "$hardcode_direct" = no; then 679154b44505Smrg add="$dir/$linklib" 679254b44505Smrg case $host in 679354b44505Smrg *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 679454b44505Smrg *-*-sysv4*uw2*) add_dir="-L$dir" ;; 679554b44505Smrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 679654b44505Smrg *-*-unixware7*) add_dir="-L$dir" ;; 679754b44505Smrg *-*-darwin* ) 679854b44505Smrg # if the lib is a (non-dlopened) module then we can not 679954b44505Smrg # link against it, someone is ignoring the earlier warnings 680054b44505Smrg if /usr/bin/file -L $add 2> /dev/null | 680154b44505Smrg $GREP ": [^:]* bundle" >/dev/null ; then 680254b44505Smrg if test "X$dlopenmodule" != "X$lib"; then 680354b44505Smrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 680454b44505Smrg if test -z "$old_library" ; then 680554b44505Smrg echo 680654b44505Smrg echo "*** And there doesn't seem to be a static archive available" 680754b44505Smrg echo "*** The link will probably fail, sorry" 680854b44505Smrg else 680954b44505Smrg add="$dir/$old_library" 681054b44505Smrg fi 681154b44505Smrg elif test -n "$old_library"; then 681254b44505Smrg add="$dir/$old_library" 681354b44505Smrg fi 681454b44505Smrg fi 681554b44505Smrg esac 681654b44505Smrg elif test "$hardcode_minus_L" = no; then 681754b44505Smrg case $host in 681854b44505Smrg *-*-sunos*) add_shlibpath="$dir" ;; 681954b44505Smrg esac 682054b44505Smrg add_dir="-L$dir" 682154b44505Smrg add="-l$name" 682254b44505Smrg elif test "$hardcode_shlibpath_var" = no; then 682354b44505Smrg add_shlibpath="$dir" 682454b44505Smrg add="-l$name" 682554b44505Smrg else 682654b44505Smrg lib_linked=no 682754b44505Smrg fi 682854b44505Smrg ;; 682954b44505Smrg relink) 683054b44505Smrg if test "$hardcode_direct" = yes && 683154b44505Smrg test "$hardcode_direct_absolute" = no; then 683254b44505Smrg add="$dir/$linklib" 683354b44505Smrg elif test "$hardcode_minus_L" = yes; then 683454b44505Smrg add_dir="-L$dir" 683554b44505Smrg # Try looking first in the location we're being installed to. 683654b44505Smrg if test -n "$inst_prefix_dir"; then 683754b44505Smrg case $libdir in 683854b44505Smrg [\\/]*) 683954b44505Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 684054b44505Smrg ;; 684154b44505Smrg esac 684254b44505Smrg fi 684354b44505Smrg add="-l$name" 684454b44505Smrg elif test "$hardcode_shlibpath_var" = yes; then 684554b44505Smrg add_shlibpath="$dir" 684654b44505Smrg add="-l$name" 684754b44505Smrg else 684854b44505Smrg lib_linked=no 684954b44505Smrg fi 685054b44505Smrg ;; 685154b44505Smrg *) lib_linked=no ;; 685254b44505Smrg esac 685354b44505Smrg 685454b44505Smrg if test "$lib_linked" != yes; then 685554b44505Smrg func_fatal_configuration "unsupported hardcode properties" 685654b44505Smrg fi 685754b44505Smrg 685854b44505Smrg if test -n "$add_shlibpath"; then 685954b44505Smrg case :$compile_shlibpath: in 686054b44505Smrg *":$add_shlibpath:"*) ;; 686154b44505Smrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 686254b44505Smrg esac 686354b44505Smrg fi 686454b44505Smrg if test "$linkmode" = prog; then 686554b44505Smrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 686654b44505Smrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 686754b44505Smrg else 686854b44505Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 686954b44505Smrg test -n "$add" && deplibs="$add $deplibs" 687054b44505Smrg if test "$hardcode_direct" != yes && 687154b44505Smrg test "$hardcode_minus_L" != yes && 687254b44505Smrg test "$hardcode_shlibpath_var" = yes; then 687354b44505Smrg case :$finalize_shlibpath: in 687454b44505Smrg *":$libdir:"*) ;; 687554b44505Smrg *) func_append finalize_shlibpath "$libdir:" ;; 687654b44505Smrg esac 687754b44505Smrg fi 687854b44505Smrg fi 687954b44505Smrg fi 688054b44505Smrg 688154b44505Smrg if test "$linkmode" = prog || test "$opt_mode" = relink; then 688254b44505Smrg add_shlibpath= 688354b44505Smrg add_dir= 688454b44505Smrg add= 688554b44505Smrg # Finalize command for both is simple: just hardcode it. 688654b44505Smrg if test "$hardcode_direct" = yes && 688754b44505Smrg test "$hardcode_direct_absolute" = no; then 688854b44505Smrg add="$libdir/$linklib" 688954b44505Smrg elif test "$hardcode_minus_L" = yes; then 689054b44505Smrg add_dir="-L$libdir" 689154b44505Smrg add="-l$name" 689254b44505Smrg elif test "$hardcode_shlibpath_var" = yes; then 689354b44505Smrg case :$finalize_shlibpath: in 689454b44505Smrg *":$libdir:"*) ;; 689554b44505Smrg *) func_append finalize_shlibpath "$libdir:" ;; 689654b44505Smrg esac 689754b44505Smrg add="-l$name" 689854b44505Smrg elif test "$hardcode_automatic" = yes; then 689954b44505Smrg if test -n "$inst_prefix_dir" && 690054b44505Smrg test -f "$inst_prefix_dir$libdir/$linklib" ; then 690154b44505Smrg add="$inst_prefix_dir$libdir/$linklib" 690254b44505Smrg else 690354b44505Smrg add="$libdir/$linklib" 690454b44505Smrg fi 690554b44505Smrg else 690654b44505Smrg # We cannot seem to hardcode it, guess we'll fake it. 690754b44505Smrg add_dir="-L$libdir" 690854b44505Smrg # Try looking first in the location we're being installed to. 690954b44505Smrg if test -n "$inst_prefix_dir"; then 691054b44505Smrg case $libdir in 691154b44505Smrg [\\/]*) 691254b44505Smrg func_append add_dir " -L$inst_prefix_dir$libdir" 691354b44505Smrg ;; 691454b44505Smrg esac 691554b44505Smrg fi 691654b44505Smrg add="-l$name" 691754b44505Smrg fi 691854b44505Smrg 691954b44505Smrg if test "$linkmode" = prog; then 692054b44505Smrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 692154b44505Smrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 692254b44505Smrg else 692354b44505Smrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 692454b44505Smrg test -n "$add" && deplibs="$add $deplibs" 692554b44505Smrg fi 692654b44505Smrg fi 692754b44505Smrg elif test "$linkmode" = prog; then 692854b44505Smrg # Here we assume that one of hardcode_direct or hardcode_minus_L 692954b44505Smrg # is not unsupported. This is valid on all known static and 693054b44505Smrg # shared platforms. 693154b44505Smrg if test "$hardcode_direct" != unsupported; then 693254b44505Smrg test -n "$old_library" && linklib="$old_library" 693354b44505Smrg compile_deplibs="$dir/$linklib $compile_deplibs" 693454b44505Smrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 693554b44505Smrg else 693654b44505Smrg compile_deplibs="-l$name -L$dir $compile_deplibs" 693754b44505Smrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 693854b44505Smrg fi 693954b44505Smrg elif test "$build_libtool_libs" = yes; then 694054b44505Smrg # Not a shared library 694154b44505Smrg if test "$deplibs_check_method" != pass_all; then 694254b44505Smrg # We're trying link a shared library against a static one 694354b44505Smrg # but the system doesn't support it. 694454b44505Smrg 694554b44505Smrg # Just print a warning and add the library to dependency_libs so 694654b44505Smrg # that the program can be linked against the static library. 694754b44505Smrg echo 694854b44505Smrg $ECHO "*** Warning: This system can not link to static lib archive $lib." 694954b44505Smrg echo "*** I have the capability to make that library automatically link in when" 695054b44505Smrg echo "*** you link to this library. But I can only do this if you have a" 695154b44505Smrg echo "*** shared version of the library, which you do not appear to have." 695254b44505Smrg if test "$module" = yes; then 695354b44505Smrg echo "*** But as you try to build a module library, libtool will still create " 695454b44505Smrg echo "*** a static module, that should work as long as the dlopening application" 695554b44505Smrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 695654b44505Smrg if test -z "$global_symbol_pipe"; then 695754b44505Smrg echo 695854b44505Smrg echo "*** However, this would only work if libtool was able to extract symbol" 695954b44505Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 696054b44505Smrg echo "*** not find such a program. So, this module is probably useless." 696154b44505Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 696254b44505Smrg fi 696354b44505Smrg if test "$build_old_libs" = no; then 696454b44505Smrg build_libtool_libs=module 696554b44505Smrg build_old_libs=yes 696654b44505Smrg else 696754b44505Smrg build_libtool_libs=no 696854b44505Smrg fi 696954b44505Smrg fi 697054b44505Smrg else 697154b44505Smrg deplibs="$dir/$old_library $deplibs" 697254b44505Smrg link_static=yes 697354b44505Smrg fi 697454b44505Smrg fi # link shared/static library? 697554b44505Smrg 697654b44505Smrg if test "$linkmode" = lib; then 697754b44505Smrg if test -n "$dependency_libs" && 697854b44505Smrg { test "$hardcode_into_libs" != yes || 697954b44505Smrg test "$build_old_libs" = yes || 698054b44505Smrg test "$link_static" = yes; }; then 698154b44505Smrg # Extract -R from dependency_libs 698254b44505Smrg temp_deplibs= 698354b44505Smrg for libdir in $dependency_libs; do 698454b44505Smrg case $libdir in 698554b44505Smrg -R*) func_stripname '-R' '' "$libdir" 698654b44505Smrg temp_xrpath=$func_stripname_result 698754b44505Smrg case " $xrpath " in 698854b44505Smrg *" $temp_xrpath "*) ;; 698954b44505Smrg *) func_append xrpath " $temp_xrpath";; 699054b44505Smrg esac;; 699154b44505Smrg *) func_append temp_deplibs " $libdir";; 699254b44505Smrg esac 699354b44505Smrg done 699454b44505Smrg dependency_libs="$temp_deplibs" 699554b44505Smrg fi 699654b44505Smrg 699754b44505Smrg func_append newlib_search_path " $absdir" 699854b44505Smrg # Link against this library 699954b44505Smrg test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 700054b44505Smrg # ... and its dependency_libs 700154b44505Smrg tmp_libs= 700254b44505Smrg for deplib in $dependency_libs; do 700354b44505Smrg newdependency_libs="$deplib $newdependency_libs" 700454b44505Smrg case $deplib in 700554b44505Smrg -L*) func_stripname '-L' '' "$deplib" 700654b44505Smrg func_resolve_sysroot "$func_stripname_result";; 700754b44505Smrg *) func_resolve_sysroot "$deplib" ;; 700854b44505Smrg esac 700954b44505Smrg if $opt_preserve_dup_deps ; then 701054b44505Smrg case "$tmp_libs " in 701154b44505Smrg *" $func_resolve_sysroot_result "*) 701254b44505Smrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 701354b44505Smrg esac 701454b44505Smrg fi 701554b44505Smrg func_append tmp_libs " $func_resolve_sysroot_result" 701654b44505Smrg done 701754b44505Smrg 701854b44505Smrg if test "$link_all_deplibs" != no; then 701954b44505Smrg # Add the search paths of all dependency libraries 702054b44505Smrg for deplib in $dependency_libs; do 702154b44505Smrg path= 702254b44505Smrg case $deplib in 702354b44505Smrg -L*) path="$deplib" ;; 702454b44505Smrg *.la) 702554b44505Smrg func_resolve_sysroot "$deplib" 702654b44505Smrg deplib=$func_resolve_sysroot_result 702754b44505Smrg func_dirname "$deplib" "" "." 702854b44505Smrg dir=$func_dirname_result 702954b44505Smrg # We need an absolute path. 703054b44505Smrg case $dir in 703154b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 703254b44505Smrg *) 703354b44505Smrg absdir=`cd "$dir" && pwd` 703454b44505Smrg if test -z "$absdir"; then 703554b44505Smrg func_warning "cannot determine absolute directory name of \`$dir'" 703654b44505Smrg absdir="$dir" 703754b44505Smrg fi 703854b44505Smrg ;; 703954b44505Smrg esac 704054b44505Smrg if $GREP "^installed=no" $deplib > /dev/null; then 704154b44505Smrg case $host in 704254b44505Smrg *-*-darwin*) 704354b44505Smrg depdepl= 704454b44505Smrg eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 704554b44505Smrg if test -n "$deplibrary_names" ; then 704654b44505Smrg for tmp in $deplibrary_names ; do 704754b44505Smrg depdepl=$tmp 704854b44505Smrg done 704954b44505Smrg if test -f "$absdir/$objdir/$depdepl" ; then 705054b44505Smrg depdepl="$absdir/$objdir/$depdepl" 705154b44505Smrg darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 705254b44505Smrg if test -z "$darwin_install_name"; then 705354b44505Smrg darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 705454b44505Smrg fi 705554b44505Smrg func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 705654b44505Smrg func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 705754b44505Smrg path= 705854b44505Smrg fi 705954b44505Smrg fi 706054b44505Smrg ;; 706154b44505Smrg *) 706254b44505Smrg path="-L$absdir/$objdir" 706354b44505Smrg ;; 706454b44505Smrg esac 706554b44505Smrg else 706654b44505Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 706754b44505Smrg test -z "$libdir" && \ 706854b44505Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 706954b44505Smrg test "$absdir" != "$libdir" && \ 707054b44505Smrg func_warning "\`$deplib' seems to be moved" 707154b44505Smrg 707254b44505Smrg path="-L$absdir" 707354b44505Smrg fi 707454b44505Smrg ;; 707554b44505Smrg esac 707654b44505Smrg case " $deplibs " in 707754b44505Smrg *" $path "*) ;; 707854b44505Smrg *) deplibs="$path $deplibs" ;; 707954b44505Smrg esac 708054b44505Smrg done 708154b44505Smrg fi # link_all_deplibs != no 708254b44505Smrg fi # linkmode = lib 708354b44505Smrg done # for deplib in $libs 708454b44505Smrg if test "$pass" = link; then 708554b44505Smrg if test "$linkmode" = "prog"; then 708654b44505Smrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 708754b44505Smrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 708854b44505Smrg else 708954b44505Smrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 709054b44505Smrg fi 709154b44505Smrg fi 709254b44505Smrg dependency_libs="$newdependency_libs" 709354b44505Smrg if test "$pass" = dlpreopen; then 709454b44505Smrg # Link the dlpreopened libraries before other libraries 709554b44505Smrg for deplib in $save_deplibs; do 709654b44505Smrg deplibs="$deplib $deplibs" 709754b44505Smrg done 709854b44505Smrg fi 709954b44505Smrg if test "$pass" != dlopen; then 710054b44505Smrg if test "$pass" != conv; then 710154b44505Smrg # Make sure lib_search_path contains only unique directories. 710254b44505Smrg lib_search_path= 710354b44505Smrg for dir in $newlib_search_path; do 710454b44505Smrg case "$lib_search_path " in 710554b44505Smrg *" $dir "*) ;; 710654b44505Smrg *) func_append lib_search_path " $dir" ;; 710754b44505Smrg esac 710854b44505Smrg done 710954b44505Smrg newlib_search_path= 711054b44505Smrg fi 711154b44505Smrg 711254b44505Smrg if test "$linkmode,$pass" != "prog,link"; then 711354b44505Smrg vars="deplibs" 711454b44505Smrg else 711554b44505Smrg vars="compile_deplibs finalize_deplibs" 711654b44505Smrg fi 711754b44505Smrg for var in $vars dependency_libs; do 711854b44505Smrg # Add libraries to $var in reverse order 711954b44505Smrg eval tmp_libs=\"\$$var\" 712054b44505Smrg new_libs= 712154b44505Smrg for deplib in $tmp_libs; do 712254b44505Smrg # FIXME: Pedantically, this is the right thing to do, so 712354b44505Smrg # that some nasty dependency loop isn't accidentally 712454b44505Smrg # broken: 712554b44505Smrg #new_libs="$deplib $new_libs" 712654b44505Smrg # Pragmatically, this seems to cause very few problems in 712754b44505Smrg # practice: 712854b44505Smrg case $deplib in 712954b44505Smrg -L*) new_libs="$deplib $new_libs" ;; 713054b44505Smrg -R*) ;; 713154b44505Smrg *) 713254b44505Smrg # And here is the reason: when a library appears more 713354b44505Smrg # than once as an explicit dependence of a library, or 713454b44505Smrg # is implicitly linked in more than once by the 713554b44505Smrg # compiler, it is considered special, and multiple 713654b44505Smrg # occurrences thereof are not removed. Compare this 713754b44505Smrg # with having the same library being listed as a 713854b44505Smrg # dependency of multiple other libraries: in this case, 713954b44505Smrg # we know (pedantically, we assume) the library does not 714054b44505Smrg # need to be listed more than once, so we keep only the 714154b44505Smrg # last copy. This is not always right, but it is rare 714254b44505Smrg # enough that we require users that really mean to play 714354b44505Smrg # such unportable linking tricks to link the library 714454b44505Smrg # using -Wl,-lname, so that libtool does not consider it 714554b44505Smrg # for duplicate removal. 714654b44505Smrg case " $specialdeplibs " in 714754b44505Smrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 714854b44505Smrg *) 714954b44505Smrg case " $new_libs " in 715054b44505Smrg *" $deplib "*) ;; 715154b44505Smrg *) new_libs="$deplib $new_libs" ;; 715254b44505Smrg esac 715354b44505Smrg ;; 715454b44505Smrg esac 715554b44505Smrg ;; 715654b44505Smrg esac 715754b44505Smrg done 715854b44505Smrg tmp_libs= 715954b44505Smrg for deplib in $new_libs; do 716054b44505Smrg case $deplib in 716154b44505Smrg -L*) 716254b44505Smrg case " $tmp_libs " in 716354b44505Smrg *" $deplib "*) ;; 716454b44505Smrg *) func_append tmp_libs " $deplib" ;; 716554b44505Smrg esac 716654b44505Smrg ;; 716754b44505Smrg *) func_append tmp_libs " $deplib" ;; 716854b44505Smrg esac 716954b44505Smrg done 717054b44505Smrg eval $var=\"$tmp_libs\" 717154b44505Smrg done # for var 717254b44505Smrg fi 717354b44505Smrg # Last step: remove runtime libs from dependency_libs 717454b44505Smrg # (they stay in deplibs) 717554b44505Smrg tmp_libs= 717654b44505Smrg for i in $dependency_libs ; do 717754b44505Smrg case " $predeps $postdeps $compiler_lib_search_path " in 717854b44505Smrg *" $i "*) 717954b44505Smrg i="" 718054b44505Smrg ;; 718154b44505Smrg esac 718254b44505Smrg if test -n "$i" ; then 718354b44505Smrg func_append tmp_libs " $i" 718454b44505Smrg fi 718554b44505Smrg done 718654b44505Smrg dependency_libs=$tmp_libs 718754b44505Smrg done # for pass 718854b44505Smrg if test "$linkmode" = prog; then 718954b44505Smrg dlfiles="$newdlfiles" 719054b44505Smrg fi 719154b44505Smrg if test "$linkmode" = prog || test "$linkmode" = lib; then 719254b44505Smrg dlprefiles="$newdlprefiles" 719354b44505Smrg fi 719454b44505Smrg 719554b44505Smrg case $linkmode in 719654b44505Smrg oldlib) 719754b44505Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 719854b44505Smrg func_warning "\`-dlopen' is ignored for archives" 719954b44505Smrg fi 720054b44505Smrg 720154b44505Smrg case " $deplibs" in 720254b44505Smrg *\ -l* | *\ -L*) 720354b44505Smrg func_warning "\`-l' and \`-L' are ignored for archives" ;; 720454b44505Smrg esac 720554b44505Smrg 720654b44505Smrg test -n "$rpath" && \ 720754b44505Smrg func_warning "\`-rpath' is ignored for archives" 720854b44505Smrg 720954b44505Smrg test -n "$xrpath" && \ 721054b44505Smrg func_warning "\`-R' is ignored for archives" 721154b44505Smrg 721254b44505Smrg test -n "$vinfo" && \ 721354b44505Smrg func_warning "\`-version-info/-version-number' is ignored for archives" 721454b44505Smrg 721554b44505Smrg test -n "$release" && \ 721654b44505Smrg func_warning "\`-release' is ignored for archives" 721754b44505Smrg 721854b44505Smrg test -n "$export_symbols$export_symbols_regex" && \ 721954b44505Smrg func_warning "\`-export-symbols' is ignored for archives" 722054b44505Smrg 722154b44505Smrg # Now set the variables for building old libraries. 722254b44505Smrg build_libtool_libs=no 722354b44505Smrg oldlibs="$output" 722454b44505Smrg func_append objs "$old_deplibs" 722554b44505Smrg ;; 722654b44505Smrg 722754b44505Smrg lib) 722854b44505Smrg # Make sure we only generate libraries of the form `libNAME.la'. 722954b44505Smrg case $outputname in 723054b44505Smrg lib*) 723154b44505Smrg func_stripname 'lib' '.la' "$outputname" 723254b44505Smrg name=$func_stripname_result 723354b44505Smrg eval shared_ext=\"$shrext_cmds\" 723454b44505Smrg eval libname=\"$libname_spec\" 723554b44505Smrg ;; 723654b44505Smrg *) 723754b44505Smrg test "$module" = no && \ 723854b44505Smrg func_fatal_help "libtool library \`$output' must begin with \`lib'" 723954b44505Smrg 724054b44505Smrg if test "$need_lib_prefix" != no; then 724154b44505Smrg # Add the "lib" prefix for modules if required 724254b44505Smrg func_stripname '' '.la' "$outputname" 724354b44505Smrg name=$func_stripname_result 724454b44505Smrg eval shared_ext=\"$shrext_cmds\" 724554b44505Smrg eval libname=\"$libname_spec\" 724654b44505Smrg else 724754b44505Smrg func_stripname '' '.la' "$outputname" 724854b44505Smrg libname=$func_stripname_result 724954b44505Smrg fi 725054b44505Smrg ;; 725154b44505Smrg esac 725254b44505Smrg 725354b44505Smrg if test -n "$objs"; then 725454b44505Smrg if test "$deplibs_check_method" != pass_all; then 725554b44505Smrg func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 725654b44505Smrg else 725754b44505Smrg echo 725854b44505Smrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 725954b44505Smrg $ECHO "*** objects $objs is not portable!" 726054b44505Smrg func_append libobjs " $objs" 726154b44505Smrg fi 726254b44505Smrg fi 726354b44505Smrg 726454b44505Smrg test "$dlself" != no && \ 726554b44505Smrg func_warning "\`-dlopen self' is ignored for libtool libraries" 726654b44505Smrg 726754b44505Smrg set dummy $rpath 726854b44505Smrg shift 726954b44505Smrg test "$#" -gt 1 && \ 727054b44505Smrg func_warning "ignoring multiple \`-rpath's for a libtool library" 727154b44505Smrg 727254b44505Smrg install_libdir="$1" 727354b44505Smrg 727454b44505Smrg oldlibs= 727554b44505Smrg if test -z "$rpath"; then 727654b44505Smrg if test "$build_libtool_libs" = yes; then 727754b44505Smrg # Building a libtool convenience library. 727854b44505Smrg # Some compilers have problems with a `.al' extension so 727954b44505Smrg # convenience libraries should have the same extension an 728054b44505Smrg # archive normally would. 728154b44505Smrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 728254b44505Smrg build_libtool_libs=convenience 728354b44505Smrg build_old_libs=yes 728454b44505Smrg fi 728554b44505Smrg 728654b44505Smrg test -n "$vinfo" && \ 728754b44505Smrg func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 728854b44505Smrg 728954b44505Smrg test -n "$release" && \ 729054b44505Smrg func_warning "\`-release' is ignored for convenience libraries" 729154b44505Smrg else 729254b44505Smrg 729354b44505Smrg # Parse the version information argument. 729454b44505Smrg save_ifs="$IFS"; IFS=':' 729554b44505Smrg set dummy $vinfo 0 0 0 729654b44505Smrg shift 729754b44505Smrg IFS="$save_ifs" 729854b44505Smrg 729954b44505Smrg test -n "$7" && \ 730054b44505Smrg func_fatal_help "too many parameters to \`-version-info'" 730154b44505Smrg 730254b44505Smrg # convert absolute version numbers to libtool ages 730354b44505Smrg # this retains compatibility with .la files and attempts 730454b44505Smrg # to make the code below a bit more comprehensible 730554b44505Smrg 730654b44505Smrg case $vinfo_number in 730754b44505Smrg yes) 730854b44505Smrg number_major="$1" 730954b44505Smrg number_minor="$2" 731054b44505Smrg number_revision="$3" 731154b44505Smrg # 731254b44505Smrg # There are really only two kinds -- those that 731354b44505Smrg # use the current revision as the major version 731454b44505Smrg # and those that subtract age and use age as 731554b44505Smrg # a minor version. But, then there is irix 731654b44505Smrg # which has an extra 1 added just for fun 731754b44505Smrg # 731854b44505Smrg case $version_type in 731954b44505Smrg darwin|linux|osf|windows|none) 732054b44505Smrg func_arith $number_major + $number_minor 732154b44505Smrg current=$func_arith_result 732254b44505Smrg age="$number_minor" 732354b44505Smrg revision="$number_revision" 732454b44505Smrg ;; 732554b44505Smrg freebsd-aout|freebsd-elf|qnx|sunos) 732654b44505Smrg current="$number_major" 732754b44505Smrg revision="$number_minor" 732854b44505Smrg age="0" 732954b44505Smrg ;; 733054b44505Smrg irix|nonstopux) 733154b44505Smrg func_arith $number_major + $number_minor 733254b44505Smrg current=$func_arith_result 733354b44505Smrg age="$number_minor" 733454b44505Smrg revision="$number_minor" 733554b44505Smrg lt_irix_increment=no 733654b44505Smrg ;; 733754b44505Smrg esac 733854b44505Smrg ;; 733954b44505Smrg no) 734054b44505Smrg current="$1" 734154b44505Smrg revision="$2" 734254b44505Smrg age="$3" 734354b44505Smrg ;; 734454b44505Smrg esac 734554b44505Smrg 734654b44505Smrg # Check that each of the things are valid numbers. 734754b44505Smrg case $current in 734854b44505Smrg 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]) ;; 734954b44505Smrg *) 735054b44505Smrg func_error "CURRENT \`$current' must be a nonnegative integer" 735154b44505Smrg func_fatal_error "\`$vinfo' is not valid version information" 735254b44505Smrg ;; 735354b44505Smrg esac 735454b44505Smrg 735554b44505Smrg case $revision in 735654b44505Smrg 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]) ;; 735754b44505Smrg *) 735854b44505Smrg func_error "REVISION \`$revision' must be a nonnegative integer" 735954b44505Smrg func_fatal_error "\`$vinfo' is not valid version information" 736054b44505Smrg ;; 736154b44505Smrg esac 736254b44505Smrg 736354b44505Smrg case $age in 736454b44505Smrg 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]) ;; 736554b44505Smrg *) 736654b44505Smrg func_error "AGE \`$age' must be a nonnegative integer" 736754b44505Smrg func_fatal_error "\`$vinfo' is not valid version information" 736854b44505Smrg ;; 736954b44505Smrg esac 737054b44505Smrg 737154b44505Smrg if test "$age" -gt "$current"; then 737254b44505Smrg func_error "AGE \`$age' is greater than the current interface number \`$current'" 737354b44505Smrg func_fatal_error "\`$vinfo' is not valid version information" 737454b44505Smrg fi 737554b44505Smrg 737654b44505Smrg # Calculate the version variables. 737754b44505Smrg major= 737854b44505Smrg versuffix= 737954b44505Smrg verstring= 738054b44505Smrg case $version_type in 738154b44505Smrg none) ;; 738254b44505Smrg 738354b44505Smrg darwin) 738454b44505Smrg # Like Linux, but with the current version available in 738554b44505Smrg # verstring for coding it into the library header 738654b44505Smrg func_arith $current - $age 738754b44505Smrg major=.$func_arith_result 738854b44505Smrg versuffix="$major.$age.$revision" 738954b44505Smrg # Darwin ld doesn't like 0 for these options... 739054b44505Smrg func_arith $current + 1 739154b44505Smrg minor_current=$func_arith_result 739254b44505Smrg xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 739354b44505Smrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 739454b44505Smrg ;; 739554b44505Smrg 739654b44505Smrg freebsd-aout) 739754b44505Smrg major=".$current" 739854b44505Smrg versuffix=".$current.$revision"; 739954b44505Smrg ;; 740054b44505Smrg 740154b44505Smrg freebsd-elf) 740254b44505Smrg major=".$current" 740354b44505Smrg versuffix=".$current" 740454b44505Smrg ;; 740554b44505Smrg 740654b44505Smrg irix | nonstopux) 740754b44505Smrg if test "X$lt_irix_increment" = "Xno"; then 740854b44505Smrg func_arith $current - $age 740954b44505Smrg else 741054b44505Smrg func_arith $current - $age + 1 741154b44505Smrg fi 741254b44505Smrg major=$func_arith_result 741354b44505Smrg 741454b44505Smrg case $version_type in 741554b44505Smrg nonstopux) verstring_prefix=nonstopux ;; 741654b44505Smrg *) verstring_prefix=sgi ;; 741754b44505Smrg esac 741854b44505Smrg verstring="$verstring_prefix$major.$revision" 741954b44505Smrg 742054b44505Smrg # Add in all the interfaces that we are compatible with. 742154b44505Smrg loop=$revision 742254b44505Smrg while test "$loop" -ne 0; do 742354b44505Smrg func_arith $revision - $loop 742454b44505Smrg iface=$func_arith_result 742554b44505Smrg func_arith $loop - 1 742654b44505Smrg loop=$func_arith_result 742754b44505Smrg verstring="$verstring_prefix$major.$iface:$verstring" 742854b44505Smrg done 742954b44505Smrg 743054b44505Smrg # Before this point, $major must not contain `.'. 743154b44505Smrg major=.$major 743254b44505Smrg versuffix="$major.$revision" 743354b44505Smrg ;; 743454b44505Smrg 743554b44505Smrg linux) 743654b44505Smrg func_arith $current - $age 743754b44505Smrg major=.$func_arith_result 743854b44505Smrg versuffix="$major.$age.$revision" 743954b44505Smrg ;; 744054b44505Smrg 744154b44505Smrg osf) 744254b44505Smrg func_arith $current - $age 744354b44505Smrg major=.$func_arith_result 744454b44505Smrg versuffix=".$current.$age.$revision" 744554b44505Smrg verstring="$current.$age.$revision" 744654b44505Smrg 744754b44505Smrg # Add in all the interfaces that we are compatible with. 744854b44505Smrg loop=$age 744954b44505Smrg while test "$loop" -ne 0; do 745054b44505Smrg func_arith $current - $loop 745154b44505Smrg iface=$func_arith_result 745254b44505Smrg func_arith $loop - 1 745354b44505Smrg loop=$func_arith_result 745454b44505Smrg verstring="$verstring:${iface}.0" 745554b44505Smrg done 745654b44505Smrg 745754b44505Smrg # Make executables depend on our current version. 745854b44505Smrg func_append verstring ":${current}.0" 745954b44505Smrg ;; 746054b44505Smrg 746154b44505Smrg qnx) 746254b44505Smrg major=".$current" 746354b44505Smrg versuffix=".$current" 746454b44505Smrg ;; 746554b44505Smrg 746654b44505Smrg sunos) 746754b44505Smrg major=".$current" 746854b44505Smrg versuffix=".$current.$revision" 746954b44505Smrg ;; 747054b44505Smrg 747154b44505Smrg windows) 747254b44505Smrg # Use '-' rather than '.', since we only want one 747354b44505Smrg # extension on DOS 8.3 filesystems. 747454b44505Smrg func_arith $current - $age 747554b44505Smrg major=$func_arith_result 747654b44505Smrg versuffix="-$major" 747754b44505Smrg ;; 747854b44505Smrg 747954b44505Smrg *) 748054b44505Smrg func_fatal_configuration "unknown library version type \`$version_type'" 748154b44505Smrg ;; 748254b44505Smrg esac 748354b44505Smrg 748454b44505Smrg # Clear the version info if we defaulted, and they specified a release. 748554b44505Smrg if test -z "$vinfo" && test -n "$release"; then 748654b44505Smrg major= 748754b44505Smrg case $version_type in 748854b44505Smrg darwin) 748954b44505Smrg # we can't check for "0.0" in archive_cmds due to quoting 749054b44505Smrg # problems, so we reset it completely 749154b44505Smrg verstring= 749254b44505Smrg ;; 749354b44505Smrg *) 749454b44505Smrg verstring="0.0" 749554b44505Smrg ;; 749654b44505Smrg esac 749754b44505Smrg if test "$need_version" = no; then 749854b44505Smrg versuffix= 749954b44505Smrg else 750054b44505Smrg versuffix=".0.0" 750154b44505Smrg fi 750254b44505Smrg fi 750354b44505Smrg 750454b44505Smrg # Remove version info from name if versioning should be avoided 750554b44505Smrg if test "$avoid_version" = yes && test "$need_version" = no; then 750654b44505Smrg major= 750754b44505Smrg versuffix= 750854b44505Smrg verstring="" 750954b44505Smrg fi 751054b44505Smrg 751154b44505Smrg # Check to see if the archive will have undefined symbols. 751254b44505Smrg if test "$allow_undefined" = yes; then 751354b44505Smrg if test "$allow_undefined_flag" = unsupported; then 751454b44505Smrg func_warning "undefined symbols not allowed in $host shared libraries" 751554b44505Smrg build_libtool_libs=no 751654b44505Smrg build_old_libs=yes 751754b44505Smrg fi 751854b44505Smrg else 751954b44505Smrg # Don't allow undefined symbols. 752054b44505Smrg allow_undefined_flag="$no_undefined_flag" 752154b44505Smrg fi 752254b44505Smrg 752354b44505Smrg fi 752454b44505Smrg 752554b44505Smrg func_generate_dlsyms "$libname" "$libname" "yes" 752654b44505Smrg func_append libobjs " $symfileobj" 752754b44505Smrg test "X$libobjs" = "X " && libobjs= 752854b44505Smrg 752954b44505Smrg if test "$opt_mode" != relink; then 753054b44505Smrg # Remove our outputs, but don't remove object files since they 753154b44505Smrg # may have been created when compiling PIC objects. 753254b44505Smrg removelist= 753354b44505Smrg tempremovelist=`$ECHO "$output_objdir/*"` 753454b44505Smrg for p in $tempremovelist; do 753554b44505Smrg case $p in 753654b44505Smrg *.$objext | *.gcno) 753754b44505Smrg ;; 753854b44505Smrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 753954b44505Smrg if test "X$precious_files_regex" != "X"; then 754054b44505Smrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 754154b44505Smrg then 754254b44505Smrg continue 754354b44505Smrg fi 754454b44505Smrg fi 754554b44505Smrg func_append removelist " $p" 754654b44505Smrg ;; 754754b44505Smrg *) ;; 754854b44505Smrg esac 754954b44505Smrg done 755054b44505Smrg test -n "$removelist" && \ 755154b44505Smrg func_show_eval "${RM}r \$removelist" 755254b44505Smrg fi 755354b44505Smrg 755454b44505Smrg # Now set the variables for building old libraries. 755554b44505Smrg if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 755654b44505Smrg func_append oldlibs " $output_objdir/$libname.$libext" 755754b44505Smrg 755854b44505Smrg # Transform .lo files to .o files. 755954b44505Smrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 756054b44505Smrg fi 756154b44505Smrg 756254b44505Smrg # Eliminate all temporary directories. 756354b44505Smrg #for path in $notinst_path; do 756454b44505Smrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 756554b44505Smrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 756654b44505Smrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 756754b44505Smrg #done 756854b44505Smrg 756954b44505Smrg if test -n "$xrpath"; then 757054b44505Smrg # If the user specified any rpath flags, then add them. 757154b44505Smrg temp_xrpath= 757254b44505Smrg for libdir in $xrpath; do 757354b44505Smrg func_replace_sysroot "$libdir" 757454b44505Smrg func_append temp_xrpath " -R$func_replace_sysroot_result" 757554b44505Smrg case "$finalize_rpath " in 757654b44505Smrg *" $libdir "*) ;; 757754b44505Smrg *) func_append finalize_rpath " $libdir" ;; 757854b44505Smrg esac 757954b44505Smrg done 758054b44505Smrg if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 758154b44505Smrg dependency_libs="$temp_xrpath $dependency_libs" 758254b44505Smrg fi 758354b44505Smrg fi 758454b44505Smrg 758554b44505Smrg # Make sure dlfiles contains only unique files that won't be dlpreopened 758654b44505Smrg old_dlfiles="$dlfiles" 758754b44505Smrg dlfiles= 758854b44505Smrg for lib in $old_dlfiles; do 758954b44505Smrg case " $dlprefiles $dlfiles " in 759054b44505Smrg *" $lib "*) ;; 759154b44505Smrg *) func_append dlfiles " $lib" ;; 759254b44505Smrg esac 759354b44505Smrg done 759454b44505Smrg 759554b44505Smrg # Make sure dlprefiles contains only unique files 759654b44505Smrg old_dlprefiles="$dlprefiles" 759754b44505Smrg dlprefiles= 759854b44505Smrg for lib in $old_dlprefiles; do 759954b44505Smrg case "$dlprefiles " in 760054b44505Smrg *" $lib "*) ;; 760154b44505Smrg *) func_append dlprefiles " $lib" ;; 760254b44505Smrg esac 760354b44505Smrg done 760454b44505Smrg 760554b44505Smrg if test "$build_libtool_libs" = yes; then 760654b44505Smrg if test -n "$rpath"; then 760754b44505Smrg case $host in 760854b44505Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 760954b44505Smrg # these systems don't actually have a c library (as such)! 761054b44505Smrg ;; 761154b44505Smrg *-*-rhapsody* | *-*-darwin1.[012]) 761254b44505Smrg # Rhapsody C library is in the System framework 761354b44505Smrg func_append deplibs " System.ltframework" 761454b44505Smrg ;; 761554b44505Smrg *-*-netbsd*) 761654b44505Smrg # Don't link with libc until the a.out ld.so is fixed. 761754b44505Smrg ;; 761854b44505Smrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 761954b44505Smrg # Do not include libc due to us having libc/libc_r. 762054b44505Smrg ;; 762154b44505Smrg *-*-sco3.2v5* | *-*-sco5v6*) 762254b44505Smrg # Causes problems with __ctype 762354b44505Smrg ;; 762454b44505Smrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 762554b44505Smrg # Compiler inserts libc in the correct place for threads to work 762654b44505Smrg ;; 762754b44505Smrg *) 762854b44505Smrg # Add libc to deplibs on all other systems if necessary. 762954b44505Smrg if test "$build_libtool_need_lc" = "yes"; then 763054b44505Smrg func_append deplibs " -lc" 763154b44505Smrg fi 763254b44505Smrg ;; 763354b44505Smrg esac 763454b44505Smrg fi 763554b44505Smrg 763654b44505Smrg # Transform deplibs into only deplibs that can be linked in shared. 763754b44505Smrg name_save=$name 763854b44505Smrg libname_save=$libname 763954b44505Smrg release_save=$release 764054b44505Smrg versuffix_save=$versuffix 764154b44505Smrg major_save=$major 764254b44505Smrg # I'm not sure if I'm treating the release correctly. I think 764354b44505Smrg # release should show up in the -l (ie -lgmp5) so we don't want to 764454b44505Smrg # add it in twice. Is that correct? 764554b44505Smrg release="" 764654b44505Smrg versuffix="" 764754b44505Smrg major="" 764854b44505Smrg newdeplibs= 764954b44505Smrg droppeddeps=no 765054b44505Smrg case $deplibs_check_method in 765154b44505Smrg pass_all) 765254b44505Smrg # Don't check for shared/static. Everything works. 765354b44505Smrg # This might be a little naive. We might want to check 765454b44505Smrg # whether the library exists or not. But this is on 765554b44505Smrg # osf3 & osf4 and I'm not really sure... Just 765654b44505Smrg # implementing what was already the behavior. 765754b44505Smrg newdeplibs=$deplibs 765854b44505Smrg ;; 765954b44505Smrg test_compile) 766054b44505Smrg # This code stresses the "libraries are programs" paradigm to its 766154b44505Smrg # limits. Maybe even breaks it. We compile a program, linking it 766254b44505Smrg # against the deplibs as a proxy for the library. Then we can check 766354b44505Smrg # whether they linked in statically or dynamically with ldd. 766454b44505Smrg $opt_dry_run || $RM conftest.c 766554b44505Smrg cat > conftest.c <<EOF 766654b44505Smrg int main() { return 0; } 766754b44505SmrgEOF 766854b44505Smrg $opt_dry_run || $RM conftest 766954b44505Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 767054b44505Smrg ldd_output=`ldd conftest` 767154b44505Smrg for i in $deplibs; do 767254b44505Smrg case $i in 767354b44505Smrg -l*) 767454b44505Smrg func_stripname -l '' "$i" 767554b44505Smrg name=$func_stripname_result 767654b44505Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 767754b44505Smrg case " $predeps $postdeps " in 767854b44505Smrg *" $i "*) 767954b44505Smrg func_append newdeplibs " $i" 768054b44505Smrg i="" 768154b44505Smrg ;; 768254b44505Smrg esac 768354b44505Smrg fi 768454b44505Smrg if test -n "$i" ; then 768554b44505Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 768654b44505Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 768754b44505Smrg set dummy $deplib_matches; shift 768854b44505Smrg deplib_match=$1 768954b44505Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 769054b44505Smrg func_append newdeplibs " $i" 769154b44505Smrg else 769254b44505Smrg droppeddeps=yes 769354b44505Smrg echo 769454b44505Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 769554b44505Smrg echo "*** I have the capability to make that library automatically link in when" 769654b44505Smrg echo "*** you link to this library. But I can only do this if you have a" 769754b44505Smrg echo "*** shared version of the library, which I believe you do not have" 769854b44505Smrg echo "*** because a test_compile did reveal that the linker did not use it for" 769954b44505Smrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 770054b44505Smrg fi 770154b44505Smrg fi 770254b44505Smrg ;; 770354b44505Smrg *) 770454b44505Smrg func_append newdeplibs " $i" 770554b44505Smrg ;; 770654b44505Smrg esac 770754b44505Smrg done 770854b44505Smrg else 770954b44505Smrg # Error occurred in the first compile. Let's try to salvage 771054b44505Smrg # the situation: Compile a separate program for each library. 771154b44505Smrg for i in $deplibs; do 771254b44505Smrg case $i in 771354b44505Smrg -l*) 771454b44505Smrg func_stripname -l '' "$i" 771554b44505Smrg name=$func_stripname_result 771654b44505Smrg $opt_dry_run || $RM conftest 771754b44505Smrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 771854b44505Smrg ldd_output=`ldd conftest` 771954b44505Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 772054b44505Smrg case " $predeps $postdeps " in 772154b44505Smrg *" $i "*) 772254b44505Smrg func_append newdeplibs " $i" 772354b44505Smrg i="" 772454b44505Smrg ;; 772554b44505Smrg esac 772654b44505Smrg fi 772754b44505Smrg if test -n "$i" ; then 772854b44505Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 772954b44505Smrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 773054b44505Smrg set dummy $deplib_matches; shift 773154b44505Smrg deplib_match=$1 773254b44505Smrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 773354b44505Smrg func_append newdeplibs " $i" 773454b44505Smrg else 773554b44505Smrg droppeddeps=yes 773654b44505Smrg echo 773754b44505Smrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 773854b44505Smrg echo "*** I have the capability to make that library automatically link in when" 773954b44505Smrg echo "*** you link to this library. But I can only do this if you have a" 774054b44505Smrg echo "*** shared version of the library, which you do not appear to have" 774154b44505Smrg echo "*** because a test_compile did reveal that the linker did not use this one" 774254b44505Smrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 774354b44505Smrg fi 774454b44505Smrg fi 774554b44505Smrg else 774654b44505Smrg droppeddeps=yes 774754b44505Smrg echo 774854b44505Smrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 774954b44505Smrg echo "*** make it link in! You will probably need to install it or some" 775054b44505Smrg echo "*** library that it depends on before this library will be fully" 775154b44505Smrg echo "*** functional. Installing it before continuing would be even better." 775254b44505Smrg fi 775354b44505Smrg ;; 775454b44505Smrg *) 775554b44505Smrg func_append newdeplibs " $i" 775654b44505Smrg ;; 775754b44505Smrg esac 775854b44505Smrg done 775954b44505Smrg fi 776054b44505Smrg ;; 776154b44505Smrg file_magic*) 776254b44505Smrg set dummy $deplibs_check_method; shift 776354b44505Smrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 776454b44505Smrg for a_deplib in $deplibs; do 776554b44505Smrg case $a_deplib in 776654b44505Smrg -l*) 776754b44505Smrg func_stripname -l '' "$a_deplib" 776854b44505Smrg name=$func_stripname_result 776954b44505Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 777054b44505Smrg case " $predeps $postdeps " in 777154b44505Smrg *" $a_deplib "*) 777254b44505Smrg func_append newdeplibs " $a_deplib" 777354b44505Smrg a_deplib="" 777454b44505Smrg ;; 777554b44505Smrg esac 777654b44505Smrg fi 777754b44505Smrg if test -n "$a_deplib" ; then 777854b44505Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 777954b44505Smrg if test -n "$file_magic_glob"; then 778054b44505Smrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 778154b44505Smrg else 778254b44505Smrg libnameglob=$libname 778354b44505Smrg fi 778454b44505Smrg test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 778554b44505Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 778654b44505Smrg if test "$want_nocaseglob" = yes; then 778754b44505Smrg shopt -s nocaseglob 778854b44505Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 778954b44505Smrg $nocaseglob 779054b44505Smrg else 779154b44505Smrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 779254b44505Smrg fi 779354b44505Smrg for potent_lib in $potential_libs; do 779454b44505Smrg # Follow soft links. 779554b44505Smrg if ls -lLd "$potent_lib" 2>/dev/null | 779654b44505Smrg $GREP " -> " >/dev/null; then 779754b44505Smrg continue 779854b44505Smrg fi 779954b44505Smrg # The statement above tries to avoid entering an 780054b44505Smrg # endless loop below, in case of cyclic links. 780154b44505Smrg # We might still enter an endless loop, since a link 780254b44505Smrg # loop can be closed while we follow links, 780354b44505Smrg # but so what? 780454b44505Smrg potlib="$potent_lib" 780554b44505Smrg while test -h "$potlib" 2>/dev/null; do 780654b44505Smrg potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 780754b44505Smrg case $potliblink in 780854b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 780954b44505Smrg *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 781054b44505Smrg esac 781154b44505Smrg done 781254b44505Smrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 781354b44505Smrg $SED -e 10q | 781454b44505Smrg $EGREP "$file_magic_regex" > /dev/null; then 781554b44505Smrg func_append newdeplibs " $a_deplib" 781654b44505Smrg a_deplib="" 781754b44505Smrg break 2 781854b44505Smrg fi 781954b44505Smrg done 782054b44505Smrg done 782154b44505Smrg fi 782254b44505Smrg if test -n "$a_deplib" ; then 782354b44505Smrg droppeddeps=yes 782454b44505Smrg echo 782554b44505Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 782654b44505Smrg echo "*** I have the capability to make that library automatically link in when" 782754b44505Smrg echo "*** you link to this library. But I can only do this if you have a" 782854b44505Smrg echo "*** shared version of the library, which you do not appear to have" 782954b44505Smrg echo "*** because I did check the linker path looking for a file starting" 783054b44505Smrg if test -z "$potlib" ; then 783154b44505Smrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 783254b44505Smrg else 783354b44505Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 783454b44505Smrg $ECHO "*** using a file magic. Last file checked: $potlib" 783554b44505Smrg fi 783654b44505Smrg fi 783754b44505Smrg ;; 783854b44505Smrg *) 783954b44505Smrg # Add a -L argument. 784054b44505Smrg func_append newdeplibs " $a_deplib" 784154b44505Smrg ;; 784254b44505Smrg esac 784354b44505Smrg done # Gone through all deplibs. 784454b44505Smrg ;; 784554b44505Smrg match_pattern*) 784654b44505Smrg set dummy $deplibs_check_method; shift 784754b44505Smrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 784854b44505Smrg for a_deplib in $deplibs; do 784954b44505Smrg case $a_deplib in 785054b44505Smrg -l*) 785154b44505Smrg func_stripname -l '' "$a_deplib" 785254b44505Smrg name=$func_stripname_result 785354b44505Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 785454b44505Smrg case " $predeps $postdeps " in 785554b44505Smrg *" $a_deplib "*) 785654b44505Smrg func_append newdeplibs " $a_deplib" 785754b44505Smrg a_deplib="" 785854b44505Smrg ;; 785954b44505Smrg esac 786054b44505Smrg fi 786154b44505Smrg if test -n "$a_deplib" ; then 786254b44505Smrg libname=`eval "\\$ECHO \"$libname_spec\""` 786354b44505Smrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 786454b44505Smrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 786554b44505Smrg for potent_lib in $potential_libs; do 786654b44505Smrg potlib="$potent_lib" # see symlink-check above in file_magic test 786754b44505Smrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 786854b44505Smrg $EGREP "$match_pattern_regex" > /dev/null; then 786954b44505Smrg func_append newdeplibs " $a_deplib" 787054b44505Smrg a_deplib="" 787154b44505Smrg break 2 787254b44505Smrg fi 787354b44505Smrg done 787454b44505Smrg done 787554b44505Smrg fi 787654b44505Smrg if test -n "$a_deplib" ; then 787754b44505Smrg droppeddeps=yes 787854b44505Smrg echo 787954b44505Smrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 788054b44505Smrg echo "*** I have the capability to make that library automatically link in when" 788154b44505Smrg echo "*** you link to this library. But I can only do this if you have a" 788254b44505Smrg echo "*** shared version of the library, which you do not appear to have" 788354b44505Smrg echo "*** because I did check the linker path looking for a file starting" 788454b44505Smrg if test -z "$potlib" ; then 788554b44505Smrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 788654b44505Smrg else 788754b44505Smrg $ECHO "*** with $libname and none of the candidates passed a file format test" 788854b44505Smrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 788954b44505Smrg fi 789054b44505Smrg fi 789154b44505Smrg ;; 789254b44505Smrg *) 789354b44505Smrg # Add a -L argument. 789454b44505Smrg func_append newdeplibs " $a_deplib" 789554b44505Smrg ;; 789654b44505Smrg esac 789754b44505Smrg done # Gone through all deplibs. 789854b44505Smrg ;; 789954b44505Smrg none | unknown | *) 790054b44505Smrg newdeplibs="" 790154b44505Smrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 790254b44505Smrg if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 790354b44505Smrg for i in $predeps $postdeps ; do 790454b44505Smrg # can't use Xsed below, because $i might contain '/' 790554b44505Smrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 790654b44505Smrg done 790754b44505Smrg fi 790854b44505Smrg case $tmp_deplibs in 790954b44505Smrg *[!\ \ ]*) 791054b44505Smrg echo 791154b44505Smrg if test "X$deplibs_check_method" = "Xnone"; then 791254b44505Smrg echo "*** Warning: inter-library dependencies are not supported in this platform." 791354b44505Smrg else 791454b44505Smrg echo "*** Warning: inter-library dependencies are not known to be supported." 791554b44505Smrg fi 791654b44505Smrg echo "*** All declared inter-library dependencies are being dropped." 791754b44505Smrg droppeddeps=yes 791854b44505Smrg ;; 791954b44505Smrg esac 792054b44505Smrg ;; 792154b44505Smrg esac 792254b44505Smrg versuffix=$versuffix_save 792354b44505Smrg major=$major_save 792454b44505Smrg release=$release_save 792554b44505Smrg libname=$libname_save 792654b44505Smrg name=$name_save 792754b44505Smrg 792854b44505Smrg case $host in 792954b44505Smrg *-*-rhapsody* | *-*-darwin1.[012]) 793054b44505Smrg # On Rhapsody replace the C library with the System framework 793154b44505Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 793254b44505Smrg ;; 793354b44505Smrg esac 793454b44505Smrg 793554b44505Smrg if test "$droppeddeps" = yes; then 793654b44505Smrg if test "$module" = yes; then 793754b44505Smrg echo 793854b44505Smrg echo "*** Warning: libtool could not satisfy all declared inter-library" 793954b44505Smrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 794054b44505Smrg echo "*** a static module, that should work as long as the dlopening" 794154b44505Smrg echo "*** application is linked with the -dlopen flag." 794254b44505Smrg if test -z "$global_symbol_pipe"; then 794354b44505Smrg echo 794454b44505Smrg echo "*** However, this would only work if libtool was able to extract symbol" 794554b44505Smrg echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 794654b44505Smrg echo "*** not find such a program. So, this module is probably useless." 794754b44505Smrg echo "*** \`nm' from GNU binutils and a full rebuild may help." 794854b44505Smrg fi 794954b44505Smrg if test "$build_old_libs" = no; then 795054b44505Smrg oldlibs="$output_objdir/$libname.$libext" 795154b44505Smrg build_libtool_libs=module 795254b44505Smrg build_old_libs=yes 795354b44505Smrg else 795454b44505Smrg build_libtool_libs=no 795554b44505Smrg fi 795654b44505Smrg else 795754b44505Smrg echo "*** The inter-library dependencies that have been dropped here will be" 795854b44505Smrg echo "*** automatically added whenever a program is linked with this library" 795954b44505Smrg echo "*** or is declared to -dlopen it." 79604a041c5bSmacallan 796154b44505Smrg if test "$allow_undefined" = no; then 796254b44505Smrg echo 796354b44505Smrg echo "*** Since this library must not contain undefined symbols," 796454b44505Smrg echo "*** because either the platform does not support them or" 796554b44505Smrg echo "*** it was explicitly requested with -no-undefined," 796654b44505Smrg echo "*** libtool will only create a static version of it." 796754b44505Smrg if test "$build_old_libs" = no; then 796854b44505Smrg oldlibs="$output_objdir/$libname.$libext" 796954b44505Smrg build_libtool_libs=module 797054b44505Smrg build_old_libs=yes 797154b44505Smrg else 797254b44505Smrg build_libtool_libs=no 797354b44505Smrg fi 797454b44505Smrg fi 797554b44505Smrg fi 797654b44505Smrg fi 797754b44505Smrg # Done checking deplibs! 797854b44505Smrg deplibs=$newdeplibs 797954b44505Smrg fi 798054b44505Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 798154b44505Smrg case $host in 798254b44505Smrg *-*-darwin*) 798354b44505Smrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 798454b44505Smrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 798554b44505Smrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 798654b44505Smrg ;; 798754b44505Smrg esac 79884a041c5bSmacallan 798954b44505Smrg # move library search paths that coincide with paths to not yet 799054b44505Smrg # installed libraries to the beginning of the library search list 799154b44505Smrg new_libs= 799254b44505Smrg for path in $notinst_path; do 799354b44505Smrg case " $new_libs " in 799454b44505Smrg *" -L$path/$objdir "*) ;; 799554b44505Smrg *) 799654b44505Smrg case " $deplibs " in 799754b44505Smrg *" -L$path/$objdir "*) 799854b44505Smrg func_append new_libs " -L$path/$objdir" ;; 799954b44505Smrg esac 800054b44505Smrg ;; 800154b44505Smrg esac 800254b44505Smrg done 800354b44505Smrg for deplib in $deplibs; do 800454b44505Smrg case $deplib in 800554b44505Smrg -L*) 800654b44505Smrg case " $new_libs " in 800754b44505Smrg *" $deplib "*) ;; 800854b44505Smrg *) func_append new_libs " $deplib" ;; 800954b44505Smrg esac 801054b44505Smrg ;; 801154b44505Smrg *) func_append new_libs " $deplib" ;; 801254b44505Smrg esac 801354b44505Smrg done 801454b44505Smrg deplibs="$new_libs" 80154a041c5bSmacallan 801654b44505Smrg # All the library-specific variables (install_libdir is set above). 801754b44505Smrg library_names= 801854b44505Smrg old_library= 801954b44505Smrg dlname= 80204a041c5bSmacallan 802154b44505Smrg # Test again, we may have decided not to build it any more 802254b44505Smrg if test "$build_libtool_libs" = yes; then 802354b44505Smrg if test "$hardcode_into_libs" = yes; then 802454b44505Smrg # Hardcode the library paths 802554b44505Smrg hardcode_libdirs= 802654b44505Smrg dep_rpath= 802754b44505Smrg rpath="$finalize_rpath" 802854b44505Smrg test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 802954b44505Smrg for libdir in $rpath; do 803054b44505Smrg if test -n "$hardcode_libdir_flag_spec"; then 803154b44505Smrg if test -n "$hardcode_libdir_separator"; then 803254b44505Smrg func_replace_sysroot "$libdir" 803354b44505Smrg libdir=$func_replace_sysroot_result 803454b44505Smrg if test -z "$hardcode_libdirs"; then 803554b44505Smrg hardcode_libdirs="$libdir" 803654b44505Smrg else 803754b44505Smrg # Just accumulate the unique libdirs. 803854b44505Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 803954b44505Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 804054b44505Smrg ;; 804154b44505Smrg *) 804254b44505Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 804354b44505Smrg ;; 804454b44505Smrg esac 804554b44505Smrg fi 804654b44505Smrg else 804754b44505Smrg eval flag=\"$hardcode_libdir_flag_spec\" 804854b44505Smrg func_append dep_rpath " $flag" 804954b44505Smrg fi 805054b44505Smrg elif test -n "$runpath_var"; then 805154b44505Smrg case "$perm_rpath " in 805254b44505Smrg *" $libdir "*) ;; 805354b44505Smrg *) func_apped perm_rpath " $libdir" ;; 805454b44505Smrg esac 805554b44505Smrg fi 805654b44505Smrg done 805754b44505Smrg # Substitute the hardcoded libdirs into the rpath. 805854b44505Smrg if test -n "$hardcode_libdir_separator" && 805954b44505Smrg test -n "$hardcode_libdirs"; then 806054b44505Smrg libdir="$hardcode_libdirs" 806154b44505Smrg if test -n "$hardcode_libdir_flag_spec_ld"; then 806254b44505Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 806354b44505Smrg else 806454b44505Smrg eval dep_rpath=\"$hardcode_libdir_flag_spec\" 806554b44505Smrg fi 806654b44505Smrg fi 806754b44505Smrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 806854b44505Smrg # We should set the runpath_var. 806954b44505Smrg rpath= 807054b44505Smrg for dir in $perm_rpath; do 807154b44505Smrg func_append rpath "$dir:" 807254b44505Smrg done 807354b44505Smrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 807454b44505Smrg fi 807554b44505Smrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 807654b44505Smrg fi 80774a041c5bSmacallan 807854b44505Smrg shlibpath="$finalize_shlibpath" 807954b44505Smrg test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 808054b44505Smrg if test -n "$shlibpath"; then 808154b44505Smrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 808254b44505Smrg fi 80834a041c5bSmacallan 808454b44505Smrg # Get the real and link names of the library. 808554b44505Smrg eval shared_ext=\"$shrext_cmds\" 808654b44505Smrg eval library_names=\"$library_names_spec\" 808754b44505Smrg set dummy $library_names 808854b44505Smrg shift 808954b44505Smrg realname="$1" 809054b44505Smrg shift 80914a041c5bSmacallan 809254b44505Smrg if test -n "$soname_spec"; then 809354b44505Smrg eval soname=\"$soname_spec\" 80944a041c5bSmacallan else 809554b44505Smrg soname="$realname" 809654b44505Smrg fi 809754b44505Smrg if test -z "$dlname"; then 809854b44505Smrg dlname=$soname 80994a041c5bSmacallan fi 81004a041c5bSmacallan 810154b44505Smrg lib="$output_objdir/$realname" 810254b44505Smrg linknames= 810354b44505Smrg for link 810454b44505Smrg do 810554b44505Smrg func_append linknames " $link" 810654b44505Smrg done 81074a041c5bSmacallan 810854b44505Smrg # Use standard objects if they are pic 810954b44505Smrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 811054b44505Smrg test "X$libobjs" = "X " && libobjs= 81114a041c5bSmacallan 811254b44505Smrg delfiles= 811354b44505Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 811454b44505Smrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 811554b44505Smrg export_symbols="$output_objdir/$libname.uexp" 811654b44505Smrg func_append delfiles " $export_symbols" 811754b44505Smrg fi 81184a041c5bSmacallan 811954b44505Smrg orig_export_symbols= 812054b44505Smrg case $host_os in 812154b44505Smrg cygwin* | mingw* | cegcc*) 812254b44505Smrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 812354b44505Smrg # exporting using user supplied symfile 812454b44505Smrg if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 812554b44505Smrg # and it's NOT already a .def file. Must figure out 812654b44505Smrg # which of the given symbols are data symbols and tag 812754b44505Smrg # them as such. So, trigger use of export_symbols_cmds. 812854b44505Smrg # export_symbols gets reassigned inside the "prepare 812954b44505Smrg # the list of exported symbols" if statement, so the 813054b44505Smrg # include_expsyms logic still works. 813154b44505Smrg orig_export_symbols="$export_symbols" 813254b44505Smrg export_symbols= 813354b44505Smrg always_export_symbols=yes 813454b44505Smrg fi 813554b44505Smrg fi 813654b44505Smrg ;; 813754b44505Smrg esac 81384a041c5bSmacallan 813954b44505Smrg # Prepare the list of exported symbols 814054b44505Smrg if test -z "$export_symbols"; then 814154b44505Smrg if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 814254b44505Smrg func_verbose "generating symbol list for \`$libname.la'" 814354b44505Smrg export_symbols="$output_objdir/$libname.exp" 814454b44505Smrg $opt_dry_run || $RM $export_symbols 814554b44505Smrg cmds=$export_symbols_cmds 814654b44505Smrg save_ifs="$IFS"; IFS='~' 814754b44505Smrg for cmd1 in $cmds; do 814854b44505Smrg IFS="$save_ifs" 814954b44505Smrg # Take the normal branch if the nm_file_list_spec branch 815054b44505Smrg # doesn't work or if tool conversion is not needed. 815154b44505Smrg case $nm_file_list_spec~$to_tool_file_cmd in 815254b44505Smrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 815354b44505Smrg try_normal_branch=yes 815454b44505Smrg eval cmd=\"$cmd1\" 815554b44505Smrg func_len " $cmd" 815654b44505Smrg len=$func_len_result 815754b44505Smrg ;; 815854b44505Smrg *) 815954b44505Smrg try_normal_branch=no 816054b44505Smrg ;; 816154b44505Smrg esac 816254b44505Smrg if test "$try_normal_branch" = yes \ 816354b44505Smrg && { test "$len" -lt "$max_cmd_len" \ 816454b44505Smrg || test "$max_cmd_len" -le -1; } 816554b44505Smrg then 816654b44505Smrg func_show_eval "$cmd" 'exit $?' 816754b44505Smrg skipped_export=false 816854b44505Smrg elif test -n "$nm_file_list_spec"; then 816954b44505Smrg func_basename "$output" 817054b44505Smrg output_la=$func_basename_result 817154b44505Smrg save_libobjs=$libobjs 817254b44505Smrg save_output=$output 817354b44505Smrg output=${output_objdir}/${output_la}.nm 817454b44505Smrg func_to_tool_file "$output" 817554b44505Smrg libobjs=$nm_file_list_spec$func_to_tool_file_result 817654b44505Smrg func_append delfiles " $output" 817754b44505Smrg func_verbose "creating $NM input file list: $output" 817854b44505Smrg for obj in $save_libobjs; do 817954b44505Smrg func_to_tool_file "$obj" 818054b44505Smrg $ECHO "$func_to_tool_file_result" 818154b44505Smrg done > "$output" 818254b44505Smrg eval cmd=\"$cmd1\" 818354b44505Smrg func_show_eval "$cmd" 'exit $?' 818454b44505Smrg output=$save_output 818554b44505Smrg libobjs=$save_libobjs 818654b44505Smrg skipped_export=false 818754b44505Smrg else 818854b44505Smrg # The command line is too long to execute in one step. 818954b44505Smrg func_verbose "using reloadable object file for export list..." 819054b44505Smrg skipped_export=: 819154b44505Smrg # Break out early, otherwise skipped_export may be 819254b44505Smrg # set to false by a later but shorter cmd. 819354b44505Smrg break 819454b44505Smrg fi 819554b44505Smrg done 819654b44505Smrg IFS="$save_ifs" 819754b44505Smrg if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 819854b44505Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 819954b44505Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 820054b44505Smrg fi 820154b44505Smrg fi 82024a041c5bSmacallan fi 82034a041c5bSmacallan 820454b44505Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 820554b44505Smrg tmp_export_symbols="$export_symbols" 820654b44505Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 820754b44505Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 82084a041c5bSmacallan fi 82094a041c5bSmacallan 821054b44505Smrg if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 821154b44505Smrg # The given exports_symbols file has to be filtered, so filter it. 821254b44505Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 821354b44505Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 821454b44505Smrg # 's' commands which not all seds can handle. GNU sed should be fine 821554b44505Smrg # though. Also, the filter scales superlinearly with the number of 821654b44505Smrg # global variables. join(1) would be nice here, but unfortunately 821754b44505Smrg # isn't a blessed tool. 821854b44505Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 821954b44505Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 822054b44505Smrg export_symbols=$output_objdir/$libname.def 822154b44505Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 822254b44505Smrg fi 82234a041c5bSmacallan 822454b44505Smrg tmp_deplibs= 822554b44505Smrg for test_deplib in $deplibs; do 822654b44505Smrg case " $convenience " in 822754b44505Smrg *" $test_deplib "*) ;; 822854b44505Smrg *) 822954b44505Smrg func_append tmp_deplibs " $test_deplib" 823054b44505Smrg ;; 823154b44505Smrg esac 823254b44505Smrg done 823354b44505Smrg deplibs="$tmp_deplibs" 82344a041c5bSmacallan 823554b44505Smrg if test -n "$convenience"; then 823654b44505Smrg if test -n "$whole_archive_flag_spec" && 823754b44505Smrg test "$compiler_needs_object" = yes && 823854b44505Smrg test -z "$libobjs"; then 823954b44505Smrg # extract the archives, so we have objects to list. 824054b44505Smrg # TODO: could optimize this to just extract one archive. 824154b44505Smrg whole_archive_flag_spec= 824254b44505Smrg fi 824354b44505Smrg if test -n "$whole_archive_flag_spec"; then 824454b44505Smrg save_libobjs=$libobjs 824554b44505Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 824654b44505Smrg test "X$libobjs" = "X " && libobjs= 824754b44505Smrg else 824854b44505Smrg gentop="$output_objdir/${outputname}x" 824954b44505Smrg func_append generated " $gentop" 82504a041c5bSmacallan 825154b44505Smrg func_extract_archives $gentop $convenience 825254b44505Smrg func_append libobjs " $func_extract_archives_result" 825354b44505Smrg test "X$libobjs" = "X " && libobjs= 825454b44505Smrg fi 82554a041c5bSmacallan fi 82564a041c5bSmacallan 825754b44505Smrg if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 825854b44505Smrg eval flag=\"$thread_safe_flag_spec\" 825954b44505Smrg func_append linker_flags " $flag" 826054b44505Smrg fi 82614a041c5bSmacallan 826254b44505Smrg # Make a backup of the uninstalled library when relinking 826354b44505Smrg if test "$opt_mode" = relink; then 826454b44505Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 826554b44505Smrg fi 826654b44505Smrg 826754b44505Smrg # Do each of the archive commands. 826854b44505Smrg if test "$module" = yes && test -n "$module_cmds" ; then 826954b44505Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 827054b44505Smrg eval test_cmds=\"$module_expsym_cmds\" 827154b44505Smrg cmds=$module_expsym_cmds 827254b44505Smrg else 827354b44505Smrg eval test_cmds=\"$module_cmds\" 827454b44505Smrg cmds=$module_cmds 827554b44505Smrg fi 827654b44505Smrg else 827754b44505Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 827854b44505Smrg eval test_cmds=\"$archive_expsym_cmds\" 827954b44505Smrg cmds=$archive_expsym_cmds 828054b44505Smrg else 828154b44505Smrg eval test_cmds=\"$archive_cmds\" 828254b44505Smrg cmds=$archive_cmds 828354b44505Smrg fi 828454b44505Smrg fi 82854a041c5bSmacallan 828654b44505Smrg if test "X$skipped_export" != "X:" && 828754b44505Smrg func_len " $test_cmds" && 828854b44505Smrg len=$func_len_result && 828954b44505Smrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 82904a041c5bSmacallan : 82914a041c5bSmacallan else 829254b44505Smrg # The command line is too long to link in one step, link piecewise 829354b44505Smrg # or, if using GNU ld and skipped_export is not :, use a linker 829454b44505Smrg # script. 82954a041c5bSmacallan 829654b44505Smrg # Save the value of $output and $libobjs because we want to 829754b44505Smrg # use them later. If we have whole_archive_flag_spec, we 829854b44505Smrg # want to use save_libobjs as it was before 829954b44505Smrg # whole_archive_flag_spec was expanded, because we can't 830054b44505Smrg # assume the linker understands whole_archive_flag_spec. 830154b44505Smrg # This may have to be revisited, in case too many 830254b44505Smrg # convenience libraries get linked in and end up exceeding 830354b44505Smrg # the spec. 830454b44505Smrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 830554b44505Smrg save_libobjs=$libobjs 83064a041c5bSmacallan fi 830754b44505Smrg save_output=$output 830854b44505Smrg func_basename "$output" 830954b44505Smrg output_la=$func_basename_result 83104a041c5bSmacallan 831154b44505Smrg # Clear the reloadable object creation command queue and 831254b44505Smrg # initialize k to one. 831354b44505Smrg test_cmds= 83144a041c5bSmacallan concat_cmds= 831554b44505Smrg objlist= 831654b44505Smrg last_robj= 831754b44505Smrg k=1 83184a041c5bSmacallan 831954b44505Smrg if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 832054b44505Smrg output=${output_objdir}/${output_la}.lnkscript 832154b44505Smrg func_verbose "creating GNU ld script: $output" 832254b44505Smrg echo 'INPUT (' > $output 832354b44505Smrg for obj in $save_libobjs 832454b44505Smrg do 832554b44505Smrg func_to_tool_file "$obj" 832654b44505Smrg $ECHO "$func_to_tool_file_result" >> $output 832754b44505Smrg done 832854b44505Smrg echo ')' >> $output 832954b44505Smrg func_append delfiles " $output" 833054b44505Smrg func_to_tool_file "$output" 833154b44505Smrg output=$func_to_tool_file_result 833254b44505Smrg elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 833354b44505Smrg output=${output_objdir}/${output_la}.lnk 833454b44505Smrg func_verbose "creating linker input file list: $output" 833554b44505Smrg : > $output 833654b44505Smrg set x $save_libobjs 833754b44505Smrg shift 833854b44505Smrg firstobj= 833954b44505Smrg if test "$compiler_needs_object" = yes; then 834054b44505Smrg firstobj="$1 " 834154b44505Smrg shift 834254b44505Smrg fi 834354b44505Smrg for obj 834454b44505Smrg do 834554b44505Smrg func_to_tool_file "$obj" 834654b44505Smrg $ECHO "$func_to_tool_file_result" >> $output 834754b44505Smrg done 834854b44505Smrg func_append delfiles " $output" 834954b44505Smrg func_to_tool_file "$output" 835054b44505Smrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 835154b44505Smrg else 835254b44505Smrg if test -n "$save_libobjs"; then 835354b44505Smrg func_verbose "creating reloadable object files..." 835454b44505Smrg output=$output_objdir/$output_la-${k}.$objext 835554b44505Smrg eval test_cmds=\"$reload_cmds\" 835654b44505Smrg func_len " $test_cmds" 835754b44505Smrg len0=$func_len_result 835854b44505Smrg len=$len0 835954b44505Smrg 836054b44505Smrg # Loop over the list of objects to be linked. 836154b44505Smrg for obj in $save_libobjs 836254b44505Smrg do 836354b44505Smrg func_len " $obj" 836454b44505Smrg func_arith $len + $func_len_result 836554b44505Smrg len=$func_arith_result 836654b44505Smrg if test "X$objlist" = X || 836754b44505Smrg test "$len" -lt "$max_cmd_len"; then 836854b44505Smrg func_append objlist " $obj" 836954b44505Smrg else 837054b44505Smrg # The command $test_cmds is almost too long, add a 837154b44505Smrg # command to the queue. 837254b44505Smrg if test "$k" -eq 1 ; then 837354b44505Smrg # The first file doesn't have a previous command to add. 837454b44505Smrg reload_objs=$objlist 837554b44505Smrg eval concat_cmds=\"$reload_cmds\" 837654b44505Smrg else 837754b44505Smrg # All subsequent reloadable object files will link in 837854b44505Smrg # the last one created. 837954b44505Smrg reload_objs="$objlist $last_robj" 838054b44505Smrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 838154b44505Smrg fi 838254b44505Smrg last_robj=$output_objdir/$output_la-${k}.$objext 838354b44505Smrg func_arith $k + 1 838454b44505Smrg k=$func_arith_result 838554b44505Smrg output=$output_objdir/$output_la-${k}.$objext 838654b44505Smrg objlist=" $obj" 838754b44505Smrg func_len " $last_robj" 838854b44505Smrg func_arith $len0 + $func_len_result 838954b44505Smrg len=$func_arith_result 839054b44505Smrg fi 839154b44505Smrg done 839254b44505Smrg # Handle the remaining objects by creating one last 839354b44505Smrg # reloadable object file. All subsequent reloadable object 839454b44505Smrg # files will link in the last one created. 839554b44505Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 839654b44505Smrg reload_objs="$objlist $last_robj" 839754b44505Smrg eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 839854b44505Smrg if test -n "$last_robj"; then 839954b44505Smrg eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 84004a041c5bSmacallan fi 840154b44505Smrg func_append delfiles " $output" 840254b44505Smrg 840354b44505Smrg else 840454b44505Smrg output= 840554b44505Smrg fi 840654b44505Smrg 840754b44505Smrg if ${skipped_export-false}; then 840854b44505Smrg func_verbose "generating symbol list for \`$libname.la'" 840954b44505Smrg export_symbols="$output_objdir/$libname.exp" 841054b44505Smrg $opt_dry_run || $RM $export_symbols 841154b44505Smrg libobjs=$output 841254b44505Smrg # Append the command to create the export file. 84134a041c5bSmacallan test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 841454b44505Smrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 841554b44505Smrg if test -n "$last_robj"; then 841654b44505Smrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 841754b44505Smrg fi 841854b44505Smrg fi 841954b44505Smrg 842054b44505Smrg test -n "$save_libobjs" && 842154b44505Smrg func_verbose "creating a temporary reloadable object file: $output" 842254b44505Smrg 842354b44505Smrg # Loop through the commands generated above and execute them. 842454b44505Smrg save_ifs="$IFS"; IFS='~' 842554b44505Smrg for cmd in $concat_cmds; do 842654b44505Smrg IFS="$save_ifs" 842754b44505Smrg $opt_silent || { 842854b44505Smrg func_quote_for_expand "$cmd" 842954b44505Smrg eval "func_echo $func_quote_for_expand_result" 843054b44505Smrg } 843154b44505Smrg $opt_dry_run || eval "$cmd" || { 843254b44505Smrg lt_exit=$? 843354b44505Smrg 843454b44505Smrg # Restore the uninstalled library and exit 843554b44505Smrg if test "$opt_mode" = relink; then 843654b44505Smrg ( cd "$output_objdir" && \ 843754b44505Smrg $RM "${realname}T" && \ 843854b44505Smrg $MV "${realname}U" "$realname" ) 843954b44505Smrg fi 844054b44505Smrg 844154b44505Smrg exit $lt_exit 844254b44505Smrg } 844354b44505Smrg done 844454b44505Smrg IFS="$save_ifs" 844554b44505Smrg 844654b44505Smrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 844754b44505Smrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 844854b44505Smrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 84494a041c5bSmacallan fi 84504a041c5bSmacallan fi 84514a041c5bSmacallan 845254b44505Smrg if ${skipped_export-false}; then 845354b44505Smrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 845454b44505Smrg tmp_export_symbols="$export_symbols" 845554b44505Smrg test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 845654b44505Smrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 845754b44505Smrg fi 84584a041c5bSmacallan 845954b44505Smrg if test -n "$orig_export_symbols"; then 846054b44505Smrg # The given exports_symbols file has to be filtered, so filter it. 846154b44505Smrg func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 846254b44505Smrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 846354b44505Smrg # 's' commands which not all seds can handle. GNU sed should be fine 846454b44505Smrg # though. Also, the filter scales superlinearly with the number of 846554b44505Smrg # global variables. join(1) would be nice here, but unfortunately 846654b44505Smrg # isn't a blessed tool. 846754b44505Smrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 846854b44505Smrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 846954b44505Smrg export_symbols=$output_objdir/$libname.def 847054b44505Smrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 847154b44505Smrg fi 847254b44505Smrg fi 84734a041c5bSmacallan 847454b44505Smrg libobjs=$output 847554b44505Smrg # Restore the value of output. 847654b44505Smrg output=$save_output 84774a041c5bSmacallan 847854b44505Smrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 847954b44505Smrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 848054b44505Smrg test "X$libobjs" = "X " && libobjs= 848154b44505Smrg fi 848254b44505Smrg # Expand the library linking commands again to reset the 848354b44505Smrg # value of $libobjs for piecewise linking. 84844a041c5bSmacallan 848554b44505Smrg # Do each of the archive commands. 848654b44505Smrg if test "$module" = yes && test -n "$module_cmds" ; then 848754b44505Smrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 848854b44505Smrg cmds=$module_expsym_cmds 848954b44505Smrg else 849054b44505Smrg cmds=$module_cmds 84914a041c5bSmacallan fi 84924a041c5bSmacallan else 849354b44505Smrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 849454b44505Smrg cmds=$archive_expsym_cmds 849554b44505Smrg else 849654b44505Smrg cmds=$archive_cmds 849754b44505Smrg fi 84984a041c5bSmacallan fi 849954b44505Smrg fi 85004a041c5bSmacallan 850154b44505Smrg if test -n "$delfiles"; then 850254b44505Smrg # Append the command to remove temporary files to $cmds. 850354b44505Smrg eval cmds=\"\$cmds~\$RM $delfiles\" 850454b44505Smrg fi 85054a041c5bSmacallan 850654b44505Smrg # Add any objects from preloaded convenience libraries 850754b44505Smrg if test -n "$dlprefiles"; then 850854b44505Smrg gentop="$output_objdir/${outputname}x" 850954b44505Smrg func_append generated " $gentop" 85104a041c5bSmacallan 851154b44505Smrg func_extract_archives $gentop $dlprefiles 851254b44505Smrg func_append libobjs " $func_extract_archives_result" 851354b44505Smrg test "X$libobjs" = "X " && libobjs= 851454b44505Smrg fi 85154a041c5bSmacallan 851654b44505Smrg save_ifs="$IFS"; IFS='~' 851754b44505Smrg for cmd in $cmds; do 851854b44505Smrg IFS="$save_ifs" 851954b44505Smrg eval cmd=\"$cmd\" 852054b44505Smrg $opt_silent || { 852154b44505Smrg func_quote_for_expand "$cmd" 852254b44505Smrg eval "func_echo $func_quote_for_expand_result" 852354b44505Smrg } 852454b44505Smrg $opt_dry_run || eval "$cmd" || { 852554b44505Smrg lt_exit=$? 85264a041c5bSmacallan 852754b44505Smrg # Restore the uninstalled library and exit 852854b44505Smrg if test "$opt_mode" = relink; then 852954b44505Smrg ( cd "$output_objdir" && \ 853054b44505Smrg $RM "${realname}T" && \ 853154b44505Smrg $MV "${realname}U" "$realname" ) 853254b44505Smrg fi 85334a041c5bSmacallan 853454b44505Smrg exit $lt_exit 853554b44505Smrg } 853654b44505Smrg done 853754b44505Smrg IFS="$save_ifs" 85384a041c5bSmacallan 853954b44505Smrg # Restore the uninstalled library and exit 854054b44505Smrg if test "$opt_mode" = relink; then 854154b44505Smrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 85424a041c5bSmacallan 854354b44505Smrg if test -n "$convenience"; then 854454b44505Smrg if test -z "$whole_archive_flag_spec"; then 854554b44505Smrg func_show_eval '${RM}r "$gentop"' 854654b44505Smrg fi 854754b44505Smrg fi 85484a041c5bSmacallan 854954b44505Smrg exit $EXIT_SUCCESS 855054b44505Smrg fi 855154b44505Smrg 855254b44505Smrg # Create links to the real library. 855354b44505Smrg for linkname in $linknames; do 855454b44505Smrg if test "$realname" != "$linkname"; then 855554b44505Smrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 85564a041c5bSmacallan fi 85574a041c5bSmacallan done 85584a041c5bSmacallan 855954b44505Smrg # If -module or -export-dynamic was specified, set the dlname. 856054b44505Smrg if test "$module" = yes || test "$export_dynamic" = yes; then 856154b44505Smrg # On all known operating systems, these are identical. 856254b44505Smrg dlname="$soname" 856354b44505Smrg fi 856454b44505Smrg fi 85654a041c5bSmacallan ;; 85664a041c5bSmacallan 856754b44505Smrg obj) 856854b44505Smrg if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 856954b44505Smrg func_warning "\`-dlopen' is ignored for objects" 857054b44505Smrg fi 85714a041c5bSmacallan 857254b44505Smrg case " $deplibs" in 857354b44505Smrg *\ -l* | *\ -L*) 857454b44505Smrg func_warning "\`-l' and \`-L' are ignored for objects" ;; 85754a041c5bSmacallan esac 85764a041c5bSmacallan 857754b44505Smrg test -n "$rpath" && \ 857854b44505Smrg func_warning "\`-rpath' is ignored for objects" 85794a041c5bSmacallan 858054b44505Smrg test -n "$xrpath" && \ 858154b44505Smrg func_warning "\`-R' is ignored for objects" 85824a041c5bSmacallan 858354b44505Smrg test -n "$vinfo" && \ 858454b44505Smrg func_warning "\`-version-info' is ignored for objects" 858554b44505Smrg 858654b44505Smrg test -n "$release" && \ 858754b44505Smrg func_warning "\`-release' is ignored for objects" 858854b44505Smrg 858954b44505Smrg case $output in 859054b44505Smrg *.lo) 859154b44505Smrg test -n "$objs$old_deplibs" && \ 859254b44505Smrg func_fatal_error "cannot build library object \`$output' from non-libtool objects" 859354b44505Smrg 859454b44505Smrg libobj=$output 859554b44505Smrg func_lo2o "$libobj" 859654b44505Smrg obj=$func_lo2o_result 85974a041c5bSmacallan ;; 85984a041c5bSmacallan *) 859954b44505Smrg libobj= 860054b44505Smrg obj="$output" 86014a041c5bSmacallan ;; 86024a041c5bSmacallan esac 86034a041c5bSmacallan 860454b44505Smrg # Delete the old objects. 860554b44505Smrg $opt_dry_run || $RM $obj $libobj 86064a041c5bSmacallan 860754b44505Smrg # Objects from convenience libraries. This assumes 860854b44505Smrg # single-version convenience libraries. Whenever we create 860954b44505Smrg # different ones for PIC/non-PIC, this we'll have to duplicate 861054b44505Smrg # the extraction. 861154b44505Smrg reload_conv_objs= 861254b44505Smrg gentop= 861354b44505Smrg # reload_cmds runs $LD directly, so let us get rid of 861454b44505Smrg # -Wl from whole_archive_flag_spec and hope we can get by with 861554b44505Smrg # turning comma into space.. 861654b44505Smrg wl= 86174a041c5bSmacallan 861854b44505Smrg if test -n "$convenience"; then 861954b44505Smrg if test -n "$whole_archive_flag_spec"; then 862054b44505Smrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 862154b44505Smrg reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 862254b44505Smrg else 862354b44505Smrg gentop="$output_objdir/${obj}x" 862454b44505Smrg func_append generated " $gentop" 86254a041c5bSmacallan 862654b44505Smrg func_extract_archives $gentop $convenience 862754b44505Smrg reload_conv_objs="$reload_objs $func_extract_archives_result" 862854b44505Smrg fi 86294a041c5bSmacallan fi 86304a041c5bSmacallan 863154b44505Smrg # If we're not building shared, we need to use non_pic_objs 863254b44505Smrg test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 86334a041c5bSmacallan 863454b44505Smrg # Create the old-style object. 863554b44505Smrg reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 86364a041c5bSmacallan 863754b44505Smrg output="$obj" 863854b44505Smrg func_execute_cmds "$reload_cmds" 'exit $?' 863954b44505Smrg 864054b44505Smrg # Exit if we aren't doing a library object file. 864154b44505Smrg if test -z "$libobj"; then 864254b44505Smrg if test -n "$gentop"; then 864354b44505Smrg func_show_eval '${RM}r "$gentop"' 864454b44505Smrg fi 864554b44505Smrg 864654b44505Smrg exit $EXIT_SUCCESS 86474a041c5bSmacallan fi 864854b44505Smrg 864954b44505Smrg if test "$build_libtool_libs" != yes; then 865054b44505Smrg if test -n "$gentop"; then 865154b44505Smrg func_show_eval '${RM}r "$gentop"' 865254b44505Smrg fi 865354b44505Smrg 865454b44505Smrg # Create an invalid libtool object if no PIC, so that we don't 865554b44505Smrg # accidentally link it into a program. 865654b44505Smrg # $show "echo timestamp > $libobj" 865754b44505Smrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 865854b44505Smrg exit $EXIT_SUCCESS 865954b44505Smrg fi 866054b44505Smrg 866154b44505Smrg if test -n "$pic_flag" || test "$pic_mode" != default; then 866254b44505Smrg # Only do commands if we really have different PIC objects. 866354b44505Smrg reload_objs="$libobjs $reload_conv_objs" 866454b44505Smrg output="$libobj" 866554b44505Smrg func_execute_cmds "$reload_cmds" 'exit $?' 866654b44505Smrg fi 866754b44505Smrg 866854b44505Smrg if test -n "$gentop"; then 866954b44505Smrg func_show_eval '${RM}r "$gentop"' 867054b44505Smrg fi 867154b44505Smrg 867254b44505Smrg exit $EXIT_SUCCESS 86734a041c5bSmacallan ;; 86744a041c5bSmacallan 867554b44505Smrg prog) 867654b44505Smrg case $host in 867754b44505Smrg *cygwin*) func_stripname '' '.exe' "$output" 867854b44505Smrg output=$func_stripname_result.exe;; 867954b44505Smrg esac 868054b44505Smrg test -n "$vinfo" && \ 868154b44505Smrg func_warning "\`-version-info' is ignored for programs" 86824a041c5bSmacallan 868354b44505Smrg test -n "$release" && \ 868454b44505Smrg func_warning "\`-release' is ignored for programs" 86854a041c5bSmacallan 868654b44505Smrg test "$preload" = yes \ 868754b44505Smrg && test "$dlopen_support" = unknown \ 868854b44505Smrg && test "$dlopen_self" = unknown \ 868954b44505Smrg && test "$dlopen_self_static" = unknown && \ 869054b44505Smrg func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 869154b44505Smrg 869254b44505Smrg case $host in 869354b44505Smrg *-*-rhapsody* | *-*-darwin1.[012]) 869454b44505Smrg # On Rhapsody replace the C library is the System framework 869554b44505Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 869654b44505Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 86974a041c5bSmacallan ;; 869854b44505Smrg esac 86994a041c5bSmacallan 870054b44505Smrg case $host in 870154b44505Smrg *-*-darwin*) 870254b44505Smrg # Don't allow lazy linking, it breaks C++ global constructors 870354b44505Smrg # But is supposedly fixed on 10.4 or later (yay!). 870454b44505Smrg if test "$tagname" = CXX ; then 870554b44505Smrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 870654b44505Smrg 10.[0123]) 870754b44505Smrg func_append compile_command " ${wl}-bind_at_load" 870854b44505Smrg func_append finalize_command " ${wl}-bind_at_load" 870954b44505Smrg ;; 871054b44505Smrg esac 87114a041c5bSmacallan fi 871254b44505Smrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 871354b44505Smrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 871454b44505Smrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 871554b44505Smrg ;; 871654b44505Smrg esac 87174a041c5bSmacallan 87184a041c5bSmacallan 871954b44505Smrg # move library search paths that coincide with paths to not yet 872054b44505Smrg # installed libraries to the beginning of the library search list 872154b44505Smrg new_libs= 872254b44505Smrg for path in $notinst_path; do 872354b44505Smrg case " $new_libs " in 872454b44505Smrg *" -L$path/$objdir "*) ;; 872554b44505Smrg *) 872654b44505Smrg case " $compile_deplibs " in 872754b44505Smrg *" -L$path/$objdir "*) 872854b44505Smrg func_append new_libs " -L$path/$objdir" ;; 87294a041c5bSmacallan esac 873054b44505Smrg ;; 873154b44505Smrg esac 873254b44505Smrg done 873354b44505Smrg for deplib in $compile_deplibs; do 873454b44505Smrg case $deplib in 873554b44505Smrg -L*) 873654b44505Smrg case " $new_libs " in 873754b44505Smrg *" $deplib "*) ;; 873854b44505Smrg *) func_append new_libs " $deplib" ;; 87394a041c5bSmacallan esac 874054b44505Smrg ;; 874154b44505Smrg *) func_append new_libs " $deplib" ;; 874254b44505Smrg esac 874354b44505Smrg done 874454b44505Smrg compile_deplibs="$new_libs" 87454a041c5bSmacallan 87464a041c5bSmacallan 874754b44505Smrg func_append compile_command " $compile_deplibs" 874854b44505Smrg func_append finalize_command " $finalize_deplibs" 87494a041c5bSmacallan 875054b44505Smrg if test -n "$rpath$xrpath"; then 875154b44505Smrg # If the user specified any rpath flags, then add them. 875254b44505Smrg for libdir in $rpath $xrpath; do 875354b44505Smrg # This is the magic to use -rpath. 875454b44505Smrg case "$finalize_rpath " in 875554b44505Smrg *" $libdir "*) ;; 875654b44505Smrg *) func_append finalize_rpath " $libdir" ;; 875754b44505Smrg esac 875854b44505Smrg done 875954b44505Smrg fi 87604a041c5bSmacallan 876154b44505Smrg # Now hardcode the library paths 876254b44505Smrg rpath= 876354b44505Smrg hardcode_libdirs= 876454b44505Smrg for libdir in $compile_rpath $finalize_rpath; do 876554b44505Smrg if test -n "$hardcode_libdir_flag_spec"; then 876654b44505Smrg if test -n "$hardcode_libdir_separator"; then 876754b44505Smrg if test -z "$hardcode_libdirs"; then 876854b44505Smrg hardcode_libdirs="$libdir" 876954b44505Smrg else 877054b44505Smrg # Just accumulate the unique libdirs. 877154b44505Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 877254b44505Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 877354b44505Smrg ;; 877454b44505Smrg *) 877554b44505Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 877654b44505Smrg ;; 877754b44505Smrg esac 877854b44505Smrg fi 87794a041c5bSmacallan else 878054b44505Smrg eval flag=\"$hardcode_libdir_flag_spec\" 878154b44505Smrg func_append rpath " $flag" 87824a041c5bSmacallan fi 878354b44505Smrg elif test -n "$runpath_var"; then 878454b44505Smrg case "$perm_rpath " in 878554b44505Smrg *" $libdir "*) ;; 878654b44505Smrg *) func_append perm_rpath " $libdir" ;; 878754b44505Smrg esac 878854b44505Smrg fi 878954b44505Smrg case $host in 879054b44505Smrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 879154b44505Smrg testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 879254b44505Smrg case :$dllsearchpath: in 879354b44505Smrg *":$libdir:"*) ;; 879454b44505Smrg ::) dllsearchpath=$libdir;; 879554b44505Smrg *) func_append dllsearchpath ":$libdir";; 879654b44505Smrg esac 879754b44505Smrg case :$dllsearchpath: in 879854b44505Smrg *":$testbindir:"*) ;; 879954b44505Smrg ::) dllsearchpath=$testbindir;; 880054b44505Smrg *) func_append dllsearchpath ":$testbindir";; 880154b44505Smrg esac 880254b44505Smrg ;; 880354b44505Smrg esac 880454b44505Smrg done 880554b44505Smrg # Substitute the hardcoded libdirs into the rpath. 880654b44505Smrg if test -n "$hardcode_libdir_separator" && 880754b44505Smrg test -n "$hardcode_libdirs"; then 880854b44505Smrg libdir="$hardcode_libdirs" 880954b44505Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 881054b44505Smrg fi 881154b44505Smrg compile_rpath="$rpath" 88124a041c5bSmacallan 881354b44505Smrg rpath= 881454b44505Smrg hardcode_libdirs= 881554b44505Smrg for libdir in $finalize_rpath; do 881654b44505Smrg if test -n "$hardcode_libdir_flag_spec"; then 881754b44505Smrg if test -n "$hardcode_libdir_separator"; then 881854b44505Smrg if test -z "$hardcode_libdirs"; then 881954b44505Smrg hardcode_libdirs="$libdir" 882054b44505Smrg else 882154b44505Smrg # Just accumulate the unique libdirs. 882254b44505Smrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 882354b44505Smrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 882454b44505Smrg ;; 882554b44505Smrg *) 882654b44505Smrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 882754b44505Smrg ;; 882854b44505Smrg esac 882954b44505Smrg fi 88304a041c5bSmacallan else 883154b44505Smrg eval flag=\"$hardcode_libdir_flag_spec\" 883254b44505Smrg func_append rpath " $flag" 88334a041c5bSmacallan fi 883454b44505Smrg elif test -n "$runpath_var"; then 883554b44505Smrg case "$finalize_perm_rpath " in 883654b44505Smrg *" $libdir "*) ;; 883754b44505Smrg *) func_append finalize_perm_rpath " $libdir" ;; 883854b44505Smrg esac 88394a041c5bSmacallan fi 884054b44505Smrg done 884154b44505Smrg # Substitute the hardcoded libdirs into the rpath. 884254b44505Smrg if test -n "$hardcode_libdir_separator" && 884354b44505Smrg test -n "$hardcode_libdirs"; then 884454b44505Smrg libdir="$hardcode_libdirs" 884554b44505Smrg eval rpath=\" $hardcode_libdir_flag_spec\" 884654b44505Smrg fi 884754b44505Smrg finalize_rpath="$rpath" 88484a041c5bSmacallan 884954b44505Smrg if test -n "$libobjs" && test "$build_old_libs" = yes; then 885054b44505Smrg # Transform all the library objects into standard objects. 885154b44505Smrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 885254b44505Smrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 885354b44505Smrg fi 88544a041c5bSmacallan 885554b44505Smrg func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 88564a041c5bSmacallan 885754b44505Smrg # template prelinking step 885854b44505Smrg if test -n "$prelink_cmds"; then 885954b44505Smrg func_execute_cmds "$prelink_cmds" 'exit $?' 886054b44505Smrg fi 88614a041c5bSmacallan 886254b44505Smrg wrappers_required=yes 886354b44505Smrg case $host in 886454b44505Smrg *cegcc* | *mingw32ce*) 886554b44505Smrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 886654b44505Smrg wrappers_required=no 886754b44505Smrg ;; 886854b44505Smrg *cygwin* | *mingw* ) 886954b44505Smrg if test "$build_libtool_libs" != yes; then 887054b44505Smrg wrappers_required=no 887154b44505Smrg fi 887254b44505Smrg ;; 887354b44505Smrg *) 887454b44505Smrg if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 887554b44505Smrg wrappers_required=no 887654b44505Smrg fi 887754b44505Smrg ;; 887854b44505Smrg esac 887954b44505Smrg if test "$wrappers_required" = no; then 888054b44505Smrg # Replace the output file specification. 888154b44505Smrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 888254b44505Smrg link_command="$compile_command$compile_rpath" 88834a041c5bSmacallan 888454b44505Smrg # We have no uninstalled library dependencies, so finalize right now. 888554b44505Smrg exit_status=0 888654b44505Smrg func_show_eval "$link_command" 'exit_status=$?' 88874a041c5bSmacallan 888854b44505Smrg if test -n "$postlink_cmds"; then 888954b44505Smrg func_to_tool_file "$output" 889054b44505Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 889154b44505Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 88924a041c5bSmacallan fi 88934a041c5bSmacallan 889454b44505Smrg # Delete the generated files. 889554b44505Smrg if test -f "$output_objdir/${outputname}S.${objext}"; then 889654b44505Smrg func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 889754b44505Smrg fi 88984a041c5bSmacallan 889954b44505Smrg exit $exit_status 890054b44505Smrg fi 89014a041c5bSmacallan 890254b44505Smrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 890354b44505Smrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 890454b44505Smrg fi 890554b44505Smrg if test -n "$finalize_shlibpath"; then 890654b44505Smrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 890754b44505Smrg fi 89084a041c5bSmacallan 890954b44505Smrg compile_var= 891054b44505Smrg finalize_var= 891154b44505Smrg if test -n "$runpath_var"; then 891254b44505Smrg if test -n "$perm_rpath"; then 891354b44505Smrg # We should set the runpath_var. 891454b44505Smrg rpath= 891554b44505Smrg for dir in $perm_rpath; do 891654b44505Smrg func_append rpath "$dir:" 891754b44505Smrg done 891854b44505Smrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 89194a041c5bSmacallan fi 892054b44505Smrg if test -n "$finalize_perm_rpath"; then 892154b44505Smrg # We should set the runpath_var. 892254b44505Smrg rpath= 892354b44505Smrg for dir in $finalize_perm_rpath; do 892454b44505Smrg func_append rpath "$dir:" 892554b44505Smrg done 892654b44505Smrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 89274a041c5bSmacallan fi 892854b44505Smrg fi 89294a041c5bSmacallan 893054b44505Smrg if test "$no_install" = yes; then 893154b44505Smrg # We don't need to create a wrapper script. 893254b44505Smrg link_command="$compile_var$compile_command$compile_rpath" 893354b44505Smrg # Replace the output file specification. 893454b44505Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 893554b44505Smrg # Delete the old output file. 893654b44505Smrg $opt_dry_run || $RM $output 893754b44505Smrg # Link the executable and exit 893854b44505Smrg func_show_eval "$link_command" 'exit $?' 89394a041c5bSmacallan 894054b44505Smrg if test -n "$postlink_cmds"; then 894154b44505Smrg func_to_tool_file "$output" 894254b44505Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 894354b44505Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 89444a041c5bSmacallan fi 894554b44505Smrg 89464a041c5bSmacallan exit $EXIT_SUCCESS 894754b44505Smrg fi 89484a041c5bSmacallan 894954b44505Smrg if test "$hardcode_action" = relink; then 895054b44505Smrg # Fast installation is not supported 895154b44505Smrg link_command="$compile_var$compile_command$compile_rpath" 895254b44505Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 895354b44505Smrg 895454b44505Smrg func_warning "this platform does not like uninstalled shared libraries" 895554b44505Smrg func_warning "\`$output' will be relinked during installation" 895654b44505Smrg else 895754b44505Smrg if test "$fast_install" != no; then 895854b44505Smrg link_command="$finalize_var$compile_command$finalize_rpath" 895954b44505Smrg if test "$fast_install" = yes; then 896054b44505Smrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 896154b44505Smrg else 896254b44505Smrg # fast_install is set to needless 896354b44505Smrg relink_command= 896454b44505Smrg fi 89654a041c5bSmacallan else 896654b44505Smrg link_command="$compile_var$compile_command$compile_rpath" 896754b44505Smrg relink_command="$finalize_var$finalize_command$finalize_rpath" 89684a041c5bSmacallan fi 896954b44505Smrg fi 89704a041c5bSmacallan 897154b44505Smrg # Replace the output file specification. 897254b44505Smrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 89734a041c5bSmacallan 897454b44505Smrg # Delete the old output files. 897554b44505Smrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 89764a041c5bSmacallan 897754b44505Smrg func_show_eval "$link_command" 'exit $?' 89784a041c5bSmacallan 897954b44505Smrg if test -n "$postlink_cmds"; then 898054b44505Smrg func_to_tool_file "$output_objdir/$outputname" 898154b44505Smrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 898254b44505Smrg func_execute_cmds "$postlink_cmds" 'exit $?' 898354b44505Smrg fi 89844a041c5bSmacallan 898554b44505Smrg # Now create the wrapper script. 898654b44505Smrg func_verbose "creating $output" 89874a041c5bSmacallan 898854b44505Smrg # Quote the relink command for shipping. 898954b44505Smrg if test -n "$relink_command"; then 899054b44505Smrg # Preserve any variables that may affect compiler behavior 899154b44505Smrg for var in $variables_saved_for_relink; do 899254b44505Smrg if eval test -z \"\${$var+set}\"; then 899354b44505Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 899454b44505Smrg elif eval var_value=\$$var; test -z "$var_value"; then 899554b44505Smrg relink_command="$var=; export $var; $relink_command" 89964a041c5bSmacallan else 899754b44505Smrg func_quote_for_eval "$var_value" 899854b44505Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 89994a041c5bSmacallan fi 900054b44505Smrg done 900154b44505Smrg relink_command="(cd `pwd`; $relink_command)" 900254b44505Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 900354b44505Smrg fi 900454b44505Smrg 900554b44505Smrg # Only actually do things if not in dry run mode. 900654b44505Smrg $opt_dry_run || { 900754b44505Smrg # win32 will think the script is a binary if it has 900854b44505Smrg # a .exe suffix, so we strip it off here. 900954b44505Smrg case $output in 901054b44505Smrg *.exe) func_stripname '' '.exe' "$output" 901154b44505Smrg output=$func_stripname_result ;; 90124a041c5bSmacallan esac 901354b44505Smrg # test for cygwin because mv fails w/o .exe extensions 901454b44505Smrg case $host in 901554b44505Smrg *cygwin*) 901654b44505Smrg exeext=.exe 901754b44505Smrg func_stripname '' '.exe' "$outputname" 901854b44505Smrg outputname=$func_stripname_result ;; 901954b44505Smrg *) exeext= ;; 902054b44505Smrg esac 902154b44505Smrg case $host in 902254b44505Smrg *cygwin* | *mingw* ) 902354b44505Smrg func_dirname_and_basename "$output" "" "." 902454b44505Smrg output_name=$func_basename_result 902554b44505Smrg output_path=$func_dirname_result 902654b44505Smrg cwrappersource="$output_path/$objdir/lt-$output_name.c" 902754b44505Smrg cwrapper="$output_path/$output_name.exe" 902854b44505Smrg $RM $cwrappersource $cwrapper 902954b44505Smrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 903054b44505Smrg 903154b44505Smrg func_emit_cwrapperexe_src > $cwrappersource 903254b44505Smrg 903354b44505Smrg # The wrapper executable is built using the $host compiler, 903454b44505Smrg # because it contains $host paths and files. If cross- 903554b44505Smrg # compiling, it, like the target executable, must be 903654b44505Smrg # executed on the $host or under an emulation environment. 903754b44505Smrg $opt_dry_run || { 903854b44505Smrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 903954b44505Smrg $STRIP $cwrapper 904054b44505Smrg } 90414a041c5bSmacallan 904254b44505Smrg # Now, create the wrapper script for func_source use: 904354b44505Smrg func_ltwrapper_scriptname $cwrapper 904454b44505Smrg $RM $func_ltwrapper_scriptname_result 904554b44505Smrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 904654b44505Smrg $opt_dry_run || { 904754b44505Smrg # note: this script will not be executed, so do not chmod. 904854b44505Smrg if test "x$build" = "x$host" ; then 904954b44505Smrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 905054b44505Smrg else 905154b44505Smrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 905254b44505Smrg fi 905354b44505Smrg } 905454b44505Smrg ;; 905554b44505Smrg * ) 905654b44505Smrg $RM $output 905754b44505Smrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 90584a041c5bSmacallan 905954b44505Smrg func_emit_wrapper no > $output 906054b44505Smrg chmod +x $output 906154b44505Smrg ;; 906254b44505Smrg esac 906354b44505Smrg } 906454b44505Smrg exit $EXIT_SUCCESS 906554b44505Smrg ;; 906654b44505Smrg esac 90674a041c5bSmacallan 906854b44505Smrg # See if we need to build an old-fashioned archive. 906954b44505Smrg for oldlib in $oldlibs; do 90704a041c5bSmacallan 907154b44505Smrg if test "$build_libtool_libs" = convenience; then 907254b44505Smrg oldobjs="$libobjs_save $symfileobj" 907354b44505Smrg addlibs="$convenience" 907454b44505Smrg build_libtool_libs=no 907554b44505Smrg else 907654b44505Smrg if test "$build_libtool_libs" = module; then 907754b44505Smrg oldobjs="$libobjs_save" 907854b44505Smrg build_libtool_libs=no 907954b44505Smrg else 908054b44505Smrg oldobjs="$old_deplibs $non_pic_objects" 908154b44505Smrg if test "$preload" = yes && test -f "$symfileobj"; then 908254b44505Smrg func_append oldobjs " $symfileobj" 908354b44505Smrg fi 908454b44505Smrg fi 908554b44505Smrg addlibs="$old_convenience" 90864a041c5bSmacallan fi 90874a041c5bSmacallan 908854b44505Smrg if test -n "$addlibs"; then 908954b44505Smrg gentop="$output_objdir/${outputname}x" 909054b44505Smrg func_append generated " $gentop" 90914a041c5bSmacallan 909254b44505Smrg func_extract_archives $gentop $addlibs 909354b44505Smrg func_append oldobjs " $func_extract_archives_result" 909454b44505Smrg fi 90954a041c5bSmacallan 909654b44505Smrg # Do each command in the archive commands. 909754b44505Smrg if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 909854b44505Smrg cmds=$old_archive_from_new_cmds 909954b44505Smrg else 91004a041c5bSmacallan 910154b44505Smrg # Add any objects from preloaded convenience libraries 910254b44505Smrg if test -n "$dlprefiles"; then 910354b44505Smrg gentop="$output_objdir/${outputname}x" 910454b44505Smrg func_append generated " $gentop" 91054a041c5bSmacallan 910654b44505Smrg func_extract_archives $gentop $dlprefiles 910754b44505Smrg func_append oldobjs " $func_extract_archives_result" 910854b44505Smrg fi 91094a041c5bSmacallan 911054b44505Smrg # POSIX demands no paths to be encoded in archives. We have 911154b44505Smrg # to avoid creating archives with duplicate basenames if we 911254b44505Smrg # might have to extract them afterwards, e.g., when creating a 911354b44505Smrg # static archive out of a convenience library, or when linking 911454b44505Smrg # the entirety of a libtool archive into another (currently 911554b44505Smrg # not supported by libtool). 911654b44505Smrg if (for obj in $oldobjs 911754b44505Smrg do 911854b44505Smrg func_basename "$obj" 911954b44505Smrg $ECHO "$func_basename_result" 912054b44505Smrg done | sort | sort -uc >/dev/null 2>&1); then 912154b44505Smrg : 912254b44505Smrg else 912354b44505Smrg echo "copying selected object files to avoid basename conflicts..." 912454b44505Smrg gentop="$output_objdir/${outputname}x" 912554b44505Smrg func_append generated " $gentop" 912654b44505Smrg func_mkdir_p "$gentop" 912754b44505Smrg save_oldobjs=$oldobjs 912854b44505Smrg oldobjs= 912954b44505Smrg counter=1 913054b44505Smrg for obj in $save_oldobjs 913154b44505Smrg do 913254b44505Smrg func_basename "$obj" 913354b44505Smrg objbase="$func_basename_result" 913454b44505Smrg case " $oldobjs " in 913554b44505Smrg " ") oldobjs=$obj ;; 913654b44505Smrg *[\ /]"$objbase "*) 913754b44505Smrg while :; do 913854b44505Smrg # Make sure we don't pick an alternate name that also 913954b44505Smrg # overlaps. 914054b44505Smrg newobj=lt$counter-$objbase 914154b44505Smrg func_arith $counter + 1 914254b44505Smrg counter=$func_arith_result 914354b44505Smrg case " $oldobjs " in 914454b44505Smrg *[\ /]"$newobj "*) ;; 914554b44505Smrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 914654b44505Smrg esac 914754b44505Smrg done 914854b44505Smrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 914954b44505Smrg func_append oldobjs " $gentop/$newobj" 915054b44505Smrg ;; 915154b44505Smrg *) func_append oldobjs " $obj" ;; 915254b44505Smrg esac 91534a041c5bSmacallan done 91544a041c5bSmacallan fi 915554b44505Smrg eval cmds=\"$old_archive_cmds\" 91564a041c5bSmacallan 915754b44505Smrg func_len " $cmds" 915854b44505Smrg len=$func_len_result 915954b44505Smrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 916054b44505Smrg cmds=$old_archive_cmds 916154b44505Smrg elif test -n "$archiver_list_spec"; then 916254b44505Smrg func_verbose "using command file archive linking..." 916354b44505Smrg for obj in $oldobjs 916454b44505Smrg do 916554b44505Smrg func_to_tool_file "$obj" 916654b44505Smrg $ECHO "$func_to_tool_file_result" 916754b44505Smrg done > $output_objdir/$libname.libcmd 916854b44505Smrg func_to_tool_file "$output_objdir/$libname.libcmd" 916954b44505Smrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 917054b44505Smrg cmds=$old_archive_cmds 917154b44505Smrg else 917254b44505Smrg # the command line is too long to link in one step, link in parts 917354b44505Smrg func_verbose "using piecewise archive linking..." 917454b44505Smrg save_RANLIB=$RANLIB 917554b44505Smrg RANLIB=: 917654b44505Smrg objlist= 917754b44505Smrg concat_cmds= 917854b44505Smrg save_oldobjs=$oldobjs 917954b44505Smrg oldobjs= 918054b44505Smrg # Is there a better way of finding the last object in the list? 918154b44505Smrg for obj in $save_oldobjs 918254b44505Smrg do 918354b44505Smrg last_oldobj=$obj 918454b44505Smrg done 918554b44505Smrg eval test_cmds=\"$old_archive_cmds\" 918654b44505Smrg func_len " $test_cmds" 918754b44505Smrg len0=$func_len_result 918854b44505Smrg len=$len0 918954b44505Smrg for obj in $save_oldobjs 919054b44505Smrg do 919154b44505Smrg func_len " $obj" 919254b44505Smrg func_arith $len + $func_len_result 919354b44505Smrg len=$func_arith_result 919454b44505Smrg func_append objlist " $obj" 919554b44505Smrg if test "$len" -lt "$max_cmd_len"; then 919654b44505Smrg : 919754b44505Smrg else 919854b44505Smrg # the above command should be used before it gets too long 919954b44505Smrg oldobjs=$objlist 920054b44505Smrg if test "$obj" = "$last_oldobj" ; then 920154b44505Smrg RANLIB=$save_RANLIB 920254b44505Smrg fi 920354b44505Smrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 920454b44505Smrg eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 920554b44505Smrg objlist= 920654b44505Smrg len=$len0 920754b44505Smrg fi 920854b44505Smrg done 920954b44505Smrg RANLIB=$save_RANLIB 921054b44505Smrg oldobjs=$objlist 921154b44505Smrg if test "X$oldobjs" = "X" ; then 921254b44505Smrg eval cmds=\"\$concat_cmds\" 921354b44505Smrg else 921454b44505Smrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 921554b44505Smrg fi 921654b44505Smrg fi 921754b44505Smrg fi 921854b44505Smrg func_execute_cmds "$cmds" 'exit $?' 92194a041c5bSmacallan done 92204a041c5bSmacallan 922154b44505Smrg test -n "$generated" && \ 922254b44505Smrg func_show_eval "${RM}r$generated" 92234a041c5bSmacallan 922454b44505Smrg # Now create the libtool archive. 922554b44505Smrg case $output in 922654b44505Smrg *.la) 922754b44505Smrg old_library= 922854b44505Smrg test "$build_old_libs" = yes && old_library="$libname.$libext" 922954b44505Smrg func_verbose "creating $output" 92304a041c5bSmacallan 923154b44505Smrg # Preserve any variables that may affect compiler behavior 923254b44505Smrg for var in $variables_saved_for_relink; do 923354b44505Smrg if eval test -z \"\${$var+set}\"; then 923454b44505Smrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 923554b44505Smrg elif eval var_value=\$$var; test -z "$var_value"; then 923654b44505Smrg relink_command="$var=; export $var; $relink_command" 92374a041c5bSmacallan else 923854b44505Smrg func_quote_for_eval "$var_value" 923954b44505Smrg relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 92404a041c5bSmacallan fi 924154b44505Smrg done 924254b44505Smrg # Quote the link command for shipping. 924354b44505Smrg relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 924454b44505Smrg relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 924554b44505Smrg if test "$hardcode_automatic" = yes ; then 924654b44505Smrg relink_command= 924754b44505Smrg fi 92484a041c5bSmacallan 924954b44505Smrg # Only create the output if not a dry run. 925054b44505Smrg $opt_dry_run || { 925154b44505Smrg for installed in no yes; do 925254b44505Smrg if test "$installed" = yes; then 925354b44505Smrg if test -z "$install_libdir"; then 925454b44505Smrg break 925554b44505Smrg fi 925654b44505Smrg output="$output_objdir/$outputname"i 925754b44505Smrg # Replace all uninstalled libtool libraries with the installed ones 925854b44505Smrg newdependency_libs= 925954b44505Smrg for deplib in $dependency_libs; do 926054b44505Smrg case $deplib in 926154b44505Smrg *.la) 926254b44505Smrg func_basename "$deplib" 926354b44505Smrg name="$func_basename_result" 926454b44505Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 926554b44505Smrg test -z "$libdir" && \ 926654b44505Smrg func_fatal_error "\`$deplib' is not a valid libtool archive" 926754b44505Smrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 926854b44505Smrg ;; 926954b44505Smrg -L*) 927054b44505Smrg func_stripname -L '' "$deplib" 927154b44505Smrg func_replace_sysroot "$func_stripname_result" 927254b44505Smrg func_append newdependency_libs " -L$func_replace_sysroot_result" 927354b44505Smrg ;; 927454b44505Smrg -R*) 927554b44505Smrg func_stripname -R '' "$deplib" 927654b44505Smrg func_replace_sysroot "$func_stripname_result" 927754b44505Smrg func_append newdependency_libs " -R$func_replace_sysroot_result" 927854b44505Smrg ;; 927954b44505Smrg *) func_append newdependency_libs " $deplib" ;; 928054b44505Smrg esac 928154b44505Smrg done 928254b44505Smrg dependency_libs="$newdependency_libs" 928354b44505Smrg newdlfiles= 928454b44505Smrg 928554b44505Smrg for lib in $dlfiles; do 928654b44505Smrg case $lib in 928754b44505Smrg *.la) 928854b44505Smrg func_basename "$lib" 928954b44505Smrg name="$func_basename_result" 929054b44505Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 929154b44505Smrg test -z "$libdir" && \ 929254b44505Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 929354b44505Smrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 929454b44505Smrg ;; 929554b44505Smrg *) func_append newdlfiles " $lib" ;; 929654b44505Smrg esac 929754b44505Smrg done 929854b44505Smrg dlfiles="$newdlfiles" 929954b44505Smrg newdlprefiles= 930054b44505Smrg for lib in $dlprefiles; do 930154b44505Smrg case $lib in 930254b44505Smrg *.la) 930354b44505Smrg # Only pass preopened files to the pseudo-archive (for 930454b44505Smrg # eventual linking with the app. that links it) if we 930554b44505Smrg # didn't already link the preopened objects directly into 930654b44505Smrg # the library: 930754b44505Smrg func_basename "$lib" 930854b44505Smrg name="$func_basename_result" 930954b44505Smrg eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 931054b44505Smrg test -z "$libdir" && \ 931154b44505Smrg func_fatal_error "\`$lib' is not a valid libtool archive" 931254b44505Smrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 931354b44505Smrg ;; 931454b44505Smrg esac 931554b44505Smrg done 931654b44505Smrg dlprefiles="$newdlprefiles" 931754b44505Smrg else 931854b44505Smrg newdlfiles= 931954b44505Smrg for lib in $dlfiles; do 932054b44505Smrg case $lib in 932154b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 932254b44505Smrg *) abs=`pwd`"/$lib" ;; 932354b44505Smrg esac 932454b44505Smrg func_append newdlfiles " $abs" 932554b44505Smrg done 932654b44505Smrg dlfiles="$newdlfiles" 932754b44505Smrg newdlprefiles= 932854b44505Smrg for lib in $dlprefiles; do 932954b44505Smrg case $lib in 933054b44505Smrg [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 933154b44505Smrg *) abs=`pwd`"/$lib" ;; 933254b44505Smrg esac 933354b44505Smrg func_append newdlprefiles " $abs" 933454b44505Smrg done 933554b44505Smrg dlprefiles="$newdlprefiles" 933654b44505Smrg fi 933754b44505Smrg $RM $output 933854b44505Smrg # place dlname in correct position for cygwin 933954b44505Smrg # In fact, it would be nice if we could use this code for all target 934054b44505Smrg # systems that can't hard-code library paths into their executables 934154b44505Smrg # and that have no shared library path variable independent of PATH, 934254b44505Smrg # but it turns out we can't easily determine that from inspecting 934354b44505Smrg # libtool variables, so we have to hard-code the OSs to which it 934454b44505Smrg # applies here; at the moment, that means platforms that use the PE 934554b44505Smrg # object format with DLL files. See the long comment at the top of 934654b44505Smrg # tests/bindir.at for full details. 934754b44505Smrg tdlname=$dlname 934854b44505Smrg case $host,$output,$installed,$module,$dlname in 934954b44505Smrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 935054b44505Smrg # If a -bindir argument was supplied, place the dll there. 935154b44505Smrg if test "x$bindir" != x ; 935254b44505Smrg then 935354b44505Smrg func_relative_path "$install_libdir" "$bindir" 935454b44505Smrg tdlname=$func_relative_path_result$dlname 935554b44505Smrg else 935654b44505Smrg # Otherwise fall back on heuristic. 935754b44505Smrg tdlname=../bin/$dlname 935854b44505Smrg fi 935954b44505Smrg ;; 936054b44505Smrg esac 936154b44505Smrg $ECHO > $output "\ 936254b44505Smrg# $outputname - a libtool library file 936354b44505Smrg# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 936454b44505Smrg# 936554b44505Smrg# Please DO NOT delete this file! 936654b44505Smrg# It is necessary for linking the library. 93674a041c5bSmacallan 936854b44505Smrg# The name that we can dlopen(3). 936954b44505Smrgdlname='$tdlname' 93704a041c5bSmacallan 937154b44505Smrg# Names of this library. 937254b44505Smrglibrary_names='$library_names' 93734a041c5bSmacallan 937454b44505Smrg# The name of the static archive. 937554b44505Smrgold_library='$old_library' 93764a041c5bSmacallan 937754b44505Smrg# Linker flags that can not go in dependency_libs. 937854b44505Smrginherited_linker_flags='$new_inherited_linker_flags' 93794a041c5bSmacallan 938054b44505Smrg# Libraries that this one depends upon. 938154b44505Smrgdependency_libs='$dependency_libs' 93824a041c5bSmacallan 938354b44505Smrg# Names of additional weak libraries provided by this library 938454b44505Smrgweak_library_names='$weak_libs' 93854a041c5bSmacallan 938654b44505Smrg# Version information for $libname. 938754b44505Smrgcurrent=$current 938854b44505Smrgage=$age 938954b44505Smrgrevision=$revision 93904a041c5bSmacallan 939154b44505Smrg# Is this an already installed library? 939254b44505Smrginstalled=$installed 93934a041c5bSmacallan 939454b44505Smrg# Should we warn about portability when linking against -modules? 939554b44505Smrgshouldnotlink=$module 93964a041c5bSmacallan 939754b44505Smrg# Files to dlopen/dlpreopen 939854b44505Smrgdlopen='$dlfiles' 939954b44505Smrgdlpreopen='$dlprefiles' 94004a041c5bSmacallan 940154b44505Smrg# Directory that this library needs to be installed in: 940254b44505Smrglibdir='$install_libdir'" 940354b44505Smrg if test "$installed" = no && test "$need_relink" = yes; then 940454b44505Smrg $ECHO >> $output "\ 940554b44505Smrgrelink_command=\"$relink_command\"" 940654b44505Smrg fi 940754b44505Smrg done 940854b44505Smrg } 94094a041c5bSmacallan 941054b44505Smrg # Do a symbolic link so that the libtool archive can be found in 941154b44505Smrg # LD_LIBRARY_PATH before the program is installed. 941254b44505Smrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 941354b44505Smrg ;; 941454b44505Smrg esac 941554b44505Smrg exit $EXIT_SUCCESS 941654b44505Smrg} 94174a041c5bSmacallan 941854b44505Smrg{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 941954b44505Smrg func_mode_link ${1+"$@"} 94204a041c5bSmacallan 94214a041c5bSmacallan 942254b44505Smrg# func_mode_uninstall arg... 942354b44505Smrgfunc_mode_uninstall () 942454b44505Smrg{ 942554b44505Smrg $opt_debug 942654b44505Smrg RM="$nonopt" 94274a041c5bSmacallan files= 94284a041c5bSmacallan rmforce= 94294a041c5bSmacallan exit_status=0 94304a041c5bSmacallan 94314a041c5bSmacallan # This variable tells wrapper scripts just to set variables rather 94324a041c5bSmacallan # than running their programs. 94334a041c5bSmacallan libtool_install_magic="$magic" 94344a041c5bSmacallan 94354a041c5bSmacallan for arg 94364a041c5bSmacallan do 94374a041c5bSmacallan case $arg in 943854b44505Smrg -f) func_append RM " $arg"; rmforce=yes ;; 943954b44505Smrg -*) func_append RM " $arg" ;; 944054b44505Smrg *) func_append files " $arg" ;; 94414a041c5bSmacallan esac 94424a041c5bSmacallan done 94434a041c5bSmacallan 944454b44505Smrg test -z "$RM" && \ 944554b44505Smrg func_fatal_help "you must specify an RM program" 94464a041c5bSmacallan 94474a041c5bSmacallan rmdirs= 94484a041c5bSmacallan 94494a041c5bSmacallan for file in $files; do 945054b44505Smrg func_dirname "$file" "" "." 945154b44505Smrg dir="$func_dirname_result" 945254b44505Smrg if test "X$dir" = X.; then 945354b44505Smrg odir="$objdir" 94544a041c5bSmacallan else 945554b44505Smrg odir="$dir/$objdir" 94564a041c5bSmacallan fi 945754b44505Smrg func_basename "$file" 945854b44505Smrg name="$func_basename_result" 945954b44505Smrg test "$opt_mode" = uninstall && odir="$dir" 94604a041c5bSmacallan 946154b44505Smrg # Remember odir for removal later, being careful to avoid duplicates 946254b44505Smrg if test "$opt_mode" = clean; then 94634a041c5bSmacallan case " $rmdirs " in 946454b44505Smrg *" $odir "*) ;; 946554b44505Smrg *) func_append rmdirs " $odir" ;; 94664a041c5bSmacallan esac 94674a041c5bSmacallan fi 94684a041c5bSmacallan 94694a041c5bSmacallan # Don't error if the file doesn't exist and rm -f was used. 947054b44505Smrg if { test -L "$file"; } >/dev/null 2>&1 || 947154b44505Smrg { test -h "$file"; } >/dev/null 2>&1 || 947254b44505Smrg test -f "$file"; then 94734a041c5bSmacallan : 94744a041c5bSmacallan elif test -d "$file"; then 94754a041c5bSmacallan exit_status=1 94764a041c5bSmacallan continue 94774a041c5bSmacallan elif test "$rmforce" = yes; then 94784a041c5bSmacallan continue 94794a041c5bSmacallan fi 94804a041c5bSmacallan 94814a041c5bSmacallan rmfiles="$file" 94824a041c5bSmacallan 94834a041c5bSmacallan case $name in 94844a041c5bSmacallan *.la) 94854a041c5bSmacallan # Possibly a libtool archive, so verify it. 948654b44505Smrg if func_lalib_p "$file"; then 948754b44505Smrg func_source $dir/$name 94884a041c5bSmacallan 94894a041c5bSmacallan # Delete the libtool libraries and symlinks. 94904a041c5bSmacallan for n in $library_names; do 949154b44505Smrg func_append rmfiles " $odir/$n" 94924a041c5bSmacallan done 949354b44505Smrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 94944a041c5bSmacallan 949554b44505Smrg case "$opt_mode" in 94964a041c5bSmacallan clean) 949754b44505Smrg case " $library_names " in 94984a041c5bSmacallan *" $dlname "*) ;; 949954b44505Smrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 95004a041c5bSmacallan esac 950154b44505Smrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 95024a041c5bSmacallan ;; 95034a041c5bSmacallan uninstall) 95044a041c5bSmacallan if test -n "$library_names"; then 95054a041c5bSmacallan # Do each command in the postuninstall commands. 950654b44505Smrg func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 95074a041c5bSmacallan fi 95084a041c5bSmacallan 95094a041c5bSmacallan if test -n "$old_library"; then 95104a041c5bSmacallan # Do each command in the old_postuninstall commands. 951154b44505Smrg func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 95124a041c5bSmacallan fi 95134a041c5bSmacallan # FIXME: should reinstall the best remaining shared library. 95144a041c5bSmacallan ;; 95154a041c5bSmacallan esac 95164a041c5bSmacallan fi 95174a041c5bSmacallan ;; 95184a041c5bSmacallan 95194a041c5bSmacallan *.lo) 95204a041c5bSmacallan # Possibly a libtool object, so verify it. 952154b44505Smrg if func_lalib_p "$file"; then 95224a041c5bSmacallan 95234a041c5bSmacallan # Read the .lo file 952454b44505Smrg func_source $dir/$name 95254a041c5bSmacallan 95264a041c5bSmacallan # Add PIC object to the list of files to remove. 952754b44505Smrg if test -n "$pic_object" && 952854b44505Smrg test "$pic_object" != none; then 952954b44505Smrg func_append rmfiles " $dir/$pic_object" 95304a041c5bSmacallan fi 95314a041c5bSmacallan 95324a041c5bSmacallan # Add non-PIC object to the list of files to remove. 953354b44505Smrg if test -n "$non_pic_object" && 953454b44505Smrg test "$non_pic_object" != none; then 953554b44505Smrg func_append rmfiles " $dir/$non_pic_object" 95364a041c5bSmacallan fi 95374a041c5bSmacallan fi 95384a041c5bSmacallan ;; 95394a041c5bSmacallan 95404a041c5bSmacallan *) 954154b44505Smrg if test "$opt_mode" = clean ; then 95424a041c5bSmacallan noexename=$name 95434a041c5bSmacallan case $file in 95444a041c5bSmacallan *.exe) 954554b44505Smrg func_stripname '' '.exe' "$file" 954654b44505Smrg file=$func_stripname_result 954754b44505Smrg func_stripname '' '.exe' "$name" 954854b44505Smrg noexename=$func_stripname_result 95494a041c5bSmacallan # $file with .exe has already been added to rmfiles, 95504a041c5bSmacallan # add $file without .exe 955154b44505Smrg func_append rmfiles " $file" 95524a041c5bSmacallan ;; 95534a041c5bSmacallan esac 95544a041c5bSmacallan # Do a test to see if this is a libtool program. 955554b44505Smrg if func_ltwrapper_p "$file"; then 955654b44505Smrg if func_ltwrapper_executable_p "$file"; then 955754b44505Smrg func_ltwrapper_scriptname "$file" 955854b44505Smrg relink_command= 955954b44505Smrg func_source $func_ltwrapper_scriptname_result 956054b44505Smrg func_append rmfiles " $func_ltwrapper_scriptname_result" 956154b44505Smrg else 956254b44505Smrg relink_command= 956354b44505Smrg func_source $dir/$noexename 956454b44505Smrg fi 95654a041c5bSmacallan 95664a041c5bSmacallan # note $name still contains .exe if it was in $file originally 95674a041c5bSmacallan # as does the version of $file that was added into $rmfiles 956854b44505Smrg func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 95694a041c5bSmacallan if test "$fast_install" = yes && test -n "$relink_command"; then 957054b44505Smrg func_append rmfiles " $odir/lt-$name" 95714a041c5bSmacallan fi 95724a041c5bSmacallan if test "X$noexename" != "X$name" ; then 957354b44505Smrg func_append rmfiles " $odir/lt-${noexename}.c" 95744a041c5bSmacallan fi 95754a041c5bSmacallan fi 95764a041c5bSmacallan fi 95774a041c5bSmacallan ;; 95784a041c5bSmacallan esac 957954b44505Smrg func_show_eval "$RM $rmfiles" 'exit_status=1' 95804a041c5bSmacallan done 95814a041c5bSmacallan 95824a041c5bSmacallan # Try to remove the ${objdir}s in the directories where we deleted files 95834a041c5bSmacallan for dir in $rmdirs; do 95844a041c5bSmacallan if test -d "$dir"; then 958554b44505Smrg func_show_eval "rmdir $dir >/dev/null 2>&1" 95864a041c5bSmacallan fi 95874a041c5bSmacallan done 95884a041c5bSmacallan 95894a041c5bSmacallan exit $exit_status 959054b44505Smrg} 95914a041c5bSmacallan 959254b44505Smrg{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 959354b44505Smrg func_mode_uninstall ${1+"$@"} 95944a041c5bSmacallan 959554b44505Smrgtest -z "$opt_mode" && { 959654b44505Smrg help="$generic_help" 959754b44505Smrg func_fatal_help "you must specify a MODE" 959854b44505Smrg} 959954b44505Smrg 960054b44505Smrgtest -z "$exec_cmd" && \ 960154b44505Smrg func_fatal_help "invalid operation mode \`$opt_mode'" 96024a041c5bSmacallan 96034a041c5bSmacallanif test -n "$exec_cmd"; then 960454b44505Smrg eval exec "$exec_cmd" 96054a041c5bSmacallan exit $EXIT_FAILURE 96064a041c5bSmacallanfi 96074a041c5bSmacallan 960854b44505Smrgexit $exit_status 96094a041c5bSmacallan 96104a041c5bSmacallan 96114a041c5bSmacallan# The TAGs below are defined such that we never get into a situation 96124a041c5bSmacallan# in which we disable both kinds of libraries. Given conflicting 96134a041c5bSmacallan# choices, we go for a static library, that is the most portable, 96144a041c5bSmacallan# since we can't tell whether shared libraries were disabled because 96154a041c5bSmacallan# the user asked for that or because the platform doesn't support 96164a041c5bSmacallan# them. This is particularly important on AIX, because we don't 96174a041c5bSmacallan# support having both static and shared libraries enabled at the same 96184a041c5bSmacallan# time on that platform, so we default to a shared-only configuration. 96194a041c5bSmacallan# If a disable-shared tag is given, we'll fallback to a static-only 96204a041c5bSmacallan# configuration. But we'll never go from static-only to shared-only. 96214a041c5bSmacallan 96224a041c5bSmacallan# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 962354b44505Smrgbuild_libtool_libs=no 962454b44505Smrgbuild_old_libs=yes 96254a041c5bSmacallan# ### END LIBTOOL TAG CONFIG: disable-shared 96264a041c5bSmacallan 96274a041c5bSmacallan# ### BEGIN LIBTOOL TAG CONFIG: disable-static 962854b44505Smrgbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 96294a041c5bSmacallan# ### END LIBTOOL TAG CONFIG: disable-static 96304a041c5bSmacallan 96314a041c5bSmacallan# Local Variables: 96324a041c5bSmacallan# mode:shell-script 96334a041c5bSmacallan# sh-indentation:2 96344a041c5bSmacallan# End: 963554b44505Smrg# vi:sw=2 963654b44505Smrg 9637