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