1285612Sdelphij 2285612Sdelphij# libtool (GNU libtool) 2.4 3285612Sdelphij# Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 4285612Sdelphij 5285612Sdelphij# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 6285612Sdelphij# 2007, 2008, 2009, 2010 Free Software Foundation, Inc. 7285612Sdelphij# This is free software; see the source for copying conditions. There is NO 8285612Sdelphij# warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 9285612Sdelphij 10285612Sdelphij# GNU Libtool is free software; you can redistribute it and/or modify 11181834Sroberto# it under the terms of the GNU General Public License as published by 12181834Sroberto# the Free Software Foundation; either version 2 of the License, or 13181834Sroberto# (at your option) any later version. 14181834Sroberto# 15285612Sdelphij# As a special exception to the GNU General Public License, 16285612Sdelphij# if you distribute this file as part of a program or library that 17285612Sdelphij# is built using GNU Libtool, you may include this file under the 18285612Sdelphij# same distribution terms that you use for the rest of that program. 19285612Sdelphij# 20285612Sdelphij# GNU Libtool is distributed in the hope that it will be useful, but 21181834Sroberto# WITHOUT ANY WARRANTY; without even the implied warranty of 22181834Sroberto# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 23181834Sroberto# General Public License for more details. 24181834Sroberto# 25181834Sroberto# You should have received a copy of the GNU General Public License 26285612Sdelphij# along with GNU Libtool; see the file COPYING. If not, a copy 27285612Sdelphij# can be downloaded from http://www.gnu.org/licenses/gpl.html, 28285612Sdelphij# or obtained by writing to the Free Software Foundation, Inc., 29285612Sdelphij# 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 30285612Sdelphij 31285612Sdelphij# Usage: $progname [OPTION]... [MODE-ARG]... 32181834Sroberto# 33285612Sdelphij# Provide generalized library-building support services. 34285612Sdelphij# 35285612Sdelphij# --config show all configuration variables 36285612Sdelphij# --debug enable verbose shell tracing 37285612Sdelphij# -n, --dry-run display commands without modifying any files 38285612Sdelphij# --features display basic configuration information and exit 39285612Sdelphij# --mode=MODE use operation mode MODE 40285612Sdelphij# --preserve-dup-deps don't remove duplicate dependency libraries 41285612Sdelphij# --quiet, --silent don't print informational messages 42285612Sdelphij# --no-quiet, --no-silent 43285612Sdelphij# print informational messages (default) 44285612Sdelphij# --tag=TAG use configuration variables from tag TAG 45285612Sdelphij# -v, --verbose print more informational messages than default 46285612Sdelphij# --no-verbose don't print the extra informational messages 47285612Sdelphij# --version print version information 48285612Sdelphij# -h, --help, --help-all print short, long, or detailed help message 49285612Sdelphij# 50285612Sdelphij# MODE must be one of the following: 51285612Sdelphij# 52285612Sdelphij# clean remove files from the build directory 53285612Sdelphij# compile compile a source file into a libtool object 54285612Sdelphij# execute automatically set library path, then run a program 55285612Sdelphij# finish complete the installation of libtool libraries 56285612Sdelphij# install install libraries or executables 57285612Sdelphij# link create a library or an executable 58285612Sdelphij# uninstall remove libraries from an installed directory 59285612Sdelphij# 60285612Sdelphij# MODE-ARGS vary depending on the MODE. When passed as first option, 61285612Sdelphij# `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that. 62285612Sdelphij# Try `$progname --help --mode=MODE' for a more detailed description of MODE. 63285612Sdelphij# 64285612Sdelphij# When reporting a bug, please describe a test case to reproduce it and 65285612Sdelphij# include the following information: 66285612Sdelphij# 67285612Sdelphij# host-triplet: $host 68285612Sdelphij# shell: $SHELL 69285612Sdelphij# compiler: $LTCC 70285612Sdelphij# compiler flags: $LTCFLAGS 71285612Sdelphij# linker: $LD (gnu? $with_gnu_ld) 72285612Sdelphij# $progname: (GNU libtool) 2.4 73285612Sdelphij# automake: $automake_version 74285612Sdelphij# autoconf: $autoconf_version 75285612Sdelphij# 76285612Sdelphij# Report bugs to <bug-libtool@gnu.org>. 77285612Sdelphij# GNU libtool home page: <http://www.gnu.org/software/libtool/>. 78285612Sdelphij# General help using GNU software: <http://www.gnu.org/gethelp/>. 79181834Sroberto 80285612SdelphijPROGRAM=libtool 81285612SdelphijPACKAGE=libtool 82285612SdelphijVERSION=2.4 83285612SdelphijTIMESTAMP="" 84285612Sdelphijpackage_revision=1.3293 85181834Sroberto 86285612Sdelphij# Be Bourne compatible 87285612Sdelphijif test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then 88285612Sdelphij emulate sh 89285612Sdelphij NULLCMD=: 90285612Sdelphij # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which 91285612Sdelphij # is contrary to our usage. Disable this feature. 92285612Sdelphij alias -g '${1+"$@"}'='"$@"' 93285612Sdelphij setopt NO_GLOB_SUBST 94285612Sdelphijelse 95285612Sdelphij case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac 96285612Sdelphijfi 97285612SdelphijBIN_SH=xpg4; export BIN_SH # for Tru64 98285612SdelphijDUALCASE=1; export DUALCASE # for MKS sh 99285612Sdelphij 100285612Sdelphij# A function that is used when there is no print builtin or printf. 101285612Sdelphijfunc_fallback_echo () 102285612Sdelphij{ 103285612Sdelphij eval 'cat <<_LTECHO_EOF 104285612Sdelphij$1 105285612Sdelphij_LTECHO_EOF' 106285612Sdelphij} 107285612Sdelphij 108285612Sdelphij# NLS nuisances: We save the old values to restore during execute mode. 109285612Sdelphijlt_user_locale= 110285612Sdelphijlt_safe_locale= 111285612Sdelphijfor lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 112285612Sdelphijdo 113285612Sdelphij eval "if test \"\${$lt_var+set}\" = set; then 114285612Sdelphij save_$lt_var=\$$lt_var 115285612Sdelphij $lt_var=C 116285612Sdelphij export $lt_var 117285612Sdelphij lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\" 118285612Sdelphij lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\" 119285612Sdelphij fi" 120285612Sdelphijdone 121285612SdelphijLC_ALL=C 122285612SdelphijLANGUAGE=C 123285612Sdelphijexport LANGUAGE LC_ALL 124285612Sdelphij 125285612Sdelphij$lt_unset CDPATH 126285612Sdelphij 127285612Sdelphij 128181834Sroberto# Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 129181834Sroberto# is ksh but when the shell is invoked as "sh" and the current value of 130181834Sroberto# the _XPG environment variable is not equal to 1 (one), the special 131181834Sroberto# positional parameter $0, within a function call, is the name of the 132181834Sroberto# function. 133181834Srobertoprogpath="$0" 134181834Sroberto 135181834Sroberto 136285612Sdelphij 137285612Sdelphij: ${CP="cp -f"} 138285612Sdelphijtest "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'} 139285612Sdelphij: ${EGREP="grep -E"} 140285612Sdelphij: ${FGREP="grep -F"} 141285612Sdelphij: ${GREP="grep"} 142285612Sdelphij: ${LN_S="ln -s"} 143285612Sdelphij: ${MAKE="make"} 144285612Sdelphij: ${MKDIR="mkdir"} 145285612Sdelphij: ${MV="mv -f"} 146285612Sdelphij: ${RM="rm -f"} 147285612Sdelphij: ${SED="sed"} 148285612Sdelphij: ${SHELL="${CONFIG_SHELL-/bin/sh}"} 149285612Sdelphij: ${Xsed="$SED -e 1s/^X//"} 150285612Sdelphij 151181834Sroberto# Global variables: 152181834SrobertoEXIT_SUCCESS=0 153181834SrobertoEXIT_FAILURE=1 154285612SdelphijEXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 155285612SdelphijEXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 156181834Sroberto 157285612Sdelphijexit_status=$EXIT_SUCCESS 158181834Sroberto 159285612Sdelphij# Make sure IFS has a sensible default 160285612Sdelphijlt_nl=' 161285612Sdelphij' 162285612SdelphijIFS=" $lt_nl" 163181834Sroberto 164285612Sdelphijdirname="s,/[^/]*$,," 165285612Sdelphijbasename="s,^.*/,," 166181834Sroberto 167285612Sdelphij# func_dirname file append nondir_replacement 168285612Sdelphij# Compute the dirname of FILE. If nonempty, add APPEND to the result, 169285612Sdelphij# otherwise set result to NONDIR_REPLACEMENT. 170285612Sdelphijfunc_dirname () 171285612Sdelphij{ 172285612Sdelphij func_dirname_result=`$ECHO "${1}" | $SED "$dirname"` 173285612Sdelphij if test "X$func_dirname_result" = "X${1}"; then 174285612Sdelphij func_dirname_result="${3}" 175285612Sdelphij else 176285612Sdelphij func_dirname_result="$func_dirname_result${2}" 177285612Sdelphij fi 178285612Sdelphij} # func_dirname may be replaced by extended shell implementation 179181834Sroberto 180181834Sroberto 181285612Sdelphij# func_basename file 182285612Sdelphijfunc_basename () 183285612Sdelphij{ 184285612Sdelphij func_basename_result=`$ECHO "${1}" | $SED "$basename"` 185285612Sdelphij} # func_basename may be replaced by extended shell implementation 186285612Sdelphij 187285612Sdelphij 188285612Sdelphij# func_dirname_and_basename file append nondir_replacement 189285612Sdelphij# perform func_basename and func_dirname in a single function 190285612Sdelphij# call: 191285612Sdelphij# dirname: Compute the dirname of FILE. If nonempty, 192285612Sdelphij# add APPEND to the result, otherwise set result 193285612Sdelphij# to NONDIR_REPLACEMENT. 194285612Sdelphij# value returned in "$func_dirname_result" 195285612Sdelphij# basename: Compute filename of FILE. 196285612Sdelphij# value retuned in "$func_basename_result" 197285612Sdelphij# Implementation must be kept synchronized with func_dirname 198285612Sdelphij# and func_basename. For efficiency, we do not delegate to 199285612Sdelphij# those functions but instead duplicate the functionality here. 200285612Sdelphijfunc_dirname_and_basename () 201285612Sdelphij{ 202285612Sdelphij # Extract subdirectory from the argument. 203285612Sdelphij func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"` 204285612Sdelphij if test "X$func_dirname_result" = "X${1}"; then 205285612Sdelphij func_dirname_result="${3}" 206285612Sdelphij else 207285612Sdelphij func_dirname_result="$func_dirname_result${2}" 208285612Sdelphij fi 209285612Sdelphij func_basename_result=`$ECHO "${1}" | $SED -e "$basename"` 210285612Sdelphij} # func_dirname_and_basename may be replaced by extended shell implementation 211285612Sdelphij 212285612Sdelphij 213285612Sdelphij# func_stripname prefix suffix name 214285612Sdelphij# strip PREFIX and SUFFIX off of NAME. 215285612Sdelphij# PREFIX and SUFFIX must not contain globbing or regex special 216285612Sdelphij# characters, hashes, percent signs, but SUFFIX may contain a leading 217285612Sdelphij# dot (in which case that matches only a dot). 218285612Sdelphij# func_strip_suffix prefix name 219285612Sdelphijfunc_stripname () 220285612Sdelphij{ 221285612Sdelphij case ${2} in 222285612Sdelphij .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;; 223285612Sdelphij *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;; 224285612Sdelphij esac 225285612Sdelphij} # func_stripname may be replaced by extended shell implementation 226285612Sdelphij 227285612Sdelphij 228285612Sdelphij# These SED scripts presuppose an absolute path with a trailing slash. 229285612Sdelphijpathcar='s,^/\([^/]*\).*$,\1,' 230285612Sdelphijpathcdr='s,^/[^/]*,,' 231285612Sdelphijremovedotparts=':dotsl 232285612Sdelphij s@/\./@/@g 233285612Sdelphij t dotsl 234285612Sdelphij s,/\.$,/,' 235285612Sdelphijcollapseslashes='s@/\{1,\}@/@g' 236285612Sdelphijfinalslash='s,/*$,/,' 237285612Sdelphij 238285612Sdelphij# func_normal_abspath PATH 239285612Sdelphij# Remove doubled-up and trailing slashes, "." path components, 240285612Sdelphij# and cancel out any ".." path components in PATH after making 241285612Sdelphij# it an absolute path. 242285612Sdelphij# value returned in "$func_normal_abspath_result" 243285612Sdelphijfunc_normal_abspath () 244285612Sdelphij{ 245285612Sdelphij # Start from root dir and reassemble the path. 246285612Sdelphij func_normal_abspath_result= 247285612Sdelphij func_normal_abspath_tpath=$1 248285612Sdelphij func_normal_abspath_altnamespace= 249285612Sdelphij case $func_normal_abspath_tpath in 250285612Sdelphij "") 251285612Sdelphij # Empty path, that just means $cwd. 252285612Sdelphij func_stripname '' '/' "`pwd`" 253285612Sdelphij func_normal_abspath_result=$func_stripname_result 254285612Sdelphij return 255285612Sdelphij ;; 256285612Sdelphij # The next three entries are used to spot a run of precisely 257285612Sdelphij # two leading slashes without using negated character classes; 258285612Sdelphij # we take advantage of case's first-match behaviour. 259285612Sdelphij ///*) 260285612Sdelphij # Unusual form of absolute path, do nothing. 261285612Sdelphij ;; 262285612Sdelphij //*) 263285612Sdelphij # Not necessarily an ordinary path; POSIX reserves leading '//' 264285612Sdelphij # and for example Cygwin uses it to access remote file shares 265285612Sdelphij # over CIFS/SMB, so we conserve a leading double slash if found. 266285612Sdelphij func_normal_abspath_altnamespace=/ 267285612Sdelphij ;; 268285612Sdelphij /*) 269285612Sdelphij # Absolute path, do nothing. 270285612Sdelphij ;; 271285612Sdelphij *) 272285612Sdelphij # Relative path, prepend $cwd. 273285612Sdelphij func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 274285612Sdelphij ;; 275285612Sdelphij esac 276285612Sdelphij # Cancel out all the simple stuff to save iterations. We also want 277285612Sdelphij # the path to end with a slash for ease of parsing, so make sure 278285612Sdelphij # there is one (and only one) here. 279285612Sdelphij func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 280285612Sdelphij -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"` 281285612Sdelphij while :; do 282285612Sdelphij # Processed it all yet? 283285612Sdelphij if test "$func_normal_abspath_tpath" = / ; then 284285612Sdelphij # If we ascended to the root using ".." the result may be empty now. 285285612Sdelphij if test -z "$func_normal_abspath_result" ; then 286285612Sdelphij func_normal_abspath_result=/ 287285612Sdelphij fi 288285612Sdelphij break 289285612Sdelphij fi 290285612Sdelphij func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 291285612Sdelphij -e "$pathcar"` 292285612Sdelphij func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 293285612Sdelphij -e "$pathcdr"` 294285612Sdelphij # Figure out what to do with it 295285612Sdelphij case $func_normal_abspath_tcomponent in 296285612Sdelphij "") 297285612Sdelphij # Trailing empty path component, ignore it. 298285612Sdelphij ;; 299285612Sdelphij ..) 300285612Sdelphij # Parent dir; strip last assembled component from result. 301285612Sdelphij func_dirname "$func_normal_abspath_result" 302285612Sdelphij func_normal_abspath_result=$func_dirname_result 303285612Sdelphij ;; 304285612Sdelphij *) 305285612Sdelphij # Actual path component, append it. 306285612Sdelphij func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent 307285612Sdelphij ;; 308285612Sdelphij esac 309285612Sdelphij done 310285612Sdelphij # Restore leading double-slash if one was found on entry. 311285612Sdelphij func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 312285612Sdelphij} 313285612Sdelphij 314285612Sdelphij# func_relative_path SRCDIR DSTDIR 315285612Sdelphij# generates a relative path from SRCDIR to DSTDIR, with a trailing 316285612Sdelphij# slash if non-empty, suitable for immediately appending a filename 317285612Sdelphij# without needing to append a separator. 318285612Sdelphij# value returned in "$func_relative_path_result" 319285612Sdelphijfunc_relative_path () 320285612Sdelphij{ 321285612Sdelphij func_relative_path_result= 322285612Sdelphij func_normal_abspath "$1" 323285612Sdelphij func_relative_path_tlibdir=$func_normal_abspath_result 324285612Sdelphij func_normal_abspath "$2" 325285612Sdelphij func_relative_path_tbindir=$func_normal_abspath_result 326285612Sdelphij 327285612Sdelphij # Ascend the tree starting from libdir 328285612Sdelphij while :; do 329285612Sdelphij # check if we have found a prefix of bindir 330285612Sdelphij case $func_relative_path_tbindir in 331285612Sdelphij $func_relative_path_tlibdir) 332285612Sdelphij # found an exact match 333285612Sdelphij func_relative_path_tcancelled= 334285612Sdelphij break 335285612Sdelphij ;; 336285612Sdelphij $func_relative_path_tlibdir*) 337285612Sdelphij # found a matching prefix 338285612Sdelphij func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 339285612Sdelphij func_relative_path_tcancelled=$func_stripname_result 340285612Sdelphij if test -z "$func_relative_path_result"; then 341285612Sdelphij func_relative_path_result=. 342285612Sdelphij fi 343285612Sdelphij break 344285612Sdelphij ;; 345285612Sdelphij *) 346285612Sdelphij func_dirname $func_relative_path_tlibdir 347285612Sdelphij func_relative_path_tlibdir=${func_dirname_result} 348285612Sdelphij if test "x$func_relative_path_tlibdir" = x ; then 349285612Sdelphij # Have to descend all the way to the root! 350285612Sdelphij func_relative_path_result=../$func_relative_path_result 351285612Sdelphij func_relative_path_tcancelled=$func_relative_path_tbindir 352285612Sdelphij break 353285612Sdelphij fi 354285612Sdelphij func_relative_path_result=../$func_relative_path_result 355285612Sdelphij ;; 356285612Sdelphij esac 357285612Sdelphij done 358285612Sdelphij 359285612Sdelphij # Now calculate path; take care to avoid doubling-up slashes. 360285612Sdelphij func_stripname '' '/' "$func_relative_path_result" 361285612Sdelphij func_relative_path_result=$func_stripname_result 362285612Sdelphij func_stripname '/' '/' "$func_relative_path_tcancelled" 363285612Sdelphij if test "x$func_stripname_result" != x ; then 364285612Sdelphij func_relative_path_result=${func_relative_path_result}/${func_stripname_result} 365285612Sdelphij fi 366285612Sdelphij 367285612Sdelphij # Normalisation. If bindir is libdir, return empty string, 368285612Sdelphij # else relative path ending with a slash; either way, target 369285612Sdelphij # file name can be directly appended. 370285612Sdelphij if test ! -z "$func_relative_path_result"; then 371285612Sdelphij func_stripname './' '' "$func_relative_path_result/" 372285612Sdelphij func_relative_path_result=$func_stripname_result 373285612Sdelphij fi 374285612Sdelphij} 375285612Sdelphij 376285612Sdelphij# The name of this program: 377285612Sdelphijfunc_dirname_and_basename "$progpath" 378285612Sdelphijprogname=$func_basename_result 379285612Sdelphij 380285612Sdelphij# Make sure we have an absolute path for reexecution: 381285612Sdelphijcase $progpath in 382285612Sdelphij [\\/]*|[A-Za-z]:\\*) ;; 383285612Sdelphij *[\\/]*) 384285612Sdelphij progdir=$func_dirname_result 385285612Sdelphij progdir=`cd "$progdir" && pwd` 386285612Sdelphij progpath="$progdir/$progname" 387285612Sdelphij ;; 388285612Sdelphij *) 389285612Sdelphij save_IFS="$IFS" 390285612Sdelphij IFS=: 391285612Sdelphij for progdir in $PATH; do 392285612Sdelphij IFS="$save_IFS" 393285612Sdelphij test -x "$progdir/$progname" && break 394285612Sdelphij done 395285612Sdelphij IFS="$save_IFS" 396285612Sdelphij test -n "$progdir" || progdir=`pwd` 397285612Sdelphij progpath="$progdir/$progname" 398285612Sdelphij ;; 399285612Sdelphijesac 400285612Sdelphij 401181834Sroberto# Sed substitution that helps us do robust quoting. It backslashifies 402181834Sroberto# metacharacters that are still active within double-quoted strings. 403181834SrobertoXsed="${SED}"' -e 1s/^X//' 404285612Sdelphijsed_quote_subst='s/\([`"$\\]\)/\\\1/g' 405181834Sroberto 406285612Sdelphij# Same as above, but do not quote variable references. 407285612Sdelphijdouble_quote_subst='s/\(["`\\]\)/\\\1/g' 408181834Sroberto 409285612Sdelphij# Sed substitution that turns a string into a regex matching for the 410285612Sdelphij# string literally. 411285612Sdelphijsed_make_literal_regex='s,[].[^$\\*\/],\\&,g' 412181834Sroberto 413285612Sdelphij# Sed substitution that converts a w32 file name or path 414285612Sdelphij# which contains forward slashes, into one that contains 415285612Sdelphij# (escaped) backslashes. A very naive implementation. 416285612Sdelphijlt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 417181834Sroberto 418285612Sdelphij# Re-`\' parameter expansions in output of double_quote_subst that were 419285612Sdelphij# `\'-ed in input to the same. If an odd number of `\' preceded a '$' 420285612Sdelphij# in input to double_quote_subst, that '$' was protected from expansion. 421285612Sdelphij# Since each input `\' is now two `\'s, look for any number of runs of 422285612Sdelphij# four `\'s followed by two `\'s and then a '$'. `\' that '$'. 423285612Sdelphijbs='\\' 424285612Sdelphijbs2='\\\\' 425285612Sdelphijbs4='\\\\\\\\' 426285612Sdelphijdollar='\$' 427285612Sdelphijsed_double_backslash="\ 428285612Sdelphij s/$bs4/&\\ 429285612Sdelphij/g 430285612Sdelphij s/^$bs2$dollar/$bs&/ 431285612Sdelphij s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g 432285612Sdelphij s/\n//g" 433181834Sroberto 434285612Sdelphij# Standard options: 435285612Sdelphijopt_dry_run=false 436285612Sdelphijopt_help=false 437285612Sdelphijopt_quiet=false 438285612Sdelphijopt_verbose=false 439285612Sdelphijopt_warning=: 440181834Sroberto 441285612Sdelphij# func_echo arg... 442285612Sdelphij# Echo program name prefixed message, along with the current mode 443285612Sdelphij# name if it has been set yet. 444285612Sdelphijfunc_echo () 445285612Sdelphij{ 446285612Sdelphij $ECHO "$progname: ${opt_mode+$opt_mode: }$*" 447285612Sdelphij} 448285612Sdelphij 449285612Sdelphij# func_verbose arg... 450285612Sdelphij# Echo program name prefixed message in verbose mode only. 451285612Sdelphijfunc_verbose () 452285612Sdelphij{ 453285612Sdelphij $opt_verbose && func_echo ${1+"$@"} 454285612Sdelphij 455285612Sdelphij # A bug in bash halts the script if the last line of a function 456285612Sdelphij # fails when set -e is in force, so we need another command to 457285612Sdelphij # work around that: 458285612Sdelphij : 459285612Sdelphij} 460285612Sdelphij 461285612Sdelphij# func_echo_all arg... 462285612Sdelphij# Invoke $ECHO with all args, space-separated. 463285612Sdelphijfunc_echo_all () 464285612Sdelphij{ 465285612Sdelphij $ECHO "$*" 466285612Sdelphij} 467285612Sdelphij 468285612Sdelphij# func_error arg... 469285612Sdelphij# Echo program name prefixed message to standard error. 470285612Sdelphijfunc_error () 471285612Sdelphij{ 472285612Sdelphij $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2 473285612Sdelphij} 474285612Sdelphij 475285612Sdelphij# func_warning arg... 476285612Sdelphij# Echo program name prefixed warning message to standard error. 477285612Sdelphijfunc_warning () 478285612Sdelphij{ 479285612Sdelphij $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2 480285612Sdelphij 481285612Sdelphij # bash bug again: 482285612Sdelphij : 483285612Sdelphij} 484285612Sdelphij 485285612Sdelphij# func_fatal_error arg... 486285612Sdelphij# Echo program name prefixed message to standard error, and exit. 487285612Sdelphijfunc_fatal_error () 488285612Sdelphij{ 489285612Sdelphij func_error ${1+"$@"} 490285612Sdelphij exit $EXIT_FAILURE 491285612Sdelphij} 492285612Sdelphij 493285612Sdelphij# func_fatal_help arg... 494285612Sdelphij# Echo program name prefixed message to standard error, followed by 495285612Sdelphij# a help hint, and exit. 496285612Sdelphijfunc_fatal_help () 497285612Sdelphij{ 498285612Sdelphij func_error ${1+"$@"} 499285612Sdelphij func_fatal_error "$help" 500285612Sdelphij} 501285612Sdelphijhelp="Try \`$progname --help' for more information." ## default 502285612Sdelphij 503285612Sdelphij 504285612Sdelphij# func_grep expression filename 505285612Sdelphij# Check whether EXPRESSION matches any line of FILENAME, without output. 506285612Sdelphijfunc_grep () 507285612Sdelphij{ 508285612Sdelphij $GREP "$1" "$2" >/dev/null 2>&1 509285612Sdelphij} 510285612Sdelphij 511285612Sdelphij 512285612Sdelphij# func_mkdir_p directory-path 513285612Sdelphij# Make sure the entire path to DIRECTORY-PATH is available. 514285612Sdelphijfunc_mkdir_p () 515285612Sdelphij{ 516285612Sdelphij my_directory_path="$1" 517285612Sdelphij my_dir_list= 518285612Sdelphij 519285612Sdelphij if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then 520285612Sdelphij 521285612Sdelphij # Protect directory names starting with `-' 522285612Sdelphij case $my_directory_path in 523285612Sdelphij -*) my_directory_path="./$my_directory_path" ;; 524285612Sdelphij esac 525285612Sdelphij 526285612Sdelphij # While some portion of DIR does not yet exist... 527285612Sdelphij while test ! -d "$my_directory_path"; do 528285612Sdelphij # ...make a list in topmost first order. Use a colon delimited 529285612Sdelphij # list incase some portion of path contains whitespace. 530285612Sdelphij my_dir_list="$my_directory_path:$my_dir_list" 531285612Sdelphij 532285612Sdelphij # If the last portion added has no slash in it, the list is done 533285612Sdelphij case $my_directory_path in */*) ;; *) break ;; esac 534285612Sdelphij 535285612Sdelphij # ...otherwise throw away the child directory and loop 536285612Sdelphij my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"` 537285612Sdelphij done 538285612Sdelphij my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'` 539285612Sdelphij 540285612Sdelphij save_mkdir_p_IFS="$IFS"; IFS=':' 541285612Sdelphij for my_dir in $my_dir_list; do 542285612Sdelphij IFS="$save_mkdir_p_IFS" 543285612Sdelphij # mkdir can fail with a `File exist' error if two processes 544285612Sdelphij # try to create one of the directories concurrently. Don't 545285612Sdelphij # stop in that case! 546285612Sdelphij $MKDIR "$my_dir" 2>/dev/null || : 547285612Sdelphij done 548285612Sdelphij IFS="$save_mkdir_p_IFS" 549285612Sdelphij 550285612Sdelphij # Bail out if we (or some other process) failed to create a directory. 551285612Sdelphij test -d "$my_directory_path" || \ 552285612Sdelphij func_fatal_error "Failed to create \`$1'" 553285612Sdelphij fi 554285612Sdelphij} 555285612Sdelphij 556285612Sdelphij 557181834Sroberto# func_mktempdir [string] 558181834Sroberto# Make a temporary directory that won't clash with other running 559181834Sroberto# libtool processes, and avoids race conditions if possible. If 560181834Sroberto# given, STRING is the basename for that directory. 561181834Srobertofunc_mktempdir () 562181834Sroberto{ 563181834Sroberto my_template="${TMPDIR-/tmp}/${1-$progname}" 564181834Sroberto 565285612Sdelphij if test "$opt_dry_run" = ":"; then 566181834Sroberto # Return a directory name, but don't create it in dry-run mode 567181834Sroberto my_tmpdir="${my_template}-$$" 568181834Sroberto else 569181834Sroberto 570181834Sroberto # If mktemp works, use that first and foremost 571181834Sroberto my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null` 572181834Sroberto 573181834Sroberto if test ! -d "$my_tmpdir"; then 574285612Sdelphij # Failing that, at least try and use $RANDOM to avoid a race 575285612Sdelphij my_tmpdir="${my_template}-${RANDOM-0}$$" 576181834Sroberto 577285612Sdelphij save_mktempdir_umask=`umask` 578285612Sdelphij umask 0077 579285612Sdelphij $MKDIR "$my_tmpdir" 580285612Sdelphij umask $save_mktempdir_umask 581181834Sroberto fi 582181834Sroberto 583181834Sroberto # If we're not in dry-run mode, bomb out on failure 584285612Sdelphij test -d "$my_tmpdir" || \ 585285612Sdelphij func_fatal_error "cannot create temporary directory \`$my_tmpdir'" 586181834Sroberto fi 587181834Sroberto 588285612Sdelphij $ECHO "$my_tmpdir" 589181834Sroberto} 590181834Sroberto 591181834Sroberto 592285612Sdelphij# func_quote_for_eval arg 593285612Sdelphij# Aesthetically quote ARG to be evaled later. 594285612Sdelphij# This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT 595285612Sdelphij# is double-quoted, suitable for a subsequent eval, whereas 596285612Sdelphij# FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters 597285612Sdelphij# which are still active within double quotes backslashified. 598285612Sdelphijfunc_quote_for_eval () 599181834Sroberto{ 600285612Sdelphij case $1 in 601285612Sdelphij *[\\\`\"\$]*) 602285612Sdelphij func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;; 603285612Sdelphij *) 604285612Sdelphij func_quote_for_eval_unquoted_result="$1" ;; 605285612Sdelphij esac 606285612Sdelphij 607285612Sdelphij case $func_quote_for_eval_unquoted_result in 608285612Sdelphij # Double-quote args containing shell metacharacters to delay 609285612Sdelphij # word splitting, command substitution and and variable 610285612Sdelphij # expansion for a subsequent eval. 611285612Sdelphij # Many Bourne shells cannot handle close brackets correctly 612285612Sdelphij # in scan sets, so we specify it separately. 613285612Sdelphij *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 614285612Sdelphij func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\"" 615285612Sdelphij ;; 616285612Sdelphij *) 617285612Sdelphij func_quote_for_eval_result="$func_quote_for_eval_unquoted_result" 618285612Sdelphij esac 619285612Sdelphij} 620285612Sdelphij 621285612Sdelphij 622285612Sdelphij# func_quote_for_expand arg 623285612Sdelphij# Aesthetically quote ARG to be evaled later; same as above, 624285612Sdelphij# but do not quote variable references. 625285612Sdelphijfunc_quote_for_expand () 626285612Sdelphij{ 627285612Sdelphij case $1 in 628285612Sdelphij *[\\\`\"]*) 629285612Sdelphij my_arg=`$ECHO "$1" | $SED \ 630285612Sdelphij -e "$double_quote_subst" -e "$sed_double_backslash"` ;; 631285612Sdelphij *) 632285612Sdelphij my_arg="$1" ;; 633285612Sdelphij esac 634285612Sdelphij 635285612Sdelphij case $my_arg in 636285612Sdelphij # Double-quote args containing shell metacharacters to delay 637285612Sdelphij # word splitting and command substitution for a subsequent eval. 638285612Sdelphij # Many Bourne shells cannot handle close brackets correctly 639285612Sdelphij # in scan sets, so we specify it separately. 640285612Sdelphij *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 641285612Sdelphij my_arg="\"$my_arg\"" 642285612Sdelphij ;; 643285612Sdelphij esac 644285612Sdelphij 645285612Sdelphij func_quote_for_expand_result="$my_arg" 646285612Sdelphij} 647285612Sdelphij 648285612Sdelphij 649285612Sdelphij# func_show_eval cmd [fail_exp] 650285612Sdelphij# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 651285612Sdelphij# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 652285612Sdelphij# is given, then evaluate it. 653285612Sdelphijfunc_show_eval () 654285612Sdelphij{ 655285612Sdelphij my_cmd="$1" 656285612Sdelphij my_fail_exp="${2-:}" 657285612Sdelphij 658285612Sdelphij ${opt_silent-false} || { 659285612Sdelphij func_quote_for_expand "$my_cmd" 660285612Sdelphij eval "func_echo $func_quote_for_expand_result" 661285612Sdelphij } 662285612Sdelphij 663285612Sdelphij if ${opt_dry_run-false}; then :; else 664285612Sdelphij eval "$my_cmd" 665285612Sdelphij my_status=$? 666285612Sdelphij if test "$my_status" -eq 0; then :; else 667285612Sdelphij eval "(exit $my_status); $my_fail_exp" 668285612Sdelphij fi 669181834Sroberto fi 670285612Sdelphij} 671285612Sdelphij 672285612Sdelphij 673285612Sdelphij# func_show_eval_locale cmd [fail_exp] 674285612Sdelphij# Unless opt_silent is true, then output CMD. Then, if opt_dryrun is 675285612Sdelphij# not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 676285612Sdelphij# is given, then evaluate it. Use the saved locale for evaluation. 677285612Sdelphijfunc_show_eval_locale () 678285612Sdelphij{ 679285612Sdelphij my_cmd="$1" 680285612Sdelphij my_fail_exp="${2-:}" 681285612Sdelphij 682285612Sdelphij ${opt_silent-false} || { 683285612Sdelphij func_quote_for_expand "$my_cmd" 684285612Sdelphij eval "func_echo $func_quote_for_expand_result" 685285612Sdelphij } 686285612Sdelphij 687285612Sdelphij if ${opt_dry_run-false}; then :; else 688285612Sdelphij eval "$lt_user_locale 689285612Sdelphij $my_cmd" 690285612Sdelphij my_status=$? 691285612Sdelphij eval "$lt_safe_locale" 692285612Sdelphij if test "$my_status" -eq 0; then :; else 693285612Sdelphij eval "(exit $my_status); $my_fail_exp" 694285612Sdelphij fi 695285612Sdelphij fi 696285612Sdelphij} 697285612Sdelphij 698285612Sdelphij# func_tr_sh 699285612Sdelphij# Turn $1 into a string suitable for a shell variable name. 700285612Sdelphij# Result is stored in $func_tr_sh_result. All characters 701285612Sdelphij# not in the set a-zA-Z0-9_ are replaced with '_'. Further, 702285612Sdelphij# if $1 begins with a digit, a '_' is prepended as well. 703285612Sdelphijfunc_tr_sh () 704285612Sdelphij{ 705285612Sdelphij case $1 in 706285612Sdelphij [0-9]* | *[!a-zA-Z0-9_]*) 707285612Sdelphij func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'` 708181834Sroberto ;; 709285612Sdelphij * ) 710285612Sdelphij func_tr_sh_result=$1 711181834Sroberto ;; 712285612Sdelphij esac 713285612Sdelphij} 714285612Sdelphij 715285612Sdelphij 716285612Sdelphij# func_version 717285612Sdelphij# Echo version message to standard output and exit. 718285612Sdelphijfunc_version () 719285612Sdelphij{ 720285612Sdelphij $opt_debug 721285612Sdelphij 722285612Sdelphij $SED -n '/(C)/!b go 723285612Sdelphij :more 724285612Sdelphij /\./!{ 725285612Sdelphij N 726285612Sdelphij s/\n# / / 727285612Sdelphij b more 728285612Sdelphij } 729285612Sdelphij :go 730285612Sdelphij /^# '$PROGRAM' (GNU /,/# warranty; / { 731285612Sdelphij s/^# // 732285612Sdelphij s/^# *$// 733285612Sdelphij s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/ 734285612Sdelphij p 735285612Sdelphij }' < "$progpath" 736285612Sdelphij exit $? 737285612Sdelphij} 738285612Sdelphij 739285612Sdelphij# func_usage 740285612Sdelphij# Echo short help message to standard output and exit. 741285612Sdelphijfunc_usage () 742285612Sdelphij{ 743285612Sdelphij $opt_debug 744285612Sdelphij 745285612Sdelphij $SED -n '/^# Usage:/,/^# *.*--help/ { 746285612Sdelphij s/^# // 747285612Sdelphij s/^# *$// 748285612Sdelphij s/\$progname/'$progname'/ 749285612Sdelphij p 750285612Sdelphij }' < "$progpath" 751285612Sdelphij echo 752285612Sdelphij $ECHO "run \`$progname --help | more' for full usage" 753285612Sdelphij exit $? 754285612Sdelphij} 755285612Sdelphij 756285612Sdelphij# func_help [NOEXIT] 757285612Sdelphij# Echo long help message to standard output and exit, 758285612Sdelphij# unless 'noexit' is passed as argument. 759285612Sdelphijfunc_help () 760285612Sdelphij{ 761285612Sdelphij $opt_debug 762285612Sdelphij 763285612Sdelphij $SED -n '/^# Usage:/,/# Report bugs to/ { 764285612Sdelphij :print 765285612Sdelphij s/^# // 766285612Sdelphij s/^# *$// 767285612Sdelphij s*\$progname*'$progname'* 768285612Sdelphij s*\$host*'"$host"'* 769285612Sdelphij s*\$SHELL*'"$SHELL"'* 770285612Sdelphij s*\$LTCC*'"$LTCC"'* 771285612Sdelphij s*\$LTCFLAGS*'"$LTCFLAGS"'* 772285612Sdelphij s*\$LD*'"$LD"'* 773285612Sdelphij s/\$with_gnu_ld/'"$with_gnu_ld"'/ 774285612Sdelphij s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/ 775285612Sdelphij s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/ 776285612Sdelphij p 777285612Sdelphij d 778285612Sdelphij } 779285612Sdelphij /^# .* home page:/b print 780285612Sdelphij /^# General help using/b print 781285612Sdelphij ' < "$progpath" 782285612Sdelphij ret=$? 783285612Sdelphij if test -z "$1"; then 784285612Sdelphij exit $ret 785285612Sdelphij fi 786285612Sdelphij} 787285612Sdelphij 788285612Sdelphij# func_missing_arg argname 789285612Sdelphij# Echo program name prefixed message to standard error and set global 790285612Sdelphij# exit_cmd. 791285612Sdelphijfunc_missing_arg () 792285612Sdelphij{ 793285612Sdelphij $opt_debug 794285612Sdelphij 795285612Sdelphij func_error "missing argument for $1." 796285612Sdelphij exit_cmd=exit 797285612Sdelphij} 798285612Sdelphij 799285612Sdelphij 800285612Sdelphij# func_split_short_opt shortopt 801285612Sdelphij# Set func_split_short_opt_name and func_split_short_opt_arg shell 802285612Sdelphij# variables after splitting SHORTOPT after the 2nd character. 803285612Sdelphijfunc_split_short_opt () 804285612Sdelphij{ 805285612Sdelphij my_sed_short_opt='1s/^\(..\).*$/\1/;q' 806285612Sdelphij my_sed_short_rest='1s/^..\(.*\)$/\1/;q' 807285612Sdelphij 808285612Sdelphij func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"` 809285612Sdelphij func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"` 810285612Sdelphij} # func_split_short_opt may be replaced by extended shell implementation 811285612Sdelphij 812285612Sdelphij 813285612Sdelphij# func_split_long_opt longopt 814285612Sdelphij# Set func_split_long_opt_name and func_split_long_opt_arg shell 815285612Sdelphij# variables after splitting LONGOPT at the `=' sign. 816285612Sdelphijfunc_split_long_opt () 817285612Sdelphij{ 818285612Sdelphij my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q' 819285612Sdelphij my_sed_long_arg='1s/^--[^=]*=//' 820285612Sdelphij 821285612Sdelphij func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"` 822285612Sdelphij func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"` 823285612Sdelphij} # func_split_long_opt may be replaced by extended shell implementation 824285612Sdelphij 825285612Sdelphijexit_cmd=: 826285612Sdelphij 827285612Sdelphij 828285612Sdelphij 829285612Sdelphij 830285612Sdelphij 831285612Sdelphijmagic="%%%MAGIC variable%%%" 832285612Sdelphijmagic_exe="%%%MAGIC EXE variable%%%" 833285612Sdelphij 834285612Sdelphij# Global variables. 835285612Sdelphijnonopt= 836285612Sdelphijpreserve_args= 837285612Sdelphijlo2o="s/\\.lo\$/.${objext}/" 838285612Sdelphijo2lo="s/\\.${objext}\$/.lo/" 839285612Sdelphijextracted_archives= 840285612Sdelphijextracted_serial=0 841285612Sdelphij 842285612Sdelphij# If this variable is set in any of the actions, the command in it 843285612Sdelphij# will be execed at the end. This prevents here-documents from being 844285612Sdelphij# left over by shells. 845285612Sdelphijexec_cmd= 846285612Sdelphij 847285612Sdelphij# func_append var value 848285612Sdelphij# Append VALUE to the end of shell variable VAR. 849285612Sdelphijfunc_append () 850285612Sdelphij{ 851285612Sdelphij eval "${1}=\$${1}\${2}" 852285612Sdelphij} # func_append may be replaced by extended shell implementation 853285612Sdelphij 854285612Sdelphij# func_append_quoted var value 855285612Sdelphij# Quote VALUE and append to the end of shell variable VAR, separated 856285612Sdelphij# by a space. 857285612Sdelphijfunc_append_quoted () 858285612Sdelphij{ 859285612Sdelphij func_quote_for_eval "${2}" 860285612Sdelphij eval "${1}=\$${1}\\ \$func_quote_for_eval_result" 861285612Sdelphij} # func_append_quoted may be replaced by extended shell implementation 862285612Sdelphij 863285612Sdelphij 864285612Sdelphij# func_arith arithmetic-term... 865285612Sdelphijfunc_arith () 866285612Sdelphij{ 867285612Sdelphij func_arith_result=`expr "${@}"` 868285612Sdelphij} # func_arith may be replaced by extended shell implementation 869285612Sdelphij 870285612Sdelphij 871285612Sdelphij# func_len string 872285612Sdelphij# STRING may not start with a hyphen. 873285612Sdelphijfunc_len () 874285612Sdelphij{ 875285612Sdelphij func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len` 876285612Sdelphij} # func_len may be replaced by extended shell implementation 877285612Sdelphij 878285612Sdelphij 879285612Sdelphij# func_lo2o object 880285612Sdelphijfunc_lo2o () 881285612Sdelphij{ 882285612Sdelphij func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"` 883285612Sdelphij} # func_lo2o may be replaced by extended shell implementation 884285612Sdelphij 885285612Sdelphij 886285612Sdelphij# func_xform libobj-or-source 887285612Sdelphijfunc_xform () 888285612Sdelphij{ 889285612Sdelphij func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'` 890285612Sdelphij} # func_xform may be replaced by extended shell implementation 891285612Sdelphij 892285612Sdelphij 893285612Sdelphij# func_fatal_configuration arg... 894285612Sdelphij# Echo program name prefixed message to standard error, followed by 895285612Sdelphij# a configuration failure hint, and exit. 896285612Sdelphijfunc_fatal_configuration () 897285612Sdelphij{ 898285612Sdelphij func_error ${1+"$@"} 899285612Sdelphij func_error "See the $PACKAGE documentation for more information." 900285612Sdelphij func_fatal_error "Fatal configuration error." 901285612Sdelphij} 902285612Sdelphij 903285612Sdelphij 904285612Sdelphij# func_config 905285612Sdelphij# Display the configuration for all the tags in this script. 906285612Sdelphijfunc_config () 907285612Sdelphij{ 908285612Sdelphij re_begincf='^# ### BEGIN LIBTOOL' 909285612Sdelphij re_endcf='^# ### END LIBTOOL' 910285612Sdelphij 911285612Sdelphij # Default configuration. 912285612Sdelphij $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 913285612Sdelphij 914285612Sdelphij # Now print the configurations for the tags. 915285612Sdelphij for tagname in $taglist; do 916285612Sdelphij $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 917285612Sdelphij done 918285612Sdelphij 919285612Sdelphij exit $? 920285612Sdelphij} 921285612Sdelphij 922285612Sdelphij# func_features 923285612Sdelphij# Display the features supported by this script. 924285612Sdelphijfunc_features () 925285612Sdelphij{ 926285612Sdelphij echo "host: $host" 927285612Sdelphij if test "$build_libtool_libs" = yes; then 928285612Sdelphij echo "enable shared libraries" 929285612Sdelphij else 930285612Sdelphij echo "disable shared libraries" 931285612Sdelphij fi 932285612Sdelphij if test "$build_old_libs" = yes; then 933285612Sdelphij echo "enable static libraries" 934285612Sdelphij else 935285612Sdelphij echo "disable static libraries" 936285612Sdelphij fi 937285612Sdelphij 938285612Sdelphij exit $? 939285612Sdelphij} 940285612Sdelphij 941285612Sdelphij# func_enable_tag tagname 942285612Sdelphij# Verify that TAGNAME is valid, and either flag an error and exit, or 943285612Sdelphij# enable the TAGNAME tag. We also add TAGNAME to the global $taglist 944285612Sdelphij# variable here. 945285612Sdelphijfunc_enable_tag () 946285612Sdelphij{ 947285612Sdelphij # Global variable: 948285612Sdelphij tagname="$1" 949285612Sdelphij 950285612Sdelphij re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 951285612Sdelphij re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 952285612Sdelphij sed_extractcf="/$re_begincf/,/$re_endcf/p" 953285612Sdelphij 954285612Sdelphij # Validate tagname. 955285612Sdelphij case $tagname in 956285612Sdelphij *[!-_A-Za-z0-9,/]*) 957285612Sdelphij func_fatal_error "invalid tag name: $tagname" 958181834Sroberto ;; 959285612Sdelphij esac 960285612Sdelphij 961285612Sdelphij # Don't test for the "default" C tag, as we know it's 962285612Sdelphij # there but not specially marked. 963285612Sdelphij case $tagname in 964285612Sdelphij CC) ;; 965285612Sdelphij *) 966285612Sdelphij if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 967285612Sdelphij taglist="$taglist $tagname" 968285612Sdelphij 969285612Sdelphij # Evaluate the configuration. Be careful to quote the path 970285612Sdelphij # and the sed script, to avoid splitting on whitespace, but 971285612Sdelphij # also don't use non-portable quotes within backquotes within 972285612Sdelphij # quotes we have to do it in 2 steps: 973285612Sdelphij extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 974285612Sdelphij eval "$extractedcf" 975285612Sdelphij else 976285612Sdelphij func_error "ignoring unknown tag $tagname" 977285612Sdelphij fi 978285612Sdelphij ;; 979285612Sdelphij esac 980285612Sdelphij} 981285612Sdelphij 982285612Sdelphij# func_check_version_match 983285612Sdelphij# Ensure that we are using m4 macros, and libtool script from the same 984285612Sdelphij# release of libtool. 985285612Sdelphijfunc_check_version_match () 986285612Sdelphij{ 987285612Sdelphij if test "$package_revision" != "$macro_revision"; then 988285612Sdelphij if test "$VERSION" != "$macro_version"; then 989285612Sdelphij if test -z "$macro_version"; then 990285612Sdelphij cat >&2 <<_LT_EOF 991285612Sdelphij$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 992285612Sdelphij$progname: definition of this LT_INIT comes from an older release. 993285612Sdelphij$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 994285612Sdelphij$progname: and run autoconf again. 995285612Sdelphij_LT_EOF 996285612Sdelphij else 997285612Sdelphij cat >&2 <<_LT_EOF 998285612Sdelphij$progname: Version mismatch error. This is $PACKAGE $VERSION, but the 999285612Sdelphij$progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 1000285612Sdelphij$progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 1001285612Sdelphij$progname: and run autoconf again. 1002285612Sdelphij_LT_EOF 1003285612Sdelphij fi 1004285612Sdelphij else 1005285612Sdelphij cat >&2 <<_LT_EOF 1006285612Sdelphij$progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 1007285612Sdelphij$progname: but the definition of this LT_INIT comes from revision $macro_revision. 1008285612Sdelphij$progname: You should recreate aclocal.m4 with macros from revision $package_revision 1009285612Sdelphij$progname: of $PACKAGE $VERSION and run autoconf again. 1010285612Sdelphij_LT_EOF 1011285612Sdelphij fi 1012285612Sdelphij 1013285612Sdelphij exit $EXIT_MISMATCH 1014285612Sdelphij fi 1015285612Sdelphij} 1016285612Sdelphij 1017285612Sdelphij 1018285612Sdelphij# Shorthand for --mode=foo, only valid as the first argument 1019285612Sdelphijcase $1 in 1020285612Sdelphijclean|clea|cle|cl) 1021285612Sdelphij shift; set dummy --mode clean ${1+"$@"}; shift 1022285612Sdelphij ;; 1023285612Sdelphijcompile|compil|compi|comp|com|co|c) 1024285612Sdelphij shift; set dummy --mode compile ${1+"$@"}; shift 1025285612Sdelphij ;; 1026285612Sdelphijexecute|execut|execu|exec|exe|ex|e) 1027285612Sdelphij shift; set dummy --mode execute ${1+"$@"}; shift 1028285612Sdelphij ;; 1029285612Sdelphijfinish|finis|fini|fin|fi|f) 1030285612Sdelphij shift; set dummy --mode finish ${1+"$@"}; shift 1031285612Sdelphij ;; 1032285612Sdelphijinstall|instal|insta|inst|ins|in|i) 1033285612Sdelphij shift; set dummy --mode install ${1+"$@"}; shift 1034285612Sdelphij ;; 1035285612Sdelphijlink|lin|li|l) 1036285612Sdelphij shift; set dummy --mode link ${1+"$@"}; shift 1037285612Sdelphij ;; 1038285612Sdelphijuninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 1039285612Sdelphij shift; set dummy --mode uninstall ${1+"$@"}; shift 1040285612Sdelphij ;; 1041285612Sdelphijesac 1042285612Sdelphij 1043285612Sdelphij 1044285612Sdelphij 1045285612Sdelphij# Option defaults: 1046285612Sdelphijopt_debug=: 1047285612Sdelphijopt_dry_run=false 1048285612Sdelphijopt_config=false 1049285612Sdelphijopt_preserve_dup_deps=false 1050285612Sdelphijopt_features=false 1051285612Sdelphijopt_finish=false 1052285612Sdelphijopt_help=false 1053285612Sdelphijopt_help_all=false 1054285612Sdelphijopt_silent=: 1055285612Sdelphijopt_verbose=: 1056285612Sdelphijopt_silent=false 1057285612Sdelphijopt_verbose=false 1058285612Sdelphij 1059285612Sdelphij 1060285612Sdelphij# Parse options once, thoroughly. This comes as soon as possible in the 1061285612Sdelphij# script to make things like `--version' happen as quickly as we can. 1062285612Sdelphij{ 1063285612Sdelphij # this just eases exit handling 1064285612Sdelphij while test $# -gt 0; do 1065285612Sdelphij opt="$1" 1066285612Sdelphij shift 1067285612Sdelphij case $opt in 1068285612Sdelphij --debug|-x) opt_debug='set -x' 1069285612Sdelphij func_echo "enabling shell trace mode" 1070285612Sdelphij $opt_debug 1071285612Sdelphij ;; 1072285612Sdelphij --dry-run|--dryrun|-n) 1073285612Sdelphij opt_dry_run=: 1074285612Sdelphij ;; 1075285612Sdelphij --config) 1076285612Sdelphij opt_config=: 1077285612Sdelphijfunc_config 1078285612Sdelphij ;; 1079285612Sdelphij --dlopen|-dlopen) 1080285612Sdelphij optarg="$1" 1081285612Sdelphij opt_dlopen="${opt_dlopen+$opt_dlopen 1082285612Sdelphij}$optarg" 1083285612Sdelphij shift 1084285612Sdelphij ;; 1085285612Sdelphij --preserve-dup-deps) 1086285612Sdelphij opt_preserve_dup_deps=: 1087285612Sdelphij ;; 1088285612Sdelphij --features) 1089285612Sdelphij opt_features=: 1090285612Sdelphijfunc_features 1091285612Sdelphij ;; 1092285612Sdelphij --finish) 1093285612Sdelphij opt_finish=: 1094285612Sdelphijset dummy --mode finish ${1+"$@"}; shift 1095285612Sdelphij ;; 1096285612Sdelphij --help) 1097285612Sdelphij opt_help=: 1098285612Sdelphij ;; 1099285612Sdelphij --help-all) 1100285612Sdelphij opt_help_all=: 1101285612Sdelphijopt_help=': help-all' 1102285612Sdelphij ;; 1103285612Sdelphij --mode) 1104285612Sdelphij test $# = 0 && func_missing_arg $opt && break 1105285612Sdelphij optarg="$1" 1106285612Sdelphij opt_mode="$optarg" 1107285612Sdelphijcase $optarg in 1108285612Sdelphij # Valid mode arguments: 1109285612Sdelphij clean|compile|execute|finish|install|link|relink|uninstall) ;; 1110285612Sdelphij 1111285612Sdelphij # Catch anything else as an error 1112285612Sdelphij *) func_error "invalid argument for $opt" 1113285612Sdelphij exit_cmd=exit 1114285612Sdelphij break 1115285612Sdelphij ;; 1116285612Sdelphijesac 1117285612Sdelphij shift 1118285612Sdelphij ;; 1119285612Sdelphij --no-silent|--no-quiet) 1120285612Sdelphij opt_silent=false 1121285612Sdelphijfunc_append preserve_args " $opt" 1122285612Sdelphij ;; 1123285612Sdelphij --no-verbose) 1124285612Sdelphij opt_verbose=false 1125285612Sdelphijfunc_append preserve_args " $opt" 1126285612Sdelphij ;; 1127285612Sdelphij --silent|--quiet) 1128285612Sdelphij opt_silent=: 1129285612Sdelphijfunc_append preserve_args " $opt" 1130285612Sdelphij opt_verbose=false 1131285612Sdelphij ;; 1132285612Sdelphij --verbose|-v) 1133285612Sdelphij opt_verbose=: 1134285612Sdelphijfunc_append preserve_args " $opt" 1135285612Sdelphijopt_silent=false 1136285612Sdelphij ;; 1137285612Sdelphij --tag) 1138285612Sdelphij test $# = 0 && func_missing_arg $opt && break 1139285612Sdelphij optarg="$1" 1140285612Sdelphij opt_tag="$optarg" 1141285612Sdelphijfunc_append preserve_args " $opt $optarg" 1142285612Sdelphijfunc_enable_tag "$optarg" 1143285612Sdelphij shift 1144285612Sdelphij ;; 1145285612Sdelphij 1146285612Sdelphij -\?|-h) func_usage ;; 1147285612Sdelphij --help) func_help ;; 1148285612Sdelphij --version) func_version ;; 1149285612Sdelphij 1150285612Sdelphij # Separate optargs to long options: 1151285612Sdelphij --*=*) 1152285612Sdelphij func_split_long_opt "$opt" 1153285612Sdelphij set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"} 1154285612Sdelphij shift 1155285612Sdelphij ;; 1156285612Sdelphij 1157285612Sdelphij # Separate non-argument short options: 1158285612Sdelphij -\?*|-h*|-n*|-v*) 1159285612Sdelphij func_split_short_opt "$opt" 1160285612Sdelphij set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"} 1161285612Sdelphij shift 1162285612Sdelphij ;; 1163285612Sdelphij 1164285612Sdelphij --) break ;; 1165285612Sdelphij -*) func_fatal_help "unrecognized option \`$opt'" ;; 1166285612Sdelphij *) set dummy "$opt" ${1+"$@"}; shift; break ;; 1167181834Sroberto esac 1168285612Sdelphij done 1169285612Sdelphij 1170285612Sdelphij # Validate options: 1171285612Sdelphij 1172285612Sdelphij # save first non-option argument 1173285612Sdelphij if test "$#" -gt 0; then 1174285612Sdelphij nonopt="$opt" 1175285612Sdelphij shift 1176285612Sdelphij fi 1177285612Sdelphij 1178285612Sdelphij # preserve --debug 1179285612Sdelphij test "$opt_debug" = : || func_append preserve_args " --debug" 1180285612Sdelphij 1181285612Sdelphij case $host in 1182285612Sdelphij *cygwin* | *mingw* | *pw32* | *cegcc*) 1183285612Sdelphij # don't eliminate duplications in $postdeps and $predeps 1184285612Sdelphij opt_duplicate_compiler_generated_deps=: 1185285612Sdelphij ;; 1186285612Sdelphij *) 1187285612Sdelphij opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 1188285612Sdelphij ;; 1189285612Sdelphij esac 1190285612Sdelphij 1191285612Sdelphij $opt_help || { 1192285612Sdelphij # Sanity checks first: 1193285612Sdelphij func_check_version_match 1194285612Sdelphij 1195285612Sdelphij if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then 1196285612Sdelphij func_fatal_configuration "not configured to build any kind of library" 1197285612Sdelphij fi 1198285612Sdelphij 1199285612Sdelphij # Darwin sucks 1200285612Sdelphij eval std_shrext=\"$shrext_cmds\" 1201285612Sdelphij 1202285612Sdelphij # Only execute mode is allowed to have -dlopen flags. 1203285612Sdelphij if test -n "$opt_dlopen" && test "$opt_mode" != execute; then 1204285612Sdelphij func_error "unrecognized option \`-dlopen'" 1205285612Sdelphij $ECHO "$help" 1>&2 1206285612Sdelphij exit $EXIT_FAILURE 1207285612Sdelphij fi 1208285612Sdelphij 1209285612Sdelphij # Change the help message to a mode-specific one. 1210285612Sdelphij generic_help="$help" 1211285612Sdelphij help="Try \`$progname --help --mode=$opt_mode' for more information." 1212285612Sdelphij } 1213285612Sdelphij 1214285612Sdelphij 1215285612Sdelphij # Bail if the options were screwed 1216285612Sdelphij $exit_cmd $EXIT_FAILURE 1217285612Sdelphij} 1218285612Sdelphij 1219285612Sdelphij 1220285612Sdelphij 1221285612Sdelphij 1222285612Sdelphij## ----------- ## 1223285612Sdelphij## Main. ## 1224285612Sdelphij## ----------- ## 1225285612Sdelphij 1226285612Sdelphij# func_lalib_p file 1227285612Sdelphij# True iff FILE is a libtool `.la' library or `.lo' object file. 1228285612Sdelphij# This function is only a basic sanity check; it will hardly flush out 1229285612Sdelphij# determined imposters. 1230285612Sdelphijfunc_lalib_p () 1231285612Sdelphij{ 1232285612Sdelphij test -f "$1" && 1233285612Sdelphij $SED -e 4q "$1" 2>/dev/null \ 1234285612Sdelphij | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 1235285612Sdelphij} 1236285612Sdelphij 1237285612Sdelphij# func_lalib_unsafe_p file 1238285612Sdelphij# True iff FILE is a libtool `.la' library or `.lo' object file. 1239285612Sdelphij# This function implements the same check as func_lalib_p without 1240285612Sdelphij# resorting to external programs. To this end, it redirects stdin and 1241285612Sdelphij# closes it afterwards, without saving the original file descriptor. 1242285612Sdelphij# As a safety measure, use it only where a negative result would be 1243285612Sdelphij# fatal anyway. Works if `file' does not exist. 1244285612Sdelphijfunc_lalib_unsafe_p () 1245285612Sdelphij{ 1246285612Sdelphij lalib_p=no 1247285612Sdelphij if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 1248285612Sdelphij for lalib_p_l in 1 2 3 4 1249285612Sdelphij do 1250285612Sdelphij read lalib_p_line 1251285612Sdelphij case "$lalib_p_line" in 1252285612Sdelphij \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 1253285612Sdelphij esac 1254285612Sdelphij done 1255285612Sdelphij exec 0<&5 5<&- 1256285612Sdelphij fi 1257285612Sdelphij test "$lalib_p" = yes 1258285612Sdelphij} 1259285612Sdelphij 1260285612Sdelphij# func_ltwrapper_script_p file 1261285612Sdelphij# True iff FILE is a libtool wrapper script 1262285612Sdelphij# This function is only a basic sanity check; it will hardly flush out 1263285612Sdelphij# determined imposters. 1264285612Sdelphijfunc_ltwrapper_script_p () 1265285612Sdelphij{ 1266285612Sdelphij func_lalib_p "$1" 1267285612Sdelphij} 1268285612Sdelphij 1269285612Sdelphij# func_ltwrapper_executable_p file 1270285612Sdelphij# True iff FILE is a libtool wrapper executable 1271285612Sdelphij# This function is only a basic sanity check; it will hardly flush out 1272285612Sdelphij# determined imposters. 1273285612Sdelphijfunc_ltwrapper_executable_p () 1274285612Sdelphij{ 1275285612Sdelphij func_ltwrapper_exec_suffix= 1276285612Sdelphij case $1 in 1277285612Sdelphij *.exe) ;; 1278285612Sdelphij *) func_ltwrapper_exec_suffix=.exe ;; 1279285612Sdelphij esac 1280285612Sdelphij $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 1281285612Sdelphij} 1282285612Sdelphij 1283285612Sdelphij# func_ltwrapper_scriptname file 1284285612Sdelphij# Assumes file is an ltwrapper_executable 1285285612Sdelphij# uses $file to determine the appropriate filename for a 1286285612Sdelphij# temporary ltwrapper_script. 1287285612Sdelphijfunc_ltwrapper_scriptname () 1288285612Sdelphij{ 1289285612Sdelphij func_dirname_and_basename "$1" "" "." 1290285612Sdelphij func_stripname '' '.exe' "$func_basename_result" 1291285612Sdelphij func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper" 1292285612Sdelphij} 1293285612Sdelphij 1294285612Sdelphij# func_ltwrapper_p file 1295285612Sdelphij# True iff FILE is a libtool wrapper script or wrapper executable 1296285612Sdelphij# This function is only a basic sanity check; it will hardly flush out 1297285612Sdelphij# determined imposters. 1298285612Sdelphijfunc_ltwrapper_p () 1299285612Sdelphij{ 1300285612Sdelphij func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 1301285612Sdelphij} 1302285612Sdelphij 1303285612Sdelphij 1304285612Sdelphij# func_execute_cmds commands fail_cmd 1305285612Sdelphij# Execute tilde-delimited COMMANDS. 1306285612Sdelphij# If FAIL_CMD is given, eval that upon failure. 1307285612Sdelphij# FAIL_CMD may read-access the current command in variable CMD! 1308285612Sdelphijfunc_execute_cmds () 1309285612Sdelphij{ 1310285612Sdelphij $opt_debug 1311285612Sdelphij save_ifs=$IFS; IFS='~' 1312285612Sdelphij for cmd in $1; do 1313285612Sdelphij IFS=$save_ifs 1314285612Sdelphij eval cmd=\"$cmd\" 1315285612Sdelphij func_show_eval "$cmd" "${2-:}" 1316285612Sdelphij done 1317285612Sdelphij IFS=$save_ifs 1318285612Sdelphij} 1319285612Sdelphij 1320285612Sdelphij 1321285612Sdelphij# func_source file 1322285612Sdelphij# Source FILE, adding directory component if necessary. 1323285612Sdelphij# Note that it is not necessary on cygwin/mingw to append a dot to 1324285612Sdelphij# FILE even if both FILE and FILE.exe exist: automatic-append-.exe 1325285612Sdelphij# behavior happens only for exec(3), not for open(2)! Also, sourcing 1326285612Sdelphij# `FILE.' does not work on cygwin managed mounts. 1327285612Sdelphijfunc_source () 1328285612Sdelphij{ 1329285612Sdelphij $opt_debug 1330285612Sdelphij case $1 in 1331285612Sdelphij */* | *\\*) . "$1" ;; 1332285612Sdelphij *) . "./$1" ;; 1333285612Sdelphij esac 1334285612Sdelphij} 1335285612Sdelphij 1336285612Sdelphij 1337285612Sdelphij# func_resolve_sysroot PATH 1338285612Sdelphij# Replace a leading = in PATH with a sysroot. Store the result into 1339285612Sdelphij# func_resolve_sysroot_result 1340285612Sdelphijfunc_resolve_sysroot () 1341285612Sdelphij{ 1342285612Sdelphij func_resolve_sysroot_result=$1 1343285612Sdelphij case $func_resolve_sysroot_result in 1344285612Sdelphij =*) 1345285612Sdelphij func_stripname '=' '' "$func_resolve_sysroot_result" 1346285612Sdelphij func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 1347181834Sroberto ;; 1348181834Sroberto esac 1349181834Sroberto} 1350181834Sroberto 1351285612Sdelphij# func_replace_sysroot PATH 1352285612Sdelphij# If PATH begins with the sysroot, replace it with = and 1353285612Sdelphij# store the result into func_replace_sysroot_result. 1354285612Sdelphijfunc_replace_sysroot () 1355285612Sdelphij{ 1356285612Sdelphij case "$lt_sysroot:$1" in 1357285612Sdelphij ?*:"$lt_sysroot"*) 1358285612Sdelphij func_stripname "$lt_sysroot" '' "$1" 1359285612Sdelphij func_replace_sysroot_result="=$func_stripname_result" 1360285612Sdelphij ;; 1361285612Sdelphij *) 1362285612Sdelphij # Including no sysroot. 1363285612Sdelphij func_replace_sysroot_result=$1 1364285612Sdelphij ;; 1365285612Sdelphij esac 1366285612Sdelphij} 1367181834Sroberto 1368181834Sroberto# func_infer_tag arg 1369181834Sroberto# Infer tagged configuration to use if any are available and 1370181834Sroberto# if one wasn't chosen via the "--tag" command line option. 1371181834Sroberto# Only attempt this if the compiler in the base compile 1372181834Sroberto# command doesn't match the default compiler. 1373181834Sroberto# arg is usually of the form 'gcc ...' 1374181834Srobertofunc_infer_tag () 1375181834Sroberto{ 1376285612Sdelphij $opt_debug 1377181834Sroberto if test -n "$available_tags" && test -z "$tagname"; then 1378181834Sroberto CC_quoted= 1379181834Sroberto for arg in $CC; do 1380285612Sdelphij func_append_quoted CC_quoted "$arg" 1381181834Sroberto done 1382285612Sdelphij CC_expanded=`func_echo_all $CC` 1383285612Sdelphij CC_quoted_expanded=`func_echo_all $CC_quoted` 1384181834Sroberto case $@ in 1385181834Sroberto # Blanks in the command may have been stripped by the calling shell, 1386181834Sroberto # but not from the CC environment variable when configure was run. 1387285612Sdelphij " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1388285612Sdelphij " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 1389181834Sroberto # Blanks at the start of $base_compile will cause this to fail 1390181834Sroberto # if we don't check for them as well. 1391181834Sroberto *) 1392181834Sroberto for z in $available_tags; do 1393285612Sdelphij if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 1394181834Sroberto # Evaluate the configuration. 1395181834Sroberto eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 1396181834Sroberto CC_quoted= 1397181834Sroberto for arg in $CC; do 1398285612Sdelphij # Double-quote args containing other shell metacharacters. 1399285612Sdelphij func_append_quoted CC_quoted "$arg" 1400285612Sdelphij done 1401285612Sdelphij CC_expanded=`func_echo_all $CC` 1402285612Sdelphij CC_quoted_expanded=`func_echo_all $CC_quoted` 1403181834Sroberto case "$@ " in 1404285612Sdelphij " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 1405285612Sdelphij " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 1406181834Sroberto # The compiler in the base compile command matches 1407181834Sroberto # the one in the tagged configuration. 1408181834Sroberto # Assume this is the tagged configuration we want. 1409181834Sroberto tagname=$z 1410181834Sroberto break 1411181834Sroberto ;; 1412181834Sroberto esac 1413181834Sroberto fi 1414181834Sroberto done 1415181834Sroberto # If $tagname still isn't set, then no tagged configuration 1416181834Sroberto # was found and let the user know that the "--tag" command 1417181834Sroberto # line option must be used. 1418181834Sroberto if test -z "$tagname"; then 1419285612Sdelphij func_echo "unable to infer tagged configuration" 1420285612Sdelphij func_fatal_error "specify a tag with \`--tag'" 1421285612Sdelphij# else 1422285612Sdelphij# func_verbose "using $tagname tagged configuration" 1423181834Sroberto fi 1424181834Sroberto ;; 1425181834Sroberto esac 1426181834Sroberto fi 1427181834Sroberto} 1428181834Sroberto 1429181834Sroberto 1430285612Sdelphij 1431285612Sdelphij# func_write_libtool_object output_name pic_name nonpic_name 1432285612Sdelphij# Create a libtool object file (analogous to a ".la" file), 1433285612Sdelphij# but don't create it if we're doing a dry run. 1434285612Sdelphijfunc_write_libtool_object () 1435181834Sroberto{ 1436285612Sdelphij write_libobj=${1} 1437285612Sdelphij if test "$build_libtool_libs" = yes; then 1438285612Sdelphij write_lobj=\'${2}\' 1439285612Sdelphij else 1440285612Sdelphij write_lobj=none 1441285612Sdelphij fi 1442181834Sroberto 1443285612Sdelphij if test "$build_old_libs" = yes; then 1444285612Sdelphij write_oldobj=\'${3}\' 1445181834Sroberto else 1446285612Sdelphij write_oldobj=none 1447181834Sroberto fi 1448285612Sdelphij 1449285612Sdelphij $opt_dry_run || { 1450285612Sdelphij cat >${write_libobj}T <<EOF 1451285612Sdelphij# $write_libobj - a libtool object file 1452285612Sdelphij# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 1453285612Sdelphij# 1454285612Sdelphij# Please DO NOT delete this file! 1455285612Sdelphij# It is necessary for linking the library. 1456285612Sdelphij 1457285612Sdelphij# Name of the PIC object. 1458285612Sdelphijpic_object=$write_lobj 1459285612Sdelphij 1460285612Sdelphij# Name of the non-PIC object 1461285612Sdelphijnon_pic_object=$write_oldobj 1462285612Sdelphij 1463285612SdelphijEOF 1464285612Sdelphij $MV "${write_libobj}T" "${write_libobj}" 1465285612Sdelphij } 1466181834Sroberto} 1467181834Sroberto 1468285612Sdelphij 1469285612Sdelphij################################################## 1470285612Sdelphij# FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 1471285612Sdelphij################################################## 1472285612Sdelphij 1473285612Sdelphij# func_convert_core_file_wine_to_w32 ARG 1474285612Sdelphij# Helper function used by file name conversion functions when $build is *nix, 1475285612Sdelphij# and $host is mingw, cygwin, or some other w32 environment. Relies on a 1476285612Sdelphij# correctly configured wine environment available, with the winepath program 1477285612Sdelphij# in $build's $PATH. 1478285612Sdelphij# 1479285612Sdelphij# ARG is the $build file name to be converted to w32 format. 1480285612Sdelphij# Result is available in $func_convert_core_file_wine_to_w32_result, and will 1481285612Sdelphij# be empty on error (or when ARG is empty) 1482285612Sdelphijfunc_convert_core_file_wine_to_w32 () 1483181834Sroberto{ 1484285612Sdelphij $opt_debug 1485285612Sdelphij func_convert_core_file_wine_to_w32_result="$1" 1486285612Sdelphij if test -n "$1"; then 1487285612Sdelphij # Unfortunately, winepath does not exit with a non-zero error code, so we 1488285612Sdelphij # are forced to check the contents of stdout. On the other hand, if the 1489285612Sdelphij # command is not found, the shell will set an exit code of 127 and print 1490285612Sdelphij # *an error message* to stdout. So we must check for both error code of 1491285612Sdelphij # zero AND non-empty stdout, which explains the odd construction: 1492285612Sdelphij func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 1493285612Sdelphij if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then 1494285612Sdelphij func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 1495285612Sdelphij $SED -e "$lt_sed_naive_backslashify"` 1496285612Sdelphij else 1497285612Sdelphij func_convert_core_file_wine_to_w32_result= 1498181834Sroberto fi 1499285612Sdelphij fi 1500285612Sdelphij} 1501285612Sdelphij# end: func_convert_core_file_wine_to_w32 1502181834Sroberto 1503181834Sroberto 1504285612Sdelphij# func_convert_core_path_wine_to_w32 ARG 1505285612Sdelphij# Helper function used by path conversion functions when $build is *nix, and 1506285612Sdelphij# $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 1507285612Sdelphij# configured wine environment available, with the winepath program in $build's 1508285612Sdelphij# $PATH. Assumes ARG has no leading or trailing path separator characters. 1509285612Sdelphij# 1510285612Sdelphij# ARG is path to be converted from $build format to win32. 1511285612Sdelphij# Result is available in $func_convert_core_path_wine_to_w32_result. 1512285612Sdelphij# Unconvertible file (directory) names in ARG are skipped; if no directory names 1513285612Sdelphij# are convertible, then the result may be empty. 1514285612Sdelphijfunc_convert_core_path_wine_to_w32 () 1515285612Sdelphij{ 1516285612Sdelphij $opt_debug 1517285612Sdelphij # unfortunately, winepath doesn't convert paths, only file names 1518285612Sdelphij func_convert_core_path_wine_to_w32_result="" 1519285612Sdelphij if test -n "$1"; then 1520285612Sdelphij oldIFS=$IFS 1521285612Sdelphij IFS=: 1522285612Sdelphij for func_convert_core_path_wine_to_w32_f in $1; do 1523285612Sdelphij IFS=$oldIFS 1524285612Sdelphij func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 1525285612Sdelphij if test -n "$func_convert_core_file_wine_to_w32_result" ; then 1526285612Sdelphij if test -z "$func_convert_core_path_wine_to_w32_result"; then 1527285612Sdelphij func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result" 1528285612Sdelphij else 1529285612Sdelphij func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 1530285612Sdelphij fi 1531181834Sroberto fi 1532181834Sroberto done 1533285612Sdelphij IFS=$oldIFS 1534285612Sdelphij fi 1535181834Sroberto} 1536285612Sdelphij# end: func_convert_core_path_wine_to_w32 1537181834Sroberto 1538181834Sroberto 1539285612Sdelphij# func_cygpath ARGS... 1540285612Sdelphij# Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 1541285612Sdelphij# when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 1542285612Sdelphij# $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 1543285612Sdelphij# (2), returns the Cygwin file name or path in func_cygpath_result (input 1544285612Sdelphij# file name or path is assumed to be in w32 format, as previously converted 1545285612Sdelphij# from $build's *nix or MSYS format). In case (3), returns the w32 file name 1546285612Sdelphij# or path in func_cygpath_result (input file name or path is assumed to be in 1547285612Sdelphij# Cygwin format). Returns an empty string on error. 1548285612Sdelphij# 1549285612Sdelphij# ARGS are passed to cygpath, with the last one being the file name or path to 1550285612Sdelphij# be converted. 1551285612Sdelphij# 1552285612Sdelphij# Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 1553285612Sdelphij# environment variable; do not put it in $PATH. 1554285612Sdelphijfunc_cygpath () 1555285612Sdelphij{ 1556285612Sdelphij $opt_debug 1557285612Sdelphij if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 1558285612Sdelphij func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 1559285612Sdelphij if test "$?" -ne 0; then 1560285612Sdelphij # on failure, ensure result is empty 1561285612Sdelphij func_cygpath_result= 1562285612Sdelphij fi 1563285612Sdelphij else 1564285612Sdelphij func_cygpath_result= 1565285612Sdelphij func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'" 1566285612Sdelphij fi 1567285612Sdelphij} 1568285612Sdelphij#end: func_cygpath 1569181834Sroberto 1570181834Sroberto 1571285612Sdelphij# func_convert_core_msys_to_w32 ARG 1572285612Sdelphij# Convert file name or path ARG from MSYS format to w32 format. Return 1573285612Sdelphij# result in func_convert_core_msys_to_w32_result. 1574285612Sdelphijfunc_convert_core_msys_to_w32 () 1575285612Sdelphij{ 1576285612Sdelphij $opt_debug 1577285612Sdelphij # awkward: cmd appends spaces to result 1578285612Sdelphij func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 1579285612Sdelphij $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"` 1580285612Sdelphij} 1581285612Sdelphij#end: func_convert_core_msys_to_w32 1582285612Sdelphij 1583285612Sdelphij 1584285612Sdelphij# func_convert_file_check ARG1 ARG2 1585285612Sdelphij# Verify that ARG1 (a file name in $build format) was converted to $host 1586285612Sdelphij# format in ARG2. Otherwise, emit an error message, but continue (resetting 1587285612Sdelphij# func_to_host_file_result to ARG1). 1588285612Sdelphijfunc_convert_file_check () 1589285612Sdelphij{ 1590285612Sdelphij $opt_debug 1591285612Sdelphij if test -z "$2" && test -n "$1" ; then 1592285612Sdelphij func_error "Could not determine host file name corresponding to" 1593285612Sdelphij func_error " \`$1'" 1594285612Sdelphij func_error "Continuing, but uninstalled executables may not work." 1595285612Sdelphij # Fallback: 1596285612Sdelphij func_to_host_file_result="$1" 1597285612Sdelphij fi 1598285612Sdelphij} 1599285612Sdelphij# end func_convert_file_check 1600285612Sdelphij 1601285612Sdelphij 1602285612Sdelphij# func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 1603285612Sdelphij# Verify that FROM_PATH (a path in $build format) was converted to $host 1604285612Sdelphij# format in TO_PATH. Otherwise, emit an error message, but continue, resetting 1605285612Sdelphij# func_to_host_file_result to a simplistic fallback value (see below). 1606285612Sdelphijfunc_convert_path_check () 1607285612Sdelphij{ 1608285612Sdelphij $opt_debug 1609285612Sdelphij if test -z "$4" && test -n "$3"; then 1610285612Sdelphij func_error "Could not determine the host path corresponding to" 1611285612Sdelphij func_error " \`$3'" 1612285612Sdelphij func_error "Continuing, but uninstalled executables may not work." 1613285612Sdelphij # Fallback. This is a deliberately simplistic "conversion" and 1614285612Sdelphij # should not be "improved". See libtool.info. 1615285612Sdelphij if test "x$1" != "x$2"; then 1616285612Sdelphij lt_replace_pathsep_chars="s|$1|$2|g" 1617285612Sdelphij func_to_host_path_result=`echo "$3" | 1618285612Sdelphij $SED -e "$lt_replace_pathsep_chars"` 1619285612Sdelphij else 1620285612Sdelphij func_to_host_path_result="$3" 1621285612Sdelphij fi 1622285612Sdelphij fi 1623285612Sdelphij} 1624285612Sdelphij# end func_convert_path_check 1625285612Sdelphij 1626285612Sdelphij 1627285612Sdelphij# func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 1628285612Sdelphij# Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 1629285612Sdelphij# and appending REPL if ORIG matches BACKPAT. 1630285612Sdelphijfunc_convert_path_front_back_pathsep () 1631285612Sdelphij{ 1632285612Sdelphij $opt_debug 1633285612Sdelphij case $4 in 1634285612Sdelphij $1 ) func_to_host_path_result="$3$func_to_host_path_result" 1635285612Sdelphij ;; 1636181834Sroberto esac 1637285612Sdelphij case $4 in 1638285612Sdelphij $2 ) func_append func_to_host_path_result "$3" 1639285612Sdelphij ;; 1640285612Sdelphij esac 1641285612Sdelphij} 1642285612Sdelphij# end func_convert_path_front_back_pathsep 1643181834Sroberto 1644181834Sroberto 1645285612Sdelphij################################################## 1646285612Sdelphij# $build to $host FILE NAME CONVERSION FUNCTIONS # 1647285612Sdelphij################################################## 1648285612Sdelphij# invoked via `$to_host_file_cmd ARG' 1649285612Sdelphij# 1650285612Sdelphij# In each case, ARG is the path to be converted from $build to $host format. 1651285612Sdelphij# Result will be available in $func_to_host_file_result. 1652181834Sroberto 1653285612Sdelphij 1654285612Sdelphij# func_to_host_file ARG 1655285612Sdelphij# Converts the file name ARG from $build format to $host format. Return result 1656285612Sdelphij# in func_to_host_file_result. 1657285612Sdelphijfunc_to_host_file () 1658285612Sdelphij{ 1659285612Sdelphij $opt_debug 1660285612Sdelphij $to_host_file_cmd "$1" 1661285612Sdelphij} 1662285612Sdelphij# end func_to_host_file 1663285612Sdelphij 1664285612Sdelphij 1665285612Sdelphij# func_to_tool_file ARG LAZY 1666285612Sdelphij# converts the file name ARG from $build format to toolchain format. Return 1667285612Sdelphij# result in func_to_tool_file_result. If the conversion in use is listed 1668285612Sdelphij# in (the comma separated) LAZY, no conversion takes place. 1669285612Sdelphijfunc_to_tool_file () 1670285612Sdelphij{ 1671285612Sdelphij $opt_debug 1672285612Sdelphij case ,$2, in 1673285612Sdelphij *,"$to_tool_file_cmd",*) 1674285612Sdelphij func_to_tool_file_result=$1 1675181834Sroberto ;; 1676181834Sroberto *) 1677285612Sdelphij $to_tool_file_cmd "$1" 1678285612Sdelphij func_to_tool_file_result=$func_to_host_file_result 1679181834Sroberto ;; 1680285612Sdelphij esac 1681285612Sdelphij} 1682285612Sdelphij# end func_to_tool_file 1683181834Sroberto 1684285612Sdelphij 1685285612Sdelphij# func_convert_file_noop ARG 1686285612Sdelphij# Copy ARG to func_to_host_file_result. 1687285612Sdelphijfunc_convert_file_noop () 1688285612Sdelphij{ 1689285612Sdelphij func_to_host_file_result="$1" 1690285612Sdelphij} 1691285612Sdelphij# end func_convert_file_noop 1692285612Sdelphij 1693285612Sdelphij 1694285612Sdelphij# func_convert_file_msys_to_w32 ARG 1695285612Sdelphij# Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 1696285612Sdelphij# conversion to w32 is not available inside the cwrapper. Returns result in 1697285612Sdelphij# func_to_host_file_result. 1698285612Sdelphijfunc_convert_file_msys_to_w32 () 1699285612Sdelphij{ 1700285612Sdelphij $opt_debug 1701285612Sdelphij func_to_host_file_result="$1" 1702285612Sdelphij if test -n "$1"; then 1703285612Sdelphij func_convert_core_msys_to_w32 "$1" 1704285612Sdelphij func_to_host_file_result="$func_convert_core_msys_to_w32_result" 1705181834Sroberto fi 1706285612Sdelphij func_convert_file_check "$1" "$func_to_host_file_result" 1707285612Sdelphij} 1708285612Sdelphij# end func_convert_file_msys_to_w32 1709181834Sroberto 1710181834Sroberto 1711285612Sdelphij# func_convert_file_cygwin_to_w32 ARG 1712285612Sdelphij# Convert file name ARG from Cygwin to w32 format. Returns result in 1713285612Sdelphij# func_to_host_file_result. 1714285612Sdelphijfunc_convert_file_cygwin_to_w32 () 1715285612Sdelphij{ 1716285612Sdelphij $opt_debug 1717285612Sdelphij func_to_host_file_result="$1" 1718285612Sdelphij if test -n "$1"; then 1719285612Sdelphij # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 1720285612Sdelphij # LT_CYGPATH in this case. 1721285612Sdelphij func_to_host_file_result=`cygpath -m "$1"` 1722285612Sdelphij fi 1723285612Sdelphij func_convert_file_check "$1" "$func_to_host_file_result" 1724285612Sdelphij} 1725285612Sdelphij# end func_convert_file_cygwin_to_w32 1726181834Sroberto 1727181834Sroberto 1728285612Sdelphij# func_convert_file_nix_to_w32 ARG 1729285612Sdelphij# Convert file name ARG from *nix to w32 format. Requires a wine environment 1730285612Sdelphij# and a working winepath. Returns result in func_to_host_file_result. 1731285612Sdelphijfunc_convert_file_nix_to_w32 () 1732285612Sdelphij{ 1733285612Sdelphij $opt_debug 1734285612Sdelphij func_to_host_file_result="$1" 1735285612Sdelphij if test -n "$1"; then 1736285612Sdelphij func_convert_core_file_wine_to_w32 "$1" 1737285612Sdelphij func_to_host_file_result="$func_convert_core_file_wine_to_w32_result" 1738285612Sdelphij fi 1739285612Sdelphij func_convert_file_check "$1" "$func_to_host_file_result" 1740285612Sdelphij} 1741285612Sdelphij# end func_convert_file_nix_to_w32 1742181834Sroberto 1743181834Sroberto 1744285612Sdelphij# func_convert_file_msys_to_cygwin ARG 1745285612Sdelphij# Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1746285612Sdelphij# Returns result in func_to_host_file_result. 1747285612Sdelphijfunc_convert_file_msys_to_cygwin () 1748285612Sdelphij{ 1749285612Sdelphij $opt_debug 1750285612Sdelphij func_to_host_file_result="$1" 1751285612Sdelphij if test -n "$1"; then 1752285612Sdelphij func_convert_core_msys_to_w32 "$1" 1753285612Sdelphij func_cygpath -u "$func_convert_core_msys_to_w32_result" 1754285612Sdelphij func_to_host_file_result="$func_cygpath_result" 1755285612Sdelphij fi 1756285612Sdelphij func_convert_file_check "$1" "$func_to_host_file_result" 1757285612Sdelphij} 1758285612Sdelphij# end func_convert_file_msys_to_cygwin 1759181834Sroberto 1760181834Sroberto 1761285612Sdelphij# func_convert_file_nix_to_cygwin ARG 1762285612Sdelphij# Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 1763285612Sdelphij# in a wine environment, working winepath, and LT_CYGPATH set. Returns result 1764285612Sdelphij# in func_to_host_file_result. 1765285612Sdelphijfunc_convert_file_nix_to_cygwin () 1766285612Sdelphij{ 1767285612Sdelphij $opt_debug 1768285612Sdelphij func_to_host_file_result="$1" 1769285612Sdelphij if test -n "$1"; then 1770285612Sdelphij # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 1771285612Sdelphij func_convert_core_file_wine_to_w32 "$1" 1772285612Sdelphij func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 1773285612Sdelphij func_to_host_file_result="$func_cygpath_result" 1774285612Sdelphij fi 1775285612Sdelphij func_convert_file_check "$1" "$func_to_host_file_result" 1776285612Sdelphij} 1777285612Sdelphij# end func_convert_file_nix_to_cygwin 1778181834Sroberto 1779181834Sroberto 1780285612Sdelphij############################################# 1781285612Sdelphij# $build to $host PATH CONVERSION FUNCTIONS # 1782285612Sdelphij############################################# 1783285612Sdelphij# invoked via `$to_host_path_cmd ARG' 1784285612Sdelphij# 1785285612Sdelphij# In each case, ARG is the path to be converted from $build to $host format. 1786285612Sdelphij# The result will be available in $func_to_host_path_result. 1787285612Sdelphij# 1788285612Sdelphij# Path separators are also converted from $build format to $host format. If 1789285612Sdelphij# ARG begins or ends with a path separator character, it is preserved (but 1790285612Sdelphij# converted to $host format) on output. 1791285612Sdelphij# 1792285612Sdelphij# All path conversion functions are named using the following convention: 1793285612Sdelphij# file name conversion function : func_convert_file_X_to_Y () 1794285612Sdelphij# path conversion function : func_convert_path_X_to_Y () 1795285612Sdelphij# where, for any given $build/$host combination the 'X_to_Y' value is the 1796285612Sdelphij# same. If conversion functions are added for new $build/$host combinations, 1797285612Sdelphij# the two new functions must follow this pattern, or func_init_to_host_path_cmd 1798285612Sdelphij# will break. 1799181834Sroberto 1800181834Sroberto 1801285612Sdelphij# func_init_to_host_path_cmd 1802285612Sdelphij# Ensures that function "pointer" variable $to_host_path_cmd is set to the 1803285612Sdelphij# appropriate value, based on the value of $to_host_file_cmd. 1804285612Sdelphijto_host_path_cmd= 1805285612Sdelphijfunc_init_to_host_path_cmd () 1806285612Sdelphij{ 1807285612Sdelphij $opt_debug 1808285612Sdelphij if test -z "$to_host_path_cmd"; then 1809285612Sdelphij func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 1810285612Sdelphij to_host_path_cmd="func_convert_path_${func_stripname_result}" 1811285612Sdelphij fi 1812285612Sdelphij} 1813181834Sroberto 1814181834Sroberto 1815285612Sdelphij# func_to_host_path ARG 1816285612Sdelphij# Converts the path ARG from $build format to $host format. Return result 1817285612Sdelphij# in func_to_host_path_result. 1818285612Sdelphijfunc_to_host_path () 1819285612Sdelphij{ 1820285612Sdelphij $opt_debug 1821285612Sdelphij func_init_to_host_path_cmd 1822285612Sdelphij $to_host_path_cmd "$1" 1823285612Sdelphij} 1824285612Sdelphij# end func_to_host_path 1825181834Sroberto 1826181834Sroberto 1827285612Sdelphij# func_convert_path_noop ARG 1828285612Sdelphij# Copy ARG to func_to_host_path_result. 1829285612Sdelphijfunc_convert_path_noop () 1830285612Sdelphij{ 1831285612Sdelphij func_to_host_path_result="$1" 1832285612Sdelphij} 1833285612Sdelphij# end func_convert_path_noop 1834181834Sroberto 1835181834Sroberto 1836285612Sdelphij# func_convert_path_msys_to_w32 ARG 1837285612Sdelphij# Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 1838285612Sdelphij# conversion to w32 is not available inside the cwrapper. Returns result in 1839285612Sdelphij# func_to_host_path_result. 1840285612Sdelphijfunc_convert_path_msys_to_w32 () 1841285612Sdelphij{ 1842285612Sdelphij $opt_debug 1843285612Sdelphij func_to_host_path_result="$1" 1844285612Sdelphij if test -n "$1"; then 1845285612Sdelphij # Remove leading and trailing path separator characters from ARG. MSYS 1846285612Sdelphij # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 1847285612Sdelphij # and winepath ignores them completely. 1848285612Sdelphij func_stripname : : "$1" 1849285612Sdelphij func_to_host_path_tmp1=$func_stripname_result 1850285612Sdelphij func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1851285612Sdelphij func_to_host_path_result="$func_convert_core_msys_to_w32_result" 1852285612Sdelphij func_convert_path_check : ";" \ 1853285612Sdelphij "$func_to_host_path_tmp1" "$func_to_host_path_result" 1854285612Sdelphij func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1855285612Sdelphij fi 1856285612Sdelphij} 1857285612Sdelphij# end func_convert_path_msys_to_w32 1858181834Sroberto 1859181834Sroberto 1860285612Sdelphij# func_convert_path_cygwin_to_w32 ARG 1861285612Sdelphij# Convert path ARG from Cygwin to w32 format. Returns result in 1862285612Sdelphij# func_to_host_file_result. 1863285612Sdelphijfunc_convert_path_cygwin_to_w32 () 1864285612Sdelphij{ 1865285612Sdelphij $opt_debug 1866285612Sdelphij func_to_host_path_result="$1" 1867285612Sdelphij if test -n "$1"; then 1868285612Sdelphij # See func_convert_path_msys_to_w32: 1869285612Sdelphij func_stripname : : "$1" 1870285612Sdelphij func_to_host_path_tmp1=$func_stripname_result 1871285612Sdelphij func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 1872285612Sdelphij func_convert_path_check : ";" \ 1873285612Sdelphij "$func_to_host_path_tmp1" "$func_to_host_path_result" 1874285612Sdelphij func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1875181834Sroberto fi 1876285612Sdelphij} 1877285612Sdelphij# end func_convert_path_cygwin_to_w32 1878181834Sroberto 1879285612Sdelphij 1880285612Sdelphij# func_convert_path_nix_to_w32 ARG 1881285612Sdelphij# Convert path ARG from *nix to w32 format. Requires a wine environment and 1882285612Sdelphij# a working winepath. Returns result in func_to_host_file_result. 1883285612Sdelphijfunc_convert_path_nix_to_w32 () 1884285612Sdelphij{ 1885285612Sdelphij $opt_debug 1886285612Sdelphij func_to_host_path_result="$1" 1887285612Sdelphij if test -n "$1"; then 1888285612Sdelphij # See func_convert_path_msys_to_w32: 1889285612Sdelphij func_stripname : : "$1" 1890285612Sdelphij func_to_host_path_tmp1=$func_stripname_result 1891285612Sdelphij func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1892285612Sdelphij func_to_host_path_result="$func_convert_core_path_wine_to_w32_result" 1893285612Sdelphij func_convert_path_check : ";" \ 1894285612Sdelphij "$func_to_host_path_tmp1" "$func_to_host_path_result" 1895285612Sdelphij func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 1896181834Sroberto fi 1897285612Sdelphij} 1898285612Sdelphij# end func_convert_path_nix_to_w32 1899181834Sroberto 1900181834Sroberto 1901285612Sdelphij# func_convert_path_msys_to_cygwin ARG 1902285612Sdelphij# Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 1903285612Sdelphij# Returns result in func_to_host_file_result. 1904285612Sdelphijfunc_convert_path_msys_to_cygwin () 1905285612Sdelphij{ 1906285612Sdelphij $opt_debug 1907285612Sdelphij func_to_host_path_result="$1" 1908285612Sdelphij if test -n "$1"; then 1909285612Sdelphij # See func_convert_path_msys_to_w32: 1910285612Sdelphij func_stripname : : "$1" 1911285612Sdelphij func_to_host_path_tmp1=$func_stripname_result 1912285612Sdelphij func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 1913285612Sdelphij func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 1914285612Sdelphij func_to_host_path_result="$func_cygpath_result" 1915285612Sdelphij func_convert_path_check : : \ 1916285612Sdelphij "$func_to_host_path_tmp1" "$func_to_host_path_result" 1917285612Sdelphij func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1918285612Sdelphij fi 1919285612Sdelphij} 1920285612Sdelphij# end func_convert_path_msys_to_cygwin 1921285612Sdelphij 1922285612Sdelphij 1923285612Sdelphij# func_convert_path_nix_to_cygwin ARG 1924285612Sdelphij# Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 1925285612Sdelphij# a wine environment, working winepath, and LT_CYGPATH set. Returns result in 1926285612Sdelphij# func_to_host_file_result. 1927285612Sdelphijfunc_convert_path_nix_to_cygwin () 1928285612Sdelphij{ 1929285612Sdelphij $opt_debug 1930285612Sdelphij func_to_host_path_result="$1" 1931285612Sdelphij if test -n "$1"; then 1932285612Sdelphij # Remove leading and trailing path separator characters from 1933285612Sdelphij # ARG. msys behavior is inconsistent here, cygpath turns them 1934285612Sdelphij # into '.;' and ';.', and winepath ignores them completely. 1935285612Sdelphij func_stripname : : "$1" 1936285612Sdelphij func_to_host_path_tmp1=$func_stripname_result 1937285612Sdelphij func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 1938285612Sdelphij func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 1939285612Sdelphij func_to_host_path_result="$func_cygpath_result" 1940285612Sdelphij func_convert_path_check : : \ 1941285612Sdelphij "$func_to_host_path_tmp1" "$func_to_host_path_result" 1942285612Sdelphij func_convert_path_front_back_pathsep ":*" "*:" : "$1" 1943285612Sdelphij fi 1944285612Sdelphij} 1945285612Sdelphij# end func_convert_path_nix_to_cygwin 1946285612Sdelphij 1947285612Sdelphij 1948285612Sdelphij# func_mode_compile arg... 1949285612Sdelphijfunc_mode_compile () 1950285612Sdelphij{ 1951285612Sdelphij $opt_debug 1952181834Sroberto # Get the compilation command and the source file. 1953181834Sroberto base_compile= 1954181834Sroberto srcfile="$nonopt" # always keep a non-empty value in "srcfile" 1955181834Sroberto suppress_opt=yes 1956181834Sroberto suppress_output= 1957181834Sroberto arg_mode=normal 1958181834Sroberto libobj= 1959181834Sroberto later= 1960285612Sdelphij pie_flag= 1961181834Sroberto 1962181834Sroberto for arg 1963181834Sroberto do 1964181834Sroberto case $arg_mode in 1965181834Sroberto arg ) 1966181834Sroberto # do not "continue". Instead, add this to base_compile 1967181834Sroberto lastarg="$arg" 1968181834Sroberto arg_mode=normal 1969181834Sroberto ;; 1970181834Sroberto 1971181834Sroberto target ) 1972181834Sroberto libobj="$arg" 1973181834Sroberto arg_mode=normal 1974181834Sroberto continue 1975181834Sroberto ;; 1976181834Sroberto 1977181834Sroberto normal ) 1978181834Sroberto # Accept any command-line options. 1979181834Sroberto case $arg in 1980181834Sroberto -o) 1981285612Sdelphij test -n "$libobj" && \ 1982285612Sdelphij func_fatal_error "you cannot specify \`-o' more than once" 1983181834Sroberto arg_mode=target 1984181834Sroberto continue 1985181834Sroberto ;; 1986181834Sroberto 1987285612Sdelphij -pie | -fpie | -fPIE) 1988285612Sdelphij func_append pie_flag " $arg" 1989181834Sroberto continue 1990181834Sroberto ;; 1991181834Sroberto 1992285612Sdelphij -shared | -static | -prefer-pic | -prefer-non-pic) 1993285612Sdelphij func_append later " $arg" 1994285612Sdelphij continue 1995285612Sdelphij ;; 1996285612Sdelphij 1997181834Sroberto -no-suppress) 1998181834Sroberto suppress_opt=no 1999181834Sroberto continue 2000181834Sroberto ;; 2001181834Sroberto 2002181834Sroberto -Xcompiler) 2003181834Sroberto arg_mode=arg # the next one goes into the "base_compile" arg list 2004181834Sroberto continue # The current "srcfile" will either be retained or 2005181834Sroberto ;; # replaced later. I would guess that would be a bug. 2006181834Sroberto 2007181834Sroberto -Wc,*) 2008285612Sdelphij func_stripname '-Wc,' '' "$arg" 2009285612Sdelphij args=$func_stripname_result 2010181834Sroberto lastarg= 2011181834Sroberto save_ifs="$IFS"; IFS=',' 2012285612Sdelphij for arg in $args; do 2013181834Sroberto IFS="$save_ifs" 2014285612Sdelphij func_append_quoted lastarg "$arg" 2015181834Sroberto done 2016181834Sroberto IFS="$save_ifs" 2017285612Sdelphij func_stripname ' ' '' "$lastarg" 2018285612Sdelphij lastarg=$func_stripname_result 2019181834Sroberto 2020181834Sroberto # Add the arguments to base_compile. 2021285612Sdelphij func_append base_compile " $lastarg" 2022181834Sroberto continue 2023181834Sroberto ;; 2024181834Sroberto 2025285612Sdelphij *) 2026181834Sroberto # Accept the current argument as the source file. 2027181834Sroberto # The previous "srcfile" becomes the current argument. 2028181834Sroberto # 2029181834Sroberto lastarg="$srcfile" 2030181834Sroberto srcfile="$arg" 2031181834Sroberto ;; 2032181834Sroberto esac # case $arg 2033181834Sroberto ;; 2034181834Sroberto esac # case $arg_mode 2035181834Sroberto 2036181834Sroberto # Aesthetically quote the previous argument. 2037285612Sdelphij func_append_quoted base_compile "$lastarg" 2038181834Sroberto done # for arg 2039181834Sroberto 2040181834Sroberto case $arg_mode in 2041181834Sroberto arg) 2042285612Sdelphij func_fatal_error "you must specify an argument for -Xcompile" 2043181834Sroberto ;; 2044181834Sroberto target) 2045285612Sdelphij func_fatal_error "you must specify a target with \`-o'" 2046181834Sroberto ;; 2047181834Sroberto *) 2048181834Sroberto # Get the name of the library object. 2049285612Sdelphij test -z "$libobj" && { 2050285612Sdelphij func_basename "$srcfile" 2051285612Sdelphij libobj="$func_basename_result" 2052285612Sdelphij } 2053181834Sroberto ;; 2054181834Sroberto esac 2055181834Sroberto 2056181834Sroberto # Recognize several different file suffixes. 2057181834Sroberto # If the user specifies -o file.o, it is replaced with file.lo 2058181834Sroberto case $libobj in 2059285612Sdelphij *.[cCFSifmso] | \ 2060285612Sdelphij *.ada | *.adb | *.ads | *.asm | \ 2061285612Sdelphij *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 2062285612Sdelphij *.[fF][09]? | *.for | *.java | *.obj | *.sx | *.cu | *.cup) 2063285612Sdelphij func_xform "$libobj" 2064285612Sdelphij libobj=$func_xform_result 2065285612Sdelphij ;; 2066181834Sroberto esac 2067181834Sroberto 2068181834Sroberto case $libobj in 2069285612Sdelphij *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 2070181834Sroberto *) 2071285612Sdelphij func_fatal_error "cannot determine name of library object from \`$libobj'" 2072181834Sroberto ;; 2073181834Sroberto esac 2074181834Sroberto 2075181834Sroberto func_infer_tag $base_compile 2076181834Sroberto 2077181834Sroberto for arg in $later; do 2078181834Sroberto case $arg in 2079285612Sdelphij -shared) 2080285612Sdelphij test "$build_libtool_libs" != yes && \ 2081285612Sdelphij func_fatal_configuration "can not build a shared library" 2082285612Sdelphij build_old_libs=no 2083285612Sdelphij continue 2084285612Sdelphij ;; 2085285612Sdelphij 2086181834Sroberto -static) 2087285612Sdelphij build_libtool_libs=no 2088181834Sroberto build_old_libs=yes 2089181834Sroberto continue 2090181834Sroberto ;; 2091181834Sroberto 2092181834Sroberto -prefer-pic) 2093181834Sroberto pic_mode=yes 2094181834Sroberto continue 2095181834Sroberto ;; 2096181834Sroberto 2097181834Sroberto -prefer-non-pic) 2098181834Sroberto pic_mode=no 2099181834Sroberto continue 2100181834Sroberto ;; 2101181834Sroberto esac 2102181834Sroberto done 2103181834Sroberto 2104285612Sdelphij func_quote_for_eval "$libobj" 2105285612Sdelphij test "X$libobj" != "X$func_quote_for_eval_result" \ 2106285612Sdelphij && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 2107285612Sdelphij && func_warning "libobj name \`$libobj' may not contain shell special characters." 2108285612Sdelphij func_dirname_and_basename "$obj" "/" "" 2109285612Sdelphij objname="$func_basename_result" 2110285612Sdelphij xdir="$func_dirname_result" 2111181834Sroberto lobj=${xdir}$objdir/$objname 2112181834Sroberto 2113285612Sdelphij test -z "$base_compile" && \ 2114285612Sdelphij func_fatal_help "you must specify a compilation command" 2115181834Sroberto 2116181834Sroberto # Delete any leftover library objects. 2117181834Sroberto if test "$build_old_libs" = yes; then 2118181834Sroberto removelist="$obj $lobj $libobj ${libobj}T" 2119181834Sroberto else 2120181834Sroberto removelist="$lobj $libobj ${libobj}T" 2121181834Sroberto fi 2122181834Sroberto 2123181834Sroberto # On Cygwin there's no "real" PIC flag so we must build both object types 2124181834Sroberto case $host_os in 2125285612Sdelphij cygwin* | mingw* | pw32* | os2* | cegcc*) 2126181834Sroberto pic_mode=default 2127181834Sroberto ;; 2128181834Sroberto esac 2129181834Sroberto if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then 2130181834Sroberto # non-PIC code in shared libraries is not supported 2131181834Sroberto pic_mode=default 2132181834Sroberto fi 2133181834Sroberto 2134181834Sroberto # Calculate the filename of the output object if compiler does 2135181834Sroberto # not support -o with -c 2136181834Sroberto if test "$compiler_c_o" = no; then 2137285612Sdelphij output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext} 2138181834Sroberto lockfile="$output_obj.lock" 2139181834Sroberto else 2140181834Sroberto output_obj= 2141181834Sroberto need_locks=no 2142181834Sroberto lockfile= 2143181834Sroberto fi 2144181834Sroberto 2145181834Sroberto # Lock this critical section if it is needed 2146181834Sroberto # We use this script file to make the link, it avoids creating a new file 2147181834Sroberto if test "$need_locks" = yes; then 2148285612Sdelphij until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 2149285612Sdelphij func_echo "Waiting for $lockfile to be removed" 2150181834Sroberto sleep 2 2151181834Sroberto done 2152181834Sroberto elif test "$need_locks" = warn; then 2153181834Sroberto if test -f "$lockfile"; then 2154285612Sdelphij $ECHO "\ 2155181834Sroberto*** ERROR, $lockfile exists and contains: 2156181834Sroberto`cat $lockfile 2>/dev/null` 2157181834Sroberto 2158181834SrobertoThis indicates that another process is trying to use the same 2159181834Srobertotemporary object file, and libtool could not work around it because 2160181834Srobertoyour compiler does not support \`-c' and \`-o' together. If you 2161181834Srobertorepeat this compilation, it may succeed, by chance, but you had better 2162181834Srobertoavoid parallel builds (make -j) in this platform, or get a better 2163181834Srobertocompiler." 2164181834Sroberto 2165285612Sdelphij $opt_dry_run || $RM $removelist 2166181834Sroberto exit $EXIT_FAILURE 2167181834Sroberto fi 2168285612Sdelphij func_append removelist " $output_obj" 2169285612Sdelphij $ECHO "$srcfile" > "$lockfile" 2170181834Sroberto fi 2171181834Sroberto 2172285612Sdelphij $opt_dry_run || $RM $removelist 2173285612Sdelphij func_append removelist " $lockfile" 2174285612Sdelphij trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 2175181834Sroberto 2176285612Sdelphij func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 2177285612Sdelphij srcfile=$func_to_tool_file_result 2178285612Sdelphij func_quote_for_eval "$srcfile" 2179285612Sdelphij qsrcfile=$func_quote_for_eval_result 2180181834Sroberto 2181181834Sroberto # Only build a PIC object if we are building libtool libraries. 2182181834Sroberto if test "$build_libtool_libs" = yes; then 2183181834Sroberto # Without this assignment, base_compile gets emptied. 2184181834Sroberto fbsd_hideous_sh_bug=$base_compile 2185181834Sroberto 2186181834Sroberto if test "$pic_mode" != no; then 2187181834Sroberto command="$base_compile $qsrcfile $pic_flag" 2188181834Sroberto else 2189181834Sroberto # Don't build PIC code 2190181834Sroberto command="$base_compile $qsrcfile" 2191181834Sroberto fi 2192181834Sroberto 2193285612Sdelphij func_mkdir_p "$xdir$objdir" 2194181834Sroberto 2195181834Sroberto if test -z "$output_obj"; then 2196181834Sroberto # Place PIC objects in $objdir 2197285612Sdelphij func_append command " -o $lobj" 2198181834Sroberto fi 2199181834Sroberto 2200285612Sdelphij func_show_eval_locale "$command" \ 2201285612Sdelphij 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 2202181834Sroberto 2203181834Sroberto if test "$need_locks" = warn && 2204181834Sroberto test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2205285612Sdelphij $ECHO "\ 2206181834Sroberto*** ERROR, $lockfile contains: 2207181834Sroberto`cat $lockfile 2>/dev/null` 2208181834Sroberto 2209181834Srobertobut it should contain: 2210181834Sroberto$srcfile 2211181834Sroberto 2212181834SrobertoThis indicates that another process is trying to use the same 2213181834Srobertotemporary object file, and libtool could not work around it because 2214181834Srobertoyour compiler does not support \`-c' and \`-o' together. If you 2215181834Srobertorepeat this compilation, it may succeed, by chance, but you had better 2216181834Srobertoavoid parallel builds (make -j) in this platform, or get a better 2217181834Srobertocompiler." 2218181834Sroberto 2219285612Sdelphij $opt_dry_run || $RM $removelist 2220181834Sroberto exit $EXIT_FAILURE 2221181834Sroberto fi 2222181834Sroberto 2223181834Sroberto # Just move the object if needed, then go on to compile the next one 2224181834Sroberto if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 2225285612Sdelphij func_show_eval '$MV "$output_obj" "$lobj"' \ 2226285612Sdelphij 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2227181834Sroberto fi 2228181834Sroberto 2229181834Sroberto # Allow error messages only from the first compilation. 2230181834Sroberto if test "$suppress_opt" = yes; then 2231285612Sdelphij suppress_output=' >/dev/null 2>&1' 2232181834Sroberto fi 2233181834Sroberto fi 2234181834Sroberto 2235181834Sroberto # Only build a position-dependent object if we build old libraries. 2236181834Sroberto if test "$build_old_libs" = yes; then 2237181834Sroberto if test "$pic_mode" != yes; then 2238181834Sroberto # Don't build PIC code 2239285612Sdelphij command="$base_compile $qsrcfile$pie_flag" 2240181834Sroberto else 2241181834Sroberto command="$base_compile $qsrcfile $pic_flag" 2242181834Sroberto fi 2243181834Sroberto if test "$compiler_c_o" = yes; then 2244285612Sdelphij func_append command " -o $obj" 2245181834Sroberto fi 2246181834Sroberto 2247181834Sroberto # Suppress compiler output if we already did a PIC compilation. 2248285612Sdelphij func_append command "$suppress_output" 2249285612Sdelphij func_show_eval_locale "$command" \ 2250285612Sdelphij '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 2251181834Sroberto 2252181834Sroberto if test "$need_locks" = warn && 2253181834Sroberto test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 2254285612Sdelphij $ECHO "\ 2255181834Sroberto*** ERROR, $lockfile contains: 2256181834Sroberto`cat $lockfile 2>/dev/null` 2257181834Sroberto 2258181834Srobertobut it should contain: 2259181834Sroberto$srcfile 2260181834Sroberto 2261181834SrobertoThis indicates that another process is trying to use the same 2262181834Srobertotemporary object file, and libtool could not work around it because 2263181834Srobertoyour compiler does not support \`-c' and \`-o' together. If you 2264181834Srobertorepeat this compilation, it may succeed, by chance, but you had better 2265181834Srobertoavoid parallel builds (make -j) in this platform, or get a better 2266181834Srobertocompiler." 2267181834Sroberto 2268285612Sdelphij $opt_dry_run || $RM $removelist 2269181834Sroberto exit $EXIT_FAILURE 2270181834Sroberto fi 2271181834Sroberto 2272181834Sroberto # Just move the object if needed 2273181834Sroberto if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 2274285612Sdelphij func_show_eval '$MV "$output_obj" "$obj"' \ 2275285612Sdelphij 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 2276285612Sdelphij fi 2277285612Sdelphij fi 2278285612Sdelphij 2279285612Sdelphij $opt_dry_run || { 2280285612Sdelphij func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 2281285612Sdelphij 2282285612Sdelphij # Unlock the critical section if it was locked 2283285612Sdelphij if test "$need_locks" != no; then 2284285612Sdelphij removelist=$lockfile 2285285612Sdelphij $RM "$lockfile" 2286285612Sdelphij fi 2287285612Sdelphij } 2288285612Sdelphij 2289285612Sdelphij exit $EXIT_SUCCESS 2290285612Sdelphij} 2291285612Sdelphij 2292285612Sdelphij$opt_help || { 2293285612Sdelphij test "$opt_mode" = compile && func_mode_compile ${1+"$@"} 2294285612Sdelphij} 2295285612Sdelphij 2296285612Sdelphijfunc_mode_help () 2297285612Sdelphij{ 2298285612Sdelphij # We need to display help for each of the modes. 2299285612Sdelphij case $opt_mode in 2300285612Sdelphij "") 2301285612Sdelphij # Generic help is extracted from the usage comments 2302285612Sdelphij # at the start of this file. 2303285612Sdelphij func_help 2304285612Sdelphij ;; 2305285612Sdelphij 2306285612Sdelphij clean) 2307285612Sdelphij $ECHO \ 2308285612Sdelphij"Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 2309285612Sdelphij 2310285612SdelphijRemove files from the build directory. 2311285612Sdelphij 2312285612SdelphijRM is the name of the program to use to delete files associated with each FILE 2313285612Sdelphij(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2314285612Sdelphijto RM. 2315285612Sdelphij 2316285612SdelphijIf FILE is a libtool library, object or program, all the files associated 2317285612Sdelphijwith it are deleted. Otherwise, only FILE itself is deleted using RM." 2318285612Sdelphij ;; 2319285612Sdelphij 2320285612Sdelphij compile) 2321285612Sdelphij $ECHO \ 2322285612Sdelphij"Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 2323285612Sdelphij 2324285612SdelphijCompile a source file into a libtool library object. 2325285612Sdelphij 2326285612SdelphijThis mode accepts the following additional options: 2327285612Sdelphij 2328285612Sdelphij -o OUTPUT-FILE set the output file name to OUTPUT-FILE 2329285612Sdelphij -no-suppress do not suppress compiler output for multiple passes 2330285612Sdelphij -prefer-pic try to build PIC objects only 2331285612Sdelphij -prefer-non-pic try to build non-PIC objects only 2332285612Sdelphij -shared do not build a \`.o' file suitable for static linking 2333285612Sdelphij -static only build a \`.o' file suitable for static linking 2334285612Sdelphij -Wc,FLAG pass FLAG directly to the compiler 2335285612Sdelphij 2336285612SdelphijCOMPILE-COMMAND is a command to be used in creating a \`standard' object file 2337285612Sdelphijfrom the given SOURCEFILE. 2338285612Sdelphij 2339285612SdelphijThe output file name is determined by removing the directory component from 2340285612SdelphijSOURCEFILE, then substituting the C source code suffix \`.c' with the 2341285612Sdelphijlibrary object suffix, \`.lo'." 2342285612Sdelphij ;; 2343285612Sdelphij 2344285612Sdelphij execute) 2345285612Sdelphij $ECHO \ 2346285612Sdelphij"Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 2347285612Sdelphij 2348285612SdelphijAutomatically set library path, then run a program. 2349285612Sdelphij 2350285612SdelphijThis mode accepts the following additional options: 2351285612Sdelphij 2352285612Sdelphij -dlopen FILE add the directory containing FILE to the library path 2353285612Sdelphij 2354285612SdelphijThis mode sets the library path environment variable according to \`-dlopen' 2355285612Sdelphijflags. 2356285612Sdelphij 2357285612SdelphijIf any of the ARGS are libtool executable wrappers, then they are translated 2358285612Sdelphijinto their corresponding uninstalled binary, and any of their required library 2359285612Sdelphijdirectories are added to the library path. 2360285612Sdelphij 2361285612SdelphijThen, COMMAND is executed, with ARGS as arguments." 2362285612Sdelphij ;; 2363285612Sdelphij 2364285612Sdelphij finish) 2365285612Sdelphij $ECHO \ 2366285612Sdelphij"Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 2367285612Sdelphij 2368285612SdelphijComplete the installation of libtool libraries. 2369285612Sdelphij 2370285612SdelphijEach LIBDIR is a directory that contains libtool libraries. 2371285612Sdelphij 2372285612SdelphijThe commands that this mode executes may require superuser privileges. Use 2373285612Sdelphijthe \`--dry-run' option if you just want to see what would be executed." 2374285612Sdelphij ;; 2375285612Sdelphij 2376285612Sdelphij install) 2377285612Sdelphij $ECHO \ 2378285612Sdelphij"Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 2379285612Sdelphij 2380285612SdelphijInstall executables or libraries. 2381285612Sdelphij 2382285612SdelphijINSTALL-COMMAND is the installation command. The first component should be 2383285612Sdelphijeither the \`install' or \`cp' program. 2384285612Sdelphij 2385285612SdelphijThe following components of INSTALL-COMMAND are treated specially: 2386285612Sdelphij 2387285612Sdelphij -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 2388285612Sdelphij 2389285612SdelphijThe rest of the components are interpreted as arguments to that command (only 2390285612SdelphijBSD-compatible install options are recognized)." 2391285612Sdelphij ;; 2392285612Sdelphij 2393285612Sdelphij link) 2394285612Sdelphij $ECHO \ 2395285612Sdelphij"Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 2396285612Sdelphij 2397285612SdelphijLink object files or libraries together to form another library, or to 2398285612Sdelphijcreate an executable program. 2399285612Sdelphij 2400285612SdelphijLINK-COMMAND is a command using the C compiler that you would use to create 2401285612Sdelphija program from several object files. 2402285612Sdelphij 2403285612SdelphijThe following components of LINK-COMMAND are treated specially: 2404285612Sdelphij 2405285612Sdelphij -all-static do not do any dynamic linking at all 2406285612Sdelphij -avoid-version do not add a version suffix if possible 2407285612Sdelphij -bindir BINDIR specify path to binaries directory (for systems where 2408285612Sdelphij libraries must be found in the PATH setting at runtime) 2409285612Sdelphij -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime 2410285612Sdelphij -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 2411285612Sdelphij -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 2412285612Sdelphij -export-symbols SYMFILE 2413285612Sdelphij try to export only the symbols listed in SYMFILE 2414285612Sdelphij -export-symbols-regex REGEX 2415285612Sdelphij try to export only the symbols matching REGEX 2416285612Sdelphij -LLIBDIR search LIBDIR for required installed libraries 2417285612Sdelphij -lNAME OUTPUT-FILE requires the installed library libNAME 2418285612Sdelphij -module build a library that can dlopened 2419285612Sdelphij -no-fast-install disable the fast-install mode 2420285612Sdelphij -no-install link a not-installable executable 2421285612Sdelphij -no-undefined declare that a library does not refer to external symbols 2422285612Sdelphij -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 2423285612Sdelphij -objectlist FILE Use a list of object files found in FILE to specify objects 2424285612Sdelphij -precious-files-regex REGEX 2425285612Sdelphij don't remove output files matching REGEX 2426285612Sdelphij -release RELEASE specify package release information 2427285612Sdelphij -rpath LIBDIR the created library will eventually be installed in LIBDIR 2428285612Sdelphij -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 2429285612Sdelphij -shared only do dynamic linking of libtool libraries 2430285612Sdelphij -shrext SUFFIX override the standard shared library file extension 2431285612Sdelphij -static do not do any dynamic linking of uninstalled libtool libraries 2432285612Sdelphij -static-libtool-libs 2433285612Sdelphij do not do any dynamic linking of libtool libraries 2434285612Sdelphij -version-info CURRENT[:REVISION[:AGE]] 2435285612Sdelphij specify library version info [each variable defaults to 0] 2436285612Sdelphij -weak LIBNAME declare that the target provides the LIBNAME interface 2437285612Sdelphij -Wc,FLAG 2438285612Sdelphij -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 2439285612Sdelphij -Wl,FLAG 2440285612Sdelphij -Xlinker FLAG pass linker-specific FLAG directly to the linker 2441285612Sdelphij -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 2442285612Sdelphij 2443285612SdelphijAll other options (arguments beginning with \`-') are ignored. 2444285612Sdelphij 2445285612SdelphijEvery other argument is treated as a filename. Files ending in \`.la' are 2446285612Sdelphijtreated as uninstalled libtool libraries, other files are standard or library 2447285612Sdelphijobject files. 2448285612Sdelphij 2449285612SdelphijIf the OUTPUT-FILE ends in \`.la', then a libtool library is created, 2450285612Sdelphijonly library objects (\`.lo' files) may be specified, and \`-rpath' is 2451285612Sdelphijrequired, except when creating a convenience library. 2452285612Sdelphij 2453285612SdelphijIf OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created 2454285612Sdelphijusing \`ar' and \`ranlib', or on Windows using \`lib'. 2455285612Sdelphij 2456285612SdelphijIf OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file 2457285612Sdelphijis created, otherwise an executable program is created." 2458285612Sdelphij ;; 2459285612Sdelphij 2460285612Sdelphij uninstall) 2461285612Sdelphij $ECHO \ 2462285612Sdelphij"Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 2463285612Sdelphij 2464285612SdelphijRemove libraries from an installation directory. 2465285612Sdelphij 2466285612SdelphijRM is the name of the program to use to delete files associated with each FILE 2467285612Sdelphij(typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed 2468285612Sdelphijto RM. 2469285612Sdelphij 2470285612SdelphijIf FILE is a libtool library, all the files associated with it are deleted. 2471285612SdelphijOtherwise, only FILE itself is deleted using RM." 2472285612Sdelphij ;; 2473285612Sdelphij 2474285612Sdelphij *) 2475285612Sdelphij func_fatal_help "invalid operation mode \`$opt_mode'" 2476285612Sdelphij ;; 2477285612Sdelphij esac 2478285612Sdelphij 2479285612Sdelphij echo 2480285612Sdelphij $ECHO "Try \`$progname --help' for more information about other modes." 2481285612Sdelphij} 2482285612Sdelphij 2483285612Sdelphij# Now that we've collected a possible --mode arg, show help if necessary 2484285612Sdelphijif $opt_help; then 2485285612Sdelphij if test "$opt_help" = :; then 2486285612Sdelphij func_mode_help 2487285612Sdelphij else 2488285612Sdelphij { 2489285612Sdelphij func_help noexit 2490285612Sdelphij for opt_mode in compile link execute install finish uninstall clean; do 2491285612Sdelphij func_mode_help 2492285612Sdelphij done 2493285612Sdelphij } | sed -n '1p; 2,$s/^Usage:/ or: /p' 2494285612Sdelphij { 2495285612Sdelphij func_help noexit 2496285612Sdelphij for opt_mode in compile link execute install finish uninstall clean; do 2497285612Sdelphij echo 2498285612Sdelphij func_mode_help 2499285612Sdelphij done 2500285612Sdelphij } | 2501285612Sdelphij sed '1d 2502285612Sdelphij /^When reporting/,/^Report/{ 2503285612Sdelphij H 2504285612Sdelphij d 2505285612Sdelphij } 2506285612Sdelphij $x 2507285612Sdelphij /information about other modes/d 2508285612Sdelphij /more detailed .*MODE/d 2509285612Sdelphij s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 2510285612Sdelphij fi 2511285612Sdelphij exit $? 2512285612Sdelphijfi 2513285612Sdelphij 2514285612Sdelphij 2515285612Sdelphij# func_mode_execute arg... 2516285612Sdelphijfunc_mode_execute () 2517285612Sdelphij{ 2518285612Sdelphij $opt_debug 2519285612Sdelphij # The first argument is the command name. 2520285612Sdelphij cmd="$nonopt" 2521285612Sdelphij test -z "$cmd" && \ 2522285612Sdelphij func_fatal_help "you must specify a COMMAND" 2523285612Sdelphij 2524285612Sdelphij # Handle -dlopen flags immediately. 2525285612Sdelphij for file in $opt_dlopen; do 2526285612Sdelphij test -f "$file" \ 2527285612Sdelphij || func_fatal_help "\`$file' is not a file" 2528285612Sdelphij 2529285612Sdelphij dir= 2530285612Sdelphij case $file in 2531285612Sdelphij *.la) 2532285612Sdelphij func_resolve_sysroot "$file" 2533285612Sdelphij file=$func_resolve_sysroot_result 2534285612Sdelphij 2535285612Sdelphij # Check to see that this really is a libtool archive. 2536285612Sdelphij func_lalib_unsafe_p "$file" \ 2537285612Sdelphij || func_fatal_help "\`$lib' is not a valid libtool archive" 2538285612Sdelphij 2539285612Sdelphij # Read the libtool library. 2540285612Sdelphij dlname= 2541285612Sdelphij library_names= 2542285612Sdelphij func_source "$file" 2543285612Sdelphij 2544285612Sdelphij # Skip this library if it cannot be dlopened. 2545285612Sdelphij if test -z "$dlname"; then 2546285612Sdelphij # Warn if it was a shared library. 2547285612Sdelphij test -n "$library_names" && \ 2548285612Sdelphij func_warning "\`$file' was not linked with \`-export-dynamic'" 2549285612Sdelphij continue 2550285612Sdelphij fi 2551285612Sdelphij 2552285612Sdelphij func_dirname "$file" "" "." 2553285612Sdelphij dir="$func_dirname_result" 2554285612Sdelphij 2555285612Sdelphij if test -f "$dir/$objdir/$dlname"; then 2556285612Sdelphij func_append dir "/$objdir" 2557181834Sroberto else 2558285612Sdelphij if test ! -f "$dir/$dlname"; then 2559285612Sdelphij func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 2560285612Sdelphij fi 2561181834Sroberto fi 2562285612Sdelphij ;; 2563285612Sdelphij 2564285612Sdelphij *.lo) 2565285612Sdelphij # Just add the directory containing the .lo file. 2566285612Sdelphij func_dirname "$file" "" "." 2567285612Sdelphij dir="$func_dirname_result" 2568285612Sdelphij ;; 2569285612Sdelphij 2570285612Sdelphij *) 2571285612Sdelphij func_warning "\`-dlopen' is ignored for non-libtool libraries and objects" 2572285612Sdelphij continue 2573285612Sdelphij ;; 2574285612Sdelphij esac 2575285612Sdelphij 2576285612Sdelphij # Get the absolute pathname. 2577285612Sdelphij absdir=`cd "$dir" && pwd` 2578285612Sdelphij test -n "$absdir" && dir="$absdir" 2579285612Sdelphij 2580285612Sdelphij # Now add the directory to shlibpath_var. 2581285612Sdelphij if eval "test -z \"\$$shlibpath_var\""; then 2582285612Sdelphij eval "$shlibpath_var=\"\$dir\"" 2583285612Sdelphij else 2584285612Sdelphij eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 2585181834Sroberto fi 2586285612Sdelphij done 2587181834Sroberto 2588285612Sdelphij # This variable tells wrapper scripts just to set shlibpath_var 2589285612Sdelphij # rather than running their programs. 2590285612Sdelphij libtool_execute_magic="$magic" 2591181834Sroberto 2592285612Sdelphij # Check if any of the arguments is a wrapper script. 2593285612Sdelphij args= 2594285612Sdelphij for file 2595285612Sdelphij do 2596285612Sdelphij case $file in 2597285612Sdelphij -* | *.la | *.lo ) ;; 2598285612Sdelphij *) 2599285612Sdelphij # Do a test to see if this is really a libtool program. 2600285612Sdelphij if func_ltwrapper_script_p "$file"; then 2601285612Sdelphij func_source "$file" 2602285612Sdelphij # Transform arg to wrapped name. 2603285612Sdelphij file="$progdir/$program" 2604285612Sdelphij elif func_ltwrapper_executable_p "$file"; then 2605285612Sdelphij func_ltwrapper_scriptname "$file" 2606285612Sdelphij func_source "$func_ltwrapper_scriptname_result" 2607285612Sdelphij # Transform arg to wrapped name. 2608285612Sdelphij file="$progdir/$program" 2609285612Sdelphij fi 2610285612Sdelphij ;; 2611285612Sdelphij esac 2612285612Sdelphij # Quote arguments (to preserve shell metacharacters). 2613285612Sdelphij func_append_quoted args "$file" 2614285612Sdelphij done 2615285612Sdelphij 2616285612Sdelphij if test "X$opt_dry_run" = Xfalse; then 2617285612Sdelphij if test -n "$shlibpath_var"; then 2618285612Sdelphij # Export the shlibpath_var. 2619285612Sdelphij eval "export $shlibpath_var" 2620285612Sdelphij fi 2621285612Sdelphij 2622285612Sdelphij # Restore saved environment variables 2623285612Sdelphij for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 2624285612Sdelphij do 2625285612Sdelphij eval "if test \"\${save_$lt_var+set}\" = set; then 2626285612Sdelphij $lt_var=\$save_$lt_var; export $lt_var 2627285612Sdelphij else 2628285612Sdelphij $lt_unset $lt_var 2629285612Sdelphij fi" 2630285612Sdelphij done 2631285612Sdelphij 2632285612Sdelphij # Now prepare to actually exec the command. 2633285612Sdelphij exec_cmd="\$cmd$args" 2634181834Sroberto else 2635285612Sdelphij # Display what would be done. 2636285612Sdelphij if test -n "$shlibpath_var"; then 2637285612Sdelphij eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 2638285612Sdelphij echo "export $shlibpath_var" 2639285612Sdelphij fi 2640285612Sdelphij $ECHO "$cmd$args" 2641285612Sdelphij exit $EXIT_SUCCESS 2642285612Sdelphij fi 2643285612Sdelphij} 2644181834Sroberto 2645285612Sdelphijtest "$opt_mode" = execute && func_mode_execute ${1+"$@"} 2646285612Sdelphij 2647285612Sdelphij 2648285612Sdelphij# func_mode_finish arg... 2649285612Sdelphijfunc_mode_finish () 2650285612Sdelphij{ 2651285612Sdelphij $opt_debug 2652285612Sdelphij libs= 2653285612Sdelphij libdirs= 2654285612Sdelphij admincmds= 2655285612Sdelphij 2656285612Sdelphij for opt in "$nonopt" ${1+"$@"} 2657285612Sdelphij do 2658285612Sdelphij if test -d "$opt"; then 2659285612Sdelphij func_append libdirs " $opt" 2660285612Sdelphij 2661285612Sdelphij elif test -f "$opt"; then 2662285612Sdelphij if func_lalib_unsafe_p "$opt"; then 2663285612Sdelphij func_append libs " $opt" 2664285612Sdelphij else 2665285612Sdelphij func_warning "\`$opt' is not a valid libtool archive" 2666285612Sdelphij fi 2667285612Sdelphij 2668285612Sdelphij else 2669285612Sdelphij func_fatal_error "invalid argument \`$opt'" 2670285612Sdelphij fi 2671285612Sdelphij done 2672285612Sdelphij 2673285612Sdelphij if test -n "$libs"; then 2674285612Sdelphij if test -n "$lt_sysroot"; then 2675285612Sdelphij sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 2676285612Sdelphij sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 2677285612Sdelphij else 2678285612Sdelphij sysroot_cmd= 2679285612Sdelphij fi 2680285612Sdelphij 2681285612Sdelphij # Remove sysroot references 2682285612Sdelphij if $opt_dry_run; then 2683285612Sdelphij for lib in $libs; do 2684285612Sdelphij echo "removing references to $lt_sysroot and \`=' prefixes from $lib" 2685285612Sdelphij done 2686285612Sdelphij else 2687285612Sdelphij tmpdir=`func_mktempdir` 2688285612Sdelphij for lib in $libs; do 2689285612Sdelphij sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 2690285612Sdelphij > $tmpdir/tmp-la 2691285612Sdelphij mv -f $tmpdir/tmp-la $lib 2692285612Sdelphij done 2693285612Sdelphij ${RM}r "$tmpdir" 2694285612Sdelphij fi 2695181834Sroberto fi 2696181834Sroberto 2697285612Sdelphij if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2698285612Sdelphij for libdir in $libdirs; do 2699285612Sdelphij if test -n "$finish_cmds"; then 2700285612Sdelphij # Do each command in the finish commands. 2701285612Sdelphij func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 2702285612Sdelphij'"$cmd"'"' 2703285612Sdelphij fi 2704285612Sdelphij if test -n "$finish_eval"; then 2705285612Sdelphij # Do the single finish_eval. 2706285612Sdelphij eval cmds=\"$finish_eval\" 2707285612Sdelphij $opt_dry_run || eval "$cmds" || func_append admincmds " 2708285612Sdelphij $cmds" 2709285612Sdelphij fi 2710285612Sdelphij done 2711285612Sdelphij fi 2712181834Sroberto 2713285612Sdelphij # Exit here if they wanted silent mode. 2714285612Sdelphij $opt_silent && exit $EXIT_SUCCESS 2715285612Sdelphij 2716285612Sdelphij if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 2717285612Sdelphij echo "----------------------------------------------------------------------" 2718285612Sdelphij echo "Libraries have been installed in:" 2719285612Sdelphij for libdir in $libdirs; do 2720285612Sdelphij $ECHO " $libdir" 2721285612Sdelphij done 2722285612Sdelphij echo 2723285612Sdelphij echo "If you ever happen to want to link against installed libraries" 2724285612Sdelphij echo "in a given directory, LIBDIR, you must either use libtool, and" 2725285612Sdelphij echo "specify the full pathname of the library, or use the \`-LLIBDIR'" 2726285612Sdelphij echo "flag during linking and do at least one of the following:" 2727285612Sdelphij if test -n "$shlibpath_var"; then 2728285612Sdelphij echo " - add LIBDIR to the \`$shlibpath_var' environment variable" 2729285612Sdelphij echo " during execution" 2730285612Sdelphij fi 2731285612Sdelphij if test -n "$runpath_var"; then 2732285612Sdelphij echo " - add LIBDIR to the \`$runpath_var' environment variable" 2733285612Sdelphij echo " during linking" 2734285612Sdelphij fi 2735285612Sdelphij if test -n "$hardcode_libdir_flag_spec"; then 2736285612Sdelphij libdir=LIBDIR 2737285612Sdelphij eval flag=\"$hardcode_libdir_flag_spec\" 2738285612Sdelphij 2739285612Sdelphij $ECHO " - use the \`$flag' linker flag" 2740285612Sdelphij fi 2741285612Sdelphij if test -n "$admincmds"; then 2742285612Sdelphij $ECHO " - have your system administrator run these commands:$admincmds" 2743285612Sdelphij fi 2744285612Sdelphij if test -f /etc/ld.so.conf; then 2745285612Sdelphij echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'" 2746285612Sdelphij fi 2747285612Sdelphij echo 2748285612Sdelphij 2749285612Sdelphij echo "See any operating system documentation about shared libraries for" 2750285612Sdelphij case $host in 2751285612Sdelphij solaris2.[6789]|solaris2.1[0-9]) 2752285612Sdelphij echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 2753285612Sdelphij echo "pages." 2754285612Sdelphij ;; 2755285612Sdelphij *) 2756285612Sdelphij echo "more information, such as the ld(1) and ld.so(8) manual pages." 2757285612Sdelphij ;; 2758285612Sdelphij esac 2759285612Sdelphij echo "----------------------------------------------------------------------" 2760181834Sroberto fi 2761285612Sdelphij exit $EXIT_SUCCESS 2762285612Sdelphij} 2763181834Sroberto 2764285612Sdelphijtest "$opt_mode" = finish && func_mode_finish ${1+"$@"} 2765285612Sdelphij 2766285612Sdelphij 2767285612Sdelphij# func_mode_install arg... 2768285612Sdelphijfunc_mode_install () 2769285612Sdelphij{ 2770285612Sdelphij $opt_debug 2771285612Sdelphij # There may be an optional sh(1) argument at the beginning of 2772285612Sdelphij # install_prog (especially on Windows NT). 2773285612Sdelphij if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh || 2774285612Sdelphij # Allow the use of GNU shtool's install command. 2775285612Sdelphij case $nonopt in *shtool*) :;; *) false;; esac; then 2776285612Sdelphij # Aesthetically quote it. 2777285612Sdelphij func_quote_for_eval "$nonopt" 2778285612Sdelphij install_prog="$func_quote_for_eval_result " 2779285612Sdelphij arg=$1 2780285612Sdelphij shift 2781285612Sdelphij else 2782285612Sdelphij install_prog= 2783285612Sdelphij arg=$nonopt 2784285612Sdelphij fi 2785285612Sdelphij 2786285612Sdelphij # The real first argument should be the name of the installation program. 2787285612Sdelphij # Aesthetically quote it. 2788285612Sdelphij func_quote_for_eval "$arg" 2789285612Sdelphij func_append install_prog "$func_quote_for_eval_result" 2790285612Sdelphij install_shared_prog=$install_prog 2791285612Sdelphij case " $install_prog " in 2792285612Sdelphij *[\\\ /]cp\ *) install_cp=: ;; 2793285612Sdelphij *) install_cp=false ;; 2794285612Sdelphij esac 2795285612Sdelphij 2796285612Sdelphij # We need to accept at least all the BSD install flags. 2797285612Sdelphij dest= 2798285612Sdelphij files= 2799285612Sdelphij opts= 2800285612Sdelphij prev= 2801285612Sdelphij install_type= 2802285612Sdelphij isdir=no 2803285612Sdelphij stripme= 2804285612Sdelphij no_mode=: 2805285612Sdelphij for arg 2806285612Sdelphij do 2807285612Sdelphij arg2= 2808285612Sdelphij if test -n "$dest"; then 2809285612Sdelphij func_append files " $dest" 2810285612Sdelphij dest=$arg 2811285612Sdelphij continue 2812285612Sdelphij fi 2813285612Sdelphij 2814285612Sdelphij case $arg in 2815285612Sdelphij -d) isdir=yes ;; 2816285612Sdelphij -f) 2817285612Sdelphij if $install_cp; then :; else 2818285612Sdelphij prev=$arg 2819285612Sdelphij fi 2820285612Sdelphij ;; 2821285612Sdelphij -g | -m | -o) 2822285612Sdelphij prev=$arg 2823285612Sdelphij ;; 2824285612Sdelphij -s) 2825285612Sdelphij stripme=" -s" 2826285612Sdelphij continue 2827285612Sdelphij ;; 2828285612Sdelphij -*) 2829285612Sdelphij ;; 2830285612Sdelphij *) 2831285612Sdelphij # If the previous option needed an argument, then skip it. 2832285612Sdelphij if test -n "$prev"; then 2833285612Sdelphij if test "x$prev" = x-m && test -n "$install_override_mode"; then 2834285612Sdelphij arg2=$install_override_mode 2835285612Sdelphij no_mode=false 2836285612Sdelphij fi 2837285612Sdelphij prev= 2838285612Sdelphij else 2839285612Sdelphij dest=$arg 2840285612Sdelphij continue 2841285612Sdelphij fi 2842285612Sdelphij ;; 2843285612Sdelphij esac 2844285612Sdelphij 2845285612Sdelphij # Aesthetically quote the argument. 2846285612Sdelphij func_quote_for_eval "$arg" 2847285612Sdelphij func_append install_prog " $func_quote_for_eval_result" 2848285612Sdelphij if test -n "$arg2"; then 2849285612Sdelphij func_quote_for_eval "$arg2" 2850285612Sdelphij fi 2851285612Sdelphij func_append install_shared_prog " $func_quote_for_eval_result" 2852285612Sdelphij done 2853285612Sdelphij 2854285612Sdelphij test -z "$install_prog" && \ 2855285612Sdelphij func_fatal_help "you must specify an install program" 2856285612Sdelphij 2857285612Sdelphij test -n "$prev" && \ 2858285612Sdelphij func_fatal_help "the \`$prev' option requires an argument" 2859285612Sdelphij 2860285612Sdelphij if test -n "$install_override_mode" && $no_mode; then 2861285612Sdelphij if $install_cp; then :; else 2862285612Sdelphij func_quote_for_eval "$install_override_mode" 2863285612Sdelphij func_append install_shared_prog " -m $func_quote_for_eval_result" 2864285612Sdelphij fi 2865285612Sdelphij fi 2866285612Sdelphij 2867285612Sdelphij if test -z "$files"; then 2868285612Sdelphij if test -z "$dest"; then 2869285612Sdelphij func_fatal_help "no file or destination specified" 2870285612Sdelphij else 2871285612Sdelphij func_fatal_help "you must specify a destination" 2872285612Sdelphij fi 2873285612Sdelphij fi 2874285612Sdelphij 2875285612Sdelphij # Strip any trailing slash from the destination. 2876285612Sdelphij func_stripname '' '/' "$dest" 2877285612Sdelphij dest=$func_stripname_result 2878285612Sdelphij 2879285612Sdelphij # Check to see that the destination is a directory. 2880285612Sdelphij test -d "$dest" && isdir=yes 2881285612Sdelphij if test "$isdir" = yes; then 2882285612Sdelphij destdir="$dest" 2883285612Sdelphij destname= 2884285612Sdelphij else 2885285612Sdelphij func_dirname_and_basename "$dest" "" "." 2886285612Sdelphij destdir="$func_dirname_result" 2887285612Sdelphij destname="$func_basename_result" 2888285612Sdelphij 2889285612Sdelphij # Not a directory, so check to see that there is only one file specified. 2890285612Sdelphij set dummy $files; shift 2891285612Sdelphij test "$#" -gt 1 && \ 2892285612Sdelphij func_fatal_help "\`$dest' is not a directory" 2893285612Sdelphij fi 2894285612Sdelphij case $destdir in 2895285612Sdelphij [\\/]* | [A-Za-z]:[\\/]*) ;; 2896285612Sdelphij *) 2897285612Sdelphij for file in $files; do 2898285612Sdelphij case $file in 2899285612Sdelphij *.lo) ;; 2900285612Sdelphij *) 2901285612Sdelphij func_fatal_help "\`$destdir' must be an absolute directory name" 2902285612Sdelphij ;; 2903285612Sdelphij esac 2904285612Sdelphij done 2905285612Sdelphij ;; 2906285612Sdelphij esac 2907285612Sdelphij 2908285612Sdelphij # This variable tells wrapper scripts just to set variables rather 2909285612Sdelphij # than running their programs. 2910285612Sdelphij libtool_install_magic="$magic" 2911285612Sdelphij 2912285612Sdelphij staticlibs= 2913285612Sdelphij future_libdirs= 2914285612Sdelphij current_libdirs= 2915285612Sdelphij for file in $files; do 2916285612Sdelphij 2917285612Sdelphij # Do each installation. 2918285612Sdelphij case $file in 2919285612Sdelphij *.$libext) 2920285612Sdelphij # Do the static libraries later. 2921285612Sdelphij func_append staticlibs " $file" 2922285612Sdelphij ;; 2923285612Sdelphij 2924285612Sdelphij *.la) 2925285612Sdelphij func_resolve_sysroot "$file" 2926285612Sdelphij file=$func_resolve_sysroot_result 2927285612Sdelphij 2928285612Sdelphij # Check to see that this really is a libtool archive. 2929285612Sdelphij func_lalib_unsafe_p "$file" \ 2930285612Sdelphij || func_fatal_help "\`$file' is not a valid libtool archive" 2931285612Sdelphij 2932285612Sdelphij library_names= 2933285612Sdelphij old_library= 2934285612Sdelphij relink_command= 2935285612Sdelphij func_source "$file" 2936285612Sdelphij 2937285612Sdelphij # Add the libdir to current_libdirs if it is the destination. 2938285612Sdelphij if test "X$destdir" = "X$libdir"; then 2939285612Sdelphij case "$current_libdirs " in 2940285612Sdelphij *" $libdir "*) ;; 2941285612Sdelphij *) func_append current_libdirs " $libdir" ;; 2942285612Sdelphij esac 2943285612Sdelphij else 2944285612Sdelphij # Note the libdir as a future libdir. 2945285612Sdelphij case "$future_libdirs " in 2946285612Sdelphij *" $libdir "*) ;; 2947285612Sdelphij *) func_append future_libdirs " $libdir" ;; 2948285612Sdelphij esac 2949285612Sdelphij fi 2950285612Sdelphij 2951285612Sdelphij func_dirname "$file" "/" "" 2952285612Sdelphij dir="$func_dirname_result" 2953285612Sdelphij func_append dir "$objdir" 2954285612Sdelphij 2955285612Sdelphij if test -n "$relink_command"; then 2956285612Sdelphij # Determine the prefix the user has applied to our future dir. 2957285612Sdelphij inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 2958285612Sdelphij 2959285612Sdelphij # Don't allow the user to place us outside of our expected 2960285612Sdelphij # location b/c this prevents finding dependent libraries that 2961285612Sdelphij # are installed to the same prefix. 2962285612Sdelphij # At present, this check doesn't affect windows .dll's that 2963285612Sdelphij # are installed into $libdir/../bin (currently, that works fine) 2964285612Sdelphij # but it's something to keep an eye on. 2965285612Sdelphij test "$inst_prefix_dir" = "$destdir" && \ 2966285612Sdelphij func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir" 2967285612Sdelphij 2968285612Sdelphij if test -n "$inst_prefix_dir"; then 2969285612Sdelphij # Stick the inst_prefix_dir data into the link command. 2970285612Sdelphij relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 2971285612Sdelphij else 2972285612Sdelphij relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 2973285612Sdelphij fi 2974285612Sdelphij 2975285612Sdelphij func_warning "relinking \`$file'" 2976285612Sdelphij func_show_eval "$relink_command" \ 2977285612Sdelphij 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"' 2978285612Sdelphij fi 2979285612Sdelphij 2980285612Sdelphij # See the names of the shared library. 2981285612Sdelphij set dummy $library_names; shift 2982285612Sdelphij if test -n "$1"; then 2983285612Sdelphij realname="$1" 2984285612Sdelphij shift 2985285612Sdelphij 2986285612Sdelphij srcname="$realname" 2987285612Sdelphij test -n "$relink_command" && srcname="$realname"T 2988285612Sdelphij 2989285612Sdelphij # Install the shared library and build the symlinks. 2990285612Sdelphij func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 2991285612Sdelphij 'exit $?' 2992285612Sdelphij tstripme="$stripme" 2993285612Sdelphij case $host_os in 2994285612Sdelphij cygwin* | mingw* | pw32* | cegcc*) 2995285612Sdelphij case $realname in 2996285612Sdelphij *.dll.a) 2997285612Sdelphij tstripme="" 2998285612Sdelphij ;; 2999285612Sdelphij esac 3000285612Sdelphij ;; 3001285612Sdelphij esac 3002285612Sdelphij if test -n "$tstripme" && test -n "$striplib"; then 3003285612Sdelphij func_show_eval "$striplib $destdir/$realname" 'exit $?' 3004285612Sdelphij fi 3005285612Sdelphij 3006285612Sdelphij if test "$#" -gt 0; then 3007285612Sdelphij # Delete the old symlinks, and create new ones. 3008285612Sdelphij # Try `ln -sf' first, because the `ln' binary might depend on 3009285612Sdelphij # the symlink we replace! Solaris /bin/ln does not understand -f, 3010285612Sdelphij # so we also need to try rm && ln -s. 3011285612Sdelphij for linkname 3012285612Sdelphij do 3013285612Sdelphij test "$linkname" != "$realname" \ 3014285612Sdelphij && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 3015285612Sdelphij done 3016285612Sdelphij fi 3017285612Sdelphij 3018285612Sdelphij # Do each command in the postinstall commands. 3019285612Sdelphij lib="$destdir/$realname" 3020285612Sdelphij func_execute_cmds "$postinstall_cmds" 'exit $?' 3021285612Sdelphij fi 3022285612Sdelphij 3023285612Sdelphij # Install the pseudo-library for information purposes. 3024285612Sdelphij func_basename "$file" 3025285612Sdelphij name="$func_basename_result" 3026285612Sdelphij instname="$dir/$name"i 3027285612Sdelphij func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 3028285612Sdelphij 3029285612Sdelphij # Maybe install the static library, too. 3030285612Sdelphij test -n "$old_library" && func_append staticlibs " $dir/$old_library" 3031285612Sdelphij ;; 3032285612Sdelphij 3033285612Sdelphij *.lo) 3034285612Sdelphij # Install (i.e. copy) a libtool object. 3035285612Sdelphij 3036285612Sdelphij # Figure out destination file name, if it wasn't already specified. 3037285612Sdelphij if test -n "$destname"; then 3038285612Sdelphij destfile="$destdir/$destname" 3039285612Sdelphij else 3040285612Sdelphij func_basename "$file" 3041285612Sdelphij destfile="$func_basename_result" 3042285612Sdelphij destfile="$destdir/$destfile" 3043285612Sdelphij fi 3044285612Sdelphij 3045285612Sdelphij # Deduce the name of the destination old-style object file. 3046285612Sdelphij case $destfile in 3047285612Sdelphij *.lo) 3048285612Sdelphij func_lo2o "$destfile" 3049285612Sdelphij staticdest=$func_lo2o_result 3050285612Sdelphij ;; 3051285612Sdelphij *.$objext) 3052285612Sdelphij staticdest="$destfile" 3053285612Sdelphij destfile= 3054285612Sdelphij ;; 3055285612Sdelphij *) 3056285612Sdelphij func_fatal_help "cannot copy a libtool object to \`$destfile'" 3057285612Sdelphij ;; 3058285612Sdelphij esac 3059285612Sdelphij 3060285612Sdelphij # Install the libtool object if requested. 3061285612Sdelphij test -n "$destfile" && \ 3062285612Sdelphij func_show_eval "$install_prog $file $destfile" 'exit $?' 3063285612Sdelphij 3064285612Sdelphij # Install the old object if enabled. 3065285612Sdelphij if test "$build_old_libs" = yes; then 3066285612Sdelphij # Deduce the name of the old-style object file. 3067285612Sdelphij func_lo2o "$file" 3068285612Sdelphij staticobj=$func_lo2o_result 3069285612Sdelphij func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 3070285612Sdelphij fi 3071285612Sdelphij exit $EXIT_SUCCESS 3072285612Sdelphij ;; 3073285612Sdelphij 3074285612Sdelphij *) 3075285612Sdelphij # Figure out destination file name, if it wasn't already specified. 3076285612Sdelphij if test -n "$destname"; then 3077285612Sdelphij destfile="$destdir/$destname" 3078285612Sdelphij else 3079285612Sdelphij func_basename "$file" 3080285612Sdelphij destfile="$func_basename_result" 3081285612Sdelphij destfile="$destdir/$destfile" 3082285612Sdelphij fi 3083285612Sdelphij 3084285612Sdelphij # If the file is missing, and there is a .exe on the end, strip it 3085285612Sdelphij # because it is most likely a libtool script we actually want to 3086285612Sdelphij # install 3087285612Sdelphij stripped_ext="" 3088285612Sdelphij case $file in 3089285612Sdelphij *.exe) 3090285612Sdelphij if test ! -f "$file"; then 3091285612Sdelphij func_stripname '' '.exe' "$file" 3092285612Sdelphij file=$func_stripname_result 3093285612Sdelphij stripped_ext=".exe" 3094285612Sdelphij fi 3095285612Sdelphij ;; 3096285612Sdelphij esac 3097285612Sdelphij 3098285612Sdelphij # Do a test to see if this is really a libtool program. 3099285612Sdelphij case $host in 3100285612Sdelphij *cygwin* | *mingw*) 3101285612Sdelphij if func_ltwrapper_executable_p "$file"; then 3102285612Sdelphij func_ltwrapper_scriptname "$file" 3103285612Sdelphij wrapper=$func_ltwrapper_scriptname_result 3104285612Sdelphij else 3105285612Sdelphij func_stripname '' '.exe' "$file" 3106285612Sdelphij wrapper=$func_stripname_result 3107285612Sdelphij fi 3108285612Sdelphij ;; 3109285612Sdelphij *) 3110285612Sdelphij wrapper=$file 3111285612Sdelphij ;; 3112285612Sdelphij esac 3113285612Sdelphij if func_ltwrapper_script_p "$wrapper"; then 3114285612Sdelphij notinst_deplibs= 3115285612Sdelphij relink_command= 3116285612Sdelphij 3117285612Sdelphij func_source "$wrapper" 3118285612Sdelphij 3119285612Sdelphij # Check the variables that should have been set. 3120285612Sdelphij test -z "$generated_by_libtool_version" && \ 3121285612Sdelphij func_fatal_error "invalid libtool wrapper script \`$wrapper'" 3122285612Sdelphij 3123285612Sdelphij finalize=yes 3124285612Sdelphij for lib in $notinst_deplibs; do 3125285612Sdelphij # Check to see that each library is installed. 3126285612Sdelphij libdir= 3127285612Sdelphij if test -f "$lib"; then 3128285612Sdelphij func_source "$lib" 3129285612Sdelphij fi 3130285612Sdelphij libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test 3131285612Sdelphij if test -n "$libdir" && test ! -f "$libfile"; then 3132285612Sdelphij func_warning "\`$lib' has not been installed in \`$libdir'" 3133285612Sdelphij finalize=no 3134285612Sdelphij fi 3135285612Sdelphij done 3136285612Sdelphij 3137285612Sdelphij relink_command= 3138285612Sdelphij func_source "$wrapper" 3139285612Sdelphij 3140285612Sdelphij outputname= 3141285612Sdelphij if test "$fast_install" = no && test -n "$relink_command"; then 3142285612Sdelphij $opt_dry_run || { 3143285612Sdelphij if test "$finalize" = yes; then 3144285612Sdelphij tmpdir=`func_mktempdir` 3145285612Sdelphij func_basename "$file$stripped_ext" 3146285612Sdelphij file="$func_basename_result" 3147285612Sdelphij outputname="$tmpdir/$file" 3148285612Sdelphij # Replace the output file specification. 3149285612Sdelphij relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 3150285612Sdelphij 3151285612Sdelphij $opt_silent || { 3152285612Sdelphij func_quote_for_expand "$relink_command" 3153285612Sdelphij eval "func_echo $func_quote_for_expand_result" 3154285612Sdelphij } 3155285612Sdelphij if eval "$relink_command"; then : 3156285612Sdelphij else 3157285612Sdelphij func_error "error: relink \`$file' with the above command before installing it" 3158285612Sdelphij $opt_dry_run || ${RM}r "$tmpdir" 3159285612Sdelphij continue 3160285612Sdelphij fi 3161285612Sdelphij file="$outputname" 3162285612Sdelphij else 3163285612Sdelphij func_warning "cannot relink \`$file'" 3164285612Sdelphij fi 3165285612Sdelphij } 3166285612Sdelphij else 3167285612Sdelphij # Install the binary that we compiled earlier. 3168285612Sdelphij file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 3169285612Sdelphij fi 3170285612Sdelphij fi 3171285612Sdelphij 3172285612Sdelphij # remove .exe since cygwin /usr/bin/install will append another 3173285612Sdelphij # one anyway 3174285612Sdelphij case $install_prog,$host in 3175285612Sdelphij */usr/bin/install*,*cygwin*) 3176285612Sdelphij case $file:$destfile in 3177285612Sdelphij *.exe:*.exe) 3178285612Sdelphij # this is ok 3179285612Sdelphij ;; 3180285612Sdelphij *.exe:*) 3181285612Sdelphij destfile=$destfile.exe 3182285612Sdelphij ;; 3183285612Sdelphij *:*.exe) 3184285612Sdelphij func_stripname '' '.exe' "$destfile" 3185285612Sdelphij destfile=$func_stripname_result 3186285612Sdelphij ;; 3187285612Sdelphij esac 3188285612Sdelphij ;; 3189285612Sdelphij esac 3190285612Sdelphij func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 3191285612Sdelphij $opt_dry_run || if test -n "$outputname"; then 3192285612Sdelphij ${RM}r "$tmpdir" 3193285612Sdelphij fi 3194285612Sdelphij ;; 3195285612Sdelphij esac 3196285612Sdelphij done 3197285612Sdelphij 3198285612Sdelphij for file in $staticlibs; do 3199285612Sdelphij func_basename "$file" 3200285612Sdelphij name="$func_basename_result" 3201285612Sdelphij 3202285612Sdelphij # Set up the ranlib parameters. 3203285612Sdelphij oldlib="$destdir/$name" 3204285612Sdelphij 3205285612Sdelphij func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 3206285612Sdelphij 3207285612Sdelphij if test -n "$stripme" && test -n "$old_striplib"; then 3208285612Sdelphij func_show_eval "$old_striplib $oldlib" 'exit $?' 3209285612Sdelphij fi 3210285612Sdelphij 3211285612Sdelphij # Do each command in the postinstall commands. 3212285612Sdelphij func_execute_cmds "$old_postinstall_cmds" 'exit $?' 3213285612Sdelphij done 3214285612Sdelphij 3215285612Sdelphij test -n "$future_libdirs" && \ 3216285612Sdelphij func_warning "remember to run \`$progname --finish$future_libdirs'" 3217285612Sdelphij 3218285612Sdelphij if test -n "$current_libdirs"; then 3219285612Sdelphij # Maybe just do a dry run. 3220285612Sdelphij $opt_dry_run && current_libdirs=" -n$current_libdirs" 3221285612Sdelphij exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs' 3222285612Sdelphij else 3223285612Sdelphij exit $EXIT_SUCCESS 3224285612Sdelphij fi 3225285612Sdelphij} 3226285612Sdelphij 3227285612Sdelphijtest "$opt_mode" = install && func_mode_install ${1+"$@"} 3228285612Sdelphij 3229285612Sdelphij 3230285612Sdelphij# func_generate_dlsyms outputname originator pic_p 3231285612Sdelphij# Extract symbols from dlprefiles and create ${outputname}S.o with 3232285612Sdelphij# a dlpreopen symbol table. 3233285612Sdelphijfunc_generate_dlsyms () 3234285612Sdelphij{ 3235285612Sdelphij $opt_debug 3236285612Sdelphij my_outputname="$1" 3237285612Sdelphij my_originator="$2" 3238285612Sdelphij my_pic_p="${3-no}" 3239285612Sdelphij my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'` 3240285612Sdelphij my_dlsyms= 3241285612Sdelphij 3242285612Sdelphij if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 3243285612Sdelphij if test -n "$NM" && test -n "$global_symbol_pipe"; then 3244285612Sdelphij my_dlsyms="${my_outputname}S.c" 3245285612Sdelphij else 3246285612Sdelphij func_error "not configured to extract global symbols from dlpreopened files" 3247285612Sdelphij fi 3248285612Sdelphij fi 3249285612Sdelphij 3250285612Sdelphij if test -n "$my_dlsyms"; then 3251285612Sdelphij case $my_dlsyms in 3252285612Sdelphij "") ;; 3253285612Sdelphij *.c) 3254285612Sdelphij # Discover the nlist of each of the dlfiles. 3255285612Sdelphij nlist="$output_objdir/${my_outputname}.nm" 3256285612Sdelphij 3257285612Sdelphij func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 3258285612Sdelphij 3259285612Sdelphij # Parse the name list into a source file. 3260285612Sdelphij func_verbose "creating $output_objdir/$my_dlsyms" 3261285612Sdelphij 3262285612Sdelphij $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 3263285612Sdelphij/* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */ 3264285612Sdelphij/* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */ 3265285612Sdelphij 3266285612Sdelphij#ifdef __cplusplus 3267285612Sdelphijextern \"C\" { 3268285612Sdelphij#endif 3269285612Sdelphij 3270285612Sdelphij#if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 3271285612Sdelphij#pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 3272285612Sdelphij#endif 3273285612Sdelphij 3274285612Sdelphij/* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 3275285612Sdelphij#if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE) 3276285612Sdelphij/* DATA imports from DLLs on WIN32 con't be const, because runtime 3277285612Sdelphij relocations are performed -- see ld's documentation on pseudo-relocs. */ 3278285612Sdelphij# define LT_DLSYM_CONST 3279285612Sdelphij#elif defined(__osf__) 3280285612Sdelphij/* This system does not cope well with relocations in const data. */ 3281285612Sdelphij# define LT_DLSYM_CONST 3282285612Sdelphij#else 3283285612Sdelphij# define LT_DLSYM_CONST const 3284285612Sdelphij#endif 3285285612Sdelphij 3286285612Sdelphij/* External symbol declarations for the compiler. */\ 3287285612Sdelphij" 3288285612Sdelphij 3289285612Sdelphij if test "$dlself" = yes; then 3290285612Sdelphij func_verbose "generating symbol list for \`$output'" 3291285612Sdelphij 3292285612Sdelphij $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 3293285612Sdelphij 3294285612Sdelphij # Add our own program objects to the symbol list. 3295285612Sdelphij progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 3296285612Sdelphij for progfile in $progfiles; do 3297285612Sdelphij func_to_tool_file "$progfile" func_convert_file_msys_to_w32 3298285612Sdelphij func_verbose "extracting global C symbols from \`$func_to_tool_file_result'" 3299285612Sdelphij $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 3300285612Sdelphij done 3301285612Sdelphij 3302285612Sdelphij if test -n "$exclude_expsyms"; then 3303285612Sdelphij $opt_dry_run || { 3304285612Sdelphij eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 3305285612Sdelphij eval '$MV "$nlist"T "$nlist"' 3306285612Sdelphij } 3307285612Sdelphij fi 3308285612Sdelphij 3309285612Sdelphij if test -n "$export_symbols_regex"; then 3310285612Sdelphij $opt_dry_run || { 3311285612Sdelphij eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 3312285612Sdelphij eval '$MV "$nlist"T "$nlist"' 3313285612Sdelphij } 3314285612Sdelphij fi 3315285612Sdelphij 3316285612Sdelphij # Prepare the list of exported symbols 3317285612Sdelphij if test -z "$export_symbols"; then 3318285612Sdelphij export_symbols="$output_objdir/$outputname.exp" 3319285612Sdelphij $opt_dry_run || { 3320285612Sdelphij $RM $export_symbols 3321285612Sdelphij eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 3322285612Sdelphij case $host in 3323285612Sdelphij *cygwin* | *mingw* | *cegcc* ) 3324285612Sdelphij eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3325285612Sdelphij eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 3326285612Sdelphij ;; 3327285612Sdelphij esac 3328285612Sdelphij } 3329285612Sdelphij else 3330285612Sdelphij $opt_dry_run || { 3331285612Sdelphij eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 3332285612Sdelphij eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 3333285612Sdelphij eval '$MV "$nlist"T "$nlist"' 3334285612Sdelphij case $host in 3335285612Sdelphij *cygwin* | *mingw* | *cegcc* ) 3336285612Sdelphij eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 3337285612Sdelphij eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 3338285612Sdelphij ;; 3339285612Sdelphij esac 3340285612Sdelphij } 3341285612Sdelphij fi 3342285612Sdelphij fi 3343285612Sdelphij 3344285612Sdelphij for dlprefile in $dlprefiles; do 3345285612Sdelphij func_verbose "extracting global C symbols from \`$dlprefile'" 3346285612Sdelphij func_basename "$dlprefile" 3347285612Sdelphij name="$func_basename_result" 3348285612Sdelphij case $host in 3349285612Sdelphij *cygwin* | *mingw* | *cegcc* ) 3350285612Sdelphij # if an import library, we need to obtain dlname 3351285612Sdelphij if func_win32_import_lib_p "$dlprefile"; then 3352285612Sdelphij func_tr_sh "$dlprefile" 3353285612Sdelphij eval "curr_lafile=\$libfile_$func_tr_sh_result" 3354285612Sdelphij dlprefile_dlbasename="" 3355285612Sdelphij if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 3356285612Sdelphij # Use subshell, to avoid clobbering current variable values 3357285612Sdelphij dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 3358285612Sdelphij if test -n "$dlprefile_dlname" ; then 3359285612Sdelphij func_basename "$dlprefile_dlname" 3360285612Sdelphij dlprefile_dlbasename="$func_basename_result" 3361285612Sdelphij else 3362285612Sdelphij # no lafile. user explicitly requested -dlpreopen <import library>. 3363285612Sdelphij $sharedlib_from_linklib_cmd "$dlprefile" 3364285612Sdelphij dlprefile_dlbasename=$sharedlib_from_linklib_result 3365285612Sdelphij fi 3366285612Sdelphij fi 3367285612Sdelphij $opt_dry_run || { 3368285612Sdelphij if test -n "$dlprefile_dlbasename" ; then 3369285612Sdelphij eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 3370285612Sdelphij else 3371285612Sdelphij func_warning "Could not compute DLL name from $name" 3372285612Sdelphij eval '$ECHO ": $name " >> "$nlist"' 3373285612Sdelphij fi 3374285612Sdelphij func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3375285612Sdelphij eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 3376285612Sdelphij $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 3377285612Sdelphij } 3378285612Sdelphij else # not an import lib 3379285612Sdelphij $opt_dry_run || { 3380285612Sdelphij eval '$ECHO ": $name " >> "$nlist"' 3381285612Sdelphij func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3382285612Sdelphij eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3383285612Sdelphij } 3384285612Sdelphij fi 3385285612Sdelphij ;; 3386285612Sdelphij *) 3387285612Sdelphij $opt_dry_run || { 3388285612Sdelphij eval '$ECHO ": $name " >> "$nlist"' 3389285612Sdelphij func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 3390285612Sdelphij eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 3391285612Sdelphij } 3392285612Sdelphij ;; 3393285612Sdelphij esac 3394285612Sdelphij done 3395285612Sdelphij 3396285612Sdelphij $opt_dry_run || { 3397285612Sdelphij # Make sure we have at least an empty file. 3398285612Sdelphij test -f "$nlist" || : > "$nlist" 3399285612Sdelphij 3400285612Sdelphij if test -n "$exclude_expsyms"; then 3401285612Sdelphij $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 3402285612Sdelphij $MV "$nlist"T "$nlist" 3403285612Sdelphij fi 3404285612Sdelphij 3405285612Sdelphij # Try sorting and uniquifying the output. 3406285612Sdelphij if $GREP -v "^: " < "$nlist" | 3407285612Sdelphij if sort -k 3 </dev/null >/dev/null 2>&1; then 3408285612Sdelphij sort -k 3 3409285612Sdelphij else 3410285612Sdelphij sort +2 3411285612Sdelphij fi | 3412285612Sdelphij uniq > "$nlist"S; then 3413285612Sdelphij : 3414285612Sdelphij else 3415285612Sdelphij $GREP -v "^: " < "$nlist" > "$nlist"S 3416285612Sdelphij fi 3417285612Sdelphij 3418285612Sdelphij if test -f "$nlist"S; then 3419285612Sdelphij eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 3420285612Sdelphij else 3421285612Sdelphij echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 3422285612Sdelphij fi 3423285612Sdelphij 3424285612Sdelphij echo >> "$output_objdir/$my_dlsyms" "\ 3425285612Sdelphij 3426285612Sdelphij/* The mapping between symbol names and symbols. */ 3427285612Sdelphijtypedef struct { 3428285612Sdelphij const char *name; 3429285612Sdelphij void *address; 3430285612Sdelphij} lt_dlsymlist; 3431285612Sdelphijextern LT_DLSYM_CONST lt_dlsymlist 3432285612Sdelphijlt_${my_prefix}_LTX_preloaded_symbols[]; 3433285612SdelphijLT_DLSYM_CONST lt_dlsymlist 3434285612Sdelphijlt_${my_prefix}_LTX_preloaded_symbols[] = 3435285612Sdelphij{\ 3436285612Sdelphij { \"$my_originator\", (void *) 0 }," 3437285612Sdelphij 3438285612Sdelphij case $need_lib_prefix in 3439285612Sdelphij no) 3440285612Sdelphij eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 3441285612Sdelphij ;; 3442285612Sdelphij *) 3443285612Sdelphij eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 3444285612Sdelphij ;; 3445285612Sdelphij esac 3446285612Sdelphij echo >> "$output_objdir/$my_dlsyms" "\ 3447285612Sdelphij {0, (void *) 0} 3448285612Sdelphij}; 3449285612Sdelphij 3450285612Sdelphij/* This works around a problem in FreeBSD linker */ 3451285612Sdelphij#ifdef FREEBSD_WORKAROUND 3452285612Sdelphijstatic const void *lt_preloaded_setup() { 3453285612Sdelphij return lt_${my_prefix}_LTX_preloaded_symbols; 3454285612Sdelphij} 3455285612Sdelphij#endif 3456285612Sdelphij 3457285612Sdelphij#ifdef __cplusplus 3458285612Sdelphij} 3459285612Sdelphij#endif\ 3460285612Sdelphij" 3461285612Sdelphij } # !$opt_dry_run 3462285612Sdelphij 3463285612Sdelphij pic_flag_for_symtable= 3464285612Sdelphij case "$compile_command " in 3465285612Sdelphij *" -static "*) ;; 3466285612Sdelphij *) 3467285612Sdelphij case $host in 3468285612Sdelphij # compiling the symbol table file with pic_flag works around 3469285612Sdelphij # a FreeBSD bug that causes programs to crash when -lm is 3470285612Sdelphij # linked before any other PIC object. But we must not use 3471285612Sdelphij # pic_flag when linking with -static. The problem exists in 3472285612Sdelphij # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 3473285612Sdelphij *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 3474285612Sdelphij pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 3475285612Sdelphij *-*-hpux*) 3476285612Sdelphij pic_flag_for_symtable=" $pic_flag" ;; 3477285612Sdelphij *) 3478285612Sdelphij if test "X$my_pic_p" != Xno; then 3479285612Sdelphij pic_flag_for_symtable=" $pic_flag" 3480285612Sdelphij fi 3481285612Sdelphij ;; 3482285612Sdelphij esac 3483285612Sdelphij ;; 3484285612Sdelphij esac 3485285612Sdelphij symtab_cflags= 3486285612Sdelphij for arg in $LTCFLAGS; do 3487285612Sdelphij case $arg in 3488285612Sdelphij -pie | -fpie | -fPIE) ;; 3489285612Sdelphij *) func_append symtab_cflags " $arg" ;; 3490285612Sdelphij esac 3491285612Sdelphij done 3492285612Sdelphij 3493285612Sdelphij # Now compile the dynamic symbol file. 3494285612Sdelphij func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 3495285612Sdelphij 3496285612Sdelphij # Clean up the generated files. 3497285612Sdelphij func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"' 3498285612Sdelphij 3499285612Sdelphij # Transform the symbol file into the correct name. 3500285612Sdelphij symfileobj="$output_objdir/${my_outputname}S.$objext" 3501285612Sdelphij case $host in 3502285612Sdelphij *cygwin* | *mingw* | *cegcc* ) 3503285612Sdelphij if test -f "$output_objdir/$my_outputname.def"; then 3504285612Sdelphij compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3505285612Sdelphij finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 3506285612Sdelphij else 3507285612Sdelphij compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3508285612Sdelphij finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3509285612Sdelphij fi 3510285612Sdelphij ;; 3511285612Sdelphij *) 3512285612Sdelphij compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3513285612Sdelphij finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 3514285612Sdelphij ;; 3515285612Sdelphij esac 3516285612Sdelphij ;; 3517285612Sdelphij *) 3518285612Sdelphij func_fatal_error "unknown suffix for \`$my_dlsyms'" 3519285612Sdelphij ;; 3520285612Sdelphij esac 3521285612Sdelphij else 3522285612Sdelphij # We keep going just in case the user didn't refer to 3523285612Sdelphij # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 3524285612Sdelphij # really was required. 3525285612Sdelphij 3526285612Sdelphij # Nullify the symbol file. 3527285612Sdelphij compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 3528285612Sdelphij finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 3529285612Sdelphij fi 3530285612Sdelphij} 3531285612Sdelphij 3532285612Sdelphij# func_win32_libid arg 3533285612Sdelphij# return the library type of file 'arg' 3534285612Sdelphij# 3535285612Sdelphij# Need a lot of goo to handle *both* DLLs and import libs 3536285612Sdelphij# Has to be a shell function in order to 'eat' the argument 3537285612Sdelphij# that is supplied when $file_magic_command is called. 3538285612Sdelphij# Despite the name, also deal with 64 bit binaries. 3539285612Sdelphijfunc_win32_libid () 3540285612Sdelphij{ 3541285612Sdelphij $opt_debug 3542285612Sdelphij win32_libid_type="unknown" 3543285612Sdelphij win32_fileres=`file -L $1 2>/dev/null` 3544285612Sdelphij case $win32_fileres in 3545285612Sdelphij *ar\ archive\ import\ library*) # definitely import 3546285612Sdelphij win32_libid_type="x86 archive import" 3547181834Sroberto ;; 3548285612Sdelphij *ar\ archive*) # could be an import, or static 3549285612Sdelphij # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 3550285612Sdelphij if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 3551285612Sdelphij $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 3552285612Sdelphij func_to_tool_file "$1" func_convert_file_msys_to_w32 3553285612Sdelphij win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 3554285612Sdelphij $SED -n -e ' 3555285612Sdelphij 1,100{ 3556285612Sdelphij / I /{ 3557285612Sdelphij s,.*,import, 3558285612Sdelphij p 3559285612Sdelphij q 3560285612Sdelphij } 3561285612Sdelphij }'` 3562285612Sdelphij case $win32_nmres in 3563285612Sdelphij import*) win32_libid_type="x86 archive import";; 3564285612Sdelphij *) win32_libid_type="x86 archive static";; 3565285612Sdelphij esac 3566285612Sdelphij fi 3567285612Sdelphij ;; 3568285612Sdelphij *DLL*) 3569285612Sdelphij win32_libid_type="x86 DLL" 3570285612Sdelphij ;; 3571285612Sdelphij *executable*) # but shell scripts are "executable" too... 3572285612Sdelphij case $win32_fileres in 3573285612Sdelphij *MS\ Windows\ PE\ Intel*) 3574285612Sdelphij win32_libid_type="x86 DLL" 3575285612Sdelphij ;; 3576285612Sdelphij esac 3577285612Sdelphij ;; 3578285612Sdelphij esac 3579285612Sdelphij $ECHO "$win32_libid_type" 3580285612Sdelphij} 3581181834Sroberto 3582285612Sdelphij# func_cygming_dll_for_implib ARG 3583285612Sdelphij# 3584285612Sdelphij# Platform-specific function to extract the 3585285612Sdelphij# name of the DLL associated with the specified 3586285612Sdelphij# import library ARG. 3587285612Sdelphij# Invoked by eval'ing the libtool variable 3588285612Sdelphij# $sharedlib_from_linklib_cmd 3589285612Sdelphij# Result is available in the variable 3590285612Sdelphij# $sharedlib_from_linklib_result 3591285612Sdelphijfunc_cygming_dll_for_implib () 3592285612Sdelphij{ 3593285612Sdelphij $opt_debug 3594285612Sdelphij sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 3595285612Sdelphij} 3596285612Sdelphij 3597285612Sdelphij# func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 3598285612Sdelphij# 3599285612Sdelphij# The is the core of a fallback implementation of a 3600285612Sdelphij# platform-specific function to extract the name of the 3601285612Sdelphij# DLL associated with the specified import library LIBNAME. 3602285612Sdelphij# 3603285612Sdelphij# SECTION_NAME is either .idata$6 or .idata$7, depending 3604285612Sdelphij# on the platform and compiler that created the implib. 3605285612Sdelphij# 3606285612Sdelphij# Echos the name of the DLL associated with the 3607285612Sdelphij# specified import library. 3608285612Sdelphijfunc_cygming_dll_for_implib_fallback_core () 3609285612Sdelphij{ 3610285612Sdelphij $opt_debug 3611285612Sdelphij match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 3612285612Sdelphij $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 3613285612Sdelphij $SED '/^Contents of section '"$match_literal"':/{ 3614285612Sdelphij # Place marker at beginning of archive member dllname section 3615285612Sdelphij s/.*/====MARK====/ 3616285612Sdelphij p 3617285612Sdelphij d 3618285612Sdelphij } 3619285612Sdelphij # These lines can sometimes be longer than 43 characters, but 3620285612Sdelphij # are always uninteresting 3621285612Sdelphij /:[ ]*file format pe[i]\{,1\}-/d 3622285612Sdelphij /^In archive [^:]*:/d 3623285612Sdelphij # Ensure marker is printed 3624285612Sdelphij /^====MARK====/p 3625285612Sdelphij # Remove all lines with less than 43 characters 3626285612Sdelphij /^.\{43\}/!d 3627285612Sdelphij # From remaining lines, remove first 43 characters 3628285612Sdelphij s/^.\{43\}//' | 3629285612Sdelphij $SED -n ' 3630285612Sdelphij # Join marker and all lines until next marker into a single line 3631285612Sdelphij /^====MARK====/ b para 3632285612Sdelphij H 3633285612Sdelphij $ b para 3634285612Sdelphij b 3635285612Sdelphij :para 3636285612Sdelphij x 3637285612Sdelphij s/\n//g 3638285612Sdelphij # Remove the marker 3639285612Sdelphij s/^====MARK====// 3640285612Sdelphij # Remove trailing dots and whitespace 3641285612Sdelphij s/[\. \t]*$// 3642285612Sdelphij # Print 3643285612Sdelphij /./p' | 3644285612Sdelphij # we now have a list, one entry per line, of the stringified 3645285612Sdelphij # contents of the appropriate section of all members of the 3646285612Sdelphij # archive which possess that section. Heuristic: eliminate 3647285612Sdelphij # all those which have a first or second character that is 3648285612Sdelphij # a '.' (that is, objdump's representation of an unprintable 3649285612Sdelphij # character.) This should work for all archives with less than 3650285612Sdelphij # 0x302f exports -- but will fail for DLLs whose name actually 3651285612Sdelphij # begins with a literal '.' or a single character followed by 3652285612Sdelphij # a '.'. 3653285612Sdelphij # 3654285612Sdelphij # Of those that remain, print the first one. 3655285612Sdelphij $SED -e '/^\./d;/^.\./d;q' 3656285612Sdelphij} 3657285612Sdelphij 3658285612Sdelphij# func_cygming_gnu_implib_p ARG 3659285612Sdelphij# This predicate returns with zero status (TRUE) if 3660285612Sdelphij# ARG is a GNU/binutils-style import library. Returns 3661285612Sdelphij# with nonzero status (FALSE) otherwise. 3662285612Sdelphijfunc_cygming_gnu_implib_p () 3663285612Sdelphij{ 3664285612Sdelphij $opt_debug 3665285612Sdelphij func_to_tool_file "$1" func_convert_file_msys_to_w32 3666285612Sdelphij 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)$'` 3667285612Sdelphij test -n "$func_cygming_gnu_implib_tmp" 3668285612Sdelphij} 3669285612Sdelphij 3670285612Sdelphij# func_cygming_ms_implib_p ARG 3671285612Sdelphij# This predicate returns with zero status (TRUE) if 3672285612Sdelphij# ARG is an MS-style import library. Returns 3673285612Sdelphij# with nonzero status (FALSE) otherwise. 3674285612Sdelphijfunc_cygming_ms_implib_p () 3675285612Sdelphij{ 3676285612Sdelphij $opt_debug 3677285612Sdelphij func_to_tool_file "$1" func_convert_file_msys_to_w32 3678285612Sdelphij func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 3679285612Sdelphij test -n "$func_cygming_ms_implib_tmp" 3680285612Sdelphij} 3681285612Sdelphij 3682285612Sdelphij# func_cygming_dll_for_implib_fallback ARG 3683285612Sdelphij# Platform-specific function to extract the 3684285612Sdelphij# name of the DLL associated with the specified 3685285612Sdelphij# import library ARG. 3686285612Sdelphij# 3687285612Sdelphij# This fallback implementation is for use when $DLLTOOL 3688285612Sdelphij# does not support the --identify-strict option. 3689285612Sdelphij# Invoked by eval'ing the libtool variable 3690285612Sdelphij# $sharedlib_from_linklib_cmd 3691285612Sdelphij# Result is available in the variable 3692285612Sdelphij# $sharedlib_from_linklib_result 3693285612Sdelphijfunc_cygming_dll_for_implib_fallback () 3694285612Sdelphij{ 3695285612Sdelphij $opt_debug 3696285612Sdelphij if func_cygming_gnu_implib_p "$1" ; then 3697285612Sdelphij # binutils import library 3698285612Sdelphij sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 3699285612Sdelphij elif func_cygming_ms_implib_p "$1" ; then 3700285612Sdelphij # ms-generated import library 3701285612Sdelphij sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 3702285612Sdelphij else 3703285612Sdelphij # unknown 3704285612Sdelphij sharedlib_from_linklib_result="" 3705285612Sdelphij fi 3706285612Sdelphij} 3707285612Sdelphij 3708285612Sdelphij 3709285612Sdelphij# func_extract_an_archive dir oldlib 3710285612Sdelphijfunc_extract_an_archive () 3711285612Sdelphij{ 3712285612Sdelphij $opt_debug 3713285612Sdelphij f_ex_an_ar_dir="$1"; shift 3714285612Sdelphij f_ex_an_ar_oldlib="$1" 3715285612Sdelphij if test "$lock_old_archive_extraction" = yes; then 3716285612Sdelphij lockfile=$f_ex_an_ar_oldlib.lock 3717285612Sdelphij until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3718285612Sdelphij func_echo "Waiting for $lockfile to be removed" 3719285612Sdelphij sleep 2 3720285612Sdelphij done 3721285612Sdelphij fi 3722285612Sdelphij func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 3723285612Sdelphij 'stat=$?; rm -f "$lockfile"; exit $stat' 3724285612Sdelphij if test "$lock_old_archive_extraction" = yes; then 3725285612Sdelphij $opt_dry_run || rm -f "$lockfile" 3726285612Sdelphij fi 3727285612Sdelphij if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 3728285612Sdelphij : 3729285612Sdelphij else 3730285612Sdelphij func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 3731285612Sdelphij fi 3732285612Sdelphij} 3733285612Sdelphij 3734285612Sdelphij 3735285612Sdelphij# func_extract_archives gentop oldlib ... 3736285612Sdelphijfunc_extract_archives () 3737285612Sdelphij{ 3738285612Sdelphij $opt_debug 3739285612Sdelphij my_gentop="$1"; shift 3740285612Sdelphij my_oldlibs=${1+"$@"} 3741285612Sdelphij my_oldobjs="" 3742285612Sdelphij my_xlib="" 3743285612Sdelphij my_xabs="" 3744285612Sdelphij my_xdir="" 3745285612Sdelphij 3746285612Sdelphij for my_xlib in $my_oldlibs; do 3747285612Sdelphij # Extract the objects. 3748285612Sdelphij case $my_xlib in 3749285612Sdelphij [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;; 3750285612Sdelphij *) my_xabs=`pwd`"/$my_xlib" ;; 3751285612Sdelphij esac 3752285612Sdelphij func_basename "$my_xlib" 3753285612Sdelphij my_xlib="$func_basename_result" 3754285612Sdelphij my_xlib_u=$my_xlib 3755285612Sdelphij while :; do 3756285612Sdelphij case " $extracted_archives " in 3757285612Sdelphij *" $my_xlib_u "*) 3758285612Sdelphij func_arith $extracted_serial + 1 3759285612Sdelphij extracted_serial=$func_arith_result 3760285612Sdelphij my_xlib_u=lt$extracted_serial-$my_xlib ;; 3761285612Sdelphij *) break ;; 3762285612Sdelphij esac 3763285612Sdelphij done 3764285612Sdelphij extracted_archives="$extracted_archives $my_xlib_u" 3765285612Sdelphij my_xdir="$my_gentop/$my_xlib_u" 3766285612Sdelphij 3767285612Sdelphij func_mkdir_p "$my_xdir" 3768285612Sdelphij 3769285612Sdelphij case $host in 3770285612Sdelphij *-darwin*) 3771285612Sdelphij func_verbose "Extracting $my_xabs" 3772285612Sdelphij # Do not bother doing anything if just a dry run 3773285612Sdelphij $opt_dry_run || { 3774285612Sdelphij darwin_orig_dir=`pwd` 3775285612Sdelphij cd $my_xdir || exit $? 3776285612Sdelphij darwin_archive=$my_xabs 3777285612Sdelphij darwin_curdir=`pwd` 3778285612Sdelphij darwin_base_archive=`basename "$darwin_archive"` 3779285612Sdelphij darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 3780285612Sdelphij if test -n "$darwin_arches"; then 3781285612Sdelphij darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 3782285612Sdelphij darwin_arch= 3783285612Sdelphij func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 3784285612Sdelphij for darwin_arch in $darwin_arches ; do 3785285612Sdelphij func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3786285612Sdelphij $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}" 3787285612Sdelphij cd "unfat-$$/${darwin_base_archive}-${darwin_arch}" 3788285612Sdelphij func_extract_an_archive "`pwd`" "${darwin_base_archive}" 3789285612Sdelphij cd "$darwin_curdir" 3790285612Sdelphij $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" 3791285612Sdelphij done # $darwin_arches 3792285612Sdelphij ## Okay now we've a bunch of thin objects, gotta fatten them up :) 3793285612Sdelphij darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u` 3794285612Sdelphij darwin_file= 3795285612Sdelphij darwin_files= 3796285612Sdelphij for darwin_file in $darwin_filelist; do 3797285612Sdelphij darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 3798285612Sdelphij $LIPO -create -output "$darwin_file" $darwin_files 3799285612Sdelphij done # $darwin_filelist 3800285612Sdelphij $RM -rf unfat-$$ 3801285612Sdelphij cd "$darwin_orig_dir" 3802285612Sdelphij else 3803285612Sdelphij cd $darwin_orig_dir 3804285612Sdelphij func_extract_an_archive "$my_xdir" "$my_xabs" 3805285612Sdelphij fi # $darwin_arches 3806285612Sdelphij } # !$opt_dry_run 3807285612Sdelphij ;; 3808285612Sdelphij *) 3809285612Sdelphij func_extract_an_archive "$my_xdir" "$my_xabs" 3810285612Sdelphij ;; 3811285612Sdelphij esac 3812285612Sdelphij my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 3813285612Sdelphij done 3814285612Sdelphij 3815285612Sdelphij func_extract_archives_result="$my_oldobjs" 3816285612Sdelphij} 3817285612Sdelphij 3818285612Sdelphij 3819285612Sdelphij# func_emit_wrapper [arg=no] 3820285612Sdelphij# 3821285612Sdelphij# Emit a libtool wrapper script on stdout. 3822285612Sdelphij# Don't directly open a file because we may want to 3823285612Sdelphij# incorporate the script contents within a cygwin/mingw 3824285612Sdelphij# wrapper executable. Must ONLY be called from within 3825285612Sdelphij# func_mode_link because it depends on a number of variables 3826285612Sdelphij# set therein. 3827285612Sdelphij# 3828285612Sdelphij# ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 3829285612Sdelphij# variable will take. If 'yes', then the emitted script 3830285612Sdelphij# will assume that the directory in which it is stored is 3831285612Sdelphij# the $objdir directory. This is a cygwin/mingw-specific 3832285612Sdelphij# behavior. 3833285612Sdelphijfunc_emit_wrapper () 3834285612Sdelphij{ 3835285612Sdelphij func_emit_wrapper_arg1=${1-no} 3836285612Sdelphij 3837285612Sdelphij $ECHO "\ 3838285612Sdelphij#! $SHELL 3839285612Sdelphij 3840285612Sdelphij# $output - temporary wrapper script for $objdir/$outputname 3841285612Sdelphij# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 3842285612Sdelphij# 3843285612Sdelphij# The $output program cannot be directly executed until all the libtool 3844285612Sdelphij# libraries that it depends on are installed. 3845285612Sdelphij# 3846285612Sdelphij# This wrapper script should never be moved out of the build directory. 3847285612Sdelphij# If it is, it will not operate correctly. 3848285612Sdelphij 3849285612Sdelphij# Sed substitution that helps us do robust quoting. It backslashifies 3850285612Sdelphij# metacharacters that are still active within double-quoted strings. 3851285612Sdelphijsed_quote_subst='$sed_quote_subst' 3852285612Sdelphij 3853285612Sdelphij# Be Bourne compatible 3854285612Sdelphijif test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 3855285612Sdelphij emulate sh 3856285612Sdelphij NULLCMD=: 3857285612Sdelphij # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 3858285612Sdelphij # is contrary to our usage. Disable this feature. 3859285612Sdelphij alias -g '\${1+\"\$@\"}'='\"\$@\"' 3860285612Sdelphij setopt NO_GLOB_SUBST 3861285612Sdelphijelse 3862285612Sdelphij case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 3863285612Sdelphijfi 3864285612SdelphijBIN_SH=xpg4; export BIN_SH # for Tru64 3865285612SdelphijDUALCASE=1; export DUALCASE # for MKS sh 3866285612Sdelphij 3867285612Sdelphij# The HP-UX ksh and POSIX shell print the target directory to stdout 3868285612Sdelphij# if CDPATH is set. 3869285612Sdelphij(unset CDPATH) >/dev/null 2>&1 && unset CDPATH 3870285612Sdelphij 3871285612Sdelphijrelink_command=\"$relink_command\" 3872285612Sdelphij 3873285612Sdelphij# This environment variable determines our operation mode. 3874285612Sdelphijif test \"\$libtool_install_magic\" = \"$magic\"; then 3875285612Sdelphij # install mode needs the following variables: 3876285612Sdelphij generated_by_libtool_version='$macro_version' 3877285612Sdelphij notinst_deplibs='$notinst_deplibs' 3878285612Sdelphijelse 3879285612Sdelphij # When we are sourced in execute mode, \$file and \$ECHO are already set. 3880285612Sdelphij if test \"\$libtool_execute_magic\" != \"$magic\"; then 3881285612Sdelphij file=\"\$0\"" 3882285612Sdelphij 3883285612Sdelphij qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"` 3884285612Sdelphij $ECHO "\ 3885285612Sdelphij 3886285612Sdelphij# A function that is used when there is no print builtin or printf. 3887285612Sdelphijfunc_fallback_echo () 3888285612Sdelphij{ 3889285612Sdelphij eval 'cat <<_LTECHO_EOF 3890285612Sdelphij\$1 3891285612Sdelphij_LTECHO_EOF' 3892285612Sdelphij} 3893285612Sdelphij ECHO=\"$qECHO\" 3894285612Sdelphij fi 3895285612Sdelphij 3896285612Sdelphij# Very basic option parsing. These options are (a) specific to 3897285612Sdelphij# the libtool wrapper, (b) are identical between the wrapper 3898285612Sdelphij# /script/ and the wrapper /executable/ which is used only on 3899285612Sdelphij# windows platforms, and (c) all begin with the string "--lt-" 3900285612Sdelphij# (application programs are unlikely to have options which match 3901285612Sdelphij# this pattern). 3902285612Sdelphij# 3903285612Sdelphij# There are only two supported options: --lt-debug and 3904285612Sdelphij# --lt-dump-script. There is, deliberately, no --lt-help. 3905285612Sdelphij# 3906285612Sdelphij# The first argument to this parsing function should be the 3907285612Sdelphij# script's $0 value, followed by "$@". 3908285612Sdelphijlt_option_debug= 3909285612Sdelphijfunc_parse_lt_options () 3910285612Sdelphij{ 3911285612Sdelphij lt_script_arg0=\$0 3912285612Sdelphij shift 3913285612Sdelphij for lt_opt 3914285612Sdelphij do 3915285612Sdelphij case \"\$lt_opt\" in 3916285612Sdelphij --lt-debug) lt_option_debug=1 ;; 3917285612Sdelphij --lt-dump-script) 3918285612Sdelphij lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 3919285612Sdelphij test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 3920285612Sdelphij lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 3921285612Sdelphij cat \"\$lt_dump_D/\$lt_dump_F\" 3922285612Sdelphij exit 0 3923285612Sdelphij ;; 3924285612Sdelphij --lt-*) 3925285612Sdelphij \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 3926285612Sdelphij exit 1 3927285612Sdelphij ;; 3928285612Sdelphij esac 3929285612Sdelphij done 3930285612Sdelphij 3931285612Sdelphij # Print the debug banner immediately: 3932285612Sdelphij if test -n \"\$lt_option_debug\"; then 3933285612Sdelphij echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2 3934285612Sdelphij fi 3935285612Sdelphij} 3936285612Sdelphij 3937285612Sdelphij# Used when --lt-debug. Prints its arguments to stdout 3938285612Sdelphij# (redirection is the responsibility of the caller) 3939285612Sdelphijfunc_lt_dump_args () 3940285612Sdelphij{ 3941285612Sdelphij lt_dump_args_N=1; 3942285612Sdelphij for lt_arg 3943285612Sdelphij do 3944285612Sdelphij \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\" 3945285612Sdelphij lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 3946285612Sdelphij done 3947285612Sdelphij} 3948285612Sdelphij 3949285612Sdelphij# Core function for launching the target application 3950285612Sdelphijfunc_exec_program_core () 3951285612Sdelphij{ 3952285612Sdelphij" 3953285612Sdelphij case $host in 3954285612Sdelphij # Backslashes separate directories on plain windows 3955285612Sdelphij *-*-mingw | *-*-os2* | *-cegcc*) 3956285612Sdelphij $ECHO "\ 3957285612Sdelphij if test -n \"\$lt_option_debug\"; then 3958285612Sdelphij \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2 3959285612Sdelphij func_lt_dump_args \${1+\"\$@\"} 1>&2 3960285612Sdelphij fi 3961285612Sdelphij exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 3962285612Sdelphij" 3963285612Sdelphij ;; 3964285612Sdelphij 3965285612Sdelphij *) 3966285612Sdelphij $ECHO "\ 3967285612Sdelphij if test -n \"\$lt_option_debug\"; then 3968285612Sdelphij \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2 3969285612Sdelphij func_lt_dump_args \${1+\"\$@\"} 1>&2 3970285612Sdelphij fi 3971285612Sdelphij exec \"\$progdir/\$program\" \${1+\"\$@\"} 3972285612Sdelphij" 3973285612Sdelphij ;; 3974285612Sdelphij esac 3975285612Sdelphij $ECHO "\ 3976285612Sdelphij \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 3977285612Sdelphij exit 1 3978285612Sdelphij} 3979285612Sdelphij 3980285612Sdelphij# A function to encapsulate launching the target application 3981285612Sdelphij# Strips options in the --lt-* namespace from \$@ and 3982285612Sdelphij# launches target application with the remaining arguments. 3983285612Sdelphijfunc_exec_program () 3984285612Sdelphij{ 3985285612Sdelphij for lt_wr_arg 3986285612Sdelphij do 3987285612Sdelphij case \$lt_wr_arg in 3988285612Sdelphij --lt-*) ;; 3989285612Sdelphij *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 3990285612Sdelphij esac 3991285612Sdelphij shift 3992285612Sdelphij done 3993285612Sdelphij func_exec_program_core \${1+\"\$@\"} 3994285612Sdelphij} 3995285612Sdelphij 3996285612Sdelphij # Parse options 3997285612Sdelphij func_parse_lt_options \"\$0\" \${1+\"\$@\"} 3998285612Sdelphij 3999285612Sdelphij # Find the directory that this script lives in. 4000285612Sdelphij thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 4001285612Sdelphij test \"x\$thisdir\" = \"x\$file\" && thisdir=. 4002285612Sdelphij 4003285612Sdelphij # Follow symbolic links until we get to the real thisdir. 4004285612Sdelphij file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 4005285612Sdelphij while test -n \"\$file\"; do 4006285612Sdelphij destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 4007285612Sdelphij 4008285612Sdelphij # If there was a directory component, then change thisdir. 4009285612Sdelphij if test \"x\$destdir\" != \"x\$file\"; then 4010285612Sdelphij case \"\$destdir\" in 4011285612Sdelphij [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 4012285612Sdelphij *) thisdir=\"\$thisdir/\$destdir\" ;; 4013285612Sdelphij esac 4014285612Sdelphij fi 4015285612Sdelphij 4016285612Sdelphij file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 4017285612Sdelphij file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 4018285612Sdelphij done 4019285612Sdelphij 4020285612Sdelphij # Usually 'no', except on cygwin/mingw when embedded into 4021285612Sdelphij # the cwrapper. 4022285612Sdelphij WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 4023285612Sdelphij if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 4024285612Sdelphij # special case for '.' 4025285612Sdelphij if test \"\$thisdir\" = \".\"; then 4026285612Sdelphij thisdir=\`pwd\` 4027285612Sdelphij fi 4028285612Sdelphij # remove .libs from thisdir 4029285612Sdelphij case \"\$thisdir\" in 4030285612Sdelphij *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 4031285612Sdelphij $objdir ) thisdir=. ;; 4032285612Sdelphij esac 4033285612Sdelphij fi 4034285612Sdelphij 4035285612Sdelphij # Try to get the absolute directory name. 4036285612Sdelphij absdir=\`cd \"\$thisdir\" && pwd\` 4037285612Sdelphij test -n \"\$absdir\" && thisdir=\"\$absdir\" 4038285612Sdelphij" 4039285612Sdelphij 4040285612Sdelphij if test "$fast_install" = yes; then 4041285612Sdelphij $ECHO "\ 4042285612Sdelphij program=lt-'$outputname'$exeext 4043285612Sdelphij progdir=\"\$thisdir/$objdir\" 4044285612Sdelphij 4045285612Sdelphij if test ! -f \"\$progdir/\$program\" || 4046285612Sdelphij { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\ 4047285612Sdelphij test \"X\$file\" != \"X\$progdir/\$program\"; }; then 4048285612Sdelphij 4049285612Sdelphij file=\"\$\$-\$program\" 4050285612Sdelphij 4051285612Sdelphij if test ! -d \"\$progdir\"; then 4052285612Sdelphij $MKDIR \"\$progdir\" 4053285612Sdelphij else 4054285612Sdelphij $RM \"\$progdir/\$file\" 4055285612Sdelphij fi" 4056285612Sdelphij 4057285612Sdelphij $ECHO "\ 4058285612Sdelphij 4059285612Sdelphij # relink executable if necessary 4060285612Sdelphij if test -n \"\$relink_command\"; then 4061285612Sdelphij if relink_command_output=\`eval \$relink_command 2>&1\`; then : 4062285612Sdelphij else 4063285612Sdelphij $ECHO \"\$relink_command_output\" >&2 4064285612Sdelphij $RM \"\$progdir/\$file\" 4065285612Sdelphij exit 1 4066285612Sdelphij fi 4067285612Sdelphij fi 4068285612Sdelphij 4069285612Sdelphij $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 4070285612Sdelphij { $RM \"\$progdir/\$program\"; 4071285612Sdelphij $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 4072285612Sdelphij $RM \"\$progdir/\$file\" 4073285612Sdelphij fi" 4074285612Sdelphij else 4075285612Sdelphij $ECHO "\ 4076285612Sdelphij program='$outputname' 4077285612Sdelphij progdir=\"\$thisdir/$objdir\" 4078285612Sdelphij" 4079285612Sdelphij fi 4080285612Sdelphij 4081285612Sdelphij $ECHO "\ 4082285612Sdelphij 4083285612Sdelphij if test -f \"\$progdir/\$program\"; then" 4084285612Sdelphij 4085285612Sdelphij # fixup the dll searchpath if we need to. 4086285612Sdelphij # 4087285612Sdelphij # Fix the DLL searchpath if we need to. Do this before prepending 4088285612Sdelphij # to shlibpath, because on Windows, both are PATH and uninstalled 4089285612Sdelphij # libraries must come first. 4090285612Sdelphij if test -n "$dllsearchpath"; then 4091285612Sdelphij $ECHO "\ 4092285612Sdelphij # Add the dll search path components to the executable PATH 4093285612Sdelphij PATH=$dllsearchpath:\$PATH 4094285612Sdelphij" 4095285612Sdelphij fi 4096285612Sdelphij 4097285612Sdelphij # Export our shlibpath_var if we have one. 4098285612Sdelphij if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4099285612Sdelphij $ECHO "\ 4100285612Sdelphij # Add our own library path to $shlibpath_var 4101285612Sdelphij $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 4102285612Sdelphij 4103285612Sdelphij # Some systems cannot cope with colon-terminated $shlibpath_var 4104285612Sdelphij # The second colon is a workaround for a bug in BeOS R4 sed 4105285612Sdelphij $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 4106285612Sdelphij 4107285612Sdelphij export $shlibpath_var 4108285612Sdelphij" 4109285612Sdelphij fi 4110285612Sdelphij 4111285612Sdelphij $ECHO "\ 4112285612Sdelphij if test \"\$libtool_execute_magic\" != \"$magic\"; then 4113285612Sdelphij # Run the actual program with our arguments. 4114285612Sdelphij func_exec_program \${1+\"\$@\"} 4115285612Sdelphij fi 4116285612Sdelphij else 4117285612Sdelphij # The program doesn't exist. 4118285612Sdelphij \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2 4119285612Sdelphij \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 4120285612Sdelphij \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 4121285612Sdelphij exit 1 4122285612Sdelphij fi 4123285612Sdelphijfi\ 4124285612Sdelphij" 4125285612Sdelphij} 4126285612Sdelphij 4127285612Sdelphij 4128285612Sdelphij# func_emit_cwrapperexe_src 4129285612Sdelphij# emit the source code for a wrapper executable on stdout 4130285612Sdelphij# Must ONLY be called from within func_mode_link because 4131285612Sdelphij# it depends on a number of variable set therein. 4132285612Sdelphijfunc_emit_cwrapperexe_src () 4133285612Sdelphij{ 4134285612Sdelphij cat <<EOF 4135285612Sdelphij 4136285612Sdelphij/* $cwrappersource - temporary wrapper executable for $objdir/$outputname 4137285612Sdelphij Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 4138285612Sdelphij 4139285612Sdelphij The $output program cannot be directly executed until all the libtool 4140285612Sdelphij libraries that it depends on are installed. 4141285612Sdelphij 4142285612Sdelphij This wrapper executable should never be moved out of the build directory. 4143285612Sdelphij If it is, it will not operate correctly. 4144285612Sdelphij*/ 4145285612SdelphijEOF 4146285612Sdelphij cat <<"EOF" 4147285612Sdelphij#ifdef _MSC_VER 4148285612Sdelphij# define _CRT_SECURE_NO_DEPRECATE 1 4149285612Sdelphij#endif 4150285612Sdelphij#include <stdio.h> 4151285612Sdelphij#include <stdlib.h> 4152285612Sdelphij#ifdef _MSC_VER 4153285612Sdelphij# include <direct.h> 4154285612Sdelphij# include <process.h> 4155285612Sdelphij# include <io.h> 4156285612Sdelphij#else 4157285612Sdelphij# include <unistd.h> 4158285612Sdelphij# include <stdint.h> 4159285612Sdelphij# ifdef __CYGWIN__ 4160285612Sdelphij# include <io.h> 4161285612Sdelphij# endif 4162285612Sdelphij#endif 4163285612Sdelphij#include <malloc.h> 4164285612Sdelphij#include <stdarg.h> 4165285612Sdelphij#include <assert.h> 4166285612Sdelphij#include <string.h> 4167285612Sdelphij#include <ctype.h> 4168285612Sdelphij#include <errno.h> 4169285612Sdelphij#include <fcntl.h> 4170285612Sdelphij#include <sys/stat.h> 4171285612Sdelphij 4172285612Sdelphij/* declarations of non-ANSI functions */ 4173285612Sdelphij#if defined(__MINGW32__) 4174285612Sdelphij# ifdef __STRICT_ANSI__ 4175285612Sdelphijint _putenv (const char *); 4176285612Sdelphij# endif 4177285612Sdelphij#elif defined(__CYGWIN__) 4178285612Sdelphij# ifdef __STRICT_ANSI__ 4179285612Sdelphijchar *realpath (const char *, char *); 4180285612Sdelphijint putenv (char *); 4181285612Sdelphijint setenv (const char *, const char *, int); 4182285612Sdelphij# endif 4183285612Sdelphij/* #elif defined (other platforms) ... */ 4184285612Sdelphij#endif 4185285612Sdelphij 4186285612Sdelphij/* portability defines, excluding path handling macros */ 4187285612Sdelphij#if defined(_MSC_VER) 4188285612Sdelphij# define setmode _setmode 4189285612Sdelphij# define stat _stat 4190285612Sdelphij# define chmod _chmod 4191285612Sdelphij# define getcwd _getcwd 4192285612Sdelphij# define putenv _putenv 4193285612Sdelphij# define S_IXUSR _S_IEXEC 4194285612Sdelphij# ifndef _INTPTR_T_DEFINED 4195285612Sdelphij# define _INTPTR_T_DEFINED 4196285612Sdelphij# define intptr_t int 4197285612Sdelphij# endif 4198285612Sdelphij#elif defined(__MINGW32__) 4199285612Sdelphij# define setmode _setmode 4200285612Sdelphij# define stat _stat 4201285612Sdelphij# define chmod _chmod 4202285612Sdelphij# define getcwd _getcwd 4203285612Sdelphij# define putenv _putenv 4204285612Sdelphij#elif defined(__CYGWIN__) 4205285612Sdelphij# define HAVE_SETENV 4206285612Sdelphij# define FOPEN_WB "wb" 4207285612Sdelphij/* #elif defined (other platforms) ... */ 4208285612Sdelphij#endif 4209285612Sdelphij 4210285612Sdelphij#if defined(PATH_MAX) 4211285612Sdelphij# define LT_PATHMAX PATH_MAX 4212285612Sdelphij#elif defined(MAXPATHLEN) 4213285612Sdelphij# define LT_PATHMAX MAXPATHLEN 4214285612Sdelphij#else 4215285612Sdelphij# define LT_PATHMAX 1024 4216285612Sdelphij#endif 4217285612Sdelphij 4218285612Sdelphij#ifndef S_IXOTH 4219285612Sdelphij# define S_IXOTH 0 4220285612Sdelphij#endif 4221285612Sdelphij#ifndef S_IXGRP 4222285612Sdelphij# define S_IXGRP 0 4223285612Sdelphij#endif 4224285612Sdelphij 4225285612Sdelphij/* path handling portability macros */ 4226285612Sdelphij#ifndef DIR_SEPARATOR 4227285612Sdelphij# define DIR_SEPARATOR '/' 4228285612Sdelphij# define PATH_SEPARATOR ':' 4229285612Sdelphij#endif 4230285612Sdelphij 4231285612Sdelphij#if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \ 4232285612Sdelphij defined (__OS2__) 4233285612Sdelphij# define HAVE_DOS_BASED_FILE_SYSTEM 4234285612Sdelphij# define FOPEN_WB "wb" 4235285612Sdelphij# ifndef DIR_SEPARATOR_2 4236285612Sdelphij# define DIR_SEPARATOR_2 '\\' 4237285612Sdelphij# endif 4238285612Sdelphij# ifndef PATH_SEPARATOR_2 4239285612Sdelphij# define PATH_SEPARATOR_2 ';' 4240285612Sdelphij# endif 4241285612Sdelphij#endif 4242285612Sdelphij 4243285612Sdelphij#ifndef DIR_SEPARATOR_2 4244285612Sdelphij# define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 4245285612Sdelphij#else /* DIR_SEPARATOR_2 */ 4246285612Sdelphij# define IS_DIR_SEPARATOR(ch) \ 4247285612Sdelphij (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 4248285612Sdelphij#endif /* DIR_SEPARATOR_2 */ 4249285612Sdelphij 4250285612Sdelphij#ifndef PATH_SEPARATOR_2 4251285612Sdelphij# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 4252285612Sdelphij#else /* PATH_SEPARATOR_2 */ 4253285612Sdelphij# define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 4254285612Sdelphij#endif /* PATH_SEPARATOR_2 */ 4255285612Sdelphij 4256285612Sdelphij#ifndef FOPEN_WB 4257285612Sdelphij# define FOPEN_WB "w" 4258285612Sdelphij#endif 4259285612Sdelphij#ifndef _O_BINARY 4260285612Sdelphij# define _O_BINARY 0 4261285612Sdelphij#endif 4262285612Sdelphij 4263285612Sdelphij#define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 4264285612Sdelphij#define XFREE(stale) do { \ 4265285612Sdelphij if (stale) { free ((void *) stale); stale = 0; } \ 4266285612Sdelphij} while (0) 4267285612Sdelphij 4268285612Sdelphij#if defined(LT_DEBUGWRAPPER) 4269285612Sdelphijstatic int lt_debug = 1; 4270285612Sdelphij#else 4271285612Sdelphijstatic int lt_debug = 0; 4272285612Sdelphij#endif 4273285612Sdelphij 4274285612Sdelphijconst char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 4275285612Sdelphij 4276285612Sdelphijvoid *xmalloc (size_t num); 4277285612Sdelphijchar *xstrdup (const char *string); 4278285612Sdelphijconst char *base_name (const char *name); 4279285612Sdelphijchar *find_executable (const char *wrapper); 4280285612Sdelphijchar *chase_symlinks (const char *pathspec); 4281285612Sdelphijint make_executable (const char *path); 4282285612Sdelphijint check_executable (const char *path); 4283285612Sdelphijchar *strendzap (char *str, const char *pat); 4284285612Sdelphijvoid lt_debugprintf (const char *file, int line, const char *fmt, ...); 4285285612Sdelphijvoid lt_fatal (const char *file, int line, const char *message, ...); 4286285612Sdelphijstatic const char *nonnull (const char *s); 4287285612Sdelphijstatic const char *nonempty (const char *s); 4288285612Sdelphijvoid lt_setenv (const char *name, const char *value); 4289285612Sdelphijchar *lt_extend_str (const char *orig_value, const char *add, int to_end); 4290285612Sdelphijvoid lt_update_exe_path (const char *name, const char *value); 4291285612Sdelphijvoid lt_update_lib_path (const char *name, const char *value); 4292285612Sdelphijchar **prepare_spawn (char **argv); 4293285612Sdelphijvoid lt_dump_script (FILE *f); 4294285612SdelphijEOF 4295285612Sdelphij 4296285612Sdelphij cat <<EOF 4297285612Sdelphijvolatile const char * MAGIC_EXE = "$magic_exe"; 4298285612Sdelphijconst char * LIB_PATH_VARNAME = "$shlibpath_var"; 4299285612SdelphijEOF 4300285612Sdelphij 4301285612Sdelphij if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 4302285612Sdelphij func_to_host_path "$temp_rpath" 4303285612Sdelphij cat <<EOF 4304285612Sdelphijconst char * LIB_PATH_VALUE = "$func_to_host_path_result"; 4305285612SdelphijEOF 4306285612Sdelphij else 4307285612Sdelphij cat <<"EOF" 4308285612Sdelphijconst char * LIB_PATH_VALUE = ""; 4309285612SdelphijEOF 4310285612Sdelphij fi 4311285612Sdelphij 4312285612Sdelphij if test -n "$dllsearchpath"; then 4313285612Sdelphij func_to_host_path "$dllsearchpath:" 4314285612Sdelphij cat <<EOF 4315285612Sdelphijconst char * EXE_PATH_VARNAME = "PATH"; 4316285612Sdelphijconst char * EXE_PATH_VALUE = "$func_to_host_path_result"; 4317285612SdelphijEOF 4318285612Sdelphij else 4319285612Sdelphij cat <<"EOF" 4320285612Sdelphijconst char * EXE_PATH_VARNAME = ""; 4321285612Sdelphijconst char * EXE_PATH_VALUE = ""; 4322285612SdelphijEOF 4323285612Sdelphij fi 4324285612Sdelphij 4325285612Sdelphij if test "$fast_install" = yes; then 4326285612Sdelphij cat <<EOF 4327285612Sdelphijconst char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 4328285612SdelphijEOF 4329285612Sdelphij else 4330285612Sdelphij cat <<EOF 4331285612Sdelphijconst char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 4332285612SdelphijEOF 4333285612Sdelphij fi 4334285612Sdelphij 4335285612Sdelphij 4336285612Sdelphij cat <<"EOF" 4337285612Sdelphij 4338285612Sdelphij#define LTWRAPPER_OPTION_PREFIX "--lt-" 4339285612Sdelphij 4340285612Sdelphijstatic const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 4341285612Sdelphijstatic const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 4342285612Sdelphijstatic const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 4343285612Sdelphij 4344285612Sdelphijint 4345285612Sdelphijmain (int argc, char *argv[]) 4346285612Sdelphij{ 4347285612Sdelphij char **newargz; 4348285612Sdelphij int newargc; 4349285612Sdelphij char *tmp_pathspec; 4350285612Sdelphij char *actual_cwrapper_path; 4351285612Sdelphij char *actual_cwrapper_name; 4352285612Sdelphij char *target_name; 4353285612Sdelphij char *lt_argv_zero; 4354285612Sdelphij intptr_t rval = 127; 4355285612Sdelphij 4356285612Sdelphij int i; 4357285612Sdelphij 4358285612Sdelphij program_name = (char *) xstrdup (base_name (argv[0])); 4359285612Sdelphij newargz = XMALLOC (char *, argc + 1); 4360285612Sdelphij 4361285612Sdelphij /* very simple arg parsing; don't want to rely on getopt 4362285612Sdelphij * also, copy all non cwrapper options to newargz, except 4363285612Sdelphij * argz[0], which is handled differently 4364285612Sdelphij */ 4365285612Sdelphij newargc=0; 4366285612Sdelphij for (i = 1; i < argc; i++) 4367285612Sdelphij { 4368285612Sdelphij if (strcmp (argv[i], dumpscript_opt) == 0) 4369285612Sdelphij { 4370285612SdelphijEOF 4371285612Sdelphij case "$host" in 4372285612Sdelphij *mingw* | *cygwin* ) 4373285612Sdelphij # make stdout use "unix" line endings 4374285612Sdelphij echo " setmode(1,_O_BINARY);" 4375285612Sdelphij ;; 4376285612Sdelphij esac 4377285612Sdelphij 4378285612Sdelphij cat <<"EOF" 4379285612Sdelphij lt_dump_script (stdout); 4380285612Sdelphij return 0; 4381285612Sdelphij } 4382285612Sdelphij if (strcmp (argv[i], debug_opt) == 0) 4383285612Sdelphij { 4384285612Sdelphij lt_debug = 1; 4385285612Sdelphij continue; 4386285612Sdelphij } 4387285612Sdelphij if (strcmp (argv[i], ltwrapper_option_prefix) == 0) 4388285612Sdelphij { 4389285612Sdelphij /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 4390285612Sdelphij namespace, but it is not one of the ones we know about and 4391285612Sdelphij have already dealt with, above (inluding dump-script), then 4392285612Sdelphij report an error. Otherwise, targets might begin to believe 4393285612Sdelphij they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 4394285612Sdelphij namespace. The first time any user complains about this, we'll 4395285612Sdelphij need to make LTWRAPPER_OPTION_PREFIX a configure-time option 4396285612Sdelphij or a configure.ac-settable value. 4397285612Sdelphij */ 4398285612Sdelphij lt_fatal (__FILE__, __LINE__, 4399285612Sdelphij "unrecognized %s option: '%s'", 4400285612Sdelphij ltwrapper_option_prefix, argv[i]); 4401285612Sdelphij } 4402285612Sdelphij /* otherwise ... */ 4403285612Sdelphij newargz[++newargc] = xstrdup (argv[i]); 4404285612Sdelphij } 4405285612Sdelphij newargz[++newargc] = NULL; 4406285612Sdelphij 4407285612SdelphijEOF 4408285612Sdelphij cat <<EOF 4409285612Sdelphij /* The GNU banner must be the first non-error debug message */ 4410285612Sdelphij lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n"); 4411285612SdelphijEOF 4412285612Sdelphij cat <<"EOF" 4413285612Sdelphij lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 4414285612Sdelphij lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 4415285612Sdelphij 4416285612Sdelphij tmp_pathspec = find_executable (argv[0]); 4417285612Sdelphij if (tmp_pathspec == NULL) 4418285612Sdelphij lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 4419285612Sdelphij lt_debugprintf (__FILE__, __LINE__, 4420285612Sdelphij "(main) found exe (before symlink chase) at: %s\n", 4421285612Sdelphij tmp_pathspec); 4422285612Sdelphij 4423285612Sdelphij actual_cwrapper_path = chase_symlinks (tmp_pathspec); 4424285612Sdelphij lt_debugprintf (__FILE__, __LINE__, 4425285612Sdelphij "(main) found exe (after symlink chase) at: %s\n", 4426285612Sdelphij actual_cwrapper_path); 4427285612Sdelphij XFREE (tmp_pathspec); 4428285612Sdelphij 4429285612Sdelphij actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 4430285612Sdelphij strendzap (actual_cwrapper_path, actual_cwrapper_name); 4431285612Sdelphij 4432285612Sdelphij /* wrapper name transforms */ 4433285612Sdelphij strendzap (actual_cwrapper_name, ".exe"); 4434285612Sdelphij tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 4435285612Sdelphij XFREE (actual_cwrapper_name); 4436285612Sdelphij actual_cwrapper_name = tmp_pathspec; 4437285612Sdelphij tmp_pathspec = 0; 4438285612Sdelphij 4439285612Sdelphij /* target_name transforms -- use actual target program name; might have lt- prefix */ 4440285612Sdelphij target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 4441285612Sdelphij strendzap (target_name, ".exe"); 4442285612Sdelphij tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 4443285612Sdelphij XFREE (target_name); 4444285612Sdelphij target_name = tmp_pathspec; 4445285612Sdelphij tmp_pathspec = 0; 4446285612Sdelphij 4447285612Sdelphij lt_debugprintf (__FILE__, __LINE__, 4448285612Sdelphij "(main) libtool target name: %s\n", 4449285612Sdelphij target_name); 4450285612SdelphijEOF 4451285612Sdelphij 4452285612Sdelphij cat <<EOF 4453285612Sdelphij newargz[0] = 4454285612Sdelphij XMALLOC (char, (strlen (actual_cwrapper_path) + 4455285612Sdelphij strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 4456285612Sdelphij strcpy (newargz[0], actual_cwrapper_path); 4457285612Sdelphij strcat (newargz[0], "$objdir"); 4458285612Sdelphij strcat (newargz[0], "/"); 4459285612SdelphijEOF 4460285612Sdelphij 4461285612Sdelphij cat <<"EOF" 4462285612Sdelphij /* stop here, and copy so we don't have to do this twice */ 4463285612Sdelphij tmp_pathspec = xstrdup (newargz[0]); 4464285612Sdelphij 4465285612Sdelphij /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 4466285612Sdelphij strcat (newargz[0], actual_cwrapper_name); 4467285612Sdelphij 4468285612Sdelphij /* DO want the lt- prefix here if it exists, so use target_name */ 4469285612Sdelphij lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 4470285612Sdelphij XFREE (tmp_pathspec); 4471285612Sdelphij tmp_pathspec = NULL; 4472285612SdelphijEOF 4473285612Sdelphij 4474285612Sdelphij case $host_os in 4475285612Sdelphij mingw*) 4476285612Sdelphij cat <<"EOF" 4477285612Sdelphij { 4478285612Sdelphij char* p; 4479285612Sdelphij while ((p = strchr (newargz[0], '\\')) != NULL) 4480285612Sdelphij { 4481285612Sdelphij *p = '/'; 4482285612Sdelphij } 4483285612Sdelphij while ((p = strchr (lt_argv_zero, '\\')) != NULL) 4484285612Sdelphij { 4485285612Sdelphij *p = '/'; 4486285612Sdelphij } 4487285612Sdelphij } 4488285612SdelphijEOF 4489285612Sdelphij ;; 4490285612Sdelphij esac 4491285612Sdelphij 4492285612Sdelphij cat <<"EOF" 4493285612Sdelphij XFREE (target_name); 4494285612Sdelphij XFREE (actual_cwrapper_path); 4495285612Sdelphij XFREE (actual_cwrapper_name); 4496285612Sdelphij 4497285612Sdelphij lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 4498285612Sdelphij lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 4499285612Sdelphij /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 4500285612Sdelphij be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 4501285612Sdelphij because on Windows, both *_VARNAMEs are PATH but uninstalled 4502285612Sdelphij libraries must come first. */ 4503285612Sdelphij lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 4504285612Sdelphij lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 4505285612Sdelphij 4506285612Sdelphij lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 4507285612Sdelphij nonnull (lt_argv_zero)); 4508285612Sdelphij for (i = 0; i < newargc; i++) 4509285612Sdelphij { 4510285612Sdelphij lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 4511285612Sdelphij i, nonnull (newargz[i])); 4512285612Sdelphij } 4513285612Sdelphij 4514285612SdelphijEOF 4515285612Sdelphij 4516285612Sdelphij case $host_os in 4517285612Sdelphij mingw*) 4518285612Sdelphij cat <<"EOF" 4519285612Sdelphij /* execv doesn't actually work on mingw as expected on unix */ 4520285612Sdelphij newargz = prepare_spawn (newargz); 4521285612Sdelphij rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 4522285612Sdelphij if (rval == -1) 4523285612Sdelphij { 4524285612Sdelphij /* failed to start process */ 4525285612Sdelphij lt_debugprintf (__FILE__, __LINE__, 4526285612Sdelphij "(main) failed to launch target \"%s\": %s\n", 4527285612Sdelphij lt_argv_zero, nonnull (strerror (errno))); 4528285612Sdelphij return 127; 4529285612Sdelphij } 4530285612Sdelphij return rval; 4531285612SdelphijEOF 4532285612Sdelphij ;; 4533285612Sdelphij *) 4534285612Sdelphij cat <<"EOF" 4535285612Sdelphij execv (lt_argv_zero, newargz); 4536285612Sdelphij return rval; /* =127, but avoids unused variable warning */ 4537285612SdelphijEOF 4538285612Sdelphij ;; 4539285612Sdelphij esac 4540285612Sdelphij 4541285612Sdelphij cat <<"EOF" 4542285612Sdelphij} 4543285612Sdelphij 4544285612Sdelphijvoid * 4545285612Sdelphijxmalloc (size_t num) 4546285612Sdelphij{ 4547285612Sdelphij void *p = (void *) malloc (num); 4548285612Sdelphij if (!p) 4549285612Sdelphij lt_fatal (__FILE__, __LINE__, "memory exhausted"); 4550285612Sdelphij 4551285612Sdelphij return p; 4552285612Sdelphij} 4553285612Sdelphij 4554285612Sdelphijchar * 4555285612Sdelphijxstrdup (const char *string) 4556285612Sdelphij{ 4557285612Sdelphij return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 4558285612Sdelphij string) : NULL; 4559285612Sdelphij} 4560285612Sdelphij 4561285612Sdelphijconst char * 4562285612Sdelphijbase_name (const char *name) 4563285612Sdelphij{ 4564285612Sdelphij const char *base; 4565285612Sdelphij 4566285612Sdelphij#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4567285612Sdelphij /* Skip over the disk name in MSDOS pathnames. */ 4568285612Sdelphij if (isalpha ((unsigned char) name[0]) && name[1] == ':') 4569285612Sdelphij name += 2; 4570285612Sdelphij#endif 4571285612Sdelphij 4572285612Sdelphij for (base = name; *name; name++) 4573285612Sdelphij if (IS_DIR_SEPARATOR (*name)) 4574285612Sdelphij base = name + 1; 4575285612Sdelphij return base; 4576285612Sdelphij} 4577285612Sdelphij 4578285612Sdelphijint 4579285612Sdelphijcheck_executable (const char *path) 4580285612Sdelphij{ 4581285612Sdelphij struct stat st; 4582285612Sdelphij 4583285612Sdelphij lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 4584285612Sdelphij nonempty (path)); 4585285612Sdelphij if ((!path) || (!*path)) 4586285612Sdelphij return 0; 4587285612Sdelphij 4588285612Sdelphij if ((stat (path, &st) >= 0) 4589285612Sdelphij && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 4590285612Sdelphij return 1; 4591285612Sdelphij else 4592285612Sdelphij return 0; 4593285612Sdelphij} 4594285612Sdelphij 4595285612Sdelphijint 4596285612Sdelphijmake_executable (const char *path) 4597285612Sdelphij{ 4598285612Sdelphij int rval = 0; 4599285612Sdelphij struct stat st; 4600285612Sdelphij 4601285612Sdelphij lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 4602285612Sdelphij nonempty (path)); 4603285612Sdelphij if ((!path) || (!*path)) 4604285612Sdelphij return 0; 4605285612Sdelphij 4606285612Sdelphij if (stat (path, &st) >= 0) 4607285612Sdelphij { 4608285612Sdelphij rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 4609285612Sdelphij } 4610285612Sdelphij return rval; 4611285612Sdelphij} 4612285612Sdelphij 4613285612Sdelphij/* Searches for the full path of the wrapper. Returns 4614285612Sdelphij newly allocated full path name if found, NULL otherwise 4615285612Sdelphij Does not chase symlinks, even on platforms that support them. 4616285612Sdelphij*/ 4617285612Sdelphijchar * 4618285612Sdelphijfind_executable (const char *wrapper) 4619285612Sdelphij{ 4620285612Sdelphij int has_slash = 0; 4621285612Sdelphij const char *p; 4622285612Sdelphij const char *p_next; 4623285612Sdelphij /* static buffer for getcwd */ 4624285612Sdelphij char tmp[LT_PATHMAX + 1]; 4625285612Sdelphij int tmp_len; 4626285612Sdelphij char *concat_name; 4627285612Sdelphij 4628285612Sdelphij lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 4629285612Sdelphij nonempty (wrapper)); 4630285612Sdelphij 4631285612Sdelphij if ((wrapper == NULL) || (*wrapper == '\0')) 4632285612Sdelphij return NULL; 4633285612Sdelphij 4634285612Sdelphij /* Absolute path? */ 4635285612Sdelphij#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4636285612Sdelphij if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 4637285612Sdelphij { 4638285612Sdelphij concat_name = xstrdup (wrapper); 4639285612Sdelphij if (check_executable (concat_name)) 4640285612Sdelphij return concat_name; 4641285612Sdelphij XFREE (concat_name); 4642285612Sdelphij } 4643285612Sdelphij else 4644285612Sdelphij { 4645285612Sdelphij#endif 4646285612Sdelphij if (IS_DIR_SEPARATOR (wrapper[0])) 4647285612Sdelphij { 4648285612Sdelphij concat_name = xstrdup (wrapper); 4649285612Sdelphij if (check_executable (concat_name)) 4650285612Sdelphij return concat_name; 4651285612Sdelphij XFREE (concat_name); 4652285612Sdelphij } 4653285612Sdelphij#if defined (HAVE_DOS_BASED_FILE_SYSTEM) 4654285612Sdelphij } 4655285612Sdelphij#endif 4656285612Sdelphij 4657285612Sdelphij for (p = wrapper; *p; p++) 4658285612Sdelphij if (*p == '/') 4659285612Sdelphij { 4660285612Sdelphij has_slash = 1; 4661285612Sdelphij break; 4662285612Sdelphij } 4663285612Sdelphij if (!has_slash) 4664285612Sdelphij { 4665285612Sdelphij /* no slashes; search PATH */ 4666285612Sdelphij const char *path = getenv ("PATH"); 4667285612Sdelphij if (path != NULL) 4668285612Sdelphij { 4669285612Sdelphij for (p = path; *p; p = p_next) 4670285612Sdelphij { 4671285612Sdelphij const char *q; 4672285612Sdelphij size_t p_len; 4673285612Sdelphij for (q = p; *q; q++) 4674285612Sdelphij if (IS_PATH_SEPARATOR (*q)) 4675285612Sdelphij break; 4676285612Sdelphij p_len = q - p; 4677285612Sdelphij p_next = (*q == '\0' ? q : q + 1); 4678285612Sdelphij if (p_len == 0) 4679285612Sdelphij { 4680285612Sdelphij /* empty path: current directory */ 4681285612Sdelphij if (getcwd (tmp, LT_PATHMAX) == NULL) 4682285612Sdelphij lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4683285612Sdelphij nonnull (strerror (errno))); 4684285612Sdelphij tmp_len = strlen (tmp); 4685285612Sdelphij concat_name = 4686285612Sdelphij XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4687285612Sdelphij memcpy (concat_name, tmp, tmp_len); 4688285612Sdelphij concat_name[tmp_len] = '/'; 4689285612Sdelphij strcpy (concat_name + tmp_len + 1, wrapper); 4690285612Sdelphij } 4691285612Sdelphij else 4692285612Sdelphij { 4693285612Sdelphij concat_name = 4694285612Sdelphij XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 4695285612Sdelphij memcpy (concat_name, p, p_len); 4696285612Sdelphij concat_name[p_len] = '/'; 4697285612Sdelphij strcpy (concat_name + p_len + 1, wrapper); 4698285612Sdelphij } 4699285612Sdelphij if (check_executable (concat_name)) 4700285612Sdelphij return concat_name; 4701285612Sdelphij XFREE (concat_name); 4702285612Sdelphij } 4703285612Sdelphij } 4704285612Sdelphij /* not found in PATH; assume curdir */ 4705285612Sdelphij } 4706285612Sdelphij /* Relative path | not found in path: prepend cwd */ 4707285612Sdelphij if (getcwd (tmp, LT_PATHMAX) == NULL) 4708285612Sdelphij lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 4709285612Sdelphij nonnull (strerror (errno))); 4710285612Sdelphij tmp_len = strlen (tmp); 4711285612Sdelphij concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 4712285612Sdelphij memcpy (concat_name, tmp, tmp_len); 4713285612Sdelphij concat_name[tmp_len] = '/'; 4714285612Sdelphij strcpy (concat_name + tmp_len + 1, wrapper); 4715285612Sdelphij 4716285612Sdelphij if (check_executable (concat_name)) 4717285612Sdelphij return concat_name; 4718285612Sdelphij XFREE (concat_name); 4719285612Sdelphij return NULL; 4720285612Sdelphij} 4721285612Sdelphij 4722285612Sdelphijchar * 4723285612Sdelphijchase_symlinks (const char *pathspec) 4724285612Sdelphij{ 4725285612Sdelphij#ifndef S_ISLNK 4726285612Sdelphij return xstrdup (pathspec); 4727285612Sdelphij#else 4728285612Sdelphij char buf[LT_PATHMAX]; 4729285612Sdelphij struct stat s; 4730285612Sdelphij char *tmp_pathspec = xstrdup (pathspec); 4731285612Sdelphij char *p; 4732285612Sdelphij int has_symlinks = 0; 4733285612Sdelphij while (strlen (tmp_pathspec) && !has_symlinks) 4734285612Sdelphij { 4735285612Sdelphij lt_debugprintf (__FILE__, __LINE__, 4736285612Sdelphij "checking path component for symlinks: %s\n", 4737285612Sdelphij tmp_pathspec); 4738285612Sdelphij if (lstat (tmp_pathspec, &s) == 0) 4739285612Sdelphij { 4740285612Sdelphij if (S_ISLNK (s.st_mode) != 0) 4741285612Sdelphij { 4742285612Sdelphij has_symlinks = 1; 4743285612Sdelphij break; 4744285612Sdelphij } 4745285612Sdelphij 4746285612Sdelphij /* search backwards for last DIR_SEPARATOR */ 4747285612Sdelphij p = tmp_pathspec + strlen (tmp_pathspec) - 1; 4748285612Sdelphij while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4749285612Sdelphij p--; 4750285612Sdelphij if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 4751285612Sdelphij { 4752285612Sdelphij /* no more DIR_SEPARATORS left */ 4753285612Sdelphij break; 4754285612Sdelphij } 4755285612Sdelphij *p = '\0'; 4756285612Sdelphij } 4757285612Sdelphij else 4758285612Sdelphij { 4759285612Sdelphij lt_fatal (__FILE__, __LINE__, 4760285612Sdelphij "error accessing file \"%s\": %s", 4761285612Sdelphij tmp_pathspec, nonnull (strerror (errno))); 4762285612Sdelphij } 4763285612Sdelphij } 4764285612Sdelphij XFREE (tmp_pathspec); 4765285612Sdelphij 4766285612Sdelphij if (!has_symlinks) 4767285612Sdelphij { 4768285612Sdelphij return xstrdup (pathspec); 4769285612Sdelphij } 4770285612Sdelphij 4771285612Sdelphij tmp_pathspec = realpath (pathspec, buf); 4772285612Sdelphij if (tmp_pathspec == 0) 4773285612Sdelphij { 4774285612Sdelphij lt_fatal (__FILE__, __LINE__, 4775285612Sdelphij "could not follow symlinks for %s", pathspec); 4776285612Sdelphij } 4777285612Sdelphij return xstrdup (tmp_pathspec); 4778285612Sdelphij#endif 4779285612Sdelphij} 4780285612Sdelphij 4781285612Sdelphijchar * 4782285612Sdelphijstrendzap (char *str, const char *pat) 4783285612Sdelphij{ 4784285612Sdelphij size_t len, patlen; 4785285612Sdelphij 4786285612Sdelphij assert (str != NULL); 4787285612Sdelphij assert (pat != NULL); 4788285612Sdelphij 4789285612Sdelphij len = strlen (str); 4790285612Sdelphij patlen = strlen (pat); 4791285612Sdelphij 4792285612Sdelphij if (patlen <= len) 4793285612Sdelphij { 4794285612Sdelphij str += len - patlen; 4795285612Sdelphij if (strcmp (str, pat) == 0) 4796285612Sdelphij *str = '\0'; 4797285612Sdelphij } 4798285612Sdelphij return str; 4799285612Sdelphij} 4800285612Sdelphij 4801285612Sdelphijvoid 4802285612Sdelphijlt_debugprintf (const char *file, int line, const char *fmt, ...) 4803285612Sdelphij{ 4804285612Sdelphij va_list args; 4805285612Sdelphij if (lt_debug) 4806285612Sdelphij { 4807285612Sdelphij (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 4808285612Sdelphij va_start (args, fmt); 4809285612Sdelphij (void) vfprintf (stderr, fmt, args); 4810285612Sdelphij va_end (args); 4811285612Sdelphij } 4812285612Sdelphij} 4813285612Sdelphij 4814285612Sdelphijstatic void 4815285612Sdelphijlt_error_core (int exit_status, const char *file, 4816285612Sdelphij int line, const char *mode, 4817285612Sdelphij const char *message, va_list ap) 4818285612Sdelphij{ 4819285612Sdelphij fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 4820285612Sdelphij vfprintf (stderr, message, ap); 4821285612Sdelphij fprintf (stderr, ".\n"); 4822285612Sdelphij 4823285612Sdelphij if (exit_status >= 0) 4824285612Sdelphij exit (exit_status); 4825285612Sdelphij} 4826285612Sdelphij 4827285612Sdelphijvoid 4828285612Sdelphijlt_fatal (const char *file, int line, const char *message, ...) 4829285612Sdelphij{ 4830285612Sdelphij va_list ap; 4831285612Sdelphij va_start (ap, message); 4832285612Sdelphij lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 4833285612Sdelphij va_end (ap); 4834285612Sdelphij} 4835285612Sdelphij 4836285612Sdelphijstatic const char * 4837285612Sdelphijnonnull (const char *s) 4838285612Sdelphij{ 4839285612Sdelphij return s ? s : "(null)"; 4840285612Sdelphij} 4841285612Sdelphij 4842285612Sdelphijstatic const char * 4843285612Sdelphijnonempty (const char *s) 4844285612Sdelphij{ 4845285612Sdelphij return (s && !*s) ? "(empty)" : nonnull (s); 4846285612Sdelphij} 4847285612Sdelphij 4848285612Sdelphijvoid 4849285612Sdelphijlt_setenv (const char *name, const char *value) 4850285612Sdelphij{ 4851285612Sdelphij lt_debugprintf (__FILE__, __LINE__, 4852285612Sdelphij "(lt_setenv) setting '%s' to '%s'\n", 4853285612Sdelphij nonnull (name), nonnull (value)); 4854285612Sdelphij { 4855285612Sdelphij#ifdef HAVE_SETENV 4856285612Sdelphij /* always make a copy, for consistency with !HAVE_SETENV */ 4857285612Sdelphij char *str = xstrdup (value); 4858285612Sdelphij setenv (name, str, 1); 4859285612Sdelphij#else 4860285612Sdelphij int len = strlen (name) + 1 + strlen (value) + 1; 4861285612Sdelphij char *str = XMALLOC (char, len); 4862285612Sdelphij sprintf (str, "%s=%s", name, value); 4863285612Sdelphij if (putenv (str) != EXIT_SUCCESS) 4864285612Sdelphij { 4865285612Sdelphij XFREE (str); 4866285612Sdelphij } 4867285612Sdelphij#endif 4868285612Sdelphij } 4869285612Sdelphij} 4870285612Sdelphij 4871285612Sdelphijchar * 4872285612Sdelphijlt_extend_str (const char *orig_value, const char *add, int to_end) 4873285612Sdelphij{ 4874285612Sdelphij char *new_value; 4875285612Sdelphij if (orig_value && *orig_value) 4876285612Sdelphij { 4877285612Sdelphij int orig_value_len = strlen (orig_value); 4878285612Sdelphij int add_len = strlen (add); 4879285612Sdelphij new_value = XMALLOC (char, add_len + orig_value_len + 1); 4880285612Sdelphij if (to_end) 4881285612Sdelphij { 4882285612Sdelphij strcpy (new_value, orig_value); 4883285612Sdelphij strcpy (new_value + orig_value_len, add); 4884285612Sdelphij } 4885285612Sdelphij else 4886285612Sdelphij { 4887285612Sdelphij strcpy (new_value, add); 4888285612Sdelphij strcpy (new_value + add_len, orig_value); 4889285612Sdelphij } 4890285612Sdelphij } 4891285612Sdelphij else 4892285612Sdelphij { 4893285612Sdelphij new_value = xstrdup (add); 4894285612Sdelphij } 4895285612Sdelphij return new_value; 4896285612Sdelphij} 4897285612Sdelphij 4898285612Sdelphijvoid 4899285612Sdelphijlt_update_exe_path (const char *name, const char *value) 4900285612Sdelphij{ 4901285612Sdelphij lt_debugprintf (__FILE__, __LINE__, 4902285612Sdelphij "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 4903285612Sdelphij nonnull (name), nonnull (value)); 4904285612Sdelphij 4905285612Sdelphij if (name && *name && value && *value) 4906285612Sdelphij { 4907285612Sdelphij char *new_value = lt_extend_str (getenv (name), value, 0); 4908285612Sdelphij /* some systems can't cope with a ':'-terminated path #' */ 4909285612Sdelphij int len = strlen (new_value); 4910285612Sdelphij while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 4911285612Sdelphij { 4912285612Sdelphij new_value[len-1] = '\0'; 4913285612Sdelphij } 4914285612Sdelphij lt_setenv (name, new_value); 4915285612Sdelphij XFREE (new_value); 4916285612Sdelphij } 4917285612Sdelphij} 4918285612Sdelphij 4919285612Sdelphijvoid 4920285612Sdelphijlt_update_lib_path (const char *name, const char *value) 4921285612Sdelphij{ 4922285612Sdelphij lt_debugprintf (__FILE__, __LINE__, 4923285612Sdelphij "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 4924285612Sdelphij nonnull (name), nonnull (value)); 4925285612Sdelphij 4926285612Sdelphij if (name && *name && value && *value) 4927285612Sdelphij { 4928285612Sdelphij char *new_value = lt_extend_str (getenv (name), value, 0); 4929285612Sdelphij lt_setenv (name, new_value); 4930285612Sdelphij XFREE (new_value); 4931285612Sdelphij } 4932285612Sdelphij} 4933285612Sdelphij 4934285612SdelphijEOF 4935285612Sdelphij case $host_os in 4936285612Sdelphij mingw*) 4937285612Sdelphij cat <<"EOF" 4938285612Sdelphij 4939285612Sdelphij/* Prepares an argument vector before calling spawn(). 4940285612Sdelphij Note that spawn() does not by itself call the command interpreter 4941285612Sdelphij (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 4942285612Sdelphij ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 4943285612Sdelphij GetVersionEx(&v); 4944285612Sdelphij v.dwPlatformId == VER_PLATFORM_WIN32_NT; 4945285612Sdelphij }) ? "cmd.exe" : "command.com"). 4946285612Sdelphij Instead it simply concatenates the arguments, separated by ' ', and calls 4947285612Sdelphij CreateProcess(). We must quote the arguments since Win32 CreateProcess() 4948285612Sdelphij interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 4949285612Sdelphij special way: 4950285612Sdelphij - Space and tab are interpreted as delimiters. They are not treated as 4951285612Sdelphij delimiters if they are surrounded by double quotes: "...". 4952285612Sdelphij - Unescaped double quotes are removed from the input. Their only effect is 4953285612Sdelphij that within double quotes, space and tab are treated like normal 4954285612Sdelphij characters. 4955285612Sdelphij - Backslashes not followed by double quotes are not special. 4956285612Sdelphij - But 2*n+1 backslashes followed by a double quote become 4957285612Sdelphij n backslashes followed by a double quote (n >= 0): 4958285612Sdelphij \" -> " 4959285612Sdelphij \\\" -> \" 4960285612Sdelphij \\\\\" -> \\" 4961285612Sdelphij */ 4962285612Sdelphij#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" 4963285612Sdelphij#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" 4964285612Sdelphijchar ** 4965285612Sdelphijprepare_spawn (char **argv) 4966285612Sdelphij{ 4967285612Sdelphij size_t argc; 4968285612Sdelphij char **new_argv; 4969285612Sdelphij size_t i; 4970285612Sdelphij 4971285612Sdelphij /* Count number of arguments. */ 4972285612Sdelphij for (argc = 0; argv[argc] != NULL; argc++) 4973285612Sdelphij ; 4974285612Sdelphij 4975285612Sdelphij /* Allocate new argument vector. */ 4976285612Sdelphij new_argv = XMALLOC (char *, argc + 1); 4977285612Sdelphij 4978285612Sdelphij /* Put quoted arguments into the new argument vector. */ 4979285612Sdelphij for (i = 0; i < argc; i++) 4980285612Sdelphij { 4981285612Sdelphij const char *string = argv[i]; 4982285612Sdelphij 4983285612Sdelphij if (string[0] == '\0') 4984285612Sdelphij new_argv[i] = xstrdup ("\"\""); 4985285612Sdelphij else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 4986285612Sdelphij { 4987285612Sdelphij int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 4988285612Sdelphij size_t length; 4989285612Sdelphij unsigned int backslashes; 4990285612Sdelphij const char *s; 4991285612Sdelphij char *quoted_string; 4992285612Sdelphij char *p; 4993285612Sdelphij 4994285612Sdelphij length = 0; 4995285612Sdelphij backslashes = 0; 4996285612Sdelphij if (quote_around) 4997285612Sdelphij length++; 4998285612Sdelphij for (s = string; *s != '\0'; s++) 4999285612Sdelphij { 5000285612Sdelphij char c = *s; 5001285612Sdelphij if (c == '"') 5002285612Sdelphij length += backslashes + 1; 5003285612Sdelphij length++; 5004285612Sdelphij if (c == '\\') 5005285612Sdelphij backslashes++; 5006285612Sdelphij else 5007285612Sdelphij backslashes = 0; 5008285612Sdelphij } 5009285612Sdelphij if (quote_around) 5010285612Sdelphij length += backslashes + 1; 5011285612Sdelphij 5012285612Sdelphij quoted_string = XMALLOC (char, length + 1); 5013285612Sdelphij 5014285612Sdelphij p = quoted_string; 5015285612Sdelphij backslashes = 0; 5016285612Sdelphij if (quote_around) 5017285612Sdelphij *p++ = '"'; 5018285612Sdelphij for (s = string; *s != '\0'; s++) 5019285612Sdelphij { 5020285612Sdelphij char c = *s; 5021285612Sdelphij if (c == '"') 5022285612Sdelphij { 5023285612Sdelphij unsigned int j; 5024285612Sdelphij for (j = backslashes + 1; j > 0; j--) 5025285612Sdelphij *p++ = '\\'; 5026285612Sdelphij } 5027285612Sdelphij *p++ = c; 5028285612Sdelphij if (c == '\\') 5029285612Sdelphij backslashes++; 5030285612Sdelphij else 5031285612Sdelphij backslashes = 0; 5032285612Sdelphij } 5033285612Sdelphij if (quote_around) 5034285612Sdelphij { 5035285612Sdelphij unsigned int j; 5036285612Sdelphij for (j = backslashes; j > 0; j--) 5037285612Sdelphij *p++ = '\\'; 5038285612Sdelphij *p++ = '"'; 5039285612Sdelphij } 5040285612Sdelphij *p = '\0'; 5041285612Sdelphij 5042285612Sdelphij new_argv[i] = quoted_string; 5043285612Sdelphij } 5044285612Sdelphij else 5045285612Sdelphij new_argv[i] = (char *) string; 5046285612Sdelphij } 5047285612Sdelphij new_argv[argc] = NULL; 5048285612Sdelphij 5049285612Sdelphij return new_argv; 5050285612Sdelphij} 5051285612SdelphijEOF 5052285612Sdelphij ;; 5053285612Sdelphij esac 5054285612Sdelphij 5055285612Sdelphij cat <<"EOF" 5056285612Sdelphijvoid lt_dump_script (FILE* f) 5057285612Sdelphij{ 5058285612SdelphijEOF 5059285612Sdelphij func_emit_wrapper yes | 5060285612Sdelphij $SED -e 's/\([\\"]\)/\\\1/g' \ 5061285612Sdelphij -e 's/^/ fputs ("/' -e 's/$/\\n", f);/' 5062285612Sdelphij 5063285612Sdelphij cat <<"EOF" 5064285612Sdelphij} 5065285612SdelphijEOF 5066285612Sdelphij} 5067285612Sdelphij# end: func_emit_cwrapperexe_src 5068285612Sdelphij 5069285612Sdelphij# func_win32_import_lib_p ARG 5070285612Sdelphij# True if ARG is an import lib, as indicated by $file_magic_cmd 5071285612Sdelphijfunc_win32_import_lib_p () 5072285612Sdelphij{ 5073285612Sdelphij $opt_debug 5074285612Sdelphij case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 5075285612Sdelphij *import*) : ;; 5076285612Sdelphij *) false ;; 5077285612Sdelphij esac 5078285612Sdelphij} 5079285612Sdelphij 5080285612Sdelphij# func_mode_link arg... 5081285612Sdelphijfunc_mode_link () 5082285612Sdelphij{ 5083285612Sdelphij $opt_debug 5084181834Sroberto case $host in 5085285612Sdelphij *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5086181834Sroberto # It is impossible to link a dll without this setting, and 5087181834Sroberto # we shouldn't force the makefile maintainer to figure out 5088181834Sroberto # which system we are compiling for in order to pass an extra 5089181834Sroberto # flag for every libtool invocation. 5090181834Sroberto # allow_undefined=no 5091181834Sroberto 5092181834Sroberto # FIXME: Unfortunately, there are problems with the above when trying 5093181834Sroberto # to make a dll which has undefined symbols, in which case not 5094181834Sroberto # even a static library is built. For now, we need to specify 5095181834Sroberto # -no-undefined on the libtool link line when we can be certain 5096181834Sroberto # that all symbols are satisfied, otherwise we get a static library. 5097181834Sroberto allow_undefined=yes 5098181834Sroberto ;; 5099181834Sroberto *) 5100181834Sroberto allow_undefined=yes 5101181834Sroberto ;; 5102181834Sroberto esac 5103285612Sdelphij libtool_args=$nonopt 5104181834Sroberto base_compile="$nonopt $@" 5105285612Sdelphij compile_command=$nonopt 5106285612Sdelphij finalize_command=$nonopt 5107181834Sroberto 5108181834Sroberto compile_rpath= 5109181834Sroberto finalize_rpath= 5110181834Sroberto compile_shlibpath= 5111181834Sroberto finalize_shlibpath= 5112181834Sroberto convenience= 5113181834Sroberto old_convenience= 5114181834Sroberto deplibs= 5115181834Sroberto old_deplibs= 5116181834Sroberto compiler_flags= 5117181834Sroberto linker_flags= 5118181834Sroberto dllsearchpath= 5119181834Sroberto lib_search_path=`pwd` 5120181834Sroberto inst_prefix_dir= 5121285612Sdelphij new_inherited_linker_flags= 5122181834Sroberto 5123181834Sroberto avoid_version=no 5124285612Sdelphij bindir= 5125181834Sroberto dlfiles= 5126181834Sroberto dlprefiles= 5127181834Sroberto dlself=no 5128181834Sroberto export_dynamic=no 5129181834Sroberto export_symbols= 5130181834Sroberto export_symbols_regex= 5131181834Sroberto generated= 5132181834Sroberto libobjs= 5133181834Sroberto ltlibs= 5134181834Sroberto module=no 5135181834Sroberto no_install=no 5136181834Sroberto objs= 5137181834Sroberto non_pic_objects= 5138181834Sroberto precious_files_regex= 5139181834Sroberto prefer_static_libs=no 5140181834Sroberto preload=no 5141181834Sroberto prev= 5142181834Sroberto prevarg= 5143181834Sroberto release= 5144181834Sroberto rpath= 5145181834Sroberto xrpath= 5146181834Sroberto perm_rpath= 5147181834Sroberto temp_rpath= 5148181834Sroberto thread_safe=no 5149181834Sroberto vinfo= 5150181834Sroberto vinfo_number=no 5151285612Sdelphij weak_libs= 5152285612Sdelphij single_module="${wl}-single_module" 5153181834Sroberto func_infer_tag $base_compile 5154181834Sroberto 5155181834Sroberto # We need to know -static, to get the right output filenames. 5156181834Sroberto for arg 5157181834Sroberto do 5158181834Sroberto case $arg in 5159285612Sdelphij -shared) 5160285612Sdelphij test "$build_libtool_libs" != yes && \ 5161285612Sdelphij func_fatal_configuration "can not build a shared library" 5162285612Sdelphij build_old_libs=no 5163285612Sdelphij break 5164285612Sdelphij ;; 5165285612Sdelphij -all-static | -static | -static-libtool-libs) 5166285612Sdelphij case $arg in 5167285612Sdelphij -all-static) 5168181834Sroberto if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then 5169285612Sdelphij func_warning "complete static linking is impossible in this configuration" 5170181834Sroberto fi 5171181834Sroberto if test -n "$link_static_flag"; then 5172181834Sroberto dlopen_self=$dlopen_self_static 5173181834Sroberto fi 5174181834Sroberto prefer_static_libs=yes 5175285612Sdelphij ;; 5176285612Sdelphij -static) 5177181834Sroberto if test -z "$pic_flag" && test -n "$link_static_flag"; then 5178181834Sroberto dlopen_self=$dlopen_self_static 5179181834Sroberto fi 5180181834Sroberto prefer_static_libs=built 5181285612Sdelphij ;; 5182285612Sdelphij -static-libtool-libs) 5183285612Sdelphij if test -z "$pic_flag" && test -n "$link_static_flag"; then 5184285612Sdelphij dlopen_self=$dlopen_self_static 5185285612Sdelphij fi 5186285612Sdelphij prefer_static_libs=yes 5187285612Sdelphij ;; 5188285612Sdelphij esac 5189181834Sroberto build_libtool_libs=no 5190181834Sroberto build_old_libs=yes 5191181834Sroberto break 5192181834Sroberto ;; 5193181834Sroberto esac 5194181834Sroberto done 5195181834Sroberto 5196181834Sroberto # See if our shared archives depend on static archives. 5197181834Sroberto test -n "$old_archive_from_new_cmds" && build_old_libs=yes 5198181834Sroberto 5199181834Sroberto # Go through the arguments, transforming them on the way. 5200181834Sroberto while test "$#" -gt 0; do 5201181834Sroberto arg="$1" 5202181834Sroberto shift 5203285612Sdelphij func_quote_for_eval "$arg" 5204285612Sdelphij qarg=$func_quote_for_eval_unquoted_result 5205285612Sdelphij func_append libtool_args " $func_quote_for_eval_result" 5206181834Sroberto 5207181834Sroberto # If the previous option needs an argument, assign it. 5208181834Sroberto if test -n "$prev"; then 5209181834Sroberto case $prev in 5210181834Sroberto output) 5211285612Sdelphij func_append compile_command " @OUTPUT@" 5212285612Sdelphij func_append finalize_command " @OUTPUT@" 5213181834Sroberto ;; 5214181834Sroberto esac 5215181834Sroberto 5216181834Sroberto case $prev in 5217285612Sdelphij bindir) 5218285612Sdelphij bindir="$arg" 5219285612Sdelphij prev= 5220285612Sdelphij continue 5221285612Sdelphij ;; 5222181834Sroberto dlfiles|dlprefiles) 5223181834Sroberto if test "$preload" = no; then 5224181834Sroberto # Add the symbol object into the linking commands. 5225285612Sdelphij func_append compile_command " @SYMFILE@" 5226285612Sdelphij func_append finalize_command " @SYMFILE@" 5227181834Sroberto preload=yes 5228181834Sroberto fi 5229181834Sroberto case $arg in 5230181834Sroberto *.la | *.lo) ;; # We handle these cases below. 5231181834Sroberto force) 5232181834Sroberto if test "$dlself" = no; then 5233181834Sroberto dlself=needless 5234181834Sroberto export_dynamic=yes 5235181834Sroberto fi 5236181834Sroberto prev= 5237181834Sroberto continue 5238181834Sroberto ;; 5239181834Sroberto self) 5240181834Sroberto if test "$prev" = dlprefiles; then 5241181834Sroberto dlself=yes 5242181834Sroberto elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then 5243181834Sroberto dlself=yes 5244181834Sroberto else 5245181834Sroberto dlself=needless 5246181834Sroberto export_dynamic=yes 5247181834Sroberto fi 5248181834Sroberto prev= 5249181834Sroberto continue 5250181834Sroberto ;; 5251181834Sroberto *) 5252181834Sroberto if test "$prev" = dlfiles; then 5253285612Sdelphij func_append dlfiles " $arg" 5254181834Sroberto else 5255285612Sdelphij func_append dlprefiles " $arg" 5256181834Sroberto fi 5257181834Sroberto prev= 5258181834Sroberto continue 5259181834Sroberto ;; 5260181834Sroberto esac 5261181834Sroberto ;; 5262181834Sroberto expsyms) 5263181834Sroberto export_symbols="$arg" 5264285612Sdelphij test -f "$arg" \ 5265285612Sdelphij || func_fatal_error "symbol file \`$arg' does not exist" 5266181834Sroberto prev= 5267181834Sroberto continue 5268181834Sroberto ;; 5269181834Sroberto expsyms_regex) 5270181834Sroberto export_symbols_regex="$arg" 5271181834Sroberto prev= 5272181834Sroberto continue 5273181834Sroberto ;; 5274285612Sdelphij framework) 5275285612Sdelphij case $host in 5276285612Sdelphij *-*-darwin*) 5277285612Sdelphij case "$deplibs " in 5278285612Sdelphij *" $qarg.ltframework "*) ;; 5279285612Sdelphij *) func_append deplibs " $qarg.ltframework" # this is fixed later 5280285612Sdelphij ;; 5281285612Sdelphij esac 5282285612Sdelphij ;; 5283285612Sdelphij esac 5284181834Sroberto prev= 5285181834Sroberto continue 5286181834Sroberto ;; 5287285612Sdelphij inst_prefix) 5288285612Sdelphij inst_prefix_dir="$arg" 5289181834Sroberto prev= 5290181834Sroberto continue 5291181834Sroberto ;; 5292181834Sroberto objectlist) 5293181834Sroberto if test -f "$arg"; then 5294181834Sroberto save_arg=$arg 5295181834Sroberto moreargs= 5296285612Sdelphij for fil in `cat "$save_arg"` 5297181834Sroberto do 5298285612Sdelphij# func_append moreargs " $fil" 5299181834Sroberto arg=$fil 5300181834Sroberto # A libtool-controlled object. 5301181834Sroberto 5302181834Sroberto # Check to see that this really is a libtool object. 5303285612Sdelphij if func_lalib_unsafe_p "$arg"; then 5304181834Sroberto pic_object= 5305181834Sroberto non_pic_object= 5306181834Sroberto 5307181834Sroberto # Read the .lo file 5308285612Sdelphij func_source "$arg" 5309181834Sroberto 5310285612Sdelphij if test -z "$pic_object" || 5311181834Sroberto test -z "$non_pic_object" || 5312285612Sdelphij test "$pic_object" = none && 5313181834Sroberto test "$non_pic_object" = none; then 5314285612Sdelphij func_fatal_error "cannot find name of object for \`$arg'" 5315181834Sroberto fi 5316181834Sroberto 5317181834Sroberto # Extract subdirectory from the argument. 5318285612Sdelphij func_dirname "$arg" "/" "" 5319285612Sdelphij xdir="$func_dirname_result" 5320181834Sroberto 5321181834Sroberto if test "$pic_object" != none; then 5322181834Sroberto # Prepend the subdirectory the object is found in. 5323181834Sroberto pic_object="$xdir$pic_object" 5324181834Sroberto 5325181834Sroberto if test "$prev" = dlfiles; then 5326181834Sroberto if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5327285612Sdelphij func_append dlfiles " $pic_object" 5328181834Sroberto prev= 5329181834Sroberto continue 5330181834Sroberto else 5331181834Sroberto # If libtool objects are unsupported, then we need to preload. 5332181834Sroberto prev=dlprefiles 5333181834Sroberto fi 5334181834Sroberto fi 5335181834Sroberto 5336181834Sroberto # CHECK ME: I think I busted this. -Ossama 5337181834Sroberto if test "$prev" = dlprefiles; then 5338181834Sroberto # Preload the old-style object. 5339285612Sdelphij func_append dlprefiles " $pic_object" 5340181834Sroberto prev= 5341181834Sroberto fi 5342181834Sroberto 5343181834Sroberto # A PIC object. 5344285612Sdelphij func_append libobjs " $pic_object" 5345181834Sroberto arg="$pic_object" 5346181834Sroberto fi 5347181834Sroberto 5348181834Sroberto # Non-PIC object. 5349181834Sroberto if test "$non_pic_object" != none; then 5350181834Sroberto # Prepend the subdirectory the object is found in. 5351181834Sroberto non_pic_object="$xdir$non_pic_object" 5352181834Sroberto 5353181834Sroberto # A standard non-PIC object 5354285612Sdelphij func_append non_pic_objects " $non_pic_object" 5355181834Sroberto if test -z "$pic_object" || test "$pic_object" = none ; then 5356181834Sroberto arg="$non_pic_object" 5357181834Sroberto fi 5358181834Sroberto else 5359181834Sroberto # If the PIC object exists, use it instead. 5360181834Sroberto # $xdir was prepended to $pic_object above. 5361181834Sroberto non_pic_object="$pic_object" 5362285612Sdelphij func_append non_pic_objects " $non_pic_object" 5363181834Sroberto fi 5364181834Sroberto else 5365181834Sroberto # Only an error if not doing a dry-run. 5366285612Sdelphij if $opt_dry_run; then 5367181834Sroberto # Extract subdirectory from the argument. 5368285612Sdelphij func_dirname "$arg" "/" "" 5369285612Sdelphij xdir="$func_dirname_result" 5370181834Sroberto 5371285612Sdelphij func_lo2o "$arg" 5372285612Sdelphij pic_object=$xdir$objdir/$func_lo2o_result 5373285612Sdelphij non_pic_object=$xdir$func_lo2o_result 5374285612Sdelphij func_append libobjs " $pic_object" 5375285612Sdelphij func_append non_pic_objects " $non_pic_object" 5376285612Sdelphij else 5377285612Sdelphij func_fatal_error "\`$arg' is not a valid libtool object" 5378181834Sroberto fi 5379181834Sroberto fi 5380181834Sroberto done 5381181834Sroberto else 5382285612Sdelphij func_fatal_error "link input file \`$arg' does not exist" 5383181834Sroberto fi 5384181834Sroberto arg=$save_arg 5385181834Sroberto prev= 5386181834Sroberto continue 5387181834Sroberto ;; 5388285612Sdelphij precious_regex) 5389285612Sdelphij precious_files_regex="$arg" 5390285612Sdelphij prev= 5391285612Sdelphij continue 5392285612Sdelphij ;; 5393285612Sdelphij release) 5394285612Sdelphij release="-$arg" 5395285612Sdelphij prev= 5396285612Sdelphij continue 5397285612Sdelphij ;; 5398181834Sroberto rpath | xrpath) 5399181834Sroberto # We need an absolute path. 5400181834Sroberto case $arg in 5401181834Sroberto [\\/]* | [A-Za-z]:[\\/]*) ;; 5402181834Sroberto *) 5403285612Sdelphij func_fatal_error "only absolute run-paths are allowed" 5404181834Sroberto ;; 5405181834Sroberto esac 5406181834Sroberto if test "$prev" = rpath; then 5407181834Sroberto case "$rpath " in 5408181834Sroberto *" $arg "*) ;; 5409285612Sdelphij *) func_append rpath " $arg" ;; 5410181834Sroberto esac 5411181834Sroberto else 5412181834Sroberto case "$xrpath " in 5413181834Sroberto *" $arg "*) ;; 5414285612Sdelphij *) func_append xrpath " $arg" ;; 5415181834Sroberto esac 5416181834Sroberto fi 5417181834Sroberto prev= 5418181834Sroberto continue 5419181834Sroberto ;; 5420285612Sdelphij shrext) 5421285612Sdelphij shrext_cmds="$arg" 5422181834Sroberto prev= 5423181834Sroberto continue 5424181834Sroberto ;; 5425285612Sdelphij weak) 5426285612Sdelphij func_append weak_libs " $arg" 5427181834Sroberto prev= 5428181834Sroberto continue 5429181834Sroberto ;; 5430181834Sroberto xcclinker) 5431285612Sdelphij func_append linker_flags " $qarg" 5432285612Sdelphij func_append compiler_flags " $qarg" 5433181834Sroberto prev= 5434285612Sdelphij func_append compile_command " $qarg" 5435285612Sdelphij func_append finalize_command " $qarg" 5436181834Sroberto continue 5437181834Sroberto ;; 5438285612Sdelphij xcompiler) 5439285612Sdelphij func_append compiler_flags " $qarg" 5440181834Sroberto prev= 5441285612Sdelphij func_append compile_command " $qarg" 5442285612Sdelphij func_append finalize_command " $qarg" 5443181834Sroberto continue 5444181834Sroberto ;; 5445285612Sdelphij xlinker) 5446285612Sdelphij func_append linker_flags " $qarg" 5447285612Sdelphij func_append compiler_flags " $wl$qarg" 5448181834Sroberto prev= 5449285612Sdelphij func_append compile_command " $wl$qarg" 5450285612Sdelphij func_append finalize_command " $wl$qarg" 5451181834Sroberto continue 5452181834Sroberto ;; 5453181834Sroberto *) 5454181834Sroberto eval "$prev=\"\$arg\"" 5455181834Sroberto prev= 5456181834Sroberto continue 5457181834Sroberto ;; 5458181834Sroberto esac 5459181834Sroberto fi # test -n "$prev" 5460181834Sroberto 5461181834Sroberto prevarg="$arg" 5462181834Sroberto 5463181834Sroberto case $arg in 5464181834Sroberto -all-static) 5465181834Sroberto if test -n "$link_static_flag"; then 5466285612Sdelphij # See comment for -static flag below, for more details. 5467285612Sdelphij func_append compile_command " $link_static_flag" 5468285612Sdelphij func_append finalize_command " $link_static_flag" 5469181834Sroberto fi 5470181834Sroberto continue 5471181834Sroberto ;; 5472181834Sroberto 5473181834Sroberto -allow-undefined) 5474181834Sroberto # FIXME: remove this flag sometime in the future. 5475285612Sdelphij func_fatal_error "\`-allow-undefined' must not be used because it is the default" 5476181834Sroberto ;; 5477181834Sroberto 5478181834Sroberto -avoid-version) 5479181834Sroberto avoid_version=yes 5480181834Sroberto continue 5481181834Sroberto ;; 5482181834Sroberto 5483285612Sdelphij -bindir) 5484285612Sdelphij prev=bindir 5485285612Sdelphij continue 5486285612Sdelphij ;; 5487285612Sdelphij 5488181834Sroberto -dlopen) 5489181834Sroberto prev=dlfiles 5490181834Sroberto continue 5491181834Sroberto ;; 5492181834Sroberto 5493181834Sroberto -dlpreopen) 5494181834Sroberto prev=dlprefiles 5495181834Sroberto continue 5496181834Sroberto ;; 5497181834Sroberto 5498181834Sroberto -export-dynamic) 5499181834Sroberto export_dynamic=yes 5500181834Sroberto continue 5501181834Sroberto ;; 5502181834Sroberto 5503181834Sroberto -export-symbols | -export-symbols-regex) 5504181834Sroberto if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 5505285612Sdelphij func_fatal_error "more than one -exported-symbols argument is not allowed" 5506181834Sroberto fi 5507181834Sroberto if test "X$arg" = "X-export-symbols"; then 5508181834Sroberto prev=expsyms 5509181834Sroberto else 5510181834Sroberto prev=expsyms_regex 5511181834Sroberto fi 5512181834Sroberto continue 5513181834Sroberto ;; 5514181834Sroberto 5515285612Sdelphij -framework) 5516285612Sdelphij prev=framework 5517181834Sroberto continue 5518181834Sroberto ;; 5519181834Sroberto 5520181834Sroberto -inst-prefix-dir) 5521181834Sroberto prev=inst_prefix 5522181834Sroberto continue 5523181834Sroberto ;; 5524181834Sroberto 5525181834Sroberto # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 5526181834Sroberto # so, if we see these flags be careful not to treat them like -L 5527181834Sroberto -L[A-Z][A-Z]*:*) 5528181834Sroberto case $with_gcc/$host in 5529181834Sroberto no/*-*-irix* | /*-*-irix*) 5530285612Sdelphij func_append compile_command " $arg" 5531285612Sdelphij func_append finalize_command " $arg" 5532181834Sroberto ;; 5533181834Sroberto esac 5534181834Sroberto continue 5535181834Sroberto ;; 5536181834Sroberto 5537181834Sroberto -L*) 5538285612Sdelphij func_stripname "-L" '' "$arg" 5539285612Sdelphij if test -z "$func_stripname_result"; then 5540285612Sdelphij if test "$#" -gt 0; then 5541285612Sdelphij func_fatal_error "require no space between \`-L' and \`$1'" 5542285612Sdelphij else 5543285612Sdelphij func_fatal_error "need path for \`-L' option" 5544285612Sdelphij fi 5545285612Sdelphij fi 5546285612Sdelphij func_resolve_sysroot "$func_stripname_result" 5547285612Sdelphij dir=$func_resolve_sysroot_result 5548181834Sroberto # We need an absolute path. 5549181834Sroberto case $dir in 5550181834Sroberto [\\/]* | [A-Za-z]:[\\/]*) ;; 5551181834Sroberto *) 5552181834Sroberto absdir=`cd "$dir" && pwd` 5553285612Sdelphij test -z "$absdir" && \ 5554285612Sdelphij func_fatal_error "cannot determine absolute directory name of \`$dir'" 5555181834Sroberto dir="$absdir" 5556181834Sroberto ;; 5557181834Sroberto esac 5558181834Sroberto case "$deplibs " in 5559285612Sdelphij *" -L$dir "* | *" $arg "*) 5560285612Sdelphij # Will only happen for absolute or sysroot arguments 5561285612Sdelphij ;; 5562181834Sroberto *) 5563285612Sdelphij # Preserve sysroot, but never include relative directories 5564285612Sdelphij case $dir in 5565285612Sdelphij [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 5566285612Sdelphij *) func_append deplibs " -L$dir" ;; 5567285612Sdelphij esac 5568285612Sdelphij func_append lib_search_path " $dir" 5569181834Sroberto ;; 5570181834Sroberto esac 5571181834Sroberto case $host in 5572285612Sdelphij *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 5573285612Sdelphij testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 5574181834Sroberto case :$dllsearchpath: in 5575181834Sroberto *":$dir:"*) ;; 5576285612Sdelphij ::) dllsearchpath=$dir;; 5577285612Sdelphij *) func_append dllsearchpath ":$dir";; 5578181834Sroberto esac 5579181834Sroberto case :$dllsearchpath: in 5580181834Sroberto *":$testbindir:"*) ;; 5581285612Sdelphij ::) dllsearchpath=$testbindir;; 5582285612Sdelphij *) func_append dllsearchpath ":$testbindir";; 5583181834Sroberto esac 5584181834Sroberto ;; 5585181834Sroberto esac 5586181834Sroberto continue 5587181834Sroberto ;; 5588181834Sroberto 5589181834Sroberto -l*) 5590181834Sroberto if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then 5591181834Sroberto case $host in 5592285612Sdelphij *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 5593181834Sroberto # These systems don't actually have a C or math library (as such) 5594181834Sroberto continue 5595181834Sroberto ;; 5596181834Sroberto *-*-os2*) 5597181834Sroberto # These systems don't actually have a C library (as such) 5598181834Sroberto test "X$arg" = "X-lc" && continue 5599181834Sroberto ;; 5600181834Sroberto *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5601181834Sroberto # Do not include libc due to us having libc/libc_r. 5602181834Sroberto test "X$arg" = "X-lc" && continue 5603181834Sroberto ;; 5604181834Sroberto *-*-rhapsody* | *-*-darwin1.[012]) 5605181834Sroberto # Rhapsody C and math libraries are in the System framework 5606285612Sdelphij func_append deplibs " System.ltframework" 5607181834Sroberto continue 5608181834Sroberto ;; 5609181834Sroberto *-*-sco3.2v5* | *-*-sco5v6*) 5610181834Sroberto # Causes problems with __ctype 5611181834Sroberto test "X$arg" = "X-lc" && continue 5612181834Sroberto ;; 5613181834Sroberto *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 5614181834Sroberto # Compiler inserts libc in the correct place for threads to work 5615181834Sroberto test "X$arg" = "X-lc" && continue 5616181834Sroberto ;; 5617181834Sroberto esac 5618181834Sroberto elif test "X$arg" = "X-lc_r"; then 5619181834Sroberto case $host in 5620181834Sroberto *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 5621181834Sroberto # Do not include libc_r directly, use -pthread flag. 5622181834Sroberto continue 5623181834Sroberto ;; 5624181834Sroberto esac 5625181834Sroberto fi 5626285612Sdelphij func_append deplibs " $arg" 5627181834Sroberto continue 5628181834Sroberto ;; 5629181834Sroberto 5630285612Sdelphij -module) 5631285612Sdelphij module=yes 5632285612Sdelphij continue 5633285612Sdelphij ;; 5634285612Sdelphij 5635181834Sroberto # Tru64 UNIX uses -model [arg] to determine the layout of C++ 5636181834Sroberto # classes, name mangling, and exception handling. 5637285612Sdelphij # Darwin uses the -arch flag to determine output architecture. 5638285612Sdelphij -model|-arch|-isysroot|--sysroot) 5639285612Sdelphij func_append compiler_flags " $arg" 5640285612Sdelphij func_append compile_command " $arg" 5641285612Sdelphij func_append finalize_command " $arg" 5642181834Sroberto prev=xcompiler 5643181834Sroberto continue 5644181834Sroberto ;; 5645181834Sroberto 5646285612Sdelphij -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 5647285612Sdelphij func_append compiler_flags " $arg" 5648285612Sdelphij func_append compile_command " $arg" 5649285612Sdelphij func_append finalize_command " $arg" 5650285612Sdelphij case "$new_inherited_linker_flags " in 5651285612Sdelphij *" $arg "*) ;; 5652285612Sdelphij * ) func_append new_inherited_linker_flags " $arg" ;; 5653285612Sdelphij esac 5654181834Sroberto continue 5655181834Sroberto ;; 5656181834Sroberto 5657285612Sdelphij -multi_module) 5658285612Sdelphij single_module="${wl}-multi_module" 5659181834Sroberto continue 5660181834Sroberto ;; 5661181834Sroberto 5662181834Sroberto -no-fast-install) 5663181834Sroberto fast_install=no 5664181834Sroberto continue 5665181834Sroberto ;; 5666181834Sroberto 5667181834Sroberto -no-install) 5668181834Sroberto case $host in 5669285612Sdelphij *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 5670181834Sroberto # The PATH hackery in wrapper scripts is required on Windows 5671285612Sdelphij # and Darwin in order for the loader to find any dlls it needs. 5672285612Sdelphij func_warning "\`-no-install' is ignored for $host" 5673285612Sdelphij func_warning "assuming \`-no-fast-install' instead" 5674181834Sroberto fast_install=no 5675181834Sroberto ;; 5676181834Sroberto *) no_install=yes ;; 5677181834Sroberto esac 5678181834Sroberto continue 5679181834Sroberto ;; 5680181834Sroberto 5681181834Sroberto -no-undefined) 5682181834Sroberto allow_undefined=no 5683181834Sroberto continue 5684181834Sroberto ;; 5685181834Sroberto 5686181834Sroberto -objectlist) 5687181834Sroberto prev=objectlist 5688181834Sroberto continue 5689181834Sroberto ;; 5690181834Sroberto 5691181834Sroberto -o) prev=output ;; 5692181834Sroberto 5693181834Sroberto -precious-files-regex) 5694181834Sroberto prev=precious_regex 5695181834Sroberto continue 5696181834Sroberto ;; 5697181834Sroberto 5698181834Sroberto -release) 5699181834Sroberto prev=release 5700181834Sroberto continue 5701181834Sroberto ;; 5702181834Sroberto 5703181834Sroberto -rpath) 5704181834Sroberto prev=rpath 5705181834Sroberto continue 5706181834Sroberto ;; 5707181834Sroberto 5708181834Sroberto -R) 5709181834Sroberto prev=xrpath 5710181834Sroberto continue 5711181834Sroberto ;; 5712181834Sroberto 5713181834Sroberto -R*) 5714285612Sdelphij func_stripname '-R' '' "$arg" 5715285612Sdelphij dir=$func_stripname_result 5716181834Sroberto # We need an absolute path. 5717181834Sroberto case $dir in 5718181834Sroberto [\\/]* | [A-Za-z]:[\\/]*) ;; 5719285612Sdelphij =*) 5720285612Sdelphij func_stripname '=' '' "$dir" 5721285612Sdelphij dir=$lt_sysroot$func_stripname_result 5722285612Sdelphij ;; 5723181834Sroberto *) 5724285612Sdelphij func_fatal_error "only absolute run-paths are allowed" 5725181834Sroberto ;; 5726181834Sroberto esac 5727181834Sroberto case "$xrpath " in 5728181834Sroberto *" $dir "*) ;; 5729285612Sdelphij *) func_append xrpath " $dir" ;; 5730181834Sroberto esac 5731181834Sroberto continue 5732181834Sroberto ;; 5733181834Sroberto 5734285612Sdelphij -shared) 5735285612Sdelphij # The effects of -shared are defined in a previous loop. 5736285612Sdelphij continue 5737285612Sdelphij ;; 5738285612Sdelphij 5739285612Sdelphij -shrext) 5740285612Sdelphij prev=shrext 5741285612Sdelphij continue 5742285612Sdelphij ;; 5743285612Sdelphij 5744285612Sdelphij -static | -static-libtool-libs) 5745181834Sroberto # The effects of -static are defined in a previous loop. 5746181834Sroberto # We used to do the same as -all-static on platforms that 5747181834Sroberto # didn't have a PIC flag, but the assumption that the effects 5748181834Sroberto # would be equivalent was wrong. It would break on at least 5749181834Sroberto # Digital Unix and AIX. 5750181834Sroberto continue 5751181834Sroberto ;; 5752181834Sroberto 5753181834Sroberto -thread-safe) 5754181834Sroberto thread_safe=yes 5755181834Sroberto continue 5756181834Sroberto ;; 5757181834Sroberto 5758181834Sroberto -version-info) 5759181834Sroberto prev=vinfo 5760181834Sroberto continue 5761181834Sroberto ;; 5762285612Sdelphij 5763181834Sroberto -version-number) 5764181834Sroberto prev=vinfo 5765181834Sroberto vinfo_number=yes 5766181834Sroberto continue 5767181834Sroberto ;; 5768181834Sroberto 5769285612Sdelphij -weak) 5770285612Sdelphij prev=weak 5771285612Sdelphij continue 5772285612Sdelphij ;; 5773285612Sdelphij 5774181834Sroberto -Wc,*) 5775285612Sdelphij func_stripname '-Wc,' '' "$arg" 5776285612Sdelphij args=$func_stripname_result 5777181834Sroberto arg= 5778181834Sroberto save_ifs="$IFS"; IFS=',' 5779181834Sroberto for flag in $args; do 5780181834Sroberto IFS="$save_ifs" 5781285612Sdelphij func_quote_for_eval "$flag" 5782285612Sdelphij func_append arg " $func_quote_for_eval_result" 5783285612Sdelphij func_append compiler_flags " $func_quote_for_eval_result" 5784181834Sroberto done 5785181834Sroberto IFS="$save_ifs" 5786285612Sdelphij func_stripname ' ' '' "$arg" 5787285612Sdelphij arg=$func_stripname_result 5788181834Sroberto ;; 5789181834Sroberto 5790181834Sroberto -Wl,*) 5791285612Sdelphij func_stripname '-Wl,' '' "$arg" 5792285612Sdelphij args=$func_stripname_result 5793181834Sroberto arg= 5794181834Sroberto save_ifs="$IFS"; IFS=',' 5795181834Sroberto for flag in $args; do 5796181834Sroberto IFS="$save_ifs" 5797285612Sdelphij func_quote_for_eval "$flag" 5798285612Sdelphij func_append arg " $wl$func_quote_for_eval_result" 5799285612Sdelphij func_append compiler_flags " $wl$func_quote_for_eval_result" 5800285612Sdelphij func_append linker_flags " $func_quote_for_eval_result" 5801181834Sroberto done 5802181834Sroberto IFS="$save_ifs" 5803285612Sdelphij func_stripname ' ' '' "$arg" 5804285612Sdelphij arg=$func_stripname_result 5805181834Sroberto ;; 5806181834Sroberto 5807181834Sroberto -Xcompiler) 5808181834Sroberto prev=xcompiler 5809181834Sroberto continue 5810181834Sroberto ;; 5811181834Sroberto 5812181834Sroberto -Xlinker) 5813181834Sroberto prev=xlinker 5814181834Sroberto continue 5815181834Sroberto ;; 5816181834Sroberto 5817181834Sroberto -XCClinker) 5818181834Sroberto prev=xcclinker 5819181834Sroberto continue 5820181834Sroberto ;; 5821181834Sroberto 5822285612Sdelphij # -msg_* for osf cc 5823285612Sdelphij -msg_*) 5824285612Sdelphij func_quote_for_eval "$arg" 5825285612Sdelphij arg="$func_quote_for_eval_result" 5826285612Sdelphij ;; 5827285612Sdelphij 5828285612Sdelphij # Flags to be passed through unchanged, with rationale: 5829285612Sdelphij # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 5830285612Sdelphij # -r[0-9][0-9]* specify processor for the SGI compiler 5831285612Sdelphij # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 5832285612Sdelphij # +DA*, +DD* enable 64-bit mode for the HP compiler 5833285612Sdelphij # -q* compiler args for the IBM compiler 5834285612Sdelphij # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 5835285612Sdelphij # -F/path path to uninstalled frameworks, gcc on darwin 5836285612Sdelphij # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 5837285612Sdelphij # @file GCC response files 5838285612Sdelphij # -tp=* Portland pgcc target processor selection 5839285612Sdelphij # --sysroot=* for sysroot support 5840285612Sdelphij # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 5841285612Sdelphij -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 5842285612Sdelphij -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 5843285612Sdelphij -O*|-flto*|-fwhopr*|-fuse-linker-plugin) 5844285612Sdelphij func_quote_for_eval "$arg" 5845285612Sdelphij arg="$func_quote_for_eval_result" 5846285612Sdelphij func_append compile_command " $arg" 5847285612Sdelphij func_append finalize_command " $arg" 5848285612Sdelphij func_append compiler_flags " $arg" 5849285612Sdelphij continue 5850285612Sdelphij ;; 5851285612Sdelphij 5852181834Sroberto # Some other compiler flag. 5853181834Sroberto -* | +*) 5854285612Sdelphij func_quote_for_eval "$arg" 5855285612Sdelphij arg="$func_quote_for_eval_result" 5856181834Sroberto ;; 5857181834Sroberto 5858181834Sroberto *.$objext) 5859181834Sroberto # A standard object. 5860285612Sdelphij func_append objs " $arg" 5861181834Sroberto ;; 5862181834Sroberto 5863181834Sroberto *.lo) 5864181834Sroberto # A libtool-controlled object. 5865181834Sroberto 5866181834Sroberto # Check to see that this really is a libtool object. 5867285612Sdelphij if func_lalib_unsafe_p "$arg"; then 5868181834Sroberto pic_object= 5869181834Sroberto non_pic_object= 5870181834Sroberto 5871181834Sroberto # Read the .lo file 5872285612Sdelphij func_source "$arg" 5873181834Sroberto 5874285612Sdelphij if test -z "$pic_object" || 5875181834Sroberto test -z "$non_pic_object" || 5876285612Sdelphij test "$pic_object" = none && 5877181834Sroberto test "$non_pic_object" = none; then 5878285612Sdelphij func_fatal_error "cannot find name of object for \`$arg'" 5879181834Sroberto fi 5880181834Sroberto 5881181834Sroberto # Extract subdirectory from the argument. 5882285612Sdelphij func_dirname "$arg" "/" "" 5883285612Sdelphij xdir="$func_dirname_result" 5884181834Sroberto 5885181834Sroberto if test "$pic_object" != none; then 5886181834Sroberto # Prepend the subdirectory the object is found in. 5887181834Sroberto pic_object="$xdir$pic_object" 5888181834Sroberto 5889181834Sroberto if test "$prev" = dlfiles; then 5890181834Sroberto if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then 5891285612Sdelphij func_append dlfiles " $pic_object" 5892181834Sroberto prev= 5893181834Sroberto continue 5894181834Sroberto else 5895181834Sroberto # If libtool objects are unsupported, then we need to preload. 5896181834Sroberto prev=dlprefiles 5897181834Sroberto fi 5898181834Sroberto fi 5899181834Sroberto 5900181834Sroberto # CHECK ME: I think I busted this. -Ossama 5901181834Sroberto if test "$prev" = dlprefiles; then 5902181834Sroberto # Preload the old-style object. 5903285612Sdelphij func_append dlprefiles " $pic_object" 5904181834Sroberto prev= 5905181834Sroberto fi 5906181834Sroberto 5907181834Sroberto # A PIC object. 5908285612Sdelphij func_append libobjs " $pic_object" 5909181834Sroberto arg="$pic_object" 5910181834Sroberto fi 5911181834Sroberto 5912181834Sroberto # Non-PIC object. 5913181834Sroberto if test "$non_pic_object" != none; then 5914181834Sroberto # Prepend the subdirectory the object is found in. 5915181834Sroberto non_pic_object="$xdir$non_pic_object" 5916181834Sroberto 5917181834Sroberto # A standard non-PIC object 5918285612Sdelphij func_append non_pic_objects " $non_pic_object" 5919181834Sroberto if test -z "$pic_object" || test "$pic_object" = none ; then 5920181834Sroberto arg="$non_pic_object" 5921181834Sroberto fi 5922181834Sroberto else 5923181834Sroberto # If the PIC object exists, use it instead. 5924181834Sroberto # $xdir was prepended to $pic_object above. 5925181834Sroberto non_pic_object="$pic_object" 5926285612Sdelphij func_append non_pic_objects " $non_pic_object" 5927181834Sroberto fi 5928181834Sroberto else 5929181834Sroberto # Only an error if not doing a dry-run. 5930285612Sdelphij if $opt_dry_run; then 5931181834Sroberto # Extract subdirectory from the argument. 5932285612Sdelphij func_dirname "$arg" "/" "" 5933285612Sdelphij xdir="$func_dirname_result" 5934181834Sroberto 5935285612Sdelphij func_lo2o "$arg" 5936285612Sdelphij pic_object=$xdir$objdir/$func_lo2o_result 5937285612Sdelphij non_pic_object=$xdir$func_lo2o_result 5938285612Sdelphij func_append libobjs " $pic_object" 5939285612Sdelphij func_append non_pic_objects " $non_pic_object" 5940285612Sdelphij else 5941285612Sdelphij func_fatal_error "\`$arg' is not a valid libtool object" 5942181834Sroberto fi 5943181834Sroberto fi 5944181834Sroberto ;; 5945181834Sroberto 5946181834Sroberto *.$libext) 5947181834Sroberto # An archive. 5948285612Sdelphij func_append deplibs " $arg" 5949285612Sdelphij func_append old_deplibs " $arg" 5950181834Sroberto continue 5951181834Sroberto ;; 5952181834Sroberto 5953181834Sroberto *.la) 5954181834Sroberto # A libtool-controlled library. 5955181834Sroberto 5956285612Sdelphij func_resolve_sysroot "$arg" 5957181834Sroberto if test "$prev" = dlfiles; then 5958181834Sroberto # This library was specified with -dlopen. 5959285612Sdelphij func_append dlfiles " $func_resolve_sysroot_result" 5960181834Sroberto prev= 5961181834Sroberto elif test "$prev" = dlprefiles; then 5962181834Sroberto # The library was specified with -dlpreopen. 5963285612Sdelphij func_append dlprefiles " $func_resolve_sysroot_result" 5964181834Sroberto prev= 5965181834Sroberto else 5966285612Sdelphij func_append deplibs " $func_resolve_sysroot_result" 5967181834Sroberto fi 5968181834Sroberto continue 5969181834Sroberto ;; 5970181834Sroberto 5971181834Sroberto # Some other compiler argument. 5972181834Sroberto *) 5973181834Sroberto # Unknown arguments in both finalize_command and compile_command need 5974181834Sroberto # to be aesthetically quoted because they are evaled later. 5975285612Sdelphij func_quote_for_eval "$arg" 5976285612Sdelphij arg="$func_quote_for_eval_result" 5977181834Sroberto ;; 5978181834Sroberto esac # arg 5979181834Sroberto 5980181834Sroberto # Now actually substitute the argument into the commands. 5981181834Sroberto if test -n "$arg"; then 5982285612Sdelphij func_append compile_command " $arg" 5983285612Sdelphij func_append finalize_command " $arg" 5984181834Sroberto fi 5985181834Sroberto done # argument parsing loop 5986181834Sroberto 5987285612Sdelphij test -n "$prev" && \ 5988285612Sdelphij func_fatal_help "the \`$prevarg' option requires an argument" 5989181834Sroberto 5990181834Sroberto if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then 5991181834Sroberto eval arg=\"$export_dynamic_flag_spec\" 5992285612Sdelphij func_append compile_command " $arg" 5993285612Sdelphij func_append finalize_command " $arg" 5994181834Sroberto fi 5995181834Sroberto 5996181834Sroberto oldlibs= 5997181834Sroberto # calculate the name of the file, without its directory 5998285612Sdelphij func_basename "$output" 5999285612Sdelphij outputname="$func_basename_result" 6000181834Sroberto libobjs_save="$libobjs" 6001181834Sroberto 6002181834Sroberto if test -n "$shlibpath_var"; then 6003181834Sroberto # get the directories listed in $shlibpath_var 6004285612Sdelphij eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\` 6005181834Sroberto else 6006181834Sroberto shlib_search_path= 6007181834Sroberto fi 6008181834Sroberto eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 6009181834Sroberto eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 6010181834Sroberto 6011285612Sdelphij func_dirname "$output" "/" "" 6012285612Sdelphij output_objdir="$func_dirname_result$objdir" 6013285612Sdelphij func_to_tool_file "$output_objdir/" 6014285612Sdelphij tool_output_objdir=$func_to_tool_file_result 6015181834Sroberto # Create the object directory. 6016285612Sdelphij func_mkdir_p "$output_objdir" 6017181834Sroberto 6018181834Sroberto # Determine the type of output 6019181834Sroberto case $output in 6020181834Sroberto "") 6021285612Sdelphij func_fatal_help "you must specify an output file" 6022181834Sroberto ;; 6023181834Sroberto *.$libext) linkmode=oldlib ;; 6024181834Sroberto *.lo | *.$objext) linkmode=obj ;; 6025181834Sroberto *.la) linkmode=lib ;; 6026181834Sroberto *) linkmode=prog ;; # Anything else should be a program. 6027181834Sroberto esac 6028181834Sroberto 6029181834Sroberto specialdeplibs= 6030181834Sroberto 6031181834Sroberto libs= 6032181834Sroberto # Find all interdependent deplibs by searching for libraries 6033181834Sroberto # that are linked more than once (e.g. -la -lb -la) 6034181834Sroberto for deplib in $deplibs; do 6035285612Sdelphij if $opt_preserve_dup_deps ; then 6036181834Sroberto case "$libs " in 6037285612Sdelphij *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6038181834Sroberto esac 6039181834Sroberto fi 6040285612Sdelphij func_append libs " $deplib" 6041181834Sroberto done 6042181834Sroberto 6043181834Sroberto if test "$linkmode" = lib; then 6044181834Sroberto libs="$predeps $libs $compiler_lib_search_path $postdeps" 6045181834Sroberto 6046181834Sroberto # Compute libraries that are listed more than once in $predeps 6047181834Sroberto # $postdeps and mark them as special (i.e., whose duplicates are 6048181834Sroberto # not to be eliminated). 6049181834Sroberto pre_post_deps= 6050285612Sdelphij if $opt_duplicate_compiler_generated_deps; then 6051181834Sroberto for pre_post_dep in $predeps $postdeps; do 6052181834Sroberto case "$pre_post_deps " in 6053285612Sdelphij *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 6054181834Sroberto esac 6055285612Sdelphij func_append pre_post_deps " $pre_post_dep" 6056181834Sroberto done 6057181834Sroberto fi 6058181834Sroberto pre_post_deps= 6059181834Sroberto fi 6060181834Sroberto 6061181834Sroberto deplibs= 6062181834Sroberto newdependency_libs= 6063181834Sroberto newlib_search_path= 6064181834Sroberto need_relink=no # whether we're linking any uninstalled libtool libraries 6065181834Sroberto notinst_deplibs= # not-installed libtool libraries 6066285612Sdelphij notinst_path= # paths that contain not-installed libtool libraries 6067285612Sdelphij 6068181834Sroberto case $linkmode in 6069181834Sroberto lib) 6070285612Sdelphij passes="conv dlpreopen link" 6071181834Sroberto for file in $dlfiles $dlprefiles; do 6072181834Sroberto case $file in 6073181834Sroberto *.la) ;; 6074181834Sroberto *) 6075285612Sdelphij func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file" 6076181834Sroberto ;; 6077181834Sroberto esac 6078181834Sroberto done 6079181834Sroberto ;; 6080181834Sroberto prog) 6081181834Sroberto compile_deplibs= 6082181834Sroberto finalize_deplibs= 6083181834Sroberto alldeplibs=no 6084181834Sroberto newdlfiles= 6085181834Sroberto newdlprefiles= 6086181834Sroberto passes="conv scan dlopen dlpreopen link" 6087181834Sroberto ;; 6088181834Sroberto *) passes="conv" 6089181834Sroberto ;; 6090181834Sroberto esac 6091285612Sdelphij 6092181834Sroberto for pass in $passes; do 6093285612Sdelphij # The preopen pass in lib mode reverses $deplibs; put it back here 6094285612Sdelphij # so that -L comes before libs that need it for instance... 6095285612Sdelphij if test "$linkmode,$pass" = "lib,link"; then 6096285612Sdelphij ## FIXME: Find the place where the list is rebuilt in the wrong 6097285612Sdelphij ## order, and fix it there properly 6098285612Sdelphij tmp_deplibs= 6099285612Sdelphij for deplib in $deplibs; do 6100285612Sdelphij tmp_deplibs="$deplib $tmp_deplibs" 6101285612Sdelphij done 6102285612Sdelphij deplibs="$tmp_deplibs" 6103285612Sdelphij fi 6104285612Sdelphij 6105181834Sroberto if test "$linkmode,$pass" = "lib,link" || 6106181834Sroberto test "$linkmode,$pass" = "prog,scan"; then 6107181834Sroberto libs="$deplibs" 6108181834Sroberto deplibs= 6109181834Sroberto fi 6110181834Sroberto if test "$linkmode" = prog; then 6111181834Sroberto case $pass in 6112181834Sroberto dlopen) libs="$dlfiles" ;; 6113181834Sroberto dlpreopen) libs="$dlprefiles" ;; 6114181834Sroberto link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 6115181834Sroberto esac 6116181834Sroberto fi 6117285612Sdelphij if test "$linkmode,$pass" = "lib,dlpreopen"; then 6118285612Sdelphij # Collect and forward deplibs of preopened libtool libs 6119285612Sdelphij for lib in $dlprefiles; do 6120285612Sdelphij # Ignore non-libtool-libs 6121285612Sdelphij dependency_libs= 6122285612Sdelphij func_resolve_sysroot "$lib" 6123285612Sdelphij case $lib in 6124285612Sdelphij *.la) func_source "$func_resolve_sysroot_result" ;; 6125285612Sdelphij esac 6126285612Sdelphij 6127285612Sdelphij # Collect preopened libtool deplibs, except any this library 6128285612Sdelphij # has declared as weak libs 6129285612Sdelphij for deplib in $dependency_libs; do 6130285612Sdelphij func_basename "$deplib" 6131285612Sdelphij deplib_base=$func_basename_result 6132285612Sdelphij case " $weak_libs " in 6133285612Sdelphij *" $deplib_base "*) ;; 6134285612Sdelphij *) func_append deplibs " $deplib" ;; 6135285612Sdelphij esac 6136285612Sdelphij done 6137285612Sdelphij done 6138285612Sdelphij libs="$dlprefiles" 6139285612Sdelphij fi 6140181834Sroberto if test "$pass" = dlopen; then 6141181834Sroberto # Collect dlpreopened libraries 6142181834Sroberto save_deplibs="$deplibs" 6143181834Sroberto deplibs= 6144181834Sroberto fi 6145285612Sdelphij 6146181834Sroberto for deplib in $libs; do 6147181834Sroberto lib= 6148181834Sroberto found=no 6149181834Sroberto case $deplib in 6150285612Sdelphij -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads) 6151181834Sroberto if test "$linkmode,$pass" = "prog,link"; then 6152181834Sroberto compile_deplibs="$deplib $compile_deplibs" 6153181834Sroberto finalize_deplibs="$deplib $finalize_deplibs" 6154181834Sroberto else 6155285612Sdelphij func_append compiler_flags " $deplib" 6156285612Sdelphij if test "$linkmode" = lib ; then 6157285612Sdelphij case "$new_inherited_linker_flags " in 6158285612Sdelphij *" $deplib "*) ;; 6159285612Sdelphij * ) func_append new_inherited_linker_flags " $deplib" ;; 6160285612Sdelphij esac 6161285612Sdelphij fi 6162181834Sroberto fi 6163181834Sroberto continue 6164181834Sroberto ;; 6165181834Sroberto -l*) 6166181834Sroberto if test "$linkmode" != lib && test "$linkmode" != prog; then 6167285612Sdelphij func_warning "\`-l' is ignored for archives/objects" 6168181834Sroberto continue 6169181834Sroberto fi 6170285612Sdelphij func_stripname '-l' '' "$deplib" 6171285612Sdelphij name=$func_stripname_result 6172285612Sdelphij if test "$linkmode" = lib; then 6173285612Sdelphij searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 6174285612Sdelphij else 6175285612Sdelphij searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 6176285612Sdelphij fi 6177285612Sdelphij for searchdir in $searchdirs; do 6178181834Sroberto for search_ext in .la $std_shrext .so .a; do 6179181834Sroberto # Search the libtool library 6180181834Sroberto lib="$searchdir/lib${name}${search_ext}" 6181181834Sroberto if test -f "$lib"; then 6182181834Sroberto if test "$search_ext" = ".la"; then 6183181834Sroberto found=yes 6184181834Sroberto else 6185181834Sroberto found=no 6186181834Sroberto fi 6187181834Sroberto break 2 6188181834Sroberto fi 6189181834Sroberto done 6190181834Sroberto done 6191181834Sroberto if test "$found" != yes; then 6192181834Sroberto # deplib doesn't seem to be a libtool library 6193181834Sroberto if test "$linkmode,$pass" = "prog,link"; then 6194181834Sroberto compile_deplibs="$deplib $compile_deplibs" 6195181834Sroberto finalize_deplibs="$deplib $finalize_deplibs" 6196181834Sroberto else 6197181834Sroberto deplibs="$deplib $deplibs" 6198181834Sroberto test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6199181834Sroberto fi 6200181834Sroberto continue 6201181834Sroberto else # deplib is a libtool library 6202181834Sroberto # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 6203181834Sroberto # We need to do some special things here, and not later. 6204181834Sroberto if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 6205181834Sroberto case " $predeps $postdeps " in 6206181834Sroberto *" $deplib "*) 6207285612Sdelphij if func_lalib_p "$lib"; then 6208181834Sroberto library_names= 6209181834Sroberto old_library= 6210285612Sdelphij func_source "$lib" 6211181834Sroberto for l in $old_library $library_names; do 6212181834Sroberto ll="$l" 6213181834Sroberto done 6214181834Sroberto if test "X$ll" = "X$old_library" ; then # only static version available 6215181834Sroberto found=no 6216285612Sdelphij func_dirname "$lib" "" "." 6217285612Sdelphij ladir="$func_dirname_result" 6218181834Sroberto lib=$ladir/$old_library 6219181834Sroberto if test "$linkmode,$pass" = "prog,link"; then 6220181834Sroberto compile_deplibs="$deplib $compile_deplibs" 6221181834Sroberto finalize_deplibs="$deplib $finalize_deplibs" 6222181834Sroberto else 6223181834Sroberto deplibs="$deplib $deplibs" 6224181834Sroberto test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs" 6225181834Sroberto fi 6226181834Sroberto continue 6227181834Sroberto fi 6228181834Sroberto fi 6229285612Sdelphij ;; 6230181834Sroberto *) ;; 6231181834Sroberto esac 6232181834Sroberto fi 6233181834Sroberto fi 6234181834Sroberto ;; # -l 6235285612Sdelphij *.ltframework) 6236285612Sdelphij if test "$linkmode,$pass" = "prog,link"; then 6237285612Sdelphij compile_deplibs="$deplib $compile_deplibs" 6238285612Sdelphij finalize_deplibs="$deplib $finalize_deplibs" 6239285612Sdelphij else 6240285612Sdelphij deplibs="$deplib $deplibs" 6241285612Sdelphij if test "$linkmode" = lib ; then 6242285612Sdelphij case "$new_inherited_linker_flags " in 6243285612Sdelphij *" $deplib "*) ;; 6244285612Sdelphij * ) func_append new_inherited_linker_flags " $deplib" ;; 6245285612Sdelphij esac 6246285612Sdelphij fi 6247285612Sdelphij fi 6248285612Sdelphij continue 6249285612Sdelphij ;; 6250181834Sroberto -L*) 6251181834Sroberto case $linkmode in 6252181834Sroberto lib) 6253181834Sroberto deplibs="$deplib $deplibs" 6254181834Sroberto test "$pass" = conv && continue 6255181834Sroberto newdependency_libs="$deplib $newdependency_libs" 6256285612Sdelphij func_stripname '-L' '' "$deplib" 6257285612Sdelphij func_resolve_sysroot "$func_stripname_result" 6258285612Sdelphij func_append newlib_search_path " $func_resolve_sysroot_result" 6259181834Sroberto ;; 6260181834Sroberto prog) 6261181834Sroberto if test "$pass" = conv; then 6262181834Sroberto deplibs="$deplib $deplibs" 6263181834Sroberto continue 6264181834Sroberto fi 6265181834Sroberto if test "$pass" = scan; then 6266181834Sroberto deplibs="$deplib $deplibs" 6267181834Sroberto else 6268181834Sroberto compile_deplibs="$deplib $compile_deplibs" 6269181834Sroberto finalize_deplibs="$deplib $finalize_deplibs" 6270181834Sroberto fi 6271285612Sdelphij func_stripname '-L' '' "$deplib" 6272285612Sdelphij func_resolve_sysroot "$func_stripname_result" 6273285612Sdelphij func_append newlib_search_path " $func_resolve_sysroot_result" 6274181834Sroberto ;; 6275181834Sroberto *) 6276285612Sdelphij func_warning "\`-L' is ignored for archives/objects" 6277181834Sroberto ;; 6278181834Sroberto esac # linkmode 6279181834Sroberto continue 6280181834Sroberto ;; # -L 6281181834Sroberto -R*) 6282181834Sroberto if test "$pass" = link; then 6283285612Sdelphij func_stripname '-R' '' "$deplib" 6284285612Sdelphij func_resolve_sysroot "$func_stripname_result" 6285285612Sdelphij dir=$func_resolve_sysroot_result 6286181834Sroberto # Make sure the xrpath contains only unique directories. 6287181834Sroberto case "$xrpath " in 6288181834Sroberto *" $dir "*) ;; 6289285612Sdelphij *) func_append xrpath " $dir" ;; 6290181834Sroberto esac 6291181834Sroberto fi 6292181834Sroberto deplibs="$deplib $deplibs" 6293181834Sroberto continue 6294181834Sroberto ;; 6295285612Sdelphij *.la) 6296285612Sdelphij func_resolve_sysroot "$deplib" 6297285612Sdelphij lib=$func_resolve_sysroot_result 6298285612Sdelphij ;; 6299181834Sroberto *.$libext) 6300181834Sroberto if test "$pass" = conv; then 6301181834Sroberto deplibs="$deplib $deplibs" 6302181834Sroberto continue 6303181834Sroberto fi 6304181834Sroberto case $linkmode in 6305181834Sroberto lib) 6306285612Sdelphij # Linking convenience modules into shared libraries is allowed, 6307285612Sdelphij # but linking other static libraries is non-portable. 6308285612Sdelphij case " $dlpreconveniencelibs " in 6309285612Sdelphij *" $deplib "*) ;; 6310285612Sdelphij *) 6311285612Sdelphij valid_a_lib=no 6312285612Sdelphij case $deplibs_check_method in 6313285612Sdelphij match_pattern*) 6314285612Sdelphij set dummy $deplibs_check_method; shift 6315285612Sdelphij match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 6316285612Sdelphij if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 6317181834Sroberto | $EGREP "$match_pattern_regex" > /dev/null; then 6318285612Sdelphij valid_a_lib=yes 6319285612Sdelphij fi 6320285612Sdelphij ;; 6321285612Sdelphij pass_all) 6322181834Sroberto valid_a_lib=yes 6323181834Sroberto ;; 6324285612Sdelphij esac 6325285612Sdelphij if test "$valid_a_lib" != yes; then 6326285612Sdelphij echo 6327285612Sdelphij $ECHO "*** Warning: Trying to link with static lib archive $deplib." 6328285612Sdelphij echo "*** I have the capability to make that library automatically link in when" 6329285612Sdelphij echo "*** you link to this library. But I can only do this if you have a" 6330285612Sdelphij echo "*** shared version of the library, which you do not appear to have" 6331285612Sdelphij echo "*** because the file extensions .$libext of this argument makes me believe" 6332285612Sdelphij echo "*** that it is just a static archive that I should not use here." 6333285612Sdelphij else 6334285612Sdelphij echo 6335285612Sdelphij $ECHO "*** Warning: Linking the shared library $output against the" 6336285612Sdelphij $ECHO "*** static library $deplib is not portable!" 6337285612Sdelphij deplibs="$deplib $deplibs" 6338285612Sdelphij fi 6339285612Sdelphij ;; 6340285612Sdelphij esac 6341181834Sroberto continue 6342181834Sroberto ;; 6343181834Sroberto prog) 6344181834Sroberto if test "$pass" != link; then 6345181834Sroberto deplibs="$deplib $deplibs" 6346181834Sroberto else 6347181834Sroberto compile_deplibs="$deplib $compile_deplibs" 6348181834Sroberto finalize_deplibs="$deplib $finalize_deplibs" 6349181834Sroberto fi 6350181834Sroberto continue 6351181834Sroberto ;; 6352181834Sroberto esac # linkmode 6353181834Sroberto ;; # *.$libext 6354181834Sroberto *.lo | *.$objext) 6355181834Sroberto if test "$pass" = conv; then 6356181834Sroberto deplibs="$deplib $deplibs" 6357181834Sroberto elif test "$linkmode" = prog; then 6358181834Sroberto if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then 6359181834Sroberto # If there is no dlopen support or we're linking statically, 6360181834Sroberto # we need to preload. 6361285612Sdelphij func_append newdlprefiles " $deplib" 6362181834Sroberto compile_deplibs="$deplib $compile_deplibs" 6363181834Sroberto finalize_deplibs="$deplib $finalize_deplibs" 6364181834Sroberto else 6365285612Sdelphij func_append newdlfiles " $deplib" 6366181834Sroberto fi 6367181834Sroberto fi 6368181834Sroberto continue 6369181834Sroberto ;; 6370181834Sroberto %DEPLIBS%) 6371181834Sroberto alldeplibs=yes 6372181834Sroberto continue 6373181834Sroberto ;; 6374181834Sroberto esac # case $deplib 6375285612Sdelphij 6376181834Sroberto if test "$found" = yes || test -f "$lib"; then : 6377181834Sroberto else 6378285612Sdelphij func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'" 6379181834Sroberto fi 6380181834Sroberto 6381181834Sroberto # Check to see that this really is a libtool archive. 6382285612Sdelphij func_lalib_unsafe_p "$lib" \ 6383285612Sdelphij || func_fatal_error "\`$lib' is not a valid libtool archive" 6384181834Sroberto 6385285612Sdelphij func_dirname "$lib" "" "." 6386285612Sdelphij ladir="$func_dirname_result" 6387181834Sroberto 6388181834Sroberto dlname= 6389181834Sroberto dlopen= 6390181834Sroberto dlpreopen= 6391181834Sroberto libdir= 6392181834Sroberto library_names= 6393181834Sroberto old_library= 6394285612Sdelphij inherited_linker_flags= 6395181834Sroberto # If the library was installed with an old release of libtool, 6396181834Sroberto # it will not redefine variables installed, or shouldnotlink 6397181834Sroberto installed=yes 6398181834Sroberto shouldnotlink=no 6399181834Sroberto avoidtemprpath= 6400181834Sroberto 6401181834Sroberto 6402181834Sroberto # Read the .la file 6403285612Sdelphij func_source "$lib" 6404181834Sroberto 6405285612Sdelphij # Convert "-framework foo" to "foo.ltframework" 6406285612Sdelphij if test -n "$inherited_linker_flags"; then 6407285612Sdelphij tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 6408285612Sdelphij for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 6409285612Sdelphij case " $new_inherited_linker_flags " in 6410285612Sdelphij *" $tmp_inherited_linker_flag "*) ;; 6411285612Sdelphij *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 6412285612Sdelphij esac 6413285612Sdelphij done 6414285612Sdelphij fi 6415285612Sdelphij dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 6416181834Sroberto if test "$linkmode,$pass" = "lib,link" || 6417181834Sroberto test "$linkmode,$pass" = "prog,scan" || 6418181834Sroberto { test "$linkmode" != prog && test "$linkmode" != lib; }; then 6419285612Sdelphij test -n "$dlopen" && func_append dlfiles " $dlopen" 6420285612Sdelphij test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 6421181834Sroberto fi 6422181834Sroberto 6423181834Sroberto if test "$pass" = conv; then 6424181834Sroberto # Only check for convenience libraries 6425181834Sroberto deplibs="$lib $deplibs" 6426181834Sroberto if test -z "$libdir"; then 6427181834Sroberto if test -z "$old_library"; then 6428285612Sdelphij func_fatal_error "cannot find name of link library for \`$lib'" 6429181834Sroberto fi 6430181834Sroberto # It is a libtool convenience library, so add in its objects. 6431285612Sdelphij func_append convenience " $ladir/$objdir/$old_library" 6432285612Sdelphij func_append old_convenience " $ladir/$objdir/$old_library" 6433181834Sroberto elif test "$linkmode" != prog && test "$linkmode" != lib; then 6434285612Sdelphij func_fatal_error "\`$lib' is not a convenience library" 6435181834Sroberto fi 6436285612Sdelphij tmp_libs= 6437285612Sdelphij for deplib in $dependency_libs; do 6438285612Sdelphij deplibs="$deplib $deplibs" 6439285612Sdelphij if $opt_preserve_dup_deps ; then 6440285612Sdelphij case "$tmp_libs " in 6441285612Sdelphij *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6442285612Sdelphij esac 6443285612Sdelphij fi 6444285612Sdelphij func_append tmp_libs " $deplib" 6445285612Sdelphij done 6446181834Sroberto continue 6447181834Sroberto fi # $pass = conv 6448181834Sroberto 6449181834Sroberto 6450181834Sroberto # Get the name of the library we link against. 6451181834Sroberto linklib= 6452285612Sdelphij if test -n "$old_library" && 6453285612Sdelphij { test "$prefer_static_libs" = yes || 6454285612Sdelphij test "$prefer_static_libs,$installed" = "built,no"; }; then 6455285612Sdelphij linklib=$old_library 6456285612Sdelphij else 6457285612Sdelphij for l in $old_library $library_names; do 6458285612Sdelphij linklib="$l" 6459285612Sdelphij done 6460285612Sdelphij fi 6461181834Sroberto if test -z "$linklib"; then 6462285612Sdelphij func_fatal_error "cannot find name of link library for \`$lib'" 6463181834Sroberto fi 6464181834Sroberto 6465181834Sroberto # This library was specified with -dlopen. 6466181834Sroberto if test "$pass" = dlopen; then 6467181834Sroberto if test -z "$libdir"; then 6468285612Sdelphij func_fatal_error "cannot -dlopen a convenience library: \`$lib'" 6469181834Sroberto fi 6470181834Sroberto if test -z "$dlname" || 6471181834Sroberto test "$dlopen_support" != yes || 6472181834Sroberto test "$build_libtool_libs" = no; then 6473181834Sroberto # If there is no dlname, no dlopen support or we're linking 6474181834Sroberto # statically, we need to preload. We also need to preload any 6475181834Sroberto # dependent libraries so libltdl's deplib preloader doesn't 6476181834Sroberto # bomb out in the load deplibs phase. 6477285612Sdelphij func_append dlprefiles " $lib $dependency_libs" 6478181834Sroberto else 6479285612Sdelphij func_append newdlfiles " $lib" 6480181834Sroberto fi 6481181834Sroberto continue 6482181834Sroberto fi # $pass = dlopen 6483181834Sroberto 6484181834Sroberto # We need an absolute path. 6485181834Sroberto case $ladir in 6486181834Sroberto [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;; 6487181834Sroberto *) 6488181834Sroberto abs_ladir=`cd "$ladir" && pwd` 6489181834Sroberto if test -z "$abs_ladir"; then 6490285612Sdelphij func_warning "cannot determine absolute directory name of \`$ladir'" 6491285612Sdelphij func_warning "passing it literally to the linker, although it might fail" 6492181834Sroberto abs_ladir="$ladir" 6493181834Sroberto fi 6494181834Sroberto ;; 6495181834Sroberto esac 6496285612Sdelphij func_basename "$lib" 6497285612Sdelphij laname="$func_basename_result" 6498181834Sroberto 6499181834Sroberto # Find the relevant object directory and library name. 6500181834Sroberto if test "X$installed" = Xyes; then 6501285612Sdelphij if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6502285612Sdelphij func_warning "library \`$lib' was moved." 6503181834Sroberto dir="$ladir" 6504181834Sroberto absdir="$abs_ladir" 6505181834Sroberto libdir="$abs_ladir" 6506181834Sroberto else 6507285612Sdelphij dir="$lt_sysroot$libdir" 6508285612Sdelphij absdir="$lt_sysroot$libdir" 6509181834Sroberto fi 6510181834Sroberto test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes 6511181834Sroberto else 6512181834Sroberto if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 6513181834Sroberto dir="$ladir" 6514181834Sroberto absdir="$abs_ladir" 6515181834Sroberto # Remove this search path later 6516285612Sdelphij func_append notinst_path " $abs_ladir" 6517181834Sroberto else 6518181834Sroberto dir="$ladir/$objdir" 6519181834Sroberto absdir="$abs_ladir/$objdir" 6520181834Sroberto # Remove this search path later 6521285612Sdelphij func_append notinst_path " $abs_ladir" 6522181834Sroberto fi 6523181834Sroberto fi # $installed = yes 6524285612Sdelphij func_stripname 'lib' '.la' "$laname" 6525285612Sdelphij name=$func_stripname_result 6526181834Sroberto 6527181834Sroberto # This library was specified with -dlpreopen. 6528181834Sroberto if test "$pass" = dlpreopen; then 6529285612Sdelphij if test -z "$libdir" && test "$linkmode" = prog; then 6530285612Sdelphij func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'" 6531181834Sroberto fi 6532285612Sdelphij case "$host" in 6533285612Sdelphij # special handling for platforms with PE-DLLs. 6534285612Sdelphij *cygwin* | *mingw* | *cegcc* ) 6535285612Sdelphij # Linker will automatically link against shared library if both 6536285612Sdelphij # static and shared are present. Therefore, ensure we extract 6537285612Sdelphij # symbols from the import library if a shared library is present 6538285612Sdelphij # (otherwise, the dlopen module name will be incorrect). We do 6539285612Sdelphij # this by putting the import library name into $newdlprefiles. 6540285612Sdelphij # We recover the dlopen module name by 'saving' the la file 6541285612Sdelphij # name in a special purpose variable, and (later) extracting the 6542285612Sdelphij # dlname from the la file. 6543285612Sdelphij if test -n "$dlname"; then 6544285612Sdelphij func_tr_sh "$dir/$linklib" 6545285612Sdelphij eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 6546285612Sdelphij func_append newdlprefiles " $dir/$linklib" 6547285612Sdelphij else 6548285612Sdelphij func_append newdlprefiles " $dir/$old_library" 6549285612Sdelphij # Keep a list of preopened convenience libraries to check 6550285612Sdelphij # that they are being used correctly in the link pass. 6551285612Sdelphij test -z "$libdir" && \ 6552285612Sdelphij func_append dlpreconveniencelibs " $dir/$old_library" 6553285612Sdelphij fi 6554285612Sdelphij ;; 6555285612Sdelphij * ) 6556285612Sdelphij # Prefer using a static library (so that no silly _DYNAMIC symbols 6557285612Sdelphij # are required to link). 6558285612Sdelphij if test -n "$old_library"; then 6559285612Sdelphij func_append newdlprefiles " $dir/$old_library" 6560285612Sdelphij # Keep a list of preopened convenience libraries to check 6561285612Sdelphij # that they are being used correctly in the link pass. 6562285612Sdelphij test -z "$libdir" && \ 6563285612Sdelphij func_append dlpreconveniencelibs " $dir/$old_library" 6564285612Sdelphij # Otherwise, use the dlname, so that lt_dlopen finds it. 6565285612Sdelphij elif test -n "$dlname"; then 6566285612Sdelphij func_append newdlprefiles " $dir/$dlname" 6567285612Sdelphij else 6568285612Sdelphij func_append newdlprefiles " $dir/$linklib" 6569285612Sdelphij fi 6570285612Sdelphij ;; 6571285612Sdelphij esac 6572181834Sroberto fi # $pass = dlpreopen 6573181834Sroberto 6574181834Sroberto if test -z "$libdir"; then 6575181834Sroberto # Link the convenience library 6576181834Sroberto if test "$linkmode" = lib; then 6577181834Sroberto deplibs="$dir/$old_library $deplibs" 6578181834Sroberto elif test "$linkmode,$pass" = "prog,link"; then 6579181834Sroberto compile_deplibs="$dir/$old_library $compile_deplibs" 6580181834Sroberto finalize_deplibs="$dir/$old_library $finalize_deplibs" 6581181834Sroberto else 6582181834Sroberto deplibs="$lib $deplibs" # used for prog,scan pass 6583181834Sroberto fi 6584181834Sroberto continue 6585181834Sroberto fi 6586181834Sroberto 6587181834Sroberto 6588181834Sroberto if test "$linkmode" = prog && test "$pass" != link; then 6589285612Sdelphij func_append newlib_search_path " $ladir" 6590181834Sroberto deplibs="$lib $deplibs" 6591181834Sroberto 6592181834Sroberto linkalldeplibs=no 6593181834Sroberto if test "$link_all_deplibs" != no || test -z "$library_names" || 6594181834Sroberto test "$build_libtool_libs" = no; then 6595181834Sroberto linkalldeplibs=yes 6596181834Sroberto fi 6597181834Sroberto 6598181834Sroberto tmp_libs= 6599181834Sroberto for deplib in $dependency_libs; do 6600181834Sroberto case $deplib in 6601285612Sdelphij -L*) func_stripname '-L' '' "$deplib" 6602285612Sdelphij func_resolve_sysroot "$func_stripname_result" 6603285612Sdelphij func_append newlib_search_path " $func_resolve_sysroot_result" 6604285612Sdelphij ;; 6605181834Sroberto esac 6606181834Sroberto # Need to link against all dependency_libs? 6607181834Sroberto if test "$linkalldeplibs" = yes; then 6608181834Sroberto deplibs="$deplib $deplibs" 6609181834Sroberto else 6610181834Sroberto # Need to hardcode shared library paths 6611181834Sroberto # or/and link against static libraries 6612181834Sroberto newdependency_libs="$deplib $newdependency_libs" 6613181834Sroberto fi 6614285612Sdelphij if $opt_preserve_dup_deps ; then 6615181834Sroberto case "$tmp_libs " in 6616285612Sdelphij *" $deplib "*) func_append specialdeplibs " $deplib" ;; 6617181834Sroberto esac 6618181834Sroberto fi 6619285612Sdelphij func_append tmp_libs " $deplib" 6620181834Sroberto done # for deplib 6621181834Sroberto continue 6622181834Sroberto fi # $linkmode = prog... 6623181834Sroberto 6624181834Sroberto if test "$linkmode,$pass" = "prog,link"; then 6625181834Sroberto if test -n "$library_names" && 6626285612Sdelphij { { test "$prefer_static_libs" = no || 6627285612Sdelphij test "$prefer_static_libs,$installed" = "built,yes"; } || 6628285612Sdelphij test -z "$old_library"; }; then 6629181834Sroberto # We need to hardcode the library path 6630181834Sroberto if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then 6631181834Sroberto # Make sure the rpath contains only unique directories. 6632285612Sdelphij case "$temp_rpath:" in 6633285612Sdelphij *"$absdir:"*) ;; 6634285612Sdelphij *) func_append temp_rpath "$absdir:" ;; 6635181834Sroberto esac 6636181834Sroberto fi 6637181834Sroberto 6638181834Sroberto # Hardcode the library path. 6639181834Sroberto # Skip directories that are in the system default run-time 6640181834Sroberto # search path. 6641181834Sroberto case " $sys_lib_dlsearch_path " in 6642181834Sroberto *" $absdir "*) ;; 6643181834Sroberto *) 6644181834Sroberto case "$compile_rpath " in 6645181834Sroberto *" $absdir "*) ;; 6646285612Sdelphij *) func_append compile_rpath " $absdir" ;; 6647181834Sroberto esac 6648181834Sroberto ;; 6649181834Sroberto esac 6650181834Sroberto case " $sys_lib_dlsearch_path " in 6651181834Sroberto *" $libdir "*) ;; 6652181834Sroberto *) 6653181834Sroberto case "$finalize_rpath " in 6654181834Sroberto *" $libdir "*) ;; 6655285612Sdelphij *) func_append finalize_rpath " $libdir" ;; 6656181834Sroberto esac 6657181834Sroberto ;; 6658181834Sroberto esac 6659181834Sroberto fi # $linkmode,$pass = prog,link... 6660181834Sroberto 6661181834Sroberto if test "$alldeplibs" = yes && 6662181834Sroberto { test "$deplibs_check_method" = pass_all || 6663181834Sroberto { test "$build_libtool_libs" = yes && 6664181834Sroberto test -n "$library_names"; }; }; then 6665181834Sroberto # We only need to search for static libraries 6666181834Sroberto continue 6667181834Sroberto fi 6668181834Sroberto fi 6669181834Sroberto 6670181834Sroberto link_static=no # Whether the deplib will be linked statically 6671181834Sroberto use_static_libs=$prefer_static_libs 6672285612Sdelphij if test "$use_static_libs" = built && test "$installed" = yes; then 6673181834Sroberto use_static_libs=no 6674181834Sroberto fi 6675181834Sroberto if test -n "$library_names" && 6676181834Sroberto { test "$use_static_libs" = no || test -z "$old_library"; }; then 6677285612Sdelphij case $host in 6678285612Sdelphij *cygwin* | *mingw* | *cegcc*) 6679285612Sdelphij # No point in relinking DLLs because paths are not encoded 6680285612Sdelphij func_append notinst_deplibs " $lib" 6681285612Sdelphij need_relink=no 6682285612Sdelphij ;; 6683285612Sdelphij *) 6684285612Sdelphij if test "$installed" = no; then 6685285612Sdelphij func_append notinst_deplibs " $lib" 6686285612Sdelphij need_relink=yes 6687285612Sdelphij fi 6688285612Sdelphij ;; 6689285612Sdelphij esac 6690181834Sroberto # This is a shared library 6691181834Sroberto 6692285612Sdelphij # Warn about portability, can't link against -module's on some 6693285612Sdelphij # systems (darwin). Don't bleat about dlopened modules though! 6694285612Sdelphij dlopenmodule="" 6695285612Sdelphij for dlpremoduletest in $dlprefiles; do 6696285612Sdelphij if test "X$dlpremoduletest" = "X$lib"; then 6697285612Sdelphij dlopenmodule="$dlpremoduletest" 6698285612Sdelphij break 6699285612Sdelphij fi 6700285612Sdelphij done 6701285612Sdelphij if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then 6702285612Sdelphij echo 6703181834Sroberto if test "$linkmode" = prog; then 6704285612Sdelphij $ECHO "*** Warning: Linking the executable $output against the loadable module" 6705181834Sroberto else 6706285612Sdelphij $ECHO "*** Warning: Linking the shared library $output against the loadable module" 6707181834Sroberto fi 6708285612Sdelphij $ECHO "*** $linklib is not portable!" 6709181834Sroberto fi 6710181834Sroberto if test "$linkmode" = lib && 6711181834Sroberto test "$hardcode_into_libs" = yes; then 6712181834Sroberto # Hardcode the library path. 6713181834Sroberto # Skip directories that are in the system default run-time 6714181834Sroberto # search path. 6715181834Sroberto case " $sys_lib_dlsearch_path " in 6716181834Sroberto *" $absdir "*) ;; 6717181834Sroberto *) 6718181834Sroberto case "$compile_rpath " in 6719181834Sroberto *" $absdir "*) ;; 6720285612Sdelphij *) func_append compile_rpath " $absdir" ;; 6721181834Sroberto esac 6722181834Sroberto ;; 6723181834Sroberto esac 6724181834Sroberto case " $sys_lib_dlsearch_path " in 6725181834Sroberto *" $libdir "*) ;; 6726181834Sroberto *) 6727181834Sroberto case "$finalize_rpath " in 6728181834Sroberto *" $libdir "*) ;; 6729285612Sdelphij *) func_append finalize_rpath " $libdir" ;; 6730181834Sroberto esac 6731181834Sroberto ;; 6732181834Sroberto esac 6733181834Sroberto fi 6734181834Sroberto 6735181834Sroberto if test -n "$old_archive_from_expsyms_cmds"; then 6736181834Sroberto # figure out the soname 6737181834Sroberto set dummy $library_names 6738285612Sdelphij shift 6739285612Sdelphij realname="$1" 6740285612Sdelphij shift 6741285612Sdelphij libname=`eval "\\$ECHO \"$libname_spec\""` 6742181834Sroberto # use dlname if we got it. it's perfectly good, no? 6743181834Sroberto if test -n "$dlname"; then 6744181834Sroberto soname="$dlname" 6745181834Sroberto elif test -n "$soname_spec"; then 6746181834Sroberto # bleh windows 6747181834Sroberto case $host in 6748285612Sdelphij *cygwin* | mingw* | *cegcc*) 6749285612Sdelphij func_arith $current - $age 6750285612Sdelphij major=$func_arith_result 6751181834Sroberto versuffix="-$major" 6752181834Sroberto ;; 6753181834Sroberto esac 6754181834Sroberto eval soname=\"$soname_spec\" 6755181834Sroberto else 6756181834Sroberto soname="$realname" 6757181834Sroberto fi 6758181834Sroberto 6759181834Sroberto # Make a new name for the extract_expsyms_cmds to use 6760181834Sroberto soroot="$soname" 6761285612Sdelphij func_basename "$soroot" 6762285612Sdelphij soname="$func_basename_result" 6763285612Sdelphij func_stripname 'lib' '.dll' "$soname" 6764285612Sdelphij newlib=libimp-$func_stripname_result.a 6765181834Sroberto 6766181834Sroberto # If the library has no export list, then create one now 6767181834Sroberto if test -f "$output_objdir/$soname-def"; then : 6768181834Sroberto else 6769285612Sdelphij func_verbose "extracting exported symbol list from \`$soname'" 6770285612Sdelphij func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 6771181834Sroberto fi 6772181834Sroberto 6773181834Sroberto # Create $newlib 6774181834Sroberto if test -f "$output_objdir/$newlib"; then :; else 6775285612Sdelphij func_verbose "generating import library for \`$soname'" 6776285612Sdelphij func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 6777181834Sroberto fi 6778181834Sroberto # make sure the library variables are pointing to the new library 6779181834Sroberto dir=$output_objdir 6780181834Sroberto linklib=$newlib 6781181834Sroberto fi # test -n "$old_archive_from_expsyms_cmds" 6782181834Sroberto 6783285612Sdelphij if test "$linkmode" = prog || test "$opt_mode" != relink; then 6784181834Sroberto add_shlibpath= 6785181834Sroberto add_dir= 6786181834Sroberto add= 6787181834Sroberto lib_linked=yes 6788181834Sroberto case $hardcode_action in 6789181834Sroberto immediate | unsupported) 6790181834Sroberto if test "$hardcode_direct" = no; then 6791181834Sroberto add="$dir/$linklib" 6792181834Sroberto case $host in 6793181834Sroberto *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;; 6794181834Sroberto *-*-sysv4*uw2*) add_dir="-L$dir" ;; 6795181834Sroberto *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 6796181834Sroberto *-*-unixware7*) add_dir="-L$dir" ;; 6797181834Sroberto *-*-darwin* ) 6798285612Sdelphij # if the lib is a (non-dlopened) module then we can not 6799285612Sdelphij # link against it, someone is ignoring the earlier warnings 6800181834Sroberto if /usr/bin/file -L $add 2> /dev/null | 6801285612Sdelphij $GREP ": [^:]* bundle" >/dev/null ; then 6802285612Sdelphij if test "X$dlopenmodule" != "X$lib"; then 6803285612Sdelphij $ECHO "*** Warning: lib $linklib is a module, not a shared library" 6804285612Sdelphij if test -z "$old_library" ; then 6805285612Sdelphij echo 6806285612Sdelphij echo "*** And there doesn't seem to be a static archive available" 6807285612Sdelphij echo "*** The link will probably fail, sorry" 6808285612Sdelphij else 6809285612Sdelphij add="$dir/$old_library" 6810285612Sdelphij fi 6811285612Sdelphij elif test -n "$old_library"; then 6812285612Sdelphij add="$dir/$old_library" 6813181834Sroberto fi 6814181834Sroberto fi 6815181834Sroberto esac 6816181834Sroberto elif test "$hardcode_minus_L" = no; then 6817181834Sroberto case $host in 6818181834Sroberto *-*-sunos*) add_shlibpath="$dir" ;; 6819181834Sroberto esac 6820181834Sroberto add_dir="-L$dir" 6821181834Sroberto add="-l$name" 6822181834Sroberto elif test "$hardcode_shlibpath_var" = no; then 6823181834Sroberto add_shlibpath="$dir" 6824181834Sroberto add="-l$name" 6825181834Sroberto else 6826181834Sroberto lib_linked=no 6827181834Sroberto fi 6828181834Sroberto ;; 6829181834Sroberto relink) 6830285612Sdelphij if test "$hardcode_direct" = yes && 6831285612Sdelphij test "$hardcode_direct_absolute" = no; then 6832181834Sroberto add="$dir/$linklib" 6833181834Sroberto elif test "$hardcode_minus_L" = yes; then 6834181834Sroberto add_dir="-L$dir" 6835181834Sroberto # Try looking first in the location we're being installed to. 6836181834Sroberto if test -n "$inst_prefix_dir"; then 6837181834Sroberto case $libdir in 6838181834Sroberto [\\/]*) 6839285612Sdelphij func_append add_dir " -L$inst_prefix_dir$libdir" 6840181834Sroberto ;; 6841181834Sroberto esac 6842181834Sroberto fi 6843181834Sroberto add="-l$name" 6844181834Sroberto elif test "$hardcode_shlibpath_var" = yes; then 6845181834Sroberto add_shlibpath="$dir" 6846181834Sroberto add="-l$name" 6847181834Sroberto else 6848181834Sroberto lib_linked=no 6849181834Sroberto fi 6850181834Sroberto ;; 6851181834Sroberto *) lib_linked=no ;; 6852181834Sroberto esac 6853181834Sroberto 6854181834Sroberto if test "$lib_linked" != yes; then 6855285612Sdelphij func_fatal_configuration "unsupported hardcode properties" 6856181834Sroberto fi 6857181834Sroberto 6858181834Sroberto if test -n "$add_shlibpath"; then 6859181834Sroberto case :$compile_shlibpath: in 6860181834Sroberto *":$add_shlibpath:"*) ;; 6861285612Sdelphij *) func_append compile_shlibpath "$add_shlibpath:" ;; 6862181834Sroberto esac 6863181834Sroberto fi 6864181834Sroberto if test "$linkmode" = prog; then 6865181834Sroberto test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 6866181834Sroberto test -n "$add" && compile_deplibs="$add $compile_deplibs" 6867181834Sroberto else 6868181834Sroberto test -n "$add_dir" && deplibs="$add_dir $deplibs" 6869181834Sroberto test -n "$add" && deplibs="$add $deplibs" 6870285612Sdelphij if test "$hardcode_direct" != yes && 6871285612Sdelphij test "$hardcode_minus_L" != yes && 6872181834Sroberto test "$hardcode_shlibpath_var" = yes; then 6873181834Sroberto case :$finalize_shlibpath: in 6874181834Sroberto *":$libdir:"*) ;; 6875285612Sdelphij *) func_append finalize_shlibpath "$libdir:" ;; 6876181834Sroberto esac 6877181834Sroberto fi 6878181834Sroberto fi 6879181834Sroberto fi 6880181834Sroberto 6881285612Sdelphij if test "$linkmode" = prog || test "$opt_mode" = relink; then 6882181834Sroberto add_shlibpath= 6883181834Sroberto add_dir= 6884181834Sroberto add= 6885181834Sroberto # Finalize command for both is simple: just hardcode it. 6886285612Sdelphij if test "$hardcode_direct" = yes && 6887285612Sdelphij test "$hardcode_direct_absolute" = no; then 6888181834Sroberto add="$libdir/$linklib" 6889181834Sroberto elif test "$hardcode_minus_L" = yes; then 6890181834Sroberto add_dir="-L$libdir" 6891181834Sroberto add="-l$name" 6892181834Sroberto elif test "$hardcode_shlibpath_var" = yes; then 6893181834Sroberto case :$finalize_shlibpath: in 6894181834Sroberto *":$libdir:"*) ;; 6895285612Sdelphij *) func_append finalize_shlibpath "$libdir:" ;; 6896181834Sroberto esac 6897181834Sroberto add="-l$name" 6898181834Sroberto elif test "$hardcode_automatic" = yes; then 6899181834Sroberto if test -n "$inst_prefix_dir" && 6900181834Sroberto test -f "$inst_prefix_dir$libdir/$linklib" ; then 6901285612Sdelphij add="$inst_prefix_dir$libdir/$linklib" 6902181834Sroberto else 6903285612Sdelphij add="$libdir/$linklib" 6904181834Sroberto fi 6905181834Sroberto else 6906181834Sroberto # We cannot seem to hardcode it, guess we'll fake it. 6907181834Sroberto add_dir="-L$libdir" 6908181834Sroberto # Try looking first in the location we're being installed to. 6909181834Sroberto if test -n "$inst_prefix_dir"; then 6910181834Sroberto case $libdir in 6911181834Sroberto [\\/]*) 6912285612Sdelphij func_append add_dir " -L$inst_prefix_dir$libdir" 6913181834Sroberto ;; 6914181834Sroberto esac 6915181834Sroberto fi 6916181834Sroberto add="-l$name" 6917181834Sroberto fi 6918181834Sroberto 6919181834Sroberto if test "$linkmode" = prog; then 6920181834Sroberto test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 6921181834Sroberto test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 6922181834Sroberto else 6923181834Sroberto test -n "$add_dir" && deplibs="$add_dir $deplibs" 6924181834Sroberto test -n "$add" && deplibs="$add $deplibs" 6925181834Sroberto fi 6926181834Sroberto fi 6927181834Sroberto elif test "$linkmode" = prog; then 6928181834Sroberto # Here we assume that one of hardcode_direct or hardcode_minus_L 6929181834Sroberto # is not unsupported. This is valid on all known static and 6930181834Sroberto # shared platforms. 6931181834Sroberto if test "$hardcode_direct" != unsupported; then 6932181834Sroberto test -n "$old_library" && linklib="$old_library" 6933181834Sroberto compile_deplibs="$dir/$linklib $compile_deplibs" 6934181834Sroberto finalize_deplibs="$dir/$linklib $finalize_deplibs" 6935181834Sroberto else 6936181834Sroberto compile_deplibs="-l$name -L$dir $compile_deplibs" 6937181834Sroberto finalize_deplibs="-l$name -L$dir $finalize_deplibs" 6938181834Sroberto fi 6939181834Sroberto elif test "$build_libtool_libs" = yes; then 6940181834Sroberto # Not a shared library 6941181834Sroberto if test "$deplibs_check_method" != pass_all; then 6942181834Sroberto # We're trying link a shared library against a static one 6943181834Sroberto # but the system doesn't support it. 6944181834Sroberto 6945181834Sroberto # Just print a warning and add the library to dependency_libs so 6946181834Sroberto # that the program can be linked against the static library. 6947285612Sdelphij echo 6948285612Sdelphij $ECHO "*** Warning: This system can not link to static lib archive $lib." 6949285612Sdelphij echo "*** I have the capability to make that library automatically link in when" 6950285612Sdelphij echo "*** you link to this library. But I can only do this if you have a" 6951285612Sdelphij echo "*** shared version of the library, which you do not appear to have." 6952181834Sroberto if test "$module" = yes; then 6953285612Sdelphij echo "*** But as you try to build a module library, libtool will still create " 6954285612Sdelphij echo "*** a static module, that should work as long as the dlopening application" 6955285612Sdelphij echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 6956181834Sroberto if test -z "$global_symbol_pipe"; then 6957285612Sdelphij echo 6958285612Sdelphij echo "*** However, this would only work if libtool was able to extract symbol" 6959285612Sdelphij echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 6960285612Sdelphij echo "*** not find such a program. So, this module is probably useless." 6961285612Sdelphij echo "*** \`nm' from GNU binutils and a full rebuild may help." 6962181834Sroberto fi 6963181834Sroberto if test "$build_old_libs" = no; then 6964181834Sroberto build_libtool_libs=module 6965181834Sroberto build_old_libs=yes 6966181834Sroberto else 6967181834Sroberto build_libtool_libs=no 6968181834Sroberto fi 6969181834Sroberto fi 6970181834Sroberto else 6971181834Sroberto deplibs="$dir/$old_library $deplibs" 6972181834Sroberto link_static=yes 6973181834Sroberto fi 6974181834Sroberto fi # link shared/static library? 6975181834Sroberto 6976181834Sroberto if test "$linkmode" = lib; then 6977181834Sroberto if test -n "$dependency_libs" && 6978181834Sroberto { test "$hardcode_into_libs" != yes || 6979181834Sroberto test "$build_old_libs" = yes || 6980181834Sroberto test "$link_static" = yes; }; then 6981181834Sroberto # Extract -R from dependency_libs 6982181834Sroberto temp_deplibs= 6983181834Sroberto for libdir in $dependency_libs; do 6984181834Sroberto case $libdir in 6985285612Sdelphij -R*) func_stripname '-R' '' "$libdir" 6986285612Sdelphij temp_xrpath=$func_stripname_result 6987181834Sroberto case " $xrpath " in 6988181834Sroberto *" $temp_xrpath "*) ;; 6989285612Sdelphij *) func_append xrpath " $temp_xrpath";; 6990181834Sroberto esac;; 6991285612Sdelphij *) func_append temp_deplibs " $libdir";; 6992181834Sroberto esac 6993181834Sroberto done 6994181834Sroberto dependency_libs="$temp_deplibs" 6995181834Sroberto fi 6996181834Sroberto 6997285612Sdelphij func_append newlib_search_path " $absdir" 6998181834Sroberto # Link against this library 6999181834Sroberto test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 7000181834Sroberto # ... and its dependency_libs 7001181834Sroberto tmp_libs= 7002181834Sroberto for deplib in $dependency_libs; do 7003181834Sroberto newdependency_libs="$deplib $newdependency_libs" 7004285612Sdelphij case $deplib in 7005285612Sdelphij -L*) func_stripname '-L' '' "$deplib" 7006285612Sdelphij func_resolve_sysroot "$func_stripname_result";; 7007285612Sdelphij *) func_resolve_sysroot "$deplib" ;; 7008285612Sdelphij esac 7009285612Sdelphij if $opt_preserve_dup_deps ; then 7010181834Sroberto case "$tmp_libs " in 7011285612Sdelphij *" $func_resolve_sysroot_result "*) 7012285612Sdelphij func_append specialdeplibs " $func_resolve_sysroot_result" ;; 7013181834Sroberto esac 7014181834Sroberto fi 7015285612Sdelphij func_append tmp_libs " $func_resolve_sysroot_result" 7016181834Sroberto done 7017181834Sroberto 7018181834Sroberto if test "$link_all_deplibs" != no; then 7019181834Sroberto # Add the search paths of all dependency libraries 7020181834Sroberto for deplib in $dependency_libs; do 7021285612Sdelphij path= 7022181834Sroberto case $deplib in 7023181834Sroberto -L*) path="$deplib" ;; 7024181834Sroberto *.la) 7025285612Sdelphij func_resolve_sysroot "$deplib" 7026285612Sdelphij deplib=$func_resolve_sysroot_result 7027285612Sdelphij func_dirname "$deplib" "" "." 7028285612Sdelphij dir=$func_dirname_result 7029181834Sroberto # We need an absolute path. 7030181834Sroberto case $dir in 7031181834Sroberto [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;; 7032181834Sroberto *) 7033181834Sroberto absdir=`cd "$dir" && pwd` 7034181834Sroberto if test -z "$absdir"; then 7035285612Sdelphij func_warning "cannot determine absolute directory name of \`$dir'" 7036181834Sroberto absdir="$dir" 7037181834Sroberto fi 7038181834Sroberto ;; 7039181834Sroberto esac 7040285612Sdelphij if $GREP "^installed=no" $deplib > /dev/null; then 7041181834Sroberto case $host in 7042181834Sroberto *-*-darwin*) 7043285612Sdelphij depdepl= 7044181834Sroberto eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 7045181834Sroberto if test -n "$deplibrary_names" ; then 7046181834Sroberto for tmp in $deplibrary_names ; do 7047181834Sroberto depdepl=$tmp 7048181834Sroberto done 7049285612Sdelphij if test -f "$absdir/$objdir/$depdepl" ; then 7050285612Sdelphij depdepl="$absdir/$objdir/$depdepl" 7051285612Sdelphij darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7052285612Sdelphij if test -z "$darwin_install_name"; then 7053285612Sdelphij darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 7054285612Sdelphij fi 7055285612Sdelphij func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}" 7056285612Sdelphij func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}" 7057285612Sdelphij path= 7058181834Sroberto fi 7059181834Sroberto fi 7060181834Sroberto ;; 7061181834Sroberto *) 7062285612Sdelphij path="-L$absdir/$objdir" 7063181834Sroberto ;; 7064181834Sroberto esac 7065285612Sdelphij else 7066285612Sdelphij eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 7067285612Sdelphij test -z "$libdir" && \ 7068285612Sdelphij func_fatal_error "\`$deplib' is not a valid libtool archive" 7069285612Sdelphij test "$absdir" != "$libdir" && \ 7070285612Sdelphij func_warning "\`$deplib' seems to be moved" 7071285612Sdelphij 7072285612Sdelphij path="-L$absdir" 7073285612Sdelphij fi 7074181834Sroberto ;; 7075181834Sroberto esac 7076181834Sroberto case " $deplibs " in 7077181834Sroberto *" $path "*) ;; 7078181834Sroberto *) deplibs="$path $deplibs" ;; 7079181834Sroberto esac 7080181834Sroberto done 7081181834Sroberto fi # link_all_deplibs != no 7082181834Sroberto fi # linkmode = lib 7083181834Sroberto done # for deplib in $libs 7084285612Sdelphij if test "$pass" = link; then 7085285612Sdelphij if test "$linkmode" = "prog"; then 7086285612Sdelphij compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 7087285612Sdelphij finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 7088285612Sdelphij else 7089285612Sdelphij compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7090285612Sdelphij fi 7091285612Sdelphij fi 7092181834Sroberto dependency_libs="$newdependency_libs" 7093181834Sroberto if test "$pass" = dlpreopen; then 7094181834Sroberto # Link the dlpreopened libraries before other libraries 7095181834Sroberto for deplib in $save_deplibs; do 7096181834Sroberto deplibs="$deplib $deplibs" 7097181834Sroberto done 7098181834Sroberto fi 7099181834Sroberto if test "$pass" != dlopen; then 7100181834Sroberto if test "$pass" != conv; then 7101181834Sroberto # Make sure lib_search_path contains only unique directories. 7102181834Sroberto lib_search_path= 7103181834Sroberto for dir in $newlib_search_path; do 7104181834Sroberto case "$lib_search_path " in 7105181834Sroberto *" $dir "*) ;; 7106285612Sdelphij *) func_append lib_search_path " $dir" ;; 7107181834Sroberto esac 7108181834Sroberto done 7109181834Sroberto newlib_search_path= 7110181834Sroberto fi 7111181834Sroberto 7112181834Sroberto if test "$linkmode,$pass" != "prog,link"; then 7113181834Sroberto vars="deplibs" 7114181834Sroberto else 7115181834Sroberto vars="compile_deplibs finalize_deplibs" 7116181834Sroberto fi 7117181834Sroberto for var in $vars dependency_libs; do 7118181834Sroberto # Add libraries to $var in reverse order 7119181834Sroberto eval tmp_libs=\"\$$var\" 7120181834Sroberto new_libs= 7121181834Sroberto for deplib in $tmp_libs; do 7122181834Sroberto # FIXME: Pedantically, this is the right thing to do, so 7123181834Sroberto # that some nasty dependency loop isn't accidentally 7124181834Sroberto # broken: 7125181834Sroberto #new_libs="$deplib $new_libs" 7126181834Sroberto # Pragmatically, this seems to cause very few problems in 7127181834Sroberto # practice: 7128181834Sroberto case $deplib in 7129181834Sroberto -L*) new_libs="$deplib $new_libs" ;; 7130181834Sroberto -R*) ;; 7131181834Sroberto *) 7132181834Sroberto # And here is the reason: when a library appears more 7133181834Sroberto # than once as an explicit dependence of a library, or 7134181834Sroberto # is implicitly linked in more than once by the 7135181834Sroberto # compiler, it is considered special, and multiple 7136181834Sroberto # occurrences thereof are not removed. Compare this 7137181834Sroberto # with having the same library being listed as a 7138181834Sroberto # dependency of multiple other libraries: in this case, 7139181834Sroberto # we know (pedantically, we assume) the library does not 7140181834Sroberto # need to be listed more than once, so we keep only the 7141181834Sroberto # last copy. This is not always right, but it is rare 7142181834Sroberto # enough that we require users that really mean to play 7143181834Sroberto # such unportable linking tricks to link the library 7144181834Sroberto # using -Wl,-lname, so that libtool does not consider it 7145181834Sroberto # for duplicate removal. 7146181834Sroberto case " $specialdeplibs " in 7147181834Sroberto *" $deplib "*) new_libs="$deplib $new_libs" ;; 7148181834Sroberto *) 7149181834Sroberto case " $new_libs " in 7150181834Sroberto *" $deplib "*) ;; 7151181834Sroberto *) new_libs="$deplib $new_libs" ;; 7152181834Sroberto esac 7153181834Sroberto ;; 7154181834Sroberto esac 7155181834Sroberto ;; 7156181834Sroberto esac 7157181834Sroberto done 7158181834Sroberto tmp_libs= 7159181834Sroberto for deplib in $new_libs; do 7160181834Sroberto case $deplib in 7161181834Sroberto -L*) 7162181834Sroberto case " $tmp_libs " in 7163181834Sroberto *" $deplib "*) ;; 7164285612Sdelphij *) func_append tmp_libs " $deplib" ;; 7165181834Sroberto esac 7166181834Sroberto ;; 7167285612Sdelphij *) func_append tmp_libs " $deplib" ;; 7168181834Sroberto esac 7169181834Sroberto done 7170181834Sroberto eval $var=\"$tmp_libs\" 7171181834Sroberto done # for var 7172181834Sroberto fi 7173181834Sroberto # Last step: remove runtime libs from dependency_libs 7174181834Sroberto # (they stay in deplibs) 7175181834Sroberto tmp_libs= 7176181834Sroberto for i in $dependency_libs ; do 7177181834Sroberto case " $predeps $postdeps $compiler_lib_search_path " in 7178181834Sroberto *" $i "*) 7179181834Sroberto i="" 7180181834Sroberto ;; 7181181834Sroberto esac 7182181834Sroberto if test -n "$i" ; then 7183285612Sdelphij func_append tmp_libs " $i" 7184181834Sroberto fi 7185181834Sroberto done 7186181834Sroberto dependency_libs=$tmp_libs 7187181834Sroberto done # for pass 7188181834Sroberto if test "$linkmode" = prog; then 7189181834Sroberto dlfiles="$newdlfiles" 7190285612Sdelphij fi 7191285612Sdelphij if test "$linkmode" = prog || test "$linkmode" = lib; then 7192181834Sroberto dlprefiles="$newdlprefiles" 7193181834Sroberto fi 7194181834Sroberto 7195181834Sroberto case $linkmode in 7196181834Sroberto oldlib) 7197181834Sroberto if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 7198285612Sdelphij func_warning "\`-dlopen' is ignored for archives" 7199181834Sroberto fi 7200181834Sroberto 7201285612Sdelphij case " $deplibs" in 7202285612Sdelphij *\ -l* | *\ -L*) 7203285612Sdelphij func_warning "\`-l' and \`-L' are ignored for archives" ;; 7204285612Sdelphij esac 7205181834Sroberto 7206285612Sdelphij test -n "$rpath" && \ 7207285612Sdelphij func_warning "\`-rpath' is ignored for archives" 7208181834Sroberto 7209285612Sdelphij test -n "$xrpath" && \ 7210285612Sdelphij func_warning "\`-R' is ignored for archives" 7211181834Sroberto 7212285612Sdelphij test -n "$vinfo" && \ 7213285612Sdelphij func_warning "\`-version-info/-version-number' is ignored for archives" 7214181834Sroberto 7215285612Sdelphij test -n "$release" && \ 7216285612Sdelphij func_warning "\`-release' is ignored for archives" 7217181834Sroberto 7218285612Sdelphij test -n "$export_symbols$export_symbols_regex" && \ 7219285612Sdelphij func_warning "\`-export-symbols' is ignored for archives" 7220285612Sdelphij 7221181834Sroberto # Now set the variables for building old libraries. 7222181834Sroberto build_libtool_libs=no 7223181834Sroberto oldlibs="$output" 7224285612Sdelphij func_append objs "$old_deplibs" 7225181834Sroberto ;; 7226181834Sroberto 7227181834Sroberto lib) 7228181834Sroberto # Make sure we only generate libraries of the form `libNAME.la'. 7229181834Sroberto case $outputname in 7230181834Sroberto lib*) 7231285612Sdelphij func_stripname 'lib' '.la' "$outputname" 7232285612Sdelphij name=$func_stripname_result 7233181834Sroberto eval shared_ext=\"$shrext_cmds\" 7234181834Sroberto eval libname=\"$libname_spec\" 7235181834Sroberto ;; 7236181834Sroberto *) 7237285612Sdelphij test "$module" = no && \ 7238285612Sdelphij func_fatal_help "libtool library \`$output' must begin with \`lib'" 7239285612Sdelphij 7240181834Sroberto if test "$need_lib_prefix" != no; then 7241181834Sroberto # Add the "lib" prefix for modules if required 7242285612Sdelphij func_stripname '' '.la' "$outputname" 7243285612Sdelphij name=$func_stripname_result 7244181834Sroberto eval shared_ext=\"$shrext_cmds\" 7245181834Sroberto eval libname=\"$libname_spec\" 7246181834Sroberto else 7247285612Sdelphij func_stripname '' '.la' "$outputname" 7248285612Sdelphij libname=$func_stripname_result 7249181834Sroberto fi 7250181834Sroberto ;; 7251181834Sroberto esac 7252181834Sroberto 7253181834Sroberto if test -n "$objs"; then 7254181834Sroberto if test "$deplibs_check_method" != pass_all; then 7255285612Sdelphij func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 7256181834Sroberto else 7257285612Sdelphij echo 7258285612Sdelphij $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 7259285612Sdelphij $ECHO "*** objects $objs is not portable!" 7260285612Sdelphij func_append libobjs " $objs" 7261181834Sroberto fi 7262181834Sroberto fi 7263181834Sroberto 7264285612Sdelphij test "$dlself" != no && \ 7265285612Sdelphij func_warning "\`-dlopen self' is ignored for libtool libraries" 7266181834Sroberto 7267181834Sroberto set dummy $rpath 7268285612Sdelphij shift 7269285612Sdelphij test "$#" -gt 1 && \ 7270285612Sdelphij func_warning "ignoring multiple \`-rpath's for a libtool library" 7271181834Sroberto 7272285612Sdelphij install_libdir="$1" 7273285612Sdelphij 7274181834Sroberto oldlibs= 7275181834Sroberto if test -z "$rpath"; then 7276181834Sroberto if test "$build_libtool_libs" = yes; then 7277181834Sroberto # Building a libtool convenience library. 7278181834Sroberto # Some compilers have problems with a `.al' extension so 7279181834Sroberto # convenience libraries should have the same extension an 7280181834Sroberto # archive normally would. 7281181834Sroberto oldlibs="$output_objdir/$libname.$libext $oldlibs" 7282181834Sroberto build_libtool_libs=convenience 7283181834Sroberto build_old_libs=yes 7284181834Sroberto fi 7285181834Sroberto 7286285612Sdelphij test -n "$vinfo" && \ 7287285612Sdelphij func_warning "\`-version-info/-version-number' is ignored for convenience libraries" 7288181834Sroberto 7289285612Sdelphij test -n "$release" && \ 7290285612Sdelphij func_warning "\`-release' is ignored for convenience libraries" 7291181834Sroberto else 7292181834Sroberto 7293181834Sroberto # Parse the version information argument. 7294181834Sroberto save_ifs="$IFS"; IFS=':' 7295181834Sroberto set dummy $vinfo 0 0 0 7296285612Sdelphij shift 7297181834Sroberto IFS="$save_ifs" 7298181834Sroberto 7299285612Sdelphij test -n "$7" && \ 7300285612Sdelphij func_fatal_help "too many parameters to \`-version-info'" 7301181834Sroberto 7302181834Sroberto # convert absolute version numbers to libtool ages 7303181834Sroberto # this retains compatibility with .la files and attempts 7304181834Sroberto # to make the code below a bit more comprehensible 7305181834Sroberto 7306181834Sroberto case $vinfo_number in 7307181834Sroberto yes) 7308285612Sdelphij number_major="$1" 7309285612Sdelphij number_minor="$2" 7310285612Sdelphij number_revision="$3" 7311181834Sroberto # 7312181834Sroberto # There are really only two kinds -- those that 7313181834Sroberto # use the current revision as the major version 7314181834Sroberto # and those that subtract age and use age as 7315181834Sroberto # a minor version. But, then there is irix 7316181834Sroberto # which has an extra 1 added just for fun 7317181834Sroberto # 7318181834Sroberto case $version_type in 7319285612Sdelphij darwin|linux|osf|windows|none) 7320285612Sdelphij func_arith $number_major + $number_minor 7321285612Sdelphij current=$func_arith_result 7322181834Sroberto age="$number_minor" 7323181834Sroberto revision="$number_revision" 7324181834Sroberto ;; 7325285612Sdelphij freebsd-aout|freebsd-elf|qnx|sunos) 7326181834Sroberto current="$number_major" 7327181834Sroberto revision="$number_minor" 7328181834Sroberto age="0" 7329181834Sroberto ;; 7330181834Sroberto irix|nonstopux) 7331285612Sdelphij func_arith $number_major + $number_minor 7332285612Sdelphij current=$func_arith_result 7333181834Sroberto age="$number_minor" 7334181834Sroberto revision="$number_minor" 7335285612Sdelphij lt_irix_increment=no 7336181834Sroberto ;; 7337181834Sroberto esac 7338181834Sroberto ;; 7339181834Sroberto no) 7340285612Sdelphij current="$1" 7341285612Sdelphij revision="$2" 7342285612Sdelphij age="$3" 7343181834Sroberto ;; 7344181834Sroberto esac 7345181834Sroberto 7346181834Sroberto # Check that each of the things are valid numbers. 7347181834Sroberto case $current in 7348181834Sroberto 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]) ;; 7349181834Sroberto *) 7350285612Sdelphij func_error "CURRENT \`$current' must be a nonnegative integer" 7351285612Sdelphij func_fatal_error "\`$vinfo' is not valid version information" 7352181834Sroberto ;; 7353181834Sroberto esac 7354181834Sroberto 7355181834Sroberto case $revision in 7356181834Sroberto 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]) ;; 7357181834Sroberto *) 7358285612Sdelphij func_error "REVISION \`$revision' must be a nonnegative integer" 7359285612Sdelphij func_fatal_error "\`$vinfo' is not valid version information" 7360181834Sroberto ;; 7361181834Sroberto esac 7362181834Sroberto 7363181834Sroberto case $age in 7364181834Sroberto 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]) ;; 7365181834Sroberto *) 7366285612Sdelphij func_error "AGE \`$age' must be a nonnegative integer" 7367285612Sdelphij func_fatal_error "\`$vinfo' is not valid version information" 7368181834Sroberto ;; 7369181834Sroberto esac 7370181834Sroberto 7371181834Sroberto if test "$age" -gt "$current"; then 7372285612Sdelphij func_error "AGE \`$age' is greater than the current interface number \`$current'" 7373285612Sdelphij func_fatal_error "\`$vinfo' is not valid version information" 7374181834Sroberto fi 7375181834Sroberto 7376181834Sroberto # Calculate the version variables. 7377181834Sroberto major= 7378181834Sroberto versuffix= 7379181834Sroberto verstring= 7380181834Sroberto case $version_type in 7381181834Sroberto none) ;; 7382181834Sroberto 7383181834Sroberto darwin) 7384181834Sroberto # Like Linux, but with the current version available in 7385181834Sroberto # verstring for coding it into the library header 7386285612Sdelphij func_arith $current - $age 7387285612Sdelphij major=.$func_arith_result 7388181834Sroberto versuffix="$major.$age.$revision" 7389181834Sroberto # Darwin ld doesn't like 0 for these options... 7390285612Sdelphij func_arith $current + 1 7391285612Sdelphij minor_current=$func_arith_result 7392285612Sdelphij xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision" 7393285612Sdelphij verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 7394181834Sroberto ;; 7395181834Sroberto 7396181834Sroberto freebsd-aout) 7397181834Sroberto major=".$current" 7398181834Sroberto versuffix=".$current.$revision"; 7399181834Sroberto ;; 7400181834Sroberto 7401181834Sroberto freebsd-elf) 7402181834Sroberto major=".$current" 7403285612Sdelphij versuffix=".$current" 7404181834Sroberto ;; 7405181834Sroberto 7406181834Sroberto irix | nonstopux) 7407285612Sdelphij if test "X$lt_irix_increment" = "Xno"; then 7408285612Sdelphij func_arith $current - $age 7409285612Sdelphij else 7410285612Sdelphij func_arith $current - $age + 1 7411285612Sdelphij fi 7412285612Sdelphij major=$func_arith_result 7413181834Sroberto 7414181834Sroberto case $version_type in 7415181834Sroberto nonstopux) verstring_prefix=nonstopux ;; 7416181834Sroberto *) verstring_prefix=sgi ;; 7417181834Sroberto esac 7418181834Sroberto verstring="$verstring_prefix$major.$revision" 7419181834Sroberto 7420181834Sroberto # Add in all the interfaces that we are compatible with. 7421181834Sroberto loop=$revision 7422181834Sroberto while test "$loop" -ne 0; do 7423285612Sdelphij func_arith $revision - $loop 7424285612Sdelphij iface=$func_arith_result 7425285612Sdelphij func_arith $loop - 1 7426285612Sdelphij loop=$func_arith_result 7427181834Sroberto verstring="$verstring_prefix$major.$iface:$verstring" 7428181834Sroberto done 7429181834Sroberto 7430181834Sroberto # Before this point, $major must not contain `.'. 7431181834Sroberto major=.$major 7432181834Sroberto versuffix="$major.$revision" 7433181834Sroberto ;; 7434181834Sroberto 7435181834Sroberto linux) 7436285612Sdelphij func_arith $current - $age 7437285612Sdelphij major=.$func_arith_result 7438181834Sroberto versuffix="$major.$age.$revision" 7439181834Sroberto ;; 7440181834Sroberto 7441181834Sroberto osf) 7442285612Sdelphij func_arith $current - $age 7443285612Sdelphij major=.$func_arith_result 7444181834Sroberto versuffix=".$current.$age.$revision" 7445181834Sroberto verstring="$current.$age.$revision" 7446181834Sroberto 7447181834Sroberto # Add in all the interfaces that we are compatible with. 7448181834Sroberto loop=$age 7449181834Sroberto while test "$loop" -ne 0; do 7450285612Sdelphij func_arith $current - $loop 7451285612Sdelphij iface=$func_arith_result 7452285612Sdelphij func_arith $loop - 1 7453285612Sdelphij loop=$func_arith_result 7454181834Sroberto verstring="$verstring:${iface}.0" 7455181834Sroberto done 7456181834Sroberto 7457181834Sroberto # Make executables depend on our current version. 7458285612Sdelphij func_append verstring ":${current}.0" 7459181834Sroberto ;; 7460181834Sroberto 7461285612Sdelphij qnx) 7462285612Sdelphij major=".$current" 7463285612Sdelphij versuffix=".$current" 7464285612Sdelphij ;; 7465285612Sdelphij 7466181834Sroberto sunos) 7467181834Sroberto major=".$current" 7468181834Sroberto versuffix=".$current.$revision" 7469181834Sroberto ;; 7470181834Sroberto 7471181834Sroberto windows) 7472181834Sroberto # Use '-' rather than '.', since we only want one 7473181834Sroberto # extension on DOS 8.3 filesystems. 7474285612Sdelphij func_arith $current - $age 7475285612Sdelphij major=$func_arith_result 7476181834Sroberto versuffix="-$major" 7477181834Sroberto ;; 7478181834Sroberto 7479181834Sroberto *) 7480285612Sdelphij func_fatal_configuration "unknown library version type \`$version_type'" 7481181834Sroberto ;; 7482181834Sroberto esac 7483181834Sroberto 7484181834Sroberto # Clear the version info if we defaulted, and they specified a release. 7485181834Sroberto if test -z "$vinfo" && test -n "$release"; then 7486181834Sroberto major= 7487181834Sroberto case $version_type in 7488181834Sroberto darwin) 7489181834Sroberto # we can't check for "0.0" in archive_cmds due to quoting 7490181834Sroberto # problems, so we reset it completely 7491181834Sroberto verstring= 7492181834Sroberto ;; 7493181834Sroberto *) 7494181834Sroberto verstring="0.0" 7495181834Sroberto ;; 7496181834Sroberto esac 7497181834Sroberto if test "$need_version" = no; then 7498181834Sroberto versuffix= 7499181834Sroberto else 7500181834Sroberto versuffix=".0.0" 7501181834Sroberto fi 7502181834Sroberto fi 7503181834Sroberto 7504181834Sroberto # Remove version info from name if versioning should be avoided 7505181834Sroberto if test "$avoid_version" = yes && test "$need_version" = no; then 7506181834Sroberto major= 7507181834Sroberto versuffix= 7508181834Sroberto verstring="" 7509181834Sroberto fi 7510181834Sroberto 7511181834Sroberto # Check to see if the archive will have undefined symbols. 7512181834Sroberto if test "$allow_undefined" = yes; then 7513181834Sroberto if test "$allow_undefined_flag" = unsupported; then 7514285612Sdelphij func_warning "undefined symbols not allowed in $host shared libraries" 7515181834Sroberto build_libtool_libs=no 7516181834Sroberto build_old_libs=yes 7517181834Sroberto fi 7518181834Sroberto else 7519181834Sroberto # Don't allow undefined symbols. 7520181834Sroberto allow_undefined_flag="$no_undefined_flag" 7521181834Sroberto fi 7522285612Sdelphij 7523181834Sroberto fi 7524181834Sroberto 7525285612Sdelphij func_generate_dlsyms "$libname" "$libname" "yes" 7526285612Sdelphij func_append libobjs " $symfileobj" 7527285612Sdelphij test "X$libobjs" = "X " && libobjs= 7528285612Sdelphij 7529285612Sdelphij if test "$opt_mode" != relink; then 7530181834Sroberto # Remove our outputs, but don't remove object files since they 7531181834Sroberto # may have been created when compiling PIC objects. 7532181834Sroberto removelist= 7533285612Sdelphij tempremovelist=`$ECHO "$output_objdir/*"` 7534181834Sroberto for p in $tempremovelist; do 7535181834Sroberto case $p in 7536285612Sdelphij *.$objext | *.gcno) 7537181834Sroberto ;; 7538181834Sroberto $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*) 7539181834Sroberto if test "X$precious_files_regex" != "X"; then 7540285612Sdelphij if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 7541285612Sdelphij then 7542181834Sroberto continue 7543181834Sroberto fi 7544181834Sroberto fi 7545285612Sdelphij func_append removelist " $p" 7546181834Sroberto ;; 7547181834Sroberto *) ;; 7548181834Sroberto esac 7549181834Sroberto done 7550285612Sdelphij test -n "$removelist" && \ 7551285612Sdelphij func_show_eval "${RM}r \$removelist" 7552181834Sroberto fi 7553181834Sroberto 7554181834Sroberto # Now set the variables for building old libraries. 7555181834Sroberto if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then 7556285612Sdelphij func_append oldlibs " $output_objdir/$libname.$libext" 7557181834Sroberto 7558181834Sroberto # Transform .lo files to .o files. 7559285612Sdelphij oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP` 7560181834Sroberto fi 7561181834Sroberto 7562181834Sroberto # Eliminate all temporary directories. 7563285612Sdelphij #for path in $notinst_path; do 7564285612Sdelphij # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 7565285612Sdelphij # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 7566285612Sdelphij # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 7567285612Sdelphij #done 7568181834Sroberto 7569181834Sroberto if test -n "$xrpath"; then 7570181834Sroberto # If the user specified any rpath flags, then add them. 7571181834Sroberto temp_xrpath= 7572181834Sroberto for libdir in $xrpath; do 7573285612Sdelphij func_replace_sysroot "$libdir" 7574285612Sdelphij func_append temp_xrpath " -R$func_replace_sysroot_result" 7575181834Sroberto case "$finalize_rpath " in 7576181834Sroberto *" $libdir "*) ;; 7577285612Sdelphij *) func_append finalize_rpath " $libdir" ;; 7578181834Sroberto esac 7579181834Sroberto done 7580181834Sroberto if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then 7581181834Sroberto dependency_libs="$temp_xrpath $dependency_libs" 7582181834Sroberto fi 7583181834Sroberto fi 7584181834Sroberto 7585181834Sroberto # Make sure dlfiles contains only unique files that won't be dlpreopened 7586181834Sroberto old_dlfiles="$dlfiles" 7587181834Sroberto dlfiles= 7588181834Sroberto for lib in $old_dlfiles; do 7589181834Sroberto case " $dlprefiles $dlfiles " in 7590181834Sroberto *" $lib "*) ;; 7591285612Sdelphij *) func_append dlfiles " $lib" ;; 7592181834Sroberto esac 7593181834Sroberto done 7594181834Sroberto 7595181834Sroberto # Make sure dlprefiles contains only unique files 7596181834Sroberto old_dlprefiles="$dlprefiles" 7597181834Sroberto dlprefiles= 7598181834Sroberto for lib in $old_dlprefiles; do 7599181834Sroberto case "$dlprefiles " in 7600181834Sroberto *" $lib "*) ;; 7601285612Sdelphij *) func_append dlprefiles " $lib" ;; 7602181834Sroberto esac 7603181834Sroberto done 7604181834Sroberto 7605181834Sroberto if test "$build_libtool_libs" = yes; then 7606181834Sroberto if test -n "$rpath"; then 7607181834Sroberto case $host in 7608285612Sdelphij *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 7609181834Sroberto # these systems don't actually have a c library (as such)! 7610181834Sroberto ;; 7611181834Sroberto *-*-rhapsody* | *-*-darwin1.[012]) 7612181834Sroberto # Rhapsody C library is in the System framework 7613285612Sdelphij func_append deplibs " System.ltframework" 7614181834Sroberto ;; 7615181834Sroberto *-*-netbsd*) 7616181834Sroberto # Don't link with libc until the a.out ld.so is fixed. 7617181834Sroberto ;; 7618181834Sroberto *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*) 7619181834Sroberto # Do not include libc due to us having libc/libc_r. 7620181834Sroberto ;; 7621181834Sroberto *-*-sco3.2v5* | *-*-sco5v6*) 7622181834Sroberto # Causes problems with __ctype 7623181834Sroberto ;; 7624181834Sroberto *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7625181834Sroberto # Compiler inserts libc in the correct place for threads to work 7626181834Sroberto ;; 7627285612Sdelphij *) 7628181834Sroberto # Add libc to deplibs on all other systems if necessary. 7629181834Sroberto if test "$build_libtool_need_lc" = "yes"; then 7630285612Sdelphij func_append deplibs " -lc" 7631181834Sroberto fi 7632181834Sroberto ;; 7633181834Sroberto esac 7634181834Sroberto fi 7635181834Sroberto 7636181834Sroberto # Transform deplibs into only deplibs that can be linked in shared. 7637181834Sroberto name_save=$name 7638181834Sroberto libname_save=$libname 7639181834Sroberto release_save=$release 7640181834Sroberto versuffix_save=$versuffix 7641181834Sroberto major_save=$major 7642181834Sroberto # I'm not sure if I'm treating the release correctly. I think 7643181834Sroberto # release should show up in the -l (ie -lgmp5) so we don't want to 7644181834Sroberto # add it in twice. Is that correct? 7645181834Sroberto release="" 7646181834Sroberto versuffix="" 7647181834Sroberto major="" 7648181834Sroberto newdeplibs= 7649181834Sroberto droppeddeps=no 7650181834Sroberto case $deplibs_check_method in 7651181834Sroberto pass_all) 7652181834Sroberto # Don't check for shared/static. Everything works. 7653181834Sroberto # This might be a little naive. We might want to check 7654181834Sroberto # whether the library exists or not. But this is on 7655181834Sroberto # osf3 & osf4 and I'm not really sure... Just 7656181834Sroberto # implementing what was already the behavior. 7657181834Sroberto newdeplibs=$deplibs 7658181834Sroberto ;; 7659181834Sroberto test_compile) 7660181834Sroberto # This code stresses the "libraries are programs" paradigm to its 7661181834Sroberto # limits. Maybe even breaks it. We compile a program, linking it 7662181834Sroberto # against the deplibs as a proxy for the library. Then we can check 7663181834Sroberto # whether they linked in statically or dynamically with ldd. 7664285612Sdelphij $opt_dry_run || $RM conftest.c 7665181834Sroberto cat > conftest.c <<EOF 7666181834Sroberto int main() { return 0; } 7667181834SrobertoEOF 7668285612Sdelphij $opt_dry_run || $RM conftest 7669285612Sdelphij if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 7670181834Sroberto ldd_output=`ldd conftest` 7671181834Sroberto for i in $deplibs; do 7672285612Sdelphij case $i in 7673285612Sdelphij -l*) 7674285612Sdelphij func_stripname -l '' "$i" 7675285612Sdelphij name=$func_stripname_result 7676181834Sroberto if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7677181834Sroberto case " $predeps $postdeps " in 7678181834Sroberto *" $i "*) 7679285612Sdelphij func_append newdeplibs " $i" 7680181834Sroberto i="" 7681181834Sroberto ;; 7682181834Sroberto esac 7683285612Sdelphij fi 7684181834Sroberto if test -n "$i" ; then 7685285612Sdelphij libname=`eval "\\$ECHO \"$libname_spec\""` 7686285612Sdelphij deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7687285612Sdelphij set dummy $deplib_matches; shift 7688285612Sdelphij deplib_match=$1 7689181834Sroberto if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7690285612Sdelphij func_append newdeplibs " $i" 7691181834Sroberto else 7692181834Sroberto droppeddeps=yes 7693285612Sdelphij echo 7694285612Sdelphij $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7695285612Sdelphij echo "*** I have the capability to make that library automatically link in when" 7696285612Sdelphij echo "*** you link to this library. But I can only do this if you have a" 7697285612Sdelphij echo "*** shared version of the library, which I believe you do not have" 7698285612Sdelphij echo "*** because a test_compile did reveal that the linker did not use it for" 7699285612Sdelphij echo "*** its dynamic dependency list that programs get resolved with at runtime." 7700181834Sroberto fi 7701181834Sroberto fi 7702285612Sdelphij ;; 7703285612Sdelphij *) 7704285612Sdelphij func_append newdeplibs " $i" 7705285612Sdelphij ;; 7706285612Sdelphij esac 7707181834Sroberto done 7708181834Sroberto else 7709181834Sroberto # Error occurred in the first compile. Let's try to salvage 7710181834Sroberto # the situation: Compile a separate program for each library. 7711181834Sroberto for i in $deplibs; do 7712285612Sdelphij case $i in 7713285612Sdelphij -l*) 7714285612Sdelphij func_stripname -l '' "$i" 7715285612Sdelphij name=$func_stripname_result 7716285612Sdelphij $opt_dry_run || $RM conftest 7717285612Sdelphij if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 7718181834Sroberto ldd_output=`ldd conftest` 7719181834Sroberto if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7720181834Sroberto case " $predeps $postdeps " in 7721181834Sroberto *" $i "*) 7722285612Sdelphij func_append newdeplibs " $i" 7723181834Sroberto i="" 7724181834Sroberto ;; 7725181834Sroberto esac 7726181834Sroberto fi 7727181834Sroberto if test -n "$i" ; then 7728285612Sdelphij libname=`eval "\\$ECHO \"$libname_spec\""` 7729285612Sdelphij deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 7730285612Sdelphij set dummy $deplib_matches; shift 7731285612Sdelphij deplib_match=$1 7732181834Sroberto if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then 7733285612Sdelphij func_append newdeplibs " $i" 7734181834Sroberto else 7735181834Sroberto droppeddeps=yes 7736285612Sdelphij echo 7737285612Sdelphij $ECHO "*** Warning: dynamic linker does not accept needed library $i." 7738285612Sdelphij echo "*** I have the capability to make that library automatically link in when" 7739285612Sdelphij echo "*** you link to this library. But I can only do this if you have a" 7740285612Sdelphij echo "*** shared version of the library, which you do not appear to have" 7741285612Sdelphij echo "*** because a test_compile did reveal that the linker did not use this one" 7742285612Sdelphij echo "*** as a dynamic dependency that programs can get resolved with at runtime." 7743181834Sroberto fi 7744181834Sroberto fi 7745181834Sroberto else 7746181834Sroberto droppeddeps=yes 7747285612Sdelphij echo 7748285612Sdelphij $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 7749285612Sdelphij echo "*** make it link in! You will probably need to install it or some" 7750285612Sdelphij echo "*** library that it depends on before this library will be fully" 7751285612Sdelphij echo "*** functional. Installing it before continuing would be even better." 7752181834Sroberto fi 7753285612Sdelphij ;; 7754285612Sdelphij *) 7755285612Sdelphij func_append newdeplibs " $i" 7756285612Sdelphij ;; 7757285612Sdelphij esac 7758181834Sroberto done 7759181834Sroberto fi 7760181834Sroberto ;; 7761181834Sroberto file_magic*) 7762285612Sdelphij set dummy $deplibs_check_method; shift 7763285612Sdelphij file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7764181834Sroberto for a_deplib in $deplibs; do 7765285612Sdelphij case $a_deplib in 7766285612Sdelphij -l*) 7767285612Sdelphij func_stripname -l '' "$a_deplib" 7768285612Sdelphij name=$func_stripname_result 7769181834Sroberto if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7770181834Sroberto case " $predeps $postdeps " in 7771181834Sroberto *" $a_deplib "*) 7772285612Sdelphij func_append newdeplibs " $a_deplib" 7773181834Sroberto a_deplib="" 7774181834Sroberto ;; 7775181834Sroberto esac 7776181834Sroberto fi 7777181834Sroberto if test -n "$a_deplib" ; then 7778285612Sdelphij libname=`eval "\\$ECHO \"$libname_spec\""` 7779285612Sdelphij if test -n "$file_magic_glob"; then 7780285612Sdelphij libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 7781285612Sdelphij else 7782285612Sdelphij libnameglob=$libname 7783285612Sdelphij fi 7784285612Sdelphij test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob` 7785181834Sroberto for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7786285612Sdelphij if test "$want_nocaseglob" = yes; then 7787285612Sdelphij shopt -s nocaseglob 7788285612Sdelphij potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7789285612Sdelphij $nocaseglob 7790285612Sdelphij else 7791285612Sdelphij potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 7792285612Sdelphij fi 7793181834Sroberto for potent_lib in $potential_libs; do 7794181834Sroberto # Follow soft links. 7795285612Sdelphij if ls -lLd "$potent_lib" 2>/dev/null | 7796285612Sdelphij $GREP " -> " >/dev/null; then 7797181834Sroberto continue 7798181834Sroberto fi 7799181834Sroberto # The statement above tries to avoid entering an 7800181834Sroberto # endless loop below, in case of cyclic links. 7801181834Sroberto # We might still enter an endless loop, since a link 7802181834Sroberto # loop can be closed while we follow links, 7803181834Sroberto # but so what? 7804181834Sroberto potlib="$potent_lib" 7805181834Sroberto while test -h "$potlib" 2>/dev/null; do 7806181834Sroberto potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'` 7807181834Sroberto case $potliblink in 7808181834Sroberto [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";; 7809285612Sdelphij *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";; 7810181834Sroberto esac 7811181834Sroberto done 7812285612Sdelphij if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 7813285612Sdelphij $SED -e 10q | 7814285612Sdelphij $EGREP "$file_magic_regex" > /dev/null; then 7815285612Sdelphij func_append newdeplibs " $a_deplib" 7816181834Sroberto a_deplib="" 7817181834Sroberto break 2 7818181834Sroberto fi 7819181834Sroberto done 7820181834Sroberto done 7821181834Sroberto fi 7822181834Sroberto if test -n "$a_deplib" ; then 7823181834Sroberto droppeddeps=yes 7824285612Sdelphij echo 7825285612Sdelphij $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7826285612Sdelphij echo "*** I have the capability to make that library automatically link in when" 7827285612Sdelphij echo "*** you link to this library. But I can only do this if you have a" 7828285612Sdelphij echo "*** shared version of the library, which you do not appear to have" 7829285612Sdelphij echo "*** because I did check the linker path looking for a file starting" 7830181834Sroberto if test -z "$potlib" ; then 7831285612Sdelphij $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 7832181834Sroberto else 7833285612Sdelphij $ECHO "*** with $libname and none of the candidates passed a file format test" 7834285612Sdelphij $ECHO "*** using a file magic. Last file checked: $potlib" 7835181834Sroberto fi 7836181834Sroberto fi 7837285612Sdelphij ;; 7838285612Sdelphij *) 7839181834Sroberto # Add a -L argument. 7840285612Sdelphij func_append newdeplibs " $a_deplib" 7841285612Sdelphij ;; 7842285612Sdelphij esac 7843181834Sroberto done # Gone through all deplibs. 7844181834Sroberto ;; 7845181834Sroberto match_pattern*) 7846285612Sdelphij set dummy $deplibs_check_method; shift 7847285612Sdelphij match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 7848181834Sroberto for a_deplib in $deplibs; do 7849285612Sdelphij case $a_deplib in 7850285612Sdelphij -l*) 7851285612Sdelphij func_stripname -l '' "$a_deplib" 7852285612Sdelphij name=$func_stripname_result 7853181834Sroberto if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7854181834Sroberto case " $predeps $postdeps " in 7855181834Sroberto *" $a_deplib "*) 7856285612Sdelphij func_append newdeplibs " $a_deplib" 7857181834Sroberto a_deplib="" 7858181834Sroberto ;; 7859181834Sroberto esac 7860181834Sroberto fi 7861181834Sroberto if test -n "$a_deplib" ; then 7862285612Sdelphij libname=`eval "\\$ECHO \"$libname_spec\""` 7863181834Sroberto for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 7864181834Sroberto potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 7865181834Sroberto for potent_lib in $potential_libs; do 7866181834Sroberto potlib="$potent_lib" # see symlink-check above in file_magic test 7867285612Sdelphij if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 7868285612Sdelphij $EGREP "$match_pattern_regex" > /dev/null; then 7869285612Sdelphij func_append newdeplibs " $a_deplib" 7870181834Sroberto a_deplib="" 7871181834Sroberto break 2 7872181834Sroberto fi 7873181834Sroberto done 7874181834Sroberto done 7875181834Sroberto fi 7876181834Sroberto if test -n "$a_deplib" ; then 7877181834Sroberto droppeddeps=yes 7878285612Sdelphij echo 7879285612Sdelphij $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 7880285612Sdelphij echo "*** I have the capability to make that library automatically link in when" 7881285612Sdelphij echo "*** you link to this library. But I can only do this if you have a" 7882285612Sdelphij echo "*** shared version of the library, which you do not appear to have" 7883285612Sdelphij echo "*** because I did check the linker path looking for a file starting" 7884181834Sroberto if test -z "$potlib" ; then 7885285612Sdelphij $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 7886181834Sroberto else 7887285612Sdelphij $ECHO "*** with $libname and none of the candidates passed a file format test" 7888285612Sdelphij $ECHO "*** using a regex pattern. Last file checked: $potlib" 7889181834Sroberto fi 7890181834Sroberto fi 7891285612Sdelphij ;; 7892285612Sdelphij *) 7893181834Sroberto # Add a -L argument. 7894285612Sdelphij func_append newdeplibs " $a_deplib" 7895285612Sdelphij ;; 7896285612Sdelphij esac 7897181834Sroberto done # Gone through all deplibs. 7898181834Sroberto ;; 7899181834Sroberto none | unknown | *) 7900181834Sroberto newdeplibs="" 7901285612Sdelphij tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 7902181834Sroberto if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then 7903181834Sroberto for i in $predeps $postdeps ; do 7904181834Sroberto # can't use Xsed below, because $i might contain '/' 7905285612Sdelphij tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"` 7906181834Sroberto done 7907181834Sroberto fi 7908285612Sdelphij case $tmp_deplibs in 7909285612Sdelphij *[!\ \ ]*) 7910285612Sdelphij echo 7911181834Sroberto if test "X$deplibs_check_method" = "Xnone"; then 7912285612Sdelphij echo "*** Warning: inter-library dependencies are not supported in this platform." 7913181834Sroberto else 7914285612Sdelphij echo "*** Warning: inter-library dependencies are not known to be supported." 7915181834Sroberto fi 7916285612Sdelphij echo "*** All declared inter-library dependencies are being dropped." 7917181834Sroberto droppeddeps=yes 7918285612Sdelphij ;; 7919285612Sdelphij esac 7920181834Sroberto ;; 7921181834Sroberto esac 7922181834Sroberto versuffix=$versuffix_save 7923181834Sroberto major=$major_save 7924181834Sroberto release=$release_save 7925181834Sroberto libname=$libname_save 7926181834Sroberto name=$name_save 7927181834Sroberto 7928181834Sroberto case $host in 7929181834Sroberto *-*-rhapsody* | *-*-darwin1.[012]) 7930285612Sdelphij # On Rhapsody replace the C library with the System framework 7931285612Sdelphij newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 7932181834Sroberto ;; 7933181834Sroberto esac 7934181834Sroberto 7935181834Sroberto if test "$droppeddeps" = yes; then 7936181834Sroberto if test "$module" = yes; then 7937285612Sdelphij echo 7938285612Sdelphij echo "*** Warning: libtool could not satisfy all declared inter-library" 7939285612Sdelphij $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 7940285612Sdelphij echo "*** a static module, that should work as long as the dlopening" 7941285612Sdelphij echo "*** application is linked with the -dlopen flag." 7942181834Sroberto if test -z "$global_symbol_pipe"; then 7943285612Sdelphij echo 7944285612Sdelphij echo "*** However, this would only work if libtool was able to extract symbol" 7945285612Sdelphij echo "*** lists from a program, using \`nm' or equivalent, but libtool could" 7946285612Sdelphij echo "*** not find such a program. So, this module is probably useless." 7947285612Sdelphij echo "*** \`nm' from GNU binutils and a full rebuild may help." 7948181834Sroberto fi 7949181834Sroberto if test "$build_old_libs" = no; then 7950181834Sroberto oldlibs="$output_objdir/$libname.$libext" 7951181834Sroberto build_libtool_libs=module 7952181834Sroberto build_old_libs=yes 7953181834Sroberto else 7954181834Sroberto build_libtool_libs=no 7955181834Sroberto fi 7956181834Sroberto else 7957285612Sdelphij echo "*** The inter-library dependencies that have been dropped here will be" 7958285612Sdelphij echo "*** automatically added whenever a program is linked with this library" 7959285612Sdelphij echo "*** or is declared to -dlopen it." 7960181834Sroberto 7961181834Sroberto if test "$allow_undefined" = no; then 7962285612Sdelphij echo 7963285612Sdelphij echo "*** Since this library must not contain undefined symbols," 7964285612Sdelphij echo "*** because either the platform does not support them or" 7965285612Sdelphij echo "*** it was explicitly requested with -no-undefined," 7966285612Sdelphij echo "*** libtool will only create a static version of it." 7967181834Sroberto if test "$build_old_libs" = no; then 7968181834Sroberto oldlibs="$output_objdir/$libname.$libext" 7969181834Sroberto build_libtool_libs=module 7970181834Sroberto build_old_libs=yes 7971181834Sroberto else 7972181834Sroberto build_libtool_libs=no 7973181834Sroberto fi 7974181834Sroberto fi 7975181834Sroberto fi 7976181834Sroberto fi 7977181834Sroberto # Done checking deplibs! 7978181834Sroberto deplibs=$newdeplibs 7979181834Sroberto fi 7980285612Sdelphij # Time to change all our "foo.ltframework" stuff back to "-framework foo" 7981285612Sdelphij case $host in 7982285612Sdelphij *-*-darwin*) 7983285612Sdelphij newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7984285612Sdelphij new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7985285612Sdelphij deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 7986285612Sdelphij ;; 7987285612Sdelphij esac 7988181834Sroberto 7989181834Sroberto # move library search paths that coincide with paths to not yet 7990181834Sroberto # installed libraries to the beginning of the library search list 7991181834Sroberto new_libs= 7992181834Sroberto for path in $notinst_path; do 7993181834Sroberto case " $new_libs " in 7994181834Sroberto *" -L$path/$objdir "*) ;; 7995181834Sroberto *) 7996181834Sroberto case " $deplibs " in 7997181834Sroberto *" -L$path/$objdir "*) 7998285612Sdelphij func_append new_libs " -L$path/$objdir" ;; 7999181834Sroberto esac 8000181834Sroberto ;; 8001181834Sroberto esac 8002181834Sroberto done 8003181834Sroberto for deplib in $deplibs; do 8004181834Sroberto case $deplib in 8005181834Sroberto -L*) 8006181834Sroberto case " $new_libs " in 8007181834Sroberto *" $deplib "*) ;; 8008285612Sdelphij *) func_append new_libs " $deplib" ;; 8009181834Sroberto esac 8010181834Sroberto ;; 8011285612Sdelphij *) func_append new_libs " $deplib" ;; 8012181834Sroberto esac 8013181834Sroberto done 8014181834Sroberto deplibs="$new_libs" 8015181834Sroberto 8016181834Sroberto # All the library-specific variables (install_libdir is set above). 8017181834Sroberto library_names= 8018181834Sroberto old_library= 8019181834Sroberto dlname= 8020181834Sroberto 8021181834Sroberto # Test again, we may have decided not to build it any more 8022181834Sroberto if test "$build_libtool_libs" = yes; then 8023181834Sroberto if test "$hardcode_into_libs" = yes; then 8024181834Sroberto # Hardcode the library paths 8025181834Sroberto hardcode_libdirs= 8026181834Sroberto dep_rpath= 8027181834Sroberto rpath="$finalize_rpath" 8028285612Sdelphij test "$opt_mode" != relink && rpath="$compile_rpath$rpath" 8029181834Sroberto for libdir in $rpath; do 8030181834Sroberto if test -n "$hardcode_libdir_flag_spec"; then 8031181834Sroberto if test -n "$hardcode_libdir_separator"; then 8032285612Sdelphij func_replace_sysroot "$libdir" 8033285612Sdelphij libdir=$func_replace_sysroot_result 8034181834Sroberto if test -z "$hardcode_libdirs"; then 8035181834Sroberto hardcode_libdirs="$libdir" 8036181834Sroberto else 8037181834Sroberto # Just accumulate the unique libdirs. 8038181834Sroberto case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8039181834Sroberto *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8040181834Sroberto ;; 8041181834Sroberto *) 8042285612Sdelphij func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8043181834Sroberto ;; 8044181834Sroberto esac 8045181834Sroberto fi 8046181834Sroberto else 8047181834Sroberto eval flag=\"$hardcode_libdir_flag_spec\" 8048285612Sdelphij func_append dep_rpath " $flag" 8049181834Sroberto fi 8050181834Sroberto elif test -n "$runpath_var"; then 8051181834Sroberto case "$perm_rpath " in 8052181834Sroberto *" $libdir "*) ;; 8053285612Sdelphij *) func_apped perm_rpath " $libdir" ;; 8054181834Sroberto esac 8055181834Sroberto fi 8056181834Sroberto done 8057181834Sroberto # Substitute the hardcoded libdirs into the rpath. 8058181834Sroberto if test -n "$hardcode_libdir_separator" && 8059181834Sroberto test -n "$hardcode_libdirs"; then 8060181834Sroberto libdir="$hardcode_libdirs" 8061181834Sroberto if test -n "$hardcode_libdir_flag_spec_ld"; then 8062181834Sroberto eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\" 8063181834Sroberto else 8064181834Sroberto eval dep_rpath=\"$hardcode_libdir_flag_spec\" 8065181834Sroberto fi 8066181834Sroberto fi 8067181834Sroberto if test -n "$runpath_var" && test -n "$perm_rpath"; then 8068181834Sroberto # We should set the runpath_var. 8069181834Sroberto rpath= 8070181834Sroberto for dir in $perm_rpath; do 8071285612Sdelphij func_append rpath "$dir:" 8072181834Sroberto done 8073181834Sroberto eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 8074181834Sroberto fi 8075181834Sroberto test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 8076181834Sroberto fi 8077181834Sroberto 8078181834Sroberto shlibpath="$finalize_shlibpath" 8079285612Sdelphij test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath" 8080181834Sroberto if test -n "$shlibpath"; then 8081181834Sroberto eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 8082181834Sroberto fi 8083181834Sroberto 8084181834Sroberto # Get the real and link names of the library. 8085181834Sroberto eval shared_ext=\"$shrext_cmds\" 8086181834Sroberto eval library_names=\"$library_names_spec\" 8087181834Sroberto set dummy $library_names 8088285612Sdelphij shift 8089285612Sdelphij realname="$1" 8090285612Sdelphij shift 8091181834Sroberto 8092181834Sroberto if test -n "$soname_spec"; then 8093181834Sroberto eval soname=\"$soname_spec\" 8094181834Sroberto else 8095181834Sroberto soname="$realname" 8096181834Sroberto fi 8097181834Sroberto if test -z "$dlname"; then 8098181834Sroberto dlname=$soname 8099181834Sroberto fi 8100181834Sroberto 8101181834Sroberto lib="$output_objdir/$realname" 8102181834Sroberto linknames= 8103181834Sroberto for link 8104181834Sroberto do 8105285612Sdelphij func_append linknames " $link" 8106181834Sroberto done 8107181834Sroberto 8108181834Sroberto # Use standard objects if they are pic 8109285612Sdelphij test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 8110285612Sdelphij test "X$libobjs" = "X " && libobjs= 8111181834Sroberto 8112285612Sdelphij delfiles= 8113285612Sdelphij if test -n "$export_symbols" && test -n "$include_expsyms"; then 8114285612Sdelphij $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 8115285612Sdelphij export_symbols="$output_objdir/$libname.uexp" 8116285612Sdelphij func_append delfiles " $export_symbols" 8117285612Sdelphij fi 8118285612Sdelphij 8119285612Sdelphij orig_export_symbols= 8120285612Sdelphij case $host_os in 8121285612Sdelphij cygwin* | mingw* | cegcc*) 8122285612Sdelphij if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 8123285612Sdelphij # exporting using user supplied symfile 8124285612Sdelphij if test "x`$SED 1q $export_symbols`" != xEXPORTS; then 8125285612Sdelphij # and it's NOT already a .def file. Must figure out 8126285612Sdelphij # which of the given symbols are data symbols and tag 8127285612Sdelphij # them as such. So, trigger use of export_symbols_cmds. 8128285612Sdelphij # export_symbols gets reassigned inside the "prepare 8129285612Sdelphij # the list of exported symbols" if statement, so the 8130285612Sdelphij # include_expsyms logic still works. 8131285612Sdelphij orig_export_symbols="$export_symbols" 8132285612Sdelphij export_symbols= 8133285612Sdelphij always_export_symbols=yes 8134285612Sdelphij fi 8135285612Sdelphij fi 8136285612Sdelphij ;; 8137285612Sdelphij esac 8138285612Sdelphij 8139181834Sroberto # Prepare the list of exported symbols 8140181834Sroberto if test -z "$export_symbols"; then 8141181834Sroberto if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then 8142285612Sdelphij func_verbose "generating symbol list for \`$libname.la'" 8143181834Sroberto export_symbols="$output_objdir/$libname.exp" 8144285612Sdelphij $opt_dry_run || $RM $export_symbols 8145181834Sroberto cmds=$export_symbols_cmds 8146181834Sroberto save_ifs="$IFS"; IFS='~' 8147285612Sdelphij for cmd1 in $cmds; do 8148181834Sroberto IFS="$save_ifs" 8149285612Sdelphij # Take the normal branch if the nm_file_list_spec branch 8150285612Sdelphij # doesn't work or if tool conversion is not needed. 8151285612Sdelphij case $nm_file_list_spec~$to_tool_file_cmd in 8152285612Sdelphij *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 8153285612Sdelphij try_normal_branch=yes 8154285612Sdelphij eval cmd=\"$cmd1\" 8155285612Sdelphij func_len " $cmd" 8156285612Sdelphij len=$func_len_result 8157285612Sdelphij ;; 8158285612Sdelphij *) 8159285612Sdelphij try_normal_branch=no 8160285612Sdelphij ;; 8161285612Sdelphij esac 8162285612Sdelphij if test "$try_normal_branch" = yes \ 8163285612Sdelphij && { test "$len" -lt "$max_cmd_len" \ 8164285612Sdelphij || test "$max_cmd_len" -le -1; } 8165285612Sdelphij then 8166285612Sdelphij func_show_eval "$cmd" 'exit $?' 8167285612Sdelphij skipped_export=false 8168285612Sdelphij elif test -n "$nm_file_list_spec"; then 8169285612Sdelphij func_basename "$output" 8170285612Sdelphij output_la=$func_basename_result 8171285612Sdelphij save_libobjs=$libobjs 8172285612Sdelphij save_output=$output 8173285612Sdelphij output=${output_objdir}/${output_la}.nm 8174285612Sdelphij func_to_tool_file "$output" 8175285612Sdelphij libobjs=$nm_file_list_spec$func_to_tool_file_result 8176285612Sdelphij func_append delfiles " $output" 8177285612Sdelphij func_verbose "creating $NM input file list: $output" 8178285612Sdelphij for obj in $save_libobjs; do 8179285612Sdelphij func_to_tool_file "$obj" 8180285612Sdelphij $ECHO "$func_to_tool_file_result" 8181285612Sdelphij done > "$output" 8182285612Sdelphij eval cmd=\"$cmd1\" 8183285612Sdelphij func_show_eval "$cmd" 'exit $?' 8184285612Sdelphij output=$save_output 8185285612Sdelphij libobjs=$save_libobjs 8186285612Sdelphij skipped_export=false 8187181834Sroberto else 8188285612Sdelphij # The command line is too long to execute in one step. 8189285612Sdelphij func_verbose "using reloadable object file for export list..." 8190285612Sdelphij skipped_export=: 8191181834Sroberto # Break out early, otherwise skipped_export may be 8192181834Sroberto # set to false by a later but shorter cmd. 8193181834Sroberto break 8194181834Sroberto fi 8195181834Sroberto done 8196181834Sroberto IFS="$save_ifs" 8197285612Sdelphij if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then 8198285612Sdelphij func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8199285612Sdelphij func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8200181834Sroberto fi 8201181834Sroberto fi 8202181834Sroberto fi 8203181834Sroberto 8204181834Sroberto if test -n "$export_symbols" && test -n "$include_expsyms"; then 8205285612Sdelphij tmp_export_symbols="$export_symbols" 8206285612Sdelphij test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8207285612Sdelphij $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8208181834Sroberto fi 8209181834Sroberto 8210285612Sdelphij if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then 8211285612Sdelphij # The given exports_symbols file has to be filtered, so filter it. 8212285612Sdelphij func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8213285612Sdelphij # FIXME: $output_objdir/$libname.filter potentially contains lots of 8214285612Sdelphij # 's' commands which not all seds can handle. GNU sed should be fine 8215285612Sdelphij # though. Also, the filter scales superlinearly with the number of 8216285612Sdelphij # global variables. join(1) would be nice here, but unfortunately 8217285612Sdelphij # isn't a blessed tool. 8218285612Sdelphij $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8219285612Sdelphij func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8220285612Sdelphij export_symbols=$output_objdir/$libname.def 8221285612Sdelphij $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8222285612Sdelphij fi 8223285612Sdelphij 8224181834Sroberto tmp_deplibs= 8225181834Sroberto for test_deplib in $deplibs; do 8226285612Sdelphij case " $convenience " in 8227285612Sdelphij *" $test_deplib "*) ;; 8228285612Sdelphij *) 8229285612Sdelphij func_append tmp_deplibs " $test_deplib" 8230285612Sdelphij ;; 8231285612Sdelphij esac 8232181834Sroberto done 8233181834Sroberto deplibs="$tmp_deplibs" 8234181834Sroberto 8235181834Sroberto if test -n "$convenience"; then 8236285612Sdelphij if test -n "$whole_archive_flag_spec" && 8237285612Sdelphij test "$compiler_needs_object" = yes && 8238285612Sdelphij test -z "$libobjs"; then 8239285612Sdelphij # extract the archives, so we have objects to list. 8240285612Sdelphij # TODO: could optimize this to just extract one archive. 8241285612Sdelphij whole_archive_flag_spec= 8242285612Sdelphij fi 8243181834Sroberto if test -n "$whole_archive_flag_spec"; then 8244181834Sroberto save_libobjs=$libobjs 8245181834Sroberto eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8246285612Sdelphij test "X$libobjs" = "X " && libobjs= 8247181834Sroberto else 8248181834Sroberto gentop="$output_objdir/${outputname}x" 8249285612Sdelphij func_append generated " $gentop" 8250181834Sroberto 8251181834Sroberto func_extract_archives $gentop $convenience 8252285612Sdelphij func_append libobjs " $func_extract_archives_result" 8253285612Sdelphij test "X$libobjs" = "X " && libobjs= 8254181834Sroberto fi 8255181834Sroberto fi 8256285612Sdelphij 8257181834Sroberto if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then 8258181834Sroberto eval flag=\"$thread_safe_flag_spec\" 8259285612Sdelphij func_append linker_flags " $flag" 8260181834Sroberto fi 8261181834Sroberto 8262181834Sroberto # Make a backup of the uninstalled library when relinking 8263285612Sdelphij if test "$opt_mode" = relink; then 8264285612Sdelphij $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 8265181834Sroberto fi 8266181834Sroberto 8267181834Sroberto # Do each of the archive commands. 8268181834Sroberto if test "$module" = yes && test -n "$module_cmds" ; then 8269181834Sroberto if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8270181834Sroberto eval test_cmds=\"$module_expsym_cmds\" 8271181834Sroberto cmds=$module_expsym_cmds 8272181834Sroberto else 8273181834Sroberto eval test_cmds=\"$module_cmds\" 8274181834Sroberto cmds=$module_cmds 8275181834Sroberto fi 8276181834Sroberto else 8277285612Sdelphij if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8278285612Sdelphij eval test_cmds=\"$archive_expsym_cmds\" 8279285612Sdelphij cmds=$archive_expsym_cmds 8280285612Sdelphij else 8281285612Sdelphij eval test_cmds=\"$archive_cmds\" 8282285612Sdelphij cmds=$archive_cmds 8283181834Sroberto fi 8284181834Sroberto fi 8285181834Sroberto 8286181834Sroberto if test "X$skipped_export" != "X:" && 8287285612Sdelphij func_len " $test_cmds" && 8288285612Sdelphij len=$func_len_result && 8289285612Sdelphij test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 8290181834Sroberto : 8291181834Sroberto else 8292285612Sdelphij # The command line is too long to link in one step, link piecewise 8293285612Sdelphij # or, if using GNU ld and skipped_export is not :, use a linker 8294285612Sdelphij # script. 8295181834Sroberto 8296181834Sroberto # Save the value of $output and $libobjs because we want to 8297181834Sroberto # use them later. If we have whole_archive_flag_spec, we 8298181834Sroberto # want to use save_libobjs as it was before 8299181834Sroberto # whole_archive_flag_spec was expanded, because we can't 8300181834Sroberto # assume the linker understands whole_archive_flag_spec. 8301181834Sroberto # This may have to be revisited, in case too many 8302181834Sroberto # convenience libraries get linked in and end up exceeding 8303181834Sroberto # the spec. 8304181834Sroberto if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 8305181834Sroberto save_libobjs=$libobjs 8306181834Sroberto fi 8307181834Sroberto save_output=$output 8308285612Sdelphij func_basename "$output" 8309285612Sdelphij output_la=$func_basename_result 8310181834Sroberto 8311181834Sroberto # Clear the reloadable object creation command queue and 8312181834Sroberto # initialize k to one. 8313181834Sroberto test_cmds= 8314181834Sroberto concat_cmds= 8315181834Sroberto objlist= 8316181834Sroberto last_robj= 8317181834Sroberto k=1 8318285612Sdelphij 8319285612Sdelphij if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then 8320285612Sdelphij output=${output_objdir}/${output_la}.lnkscript 8321285612Sdelphij func_verbose "creating GNU ld script: $output" 8322285612Sdelphij echo 'INPUT (' > $output 8323285612Sdelphij for obj in $save_libobjs 8324285612Sdelphij do 8325285612Sdelphij func_to_tool_file "$obj" 8326285612Sdelphij $ECHO "$func_to_tool_file_result" >> $output 8327285612Sdelphij done 8328285612Sdelphij echo ')' >> $output 8329285612Sdelphij func_append delfiles " $output" 8330285612Sdelphij func_to_tool_file "$output" 8331285612Sdelphij output=$func_to_tool_file_result 8332285612Sdelphij elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then 8333285612Sdelphij output=${output_objdir}/${output_la}.lnk 8334285612Sdelphij func_verbose "creating linker input file list: $output" 8335285612Sdelphij : > $output 8336285612Sdelphij set x $save_libobjs 8337285612Sdelphij shift 8338285612Sdelphij firstobj= 8339285612Sdelphij if test "$compiler_needs_object" = yes; then 8340285612Sdelphij firstobj="$1 " 8341285612Sdelphij shift 8342285612Sdelphij fi 8343285612Sdelphij for obj 8344285612Sdelphij do 8345285612Sdelphij func_to_tool_file "$obj" 8346285612Sdelphij $ECHO "$func_to_tool_file_result" >> $output 8347285612Sdelphij done 8348285612Sdelphij func_append delfiles " $output" 8349285612Sdelphij func_to_tool_file "$output" 8350285612Sdelphij output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 8351285612Sdelphij else 8352285612Sdelphij if test -n "$save_libobjs"; then 8353285612Sdelphij func_verbose "creating reloadable object files..." 8354285612Sdelphij output=$output_objdir/$output_la-${k}.$objext 8355285612Sdelphij eval test_cmds=\"$reload_cmds\" 8356285612Sdelphij func_len " $test_cmds" 8357285612Sdelphij len0=$func_len_result 8358285612Sdelphij len=$len0 8359285612Sdelphij 8360285612Sdelphij # Loop over the list of objects to be linked. 8361285612Sdelphij for obj in $save_libobjs 8362285612Sdelphij do 8363285612Sdelphij func_len " $obj" 8364285612Sdelphij func_arith $len + $func_len_result 8365285612Sdelphij len=$func_arith_result 8366285612Sdelphij if test "X$objlist" = X || 8367285612Sdelphij test "$len" -lt "$max_cmd_len"; then 8368285612Sdelphij func_append objlist " $obj" 8369285612Sdelphij else 8370285612Sdelphij # The command $test_cmds is almost too long, add a 8371285612Sdelphij # command to the queue. 8372285612Sdelphij if test "$k" -eq 1 ; then 8373285612Sdelphij # The first file doesn't have a previous command to add. 8374285612Sdelphij reload_objs=$objlist 8375285612Sdelphij eval concat_cmds=\"$reload_cmds\" 8376285612Sdelphij else 8377285612Sdelphij # All subsequent reloadable object files will link in 8378285612Sdelphij # the last one created. 8379285612Sdelphij reload_objs="$objlist $last_robj" 8380285612Sdelphij eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 8381285612Sdelphij fi 8382285612Sdelphij last_robj=$output_objdir/$output_la-${k}.$objext 8383285612Sdelphij func_arith $k + 1 8384285612Sdelphij k=$func_arith_result 8385285612Sdelphij output=$output_objdir/$output_la-${k}.$objext 8386285612Sdelphij objlist=" $obj" 8387285612Sdelphij func_len " $last_robj" 8388285612Sdelphij func_arith $len0 + $func_len_result 8389285612Sdelphij len=$func_arith_result 8390285612Sdelphij fi 8391285612Sdelphij done 8392285612Sdelphij # Handle the remaining objects by creating one last 8393285612Sdelphij # reloadable object file. All subsequent reloadable object 8394285612Sdelphij # files will link in the last one created. 8395285612Sdelphij test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8396285612Sdelphij reload_objs="$objlist $last_robj" 8397285612Sdelphij eval concat_cmds=\"\${concat_cmds}$reload_cmds\" 8398285612Sdelphij if test -n "$last_robj"; then 8399285612Sdelphij eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\" 8400285612Sdelphij fi 8401285612Sdelphij func_append delfiles " $output" 8402285612Sdelphij 8403181834Sroberto else 8404285612Sdelphij output= 8405285612Sdelphij fi 8406285612Sdelphij 8407285612Sdelphij if ${skipped_export-false}; then 8408285612Sdelphij func_verbose "generating symbol list for \`$libname.la'" 8409285612Sdelphij export_symbols="$output_objdir/$libname.exp" 8410285612Sdelphij $opt_dry_run || $RM $export_symbols 8411285612Sdelphij libobjs=$output 8412285612Sdelphij # Append the command to create the export file. 8413285612Sdelphij test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 8414285612Sdelphij eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 8415285612Sdelphij if test -n "$last_robj"; then 8416285612Sdelphij eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 8417181834Sroberto fi 8418181834Sroberto fi 8419181834Sroberto 8420285612Sdelphij test -n "$save_libobjs" && 8421285612Sdelphij func_verbose "creating a temporary reloadable object file: $output" 8422181834Sroberto 8423285612Sdelphij # Loop through the commands generated above and execute them. 8424285612Sdelphij save_ifs="$IFS"; IFS='~' 8425285612Sdelphij for cmd in $concat_cmds; do 8426285612Sdelphij IFS="$save_ifs" 8427285612Sdelphij $opt_silent || { 8428285612Sdelphij func_quote_for_expand "$cmd" 8429285612Sdelphij eval "func_echo $func_quote_for_expand_result" 8430285612Sdelphij } 8431285612Sdelphij $opt_dry_run || eval "$cmd" || { 8432285612Sdelphij lt_exit=$? 8433181834Sroberto 8434285612Sdelphij # Restore the uninstalled library and exit 8435285612Sdelphij if test "$opt_mode" = relink; then 8436285612Sdelphij ( cd "$output_objdir" && \ 8437285612Sdelphij $RM "${realname}T" && \ 8438285612Sdelphij $MV "${realname}U" "$realname" ) 8439285612Sdelphij fi 8440181834Sroberto 8441285612Sdelphij exit $lt_exit 8442285612Sdelphij } 8443285612Sdelphij done 8444181834Sroberto IFS="$save_ifs" 8445181834Sroberto 8446285612Sdelphij if test -n "$export_symbols_regex" && ${skipped_export-false}; then 8447285612Sdelphij func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 8448285612Sdelphij func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 8449285612Sdelphij fi 8450285612Sdelphij fi 8451285612Sdelphij 8452285612Sdelphij if ${skipped_export-false}; then 8453285612Sdelphij if test -n "$export_symbols" && test -n "$include_expsyms"; then 8454285612Sdelphij tmp_export_symbols="$export_symbols" 8455285612Sdelphij test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols" 8456285612Sdelphij $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 8457285612Sdelphij fi 8458285612Sdelphij 8459285612Sdelphij if test -n "$orig_export_symbols"; then 8460285612Sdelphij # The given exports_symbols file has to be filtered, so filter it. 8461285612Sdelphij func_verbose "filter symbol list for \`$libname.la' to tag DATA exports" 8462285612Sdelphij # FIXME: $output_objdir/$libname.filter potentially contains lots of 8463285612Sdelphij # 's' commands which not all seds can handle. GNU sed should be fine 8464285612Sdelphij # though. Also, the filter scales superlinearly with the number of 8465285612Sdelphij # global variables. join(1) would be nice here, but unfortunately 8466285612Sdelphij # isn't a blessed tool. 8467285612Sdelphij $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 8468285612Sdelphij func_append delfiles " $export_symbols $output_objdir/$libname.filter" 8469285612Sdelphij export_symbols=$output_objdir/$libname.def 8470285612Sdelphij $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 8471285612Sdelphij fi 8472285612Sdelphij fi 8473285612Sdelphij 8474181834Sroberto libobjs=$output 8475181834Sroberto # Restore the value of output. 8476181834Sroberto output=$save_output 8477181834Sroberto 8478181834Sroberto if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 8479181834Sroberto eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 8480285612Sdelphij test "X$libobjs" = "X " && libobjs= 8481181834Sroberto fi 8482181834Sroberto # Expand the library linking commands again to reset the 8483181834Sroberto # value of $libobjs for piecewise linking. 8484181834Sroberto 8485181834Sroberto # Do each of the archive commands. 8486181834Sroberto if test "$module" = yes && test -n "$module_cmds" ; then 8487181834Sroberto if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 8488181834Sroberto cmds=$module_expsym_cmds 8489181834Sroberto else 8490181834Sroberto cmds=$module_cmds 8491181834Sroberto fi 8492181834Sroberto else 8493285612Sdelphij if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 8494285612Sdelphij cmds=$archive_expsym_cmds 8495285612Sdelphij else 8496285612Sdelphij cmds=$archive_cmds 8497181834Sroberto fi 8498181834Sroberto fi 8499285612Sdelphij fi 8500181834Sroberto 8501285612Sdelphij if test -n "$delfiles"; then 8502285612Sdelphij # Append the command to remove temporary files to $cmds. 8503285612Sdelphij eval cmds=\"\$cmds~\$RM $delfiles\" 8504181834Sroberto fi 8505285612Sdelphij 8506285612Sdelphij # Add any objects from preloaded convenience libraries 8507285612Sdelphij if test -n "$dlprefiles"; then 8508285612Sdelphij gentop="$output_objdir/${outputname}x" 8509285612Sdelphij func_append generated " $gentop" 8510285612Sdelphij 8511285612Sdelphij func_extract_archives $gentop $dlprefiles 8512285612Sdelphij func_append libobjs " $func_extract_archives_result" 8513285612Sdelphij test "X$libobjs" = "X " && libobjs= 8514285612Sdelphij fi 8515285612Sdelphij 8516181834Sroberto save_ifs="$IFS"; IFS='~' 8517181834Sroberto for cmd in $cmds; do 8518181834Sroberto IFS="$save_ifs" 8519181834Sroberto eval cmd=\"$cmd\" 8520285612Sdelphij $opt_silent || { 8521285612Sdelphij func_quote_for_expand "$cmd" 8522285612Sdelphij eval "func_echo $func_quote_for_expand_result" 8523285612Sdelphij } 8524285612Sdelphij $opt_dry_run || eval "$cmd" || { 8525181834Sroberto lt_exit=$? 8526181834Sroberto 8527181834Sroberto # Restore the uninstalled library and exit 8528285612Sdelphij if test "$opt_mode" = relink; then 8529285612Sdelphij ( cd "$output_objdir" && \ 8530285612Sdelphij $RM "${realname}T" && \ 8531285612Sdelphij $MV "${realname}U" "$realname" ) 8532181834Sroberto fi 8533181834Sroberto 8534181834Sroberto exit $lt_exit 8535181834Sroberto } 8536181834Sroberto done 8537181834Sroberto IFS="$save_ifs" 8538181834Sroberto 8539181834Sroberto # Restore the uninstalled library and exit 8540285612Sdelphij if test "$opt_mode" = relink; then 8541285612Sdelphij $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 8542181834Sroberto 8543181834Sroberto if test -n "$convenience"; then 8544181834Sroberto if test -z "$whole_archive_flag_spec"; then 8545285612Sdelphij func_show_eval '${RM}r "$gentop"' 8546181834Sroberto fi 8547181834Sroberto fi 8548181834Sroberto 8549181834Sroberto exit $EXIT_SUCCESS 8550181834Sroberto fi 8551181834Sroberto 8552181834Sroberto # Create links to the real library. 8553181834Sroberto for linkname in $linknames; do 8554181834Sroberto if test "$realname" != "$linkname"; then 8555285612Sdelphij func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 8556181834Sroberto fi 8557181834Sroberto done 8558181834Sroberto 8559181834Sroberto # If -module or -export-dynamic was specified, set the dlname. 8560181834Sroberto if test "$module" = yes || test "$export_dynamic" = yes; then 8561181834Sroberto # On all known operating systems, these are identical. 8562181834Sroberto dlname="$soname" 8563181834Sroberto fi 8564181834Sroberto fi 8565181834Sroberto ;; 8566181834Sroberto 8567181834Sroberto obj) 8568181834Sroberto if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then 8569285612Sdelphij func_warning "\`-dlopen' is ignored for objects" 8570181834Sroberto fi 8571181834Sroberto 8572285612Sdelphij case " $deplibs" in 8573285612Sdelphij *\ -l* | *\ -L*) 8574285612Sdelphij func_warning "\`-l' and \`-L' are ignored for objects" ;; 8575285612Sdelphij esac 8576181834Sroberto 8577285612Sdelphij test -n "$rpath" && \ 8578285612Sdelphij func_warning "\`-rpath' is ignored for objects" 8579181834Sroberto 8580285612Sdelphij test -n "$xrpath" && \ 8581285612Sdelphij func_warning "\`-R' is ignored for objects" 8582181834Sroberto 8583285612Sdelphij test -n "$vinfo" && \ 8584285612Sdelphij func_warning "\`-version-info' is ignored for objects" 8585181834Sroberto 8586285612Sdelphij test -n "$release" && \ 8587285612Sdelphij func_warning "\`-release' is ignored for objects" 8588285612Sdelphij 8589181834Sroberto case $output in 8590181834Sroberto *.lo) 8591285612Sdelphij test -n "$objs$old_deplibs" && \ 8592285612Sdelphij func_fatal_error "cannot build library object \`$output' from non-libtool objects" 8593285612Sdelphij 8594285612Sdelphij libobj=$output 8595285612Sdelphij func_lo2o "$libobj" 8596285612Sdelphij obj=$func_lo2o_result 8597181834Sroberto ;; 8598181834Sroberto *) 8599181834Sroberto libobj= 8600181834Sroberto obj="$output" 8601181834Sroberto ;; 8602181834Sroberto esac 8603181834Sroberto 8604181834Sroberto # Delete the old objects. 8605285612Sdelphij $opt_dry_run || $RM $obj $libobj 8606181834Sroberto 8607181834Sroberto # Objects from convenience libraries. This assumes 8608181834Sroberto # single-version convenience libraries. Whenever we create 8609181834Sroberto # different ones for PIC/non-PIC, this we'll have to duplicate 8610181834Sroberto # the extraction. 8611181834Sroberto reload_conv_objs= 8612181834Sroberto gentop= 8613181834Sroberto # reload_cmds runs $LD directly, so let us get rid of 8614285612Sdelphij # -Wl from whole_archive_flag_spec and hope we can get by with 8615285612Sdelphij # turning comma into space.. 8616181834Sroberto wl= 8617181834Sroberto 8618181834Sroberto if test -n "$convenience"; then 8619181834Sroberto if test -n "$whole_archive_flag_spec"; then 8620285612Sdelphij eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 8621285612Sdelphij reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 8622181834Sroberto else 8623181834Sroberto gentop="$output_objdir/${obj}x" 8624285612Sdelphij func_append generated " $gentop" 8625181834Sroberto 8626181834Sroberto func_extract_archives $gentop $convenience 8627181834Sroberto reload_conv_objs="$reload_objs $func_extract_archives_result" 8628181834Sroberto fi 8629181834Sroberto fi 8630181834Sroberto 8631285612Sdelphij # If we're not building shared, we need to use non_pic_objs 8632285612Sdelphij test "$build_libtool_libs" != yes && libobjs="$non_pic_objects" 8633285612Sdelphij 8634181834Sroberto # Create the old-style object. 8635285612Sdelphij reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test 8636181834Sroberto 8637181834Sroberto output="$obj" 8638285612Sdelphij func_execute_cmds "$reload_cmds" 'exit $?' 8639181834Sroberto 8640181834Sroberto # Exit if we aren't doing a library object file. 8641181834Sroberto if test -z "$libobj"; then 8642181834Sroberto if test -n "$gentop"; then 8643285612Sdelphij func_show_eval '${RM}r "$gentop"' 8644181834Sroberto fi 8645181834Sroberto 8646181834Sroberto exit $EXIT_SUCCESS 8647181834Sroberto fi 8648181834Sroberto 8649181834Sroberto if test "$build_libtool_libs" != yes; then 8650181834Sroberto if test -n "$gentop"; then 8651285612Sdelphij func_show_eval '${RM}r "$gentop"' 8652181834Sroberto fi 8653181834Sroberto 8654181834Sroberto # Create an invalid libtool object if no PIC, so that we don't 8655181834Sroberto # accidentally link it into a program. 8656181834Sroberto # $show "echo timestamp > $libobj" 8657285612Sdelphij # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 8658181834Sroberto exit $EXIT_SUCCESS 8659181834Sroberto fi 8660181834Sroberto 8661181834Sroberto if test -n "$pic_flag" || test "$pic_mode" != default; then 8662181834Sroberto # Only do commands if we really have different PIC objects. 8663181834Sroberto reload_objs="$libobjs $reload_conv_objs" 8664181834Sroberto output="$libobj" 8665285612Sdelphij func_execute_cmds "$reload_cmds" 'exit $?' 8666181834Sroberto fi 8667181834Sroberto 8668181834Sroberto if test -n "$gentop"; then 8669285612Sdelphij func_show_eval '${RM}r "$gentop"' 8670181834Sroberto fi 8671181834Sroberto 8672181834Sroberto exit $EXIT_SUCCESS 8673181834Sroberto ;; 8674181834Sroberto 8675181834Sroberto prog) 8676181834Sroberto case $host in 8677285612Sdelphij *cygwin*) func_stripname '' '.exe' "$output" 8678285612Sdelphij output=$func_stripname_result.exe;; 8679181834Sroberto esac 8680285612Sdelphij test -n "$vinfo" && \ 8681285612Sdelphij func_warning "\`-version-info' is ignored for programs" 8682181834Sroberto 8683285612Sdelphij test -n "$release" && \ 8684285612Sdelphij func_warning "\`-release' is ignored for programs" 8685181834Sroberto 8686285612Sdelphij test "$preload" = yes \ 8687285612Sdelphij && test "$dlopen_support" = unknown \ 8688285612Sdelphij && test "$dlopen_self" = unknown \ 8689285612Sdelphij && test "$dlopen_self_static" = unknown && \ 8690285612Sdelphij func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support." 8691181834Sroberto 8692181834Sroberto case $host in 8693181834Sroberto *-*-rhapsody* | *-*-darwin1.[012]) 8694181834Sroberto # On Rhapsody replace the C library is the System framework 8695285612Sdelphij compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 8696285612Sdelphij finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 8697181834Sroberto ;; 8698181834Sroberto esac 8699181834Sroberto 8700181834Sroberto case $host in 8701285612Sdelphij *-*-darwin*) 8702285612Sdelphij # Don't allow lazy linking, it breaks C++ global constructors 8703285612Sdelphij # But is supposedly fixed on 10.4 or later (yay!). 8704285612Sdelphij if test "$tagname" = CXX ; then 8705285612Sdelphij case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 8706285612Sdelphij 10.[0123]) 8707285612Sdelphij func_append compile_command " ${wl}-bind_at_load" 8708285612Sdelphij func_append finalize_command " ${wl}-bind_at_load" 8709285612Sdelphij ;; 8710285612Sdelphij esac 8711285612Sdelphij fi 8712285612Sdelphij # Time to change all our "foo.ltframework" stuff back to "-framework foo" 8713285612Sdelphij compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8714285612Sdelphij finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8715285612Sdelphij ;; 8716181834Sroberto esac 8717181834Sroberto 8718181834Sroberto 8719181834Sroberto # move library search paths that coincide with paths to not yet 8720181834Sroberto # installed libraries to the beginning of the library search list 8721181834Sroberto new_libs= 8722181834Sroberto for path in $notinst_path; do 8723181834Sroberto case " $new_libs " in 8724181834Sroberto *" -L$path/$objdir "*) ;; 8725181834Sroberto *) 8726181834Sroberto case " $compile_deplibs " in 8727181834Sroberto *" -L$path/$objdir "*) 8728285612Sdelphij func_append new_libs " -L$path/$objdir" ;; 8729181834Sroberto esac 8730181834Sroberto ;; 8731181834Sroberto esac 8732181834Sroberto done 8733181834Sroberto for deplib in $compile_deplibs; do 8734181834Sroberto case $deplib in 8735181834Sroberto -L*) 8736181834Sroberto case " $new_libs " in 8737181834Sroberto *" $deplib "*) ;; 8738285612Sdelphij *) func_append new_libs " $deplib" ;; 8739181834Sroberto esac 8740181834Sroberto ;; 8741285612Sdelphij *) func_append new_libs " $deplib" ;; 8742181834Sroberto esac 8743181834Sroberto done 8744181834Sroberto compile_deplibs="$new_libs" 8745181834Sroberto 8746181834Sroberto 8747285612Sdelphij func_append compile_command " $compile_deplibs" 8748285612Sdelphij func_append finalize_command " $finalize_deplibs" 8749181834Sroberto 8750181834Sroberto if test -n "$rpath$xrpath"; then 8751181834Sroberto # If the user specified any rpath flags, then add them. 8752181834Sroberto for libdir in $rpath $xrpath; do 8753181834Sroberto # This is the magic to use -rpath. 8754181834Sroberto case "$finalize_rpath " in 8755181834Sroberto *" $libdir "*) ;; 8756285612Sdelphij *) func_append finalize_rpath " $libdir" ;; 8757181834Sroberto esac 8758181834Sroberto done 8759181834Sroberto fi 8760181834Sroberto 8761181834Sroberto # Now hardcode the library paths 8762181834Sroberto rpath= 8763181834Sroberto hardcode_libdirs= 8764181834Sroberto for libdir in $compile_rpath $finalize_rpath; do 8765181834Sroberto if test -n "$hardcode_libdir_flag_spec"; then 8766181834Sroberto if test -n "$hardcode_libdir_separator"; then 8767181834Sroberto if test -z "$hardcode_libdirs"; then 8768181834Sroberto hardcode_libdirs="$libdir" 8769181834Sroberto else 8770181834Sroberto # Just accumulate the unique libdirs. 8771181834Sroberto case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8772181834Sroberto *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8773181834Sroberto ;; 8774181834Sroberto *) 8775285612Sdelphij func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8776181834Sroberto ;; 8777181834Sroberto esac 8778181834Sroberto fi 8779181834Sroberto else 8780181834Sroberto eval flag=\"$hardcode_libdir_flag_spec\" 8781285612Sdelphij func_append rpath " $flag" 8782181834Sroberto fi 8783181834Sroberto elif test -n "$runpath_var"; then 8784181834Sroberto case "$perm_rpath " in 8785181834Sroberto *" $libdir "*) ;; 8786285612Sdelphij *) func_append perm_rpath " $libdir" ;; 8787181834Sroberto esac 8788181834Sroberto fi 8789181834Sroberto case $host in 8790285612Sdelphij *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 8791285612Sdelphij testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'` 8792181834Sroberto case :$dllsearchpath: in 8793181834Sroberto *":$libdir:"*) ;; 8794285612Sdelphij ::) dllsearchpath=$libdir;; 8795285612Sdelphij *) func_append dllsearchpath ":$libdir";; 8796181834Sroberto esac 8797181834Sroberto case :$dllsearchpath: in 8798181834Sroberto *":$testbindir:"*) ;; 8799285612Sdelphij ::) dllsearchpath=$testbindir;; 8800285612Sdelphij *) func_append dllsearchpath ":$testbindir";; 8801181834Sroberto esac 8802181834Sroberto ;; 8803181834Sroberto esac 8804181834Sroberto done 8805181834Sroberto # Substitute the hardcoded libdirs into the rpath. 8806181834Sroberto if test -n "$hardcode_libdir_separator" && 8807181834Sroberto test -n "$hardcode_libdirs"; then 8808181834Sroberto libdir="$hardcode_libdirs" 8809181834Sroberto eval rpath=\" $hardcode_libdir_flag_spec\" 8810181834Sroberto fi 8811181834Sroberto compile_rpath="$rpath" 8812181834Sroberto 8813181834Sroberto rpath= 8814181834Sroberto hardcode_libdirs= 8815181834Sroberto for libdir in $finalize_rpath; do 8816181834Sroberto if test -n "$hardcode_libdir_flag_spec"; then 8817181834Sroberto if test -n "$hardcode_libdir_separator"; then 8818181834Sroberto if test -z "$hardcode_libdirs"; then 8819181834Sroberto hardcode_libdirs="$libdir" 8820181834Sroberto else 8821181834Sroberto # Just accumulate the unique libdirs. 8822181834Sroberto case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 8823181834Sroberto *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 8824181834Sroberto ;; 8825181834Sroberto *) 8826285612Sdelphij func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 8827181834Sroberto ;; 8828181834Sroberto esac 8829181834Sroberto fi 8830181834Sroberto else 8831181834Sroberto eval flag=\"$hardcode_libdir_flag_spec\" 8832285612Sdelphij func_append rpath " $flag" 8833181834Sroberto fi 8834181834Sroberto elif test -n "$runpath_var"; then 8835181834Sroberto case "$finalize_perm_rpath " in 8836181834Sroberto *" $libdir "*) ;; 8837285612Sdelphij *) func_append finalize_perm_rpath " $libdir" ;; 8838181834Sroberto esac 8839181834Sroberto fi 8840181834Sroberto done 8841181834Sroberto # Substitute the hardcoded libdirs into the rpath. 8842181834Sroberto if test -n "$hardcode_libdir_separator" && 8843181834Sroberto test -n "$hardcode_libdirs"; then 8844181834Sroberto libdir="$hardcode_libdirs" 8845181834Sroberto eval rpath=\" $hardcode_libdir_flag_spec\" 8846181834Sroberto fi 8847181834Sroberto finalize_rpath="$rpath" 8848181834Sroberto 8849181834Sroberto if test -n "$libobjs" && test "$build_old_libs" = yes; then 8850181834Sroberto # Transform all the library objects into standard objects. 8851285612Sdelphij compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8852285612Sdelphij finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 8853181834Sroberto fi 8854181834Sroberto 8855285612Sdelphij func_generate_dlsyms "$outputname" "@PROGRAM@" "no" 8856181834Sroberto 8857285612Sdelphij # template prelinking step 8858285612Sdelphij if test -n "$prelink_cmds"; then 8859285612Sdelphij func_execute_cmds "$prelink_cmds" 'exit $?' 8860181834Sroberto fi 8861181834Sroberto 8862285612Sdelphij wrappers_required=yes 8863285612Sdelphij case $host in 8864285612Sdelphij *cegcc* | *mingw32ce*) 8865285612Sdelphij # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 8866285612Sdelphij wrappers_required=no 8867285612Sdelphij ;; 8868285612Sdelphij *cygwin* | *mingw* ) 8869285612Sdelphij if test "$build_libtool_libs" != yes; then 8870285612Sdelphij wrappers_required=no 8871285612Sdelphij fi 8872285612Sdelphij ;; 8873285612Sdelphij *) 8874285612Sdelphij if test "$need_relink" = no || test "$build_libtool_libs" != yes; then 8875285612Sdelphij wrappers_required=no 8876285612Sdelphij fi 8877285612Sdelphij ;; 8878285612Sdelphij esac 8879285612Sdelphij if test "$wrappers_required" = no; then 8880181834Sroberto # Replace the output file specification. 8881285612Sdelphij compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8882181834Sroberto link_command="$compile_command$compile_rpath" 8883181834Sroberto 8884181834Sroberto # We have no uninstalled library dependencies, so finalize right now. 8885285612Sdelphij exit_status=0 8886285612Sdelphij func_show_eval "$link_command" 'exit_status=$?' 8887181834Sroberto 8888285612Sdelphij if test -n "$postlink_cmds"; then 8889285612Sdelphij func_to_tool_file "$output" 8890285612Sdelphij postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8891285612Sdelphij func_execute_cmds "$postlink_cmds" 'exit $?' 8892285612Sdelphij fi 8893285612Sdelphij 8894181834Sroberto # Delete the generated files. 8895285612Sdelphij if test -f "$output_objdir/${outputname}S.${objext}"; then 8896285612Sdelphij func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"' 8897181834Sroberto fi 8898181834Sroberto 8899181834Sroberto exit $exit_status 8900181834Sroberto fi 8901181834Sroberto 8902181834Sroberto if test -n "$compile_shlibpath$finalize_shlibpath"; then 8903181834Sroberto compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 8904181834Sroberto fi 8905181834Sroberto if test -n "$finalize_shlibpath"; then 8906181834Sroberto finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 8907181834Sroberto fi 8908181834Sroberto 8909181834Sroberto compile_var= 8910181834Sroberto finalize_var= 8911181834Sroberto if test -n "$runpath_var"; then 8912181834Sroberto if test -n "$perm_rpath"; then 8913181834Sroberto # We should set the runpath_var. 8914181834Sroberto rpath= 8915181834Sroberto for dir in $perm_rpath; do 8916285612Sdelphij func_append rpath "$dir:" 8917181834Sroberto done 8918181834Sroberto compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 8919181834Sroberto fi 8920181834Sroberto if test -n "$finalize_perm_rpath"; then 8921181834Sroberto # We should set the runpath_var. 8922181834Sroberto rpath= 8923181834Sroberto for dir in $finalize_perm_rpath; do 8924285612Sdelphij func_append rpath "$dir:" 8925181834Sroberto done 8926181834Sroberto finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 8927181834Sroberto fi 8928181834Sroberto fi 8929181834Sroberto 8930181834Sroberto if test "$no_install" = yes; then 8931181834Sroberto # We don't need to create a wrapper script. 8932181834Sroberto link_command="$compile_var$compile_command$compile_rpath" 8933181834Sroberto # Replace the output file specification. 8934285612Sdelphij link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 8935181834Sroberto # Delete the old output file. 8936285612Sdelphij $opt_dry_run || $RM $output 8937181834Sroberto # Link the executable and exit 8938285612Sdelphij func_show_eval "$link_command" 'exit $?' 8939285612Sdelphij 8940285612Sdelphij if test -n "$postlink_cmds"; then 8941285612Sdelphij func_to_tool_file "$output" 8942285612Sdelphij postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 8943285612Sdelphij func_execute_cmds "$postlink_cmds" 'exit $?' 8944285612Sdelphij fi 8945285612Sdelphij 8946181834Sroberto exit $EXIT_SUCCESS 8947181834Sroberto fi 8948181834Sroberto 8949181834Sroberto if test "$hardcode_action" = relink; then 8950181834Sroberto # Fast installation is not supported 8951181834Sroberto link_command="$compile_var$compile_command$compile_rpath" 8952181834Sroberto relink_command="$finalize_var$finalize_command$finalize_rpath" 8953181834Sroberto 8954285612Sdelphij func_warning "this platform does not like uninstalled shared libraries" 8955285612Sdelphij func_warning "\`$output' will be relinked during installation" 8956181834Sroberto else 8957181834Sroberto if test "$fast_install" != no; then 8958181834Sroberto link_command="$finalize_var$compile_command$finalize_rpath" 8959181834Sroberto if test "$fast_install" = yes; then 8960285612Sdelphij relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 8961181834Sroberto else 8962181834Sroberto # fast_install is set to needless 8963181834Sroberto relink_command= 8964181834Sroberto fi 8965181834Sroberto else 8966181834Sroberto link_command="$compile_var$compile_command$compile_rpath" 8967181834Sroberto relink_command="$finalize_var$finalize_command$finalize_rpath" 8968181834Sroberto fi 8969181834Sroberto fi 8970181834Sroberto 8971181834Sroberto # Replace the output file specification. 8972285612Sdelphij link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 8973181834Sroberto 8974181834Sroberto # Delete the old output files. 8975285612Sdelphij $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 8976181834Sroberto 8977285612Sdelphij func_show_eval "$link_command" 'exit $?' 8978181834Sroberto 8979285612Sdelphij if test -n "$postlink_cmds"; then 8980285612Sdelphij func_to_tool_file "$output_objdir/$outputname" 8981285612Sdelphij 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'` 8982285612Sdelphij func_execute_cmds "$postlink_cmds" 'exit $?' 8983285612Sdelphij fi 8984285612Sdelphij 8985181834Sroberto # Now create the wrapper script. 8986285612Sdelphij func_verbose "creating $output" 8987181834Sroberto 8988181834Sroberto # Quote the relink command for shipping. 8989181834Sroberto if test -n "$relink_command"; then 8990181834Sroberto # Preserve any variables that may affect compiler behavior 8991181834Sroberto for var in $variables_saved_for_relink; do 8992181834Sroberto if eval test -z \"\${$var+set}\"; then 8993285612Sdelphij relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 8994181834Sroberto elif eval var_value=\$$var; test -z "$var_value"; then 8995181834Sroberto relink_command="$var=; export $var; $relink_command" 8996181834Sroberto else 8997285612Sdelphij func_quote_for_eval "$var_value" 8998285612Sdelphij relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 8999181834Sroberto fi 9000181834Sroberto done 9001181834Sroberto relink_command="(cd `pwd`; $relink_command)" 9002285612Sdelphij relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9003181834Sroberto fi 9004181834Sroberto 9005285612Sdelphij # Only actually do things if not in dry run mode. 9006285612Sdelphij $opt_dry_run || { 9007181834Sroberto # win32 will think the script is a binary if it has 9008181834Sroberto # a .exe suffix, so we strip it off here. 9009181834Sroberto case $output in 9010285612Sdelphij *.exe) func_stripname '' '.exe' "$output" 9011285612Sdelphij output=$func_stripname_result ;; 9012181834Sroberto esac 9013181834Sroberto # test for cygwin because mv fails w/o .exe extensions 9014181834Sroberto case $host in 9015181834Sroberto *cygwin*) 9016181834Sroberto exeext=.exe 9017285612Sdelphij func_stripname '' '.exe' "$outputname" 9018285612Sdelphij outputname=$func_stripname_result ;; 9019181834Sroberto *) exeext= ;; 9020181834Sroberto esac 9021181834Sroberto case $host in 9022181834Sroberto *cygwin* | *mingw* ) 9023285612Sdelphij func_dirname_and_basename "$output" "" "." 9024285612Sdelphij output_name=$func_basename_result 9025285612Sdelphij output_path=$func_dirname_result 9026285612Sdelphij cwrappersource="$output_path/$objdir/lt-$output_name.c" 9027285612Sdelphij cwrapper="$output_path/$output_name.exe" 9028285612Sdelphij $RM $cwrappersource $cwrapper 9029285612Sdelphij trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 9030181834Sroberto 9031285612Sdelphij func_emit_cwrapperexe_src > $cwrappersource 9032181834Sroberto 9033285612Sdelphij # The wrapper executable is built using the $host compiler, 9034285612Sdelphij # because it contains $host paths and files. If cross- 9035285612Sdelphij # compiling, it, like the target executable, must be 9036285612Sdelphij # executed on the $host or under an emulation environment. 9037285612Sdelphij $opt_dry_run || { 9038285612Sdelphij $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 9039285612Sdelphij $STRIP $cwrapper 9040285612Sdelphij } 9041181834Sroberto 9042285612Sdelphij # Now, create the wrapper script for func_source use: 9043285612Sdelphij func_ltwrapper_scriptname $cwrapper 9044285612Sdelphij $RM $func_ltwrapper_scriptname_result 9045285612Sdelphij trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 9046285612Sdelphij $opt_dry_run || { 9047285612Sdelphij # note: this script will not be executed, so do not chmod. 9048285612Sdelphij if test "x$build" = "x$host" ; then 9049285612Sdelphij $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 9050285612Sdelphij else 9051285612Sdelphij func_emit_wrapper no > $func_ltwrapper_scriptname_result 9052285612Sdelphij fi 9053285612Sdelphij } 9054181834Sroberto ;; 9055285612Sdelphij * ) 9056285612Sdelphij $RM $output 9057285612Sdelphij trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 9058181834Sroberto 9059285612Sdelphij func_emit_wrapper no > $output 9060285612Sdelphij chmod +x $output 9061181834Sroberto ;; 9062181834Sroberto esac 9063285612Sdelphij } 9064181834Sroberto exit $EXIT_SUCCESS 9065181834Sroberto ;; 9066181834Sroberto esac 9067181834Sroberto 9068181834Sroberto # See if we need to build an old-fashioned archive. 9069181834Sroberto for oldlib in $oldlibs; do 9070181834Sroberto 9071181834Sroberto if test "$build_libtool_libs" = convenience; then 9072285612Sdelphij oldobjs="$libobjs_save $symfileobj" 9073181834Sroberto addlibs="$convenience" 9074181834Sroberto build_libtool_libs=no 9075181834Sroberto else 9076181834Sroberto if test "$build_libtool_libs" = module; then 9077181834Sroberto oldobjs="$libobjs_save" 9078181834Sroberto build_libtool_libs=no 9079181834Sroberto else 9080181834Sroberto oldobjs="$old_deplibs $non_pic_objects" 9081285612Sdelphij if test "$preload" = yes && test -f "$symfileobj"; then 9082285612Sdelphij func_append oldobjs " $symfileobj" 9083285612Sdelphij fi 9084181834Sroberto fi 9085181834Sroberto addlibs="$old_convenience" 9086181834Sroberto fi 9087181834Sroberto 9088181834Sroberto if test -n "$addlibs"; then 9089181834Sroberto gentop="$output_objdir/${outputname}x" 9090285612Sdelphij func_append generated " $gentop" 9091181834Sroberto 9092181834Sroberto func_extract_archives $gentop $addlibs 9093285612Sdelphij func_append oldobjs " $func_extract_archives_result" 9094181834Sroberto fi 9095181834Sroberto 9096181834Sroberto # Do each command in the archive commands. 9097181834Sroberto if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then 9098285612Sdelphij cmds=$old_archive_from_new_cmds 9099181834Sroberto else 9100285612Sdelphij 9101285612Sdelphij # Add any objects from preloaded convenience libraries 9102285612Sdelphij if test -n "$dlprefiles"; then 9103285612Sdelphij gentop="$output_objdir/${outputname}x" 9104285612Sdelphij func_append generated " $gentop" 9105285612Sdelphij 9106285612Sdelphij func_extract_archives $gentop $dlprefiles 9107285612Sdelphij func_append oldobjs " $func_extract_archives_result" 9108285612Sdelphij fi 9109285612Sdelphij 9110181834Sroberto # POSIX demands no paths to be encoded in archives. We have 9111181834Sroberto # to avoid creating archives with duplicate basenames if we 9112181834Sroberto # might have to extract them afterwards, e.g., when creating a 9113181834Sroberto # static archive out of a convenience library, or when linking 9114181834Sroberto # the entirety of a libtool archive into another (currently 9115181834Sroberto # not supported by libtool). 9116181834Sroberto if (for obj in $oldobjs 9117181834Sroberto do 9118285612Sdelphij func_basename "$obj" 9119285612Sdelphij $ECHO "$func_basename_result" 9120181834Sroberto done | sort | sort -uc >/dev/null 2>&1); then 9121181834Sroberto : 9122181834Sroberto else 9123285612Sdelphij echo "copying selected object files to avoid basename conflicts..." 9124285612Sdelphij gentop="$output_objdir/${outputname}x" 9125285612Sdelphij func_append generated " $gentop" 9126285612Sdelphij func_mkdir_p "$gentop" 9127181834Sroberto save_oldobjs=$oldobjs 9128181834Sroberto oldobjs= 9129181834Sroberto counter=1 9130181834Sroberto for obj in $save_oldobjs 9131181834Sroberto do 9132285612Sdelphij func_basename "$obj" 9133285612Sdelphij objbase="$func_basename_result" 9134181834Sroberto case " $oldobjs " in 9135181834Sroberto " ") oldobjs=$obj ;; 9136181834Sroberto *[\ /]"$objbase "*) 9137181834Sroberto while :; do 9138181834Sroberto # Make sure we don't pick an alternate name that also 9139181834Sroberto # overlaps. 9140181834Sroberto newobj=lt$counter-$objbase 9141285612Sdelphij func_arith $counter + 1 9142285612Sdelphij counter=$func_arith_result 9143181834Sroberto case " $oldobjs " in 9144181834Sroberto *[\ /]"$newobj "*) ;; 9145181834Sroberto *) if test ! -f "$gentop/$newobj"; then break; fi ;; 9146181834Sroberto esac 9147181834Sroberto done 9148285612Sdelphij func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 9149285612Sdelphij func_append oldobjs " $gentop/$newobj" 9150181834Sroberto ;; 9151285612Sdelphij *) func_append oldobjs " $obj" ;; 9152181834Sroberto esac 9153181834Sroberto done 9154181834Sroberto fi 9155181834Sroberto eval cmds=\"$old_archive_cmds\" 9156181834Sroberto 9157285612Sdelphij func_len " $cmds" 9158285612Sdelphij len=$func_len_result 9159285612Sdelphij if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 9160181834Sroberto cmds=$old_archive_cmds 9161285612Sdelphij elif test -n "$archiver_list_spec"; then 9162285612Sdelphij func_verbose "using command file archive linking..." 9163285612Sdelphij for obj in $oldobjs 9164285612Sdelphij do 9165285612Sdelphij func_to_tool_file "$obj" 9166285612Sdelphij $ECHO "$func_to_tool_file_result" 9167285612Sdelphij done > $output_objdir/$libname.libcmd 9168285612Sdelphij func_to_tool_file "$output_objdir/$libname.libcmd" 9169285612Sdelphij oldobjs=" $archiver_list_spec$func_to_tool_file_result" 9170285612Sdelphij cmds=$old_archive_cmds 9171181834Sroberto else 9172181834Sroberto # the command line is too long to link in one step, link in parts 9173285612Sdelphij func_verbose "using piecewise archive linking..." 9174181834Sroberto save_RANLIB=$RANLIB 9175181834Sroberto RANLIB=: 9176181834Sroberto objlist= 9177181834Sroberto concat_cmds= 9178181834Sroberto save_oldobjs=$oldobjs 9179285612Sdelphij oldobjs= 9180181834Sroberto # Is there a better way of finding the last object in the list? 9181181834Sroberto for obj in $save_oldobjs 9182181834Sroberto do 9183181834Sroberto last_oldobj=$obj 9184181834Sroberto done 9185285612Sdelphij eval test_cmds=\"$old_archive_cmds\" 9186285612Sdelphij func_len " $test_cmds" 9187285612Sdelphij len0=$func_len_result 9188285612Sdelphij len=$len0 9189181834Sroberto for obj in $save_oldobjs 9190181834Sroberto do 9191285612Sdelphij func_len " $obj" 9192285612Sdelphij func_arith $len + $func_len_result 9193285612Sdelphij len=$func_arith_result 9194285612Sdelphij func_append objlist " $obj" 9195285612Sdelphij if test "$len" -lt "$max_cmd_len"; then 9196181834Sroberto : 9197181834Sroberto else 9198181834Sroberto # the above command should be used before it gets too long 9199181834Sroberto oldobjs=$objlist 9200181834Sroberto if test "$obj" = "$last_oldobj" ; then 9201285612Sdelphij RANLIB=$save_RANLIB 9202181834Sroberto fi 9203181834Sroberto test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 9204181834Sroberto eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\" 9205181834Sroberto objlist= 9206285612Sdelphij len=$len0 9207181834Sroberto fi 9208181834Sroberto done 9209181834Sroberto RANLIB=$save_RANLIB 9210181834Sroberto oldobjs=$objlist 9211181834Sroberto if test "X$oldobjs" = "X" ; then 9212181834Sroberto eval cmds=\"\$concat_cmds\" 9213181834Sroberto else 9214181834Sroberto eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 9215181834Sroberto fi 9216181834Sroberto fi 9217181834Sroberto fi 9218285612Sdelphij func_execute_cmds "$cmds" 'exit $?' 9219181834Sroberto done 9220181834Sroberto 9221285612Sdelphij test -n "$generated" && \ 9222285612Sdelphij func_show_eval "${RM}r$generated" 9223181834Sroberto 9224181834Sroberto # Now create the libtool archive. 9225181834Sroberto case $output in 9226181834Sroberto *.la) 9227181834Sroberto old_library= 9228181834Sroberto test "$build_old_libs" = yes && old_library="$libname.$libext" 9229285612Sdelphij func_verbose "creating $output" 9230181834Sroberto 9231181834Sroberto # Preserve any variables that may affect compiler behavior 9232181834Sroberto for var in $variables_saved_for_relink; do 9233181834Sroberto if eval test -z \"\${$var+set}\"; then 9234285612Sdelphij relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 9235181834Sroberto elif eval var_value=\$$var; test -z "$var_value"; then 9236181834Sroberto relink_command="$var=; export $var; $relink_command" 9237181834Sroberto else 9238285612Sdelphij func_quote_for_eval "$var_value" 9239285612Sdelphij relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command" 9240181834Sroberto fi 9241181834Sroberto done 9242181834Sroberto # Quote the link command for shipping. 9243181834Sroberto relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 9244285612Sdelphij relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"` 9245181834Sroberto if test "$hardcode_automatic" = yes ; then 9246181834Sroberto relink_command= 9247181834Sroberto fi 9248181834Sroberto 9249181834Sroberto # Only create the output if not a dry run. 9250285612Sdelphij $opt_dry_run || { 9251181834Sroberto for installed in no yes; do 9252181834Sroberto if test "$installed" = yes; then 9253181834Sroberto if test -z "$install_libdir"; then 9254181834Sroberto break 9255181834Sroberto fi 9256181834Sroberto output="$output_objdir/$outputname"i 9257181834Sroberto # Replace all uninstalled libtool libraries with the installed ones 9258181834Sroberto newdependency_libs= 9259181834Sroberto for deplib in $dependency_libs; do 9260181834Sroberto case $deplib in 9261181834Sroberto *.la) 9262285612Sdelphij func_basename "$deplib" 9263285612Sdelphij name="$func_basename_result" 9264181834Sroberto eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 9265285612Sdelphij test -z "$libdir" && \ 9266285612Sdelphij func_fatal_error "\`$deplib' is not a valid libtool archive" 9267285612Sdelphij func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 9268181834Sroberto ;; 9269285612Sdelphij -L*) 9270285612Sdelphij func_stripname -L '' "$deplib" 9271285612Sdelphij func_replace_sysroot "$func_stripname_result" 9272285612Sdelphij func_append newdependency_libs " -L$func_replace_sysroot_result" 9273285612Sdelphij ;; 9274285612Sdelphij -R*) 9275285612Sdelphij func_stripname -R '' "$deplib" 9276285612Sdelphij func_replace_sysroot "$func_stripname_result" 9277285612Sdelphij func_append newdependency_libs " -R$func_replace_sysroot_result" 9278285612Sdelphij ;; 9279285612Sdelphij *) func_append newdependency_libs " $deplib" ;; 9280181834Sroberto esac 9281181834Sroberto done 9282181834Sroberto dependency_libs="$newdependency_libs" 9283181834Sroberto newdlfiles= 9284285612Sdelphij 9285181834Sroberto for lib in $dlfiles; do 9286285612Sdelphij case $lib in 9287285612Sdelphij *.la) 9288285612Sdelphij func_basename "$lib" 9289285612Sdelphij name="$func_basename_result" 9290285612Sdelphij eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9291285612Sdelphij test -z "$libdir" && \ 9292285612Sdelphij func_fatal_error "\`$lib' is not a valid libtool archive" 9293285612Sdelphij func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 9294285612Sdelphij ;; 9295285612Sdelphij *) func_append newdlfiles " $lib" ;; 9296285612Sdelphij esac 9297181834Sroberto done 9298181834Sroberto dlfiles="$newdlfiles" 9299181834Sroberto newdlprefiles= 9300181834Sroberto for lib in $dlprefiles; do 9301285612Sdelphij case $lib in 9302285612Sdelphij *.la) 9303285612Sdelphij # Only pass preopened files to the pseudo-archive (for 9304285612Sdelphij # eventual linking with the app. that links it) if we 9305285612Sdelphij # didn't already link the preopened objects directly into 9306285612Sdelphij # the library: 9307285612Sdelphij func_basename "$lib" 9308285612Sdelphij name="$func_basename_result" 9309285612Sdelphij eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 9310285612Sdelphij test -z "$libdir" && \ 9311285612Sdelphij func_fatal_error "\`$lib' is not a valid libtool archive" 9312285612Sdelphij func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 9313285612Sdelphij ;; 9314285612Sdelphij esac 9315181834Sroberto done 9316181834Sroberto dlprefiles="$newdlprefiles" 9317181834Sroberto else 9318181834Sroberto newdlfiles= 9319181834Sroberto for lib in $dlfiles; do 9320181834Sroberto case $lib in 9321181834Sroberto [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9322181834Sroberto *) abs=`pwd`"/$lib" ;; 9323181834Sroberto esac 9324285612Sdelphij func_append newdlfiles " $abs" 9325181834Sroberto done 9326181834Sroberto dlfiles="$newdlfiles" 9327181834Sroberto newdlprefiles= 9328181834Sroberto for lib in $dlprefiles; do 9329181834Sroberto case $lib in 9330181834Sroberto [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;; 9331181834Sroberto *) abs=`pwd`"/$lib" ;; 9332181834Sroberto esac 9333285612Sdelphij func_append newdlprefiles " $abs" 9334181834Sroberto done 9335181834Sroberto dlprefiles="$newdlprefiles" 9336181834Sroberto fi 9337285612Sdelphij $RM $output 9338181834Sroberto # place dlname in correct position for cygwin 9339285612Sdelphij # In fact, it would be nice if we could use this code for all target 9340285612Sdelphij # systems that can't hard-code library paths into their executables 9341285612Sdelphij # and that have no shared library path variable independent of PATH, 9342285612Sdelphij # but it turns out we can't easily determine that from inspecting 9343285612Sdelphij # libtool variables, so we have to hard-code the OSs to which it 9344285612Sdelphij # applies here; at the moment, that means platforms that use the PE 9345285612Sdelphij # object format with DLL files. See the long comment at the top of 9346285612Sdelphij # tests/bindir.at for full details. 9347181834Sroberto tdlname=$dlname 9348181834Sroberto case $host,$output,$installed,$module,$dlname in 9349285612Sdelphij *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 9350285612Sdelphij # If a -bindir argument was supplied, place the dll there. 9351285612Sdelphij if test "x$bindir" != x ; 9352285612Sdelphij then 9353285612Sdelphij func_relative_path "$install_libdir" "$bindir" 9354285612Sdelphij tdlname=$func_relative_path_result$dlname 9355285612Sdelphij else 9356285612Sdelphij # Otherwise fall back on heuristic. 9357285612Sdelphij tdlname=../bin/$dlname 9358285612Sdelphij fi 9359285612Sdelphij ;; 9360181834Sroberto esac 9361285612Sdelphij $ECHO > $output "\ 9362181834Sroberto# $outputname - a libtool library file 9363285612Sdelphij# Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION 9364181834Sroberto# 9365181834Sroberto# Please DO NOT delete this file! 9366181834Sroberto# It is necessary for linking the library. 9367181834Sroberto 9368181834Sroberto# The name that we can dlopen(3). 9369181834Srobertodlname='$tdlname' 9370181834Sroberto 9371181834Sroberto# Names of this library. 9372181834Srobertolibrary_names='$library_names' 9373181834Sroberto 9374181834Sroberto# The name of the static archive. 9375181834Srobertoold_library='$old_library' 9376181834Sroberto 9377285612Sdelphij# Linker flags that can not go in dependency_libs. 9378285612Sdelphijinherited_linker_flags='$new_inherited_linker_flags' 9379285612Sdelphij 9380181834Sroberto# Libraries that this one depends upon. 9381181834Srobertodependency_libs='$dependency_libs' 9382181834Sroberto 9383285612Sdelphij# Names of additional weak libraries provided by this library 9384285612Sdelphijweak_library_names='$weak_libs' 9385285612Sdelphij 9386181834Sroberto# Version information for $libname. 9387181834Srobertocurrent=$current 9388181834Srobertoage=$age 9389181834Srobertorevision=$revision 9390181834Sroberto 9391181834Sroberto# Is this an already installed library? 9392181834Srobertoinstalled=$installed 9393181834Sroberto 9394181834Sroberto# Should we warn about portability when linking against -modules? 9395181834Srobertoshouldnotlink=$module 9396181834Sroberto 9397181834Sroberto# Files to dlopen/dlpreopen 9398181834Srobertodlopen='$dlfiles' 9399181834Srobertodlpreopen='$dlprefiles' 9400181834Sroberto 9401181834Sroberto# Directory that this library needs to be installed in: 9402181834Srobertolibdir='$install_libdir'" 9403181834Sroberto if test "$installed" = no && test "$need_relink" = yes; then 9404285612Sdelphij $ECHO >> $output "\ 9405181834Srobertorelink_command=\"$relink_command\"" 9406181834Sroberto fi 9407181834Sroberto done 9408285612Sdelphij } 9409181834Sroberto 9410181834Sroberto # Do a symbolic link so that the libtool archive can be found in 9411181834Sroberto # LD_LIBRARY_PATH before the program is installed. 9412285612Sdelphij func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 9413181834Sroberto ;; 9414181834Sroberto esac 9415181834Sroberto exit $EXIT_SUCCESS 9416285612Sdelphij} 9417181834Sroberto 9418285612Sdelphij{ test "$opt_mode" = link || test "$opt_mode" = relink; } && 9419285612Sdelphij func_mode_link ${1+"$@"} 9420181834Sroberto 9421181834Sroberto 9422285612Sdelphij# func_mode_uninstall arg... 9423285612Sdelphijfunc_mode_uninstall () 9424285612Sdelphij{ 9425285612Sdelphij $opt_debug 9426285612Sdelphij RM="$nonopt" 9427181834Sroberto files= 9428181834Sroberto rmforce= 9429181834Sroberto exit_status=0 9430181834Sroberto 9431181834Sroberto # This variable tells wrapper scripts just to set variables rather 9432181834Sroberto # than running their programs. 9433181834Sroberto libtool_install_magic="$magic" 9434181834Sroberto 9435181834Sroberto for arg 9436181834Sroberto do 9437181834Sroberto case $arg in 9438285612Sdelphij -f) func_append RM " $arg"; rmforce=yes ;; 9439285612Sdelphij -*) func_append RM " $arg" ;; 9440285612Sdelphij *) func_append files " $arg" ;; 9441181834Sroberto esac 9442181834Sroberto done 9443181834Sroberto 9444285612Sdelphij test -z "$RM" && \ 9445285612Sdelphij func_fatal_help "you must specify an RM program" 9446181834Sroberto 9447181834Sroberto rmdirs= 9448181834Sroberto 9449181834Sroberto for file in $files; do 9450285612Sdelphij func_dirname "$file" "" "." 9451285612Sdelphij dir="$func_dirname_result" 9452285612Sdelphij if test "X$dir" = X.; then 9453285612Sdelphij odir="$objdir" 9454181834Sroberto else 9455285612Sdelphij odir="$dir/$objdir" 9456181834Sroberto fi 9457285612Sdelphij func_basename "$file" 9458285612Sdelphij name="$func_basename_result" 9459285612Sdelphij test "$opt_mode" = uninstall && odir="$dir" 9460181834Sroberto 9461285612Sdelphij # Remember odir for removal later, being careful to avoid duplicates 9462285612Sdelphij if test "$opt_mode" = clean; then 9463181834Sroberto case " $rmdirs " in 9464285612Sdelphij *" $odir "*) ;; 9465285612Sdelphij *) func_append rmdirs " $odir" ;; 9466181834Sroberto esac 9467181834Sroberto fi 9468181834Sroberto 9469181834Sroberto # Don't error if the file doesn't exist and rm -f was used. 9470285612Sdelphij if { test -L "$file"; } >/dev/null 2>&1 || 9471285612Sdelphij { test -h "$file"; } >/dev/null 2>&1 || 9472285612Sdelphij test -f "$file"; then 9473181834Sroberto : 9474181834Sroberto elif test -d "$file"; then 9475181834Sroberto exit_status=1 9476181834Sroberto continue 9477181834Sroberto elif test "$rmforce" = yes; then 9478181834Sroberto continue 9479181834Sroberto fi 9480181834Sroberto 9481181834Sroberto rmfiles="$file" 9482181834Sroberto 9483181834Sroberto case $name in 9484181834Sroberto *.la) 9485181834Sroberto # Possibly a libtool archive, so verify it. 9486285612Sdelphij if func_lalib_p "$file"; then 9487285612Sdelphij func_source $dir/$name 9488181834Sroberto 9489181834Sroberto # Delete the libtool libraries and symlinks. 9490181834Sroberto for n in $library_names; do 9491285612Sdelphij func_append rmfiles " $odir/$n" 9492181834Sroberto done 9493285612Sdelphij test -n "$old_library" && func_append rmfiles " $odir/$old_library" 9494181834Sroberto 9495285612Sdelphij case "$opt_mode" in 9496181834Sroberto clean) 9497285612Sdelphij case " $library_names " in 9498181834Sroberto *" $dlname "*) ;; 9499285612Sdelphij *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 9500181834Sroberto esac 9501285612Sdelphij test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 9502181834Sroberto ;; 9503181834Sroberto uninstall) 9504181834Sroberto if test -n "$library_names"; then 9505181834Sroberto # Do each command in the postuninstall commands. 9506285612Sdelphij func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9507181834Sroberto fi 9508181834Sroberto 9509181834Sroberto if test -n "$old_library"; then 9510181834Sroberto # Do each command in the old_postuninstall commands. 9511285612Sdelphij func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1' 9512181834Sroberto fi 9513181834Sroberto # FIXME: should reinstall the best remaining shared library. 9514181834Sroberto ;; 9515181834Sroberto esac 9516181834Sroberto fi 9517181834Sroberto ;; 9518181834Sroberto 9519181834Sroberto *.lo) 9520181834Sroberto # Possibly a libtool object, so verify it. 9521285612Sdelphij if func_lalib_p "$file"; then 9522181834Sroberto 9523181834Sroberto # Read the .lo file 9524285612Sdelphij func_source $dir/$name 9525181834Sroberto 9526181834Sroberto # Add PIC object to the list of files to remove. 9527285612Sdelphij if test -n "$pic_object" && 9528285612Sdelphij test "$pic_object" != none; then 9529285612Sdelphij func_append rmfiles " $dir/$pic_object" 9530181834Sroberto fi 9531181834Sroberto 9532181834Sroberto # Add non-PIC object to the list of files to remove. 9533285612Sdelphij if test -n "$non_pic_object" && 9534285612Sdelphij test "$non_pic_object" != none; then 9535285612Sdelphij func_append rmfiles " $dir/$non_pic_object" 9536181834Sroberto fi 9537181834Sroberto fi 9538181834Sroberto ;; 9539181834Sroberto 9540181834Sroberto *) 9541285612Sdelphij if test "$opt_mode" = clean ; then 9542181834Sroberto noexename=$name 9543181834Sroberto case $file in 9544181834Sroberto *.exe) 9545285612Sdelphij func_stripname '' '.exe' "$file" 9546285612Sdelphij file=$func_stripname_result 9547285612Sdelphij func_stripname '' '.exe' "$name" 9548285612Sdelphij noexename=$func_stripname_result 9549181834Sroberto # $file with .exe has already been added to rmfiles, 9550181834Sroberto # add $file without .exe 9551285612Sdelphij func_append rmfiles " $file" 9552181834Sroberto ;; 9553181834Sroberto esac 9554181834Sroberto # Do a test to see if this is a libtool program. 9555285612Sdelphij if func_ltwrapper_p "$file"; then 9556285612Sdelphij if func_ltwrapper_executable_p "$file"; then 9557285612Sdelphij func_ltwrapper_scriptname "$file" 9558285612Sdelphij relink_command= 9559285612Sdelphij func_source $func_ltwrapper_scriptname_result 9560285612Sdelphij func_append rmfiles " $func_ltwrapper_scriptname_result" 9561285612Sdelphij else 9562285612Sdelphij relink_command= 9563285612Sdelphij func_source $dir/$noexename 9564285612Sdelphij fi 9565181834Sroberto 9566181834Sroberto # note $name still contains .exe if it was in $file originally 9567181834Sroberto # as does the version of $file that was added into $rmfiles 9568285612Sdelphij func_append rmfiles " $odir/$name $odir/${name}S.${objext}" 9569181834Sroberto if test "$fast_install" = yes && test -n "$relink_command"; then 9570285612Sdelphij func_append rmfiles " $odir/lt-$name" 9571181834Sroberto fi 9572181834Sroberto if test "X$noexename" != "X$name" ; then 9573285612Sdelphij func_append rmfiles " $odir/lt-${noexename}.c" 9574181834Sroberto fi 9575181834Sroberto fi 9576181834Sroberto fi 9577181834Sroberto ;; 9578181834Sroberto esac 9579285612Sdelphij func_show_eval "$RM $rmfiles" 'exit_status=1' 9580181834Sroberto done 9581181834Sroberto 9582181834Sroberto # Try to remove the ${objdir}s in the directories where we deleted files 9583181834Sroberto for dir in $rmdirs; do 9584181834Sroberto if test -d "$dir"; then 9585285612Sdelphij func_show_eval "rmdir $dir >/dev/null 2>&1" 9586181834Sroberto fi 9587181834Sroberto done 9588181834Sroberto 9589181834Sroberto exit $exit_status 9590285612Sdelphij} 9591181834Sroberto 9592285612Sdelphij{ test "$opt_mode" = uninstall || test "$opt_mode" = clean; } && 9593285612Sdelphij func_mode_uninstall ${1+"$@"} 9594181834Sroberto 9595285612Sdelphijtest -z "$opt_mode" && { 9596285612Sdelphij help="$generic_help" 9597285612Sdelphij func_fatal_help "you must specify a MODE" 9598285612Sdelphij} 9599181834Sroberto 9600285612Sdelphijtest -z "$exec_cmd" && \ 9601285612Sdelphij func_fatal_help "invalid operation mode \`$opt_mode'" 9602285612Sdelphij 9603181834Srobertoif test -n "$exec_cmd"; then 9604285612Sdelphij eval exec "$exec_cmd" 9605181834Sroberto exit $EXIT_FAILURE 9606181834Srobertofi 9607181834Sroberto 9608285612Sdelphijexit $exit_status 9609181834Sroberto 9610181834Sroberto 9611181834Sroberto# The TAGs below are defined such that we never get into a situation 9612181834Sroberto# in which we disable both kinds of libraries. Given conflicting 9613181834Sroberto# choices, we go for a static library, that is the most portable, 9614181834Sroberto# since we can't tell whether shared libraries were disabled because 9615181834Sroberto# the user asked for that or because the platform doesn't support 9616181834Sroberto# them. This is particularly important on AIX, because we don't 9617181834Sroberto# support having both static and shared libraries enabled at the same 9618181834Sroberto# time on that platform, so we default to a shared-only configuration. 9619181834Sroberto# If a disable-shared tag is given, we'll fallback to a static-only 9620181834Sroberto# configuration. But we'll never go from static-only to shared-only. 9621181834Sroberto 9622181834Sroberto# ### BEGIN LIBTOOL TAG CONFIG: disable-shared 9623285612Sdelphijbuild_libtool_libs=no 9624285612Sdelphijbuild_old_libs=yes 9625181834Sroberto# ### END LIBTOOL TAG CONFIG: disable-shared 9626181834Sroberto 9627181834Sroberto# ### BEGIN LIBTOOL TAG CONFIG: disable-static 9628285612Sdelphijbuild_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 9629181834Sroberto# ### END LIBTOOL TAG CONFIG: disable-static 9630181834Sroberto 9631181834Sroberto# Local Variables: 9632181834Sroberto# mode:shell-script 9633181834Sroberto# sh-indentation:2 9634181834Sroberto# End: 9635285612Sdelphij# vi:sw=2 9636285612Sdelphij 9637