annotate ltmain.sh @ 20:dd5b333a7960

Regenerate Autotools files myself with Ron's patch
author Adam Chlipala <adam@chlipala.net>
date Sat, 23 Jun 2012 09:58:31 -0400
parents 4bb4db8f9cdc
children
rev   line source
adam@12 1
adam@20 2 # libtool (GNU libtool) 2.4.2
adam@0 3 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
adam@0 4
adam@12 5 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
adam@20 6 # 2007, 2008, 2009, 2010, 2011 Free Software Foundation, Inc.
adam@0 7 # This is free software; see the source for copying conditions. There is NO
adam@0 8 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
adam@0 9
adam@0 10 # GNU Libtool is free software; you can redistribute it and/or modify
adam@0 11 # it under the terms of the GNU General Public License as published by
adam@0 12 # the Free Software Foundation; either version 2 of the License, or
adam@0 13 # (at your option) any later version.
adam@0 14 #
adam@0 15 # As a special exception to the GNU General Public License,
adam@0 16 # if you distribute this file as part of a program or library that
adam@0 17 # is built using GNU Libtool, you may include this file under the
adam@0 18 # same distribution terms that you use for the rest of that program.
adam@0 19 #
adam@0 20 # GNU Libtool is distributed in the hope that it will be useful, but
adam@0 21 # WITHOUT ANY WARRANTY; without even the implied warranty of
adam@0 22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
adam@0 23 # General Public License for more details.
adam@0 24 #
adam@0 25 # You should have received a copy of the GNU General Public License
adam@0 26 # along with GNU Libtool; see the file COPYING. If not, a copy
adam@0 27 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
adam@0 28 # or obtained by writing to the Free Software Foundation, Inc.,
adam@0 29 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
adam@0 30
adam@0 31 # Usage: $progname [OPTION]... [MODE-ARG]...
adam@0 32 #
adam@0 33 # Provide generalized library-building support services.
adam@0 34 #
adam@12 35 # --config show all configuration variables
adam@12 36 # --debug enable verbose shell tracing
adam@12 37 # -n, --dry-run display commands without modifying any files
adam@12 38 # --features display basic configuration information and exit
adam@12 39 # --mode=MODE use operation mode MODE
adam@12 40 # --preserve-dup-deps don't remove duplicate dependency libraries
adam@12 41 # --quiet, --silent don't print informational messages
adam@12 42 # --no-quiet, --no-silent
adam@12 43 # print informational messages (default)
adam@20 44 # --no-warn don't display warning messages
adam@12 45 # --tag=TAG use configuration variables from tag TAG
adam@12 46 # -v, --verbose print more informational messages than default
adam@12 47 # --no-verbose don't print the extra informational messages
adam@12 48 # --version print version information
adam@12 49 # -h, --help, --help-all print short, long, or detailed help message
adam@0 50 #
adam@0 51 # MODE must be one of the following:
adam@0 52 #
adam@12 53 # clean remove files from the build directory
adam@12 54 # compile compile a source file into a libtool object
adam@12 55 # execute automatically set library path, then run a program
adam@12 56 # finish complete the installation of libtool libraries
adam@12 57 # install install libraries or executables
adam@12 58 # link create a library or an executable
adam@12 59 # uninstall remove libraries from an installed directory
adam@0 60 #
adam@12 61 # MODE-ARGS vary depending on the MODE. When passed as first option,
adam@12 62 # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
adam@0 63 # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
adam@0 64 #
adam@0 65 # When reporting a bug, please describe a test case to reproduce it and
adam@0 66 # include the following information:
adam@0 67 #
adam@12 68 # host-triplet: $host
adam@12 69 # shell: $SHELL
adam@12 70 # compiler: $LTCC
adam@12 71 # compiler flags: $LTCFLAGS
adam@12 72 # linker: $LD (gnu? $with_gnu_ld)
adam@20 73 # $progname: (GNU libtool) 2.4.2 Debian-2.4.2-1
adam@12 74 # automake: $automake_version
adam@12 75 # autoconf: $autoconf_version
adam@0 76 #
adam@0 77 # Report bugs to <bug-libtool@gnu.org>.
adam@12 78 # GNU libtool home page: <http://www.gnu.org/software/libtool/>.
adam@12 79 # General help using GNU software: <http://www.gnu.org/gethelp/>.
adam@12 80
adam@12 81 PROGRAM=libtool
adam@0 82 PACKAGE=libtool
adam@20 83 VERSION="2.4.2 Debian-2.4.2-1"
adam@0 84 TIMESTAMP=""
adam@20 85 package_revision=1.3337
adam@0 86
adam@0 87 # Be Bourne compatible
adam@0 88 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
adam@0 89 emulate sh
adam@0 90 NULLCMD=:
adam@0 91 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
adam@0 92 # is contrary to our usage. Disable this feature.
adam@0 93 alias -g '${1+"$@"}'='"$@"'
adam@0 94 setopt NO_GLOB_SUBST
adam@0 95 else
adam@0 96 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
adam@0 97 fi
adam@0 98 BIN_SH=xpg4; export BIN_SH # for Tru64
adam@0 99 DUALCASE=1; export DUALCASE # for MKS sh
adam@0 100
adam@12 101 # A function that is used when there is no print builtin or printf.
adam@12 102 func_fallback_echo ()
adam@12 103 {
adam@12 104 eval 'cat <<_LTECHO_EOF
adam@12 105 $1
adam@12 106 _LTECHO_EOF'
adam@12 107 }
adam@12 108
adam@0 109 # NLS nuisances: We save the old values to restore during execute mode.
adam@0 110 lt_user_locale=
adam@0 111 lt_safe_locale=
adam@0 112 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
adam@0 113 do
adam@0 114 eval "if test \"\${$lt_var+set}\" = set; then
adam@0 115 save_$lt_var=\$$lt_var
adam@0 116 $lt_var=C
adam@0 117 export $lt_var
adam@0 118 lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
adam@0 119 lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
adam@0 120 fi"
adam@0 121 done
adam@12 122 LC_ALL=C
adam@12 123 LANGUAGE=C
adam@12 124 export LANGUAGE LC_ALL
adam@0 125
adam@0 126 $lt_unset CDPATH
adam@0 127
adam@0 128
adam@12 129 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
adam@12 130 # is ksh but when the shell is invoked as "sh" and the current value of
adam@12 131 # the _XPG environment variable is not equal to 1 (one), the special
adam@12 132 # positional parameter $0, within a function call, is the name of the
adam@12 133 # function.
adam@12 134 progpath="$0"
adam@0 135
adam@0 136
adam@0 137
adam@0 138 : ${CP="cp -f"}
adam@12 139 test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
adam@0 140 : ${MAKE="make"}
adam@0 141 : ${MKDIR="mkdir"}
adam@0 142 : ${MV="mv -f"}
adam@0 143 : ${RM="rm -f"}
adam@0 144 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
adam@0 145 : ${Xsed="$SED -e 1s/^X//"}
adam@0 146
adam@0 147 # Global variables:
adam@0 148 EXIT_SUCCESS=0
adam@0 149 EXIT_FAILURE=1
adam@0 150 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
adam@0 151 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
adam@0 152
adam@0 153 exit_status=$EXIT_SUCCESS
adam@0 154
adam@0 155 # Make sure IFS has a sensible default
adam@0 156 lt_nl='
adam@0 157 '
adam@0 158 IFS=" $lt_nl"
adam@0 159
adam@0 160 dirname="s,/[^/]*$,,"
adam@0 161 basename="s,^.*/,,"
adam@0 162
adam@12 163 # func_dirname file append nondir_replacement
adam@12 164 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
adam@12 165 # otherwise set result to NONDIR_REPLACEMENT.
adam@12 166 func_dirname ()
adam@12 167 {
adam@12 168 func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
adam@12 169 if test "X$func_dirname_result" = "X${1}"; then
adam@12 170 func_dirname_result="${3}"
adam@12 171 else
adam@12 172 func_dirname_result="$func_dirname_result${2}"
adam@12 173 fi
adam@12 174 } # func_dirname may be replaced by extended shell implementation
adam@12 175
adam@12 176
adam@12 177 # func_basename file
adam@12 178 func_basename ()
adam@12 179 {
adam@12 180 func_basename_result=`$ECHO "${1}" | $SED "$basename"`
adam@12 181 } # func_basename may be replaced by extended shell implementation
adam@12 182
adam@12 183
adam@0 184 # func_dirname_and_basename file append nondir_replacement
adam@0 185 # perform func_basename and func_dirname in a single function
adam@0 186 # call:
adam@0 187 # dirname: Compute the dirname of FILE. If nonempty,
adam@0 188 # add APPEND to the result, otherwise set result
adam@0 189 # to NONDIR_REPLACEMENT.
adam@0 190 # value returned in "$func_dirname_result"
adam@0 191 # basename: Compute filename of FILE.
adam@0 192 # value retuned in "$func_basename_result"
adam@0 193 # Implementation must be kept synchronized with func_dirname
adam@0 194 # and func_basename. For efficiency, we do not delegate to
adam@0 195 # those functions but instead duplicate the functionality here.
adam@0 196 func_dirname_and_basename ()
adam@0 197 {
adam@12 198 # Extract subdirectory from the argument.
adam@12 199 func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
adam@12 200 if test "X$func_dirname_result" = "X${1}"; then
adam@12 201 func_dirname_result="${3}"
adam@12 202 else
adam@12 203 func_dirname_result="$func_dirname_result${2}"
adam@12 204 fi
adam@12 205 func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
adam@12 206 } # func_dirname_and_basename may be replaced by extended shell implementation
adam@12 207
adam@12 208
adam@12 209 # func_stripname prefix suffix name
adam@12 210 # strip PREFIX and SUFFIX off of NAME.
adam@12 211 # PREFIX and SUFFIX must not contain globbing or regex special
adam@12 212 # characters, hashes, percent signs, but SUFFIX may contain a leading
adam@12 213 # dot (in which case that matches only a dot).
adam@12 214 # func_strip_suffix prefix name
adam@12 215 func_stripname ()
adam@12 216 {
adam@12 217 case ${2} in
adam@12 218 .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
adam@12 219 *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
adam@12 220 esac
adam@12 221 } # func_stripname may be replaced by extended shell implementation
adam@12 222
adam@12 223
adam@12 224 # These SED scripts presuppose an absolute path with a trailing slash.
adam@12 225 pathcar='s,^/\([^/]*\).*$,\1,'
adam@12 226 pathcdr='s,^/[^/]*,,'
adam@12 227 removedotparts=':dotsl
adam@12 228 s@/\./@/@g
adam@12 229 t dotsl
adam@12 230 s,/\.$,/,'
adam@12 231 collapseslashes='s@/\{1,\}@/@g'
adam@12 232 finalslash='s,/*$,/,'
adam@12 233
adam@12 234 # func_normal_abspath PATH
adam@12 235 # Remove doubled-up and trailing slashes, "." path components,
adam@12 236 # and cancel out any ".." path components in PATH after making
adam@12 237 # it an absolute path.
adam@12 238 # value returned in "$func_normal_abspath_result"
adam@12 239 func_normal_abspath ()
adam@12 240 {
adam@12 241 # Start from root dir and reassemble the path.
adam@12 242 func_normal_abspath_result=
adam@12 243 func_normal_abspath_tpath=$1
adam@12 244 func_normal_abspath_altnamespace=
adam@12 245 case $func_normal_abspath_tpath in
adam@12 246 "")
adam@12 247 # Empty path, that just means $cwd.
adam@12 248 func_stripname '' '/' "`pwd`"
adam@12 249 func_normal_abspath_result=$func_stripname_result
adam@12 250 return
adam@12 251 ;;
adam@12 252 # The next three entries are used to spot a run of precisely
adam@12 253 # two leading slashes without using negated character classes;
adam@12 254 # we take advantage of case's first-match behaviour.
adam@12 255 ///*)
adam@12 256 # Unusual form of absolute path, do nothing.
adam@12 257 ;;
adam@12 258 //*)
adam@12 259 # Not necessarily an ordinary path; POSIX reserves leading '//'
adam@12 260 # and for example Cygwin uses it to access remote file shares
adam@12 261 # over CIFS/SMB, so we conserve a leading double slash if found.
adam@12 262 func_normal_abspath_altnamespace=/
adam@12 263 ;;
adam@12 264 /*)
adam@12 265 # Absolute path, do nothing.
adam@12 266 ;;
adam@12 267 *)
adam@12 268 # Relative path, prepend $cwd.
adam@12 269 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
adam@12 270 ;;
adam@12 271 esac
adam@12 272 # Cancel out all the simple stuff to save iterations. We also want
adam@12 273 # the path to end with a slash for ease of parsing, so make sure
adam@12 274 # there is one (and only one) here.
adam@12 275 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
adam@12 276 -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
adam@12 277 while :; do
adam@12 278 # Processed it all yet?
adam@12 279 if test "$func_normal_abspath_tpath" = / ; then
adam@12 280 # If we ascended to the root using ".." the result may be empty now.
adam@12 281 if test -z "$func_normal_abspath_result" ; then
adam@12 282 func_normal_abspath_result=/
adam@12 283 fi
adam@12 284 break
adam@12 285 fi
adam@12 286 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
adam@12 287 -e "$pathcar"`
adam@12 288 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
adam@12 289 -e "$pathcdr"`
adam@12 290 # Figure out what to do with it
adam@12 291 case $func_normal_abspath_tcomponent in
adam@12 292 "")
adam@12 293 # Trailing empty path component, ignore it.
adam@12 294 ;;
adam@12 295 ..)
adam@12 296 # Parent dir; strip last assembled component from result.
adam@12 297 func_dirname "$func_normal_abspath_result"
adam@12 298 func_normal_abspath_result=$func_dirname_result
adam@12 299 ;;
adam@12 300 *)
adam@12 301 # Actual path component, append it.
adam@12 302 func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
adam@12 303 ;;
adam@12 304 esac
adam@12 305 done
adam@12 306 # Restore leading double-slash if one was found on entry.
adam@12 307 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
adam@12 308 }
adam@12 309
adam@12 310 # func_relative_path SRCDIR DSTDIR
adam@12 311 # generates a relative path from SRCDIR to DSTDIR, with a trailing
adam@12 312 # slash if non-empty, suitable for immediately appending a filename
adam@12 313 # without needing to append a separator.
adam@12 314 # value returned in "$func_relative_path_result"
adam@12 315 func_relative_path ()
adam@12 316 {
adam@12 317 func_relative_path_result=
adam@12 318 func_normal_abspath "$1"
adam@12 319 func_relative_path_tlibdir=$func_normal_abspath_result
adam@12 320 func_normal_abspath "$2"
adam@12 321 func_relative_path_tbindir=$func_normal_abspath_result
adam@12 322
adam@12 323 # Ascend the tree starting from libdir
adam@12 324 while :; do
adam@12 325 # check if we have found a prefix of bindir
adam@12 326 case $func_relative_path_tbindir in
adam@12 327 $func_relative_path_tlibdir)
adam@12 328 # found an exact match
adam@12 329 func_relative_path_tcancelled=
adam@12 330 break
adam@12 331 ;;
adam@12 332 $func_relative_path_tlibdir*)
adam@12 333 # found a matching prefix
adam@12 334 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
adam@12 335 func_relative_path_tcancelled=$func_stripname_result
adam@12 336 if test -z "$func_relative_path_result"; then
adam@12 337 func_relative_path_result=.
adam@12 338 fi
adam@12 339 break
adam@12 340 ;;
adam@12 341 *)
adam@12 342 func_dirname $func_relative_path_tlibdir
adam@12 343 func_relative_path_tlibdir=${func_dirname_result}
adam@12 344 if test "x$func_relative_path_tlibdir" = x ; then
adam@12 345 # Have to descend all the way to the root!
adam@12 346 func_relative_path_result=../$func_relative_path_result
adam@12 347 func_relative_path_tcancelled=$func_relative_path_tbindir
adam@12 348 break
adam@12 349 fi
adam@12 350 func_relative_path_result=../$func_relative_path_result
adam@12 351 ;;
adam@12 352 esac
adam@12 353 done
adam@12 354
adam@12 355 # Now calculate path; take care to avoid doubling-up slashes.
adam@12 356 func_stripname '' '/' "$func_relative_path_result"
adam@12 357 func_relative_path_result=$func_stripname_result
adam@12 358 func_stripname '/' '/' "$func_relative_path_tcancelled"
adam@12 359 if test "x$func_stripname_result" != x ; then
adam@12 360 func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
adam@0 361 fi
adam@12 362
adam@12 363 # Normalisation. If bindir is libdir, return empty string,
adam@12 364 # else relative path ending with a slash; either way, target
adam@12 365 # file name can be directly appended.
adam@12 366 if test ! -z "$func_relative_path_result"; then
adam@12 367 func_stripname './' '' "$func_relative_path_result/"
adam@12 368 func_relative_path_result=$func_stripname_result
adam@12 369 fi
adam@12 370 }
adam@0 371
adam@0 372 # The name of this program:
adam@0 373 func_dirname_and_basename "$progpath"
adam@0 374 progname=$func_basename_result
adam@0 375
adam@0 376 # Make sure we have an absolute path for reexecution:
adam@0 377 case $progpath in
adam@0 378 [\\/]*|[A-Za-z]:\\*) ;;
adam@0 379 *[\\/]*)
adam@0 380 progdir=$func_dirname_result
adam@0 381 progdir=`cd "$progdir" && pwd`
adam@0 382 progpath="$progdir/$progname"
adam@0 383 ;;
adam@0 384 *)
adam@0 385 save_IFS="$IFS"
adam@20 386 IFS=${PATH_SEPARATOR-:}
adam@0 387 for progdir in $PATH; do
adam@0 388 IFS="$save_IFS"
adam@0 389 test -x "$progdir/$progname" && break
adam@0 390 done
adam@0 391 IFS="$save_IFS"
adam@0 392 test -n "$progdir" || progdir=`pwd`
adam@0 393 progpath="$progdir/$progname"
adam@0 394 ;;
adam@0 395 esac
adam@0 396
adam@0 397 # Sed substitution that helps us do robust quoting. It backslashifies
adam@0 398 # metacharacters that are still active within double-quoted strings.
adam@0 399 Xsed="${SED}"' -e 1s/^X//'
adam@0 400 sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
adam@0 401
adam@0 402 # Same as above, but do not quote variable references.
adam@0 403 double_quote_subst='s/\(["`\\]\)/\\\1/g'
adam@0 404
adam@12 405 # Sed substitution that turns a string into a regex matching for the
adam@12 406 # string literally.
adam@12 407 sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
adam@12 408
adam@12 409 # Sed substitution that converts a w32 file name or path
adam@12 410 # which contains forward slashes, into one that contains
adam@12 411 # (escaped) backslashes. A very naive implementation.
adam@12 412 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
adam@12 413
adam@0 414 # Re-`\' parameter expansions in output of double_quote_subst that were
adam@0 415 # `\'-ed in input to the same. If an odd number of `\' preceded a '$'
adam@0 416 # in input to double_quote_subst, that '$' was protected from expansion.
adam@0 417 # Since each input `\' is now two `\'s, look for any number of runs of
adam@0 418 # four `\'s followed by two `\'s and then a '$'. `\' that '$'.
adam@0 419 bs='\\'
adam@0 420 bs2='\\\\'
adam@0 421 bs4='\\\\\\\\'
adam@0 422 dollar='\$'
adam@0 423 sed_double_backslash="\
adam@0 424 s/$bs4/&\\
adam@0 425 /g
adam@0 426 s/^$bs2$dollar/$bs&/
adam@0 427 s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
adam@0 428 s/\n//g"
adam@0 429
adam@0 430 # Standard options:
adam@0 431 opt_dry_run=false
adam@0 432 opt_help=false
adam@0 433 opt_quiet=false
adam@0 434 opt_verbose=false
adam@0 435 opt_warning=:
adam@0 436
adam@0 437 # func_echo arg...
adam@0 438 # Echo program name prefixed message, along with the current mode
adam@0 439 # name if it has been set yet.
adam@0 440 func_echo ()
adam@0 441 {
adam@12 442 $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
adam@0 443 }
adam@0 444
adam@0 445 # func_verbose arg...
adam@0 446 # Echo program name prefixed message in verbose mode only.
adam@0 447 func_verbose ()
adam@0 448 {
adam@0 449 $opt_verbose && func_echo ${1+"$@"}
adam@0 450
adam@0 451 # A bug in bash halts the script if the last line of a function
adam@0 452 # fails when set -e is in force, so we need another command to
adam@0 453 # work around that:
adam@0 454 :
adam@0 455 }
adam@0 456
adam@12 457 # func_echo_all arg...
adam@12 458 # Invoke $ECHO with all args, space-separated.
adam@12 459 func_echo_all ()
adam@12 460 {
adam@12 461 $ECHO "$*"
adam@12 462 }
adam@12 463
adam@0 464 # func_error arg...
adam@0 465 # Echo program name prefixed message to standard error.
adam@0 466 func_error ()
adam@0 467 {
adam@12 468 $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
adam@0 469 }
adam@0 470
adam@0 471 # func_warning arg...
adam@0 472 # Echo program name prefixed warning message to standard error.
adam@0 473 func_warning ()
adam@0 474 {
adam@12 475 $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
adam@0 476
adam@0 477 # bash bug again:
adam@0 478 :
adam@0 479 }
adam@0 480
adam@0 481 # func_fatal_error arg...
adam@0 482 # Echo program name prefixed message to standard error, and exit.
adam@0 483 func_fatal_error ()
adam@0 484 {
adam@0 485 func_error ${1+"$@"}
adam@0 486 exit $EXIT_FAILURE
adam@0 487 }
adam@0 488
adam@0 489 # func_fatal_help arg...
adam@0 490 # Echo program name prefixed message to standard error, followed by
adam@0 491 # a help hint, and exit.
adam@0 492 func_fatal_help ()
adam@0 493 {
adam@0 494 func_error ${1+"$@"}
adam@0 495 func_fatal_error "$help"
adam@0 496 }
adam@0 497 help="Try \`$progname --help' for more information." ## default
adam@0 498
adam@0 499
adam@0 500 # func_grep expression filename
adam@0 501 # Check whether EXPRESSION matches any line of FILENAME, without output.
adam@0 502 func_grep ()
adam@0 503 {
adam@0 504 $GREP "$1" "$2" >/dev/null 2>&1
adam@0 505 }
adam@0 506
adam@0 507
adam@0 508 # func_mkdir_p directory-path
adam@0 509 # Make sure the entire path to DIRECTORY-PATH is available.
adam@0 510 func_mkdir_p ()
adam@0 511 {
adam@0 512 my_directory_path="$1"
adam@0 513 my_dir_list=
adam@0 514
adam@0 515 if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
adam@0 516
adam@0 517 # Protect directory names starting with `-'
adam@0 518 case $my_directory_path in
adam@0 519 -*) my_directory_path="./$my_directory_path" ;;
adam@0 520 esac
adam@0 521
adam@0 522 # While some portion of DIR does not yet exist...
adam@0 523 while test ! -d "$my_directory_path"; do
adam@0 524 # ...make a list in topmost first order. Use a colon delimited
adam@0 525 # list incase some portion of path contains whitespace.
adam@0 526 my_dir_list="$my_directory_path:$my_dir_list"
adam@0 527
adam@0 528 # If the last portion added has no slash in it, the list is done
adam@0 529 case $my_directory_path in */*) ;; *) break ;; esac
adam@0 530
adam@0 531 # ...otherwise throw away the child directory and loop
adam@12 532 my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
adam@0 533 done
adam@12 534 my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
adam@0 535
adam@0 536 save_mkdir_p_IFS="$IFS"; IFS=':'
adam@0 537 for my_dir in $my_dir_list; do
adam@0 538 IFS="$save_mkdir_p_IFS"
adam@0 539 # mkdir can fail with a `File exist' error if two processes
adam@0 540 # try to create one of the directories concurrently. Don't
adam@0 541 # stop in that case!
adam@0 542 $MKDIR "$my_dir" 2>/dev/null || :
adam@0 543 done
adam@0 544 IFS="$save_mkdir_p_IFS"
adam@0 545
adam@0 546 # Bail out if we (or some other process) failed to create a directory.
adam@0 547 test -d "$my_directory_path" || \
adam@0 548 func_fatal_error "Failed to create \`$1'"
adam@0 549 fi
adam@0 550 }
adam@0 551
adam@0 552
adam@0 553 # func_mktempdir [string]
adam@0 554 # Make a temporary directory that won't clash with other running
adam@0 555 # libtool processes, and avoids race conditions if possible. If
adam@0 556 # given, STRING is the basename for that directory.
adam@0 557 func_mktempdir ()
adam@0 558 {
adam@0 559 my_template="${TMPDIR-/tmp}/${1-$progname}"
adam@0 560
adam@0 561 if test "$opt_dry_run" = ":"; then
adam@0 562 # Return a directory name, but don't create it in dry-run mode
adam@0 563 my_tmpdir="${my_template}-$$"
adam@0 564 else
adam@0 565
adam@0 566 # If mktemp works, use that first and foremost
adam@0 567 my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
adam@0 568
adam@0 569 if test ! -d "$my_tmpdir"; then
adam@0 570 # Failing that, at least try and use $RANDOM to avoid a race
adam@0 571 my_tmpdir="${my_template}-${RANDOM-0}$$"
adam@0 572
adam@0 573 save_mktempdir_umask=`umask`
adam@0 574 umask 0077
adam@0 575 $MKDIR "$my_tmpdir"
adam@0 576 umask $save_mktempdir_umask
adam@0 577 fi
adam@0 578
adam@0 579 # If we're not in dry-run mode, bomb out on failure
adam@0 580 test -d "$my_tmpdir" || \
adam@0 581 func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
adam@0 582 fi
adam@0 583
adam@12 584 $ECHO "$my_tmpdir"
adam@0 585 }
adam@0 586
adam@0 587
adam@0 588 # func_quote_for_eval arg
adam@0 589 # Aesthetically quote ARG to be evaled later.
adam@0 590 # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
adam@0 591 # is double-quoted, suitable for a subsequent eval, whereas
adam@0 592 # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
adam@0 593 # which are still active within double quotes backslashified.
adam@0 594 func_quote_for_eval ()
adam@0 595 {
adam@0 596 case $1 in
adam@0 597 *[\\\`\"\$]*)
adam@12 598 func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
adam@0 599 *)
adam@0 600 func_quote_for_eval_unquoted_result="$1" ;;
adam@0 601 esac
adam@0 602
adam@0 603 case $func_quote_for_eval_unquoted_result in
adam@0 604 # Double-quote args containing shell metacharacters to delay
adam@0 605 # word splitting, command substitution and and variable
adam@0 606 # expansion for a subsequent eval.
adam@0 607 # Many Bourne shells cannot handle close brackets correctly
adam@0 608 # in scan sets, so we specify it separately.
adam@0 609 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
adam@0 610 func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
adam@0 611 ;;
adam@0 612 *)
adam@0 613 func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
adam@0 614 esac
adam@0 615 }
adam@0 616
adam@0 617
adam@0 618 # func_quote_for_expand arg
adam@0 619 # Aesthetically quote ARG to be evaled later; same as above,
adam@0 620 # but do not quote variable references.
adam@0 621 func_quote_for_expand ()
adam@0 622 {
adam@0 623 case $1 in
adam@0 624 *[\\\`\"]*)
adam@12 625 my_arg=`$ECHO "$1" | $SED \
adam@0 626 -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
adam@0 627 *)
adam@0 628 my_arg="$1" ;;
adam@0 629 esac
adam@0 630
adam@0 631 case $my_arg in
adam@0 632 # Double-quote args containing shell metacharacters to delay
adam@0 633 # word splitting and command substitution for a subsequent eval.
adam@0 634 # Many Bourne shells cannot handle close brackets correctly
adam@0 635 # in scan sets, so we specify it separately.
adam@0 636 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
adam@0 637 my_arg="\"$my_arg\""
adam@0 638 ;;
adam@0 639 esac
adam@0 640
adam@0 641 func_quote_for_expand_result="$my_arg"
adam@0 642 }
adam@0 643
adam@0 644
adam@0 645 # func_show_eval cmd [fail_exp]
adam@0 646 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
adam@0 647 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
adam@0 648 # is given, then evaluate it.
adam@0 649 func_show_eval ()
adam@0 650 {
adam@0 651 my_cmd="$1"
adam@0 652 my_fail_exp="${2-:}"
adam@0 653
adam@0 654 ${opt_silent-false} || {
adam@0 655 func_quote_for_expand "$my_cmd"
adam@0 656 eval "func_echo $func_quote_for_expand_result"
adam@0 657 }
adam@0 658
adam@0 659 if ${opt_dry_run-false}; then :; else
adam@0 660 eval "$my_cmd"
adam@0 661 my_status=$?
adam@0 662 if test "$my_status" -eq 0; then :; else
adam@0 663 eval "(exit $my_status); $my_fail_exp"
adam@0 664 fi
adam@0 665 fi
adam@0 666 }
adam@0 667
adam@0 668
adam@0 669 # func_show_eval_locale cmd [fail_exp]
adam@0 670 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
adam@0 671 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
adam@0 672 # is given, then evaluate it. Use the saved locale for evaluation.
adam@0 673 func_show_eval_locale ()
adam@0 674 {
adam@0 675 my_cmd="$1"
adam@0 676 my_fail_exp="${2-:}"
adam@0 677
adam@0 678 ${opt_silent-false} || {
adam@0 679 func_quote_for_expand "$my_cmd"
adam@0 680 eval "func_echo $func_quote_for_expand_result"
adam@0 681 }
adam@0 682
adam@0 683 if ${opt_dry_run-false}; then :; else
adam@0 684 eval "$lt_user_locale
adam@0 685 $my_cmd"
adam@0 686 my_status=$?
adam@0 687 eval "$lt_safe_locale"
adam@0 688 if test "$my_status" -eq 0; then :; else
adam@0 689 eval "(exit $my_status); $my_fail_exp"
adam@0 690 fi
adam@0 691 fi
adam@0 692 }
adam@0 693
adam@12 694 # func_tr_sh
adam@12 695 # Turn $1 into a string suitable for a shell variable name.
adam@12 696 # Result is stored in $func_tr_sh_result. All characters
adam@12 697 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
adam@12 698 # if $1 begins with a digit, a '_' is prepended as well.
adam@12 699 func_tr_sh ()
adam@12 700 {
adam@12 701 case $1 in
adam@12 702 [0-9]* | *[!a-zA-Z0-9_]*)
adam@12 703 func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
adam@12 704 ;;
adam@12 705 * )
adam@12 706 func_tr_sh_result=$1
adam@12 707 ;;
adam@12 708 esac
adam@12 709 }
adam@0 710
adam@0 711
adam@0 712 # func_version
adam@0 713 # Echo version message to standard output and exit.
adam@0 714 func_version ()
adam@0 715 {
adam@12 716 $opt_debug
adam@12 717
adam@12 718 $SED -n '/(C)/!b go
adam@12 719 :more
adam@12 720 /\./!{
adam@12 721 N
adam@12 722 s/\n# / /
adam@12 723 b more
adam@12 724 }
adam@12 725 :go
adam@12 726 /^# '$PROGRAM' (GNU /,/# warranty; / {
adam@0 727 s/^# //
adam@0 728 s/^# *$//
adam@0 729 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
adam@0 730 p
adam@0 731 }' < "$progpath"
adam@0 732 exit $?
adam@0 733 }
adam@0 734
adam@0 735 # func_usage
adam@0 736 # Echo short help message to standard output and exit.
adam@0 737 func_usage ()
adam@0 738 {
adam@12 739 $opt_debug
adam@12 740
adam@12 741 $SED -n '/^# Usage:/,/^# *.*--help/ {
adam@0 742 s/^# //
adam@0 743 s/^# *$//
adam@0 744 s/\$progname/'$progname'/
adam@0 745 p
adam@0 746 }' < "$progpath"
adam@12 747 echo
adam@0 748 $ECHO "run \`$progname --help | more' for full usage"
adam@0 749 exit $?
adam@0 750 }
adam@0 751
adam@12 752 # func_help [NOEXIT]
adam@12 753 # Echo long help message to standard output and exit,
adam@12 754 # unless 'noexit' is passed as argument.
adam@0 755 func_help ()
adam@0 756 {
adam@12 757 $opt_debug
adam@12 758
adam@0 759 $SED -n '/^# Usage:/,/# Report bugs to/ {
adam@12 760 :print
adam@0 761 s/^# //
adam@0 762 s/^# *$//
adam@0 763 s*\$progname*'$progname'*
adam@0 764 s*\$host*'"$host"'*
adam@0 765 s*\$SHELL*'"$SHELL"'*
adam@0 766 s*\$LTCC*'"$LTCC"'*
adam@0 767 s*\$LTCFLAGS*'"$LTCFLAGS"'*
adam@0 768 s*\$LD*'"$LD"'*
adam@0 769 s/\$with_gnu_ld/'"$with_gnu_ld"'/
adam@20 770 s/\$automake_version/'"`(${AUTOMAKE-automake} --version) 2>/dev/null |$SED 1q`"'/
adam@20 771 s/\$autoconf_version/'"`(${AUTOCONF-autoconf} --version) 2>/dev/null |$SED 1q`"'/
adam@0 772 p
adam@12 773 d
adam@12 774 }
adam@12 775 /^# .* home page:/b print
adam@12 776 /^# General help using/b print
adam@12 777 ' < "$progpath"
adam@12 778 ret=$?
adam@12 779 if test -z "$1"; then
adam@12 780 exit $ret
adam@12 781 fi
adam@0 782 }
adam@0 783
adam@0 784 # func_missing_arg argname
adam@0 785 # Echo program name prefixed message to standard error and set global
adam@0 786 # exit_cmd.
adam@0 787 func_missing_arg ()
adam@0 788 {
adam@12 789 $opt_debug
adam@12 790
adam@12 791 func_error "missing argument for $1."
adam@0 792 exit_cmd=exit
adam@0 793 }
adam@0 794
adam@12 795
adam@12 796 # func_split_short_opt shortopt
adam@12 797 # Set func_split_short_opt_name and func_split_short_opt_arg shell
adam@12 798 # variables after splitting SHORTOPT after the 2nd character.
adam@12 799 func_split_short_opt ()
adam@12 800 {
adam@12 801 my_sed_short_opt='1s/^\(..\).*$/\1/;q'
adam@12 802 my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
adam@12 803
adam@12 804 func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
adam@12 805 func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
adam@12 806 } # func_split_short_opt may be replaced by extended shell implementation
adam@12 807
adam@12 808
adam@12 809 # func_split_long_opt longopt
adam@12 810 # Set func_split_long_opt_name and func_split_long_opt_arg shell
adam@12 811 # variables after splitting LONGOPT at the `=' sign.
adam@12 812 func_split_long_opt ()
adam@12 813 {
adam@12 814 my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
adam@12 815 my_sed_long_arg='1s/^--[^=]*=//'
adam@12 816
adam@12 817 func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
adam@12 818 func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
adam@12 819 } # func_split_long_opt may be replaced by extended shell implementation
adam@12 820
adam@0 821 exit_cmd=:
adam@0 822
adam@0 823
adam@0 824
adam@0 825
adam@0 826
adam@0 827 magic="%%%MAGIC variable%%%"
adam@0 828 magic_exe="%%%MAGIC EXE variable%%%"
adam@0 829
adam@0 830 # Global variables.
adam@0 831 nonopt=
adam@0 832 preserve_args=
adam@0 833 lo2o="s/\\.lo\$/.${objext}/"
adam@0 834 o2lo="s/\\.${objext}\$/.lo/"
adam@0 835 extracted_archives=
adam@0 836 extracted_serial=0
adam@0 837
adam@0 838 # If this variable is set in any of the actions, the command in it
adam@0 839 # will be execed at the end. This prevents here-documents from being
adam@0 840 # left over by shells.
adam@0 841 exec_cmd=
adam@0 842
adam@12 843 # func_append var value
adam@12 844 # Append VALUE to the end of shell variable VAR.
adam@12 845 func_append ()
adam@12 846 {
adam@12 847 eval "${1}=\$${1}\${2}"
adam@12 848 } # func_append may be replaced by extended shell implementation
adam@12 849
adam@12 850 # func_append_quoted var value
adam@12 851 # Quote VALUE and append to the end of shell variable VAR, separated
adam@12 852 # by a space.
adam@12 853 func_append_quoted ()
adam@12 854 {
adam@12 855 func_quote_for_eval "${2}"
adam@12 856 eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
adam@12 857 } # func_append_quoted may be replaced by extended shell implementation
adam@12 858
adam@12 859
adam@12 860 # func_arith arithmetic-term...
adam@12 861 func_arith ()
adam@12 862 {
adam@12 863 func_arith_result=`expr "${@}"`
adam@12 864 } # func_arith may be replaced by extended shell implementation
adam@12 865
adam@12 866
adam@12 867 # func_len string
adam@12 868 # STRING may not start with a hyphen.
adam@12 869 func_len ()
adam@12 870 {
adam@12 871 func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
adam@12 872 } # func_len may be replaced by extended shell implementation
adam@12 873
adam@12 874
adam@12 875 # func_lo2o object
adam@12 876 func_lo2o ()
adam@12 877 {
adam@12 878 func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
adam@12 879 } # func_lo2o may be replaced by extended shell implementation
adam@12 880
adam@12 881
adam@12 882 # func_xform libobj-or-source
adam@12 883 func_xform ()
adam@12 884 {
adam@12 885 func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
adam@12 886 } # func_xform may be replaced by extended shell implementation
adam@12 887
adam@12 888
adam@0 889 # func_fatal_configuration arg...
adam@0 890 # Echo program name prefixed message to standard error, followed by
adam@0 891 # a configuration failure hint, and exit.
adam@0 892 func_fatal_configuration ()
adam@0 893 {
adam@0 894 func_error ${1+"$@"}
adam@0 895 func_error "See the $PACKAGE documentation for more information."
adam@0 896 func_fatal_error "Fatal configuration error."
adam@0 897 }
adam@0 898
adam@0 899
adam@0 900 # func_config
adam@0 901 # Display the configuration for all the tags in this script.
adam@0 902 func_config ()
adam@0 903 {
adam@0 904 re_begincf='^# ### BEGIN LIBTOOL'
adam@0 905 re_endcf='^# ### END LIBTOOL'
adam@0 906
adam@0 907 # Default configuration.
adam@0 908 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
adam@0 909
adam@0 910 # Now print the configurations for the tags.
adam@0 911 for tagname in $taglist; do
adam@0 912 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
adam@0 913 done
adam@0 914
adam@0 915 exit $?
adam@0 916 }
adam@0 917
adam@0 918 # func_features
adam@0 919 # Display the features supported by this script.
adam@0 920 func_features ()
adam@0 921 {
adam@12 922 echo "host: $host"
adam@0 923 if test "$build_libtool_libs" = yes; then
adam@12 924 echo "enable shared libraries"
adam@0 925 else
adam@12 926 echo "disable shared libraries"
adam@0 927 fi
adam@0 928 if test "$build_old_libs" = yes; then
adam@12 929 echo "enable static libraries"
adam@0 930 else
adam@12 931 echo "disable static libraries"
adam@0 932 fi
adam@0 933
adam@0 934 exit $?
adam@0 935 }
adam@0 936
adam@0 937 # func_enable_tag tagname
adam@0 938 # Verify that TAGNAME is valid, and either flag an error and exit, or
adam@0 939 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
adam@0 940 # variable here.
adam@0 941 func_enable_tag ()
adam@0 942 {
adam@0 943 # Global variable:
adam@0 944 tagname="$1"
adam@0 945
adam@0 946 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
adam@0 947 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
adam@0 948 sed_extractcf="/$re_begincf/,/$re_endcf/p"
adam@0 949
adam@0 950 # Validate tagname.
adam@0 951 case $tagname in
adam@0 952 *[!-_A-Za-z0-9,/]*)
adam@0 953 func_fatal_error "invalid tag name: $tagname"
adam@0 954 ;;
adam@0 955 esac
adam@0 956
adam@0 957 # Don't test for the "default" C tag, as we know it's
adam@0 958 # there but not specially marked.
adam@0 959 case $tagname in
adam@0 960 CC) ;;
adam@0 961 *)
adam@0 962 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
adam@0 963 taglist="$taglist $tagname"
adam@0 964
adam@0 965 # Evaluate the configuration. Be careful to quote the path
adam@0 966 # and the sed script, to avoid splitting on whitespace, but
adam@0 967 # also don't use non-portable quotes within backquotes within
adam@0 968 # quotes we have to do it in 2 steps:
adam@0 969 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
adam@0 970 eval "$extractedcf"
adam@0 971 else
adam@0 972 func_error "ignoring unknown tag $tagname"
adam@0 973 fi
adam@0 974 ;;
adam@0 975 esac
adam@0 976 }
adam@0 977
adam@0 978 # func_check_version_match
adam@0 979 # Ensure that we are using m4 macros, and libtool script from the same
adam@0 980 # release of libtool.
adam@0 981 func_check_version_match ()
adam@0 982 {
adam@0 983 if test "$package_revision" != "$macro_revision"; then
adam@0 984 if test "$VERSION" != "$macro_version"; then
adam@0 985 if test -z "$macro_version"; then
adam@0 986 cat >&2 <<_LT_EOF
adam@0 987 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
adam@0 988 $progname: definition of this LT_INIT comes from an older release.
adam@0 989 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
adam@0 990 $progname: and run autoconf again.
adam@0 991 _LT_EOF
adam@0 992 else
adam@0 993 cat >&2 <<_LT_EOF
adam@0 994 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
adam@0 995 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
adam@0 996 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
adam@0 997 $progname: and run autoconf again.
adam@0 998 _LT_EOF
adam@0 999 fi
adam@0 1000 else
adam@0 1001 cat >&2 <<_LT_EOF
adam@0 1002 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
adam@0 1003 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
adam@0 1004 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
adam@0 1005 $progname: of $PACKAGE $VERSION and run autoconf again.
adam@0 1006 _LT_EOF
adam@0 1007 fi
adam@0 1008
adam@0 1009 exit $EXIT_MISMATCH
adam@0 1010 fi
adam@0 1011 }
adam@0 1012
adam@0 1013
adam@12 1014 # Shorthand for --mode=foo, only valid as the first argument
adam@12 1015 case $1 in
adam@12 1016 clean|clea|cle|cl)
adam@12 1017 shift; set dummy --mode clean ${1+"$@"}; shift
adam@12 1018 ;;
adam@12 1019 compile|compil|compi|comp|com|co|c)
adam@12 1020 shift; set dummy --mode compile ${1+"$@"}; shift
adam@12 1021 ;;
adam@12 1022 execute|execut|execu|exec|exe|ex|e)
adam@12 1023 shift; set dummy --mode execute ${1+"$@"}; shift
adam@12 1024 ;;
adam@12 1025 finish|finis|fini|fin|fi|f)
adam@12 1026 shift; set dummy --mode finish ${1+"$@"}; shift
adam@12 1027 ;;
adam@12 1028 install|instal|insta|inst|ins|in|i)
adam@12 1029 shift; set dummy --mode install ${1+"$@"}; shift
adam@12 1030 ;;
adam@12 1031 link|lin|li|l)
adam@12 1032 shift; set dummy --mode link ${1+"$@"}; shift
adam@12 1033 ;;
adam@12 1034 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
adam@12 1035 shift; set dummy --mode uninstall ${1+"$@"}; shift
adam@12 1036 ;;
adam@12 1037 esac
adam@12 1038
adam@12 1039
adam@12 1040
adam@12 1041 # Option defaults:
adam@12 1042 opt_debug=:
adam@12 1043 opt_dry_run=false
adam@12 1044 opt_config=false
adam@12 1045 opt_preserve_dup_deps=false
adam@12 1046 opt_features=false
adam@12 1047 opt_finish=false
adam@12 1048 opt_help=false
adam@12 1049 opt_help_all=false
adam@12 1050 opt_silent=:
adam@20 1051 opt_warning=:
adam@12 1052 opt_verbose=:
adam@12 1053 opt_silent=false
adam@12 1054 opt_verbose=false
adam@12 1055
adam@12 1056
adam@12 1057 # Parse options once, thoroughly. This comes as soon as possible in the
adam@12 1058 # script to make things like `--version' happen as quickly as we can.
adam@12 1059 {
adam@12 1060 # this just eases exit handling
adam@12 1061 while test $# -gt 0; do
adam@12 1062 opt="$1"
adam@12 1063 shift
adam@12 1064 case $opt in
adam@12 1065 --debug|-x) opt_debug='set -x'
adam@12 1066 func_echo "enabling shell trace mode"
adam@12 1067 $opt_debug
adam@12 1068 ;;
adam@12 1069 --dry-run|--dryrun|-n)
adam@12 1070 opt_dry_run=:
adam@12 1071 ;;
adam@12 1072 --config)
adam@12 1073 opt_config=:
adam@12 1074 func_config
adam@12 1075 ;;
adam@12 1076 --dlopen|-dlopen)
adam@12 1077 optarg="$1"
adam@12 1078 opt_dlopen="${opt_dlopen+$opt_dlopen
adam@12 1079 }$optarg"
adam@12 1080 shift
adam@12 1081 ;;
adam@12 1082 --preserve-dup-deps)
adam@12 1083 opt_preserve_dup_deps=:
adam@12 1084 ;;
adam@12 1085 --features)
adam@12 1086 opt_features=:
adam@12 1087 func_features
adam@12 1088 ;;
adam@12 1089 --finish)
adam@12 1090 opt_finish=:
adam@12 1091 set dummy --mode finish ${1+"$@"}; shift
adam@12 1092 ;;
adam@12 1093 --help)
adam@12 1094 opt_help=:
adam@12 1095 ;;
adam@12 1096 --help-all)
adam@12 1097 opt_help_all=:
adam@12 1098 opt_help=': help-all'
adam@12 1099 ;;
adam@12 1100 --mode)
adam@12 1101 test $# = 0 && func_missing_arg $opt && break
adam@12 1102 optarg="$1"
adam@12 1103 opt_mode="$optarg"
adam@12 1104 case $optarg in
adam@12 1105 # Valid mode arguments:
adam@12 1106 clean|compile|execute|finish|install|link|relink|uninstall) ;;
adam@12 1107
adam@12 1108 # Catch anything else as an error
adam@12 1109 *) func_error "invalid argument for $opt"
adam@12 1110 exit_cmd=exit
adam@12 1111 break
adam@12 1112 ;;
adam@12 1113 esac
adam@12 1114 shift
adam@12 1115 ;;
adam@12 1116 --no-silent|--no-quiet)
adam@12 1117 opt_silent=false
adam@12 1118 func_append preserve_args " $opt"
adam@12 1119 ;;
adam@20 1120 --no-warning|--no-warn)
adam@20 1121 opt_warning=false
adam@20 1122 func_append preserve_args " $opt"
adam@20 1123 ;;
adam@12 1124 --no-verbose)
adam@12 1125 opt_verbose=false
adam@12 1126 func_append preserve_args " $opt"
adam@12 1127 ;;
adam@12 1128 --silent|--quiet)
adam@12 1129 opt_silent=:
adam@12 1130 func_append preserve_args " $opt"
adam@12 1131 opt_verbose=false
adam@12 1132 ;;
adam@12 1133 --verbose|-v)
adam@12 1134 opt_verbose=:
adam@12 1135 func_append preserve_args " $opt"
adam@12 1136 opt_silent=false
adam@12 1137 ;;
adam@12 1138 --tag)
adam@12 1139 test $# = 0 && func_missing_arg $opt && break
adam@12 1140 optarg="$1"
adam@12 1141 opt_tag="$optarg"
adam@12 1142 func_append preserve_args " $opt $optarg"
adam@12 1143 func_enable_tag "$optarg"
adam@12 1144 shift
adam@12 1145 ;;
adam@12 1146
adam@12 1147 -\?|-h) func_usage ;;
adam@12 1148 --help) func_help ;;
adam@12 1149 --version) func_version ;;
adam@12 1150
adam@12 1151 # Separate optargs to long options:
adam@12 1152 --*=*)
adam@12 1153 func_split_long_opt "$opt"
adam@12 1154 set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
adam@12 1155 shift
adam@12 1156 ;;
adam@12 1157
adam@12 1158 # Separate non-argument short options:
adam@12 1159 -\?*|-h*|-n*|-v*)
adam@12 1160 func_split_short_opt "$opt"
adam@12 1161 set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
adam@12 1162 shift
adam@12 1163 ;;
adam@12 1164
adam@12 1165 --) break ;;
adam@12 1166 -*) func_fatal_help "unrecognized option \`$opt'" ;;
adam@12 1167 *) set dummy "$opt" ${1+"$@"}; shift; break ;;
adam@12 1168 esac
adam@12 1169 done
adam@12 1170
adam@12 1171 # Validate options:
adam@12 1172
adam@12 1173 # save first non-option argument
adam@12 1174 if test "$#" -gt 0; then
adam@12 1175 nonopt="$opt"
adam@12 1176 shift
adam@12 1177 fi
adam@12 1178
adam@12 1179 # preserve --debug
adam@12 1180 test "$opt_debug" = : || func_append preserve_args " --debug"
adam@12 1181
adam@12 1182 case $host in
adam@12 1183 *cygwin* | *mingw* | *pw32* | *cegcc*)
adam@12 1184 # don't eliminate duplications in $postdeps and $predeps
adam@12 1185 opt_duplicate_compiler_generated_deps=:
adam@12 1186 ;;
adam@12 1187 *)
adam@12 1188 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
adam@12 1189 ;;
adam@12 1190 esac
adam@12 1191
adam@12 1192 $opt_help || {
adam@12 1193 # Sanity checks first:
adam@12 1194 func_check_version_match
adam@12 1195
adam@12 1196 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
adam@12 1197 func_fatal_configuration "not configured to build any kind of library"
adam@12 1198 fi
adam@12 1199
adam@12 1200 # Darwin sucks
adam@12 1201 eval std_shrext=\"$shrext_cmds\"
adam@12 1202
adam@12 1203 # Only execute mode is allowed to have -dlopen flags.
adam@12 1204 if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
adam@12 1205 func_error "unrecognized option \`-dlopen'"
adam@12 1206 $ECHO "$help" 1>&2
adam@12 1207 exit $EXIT_FAILURE
adam@12 1208 fi
adam@12 1209
adam@12 1210 # Change the help message to a mode-specific one.
adam@12 1211 generic_help="$help"
adam@12 1212 help="Try \`$progname --help --mode=$opt_mode' for more information."
adam@12 1213 }
adam@12 1214
adam@12 1215
adam@12 1216 # Bail if the options were screwed
adam@12 1217 $exit_cmd $EXIT_FAILURE
adam@12 1218 }
adam@12 1219
adam@12 1220
adam@12 1221
adam@12 1222
adam@0 1223 ## ----------- ##
adam@0 1224 ## Main. ##
adam@0 1225 ## ----------- ##
adam@0 1226
adam@0 1227 # func_lalib_p file
adam@0 1228 # True iff FILE is a libtool `.la' library or `.lo' object file.
adam@0 1229 # This function is only a basic sanity check; it will hardly flush out
adam@0 1230 # determined imposters.
adam@0 1231 func_lalib_p ()
adam@0 1232 {
adam@0 1233 test -f "$1" &&
adam@0 1234 $SED -e 4q "$1" 2>/dev/null \
adam@0 1235 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
adam@0 1236 }
adam@0 1237
adam@0 1238 # func_lalib_unsafe_p file
adam@0 1239 # True iff FILE is a libtool `.la' library or `.lo' object file.
adam@0 1240 # This function implements the same check as func_lalib_p without
adam@0 1241 # resorting to external programs. To this end, it redirects stdin and
adam@0 1242 # closes it afterwards, without saving the original file descriptor.
adam@0 1243 # As a safety measure, use it only where a negative result would be
adam@0 1244 # fatal anyway. Works if `file' does not exist.
adam@0 1245 func_lalib_unsafe_p ()
adam@0 1246 {
adam@0 1247 lalib_p=no
adam@0 1248 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
adam@0 1249 for lalib_p_l in 1 2 3 4
adam@0 1250 do
adam@0 1251 read lalib_p_line
adam@0 1252 case "$lalib_p_line" in
adam@0 1253 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
adam@0 1254 esac
adam@0 1255 done
adam@0 1256 exec 0<&5 5<&-
adam@0 1257 fi
adam@0 1258 test "$lalib_p" = yes
adam@0 1259 }
adam@0 1260
adam@0 1261 # func_ltwrapper_script_p file
adam@0 1262 # True iff FILE is a libtool wrapper script
adam@0 1263 # This function is only a basic sanity check; it will hardly flush out
adam@0 1264 # determined imposters.
adam@0 1265 func_ltwrapper_script_p ()
adam@0 1266 {
adam@0 1267 func_lalib_p "$1"
adam@0 1268 }
adam@0 1269
adam@0 1270 # func_ltwrapper_executable_p file
adam@0 1271 # True iff FILE is a libtool wrapper executable
adam@0 1272 # This function is only a basic sanity check; it will hardly flush out
adam@0 1273 # determined imposters.
adam@0 1274 func_ltwrapper_executable_p ()
adam@0 1275 {
adam@0 1276 func_ltwrapper_exec_suffix=
adam@0 1277 case $1 in
adam@0 1278 *.exe) ;;
adam@0 1279 *) func_ltwrapper_exec_suffix=.exe ;;
adam@0 1280 esac
adam@0 1281 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
adam@0 1282 }
adam@0 1283
adam@0 1284 # func_ltwrapper_scriptname file
adam@0 1285 # Assumes file is an ltwrapper_executable
adam@0 1286 # uses $file to determine the appropriate filename for a
adam@0 1287 # temporary ltwrapper_script.
adam@0 1288 func_ltwrapper_scriptname ()
adam@0 1289 {
adam@12 1290 func_dirname_and_basename "$1" "" "."
adam@12 1291 func_stripname '' '.exe' "$func_basename_result"
adam@12 1292 func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
adam@0 1293 }
adam@0 1294
adam@0 1295 # func_ltwrapper_p file
adam@0 1296 # True iff FILE is a libtool wrapper script or wrapper executable
adam@0 1297 # This function is only a basic sanity check; it will hardly flush out
adam@0 1298 # determined imposters.
adam@0 1299 func_ltwrapper_p ()
adam@0 1300 {
adam@0 1301 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
adam@0 1302 }
adam@0 1303
adam@0 1304
adam@0 1305 # func_execute_cmds commands fail_cmd
adam@0 1306 # Execute tilde-delimited COMMANDS.
adam@0 1307 # If FAIL_CMD is given, eval that upon failure.
adam@0 1308 # FAIL_CMD may read-access the current command in variable CMD!
adam@0 1309 func_execute_cmds ()
adam@0 1310 {
adam@0 1311 $opt_debug
adam@0 1312 save_ifs=$IFS; IFS='~'
adam@0 1313 for cmd in $1; do
adam@0 1314 IFS=$save_ifs
adam@0 1315 eval cmd=\"$cmd\"
adam@0 1316 func_show_eval "$cmd" "${2-:}"
adam@0 1317 done
adam@0 1318 IFS=$save_ifs
adam@0 1319 }
adam@0 1320
adam@0 1321
adam@0 1322 # func_source file
adam@0 1323 # Source FILE, adding directory component if necessary.
adam@0 1324 # Note that it is not necessary on cygwin/mingw to append a dot to
adam@0 1325 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
adam@0 1326 # behavior happens only for exec(3), not for open(2)! Also, sourcing
adam@0 1327 # `FILE.' does not work on cygwin managed mounts.
adam@0 1328 func_source ()
adam@0 1329 {
adam@0 1330 $opt_debug
adam@0 1331 case $1 in
adam@0 1332 */* | *\\*) . "$1" ;;
adam@0 1333 *) . "./$1" ;;
adam@0 1334 esac
adam@0 1335 }
adam@0 1336
adam@0 1337
adam@12 1338 # func_resolve_sysroot PATH
adam@12 1339 # Replace a leading = in PATH with a sysroot. Store the result into
adam@12 1340 # func_resolve_sysroot_result
adam@12 1341 func_resolve_sysroot ()
adam@12 1342 {
adam@12 1343 func_resolve_sysroot_result=$1
adam@12 1344 case $func_resolve_sysroot_result in
adam@12 1345 =*)
adam@12 1346 func_stripname '=' '' "$func_resolve_sysroot_result"
adam@12 1347 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
adam@12 1348 ;;
adam@12 1349 esac
adam@12 1350 }
adam@12 1351
adam@12 1352 # func_replace_sysroot PATH
adam@12 1353 # If PATH begins with the sysroot, replace it with = and
adam@12 1354 # store the result into func_replace_sysroot_result.
adam@12 1355 func_replace_sysroot ()
adam@12 1356 {
adam@12 1357 case "$lt_sysroot:$1" in
adam@12 1358 ?*:"$lt_sysroot"*)
adam@12 1359 func_stripname "$lt_sysroot" '' "$1"
adam@12 1360 func_replace_sysroot_result="=$func_stripname_result"
adam@12 1361 ;;
adam@12 1362 *)
adam@12 1363 # Including no sysroot.
adam@12 1364 func_replace_sysroot_result=$1
adam@12 1365 ;;
adam@12 1366 esac
adam@12 1367 }
adam@12 1368
adam@0 1369 # func_infer_tag arg
adam@0 1370 # Infer tagged configuration to use if any are available and
adam@0 1371 # if one wasn't chosen via the "--tag" command line option.
adam@0 1372 # Only attempt this if the compiler in the base compile
adam@0 1373 # command doesn't match the default compiler.
adam@0 1374 # arg is usually of the form 'gcc ...'
adam@0 1375 func_infer_tag ()
adam@0 1376 {
adam@0 1377 $opt_debug
adam@0 1378 if test -n "$available_tags" && test -z "$tagname"; then
adam@0 1379 CC_quoted=
adam@0 1380 for arg in $CC; do
adam@12 1381 func_append_quoted CC_quoted "$arg"
adam@0 1382 done
adam@12 1383 CC_expanded=`func_echo_all $CC`
adam@12 1384 CC_quoted_expanded=`func_echo_all $CC_quoted`
adam@0 1385 case $@ in
adam@0 1386 # Blanks in the command may have been stripped by the calling shell,
adam@0 1387 # but not from the CC environment variable when configure was run.
adam@12 1388 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
adam@12 1389 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
adam@0 1390 # Blanks at the start of $base_compile will cause this to fail
adam@0 1391 # if we don't check for them as well.
adam@0 1392 *)
adam@0 1393 for z in $available_tags; do
adam@0 1394 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
adam@0 1395 # Evaluate the configuration.
adam@0 1396 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
adam@0 1397 CC_quoted=
adam@0 1398 for arg in $CC; do
adam@0 1399 # Double-quote args containing other shell metacharacters.
adam@12 1400 func_append_quoted CC_quoted "$arg"
adam@0 1401 done
adam@12 1402 CC_expanded=`func_echo_all $CC`
adam@12 1403 CC_quoted_expanded=`func_echo_all $CC_quoted`
adam@0 1404 case "$@ " in
adam@12 1405 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
adam@12 1406 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
adam@0 1407 # The compiler in the base compile command matches
adam@0 1408 # the one in the tagged configuration.
adam@0 1409 # Assume this is the tagged configuration we want.
adam@0 1410 tagname=$z
adam@0 1411 break
adam@0 1412 ;;
adam@0 1413 esac
adam@0 1414 fi
adam@0 1415 done
adam@0 1416 # If $tagname still isn't set, then no tagged configuration
adam@0 1417 # was found and let the user know that the "--tag" command
adam@0 1418 # line option must be used.
adam@0 1419 if test -z "$tagname"; then
adam@0 1420 func_echo "unable to infer tagged configuration"
adam@0 1421 func_fatal_error "specify a tag with \`--tag'"
adam@0 1422 # else
adam@0 1423 # func_verbose "using $tagname tagged configuration"
adam@0 1424 fi
adam@0 1425 ;;
adam@0 1426 esac
adam@0 1427 fi
adam@0 1428 }
adam@0 1429
adam@0 1430
adam@0 1431
adam@0 1432 # func_write_libtool_object output_name pic_name nonpic_name
adam@0 1433 # Create a libtool object file (analogous to a ".la" file),
adam@0 1434 # but don't create it if we're doing a dry run.
adam@0 1435 func_write_libtool_object ()
adam@0 1436 {
adam@0 1437 write_libobj=${1}
adam@0 1438 if test "$build_libtool_libs" = yes; then
adam@0 1439 write_lobj=\'${2}\'
adam@0 1440 else
adam@0 1441 write_lobj=none
adam@0 1442 fi
adam@0 1443
adam@0 1444 if test "$build_old_libs" = yes; then
adam@0 1445 write_oldobj=\'${3}\'
adam@0 1446 else
adam@0 1447 write_oldobj=none
adam@0 1448 fi
adam@0 1449
adam@0 1450 $opt_dry_run || {
adam@0 1451 cat >${write_libobj}T <<EOF
adam@0 1452 # $write_libobj - a libtool object file
adam@0 1453 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
adam@0 1454 #
adam@0 1455 # Please DO NOT delete this file!
adam@0 1456 # It is necessary for linking the library.
adam@0 1457
adam@0 1458 # Name of the PIC object.
adam@0 1459 pic_object=$write_lobj
adam@0 1460
adam@0 1461 # Name of the non-PIC object
adam@0 1462 non_pic_object=$write_oldobj
adam@0 1463
adam@0 1464 EOF
adam@0 1465 $MV "${write_libobj}T" "${write_libobj}"
adam@0 1466 }
adam@0 1467 }
adam@0 1468
adam@12 1469
adam@12 1470 ##################################################
adam@12 1471 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
adam@12 1472 ##################################################
adam@12 1473
adam@12 1474 # func_convert_core_file_wine_to_w32 ARG
adam@12 1475 # Helper function used by file name conversion functions when $build is *nix,
adam@12 1476 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
adam@12 1477 # correctly configured wine environment available, with the winepath program
adam@12 1478 # in $build's $PATH.
adam@12 1479 #
adam@12 1480 # ARG is the $build file name to be converted to w32 format.
adam@12 1481 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
adam@12 1482 # be empty on error (or when ARG is empty)
adam@12 1483 func_convert_core_file_wine_to_w32 ()
adam@12 1484 {
adam@12 1485 $opt_debug
adam@12 1486 func_convert_core_file_wine_to_w32_result="$1"
adam@12 1487 if test -n "$1"; then
adam@12 1488 # Unfortunately, winepath does not exit with a non-zero error code, so we
adam@12 1489 # are forced to check the contents of stdout. On the other hand, if the
adam@12 1490 # command is not found, the shell will set an exit code of 127 and print
adam@12 1491 # *an error message* to stdout. So we must check for both error code of
adam@12 1492 # zero AND non-empty stdout, which explains the odd construction:
adam@12 1493 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
adam@12 1494 if test "$?" -eq 0 && test -n "${func_convert_core_file_wine_to_w32_tmp}"; then
adam@12 1495 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
adam@12 1496 $SED -e "$lt_sed_naive_backslashify"`
adam@12 1497 else
adam@12 1498 func_convert_core_file_wine_to_w32_result=
adam@12 1499 fi
adam@12 1500 fi
adam@12 1501 }
adam@12 1502 # end: func_convert_core_file_wine_to_w32
adam@12 1503
adam@12 1504
adam@12 1505 # func_convert_core_path_wine_to_w32 ARG
adam@12 1506 # Helper function used by path conversion functions when $build is *nix, and
adam@12 1507 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
adam@12 1508 # configured wine environment available, with the winepath program in $build's
adam@12 1509 # $PATH. Assumes ARG has no leading or trailing path separator characters.
adam@12 1510 #
adam@12 1511 # ARG is path to be converted from $build format to win32.
adam@12 1512 # Result is available in $func_convert_core_path_wine_to_w32_result.
adam@12 1513 # Unconvertible file (directory) names in ARG are skipped; if no directory names
adam@12 1514 # are convertible, then the result may be empty.
adam@12 1515 func_convert_core_path_wine_to_w32 ()
adam@12 1516 {
adam@12 1517 $opt_debug
adam@12 1518 # unfortunately, winepath doesn't convert paths, only file names
adam@12 1519 func_convert_core_path_wine_to_w32_result=""
adam@12 1520 if test -n "$1"; then
adam@12 1521 oldIFS=$IFS
adam@12 1522 IFS=:
adam@12 1523 for func_convert_core_path_wine_to_w32_f in $1; do
adam@12 1524 IFS=$oldIFS
adam@12 1525 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
adam@12 1526 if test -n "$func_convert_core_file_wine_to_w32_result" ; then
adam@12 1527 if test -z "$func_convert_core_path_wine_to_w32_result"; then
adam@12 1528 func_convert_core_path_wine_to_w32_result="$func_convert_core_file_wine_to_w32_result"
adam@12 1529 else
adam@12 1530 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
adam@12 1531 fi
adam@12 1532 fi
adam@12 1533 done
adam@12 1534 IFS=$oldIFS
adam@12 1535 fi
adam@12 1536 }
adam@12 1537 # end: func_convert_core_path_wine_to_w32
adam@12 1538
adam@12 1539
adam@12 1540 # func_cygpath ARGS...
adam@12 1541 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
adam@12 1542 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
adam@12 1543 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
adam@12 1544 # (2), returns the Cygwin file name or path in func_cygpath_result (input
adam@12 1545 # file name or path is assumed to be in w32 format, as previously converted
adam@12 1546 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
adam@12 1547 # or path in func_cygpath_result (input file name or path is assumed to be in
adam@12 1548 # Cygwin format). Returns an empty string on error.
adam@12 1549 #
adam@12 1550 # ARGS are passed to cygpath, with the last one being the file name or path to
adam@12 1551 # be converted.
adam@12 1552 #
adam@12 1553 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
adam@12 1554 # environment variable; do not put it in $PATH.
adam@12 1555 func_cygpath ()
adam@12 1556 {
adam@12 1557 $opt_debug
adam@12 1558 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
adam@12 1559 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
adam@12 1560 if test "$?" -ne 0; then
adam@12 1561 # on failure, ensure result is empty
adam@12 1562 func_cygpath_result=
adam@12 1563 fi
adam@12 1564 else
adam@12 1565 func_cygpath_result=
adam@12 1566 func_error "LT_CYGPATH is empty or specifies non-existent file: \`$LT_CYGPATH'"
adam@12 1567 fi
adam@12 1568 }
adam@12 1569 #end: func_cygpath
adam@12 1570
adam@12 1571
adam@12 1572 # func_convert_core_msys_to_w32 ARG
adam@12 1573 # Convert file name or path ARG from MSYS format to w32 format. Return
adam@12 1574 # result in func_convert_core_msys_to_w32_result.
adam@12 1575 func_convert_core_msys_to_w32 ()
adam@12 1576 {
adam@12 1577 $opt_debug
adam@12 1578 # awkward: cmd appends spaces to result
adam@12 1579 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
adam@12 1580 $SED -e 's/[ ]*$//' -e "$lt_sed_naive_backslashify"`
adam@12 1581 }
adam@12 1582 #end: func_convert_core_msys_to_w32
adam@12 1583
adam@12 1584
adam@12 1585 # func_convert_file_check ARG1 ARG2
adam@12 1586 # Verify that ARG1 (a file name in $build format) was converted to $host
adam@12 1587 # format in ARG2. Otherwise, emit an error message, but continue (resetting
adam@12 1588 # func_to_host_file_result to ARG1).
adam@12 1589 func_convert_file_check ()
adam@12 1590 {
adam@12 1591 $opt_debug
adam@12 1592 if test -z "$2" && test -n "$1" ; then
adam@12 1593 func_error "Could not determine host file name corresponding to"
adam@12 1594 func_error " \`$1'"
adam@12 1595 func_error "Continuing, but uninstalled executables may not work."
adam@12 1596 # Fallback:
adam@12 1597 func_to_host_file_result="$1"
adam@12 1598 fi
adam@12 1599 }
adam@12 1600 # end func_convert_file_check
adam@12 1601
adam@12 1602
adam@12 1603 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
adam@12 1604 # Verify that FROM_PATH (a path in $build format) was converted to $host
adam@12 1605 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
adam@12 1606 # func_to_host_file_result to a simplistic fallback value (see below).
adam@12 1607 func_convert_path_check ()
adam@12 1608 {
adam@12 1609 $opt_debug
adam@12 1610 if test -z "$4" && test -n "$3"; then
adam@12 1611 func_error "Could not determine the host path corresponding to"
adam@12 1612 func_error " \`$3'"
adam@12 1613 func_error "Continuing, but uninstalled executables may not work."
adam@12 1614 # Fallback. This is a deliberately simplistic "conversion" and
adam@12 1615 # should not be "improved". See libtool.info.
adam@12 1616 if test "x$1" != "x$2"; then
adam@12 1617 lt_replace_pathsep_chars="s|$1|$2|g"
adam@12 1618 func_to_host_path_result=`echo "$3" |
adam@12 1619 $SED -e "$lt_replace_pathsep_chars"`
adam@12 1620 else
adam@12 1621 func_to_host_path_result="$3"
adam@12 1622 fi
adam@12 1623 fi
adam@12 1624 }
adam@12 1625 # end func_convert_path_check
adam@12 1626
adam@12 1627
adam@12 1628 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
adam@12 1629 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
adam@12 1630 # and appending REPL if ORIG matches BACKPAT.
adam@12 1631 func_convert_path_front_back_pathsep ()
adam@12 1632 {
adam@12 1633 $opt_debug
adam@12 1634 case $4 in
adam@12 1635 $1 ) func_to_host_path_result="$3$func_to_host_path_result"
adam@12 1636 ;;
adam@12 1637 esac
adam@12 1638 case $4 in
adam@12 1639 $2 ) func_append func_to_host_path_result "$3"
adam@12 1640 ;;
adam@12 1641 esac
adam@12 1642 }
adam@12 1643 # end func_convert_path_front_back_pathsep
adam@12 1644
adam@12 1645
adam@12 1646 ##################################################
adam@12 1647 # $build to $host FILE NAME CONVERSION FUNCTIONS #
adam@12 1648 ##################################################
adam@12 1649 # invoked via `$to_host_file_cmd ARG'
adam@12 1650 #
adam@12 1651 # In each case, ARG is the path to be converted from $build to $host format.
adam@12 1652 # Result will be available in $func_to_host_file_result.
adam@12 1653
adam@12 1654
adam@12 1655 # func_to_host_file ARG
adam@12 1656 # Converts the file name ARG from $build format to $host format. Return result
adam@12 1657 # in func_to_host_file_result.
adam@12 1658 func_to_host_file ()
adam@12 1659 {
adam@12 1660 $opt_debug
adam@12 1661 $to_host_file_cmd "$1"
adam@12 1662 }
adam@12 1663 # end func_to_host_file
adam@12 1664
adam@12 1665
adam@12 1666 # func_to_tool_file ARG LAZY
adam@12 1667 # converts the file name ARG from $build format to toolchain format. Return
adam@12 1668 # result in func_to_tool_file_result. If the conversion in use is listed
adam@12 1669 # in (the comma separated) LAZY, no conversion takes place.
adam@12 1670 func_to_tool_file ()
adam@12 1671 {
adam@12 1672 $opt_debug
adam@12 1673 case ,$2, in
adam@12 1674 *,"$to_tool_file_cmd",*)
adam@12 1675 func_to_tool_file_result=$1
adam@12 1676 ;;
adam@12 1677 *)
adam@12 1678 $to_tool_file_cmd "$1"
adam@12 1679 func_to_tool_file_result=$func_to_host_file_result
adam@12 1680 ;;
adam@12 1681 esac
adam@12 1682 }
adam@12 1683 # end func_to_tool_file
adam@12 1684
adam@12 1685
adam@12 1686 # func_convert_file_noop ARG
adam@12 1687 # Copy ARG to func_to_host_file_result.
adam@12 1688 func_convert_file_noop ()
adam@12 1689 {
adam@12 1690 func_to_host_file_result="$1"
adam@12 1691 }
adam@12 1692 # end func_convert_file_noop
adam@12 1693
adam@12 1694
adam@12 1695 # func_convert_file_msys_to_w32 ARG
adam@12 1696 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
adam@12 1697 # conversion to w32 is not available inside the cwrapper. Returns result in
adam@12 1698 # func_to_host_file_result.
adam@12 1699 func_convert_file_msys_to_w32 ()
adam@12 1700 {
adam@12 1701 $opt_debug
adam@12 1702 func_to_host_file_result="$1"
adam@12 1703 if test -n "$1"; then
adam@12 1704 func_convert_core_msys_to_w32 "$1"
adam@12 1705 func_to_host_file_result="$func_convert_core_msys_to_w32_result"
adam@12 1706 fi
adam@12 1707 func_convert_file_check "$1" "$func_to_host_file_result"
adam@12 1708 }
adam@12 1709 # end func_convert_file_msys_to_w32
adam@12 1710
adam@12 1711
adam@12 1712 # func_convert_file_cygwin_to_w32 ARG
adam@12 1713 # Convert file name ARG from Cygwin to w32 format. Returns result in
adam@12 1714 # func_to_host_file_result.
adam@12 1715 func_convert_file_cygwin_to_w32 ()
adam@12 1716 {
adam@12 1717 $opt_debug
adam@12 1718 func_to_host_file_result="$1"
adam@12 1719 if test -n "$1"; then
adam@12 1720 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
adam@12 1721 # LT_CYGPATH in this case.
adam@12 1722 func_to_host_file_result=`cygpath -m "$1"`
adam@12 1723 fi
adam@12 1724 func_convert_file_check "$1" "$func_to_host_file_result"
adam@12 1725 }
adam@12 1726 # end func_convert_file_cygwin_to_w32
adam@12 1727
adam@12 1728
adam@12 1729 # func_convert_file_nix_to_w32 ARG
adam@12 1730 # Convert file name ARG from *nix to w32 format. Requires a wine environment
adam@12 1731 # and a working winepath. Returns result in func_to_host_file_result.
adam@12 1732 func_convert_file_nix_to_w32 ()
adam@12 1733 {
adam@12 1734 $opt_debug
adam@12 1735 func_to_host_file_result="$1"
adam@12 1736 if test -n "$1"; then
adam@12 1737 func_convert_core_file_wine_to_w32 "$1"
adam@12 1738 func_to_host_file_result="$func_convert_core_file_wine_to_w32_result"
adam@12 1739 fi
adam@12 1740 func_convert_file_check "$1" "$func_to_host_file_result"
adam@12 1741 }
adam@12 1742 # end func_convert_file_nix_to_w32
adam@12 1743
adam@12 1744
adam@12 1745 # func_convert_file_msys_to_cygwin ARG
adam@12 1746 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
adam@12 1747 # Returns result in func_to_host_file_result.
adam@12 1748 func_convert_file_msys_to_cygwin ()
adam@12 1749 {
adam@12 1750 $opt_debug
adam@12 1751 func_to_host_file_result="$1"
adam@12 1752 if test -n "$1"; then
adam@12 1753 func_convert_core_msys_to_w32 "$1"
adam@12 1754 func_cygpath -u "$func_convert_core_msys_to_w32_result"
adam@12 1755 func_to_host_file_result="$func_cygpath_result"
adam@12 1756 fi
adam@12 1757 func_convert_file_check "$1" "$func_to_host_file_result"
adam@12 1758 }
adam@12 1759 # end func_convert_file_msys_to_cygwin
adam@12 1760
adam@12 1761
adam@12 1762 # func_convert_file_nix_to_cygwin ARG
adam@12 1763 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
adam@12 1764 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
adam@12 1765 # in func_to_host_file_result.
adam@12 1766 func_convert_file_nix_to_cygwin ()
adam@12 1767 {
adam@12 1768 $opt_debug
adam@12 1769 func_to_host_file_result="$1"
adam@12 1770 if test -n "$1"; then
adam@12 1771 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
adam@12 1772 func_convert_core_file_wine_to_w32 "$1"
adam@12 1773 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
adam@12 1774 func_to_host_file_result="$func_cygpath_result"
adam@12 1775 fi
adam@12 1776 func_convert_file_check "$1" "$func_to_host_file_result"
adam@12 1777 }
adam@12 1778 # end func_convert_file_nix_to_cygwin
adam@12 1779
adam@12 1780
adam@12 1781 #############################################
adam@12 1782 # $build to $host PATH CONVERSION FUNCTIONS #
adam@12 1783 #############################################
adam@12 1784 # invoked via `$to_host_path_cmd ARG'
adam@12 1785 #
adam@12 1786 # In each case, ARG is the path to be converted from $build to $host format.
adam@12 1787 # The result will be available in $func_to_host_path_result.
adam@12 1788 #
adam@12 1789 # Path separators are also converted from $build format to $host format. If
adam@12 1790 # ARG begins or ends with a path separator character, it is preserved (but
adam@12 1791 # converted to $host format) on output.
adam@12 1792 #
adam@12 1793 # All path conversion functions are named using the following convention:
adam@12 1794 # file name conversion function : func_convert_file_X_to_Y ()
adam@12 1795 # path conversion function : func_convert_path_X_to_Y ()
adam@12 1796 # where, for any given $build/$host combination the 'X_to_Y' value is the
adam@12 1797 # same. If conversion functions are added for new $build/$host combinations,
adam@12 1798 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
adam@12 1799 # will break.
adam@12 1800
adam@12 1801
adam@12 1802 # func_init_to_host_path_cmd
adam@12 1803 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
adam@12 1804 # appropriate value, based on the value of $to_host_file_cmd.
adam@12 1805 to_host_path_cmd=
adam@12 1806 func_init_to_host_path_cmd ()
adam@12 1807 {
adam@12 1808 $opt_debug
adam@12 1809 if test -z "$to_host_path_cmd"; then
adam@12 1810 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
adam@12 1811 to_host_path_cmd="func_convert_path_${func_stripname_result}"
adam@12 1812 fi
adam@12 1813 }
adam@12 1814
adam@12 1815
adam@12 1816 # func_to_host_path ARG
adam@12 1817 # Converts the path ARG from $build format to $host format. Return result
adam@12 1818 # in func_to_host_path_result.
adam@12 1819 func_to_host_path ()
adam@12 1820 {
adam@12 1821 $opt_debug
adam@12 1822 func_init_to_host_path_cmd
adam@12 1823 $to_host_path_cmd "$1"
adam@12 1824 }
adam@12 1825 # end func_to_host_path
adam@12 1826
adam@12 1827
adam@12 1828 # func_convert_path_noop ARG
adam@12 1829 # Copy ARG to func_to_host_path_result.
adam@12 1830 func_convert_path_noop ()
adam@12 1831 {
adam@12 1832 func_to_host_path_result="$1"
adam@12 1833 }
adam@12 1834 # end func_convert_path_noop
adam@12 1835
adam@12 1836
adam@12 1837 # func_convert_path_msys_to_w32 ARG
adam@12 1838 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
adam@12 1839 # conversion to w32 is not available inside the cwrapper. Returns result in
adam@12 1840 # func_to_host_path_result.
adam@12 1841 func_convert_path_msys_to_w32 ()
adam@12 1842 {
adam@12 1843 $opt_debug
adam@12 1844 func_to_host_path_result="$1"
adam@12 1845 if test -n "$1"; then
adam@12 1846 # Remove leading and trailing path separator characters from ARG. MSYS
adam@12 1847 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
adam@12 1848 # and winepath ignores them completely.
adam@12 1849 func_stripname : : "$1"
adam@12 1850 func_to_host_path_tmp1=$func_stripname_result
adam@12 1851 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
adam@12 1852 func_to_host_path_result="$func_convert_core_msys_to_w32_result"
adam@12 1853 func_convert_path_check : ";" \
adam@12 1854 "$func_to_host_path_tmp1" "$func_to_host_path_result"
adam@12 1855 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
adam@12 1856 fi
adam@12 1857 }
adam@12 1858 # end func_convert_path_msys_to_w32
adam@12 1859
adam@12 1860
adam@12 1861 # func_convert_path_cygwin_to_w32 ARG
adam@12 1862 # Convert path ARG from Cygwin to w32 format. Returns result in
adam@12 1863 # func_to_host_file_result.
adam@12 1864 func_convert_path_cygwin_to_w32 ()
adam@12 1865 {
adam@12 1866 $opt_debug
adam@12 1867 func_to_host_path_result="$1"
adam@12 1868 if test -n "$1"; then
adam@12 1869 # See func_convert_path_msys_to_w32:
adam@12 1870 func_stripname : : "$1"
adam@12 1871 func_to_host_path_tmp1=$func_stripname_result
adam@12 1872 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
adam@12 1873 func_convert_path_check : ";" \
adam@12 1874 "$func_to_host_path_tmp1" "$func_to_host_path_result"
adam@12 1875 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
adam@12 1876 fi
adam@12 1877 }
adam@12 1878 # end func_convert_path_cygwin_to_w32
adam@12 1879
adam@12 1880
adam@12 1881 # func_convert_path_nix_to_w32 ARG
adam@12 1882 # Convert path ARG from *nix to w32 format. Requires a wine environment and
adam@12 1883 # a working winepath. Returns result in func_to_host_file_result.
adam@12 1884 func_convert_path_nix_to_w32 ()
adam@12 1885 {
adam@12 1886 $opt_debug
adam@12 1887 func_to_host_path_result="$1"
adam@12 1888 if test -n "$1"; then
adam@12 1889 # See func_convert_path_msys_to_w32:
adam@12 1890 func_stripname : : "$1"
adam@12 1891 func_to_host_path_tmp1=$func_stripname_result
adam@12 1892 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
adam@12 1893 func_to_host_path_result="$func_convert_core_path_wine_to_w32_result"
adam@12 1894 func_convert_path_check : ";" \
adam@12 1895 "$func_to_host_path_tmp1" "$func_to_host_path_result"
adam@12 1896 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
adam@12 1897 fi
adam@12 1898 }
adam@12 1899 # end func_convert_path_nix_to_w32
adam@12 1900
adam@12 1901
adam@12 1902 # func_convert_path_msys_to_cygwin ARG
adam@12 1903 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
adam@12 1904 # Returns result in func_to_host_file_result.
adam@12 1905 func_convert_path_msys_to_cygwin ()
adam@12 1906 {
adam@12 1907 $opt_debug
adam@12 1908 func_to_host_path_result="$1"
adam@12 1909 if test -n "$1"; then
adam@12 1910 # See func_convert_path_msys_to_w32:
adam@12 1911 func_stripname : : "$1"
adam@12 1912 func_to_host_path_tmp1=$func_stripname_result
adam@12 1913 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
adam@12 1914 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
adam@12 1915 func_to_host_path_result="$func_cygpath_result"
adam@12 1916 func_convert_path_check : : \
adam@12 1917 "$func_to_host_path_tmp1" "$func_to_host_path_result"
adam@12 1918 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
adam@12 1919 fi
adam@12 1920 }
adam@12 1921 # end func_convert_path_msys_to_cygwin
adam@12 1922
adam@12 1923
adam@12 1924 # func_convert_path_nix_to_cygwin ARG
adam@12 1925 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
adam@12 1926 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
adam@12 1927 # func_to_host_file_result.
adam@12 1928 func_convert_path_nix_to_cygwin ()
adam@12 1929 {
adam@12 1930 $opt_debug
adam@12 1931 func_to_host_path_result="$1"
adam@12 1932 if test -n "$1"; then
adam@12 1933 # Remove leading and trailing path separator characters from
adam@12 1934 # ARG. msys behavior is inconsistent here, cygpath turns them
adam@12 1935 # into '.;' and ';.', and winepath ignores them completely.
adam@12 1936 func_stripname : : "$1"
adam@12 1937 func_to_host_path_tmp1=$func_stripname_result
adam@12 1938 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
adam@12 1939 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
adam@12 1940 func_to_host_path_result="$func_cygpath_result"
adam@12 1941 func_convert_path_check : : \
adam@12 1942 "$func_to_host_path_tmp1" "$func_to_host_path_result"
adam@12 1943 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
adam@12 1944 fi
adam@12 1945 }
adam@12 1946 # end func_convert_path_nix_to_cygwin
adam@12 1947
adam@12 1948
adam@0 1949 # func_mode_compile arg...
adam@0 1950 func_mode_compile ()
adam@0 1951 {
adam@0 1952 $opt_debug
adam@0 1953 # Get the compilation command and the source file.
adam@0 1954 base_compile=
adam@0 1955 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
adam@0 1956 suppress_opt=yes
adam@0 1957 suppress_output=
adam@0 1958 arg_mode=normal
adam@0 1959 libobj=
adam@0 1960 later=
adam@0 1961 pie_flag=
adam@0 1962
adam@0 1963 for arg
adam@0 1964 do
adam@0 1965 case $arg_mode in
adam@0 1966 arg )
adam@0 1967 # do not "continue". Instead, add this to base_compile
adam@0 1968 lastarg="$arg"
adam@0 1969 arg_mode=normal
adam@0 1970 ;;
adam@0 1971
adam@0 1972 target )
adam@0 1973 libobj="$arg"
adam@0 1974 arg_mode=normal
adam@0 1975 continue
adam@0 1976 ;;
adam@0 1977
adam@0 1978 normal )
adam@0 1979 # Accept any command-line options.
adam@0 1980 case $arg in
adam@0 1981 -o)
adam@0 1982 test -n "$libobj" && \
adam@0 1983 func_fatal_error "you cannot specify \`-o' more than once"
adam@0 1984 arg_mode=target
adam@0 1985 continue
adam@0 1986 ;;
adam@0 1987
adam@0 1988 -pie | -fpie | -fPIE)
adam@12 1989 func_append pie_flag " $arg"
adam@0 1990 continue
adam@0 1991 ;;
adam@0 1992
adam@0 1993 -shared | -static | -prefer-pic | -prefer-non-pic)
adam@12 1994 func_append later " $arg"
adam@0 1995 continue
adam@0 1996 ;;
adam@0 1997
adam@0 1998 -no-suppress)
adam@0 1999 suppress_opt=no
adam@0 2000 continue
adam@0 2001 ;;
adam@0 2002
adam@0 2003 -Xcompiler)
adam@0 2004 arg_mode=arg # the next one goes into the "base_compile" arg list
adam@0 2005 continue # The current "srcfile" will either be retained or
adam@0 2006 ;; # replaced later. I would guess that would be a bug.
adam@0 2007
adam@0 2008 -Wc,*)
adam@0 2009 func_stripname '-Wc,' '' "$arg"
adam@0 2010 args=$func_stripname_result
adam@0 2011 lastarg=
adam@0 2012 save_ifs="$IFS"; IFS=','
adam@0 2013 for arg in $args; do
adam@0 2014 IFS="$save_ifs"
adam@12 2015 func_append_quoted lastarg "$arg"
adam@0 2016 done
adam@0 2017 IFS="$save_ifs"
adam@0 2018 func_stripname ' ' '' "$lastarg"
adam@0 2019 lastarg=$func_stripname_result
adam@0 2020
adam@0 2021 # Add the arguments to base_compile.
adam@12 2022 func_append base_compile " $lastarg"
adam@0 2023 continue
adam@0 2024 ;;
adam@0 2025
adam@0 2026 *)
adam@0 2027 # Accept the current argument as the source file.
adam@0 2028 # The previous "srcfile" becomes the current argument.
adam@0 2029 #
adam@0 2030 lastarg="$srcfile"
adam@0 2031 srcfile="$arg"
adam@0 2032 ;;
adam@0 2033 esac # case $arg
adam@0 2034 ;;
adam@0 2035 esac # case $arg_mode
adam@0 2036
adam@0 2037 # Aesthetically quote the previous argument.
adam@12 2038 func_append_quoted base_compile "$lastarg"
adam@0 2039 done # for arg
adam@0 2040
adam@0 2041 case $arg_mode in
adam@0 2042 arg)
adam@0 2043 func_fatal_error "you must specify an argument for -Xcompile"
adam@0 2044 ;;
adam@0 2045 target)
adam@0 2046 func_fatal_error "you must specify a target with \`-o'"
adam@0 2047 ;;
adam@0 2048 *)
adam@0 2049 # Get the name of the library object.
adam@0 2050 test -z "$libobj" && {
adam@0 2051 func_basename "$srcfile"
adam@0 2052 libobj="$func_basename_result"
adam@0 2053 }
adam@0 2054 ;;
adam@0 2055 esac
adam@0 2056
adam@0 2057 # Recognize several different file suffixes.
adam@0 2058 # If the user specifies -o file.o, it is replaced with file.lo
adam@0 2059 case $libobj in
adam@0 2060 *.[cCFSifmso] | \
adam@0 2061 *.ada | *.adb | *.ads | *.asm | \
adam@0 2062 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
adam@20 2063 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
adam@0 2064 func_xform "$libobj"
adam@0 2065 libobj=$func_xform_result
adam@0 2066 ;;
adam@0 2067 esac
adam@0 2068
adam@0 2069 case $libobj in
adam@0 2070 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
adam@0 2071 *)
adam@0 2072 func_fatal_error "cannot determine name of library object from \`$libobj'"
adam@0 2073 ;;
adam@0 2074 esac
adam@0 2075
adam@0 2076 func_infer_tag $base_compile
adam@0 2077
adam@0 2078 for arg in $later; do
adam@0 2079 case $arg in
adam@0 2080 -shared)
adam@0 2081 test "$build_libtool_libs" != yes && \
adam@0 2082 func_fatal_configuration "can not build a shared library"
adam@0 2083 build_old_libs=no
adam@0 2084 continue
adam@0 2085 ;;
adam@0 2086
adam@0 2087 -static)
adam@0 2088 build_libtool_libs=no
adam@0 2089 build_old_libs=yes
adam@0 2090 continue
adam@0 2091 ;;
adam@0 2092
adam@0 2093 -prefer-pic)
adam@0 2094 pic_mode=yes
adam@0 2095 continue
adam@0 2096 ;;
adam@0 2097
adam@0 2098 -prefer-non-pic)
adam@0 2099 pic_mode=no
adam@0 2100 continue
adam@0 2101 ;;
adam@0 2102 esac
adam@0 2103 done
adam@0 2104
adam@0 2105 func_quote_for_eval "$libobj"
adam@0 2106 test "X$libobj" != "X$func_quote_for_eval_result" \
adam@0 2107 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
adam@0 2108 && func_warning "libobj name \`$libobj' may not contain shell special characters."
adam@0 2109 func_dirname_and_basename "$obj" "/" ""
adam@0 2110 objname="$func_basename_result"
adam@0 2111 xdir="$func_dirname_result"
adam@0 2112 lobj=${xdir}$objdir/$objname
adam@0 2113
adam@0 2114 test -z "$base_compile" && \
adam@0 2115 func_fatal_help "you must specify a compilation command"
adam@0 2116
adam@0 2117 # Delete any leftover library objects.
adam@0 2118 if test "$build_old_libs" = yes; then
adam@0 2119 removelist="$obj $lobj $libobj ${libobj}T"
adam@0 2120 else
adam@0 2121 removelist="$lobj $libobj ${libobj}T"
adam@0 2122 fi
adam@0 2123
adam@0 2124 # On Cygwin there's no "real" PIC flag so we must build both object types
adam@0 2125 case $host_os in
adam@0 2126 cygwin* | mingw* | pw32* | os2* | cegcc*)
adam@0 2127 pic_mode=default
adam@0 2128 ;;
adam@0 2129 esac
adam@0 2130 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
adam@0 2131 # non-PIC code in shared libraries is not supported
adam@0 2132 pic_mode=default
adam@0 2133 fi
adam@0 2134
adam@0 2135 # Calculate the filename of the output object if compiler does
adam@0 2136 # not support -o with -c
adam@0 2137 if test "$compiler_c_o" = no; then
adam@12 2138 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.${objext}
adam@0 2139 lockfile="$output_obj.lock"
adam@0 2140 else
adam@0 2141 output_obj=
adam@0 2142 need_locks=no
adam@0 2143 lockfile=
adam@0 2144 fi
adam@0 2145
adam@0 2146 # Lock this critical section if it is needed
adam@0 2147 # We use this script file to make the link, it avoids creating a new file
adam@0 2148 if test "$need_locks" = yes; then
adam@0 2149 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
adam@0 2150 func_echo "Waiting for $lockfile to be removed"
adam@0 2151 sleep 2
adam@0 2152 done
adam@0 2153 elif test "$need_locks" = warn; then
adam@0 2154 if test -f "$lockfile"; then
adam@0 2155 $ECHO "\
adam@0 2156 *** ERROR, $lockfile exists and contains:
adam@0 2157 `cat $lockfile 2>/dev/null`
adam@0 2158
adam@0 2159 This indicates that another process is trying to use the same
adam@0 2160 temporary object file, and libtool could not work around it because
adam@0 2161 your compiler does not support \`-c' and \`-o' together. If you
adam@0 2162 repeat this compilation, it may succeed, by chance, but you had better
adam@0 2163 avoid parallel builds (make -j) in this platform, or get a better
adam@0 2164 compiler."
adam@0 2165
adam@0 2166 $opt_dry_run || $RM $removelist
adam@0 2167 exit $EXIT_FAILURE
adam@0 2168 fi
adam@12 2169 func_append removelist " $output_obj"
adam@0 2170 $ECHO "$srcfile" > "$lockfile"
adam@0 2171 fi
adam@0 2172
adam@0 2173 $opt_dry_run || $RM $removelist
adam@12 2174 func_append removelist " $lockfile"
adam@0 2175 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
adam@0 2176
adam@12 2177 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
adam@12 2178 srcfile=$func_to_tool_file_result
adam@0 2179 func_quote_for_eval "$srcfile"
adam@0 2180 qsrcfile=$func_quote_for_eval_result
adam@0 2181
adam@0 2182 # Only build a PIC object if we are building libtool libraries.
adam@0 2183 if test "$build_libtool_libs" = yes; then
adam@0 2184 # Without this assignment, base_compile gets emptied.
adam@0 2185 fbsd_hideous_sh_bug=$base_compile
adam@0 2186
adam@0 2187 if test "$pic_mode" != no; then
adam@0 2188 command="$base_compile $qsrcfile $pic_flag"
adam@0 2189 else
adam@0 2190 # Don't build PIC code
adam@0 2191 command="$base_compile $qsrcfile"
adam@0 2192 fi
adam@0 2193
adam@0 2194 func_mkdir_p "$xdir$objdir"
adam@0 2195
adam@0 2196 if test -z "$output_obj"; then
adam@0 2197 # Place PIC objects in $objdir
adam@12 2198 func_append command " -o $lobj"
adam@0 2199 fi
adam@0 2200
adam@0 2201 func_show_eval_locale "$command" \
adam@0 2202 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
adam@0 2203
adam@0 2204 if test "$need_locks" = warn &&
adam@0 2205 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
adam@0 2206 $ECHO "\
adam@0 2207 *** ERROR, $lockfile contains:
adam@0 2208 `cat $lockfile 2>/dev/null`
adam@0 2209
adam@0 2210 but it should contain:
adam@0 2211 $srcfile
adam@0 2212
adam@0 2213 This indicates that another process is trying to use the same
adam@0 2214 temporary object file, and libtool could not work around it because
adam@0 2215 your compiler does not support \`-c' and \`-o' together. If you
adam@0 2216 repeat this compilation, it may succeed, by chance, but you had better
adam@0 2217 avoid parallel builds (make -j) in this platform, or get a better
adam@0 2218 compiler."
adam@0 2219
adam@0 2220 $opt_dry_run || $RM $removelist
adam@0 2221 exit $EXIT_FAILURE
adam@0 2222 fi
adam@0 2223
adam@0 2224 # Just move the object if needed, then go on to compile the next one
adam@0 2225 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
adam@0 2226 func_show_eval '$MV "$output_obj" "$lobj"' \
adam@0 2227 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
adam@0 2228 fi
adam@0 2229
adam@0 2230 # Allow error messages only from the first compilation.
adam@0 2231 if test "$suppress_opt" = yes; then
adam@0 2232 suppress_output=' >/dev/null 2>&1'
adam@0 2233 fi
adam@0 2234 fi
adam@0 2235
adam@0 2236 # Only build a position-dependent object if we build old libraries.
adam@0 2237 if test "$build_old_libs" = yes; then
adam@0 2238 if test "$pic_mode" != yes; then
adam@0 2239 # Don't build PIC code
adam@0 2240 command="$base_compile $qsrcfile$pie_flag"
adam@0 2241 else
adam@0 2242 command="$base_compile $qsrcfile $pic_flag"
adam@0 2243 fi
adam@0 2244 if test "$compiler_c_o" = yes; then
adam@12 2245 func_append command " -o $obj"
adam@0 2246 fi
adam@0 2247
adam@0 2248 # Suppress compiler output if we already did a PIC compilation.
adam@12 2249 func_append command "$suppress_output"
adam@0 2250 func_show_eval_locale "$command" \
adam@0 2251 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
adam@0 2252
adam@0 2253 if test "$need_locks" = warn &&
adam@0 2254 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
adam@0 2255 $ECHO "\
adam@0 2256 *** ERROR, $lockfile contains:
adam@0 2257 `cat $lockfile 2>/dev/null`
adam@0 2258
adam@0 2259 but it should contain:
adam@0 2260 $srcfile
adam@0 2261
adam@0 2262 This indicates that another process is trying to use the same
adam@0 2263 temporary object file, and libtool could not work around it because
adam@0 2264 your compiler does not support \`-c' and \`-o' together. If you
adam@0 2265 repeat this compilation, it may succeed, by chance, but you had better
adam@0 2266 avoid parallel builds (make -j) in this platform, or get a better
adam@0 2267 compiler."
adam@0 2268
adam@0 2269 $opt_dry_run || $RM $removelist
adam@0 2270 exit $EXIT_FAILURE
adam@0 2271 fi
adam@0 2272
adam@0 2273 # Just move the object if needed
adam@0 2274 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
adam@0 2275 func_show_eval '$MV "$output_obj" "$obj"' \
adam@0 2276 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
adam@0 2277 fi
adam@0 2278 fi
adam@0 2279
adam@0 2280 $opt_dry_run || {
adam@0 2281 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
adam@0 2282
adam@0 2283 # Unlock the critical section if it was locked
adam@0 2284 if test "$need_locks" != no; then
adam@0 2285 removelist=$lockfile
adam@0 2286 $RM "$lockfile"
adam@0 2287 fi
adam@0 2288 }
adam@0 2289
adam@0 2290 exit $EXIT_SUCCESS
adam@0 2291 }
adam@0 2292
adam@0 2293 $opt_help || {
adam@12 2294 test "$opt_mode" = compile && func_mode_compile ${1+"$@"}
adam@0 2295 }
adam@0 2296
adam@0 2297 func_mode_help ()
adam@0 2298 {
adam@0 2299 # We need to display help for each of the modes.
adam@12 2300 case $opt_mode in
adam@0 2301 "")
adam@0 2302 # Generic help is extracted from the usage comments
adam@0 2303 # at the start of this file.
adam@0 2304 func_help
adam@0 2305 ;;
adam@0 2306
adam@0 2307 clean)
adam@0 2308 $ECHO \
adam@0 2309 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
adam@0 2310
adam@0 2311 Remove files from the build directory.
adam@0 2312
adam@0 2313 RM is the name of the program to use to delete files associated with each FILE
adam@0 2314 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
adam@0 2315 to RM.
adam@0 2316
adam@0 2317 If FILE is a libtool library, object or program, all the files associated
adam@0 2318 with it are deleted. Otherwise, only FILE itself is deleted using RM."
adam@0 2319 ;;
adam@0 2320
adam@0 2321 compile)
adam@0 2322 $ECHO \
adam@0 2323 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
adam@0 2324
adam@0 2325 Compile a source file into a libtool library object.
adam@0 2326
adam@0 2327 This mode accepts the following additional options:
adam@0 2328
adam@0 2329 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
adam@0 2330 -no-suppress do not suppress compiler output for multiple passes
adam@12 2331 -prefer-pic try to build PIC objects only
adam@12 2332 -prefer-non-pic try to build non-PIC objects only
adam@0 2333 -shared do not build a \`.o' file suitable for static linking
adam@0 2334 -static only build a \`.o' file suitable for static linking
adam@12 2335 -Wc,FLAG pass FLAG directly to the compiler
adam@0 2336
adam@0 2337 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
adam@0 2338 from the given SOURCEFILE.
adam@0 2339
adam@0 2340 The output file name is determined by removing the directory component from
adam@0 2341 SOURCEFILE, then substituting the C source code suffix \`.c' with the
adam@0 2342 library object suffix, \`.lo'."
adam@0 2343 ;;
adam@0 2344
adam@0 2345 execute)
adam@0 2346 $ECHO \
adam@0 2347 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
adam@0 2348
adam@0 2349 Automatically set library path, then run a program.
adam@0 2350
adam@0 2351 This mode accepts the following additional options:
adam@0 2352
adam@0 2353 -dlopen FILE add the directory containing FILE to the library path
adam@0 2354
adam@0 2355 This mode sets the library path environment variable according to \`-dlopen'
adam@0 2356 flags.
adam@0 2357
adam@0 2358 If any of the ARGS are libtool executable wrappers, then they are translated
adam@0 2359 into their corresponding uninstalled binary, and any of their required library
adam@0 2360 directories are added to the library path.
adam@0 2361
adam@0 2362 Then, COMMAND is executed, with ARGS as arguments."
adam@0 2363 ;;
adam@0 2364
adam@0 2365 finish)
adam@0 2366 $ECHO \
adam@0 2367 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
adam@0 2368
adam@0 2369 Complete the installation of libtool libraries.
adam@0 2370
adam@0 2371 Each LIBDIR is a directory that contains libtool libraries.
adam@0 2372
adam@0 2373 The commands that this mode executes may require superuser privileges. Use
adam@0 2374 the \`--dry-run' option if you just want to see what would be executed."
adam@0 2375 ;;
adam@0 2376
adam@0 2377 install)
adam@0 2378 $ECHO \
adam@0 2379 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
adam@0 2380
adam@0 2381 Install executables or libraries.
adam@0 2382
adam@0 2383 INSTALL-COMMAND is the installation command. The first component should be
adam@0 2384 either the \`install' or \`cp' program.
adam@0 2385
adam@0 2386 The following components of INSTALL-COMMAND are treated specially:
adam@0 2387
adam@12 2388 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
adam@0 2389
adam@0 2390 The rest of the components are interpreted as arguments to that command (only
adam@0 2391 BSD-compatible install options are recognized)."
adam@0 2392 ;;
adam@0 2393
adam@0 2394 link)
adam@0 2395 $ECHO \
adam@0 2396 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
adam@0 2397
adam@0 2398 Link object files or libraries together to form another library, or to
adam@0 2399 create an executable program.
adam@0 2400
adam@0 2401 LINK-COMMAND is a command using the C compiler that you would use to create
adam@0 2402 a program from several object files.
adam@0 2403
adam@0 2404 The following components of LINK-COMMAND are treated specially:
adam@0 2405
adam@0 2406 -all-static do not do any dynamic linking at all
adam@0 2407 -avoid-version do not add a version suffix if possible
adam@12 2408 -bindir BINDIR specify path to binaries directory (for systems where
adam@12 2409 libraries must be found in the PATH setting at runtime)
adam@0 2410 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
adam@0 2411 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
adam@0 2412 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
adam@0 2413 -export-symbols SYMFILE
adam@0 2414 try to export only the symbols listed in SYMFILE
adam@0 2415 -export-symbols-regex REGEX
adam@0 2416 try to export only the symbols matching REGEX
adam@0 2417 -LLIBDIR search LIBDIR for required installed libraries
adam@0 2418 -lNAME OUTPUT-FILE requires the installed library libNAME
adam@0 2419 -module build a library that can dlopened
adam@0 2420 -no-fast-install disable the fast-install mode
adam@0 2421 -no-install link a not-installable executable
adam@0 2422 -no-undefined declare that a library does not refer to external symbols
adam@0 2423 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
adam@0 2424 -objectlist FILE Use a list of object files found in FILE to specify objects
adam@0 2425 -precious-files-regex REGEX
adam@0 2426 don't remove output files matching REGEX
adam@0 2427 -release RELEASE specify package release information
adam@0 2428 -rpath LIBDIR the created library will eventually be installed in LIBDIR
adam@0 2429 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
adam@0 2430 -shared only do dynamic linking of libtool libraries
adam@0 2431 -shrext SUFFIX override the standard shared library file extension
adam@0 2432 -static do not do any dynamic linking of uninstalled libtool libraries
adam@0 2433 -static-libtool-libs
adam@0 2434 do not do any dynamic linking of libtool libraries
adam@0 2435 -version-info CURRENT[:REVISION[:AGE]]
adam@0 2436 specify library version info [each variable defaults to 0]
adam@0 2437 -weak LIBNAME declare that the target provides the LIBNAME interface
adam@12 2438 -Wc,FLAG
adam@12 2439 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
adam@12 2440 -Wl,FLAG
adam@12 2441 -Xlinker FLAG pass linker-specific FLAG directly to the linker
adam@12 2442 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
adam@0 2443
adam@0 2444 All other options (arguments beginning with \`-') are ignored.
adam@0 2445
adam@0 2446 Every other argument is treated as a filename. Files ending in \`.la' are
adam@0 2447 treated as uninstalled libtool libraries, other files are standard or library
adam@0 2448 object files.
adam@0 2449
adam@0 2450 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
adam@0 2451 only library objects (\`.lo' files) may be specified, and \`-rpath' is
adam@0 2452 required, except when creating a convenience library.
adam@0 2453
adam@0 2454 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
adam@0 2455 using \`ar' and \`ranlib', or on Windows using \`lib'.
adam@0 2456
adam@0 2457 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
adam@0 2458 is created, otherwise an executable program is created."
adam@0 2459 ;;
adam@0 2460
adam@0 2461 uninstall)
adam@0 2462 $ECHO \
adam@0 2463 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
adam@0 2464
adam@0 2465 Remove libraries from an installation directory.
adam@0 2466
adam@0 2467 RM is the name of the program to use to delete files associated with each FILE
adam@0 2468 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
adam@0 2469 to RM.
adam@0 2470
adam@0 2471 If FILE is a libtool library, all the files associated with it are deleted.
adam@0 2472 Otherwise, only FILE itself is deleted using RM."
adam@0 2473 ;;
adam@0 2474
adam@0 2475 *)
adam@12 2476 func_fatal_help "invalid operation mode \`$opt_mode'"
adam@0 2477 ;;
adam@0 2478 esac
adam@0 2479
adam@12 2480 echo
adam@0 2481 $ECHO "Try \`$progname --help' for more information about other modes."
adam@12 2482 }
adam@12 2483
adam@12 2484 # Now that we've collected a possible --mode arg, show help if necessary
adam@12 2485 if $opt_help; then
adam@12 2486 if test "$opt_help" = :; then
adam@12 2487 func_mode_help
adam@12 2488 else
adam@12 2489 {
adam@12 2490 func_help noexit
adam@12 2491 for opt_mode in compile link execute install finish uninstall clean; do
adam@12 2492 func_mode_help
adam@12 2493 done
adam@12 2494 } | sed -n '1p; 2,$s/^Usage:/ or: /p'
adam@12 2495 {
adam@12 2496 func_help noexit
adam@12 2497 for opt_mode in compile link execute install finish uninstall clean; do
adam@12 2498 echo
adam@12 2499 func_mode_help
adam@12 2500 done
adam@12 2501 } |
adam@12 2502 sed '1d
adam@12 2503 /^When reporting/,/^Report/{
adam@12 2504 H
adam@12 2505 d
adam@12 2506 }
adam@12 2507 $x
adam@12 2508 /information about other modes/d
adam@12 2509 /more detailed .*MODE/d
adam@12 2510 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
adam@12 2511 fi
adam@12 2512 exit $?
adam@12 2513 fi
adam@0 2514
adam@0 2515
adam@0 2516 # func_mode_execute arg...
adam@0 2517 func_mode_execute ()
adam@0 2518 {
adam@0 2519 $opt_debug
adam@0 2520 # The first argument is the command name.
adam@0 2521 cmd="$nonopt"
adam@0 2522 test -z "$cmd" && \
adam@0 2523 func_fatal_help "you must specify a COMMAND"
adam@0 2524
adam@0 2525 # Handle -dlopen flags immediately.
adam@12 2526 for file in $opt_dlopen; do
adam@0 2527 test -f "$file" \
adam@0 2528 || func_fatal_help "\`$file' is not a file"
adam@0 2529
adam@0 2530 dir=
adam@0 2531 case $file in
adam@0 2532 *.la)
adam@12 2533 func_resolve_sysroot "$file"
adam@12 2534 file=$func_resolve_sysroot_result
adam@12 2535
adam@0 2536 # Check to see that this really is a libtool archive.
adam@0 2537 func_lalib_unsafe_p "$file" \
adam@0 2538 || func_fatal_help "\`$lib' is not a valid libtool archive"
adam@0 2539
adam@0 2540 # Read the libtool library.
adam@0 2541 dlname=
adam@0 2542 library_names=
adam@0 2543 func_source "$file"
adam@0 2544
adam@0 2545 # Skip this library if it cannot be dlopened.
adam@0 2546 if test -z "$dlname"; then
adam@0 2547 # Warn if it was a shared library.
adam@0 2548 test -n "$library_names" && \
adam@0 2549 func_warning "\`$file' was not linked with \`-export-dynamic'"
adam@0 2550 continue
adam@0 2551 fi
adam@0 2552
adam@0 2553 func_dirname "$file" "" "."
adam@0 2554 dir="$func_dirname_result"
adam@0 2555
adam@0 2556 if test -f "$dir/$objdir/$dlname"; then
adam@12 2557 func_append dir "/$objdir"
adam@0 2558 else
adam@0 2559 if test ! -f "$dir/$dlname"; then
adam@0 2560 func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
adam@0 2561 fi
adam@0 2562 fi
adam@0 2563 ;;
adam@0 2564
adam@0 2565 *.lo)
adam@0 2566 # Just add the directory containing the .lo file.
adam@0 2567 func_dirname "$file" "" "."
adam@0 2568 dir="$func_dirname_result"
adam@0 2569 ;;
adam@0 2570
adam@0 2571 *)
adam@0 2572 func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
adam@0 2573 continue
adam@0 2574 ;;
adam@0 2575 esac
adam@0 2576
adam@0 2577 # Get the absolute pathname.
adam@0 2578 absdir=`cd "$dir" && pwd`
adam@0 2579 test -n "$absdir" && dir="$absdir"
adam@0 2580
adam@0 2581 # Now add the directory to shlibpath_var.
adam@0 2582 if eval "test -z \"\$$shlibpath_var\""; then
adam@0 2583 eval "$shlibpath_var=\"\$dir\""
adam@0 2584 else
adam@0 2585 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
adam@0 2586 fi
adam@0 2587 done
adam@0 2588
adam@0 2589 # This variable tells wrapper scripts just to set shlibpath_var
adam@0 2590 # rather than running their programs.
adam@0 2591 libtool_execute_magic="$magic"
adam@0 2592
adam@0 2593 # Check if any of the arguments is a wrapper script.
adam@0 2594 args=
adam@0 2595 for file
adam@0 2596 do
adam@0 2597 case $file in
adam@12 2598 -* | *.la | *.lo ) ;;
adam@0 2599 *)
adam@0 2600 # Do a test to see if this is really a libtool program.
adam@0 2601 if func_ltwrapper_script_p "$file"; then
adam@0 2602 func_source "$file"
adam@0 2603 # Transform arg to wrapped name.
adam@0 2604 file="$progdir/$program"
adam@0 2605 elif func_ltwrapper_executable_p "$file"; then
adam@0 2606 func_ltwrapper_scriptname "$file"
adam@0 2607 func_source "$func_ltwrapper_scriptname_result"
adam@0 2608 # Transform arg to wrapped name.
adam@0 2609 file="$progdir/$program"
adam@0 2610 fi
adam@0 2611 ;;
adam@0 2612 esac
adam@0 2613 # Quote arguments (to preserve shell metacharacters).
adam@12 2614 func_append_quoted args "$file"
adam@0 2615 done
adam@0 2616
adam@0 2617 if test "X$opt_dry_run" = Xfalse; then
adam@0 2618 if test -n "$shlibpath_var"; then
adam@0 2619 # Export the shlibpath_var.
adam@0 2620 eval "export $shlibpath_var"
adam@0 2621 fi
adam@0 2622
adam@0 2623 # Restore saved environment variables
adam@0 2624 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
adam@0 2625 do
adam@0 2626 eval "if test \"\${save_$lt_var+set}\" = set; then
adam@0 2627 $lt_var=\$save_$lt_var; export $lt_var
adam@0 2628 else
adam@0 2629 $lt_unset $lt_var
adam@0 2630 fi"
adam@0 2631 done
adam@0 2632
adam@0 2633 # Now prepare to actually exec the command.
adam@0 2634 exec_cmd="\$cmd$args"
adam@0 2635 else
adam@0 2636 # Display what would be done.
adam@0 2637 if test -n "$shlibpath_var"; then
adam@0 2638 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
adam@12 2639 echo "export $shlibpath_var"
adam@0 2640 fi
adam@0 2641 $ECHO "$cmd$args"
adam@0 2642 exit $EXIT_SUCCESS
adam@0 2643 fi
adam@0 2644 }
adam@0 2645
adam@12 2646 test "$opt_mode" = execute && func_mode_execute ${1+"$@"}
adam@0 2647
adam@0 2648
adam@0 2649 # func_mode_finish arg...
adam@0 2650 func_mode_finish ()
adam@0 2651 {
adam@0 2652 $opt_debug
adam@12 2653 libs=
adam@12 2654 libdirs=
adam@0 2655 admincmds=
adam@0 2656
adam@12 2657 for opt in "$nonopt" ${1+"$@"}
adam@12 2658 do
adam@12 2659 if test -d "$opt"; then
adam@12 2660 func_append libdirs " $opt"
adam@12 2661
adam@12 2662 elif test -f "$opt"; then
adam@12 2663 if func_lalib_unsafe_p "$opt"; then
adam@12 2664 func_append libs " $opt"
adam@12 2665 else
adam@12 2666 func_warning "\`$opt' is not a valid libtool archive"
adam@12 2667 fi
adam@12 2668
adam@12 2669 else
adam@12 2670 func_fatal_error "invalid argument \`$opt'"
adam@12 2671 fi
adam@12 2672 done
adam@12 2673
adam@12 2674 if test -n "$libs"; then
adam@12 2675 if test -n "$lt_sysroot"; then
adam@12 2676 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
adam@12 2677 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
adam@12 2678 else
adam@12 2679 sysroot_cmd=
adam@12 2680 fi
adam@12 2681
adam@12 2682 # Remove sysroot references
adam@12 2683 if $opt_dry_run; then
adam@12 2684 for lib in $libs; do
adam@12 2685 echo "removing references to $lt_sysroot and \`=' prefixes from $lib"
adam@12 2686 done
adam@12 2687 else
adam@12 2688 tmpdir=`func_mktempdir`
adam@12 2689 for lib in $libs; do
adam@12 2690 sed -e "${sysroot_cmd} s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
adam@12 2691 > $tmpdir/tmp-la
adam@12 2692 mv -f $tmpdir/tmp-la $lib
adam@12 2693 done
adam@12 2694 ${RM}r "$tmpdir"
adam@12 2695 fi
adam@12 2696 fi
adam@12 2697
adam@0 2698 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
adam@0 2699 for libdir in $libdirs; do
adam@0 2700 if test -n "$finish_cmds"; then
adam@0 2701 # Do each command in the finish commands.
adam@0 2702 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
adam@0 2703 '"$cmd"'"'
adam@0 2704 fi
adam@0 2705 if test -n "$finish_eval"; then
adam@0 2706 # Do the single finish_eval.
adam@0 2707 eval cmds=\"$finish_eval\"
adam@12 2708 $opt_dry_run || eval "$cmds" || func_append admincmds "
adam@0 2709 $cmds"
adam@0 2710 fi
adam@0 2711 done
adam@0 2712 fi
adam@0 2713
adam@0 2714 # Exit here if they wanted silent mode.
adam@0 2715 $opt_silent && exit $EXIT_SUCCESS
adam@0 2716
adam@12 2717 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
adam@12 2718 echo "----------------------------------------------------------------------"
adam@12 2719 echo "Libraries have been installed in:"
adam@12 2720 for libdir in $libdirs; do
adam@12 2721 $ECHO " $libdir"
adam@12 2722 done
adam@12 2723 echo
adam@12 2724 echo "If you ever happen to want to link against installed libraries"
adam@12 2725 echo "in a given directory, LIBDIR, you must either use libtool, and"
adam@12 2726 echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
adam@12 2727 echo "flag during linking and do at least one of the following:"
adam@12 2728 if test -n "$shlibpath_var"; then
adam@12 2729 echo " - add LIBDIR to the \`$shlibpath_var' environment variable"
adam@12 2730 echo " during execution"
adam@12 2731 fi
adam@12 2732 if test -n "$runpath_var"; then
adam@12 2733 echo " - add LIBDIR to the \`$runpath_var' environment variable"
adam@12 2734 echo " during linking"
adam@12 2735 fi
adam@12 2736 if test -n "$hardcode_libdir_flag_spec"; then
adam@12 2737 libdir=LIBDIR
adam@12 2738 eval flag=\"$hardcode_libdir_flag_spec\"
adam@12 2739
adam@12 2740 $ECHO " - use the \`$flag' linker flag"
adam@12 2741 fi
adam@12 2742 if test -n "$admincmds"; then
adam@12 2743 $ECHO " - have your system administrator run these commands:$admincmds"
adam@12 2744 fi
adam@12 2745 if test -f /etc/ld.so.conf; then
adam@12 2746 echo " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
adam@12 2747 fi
adam@12 2748 echo
adam@12 2749
adam@12 2750 echo "See any operating system documentation about shared libraries for"
adam@12 2751 case $host in
adam@12 2752 solaris2.[6789]|solaris2.1[0-9])
adam@12 2753 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
adam@12 2754 echo "pages."
adam@12 2755 ;;
adam@12 2756 *)
adam@12 2757 echo "more information, such as the ld(1) and ld.so(8) manual pages."
adam@12 2758 ;;
adam@12 2759 esac
adam@12 2760 echo "----------------------------------------------------------------------"
adam@0 2761 fi
adam@0 2762 exit $EXIT_SUCCESS
adam@0 2763 }
adam@0 2764
adam@12 2765 test "$opt_mode" = finish && func_mode_finish ${1+"$@"}
adam@0 2766
adam@0 2767
adam@0 2768 # func_mode_install arg...
adam@0 2769 func_mode_install ()
adam@0 2770 {
adam@0 2771 $opt_debug
adam@0 2772 # There may be an optional sh(1) argument at the beginning of
adam@0 2773 # install_prog (especially on Windows NT).
adam@0 2774 if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
adam@0 2775 # Allow the use of GNU shtool's install command.
adam@12 2776 case $nonopt in *shtool*) :;; *) false;; esac; then
adam@0 2777 # Aesthetically quote it.
adam@0 2778 func_quote_for_eval "$nonopt"
adam@0 2779 install_prog="$func_quote_for_eval_result "
adam@0 2780 arg=$1
adam@0 2781 shift
adam@0 2782 else
adam@0 2783 install_prog=
adam@0 2784 arg=$nonopt
adam@0 2785 fi
adam@0 2786
adam@0 2787 # The real first argument should be the name of the installation program.
adam@0 2788 # Aesthetically quote it.
adam@0 2789 func_quote_for_eval "$arg"
adam@12 2790 func_append install_prog "$func_quote_for_eval_result"
adam@12 2791 install_shared_prog=$install_prog
adam@12 2792 case " $install_prog " in
adam@12 2793 *[\\\ /]cp\ *) install_cp=: ;;
adam@12 2794 *) install_cp=false ;;
adam@12 2795 esac
adam@0 2796
adam@0 2797 # We need to accept at least all the BSD install flags.
adam@0 2798 dest=
adam@0 2799 files=
adam@0 2800 opts=
adam@0 2801 prev=
adam@0 2802 install_type=
adam@0 2803 isdir=no
adam@0 2804 stripme=
adam@12 2805 no_mode=:
adam@0 2806 for arg
adam@0 2807 do
adam@12 2808 arg2=
adam@0 2809 if test -n "$dest"; then
adam@12 2810 func_append files " $dest"
adam@0 2811 dest=$arg
adam@0 2812 continue
adam@0 2813 fi
adam@0 2814
adam@0 2815 case $arg in
adam@0 2816 -d) isdir=yes ;;
adam@0 2817 -f)
adam@12 2818 if $install_cp; then :; else
adam@12 2819 prev=$arg
adam@12 2820 fi
adam@0 2821 ;;
adam@0 2822 -g | -m | -o)
adam@0 2823 prev=$arg
adam@0 2824 ;;
adam@0 2825 -s)
adam@0 2826 stripme=" -s"
adam@0 2827 continue
adam@0 2828 ;;
adam@0 2829 -*)
adam@0 2830 ;;
adam@0 2831 *)
adam@0 2832 # If the previous option needed an argument, then skip it.
adam@0 2833 if test -n "$prev"; then
adam@12 2834 if test "x$prev" = x-m && test -n "$install_override_mode"; then
adam@12 2835 arg2=$install_override_mode
adam@12 2836 no_mode=false
adam@12 2837 fi
adam@0 2838 prev=
adam@0 2839 else
adam@0 2840 dest=$arg
adam@0 2841 continue
adam@0 2842 fi
adam@0 2843 ;;
adam@0 2844 esac
adam@0 2845
adam@0 2846 # Aesthetically quote the argument.
adam@0 2847 func_quote_for_eval "$arg"
adam@12 2848 func_append install_prog " $func_quote_for_eval_result"
adam@12 2849 if test -n "$arg2"; then
adam@12 2850 func_quote_for_eval "$arg2"
adam@12 2851 fi
adam@12 2852 func_append install_shared_prog " $func_quote_for_eval_result"
adam@0 2853 done
adam@0 2854
adam@0 2855 test -z "$install_prog" && \
adam@0 2856 func_fatal_help "you must specify an install program"
adam@0 2857
adam@0 2858 test -n "$prev" && \
adam@0 2859 func_fatal_help "the \`$prev' option requires an argument"
adam@0 2860
adam@12 2861 if test -n "$install_override_mode" && $no_mode; then
adam@12 2862 if $install_cp; then :; else
adam@12 2863 func_quote_for_eval "$install_override_mode"
adam@12 2864 func_append install_shared_prog " -m $func_quote_for_eval_result"
adam@12 2865 fi
adam@12 2866 fi
adam@12 2867
adam@0 2868 if test -z "$files"; then
adam@0 2869 if test -z "$dest"; then
adam@0 2870 func_fatal_help "no file or destination specified"
adam@0 2871 else
adam@0 2872 func_fatal_help "you must specify a destination"
adam@0 2873 fi
adam@0 2874 fi
adam@0 2875
adam@0 2876 # Strip any trailing slash from the destination.
adam@0 2877 func_stripname '' '/' "$dest"
adam@0 2878 dest=$func_stripname_result
adam@0 2879
adam@0 2880 # Check to see that the destination is a directory.
adam@0 2881 test -d "$dest" && isdir=yes
adam@0 2882 if test "$isdir" = yes; then
adam@0 2883 destdir="$dest"
adam@0 2884 destname=
adam@0 2885 else
adam@0 2886 func_dirname_and_basename "$dest" "" "."
adam@0 2887 destdir="$func_dirname_result"
adam@0 2888 destname="$func_basename_result"
adam@0 2889
adam@0 2890 # Not a directory, so check to see that there is only one file specified.
adam@0 2891 set dummy $files; shift
adam@0 2892 test "$#" -gt 1 && \
adam@0 2893 func_fatal_help "\`$dest' is not a directory"
adam@0 2894 fi
adam@0 2895 case $destdir in
adam@0 2896 [\\/]* | [A-Za-z]:[\\/]*) ;;
adam@0 2897 *)
adam@0 2898 for file in $files; do
adam@0 2899 case $file in
adam@0 2900 *.lo) ;;
adam@0 2901 *)
adam@0 2902 func_fatal_help "\`$destdir' must be an absolute directory name"
adam@0 2903 ;;
adam@0 2904 esac
adam@0 2905 done
adam@0 2906 ;;
adam@0 2907 esac
adam@0 2908
adam@0 2909 # This variable tells wrapper scripts just to set variables rather
adam@0 2910 # than running their programs.
adam@0 2911 libtool_install_magic="$magic"
adam@0 2912
adam@0 2913 staticlibs=
adam@0 2914 future_libdirs=
adam@0 2915 current_libdirs=
adam@0 2916 for file in $files; do
adam@0 2917
adam@0 2918 # Do each installation.
adam@0 2919 case $file in
adam@0 2920 *.$libext)
adam@0 2921 # Do the static libraries later.
adam@12 2922 func_append staticlibs " $file"
adam@0 2923 ;;
adam@0 2924
adam@0 2925 *.la)
adam@12 2926 func_resolve_sysroot "$file"
adam@12 2927 file=$func_resolve_sysroot_result
adam@12 2928
adam@0 2929 # Check to see that this really is a libtool archive.
adam@0 2930 func_lalib_unsafe_p "$file" \
adam@0 2931 || func_fatal_help "\`$file' is not a valid libtool archive"
adam@0 2932
adam@0 2933 library_names=
adam@0 2934 old_library=
adam@0 2935 relink_command=
adam@0 2936 func_source "$file"
adam@0 2937
adam@0 2938 # Add the libdir to current_libdirs if it is the destination.
adam@0 2939 if test "X$destdir" = "X$libdir"; then
adam@0 2940 case "$current_libdirs " in
adam@0 2941 *" $libdir "*) ;;
adam@12 2942 *) func_append current_libdirs " $libdir" ;;
adam@0 2943 esac
adam@0 2944 else
adam@0 2945 # Note the libdir as a future libdir.
adam@0 2946 case "$future_libdirs " in
adam@0 2947 *" $libdir "*) ;;
adam@12 2948 *) func_append future_libdirs " $libdir" ;;
adam@0 2949 esac
adam@0 2950 fi
adam@0 2951
adam@0 2952 func_dirname "$file" "/" ""
adam@0 2953 dir="$func_dirname_result"
adam@12 2954 func_append dir "$objdir"
adam@0 2955
adam@0 2956 if test -n "$relink_command"; then
adam@0 2957 # Determine the prefix the user has applied to our future dir.
adam@12 2958 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
adam@0 2959
adam@0 2960 # Don't allow the user to place us outside of our expected
adam@0 2961 # location b/c this prevents finding dependent libraries that
adam@0 2962 # are installed to the same prefix.
adam@0 2963 # At present, this check doesn't affect windows .dll's that
adam@0 2964 # are installed into $libdir/../bin (currently, that works fine)
adam@0 2965 # but it's something to keep an eye on.
adam@0 2966 test "$inst_prefix_dir" = "$destdir" && \
adam@0 2967 func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
adam@0 2968
adam@0 2969 if test -n "$inst_prefix_dir"; then
adam@0 2970 # Stick the inst_prefix_dir data into the link command.
adam@12 2971 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
adam@0 2972 else
adam@12 2973 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
adam@0 2974 fi
adam@0 2975
adam@0 2976 func_warning "relinking \`$file'"
adam@0 2977 func_show_eval "$relink_command" \
adam@0 2978 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
adam@0 2979 fi
adam@0 2980
adam@0 2981 # See the names of the shared library.
adam@0 2982 set dummy $library_names; shift
adam@0 2983 if test -n "$1"; then
adam@0 2984 realname="$1"
adam@0 2985 shift
adam@0 2986
adam@0 2987 srcname="$realname"
adam@0 2988 test -n "$relink_command" && srcname="$realname"T
adam@0 2989
adam@0 2990 # Install the shared library and build the symlinks.
adam@12 2991 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
adam@0 2992 'exit $?'
adam@0 2993 tstripme="$stripme"
adam@0 2994 case $host_os in
adam@0 2995 cygwin* | mingw* | pw32* | cegcc*)
adam@0 2996 case $realname in
adam@0 2997 *.dll.a)
adam@0 2998 tstripme=""
adam@0 2999 ;;
adam@0 3000 esac
adam@0 3001 ;;
adam@0 3002 esac
adam@0 3003 if test -n "$tstripme" && test -n "$striplib"; then
adam@0 3004 func_show_eval "$striplib $destdir/$realname" 'exit $?'
adam@0 3005 fi
adam@0 3006
adam@0 3007 if test "$#" -gt 0; then
adam@0 3008 # Delete the old symlinks, and create new ones.
adam@0 3009 # Try `ln -sf' first, because the `ln' binary might depend on
adam@0 3010 # the symlink we replace! Solaris /bin/ln does not understand -f,
adam@0 3011 # so we also need to try rm && ln -s.
adam@0 3012 for linkname
adam@0 3013 do
adam@0 3014 test "$linkname" != "$realname" \
adam@0 3015 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
adam@0 3016 done
adam@0 3017 fi
adam@0 3018
adam@0 3019 # Do each command in the postinstall commands.
adam@0 3020 lib="$destdir/$realname"
adam@0 3021 func_execute_cmds "$postinstall_cmds" 'exit $?'
adam@0 3022 fi
adam@0 3023
adam@0 3024 # Install the pseudo-library for information purposes.
adam@0 3025 func_basename "$file"
adam@0 3026 name="$func_basename_result"
adam@0 3027 instname="$dir/$name"i
adam@0 3028 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
adam@0 3029
adam@0 3030 # Maybe install the static library, too.
adam@12 3031 test -n "$old_library" && func_append staticlibs " $dir/$old_library"
adam@0 3032 ;;
adam@0 3033
adam@0 3034 *.lo)
adam@0 3035 # Install (i.e. copy) a libtool object.
adam@0 3036
adam@0 3037 # Figure out destination file name, if it wasn't already specified.
adam@0 3038 if test -n "$destname"; then
adam@0 3039 destfile="$destdir/$destname"
adam@0 3040 else
adam@0 3041 func_basename "$file"
adam@0 3042 destfile="$func_basename_result"
adam@0 3043 destfile="$destdir/$destfile"
adam@0 3044 fi
adam@0 3045
adam@0 3046 # Deduce the name of the destination old-style object file.
adam@0 3047 case $destfile in
adam@0 3048 *.lo)
adam@0 3049 func_lo2o "$destfile"
adam@0 3050 staticdest=$func_lo2o_result
adam@0 3051 ;;
adam@0 3052 *.$objext)
adam@0 3053 staticdest="$destfile"
adam@0 3054 destfile=
adam@0 3055 ;;
adam@0 3056 *)
adam@0 3057 func_fatal_help "cannot copy a libtool object to \`$destfile'"
adam@0 3058 ;;
adam@0 3059 esac
adam@0 3060
adam@0 3061 # Install the libtool object if requested.
adam@0 3062 test -n "$destfile" && \
adam@0 3063 func_show_eval "$install_prog $file $destfile" 'exit $?'
adam@0 3064
adam@0 3065 # Install the old object if enabled.
adam@0 3066 if test "$build_old_libs" = yes; then
adam@0 3067 # Deduce the name of the old-style object file.
adam@0 3068 func_lo2o "$file"
adam@0 3069 staticobj=$func_lo2o_result
adam@0 3070 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
adam@0 3071 fi
adam@0 3072 exit $EXIT_SUCCESS
adam@0 3073 ;;
adam@0 3074
adam@0 3075 *)
adam@0 3076 # Figure out destination file name, if it wasn't already specified.
adam@0 3077 if test -n "$destname"; then
adam@0 3078 destfile="$destdir/$destname"
adam@0 3079 else
adam@0 3080 func_basename "$file"
adam@0 3081 destfile="$func_basename_result"
adam@0 3082 destfile="$destdir/$destfile"
adam@0 3083 fi
adam@0 3084
adam@0 3085 # If the file is missing, and there is a .exe on the end, strip it
adam@0 3086 # because it is most likely a libtool script we actually want to
adam@0 3087 # install
adam@0 3088 stripped_ext=""
adam@0 3089 case $file in
adam@0 3090 *.exe)
adam@0 3091 if test ! -f "$file"; then
adam@0 3092 func_stripname '' '.exe' "$file"
adam@0 3093 file=$func_stripname_result
adam@0 3094 stripped_ext=".exe"
adam@0 3095 fi
adam@0 3096 ;;
adam@0 3097 esac
adam@0 3098
adam@0 3099 # Do a test to see if this is really a libtool program.
adam@0 3100 case $host in
adam@0 3101 *cygwin* | *mingw*)
adam@0 3102 if func_ltwrapper_executable_p "$file"; then
adam@0 3103 func_ltwrapper_scriptname "$file"
adam@0 3104 wrapper=$func_ltwrapper_scriptname_result
adam@0 3105 else
adam@0 3106 func_stripname '' '.exe' "$file"
adam@0 3107 wrapper=$func_stripname_result
adam@0 3108 fi
adam@0 3109 ;;
adam@0 3110 *)
adam@0 3111 wrapper=$file
adam@0 3112 ;;
adam@0 3113 esac
adam@0 3114 if func_ltwrapper_script_p "$wrapper"; then
adam@0 3115 notinst_deplibs=
adam@0 3116 relink_command=
adam@0 3117
adam@0 3118 func_source "$wrapper"
adam@0 3119
adam@0 3120 # Check the variables that should have been set.
adam@0 3121 test -z "$generated_by_libtool_version" && \
adam@0 3122 func_fatal_error "invalid libtool wrapper script \`$wrapper'"
adam@0 3123
adam@0 3124 finalize=yes
adam@0 3125 for lib in $notinst_deplibs; do
adam@0 3126 # Check to see that each library is installed.
adam@0 3127 libdir=
adam@0 3128 if test -f "$lib"; then
adam@0 3129 func_source "$lib"
adam@0 3130 fi
adam@12 3131 libfile="$libdir/"`$ECHO "$lib" | $SED 's%^.*/%%g'` ### testsuite: skip nested quoting test
adam@0 3132 if test -n "$libdir" && test ! -f "$libfile"; then
adam@0 3133 func_warning "\`$lib' has not been installed in \`$libdir'"
adam@0 3134 finalize=no
adam@0 3135 fi
adam@0 3136 done
adam@0 3137
adam@0 3138 relink_command=
adam@0 3139 func_source "$wrapper"
adam@0 3140
adam@0 3141 outputname=
adam@0 3142 if test "$fast_install" = no && test -n "$relink_command"; then
adam@0 3143 $opt_dry_run || {
adam@0 3144 if test "$finalize" = yes; then
adam@0 3145 tmpdir=`func_mktempdir`
adam@0 3146 func_basename "$file$stripped_ext"
adam@0 3147 file="$func_basename_result"
adam@0 3148 outputname="$tmpdir/$file"
adam@0 3149 # Replace the output file specification.
adam@12 3150 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
adam@0 3151
adam@0 3152 $opt_silent || {
adam@0 3153 func_quote_for_expand "$relink_command"
adam@0 3154 eval "func_echo $func_quote_for_expand_result"
adam@0 3155 }
adam@0 3156 if eval "$relink_command"; then :
adam@0 3157 else
adam@0 3158 func_error "error: relink \`$file' with the above command before installing it"
adam@0 3159 $opt_dry_run || ${RM}r "$tmpdir"
adam@0 3160 continue
adam@0 3161 fi
adam@0 3162 file="$outputname"
adam@0 3163 else
adam@0 3164 func_warning "cannot relink \`$file'"
adam@0 3165 fi
adam@0 3166 }
adam@0 3167 else
adam@0 3168 # Install the binary that we compiled earlier.
adam@12 3169 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
adam@0 3170 fi
adam@0 3171 fi
adam@0 3172
adam@0 3173 # remove .exe since cygwin /usr/bin/install will append another
adam@0 3174 # one anyway
adam@0 3175 case $install_prog,$host in
adam@0 3176 */usr/bin/install*,*cygwin*)
adam@0 3177 case $file:$destfile in
adam@0 3178 *.exe:*.exe)
adam@0 3179 # this is ok
adam@0 3180 ;;
adam@0 3181 *.exe:*)
adam@0 3182 destfile=$destfile.exe
adam@0 3183 ;;
adam@0 3184 *:*.exe)
adam@0 3185 func_stripname '' '.exe' "$destfile"
adam@0 3186 destfile=$func_stripname_result
adam@0 3187 ;;
adam@0 3188 esac
adam@0 3189 ;;
adam@0 3190 esac
adam@0 3191 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
adam@0 3192 $opt_dry_run || if test -n "$outputname"; then
adam@0 3193 ${RM}r "$tmpdir"
adam@0 3194 fi
adam@0 3195 ;;
adam@0 3196 esac
adam@0 3197 done
adam@0 3198
adam@0 3199 for file in $staticlibs; do
adam@0 3200 func_basename "$file"
adam@0 3201 name="$func_basename_result"
adam@0 3202
adam@0 3203 # Set up the ranlib parameters.
adam@0 3204 oldlib="$destdir/$name"
adam@20 3205 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
adam@20 3206 tool_oldlib=$func_to_tool_file_result
adam@0 3207
adam@0 3208 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
adam@0 3209
adam@0 3210 if test -n "$stripme" && test -n "$old_striplib"; then
adam@20 3211 func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
adam@0 3212 fi
adam@0 3213
adam@0 3214 # Do each command in the postinstall commands.
adam@0 3215 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
adam@0 3216 done
adam@0 3217
adam@0 3218 test -n "$future_libdirs" && \
adam@0 3219 func_warning "remember to run \`$progname --finish$future_libdirs'"
adam@0 3220
adam@0 3221 if test -n "$current_libdirs"; then
adam@0 3222 # Maybe just do a dry run.
adam@0 3223 $opt_dry_run && current_libdirs=" -n$current_libdirs"
adam@0 3224 exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
adam@0 3225 else
adam@0 3226 exit $EXIT_SUCCESS
adam@0 3227 fi
adam@0 3228 }
adam@0 3229
adam@12 3230 test "$opt_mode" = install && func_mode_install ${1+"$@"}
adam@0 3231
adam@0 3232
adam@0 3233 # func_generate_dlsyms outputname originator pic_p
adam@0 3234 # Extract symbols from dlprefiles and create ${outputname}S.o with
adam@0 3235 # a dlpreopen symbol table.
adam@0 3236 func_generate_dlsyms ()
adam@0 3237 {
adam@0 3238 $opt_debug
adam@0 3239 my_outputname="$1"
adam@0 3240 my_originator="$2"
adam@0 3241 my_pic_p="${3-no}"
adam@0 3242 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
adam@0 3243 my_dlsyms=
adam@0 3244
adam@0 3245 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
adam@0 3246 if test -n "$NM" && test -n "$global_symbol_pipe"; then
adam@0 3247 my_dlsyms="${my_outputname}S.c"
adam@0 3248 else
adam@0 3249 func_error "not configured to extract global symbols from dlpreopened files"
adam@0 3250 fi
adam@0 3251 fi
adam@0 3252
adam@0 3253 if test -n "$my_dlsyms"; then
adam@0 3254 case $my_dlsyms in
adam@0 3255 "") ;;
adam@0 3256 *.c)
adam@0 3257 # Discover the nlist of each of the dlfiles.
adam@0 3258 nlist="$output_objdir/${my_outputname}.nm"
adam@0 3259
adam@0 3260 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
adam@0 3261
adam@0 3262 # Parse the name list into a source file.
adam@0 3263 func_verbose "creating $output_objdir/$my_dlsyms"
adam@0 3264
adam@0 3265 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
adam@0 3266 /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
adam@0 3267 /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
adam@0 3268
adam@0 3269 #ifdef __cplusplus
adam@0 3270 extern \"C\" {
adam@0 3271 #endif
adam@0 3272
adam@12 3273 #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
adam@12 3274 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
adam@12 3275 #endif
adam@12 3276
adam@12 3277 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
adam@12 3278 #if defined(_WIN32) || defined(__CYGWIN__) || defined(_WIN32_WCE)
adam@12 3279 /* DATA imports from DLLs on WIN32 con't be const, because runtime
adam@12 3280 relocations are performed -- see ld's documentation on pseudo-relocs. */
adam@12 3281 # define LT_DLSYM_CONST
adam@12 3282 #elif defined(__osf__)
adam@12 3283 /* This system does not cope well with relocations in const data. */
adam@12 3284 # define LT_DLSYM_CONST
adam@12 3285 #else
adam@12 3286 # define LT_DLSYM_CONST const
adam@12 3287 #endif
adam@12 3288
adam@0 3289 /* External symbol declarations for the compiler. */\
adam@0 3290 "
adam@0 3291
adam@0 3292 if test "$dlself" = yes; then
adam@0 3293 func_verbose "generating symbol list for \`$output'"
adam@0 3294
adam@0 3295 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
adam@0 3296
adam@0 3297 # Add our own program objects to the symbol list.
adam@12 3298 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
adam@0 3299 for progfile in $progfiles; do
adam@12 3300 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
adam@12 3301 func_verbose "extracting global C symbols from \`$func_to_tool_file_result'"
adam@12 3302 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
adam@0 3303 done
adam@0 3304
adam@0 3305 if test -n "$exclude_expsyms"; then
adam@0 3306 $opt_dry_run || {
adam@0 3307 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
adam@0 3308 eval '$MV "$nlist"T "$nlist"'
adam@0 3309 }
adam@0 3310 fi
adam@0 3311
adam@0 3312 if test -n "$export_symbols_regex"; then
adam@0 3313 $opt_dry_run || {
adam@0 3314 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
adam@0 3315 eval '$MV "$nlist"T "$nlist"'
adam@0 3316 }
adam@0 3317 fi
adam@0 3318
adam@0 3319 # Prepare the list of exported symbols
adam@0 3320 if test -z "$export_symbols"; then
adam@0 3321 export_symbols="$output_objdir/$outputname.exp"
adam@0 3322 $opt_dry_run || {
adam@0 3323 $RM $export_symbols
adam@0 3324 eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
adam@0 3325 case $host in
adam@0 3326 *cygwin* | *mingw* | *cegcc* )
adam@0 3327 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
adam@0 3328 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
adam@0 3329 ;;
adam@0 3330 esac
adam@0 3331 }
adam@0 3332 else
adam@0 3333 $opt_dry_run || {
adam@0 3334 eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
adam@0 3335 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
adam@0 3336 eval '$MV "$nlist"T "$nlist"'
adam@0 3337 case $host in
adam@12 3338 *cygwin* | *mingw* | *cegcc* )
adam@0 3339 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
adam@0 3340 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
adam@0 3341 ;;
adam@0 3342 esac
adam@0 3343 }
adam@0 3344 fi
adam@0 3345 fi
adam@0 3346
adam@0 3347 for dlprefile in $dlprefiles; do
adam@0 3348 func_verbose "extracting global C symbols from \`$dlprefile'"
adam@0 3349 func_basename "$dlprefile"
adam@0 3350 name="$func_basename_result"
adam@12 3351 case $host in
adam@12 3352 *cygwin* | *mingw* | *cegcc* )
adam@12 3353 # if an import library, we need to obtain dlname
adam@12 3354 if func_win32_import_lib_p "$dlprefile"; then
adam@12 3355 func_tr_sh "$dlprefile"
adam@12 3356 eval "curr_lafile=\$libfile_$func_tr_sh_result"
adam@12 3357 dlprefile_dlbasename=""
adam@12 3358 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
adam@12 3359 # Use subshell, to avoid clobbering current variable values
adam@12 3360 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
adam@12 3361 if test -n "$dlprefile_dlname" ; then
adam@12 3362 func_basename "$dlprefile_dlname"
adam@12 3363 dlprefile_dlbasename="$func_basename_result"
adam@12 3364 else
adam@12 3365 # no lafile. user explicitly requested -dlpreopen <import library>.
adam@12 3366 $sharedlib_from_linklib_cmd "$dlprefile"
adam@12 3367 dlprefile_dlbasename=$sharedlib_from_linklib_result
adam@12 3368 fi
adam@12 3369 fi
adam@12 3370 $opt_dry_run || {
adam@12 3371 if test -n "$dlprefile_dlbasename" ; then
adam@12 3372 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
adam@12 3373 else
adam@12 3374 func_warning "Could not compute DLL name from $name"
adam@12 3375 eval '$ECHO ": $name " >> "$nlist"'
adam@12 3376 fi
adam@12 3377 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
adam@12 3378 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
adam@12 3379 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
adam@12 3380 }
adam@12 3381 else # not an import lib
adam@12 3382 $opt_dry_run || {
adam@12 3383 eval '$ECHO ": $name " >> "$nlist"'
adam@12 3384 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
adam@12 3385 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
adam@12 3386 }
adam@12 3387 fi
adam@12 3388 ;;
adam@12 3389 *)
adam@12 3390 $opt_dry_run || {
adam@12 3391 eval '$ECHO ": $name " >> "$nlist"'
adam@12 3392 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
adam@12 3393 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
adam@12 3394 }
adam@12 3395 ;;
adam@12 3396 esac
adam@0 3397 done
adam@0 3398
adam@0 3399 $opt_dry_run || {
adam@0 3400 # Make sure we have at least an empty file.
adam@0 3401 test -f "$nlist" || : > "$nlist"
adam@0 3402
adam@0 3403 if test -n "$exclude_expsyms"; then
adam@0 3404 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
adam@0 3405 $MV "$nlist"T "$nlist"
adam@0 3406 fi
adam@0 3407
adam@0 3408 # Try sorting and uniquifying the output.
adam@0 3409 if $GREP -v "^: " < "$nlist" |
adam@0 3410 if sort -k 3 </dev/null >/dev/null 2>&1; then
adam@0 3411 sort -k 3
adam@0 3412 else
adam@0 3413 sort +2
adam@0 3414 fi |
adam@0 3415 uniq > "$nlist"S; then
adam@0 3416 :
adam@0 3417 else
adam@0 3418 $GREP -v "^: " < "$nlist" > "$nlist"S
adam@0 3419 fi
adam@0 3420
adam@0 3421 if test -f "$nlist"S; then
adam@0 3422 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
adam@0 3423 else
adam@12 3424 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
adam@0 3425 fi
adam@0 3426
adam@12 3427 echo >> "$output_objdir/$my_dlsyms" "\
adam@0 3428
adam@0 3429 /* The mapping between symbol names and symbols. */
adam@0 3430 typedef struct {
adam@0 3431 const char *name;
adam@0 3432 void *address;
adam@0 3433 } lt_dlsymlist;
adam@12 3434 extern LT_DLSYM_CONST lt_dlsymlist
adam@0 3435 lt_${my_prefix}_LTX_preloaded_symbols[];
adam@12 3436 LT_DLSYM_CONST lt_dlsymlist
adam@0 3437 lt_${my_prefix}_LTX_preloaded_symbols[] =
adam@0 3438 {\
adam@0 3439 { \"$my_originator\", (void *) 0 },"
adam@0 3440
adam@0 3441 case $need_lib_prefix in
adam@0 3442 no)
adam@0 3443 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
adam@0 3444 ;;
adam@0 3445 *)
adam@0 3446 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
adam@0 3447 ;;
adam@0 3448 esac
adam@12 3449 echo >> "$output_objdir/$my_dlsyms" "\
adam@0 3450 {0, (void *) 0}
adam@0 3451 };
adam@0 3452
adam@0 3453 /* This works around a problem in FreeBSD linker */
adam@0 3454 #ifdef FREEBSD_WORKAROUND
adam@0 3455 static const void *lt_preloaded_setup() {
adam@0 3456 return lt_${my_prefix}_LTX_preloaded_symbols;
adam@0 3457 }
adam@0 3458 #endif
adam@0 3459
adam@0 3460 #ifdef __cplusplus
adam@0 3461 }
adam@0 3462 #endif\
adam@0 3463 "
adam@0 3464 } # !$opt_dry_run
adam@0 3465
adam@0 3466 pic_flag_for_symtable=
adam@0 3467 case "$compile_command " in
adam@0 3468 *" -static "*) ;;
adam@0 3469 *)
adam@0 3470 case $host in
adam@0 3471 # compiling the symbol table file with pic_flag works around
adam@0 3472 # a FreeBSD bug that causes programs to crash when -lm is
adam@0 3473 # linked before any other PIC object. But we must not use
adam@0 3474 # pic_flag when linking with -static. The problem exists in
adam@0 3475 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
adam@20 3476 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
adam@0 3477 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
adam@0 3478 *-*-hpux*)
adam@0 3479 pic_flag_for_symtable=" $pic_flag" ;;
adam@0 3480 *)
adam@0 3481 if test "X$my_pic_p" != Xno; then
adam@0 3482 pic_flag_for_symtable=" $pic_flag"
adam@0 3483 fi
adam@0 3484 ;;
adam@0 3485 esac
adam@0 3486 ;;
adam@0 3487 esac
adam@0 3488 symtab_cflags=
adam@0 3489 for arg in $LTCFLAGS; do
adam@0 3490 case $arg in
adam@0 3491 -pie | -fpie | -fPIE) ;;
adam@12 3492 *) func_append symtab_cflags " $arg" ;;
adam@0 3493 esac
adam@0 3494 done
adam@0 3495
adam@0 3496 # Now compile the dynamic symbol file.
adam@0 3497 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
adam@0 3498
adam@0 3499 # Clean up the generated files.
adam@0 3500 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
adam@0 3501
adam@0 3502 # Transform the symbol file into the correct name.
adam@0 3503 symfileobj="$output_objdir/${my_outputname}S.$objext"
adam@0 3504 case $host in
adam@0 3505 *cygwin* | *mingw* | *cegcc* )
adam@0 3506 if test -f "$output_objdir/$my_outputname.def"; then
adam@12 3507 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
adam@12 3508 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
adam@0 3509 else
adam@12 3510 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
adam@12 3511 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
adam@0 3512 fi
adam@0 3513 ;;
adam@0 3514 *)
adam@12 3515 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
adam@12 3516 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
adam@0 3517 ;;
adam@0 3518 esac
adam@0 3519 ;;
adam@0 3520 *)
adam@0 3521 func_fatal_error "unknown suffix for \`$my_dlsyms'"
adam@0 3522 ;;
adam@0 3523 esac
adam@0 3524 else
adam@0 3525 # We keep going just in case the user didn't refer to
adam@0 3526 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
adam@0 3527 # really was required.
adam@0 3528
adam@0 3529 # Nullify the symbol file.
adam@12 3530 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
adam@12 3531 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
adam@0 3532 fi
adam@0 3533 }
adam@0 3534
adam@0 3535 # func_win32_libid arg
adam@0 3536 # return the library type of file 'arg'
adam@0 3537 #
adam@0 3538 # Need a lot of goo to handle *both* DLLs and import libs
adam@0 3539 # Has to be a shell function in order to 'eat' the argument
adam@0 3540 # that is supplied when $file_magic_command is called.
adam@12 3541 # Despite the name, also deal with 64 bit binaries.
adam@0 3542 func_win32_libid ()
adam@0 3543 {
adam@0 3544 $opt_debug
adam@0 3545 win32_libid_type="unknown"
adam@0 3546 win32_fileres=`file -L $1 2>/dev/null`
adam@0 3547 case $win32_fileres in
adam@0 3548 *ar\ archive\ import\ library*) # definitely import
adam@0 3549 win32_libid_type="x86 archive import"
adam@0 3550 ;;
adam@0 3551 *ar\ archive*) # could be an import, or static
adam@12 3552 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
adam@0 3553 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
adam@12 3554 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
adam@12 3555 func_to_tool_file "$1" func_convert_file_msys_to_w32
adam@12 3556 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
adam@0 3557 $SED -n -e '
adam@0 3558 1,100{
adam@0 3559 / I /{
adam@0 3560 s,.*,import,
adam@0 3561 p
adam@0 3562 q
adam@0 3563 }
adam@0 3564 }'`
adam@0 3565 case $win32_nmres in
adam@0 3566 import*) win32_libid_type="x86 archive import";;
adam@0 3567 *) win32_libid_type="x86 archive static";;
adam@0 3568 esac
adam@0 3569 fi
adam@0 3570 ;;
adam@0 3571 *DLL*)
adam@0 3572 win32_libid_type="x86 DLL"
adam@0 3573 ;;
adam@0 3574 *executable*) # but shell scripts are "executable" too...
adam@0 3575 case $win32_fileres in
adam@0 3576 *MS\ Windows\ PE\ Intel*)
adam@0 3577 win32_libid_type="x86 DLL"
adam@0 3578 ;;
adam@0 3579 esac
adam@0 3580 ;;
adam@0 3581 esac
adam@0 3582 $ECHO "$win32_libid_type"
adam@0 3583 }
adam@0 3584
adam@12 3585 # func_cygming_dll_for_implib ARG
adam@12 3586 #
adam@12 3587 # Platform-specific function to extract the
adam@12 3588 # name of the DLL associated with the specified
adam@12 3589 # import library ARG.
adam@12 3590 # Invoked by eval'ing the libtool variable
adam@12 3591 # $sharedlib_from_linklib_cmd
adam@12 3592 # Result is available in the variable
adam@12 3593 # $sharedlib_from_linklib_result
adam@12 3594 func_cygming_dll_for_implib ()
adam@12 3595 {
adam@12 3596 $opt_debug
adam@12 3597 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
adam@12 3598 }
adam@12 3599
adam@12 3600 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
adam@12 3601 #
adam@12 3602 # The is the core of a fallback implementation of a
adam@12 3603 # platform-specific function to extract the name of the
adam@12 3604 # DLL associated with the specified import library LIBNAME.
adam@12 3605 #
adam@12 3606 # SECTION_NAME is either .idata$6 or .idata$7, depending
adam@12 3607 # on the platform and compiler that created the implib.
adam@12 3608 #
adam@12 3609 # Echos the name of the DLL associated with the
adam@12 3610 # specified import library.
adam@12 3611 func_cygming_dll_for_implib_fallback_core ()
adam@12 3612 {
adam@12 3613 $opt_debug
adam@12 3614 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
adam@12 3615 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
adam@12 3616 $SED '/^Contents of section '"$match_literal"':/{
adam@12 3617 # Place marker at beginning of archive member dllname section
adam@12 3618 s/.*/====MARK====/
adam@12 3619 p
adam@12 3620 d
adam@12 3621 }
adam@12 3622 # These lines can sometimes be longer than 43 characters, but
adam@12 3623 # are always uninteresting
adam@12 3624 /:[ ]*file format pe[i]\{,1\}-/d
adam@12 3625 /^In archive [^:]*:/d
adam@12 3626 # Ensure marker is printed
adam@12 3627 /^====MARK====/p
adam@12 3628 # Remove all lines with less than 43 characters
adam@12 3629 /^.\{43\}/!d
adam@12 3630 # From remaining lines, remove first 43 characters
adam@12 3631 s/^.\{43\}//' |
adam@12 3632 $SED -n '
adam@12 3633 # Join marker and all lines until next marker into a single line
adam@12 3634 /^====MARK====/ b para
adam@12 3635 H
adam@12 3636 $ b para
adam@12 3637 b
adam@12 3638 :para
adam@12 3639 x
adam@12 3640 s/\n//g
adam@12 3641 # Remove the marker
adam@12 3642 s/^====MARK====//
adam@12 3643 # Remove trailing dots and whitespace
adam@12 3644 s/[\. \t]*$//
adam@12 3645 # Print
adam@12 3646 /./p' |
adam@12 3647 # we now have a list, one entry per line, of the stringified
adam@12 3648 # contents of the appropriate section of all members of the
adam@12 3649 # archive which possess that section. Heuristic: eliminate
adam@12 3650 # all those which have a first or second character that is
adam@12 3651 # a '.' (that is, objdump's representation of an unprintable
adam@12 3652 # character.) This should work for all archives with less than
adam@12 3653 # 0x302f exports -- but will fail for DLLs whose name actually
adam@12 3654 # begins with a literal '.' or a single character followed by
adam@12 3655 # a '.'.
adam@12 3656 #
adam@12 3657 # Of those that remain, print the first one.
adam@12 3658 $SED -e '/^\./d;/^.\./d;q'
adam@12 3659 }
adam@12 3660
adam@12 3661 # func_cygming_gnu_implib_p ARG
adam@12 3662 # This predicate returns with zero status (TRUE) if
adam@12 3663 # ARG is a GNU/binutils-style import library. Returns
adam@12 3664 # with nonzero status (FALSE) otherwise.
adam@12 3665 func_cygming_gnu_implib_p ()
adam@12 3666 {
adam@12 3667 $opt_debug
adam@12 3668 func_to_tool_file "$1" func_convert_file_msys_to_w32
adam@12 3669 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)$'`
adam@12 3670 test -n "$func_cygming_gnu_implib_tmp"
adam@12 3671 }
adam@12 3672
adam@12 3673 # func_cygming_ms_implib_p ARG
adam@12 3674 # This predicate returns with zero status (TRUE) if
adam@12 3675 # ARG is an MS-style import library. Returns
adam@12 3676 # with nonzero status (FALSE) otherwise.
adam@12 3677 func_cygming_ms_implib_p ()
adam@12 3678 {
adam@12 3679 $opt_debug
adam@12 3680 func_to_tool_file "$1" func_convert_file_msys_to_w32
adam@12 3681 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
adam@12 3682 test -n "$func_cygming_ms_implib_tmp"
adam@12 3683 }
adam@12 3684
adam@12 3685 # func_cygming_dll_for_implib_fallback ARG
adam@12 3686 # Platform-specific function to extract the
adam@12 3687 # name of the DLL associated with the specified
adam@12 3688 # import library ARG.
adam@12 3689 #
adam@12 3690 # This fallback implementation is for use when $DLLTOOL
adam@12 3691 # does not support the --identify-strict option.
adam@12 3692 # Invoked by eval'ing the libtool variable
adam@12 3693 # $sharedlib_from_linklib_cmd
adam@12 3694 # Result is available in the variable
adam@12 3695 # $sharedlib_from_linklib_result
adam@12 3696 func_cygming_dll_for_implib_fallback ()
adam@12 3697 {
adam@12 3698 $opt_debug
adam@12 3699 if func_cygming_gnu_implib_p "$1" ; then
adam@12 3700 # binutils import library
adam@12 3701 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
adam@12 3702 elif func_cygming_ms_implib_p "$1" ; then
adam@12 3703 # ms-generated import library
adam@12 3704 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
adam@12 3705 else
adam@12 3706 # unknown
adam@12 3707 sharedlib_from_linklib_result=""
adam@12 3708 fi
adam@12 3709 }
adam@0 3710
adam@0 3711
adam@0 3712 # func_extract_an_archive dir oldlib
adam@0 3713 func_extract_an_archive ()
adam@0 3714 {
adam@0 3715 $opt_debug
adam@0 3716 f_ex_an_ar_dir="$1"; shift
adam@0 3717 f_ex_an_ar_oldlib="$1"
adam@12 3718 if test "$lock_old_archive_extraction" = yes; then
adam@12 3719 lockfile=$f_ex_an_ar_oldlib.lock
adam@12 3720 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
adam@12 3721 func_echo "Waiting for $lockfile to be removed"
adam@12 3722 sleep 2
adam@12 3723 done
adam@12 3724 fi
adam@12 3725 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
adam@12 3726 'stat=$?; rm -f "$lockfile"; exit $stat'
adam@12 3727 if test "$lock_old_archive_extraction" = yes; then
adam@12 3728 $opt_dry_run || rm -f "$lockfile"
adam@12 3729 fi
adam@0 3730 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
adam@0 3731 :
adam@0 3732 else
adam@0 3733 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
adam@0 3734 fi
adam@0 3735 }
adam@0 3736
adam@0 3737
adam@0 3738 # func_extract_archives gentop oldlib ...
adam@0 3739 func_extract_archives ()
adam@0 3740 {
adam@0 3741 $opt_debug
adam@0 3742 my_gentop="$1"; shift
adam@0 3743 my_oldlibs=${1+"$@"}
adam@0 3744 my_oldobjs=""
adam@0 3745 my_xlib=""
adam@0 3746 my_xabs=""
adam@0 3747 my_xdir=""
adam@0 3748
adam@0 3749 for my_xlib in $my_oldlibs; do
adam@0 3750 # Extract the objects.
adam@0 3751 case $my_xlib in
adam@0 3752 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
adam@0 3753 *) my_xabs=`pwd`"/$my_xlib" ;;
adam@0 3754 esac
adam@0 3755 func_basename "$my_xlib"
adam@0 3756 my_xlib="$func_basename_result"
adam@0 3757 my_xlib_u=$my_xlib
adam@0 3758 while :; do
adam@0 3759 case " $extracted_archives " in
adam@0 3760 *" $my_xlib_u "*)
adam@0 3761 func_arith $extracted_serial + 1
adam@0 3762 extracted_serial=$func_arith_result
adam@0 3763 my_xlib_u=lt$extracted_serial-$my_xlib ;;
adam@0 3764 *) break ;;
adam@0 3765 esac
adam@0 3766 done
adam@0 3767 extracted_archives="$extracted_archives $my_xlib_u"
adam@0 3768 my_xdir="$my_gentop/$my_xlib_u"
adam@0 3769
adam@0 3770 func_mkdir_p "$my_xdir"
adam@0 3771
adam@0 3772 case $host in
adam@0 3773 *-darwin*)
adam@0 3774 func_verbose "Extracting $my_xabs"
adam@0 3775 # Do not bother doing anything if just a dry run
adam@0 3776 $opt_dry_run || {
adam@0 3777 darwin_orig_dir=`pwd`
adam@0 3778 cd $my_xdir || exit $?
adam@0 3779 darwin_archive=$my_xabs
adam@0 3780 darwin_curdir=`pwd`
adam@0 3781 darwin_base_archive=`basename "$darwin_archive"`
adam@0 3782 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
adam@0 3783 if test -n "$darwin_arches"; then
adam@0 3784 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
adam@0 3785 darwin_arch=
adam@0 3786 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
adam@0 3787 for darwin_arch in $darwin_arches ; do
adam@0 3788 func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
adam@0 3789 $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
adam@0 3790 cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
adam@0 3791 func_extract_an_archive "`pwd`" "${darwin_base_archive}"
adam@0 3792 cd "$darwin_curdir"
adam@0 3793 $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
adam@0 3794 done # $darwin_arches
adam@0 3795 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
adam@0 3796 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
adam@0 3797 darwin_file=
adam@0 3798 darwin_files=
adam@0 3799 for darwin_file in $darwin_filelist; do
adam@12 3800 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
adam@0 3801 $LIPO -create -output "$darwin_file" $darwin_files
adam@0 3802 done # $darwin_filelist
adam@0 3803 $RM -rf unfat-$$
adam@0 3804 cd "$darwin_orig_dir"
adam@0 3805 else
adam@0 3806 cd $darwin_orig_dir
adam@0 3807 func_extract_an_archive "$my_xdir" "$my_xabs"
adam@0 3808 fi # $darwin_arches
adam@0 3809 } # !$opt_dry_run
adam@0 3810 ;;
adam@0 3811 *)
adam@0 3812 func_extract_an_archive "$my_xdir" "$my_xabs"
adam@0 3813 ;;
adam@0 3814 esac
adam@12 3815 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
adam@0 3816 done
adam@0 3817
adam@0 3818 func_extract_archives_result="$my_oldobjs"
adam@0 3819 }
adam@0 3820
adam@0 3821
adam@0 3822 # func_emit_wrapper [arg=no]
adam@0 3823 #
adam@0 3824 # Emit a libtool wrapper script on stdout.
adam@0 3825 # Don't directly open a file because we may want to
adam@0 3826 # incorporate the script contents within a cygwin/mingw
adam@0 3827 # wrapper executable. Must ONLY be called from within
adam@0 3828 # func_mode_link because it depends on a number of variables
adam@0 3829 # set therein.
adam@0 3830 #
adam@0 3831 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
adam@0 3832 # variable will take. If 'yes', then the emitted script
adam@0 3833 # will assume that the directory in which it is stored is
adam@0 3834 # the $objdir directory. This is a cygwin/mingw-specific
adam@0 3835 # behavior.
adam@0 3836 func_emit_wrapper ()
adam@0 3837 {
adam@12 3838 func_emit_wrapper_arg1=${1-no}
adam@12 3839
adam@12 3840 $ECHO "\
adam@12 3841 #! $SHELL
adam@12 3842
adam@12 3843 # $output - temporary wrapper script for $objdir/$outputname
adam@12 3844 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
adam@0 3845 #
adam@12 3846 # The $output program cannot be directly executed until all the libtool
adam@12 3847 # libraries that it depends on are installed.
adam@0 3848 #
adam@12 3849 # This wrapper script should never be moved out of the build directory.
adam@12 3850 # If it is, it will not operate correctly.
adam@12 3851
adam@12 3852 # Sed substitution that helps us do robust quoting. It backslashifies
adam@12 3853 # metacharacters that are still active within double-quoted strings.
adam@12 3854 sed_quote_subst='$sed_quote_subst'
adam@12 3855
adam@12 3856 # Be Bourne compatible
adam@12 3857 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
adam@12 3858 emulate sh
adam@12 3859 NULLCMD=:
adam@12 3860 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
adam@12 3861 # is contrary to our usage. Disable this feature.
adam@12 3862 alias -g '\${1+\"\$@\"}'='\"\$@\"'
adam@12 3863 setopt NO_GLOB_SUBST
adam@12 3864 else
adam@12 3865 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
adam@12 3866 fi
adam@12 3867 BIN_SH=xpg4; export BIN_SH # for Tru64
adam@12 3868 DUALCASE=1; export DUALCASE # for MKS sh
adam@12 3869
adam@12 3870 # The HP-UX ksh and POSIX shell print the target directory to stdout
adam@12 3871 # if CDPATH is set.
adam@12 3872 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
adam@12 3873
adam@12 3874 relink_command=\"$relink_command\"
adam@12 3875
adam@12 3876 # This environment variable determines our operation mode.
adam@12 3877 if test \"\$libtool_install_magic\" = \"$magic\"; then
adam@12 3878 # install mode needs the following variables:
adam@12 3879 generated_by_libtool_version='$macro_version'
adam@12 3880 notinst_deplibs='$notinst_deplibs'
adam@12 3881 else
adam@12 3882 # When we are sourced in execute mode, \$file and \$ECHO are already set.
adam@12 3883 if test \"\$libtool_execute_magic\" != \"$magic\"; then
adam@12 3884 file=\"\$0\""
adam@12 3885
adam@12 3886 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
adam@12 3887 $ECHO "\
adam@12 3888
adam@12 3889 # A function that is used when there is no print builtin or printf.
adam@12 3890 func_fallback_echo ()
adam@12 3891 {
adam@12 3892 eval 'cat <<_LTECHO_EOF
adam@12 3893 \$1
adam@12 3894 _LTECHO_EOF'
adam@12 3895 }
adam@12 3896 ECHO=\"$qECHO\"
adam@12 3897 fi
adam@12 3898
adam@12 3899 # Very basic option parsing. These options are (a) specific to
adam@12 3900 # the libtool wrapper, (b) are identical between the wrapper
adam@12 3901 # /script/ and the wrapper /executable/ which is used only on
adam@12 3902 # windows platforms, and (c) all begin with the string "--lt-"
adam@12 3903 # (application programs are unlikely to have options which match
adam@12 3904 # this pattern).
adam@12 3905 #
adam@12 3906 # There are only two supported options: --lt-debug and
adam@12 3907 # --lt-dump-script. There is, deliberately, no --lt-help.
adam@12 3908 #
adam@12 3909 # The first argument to this parsing function should be the
adam@12 3910 # script's $0 value, followed by "$@".
adam@12 3911 lt_option_debug=
adam@12 3912 func_parse_lt_options ()
adam@12 3913 {
adam@12 3914 lt_script_arg0=\$0
adam@12 3915 shift
adam@12 3916 for lt_opt
adam@12 3917 do
adam@12 3918 case \"\$lt_opt\" in
adam@12 3919 --lt-debug) lt_option_debug=1 ;;
adam@12 3920 --lt-dump-script)
adam@12 3921 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
adam@12 3922 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
adam@12 3923 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
adam@12 3924 cat \"\$lt_dump_D/\$lt_dump_F\"
adam@12 3925 exit 0
adam@12 3926 ;;
adam@12 3927 --lt-*)
adam@12 3928 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
adam@12 3929 exit 1
adam@12 3930 ;;
adam@12 3931 esac
adam@12 3932 done
adam@12 3933
adam@12 3934 # Print the debug banner immediately:
adam@12 3935 if test -n \"\$lt_option_debug\"; then
adam@12 3936 echo \"${outputname}:${output}:\${LINENO}: libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\" 1>&2
adam@12 3937 fi
adam@12 3938 }
adam@12 3939
adam@12 3940 # Used when --lt-debug. Prints its arguments to stdout
adam@12 3941 # (redirection is the responsibility of the caller)
adam@12 3942 func_lt_dump_args ()
adam@12 3943 {
adam@12 3944 lt_dump_args_N=1;
adam@12 3945 for lt_arg
adam@12 3946 do
adam@12 3947 \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[\$lt_dump_args_N]: \$lt_arg\"
adam@12 3948 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
adam@12 3949 done
adam@12 3950 }
adam@12 3951
adam@12 3952 # Core function for launching the target application
adam@12 3953 func_exec_program_core ()
adam@12 3954 {
adam@12 3955 "
adam@12 3956 case $host in
adam@12 3957 # Backslashes separate directories on plain windows
adam@12 3958 *-*-mingw | *-*-os2* | *-cegcc*)
adam@12 3959 $ECHO "\
adam@12 3960 if test -n \"\$lt_option_debug\"; then
adam@12 3961 \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir\\\\\$program\" 1>&2
adam@12 3962 func_lt_dump_args \${1+\"\$@\"} 1>&2
adam@12 3963 fi
adam@12 3964 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
adam@12 3965 "
adam@12 3966 ;;
adam@12 3967
adam@12 3968 *)
adam@12 3969 $ECHO "\
adam@12 3970 if test -n \"\$lt_option_debug\"; then
adam@12 3971 \$ECHO \"${outputname}:${output}:\${LINENO}: newargv[0]: \$progdir/\$program\" 1>&2
adam@12 3972 func_lt_dump_args \${1+\"\$@\"} 1>&2
adam@12 3973 fi
adam@12 3974 exec \"\$progdir/\$program\" \${1+\"\$@\"}
adam@12 3975 "
adam@12 3976 ;;
adam@12 3977 esac
adam@12 3978 $ECHO "\
adam@12 3979 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
adam@12 3980 exit 1
adam@12 3981 }
adam@12 3982
adam@12 3983 # A function to encapsulate launching the target application
adam@12 3984 # Strips options in the --lt-* namespace from \$@ and
adam@12 3985 # launches target application with the remaining arguments.
adam@12 3986 func_exec_program ()
adam@12 3987 {
adam@20 3988 case \" \$* \" in
adam@20 3989 *\\ --lt-*)
adam@20 3990 for lt_wr_arg
adam@20 3991 do
adam@20 3992 case \$lt_wr_arg in
adam@20 3993 --lt-*) ;;
adam@20 3994 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
adam@20 3995 esac
adam@20 3996 shift
adam@20 3997 done ;;
adam@20 3998 esac
adam@12 3999 func_exec_program_core \${1+\"\$@\"}
adam@12 4000 }
adam@12 4001
adam@12 4002 # Parse options
adam@12 4003 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
adam@12 4004
adam@12 4005 # Find the directory that this script lives in.
adam@12 4006 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
adam@12 4007 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
adam@12 4008
adam@12 4009 # Follow symbolic links until we get to the real thisdir.
adam@12 4010 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
adam@12 4011 while test -n \"\$file\"; do
adam@12 4012 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
adam@12 4013
adam@12 4014 # If there was a directory component, then change thisdir.
adam@12 4015 if test \"x\$destdir\" != \"x\$file\"; then
adam@12 4016 case \"\$destdir\" in
adam@12 4017 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
adam@12 4018 *) thisdir=\"\$thisdir/\$destdir\" ;;
adam@12 4019 esac
adam@12 4020 fi
adam@12 4021
adam@12 4022 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
adam@12 4023 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
adam@12 4024 done
adam@12 4025
adam@12 4026 # Usually 'no', except on cygwin/mingw when embedded into
adam@12 4027 # the cwrapper.
adam@12 4028 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
adam@12 4029 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
adam@12 4030 # special case for '.'
adam@12 4031 if test \"\$thisdir\" = \".\"; then
adam@12 4032 thisdir=\`pwd\`
adam@12 4033 fi
adam@12 4034 # remove .libs from thisdir
adam@12 4035 case \"\$thisdir\" in
adam@12 4036 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
adam@12 4037 $objdir ) thisdir=. ;;
adam@0 4038 esac
adam@0 4039 fi
adam@12 4040
adam@12 4041 # Try to get the absolute directory name.
adam@12 4042 absdir=\`cd \"\$thisdir\" && pwd\`
adam@12 4043 test -n \"\$absdir\" && thisdir=\"\$absdir\"
adam@12 4044 "
adam@12 4045
adam@12 4046 if test "$fast_install" = yes; then
adam@12 4047 $ECHO "\
adam@12 4048 program=lt-'$outputname'$exeext
adam@12 4049 progdir=\"\$thisdir/$objdir\"
adam@12 4050
adam@12 4051 if test ! -f \"\$progdir/\$program\" ||
adam@12 4052 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
adam@12 4053 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
adam@12 4054
adam@12 4055 file=\"\$\$-\$program\"
adam@12 4056
adam@12 4057 if test ! -d \"\$progdir\"; then
adam@12 4058 $MKDIR \"\$progdir\"
adam@12 4059 else
adam@12 4060 $RM \"\$progdir/\$file\"
adam@12 4061 fi"
adam@12 4062
adam@12 4063 $ECHO "\
adam@12 4064
adam@12 4065 # relink executable if necessary
adam@12 4066 if test -n \"\$relink_command\"; then
adam@12 4067 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
adam@12 4068 else
adam@12 4069 $ECHO \"\$relink_command_output\" >&2
adam@12 4070 $RM \"\$progdir/\$file\"
adam@12 4071 exit 1
adam@12 4072 fi
adam@12 4073 fi
adam@12 4074
adam@12 4075 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
adam@12 4076 { $RM \"\$progdir/\$program\";
adam@12 4077 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
adam@12 4078 $RM \"\$progdir/\$file\"
adam@12 4079 fi"
adam@12 4080 else
adam@12 4081 $ECHO "\
adam@12 4082 program='$outputname'
adam@12 4083 progdir=\"\$thisdir/$objdir\"
adam@12 4084 "
adam@12 4085 fi
adam@12 4086
adam@12 4087 $ECHO "\
adam@12 4088
adam@12 4089 if test -f \"\$progdir/\$program\"; then"
adam@12 4090
adam@12 4091 # fixup the dll searchpath if we need to.
adam@12 4092 #
adam@12 4093 # Fix the DLL searchpath if we need to. Do this before prepending
adam@12 4094 # to shlibpath, because on Windows, both are PATH and uninstalled
adam@12 4095 # libraries must come first.
adam@12 4096 if test -n "$dllsearchpath"; then
adam@12 4097 $ECHO "\
adam@12 4098 # Add the dll search path components to the executable PATH
adam@12 4099 PATH=$dllsearchpath:\$PATH
adam@12 4100 "
adam@12 4101 fi
adam@12 4102
adam@12 4103 # Export our shlibpath_var if we have one.
adam@12 4104 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
adam@12 4105 $ECHO "\
adam@12 4106 # Add our own library path to $shlibpath_var
adam@12 4107 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
adam@12 4108
adam@12 4109 # Some systems cannot cope with colon-terminated $shlibpath_var
adam@12 4110 # The second colon is a workaround for a bug in BeOS R4 sed
adam@12 4111 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
adam@12 4112
adam@12 4113 export $shlibpath_var
adam@12 4114 "
adam@12 4115 fi
adam@12 4116
adam@12 4117 $ECHO "\
adam@12 4118 if test \"\$libtool_execute_magic\" != \"$magic\"; then
adam@12 4119 # Run the actual program with our arguments.
adam@12 4120 func_exec_program \${1+\"\$@\"}
adam@12 4121 fi
adam@12 4122 else
adam@12 4123 # The program doesn't exist.
adam@12 4124 \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
adam@12 4125 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
adam@12 4126 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
adam@12 4127 exit 1
adam@0 4128 fi
adam@12 4129 fi\
adam@12 4130 "
adam@12 4131 }
adam@12 4132
adam@0 4133
adam@0 4134 # func_emit_cwrapperexe_src
adam@0 4135 # emit the source code for a wrapper executable on stdout
adam@0 4136 # Must ONLY be called from within func_mode_link because
adam@0 4137 # it depends on a number of variable set therein.
adam@0 4138 func_emit_cwrapperexe_src ()
adam@0 4139 {
adam@0 4140 cat <<EOF
adam@0 4141
adam@0 4142 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
adam@0 4143 Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
adam@0 4144
adam@0 4145 The $output program cannot be directly executed until all the libtool
adam@0 4146 libraries that it depends on are installed.
adam@0 4147
adam@0 4148 This wrapper executable should never be moved out of the build directory.
adam@0 4149 If it is, it will not operate correctly.
adam@0 4150 */
adam@0 4151 EOF
adam@0 4152 cat <<"EOF"
adam@12 4153 #ifdef _MSC_VER
adam@12 4154 # define _CRT_SECURE_NO_DEPRECATE 1
adam@12 4155 #endif
adam@0 4156 #include <stdio.h>
adam@0 4157 #include <stdlib.h>
adam@0 4158 #ifdef _MSC_VER
adam@0 4159 # include <direct.h>
adam@0 4160 # include <process.h>
adam@0 4161 # include <io.h>
adam@0 4162 #else
adam@0 4163 # include <unistd.h>
adam@0 4164 # include <stdint.h>
adam@0 4165 # ifdef __CYGWIN__
adam@0 4166 # include <io.h>
adam@0 4167 # endif
adam@0 4168 #endif
adam@0 4169 #include <malloc.h>
adam@0 4170 #include <stdarg.h>
adam@0 4171 #include <assert.h>
adam@0 4172 #include <string.h>
adam@0 4173 #include <ctype.h>
adam@0 4174 #include <errno.h>
adam@0 4175 #include <fcntl.h>
adam@0 4176 #include <sys/stat.h>
adam@0 4177
adam@12 4178 /* declarations of non-ANSI functions */
adam@12 4179 #if defined(__MINGW32__)
adam@12 4180 # ifdef __STRICT_ANSI__
adam@12 4181 int _putenv (const char *);
adam@12 4182 # endif
adam@12 4183 #elif defined(__CYGWIN__)
adam@12 4184 # ifdef __STRICT_ANSI__
adam@12 4185 char *realpath (const char *, char *);
adam@12 4186 int putenv (char *);
adam@12 4187 int setenv (const char *, const char *, int);
adam@12 4188 # endif
adam@12 4189 /* #elif defined (other platforms) ... */
adam@12 4190 #endif
adam@12 4191
adam@12 4192 /* portability defines, excluding path handling macros */
adam@12 4193 #if defined(_MSC_VER)
adam@12 4194 # define setmode _setmode
adam@12 4195 # define stat _stat
adam@12 4196 # define chmod _chmod
adam@12 4197 # define getcwd _getcwd
adam@12 4198 # define putenv _putenv
adam@12 4199 # define S_IXUSR _S_IEXEC
adam@12 4200 # ifndef _INTPTR_T_DEFINED
adam@12 4201 # define _INTPTR_T_DEFINED
adam@12 4202 # define intptr_t int
adam@12 4203 # endif
adam@12 4204 #elif defined(__MINGW32__)
adam@12 4205 # define setmode _setmode
adam@12 4206 # define stat _stat
adam@12 4207 # define chmod _chmod
adam@12 4208 # define getcwd _getcwd
adam@12 4209 # define putenv _putenv
adam@12 4210 #elif defined(__CYGWIN__)
adam@12 4211 # define HAVE_SETENV
adam@12 4212 # define FOPEN_WB "wb"
adam@12 4213 /* #elif defined (other platforms) ... */
adam@12 4214 #endif
adam@12 4215
adam@0 4216 #if defined(PATH_MAX)
adam@0 4217 # define LT_PATHMAX PATH_MAX
adam@0 4218 #elif defined(MAXPATHLEN)
adam@0 4219 # define LT_PATHMAX MAXPATHLEN
adam@0 4220 #else
adam@0 4221 # define LT_PATHMAX 1024
adam@0 4222 #endif
adam@0 4223
adam@0 4224 #ifndef S_IXOTH
adam@0 4225 # define S_IXOTH 0
adam@0 4226 #endif
adam@0 4227 #ifndef S_IXGRP
adam@0 4228 # define S_IXGRP 0
adam@0 4229 #endif
adam@0 4230
adam@12 4231 /* path handling portability macros */
adam@0 4232 #ifndef DIR_SEPARATOR
adam@0 4233 # define DIR_SEPARATOR '/'
adam@0 4234 # define PATH_SEPARATOR ':'
adam@0 4235 #endif
adam@0 4236
adam@0 4237 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
adam@0 4238 defined (__OS2__)
adam@0 4239 # define HAVE_DOS_BASED_FILE_SYSTEM
adam@0 4240 # define FOPEN_WB "wb"
adam@0 4241 # ifndef DIR_SEPARATOR_2
adam@0 4242 # define DIR_SEPARATOR_2 '\\'
adam@0 4243 # endif
adam@0 4244 # ifndef PATH_SEPARATOR_2
adam@0 4245 # define PATH_SEPARATOR_2 ';'
adam@0 4246 # endif
adam@0 4247 #endif
adam@0 4248
adam@0 4249 #ifndef DIR_SEPARATOR_2
adam@0 4250 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
adam@0 4251 #else /* DIR_SEPARATOR_2 */
adam@0 4252 # define IS_DIR_SEPARATOR(ch) \
adam@0 4253 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
adam@0 4254 #endif /* DIR_SEPARATOR_2 */
adam@0 4255
adam@0 4256 #ifndef PATH_SEPARATOR_2
adam@0 4257 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
adam@0 4258 #else /* PATH_SEPARATOR_2 */
adam@0 4259 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
adam@0 4260 #endif /* PATH_SEPARATOR_2 */
adam@0 4261
adam@0 4262 #ifndef FOPEN_WB
adam@0 4263 # define FOPEN_WB "w"
adam@0 4264 #endif
adam@0 4265 #ifndef _O_BINARY
adam@0 4266 # define _O_BINARY 0
adam@0 4267 #endif
adam@0 4268
adam@0 4269 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
adam@0 4270 #define XFREE(stale) do { \
adam@0 4271 if (stale) { free ((void *) stale); stale = 0; } \
adam@0 4272 } while (0)
adam@0 4273
adam@12 4274 #if defined(LT_DEBUGWRAPPER)
adam@12 4275 static int lt_debug = 1;
adam@0 4276 #else
adam@12 4277 static int lt_debug = 0;
adam@0 4278 #endif
adam@0 4279
adam@12 4280 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
adam@0 4281
adam@0 4282 void *xmalloc (size_t num);
adam@0 4283 char *xstrdup (const char *string);
adam@0 4284 const char *base_name (const char *name);
adam@0 4285 char *find_executable (const char *wrapper);
adam@0 4286 char *chase_symlinks (const char *pathspec);
adam@0 4287 int make_executable (const char *path);
adam@0 4288 int check_executable (const char *path);
adam@0 4289 char *strendzap (char *str, const char *pat);
adam@12 4290 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
adam@12 4291 void lt_fatal (const char *file, int line, const char *message, ...);
adam@12 4292 static const char *nonnull (const char *s);
adam@12 4293 static const char *nonempty (const char *s);
adam@0 4294 void lt_setenv (const char *name, const char *value);
adam@0 4295 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
adam@0 4296 void lt_update_exe_path (const char *name, const char *value);
adam@0 4297 void lt_update_lib_path (const char *name, const char *value);
adam@12 4298 char **prepare_spawn (char **argv);
adam@12 4299 void lt_dump_script (FILE *f);
adam@0 4300 EOF
adam@0 4301
adam@0 4302 cat <<EOF
adam@12 4303 volatile const char * MAGIC_EXE = "$magic_exe";
adam@0 4304 const char * LIB_PATH_VARNAME = "$shlibpath_var";
adam@0 4305 EOF
adam@0 4306
adam@0 4307 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
adam@12 4308 func_to_host_path "$temp_rpath"
adam@0 4309 cat <<EOF
adam@12 4310 const char * LIB_PATH_VALUE = "$func_to_host_path_result";
adam@0 4311 EOF
adam@0 4312 else
adam@0 4313 cat <<"EOF"
adam@0 4314 const char * LIB_PATH_VALUE = "";
adam@0 4315 EOF
adam@0 4316 fi
adam@0 4317
adam@0 4318 if test -n "$dllsearchpath"; then
adam@12 4319 func_to_host_path "$dllsearchpath:"
adam@0 4320 cat <<EOF
adam@0 4321 const char * EXE_PATH_VARNAME = "PATH";
adam@12 4322 const char * EXE_PATH_VALUE = "$func_to_host_path_result";
adam@0 4323 EOF
adam@0 4324 else
adam@0 4325 cat <<"EOF"
adam@0 4326 const char * EXE_PATH_VARNAME = "";
adam@0 4327 const char * EXE_PATH_VALUE = "";
adam@0 4328 EOF
adam@0 4329 fi
adam@0 4330
adam@0 4331 if test "$fast_install" = yes; then
adam@0 4332 cat <<EOF
adam@0 4333 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
adam@0 4334 EOF
adam@0 4335 else
adam@0 4336 cat <<EOF
adam@0 4337 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
adam@0 4338 EOF
adam@0 4339 fi
adam@0 4340
adam@0 4341
adam@0 4342 cat <<"EOF"
adam@0 4343
adam@0 4344 #define LTWRAPPER_OPTION_PREFIX "--lt-"
adam@12 4345
adam@0 4346 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
adam@0 4347 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
adam@12 4348 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
adam@0 4349
adam@0 4350 int
adam@0 4351 main (int argc, char *argv[])
adam@0 4352 {
adam@0 4353 char **newargz;
adam@0 4354 int newargc;
adam@0 4355 char *tmp_pathspec;
adam@0 4356 char *actual_cwrapper_path;
adam@0 4357 char *actual_cwrapper_name;
adam@0 4358 char *target_name;
adam@0 4359 char *lt_argv_zero;
adam@0 4360 intptr_t rval = 127;
adam@0 4361
adam@0 4362 int i;
adam@0 4363
adam@0 4364 program_name = (char *) xstrdup (base_name (argv[0]));
adam@12 4365 newargz = XMALLOC (char *, argc + 1);
adam@12 4366
adam@12 4367 /* very simple arg parsing; don't want to rely on getopt
adam@12 4368 * also, copy all non cwrapper options to newargz, except
adam@12 4369 * argz[0], which is handled differently
adam@12 4370 */
adam@12 4371 newargc=0;
adam@0 4372 for (i = 1; i < argc; i++)
adam@0 4373 {
adam@0 4374 if (strcmp (argv[i], dumpscript_opt) == 0)
adam@0 4375 {
adam@0 4376 EOF
adam@0 4377 case "$host" in
adam@0 4378 *mingw* | *cygwin* )
adam@0 4379 # make stdout use "unix" line endings
adam@0 4380 echo " setmode(1,_O_BINARY);"
adam@0 4381 ;;
adam@0 4382 esac
adam@0 4383
adam@0 4384 cat <<"EOF"
adam@12 4385 lt_dump_script (stdout);
adam@0 4386 return 0;
adam@0 4387 }
adam@12 4388 if (strcmp (argv[i], debug_opt) == 0)
adam@12 4389 {
adam@12 4390 lt_debug = 1;
adam@12 4391 continue;
adam@12 4392 }
adam@12 4393 if (strcmp (argv[i], ltwrapper_option_prefix) == 0)
adam@12 4394 {
adam@12 4395 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
adam@12 4396 namespace, but it is not one of the ones we know about and
adam@12 4397 have already dealt with, above (inluding dump-script), then
adam@12 4398 report an error. Otherwise, targets might begin to believe
adam@12 4399 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
adam@12 4400 namespace. The first time any user complains about this, we'll
adam@12 4401 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
adam@12 4402 or a configure.ac-settable value.
adam@12 4403 */
adam@12 4404 lt_fatal (__FILE__, __LINE__,
adam@12 4405 "unrecognized %s option: '%s'",
adam@12 4406 ltwrapper_option_prefix, argv[i]);
adam@12 4407 }
adam@12 4408 /* otherwise ... */
adam@12 4409 newargz[++newargc] = xstrdup (argv[i]);
adam@0 4410 }
adam@12 4411 newargz[++newargc] = NULL;
adam@12 4412
adam@12 4413 EOF
adam@12 4414 cat <<EOF
adam@12 4415 /* The GNU banner must be the first non-error debug message */
adam@12 4416 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE$TIMESTAMP) $VERSION\n");
adam@12 4417 EOF
adam@12 4418 cat <<"EOF"
adam@12 4419 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
adam@12 4420 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
adam@12 4421
adam@0 4422 tmp_pathspec = find_executable (argv[0]);
adam@0 4423 if (tmp_pathspec == NULL)
adam@12 4424 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
adam@12 4425 lt_debugprintf (__FILE__, __LINE__,
adam@12 4426 "(main) found exe (before symlink chase) at: %s\n",
adam@12 4427 tmp_pathspec);
adam@0 4428
adam@0 4429 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
adam@12 4430 lt_debugprintf (__FILE__, __LINE__,
adam@12 4431 "(main) found exe (after symlink chase) at: %s\n",
adam@12 4432 actual_cwrapper_path);
adam@0 4433 XFREE (tmp_pathspec);
adam@0 4434
adam@12 4435 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
adam@0 4436 strendzap (actual_cwrapper_path, actual_cwrapper_name);
adam@0 4437
adam@0 4438 /* wrapper name transforms */
adam@0 4439 strendzap (actual_cwrapper_name, ".exe");
adam@0 4440 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
adam@0 4441 XFREE (actual_cwrapper_name);
adam@0 4442 actual_cwrapper_name = tmp_pathspec;
adam@0 4443 tmp_pathspec = 0;
adam@0 4444
adam@0 4445 /* target_name transforms -- use actual target program name; might have lt- prefix */
adam@0 4446 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
adam@0 4447 strendzap (target_name, ".exe");
adam@0 4448 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
adam@0 4449 XFREE (target_name);
adam@0 4450 target_name = tmp_pathspec;
adam@0 4451 tmp_pathspec = 0;
adam@0 4452
adam@12 4453 lt_debugprintf (__FILE__, __LINE__,
adam@12 4454 "(main) libtool target name: %s\n",
adam@12 4455 target_name);
adam@0 4456 EOF
adam@0 4457
adam@0 4458 cat <<EOF
adam@0 4459 newargz[0] =
adam@0 4460 XMALLOC (char, (strlen (actual_cwrapper_path) +
adam@0 4461 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
adam@0 4462 strcpy (newargz[0], actual_cwrapper_path);
adam@0 4463 strcat (newargz[0], "$objdir");
adam@0 4464 strcat (newargz[0], "/");
adam@0 4465 EOF
adam@0 4466
adam@0 4467 cat <<"EOF"
adam@0 4468 /* stop here, and copy so we don't have to do this twice */
adam@0 4469 tmp_pathspec = xstrdup (newargz[0]);
adam@0 4470
adam@0 4471 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
adam@0 4472 strcat (newargz[0], actual_cwrapper_name);
adam@0 4473
adam@0 4474 /* DO want the lt- prefix here if it exists, so use target_name */
adam@0 4475 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
adam@0 4476 XFREE (tmp_pathspec);
adam@0 4477 tmp_pathspec = NULL;
adam@0 4478 EOF
adam@0 4479
adam@0 4480 case $host_os in
adam@0 4481 mingw*)
adam@0 4482 cat <<"EOF"
adam@0 4483 {
adam@0 4484 char* p;
adam@0 4485 while ((p = strchr (newargz[0], '\\')) != NULL)
adam@0 4486 {
adam@0 4487 *p = '/';
adam@0 4488 }
adam@0 4489 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
adam@0 4490 {
adam@0 4491 *p = '/';
adam@0 4492 }
adam@0 4493 }
adam@0 4494 EOF
adam@0 4495 ;;
adam@0 4496 esac
adam@0 4497
adam@0 4498 cat <<"EOF"
adam@0 4499 XFREE (target_name);
adam@0 4500 XFREE (actual_cwrapper_path);
adam@0 4501 XFREE (actual_cwrapper_name);
adam@0 4502
adam@0 4503 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
adam@0 4504 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
adam@12 4505 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
adam@12 4506 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
adam@12 4507 because on Windows, both *_VARNAMEs are PATH but uninstalled
adam@12 4508 libraries must come first. */
adam@12 4509 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
adam@0 4510 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
adam@12 4511
adam@12 4512 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
adam@12 4513 nonnull (lt_argv_zero));
adam@0 4514 for (i = 0; i < newargc; i++)
adam@0 4515 {
adam@12 4516 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
adam@12 4517 i, nonnull (newargz[i]));
adam@0 4518 }
adam@0 4519
adam@0 4520 EOF
adam@0 4521
adam@0 4522 case $host_os in
adam@0 4523 mingw*)
adam@0 4524 cat <<"EOF"
adam@0 4525 /* execv doesn't actually work on mingw as expected on unix */
adam@12 4526 newargz = prepare_spawn (newargz);
adam@0 4527 rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
adam@0 4528 if (rval == -1)
adam@0 4529 {
adam@0 4530 /* failed to start process */
adam@12 4531 lt_debugprintf (__FILE__, __LINE__,
adam@12 4532 "(main) failed to launch target \"%s\": %s\n",
adam@12 4533 lt_argv_zero, nonnull (strerror (errno)));
adam@0 4534 return 127;
adam@0 4535 }
adam@0 4536 return rval;
adam@0 4537 EOF
adam@0 4538 ;;
adam@0 4539 *)
adam@0 4540 cat <<"EOF"
adam@0 4541 execv (lt_argv_zero, newargz);
adam@0 4542 return rval; /* =127, but avoids unused variable warning */
adam@0 4543 EOF
adam@0 4544 ;;
adam@0 4545 esac
adam@0 4546
adam@0 4547 cat <<"EOF"
adam@0 4548 }
adam@0 4549
adam@0 4550 void *
adam@0 4551 xmalloc (size_t num)
adam@0 4552 {
adam@0 4553 void *p = (void *) malloc (num);
adam@0 4554 if (!p)
adam@12 4555 lt_fatal (__FILE__, __LINE__, "memory exhausted");
adam@0 4556
adam@0 4557 return p;
adam@0 4558 }
adam@0 4559
adam@0 4560 char *
adam@0 4561 xstrdup (const char *string)
adam@0 4562 {
adam@0 4563 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
adam@0 4564 string) : NULL;
adam@0 4565 }
adam@0 4566
adam@0 4567 const char *
adam@0 4568 base_name (const char *name)
adam@0 4569 {
adam@0 4570 const char *base;
adam@0 4571
adam@0 4572 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
adam@0 4573 /* Skip over the disk name in MSDOS pathnames. */
adam@0 4574 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
adam@0 4575 name += 2;
adam@0 4576 #endif
adam@0 4577
adam@0 4578 for (base = name; *name; name++)
adam@0 4579 if (IS_DIR_SEPARATOR (*name))
adam@0 4580 base = name + 1;
adam@0 4581 return base;
adam@0 4582 }
adam@0 4583
adam@0 4584 int
adam@0 4585 check_executable (const char *path)
adam@0 4586 {
adam@0 4587 struct stat st;
adam@0 4588
adam@12 4589 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
adam@12 4590 nonempty (path));
adam@0 4591 if ((!path) || (!*path))
adam@0 4592 return 0;
adam@0 4593
adam@0 4594 if ((stat (path, &st) >= 0)
adam@0 4595 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
adam@0 4596 return 1;
adam@0 4597 else
adam@0 4598 return 0;
adam@0 4599 }
adam@0 4600
adam@0 4601 int
adam@0 4602 make_executable (const char *path)
adam@0 4603 {
adam@0 4604 int rval = 0;
adam@0 4605 struct stat st;
adam@0 4606
adam@12 4607 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
adam@12 4608 nonempty (path));
adam@0 4609 if ((!path) || (!*path))
adam@0 4610 return 0;
adam@0 4611
adam@0 4612 if (stat (path, &st) >= 0)
adam@0 4613 {
adam@0 4614 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
adam@0 4615 }
adam@0 4616 return rval;
adam@0 4617 }
adam@0 4618
adam@0 4619 /* Searches for the full path of the wrapper. Returns
adam@0 4620 newly allocated full path name if found, NULL otherwise
adam@0 4621 Does not chase symlinks, even on platforms that support them.
adam@0 4622 */
adam@0 4623 char *
adam@0 4624 find_executable (const char *wrapper)
adam@0 4625 {
adam@0 4626 int has_slash = 0;
adam@0 4627 const char *p;
adam@0 4628 const char *p_next;
adam@0 4629 /* static buffer for getcwd */
adam@0 4630 char tmp[LT_PATHMAX + 1];
adam@0 4631 int tmp_len;
adam@0 4632 char *concat_name;
adam@0 4633
adam@12 4634 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
adam@12 4635 nonempty (wrapper));
adam@0 4636
adam@0 4637 if ((wrapper == NULL) || (*wrapper == '\0'))
adam@0 4638 return NULL;
adam@0 4639
adam@0 4640 /* Absolute path? */
adam@0 4641 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
adam@0 4642 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
adam@0 4643 {
adam@0 4644 concat_name = xstrdup (wrapper);
adam@0 4645 if (check_executable (concat_name))
adam@0 4646 return concat_name;
adam@0 4647 XFREE (concat_name);
adam@0 4648 }
adam@0 4649 else
adam@0 4650 {
adam@0 4651 #endif
adam@0 4652 if (IS_DIR_SEPARATOR (wrapper[0]))
adam@0 4653 {
adam@0 4654 concat_name = xstrdup (wrapper);
adam@0 4655 if (check_executable (concat_name))
adam@0 4656 return concat_name;
adam@0 4657 XFREE (concat_name);
adam@0 4658 }
adam@0 4659 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
adam@0 4660 }
adam@0 4661 #endif
adam@0 4662
adam@0 4663 for (p = wrapper; *p; p++)
adam@0 4664 if (*p == '/')
adam@0 4665 {
adam@0 4666 has_slash = 1;
adam@0 4667 break;
adam@0 4668 }
adam@0 4669 if (!has_slash)
adam@0 4670 {
adam@0 4671 /* no slashes; search PATH */
adam@0 4672 const char *path = getenv ("PATH");
adam@0 4673 if (path != NULL)
adam@0 4674 {
adam@0 4675 for (p = path; *p; p = p_next)
adam@0 4676 {
adam@0 4677 const char *q;
adam@0 4678 size_t p_len;
adam@0 4679 for (q = p; *q; q++)
adam@0 4680 if (IS_PATH_SEPARATOR (*q))
adam@0 4681 break;
adam@0 4682 p_len = q - p;
adam@0 4683 p_next = (*q == '\0' ? q : q + 1);
adam@0 4684 if (p_len == 0)
adam@0 4685 {
adam@0 4686 /* empty path: current directory */
adam@0 4687 if (getcwd (tmp, LT_PATHMAX) == NULL)
adam@12 4688 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
adam@12 4689 nonnull (strerror (errno)));
adam@0 4690 tmp_len = strlen (tmp);
adam@0 4691 concat_name =
adam@0 4692 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
adam@0 4693 memcpy (concat_name, tmp, tmp_len);
adam@0 4694 concat_name[tmp_len] = '/';
adam@0 4695 strcpy (concat_name + tmp_len + 1, wrapper);
adam@0 4696 }
adam@0 4697 else
adam@0 4698 {
adam@0 4699 concat_name =
adam@0 4700 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
adam@0 4701 memcpy (concat_name, p, p_len);
adam@0 4702 concat_name[p_len] = '/';
adam@0 4703 strcpy (concat_name + p_len + 1, wrapper);
adam@0 4704 }
adam@0 4705 if (check_executable (concat_name))
adam@0 4706 return concat_name;
adam@0 4707 XFREE (concat_name);
adam@0 4708 }
adam@0 4709 }
adam@0 4710 /* not found in PATH; assume curdir */
adam@0 4711 }
adam@0 4712 /* Relative path | not found in path: prepend cwd */
adam@0 4713 if (getcwd (tmp, LT_PATHMAX) == NULL)
adam@12 4714 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
adam@12 4715 nonnull (strerror (errno)));
adam@0 4716 tmp_len = strlen (tmp);
adam@0 4717 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
adam@0 4718 memcpy (concat_name, tmp, tmp_len);
adam@0 4719 concat_name[tmp_len] = '/';
adam@0 4720 strcpy (concat_name + tmp_len + 1, wrapper);
adam@0 4721
adam@0 4722 if (check_executable (concat_name))
adam@0 4723 return concat_name;
adam@0 4724 XFREE (concat_name);
adam@0 4725 return NULL;
adam@0 4726 }
adam@0 4727
adam@0 4728 char *
adam@0 4729 chase_symlinks (const char *pathspec)
adam@0 4730 {
adam@0 4731 #ifndef S_ISLNK
adam@0 4732 return xstrdup (pathspec);
adam@0 4733 #else
adam@0 4734 char buf[LT_PATHMAX];
adam@0 4735 struct stat s;
adam@0 4736 char *tmp_pathspec = xstrdup (pathspec);
adam@0 4737 char *p;
adam@0 4738 int has_symlinks = 0;
adam@0 4739 while (strlen (tmp_pathspec) && !has_symlinks)
adam@0 4740 {
adam@12 4741 lt_debugprintf (__FILE__, __LINE__,
adam@12 4742 "checking path component for symlinks: %s\n",
adam@12 4743 tmp_pathspec);
adam@0 4744 if (lstat (tmp_pathspec, &s) == 0)
adam@0 4745 {
adam@0 4746 if (S_ISLNK (s.st_mode) != 0)
adam@0 4747 {
adam@0 4748 has_symlinks = 1;
adam@0 4749 break;
adam@0 4750 }
adam@0 4751
adam@0 4752 /* search backwards for last DIR_SEPARATOR */
adam@0 4753 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
adam@0 4754 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
adam@0 4755 p--;
adam@0 4756 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
adam@0 4757 {
adam@0 4758 /* no more DIR_SEPARATORS left */
adam@0 4759 break;
adam@0 4760 }
adam@0 4761 *p = '\0';
adam@0 4762 }
adam@0 4763 else
adam@0 4764 {
adam@12 4765 lt_fatal (__FILE__, __LINE__,
adam@12 4766 "error accessing file \"%s\": %s",
adam@12 4767 tmp_pathspec, nonnull (strerror (errno)));
adam@0 4768 }
adam@0 4769 }
adam@0 4770 XFREE (tmp_pathspec);
adam@0 4771
adam@0 4772 if (!has_symlinks)
adam@0 4773 {
adam@0 4774 return xstrdup (pathspec);
adam@0 4775 }
adam@0 4776
adam@0 4777 tmp_pathspec = realpath (pathspec, buf);
adam@0 4778 if (tmp_pathspec == 0)
adam@0 4779 {
adam@12 4780 lt_fatal (__FILE__, __LINE__,
adam@12 4781 "could not follow symlinks for %s", pathspec);
adam@0 4782 }
adam@0 4783 return xstrdup (tmp_pathspec);
adam@0 4784 #endif
adam@0 4785 }
adam@0 4786
adam@0 4787 char *
adam@0 4788 strendzap (char *str, const char *pat)
adam@0 4789 {
adam@0 4790 size_t len, patlen;
adam@0 4791
adam@0 4792 assert (str != NULL);
adam@0 4793 assert (pat != NULL);
adam@0 4794
adam@0 4795 len = strlen (str);
adam@0 4796 patlen = strlen (pat);
adam@0 4797
adam@0 4798 if (patlen <= len)
adam@0 4799 {
adam@0 4800 str += len - patlen;
adam@0 4801 if (strcmp (str, pat) == 0)
adam@0 4802 *str = '\0';
adam@0 4803 }
adam@0 4804 return str;
adam@0 4805 }
adam@0 4806
adam@12 4807 void
adam@12 4808 lt_debugprintf (const char *file, int line, const char *fmt, ...)
adam@12 4809 {
adam@12 4810 va_list args;
adam@12 4811 if (lt_debug)
adam@12 4812 {
adam@12 4813 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
adam@12 4814 va_start (args, fmt);
adam@12 4815 (void) vfprintf (stderr, fmt, args);
adam@12 4816 va_end (args);
adam@12 4817 }
adam@12 4818 }
adam@12 4819
adam@0 4820 static void
adam@12 4821 lt_error_core (int exit_status, const char *file,
adam@12 4822 int line, const char *mode,
adam@0 4823 const char *message, va_list ap)
adam@0 4824 {
adam@12 4825 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
adam@0 4826 vfprintf (stderr, message, ap);
adam@0 4827 fprintf (stderr, ".\n");
adam@0 4828
adam@0 4829 if (exit_status >= 0)
adam@0 4830 exit (exit_status);
adam@0 4831 }
adam@0 4832
adam@0 4833 void
adam@12 4834 lt_fatal (const char *file, int line, const char *message, ...)
adam@0 4835 {
adam@0 4836 va_list ap;
adam@0 4837 va_start (ap, message);
adam@12 4838 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
adam@0 4839 va_end (ap);
adam@0 4840 }
adam@0 4841
adam@12 4842 static const char *
adam@12 4843 nonnull (const char *s)
adam@12 4844 {
adam@12 4845 return s ? s : "(null)";
adam@12 4846 }
adam@12 4847
adam@12 4848 static const char *
adam@12 4849 nonempty (const char *s)
adam@12 4850 {
adam@12 4851 return (s && !*s) ? "(empty)" : nonnull (s);
adam@12 4852 }
adam@12 4853
adam@0 4854 void
adam@0 4855 lt_setenv (const char *name, const char *value)
adam@0 4856 {
adam@12 4857 lt_debugprintf (__FILE__, __LINE__,
adam@12 4858 "(lt_setenv) setting '%s' to '%s'\n",
adam@12 4859 nonnull (name), nonnull (value));
adam@0 4860 {
adam@0 4861 #ifdef HAVE_SETENV
adam@0 4862 /* always make a copy, for consistency with !HAVE_SETENV */
adam@0 4863 char *str = xstrdup (value);
adam@0 4864 setenv (name, str, 1);
adam@0 4865 #else
adam@0 4866 int len = strlen (name) + 1 + strlen (value) + 1;
adam@0 4867 char *str = XMALLOC (char, len);
adam@0 4868 sprintf (str, "%s=%s", name, value);
adam@0 4869 if (putenv (str) != EXIT_SUCCESS)
adam@0 4870 {
adam@0 4871 XFREE (str);
adam@0 4872 }
adam@0 4873 #endif
adam@0 4874 }
adam@0 4875 }
adam@0 4876
adam@0 4877 char *
adam@0 4878 lt_extend_str (const char *orig_value, const char *add, int to_end)
adam@0 4879 {
adam@0 4880 char *new_value;
adam@0 4881 if (orig_value && *orig_value)
adam@0 4882 {
adam@0 4883 int orig_value_len = strlen (orig_value);
adam@0 4884 int add_len = strlen (add);
adam@0 4885 new_value = XMALLOC (char, add_len + orig_value_len + 1);
adam@0 4886 if (to_end)
adam@0 4887 {
adam@0 4888 strcpy (new_value, orig_value);
adam@0 4889 strcpy (new_value + orig_value_len, add);
adam@0 4890 }
adam@0 4891 else
adam@0 4892 {
adam@0 4893 strcpy (new_value, add);
adam@0 4894 strcpy (new_value + add_len, orig_value);
adam@0 4895 }
adam@0 4896 }
adam@0 4897 else
adam@0 4898 {
adam@0 4899 new_value = xstrdup (add);
adam@0 4900 }
adam@0 4901 return new_value;
adam@0 4902 }
adam@0 4903
adam@0 4904 void
adam@0 4905 lt_update_exe_path (const char *name, const char *value)
adam@0 4906 {
adam@12 4907 lt_debugprintf (__FILE__, __LINE__,
adam@12 4908 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
adam@12 4909 nonnull (name), nonnull (value));
adam@0 4910
adam@0 4911 if (name && *name && value && *value)
adam@0 4912 {
adam@0 4913 char *new_value = lt_extend_str (getenv (name), value, 0);
adam@0 4914 /* some systems can't cope with a ':'-terminated path #' */
adam@0 4915 int len = strlen (new_value);
adam@0 4916 while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
adam@0 4917 {
adam@0 4918 new_value[len-1] = '\0';
adam@0 4919 }
adam@0 4920 lt_setenv (name, new_value);
adam@0 4921 XFREE (new_value);
adam@0 4922 }
adam@0 4923 }
adam@0 4924
adam@0 4925 void
adam@0 4926 lt_update_lib_path (const char *name, const char *value)
adam@0 4927 {
adam@12 4928 lt_debugprintf (__FILE__, __LINE__,
adam@12 4929 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
adam@12 4930 nonnull (name), nonnull (value));
adam@0 4931
adam@0 4932 if (name && *name && value && *value)
adam@0 4933 {
adam@0 4934 char *new_value = lt_extend_str (getenv (name), value, 0);
adam@0 4935 lt_setenv (name, new_value);
adam@0 4936 XFREE (new_value);
adam@0 4937 }
adam@0 4938 }
adam@0 4939
adam@0 4940 EOF
adam@12 4941 case $host_os in
adam@12 4942 mingw*)
adam@12 4943 cat <<"EOF"
adam@12 4944
adam@12 4945 /* Prepares an argument vector before calling spawn().
adam@12 4946 Note that spawn() does not by itself call the command interpreter
adam@12 4947 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
adam@12 4948 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
adam@12 4949 GetVersionEx(&v);
adam@12 4950 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
adam@12 4951 }) ? "cmd.exe" : "command.com").
adam@12 4952 Instead it simply concatenates the arguments, separated by ' ', and calls
adam@12 4953 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
adam@12 4954 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
adam@12 4955 special way:
adam@12 4956 - Space and tab are interpreted as delimiters. They are not treated as
adam@12 4957 delimiters if they are surrounded by double quotes: "...".
adam@12 4958 - Unescaped double quotes are removed from the input. Their only effect is
adam@12 4959 that within double quotes, space and tab are treated like normal
adam@12 4960 characters.
adam@12 4961 - Backslashes not followed by double quotes are not special.
adam@12 4962 - But 2*n+1 backslashes followed by a double quote become
adam@12 4963 n backslashes followed by a double quote (n >= 0):
adam@12 4964 \" -> "
adam@12 4965 \\\" -> \"
adam@12 4966 \\\\\" -> \\"
adam@12 4967 */
adam@12 4968 #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"
adam@12 4969 #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"
adam@12 4970 char **
adam@12 4971 prepare_spawn (char **argv)
adam@12 4972 {
adam@12 4973 size_t argc;
adam@12 4974 char **new_argv;
adam@12 4975 size_t i;
adam@12 4976
adam@12 4977 /* Count number of arguments. */
adam@12 4978 for (argc = 0; argv[argc] != NULL; argc++)
adam@12 4979 ;
adam@12 4980
adam@12 4981 /* Allocate new argument vector. */
adam@12 4982 new_argv = XMALLOC (char *, argc + 1);
adam@12 4983
adam@12 4984 /* Put quoted arguments into the new argument vector. */
adam@12 4985 for (i = 0; i < argc; i++)
adam@12 4986 {
adam@12 4987 const char *string = argv[i];
adam@12 4988
adam@12 4989 if (string[0] == '\0')
adam@12 4990 new_argv[i] = xstrdup ("\"\"");
adam@12 4991 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
adam@12 4992 {
adam@12 4993 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
adam@12 4994 size_t length;
adam@12 4995 unsigned int backslashes;
adam@12 4996 const char *s;
adam@12 4997 char *quoted_string;
adam@12 4998 char *p;
adam@12 4999
adam@12 5000 length = 0;
adam@12 5001 backslashes = 0;
adam@12 5002 if (quote_around)
adam@12 5003 length++;
adam@12 5004 for (s = string; *s != '\0'; s++)
adam@12 5005 {
adam@12 5006 char c = *s;
adam@12 5007 if (c == '"')
adam@12 5008 length += backslashes + 1;
adam@12 5009 length++;
adam@12 5010 if (c == '\\')
adam@12 5011 backslashes++;
adam@12 5012 else
adam@12 5013 backslashes = 0;
adam@12 5014 }
adam@12 5015 if (quote_around)
adam@12 5016 length += backslashes + 1;
adam@12 5017
adam@12 5018 quoted_string = XMALLOC (char, length + 1);
adam@12 5019
adam@12 5020 p = quoted_string;
adam@12 5021 backslashes = 0;
adam@12 5022 if (quote_around)
adam@12 5023 *p++ = '"';
adam@12 5024 for (s = string; *s != '\0'; s++)
adam@12 5025 {
adam@12 5026 char c = *s;
adam@12 5027 if (c == '"')
adam@12 5028 {
adam@12 5029 unsigned int j;
adam@12 5030 for (j = backslashes + 1; j > 0; j--)
adam@12 5031 *p++ = '\\';
adam@12 5032 }
adam@12 5033 *p++ = c;
adam@12 5034 if (c == '\\')
adam@12 5035 backslashes++;
adam@12 5036 else
adam@12 5037 backslashes = 0;
adam@12 5038 }
adam@12 5039 if (quote_around)
adam@12 5040 {
adam@12 5041 unsigned int j;
adam@12 5042 for (j = backslashes; j > 0; j--)
adam@12 5043 *p++ = '\\';
adam@12 5044 *p++ = '"';
adam@12 5045 }
adam@12 5046 *p = '\0';
adam@12 5047
adam@12 5048 new_argv[i] = quoted_string;
adam@12 5049 }
adam@12 5050 else
adam@12 5051 new_argv[i] = (char *) string;
adam@12 5052 }
adam@12 5053 new_argv[argc] = NULL;
adam@12 5054
adam@12 5055 return new_argv;
adam@12 5056 }
adam@12 5057 EOF
adam@12 5058 ;;
adam@12 5059 esac
adam@12 5060
adam@12 5061 cat <<"EOF"
adam@12 5062 void lt_dump_script (FILE* f)
adam@12 5063 {
adam@12 5064 EOF
adam@12 5065 func_emit_wrapper yes |
adam@20 5066 $SED -n -e '
adam@20 5067 s/^\(.\{79\}\)\(..*\)/\1\
adam@20 5068 \2/
adam@20 5069 h
adam@20 5070 s/\([\\"]\)/\\\1/g
adam@20 5071 s/$/\\n/
adam@20 5072 s/\([^\n]*\).*/ fputs ("\1", f);/p
adam@20 5073 g
adam@20 5074 D'
adam@12 5075 cat <<"EOF"
adam@12 5076 }
adam@12 5077 EOF
adam@0 5078 }
adam@0 5079 # end: func_emit_cwrapperexe_src
adam@0 5080
adam@12 5081 # func_win32_import_lib_p ARG
adam@12 5082 # True if ARG is an import lib, as indicated by $file_magic_cmd
adam@12 5083 func_win32_import_lib_p ()
adam@12 5084 {
adam@12 5085 $opt_debug
adam@12 5086 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
adam@12 5087 *import*) : ;;
adam@12 5088 *) false ;;
adam@12 5089 esac
adam@12 5090 }
adam@12 5091
adam@0 5092 # func_mode_link arg...
adam@0 5093 func_mode_link ()
adam@0 5094 {
adam@0 5095 $opt_debug
adam@0 5096 case $host in
adam@0 5097 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
adam@0 5098 # It is impossible to link a dll without this setting, and
adam@0 5099 # we shouldn't force the makefile maintainer to figure out
adam@0 5100 # which system we are compiling for in order to pass an extra
adam@0 5101 # flag for every libtool invocation.
adam@0 5102 # allow_undefined=no
adam@0 5103
adam@0 5104 # FIXME: Unfortunately, there are problems with the above when trying
adam@0 5105 # to make a dll which has undefined symbols, in which case not
adam@0 5106 # even a static library is built. For now, we need to specify
adam@0 5107 # -no-undefined on the libtool link line when we can be certain
adam@0 5108 # that all symbols are satisfied, otherwise we get a static library.
adam@0 5109 allow_undefined=yes
adam@0 5110 ;;
adam@0 5111 *)
adam@0 5112 allow_undefined=yes
adam@0 5113 ;;
adam@0 5114 esac
adam@0 5115 libtool_args=$nonopt
adam@0 5116 base_compile="$nonopt $@"
adam@0 5117 compile_command=$nonopt
adam@0 5118 finalize_command=$nonopt
adam@0 5119
adam@0 5120 compile_rpath=
adam@0 5121 finalize_rpath=
adam@0 5122 compile_shlibpath=
adam@0 5123 finalize_shlibpath=
adam@0 5124 convenience=
adam@0 5125 old_convenience=
adam@0 5126 deplibs=
adam@0 5127 old_deplibs=
adam@0 5128 compiler_flags=
adam@0 5129 linker_flags=
adam@0 5130 dllsearchpath=
adam@0 5131 lib_search_path=`pwd`
adam@0 5132 inst_prefix_dir=
adam@0 5133 new_inherited_linker_flags=
adam@0 5134
adam@0 5135 avoid_version=no
adam@12 5136 bindir=
adam@0 5137 dlfiles=
adam@0 5138 dlprefiles=
adam@0 5139 dlself=no
adam@0 5140 export_dynamic=no
adam@0 5141 export_symbols=
adam@0 5142 export_symbols_regex=
adam@0 5143 generated=
adam@0 5144 libobjs=
adam@0 5145 ltlibs=
adam@0 5146 module=no
adam@0 5147 no_install=no
adam@0 5148 objs=
adam@0 5149 non_pic_objects=
adam@0 5150 precious_files_regex=
adam@0 5151 prefer_static_libs=no
adam@0 5152 preload=no
adam@0 5153 prev=
adam@0 5154 prevarg=
adam@0 5155 release=
adam@0 5156 rpath=
adam@0 5157 xrpath=
adam@0 5158 perm_rpath=
adam@0 5159 temp_rpath=
adam@0 5160 thread_safe=no
adam@0 5161 vinfo=
adam@0 5162 vinfo_number=no
adam@0 5163 weak_libs=
adam@0 5164 single_module="${wl}-single_module"
adam@0 5165 func_infer_tag $base_compile
adam@0 5166
adam@0 5167 # We need to know -static, to get the right output filenames.
adam@0 5168 for arg
adam@0 5169 do
adam@0 5170 case $arg in
adam@0 5171 -shared)
adam@0 5172 test "$build_libtool_libs" != yes && \
adam@0 5173 func_fatal_configuration "can not build a shared library"
adam@0 5174 build_old_libs=no
adam@0 5175 break
adam@0 5176 ;;
adam@0 5177 -all-static | -static | -static-libtool-libs)
adam@0 5178 case $arg in
adam@0 5179 -all-static)
adam@0 5180 if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
adam@0 5181 func_warning "complete static linking is impossible in this configuration"
adam@0 5182 fi
adam@0 5183 if test -n "$link_static_flag"; then
adam@0 5184 dlopen_self=$dlopen_self_static
adam@0 5185 fi
adam@0 5186 prefer_static_libs=yes
adam@0 5187 ;;
adam@0 5188 -static)
adam@0 5189 if test -z "$pic_flag" && test -n "$link_static_flag"; then
adam@0 5190 dlopen_self=$dlopen_self_static
adam@0 5191 fi
adam@0 5192 prefer_static_libs=built
adam@0 5193 ;;
adam@0 5194 -static-libtool-libs)
adam@0 5195 if test -z "$pic_flag" && test -n "$link_static_flag"; then
adam@0 5196 dlopen_self=$dlopen_self_static
adam@0 5197 fi
adam@0 5198 prefer_static_libs=yes
adam@0 5199 ;;
adam@0 5200 esac
adam@0 5201 build_libtool_libs=no
adam@0 5202 build_old_libs=yes
adam@0 5203 break
adam@0 5204 ;;
adam@0 5205 esac
adam@0 5206 done
adam@0 5207
adam@0 5208 # See if our shared archives depend on static archives.
adam@0 5209 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
adam@0 5210
adam@0 5211 # Go through the arguments, transforming them on the way.
adam@0 5212 while test "$#" -gt 0; do
adam@0 5213 arg="$1"
adam@0 5214 shift
adam@0 5215 func_quote_for_eval "$arg"
adam@0 5216 qarg=$func_quote_for_eval_unquoted_result
adam@0 5217 func_append libtool_args " $func_quote_for_eval_result"
adam@0 5218
adam@0 5219 # If the previous option needs an argument, assign it.
adam@0 5220 if test -n "$prev"; then
adam@0 5221 case $prev in
adam@0 5222 output)
adam@0 5223 func_append compile_command " @OUTPUT@"
adam@0 5224 func_append finalize_command " @OUTPUT@"
adam@0 5225 ;;
adam@0 5226 esac
adam@0 5227
adam@0 5228 case $prev in
adam@12 5229 bindir)
adam@12 5230 bindir="$arg"
adam@12 5231 prev=
adam@12 5232 continue
adam@12 5233 ;;
adam@0 5234 dlfiles|dlprefiles)
adam@0 5235 if test "$preload" = no; then
adam@0 5236 # Add the symbol object into the linking commands.
adam@0 5237 func_append compile_command " @SYMFILE@"
adam@0 5238 func_append finalize_command " @SYMFILE@"
adam@0 5239 preload=yes
adam@0 5240 fi
adam@0 5241 case $arg in
adam@0 5242 *.la | *.lo) ;; # We handle these cases below.
adam@0 5243 force)
adam@0 5244 if test "$dlself" = no; then
adam@0 5245 dlself=needless
adam@0 5246 export_dynamic=yes
adam@0 5247 fi
adam@0 5248 prev=
adam@0 5249 continue
adam@0 5250 ;;
adam@0 5251 self)
adam@0 5252 if test "$prev" = dlprefiles; then
adam@0 5253 dlself=yes
adam@0 5254 elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
adam@0 5255 dlself=yes
adam@0 5256 else
adam@0 5257 dlself=needless
adam@0 5258 export_dynamic=yes
adam@0 5259 fi
adam@0 5260 prev=
adam@0 5261 continue
adam@0 5262 ;;
adam@0 5263 *)
adam@0 5264 if test "$prev" = dlfiles; then
adam@12 5265 func_append dlfiles " $arg"
adam@0 5266 else
adam@12 5267 func_append dlprefiles " $arg"
adam@0 5268 fi
adam@0 5269 prev=
adam@0 5270 continue
adam@0 5271 ;;
adam@0 5272 esac
adam@0 5273 ;;
adam@0 5274 expsyms)
adam@0 5275 export_symbols="$arg"
adam@0 5276 test -f "$arg" \
adam@0 5277 || func_fatal_error "symbol file \`$arg' does not exist"
adam@0 5278 prev=
adam@0 5279 continue
adam@0 5280 ;;
adam@0 5281 expsyms_regex)
adam@0 5282 export_symbols_regex="$arg"
adam@0 5283 prev=
adam@0 5284 continue
adam@0 5285 ;;
adam@0 5286 framework)
adam@0 5287 case $host in
adam@0 5288 *-*-darwin*)
adam@0 5289 case "$deplibs " in
adam@0 5290 *" $qarg.ltframework "*) ;;
adam@12 5291 *) func_append deplibs " $qarg.ltframework" # this is fixed later
adam@0 5292 ;;
adam@0 5293 esac
adam@0 5294 ;;
adam@0 5295 esac
adam@0 5296 prev=
adam@0 5297 continue
adam@0 5298 ;;
adam@0 5299 inst_prefix)
adam@0 5300 inst_prefix_dir="$arg"
adam@0 5301 prev=
adam@0 5302 continue
adam@0 5303 ;;
adam@0 5304 objectlist)
adam@0 5305 if test -f "$arg"; then
adam@0 5306 save_arg=$arg
adam@0 5307 moreargs=
adam@0 5308 for fil in `cat "$save_arg"`
adam@0 5309 do
adam@12 5310 # func_append moreargs " $fil"
adam@0 5311 arg=$fil
adam@0 5312 # A libtool-controlled object.
adam@0 5313
adam@0 5314 # Check to see that this really is a libtool object.
adam@0 5315 if func_lalib_unsafe_p "$arg"; then
adam@0 5316 pic_object=
adam@0 5317 non_pic_object=
adam@0 5318
adam@0 5319 # Read the .lo file
adam@0 5320 func_source "$arg"
adam@0 5321
adam@0 5322 if test -z "$pic_object" ||
adam@0 5323 test -z "$non_pic_object" ||
adam@0 5324 test "$pic_object" = none &&
adam@0 5325 test "$non_pic_object" = none; then
adam@0 5326 func_fatal_error "cannot find name of object for \`$arg'"
adam@0 5327 fi
adam@0 5328
adam@0 5329 # Extract subdirectory from the argument.
adam@0 5330 func_dirname "$arg" "/" ""
adam@0 5331 xdir="$func_dirname_result"
adam@0 5332
adam@0 5333 if test "$pic_object" != none; then
adam@0 5334 # Prepend the subdirectory the object is found in.
adam@0 5335 pic_object="$xdir$pic_object"
adam@0 5336
adam@0 5337 if test "$prev" = dlfiles; then
adam@0 5338 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
adam@12 5339 func_append dlfiles " $pic_object"
adam@0 5340 prev=
adam@0 5341 continue
adam@0 5342 else
adam@0 5343 # If libtool objects are unsupported, then we need to preload.
adam@0 5344 prev=dlprefiles
adam@0 5345 fi
adam@0 5346 fi
adam@0 5347
adam@0 5348 # CHECK ME: I think I busted this. -Ossama
adam@0 5349 if test "$prev" = dlprefiles; then
adam@0 5350 # Preload the old-style object.
adam@12 5351 func_append dlprefiles " $pic_object"
adam@0 5352 prev=
adam@0 5353 fi
adam@0 5354
adam@0 5355 # A PIC object.
adam@0 5356 func_append libobjs " $pic_object"
adam@0 5357 arg="$pic_object"
adam@0 5358 fi
adam@0 5359
adam@0 5360 # Non-PIC object.
adam@0 5361 if test "$non_pic_object" != none; then
adam@0 5362 # Prepend the subdirectory the object is found in.
adam@0 5363 non_pic_object="$xdir$non_pic_object"
adam@0 5364
adam@0 5365 # A standard non-PIC object
adam@0 5366 func_append non_pic_objects " $non_pic_object"
adam@0 5367 if test -z "$pic_object" || test "$pic_object" = none ; then
adam@0 5368 arg="$non_pic_object"
adam@0 5369 fi
adam@0 5370 else
adam@0 5371 # If the PIC object exists, use it instead.
adam@0 5372 # $xdir was prepended to $pic_object above.
adam@0 5373 non_pic_object="$pic_object"
adam@0 5374 func_append non_pic_objects " $non_pic_object"
adam@0 5375 fi
adam@0 5376 else
adam@0 5377 # Only an error if not doing a dry-run.
adam@0 5378 if $opt_dry_run; then
adam@0 5379 # Extract subdirectory from the argument.
adam@0 5380 func_dirname "$arg" "/" ""
adam@0 5381 xdir="$func_dirname_result"
adam@0 5382
adam@0 5383 func_lo2o "$arg"
adam@0 5384 pic_object=$xdir$objdir/$func_lo2o_result
adam@0 5385 non_pic_object=$xdir$func_lo2o_result
adam@0 5386 func_append libobjs " $pic_object"
adam@0 5387 func_append non_pic_objects " $non_pic_object"
adam@0 5388 else
adam@0 5389 func_fatal_error "\`$arg' is not a valid libtool object"
adam@0 5390 fi
adam@0 5391 fi
adam@0 5392 done
adam@0 5393 else
adam@0 5394 func_fatal_error "link input file \`$arg' does not exist"
adam@0 5395 fi
adam@0 5396 arg=$save_arg
adam@0 5397 prev=
adam@0 5398 continue
adam@0 5399 ;;
adam@0 5400 precious_regex)
adam@0 5401 precious_files_regex="$arg"
adam@0 5402 prev=
adam@0 5403 continue
adam@0 5404 ;;
adam@0 5405 release)
adam@0 5406 release="-$arg"
adam@0 5407 prev=
adam@0 5408 continue
adam@0 5409 ;;
adam@0 5410 rpath | xrpath)
adam@0 5411 # We need an absolute path.
adam@0 5412 case $arg in
adam@0 5413 [\\/]* | [A-Za-z]:[\\/]*) ;;
adam@0 5414 *)
adam@0 5415 func_fatal_error "only absolute run-paths are allowed"
adam@0 5416 ;;
adam@0 5417 esac
adam@0 5418 if test "$prev" = rpath; then
adam@0 5419 case "$rpath " in
adam@0 5420 *" $arg "*) ;;
adam@12 5421 *) func_append rpath " $arg" ;;
adam@0 5422 esac
adam@0 5423 else
adam@0 5424 case "$xrpath " in
adam@0 5425 *" $arg "*) ;;
adam@12 5426 *) func_append xrpath " $arg" ;;
adam@0 5427 esac
adam@0 5428 fi
adam@0 5429 prev=
adam@0 5430 continue
adam@0 5431 ;;
adam@0 5432 shrext)
adam@0 5433 shrext_cmds="$arg"
adam@0 5434 prev=
adam@0 5435 continue
adam@0 5436 ;;
adam@0 5437 weak)
adam@12 5438 func_append weak_libs " $arg"
adam@0 5439 prev=
adam@0 5440 continue
adam@0 5441 ;;
adam@0 5442 xcclinker)
adam@12 5443 func_append linker_flags " $qarg"
adam@12 5444 func_append compiler_flags " $qarg"
adam@0 5445 prev=
adam@0 5446 func_append compile_command " $qarg"
adam@0 5447 func_append finalize_command " $qarg"
adam@0 5448 continue
adam@0 5449 ;;
adam@0 5450 xcompiler)
adam@12 5451 func_append compiler_flags " $qarg"
adam@0 5452 prev=
adam@0 5453 func_append compile_command " $qarg"
adam@0 5454 func_append finalize_command " $qarg"
adam@0 5455 continue
adam@0 5456 ;;
adam@0 5457 xlinker)
adam@12 5458 func_append linker_flags " $qarg"
adam@12 5459 func_append compiler_flags " $wl$qarg"
adam@0 5460 prev=
adam@0 5461 func_append compile_command " $wl$qarg"
adam@0 5462 func_append finalize_command " $wl$qarg"
adam@0 5463 continue
adam@0 5464 ;;
adam@0 5465 *)
adam@0 5466 eval "$prev=\"\$arg\""
adam@0 5467 prev=
adam@0 5468 continue
adam@0 5469 ;;
adam@0 5470 esac
adam@0 5471 fi # test -n "$prev"
adam@0 5472
adam@0 5473 prevarg="$arg"
adam@0 5474
adam@0 5475 case $arg in
adam@0 5476 -all-static)
adam@0 5477 if test -n "$link_static_flag"; then
adam@0 5478 # See comment for -static flag below, for more details.
adam@0 5479 func_append compile_command " $link_static_flag"
adam@0 5480 func_append finalize_command " $link_static_flag"
adam@0 5481 fi
adam@0 5482 continue
adam@0 5483 ;;
adam@0 5484
adam@0 5485 -allow-undefined)
adam@0 5486 # FIXME: remove this flag sometime in the future.
adam@0 5487 func_fatal_error "\`-allow-undefined' must not be used because it is the default"
adam@0 5488 ;;
adam@0 5489
adam@0 5490 -avoid-version)
adam@0 5491 avoid_version=yes
adam@0 5492 continue
adam@0 5493 ;;
adam@0 5494
adam@12 5495 -bindir)
adam@12 5496 prev=bindir
adam@12 5497 continue
adam@12 5498 ;;
adam@12 5499
adam@0 5500 -dlopen)
adam@0 5501 prev=dlfiles
adam@0 5502 continue
adam@0 5503 ;;
adam@0 5504
adam@0 5505 -dlpreopen)
adam@0 5506 prev=dlprefiles
adam@0 5507 continue
adam@0 5508 ;;
adam@0 5509
adam@0 5510 -export-dynamic)
adam@0 5511 export_dynamic=yes
adam@0 5512 continue
adam@0 5513 ;;
adam@0 5514
adam@0 5515 -export-symbols | -export-symbols-regex)
adam@0 5516 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
adam@0 5517 func_fatal_error "more than one -exported-symbols argument is not allowed"
adam@0 5518 fi
adam@0 5519 if test "X$arg" = "X-export-symbols"; then
adam@0 5520 prev=expsyms
adam@0 5521 else
adam@0 5522 prev=expsyms_regex
adam@0 5523 fi
adam@0 5524 continue
adam@0 5525 ;;
adam@0 5526
adam@0 5527 -framework)
adam@0 5528 prev=framework
adam@0 5529 continue
adam@0 5530 ;;
adam@0 5531
adam@0 5532 -inst-prefix-dir)
adam@0 5533 prev=inst_prefix
adam@0 5534 continue
adam@0 5535 ;;
adam@0 5536
adam@0 5537 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
adam@0 5538 # so, if we see these flags be careful not to treat them like -L
adam@0 5539 -L[A-Z][A-Z]*:*)
adam@0 5540 case $with_gcc/$host in
adam@0 5541 no/*-*-irix* | /*-*-irix*)
adam@0 5542 func_append compile_command " $arg"
adam@0 5543 func_append finalize_command " $arg"
adam@0 5544 ;;
adam@0 5545 esac
adam@0 5546 continue
adam@0 5547 ;;
adam@0 5548
adam@0 5549 -L*)
adam@12 5550 func_stripname "-L" '' "$arg"
adam@12 5551 if test -z "$func_stripname_result"; then
adam@0 5552 if test "$#" -gt 0; then
adam@0 5553 func_fatal_error "require no space between \`-L' and \`$1'"
adam@0 5554 else
adam@0 5555 func_fatal_error "need path for \`-L' option"
adam@0 5556 fi
adam@0 5557 fi
adam@12 5558 func_resolve_sysroot "$func_stripname_result"
adam@12 5559 dir=$func_resolve_sysroot_result
adam@0 5560 # We need an absolute path.
adam@0 5561 case $dir in
adam@0 5562 [\\/]* | [A-Za-z]:[\\/]*) ;;
adam@0 5563 *)
adam@0 5564 absdir=`cd "$dir" && pwd`
adam@0 5565 test -z "$absdir" && \
adam@0 5566 func_fatal_error "cannot determine absolute directory name of \`$dir'"
adam@0 5567 dir="$absdir"
adam@0 5568 ;;
adam@0 5569 esac
adam@0 5570 case "$deplibs " in
adam@12 5571 *" -L$dir "* | *" $arg "*)
adam@12 5572 # Will only happen for absolute or sysroot arguments
adam@12 5573 ;;
adam@0 5574 *)
adam@12 5575 # Preserve sysroot, but never include relative directories
adam@12 5576 case $dir in
adam@12 5577 [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
adam@12 5578 *) func_append deplibs " -L$dir" ;;
adam@12 5579 esac
adam@12 5580 func_append lib_search_path " $dir"
adam@0 5581 ;;
adam@0 5582 esac
adam@0 5583 case $host in
adam@0 5584 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
adam@12 5585 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
adam@0 5586 case :$dllsearchpath: in
adam@0 5587 *":$dir:"*) ;;
adam@0 5588 ::) dllsearchpath=$dir;;
adam@12 5589 *) func_append dllsearchpath ":$dir";;
adam@0 5590 esac
adam@0 5591 case :$dllsearchpath: in
adam@0 5592 *":$testbindir:"*) ;;
adam@0 5593 ::) dllsearchpath=$testbindir;;
adam@12 5594 *) func_append dllsearchpath ":$testbindir";;
adam@0 5595 esac
adam@0 5596 ;;
adam@0 5597 esac
adam@0 5598 continue
adam@0 5599 ;;
adam@0 5600
adam@0 5601 -l*)
adam@0 5602 if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
adam@0 5603 case $host in
adam@12 5604 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
adam@0 5605 # These systems don't actually have a C or math library (as such)
adam@0 5606 continue
adam@0 5607 ;;
adam@0 5608 *-*-os2*)
adam@0 5609 # These systems don't actually have a C library (as such)
adam@0 5610 test "X$arg" = "X-lc" && continue
adam@0 5611 ;;
adam@0 5612 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
adam@0 5613 # Do not include libc due to us having libc/libc_r.
adam@0 5614 test "X$arg" = "X-lc" && continue
adam@0 5615 ;;
adam@0 5616 *-*-rhapsody* | *-*-darwin1.[012])
adam@0 5617 # Rhapsody C and math libraries are in the System framework
adam@12 5618 func_append deplibs " System.ltframework"
adam@0 5619 continue
adam@0 5620 ;;
adam@0 5621 *-*-sco3.2v5* | *-*-sco5v6*)
adam@0 5622 # Causes problems with __ctype
adam@0 5623 test "X$arg" = "X-lc" && continue
adam@0 5624 ;;
adam@0 5625 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
adam@0 5626 # Compiler inserts libc in the correct place for threads to work
adam@0 5627 test "X$arg" = "X-lc" && continue
adam@0 5628 ;;
adam@0 5629 esac
adam@0 5630 elif test "X$arg" = "X-lc_r"; then
adam@0 5631 case $host in
adam@0 5632 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
adam@0 5633 # Do not include libc_r directly, use -pthread flag.
adam@0 5634 continue
adam@0 5635 ;;
adam@0 5636 esac
adam@0 5637 fi
adam@12 5638 func_append deplibs " $arg"
adam@0 5639 continue
adam@0 5640 ;;
adam@0 5641
adam@0 5642 -module)
adam@0 5643 module=yes
adam@0 5644 continue
adam@0 5645 ;;
adam@0 5646
adam@0 5647 # Tru64 UNIX uses -model [arg] to determine the layout of C++
adam@0 5648 # classes, name mangling, and exception handling.
adam@0 5649 # Darwin uses the -arch flag to determine output architecture.
adam@12 5650 -model|-arch|-isysroot|--sysroot)
adam@12 5651 func_append compiler_flags " $arg"
adam@0 5652 func_append compile_command " $arg"
adam@0 5653 func_append finalize_command " $arg"
adam@0 5654 prev=xcompiler
adam@0 5655 continue
adam@0 5656 ;;
adam@0 5657
adam@20 5658 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
adam@20 5659 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
adam@12 5660 func_append compiler_flags " $arg"
adam@0 5661 func_append compile_command " $arg"
adam@0 5662 func_append finalize_command " $arg"
adam@0 5663 case "$new_inherited_linker_flags " in
adam@0 5664 *" $arg "*) ;;
adam@12 5665 * ) func_append new_inherited_linker_flags " $arg" ;;
adam@0 5666 esac
adam@0 5667 continue
adam@0 5668 ;;
adam@0 5669
adam@0 5670 -multi_module)
adam@0 5671 single_module="${wl}-multi_module"
adam@0 5672 continue
adam@0 5673 ;;
adam@0 5674
adam@0 5675 -no-fast-install)
adam@0 5676 fast_install=no
adam@0 5677 continue
adam@0 5678 ;;
adam@0 5679
adam@0 5680 -no-install)
adam@0 5681 case $host in
adam@0 5682 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
adam@0 5683 # The PATH hackery in wrapper scripts is required on Windows
adam@0 5684 # and Darwin in order for the loader to find any dlls it needs.
adam@0 5685 func_warning "\`-no-install' is ignored for $host"
adam@0 5686 func_warning "assuming \`-no-fast-install' instead"
adam@0 5687 fast_install=no
adam@0 5688 ;;
adam@0 5689 *) no_install=yes ;;
adam@0 5690 esac
adam@0 5691 continue
adam@0 5692 ;;
adam@0 5693
adam@0 5694 -no-undefined)
adam@0 5695 allow_undefined=no
adam@0 5696 continue
adam@0 5697 ;;
adam@0 5698
adam@0 5699 -objectlist)
adam@0 5700 prev=objectlist
adam@0 5701 continue
adam@0 5702 ;;
adam@0 5703
adam@0 5704 -o) prev=output ;;
adam@0 5705
adam@0 5706 -precious-files-regex)
adam@0 5707 prev=precious_regex
adam@0 5708 continue
adam@0 5709 ;;
adam@0 5710
adam@0 5711 -release)
adam@0 5712 prev=release
adam@0 5713 continue
adam@0 5714 ;;
adam@0 5715
adam@0 5716 -rpath)
adam@0 5717 prev=rpath
adam@0 5718 continue
adam@0 5719 ;;
adam@0 5720
adam@0 5721 -R)
adam@0 5722 prev=xrpath
adam@0 5723 continue
adam@0 5724 ;;
adam@0 5725
adam@0 5726 -R*)
adam@0 5727 func_stripname '-R' '' "$arg"
adam@0 5728 dir=$func_stripname_result
adam@0 5729 # We need an absolute path.
adam@0 5730 case $dir in
adam@0 5731 [\\/]* | [A-Za-z]:[\\/]*) ;;
adam@12 5732 =*)
adam@12 5733 func_stripname '=' '' "$dir"
adam@12 5734 dir=$lt_sysroot$func_stripname_result
adam@12 5735 ;;
adam@0 5736 *)
adam@0 5737 func_fatal_error "only absolute run-paths are allowed"
adam@0 5738 ;;
adam@0 5739 esac
adam@0 5740 case "$xrpath " in
adam@0 5741 *" $dir "*) ;;
adam@12 5742 *) func_append xrpath " $dir" ;;
adam@0 5743 esac
adam@0 5744 continue
adam@0 5745 ;;
adam@0 5746
adam@0 5747 -shared)
adam@0 5748 # The effects of -shared are defined in a previous loop.
adam@0 5749 continue
adam@0 5750 ;;
adam@0 5751
adam@0 5752 -shrext)
adam@0 5753 prev=shrext
adam@0 5754 continue
adam@0 5755 ;;
adam@0 5756
adam@0 5757 -static | -static-libtool-libs)
adam@0 5758 # The effects of -static are defined in a previous loop.
adam@0 5759 # We used to do the same as -all-static on platforms that
adam@0 5760 # didn't have a PIC flag, but the assumption that the effects
adam@0 5761 # would be equivalent was wrong. It would break on at least
adam@0 5762 # Digital Unix and AIX.
adam@0 5763 continue
adam@0 5764 ;;
adam@0 5765
adam@0 5766 -thread-safe)
adam@0 5767 thread_safe=yes
adam@0 5768 continue
adam@0 5769 ;;
adam@0 5770
adam@0 5771 -version-info)
adam@0 5772 prev=vinfo
adam@0 5773 continue
adam@0 5774 ;;
adam@0 5775
adam@0 5776 -version-number)
adam@0 5777 prev=vinfo
adam@0 5778 vinfo_number=yes
adam@0 5779 continue
adam@0 5780 ;;
adam@0 5781
adam@0 5782 -weak)
adam@0 5783 prev=weak
adam@0 5784 continue
adam@0 5785 ;;
adam@0 5786
adam@0 5787 -Wc,*)
adam@0 5788 func_stripname '-Wc,' '' "$arg"
adam@0 5789 args=$func_stripname_result
adam@0 5790 arg=
adam@0 5791 save_ifs="$IFS"; IFS=','
adam@0 5792 for flag in $args; do
adam@0 5793 IFS="$save_ifs"
adam@0 5794 func_quote_for_eval "$flag"
adam@12 5795 func_append arg " $func_quote_for_eval_result"
adam@12 5796 func_append compiler_flags " $func_quote_for_eval_result"
adam@0 5797 done
adam@0 5798 IFS="$save_ifs"
adam@0 5799 func_stripname ' ' '' "$arg"
adam@0 5800 arg=$func_stripname_result
adam@0 5801 ;;
adam@0 5802
adam@0 5803 -Wl,*)
adam@0 5804 func_stripname '-Wl,' '' "$arg"
adam@0 5805 args=$func_stripname_result
adam@0 5806 arg=
adam@0 5807 save_ifs="$IFS"; IFS=','
adam@0 5808 for flag in $args; do
adam@0 5809 IFS="$save_ifs"
adam@0 5810 func_quote_for_eval "$flag"
adam@12 5811 func_append arg " $wl$func_quote_for_eval_result"
adam@12 5812 func_append compiler_flags " $wl$func_quote_for_eval_result"
adam@12 5813 func_append linker_flags " $func_quote_for_eval_result"
adam@0 5814 done
adam@0 5815 IFS="$save_ifs"
adam@0 5816 func_stripname ' ' '' "$arg"
adam@0 5817 arg=$func_stripname_result
adam@0 5818 ;;
adam@0 5819
adam@0 5820 -Xcompiler)
adam@0 5821 prev=xcompiler
adam@0 5822 continue
adam@0 5823 ;;
adam@0 5824
adam@0 5825 -Xlinker)
adam@0 5826 prev=xlinker
adam@0 5827 continue
adam@0 5828 ;;
adam@0 5829
adam@0 5830 -XCClinker)
adam@0 5831 prev=xcclinker
adam@0 5832 continue
adam@0 5833 ;;
adam@0 5834
adam@0 5835 # -msg_* for osf cc
adam@0 5836 -msg_*)
adam@0 5837 func_quote_for_eval "$arg"
adam@0 5838 arg="$func_quote_for_eval_result"
adam@0 5839 ;;
adam@0 5840
adam@12 5841 # Flags to be passed through unchanged, with rationale:
adam@12 5842 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
adam@12 5843 # -r[0-9][0-9]* specify processor for the SGI compiler
adam@12 5844 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
adam@12 5845 # +DA*, +DD* enable 64-bit mode for the HP compiler
adam@12 5846 # -q* compiler args for the IBM compiler
adam@12 5847 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
adam@12 5848 # -F/path path to uninstalled frameworks, gcc on darwin
adam@12 5849 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
adam@12 5850 # @file GCC response files
adam@12 5851 # -tp=* Portland pgcc target processor selection
adam@12 5852 # --sysroot=* for sysroot support
adam@12 5853 # -O*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
adam@0 5854 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
adam@12 5855 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
adam@12 5856 -O*|-flto*|-fwhopr*|-fuse-linker-plugin)
adam@0 5857 func_quote_for_eval "$arg"
adam@0 5858 arg="$func_quote_for_eval_result"
adam@0 5859 func_append compile_command " $arg"
adam@0 5860 func_append finalize_command " $arg"
adam@12 5861 func_append compiler_flags " $arg"
adam@0 5862 continue
adam@0 5863 ;;
adam@0 5864
adam@0 5865 # Some other compiler flag.
adam@0 5866 -* | +*)
adam@0 5867 func_quote_for_eval "$arg"
adam@0 5868 arg="$func_quote_for_eval_result"
adam@0 5869 ;;
adam@0 5870
adam@0 5871 *.$objext)
adam@0 5872 # A standard object.
adam@12 5873 func_append objs " $arg"
adam@0 5874 ;;
adam@0 5875
adam@0 5876 *.lo)
adam@0 5877 # A libtool-controlled object.
adam@0 5878
adam@0 5879 # Check to see that this really is a libtool object.
adam@0 5880 if func_lalib_unsafe_p "$arg"; then
adam@0 5881 pic_object=
adam@0 5882 non_pic_object=
adam@0 5883
adam@0 5884 # Read the .lo file
adam@0 5885 func_source "$arg"
adam@0 5886
adam@0 5887 if test -z "$pic_object" ||
adam@0 5888 test -z "$non_pic_object" ||
adam@0 5889 test "$pic_object" = none &&
adam@0 5890 test "$non_pic_object" = none; then
adam@0 5891 func_fatal_error "cannot find name of object for \`$arg'"
adam@0 5892 fi
adam@0 5893
adam@0 5894 # Extract subdirectory from the argument.
adam@0 5895 func_dirname "$arg" "/" ""
adam@0 5896 xdir="$func_dirname_result"
adam@0 5897
adam@0 5898 if test "$pic_object" != none; then
adam@0 5899 # Prepend the subdirectory the object is found in.
adam@0 5900 pic_object="$xdir$pic_object"
adam@0 5901
adam@0 5902 if test "$prev" = dlfiles; then
adam@0 5903 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
adam@12 5904 func_append dlfiles " $pic_object"
adam@0 5905 prev=
adam@0 5906 continue
adam@0 5907 else
adam@0 5908 # If libtool objects are unsupported, then we need to preload.
adam@0 5909 prev=dlprefiles
adam@0 5910 fi
adam@0 5911 fi
adam@0 5912
adam@0 5913 # CHECK ME: I think I busted this. -Ossama
adam@0 5914 if test "$prev" = dlprefiles; then
adam@0 5915 # Preload the old-style object.
adam@12 5916 func_append dlprefiles " $pic_object"
adam@0 5917 prev=
adam@0 5918 fi
adam@0 5919
adam@0 5920 # A PIC object.
adam@0 5921 func_append libobjs " $pic_object"
adam@0 5922 arg="$pic_object"
adam@0 5923 fi
adam@0 5924
adam@0 5925 # Non-PIC object.
adam@0 5926 if test "$non_pic_object" != none; then
adam@0 5927 # Prepend the subdirectory the object is found in.
adam@0 5928 non_pic_object="$xdir$non_pic_object"
adam@0 5929
adam@0 5930 # A standard non-PIC object
adam@0 5931 func_append non_pic_objects " $non_pic_object"
adam@0 5932 if test -z "$pic_object" || test "$pic_object" = none ; then
adam@0 5933 arg="$non_pic_object"
adam@0 5934 fi
adam@0 5935 else
adam@0 5936 # If the PIC object exists, use it instead.
adam@0 5937 # $xdir was prepended to $pic_object above.
adam@0 5938 non_pic_object="$pic_object"
adam@0 5939 func_append non_pic_objects " $non_pic_object"
adam@0 5940 fi
adam@0 5941 else
adam@0 5942 # Only an error if not doing a dry-run.
adam@0 5943 if $opt_dry_run; then
adam@0 5944 # Extract subdirectory from the argument.
adam@0 5945 func_dirname "$arg" "/" ""
adam@0 5946 xdir="$func_dirname_result"
adam@0 5947
adam@0 5948 func_lo2o "$arg"
adam@0 5949 pic_object=$xdir$objdir/$func_lo2o_result
adam@0 5950 non_pic_object=$xdir$func_lo2o_result
adam@0 5951 func_append libobjs " $pic_object"
adam@0 5952 func_append non_pic_objects " $non_pic_object"
adam@0 5953 else
adam@0 5954 func_fatal_error "\`$arg' is not a valid libtool object"
adam@0 5955 fi
adam@0 5956 fi
adam@0 5957 ;;
adam@0 5958
adam@0 5959 *.$libext)
adam@0 5960 # An archive.
adam@12 5961 func_append deplibs " $arg"
adam@12 5962 func_append old_deplibs " $arg"
adam@0 5963 continue
adam@0 5964 ;;
adam@0 5965
adam@0 5966 *.la)
adam@0 5967 # A libtool-controlled library.
adam@0 5968
adam@12 5969 func_resolve_sysroot "$arg"
adam@0 5970 if test "$prev" = dlfiles; then
adam@0 5971 # This library was specified with -dlopen.
adam@12 5972 func_append dlfiles " $func_resolve_sysroot_result"
adam@0 5973 prev=
adam@0 5974 elif test "$prev" = dlprefiles; then
adam@0 5975 # The library was specified with -dlpreopen.
adam@12 5976 func_append dlprefiles " $func_resolve_sysroot_result"
adam@0 5977 prev=
adam@0 5978 else
adam@12 5979 func_append deplibs " $func_resolve_sysroot_result"
adam@0 5980 fi
adam@0 5981 continue
adam@0 5982 ;;
adam@0 5983
adam@0 5984 # Some other compiler argument.
adam@0 5985 *)
adam@0 5986 # Unknown arguments in both finalize_command and compile_command need
adam@0 5987 # to be aesthetically quoted because they are evaled later.
adam@0 5988 func_quote_for_eval "$arg"
adam@0 5989 arg="$func_quote_for_eval_result"
adam@0 5990 ;;
adam@0 5991 esac # arg
adam@0 5992
adam@0 5993 # Now actually substitute the argument into the commands.
adam@0 5994 if test -n "$arg"; then
adam@0 5995 func_append compile_command " $arg"
adam@0 5996 func_append finalize_command " $arg"
adam@0 5997 fi
adam@0 5998 done # argument parsing loop
adam@0 5999
adam@0 6000 test -n "$prev" && \
adam@0 6001 func_fatal_help "the \`$prevarg' option requires an argument"
adam@0 6002
adam@0 6003 if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
adam@0 6004 eval arg=\"$export_dynamic_flag_spec\"
adam@0 6005 func_append compile_command " $arg"
adam@0 6006 func_append finalize_command " $arg"
adam@0 6007 fi
adam@0 6008
adam@0 6009 oldlibs=
adam@0 6010 # calculate the name of the file, without its directory
adam@0 6011 func_basename "$output"
adam@0 6012 outputname="$func_basename_result"
adam@0 6013 libobjs_save="$libobjs"
adam@0 6014
adam@0 6015 if test -n "$shlibpath_var"; then
adam@0 6016 # get the directories listed in $shlibpath_var
adam@12 6017 eval shlib_search_path=\`\$ECHO \"\${$shlibpath_var}\" \| \$SED \'s/:/ /g\'\`
adam@0 6018 else
adam@0 6019 shlib_search_path=
adam@0 6020 fi
adam@0 6021 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
adam@0 6022 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
adam@0 6023
adam@0 6024 func_dirname "$output" "/" ""
adam@0 6025 output_objdir="$func_dirname_result$objdir"
adam@12 6026 func_to_tool_file "$output_objdir/"
adam@12 6027 tool_output_objdir=$func_to_tool_file_result
adam@0 6028 # Create the object directory.
adam@0 6029 func_mkdir_p "$output_objdir"
adam@0 6030
adam@0 6031 # Determine the type of output
adam@0 6032 case $output in
adam@0 6033 "")
adam@0 6034 func_fatal_help "you must specify an output file"
adam@0 6035 ;;
adam@0 6036 *.$libext) linkmode=oldlib ;;
adam@0 6037 *.lo | *.$objext) linkmode=obj ;;
adam@0 6038 *.la) linkmode=lib ;;
adam@0 6039 *) linkmode=prog ;; # Anything else should be a program.
adam@0 6040 esac
adam@0 6041
adam@0 6042 specialdeplibs=
adam@0 6043
adam@0 6044 libs=
adam@0 6045 # Find all interdependent deplibs by searching for libraries
adam@0 6046 # that are linked more than once (e.g. -la -lb -la)
adam@0 6047 for deplib in $deplibs; do
adam@12 6048 if $opt_preserve_dup_deps ; then
adam@0 6049 case "$libs " in
adam@12 6050 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
adam@0 6051 esac
adam@0 6052 fi
adam@12 6053 func_append libs " $deplib"
adam@0 6054 done
adam@0 6055
adam@0 6056 if test "$linkmode" = lib; then
adam@0 6057 libs="$predeps $libs $compiler_lib_search_path $postdeps"
adam@0 6058
adam@0 6059 # Compute libraries that are listed more than once in $predeps
adam@0 6060 # $postdeps and mark them as special (i.e., whose duplicates are
adam@0 6061 # not to be eliminated).
adam@0 6062 pre_post_deps=
adam@0 6063 if $opt_duplicate_compiler_generated_deps; then
adam@0 6064 for pre_post_dep in $predeps $postdeps; do
adam@0 6065 case "$pre_post_deps " in
adam@12 6066 *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
adam@0 6067 esac
adam@12 6068 func_append pre_post_deps " $pre_post_dep"
adam@0 6069 done
adam@0 6070 fi
adam@0 6071 pre_post_deps=
adam@0 6072 fi
adam@0 6073
adam@0 6074 deplibs=
adam@0 6075 newdependency_libs=
adam@0 6076 newlib_search_path=
adam@0 6077 need_relink=no # whether we're linking any uninstalled libtool libraries
adam@0 6078 notinst_deplibs= # not-installed libtool libraries
adam@0 6079 notinst_path= # paths that contain not-installed libtool libraries
adam@0 6080
adam@0 6081 case $linkmode in
adam@0 6082 lib)
adam@0 6083 passes="conv dlpreopen link"
adam@0 6084 for file in $dlfiles $dlprefiles; do
adam@0 6085 case $file in
adam@0 6086 *.la) ;;
adam@0 6087 *)
adam@0 6088 func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
adam@0 6089 ;;
adam@0 6090 esac
adam@0 6091 done
adam@0 6092 ;;
adam@0 6093 prog)
adam@0 6094 compile_deplibs=
adam@0 6095 finalize_deplibs=
adam@0 6096 alldeplibs=no
adam@0 6097 newdlfiles=
adam@0 6098 newdlprefiles=
adam@0 6099 passes="conv scan dlopen dlpreopen link"
adam@0 6100 ;;
adam@0 6101 *) passes="conv"
adam@0 6102 ;;
adam@0 6103 esac
adam@0 6104
adam@0 6105 for pass in $passes; do
adam@0 6106 # The preopen pass in lib mode reverses $deplibs; put it back here
adam@0 6107 # so that -L comes before libs that need it for instance...
adam@0 6108 if test "$linkmode,$pass" = "lib,link"; then
adam@0 6109 ## FIXME: Find the place where the list is rebuilt in the wrong
adam@0 6110 ## order, and fix it there properly
adam@0 6111 tmp_deplibs=
adam@0 6112 for deplib in $deplibs; do
adam@0 6113 tmp_deplibs="$deplib $tmp_deplibs"
adam@0 6114 done
adam@0 6115 deplibs="$tmp_deplibs"
adam@0 6116 fi
adam@0 6117
adam@0 6118 if test "$linkmode,$pass" = "lib,link" ||
adam@0 6119 test "$linkmode,$pass" = "prog,scan"; then
adam@0 6120 libs="$deplibs"
adam@0 6121 deplibs=
adam@0 6122 fi
adam@0 6123 if test "$linkmode" = prog; then
adam@0 6124 case $pass in
adam@0 6125 dlopen) libs="$dlfiles" ;;
adam@0 6126 dlpreopen) libs="$dlprefiles" ;;
adam@0 6127 link)
adam@0 6128 libs="$deplibs %DEPLIBS%"
adam@0 6129 test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
adam@0 6130 ;;
adam@0 6131 esac
adam@0 6132 fi
adam@0 6133 if test "$linkmode,$pass" = "lib,dlpreopen"; then
adam@0 6134 # Collect and forward deplibs of preopened libtool libs
adam@0 6135 for lib in $dlprefiles; do
adam@0 6136 # Ignore non-libtool-libs
adam@0 6137 dependency_libs=
adam@12 6138 func_resolve_sysroot "$lib"
adam@0 6139 case $lib in
adam@12 6140 *.la) func_source "$func_resolve_sysroot_result" ;;
adam@0 6141 esac
adam@0 6142
adam@0 6143 # Collect preopened libtool deplibs, except any this library
adam@0 6144 # has declared as weak libs
adam@0 6145 for deplib in $dependency_libs; do
adam@12 6146 func_basename "$deplib"
adam@12 6147 deplib_base=$func_basename_result
adam@0 6148 case " $weak_libs " in
adam@0 6149 *" $deplib_base "*) ;;
adam@12 6150 *) func_append deplibs " $deplib" ;;
adam@0 6151 esac
adam@0 6152 done
adam@0 6153 done
adam@0 6154 libs="$dlprefiles"
adam@0 6155 fi
adam@0 6156 if test "$pass" = dlopen; then
adam@0 6157 # Collect dlpreopened libraries
adam@0 6158 save_deplibs="$deplibs"
adam@0 6159 deplibs=
adam@0 6160 fi
adam@0 6161
adam@0 6162 for deplib in $libs; do
adam@0 6163 lib=
adam@0 6164 found=no
adam@0 6165 case $deplib in
adam@20 6166 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
adam@20 6167 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
adam@0 6168 if test "$linkmode,$pass" = "prog,link"; then
adam@0 6169 compile_deplibs="$deplib $compile_deplibs"
adam@0 6170 finalize_deplibs="$deplib $finalize_deplibs"
adam@0 6171 else
adam@12 6172 func_append compiler_flags " $deplib"
adam@0 6173 if test "$linkmode" = lib ; then
adam@0 6174 case "$new_inherited_linker_flags " in
adam@0 6175 *" $deplib "*) ;;
adam@12 6176 * ) func_append new_inherited_linker_flags " $deplib" ;;
adam@0 6177 esac
adam@0 6178 fi
adam@0 6179 fi
adam@0 6180 continue
adam@0 6181 ;;
adam@0 6182 -l*)
adam@0 6183 if test "$linkmode" != lib && test "$linkmode" != prog; then
adam@0 6184 func_warning "\`-l' is ignored for archives/objects"
adam@0 6185 continue
adam@0 6186 fi
adam@0 6187 func_stripname '-l' '' "$deplib"
adam@0 6188 name=$func_stripname_result
adam@0 6189 if test "$linkmode" = lib; then
adam@0 6190 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
adam@0 6191 else
adam@0 6192 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
adam@0 6193 fi
adam@0 6194 for searchdir in $searchdirs; do
adam@0 6195 for search_ext in .la $std_shrext .so .a; do
adam@0 6196 # Search the libtool library
adam@0 6197 lib="$searchdir/lib${name}${search_ext}"
adam@0 6198 if test -f "$lib"; then
adam@0 6199 if test "$search_ext" = ".la"; then
adam@0 6200 found=yes
adam@0 6201 else
adam@0 6202 found=no
adam@0 6203 fi
adam@0 6204 break 2
adam@0 6205 fi
adam@0 6206 done
adam@0 6207 done
adam@0 6208 if test "$found" != yes; then
adam@0 6209 # deplib doesn't seem to be a libtool library
adam@0 6210 if test "$linkmode,$pass" = "prog,link"; then
adam@0 6211 compile_deplibs="$deplib $compile_deplibs"
adam@0 6212 finalize_deplibs="$deplib $finalize_deplibs"
adam@0 6213 else
adam@0 6214 deplibs="$deplib $deplibs"
adam@0 6215 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
adam@0 6216 fi
adam@0 6217 continue
adam@0 6218 else # deplib is a libtool library
adam@0 6219 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
adam@0 6220 # We need to do some special things here, and not later.
adam@0 6221 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
adam@0 6222 case " $predeps $postdeps " in
adam@0 6223 *" $deplib "*)
adam@0 6224 if func_lalib_p "$lib"; then
adam@0 6225 library_names=
adam@0 6226 old_library=
adam@0 6227 func_source "$lib"
adam@0 6228 for l in $old_library $library_names; do
adam@0 6229 ll="$l"
adam@0 6230 done
adam@0 6231 if test "X$ll" = "X$old_library" ; then # only static version available
adam@0 6232 found=no
adam@0 6233 func_dirname "$lib" "" "."
adam@0 6234 ladir="$func_dirname_result"
adam@0 6235 lib=$ladir/$old_library
adam@0 6236 if test "$linkmode,$pass" = "prog,link"; then
adam@0 6237 compile_deplibs="$deplib $compile_deplibs"
adam@0 6238 finalize_deplibs="$deplib $finalize_deplibs"
adam@0 6239 else
adam@0 6240 deplibs="$deplib $deplibs"
adam@0 6241 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
adam@0 6242 fi
adam@0 6243 continue
adam@0 6244 fi
adam@0 6245 fi
adam@0 6246 ;;
adam@0 6247 *) ;;
adam@0 6248 esac
adam@0 6249 fi
adam@0 6250 fi
adam@0 6251 ;; # -l
adam@0 6252 *.ltframework)
adam@0 6253 if test "$linkmode,$pass" = "prog,link"; then
adam@0 6254 compile_deplibs="$deplib $compile_deplibs"
adam@0 6255 finalize_deplibs="$deplib $finalize_deplibs"
adam@0 6256 else
adam@0 6257 deplibs="$deplib $deplibs"
adam@0 6258 if test "$linkmode" = lib ; then
adam@0 6259 case "$new_inherited_linker_flags " in
adam@0 6260 *" $deplib "*) ;;
adam@12 6261 * ) func_append new_inherited_linker_flags " $deplib" ;;
adam@0 6262 esac
adam@0 6263 fi
adam@0 6264 fi
adam@0 6265 continue
adam@0 6266 ;;
adam@0 6267 -L*)
adam@0 6268 case $linkmode in
adam@0 6269 lib)
adam@0 6270 deplibs="$deplib $deplibs"
adam@0 6271 test "$pass" = conv && continue
adam@0 6272 newdependency_libs="$deplib $newdependency_libs"
adam@0 6273 func_stripname '-L' '' "$deplib"
adam@12 6274 func_resolve_sysroot "$func_stripname_result"
adam@12 6275 func_append newlib_search_path " $func_resolve_sysroot_result"
adam@0 6276 ;;
adam@0 6277 prog)
adam@0 6278 if test "$pass" = conv; then
adam@0 6279 deplibs="$deplib $deplibs"
adam@0 6280 continue
adam@0 6281 fi
adam@0 6282 if test "$pass" = scan; then
adam@0 6283 deplibs="$deplib $deplibs"
adam@0 6284 else
adam@0 6285 compile_deplibs="$deplib $compile_deplibs"
adam@0 6286 finalize_deplibs="$deplib $finalize_deplibs"
adam@0 6287 fi
adam@0 6288 func_stripname '-L' '' "$deplib"
adam@12 6289 func_resolve_sysroot "$func_stripname_result"
adam@12 6290 func_append newlib_search_path " $func_resolve_sysroot_result"
adam@0 6291 ;;
adam@0 6292 *)
adam@0 6293 func_warning "\`-L' is ignored for archives/objects"
adam@0 6294 ;;
adam@0 6295 esac # linkmode
adam@0 6296 continue
adam@0 6297 ;; # -L
adam@0 6298 -R*)
adam@0 6299 if test "$pass" = link; then
adam@0 6300 func_stripname '-R' '' "$deplib"
adam@12 6301 func_resolve_sysroot "$func_stripname_result"
adam@12 6302 dir=$func_resolve_sysroot_result
adam@0 6303 # Make sure the xrpath contains only unique directories.
adam@0 6304 case "$xrpath " in
adam@0 6305 *" $dir "*) ;;
adam@12 6306 *) func_append xrpath " $dir" ;;
adam@0 6307 esac
adam@0 6308 fi
adam@0 6309 deplibs="$deplib $deplibs"
adam@0 6310 continue
adam@0 6311 ;;
adam@12 6312 *.la)
adam@12 6313 func_resolve_sysroot "$deplib"
adam@12 6314 lib=$func_resolve_sysroot_result
adam@12 6315 ;;
adam@0 6316 *.$libext)
adam@0 6317 if test "$pass" = conv; then
adam@0 6318 deplibs="$deplib $deplibs"
adam@0 6319 continue
adam@0 6320 fi
adam@0 6321 case $linkmode in
adam@0 6322 lib)
adam@0 6323 # Linking convenience modules into shared libraries is allowed,
adam@0 6324 # but linking other static libraries is non-portable.
adam@0 6325 case " $dlpreconveniencelibs " in
adam@0 6326 *" $deplib "*) ;;
adam@0 6327 *)
adam@0 6328 valid_a_lib=no
adam@0 6329 case $deplibs_check_method in
adam@0 6330 match_pattern*)
adam@0 6331 set dummy $deplibs_check_method; shift
adam@0 6332 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
adam@12 6333 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
adam@0 6334 | $EGREP "$match_pattern_regex" > /dev/null; then
adam@0 6335 valid_a_lib=yes
adam@0 6336 fi
adam@0 6337 ;;
adam@0 6338 pass_all)
adam@0 6339 valid_a_lib=yes
adam@0 6340 ;;
adam@0 6341 esac
adam@0 6342 if test "$valid_a_lib" != yes; then
adam@12 6343 echo
adam@0 6344 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
adam@12 6345 echo "*** I have the capability to make that library automatically link in when"
adam@12 6346 echo "*** you link to this library. But I can only do this if you have a"
adam@12 6347 echo "*** shared version of the library, which you do not appear to have"
adam@12 6348 echo "*** because the file extensions .$libext of this argument makes me believe"
adam@12 6349 echo "*** that it is just a static archive that I should not use here."
adam@0 6350 else
adam@12 6351 echo
adam@0 6352 $ECHO "*** Warning: Linking the shared library $output against the"
adam@0 6353 $ECHO "*** static library $deplib is not portable!"
adam@0 6354 deplibs="$deplib $deplibs"
adam@0 6355 fi
adam@0 6356 ;;
adam@0 6357 esac
adam@0 6358 continue
adam@0 6359 ;;
adam@0 6360 prog)
adam@0 6361 if test "$pass" != link; then
adam@0 6362 deplibs="$deplib $deplibs"
adam@0 6363 else
adam@0 6364 compile_deplibs="$deplib $compile_deplibs"
adam@0 6365 finalize_deplibs="$deplib $finalize_deplibs"
adam@0 6366 fi
adam@0 6367 continue
adam@0 6368 ;;
adam@0 6369 esac # linkmode
adam@0 6370 ;; # *.$libext
adam@0 6371 *.lo | *.$objext)
adam@0 6372 if test "$pass" = conv; then
adam@0 6373 deplibs="$deplib $deplibs"
adam@0 6374 elif test "$linkmode" = prog; then
adam@0 6375 if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
adam@0 6376 # If there is no dlopen support or we're linking statically,
adam@0 6377 # we need to preload.
adam@12 6378 func_append newdlprefiles " $deplib"
adam@0 6379 compile_deplibs="$deplib $compile_deplibs"
adam@0 6380 finalize_deplibs="$deplib $finalize_deplibs"
adam@0 6381 else
adam@12 6382 func_append newdlfiles " $deplib"
adam@0 6383 fi
adam@0 6384 fi
adam@0 6385 continue
adam@0 6386 ;;
adam@0 6387 %DEPLIBS%)
adam@0 6388 alldeplibs=yes
adam@0 6389 continue
adam@0 6390 ;;
adam@0 6391 esac # case $deplib
adam@0 6392
adam@0 6393 if test "$found" = yes || test -f "$lib"; then :
adam@0 6394 else
adam@0 6395 func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
adam@0 6396 fi
adam@0 6397
adam@0 6398 # Check to see that this really is a libtool archive.
adam@0 6399 func_lalib_unsafe_p "$lib" \
adam@0 6400 || func_fatal_error "\`$lib' is not a valid libtool archive"
adam@0 6401
adam@0 6402 func_dirname "$lib" "" "."
adam@0 6403 ladir="$func_dirname_result"
adam@0 6404
adam@0 6405 dlname=
adam@0 6406 dlopen=
adam@0 6407 dlpreopen=
adam@0 6408 libdir=
adam@0 6409 library_names=
adam@0 6410 old_library=
adam@0 6411 inherited_linker_flags=
adam@0 6412 # If the library was installed with an old release of libtool,
adam@0 6413 # it will not redefine variables installed, or shouldnotlink
adam@0 6414 installed=yes
adam@0 6415 shouldnotlink=no
adam@0 6416 avoidtemprpath=
adam@0 6417
adam@0 6418
adam@0 6419 # Read the .la file
adam@0 6420 func_source "$lib"
adam@0 6421
adam@0 6422 # Convert "-framework foo" to "foo.ltframework"
adam@0 6423 if test -n "$inherited_linker_flags"; then
adam@12 6424 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
adam@0 6425 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
adam@0 6426 case " $new_inherited_linker_flags " in
adam@0 6427 *" $tmp_inherited_linker_flag "*) ;;
adam@12 6428 *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
adam@0 6429 esac
adam@0 6430 done
adam@0 6431 fi
adam@12 6432 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
adam@0 6433 if test "$linkmode,$pass" = "lib,link" ||
adam@0 6434 test "$linkmode,$pass" = "prog,scan" ||
adam@0 6435 { test "$linkmode" != prog && test "$linkmode" != lib; }; then
adam@12 6436 test -n "$dlopen" && func_append dlfiles " $dlopen"
adam@12 6437 test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
adam@0 6438 fi
adam@0 6439
adam@0 6440 if test "$pass" = conv; then
adam@0 6441 # Only check for convenience libraries
adam@0 6442 deplibs="$lib $deplibs"
adam@0 6443 if test -z "$libdir"; then
adam@0 6444 if test -z "$old_library"; then
adam@0 6445 func_fatal_error "cannot find name of link library for \`$lib'"
adam@0 6446 fi
adam@0 6447 # It is a libtool convenience library, so add in its objects.
adam@12 6448 func_append convenience " $ladir/$objdir/$old_library"
adam@12 6449 func_append old_convenience " $ladir/$objdir/$old_library"
adam@0 6450 tmp_libs=
adam@0 6451 for deplib in $dependency_libs; do
adam@0 6452 deplibs="$deplib $deplibs"
adam@12 6453 if $opt_preserve_dup_deps ; then
adam@0 6454 case "$tmp_libs " in
adam@12 6455 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
adam@0 6456 esac
adam@0 6457 fi
adam@12 6458 func_append tmp_libs " $deplib"
adam@0 6459 done
adam@0 6460 elif test "$linkmode" != prog && test "$linkmode" != lib; then
adam@0 6461 func_fatal_error "\`$lib' is not a convenience library"
adam@0 6462 fi
adam@0 6463 continue
adam@0 6464 fi # $pass = conv
adam@0 6465
adam@0 6466
adam@0 6467 # Get the name of the library we link against.
adam@0 6468 linklib=
adam@12 6469 if test -n "$old_library" &&
adam@12 6470 { test "$prefer_static_libs" = yes ||
adam@12 6471 test "$prefer_static_libs,$installed" = "built,no"; }; then
adam@12 6472 linklib=$old_library
adam@12 6473 else
adam@12 6474 for l in $old_library $library_names; do
adam@12 6475 linklib="$l"
adam@12 6476 done
adam@12 6477 fi
adam@0 6478 if test -z "$linklib"; then
adam@0 6479 func_fatal_error "cannot find name of link library for \`$lib'"
adam@0 6480 fi
adam@0 6481
adam@0 6482 # This library was specified with -dlopen.
adam@0 6483 if test "$pass" = dlopen; then
adam@0 6484 if test -z "$libdir"; then
adam@0 6485 func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
adam@0 6486 fi
adam@0 6487 if test -z "$dlname" ||
adam@0 6488 test "$dlopen_support" != yes ||
adam@0 6489 test "$build_libtool_libs" = no; then
adam@0 6490 # If there is no dlname, no dlopen support or we're linking
adam@0 6491 # statically, we need to preload. We also need to preload any
adam@0 6492 # dependent libraries so libltdl's deplib preloader doesn't
adam@0 6493 # bomb out in the load deplibs phase.
adam@12 6494 func_append dlprefiles " $lib $dependency_libs"
adam@0 6495 else
adam@12 6496 func_append newdlfiles " $lib"
adam@0 6497 fi
adam@0 6498 continue
adam@0 6499 fi # $pass = dlopen
adam@0 6500
adam@0 6501 # We need an absolute path.
adam@0 6502 case $ladir in
adam@0 6503 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
adam@0 6504 *)
adam@0 6505 abs_ladir=`cd "$ladir" && pwd`
adam@0 6506 if test -z "$abs_ladir"; then
adam@0 6507 func_warning "cannot determine absolute directory name of \`$ladir'"
adam@0 6508 func_warning "passing it literally to the linker, although it might fail"
adam@0 6509 abs_ladir="$ladir"
adam@0 6510 fi
adam@0 6511 ;;
adam@0 6512 esac
adam@0 6513 func_basename "$lib"
adam@0 6514 laname="$func_basename_result"
adam@0 6515
adam@0 6516 # Find the relevant object directory and library name.
adam@0 6517 if test "X$installed" = Xyes; then
adam@12 6518 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
adam@0 6519 func_warning "library \`$lib' was moved."
adam@0 6520 dir="$ladir"
adam@0 6521 absdir="$abs_ladir"
adam@0 6522 libdir="$abs_ladir"
adam@0 6523 else
adam@12 6524 dir="$lt_sysroot$libdir"
adam@12 6525 absdir="$lt_sysroot$libdir"
adam@0 6526 fi
adam@0 6527 test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
adam@0 6528 else
adam@0 6529 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
adam@0 6530 dir="$ladir"
adam@0 6531 absdir="$abs_ladir"
adam@0 6532 # Remove this search path later
adam@12 6533 func_append notinst_path " $abs_ladir"
adam@0 6534 else
adam@0 6535 dir="$ladir/$objdir"
adam@0 6536 absdir="$abs_ladir/$objdir"
adam@0 6537 # Remove this search path later
adam@12 6538 func_append notinst_path " $abs_ladir"
adam@0 6539 fi
adam@0 6540 fi # $installed = yes
adam@0 6541 func_stripname 'lib' '.la' "$laname"
adam@0 6542 name=$func_stripname_result
adam@0 6543
adam@0 6544 # This library was specified with -dlpreopen.
adam@0 6545 if test "$pass" = dlpreopen; then
adam@0 6546 if test -z "$libdir" && test "$linkmode" = prog; then
adam@0 6547 func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
adam@0 6548 fi
adam@12 6549 case "$host" in
adam@12 6550 # special handling for platforms with PE-DLLs.
adam@12 6551 *cygwin* | *mingw* | *cegcc* )
adam@12 6552 # Linker will automatically link against shared library if both
adam@12 6553 # static and shared are present. Therefore, ensure we extract
adam@12 6554 # symbols from the import library if a shared library is present
adam@12 6555 # (otherwise, the dlopen module name will be incorrect). We do
adam@12 6556 # this by putting the import library name into $newdlprefiles.
adam@12 6557 # We recover the dlopen module name by 'saving' the la file
adam@12 6558 # name in a special purpose variable, and (later) extracting the
adam@12 6559 # dlname from the la file.
adam@12 6560 if test -n "$dlname"; then
adam@12 6561 func_tr_sh "$dir/$linklib"
adam@12 6562 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
adam@12 6563 func_append newdlprefiles " $dir/$linklib"
adam@12 6564 else
adam@12 6565 func_append newdlprefiles " $dir/$old_library"
adam@12 6566 # Keep a list of preopened convenience libraries to check
adam@12 6567 # that they are being used correctly in the link pass.
adam@12 6568 test -z "$libdir" && \
adam@12 6569 func_append dlpreconveniencelibs " $dir/$old_library"
adam@12 6570 fi
adam@12 6571 ;;
adam@12 6572 * )
adam@12 6573 # Prefer using a static library (so that no silly _DYNAMIC symbols
adam@12 6574 # are required to link).
adam@12 6575 if test -n "$old_library"; then
adam@12 6576 func_append newdlprefiles " $dir/$old_library"
adam@12 6577 # Keep a list of preopened convenience libraries to check
adam@12 6578 # that they are being used correctly in the link pass.
adam@12 6579 test -z "$libdir" && \
adam@12 6580 func_append dlpreconveniencelibs " $dir/$old_library"
adam@12 6581 # Otherwise, use the dlname, so that lt_dlopen finds it.
adam@12 6582 elif test -n "$dlname"; then
adam@12 6583 func_append newdlprefiles " $dir/$dlname"
adam@12 6584 else
adam@12 6585 func_append newdlprefiles " $dir/$linklib"
adam@12 6586 fi
adam@12 6587 ;;
adam@12 6588 esac
adam@0 6589 fi # $pass = dlpreopen
adam@0 6590
adam@0 6591 if test -z "$libdir"; then
adam@0 6592 # Link the convenience library
adam@0 6593 if test "$linkmode" = lib; then
adam@0 6594 deplibs="$dir/$old_library $deplibs"
adam@0 6595 elif test "$linkmode,$pass" = "prog,link"; then
adam@0 6596 compile_deplibs="$dir/$old_library $compile_deplibs"
adam@0 6597 finalize_deplibs="$dir/$old_library $finalize_deplibs"
adam@0 6598 else
adam@0 6599 deplibs="$lib $deplibs" # used for prog,scan pass
adam@0 6600 fi
adam@0 6601 continue
adam@0 6602 fi
adam@0 6603
adam@0 6604
adam@0 6605 if test "$linkmode" = prog && test "$pass" != link; then
adam@12 6606 func_append newlib_search_path " $ladir"
adam@0 6607 deplibs="$lib $deplibs"
adam@0 6608
adam@0 6609 linkalldeplibs=no
adam@0 6610 if test "$link_all_deplibs" != no || test -z "$library_names" ||
adam@0 6611 test "$build_libtool_libs" = no; then
adam@0 6612 linkalldeplibs=yes
adam@0 6613 fi
adam@0 6614
adam@0 6615 tmp_libs=
adam@0 6616 for deplib in $dependency_libs; do
adam@0 6617 case $deplib in
adam@0 6618 -L*) func_stripname '-L' '' "$deplib"
adam@12 6619 func_resolve_sysroot "$func_stripname_result"
adam@12 6620 func_append newlib_search_path " $func_resolve_sysroot_result"
adam@0 6621 ;;
adam@0 6622 esac
adam@0 6623 # Need to link against all dependency_libs?
adam@0 6624 if test "$linkalldeplibs" = yes; then
adam@0 6625 deplibs="$deplib $deplibs"
adam@0 6626 else
adam@0 6627 # Need to hardcode shared library paths
adam@0 6628 # or/and link against static libraries
adam@0 6629 newdependency_libs="$deplib $newdependency_libs"
adam@0 6630 fi
adam@12 6631 if $opt_preserve_dup_deps ; then
adam@0 6632 case "$tmp_libs " in
adam@12 6633 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
adam@0 6634 esac
adam@0 6635 fi
adam@12 6636 func_append tmp_libs " $deplib"
adam@0 6637 done # for deplib
adam@0 6638 continue
adam@0 6639 fi # $linkmode = prog...
adam@0 6640
adam@0 6641 if test "$linkmode,$pass" = "prog,link"; then
adam@0 6642 if test -n "$library_names" &&
adam@0 6643 { { test "$prefer_static_libs" = no ||
adam@0 6644 test "$prefer_static_libs,$installed" = "built,yes"; } ||
adam@0 6645 test -z "$old_library"; }; then
adam@0 6646 # We need to hardcode the library path
adam@0 6647 if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
adam@0 6648 # Make sure the rpath contains only unique directories.
adam@0 6649 case "$temp_rpath:" in
adam@0 6650 *"$absdir:"*) ;;
adam@12 6651 *) func_append temp_rpath "$absdir:" ;;
adam@0 6652 esac
adam@0 6653 fi
adam@0 6654
adam@0 6655 # Hardcode the library path.
adam@0 6656 # Skip directories that are in the system default run-time
adam@0 6657 # search path.
adam@0 6658 case " $sys_lib_dlsearch_path " in
adam@0 6659 *" $absdir "*) ;;
adam@0 6660 *)
adam@0 6661 case "$compile_rpath " in
adam@0 6662 *" $absdir "*) ;;
adam@12 6663 *) func_append compile_rpath " $absdir" ;;
adam@0 6664 esac
adam@0 6665 ;;
adam@0 6666 esac
adam@0 6667 case " $sys_lib_dlsearch_path " in
adam@0 6668 *" $libdir "*) ;;
adam@0 6669 *)
adam@0 6670 case "$finalize_rpath " in
adam@0 6671 *" $libdir "*) ;;
adam@12 6672 *) func_append finalize_rpath " $libdir" ;;
adam@0 6673 esac
adam@0 6674 ;;
adam@0 6675 esac
adam@0 6676 fi # $linkmode,$pass = prog,link...
adam@0 6677
adam@0 6678 if test "$alldeplibs" = yes &&
adam@0 6679 { test "$deplibs_check_method" = pass_all ||
adam@0 6680 { test "$build_libtool_libs" = yes &&
adam@0 6681 test -n "$library_names"; }; }; then
adam@0 6682 # We only need to search for static libraries
adam@0 6683 continue
adam@0 6684 fi
adam@0 6685 fi
adam@0 6686
adam@0 6687 link_static=no # Whether the deplib will be linked statically
adam@0 6688 use_static_libs=$prefer_static_libs
adam@0 6689 if test "$use_static_libs" = built && test "$installed" = yes; then
adam@0 6690 use_static_libs=no
adam@0 6691 fi
adam@0 6692 if test -n "$library_names" &&
adam@0 6693 { test "$use_static_libs" = no || test -z "$old_library"; }; then
adam@0 6694 case $host in
adam@0 6695 *cygwin* | *mingw* | *cegcc*)
adam@0 6696 # No point in relinking DLLs because paths are not encoded
adam@12 6697 func_append notinst_deplibs " $lib"
adam@0 6698 need_relink=no
adam@0 6699 ;;
adam@0 6700 *)
adam@0 6701 if test "$installed" = no; then
adam@12 6702 func_append notinst_deplibs " $lib"
adam@0 6703 need_relink=yes
adam@0 6704 fi
adam@0 6705 ;;
adam@0 6706 esac
adam@0 6707 # This is a shared library
adam@0 6708
adam@0 6709 # Warn about portability, can't link against -module's on some
adam@0 6710 # systems (darwin). Don't bleat about dlopened modules though!
adam@0 6711 dlopenmodule=""
adam@0 6712 for dlpremoduletest in $dlprefiles; do
adam@0 6713 if test "X$dlpremoduletest" = "X$lib"; then
adam@0 6714 dlopenmodule="$dlpremoduletest"
adam@0 6715 break
adam@0 6716 fi
adam@0 6717 done
adam@0 6718 if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
adam@12 6719 echo
adam@0 6720 if test "$linkmode" = prog; then
adam@0 6721 $ECHO "*** Warning: Linking the executable $output against the loadable module"
adam@0 6722 else
adam@0 6723 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
adam@0 6724 fi
adam@0 6725 $ECHO "*** $linklib is not portable!"
adam@0 6726 fi
adam@0 6727 if test "$linkmode" = lib &&
adam@0 6728 test "$hardcode_into_libs" = yes; then
adam@0 6729 # Hardcode the library path.
adam@0 6730 # Skip directories that are in the system default run-time
adam@0 6731 # search path.
adam@0 6732 case " $sys_lib_dlsearch_path " in
adam@0 6733 *" $absdir "*) ;;
adam@0 6734 *)
adam@0 6735 case "$compile_rpath " in
adam@0 6736 *" $absdir "*) ;;
adam@12 6737 *) func_append compile_rpath " $absdir" ;;
adam@0 6738 esac
adam@0 6739 ;;
adam@0 6740 esac
adam@0 6741 case " $sys_lib_dlsearch_path " in
adam@0 6742 *" $libdir "*) ;;
adam@0 6743 *)
adam@0 6744 case "$finalize_rpath " in
adam@0 6745 *" $libdir "*) ;;
adam@12 6746 *) func_append finalize_rpath " $libdir" ;;
adam@0 6747 esac
adam@0 6748 ;;
adam@0 6749 esac
adam@0 6750 fi
adam@0 6751
adam@0 6752 if test -n "$old_archive_from_expsyms_cmds"; then
adam@0 6753 # figure out the soname
adam@0 6754 set dummy $library_names
adam@0 6755 shift
adam@0 6756 realname="$1"
adam@0 6757 shift
adam@0 6758 libname=`eval "\\$ECHO \"$libname_spec\""`
adam@0 6759 # use dlname if we got it. it's perfectly good, no?
adam@0 6760 if test -n "$dlname"; then
adam@0 6761 soname="$dlname"
adam@0 6762 elif test -n "$soname_spec"; then
adam@0 6763 # bleh windows
adam@0 6764 case $host in
adam@0 6765 *cygwin* | mingw* | *cegcc*)
adam@0 6766 func_arith $current - $age
adam@0 6767 major=$func_arith_result
adam@0 6768 versuffix="-$major"
adam@0 6769 ;;
adam@0 6770 esac
adam@0 6771 eval soname=\"$soname_spec\"
adam@0 6772 else
adam@0 6773 soname="$realname"
adam@0 6774 fi
adam@0 6775
adam@0 6776 # Make a new name for the extract_expsyms_cmds to use
adam@0 6777 soroot="$soname"
adam@0 6778 func_basename "$soroot"
adam@0 6779 soname="$func_basename_result"
adam@0 6780 func_stripname 'lib' '.dll' "$soname"
adam@0 6781 newlib=libimp-$func_stripname_result.a
adam@0 6782
adam@0 6783 # If the library has no export list, then create one now
adam@0 6784 if test -f "$output_objdir/$soname-def"; then :
adam@0 6785 else
adam@0 6786 func_verbose "extracting exported symbol list from \`$soname'"
adam@0 6787 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
adam@0 6788 fi
adam@0 6789
adam@0 6790 # Create $newlib
adam@0 6791 if test -f "$output_objdir/$newlib"; then :; else
adam@0 6792 func_verbose "generating import library for \`$soname'"
adam@0 6793 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
adam@0 6794 fi
adam@0 6795 # make sure the library variables are pointing to the new library
adam@0 6796 dir=$output_objdir
adam@0 6797 linklib=$newlib
adam@0 6798 fi # test -n "$old_archive_from_expsyms_cmds"
adam@0 6799
adam@12 6800 if test "$linkmode" = prog || test "$opt_mode" != relink; then
adam@0 6801 add_shlibpath=
adam@0 6802 add_dir=
adam@0 6803 add=
adam@0 6804 lib_linked=yes
adam@0 6805 case $hardcode_action in
adam@0 6806 immediate | unsupported)
adam@0 6807 if test "$hardcode_direct" = no; then
adam@0 6808 add="$dir/$linklib"
adam@0 6809 case $host in
adam@0 6810 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
adam@0 6811 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
adam@0 6812 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
adam@0 6813 *-*-unixware7*) add_dir="-L$dir" ;;
adam@0 6814 *-*-darwin* )
adam@0 6815 # if the lib is a (non-dlopened) module then we can not
adam@0 6816 # link against it, someone is ignoring the earlier warnings
adam@0 6817 if /usr/bin/file -L $add 2> /dev/null |
adam@0 6818 $GREP ": [^:]* bundle" >/dev/null ; then
adam@0 6819 if test "X$dlopenmodule" != "X$lib"; then
adam@0 6820 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
adam@0 6821 if test -z "$old_library" ; then
adam@12 6822 echo
adam@12 6823 echo "*** And there doesn't seem to be a static archive available"
adam@12 6824 echo "*** The link will probably fail, sorry"
adam@0 6825 else
adam@0 6826 add="$dir/$old_library"
adam@0 6827 fi
adam@0 6828 elif test -n "$old_library"; then
adam@0 6829 add="$dir/$old_library"
adam@0 6830 fi
adam@0 6831 fi
adam@0 6832 esac
adam@0 6833 elif test "$hardcode_minus_L" = no; then
adam@0 6834 case $host in
adam@0 6835 *-*-sunos*) add_shlibpath="$dir" ;;
adam@0 6836 esac
adam@0 6837 add_dir="-L$dir"
adam@0 6838 add="-l$name"
adam@0 6839 elif test "$hardcode_shlibpath_var" = no; then
adam@0 6840 add_shlibpath="$dir"
adam@0 6841 add="-l$name"
adam@0 6842 else
adam@0 6843 lib_linked=no
adam@0 6844 fi
adam@0 6845 ;;
adam@0 6846 relink)
adam@0 6847 if test "$hardcode_direct" = yes &&
adam@0 6848 test "$hardcode_direct_absolute" = no; then
adam@0 6849 add="$dir/$linklib"
adam@0 6850 elif test "$hardcode_minus_L" = yes; then
adam@20 6851 add_dir="-L$absdir"
adam@0 6852 # Try looking first in the location we're being installed to.
adam@0 6853 if test -n "$inst_prefix_dir"; then
adam@0 6854 case $libdir in
adam@0 6855 [\\/]*)
adam@12 6856 func_append add_dir " -L$inst_prefix_dir$libdir"
adam@0 6857 ;;
adam@0 6858 esac
adam@0 6859 fi
adam@0 6860 add="-l$name"
adam@0 6861 elif test "$hardcode_shlibpath_var" = yes; then
adam@0 6862 add_shlibpath="$dir"
adam@0 6863 add="-l$name"
adam@0 6864 else
adam@0 6865 lib_linked=no
adam@0 6866 fi
adam@0 6867 ;;
adam@0 6868 *) lib_linked=no ;;
adam@0 6869 esac
adam@0 6870
adam@0 6871 if test "$lib_linked" != yes; then
adam@0 6872 func_fatal_configuration "unsupported hardcode properties"
adam@0 6873 fi
adam@0 6874
adam@0 6875 if test -n "$add_shlibpath"; then
adam@0 6876 case :$compile_shlibpath: in
adam@0 6877 *":$add_shlibpath:"*) ;;
adam@12 6878 *) func_append compile_shlibpath "$add_shlibpath:" ;;
adam@0 6879 esac
adam@0 6880 fi
adam@0 6881 if test "$linkmode" = prog; then
adam@0 6882 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
adam@0 6883 test -n "$add" && compile_deplibs="$add $compile_deplibs"
adam@0 6884 else
adam@0 6885 test -n "$add_dir" && deplibs="$add_dir $deplibs"
adam@0 6886 test -n "$add" && deplibs="$add $deplibs"
adam@0 6887 if test "$hardcode_direct" != yes &&
adam@0 6888 test "$hardcode_minus_L" != yes &&
adam@0 6889 test "$hardcode_shlibpath_var" = yes; then
adam@0 6890 case :$finalize_shlibpath: in
adam@0 6891 *":$libdir:"*) ;;
adam@12 6892 *) func_append finalize_shlibpath "$libdir:" ;;
adam@0 6893 esac
adam@0 6894 fi
adam@0 6895 fi
adam@0 6896 fi
adam@0 6897
adam@12 6898 if test "$linkmode" = prog || test "$opt_mode" = relink; then
adam@0 6899 add_shlibpath=
adam@0 6900 add_dir=
adam@0 6901 add=
adam@0 6902 # Finalize command for both is simple: just hardcode it.
adam@0 6903 if test "$hardcode_direct" = yes &&
adam@0 6904 test "$hardcode_direct_absolute" = no; then
adam@0 6905 add="$libdir/$linklib"
adam@0 6906 elif test "$hardcode_minus_L" = yes; then
adam@0 6907 add_dir="-L$libdir"
adam@0 6908 add="-l$name"
adam@0 6909 elif test "$hardcode_shlibpath_var" = yes; then
adam@0 6910 case :$finalize_shlibpath: in
adam@0 6911 *":$libdir:"*) ;;
adam@12 6912 *) func_append finalize_shlibpath "$libdir:" ;;
adam@0 6913 esac
adam@0 6914 add="-l$name"
adam@0 6915 elif test "$hardcode_automatic" = yes; then
adam@0 6916 if test -n "$inst_prefix_dir" &&
adam@0 6917 test -f "$inst_prefix_dir$libdir/$linklib" ; then
adam@0 6918 add="$inst_prefix_dir$libdir/$linklib"
adam@0 6919 else
adam@0 6920 add="$libdir/$linklib"
adam@0 6921 fi
adam@0 6922 else
adam@0 6923 # We cannot seem to hardcode it, guess we'll fake it.
adam@0 6924 add_dir="-L$libdir"
adam@0 6925 # Try looking first in the location we're being installed to.
adam@0 6926 if test -n "$inst_prefix_dir"; then
adam@0 6927 case $libdir in
adam@0 6928 [\\/]*)
adam@12 6929 func_append add_dir " -L$inst_prefix_dir$libdir"
adam@0 6930 ;;
adam@0 6931 esac
adam@0 6932 fi
adam@0 6933 add="-l$name"
adam@0 6934 fi
adam@0 6935
adam@0 6936 if test "$linkmode" = prog; then
adam@0 6937 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
adam@0 6938 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
adam@0 6939 else
adam@0 6940 test -n "$add_dir" && deplibs="$add_dir $deplibs"
adam@0 6941 test -n "$add" && deplibs="$add $deplibs"
adam@0 6942 fi
adam@0 6943 fi
adam@0 6944 elif test "$linkmode" = prog; then
adam@0 6945 # Here we assume that one of hardcode_direct or hardcode_minus_L
adam@0 6946 # is not unsupported. This is valid on all known static and
adam@0 6947 # shared platforms.
adam@0 6948 if test "$hardcode_direct" != unsupported; then
adam@0 6949 test -n "$old_library" && linklib="$old_library"
adam@0 6950 compile_deplibs="$dir/$linklib $compile_deplibs"
adam@0 6951 finalize_deplibs="$dir/$linklib $finalize_deplibs"
adam@0 6952 else
adam@0 6953 compile_deplibs="-l$name -L$dir $compile_deplibs"
adam@0 6954 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
adam@0 6955 fi
adam@0 6956 elif test "$build_libtool_libs" = yes; then
adam@0 6957 # Not a shared library
adam@0 6958 if test "$deplibs_check_method" != pass_all; then
adam@0 6959 # We're trying link a shared library against a static one
adam@0 6960 # but the system doesn't support it.
adam@0 6961
adam@0 6962 # Just print a warning and add the library to dependency_libs so
adam@0 6963 # that the program can be linked against the static library.
adam@12 6964 echo
adam@0 6965 $ECHO "*** Warning: This system can not link to static lib archive $lib."
adam@12 6966 echo "*** I have the capability to make that library automatically link in when"
adam@12 6967 echo "*** you link to this library. But I can only do this if you have a"
adam@12 6968 echo "*** shared version of the library, which you do not appear to have."
adam@0 6969 if test "$module" = yes; then
adam@12 6970 echo "*** But as you try to build a module library, libtool will still create "
adam@12 6971 echo "*** a static module, that should work as long as the dlopening application"
adam@12 6972 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
adam@0 6973 if test -z "$global_symbol_pipe"; then
adam@12 6974 echo
adam@12 6975 echo "*** However, this would only work if libtool was able to extract symbol"
adam@12 6976 echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
adam@12 6977 echo "*** not find such a program. So, this module is probably useless."
adam@12 6978 echo "*** \`nm' from GNU binutils and a full rebuild may help."
adam@0 6979 fi
adam@0 6980 if test "$build_old_libs" = no; then
adam@0 6981 build_libtool_libs=module
adam@0 6982 build_old_libs=yes
adam@0 6983 else
adam@0 6984 build_libtool_libs=no
adam@0 6985 fi
adam@0 6986 fi
adam@0 6987 else
adam@0 6988 deplibs="$dir/$old_library $deplibs"
adam@0 6989 link_static=yes
adam@0 6990 fi
adam@0 6991 fi # link shared/static library?
adam@0 6992
adam@0 6993 if test "$linkmode" = lib; then
adam@0 6994 if test -n "$dependency_libs" &&
adam@0 6995 { test "$hardcode_into_libs" != yes ||
adam@0 6996 test "$build_old_libs" = yes ||
adam@0 6997 test "$link_static" = yes; }; then
adam@0 6998 # Extract -R from dependency_libs
adam@0 6999 temp_deplibs=
adam@0 7000 for libdir in $dependency_libs; do
adam@0 7001 case $libdir in
adam@0 7002 -R*) func_stripname '-R' '' "$libdir"
adam@0 7003 temp_xrpath=$func_stripname_result
adam@0 7004 case " $xrpath " in
adam@0 7005 *" $temp_xrpath "*) ;;
adam@12 7006 *) func_append xrpath " $temp_xrpath";;
adam@0 7007 esac;;
adam@12 7008 *) func_append temp_deplibs " $libdir";;
adam@0 7009 esac
adam@0 7010 done
adam@0 7011 dependency_libs="$temp_deplibs"
adam@0 7012 fi
adam@0 7013
adam@12 7014 func_append newlib_search_path " $absdir"
adam@0 7015 # Link against this library
adam@0 7016 test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
adam@0 7017 # ... and its dependency_libs
adam@0 7018 tmp_libs=
adam@0 7019 for deplib in $dependency_libs; do
adam@0 7020 newdependency_libs="$deplib $newdependency_libs"
adam@12 7021 case $deplib in
adam@12 7022 -L*) func_stripname '-L' '' "$deplib"
adam@12 7023 func_resolve_sysroot "$func_stripname_result";;
adam@12 7024 *) func_resolve_sysroot "$deplib" ;;
adam@12 7025 esac
adam@12 7026 if $opt_preserve_dup_deps ; then
adam@0 7027 case "$tmp_libs " in
adam@12 7028 *" $func_resolve_sysroot_result "*)
adam@12 7029 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
adam@0 7030 esac
adam@0 7031 fi
adam@12 7032 func_append tmp_libs " $func_resolve_sysroot_result"
adam@0 7033 done
adam@0 7034
adam@0 7035 if test "$link_all_deplibs" != no; then
adam@0 7036 # Add the search paths of all dependency libraries
adam@0 7037 for deplib in $dependency_libs; do
adam@0 7038 path=
adam@0 7039 case $deplib in
adam@0 7040 -L*) path="$deplib" ;;
adam@0 7041 *.la)
adam@12 7042 func_resolve_sysroot "$deplib"
adam@12 7043 deplib=$func_resolve_sysroot_result
adam@0 7044 func_dirname "$deplib" "" "."
adam@12 7045 dir=$func_dirname_result
adam@0 7046 # We need an absolute path.
adam@0 7047 case $dir in
adam@0 7048 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
adam@0 7049 *)
adam@0 7050 absdir=`cd "$dir" && pwd`
adam@0 7051 if test -z "$absdir"; then
adam@0 7052 func_warning "cannot determine absolute directory name of \`$dir'"
adam@0 7053 absdir="$dir"
adam@0 7054 fi
adam@0 7055 ;;
adam@0 7056 esac
adam@0 7057 if $GREP "^installed=no" $deplib > /dev/null; then
adam@0 7058 case $host in
adam@0 7059 *-*-darwin*)
adam@0 7060 depdepl=
adam@0 7061 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
adam@0 7062 if test -n "$deplibrary_names" ; then
adam@0 7063 for tmp in $deplibrary_names ; do
adam@0 7064 depdepl=$tmp
adam@0 7065 done
adam@0 7066 if test -f "$absdir/$objdir/$depdepl" ; then
adam@0 7067 depdepl="$absdir/$objdir/$depdepl"
adam@0 7068 darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
adam@0 7069 if test -z "$darwin_install_name"; then
adam@0 7070 darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
adam@0 7071 fi
adam@12 7072 func_append compiler_flags " ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
adam@12 7073 func_append linker_flags " -dylib_file ${darwin_install_name}:${depdepl}"
adam@0 7074 path=
adam@0 7075 fi
adam@0 7076 fi
adam@0 7077 ;;
adam@0 7078 *)
adam@0 7079 path="-L$absdir/$objdir"
adam@0 7080 ;;
adam@0 7081 esac
adam@0 7082 else
adam@0 7083 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
adam@0 7084 test -z "$libdir" && \
adam@0 7085 func_fatal_error "\`$deplib' is not a valid libtool archive"
adam@0 7086 test "$absdir" != "$libdir" && \
adam@0 7087 func_warning "\`$deplib' seems to be moved"
adam@0 7088
adam@0 7089 path="-L$absdir"
adam@0 7090 fi
adam@0 7091 ;;
adam@0 7092 esac
adam@0 7093 case " $deplibs " in
adam@0 7094 *" $path "*) ;;
adam@0 7095 *) deplibs="$path $deplibs" ;;
adam@0 7096 esac
adam@0 7097 done
adam@0 7098 fi # link_all_deplibs != no
adam@0 7099 fi # linkmode = lib
adam@0 7100 done # for deplib in $libs
adam@0 7101 if test "$pass" = link; then
adam@0 7102 if test "$linkmode" = "prog"; then
adam@0 7103 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
adam@0 7104 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
adam@0 7105 else
adam@12 7106 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
adam@0 7107 fi
adam@0 7108 fi
adam@0 7109 dependency_libs="$newdependency_libs"
adam@0 7110 if test "$pass" = dlpreopen; then
adam@0 7111 # Link the dlpreopened libraries before other libraries
adam@0 7112 for deplib in $save_deplibs; do
adam@0 7113 deplibs="$deplib $deplibs"
adam@0 7114 done
adam@0 7115 fi
adam@0 7116 if test "$pass" != dlopen; then
adam@0 7117 if test "$pass" != conv; then
adam@0 7118 # Make sure lib_search_path contains only unique directories.
adam@0 7119 lib_search_path=
adam@0 7120 for dir in $newlib_search_path; do
adam@0 7121 case "$lib_search_path " in
adam@0 7122 *" $dir "*) ;;
adam@12 7123 *) func_append lib_search_path " $dir" ;;
adam@0 7124 esac
adam@0 7125 done
adam@0 7126 newlib_search_path=
adam@0 7127 fi
adam@0 7128
adam@0 7129 if test "$linkmode,$pass" != "prog,link"; then
adam@0 7130 vars="deplibs"
adam@0 7131 else
adam@0 7132 vars="compile_deplibs finalize_deplibs"
adam@0 7133 fi
adam@0 7134 for var in $vars dependency_libs; do
adam@0 7135 # Add libraries to $var in reverse order
adam@0 7136 eval tmp_libs=\"\$$var\"
adam@0 7137 new_libs=
adam@0 7138 for deplib in $tmp_libs; do
adam@0 7139 # FIXME: Pedantically, this is the right thing to do, so
adam@0 7140 # that some nasty dependency loop isn't accidentally
adam@0 7141 # broken:
adam@0 7142 #new_libs="$deplib $new_libs"
adam@0 7143 # Pragmatically, this seems to cause very few problems in
adam@0 7144 # practice:
adam@0 7145 case $deplib in
adam@0 7146 -L*) new_libs="$deplib $new_libs" ;;
adam@0 7147 -R*) ;;
adam@0 7148 *)
adam@0 7149 # And here is the reason: when a library appears more
adam@0 7150 # than once as an explicit dependence of a library, or
adam@0 7151 # is implicitly linked in more than once by the
adam@0 7152 # compiler, it is considered special, and multiple
adam@0 7153 # occurrences thereof are not removed. Compare this
adam@0 7154 # with having the same library being listed as a
adam@0 7155 # dependency of multiple other libraries: in this case,
adam@0 7156 # we know (pedantically, we assume) the library does not
adam@0 7157 # need to be listed more than once, so we keep only the
adam@0 7158 # last copy. This is not always right, but it is rare
adam@0 7159 # enough that we require users that really mean to play
adam@0 7160 # such unportable linking tricks to link the library
adam@0 7161 # using -Wl,-lname, so that libtool does not consider it
adam@0 7162 # for duplicate removal.
adam@0 7163 case " $specialdeplibs " in
adam@0 7164 *" $deplib "*) new_libs="$deplib $new_libs" ;;
adam@0 7165 *)
adam@0 7166 case " $new_libs " in
adam@0 7167 *" $deplib "*) ;;
adam@0 7168 *) new_libs="$deplib $new_libs" ;;
adam@0 7169 esac
adam@0 7170 ;;
adam@0 7171 esac
adam@0 7172 ;;
adam@0 7173 esac
adam@0 7174 done
adam@0 7175 tmp_libs=
adam@0 7176 for deplib in $new_libs; do
adam@0 7177 case $deplib in
adam@0 7178 -L*)
adam@0 7179 case " $tmp_libs " in
adam@0 7180 *" $deplib "*) ;;
adam@12 7181 *) func_append tmp_libs " $deplib" ;;
adam@0 7182 esac
adam@0 7183 ;;
adam@12 7184 *) func_append tmp_libs " $deplib" ;;
adam@0 7185 esac
adam@0 7186 done
adam@0 7187 eval $var=\"$tmp_libs\"
adam@0 7188 done # for var
adam@0 7189 fi
adam@0 7190 # Last step: remove runtime libs from dependency_libs
adam@0 7191 # (they stay in deplibs)
adam@0 7192 tmp_libs=
adam@0 7193 for i in $dependency_libs ; do
adam@0 7194 case " $predeps $postdeps $compiler_lib_search_path " in
adam@0 7195 *" $i "*)
adam@0 7196 i=""
adam@0 7197 ;;
adam@0 7198 esac
adam@0 7199 if test -n "$i" ; then
adam@12 7200 func_append tmp_libs " $i"
adam@0 7201 fi
adam@0 7202 done
adam@0 7203 dependency_libs=$tmp_libs
adam@0 7204 done # for pass
adam@0 7205 if test "$linkmode" = prog; then
adam@0 7206 dlfiles="$newdlfiles"
adam@0 7207 fi
adam@0 7208 if test "$linkmode" = prog || test "$linkmode" = lib; then
adam@0 7209 dlprefiles="$newdlprefiles"
adam@0 7210 fi
adam@0 7211
adam@0 7212 case $linkmode in
adam@0 7213 oldlib)
adam@0 7214 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
adam@0 7215 func_warning "\`-dlopen' is ignored for archives"
adam@0 7216 fi
adam@0 7217
adam@0 7218 case " $deplibs" in
adam@0 7219 *\ -l* | *\ -L*)
adam@0 7220 func_warning "\`-l' and \`-L' are ignored for archives" ;;
adam@0 7221 esac
adam@0 7222
adam@0 7223 test -n "$rpath" && \
adam@0 7224 func_warning "\`-rpath' is ignored for archives"
adam@0 7225
adam@0 7226 test -n "$xrpath" && \
adam@0 7227 func_warning "\`-R' is ignored for archives"
adam@0 7228
adam@0 7229 test -n "$vinfo" && \
adam@0 7230 func_warning "\`-version-info/-version-number' is ignored for archives"
adam@0 7231
adam@0 7232 test -n "$release" && \
adam@0 7233 func_warning "\`-release' is ignored for archives"
adam@0 7234
adam@0 7235 test -n "$export_symbols$export_symbols_regex" && \
adam@0 7236 func_warning "\`-export-symbols' is ignored for archives"
adam@0 7237
adam@0 7238 # Now set the variables for building old libraries.
adam@0 7239 build_libtool_libs=no
adam@0 7240 oldlibs="$output"
adam@12 7241 func_append objs "$old_deplibs"
adam@0 7242 ;;
adam@0 7243
adam@0 7244 lib)
adam@0 7245 # Make sure we only generate libraries of the form `libNAME.la'.
adam@0 7246 case $outputname in
adam@0 7247 lib*)
adam@0 7248 func_stripname 'lib' '.la' "$outputname"
adam@0 7249 name=$func_stripname_result
adam@0 7250 eval shared_ext=\"$shrext_cmds\"
adam@0 7251 eval libname=\"$libname_spec\"
adam@0 7252 ;;
adam@0 7253 *)
adam@0 7254 test "$module" = no && \
adam@0 7255 func_fatal_help "libtool library \`$output' must begin with \`lib'"
adam@0 7256
adam@0 7257 if test "$need_lib_prefix" != no; then
adam@0 7258 # Add the "lib" prefix for modules if required
adam@0 7259 func_stripname '' '.la' "$outputname"
adam@0 7260 name=$func_stripname_result
adam@0 7261 eval shared_ext=\"$shrext_cmds\"
adam@0 7262 eval libname=\"$libname_spec\"
adam@0 7263 else
adam@0 7264 func_stripname '' '.la' "$outputname"
adam@0 7265 libname=$func_stripname_result
adam@0 7266 fi
adam@0 7267 ;;
adam@0 7268 esac
adam@0 7269
adam@0 7270 if test -n "$objs"; then
adam@0 7271 if test "$deplibs_check_method" != pass_all; then
adam@0 7272 func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
adam@0 7273 else
adam@12 7274 echo
adam@0 7275 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
adam@0 7276 $ECHO "*** objects $objs is not portable!"
adam@12 7277 func_append libobjs " $objs"
adam@0 7278 fi
adam@0 7279 fi
adam@0 7280
adam@0 7281 test "$dlself" != no && \
adam@0 7282 func_warning "\`-dlopen self' is ignored for libtool libraries"
adam@0 7283
adam@0 7284 set dummy $rpath
adam@0 7285 shift
adam@0 7286 test "$#" -gt 1 && \
adam@0 7287 func_warning "ignoring multiple \`-rpath's for a libtool library"
adam@0 7288
adam@0 7289 install_libdir="$1"
adam@0 7290
adam@0 7291 oldlibs=
adam@0 7292 if test -z "$rpath"; then
adam@0 7293 if test "$build_libtool_libs" = yes; then
adam@0 7294 # Building a libtool convenience library.
adam@0 7295 # Some compilers have problems with a `.al' extension so
adam@0 7296 # convenience libraries should have the same extension an
adam@0 7297 # archive normally would.
adam@0 7298 oldlibs="$output_objdir/$libname.$libext $oldlibs"
adam@0 7299 build_libtool_libs=convenience
adam@0 7300 build_old_libs=yes
adam@0 7301 fi
adam@0 7302
adam@0 7303 test -n "$vinfo" && \
adam@0 7304 func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
adam@0 7305
adam@0 7306 test -n "$release" && \
adam@0 7307 func_warning "\`-release' is ignored for convenience libraries"
adam@0 7308 else
adam@0 7309
adam@0 7310 # Parse the version information argument.
adam@0 7311 save_ifs="$IFS"; IFS=':'
adam@0 7312 set dummy $vinfo 0 0 0
adam@0 7313 shift
adam@0 7314 IFS="$save_ifs"
adam@0 7315
adam@0 7316 test -n "$7" && \
adam@0 7317 func_fatal_help "too many parameters to \`-version-info'"
adam@0 7318
adam@0 7319 # convert absolute version numbers to libtool ages
adam@0 7320 # this retains compatibility with .la files and attempts
adam@0 7321 # to make the code below a bit more comprehensible
adam@0 7322
adam@0 7323 case $vinfo_number in
adam@0 7324 yes)
adam@0 7325 number_major="$1"
adam@0 7326 number_minor="$2"
adam@0 7327 number_revision="$3"
adam@0 7328 #
adam@0 7329 # There are really only two kinds -- those that
adam@0 7330 # use the current revision as the major version
adam@0 7331 # and those that subtract age and use age as
adam@0 7332 # a minor version. But, then there is irix
adam@0 7333 # which has an extra 1 added just for fun
adam@0 7334 #
adam@0 7335 case $version_type in
adam@20 7336 # correct linux to gnu/linux during the next big refactor
adam@0 7337 darwin|linux|osf|windows|none)
adam@0 7338 func_arith $number_major + $number_minor
adam@0 7339 current=$func_arith_result
adam@0 7340 age="$number_minor"
adam@0 7341 revision="$number_revision"
adam@0 7342 ;;
adam@12 7343 freebsd-aout|freebsd-elf|qnx|sunos)
adam@0 7344 current="$number_major"
adam@0 7345 revision="$number_minor"
adam@0 7346 age="0"
adam@0 7347 ;;
adam@0 7348 irix|nonstopux)
adam@0 7349 func_arith $number_major + $number_minor
adam@0 7350 current=$func_arith_result
adam@0 7351 age="$number_minor"
adam@0 7352 revision="$number_minor"
adam@0 7353 lt_irix_increment=no
adam@0 7354 ;;
adam@0 7355 *)
adam@0 7356 func_fatal_configuration "$modename: unknown library version type \`$version_type'"
adam@0 7357 ;;
adam@0 7358 esac
adam@0 7359 ;;
adam@0 7360 no)
adam@0 7361 current="$1"
adam@0 7362 revision="$2"
adam@0 7363 age="$3"
adam@0 7364 ;;
adam@0 7365 esac
adam@0 7366
adam@0 7367 # Check that each of the things are valid numbers.
adam@0 7368 case $current in
adam@0 7369 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]) ;;
adam@0 7370 *)
adam@0 7371 func_error "CURRENT \`$current' must be a nonnegative integer"
adam@0 7372 func_fatal_error "\`$vinfo' is not valid version information"
adam@0 7373 ;;
adam@0 7374 esac
adam@0 7375
adam@0 7376 case $revision in
adam@0 7377 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]) ;;
adam@0 7378 *)
adam@0 7379 func_error "REVISION \`$revision' must be a nonnegative integer"
adam@0 7380 func_fatal_error "\`$vinfo' is not valid version information"
adam@0 7381 ;;
adam@0 7382 esac
adam@0 7383
adam@0 7384 case $age in
adam@0 7385 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]) ;;
adam@0 7386 *)
adam@0 7387 func_error "AGE \`$age' must be a nonnegative integer"
adam@0 7388 func_fatal_error "\`$vinfo' is not valid version information"
adam@0 7389 ;;
adam@0 7390 esac
adam@0 7391
adam@0 7392 if test "$age" -gt "$current"; then
adam@0 7393 func_error "AGE \`$age' is greater than the current interface number \`$current'"
adam@0 7394 func_fatal_error "\`$vinfo' is not valid version information"
adam@0 7395 fi
adam@0 7396
adam@0 7397 # Calculate the version variables.
adam@0 7398 major=
adam@0 7399 versuffix=
adam@0 7400 verstring=
adam@0 7401 case $version_type in
adam@0 7402 none) ;;
adam@0 7403
adam@0 7404 darwin)
adam@0 7405 # Like Linux, but with the current version available in
adam@0 7406 # verstring for coding it into the library header
adam@0 7407 func_arith $current - $age
adam@0 7408 major=.$func_arith_result
adam@0 7409 versuffix="$major.$age.$revision"
adam@0 7410 # Darwin ld doesn't like 0 for these options...
adam@0 7411 func_arith $current + 1
adam@0 7412 minor_current=$func_arith_result
adam@0 7413 xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
adam@0 7414 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
adam@0 7415 ;;
adam@0 7416
adam@0 7417 freebsd-aout)
adam@0 7418 major=".$current"
adam@0 7419 versuffix=".$current.$revision";
adam@0 7420 ;;
adam@0 7421
adam@0 7422 freebsd-elf)
adam@0 7423 major=".$current"
adam@0 7424 versuffix=".$current"
adam@0 7425 ;;
adam@0 7426
adam@0 7427 irix | nonstopux)
adam@0 7428 if test "X$lt_irix_increment" = "Xno"; then
adam@0 7429 func_arith $current - $age
adam@0 7430 else
adam@0 7431 func_arith $current - $age + 1
adam@0 7432 fi
adam@0 7433 major=$func_arith_result
adam@0 7434
adam@0 7435 case $version_type in
adam@0 7436 nonstopux) verstring_prefix=nonstopux ;;
adam@0 7437 *) verstring_prefix=sgi ;;
adam@0 7438 esac
adam@0 7439 verstring="$verstring_prefix$major.$revision"
adam@0 7440
adam@0 7441 # Add in all the interfaces that we are compatible with.
adam@0 7442 loop=$revision
adam@0 7443 while test "$loop" -ne 0; do
adam@0 7444 func_arith $revision - $loop
adam@0 7445 iface=$func_arith_result
adam@0 7446 func_arith $loop - 1
adam@0 7447 loop=$func_arith_result
adam@0 7448 verstring="$verstring_prefix$major.$iface:$verstring"
adam@0 7449 done
adam@0 7450
adam@0 7451 # Before this point, $major must not contain `.'.
adam@0 7452 major=.$major
adam@0 7453 versuffix="$major.$revision"
adam@0 7454 ;;
adam@0 7455
adam@20 7456 linux) # correct to gnu/linux during the next big refactor
adam@0 7457 func_arith $current - $age
adam@0 7458 major=.$func_arith_result
adam@0 7459 versuffix="$major.$age.$revision"
adam@0 7460 ;;
adam@0 7461
adam@0 7462 osf)
adam@0 7463 func_arith $current - $age
adam@0 7464 major=.$func_arith_result
adam@0 7465 versuffix=".$current.$age.$revision"
adam@0 7466 verstring="$current.$age.$revision"
adam@0 7467
adam@0 7468 # Add in all the interfaces that we are compatible with.
adam@0 7469 loop=$age
adam@0 7470 while test "$loop" -ne 0; do
adam@0 7471 func_arith $current - $loop
adam@0 7472 iface=$func_arith_result
adam@0 7473 func_arith $loop - 1
adam@0 7474 loop=$func_arith_result
adam@0 7475 verstring="$verstring:${iface}.0"
adam@0 7476 done
adam@0 7477
adam@0 7478 # Make executables depend on our current version.
adam@12 7479 func_append verstring ":${current}.0"
adam@0 7480 ;;
adam@0 7481
adam@0 7482 qnx)
adam@0 7483 major=".$current"
adam@0 7484 versuffix=".$current"
adam@0 7485 ;;
adam@0 7486
adam@0 7487 sunos)
adam@0 7488 major=".$current"
adam@0 7489 versuffix=".$current.$revision"
adam@0 7490 ;;
adam@0 7491
adam@0 7492 windows)
adam@0 7493 # Use '-' rather than '.', since we only want one
adam@0 7494 # extension on DOS 8.3 filesystems.
adam@0 7495 func_arith $current - $age
adam@0 7496 major=$func_arith_result
adam@0 7497 versuffix="-$major"
adam@0 7498 ;;
adam@0 7499
adam@0 7500 *)
adam@0 7501 func_fatal_configuration "unknown library version type \`$version_type'"
adam@0 7502 ;;
adam@0 7503 esac
adam@0 7504
adam@0 7505 # Clear the version info if we defaulted, and they specified a release.
adam@0 7506 if test -z "$vinfo" && test -n "$release"; then
adam@0 7507 major=
adam@0 7508 case $version_type in
adam@0 7509 darwin)
adam@0 7510 # we can't check for "0.0" in archive_cmds due to quoting
adam@0 7511 # problems, so we reset it completely
adam@0 7512 verstring=
adam@0 7513 ;;
adam@0 7514 *)
adam@0 7515 verstring="0.0"
adam@0 7516 ;;
adam@0 7517 esac
adam@0 7518 if test "$need_version" = no; then
adam@0 7519 versuffix=
adam@0 7520 else
adam@0 7521 versuffix=".0.0"
adam@0 7522 fi
adam@0 7523 fi
adam@0 7524
adam@0 7525 # Remove version info from name if versioning should be avoided
adam@0 7526 if test "$avoid_version" = yes && test "$need_version" = no; then
adam@0 7527 major=
adam@0 7528 versuffix=
adam@0 7529 verstring=""
adam@0 7530 fi
adam@0 7531
adam@0 7532 # Check to see if the archive will have undefined symbols.
adam@0 7533 if test "$allow_undefined" = yes; then
adam@0 7534 if test "$allow_undefined_flag" = unsupported; then
adam@0 7535 func_warning "undefined symbols not allowed in $host shared libraries"
adam@0 7536 build_libtool_libs=no
adam@0 7537 build_old_libs=yes
adam@0 7538 fi
adam@0 7539 else
adam@0 7540 # Don't allow undefined symbols.
adam@0 7541 allow_undefined_flag="$no_undefined_flag"
adam@0 7542 fi
adam@0 7543
adam@0 7544 fi
adam@0 7545
adam@0 7546 func_generate_dlsyms "$libname" "$libname" "yes"
adam@12 7547 func_append libobjs " $symfileobj"
adam@0 7548 test "X$libobjs" = "X " && libobjs=
adam@0 7549
adam@12 7550 if test "$opt_mode" != relink; then
adam@0 7551 # Remove our outputs, but don't remove object files since they
adam@0 7552 # may have been created when compiling PIC objects.
adam@0 7553 removelist=
adam@0 7554 tempremovelist=`$ECHO "$output_objdir/*"`
adam@0 7555 for p in $tempremovelist; do
adam@0 7556 case $p in
adam@0 7557 *.$objext | *.gcno)
adam@0 7558 ;;
adam@0 7559 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
adam@0 7560 if test "X$precious_files_regex" != "X"; then
adam@0 7561 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
adam@0 7562 then
adam@0 7563 continue
adam@0 7564 fi
adam@0 7565 fi
adam@12 7566 func_append removelist " $p"
adam@0 7567 ;;
adam@0 7568 *) ;;
adam@0 7569 esac
adam@0 7570 done
adam@0 7571 test -n "$removelist" && \
adam@0 7572 func_show_eval "${RM}r \$removelist"
adam@0 7573 fi
adam@0 7574
adam@0 7575 # Now set the variables for building old libraries.
adam@0 7576 if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
adam@12 7577 func_append oldlibs " $output_objdir/$libname.$libext"
adam@0 7578
adam@0 7579 # Transform .lo files to .o files.
adam@12 7580 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; $lo2o" | $NL2SP`
adam@0 7581 fi
adam@0 7582
adam@0 7583 # Eliminate all temporary directories.
adam@0 7584 #for path in $notinst_path; do
adam@12 7585 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
adam@12 7586 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
adam@12 7587 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
adam@0 7588 #done
adam@0 7589
adam@0 7590 if test -n "$xrpath"; then
adam@0 7591 # If the user specified any rpath flags, then add them.
adam@0 7592 temp_xrpath=
adam@0 7593 for libdir in $xrpath; do
adam@12 7594 func_replace_sysroot "$libdir"
adam@12 7595 func_append temp_xrpath " -R$func_replace_sysroot_result"
adam@0 7596 case "$finalize_rpath " in
adam@0 7597 *" $libdir "*) ;;
adam@12 7598 *) func_append finalize_rpath " $libdir" ;;
adam@0 7599 esac
adam@0 7600 done
adam@0 7601 if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
adam@0 7602 dependency_libs="$temp_xrpath $dependency_libs"
adam@0 7603 fi
adam@0 7604 fi
adam@0 7605
adam@0 7606 # Make sure dlfiles contains only unique files that won't be dlpreopened
adam@0 7607 old_dlfiles="$dlfiles"
adam@0 7608 dlfiles=
adam@0 7609 for lib in $old_dlfiles; do
adam@0 7610 case " $dlprefiles $dlfiles " in
adam@0 7611 *" $lib "*) ;;
adam@12 7612 *) func_append dlfiles " $lib" ;;
adam@0 7613 esac
adam@0 7614 done
adam@0 7615
adam@0 7616 # Make sure dlprefiles contains only unique files
adam@0 7617 old_dlprefiles="$dlprefiles"
adam@0 7618 dlprefiles=
adam@0 7619 for lib in $old_dlprefiles; do
adam@0 7620 case "$dlprefiles " in
adam@0 7621 *" $lib "*) ;;
adam@12 7622 *) func_append dlprefiles " $lib" ;;
adam@0 7623 esac
adam@0 7624 done
adam@0 7625
adam@0 7626 if test "$build_libtool_libs" = yes; then
adam@0 7627 if test -n "$rpath"; then
adam@0 7628 case $host in
adam@12 7629 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
adam@0 7630 # these systems don't actually have a c library (as such)!
adam@0 7631 ;;
adam@0 7632 *-*-rhapsody* | *-*-darwin1.[012])
adam@0 7633 # Rhapsody C library is in the System framework
adam@12 7634 func_append deplibs " System.ltframework"
adam@0 7635 ;;
adam@0 7636 *-*-netbsd*)
adam@0 7637 # Don't link with libc until the a.out ld.so is fixed.
adam@0 7638 ;;
adam@0 7639 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
adam@0 7640 # Do not include libc due to us having libc/libc_r.
adam@0 7641 ;;
adam@0 7642 *-*-sco3.2v5* | *-*-sco5v6*)
adam@0 7643 # Causes problems with __ctype
adam@0 7644 ;;
adam@0 7645 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
adam@0 7646 # Compiler inserts libc in the correct place for threads to work
adam@0 7647 ;;
adam@0 7648 *)
adam@0 7649 # Add libc to deplibs on all other systems if necessary.
adam@0 7650 if test "$build_libtool_need_lc" = "yes"; then
adam@12 7651 func_append deplibs " -lc"
adam@0 7652 fi
adam@0 7653 ;;
adam@0 7654 esac
adam@0 7655 fi
adam@0 7656
adam@0 7657 # Transform deplibs into only deplibs that can be linked in shared.
adam@0 7658 name_save=$name
adam@0 7659 libname_save=$libname
adam@0 7660 release_save=$release
adam@0 7661 versuffix_save=$versuffix
adam@0 7662 major_save=$major
adam@0 7663 # I'm not sure if I'm treating the release correctly. I think
adam@0 7664 # release should show up in the -l (ie -lgmp5) so we don't want to
adam@0 7665 # add it in twice. Is that correct?
adam@0 7666 release=""
adam@0 7667 versuffix=""
adam@0 7668 major=""
adam@0 7669 newdeplibs=
adam@0 7670 droppeddeps=no
adam@0 7671 case $deplibs_check_method in
adam@0 7672 pass_all)
adam@0 7673 # Don't check for shared/static. Everything works.
adam@0 7674 # This might be a little naive. We might want to check
adam@0 7675 # whether the library exists or not. But this is on
adam@0 7676 # osf3 & osf4 and I'm not really sure... Just
adam@0 7677 # implementing what was already the behavior.
adam@0 7678 newdeplibs=$deplibs
adam@0 7679 ;;
adam@0 7680 test_compile)
adam@0 7681 # This code stresses the "libraries are programs" paradigm to its
adam@0 7682 # limits. Maybe even breaks it. We compile a program, linking it
adam@0 7683 # against the deplibs as a proxy for the library. Then we can check
adam@0 7684 # whether they linked in statically or dynamically with ldd.
adam@0 7685 $opt_dry_run || $RM conftest.c
adam@0 7686 cat > conftest.c <<EOF
adam@0 7687 int main() { return 0; }
adam@0 7688 EOF
adam@0 7689 $opt_dry_run || $RM conftest
adam@0 7690 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
adam@0 7691 ldd_output=`ldd conftest`
adam@0 7692 for i in $deplibs; do
adam@0 7693 case $i in
adam@0 7694 -l*)
adam@0 7695 func_stripname -l '' "$i"
adam@0 7696 name=$func_stripname_result
adam@0 7697 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
adam@0 7698 case " $predeps $postdeps " in
adam@0 7699 *" $i "*)
adam@12 7700 func_append newdeplibs " $i"
adam@0 7701 i=""
adam@0 7702 ;;
adam@0 7703 esac
adam@0 7704 fi
adam@0 7705 if test -n "$i" ; then
adam@0 7706 libname=`eval "\\$ECHO \"$libname_spec\""`
adam@0 7707 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
adam@0 7708 set dummy $deplib_matches; shift
adam@0 7709 deplib_match=$1
adam@0 7710 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
adam@12 7711 func_append newdeplibs " $i"
adam@0 7712 else
adam@0 7713 droppeddeps=yes
adam@12 7714 echo
adam@0 7715 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
adam@12 7716 echo "*** I have the capability to make that library automatically link in when"
adam@12 7717 echo "*** you link to this library. But I can only do this if you have a"
adam@12 7718 echo "*** shared version of the library, which I believe you do not have"
adam@12 7719 echo "*** because a test_compile did reveal that the linker did not use it for"
adam@12 7720 echo "*** its dynamic dependency list that programs get resolved with at runtime."
adam@0 7721 fi
adam@0 7722 fi
adam@0 7723 ;;
adam@0 7724 *)
adam@12 7725 func_append newdeplibs " $i"
adam@0 7726 ;;
adam@0 7727 esac
adam@0 7728 done
adam@0 7729 else
adam@0 7730 # Error occurred in the first compile. Let's try to salvage
adam@0 7731 # the situation: Compile a separate program for each library.
adam@0 7732 for i in $deplibs; do
adam@0 7733 case $i in
adam@0 7734 -l*)
adam@0 7735 func_stripname -l '' "$i"
adam@0 7736 name=$func_stripname_result
adam@0 7737 $opt_dry_run || $RM conftest
adam@0 7738 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
adam@0 7739 ldd_output=`ldd conftest`
adam@0 7740 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
adam@0 7741 case " $predeps $postdeps " in
adam@0 7742 *" $i "*)
adam@12 7743 func_append newdeplibs " $i"
adam@0 7744 i=""
adam@0 7745 ;;
adam@0 7746 esac
adam@0 7747 fi
adam@0 7748 if test -n "$i" ; then
adam@0 7749 libname=`eval "\\$ECHO \"$libname_spec\""`
adam@0 7750 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
adam@0 7751 set dummy $deplib_matches; shift
adam@0 7752 deplib_match=$1
adam@0 7753 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
adam@12 7754 func_append newdeplibs " $i"
adam@0 7755 else
adam@0 7756 droppeddeps=yes
adam@12 7757 echo
adam@0 7758 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
adam@12 7759 echo "*** I have the capability to make that library automatically link in when"
adam@12 7760 echo "*** you link to this library. But I can only do this if you have a"
adam@12 7761 echo "*** shared version of the library, which you do not appear to have"
adam@12 7762 echo "*** because a test_compile did reveal that the linker did not use this one"
adam@12 7763 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
adam@0 7764 fi
adam@0 7765 fi
adam@0 7766 else
adam@0 7767 droppeddeps=yes
adam@12 7768 echo
adam@0 7769 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
adam@12 7770 echo "*** make it link in! You will probably need to install it or some"
adam@12 7771 echo "*** library that it depends on before this library will be fully"
adam@12 7772 echo "*** functional. Installing it before continuing would be even better."
adam@0 7773 fi
adam@0 7774 ;;
adam@0 7775 *)
adam@12 7776 func_append newdeplibs " $i"
adam@0 7777 ;;
adam@0 7778 esac
adam@0 7779 done
adam@0 7780 fi
adam@0 7781 ;;
adam@0 7782 file_magic*)
adam@0 7783 set dummy $deplibs_check_method; shift
adam@0 7784 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
adam@0 7785 for a_deplib in $deplibs; do
adam@0 7786 case $a_deplib in
adam@0 7787 -l*)
adam@0 7788 func_stripname -l '' "$a_deplib"
adam@0 7789 name=$func_stripname_result
adam@0 7790 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
adam@0 7791 case " $predeps $postdeps " in
adam@0 7792 *" $a_deplib "*)
adam@12 7793 func_append newdeplibs " $a_deplib"
adam@0 7794 a_deplib=""
adam@0 7795 ;;
adam@0 7796 esac
adam@0 7797 fi
adam@0 7798 if test -n "$a_deplib" ; then
adam@0 7799 libname=`eval "\\$ECHO \"$libname_spec\""`
adam@12 7800 if test -n "$file_magic_glob"; then
adam@12 7801 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
adam@12 7802 else
adam@12 7803 libnameglob=$libname
adam@12 7804 fi
adam@12 7805 test "$want_nocaseglob" = yes && nocaseglob=`shopt -p nocaseglob`
adam@0 7806 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
adam@12 7807 if test "$want_nocaseglob" = yes; then
adam@12 7808 shopt -s nocaseglob
adam@12 7809 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
adam@12 7810 $nocaseglob
adam@12 7811 else
adam@12 7812 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
adam@12 7813 fi
adam@0 7814 for potent_lib in $potential_libs; do
adam@0 7815 # Follow soft links.
adam@0 7816 if ls -lLd "$potent_lib" 2>/dev/null |
adam@0 7817 $GREP " -> " >/dev/null; then
adam@0 7818 continue
adam@0 7819 fi
adam@0 7820 # The statement above tries to avoid entering an
adam@0 7821 # endless loop below, in case of cyclic links.
adam@0 7822 # We might still enter an endless loop, since a link
adam@0 7823 # loop can be closed while we follow links,
adam@0 7824 # but so what?
adam@0 7825 potlib="$potent_lib"
adam@0 7826 while test -h "$potlib" 2>/dev/null; do
adam@0 7827 potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
adam@0 7828 case $potliblink in
adam@0 7829 [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
adam@12 7830 *) potlib=`$ECHO "$potlib" | $SED 's,[^/]*$,,'`"$potliblink";;
adam@0 7831 esac
adam@0 7832 done
adam@0 7833 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
adam@0 7834 $SED -e 10q |
adam@0 7835 $EGREP "$file_magic_regex" > /dev/null; then
adam@12 7836 func_append newdeplibs " $a_deplib"
adam@0 7837 a_deplib=""
adam@0 7838 break 2
adam@0 7839 fi
adam@0 7840 done
adam@0 7841 done
adam@0 7842 fi
adam@0 7843 if test -n "$a_deplib" ; then
adam@0 7844 droppeddeps=yes
adam@12 7845 echo
adam@0 7846 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
adam@12 7847 echo "*** I have the capability to make that library automatically link in when"
adam@12 7848 echo "*** you link to this library. But I can only do this if you have a"
adam@12 7849 echo "*** shared version of the library, which you do not appear to have"
adam@12 7850 echo "*** because I did check the linker path looking for a file starting"
adam@0 7851 if test -z "$potlib" ; then
adam@0 7852 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
adam@0 7853 else
adam@0 7854 $ECHO "*** with $libname and none of the candidates passed a file format test"
adam@0 7855 $ECHO "*** using a file magic. Last file checked: $potlib"
adam@0 7856 fi
adam@0 7857 fi
adam@0 7858 ;;
adam@0 7859 *)
adam@0 7860 # Add a -L argument.
adam@12 7861 func_append newdeplibs " $a_deplib"
adam@0 7862 ;;
adam@0 7863 esac
adam@0 7864 done # Gone through all deplibs.
adam@0 7865 ;;
adam@0 7866 match_pattern*)
adam@0 7867 set dummy $deplibs_check_method; shift
adam@0 7868 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
adam@0 7869 for a_deplib in $deplibs; do
adam@0 7870 case $a_deplib in
adam@0 7871 -l*)
adam@0 7872 func_stripname -l '' "$a_deplib"
adam@0 7873 name=$func_stripname_result
adam@0 7874 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
adam@0 7875 case " $predeps $postdeps " in
adam@0 7876 *" $a_deplib "*)
adam@12 7877 func_append newdeplibs " $a_deplib"
adam@0 7878 a_deplib=""
adam@0 7879 ;;
adam@0 7880 esac
adam@0 7881 fi
adam@0 7882 if test -n "$a_deplib" ; then
adam@0 7883 libname=`eval "\\$ECHO \"$libname_spec\""`
adam@0 7884 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
adam@0 7885 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
adam@0 7886 for potent_lib in $potential_libs; do
adam@0 7887 potlib="$potent_lib" # see symlink-check above in file_magic test
adam@12 7888 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
adam@0 7889 $EGREP "$match_pattern_regex" > /dev/null; then
adam@12 7890 func_append newdeplibs " $a_deplib"
adam@0 7891 a_deplib=""
adam@0 7892 break 2
adam@0 7893 fi
adam@0 7894 done
adam@0 7895 done
adam@0 7896 fi
adam@0 7897 if test -n "$a_deplib" ; then
adam@0 7898 droppeddeps=yes
adam@12 7899 echo
adam@0 7900 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
adam@12 7901 echo "*** I have the capability to make that library automatically link in when"
adam@12 7902 echo "*** you link to this library. But I can only do this if you have a"
adam@12 7903 echo "*** shared version of the library, which you do not appear to have"
adam@12 7904 echo "*** because I did check the linker path looking for a file starting"
adam@0 7905 if test -z "$potlib" ; then
adam@0 7906 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
adam@0 7907 else
adam@0 7908 $ECHO "*** with $libname and none of the candidates passed a file format test"
adam@0 7909 $ECHO "*** using a regex pattern. Last file checked: $potlib"
adam@0 7910 fi
adam@0 7911 fi
adam@0 7912 ;;
adam@0 7913 *)
adam@0 7914 # Add a -L argument.
adam@12 7915 func_append newdeplibs " $a_deplib"
adam@0 7916 ;;
adam@0 7917 esac
adam@0 7918 done # Gone through all deplibs.
adam@0 7919 ;;
adam@0 7920 none | unknown | *)
adam@0 7921 newdeplibs=""
adam@12 7922 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
adam@0 7923 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
adam@0 7924 for i in $predeps $postdeps ; do
adam@0 7925 # can't use Xsed below, because $i might contain '/'
adam@12 7926 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s,$i,,"`
adam@0 7927 done
adam@0 7928 fi
adam@12 7929 case $tmp_deplibs in
adam@12 7930 *[!\ \ ]*)
adam@12 7931 echo
adam@0 7932 if test "X$deplibs_check_method" = "Xnone"; then
adam@12 7933 echo "*** Warning: inter-library dependencies are not supported in this platform."
adam@0 7934 else
adam@12 7935 echo "*** Warning: inter-library dependencies are not known to be supported."
adam@0 7936 fi
adam@12 7937 echo "*** All declared inter-library dependencies are being dropped."
adam@0 7938 droppeddeps=yes
adam@12 7939 ;;
adam@12 7940 esac
adam@0 7941 ;;
adam@0 7942 esac
adam@0 7943 versuffix=$versuffix_save
adam@0 7944 major=$major_save
adam@0 7945 release=$release_save
adam@0 7946 libname=$libname_save
adam@0 7947 name=$name_save
adam@0 7948
adam@0 7949 case $host in
adam@0 7950 *-*-rhapsody* | *-*-darwin1.[012])
adam@0 7951 # On Rhapsody replace the C library with the System framework
adam@12 7952 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
adam@0 7953 ;;
adam@0 7954 esac
adam@0 7955
adam@0 7956 if test "$droppeddeps" = yes; then
adam@0 7957 if test "$module" = yes; then
adam@12 7958 echo
adam@12 7959 echo "*** Warning: libtool could not satisfy all declared inter-library"
adam@0 7960 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
adam@12 7961 echo "*** a static module, that should work as long as the dlopening"
adam@12 7962 echo "*** application is linked with the -dlopen flag."
adam@0 7963 if test -z "$global_symbol_pipe"; then
adam@12 7964 echo
adam@12 7965 echo "*** However, this would only work if libtool was able to extract symbol"
adam@12 7966 echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
adam@12 7967 echo "*** not find such a program. So, this module is probably useless."
adam@12 7968 echo "*** \`nm' from GNU binutils and a full rebuild may help."
adam@0 7969 fi
adam@0 7970 if test "$build_old_libs" = no; then
adam@0 7971 oldlibs="$output_objdir/$libname.$libext"
adam@0 7972 build_libtool_libs=module
adam@0 7973 build_old_libs=yes
adam@0 7974 else
adam@0 7975 build_libtool_libs=no
adam@0 7976 fi
adam@0 7977 else
adam@12 7978 echo "*** The inter-library dependencies that have been dropped here will be"
adam@12 7979 echo "*** automatically added whenever a program is linked with this library"
adam@12 7980 echo "*** or is declared to -dlopen it."
adam@0 7981
adam@0 7982 if test "$allow_undefined" = no; then
adam@12 7983 echo
adam@12 7984 echo "*** Since this library must not contain undefined symbols,"
adam@12 7985 echo "*** because either the platform does not support them or"
adam@12 7986 echo "*** it was explicitly requested with -no-undefined,"
adam@12 7987 echo "*** libtool will only create a static version of it."
adam@0 7988 if test "$build_old_libs" = no; then
adam@0 7989 oldlibs="$output_objdir/$libname.$libext"
adam@0 7990 build_libtool_libs=module
adam@0 7991 build_old_libs=yes
adam@0 7992 else
adam@0 7993 build_libtool_libs=no
adam@0 7994 fi
adam@0 7995 fi
adam@0 7996 fi
adam@0 7997 fi
adam@0 7998 # Done checking deplibs!
adam@0 7999 deplibs=$newdeplibs
adam@0 8000 fi
adam@0 8001 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
adam@0 8002 case $host in
adam@0 8003 *-*-darwin*)
adam@12 8004 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
adam@12 8005 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
adam@12 8006 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
adam@0 8007 ;;
adam@0 8008 esac
adam@0 8009
adam@0 8010 # move library search paths that coincide with paths to not yet
adam@0 8011 # installed libraries to the beginning of the library search list
adam@0 8012 new_libs=
adam@0 8013 for path in $notinst_path; do
adam@0 8014 case " $new_libs " in
adam@0 8015 *" -L$path/$objdir "*) ;;
adam@0 8016 *)
adam@0 8017 case " $deplibs " in
adam@0 8018 *" -L$path/$objdir "*)
adam@12 8019 func_append new_libs " -L$path/$objdir" ;;
adam@0 8020 esac
adam@0 8021 ;;
adam@0 8022 esac
adam@0 8023 done
adam@0 8024 for deplib in $deplibs; do
adam@0 8025 case $deplib in
adam@0 8026 -L*)
adam@0 8027 case " $new_libs " in
adam@0 8028 *" $deplib "*) ;;
adam@12 8029 *) func_append new_libs " $deplib" ;;
adam@0 8030 esac
adam@0 8031 ;;
adam@12 8032 *) func_append new_libs " $deplib" ;;
adam@0 8033 esac
adam@0 8034 done
adam@0 8035 deplibs="$new_libs"
adam@0 8036
adam@0 8037 # All the library-specific variables (install_libdir is set above).
adam@0 8038 library_names=
adam@0 8039 old_library=
adam@0 8040 dlname=
adam@0 8041
adam@0 8042 # Test again, we may have decided not to build it any more
adam@0 8043 if test "$build_libtool_libs" = yes; then
adam@20 8044 # Remove ${wl} instances when linking with ld.
adam@20 8045 # FIXME: should test the right _cmds variable.
adam@20 8046 case $archive_cmds in
adam@20 8047 *\$LD\ *) wl= ;;
adam@20 8048 esac
adam@0 8049 if test "$hardcode_into_libs" = yes; then
adam@0 8050 # Hardcode the library paths
adam@0 8051 hardcode_libdirs=
adam@0 8052 dep_rpath=
adam@0 8053 rpath="$finalize_rpath"
adam@12 8054 test "$opt_mode" != relink && rpath="$compile_rpath$rpath"
adam@0 8055 for libdir in $rpath; do
adam@0 8056 if test -n "$hardcode_libdir_flag_spec"; then
adam@0 8057 if test -n "$hardcode_libdir_separator"; then
adam@12 8058 func_replace_sysroot "$libdir"
adam@12 8059 libdir=$func_replace_sysroot_result
adam@0 8060 if test -z "$hardcode_libdirs"; then
adam@0 8061 hardcode_libdirs="$libdir"
adam@0 8062 else
adam@0 8063 # Just accumulate the unique libdirs.
adam@0 8064 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
adam@0 8065 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
adam@0 8066 ;;
adam@0 8067 *)
adam@12 8068 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
adam@0 8069 ;;
adam@0 8070 esac
adam@0 8071 fi
adam@0 8072 else
adam@0 8073 eval flag=\"$hardcode_libdir_flag_spec\"
adam@12 8074 func_append dep_rpath " $flag"
adam@0 8075 fi
adam@0 8076 elif test -n "$runpath_var"; then
adam@0 8077 case "$perm_rpath " in
adam@0 8078 *" $libdir "*) ;;
adam@20 8079 *) func_append perm_rpath " $libdir" ;;
adam@0 8080 esac
adam@0 8081 fi
adam@0 8082 done
adam@0 8083 # Substitute the hardcoded libdirs into the rpath.
adam@0 8084 if test -n "$hardcode_libdir_separator" &&
adam@0 8085 test -n "$hardcode_libdirs"; then
adam@0 8086 libdir="$hardcode_libdirs"
adam@20 8087 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
adam@0 8088 fi
adam@0 8089 if test -n "$runpath_var" && test -n "$perm_rpath"; then
adam@0 8090 # We should set the runpath_var.
adam@0 8091 rpath=
adam@0 8092 for dir in $perm_rpath; do
adam@12 8093 func_append rpath "$dir:"
adam@0 8094 done
adam@0 8095 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
adam@0 8096 fi
adam@0 8097 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
adam@0 8098 fi
adam@0 8099
adam@0 8100 shlibpath="$finalize_shlibpath"
adam@12 8101 test "$opt_mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
adam@0 8102 if test -n "$shlibpath"; then
adam@0 8103 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
adam@0 8104 fi
adam@0 8105
adam@0 8106 # Get the real and link names of the library.
adam@0 8107 eval shared_ext=\"$shrext_cmds\"
adam@0 8108 eval library_names=\"$library_names_spec\"
adam@0 8109 set dummy $library_names
adam@0 8110 shift
adam@0 8111 realname="$1"
adam@0 8112 shift
adam@0 8113
adam@0 8114 if test -n "$soname_spec"; then
adam@0 8115 eval soname=\"$soname_spec\"
adam@0 8116 else
adam@0 8117 soname="$realname"
adam@0 8118 fi
adam@0 8119 if test -z "$dlname"; then
adam@0 8120 dlname=$soname
adam@0 8121 fi
adam@0 8122
adam@0 8123 lib="$output_objdir/$realname"
adam@0 8124 linknames=
adam@0 8125 for link
adam@0 8126 do
adam@12 8127 func_append linknames " $link"
adam@0 8128 done
adam@0 8129
adam@0 8130 # Use standard objects if they are pic
adam@12 8131 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
adam@0 8132 test "X$libobjs" = "X " && libobjs=
adam@0 8133
adam@0 8134 delfiles=
adam@0 8135 if test -n "$export_symbols" && test -n "$include_expsyms"; then
adam@0 8136 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
adam@0 8137 export_symbols="$output_objdir/$libname.uexp"
adam@12 8138 func_append delfiles " $export_symbols"
adam@0 8139 fi
adam@0 8140
adam@0 8141 orig_export_symbols=
adam@0 8142 case $host_os in
adam@0 8143 cygwin* | mingw* | cegcc*)
adam@0 8144 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
adam@0 8145 # exporting using user supplied symfile
adam@0 8146 if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
adam@0 8147 # and it's NOT already a .def file. Must figure out
adam@0 8148 # which of the given symbols are data symbols and tag
adam@0 8149 # them as such. So, trigger use of export_symbols_cmds.
adam@0 8150 # export_symbols gets reassigned inside the "prepare
adam@0 8151 # the list of exported symbols" if statement, so the
adam@0 8152 # include_expsyms logic still works.
adam@0 8153 orig_export_symbols="$export_symbols"
adam@0 8154 export_symbols=
adam@0 8155 always_export_symbols=yes
adam@0 8156 fi
adam@0 8157 fi
adam@0 8158 ;;
adam@0 8159 esac
adam@0 8160
adam@0 8161 # Prepare the list of exported symbols
adam@0 8162 if test -z "$export_symbols"; then
adam@0 8163 if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
adam@0 8164 func_verbose "generating symbol list for \`$libname.la'"
adam@0 8165 export_symbols="$output_objdir/$libname.exp"
adam@0 8166 $opt_dry_run || $RM $export_symbols
adam@0 8167 cmds=$export_symbols_cmds
adam@0 8168 save_ifs="$IFS"; IFS='~'
adam@12 8169 for cmd1 in $cmds; do
adam@0 8170 IFS="$save_ifs"
adam@12 8171 # Take the normal branch if the nm_file_list_spec branch
adam@12 8172 # doesn't work or if tool conversion is not needed.
adam@12 8173 case $nm_file_list_spec~$to_tool_file_cmd in
adam@12 8174 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
adam@12 8175 try_normal_branch=yes
adam@12 8176 eval cmd=\"$cmd1\"
adam@12 8177 func_len " $cmd"
adam@12 8178 len=$func_len_result
adam@12 8179 ;;
adam@12 8180 *)
adam@12 8181 try_normal_branch=no
adam@12 8182 ;;
adam@12 8183 esac
adam@12 8184 if test "$try_normal_branch" = yes \
adam@12 8185 && { test "$len" -lt "$max_cmd_len" \
adam@12 8186 || test "$max_cmd_len" -le -1; }
adam@12 8187 then
adam@0 8188 func_show_eval "$cmd" 'exit $?'
adam@0 8189 skipped_export=false
adam@12 8190 elif test -n "$nm_file_list_spec"; then
adam@12 8191 func_basename "$output"
adam@12 8192 output_la=$func_basename_result
adam@12 8193 save_libobjs=$libobjs
adam@12 8194 save_output=$output
adam@12 8195 output=${output_objdir}/${output_la}.nm
adam@12 8196 func_to_tool_file "$output"
adam@12 8197 libobjs=$nm_file_list_spec$func_to_tool_file_result
adam@12 8198 func_append delfiles " $output"
adam@12 8199 func_verbose "creating $NM input file list: $output"
adam@12 8200 for obj in $save_libobjs; do
adam@12 8201 func_to_tool_file "$obj"
adam@12 8202 $ECHO "$func_to_tool_file_result"
adam@12 8203 done > "$output"
adam@12 8204 eval cmd=\"$cmd1\"
adam@12 8205 func_show_eval "$cmd" 'exit $?'
adam@12 8206 output=$save_output
adam@12 8207 libobjs=$save_libobjs
adam@12 8208 skipped_export=false
adam@0 8209 else
adam@0 8210 # The command line is too long to execute in one step.
adam@0 8211 func_verbose "using reloadable object file for export list..."
adam@0 8212 skipped_export=:
adam@0 8213 # Break out early, otherwise skipped_export may be
adam@0 8214 # set to false by a later but shorter cmd.
adam@0 8215 break
adam@0 8216 fi
adam@0 8217 done
adam@0 8218 IFS="$save_ifs"
adam@0 8219 if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
adam@0 8220 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
adam@0 8221 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
adam@0 8222 fi
adam@0 8223 fi
adam@0 8224 fi
adam@0 8225
adam@0 8226 if test -n "$export_symbols" && test -n "$include_expsyms"; then
adam@0 8227 tmp_export_symbols="$export_symbols"
adam@0 8228 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
adam@12 8229 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
adam@0 8230 fi
adam@0 8231
adam@0 8232 if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
adam@0 8233 # The given exports_symbols file has to be filtered, so filter it.
adam@0 8234 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
adam@0 8235 # FIXME: $output_objdir/$libname.filter potentially contains lots of
adam@0 8236 # 's' commands which not all seds can handle. GNU sed should be fine
adam@0 8237 # though. Also, the filter scales superlinearly with the number of
adam@0 8238 # global variables. join(1) would be nice here, but unfortunately
adam@0 8239 # isn't a blessed tool.
adam@0 8240 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
adam@12 8241 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
adam@0 8242 export_symbols=$output_objdir/$libname.def
adam@0 8243 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
adam@0 8244 fi
adam@0 8245
adam@0 8246 tmp_deplibs=
adam@0 8247 for test_deplib in $deplibs; do
adam@0 8248 case " $convenience " in
adam@0 8249 *" $test_deplib "*) ;;
adam@0 8250 *)
adam@12 8251 func_append tmp_deplibs " $test_deplib"
adam@0 8252 ;;
adam@0 8253 esac
adam@0 8254 done
adam@0 8255 deplibs="$tmp_deplibs"
adam@0 8256
adam@0 8257 if test -n "$convenience"; then
adam@0 8258 if test -n "$whole_archive_flag_spec" &&
adam@0 8259 test "$compiler_needs_object" = yes &&
adam@0 8260 test -z "$libobjs"; then
adam@0 8261 # extract the archives, so we have objects to list.
adam@0 8262 # TODO: could optimize this to just extract one archive.
adam@0 8263 whole_archive_flag_spec=
adam@0 8264 fi
adam@0 8265 if test -n "$whole_archive_flag_spec"; then
adam@0 8266 save_libobjs=$libobjs
adam@0 8267 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
adam@0 8268 test "X$libobjs" = "X " && libobjs=
adam@0 8269 else
adam@0 8270 gentop="$output_objdir/${outputname}x"
adam@12 8271 func_append generated " $gentop"
adam@0 8272
adam@0 8273 func_extract_archives $gentop $convenience
adam@12 8274 func_append libobjs " $func_extract_archives_result"
adam@0 8275 test "X$libobjs" = "X " && libobjs=
adam@0 8276 fi
adam@0 8277 fi
adam@0 8278
adam@0 8279 if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
adam@0 8280 eval flag=\"$thread_safe_flag_spec\"
adam@12 8281 func_append linker_flags " $flag"
adam@0 8282 fi
adam@0 8283
adam@0 8284 # Make a backup of the uninstalled library when relinking
adam@12 8285 if test "$opt_mode" = relink; then
adam@0 8286 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
adam@0 8287 fi
adam@0 8288
adam@0 8289 # Do each of the archive commands.
adam@0 8290 if test "$module" = yes && test -n "$module_cmds" ; then
adam@0 8291 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
adam@0 8292 eval test_cmds=\"$module_expsym_cmds\"
adam@0 8293 cmds=$module_expsym_cmds
adam@0 8294 else
adam@0 8295 eval test_cmds=\"$module_cmds\"
adam@0 8296 cmds=$module_cmds
adam@0 8297 fi
adam@0 8298 else
adam@0 8299 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
adam@0 8300 eval test_cmds=\"$archive_expsym_cmds\"
adam@0 8301 cmds=$archive_expsym_cmds
adam@0 8302 else
adam@0 8303 eval test_cmds=\"$archive_cmds\"
adam@0 8304 cmds=$archive_cmds
adam@0 8305 fi
adam@0 8306 fi
adam@0 8307
adam@0 8308 if test "X$skipped_export" != "X:" &&
adam@0 8309 func_len " $test_cmds" &&
adam@0 8310 len=$func_len_result &&
adam@0 8311 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
adam@0 8312 :
adam@0 8313 else
adam@0 8314 # The command line is too long to link in one step, link piecewise
adam@0 8315 # or, if using GNU ld and skipped_export is not :, use a linker
adam@0 8316 # script.
adam@0 8317
adam@0 8318 # Save the value of $output and $libobjs because we want to
adam@0 8319 # use them later. If we have whole_archive_flag_spec, we
adam@0 8320 # want to use save_libobjs as it was before
adam@0 8321 # whole_archive_flag_spec was expanded, because we can't
adam@0 8322 # assume the linker understands whole_archive_flag_spec.
adam@0 8323 # This may have to be revisited, in case too many
adam@0 8324 # convenience libraries get linked in and end up exceeding
adam@0 8325 # the spec.
adam@0 8326 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
adam@0 8327 save_libobjs=$libobjs
adam@0 8328 fi
adam@0 8329 save_output=$output
adam@12 8330 func_basename "$output"
adam@12 8331 output_la=$func_basename_result
adam@0 8332
adam@0 8333 # Clear the reloadable object creation command queue and
adam@0 8334 # initialize k to one.
adam@0 8335 test_cmds=
adam@0 8336 concat_cmds=
adam@0 8337 objlist=
adam@0 8338 last_robj=
adam@0 8339 k=1
adam@0 8340
adam@0 8341 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
adam@0 8342 output=${output_objdir}/${output_la}.lnkscript
adam@0 8343 func_verbose "creating GNU ld script: $output"
adam@12 8344 echo 'INPUT (' > $output
adam@0 8345 for obj in $save_libobjs
adam@0 8346 do
adam@12 8347 func_to_tool_file "$obj"
adam@12 8348 $ECHO "$func_to_tool_file_result" >> $output
adam@0 8349 done
adam@12 8350 echo ')' >> $output
adam@12 8351 func_append delfiles " $output"
adam@12 8352 func_to_tool_file "$output"
adam@12 8353 output=$func_to_tool_file_result
adam@0 8354 elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
adam@0 8355 output=${output_objdir}/${output_la}.lnk
adam@0 8356 func_verbose "creating linker input file list: $output"
adam@0 8357 : > $output
adam@0 8358 set x $save_libobjs
adam@0 8359 shift
adam@0 8360 firstobj=
adam@0 8361 if test "$compiler_needs_object" = yes; then
adam@0 8362 firstobj="$1 "
adam@0 8363 shift
adam@0 8364 fi
adam@0 8365 for obj
adam@0 8366 do
adam@12 8367 func_to_tool_file "$obj"
adam@12 8368 $ECHO "$func_to_tool_file_result" >> $output
adam@0 8369 done
adam@12 8370 func_append delfiles " $output"
adam@12 8371 func_to_tool_file "$output"
adam@12 8372 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
adam@0 8373 else
adam@0 8374 if test -n "$save_libobjs"; then
adam@0 8375 func_verbose "creating reloadable object files..."
adam@0 8376 output=$output_objdir/$output_la-${k}.$objext
adam@0 8377 eval test_cmds=\"$reload_cmds\"
adam@0 8378 func_len " $test_cmds"
adam@0 8379 len0=$func_len_result
adam@0 8380 len=$len0
adam@0 8381
adam@0 8382 # Loop over the list of objects to be linked.
adam@0 8383 for obj in $save_libobjs
adam@0 8384 do
adam@0 8385 func_len " $obj"
adam@0 8386 func_arith $len + $func_len_result
adam@0 8387 len=$func_arith_result
adam@0 8388 if test "X$objlist" = X ||
adam@0 8389 test "$len" -lt "$max_cmd_len"; then
adam@0 8390 func_append objlist " $obj"
adam@0 8391 else
adam@0 8392 # The command $test_cmds is almost too long, add a
adam@0 8393 # command to the queue.
adam@0 8394 if test "$k" -eq 1 ; then
adam@0 8395 # The first file doesn't have a previous command to add.
adam@12 8396 reload_objs=$objlist
adam@12 8397 eval concat_cmds=\"$reload_cmds\"
adam@0 8398 else
adam@0 8399 # All subsequent reloadable object files will link in
adam@0 8400 # the last one created.
adam@12 8401 reload_objs="$objlist $last_robj"
adam@12 8402 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
adam@0 8403 fi
adam@0 8404 last_robj=$output_objdir/$output_la-${k}.$objext
adam@0 8405 func_arith $k + 1
adam@0 8406 k=$func_arith_result
adam@0 8407 output=$output_objdir/$output_la-${k}.$objext
adam@12 8408 objlist=" $obj"
adam@0 8409 func_len " $last_robj"
adam@0 8410 func_arith $len0 + $func_len_result
adam@0 8411 len=$func_arith_result
adam@0 8412 fi
adam@0 8413 done
adam@0 8414 # Handle the remaining objects by creating one last
adam@0 8415 # reloadable object file. All subsequent reloadable object
adam@0 8416 # files will link in the last one created.
adam@0 8417 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
adam@12 8418 reload_objs="$objlist $last_robj"
adam@12 8419 eval concat_cmds=\"\${concat_cmds}$reload_cmds\"
adam@0 8420 if test -n "$last_robj"; then
adam@0 8421 eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
adam@0 8422 fi
adam@12 8423 func_append delfiles " $output"
adam@0 8424
adam@0 8425 else
adam@0 8426 output=
adam@0 8427 fi
adam@0 8428
adam@0 8429 if ${skipped_export-false}; then
adam@0 8430 func_verbose "generating symbol list for \`$libname.la'"
adam@0 8431 export_symbols="$output_objdir/$libname.exp"
adam@0 8432 $opt_dry_run || $RM $export_symbols
adam@0 8433 libobjs=$output
adam@0 8434 # Append the command to create the export file.
adam@0 8435 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
adam@0 8436 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
adam@0 8437 if test -n "$last_robj"; then
adam@0 8438 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
adam@0 8439 fi
adam@0 8440 fi
adam@0 8441
adam@0 8442 test -n "$save_libobjs" &&
adam@0 8443 func_verbose "creating a temporary reloadable object file: $output"
adam@0 8444
adam@0 8445 # Loop through the commands generated above and execute them.
adam@0 8446 save_ifs="$IFS"; IFS='~'
adam@0 8447 for cmd in $concat_cmds; do
adam@0 8448 IFS="$save_ifs"
adam@0 8449 $opt_silent || {
adam@0 8450 func_quote_for_expand "$cmd"
adam@0 8451 eval "func_echo $func_quote_for_expand_result"
adam@0 8452 }
adam@0 8453 $opt_dry_run || eval "$cmd" || {
adam@0 8454 lt_exit=$?
adam@0 8455
adam@0 8456 # Restore the uninstalled library and exit
adam@12 8457 if test "$opt_mode" = relink; then
adam@0 8458 ( cd "$output_objdir" && \
adam@0 8459 $RM "${realname}T" && \
adam@0 8460 $MV "${realname}U" "$realname" )
adam@0 8461 fi
adam@0 8462
adam@0 8463 exit $lt_exit
adam@0 8464 }
adam@0 8465 done
adam@0 8466 IFS="$save_ifs"
adam@0 8467
adam@0 8468 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
adam@0 8469 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
adam@0 8470 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
adam@0 8471 fi
adam@0 8472 fi
adam@0 8473
adam@0 8474 if ${skipped_export-false}; then
adam@0 8475 if test -n "$export_symbols" && test -n "$include_expsyms"; then
adam@0 8476 tmp_export_symbols="$export_symbols"
adam@0 8477 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
adam@12 8478 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
adam@0 8479 fi
adam@0 8480
adam@0 8481 if test -n "$orig_export_symbols"; then
adam@0 8482 # The given exports_symbols file has to be filtered, so filter it.
adam@0 8483 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
adam@0 8484 # FIXME: $output_objdir/$libname.filter potentially contains lots of
adam@0 8485 # 's' commands which not all seds can handle. GNU sed should be fine
adam@0 8486 # though. Also, the filter scales superlinearly with the number of
adam@0 8487 # global variables. join(1) would be nice here, but unfortunately
adam@0 8488 # isn't a blessed tool.
adam@0 8489 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
adam@12 8490 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
adam@0 8491 export_symbols=$output_objdir/$libname.def
adam@0 8492 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
adam@0 8493 fi
adam@0 8494 fi
adam@0 8495
adam@0 8496 libobjs=$output
adam@0 8497 # Restore the value of output.
adam@0 8498 output=$save_output
adam@0 8499
adam@0 8500 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
adam@0 8501 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
adam@0 8502 test "X$libobjs" = "X " && libobjs=
adam@0 8503 fi
adam@0 8504 # Expand the library linking commands again to reset the
adam@0 8505 # value of $libobjs for piecewise linking.
adam@0 8506
adam@0 8507 # Do each of the archive commands.
adam@0 8508 if test "$module" = yes && test -n "$module_cmds" ; then
adam@0 8509 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
adam@0 8510 cmds=$module_expsym_cmds
adam@0 8511 else
adam@0 8512 cmds=$module_cmds
adam@0 8513 fi
adam@0 8514 else
adam@0 8515 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
adam@0 8516 cmds=$archive_expsym_cmds
adam@0 8517 else
adam@0 8518 cmds=$archive_cmds
adam@0 8519 fi
adam@0 8520 fi
adam@0 8521 fi
adam@0 8522
adam@0 8523 if test -n "$delfiles"; then
adam@0 8524 # Append the command to remove temporary files to $cmds.
adam@0 8525 eval cmds=\"\$cmds~\$RM $delfiles\"
adam@0 8526 fi
adam@0 8527
adam@0 8528 # Add any objects from preloaded convenience libraries
adam@0 8529 if test -n "$dlprefiles"; then
adam@0 8530 gentop="$output_objdir/${outputname}x"
adam@12 8531 func_append generated " $gentop"
adam@0 8532
adam@0 8533 func_extract_archives $gentop $dlprefiles
adam@12 8534 func_append libobjs " $func_extract_archives_result"
adam@0 8535 test "X$libobjs" = "X " && libobjs=
adam@0 8536 fi
adam@0 8537
adam@0 8538 save_ifs="$IFS"; IFS='~'
adam@0 8539 for cmd in $cmds; do
adam@0 8540 IFS="$save_ifs"
adam@0 8541 eval cmd=\"$cmd\"
adam@0 8542 $opt_silent || {
adam@0 8543 func_quote_for_expand "$cmd"
adam@0 8544 eval "func_echo $func_quote_for_expand_result"
adam@0 8545 }
adam@0 8546 $opt_dry_run || eval "$cmd" || {
adam@0 8547 lt_exit=$?
adam@0 8548
adam@0 8549 # Restore the uninstalled library and exit
adam@12 8550 if test "$opt_mode" = relink; then
adam@0 8551 ( cd "$output_objdir" && \
adam@0 8552 $RM "${realname}T" && \
adam@0 8553 $MV "${realname}U" "$realname" )
adam@0 8554 fi
adam@0 8555
adam@0 8556 exit $lt_exit
adam@0 8557 }
adam@0 8558 done
adam@0 8559 IFS="$save_ifs"
adam@0 8560
adam@0 8561 # Restore the uninstalled library and exit
adam@12 8562 if test "$opt_mode" = relink; then
adam@0 8563 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
adam@0 8564
adam@0 8565 if test -n "$convenience"; then
adam@0 8566 if test -z "$whole_archive_flag_spec"; then
adam@0 8567 func_show_eval '${RM}r "$gentop"'
adam@0 8568 fi
adam@0 8569 fi
adam@0 8570
adam@0 8571 exit $EXIT_SUCCESS
adam@0 8572 fi
adam@0 8573
adam@0 8574 # Create links to the real library.
adam@0 8575 for linkname in $linknames; do
adam@0 8576 if test "$realname" != "$linkname"; then
adam@0 8577 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
adam@0 8578 fi
adam@0 8579 done
adam@0 8580
adam@0 8581 # If -module or -export-dynamic was specified, set the dlname.
adam@0 8582 if test "$module" = yes || test "$export_dynamic" = yes; then
adam@0 8583 # On all known operating systems, these are identical.
adam@0 8584 dlname="$soname"
adam@0 8585 fi
adam@0 8586 fi
adam@0 8587 ;;
adam@0 8588
adam@0 8589 obj)
adam@0 8590 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
adam@0 8591 func_warning "\`-dlopen' is ignored for objects"
adam@0 8592 fi
adam@0 8593
adam@0 8594 case " $deplibs" in
adam@0 8595 *\ -l* | *\ -L*)
adam@0 8596 func_warning "\`-l' and \`-L' are ignored for objects" ;;
adam@0 8597 esac
adam@0 8598
adam@0 8599 test -n "$rpath" && \
adam@0 8600 func_warning "\`-rpath' is ignored for objects"
adam@0 8601
adam@0 8602 test -n "$xrpath" && \
adam@0 8603 func_warning "\`-R' is ignored for objects"
adam@0 8604
adam@0 8605 test -n "$vinfo" && \
adam@0 8606 func_warning "\`-version-info' is ignored for objects"
adam@0 8607
adam@0 8608 test -n "$release" && \
adam@0 8609 func_warning "\`-release' is ignored for objects"
adam@0 8610
adam@0 8611 case $output in
adam@0 8612 *.lo)
adam@0 8613 test -n "$objs$old_deplibs" && \
adam@0 8614 func_fatal_error "cannot build library object \`$output' from non-libtool objects"
adam@0 8615
adam@0 8616 libobj=$output
adam@0 8617 func_lo2o "$libobj"
adam@0 8618 obj=$func_lo2o_result
adam@0 8619 ;;
adam@0 8620 *)
adam@0 8621 libobj=
adam@0 8622 obj="$output"
adam@0 8623 ;;
adam@0 8624 esac
adam@0 8625
adam@0 8626 # Delete the old objects.
adam@0 8627 $opt_dry_run || $RM $obj $libobj
adam@0 8628
adam@0 8629 # Objects from convenience libraries. This assumes
adam@0 8630 # single-version convenience libraries. Whenever we create
adam@0 8631 # different ones for PIC/non-PIC, this we'll have to duplicate
adam@0 8632 # the extraction.
adam@0 8633 reload_conv_objs=
adam@0 8634 gentop=
adam@0 8635 # reload_cmds runs $LD directly, so let us get rid of
adam@0 8636 # -Wl from whole_archive_flag_spec and hope we can get by with
adam@0 8637 # turning comma into space..
adam@0 8638 wl=
adam@0 8639
adam@0 8640 if test -n "$convenience"; then
adam@0 8641 if test -n "$whole_archive_flag_spec"; then
adam@0 8642 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
adam@12 8643 reload_conv_objs=$reload_objs\ `$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
adam@0 8644 else
adam@0 8645 gentop="$output_objdir/${obj}x"
adam@12 8646 func_append generated " $gentop"
adam@0 8647
adam@0 8648 func_extract_archives $gentop $convenience
adam@0 8649 reload_conv_objs="$reload_objs $func_extract_archives_result"
adam@0 8650 fi
adam@0 8651 fi
adam@0 8652
adam@12 8653 # If we're not building shared, we need to use non_pic_objs
adam@12 8654 test "$build_libtool_libs" != yes && libobjs="$non_pic_objects"
adam@12 8655
adam@0 8656 # Create the old-style object.
adam@12 8657 reload_objs="$objs$old_deplibs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.${libext}$/d; /\.lib$/d; $lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
adam@0 8658
adam@0 8659 output="$obj"
adam@0 8660 func_execute_cmds "$reload_cmds" 'exit $?'
adam@0 8661
adam@0 8662 # Exit if we aren't doing a library object file.
adam@0 8663 if test -z "$libobj"; then
adam@0 8664 if test -n "$gentop"; then
adam@0 8665 func_show_eval '${RM}r "$gentop"'
adam@0 8666 fi
adam@0 8667
adam@0 8668 exit $EXIT_SUCCESS
adam@0 8669 fi
adam@0 8670
adam@0 8671 if test "$build_libtool_libs" != yes; then
adam@0 8672 if test -n "$gentop"; then
adam@0 8673 func_show_eval '${RM}r "$gentop"'
adam@0 8674 fi
adam@0 8675
adam@0 8676 # Create an invalid libtool object if no PIC, so that we don't
adam@0 8677 # accidentally link it into a program.
adam@0 8678 # $show "echo timestamp > $libobj"
adam@0 8679 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
adam@0 8680 exit $EXIT_SUCCESS
adam@0 8681 fi
adam@0 8682
adam@0 8683 if test -n "$pic_flag" || test "$pic_mode" != default; then
adam@0 8684 # Only do commands if we really have different PIC objects.
adam@0 8685 reload_objs="$libobjs $reload_conv_objs"
adam@0 8686 output="$libobj"
adam@0 8687 func_execute_cmds "$reload_cmds" 'exit $?'
adam@0 8688 fi
adam@0 8689
adam@0 8690 if test -n "$gentop"; then
adam@0 8691 func_show_eval '${RM}r "$gentop"'
adam@0 8692 fi
adam@0 8693
adam@0 8694 exit $EXIT_SUCCESS
adam@0 8695 ;;
adam@0 8696
adam@0 8697 prog)
adam@0 8698 case $host in
adam@0 8699 *cygwin*) func_stripname '' '.exe' "$output"
adam@0 8700 output=$func_stripname_result.exe;;
adam@0 8701 esac
adam@0 8702 test -n "$vinfo" && \
adam@0 8703 func_warning "\`-version-info' is ignored for programs"
adam@0 8704
adam@0 8705 test -n "$release" && \
adam@0 8706 func_warning "\`-release' is ignored for programs"
adam@0 8707
adam@0 8708 test "$preload" = yes \
adam@0 8709 && test "$dlopen_support" = unknown \
adam@0 8710 && test "$dlopen_self" = unknown \
adam@0 8711 && test "$dlopen_self_static" = unknown && \
adam@0 8712 func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
adam@0 8713
adam@0 8714 case $host in
adam@0 8715 *-*-rhapsody* | *-*-darwin1.[012])
adam@0 8716 # On Rhapsody replace the C library is the System framework
adam@12 8717 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
adam@12 8718 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
adam@0 8719 ;;
adam@0 8720 esac
adam@0 8721
adam@0 8722 case $host in
adam@0 8723 *-*-darwin*)
adam@0 8724 # Don't allow lazy linking, it breaks C++ global constructors
adam@0 8725 # But is supposedly fixed on 10.4 or later (yay!).
adam@0 8726 if test "$tagname" = CXX ; then
adam@0 8727 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
adam@0 8728 10.[0123])
adam@12 8729 func_append compile_command " ${wl}-bind_at_load"
adam@12 8730 func_append finalize_command " ${wl}-bind_at_load"
adam@0 8731 ;;
adam@0 8732 esac
adam@0 8733 fi
adam@0 8734 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
adam@12 8735 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
adam@12 8736 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
adam@0 8737 ;;
adam@0 8738 esac
adam@0 8739
adam@0 8740
adam@0 8741 # move library search paths that coincide with paths to not yet
adam@0 8742 # installed libraries to the beginning of the library search list
adam@0 8743 new_libs=
adam@0 8744 for path in $notinst_path; do
adam@0 8745 case " $new_libs " in
adam@0 8746 *" -L$path/$objdir "*) ;;
adam@0 8747 *)
adam@0 8748 case " $compile_deplibs " in
adam@0 8749 *" -L$path/$objdir "*)
adam@12 8750 func_append new_libs " -L$path/$objdir" ;;
adam@0 8751 esac
adam@0 8752 ;;
adam@0 8753 esac
adam@0 8754 done
adam@0 8755 for deplib in $compile_deplibs; do
adam@0 8756 case $deplib in
adam@0 8757 -L*)
adam@0 8758 case " $new_libs " in
adam@0 8759 *" $deplib "*) ;;
adam@12 8760 *) func_append new_libs " $deplib" ;;
adam@0 8761 esac
adam@0 8762 ;;
adam@12 8763 *) func_append new_libs " $deplib" ;;
adam@0 8764 esac
adam@0 8765 done
adam@0 8766 compile_deplibs="$new_libs"
adam@0 8767
adam@0 8768
adam@12 8769 func_append compile_command " $compile_deplibs"
adam@12 8770 func_append finalize_command " $finalize_deplibs"
adam@0 8771
adam@0 8772 if test -n "$rpath$xrpath"; then
adam@0 8773 # If the user specified any rpath flags, then add them.
adam@0 8774 for libdir in $rpath $xrpath; do
adam@0 8775 # This is the magic to use -rpath.
adam@0 8776 case "$finalize_rpath " in
adam@0 8777 *" $libdir "*) ;;
adam@12 8778 *) func_append finalize_rpath " $libdir" ;;
adam@0 8779 esac
adam@0 8780 done
adam@0 8781 fi
adam@0 8782
adam@0 8783 # Now hardcode the library paths
adam@0 8784 rpath=
adam@0 8785 hardcode_libdirs=
adam@0 8786 for libdir in $compile_rpath $finalize_rpath; do
adam@0 8787 if test -n "$hardcode_libdir_flag_spec"; then
adam@0 8788 if test -n "$hardcode_libdir_separator"; then
adam@0 8789 if test -z "$hardcode_libdirs"; then
adam@0 8790 hardcode_libdirs="$libdir"
adam@0 8791 else
adam@0 8792 # Just accumulate the unique libdirs.
adam@0 8793 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
adam@0 8794 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
adam@0 8795 ;;
adam@0 8796 *)
adam@12 8797 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
adam@0 8798 ;;
adam@0 8799 esac
adam@0 8800 fi
adam@0 8801 else
adam@0 8802 eval flag=\"$hardcode_libdir_flag_spec\"
adam@12 8803 func_append rpath " $flag"
adam@0 8804 fi
adam@0 8805 elif test -n "$runpath_var"; then
adam@0 8806 case "$perm_rpath " in
adam@0 8807 *" $libdir "*) ;;
adam@12 8808 *) func_append perm_rpath " $libdir" ;;
adam@0 8809 esac
adam@0 8810 fi
adam@0 8811 case $host in
adam@0 8812 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
adam@0 8813 testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
adam@0 8814 case :$dllsearchpath: in
adam@0 8815 *":$libdir:"*) ;;
adam@0 8816 ::) dllsearchpath=$libdir;;
adam@12 8817 *) func_append dllsearchpath ":$libdir";;
adam@0 8818 esac
adam@0 8819 case :$dllsearchpath: in
adam@0 8820 *":$testbindir:"*) ;;
adam@0 8821 ::) dllsearchpath=$testbindir;;
adam@12 8822 *) func_append dllsearchpath ":$testbindir";;
adam@0 8823 esac
adam@0 8824 ;;
adam@0 8825 esac
adam@0 8826 done
adam@0 8827 # Substitute the hardcoded libdirs into the rpath.
adam@0 8828 if test -n "$hardcode_libdir_separator" &&
adam@0 8829 test -n "$hardcode_libdirs"; then
adam@0 8830 libdir="$hardcode_libdirs"
adam@0 8831 eval rpath=\" $hardcode_libdir_flag_spec\"
adam@0 8832 fi
adam@0 8833 compile_rpath="$rpath"
adam@0 8834
adam@0 8835 rpath=
adam@0 8836 hardcode_libdirs=
adam@0 8837 for libdir in $finalize_rpath; do
adam@0 8838 if test -n "$hardcode_libdir_flag_spec"; then
adam@0 8839 if test -n "$hardcode_libdir_separator"; then
adam@0 8840 if test -z "$hardcode_libdirs"; then
adam@0 8841 hardcode_libdirs="$libdir"
adam@0 8842 else
adam@0 8843 # Just accumulate the unique libdirs.
adam@0 8844 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
adam@0 8845 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
adam@0 8846 ;;
adam@0 8847 *)
adam@12 8848 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
adam@0 8849 ;;
adam@0 8850 esac
adam@0 8851 fi
adam@0 8852 else
adam@0 8853 eval flag=\"$hardcode_libdir_flag_spec\"
adam@12 8854 func_append rpath " $flag"
adam@0 8855 fi
adam@0 8856 elif test -n "$runpath_var"; then
adam@0 8857 case "$finalize_perm_rpath " in
adam@0 8858 *" $libdir "*) ;;
adam@12 8859 *) func_append finalize_perm_rpath " $libdir" ;;
adam@0 8860 esac
adam@0 8861 fi
adam@0 8862 done
adam@0 8863 # Substitute the hardcoded libdirs into the rpath.
adam@0 8864 if test -n "$hardcode_libdir_separator" &&
adam@0 8865 test -n "$hardcode_libdirs"; then
adam@0 8866 libdir="$hardcode_libdirs"
adam@0 8867 eval rpath=\" $hardcode_libdir_flag_spec\"
adam@0 8868 fi
adam@0 8869 finalize_rpath="$rpath"
adam@0 8870
adam@0 8871 if test -n "$libobjs" && test "$build_old_libs" = yes; then
adam@0 8872 # Transform all the library objects into standard objects.
adam@12 8873 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
adam@12 8874 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
adam@0 8875 fi
adam@0 8876
adam@0 8877 func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
adam@0 8878
adam@0 8879 # template prelinking step
adam@0 8880 if test -n "$prelink_cmds"; then
adam@0 8881 func_execute_cmds "$prelink_cmds" 'exit $?'
adam@0 8882 fi
adam@0 8883
adam@0 8884 wrappers_required=yes
adam@0 8885 case $host in
adam@12 8886 *cegcc* | *mingw32ce*)
adam@12 8887 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
adam@12 8888 wrappers_required=no
adam@12 8889 ;;
adam@0 8890 *cygwin* | *mingw* )
adam@0 8891 if test "$build_libtool_libs" != yes; then
adam@0 8892 wrappers_required=no
adam@0 8893 fi
adam@0 8894 ;;
adam@0 8895 *)
adam@0 8896 if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
adam@0 8897 wrappers_required=no
adam@0 8898 fi
adam@0 8899 ;;
adam@0 8900 esac
adam@0 8901 if test "$wrappers_required" = no; then
adam@0 8902 # Replace the output file specification.
adam@12 8903 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
adam@0 8904 link_command="$compile_command$compile_rpath"
adam@0 8905
adam@0 8906 # We have no uninstalled library dependencies, so finalize right now.
adam@0 8907 exit_status=0
adam@0 8908 func_show_eval "$link_command" 'exit_status=$?'
adam@0 8909
adam@12 8910 if test -n "$postlink_cmds"; then
adam@12 8911 func_to_tool_file "$output"
adam@12 8912 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
adam@12 8913 func_execute_cmds "$postlink_cmds" 'exit $?'
adam@12 8914 fi
adam@12 8915
adam@0 8916 # Delete the generated files.
adam@0 8917 if test -f "$output_objdir/${outputname}S.${objext}"; then
adam@0 8918 func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
adam@0 8919 fi
adam@0 8920
adam@0 8921 exit $exit_status
adam@0 8922 fi
adam@0 8923
adam@0 8924 if test -n "$compile_shlibpath$finalize_shlibpath"; then
adam@0 8925 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
adam@0 8926 fi
adam@0 8927 if test -n "$finalize_shlibpath"; then
adam@0 8928 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
adam@0 8929 fi
adam@0 8930
adam@0 8931 compile_var=
adam@0 8932 finalize_var=
adam@0 8933 if test -n "$runpath_var"; then
adam@0 8934 if test -n "$perm_rpath"; then
adam@0 8935 # We should set the runpath_var.
adam@0 8936 rpath=
adam@0 8937 for dir in $perm_rpath; do
adam@12 8938 func_append rpath "$dir:"
adam@0 8939 done
adam@0 8940 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
adam@0 8941 fi
adam@0 8942 if test -n "$finalize_perm_rpath"; then
adam@0 8943 # We should set the runpath_var.
adam@0 8944 rpath=
adam@0 8945 for dir in $finalize_perm_rpath; do
adam@12 8946 func_append rpath "$dir:"
adam@0 8947 done
adam@0 8948 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
adam@0 8949 fi
adam@0 8950 fi
adam@0 8951
adam@0 8952 if test "$no_install" = yes; then
adam@0 8953 # We don't need to create a wrapper script.
adam@0 8954 link_command="$compile_var$compile_command$compile_rpath"
adam@0 8955 # Replace the output file specification.
adam@12 8956 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
adam@0 8957 # Delete the old output file.
adam@0 8958 $opt_dry_run || $RM $output
adam@0 8959 # Link the executable and exit
adam@0 8960 func_show_eval "$link_command" 'exit $?'
adam@12 8961
adam@12 8962 if test -n "$postlink_cmds"; then
adam@12 8963 func_to_tool_file "$output"
adam@12 8964 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
adam@12 8965 func_execute_cmds "$postlink_cmds" 'exit $?'
adam@12 8966 fi
adam@12 8967
adam@0 8968 exit $EXIT_SUCCESS
adam@0 8969 fi
adam@0 8970
adam@0 8971 if test "$hardcode_action" = relink; then
adam@0 8972 # Fast installation is not supported
adam@0 8973 link_command="$compile_var$compile_command$compile_rpath"
adam@0 8974 relink_command="$finalize_var$finalize_command$finalize_rpath"
adam@0 8975
adam@0 8976 func_warning "this platform does not like uninstalled shared libraries"
adam@0 8977 func_warning "\`$output' will be relinked during installation"
adam@0 8978 else
adam@0 8979 if test "$fast_install" != no; then
adam@0 8980 link_command="$finalize_var$compile_command$finalize_rpath"
adam@0 8981 if test "$fast_install" = yes; then
adam@12 8982 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
adam@0 8983 else
adam@0 8984 # fast_install is set to needless
adam@0 8985 relink_command=
adam@0 8986 fi
adam@0 8987 else
adam@0 8988 link_command="$compile_var$compile_command$compile_rpath"
adam@0 8989 relink_command="$finalize_var$finalize_command$finalize_rpath"
adam@0 8990 fi
adam@0 8991 fi
adam@0 8992
adam@0 8993 # Replace the output file specification.
adam@12 8994 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
adam@0 8995
adam@0 8996 # Delete the old output files.
adam@0 8997 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
adam@0 8998
adam@0 8999 func_show_eval "$link_command" 'exit $?'
adam@0 9000
adam@12 9001 if test -n "$postlink_cmds"; then
adam@12 9002 func_to_tool_file "$output_objdir/$outputname"
adam@12 9003 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'`
adam@12 9004 func_execute_cmds "$postlink_cmds" 'exit $?'
adam@12 9005 fi
adam@12 9006
adam@0 9007 # Now create the wrapper script.
adam@0 9008 func_verbose "creating $output"
adam@0 9009
adam@0 9010 # Quote the relink command for shipping.
adam@0 9011 if test -n "$relink_command"; then
adam@0 9012 # Preserve any variables that may affect compiler behavior
adam@0 9013 for var in $variables_saved_for_relink; do
adam@0 9014 if eval test -z \"\${$var+set}\"; then
adam@0 9015 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
adam@0 9016 elif eval var_value=\$$var; test -z "$var_value"; then
adam@0 9017 relink_command="$var=; export $var; $relink_command"
adam@0 9018 else
adam@0 9019 func_quote_for_eval "$var_value"
adam@0 9020 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
adam@0 9021 fi
adam@0 9022 done
adam@0 9023 relink_command="(cd `pwd`; $relink_command)"
adam@12 9024 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
adam@0 9025 fi
adam@0 9026
adam@0 9027 # Only actually do things if not in dry run mode.
adam@0 9028 $opt_dry_run || {
adam@0 9029 # win32 will think the script is a binary if it has
adam@0 9030 # a .exe suffix, so we strip it off here.
adam@0 9031 case $output in
adam@0 9032 *.exe) func_stripname '' '.exe' "$output"
adam@0 9033 output=$func_stripname_result ;;
adam@0 9034 esac
adam@0 9035 # test for cygwin because mv fails w/o .exe extensions
adam@0 9036 case $host in
adam@0 9037 *cygwin*)
adam@0 9038 exeext=.exe
adam@0 9039 func_stripname '' '.exe' "$outputname"
adam@0 9040 outputname=$func_stripname_result ;;
adam@0 9041 *) exeext= ;;
adam@0 9042 esac
adam@0 9043 case $host in
adam@0 9044 *cygwin* | *mingw* )
adam@0 9045 func_dirname_and_basename "$output" "" "."
adam@0 9046 output_name=$func_basename_result
adam@0 9047 output_path=$func_dirname_result
adam@0 9048 cwrappersource="$output_path/$objdir/lt-$output_name.c"
adam@0 9049 cwrapper="$output_path/$output_name.exe"
adam@0 9050 $RM $cwrappersource $cwrapper
adam@0 9051 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
adam@0 9052
adam@0 9053 func_emit_cwrapperexe_src > $cwrappersource
adam@0 9054
adam@0 9055 # The wrapper executable is built using the $host compiler,
adam@0 9056 # because it contains $host paths and files. If cross-
adam@0 9057 # compiling, it, like the target executable, must be
adam@0 9058 # executed on the $host or under an emulation environment.
adam@0 9059 $opt_dry_run || {
adam@0 9060 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
adam@0 9061 $STRIP $cwrapper
adam@0 9062 }
adam@0 9063
adam@0 9064 # Now, create the wrapper script for func_source use:
adam@0 9065 func_ltwrapper_scriptname $cwrapper
adam@0 9066 $RM $func_ltwrapper_scriptname_result
adam@0 9067 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
adam@0 9068 $opt_dry_run || {
adam@0 9069 # note: this script will not be executed, so do not chmod.
adam@0 9070 if test "x$build" = "x$host" ; then
adam@0 9071 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
adam@0 9072 else
adam@0 9073 func_emit_wrapper no > $func_ltwrapper_scriptname_result
adam@0 9074 fi
adam@0 9075 }
adam@0 9076 ;;
adam@0 9077 * )
adam@0 9078 $RM $output
adam@0 9079 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
adam@0 9080
adam@0 9081 func_emit_wrapper no > $output
adam@0 9082 chmod +x $output
adam@0 9083 ;;
adam@0 9084 esac
adam@0 9085 }
adam@0 9086 exit $EXIT_SUCCESS
adam@0 9087 ;;
adam@0 9088 esac
adam@0 9089
adam@0 9090 # See if we need to build an old-fashioned archive.
adam@0 9091 for oldlib in $oldlibs; do
adam@0 9092
adam@0 9093 if test "$build_libtool_libs" = convenience; then
adam@0 9094 oldobjs="$libobjs_save $symfileobj"
adam@0 9095 addlibs="$convenience"
adam@0 9096 build_libtool_libs=no
adam@0 9097 else
adam@0 9098 if test "$build_libtool_libs" = module; then
adam@0 9099 oldobjs="$libobjs_save"
adam@0 9100 build_libtool_libs=no
adam@0 9101 else
adam@0 9102 oldobjs="$old_deplibs $non_pic_objects"
adam@0 9103 if test "$preload" = yes && test -f "$symfileobj"; then
adam@12 9104 func_append oldobjs " $symfileobj"
adam@0 9105 fi
adam@0 9106 fi
adam@0 9107 addlibs="$old_convenience"
adam@0 9108 fi
adam@0 9109
adam@0 9110 if test -n "$addlibs"; then
adam@0 9111 gentop="$output_objdir/${outputname}x"
adam@12 9112 func_append generated " $gentop"
adam@0 9113
adam@0 9114 func_extract_archives $gentop $addlibs
adam@12 9115 func_append oldobjs " $func_extract_archives_result"
adam@0 9116 fi
adam@0 9117
adam@0 9118 # Do each command in the archive commands.
adam@0 9119 if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
adam@0 9120 cmds=$old_archive_from_new_cmds
adam@0 9121 else
adam@0 9122
adam@0 9123 # Add any objects from preloaded convenience libraries
adam@0 9124 if test -n "$dlprefiles"; then
adam@0 9125 gentop="$output_objdir/${outputname}x"
adam@12 9126 func_append generated " $gentop"
adam@0 9127
adam@0 9128 func_extract_archives $gentop $dlprefiles
adam@12 9129 func_append oldobjs " $func_extract_archives_result"
adam@0 9130 fi
adam@0 9131
adam@0 9132 # POSIX demands no paths to be encoded in archives. We have
adam@0 9133 # to avoid creating archives with duplicate basenames if we
adam@0 9134 # might have to extract them afterwards, e.g., when creating a
adam@0 9135 # static archive out of a convenience library, or when linking
adam@0 9136 # the entirety of a libtool archive into another (currently
adam@0 9137 # not supported by libtool).
adam@0 9138 if (for obj in $oldobjs
adam@0 9139 do
adam@0 9140 func_basename "$obj"
adam@0 9141 $ECHO "$func_basename_result"
adam@0 9142 done | sort | sort -uc >/dev/null 2>&1); then
adam@0 9143 :
adam@0 9144 else
adam@12 9145 echo "copying selected object files to avoid basename conflicts..."
adam@0 9146 gentop="$output_objdir/${outputname}x"
adam@12 9147 func_append generated " $gentop"
adam@0 9148 func_mkdir_p "$gentop"
adam@0 9149 save_oldobjs=$oldobjs
adam@0 9150 oldobjs=
adam@0 9151 counter=1
adam@0 9152 for obj in $save_oldobjs
adam@0 9153 do
adam@0 9154 func_basename "$obj"
adam@0 9155 objbase="$func_basename_result"
adam@0 9156 case " $oldobjs " in
adam@0 9157 " ") oldobjs=$obj ;;
adam@0 9158 *[\ /]"$objbase "*)
adam@0 9159 while :; do
adam@0 9160 # Make sure we don't pick an alternate name that also
adam@0 9161 # overlaps.
adam@0 9162 newobj=lt$counter-$objbase
adam@0 9163 func_arith $counter + 1
adam@0 9164 counter=$func_arith_result
adam@0 9165 case " $oldobjs " in
adam@0 9166 *[\ /]"$newobj "*) ;;
adam@0 9167 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
adam@0 9168 esac
adam@0 9169 done
adam@0 9170 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
adam@12 9171 func_append oldobjs " $gentop/$newobj"
adam@0 9172 ;;
adam@12 9173 *) func_append oldobjs " $obj" ;;
adam@0 9174 esac
adam@0 9175 done
adam@0 9176 fi
adam@20 9177 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
adam@20 9178 tool_oldlib=$func_to_tool_file_result
adam@0 9179 eval cmds=\"$old_archive_cmds\"
adam@0 9180
adam@0 9181 func_len " $cmds"
adam@0 9182 len=$func_len_result
adam@0 9183 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
adam@0 9184 cmds=$old_archive_cmds
adam@12 9185 elif test -n "$archiver_list_spec"; then
adam@12 9186 func_verbose "using command file archive linking..."
adam@12 9187 for obj in $oldobjs
adam@12 9188 do
adam@12 9189 func_to_tool_file "$obj"
adam@12 9190 $ECHO "$func_to_tool_file_result"
adam@12 9191 done > $output_objdir/$libname.libcmd
adam@12 9192 func_to_tool_file "$output_objdir/$libname.libcmd"
adam@12 9193 oldobjs=" $archiver_list_spec$func_to_tool_file_result"
adam@12 9194 cmds=$old_archive_cmds
adam@0 9195 else
adam@0 9196 # the command line is too long to link in one step, link in parts
adam@0 9197 func_verbose "using piecewise archive linking..."
adam@0 9198 save_RANLIB=$RANLIB
adam@0 9199 RANLIB=:
adam@0 9200 objlist=
adam@0 9201 concat_cmds=
adam@0 9202 save_oldobjs=$oldobjs
adam@0 9203 oldobjs=
adam@0 9204 # Is there a better way of finding the last object in the list?
adam@0 9205 for obj in $save_oldobjs
adam@0 9206 do
adam@0 9207 last_oldobj=$obj
adam@0 9208 done
adam@0 9209 eval test_cmds=\"$old_archive_cmds\"
adam@0 9210 func_len " $test_cmds"
adam@0 9211 len0=$func_len_result
adam@0 9212 len=$len0
adam@0 9213 for obj in $save_oldobjs
adam@0 9214 do
adam@0 9215 func_len " $obj"
adam@0 9216 func_arith $len + $func_len_result
adam@0 9217 len=$func_arith_result
adam@0 9218 func_append objlist " $obj"
adam@0 9219 if test "$len" -lt "$max_cmd_len"; then
adam@0 9220 :
adam@0 9221 else
adam@0 9222 # the above command should be used before it gets too long
adam@0 9223 oldobjs=$objlist
adam@0 9224 if test "$obj" = "$last_oldobj" ; then
adam@0 9225 RANLIB=$save_RANLIB
adam@0 9226 fi
adam@0 9227 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
adam@0 9228 eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
adam@0 9229 objlist=
adam@0 9230 len=$len0
adam@0 9231 fi
adam@0 9232 done
adam@0 9233 RANLIB=$save_RANLIB
adam@0 9234 oldobjs=$objlist
adam@0 9235 if test "X$oldobjs" = "X" ; then
adam@0 9236 eval cmds=\"\$concat_cmds\"
adam@0 9237 else
adam@0 9238 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
adam@0 9239 fi
adam@0 9240 fi
adam@0 9241 fi
adam@0 9242 func_execute_cmds "$cmds" 'exit $?'
adam@0 9243 done
adam@0 9244
adam@0 9245 test -n "$generated" && \
adam@0 9246 func_show_eval "${RM}r$generated"
adam@0 9247
adam@0 9248 # Now create the libtool archive.
adam@0 9249 case $output in
adam@0 9250 *.la)
adam@0 9251 old_library=
adam@0 9252 test "$build_old_libs" = yes && old_library="$libname.$libext"
adam@0 9253 func_verbose "creating $output"
adam@0 9254
adam@0 9255 # Preserve any variables that may affect compiler behavior
adam@0 9256 for var in $variables_saved_for_relink; do
adam@0 9257 if eval test -z \"\${$var+set}\"; then
adam@0 9258 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
adam@0 9259 elif eval var_value=\$$var; test -z "$var_value"; then
adam@0 9260 relink_command="$var=; export $var; $relink_command"
adam@0 9261 else
adam@0 9262 func_quote_for_eval "$var_value"
adam@0 9263 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
adam@0 9264 fi
adam@0 9265 done
adam@0 9266 # Quote the link command for shipping.
adam@0 9267 relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
adam@12 9268 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
adam@0 9269 if test "$hardcode_automatic" = yes ; then
adam@0 9270 relink_command=
adam@0 9271 fi
adam@0 9272
adam@0 9273 # Only create the output if not a dry run.
adam@0 9274 $opt_dry_run || {
adam@0 9275 for installed in no yes; do
adam@0 9276 if test "$installed" = yes; then
adam@0 9277 if test -z "$install_libdir"; then
adam@0 9278 break
adam@0 9279 fi
adam@0 9280 output="$output_objdir/$outputname"i
adam@0 9281 # Replace all uninstalled libtool libraries with the installed ones
adam@0 9282 newdependency_libs=
adam@0 9283 for deplib in $dependency_libs; do
adam@0 9284 case $deplib in
adam@0 9285 *.la)
adam@0 9286 func_basename "$deplib"
adam@0 9287 name="$func_basename_result"
adam@20 9288 func_resolve_sysroot "$deplib"
adam@20 9289 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
adam@0 9290 test -z "$libdir" && \
adam@0 9291 func_fatal_error "\`$deplib' is not a valid libtool archive"
adam@12 9292 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
adam@0 9293 ;;
adam@12 9294 -L*)
adam@12 9295 func_stripname -L '' "$deplib"
adam@12 9296 func_replace_sysroot "$func_stripname_result"
adam@12 9297 func_append newdependency_libs " -L$func_replace_sysroot_result"
adam@12 9298 ;;
adam@12 9299 -R*)
adam@12 9300 func_stripname -R '' "$deplib"
adam@12 9301 func_replace_sysroot "$func_stripname_result"
adam@12 9302 func_append newdependency_libs " -R$func_replace_sysroot_result"
adam@12 9303 ;;
adam@12 9304 *) func_append newdependency_libs " $deplib" ;;
adam@0 9305 esac
adam@0 9306 done
adam@0 9307 dependency_libs="$newdependency_libs"
adam@0 9308 newdlfiles=
adam@0 9309
adam@0 9310 for lib in $dlfiles; do
adam@0 9311 case $lib in
adam@0 9312 *.la)
adam@0 9313 func_basename "$lib"
adam@0 9314 name="$func_basename_result"
adam@0 9315 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
adam@0 9316 test -z "$libdir" && \
adam@0 9317 func_fatal_error "\`$lib' is not a valid libtool archive"
adam@12 9318 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
adam@0 9319 ;;
adam@12 9320 *) func_append newdlfiles " $lib" ;;
adam@0 9321 esac
adam@0 9322 done
adam@0 9323 dlfiles="$newdlfiles"
adam@0 9324 newdlprefiles=
adam@0 9325 for lib in $dlprefiles; do
adam@0 9326 case $lib in
adam@0 9327 *.la)
adam@0 9328 # Only pass preopened files to the pseudo-archive (for
adam@0 9329 # eventual linking with the app. that links it) if we
adam@0 9330 # didn't already link the preopened objects directly into
adam@0 9331 # the library:
adam@0 9332 func_basename "$lib"
adam@0 9333 name="$func_basename_result"
adam@0 9334 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
adam@0 9335 test -z "$libdir" && \
adam@0 9336 func_fatal_error "\`$lib' is not a valid libtool archive"
adam@12 9337 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
adam@0 9338 ;;
adam@0 9339 esac
adam@0 9340 done
adam@0 9341 dlprefiles="$newdlprefiles"
adam@0 9342 else
adam@0 9343 newdlfiles=
adam@0 9344 for lib in $dlfiles; do
adam@0 9345 case $lib in
adam@0 9346 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
adam@0 9347 *) abs=`pwd`"/$lib" ;;
adam@0 9348 esac
adam@12 9349 func_append newdlfiles " $abs"
adam@0 9350 done
adam@0 9351 dlfiles="$newdlfiles"
adam@0 9352 newdlprefiles=
adam@0 9353 for lib in $dlprefiles; do
adam@0 9354 case $lib in
adam@0 9355 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
adam@0 9356 *) abs=`pwd`"/$lib" ;;
adam@0 9357 esac
adam@12 9358 func_append newdlprefiles " $abs"
adam@0 9359 done
adam@0 9360 dlprefiles="$newdlprefiles"
adam@0 9361 fi
adam@0 9362 $RM $output
adam@0 9363 # place dlname in correct position for cygwin
adam@12 9364 # In fact, it would be nice if we could use this code for all target
adam@12 9365 # systems that can't hard-code library paths into their executables
adam@12 9366 # and that have no shared library path variable independent of PATH,
adam@12 9367 # but it turns out we can't easily determine that from inspecting
adam@12 9368 # libtool variables, so we have to hard-code the OSs to which it
adam@12 9369 # applies here; at the moment, that means platforms that use the PE
adam@12 9370 # object format with DLL files. See the long comment at the top of
adam@12 9371 # tests/bindir.at for full details.
adam@0 9372 tdlname=$dlname
adam@0 9373 case $host,$output,$installed,$module,$dlname in
adam@12 9374 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
adam@12 9375 # If a -bindir argument was supplied, place the dll there.
adam@12 9376 if test "x$bindir" != x ;
adam@12 9377 then
adam@12 9378 func_relative_path "$install_libdir" "$bindir"
adam@12 9379 tdlname=$func_relative_path_result$dlname
adam@12 9380 else
adam@12 9381 # Otherwise fall back on heuristic.
adam@12 9382 tdlname=../bin/$dlname
adam@12 9383 fi
adam@12 9384 ;;
adam@0 9385 esac
adam@0 9386 $ECHO > $output "\
adam@0 9387 # $outputname - a libtool library file
adam@0 9388 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
adam@0 9389 #
adam@0 9390 # Please DO NOT delete this file!
adam@0 9391 # It is necessary for linking the library.
adam@0 9392
adam@0 9393 # The name that we can dlopen(3).
adam@0 9394 dlname='$tdlname'
adam@0 9395
adam@0 9396 # Names of this library.
adam@0 9397 library_names='$library_names'
adam@0 9398
adam@0 9399 # The name of the static archive.
adam@0 9400 old_library='$old_library'
adam@0 9401
adam@0 9402 # Linker flags that can not go in dependency_libs.
adam@0 9403 inherited_linker_flags='$new_inherited_linker_flags'
adam@0 9404
adam@0 9405 # Libraries that this one depends upon.
adam@0 9406 dependency_libs='$dependency_libs'
adam@0 9407
adam@0 9408 # Names of additional weak libraries provided by this library
adam@0 9409 weak_library_names='$weak_libs'
adam@0 9410
adam@0 9411 # Version information for $libname.
adam@0 9412 current=$current
adam@0 9413 age=$age
adam@0 9414 revision=$revision
adam@0 9415
adam@0 9416 # Is this an already installed library?
adam@0 9417 installed=$installed
adam@0 9418
adam@0 9419 # Should we warn about portability when linking against -modules?
adam@0 9420 shouldnotlink=$module
adam@0 9421
adam@0 9422 # Files to dlopen/dlpreopen
adam@0 9423 dlopen='$dlfiles'
adam@0 9424 dlpreopen='$dlprefiles'
adam@0 9425
adam@0 9426 # Directory that this library needs to be installed in:
adam@0 9427 libdir='$install_libdir'"
adam@0 9428 if test "$installed" = no && test "$need_relink" = yes; then
adam@0 9429 $ECHO >> $output "\
adam@0 9430 relink_command=\"$relink_command\""
adam@0 9431 fi
adam@0 9432 done
adam@0 9433 }
adam@0 9434
adam@0 9435 # Do a symbolic link so that the libtool archive can be found in
adam@0 9436 # LD_LIBRARY_PATH before the program is installed.
adam@0 9437 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
adam@0 9438 ;;
adam@0 9439 esac
adam@0 9440 exit $EXIT_SUCCESS
adam@0 9441 }
adam@0 9442
adam@12 9443 { test "$opt_mode" = link || test "$opt_mode" = relink; } &&
adam@0 9444 func_mode_link ${1+"$@"}
adam@0 9445
adam@0 9446
adam@0 9447 # func_mode_uninstall arg...
adam@0 9448 func_mode_uninstall ()
adam@0 9449 {
adam@0 9450 $opt_debug
adam@0 9451 RM="$nonopt"
adam@0 9452 files=
adam@0 9453 rmforce=
adam@0 9454 exit_status=0
adam@0 9455
adam@0 9456 # This variable tells wrapper scripts just to set variables rather
adam@0 9457 # than running their programs.
adam@0 9458 libtool_install_magic="$magic"
adam@0 9459
adam@0 9460 for arg
adam@0 9461 do
adam@0 9462 case $arg in
adam@12 9463 -f) func_append RM " $arg"; rmforce=yes ;;
adam@12 9464 -*) func_append RM " $arg" ;;
adam@12 9465 *) func_append files " $arg" ;;
adam@0 9466 esac
adam@0 9467 done
adam@0 9468
adam@0 9469 test -z "$RM" && \
adam@0 9470 func_fatal_help "you must specify an RM program"
adam@0 9471
adam@0 9472 rmdirs=
adam@0 9473
adam@0 9474 for file in $files; do
adam@0 9475 func_dirname "$file" "" "."
adam@0 9476 dir="$func_dirname_result"
adam@0 9477 if test "X$dir" = X.; then
adam@12 9478 odir="$objdir"
adam@0 9479 else
adam@12 9480 odir="$dir/$objdir"
adam@0 9481 fi
adam@0 9482 func_basename "$file"
adam@0 9483 name="$func_basename_result"
adam@12 9484 test "$opt_mode" = uninstall && odir="$dir"
adam@12 9485
adam@12 9486 # Remember odir for removal later, being careful to avoid duplicates
adam@12 9487 if test "$opt_mode" = clean; then
adam@0 9488 case " $rmdirs " in
adam@12 9489 *" $odir "*) ;;
adam@12 9490 *) func_append rmdirs " $odir" ;;
adam@0 9491 esac
adam@0 9492 fi
adam@0 9493
adam@0 9494 # Don't error if the file doesn't exist and rm -f was used.
adam@0 9495 if { test -L "$file"; } >/dev/null 2>&1 ||
adam@0 9496 { test -h "$file"; } >/dev/null 2>&1 ||
adam@0 9497 test -f "$file"; then
adam@0 9498 :
adam@0 9499 elif test -d "$file"; then
adam@0 9500 exit_status=1
adam@0 9501 continue
adam@0 9502 elif test "$rmforce" = yes; then
adam@0 9503 continue
adam@0 9504 fi
adam@0 9505
adam@0 9506 rmfiles="$file"
adam@0 9507
adam@0 9508 case $name in
adam@0 9509 *.la)
adam@0 9510 # Possibly a libtool archive, so verify it.
adam@0 9511 if func_lalib_p "$file"; then
adam@0 9512 func_source $dir/$name
adam@0 9513
adam@0 9514 # Delete the libtool libraries and symlinks.
adam@0 9515 for n in $library_names; do
adam@12 9516 func_append rmfiles " $odir/$n"
adam@0 9517 done
adam@12 9518 test -n "$old_library" && func_append rmfiles " $odir/$old_library"
adam@12 9519
adam@12 9520 case "$opt_mode" in
adam@0 9521 clean)
adam@12 9522 case " $library_names " in
adam@0 9523 *" $dlname "*) ;;
adam@12 9524 *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
adam@0 9525 esac
adam@12 9526 test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
adam@0 9527 ;;
adam@0 9528 uninstall)
adam@0 9529 if test -n "$library_names"; then
adam@0 9530 # Do each command in the postuninstall commands.
adam@0 9531 func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
adam@0 9532 fi
adam@0 9533
adam@0 9534 if test -n "$old_library"; then
adam@0 9535 # Do each command in the old_postuninstall commands.
adam@0 9536 func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
adam@0 9537 fi
adam@0 9538 # FIXME: should reinstall the best remaining shared library.
adam@0 9539 ;;
adam@0 9540 esac
adam@0 9541 fi
adam@0 9542 ;;
adam@0 9543
adam@0 9544 *.lo)
adam@0 9545 # Possibly a libtool object, so verify it.
adam@0 9546 if func_lalib_p "$file"; then
adam@0 9547
adam@0 9548 # Read the .lo file
adam@0 9549 func_source $dir/$name
adam@0 9550
adam@0 9551 # Add PIC object to the list of files to remove.
adam@0 9552 if test -n "$pic_object" &&
adam@0 9553 test "$pic_object" != none; then
adam@12 9554 func_append rmfiles " $dir/$pic_object"
adam@0 9555 fi
adam@0 9556
adam@0 9557 # Add non-PIC object to the list of files to remove.
adam@0 9558 if test -n "$non_pic_object" &&
adam@0 9559 test "$non_pic_object" != none; then
adam@12 9560 func_append rmfiles " $dir/$non_pic_object"
adam@0 9561 fi
adam@0 9562 fi
adam@0 9563 ;;
adam@0 9564
adam@0 9565 *)
adam@12 9566 if test "$opt_mode" = clean ; then
adam@0 9567 noexename=$name
adam@0 9568 case $file in
adam@0 9569 *.exe)
adam@0 9570 func_stripname '' '.exe' "$file"
adam@0 9571 file=$func_stripname_result
adam@0 9572 func_stripname '' '.exe' "$name"
adam@0 9573 noexename=$func_stripname_result
adam@0 9574 # $file with .exe has already been added to rmfiles,
adam@0 9575 # add $file without .exe
adam@12 9576 func_append rmfiles " $file"
adam@0 9577 ;;
adam@0 9578 esac
adam@0 9579 # Do a test to see if this is a libtool program.
adam@0 9580 if func_ltwrapper_p "$file"; then
adam@0 9581 if func_ltwrapper_executable_p "$file"; then
adam@0 9582 func_ltwrapper_scriptname "$file"
adam@0 9583 relink_command=
adam@0 9584 func_source $func_ltwrapper_scriptname_result
adam@12 9585 func_append rmfiles " $func_ltwrapper_scriptname_result"
adam@0 9586 else
adam@0 9587 relink_command=
adam@0 9588 func_source $dir/$noexename
adam@0 9589 fi
adam@0 9590
adam@0 9591 # note $name still contains .exe if it was in $file originally
adam@0 9592 # as does the version of $file that was added into $rmfiles
adam@12 9593 func_append rmfiles " $odir/$name $odir/${name}S.${objext}"
adam@0 9594 if test "$fast_install" = yes && test -n "$relink_command"; then
adam@12 9595 func_append rmfiles " $odir/lt-$name"
adam@0 9596 fi
adam@0 9597 if test "X$noexename" != "X$name" ; then
adam@12 9598 func_append rmfiles " $odir/lt-${noexename}.c"
adam@0 9599 fi
adam@0 9600 fi
adam@0 9601 fi
adam@0 9602 ;;
adam@0 9603 esac
adam@0 9604 func_show_eval "$RM $rmfiles" 'exit_status=1'
adam@0 9605 done
adam@0 9606
adam@0 9607 # Try to remove the ${objdir}s in the directories where we deleted files
adam@0 9608 for dir in $rmdirs; do
adam@0 9609 if test -d "$dir"; then
adam@0 9610 func_show_eval "rmdir $dir >/dev/null 2>&1"
adam@0 9611 fi
adam@0 9612 done
adam@0 9613
adam@0 9614 exit $exit_status
adam@0 9615 }
adam@0 9616
adam@12 9617 { test "$opt_mode" = uninstall || test "$opt_mode" = clean; } &&
adam@0 9618 func_mode_uninstall ${1+"$@"}
adam@0 9619
adam@12 9620 test -z "$opt_mode" && {
adam@0 9621 help="$generic_help"
adam@0 9622 func_fatal_help "you must specify a MODE"
adam@0 9623 }
adam@0 9624
adam@0 9625 test -z "$exec_cmd" && \
adam@12 9626 func_fatal_help "invalid operation mode \`$opt_mode'"
adam@0 9627
adam@0 9628 if test -n "$exec_cmd"; then
adam@0 9629 eval exec "$exec_cmd"
adam@0 9630 exit $EXIT_FAILURE
adam@0 9631 fi
adam@0 9632
adam@0 9633 exit $exit_status
adam@0 9634
adam@0 9635
adam@0 9636 # The TAGs below are defined such that we never get into a situation
adam@0 9637 # in which we disable both kinds of libraries. Given conflicting
adam@0 9638 # choices, we go for a static library, that is the most portable,
adam@0 9639 # since we can't tell whether shared libraries were disabled because
adam@0 9640 # the user asked for that or because the platform doesn't support
adam@0 9641 # them. This is particularly important on AIX, because we don't
adam@0 9642 # support having both static and shared libraries enabled at the same
adam@0 9643 # time on that platform, so we default to a shared-only configuration.
adam@0 9644 # If a disable-shared tag is given, we'll fallback to a static-only
adam@0 9645 # configuration. But we'll never go from static-only to shared-only.
adam@0 9646
adam@0 9647 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
adam@0 9648 build_libtool_libs=no
adam@0 9649 build_old_libs=yes
adam@0 9650 # ### END LIBTOOL TAG CONFIG: disable-shared
adam@0 9651
adam@0 9652 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
adam@0 9653 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
adam@0 9654 # ### END LIBTOOL TAG CONFIG: disable-static
adam@0 9655
adam@0 9656 # Local Variables:
adam@0 9657 # mode:shell-script
adam@0 9658 # sh-indentation:2
adam@0 9659 # End:
adam@0 9660 # vi:sw=2
adam@0 9661