toolkit/crashreporter/google-breakpad/autotools/ltmain.sh

Sat, 03 Jan 2015 20:18:00 +0100

author
Michael Schloh von Bennewitz <michael@schloh.com>
date
Sat, 03 Jan 2015 20:18:00 +0100
branch
TOR_BUG_3246
changeset 7
129ffea94266
permissions
-rwxr-xr-x

Conditionally enable double key logic according to:
private browsing mode or privacy.thirdparty.isolate preference and
implement in GetCookieStringCommon and FindCookie where it counts...
With some reservations of how to convince FindCookie users to test
condition and pass a nullptr when disabling double key logic.

michael@0 1 # Generated from ltmain.m4sh.
michael@0 2
michael@0 3 # ltmain.sh (GNU libtool) 2.2.6b
michael@0 4 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
michael@0 5
michael@0 6 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
michael@0 7 # This is free software; see the source for copying conditions. There is NO
michael@0 8 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
michael@0 9
michael@0 10 # GNU Libtool is free software; you can redistribute it and/or modify
michael@0 11 # it under the terms of the GNU General Public License as published by
michael@0 12 # the Free Software Foundation; either version 2 of the License, or
michael@0 13 # (at your option) any later version.
michael@0 14 #
michael@0 15 # As a special exception to the GNU General Public License,
michael@0 16 # if you distribute this file as part of a program or library that
michael@0 17 # is built using GNU Libtool, you may include this file under the
michael@0 18 # same distribution terms that you use for the rest of that program.
michael@0 19 #
michael@0 20 # GNU Libtool is distributed in the hope that it will be useful, but
michael@0 21 # WITHOUT ANY WARRANTY; without even the implied warranty of
michael@0 22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
michael@0 23 # General Public License for more details.
michael@0 24 #
michael@0 25 # You should have received a copy of the GNU General Public License
michael@0 26 # along with GNU Libtool; see the file COPYING. If not, a copy
michael@0 27 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
michael@0 28 # or obtained by writing to the Free Software Foundation, Inc.,
michael@0 29 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
michael@0 30
michael@0 31 # Usage: $progname [OPTION]... [MODE-ARG]...
michael@0 32 #
michael@0 33 # Provide generalized library-building support services.
michael@0 34 #
michael@0 35 # --config show all configuration variables
michael@0 36 # --debug enable verbose shell tracing
michael@0 37 # -n, --dry-run display commands without modifying any files
michael@0 38 # --features display basic configuration information and exit
michael@0 39 # --mode=MODE use operation mode MODE
michael@0 40 # --preserve-dup-deps don't remove duplicate dependency libraries
michael@0 41 # --quiet, --silent don't print informational messages
michael@0 42 # --tag=TAG use configuration variables from tag TAG
michael@0 43 # -v, --verbose print informational messages (default)
michael@0 44 # --version print version information
michael@0 45 # -h, --help print short or long help message
michael@0 46 #
michael@0 47 # MODE must be one of the following:
michael@0 48 #
michael@0 49 # clean remove files from the build directory
michael@0 50 # compile compile a source file into a libtool object
michael@0 51 # execute automatically set library path, then run a program
michael@0 52 # finish complete the installation of libtool libraries
michael@0 53 # install install libraries or executables
michael@0 54 # link create a library or an executable
michael@0 55 # uninstall remove libraries from an installed directory
michael@0 56 #
michael@0 57 # MODE-ARGS vary depending on the MODE.
michael@0 58 # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
michael@0 59 #
michael@0 60 # When reporting a bug, please describe a test case to reproduce it and
michael@0 61 # include the following information:
michael@0 62 #
michael@0 63 # host-triplet: $host
michael@0 64 # shell: $SHELL
michael@0 65 # compiler: $LTCC
michael@0 66 # compiler flags: $LTCFLAGS
michael@0 67 # linker: $LD (gnu? $with_gnu_ld)
michael@0 68 # $progname: (GNU libtool) 2.2.6b
michael@0 69 # automake: $automake_version
michael@0 70 # autoconf: $autoconf_version
michael@0 71 #
michael@0 72 # Report bugs to <bug-libtool@gnu.org>.
michael@0 73
michael@0 74 PROGRAM=ltmain.sh
michael@0 75 PACKAGE=libtool
michael@0 76 VERSION=2.2.6b
michael@0 77 TIMESTAMP=""
michael@0 78 package_revision=1.3017
michael@0 79
michael@0 80 # Be Bourne compatible
michael@0 81 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
michael@0 82 emulate sh
michael@0 83 NULLCMD=:
michael@0 84 # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
michael@0 85 # is contrary to our usage. Disable this feature.
michael@0 86 alias -g '${1+"$@"}'='"$@"'
michael@0 87 setopt NO_GLOB_SUBST
michael@0 88 else
michael@0 89 case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
michael@0 90 fi
michael@0 91 BIN_SH=xpg4; export BIN_SH # for Tru64
michael@0 92 DUALCASE=1; export DUALCASE # for MKS sh
michael@0 93
michael@0 94 # NLS nuisances: We save the old values to restore during execute mode.
michael@0 95 # Only set LANG and LC_ALL to C if already set.
michael@0 96 # These must not be set unconditionally because not all systems understand
michael@0 97 # e.g. LANG=C (notably SCO).
michael@0 98 lt_user_locale=
michael@0 99 lt_safe_locale=
michael@0 100 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
michael@0 101 do
michael@0 102 eval "if test \"\${$lt_var+set}\" = set; then
michael@0 103 save_$lt_var=\$$lt_var
michael@0 104 $lt_var=C
michael@0 105 export $lt_var
michael@0 106 lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
michael@0 107 lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
michael@0 108 fi"
michael@0 109 done
michael@0 110
michael@0 111 $lt_unset CDPATH
michael@0 112
michael@0 113
michael@0 114
michael@0 115
michael@0 116
michael@0 117 : ${CP="cp -f"}
michael@0 118 : ${ECHO="echo"}
michael@0 119 : ${EGREP="/bin/grep -E"}
michael@0 120 : ${FGREP="/bin/grep -F"}
michael@0 121 : ${GREP="/bin/grep"}
michael@0 122 : ${LN_S="ln -s"}
michael@0 123 : ${MAKE="make"}
michael@0 124 : ${MKDIR="mkdir"}
michael@0 125 : ${MV="mv -f"}
michael@0 126 : ${RM="rm -f"}
michael@0 127 : ${SED="/bin/sed"}
michael@0 128 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
michael@0 129 : ${Xsed="$SED -e 1s/^X//"}
michael@0 130
michael@0 131 # Global variables:
michael@0 132 EXIT_SUCCESS=0
michael@0 133 EXIT_FAILURE=1
michael@0 134 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
michael@0 135 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
michael@0 136
michael@0 137 exit_status=$EXIT_SUCCESS
michael@0 138
michael@0 139 # Make sure IFS has a sensible default
michael@0 140 lt_nl='
michael@0 141 '
michael@0 142 IFS=" $lt_nl"
michael@0 143
michael@0 144 dirname="s,/[^/]*$,,"
michael@0 145 basename="s,^.*/,,"
michael@0 146
michael@0 147 # func_dirname_and_basename file append nondir_replacement
michael@0 148 # perform func_basename and func_dirname in a single function
michael@0 149 # call:
michael@0 150 # dirname: Compute the dirname of FILE. If nonempty,
michael@0 151 # add APPEND to the result, otherwise set result
michael@0 152 # to NONDIR_REPLACEMENT.
michael@0 153 # value returned in "$func_dirname_result"
michael@0 154 # basename: Compute filename of FILE.
michael@0 155 # value retuned in "$func_basename_result"
michael@0 156 # Implementation must be kept synchronized with func_dirname
michael@0 157 # and func_basename. For efficiency, we do not delegate to
michael@0 158 # those functions but instead duplicate the functionality here.
michael@0 159 func_dirname_and_basename ()
michael@0 160 {
michael@0 161 # Extract subdirectory from the argument.
michael@0 162 func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
michael@0 163 if test "X$func_dirname_result" = "X${1}"; then
michael@0 164 func_dirname_result="${3}"
michael@0 165 else
michael@0 166 func_dirname_result="$func_dirname_result${2}"
michael@0 167 fi
michael@0 168 func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
michael@0 169 }
michael@0 170
michael@0 171 # Generated shell functions inserted here.
michael@0 172
michael@0 173 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
michael@0 174 # is ksh but when the shell is invoked as "sh" and the current value of
michael@0 175 # the _XPG environment variable is not equal to 1 (one), the special
michael@0 176 # positional parameter $0, within a function call, is the name of the
michael@0 177 # function.
michael@0 178 progpath="$0"
michael@0 179
michael@0 180 # The name of this program:
michael@0 181 # In the unlikely event $progname began with a '-', it would play havoc with
michael@0 182 # func_echo (imagine progname=-n), so we prepend ./ in that case:
michael@0 183 func_dirname_and_basename "$progpath"
michael@0 184 progname=$func_basename_result
michael@0 185 case $progname in
michael@0 186 -*) progname=./$progname ;;
michael@0 187 esac
michael@0 188
michael@0 189 # Make sure we have an absolute path for reexecution:
michael@0 190 case $progpath in
michael@0 191 [\\/]*|[A-Za-z]:\\*) ;;
michael@0 192 *[\\/]*)
michael@0 193 progdir=$func_dirname_result
michael@0 194 progdir=`cd "$progdir" && pwd`
michael@0 195 progpath="$progdir/$progname"
michael@0 196 ;;
michael@0 197 *)
michael@0 198 save_IFS="$IFS"
michael@0 199 IFS=:
michael@0 200 for progdir in $PATH; do
michael@0 201 IFS="$save_IFS"
michael@0 202 test -x "$progdir/$progname" && break
michael@0 203 done
michael@0 204 IFS="$save_IFS"
michael@0 205 test -n "$progdir" || progdir=`pwd`
michael@0 206 progpath="$progdir/$progname"
michael@0 207 ;;
michael@0 208 esac
michael@0 209
michael@0 210 # Sed substitution that helps us do robust quoting. It backslashifies
michael@0 211 # metacharacters that are still active within double-quoted strings.
michael@0 212 Xsed="${SED}"' -e 1s/^X//'
michael@0 213 sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
michael@0 214
michael@0 215 # Same as above, but do not quote variable references.
michael@0 216 double_quote_subst='s/\(["`\\]\)/\\\1/g'
michael@0 217
michael@0 218 # Re-`\' parameter expansions in output of double_quote_subst that were
michael@0 219 # `\'-ed in input to the same. If an odd number of `\' preceded a '$'
michael@0 220 # in input to double_quote_subst, that '$' was protected from expansion.
michael@0 221 # Since each input `\' is now two `\'s, look for any number of runs of
michael@0 222 # four `\'s followed by two `\'s and then a '$'. `\' that '$'.
michael@0 223 bs='\\'
michael@0 224 bs2='\\\\'
michael@0 225 bs4='\\\\\\\\'
michael@0 226 dollar='\$'
michael@0 227 sed_double_backslash="\
michael@0 228 s/$bs4/&\\
michael@0 229 /g
michael@0 230 s/^$bs2$dollar/$bs&/
michael@0 231 s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
michael@0 232 s/\n//g"
michael@0 233
michael@0 234 # Standard options:
michael@0 235 opt_dry_run=false
michael@0 236 opt_help=false
michael@0 237 opt_quiet=false
michael@0 238 opt_verbose=false
michael@0 239 opt_warning=:
michael@0 240
michael@0 241 # func_echo arg...
michael@0 242 # Echo program name prefixed message, along with the current mode
michael@0 243 # name if it has been set yet.
michael@0 244 func_echo ()
michael@0 245 {
michael@0 246 $ECHO "$progname${mode+: }$mode: $*"
michael@0 247 }
michael@0 248
michael@0 249 # func_verbose arg...
michael@0 250 # Echo program name prefixed message in verbose mode only.
michael@0 251 func_verbose ()
michael@0 252 {
michael@0 253 $opt_verbose && func_echo ${1+"$@"}
michael@0 254
michael@0 255 # A bug in bash halts the script if the last line of a function
michael@0 256 # fails when set -e is in force, so we need another command to
michael@0 257 # work around that:
michael@0 258 :
michael@0 259 }
michael@0 260
michael@0 261 # func_error arg...
michael@0 262 # Echo program name prefixed message to standard error.
michael@0 263 func_error ()
michael@0 264 {
michael@0 265 $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
michael@0 266 }
michael@0 267
michael@0 268 # func_warning arg...
michael@0 269 # Echo program name prefixed warning message to standard error.
michael@0 270 func_warning ()
michael@0 271 {
michael@0 272 $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
michael@0 273
michael@0 274 # bash bug again:
michael@0 275 :
michael@0 276 }
michael@0 277
michael@0 278 # func_fatal_error arg...
michael@0 279 # Echo program name prefixed message to standard error, and exit.
michael@0 280 func_fatal_error ()
michael@0 281 {
michael@0 282 func_error ${1+"$@"}
michael@0 283 exit $EXIT_FAILURE
michael@0 284 }
michael@0 285
michael@0 286 # func_fatal_help arg...
michael@0 287 # Echo program name prefixed message to standard error, followed by
michael@0 288 # a help hint, and exit.
michael@0 289 func_fatal_help ()
michael@0 290 {
michael@0 291 func_error ${1+"$@"}
michael@0 292 func_fatal_error "$help"
michael@0 293 }
michael@0 294 help="Try \`$progname --help' for more information." ## default
michael@0 295
michael@0 296
michael@0 297 # func_grep expression filename
michael@0 298 # Check whether EXPRESSION matches any line of FILENAME, without output.
michael@0 299 func_grep ()
michael@0 300 {
michael@0 301 $GREP "$1" "$2" >/dev/null 2>&1
michael@0 302 }
michael@0 303
michael@0 304
michael@0 305 # func_mkdir_p directory-path
michael@0 306 # Make sure the entire path to DIRECTORY-PATH is available.
michael@0 307 func_mkdir_p ()
michael@0 308 {
michael@0 309 my_directory_path="$1"
michael@0 310 my_dir_list=
michael@0 311
michael@0 312 if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
michael@0 313
michael@0 314 # Protect directory names starting with `-'
michael@0 315 case $my_directory_path in
michael@0 316 -*) my_directory_path="./$my_directory_path" ;;
michael@0 317 esac
michael@0 318
michael@0 319 # While some portion of DIR does not yet exist...
michael@0 320 while test ! -d "$my_directory_path"; do
michael@0 321 # ...make a list in topmost first order. Use a colon delimited
michael@0 322 # list incase some portion of path contains whitespace.
michael@0 323 my_dir_list="$my_directory_path:$my_dir_list"
michael@0 324
michael@0 325 # If the last portion added has no slash in it, the list is done
michael@0 326 case $my_directory_path in */*) ;; *) break ;; esac
michael@0 327
michael@0 328 # ...otherwise throw away the child directory and loop
michael@0 329 my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
michael@0 330 done
michael@0 331 my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
michael@0 332
michael@0 333 save_mkdir_p_IFS="$IFS"; IFS=':'
michael@0 334 for my_dir in $my_dir_list; do
michael@0 335 IFS="$save_mkdir_p_IFS"
michael@0 336 # mkdir can fail with a `File exist' error if two processes
michael@0 337 # try to create one of the directories concurrently. Don't
michael@0 338 # stop in that case!
michael@0 339 $MKDIR "$my_dir" 2>/dev/null || :
michael@0 340 done
michael@0 341 IFS="$save_mkdir_p_IFS"
michael@0 342
michael@0 343 # Bail out if we (or some other process) failed to create a directory.
michael@0 344 test -d "$my_directory_path" || \
michael@0 345 func_fatal_error "Failed to create \`$1'"
michael@0 346 fi
michael@0 347 }
michael@0 348
michael@0 349
michael@0 350 # func_mktempdir [string]
michael@0 351 # Make a temporary directory that won't clash with other running
michael@0 352 # libtool processes, and avoids race conditions if possible. If
michael@0 353 # given, STRING is the basename for that directory.
michael@0 354 func_mktempdir ()
michael@0 355 {
michael@0 356 my_template="${TMPDIR-/tmp}/${1-$progname}"
michael@0 357
michael@0 358 if test "$opt_dry_run" = ":"; then
michael@0 359 # Return a directory name, but don't create it in dry-run mode
michael@0 360 my_tmpdir="${my_template}-$$"
michael@0 361 else
michael@0 362
michael@0 363 # If mktemp works, use that first and foremost
michael@0 364 my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
michael@0 365
michael@0 366 if test ! -d "$my_tmpdir"; then
michael@0 367 # Failing that, at least try and use $RANDOM to avoid a race
michael@0 368 my_tmpdir="${my_template}-${RANDOM-0}$$"
michael@0 369
michael@0 370 save_mktempdir_umask=`umask`
michael@0 371 umask 0077
michael@0 372 $MKDIR "$my_tmpdir"
michael@0 373 umask $save_mktempdir_umask
michael@0 374 fi
michael@0 375
michael@0 376 # If we're not in dry-run mode, bomb out on failure
michael@0 377 test -d "$my_tmpdir" || \
michael@0 378 func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
michael@0 379 fi
michael@0 380
michael@0 381 $ECHO "X$my_tmpdir" | $Xsed
michael@0 382 }
michael@0 383
michael@0 384
michael@0 385 # func_quote_for_eval arg
michael@0 386 # Aesthetically quote ARG to be evaled later.
michael@0 387 # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
michael@0 388 # is double-quoted, suitable for a subsequent eval, whereas
michael@0 389 # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
michael@0 390 # which are still active within double quotes backslashified.
michael@0 391 func_quote_for_eval ()
michael@0 392 {
michael@0 393 case $1 in
michael@0 394 *[\\\`\"\$]*)
michael@0 395 func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
michael@0 396 *)
michael@0 397 func_quote_for_eval_unquoted_result="$1" ;;
michael@0 398 esac
michael@0 399
michael@0 400 case $func_quote_for_eval_unquoted_result in
michael@0 401 # Double-quote args containing shell metacharacters to delay
michael@0 402 # word splitting, command substitution and and variable
michael@0 403 # expansion for a subsequent eval.
michael@0 404 # Many Bourne shells cannot handle close brackets correctly
michael@0 405 # in scan sets, so we specify it separately.
michael@0 406 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
michael@0 407 func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
michael@0 408 ;;
michael@0 409 *)
michael@0 410 func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
michael@0 411 esac
michael@0 412 }
michael@0 413
michael@0 414
michael@0 415 # func_quote_for_expand arg
michael@0 416 # Aesthetically quote ARG to be evaled later; same as above,
michael@0 417 # but do not quote variable references.
michael@0 418 func_quote_for_expand ()
michael@0 419 {
michael@0 420 case $1 in
michael@0 421 *[\\\`\"]*)
michael@0 422 my_arg=`$ECHO "X$1" | $Xsed \
michael@0 423 -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
michael@0 424 *)
michael@0 425 my_arg="$1" ;;
michael@0 426 esac
michael@0 427
michael@0 428 case $my_arg in
michael@0 429 # Double-quote args containing shell metacharacters to delay
michael@0 430 # word splitting and command substitution for a subsequent eval.
michael@0 431 # Many Bourne shells cannot handle close brackets correctly
michael@0 432 # in scan sets, so we specify it separately.
michael@0 433 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
michael@0 434 my_arg="\"$my_arg\""
michael@0 435 ;;
michael@0 436 esac
michael@0 437
michael@0 438 func_quote_for_expand_result="$my_arg"
michael@0 439 }
michael@0 440
michael@0 441
michael@0 442 # func_show_eval cmd [fail_exp]
michael@0 443 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
michael@0 444 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
michael@0 445 # is given, then evaluate it.
michael@0 446 func_show_eval ()
michael@0 447 {
michael@0 448 my_cmd="$1"
michael@0 449 my_fail_exp="${2-:}"
michael@0 450
michael@0 451 ${opt_silent-false} || {
michael@0 452 func_quote_for_expand "$my_cmd"
michael@0 453 eval "func_echo $func_quote_for_expand_result"
michael@0 454 }
michael@0 455
michael@0 456 if ${opt_dry_run-false}; then :; else
michael@0 457 eval "$my_cmd"
michael@0 458 my_status=$?
michael@0 459 if test "$my_status" -eq 0; then :; else
michael@0 460 eval "(exit $my_status); $my_fail_exp"
michael@0 461 fi
michael@0 462 fi
michael@0 463 }
michael@0 464
michael@0 465
michael@0 466 # func_show_eval_locale cmd [fail_exp]
michael@0 467 # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
michael@0 468 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
michael@0 469 # is given, then evaluate it. Use the saved locale for evaluation.
michael@0 470 func_show_eval_locale ()
michael@0 471 {
michael@0 472 my_cmd="$1"
michael@0 473 my_fail_exp="${2-:}"
michael@0 474
michael@0 475 ${opt_silent-false} || {
michael@0 476 func_quote_for_expand "$my_cmd"
michael@0 477 eval "func_echo $func_quote_for_expand_result"
michael@0 478 }
michael@0 479
michael@0 480 if ${opt_dry_run-false}; then :; else
michael@0 481 eval "$lt_user_locale
michael@0 482 $my_cmd"
michael@0 483 my_status=$?
michael@0 484 eval "$lt_safe_locale"
michael@0 485 if test "$my_status" -eq 0; then :; else
michael@0 486 eval "(exit $my_status); $my_fail_exp"
michael@0 487 fi
michael@0 488 fi
michael@0 489 }
michael@0 490
michael@0 491
michael@0 492
michael@0 493
michael@0 494
michael@0 495 # func_version
michael@0 496 # Echo version message to standard output and exit.
michael@0 497 func_version ()
michael@0 498 {
michael@0 499 $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
michael@0 500 s/^# //
michael@0 501 s/^# *$//
michael@0 502 s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
michael@0 503 p
michael@0 504 }' < "$progpath"
michael@0 505 exit $?
michael@0 506 }
michael@0 507
michael@0 508 # func_usage
michael@0 509 # Echo short help message to standard output and exit.
michael@0 510 func_usage ()
michael@0 511 {
michael@0 512 $SED -n '/^# Usage:/,/# -h/ {
michael@0 513 s/^# //
michael@0 514 s/^# *$//
michael@0 515 s/\$progname/'$progname'/
michael@0 516 p
michael@0 517 }' < "$progpath"
michael@0 518 $ECHO
michael@0 519 $ECHO "run \`$progname --help | more' for full usage"
michael@0 520 exit $?
michael@0 521 }
michael@0 522
michael@0 523 # func_help
michael@0 524 # Echo long help message to standard output and exit.
michael@0 525 func_help ()
michael@0 526 {
michael@0 527 $SED -n '/^# Usage:/,/# Report bugs to/ {
michael@0 528 s/^# //
michael@0 529 s/^# *$//
michael@0 530 s*\$progname*'$progname'*
michael@0 531 s*\$host*'"$host"'*
michael@0 532 s*\$SHELL*'"$SHELL"'*
michael@0 533 s*\$LTCC*'"$LTCC"'*
michael@0 534 s*\$LTCFLAGS*'"$LTCFLAGS"'*
michael@0 535 s*\$LD*'"$LD"'*
michael@0 536 s/\$with_gnu_ld/'"$with_gnu_ld"'/
michael@0 537 s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
michael@0 538 s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
michael@0 539 p
michael@0 540 }' < "$progpath"
michael@0 541 exit $?
michael@0 542 }
michael@0 543
michael@0 544 # func_missing_arg argname
michael@0 545 # Echo program name prefixed message to standard error and set global
michael@0 546 # exit_cmd.
michael@0 547 func_missing_arg ()
michael@0 548 {
michael@0 549 func_error "missing argument for $1"
michael@0 550 exit_cmd=exit
michael@0 551 }
michael@0 552
michael@0 553 exit_cmd=:
michael@0 554
michael@0 555
michael@0 556
michael@0 557
michael@0 558
michael@0 559 # Check that we have a working $ECHO.
michael@0 560 if test "X$1" = X--no-reexec; then
michael@0 561 # Discard the --no-reexec flag, and continue.
michael@0 562 shift
michael@0 563 elif test "X$1" = X--fallback-echo; then
michael@0 564 # Avoid inline document here, it may be left over
michael@0 565 :
michael@0 566 elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
michael@0 567 # Yippee, $ECHO works!
michael@0 568 :
michael@0 569 else
michael@0 570 # Restart under the correct shell, and then maybe $ECHO will work.
michael@0 571 exec $SHELL "$progpath" --no-reexec ${1+"$@"}
michael@0 572 fi
michael@0 573
michael@0 574 if test "X$1" = X--fallback-echo; then
michael@0 575 # used as fallback echo
michael@0 576 shift
michael@0 577 cat <<EOF
michael@0 578 $*
michael@0 579 EOF
michael@0 580 exit $EXIT_SUCCESS
michael@0 581 fi
michael@0 582
michael@0 583 magic="%%%MAGIC variable%%%"
michael@0 584 magic_exe="%%%MAGIC EXE variable%%%"
michael@0 585
michael@0 586 # Global variables.
michael@0 587 # $mode is unset
michael@0 588 nonopt=
michael@0 589 execute_dlfiles=
michael@0 590 preserve_args=
michael@0 591 lo2o="s/\\.lo\$/.${objext}/"
michael@0 592 o2lo="s/\\.${objext}\$/.lo/"
michael@0 593 extracted_archives=
michael@0 594 extracted_serial=0
michael@0 595
michael@0 596 opt_dry_run=false
michael@0 597 opt_duplicate_deps=false
michael@0 598 opt_silent=false
michael@0 599 opt_debug=:
michael@0 600
michael@0 601 # If this variable is set in any of the actions, the command in it
michael@0 602 # will be execed at the end. This prevents here-documents from being
michael@0 603 # left over by shells.
michael@0 604 exec_cmd=
michael@0 605
michael@0 606 # func_fatal_configuration arg...
michael@0 607 # Echo program name prefixed message to standard error, followed by
michael@0 608 # a configuration failure hint, and exit.
michael@0 609 func_fatal_configuration ()
michael@0 610 {
michael@0 611 func_error ${1+"$@"}
michael@0 612 func_error "See the $PACKAGE documentation for more information."
michael@0 613 func_fatal_error "Fatal configuration error."
michael@0 614 }
michael@0 615
michael@0 616
michael@0 617 # func_config
michael@0 618 # Display the configuration for all the tags in this script.
michael@0 619 func_config ()
michael@0 620 {
michael@0 621 re_begincf='^# ### BEGIN LIBTOOL'
michael@0 622 re_endcf='^# ### END LIBTOOL'
michael@0 623
michael@0 624 # Default configuration.
michael@0 625 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
michael@0 626
michael@0 627 # Now print the configurations for the tags.
michael@0 628 for tagname in $taglist; do
michael@0 629 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
michael@0 630 done
michael@0 631
michael@0 632 exit $?
michael@0 633 }
michael@0 634
michael@0 635 # func_features
michael@0 636 # Display the features supported by this script.
michael@0 637 func_features ()
michael@0 638 {
michael@0 639 $ECHO "host: $host"
michael@0 640 if test "$build_libtool_libs" = yes; then
michael@0 641 $ECHO "enable shared libraries"
michael@0 642 else
michael@0 643 $ECHO "disable shared libraries"
michael@0 644 fi
michael@0 645 if test "$build_old_libs" = yes; then
michael@0 646 $ECHO "enable static libraries"
michael@0 647 else
michael@0 648 $ECHO "disable static libraries"
michael@0 649 fi
michael@0 650
michael@0 651 exit $?
michael@0 652 }
michael@0 653
michael@0 654 # func_enable_tag tagname
michael@0 655 # Verify that TAGNAME is valid, and either flag an error and exit, or
michael@0 656 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
michael@0 657 # variable here.
michael@0 658 func_enable_tag ()
michael@0 659 {
michael@0 660 # Global variable:
michael@0 661 tagname="$1"
michael@0 662
michael@0 663 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
michael@0 664 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
michael@0 665 sed_extractcf="/$re_begincf/,/$re_endcf/p"
michael@0 666
michael@0 667 # Validate tagname.
michael@0 668 case $tagname in
michael@0 669 *[!-_A-Za-z0-9,/]*)
michael@0 670 func_fatal_error "invalid tag name: $tagname"
michael@0 671 ;;
michael@0 672 esac
michael@0 673
michael@0 674 # Don't test for the "default" C tag, as we know it's
michael@0 675 # there but not specially marked.
michael@0 676 case $tagname in
michael@0 677 CC) ;;
michael@0 678 *)
michael@0 679 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
michael@0 680 taglist="$taglist $tagname"
michael@0 681
michael@0 682 # Evaluate the configuration. Be careful to quote the path
michael@0 683 # and the sed script, to avoid splitting on whitespace, but
michael@0 684 # also don't use non-portable quotes within backquotes within
michael@0 685 # quotes we have to do it in 2 steps:
michael@0 686 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
michael@0 687 eval "$extractedcf"
michael@0 688 else
michael@0 689 func_error "ignoring unknown tag $tagname"
michael@0 690 fi
michael@0 691 ;;
michael@0 692 esac
michael@0 693 }
michael@0 694
michael@0 695 # Parse options once, thoroughly. This comes as soon as possible in
michael@0 696 # the script to make things like `libtool --version' happen quickly.
michael@0 697 {
michael@0 698
michael@0 699 # Shorthand for --mode=foo, only valid as the first argument
michael@0 700 case $1 in
michael@0 701 clean|clea|cle|cl)
michael@0 702 shift; set dummy --mode clean ${1+"$@"}; shift
michael@0 703 ;;
michael@0 704 compile|compil|compi|comp|com|co|c)
michael@0 705 shift; set dummy --mode compile ${1+"$@"}; shift
michael@0 706 ;;
michael@0 707 execute|execut|execu|exec|exe|ex|e)
michael@0 708 shift; set dummy --mode execute ${1+"$@"}; shift
michael@0 709 ;;
michael@0 710 finish|finis|fini|fin|fi|f)
michael@0 711 shift; set dummy --mode finish ${1+"$@"}; shift
michael@0 712 ;;
michael@0 713 install|instal|insta|inst|ins|in|i)
michael@0 714 shift; set dummy --mode install ${1+"$@"}; shift
michael@0 715 ;;
michael@0 716 link|lin|li|l)
michael@0 717 shift; set dummy --mode link ${1+"$@"}; shift
michael@0 718 ;;
michael@0 719 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
michael@0 720 shift; set dummy --mode uninstall ${1+"$@"}; shift
michael@0 721 ;;
michael@0 722 esac
michael@0 723
michael@0 724 # Parse non-mode specific arguments:
michael@0 725 while test "$#" -gt 0; do
michael@0 726 opt="$1"
michael@0 727 shift
michael@0 728
michael@0 729 case $opt in
michael@0 730 --config) func_config ;;
michael@0 731
michael@0 732 --debug) preserve_args="$preserve_args $opt"
michael@0 733 func_echo "enabling shell trace mode"
michael@0 734 opt_debug='set -x'
michael@0 735 $opt_debug
michael@0 736 ;;
michael@0 737
michael@0 738 -dlopen) test "$#" -eq 0 && func_missing_arg "$opt" && break
michael@0 739 execute_dlfiles="$execute_dlfiles $1"
michael@0 740 shift
michael@0 741 ;;
michael@0 742
michael@0 743 --dry-run | -n) opt_dry_run=: ;;
michael@0 744 --features) func_features ;;
michael@0 745 --finish) mode="finish" ;;
michael@0 746
michael@0 747 --mode) test "$#" -eq 0 && func_missing_arg "$opt" && break
michael@0 748 case $1 in
michael@0 749 # Valid mode arguments:
michael@0 750 clean) ;;
michael@0 751 compile) ;;
michael@0 752 execute) ;;
michael@0 753 finish) ;;
michael@0 754 install) ;;
michael@0 755 link) ;;
michael@0 756 relink) ;;
michael@0 757 uninstall) ;;
michael@0 758
michael@0 759 # Catch anything else as an error
michael@0 760 *) func_error "invalid argument for $opt"
michael@0 761 exit_cmd=exit
michael@0 762 break
michael@0 763 ;;
michael@0 764 esac
michael@0 765
michael@0 766 mode="$1"
michael@0 767 shift
michael@0 768 ;;
michael@0 769
michael@0 770 --preserve-dup-deps)
michael@0 771 opt_duplicate_deps=: ;;
michael@0 772
michael@0 773 --quiet|--silent) preserve_args="$preserve_args $opt"
michael@0 774 opt_silent=:
michael@0 775 ;;
michael@0 776
michael@0 777 --verbose| -v) preserve_args="$preserve_args $opt"
michael@0 778 opt_silent=false
michael@0 779 ;;
michael@0 780
michael@0 781 --tag) test "$#" -eq 0 && func_missing_arg "$opt" && break
michael@0 782 preserve_args="$preserve_args $opt $1"
michael@0 783 func_enable_tag "$1" # tagname is set here
michael@0 784 shift
michael@0 785 ;;
michael@0 786
michael@0 787 # Separate optargs to long options:
michael@0 788 -dlopen=*|--mode=*|--tag=*)
michael@0 789 func_opt_split "$opt"
michael@0 790 set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
michael@0 791 shift
michael@0 792 ;;
michael@0 793
michael@0 794 -\?|-h) func_usage ;;
michael@0 795 --help) opt_help=: ;;
michael@0 796 --version) func_version ;;
michael@0 797
michael@0 798 -*) func_fatal_help "unrecognized option \`$opt'" ;;
michael@0 799
michael@0 800 *) nonopt="$opt"
michael@0 801 break
michael@0 802 ;;
michael@0 803 esac
michael@0 804 done
michael@0 805
michael@0 806
michael@0 807 case $host in
michael@0 808 *cygwin* | *mingw* | *pw32* | *cegcc*)
michael@0 809 # don't eliminate duplications in $postdeps and $predeps
michael@0 810 opt_duplicate_compiler_generated_deps=:
michael@0 811 ;;
michael@0 812 *)
michael@0 813 opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
michael@0 814 ;;
michael@0 815 esac
michael@0 816
michael@0 817 # Having warned about all mis-specified options, bail out if
michael@0 818 # anything was wrong.
michael@0 819 $exit_cmd $EXIT_FAILURE
michael@0 820 }
michael@0 821
michael@0 822 # func_check_version_match
michael@0 823 # Ensure that we are using m4 macros, and libtool script from the same
michael@0 824 # release of libtool.
michael@0 825 func_check_version_match ()
michael@0 826 {
michael@0 827 if test "$package_revision" != "$macro_revision"; then
michael@0 828 if test "$VERSION" != "$macro_version"; then
michael@0 829 if test -z "$macro_version"; then
michael@0 830 cat >&2 <<_LT_EOF
michael@0 831 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
michael@0 832 $progname: definition of this LT_INIT comes from an older release.
michael@0 833 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
michael@0 834 $progname: and run autoconf again.
michael@0 835 _LT_EOF
michael@0 836 else
michael@0 837 cat >&2 <<_LT_EOF
michael@0 838 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
michael@0 839 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
michael@0 840 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
michael@0 841 $progname: and run autoconf again.
michael@0 842 _LT_EOF
michael@0 843 fi
michael@0 844 else
michael@0 845 cat >&2 <<_LT_EOF
michael@0 846 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
michael@0 847 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
michael@0 848 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
michael@0 849 $progname: of $PACKAGE $VERSION and run autoconf again.
michael@0 850 _LT_EOF
michael@0 851 fi
michael@0 852
michael@0 853 exit $EXIT_MISMATCH
michael@0 854 fi
michael@0 855 }
michael@0 856
michael@0 857
michael@0 858 ## ----------- ##
michael@0 859 ## Main. ##
michael@0 860 ## ----------- ##
michael@0 861
michael@0 862 $opt_help || {
michael@0 863 # Sanity checks first:
michael@0 864 func_check_version_match
michael@0 865
michael@0 866 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
michael@0 867 func_fatal_configuration "not configured to build any kind of library"
michael@0 868 fi
michael@0 869
michael@0 870 test -z "$mode" && func_fatal_error "error: you must specify a MODE."
michael@0 871
michael@0 872
michael@0 873 # Darwin sucks
michael@0 874 eval std_shrext=\"$shrext_cmds\"
michael@0 875
michael@0 876
michael@0 877 # Only execute mode is allowed to have -dlopen flags.
michael@0 878 if test -n "$execute_dlfiles" && test "$mode" != execute; then
michael@0 879 func_error "unrecognized option \`-dlopen'"
michael@0 880 $ECHO "$help" 1>&2
michael@0 881 exit $EXIT_FAILURE
michael@0 882 fi
michael@0 883
michael@0 884 # Change the help message to a mode-specific one.
michael@0 885 generic_help="$help"
michael@0 886 help="Try \`$progname --help --mode=$mode' for more information."
michael@0 887 }
michael@0 888
michael@0 889
michael@0 890 # func_lalib_p file
michael@0 891 # True iff FILE is a libtool `.la' library or `.lo' object file.
michael@0 892 # This function is only a basic sanity check; it will hardly flush out
michael@0 893 # determined imposters.
michael@0 894 func_lalib_p ()
michael@0 895 {
michael@0 896 test -f "$1" &&
michael@0 897 $SED -e 4q "$1" 2>/dev/null \
michael@0 898 | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
michael@0 899 }
michael@0 900
michael@0 901 # func_lalib_unsafe_p file
michael@0 902 # True iff FILE is a libtool `.la' library or `.lo' object file.
michael@0 903 # This function implements the same check as func_lalib_p without
michael@0 904 # resorting to external programs. To this end, it redirects stdin and
michael@0 905 # closes it afterwards, without saving the original file descriptor.
michael@0 906 # As a safety measure, use it only where a negative result would be
michael@0 907 # fatal anyway. Works if `file' does not exist.
michael@0 908 func_lalib_unsafe_p ()
michael@0 909 {
michael@0 910 lalib_p=no
michael@0 911 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
michael@0 912 for lalib_p_l in 1 2 3 4
michael@0 913 do
michael@0 914 read lalib_p_line
michael@0 915 case "$lalib_p_line" in
michael@0 916 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
michael@0 917 esac
michael@0 918 done
michael@0 919 exec 0<&5 5<&-
michael@0 920 fi
michael@0 921 test "$lalib_p" = yes
michael@0 922 }
michael@0 923
michael@0 924 # func_ltwrapper_script_p file
michael@0 925 # True iff FILE is a libtool wrapper script
michael@0 926 # This function is only a basic sanity check; it will hardly flush out
michael@0 927 # determined imposters.
michael@0 928 func_ltwrapper_script_p ()
michael@0 929 {
michael@0 930 func_lalib_p "$1"
michael@0 931 }
michael@0 932
michael@0 933 # func_ltwrapper_executable_p file
michael@0 934 # True iff FILE is a libtool wrapper executable
michael@0 935 # This function is only a basic sanity check; it will hardly flush out
michael@0 936 # determined imposters.
michael@0 937 func_ltwrapper_executable_p ()
michael@0 938 {
michael@0 939 func_ltwrapper_exec_suffix=
michael@0 940 case $1 in
michael@0 941 *.exe) ;;
michael@0 942 *) func_ltwrapper_exec_suffix=.exe ;;
michael@0 943 esac
michael@0 944 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
michael@0 945 }
michael@0 946
michael@0 947 # func_ltwrapper_scriptname file
michael@0 948 # Assumes file is an ltwrapper_executable
michael@0 949 # uses $file to determine the appropriate filename for a
michael@0 950 # temporary ltwrapper_script.
michael@0 951 func_ltwrapper_scriptname ()
michael@0 952 {
michael@0 953 func_ltwrapper_scriptname_result=""
michael@0 954 if func_ltwrapper_executable_p "$1"; then
michael@0 955 func_dirname_and_basename "$1" "" "."
michael@0 956 func_stripname '' '.exe' "$func_basename_result"
michael@0 957 func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
michael@0 958 fi
michael@0 959 }
michael@0 960
michael@0 961 # func_ltwrapper_p file
michael@0 962 # True iff FILE is a libtool wrapper script or wrapper executable
michael@0 963 # This function is only a basic sanity check; it will hardly flush out
michael@0 964 # determined imposters.
michael@0 965 func_ltwrapper_p ()
michael@0 966 {
michael@0 967 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
michael@0 968 }
michael@0 969
michael@0 970
michael@0 971 # func_execute_cmds commands fail_cmd
michael@0 972 # Execute tilde-delimited COMMANDS.
michael@0 973 # If FAIL_CMD is given, eval that upon failure.
michael@0 974 # FAIL_CMD may read-access the current command in variable CMD!
michael@0 975 func_execute_cmds ()
michael@0 976 {
michael@0 977 $opt_debug
michael@0 978 save_ifs=$IFS; IFS='~'
michael@0 979 for cmd in $1; do
michael@0 980 IFS=$save_ifs
michael@0 981 eval cmd=\"$cmd\"
michael@0 982 func_show_eval "$cmd" "${2-:}"
michael@0 983 done
michael@0 984 IFS=$save_ifs
michael@0 985 }
michael@0 986
michael@0 987
michael@0 988 # func_source file
michael@0 989 # Source FILE, adding directory component if necessary.
michael@0 990 # Note that it is not necessary on cygwin/mingw to append a dot to
michael@0 991 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
michael@0 992 # behavior happens only for exec(3), not for open(2)! Also, sourcing
michael@0 993 # `FILE.' does not work on cygwin managed mounts.
michael@0 994 func_source ()
michael@0 995 {
michael@0 996 $opt_debug
michael@0 997 case $1 in
michael@0 998 */* | *\\*) . "$1" ;;
michael@0 999 *) . "./$1" ;;
michael@0 1000 esac
michael@0 1001 }
michael@0 1002
michael@0 1003
michael@0 1004 # func_infer_tag arg
michael@0 1005 # Infer tagged configuration to use if any are available and
michael@0 1006 # if one wasn't chosen via the "--tag" command line option.
michael@0 1007 # Only attempt this if the compiler in the base compile
michael@0 1008 # command doesn't match the default compiler.
michael@0 1009 # arg is usually of the form 'gcc ...'
michael@0 1010 func_infer_tag ()
michael@0 1011 {
michael@0 1012 $opt_debug
michael@0 1013 if test -n "$available_tags" && test -z "$tagname"; then
michael@0 1014 CC_quoted=
michael@0 1015 for arg in $CC; do
michael@0 1016 func_quote_for_eval "$arg"
michael@0 1017 CC_quoted="$CC_quoted $func_quote_for_eval_result"
michael@0 1018 done
michael@0 1019 case $@ in
michael@0 1020 # Blanks in the command may have been stripped by the calling shell,
michael@0 1021 # but not from the CC environment variable when configure was run.
michael@0 1022 " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
michael@0 1023 # Blanks at the start of $base_compile will cause this to fail
michael@0 1024 # if we don't check for them as well.
michael@0 1025 *)
michael@0 1026 for z in $available_tags; do
michael@0 1027 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
michael@0 1028 # Evaluate the configuration.
michael@0 1029 eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
michael@0 1030 CC_quoted=
michael@0 1031 for arg in $CC; do
michael@0 1032 # Double-quote args containing other shell metacharacters.
michael@0 1033 func_quote_for_eval "$arg"
michael@0 1034 CC_quoted="$CC_quoted $func_quote_for_eval_result"
michael@0 1035 done
michael@0 1036 case "$@ " in
michael@0 1037 " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
michael@0 1038 # The compiler in the base compile command matches
michael@0 1039 # the one in the tagged configuration.
michael@0 1040 # Assume this is the tagged configuration we want.
michael@0 1041 tagname=$z
michael@0 1042 break
michael@0 1043 ;;
michael@0 1044 esac
michael@0 1045 fi
michael@0 1046 done
michael@0 1047 # If $tagname still isn't set, then no tagged configuration
michael@0 1048 # was found and let the user know that the "--tag" command
michael@0 1049 # line option must be used.
michael@0 1050 if test -z "$tagname"; then
michael@0 1051 func_echo "unable to infer tagged configuration"
michael@0 1052 func_fatal_error "specify a tag with \`--tag'"
michael@0 1053 # else
michael@0 1054 # func_verbose "using $tagname tagged configuration"
michael@0 1055 fi
michael@0 1056 ;;
michael@0 1057 esac
michael@0 1058 fi
michael@0 1059 }
michael@0 1060
michael@0 1061
michael@0 1062
michael@0 1063 # func_write_libtool_object output_name pic_name nonpic_name
michael@0 1064 # Create a libtool object file (analogous to a ".la" file),
michael@0 1065 # but don't create it if we're doing a dry run.
michael@0 1066 func_write_libtool_object ()
michael@0 1067 {
michael@0 1068 write_libobj=${1}
michael@0 1069 if test "$build_libtool_libs" = yes; then
michael@0 1070 write_lobj=\'${2}\'
michael@0 1071 else
michael@0 1072 write_lobj=none
michael@0 1073 fi
michael@0 1074
michael@0 1075 if test "$build_old_libs" = yes; then
michael@0 1076 write_oldobj=\'${3}\'
michael@0 1077 else
michael@0 1078 write_oldobj=none
michael@0 1079 fi
michael@0 1080
michael@0 1081 $opt_dry_run || {
michael@0 1082 cat >${write_libobj}T <<EOF
michael@0 1083 # $write_libobj - a libtool object file
michael@0 1084 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
michael@0 1085 #
michael@0 1086 # Please DO NOT delete this file!
michael@0 1087 # It is necessary for linking the library.
michael@0 1088
michael@0 1089 # Name of the PIC object.
michael@0 1090 pic_object=$write_lobj
michael@0 1091
michael@0 1092 # Name of the non-PIC object
michael@0 1093 non_pic_object=$write_oldobj
michael@0 1094
michael@0 1095 EOF
michael@0 1096 $MV "${write_libobj}T" "${write_libobj}"
michael@0 1097 }
michael@0 1098 }
michael@0 1099
michael@0 1100 # func_mode_compile arg...
michael@0 1101 func_mode_compile ()
michael@0 1102 {
michael@0 1103 $opt_debug
michael@0 1104 # Get the compilation command and the source file.
michael@0 1105 base_compile=
michael@0 1106 srcfile="$nonopt" # always keep a non-empty value in "srcfile"
michael@0 1107 suppress_opt=yes
michael@0 1108 suppress_output=
michael@0 1109 arg_mode=normal
michael@0 1110 libobj=
michael@0 1111 later=
michael@0 1112 pie_flag=
michael@0 1113
michael@0 1114 for arg
michael@0 1115 do
michael@0 1116 case $arg_mode in
michael@0 1117 arg )
michael@0 1118 # do not "continue". Instead, add this to base_compile
michael@0 1119 lastarg="$arg"
michael@0 1120 arg_mode=normal
michael@0 1121 ;;
michael@0 1122
michael@0 1123 target )
michael@0 1124 libobj="$arg"
michael@0 1125 arg_mode=normal
michael@0 1126 continue
michael@0 1127 ;;
michael@0 1128
michael@0 1129 normal )
michael@0 1130 # Accept any command-line options.
michael@0 1131 case $arg in
michael@0 1132 -o)
michael@0 1133 test -n "$libobj" && \
michael@0 1134 func_fatal_error "you cannot specify \`-o' more than once"
michael@0 1135 arg_mode=target
michael@0 1136 continue
michael@0 1137 ;;
michael@0 1138
michael@0 1139 -pie | -fpie | -fPIE)
michael@0 1140 pie_flag="$pie_flag $arg"
michael@0 1141 continue
michael@0 1142 ;;
michael@0 1143
michael@0 1144 -shared | -static | -prefer-pic | -prefer-non-pic)
michael@0 1145 later="$later $arg"
michael@0 1146 continue
michael@0 1147 ;;
michael@0 1148
michael@0 1149 -no-suppress)
michael@0 1150 suppress_opt=no
michael@0 1151 continue
michael@0 1152 ;;
michael@0 1153
michael@0 1154 -Xcompiler)
michael@0 1155 arg_mode=arg # the next one goes into the "base_compile" arg list
michael@0 1156 continue # The current "srcfile" will either be retained or
michael@0 1157 ;; # replaced later. I would guess that would be a bug.
michael@0 1158
michael@0 1159 -Wc,*)
michael@0 1160 func_stripname '-Wc,' '' "$arg"
michael@0 1161 args=$func_stripname_result
michael@0 1162 lastarg=
michael@0 1163 save_ifs="$IFS"; IFS=','
michael@0 1164 for arg in $args; do
michael@0 1165 IFS="$save_ifs"
michael@0 1166 func_quote_for_eval "$arg"
michael@0 1167 lastarg="$lastarg $func_quote_for_eval_result"
michael@0 1168 done
michael@0 1169 IFS="$save_ifs"
michael@0 1170 func_stripname ' ' '' "$lastarg"
michael@0 1171 lastarg=$func_stripname_result
michael@0 1172
michael@0 1173 # Add the arguments to base_compile.
michael@0 1174 base_compile="$base_compile $lastarg"
michael@0 1175 continue
michael@0 1176 ;;
michael@0 1177
michael@0 1178 *)
michael@0 1179 # Accept the current argument as the source file.
michael@0 1180 # The previous "srcfile" becomes the current argument.
michael@0 1181 #
michael@0 1182 lastarg="$srcfile"
michael@0 1183 srcfile="$arg"
michael@0 1184 ;;
michael@0 1185 esac # case $arg
michael@0 1186 ;;
michael@0 1187 esac # case $arg_mode
michael@0 1188
michael@0 1189 # Aesthetically quote the previous argument.
michael@0 1190 func_quote_for_eval "$lastarg"
michael@0 1191 base_compile="$base_compile $func_quote_for_eval_result"
michael@0 1192 done # for arg
michael@0 1193
michael@0 1194 case $arg_mode in
michael@0 1195 arg)
michael@0 1196 func_fatal_error "you must specify an argument for -Xcompile"
michael@0 1197 ;;
michael@0 1198 target)
michael@0 1199 func_fatal_error "you must specify a target with \`-o'"
michael@0 1200 ;;
michael@0 1201 *)
michael@0 1202 # Get the name of the library object.
michael@0 1203 test -z "$libobj" && {
michael@0 1204 func_basename "$srcfile"
michael@0 1205 libobj="$func_basename_result"
michael@0 1206 }
michael@0 1207 ;;
michael@0 1208 esac
michael@0 1209
michael@0 1210 # Recognize several different file suffixes.
michael@0 1211 # If the user specifies -o file.o, it is replaced with file.lo
michael@0 1212 case $libobj in
michael@0 1213 *.[cCFSifmso] | \
michael@0 1214 *.ada | *.adb | *.ads | *.asm | \
michael@0 1215 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
michael@0 1216 *.[fF][09]? | *.for | *.java | *.obj | *.sx)
michael@0 1217 func_xform "$libobj"
michael@0 1218 libobj=$func_xform_result
michael@0 1219 ;;
michael@0 1220 esac
michael@0 1221
michael@0 1222 case $libobj in
michael@0 1223 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
michael@0 1224 *)
michael@0 1225 func_fatal_error "cannot determine name of library object from \`$libobj'"
michael@0 1226 ;;
michael@0 1227 esac
michael@0 1228
michael@0 1229 func_infer_tag $base_compile
michael@0 1230
michael@0 1231 for arg in $later; do
michael@0 1232 case $arg in
michael@0 1233 -shared)
michael@0 1234 test "$build_libtool_libs" != yes && \
michael@0 1235 func_fatal_configuration "can not build a shared library"
michael@0 1236 build_old_libs=no
michael@0 1237 continue
michael@0 1238 ;;
michael@0 1239
michael@0 1240 -static)
michael@0 1241 build_libtool_libs=no
michael@0 1242 build_old_libs=yes
michael@0 1243 continue
michael@0 1244 ;;
michael@0 1245
michael@0 1246 -prefer-pic)
michael@0 1247 pic_mode=yes
michael@0 1248 continue
michael@0 1249 ;;
michael@0 1250
michael@0 1251 -prefer-non-pic)
michael@0 1252 pic_mode=no
michael@0 1253 continue
michael@0 1254 ;;
michael@0 1255 esac
michael@0 1256 done
michael@0 1257
michael@0 1258 func_quote_for_eval "$libobj"
michael@0 1259 test "X$libobj" != "X$func_quote_for_eval_result" \
michael@0 1260 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
michael@0 1261 && func_warning "libobj name \`$libobj' may not contain shell special characters."
michael@0 1262 func_dirname_and_basename "$obj" "/" ""
michael@0 1263 objname="$func_basename_result"
michael@0 1264 xdir="$func_dirname_result"
michael@0 1265 lobj=${xdir}$objdir/$objname
michael@0 1266
michael@0 1267 test -z "$base_compile" && \
michael@0 1268 func_fatal_help "you must specify a compilation command"
michael@0 1269
michael@0 1270 # Delete any leftover library objects.
michael@0 1271 if test "$build_old_libs" = yes; then
michael@0 1272 removelist="$obj $lobj $libobj ${libobj}T"
michael@0 1273 else
michael@0 1274 removelist="$lobj $libobj ${libobj}T"
michael@0 1275 fi
michael@0 1276
michael@0 1277 # On Cygwin there's no "real" PIC flag so we must build both object types
michael@0 1278 case $host_os in
michael@0 1279 cygwin* | mingw* | pw32* | os2* | cegcc*)
michael@0 1280 pic_mode=default
michael@0 1281 ;;
michael@0 1282 esac
michael@0 1283 if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
michael@0 1284 # non-PIC code in shared libraries is not supported
michael@0 1285 pic_mode=default
michael@0 1286 fi
michael@0 1287
michael@0 1288 # Calculate the filename of the output object if compiler does
michael@0 1289 # not support -o with -c
michael@0 1290 if test "$compiler_c_o" = no; then
michael@0 1291 output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
michael@0 1292 lockfile="$output_obj.lock"
michael@0 1293 else
michael@0 1294 output_obj=
michael@0 1295 need_locks=no
michael@0 1296 lockfile=
michael@0 1297 fi
michael@0 1298
michael@0 1299 # Lock this critical section if it is needed
michael@0 1300 # We use this script file to make the link, it avoids creating a new file
michael@0 1301 if test "$need_locks" = yes; then
michael@0 1302 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
michael@0 1303 func_echo "Waiting for $lockfile to be removed"
michael@0 1304 sleep 2
michael@0 1305 done
michael@0 1306 elif test "$need_locks" = warn; then
michael@0 1307 if test -f "$lockfile"; then
michael@0 1308 $ECHO "\
michael@0 1309 *** ERROR, $lockfile exists and contains:
michael@0 1310 `cat $lockfile 2>/dev/null`
michael@0 1311
michael@0 1312 This indicates that another process is trying to use the same
michael@0 1313 temporary object file, and libtool could not work around it because
michael@0 1314 your compiler does not support \`-c' and \`-o' together. If you
michael@0 1315 repeat this compilation, it may succeed, by chance, but you had better
michael@0 1316 avoid parallel builds (make -j) in this platform, or get a better
michael@0 1317 compiler."
michael@0 1318
michael@0 1319 $opt_dry_run || $RM $removelist
michael@0 1320 exit $EXIT_FAILURE
michael@0 1321 fi
michael@0 1322 removelist="$removelist $output_obj"
michael@0 1323 $ECHO "$srcfile" > "$lockfile"
michael@0 1324 fi
michael@0 1325
michael@0 1326 $opt_dry_run || $RM $removelist
michael@0 1327 removelist="$removelist $lockfile"
michael@0 1328 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
michael@0 1329
michael@0 1330 if test -n "$fix_srcfile_path"; then
michael@0 1331 eval srcfile=\"$fix_srcfile_path\"
michael@0 1332 fi
michael@0 1333 func_quote_for_eval "$srcfile"
michael@0 1334 qsrcfile=$func_quote_for_eval_result
michael@0 1335
michael@0 1336 # Only build a PIC object if we are building libtool libraries.
michael@0 1337 if test "$build_libtool_libs" = yes; then
michael@0 1338 # Without this assignment, base_compile gets emptied.
michael@0 1339 fbsd_hideous_sh_bug=$base_compile
michael@0 1340
michael@0 1341 if test "$pic_mode" != no; then
michael@0 1342 command="$base_compile $qsrcfile $pic_flag"
michael@0 1343 else
michael@0 1344 # Don't build PIC code
michael@0 1345 command="$base_compile $qsrcfile"
michael@0 1346 fi
michael@0 1347
michael@0 1348 func_mkdir_p "$xdir$objdir"
michael@0 1349
michael@0 1350 if test -z "$output_obj"; then
michael@0 1351 # Place PIC objects in $objdir
michael@0 1352 command="$command -o $lobj"
michael@0 1353 fi
michael@0 1354
michael@0 1355 func_show_eval_locale "$command" \
michael@0 1356 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
michael@0 1357
michael@0 1358 if test "$need_locks" = warn &&
michael@0 1359 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
michael@0 1360 $ECHO "\
michael@0 1361 *** ERROR, $lockfile contains:
michael@0 1362 `cat $lockfile 2>/dev/null`
michael@0 1363
michael@0 1364 but it should contain:
michael@0 1365 $srcfile
michael@0 1366
michael@0 1367 This indicates that another process is trying to use the same
michael@0 1368 temporary object file, and libtool could not work around it because
michael@0 1369 your compiler does not support \`-c' and \`-o' together. If you
michael@0 1370 repeat this compilation, it may succeed, by chance, but you had better
michael@0 1371 avoid parallel builds (make -j) in this platform, or get a better
michael@0 1372 compiler."
michael@0 1373
michael@0 1374 $opt_dry_run || $RM $removelist
michael@0 1375 exit $EXIT_FAILURE
michael@0 1376 fi
michael@0 1377
michael@0 1378 # Just move the object if needed, then go on to compile the next one
michael@0 1379 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
michael@0 1380 func_show_eval '$MV "$output_obj" "$lobj"' \
michael@0 1381 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
michael@0 1382 fi
michael@0 1383
michael@0 1384 # Allow error messages only from the first compilation.
michael@0 1385 if test "$suppress_opt" = yes; then
michael@0 1386 suppress_output=' >/dev/null 2>&1'
michael@0 1387 fi
michael@0 1388 fi
michael@0 1389
michael@0 1390 # Only build a position-dependent object if we build old libraries.
michael@0 1391 if test "$build_old_libs" = yes; then
michael@0 1392 if test "$pic_mode" != yes; then
michael@0 1393 # Don't build PIC code
michael@0 1394 command="$base_compile $qsrcfile$pie_flag"
michael@0 1395 else
michael@0 1396 command="$base_compile $qsrcfile $pic_flag"
michael@0 1397 fi
michael@0 1398 if test "$compiler_c_o" = yes; then
michael@0 1399 command="$command -o $obj"
michael@0 1400 fi
michael@0 1401
michael@0 1402 # Suppress compiler output if we already did a PIC compilation.
michael@0 1403 command="$command$suppress_output"
michael@0 1404 func_show_eval_locale "$command" \
michael@0 1405 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
michael@0 1406
michael@0 1407 if test "$need_locks" = warn &&
michael@0 1408 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
michael@0 1409 $ECHO "\
michael@0 1410 *** ERROR, $lockfile contains:
michael@0 1411 `cat $lockfile 2>/dev/null`
michael@0 1412
michael@0 1413 but it should contain:
michael@0 1414 $srcfile
michael@0 1415
michael@0 1416 This indicates that another process is trying to use the same
michael@0 1417 temporary object file, and libtool could not work around it because
michael@0 1418 your compiler does not support \`-c' and \`-o' together. If you
michael@0 1419 repeat this compilation, it may succeed, by chance, but you had better
michael@0 1420 avoid parallel builds (make -j) in this platform, or get a better
michael@0 1421 compiler."
michael@0 1422
michael@0 1423 $opt_dry_run || $RM $removelist
michael@0 1424 exit $EXIT_FAILURE
michael@0 1425 fi
michael@0 1426
michael@0 1427 # Just move the object if needed
michael@0 1428 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
michael@0 1429 func_show_eval '$MV "$output_obj" "$obj"' \
michael@0 1430 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
michael@0 1431 fi
michael@0 1432 fi
michael@0 1433
michael@0 1434 $opt_dry_run || {
michael@0 1435 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
michael@0 1436
michael@0 1437 # Unlock the critical section if it was locked
michael@0 1438 if test "$need_locks" != no; then
michael@0 1439 removelist=$lockfile
michael@0 1440 $RM "$lockfile"
michael@0 1441 fi
michael@0 1442 }
michael@0 1443
michael@0 1444 exit $EXIT_SUCCESS
michael@0 1445 }
michael@0 1446
michael@0 1447 $opt_help || {
michael@0 1448 test "$mode" = compile && func_mode_compile ${1+"$@"}
michael@0 1449 }
michael@0 1450
michael@0 1451 func_mode_help ()
michael@0 1452 {
michael@0 1453 # We need to display help for each of the modes.
michael@0 1454 case $mode in
michael@0 1455 "")
michael@0 1456 # Generic help is extracted from the usage comments
michael@0 1457 # at the start of this file.
michael@0 1458 func_help
michael@0 1459 ;;
michael@0 1460
michael@0 1461 clean)
michael@0 1462 $ECHO \
michael@0 1463 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
michael@0 1464
michael@0 1465 Remove files from the build directory.
michael@0 1466
michael@0 1467 RM is the name of the program to use to delete files associated with each FILE
michael@0 1468 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
michael@0 1469 to RM.
michael@0 1470
michael@0 1471 If FILE is a libtool library, object or program, all the files associated
michael@0 1472 with it are deleted. Otherwise, only FILE itself is deleted using RM."
michael@0 1473 ;;
michael@0 1474
michael@0 1475 compile)
michael@0 1476 $ECHO \
michael@0 1477 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
michael@0 1478
michael@0 1479 Compile a source file into a libtool library object.
michael@0 1480
michael@0 1481 This mode accepts the following additional options:
michael@0 1482
michael@0 1483 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
michael@0 1484 -no-suppress do not suppress compiler output for multiple passes
michael@0 1485 -prefer-pic try to building PIC objects only
michael@0 1486 -prefer-non-pic try to building non-PIC objects only
michael@0 1487 -shared do not build a \`.o' file suitable for static linking
michael@0 1488 -static only build a \`.o' file suitable for static linking
michael@0 1489
michael@0 1490 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
michael@0 1491 from the given SOURCEFILE.
michael@0 1492
michael@0 1493 The output file name is determined by removing the directory component from
michael@0 1494 SOURCEFILE, then substituting the C source code suffix \`.c' with the
michael@0 1495 library object suffix, \`.lo'."
michael@0 1496 ;;
michael@0 1497
michael@0 1498 execute)
michael@0 1499 $ECHO \
michael@0 1500 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
michael@0 1501
michael@0 1502 Automatically set library path, then run a program.
michael@0 1503
michael@0 1504 This mode accepts the following additional options:
michael@0 1505
michael@0 1506 -dlopen FILE add the directory containing FILE to the library path
michael@0 1507
michael@0 1508 This mode sets the library path environment variable according to \`-dlopen'
michael@0 1509 flags.
michael@0 1510
michael@0 1511 If any of the ARGS are libtool executable wrappers, then they are translated
michael@0 1512 into their corresponding uninstalled binary, and any of their required library
michael@0 1513 directories are added to the library path.
michael@0 1514
michael@0 1515 Then, COMMAND is executed, with ARGS as arguments."
michael@0 1516 ;;
michael@0 1517
michael@0 1518 finish)
michael@0 1519 $ECHO \
michael@0 1520 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
michael@0 1521
michael@0 1522 Complete the installation of libtool libraries.
michael@0 1523
michael@0 1524 Each LIBDIR is a directory that contains libtool libraries.
michael@0 1525
michael@0 1526 The commands that this mode executes may require superuser privileges. Use
michael@0 1527 the \`--dry-run' option if you just want to see what would be executed."
michael@0 1528 ;;
michael@0 1529
michael@0 1530 install)
michael@0 1531 $ECHO \
michael@0 1532 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
michael@0 1533
michael@0 1534 Install executables or libraries.
michael@0 1535
michael@0 1536 INSTALL-COMMAND is the installation command. The first component should be
michael@0 1537 either the \`install' or \`cp' program.
michael@0 1538
michael@0 1539 The following components of INSTALL-COMMAND are treated specially:
michael@0 1540
michael@0 1541 -inst-prefix PREFIX-DIR Use PREFIX-DIR as a staging area for installation
michael@0 1542
michael@0 1543 The rest of the components are interpreted as arguments to that command (only
michael@0 1544 BSD-compatible install options are recognized)."
michael@0 1545 ;;
michael@0 1546
michael@0 1547 link)
michael@0 1548 $ECHO \
michael@0 1549 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
michael@0 1550
michael@0 1551 Link object files or libraries together to form another library, or to
michael@0 1552 create an executable program.
michael@0 1553
michael@0 1554 LINK-COMMAND is a command using the C compiler that you would use to create
michael@0 1555 a program from several object files.
michael@0 1556
michael@0 1557 The following components of LINK-COMMAND are treated specially:
michael@0 1558
michael@0 1559 -all-static do not do any dynamic linking at all
michael@0 1560 -avoid-version do not add a version suffix if possible
michael@0 1561 -dlopen FILE \`-dlpreopen' FILE if it cannot be dlopened at runtime
michael@0 1562 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
michael@0 1563 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
michael@0 1564 -export-symbols SYMFILE
michael@0 1565 try to export only the symbols listed in SYMFILE
michael@0 1566 -export-symbols-regex REGEX
michael@0 1567 try to export only the symbols matching REGEX
michael@0 1568 -LLIBDIR search LIBDIR for required installed libraries
michael@0 1569 -lNAME OUTPUT-FILE requires the installed library libNAME
michael@0 1570 -module build a library that can dlopened
michael@0 1571 -no-fast-install disable the fast-install mode
michael@0 1572 -no-install link a not-installable executable
michael@0 1573 -no-undefined declare that a library does not refer to external symbols
michael@0 1574 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
michael@0 1575 -objectlist FILE Use a list of object files found in FILE to specify objects
michael@0 1576 -precious-files-regex REGEX
michael@0 1577 don't remove output files matching REGEX
michael@0 1578 -release RELEASE specify package release information
michael@0 1579 -rpath LIBDIR the created library will eventually be installed in LIBDIR
michael@0 1580 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
michael@0 1581 -shared only do dynamic linking of libtool libraries
michael@0 1582 -shrext SUFFIX override the standard shared library file extension
michael@0 1583 -static do not do any dynamic linking of uninstalled libtool libraries
michael@0 1584 -static-libtool-libs
michael@0 1585 do not do any dynamic linking of libtool libraries
michael@0 1586 -version-info CURRENT[:REVISION[:AGE]]
michael@0 1587 specify library version info [each variable defaults to 0]
michael@0 1588 -weak LIBNAME declare that the target provides the LIBNAME interface
michael@0 1589
michael@0 1590 All other options (arguments beginning with \`-') are ignored.
michael@0 1591
michael@0 1592 Every other argument is treated as a filename. Files ending in \`.la' are
michael@0 1593 treated as uninstalled libtool libraries, other files are standard or library
michael@0 1594 object files.
michael@0 1595
michael@0 1596 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
michael@0 1597 only library objects (\`.lo' files) may be specified, and \`-rpath' is
michael@0 1598 required, except when creating a convenience library.
michael@0 1599
michael@0 1600 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
michael@0 1601 using \`ar' and \`ranlib', or on Windows using \`lib'.
michael@0 1602
michael@0 1603 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
michael@0 1604 is created, otherwise an executable program is created."
michael@0 1605 ;;
michael@0 1606
michael@0 1607 uninstall)
michael@0 1608 $ECHO \
michael@0 1609 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
michael@0 1610
michael@0 1611 Remove libraries from an installation directory.
michael@0 1612
michael@0 1613 RM is the name of the program to use to delete files associated with each FILE
michael@0 1614 (typically \`/bin/rm'). RM-OPTIONS are options (such as \`-f') to be passed
michael@0 1615 to RM.
michael@0 1616
michael@0 1617 If FILE is a libtool library, all the files associated with it are deleted.
michael@0 1618 Otherwise, only FILE itself is deleted using RM."
michael@0 1619 ;;
michael@0 1620
michael@0 1621 *)
michael@0 1622 func_fatal_help "invalid operation mode \`$mode'"
michael@0 1623 ;;
michael@0 1624 esac
michael@0 1625
michael@0 1626 $ECHO
michael@0 1627 $ECHO "Try \`$progname --help' for more information about other modes."
michael@0 1628
michael@0 1629 exit $?
michael@0 1630 }
michael@0 1631
michael@0 1632 # Now that we've collected a possible --mode arg, show help if necessary
michael@0 1633 $opt_help && func_mode_help
michael@0 1634
michael@0 1635
michael@0 1636 # func_mode_execute arg...
michael@0 1637 func_mode_execute ()
michael@0 1638 {
michael@0 1639 $opt_debug
michael@0 1640 # The first argument is the command name.
michael@0 1641 cmd="$nonopt"
michael@0 1642 test -z "$cmd" && \
michael@0 1643 func_fatal_help "you must specify a COMMAND"
michael@0 1644
michael@0 1645 # Handle -dlopen flags immediately.
michael@0 1646 for file in $execute_dlfiles; do
michael@0 1647 test -f "$file" \
michael@0 1648 || func_fatal_help "\`$file' is not a file"
michael@0 1649
michael@0 1650 dir=
michael@0 1651 case $file in
michael@0 1652 *.la)
michael@0 1653 # Check to see that this really is a libtool archive.
michael@0 1654 func_lalib_unsafe_p "$file" \
michael@0 1655 || func_fatal_help "\`$lib' is not a valid libtool archive"
michael@0 1656
michael@0 1657 # Read the libtool library.
michael@0 1658 dlname=
michael@0 1659 library_names=
michael@0 1660 func_source "$file"
michael@0 1661
michael@0 1662 # Skip this library if it cannot be dlopened.
michael@0 1663 if test -z "$dlname"; then
michael@0 1664 # Warn if it was a shared library.
michael@0 1665 test -n "$library_names" && \
michael@0 1666 func_warning "\`$file' was not linked with \`-export-dynamic'"
michael@0 1667 continue
michael@0 1668 fi
michael@0 1669
michael@0 1670 func_dirname "$file" "" "."
michael@0 1671 dir="$func_dirname_result"
michael@0 1672
michael@0 1673 if test -f "$dir/$objdir/$dlname"; then
michael@0 1674 dir="$dir/$objdir"
michael@0 1675 else
michael@0 1676 if test ! -f "$dir/$dlname"; then
michael@0 1677 func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
michael@0 1678 fi
michael@0 1679 fi
michael@0 1680 ;;
michael@0 1681
michael@0 1682 *.lo)
michael@0 1683 # Just add the directory containing the .lo file.
michael@0 1684 func_dirname "$file" "" "."
michael@0 1685 dir="$func_dirname_result"
michael@0 1686 ;;
michael@0 1687
michael@0 1688 *)
michael@0 1689 func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
michael@0 1690 continue
michael@0 1691 ;;
michael@0 1692 esac
michael@0 1693
michael@0 1694 # Get the absolute pathname.
michael@0 1695 absdir=`cd "$dir" && pwd`
michael@0 1696 test -n "$absdir" && dir="$absdir"
michael@0 1697
michael@0 1698 # Now add the directory to shlibpath_var.
michael@0 1699 if eval "test -z \"\$$shlibpath_var\""; then
michael@0 1700 eval "$shlibpath_var=\"\$dir\""
michael@0 1701 else
michael@0 1702 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
michael@0 1703 fi
michael@0 1704 done
michael@0 1705
michael@0 1706 # This variable tells wrapper scripts just to set shlibpath_var
michael@0 1707 # rather than running their programs.
michael@0 1708 libtool_execute_magic="$magic"
michael@0 1709
michael@0 1710 # Check if any of the arguments is a wrapper script.
michael@0 1711 args=
michael@0 1712 for file
michael@0 1713 do
michael@0 1714 case $file in
michael@0 1715 -*) ;;
michael@0 1716 *)
michael@0 1717 # Do a test to see if this is really a libtool program.
michael@0 1718 if func_ltwrapper_script_p "$file"; then
michael@0 1719 func_source "$file"
michael@0 1720 # Transform arg to wrapped name.
michael@0 1721 file="$progdir/$program"
michael@0 1722 elif func_ltwrapper_executable_p "$file"; then
michael@0 1723 func_ltwrapper_scriptname "$file"
michael@0 1724 func_source "$func_ltwrapper_scriptname_result"
michael@0 1725 # Transform arg to wrapped name.
michael@0 1726 file="$progdir/$program"
michael@0 1727 fi
michael@0 1728 ;;
michael@0 1729 esac
michael@0 1730 # Quote arguments (to preserve shell metacharacters).
michael@0 1731 func_quote_for_eval "$file"
michael@0 1732 args="$args $func_quote_for_eval_result"
michael@0 1733 done
michael@0 1734
michael@0 1735 if test "X$opt_dry_run" = Xfalse; then
michael@0 1736 if test -n "$shlibpath_var"; then
michael@0 1737 # Export the shlibpath_var.
michael@0 1738 eval "export $shlibpath_var"
michael@0 1739 fi
michael@0 1740
michael@0 1741 # Restore saved environment variables
michael@0 1742 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
michael@0 1743 do
michael@0 1744 eval "if test \"\${save_$lt_var+set}\" = set; then
michael@0 1745 $lt_var=\$save_$lt_var; export $lt_var
michael@0 1746 else
michael@0 1747 $lt_unset $lt_var
michael@0 1748 fi"
michael@0 1749 done
michael@0 1750
michael@0 1751 # Now prepare to actually exec the command.
michael@0 1752 exec_cmd="\$cmd$args"
michael@0 1753 else
michael@0 1754 # Display what would be done.
michael@0 1755 if test -n "$shlibpath_var"; then
michael@0 1756 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
michael@0 1757 $ECHO "export $shlibpath_var"
michael@0 1758 fi
michael@0 1759 $ECHO "$cmd$args"
michael@0 1760 exit $EXIT_SUCCESS
michael@0 1761 fi
michael@0 1762 }
michael@0 1763
michael@0 1764 test "$mode" = execute && func_mode_execute ${1+"$@"}
michael@0 1765
michael@0 1766
michael@0 1767 # func_mode_finish arg...
michael@0 1768 func_mode_finish ()
michael@0 1769 {
michael@0 1770 $opt_debug
michael@0 1771 libdirs="$nonopt"
michael@0 1772 admincmds=
michael@0 1773
michael@0 1774 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
michael@0 1775 for dir
michael@0 1776 do
michael@0 1777 libdirs="$libdirs $dir"
michael@0 1778 done
michael@0 1779
michael@0 1780 for libdir in $libdirs; do
michael@0 1781 if test -n "$finish_cmds"; then
michael@0 1782 # Do each command in the finish commands.
michael@0 1783 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
michael@0 1784 '"$cmd"'"'
michael@0 1785 fi
michael@0 1786 if test -n "$finish_eval"; then
michael@0 1787 # Do the single finish_eval.
michael@0 1788 eval cmds=\"$finish_eval\"
michael@0 1789 $opt_dry_run || eval "$cmds" || admincmds="$admincmds
michael@0 1790 $cmds"
michael@0 1791 fi
michael@0 1792 done
michael@0 1793 fi
michael@0 1794
michael@0 1795 # Exit here if they wanted silent mode.
michael@0 1796 $opt_silent && exit $EXIT_SUCCESS
michael@0 1797
michael@0 1798 $ECHO "X----------------------------------------------------------------------" | $Xsed
michael@0 1799 $ECHO "Libraries have been installed in:"
michael@0 1800 for libdir in $libdirs; do
michael@0 1801 $ECHO " $libdir"
michael@0 1802 done
michael@0 1803 $ECHO
michael@0 1804 $ECHO "If you ever happen to want to link against installed libraries"
michael@0 1805 $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
michael@0 1806 $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
michael@0 1807 $ECHO "flag during linking and do at least one of the following:"
michael@0 1808 if test -n "$shlibpath_var"; then
michael@0 1809 $ECHO " - add LIBDIR to the \`$shlibpath_var' environment variable"
michael@0 1810 $ECHO " during execution"
michael@0 1811 fi
michael@0 1812 if test -n "$runpath_var"; then
michael@0 1813 $ECHO " - add LIBDIR to the \`$runpath_var' environment variable"
michael@0 1814 $ECHO " during linking"
michael@0 1815 fi
michael@0 1816 if test -n "$hardcode_libdir_flag_spec"; then
michael@0 1817 libdir=LIBDIR
michael@0 1818 eval flag=\"$hardcode_libdir_flag_spec\"
michael@0 1819
michael@0 1820 $ECHO " - use the \`$flag' linker flag"
michael@0 1821 fi
michael@0 1822 if test -n "$admincmds"; then
michael@0 1823 $ECHO " - have your system administrator run these commands:$admincmds"
michael@0 1824 fi
michael@0 1825 if test -f /etc/ld.so.conf; then
michael@0 1826 $ECHO " - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
michael@0 1827 fi
michael@0 1828 $ECHO
michael@0 1829
michael@0 1830 $ECHO "See any operating system documentation about shared libraries for"
michael@0 1831 case $host in
michael@0 1832 solaris2.[6789]|solaris2.1[0-9])
michael@0 1833 $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
michael@0 1834 $ECHO "pages."
michael@0 1835 ;;
michael@0 1836 *)
michael@0 1837 $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
michael@0 1838 ;;
michael@0 1839 esac
michael@0 1840 $ECHO "X----------------------------------------------------------------------" | $Xsed
michael@0 1841 exit $EXIT_SUCCESS
michael@0 1842 }
michael@0 1843
michael@0 1844 test "$mode" = finish && func_mode_finish ${1+"$@"}
michael@0 1845
michael@0 1846
michael@0 1847 # func_mode_install arg...
michael@0 1848 func_mode_install ()
michael@0 1849 {
michael@0 1850 $opt_debug
michael@0 1851 # There may be an optional sh(1) argument at the beginning of
michael@0 1852 # install_prog (especially on Windows NT).
michael@0 1853 if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
michael@0 1854 # Allow the use of GNU shtool's install command.
michael@0 1855 $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
michael@0 1856 # Aesthetically quote it.
michael@0 1857 func_quote_for_eval "$nonopt"
michael@0 1858 install_prog="$func_quote_for_eval_result "
michael@0 1859 arg=$1
michael@0 1860 shift
michael@0 1861 else
michael@0 1862 install_prog=
michael@0 1863 arg=$nonopt
michael@0 1864 fi
michael@0 1865
michael@0 1866 # The real first argument should be the name of the installation program.
michael@0 1867 # Aesthetically quote it.
michael@0 1868 func_quote_for_eval "$arg"
michael@0 1869 install_prog="$install_prog$func_quote_for_eval_result"
michael@0 1870
michael@0 1871 # We need to accept at least all the BSD install flags.
michael@0 1872 dest=
michael@0 1873 files=
michael@0 1874 opts=
michael@0 1875 prev=
michael@0 1876 install_type=
michael@0 1877 isdir=no
michael@0 1878 stripme=
michael@0 1879 for arg
michael@0 1880 do
michael@0 1881 if test -n "$dest"; then
michael@0 1882 files="$files $dest"
michael@0 1883 dest=$arg
michael@0 1884 continue
michael@0 1885 fi
michael@0 1886
michael@0 1887 case $arg in
michael@0 1888 -d) isdir=yes ;;
michael@0 1889 -f)
michael@0 1890 case " $install_prog " in
michael@0 1891 *[\\\ /]cp\ *) ;;
michael@0 1892 *) prev=$arg ;;
michael@0 1893 esac
michael@0 1894 ;;
michael@0 1895 -g | -m | -o)
michael@0 1896 prev=$arg
michael@0 1897 ;;
michael@0 1898 -s)
michael@0 1899 stripme=" -s"
michael@0 1900 continue
michael@0 1901 ;;
michael@0 1902 -*)
michael@0 1903 ;;
michael@0 1904 *)
michael@0 1905 # If the previous option needed an argument, then skip it.
michael@0 1906 if test -n "$prev"; then
michael@0 1907 prev=
michael@0 1908 else
michael@0 1909 dest=$arg
michael@0 1910 continue
michael@0 1911 fi
michael@0 1912 ;;
michael@0 1913 esac
michael@0 1914
michael@0 1915 # Aesthetically quote the argument.
michael@0 1916 func_quote_for_eval "$arg"
michael@0 1917 install_prog="$install_prog $func_quote_for_eval_result"
michael@0 1918 done
michael@0 1919
michael@0 1920 test -z "$install_prog" && \
michael@0 1921 func_fatal_help "you must specify an install program"
michael@0 1922
michael@0 1923 test -n "$prev" && \
michael@0 1924 func_fatal_help "the \`$prev' option requires an argument"
michael@0 1925
michael@0 1926 if test -z "$files"; then
michael@0 1927 if test -z "$dest"; then
michael@0 1928 func_fatal_help "no file or destination specified"
michael@0 1929 else
michael@0 1930 func_fatal_help "you must specify a destination"
michael@0 1931 fi
michael@0 1932 fi
michael@0 1933
michael@0 1934 # Strip any trailing slash from the destination.
michael@0 1935 func_stripname '' '/' "$dest"
michael@0 1936 dest=$func_stripname_result
michael@0 1937
michael@0 1938 # Check to see that the destination is a directory.
michael@0 1939 test -d "$dest" && isdir=yes
michael@0 1940 if test "$isdir" = yes; then
michael@0 1941 destdir="$dest"
michael@0 1942 destname=
michael@0 1943 else
michael@0 1944 func_dirname_and_basename "$dest" "" "."
michael@0 1945 destdir="$func_dirname_result"
michael@0 1946 destname="$func_basename_result"
michael@0 1947
michael@0 1948 # Not a directory, so check to see that there is only one file specified.
michael@0 1949 set dummy $files; shift
michael@0 1950 test "$#" -gt 1 && \
michael@0 1951 func_fatal_help "\`$dest' is not a directory"
michael@0 1952 fi
michael@0 1953 case $destdir in
michael@0 1954 [\\/]* | [A-Za-z]:[\\/]*) ;;
michael@0 1955 *)
michael@0 1956 for file in $files; do
michael@0 1957 case $file in
michael@0 1958 *.lo) ;;
michael@0 1959 *)
michael@0 1960 func_fatal_help "\`$destdir' must be an absolute directory name"
michael@0 1961 ;;
michael@0 1962 esac
michael@0 1963 done
michael@0 1964 ;;
michael@0 1965 esac
michael@0 1966
michael@0 1967 # This variable tells wrapper scripts just to set variables rather
michael@0 1968 # than running their programs.
michael@0 1969 libtool_install_magic="$magic"
michael@0 1970
michael@0 1971 staticlibs=
michael@0 1972 future_libdirs=
michael@0 1973 current_libdirs=
michael@0 1974 for file in $files; do
michael@0 1975
michael@0 1976 # Do each installation.
michael@0 1977 case $file in
michael@0 1978 *.$libext)
michael@0 1979 # Do the static libraries later.
michael@0 1980 staticlibs="$staticlibs $file"
michael@0 1981 ;;
michael@0 1982
michael@0 1983 *.la)
michael@0 1984 # Check to see that this really is a libtool archive.
michael@0 1985 func_lalib_unsafe_p "$file" \
michael@0 1986 || func_fatal_help "\`$file' is not a valid libtool archive"
michael@0 1987
michael@0 1988 library_names=
michael@0 1989 old_library=
michael@0 1990 relink_command=
michael@0 1991 func_source "$file"
michael@0 1992
michael@0 1993 # Add the libdir to current_libdirs if it is the destination.
michael@0 1994 if test "X$destdir" = "X$libdir"; then
michael@0 1995 case "$current_libdirs " in
michael@0 1996 *" $libdir "*) ;;
michael@0 1997 *) current_libdirs="$current_libdirs $libdir" ;;
michael@0 1998 esac
michael@0 1999 else
michael@0 2000 # Note the libdir as a future libdir.
michael@0 2001 case "$future_libdirs " in
michael@0 2002 *" $libdir "*) ;;
michael@0 2003 *) future_libdirs="$future_libdirs $libdir" ;;
michael@0 2004 esac
michael@0 2005 fi
michael@0 2006
michael@0 2007 func_dirname "$file" "/" ""
michael@0 2008 dir="$func_dirname_result"
michael@0 2009 dir="$dir$objdir"
michael@0 2010
michael@0 2011 if test -n "$relink_command"; then
michael@0 2012 # Determine the prefix the user has applied to our future dir.
michael@0 2013 inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
michael@0 2014
michael@0 2015 # Don't allow the user to place us outside of our expected
michael@0 2016 # location b/c this prevents finding dependent libraries that
michael@0 2017 # are installed to the same prefix.
michael@0 2018 # At present, this check doesn't affect windows .dll's that
michael@0 2019 # are installed into $libdir/../bin (currently, that works fine)
michael@0 2020 # but it's something to keep an eye on.
michael@0 2021 test "$inst_prefix_dir" = "$destdir" && \
michael@0 2022 func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
michael@0 2023
michael@0 2024 if test -n "$inst_prefix_dir"; then
michael@0 2025 # Stick the inst_prefix_dir data into the link command.
michael@0 2026 relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
michael@0 2027 else
michael@0 2028 relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
michael@0 2029 fi
michael@0 2030
michael@0 2031 func_warning "relinking \`$file'"
michael@0 2032 func_show_eval "$relink_command" \
michael@0 2033 'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
michael@0 2034 fi
michael@0 2035
michael@0 2036 # See the names of the shared library.
michael@0 2037 set dummy $library_names; shift
michael@0 2038 if test -n "$1"; then
michael@0 2039 realname="$1"
michael@0 2040 shift
michael@0 2041
michael@0 2042 srcname="$realname"
michael@0 2043 test -n "$relink_command" && srcname="$realname"T
michael@0 2044
michael@0 2045 # Install the shared library and build the symlinks.
michael@0 2046 func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
michael@0 2047 'exit $?'
michael@0 2048 tstripme="$stripme"
michael@0 2049 case $host_os in
michael@0 2050 cygwin* | mingw* | pw32* | cegcc*)
michael@0 2051 case $realname in
michael@0 2052 *.dll.a)
michael@0 2053 tstripme=""
michael@0 2054 ;;
michael@0 2055 esac
michael@0 2056 ;;
michael@0 2057 esac
michael@0 2058 if test -n "$tstripme" && test -n "$striplib"; then
michael@0 2059 func_show_eval "$striplib $destdir/$realname" 'exit $?'
michael@0 2060 fi
michael@0 2061
michael@0 2062 if test "$#" -gt 0; then
michael@0 2063 # Delete the old symlinks, and create new ones.
michael@0 2064 # Try `ln -sf' first, because the `ln' binary might depend on
michael@0 2065 # the symlink we replace! Solaris /bin/ln does not understand -f,
michael@0 2066 # so we also need to try rm && ln -s.
michael@0 2067 for linkname
michael@0 2068 do
michael@0 2069 test "$linkname" != "$realname" \
michael@0 2070 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
michael@0 2071 done
michael@0 2072 fi
michael@0 2073
michael@0 2074 # Do each command in the postinstall commands.
michael@0 2075 lib="$destdir/$realname"
michael@0 2076 func_execute_cmds "$postinstall_cmds" 'exit $?'
michael@0 2077 fi
michael@0 2078
michael@0 2079 # Install the pseudo-library for information purposes.
michael@0 2080 func_basename "$file"
michael@0 2081 name="$func_basename_result"
michael@0 2082 instname="$dir/$name"i
michael@0 2083 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
michael@0 2084
michael@0 2085 # Maybe install the static library, too.
michael@0 2086 test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
michael@0 2087 ;;
michael@0 2088
michael@0 2089 *.lo)
michael@0 2090 # Install (i.e. copy) a libtool object.
michael@0 2091
michael@0 2092 # Figure out destination file name, if it wasn't already specified.
michael@0 2093 if test -n "$destname"; then
michael@0 2094 destfile="$destdir/$destname"
michael@0 2095 else
michael@0 2096 func_basename "$file"
michael@0 2097 destfile="$func_basename_result"
michael@0 2098 destfile="$destdir/$destfile"
michael@0 2099 fi
michael@0 2100
michael@0 2101 # Deduce the name of the destination old-style object file.
michael@0 2102 case $destfile in
michael@0 2103 *.lo)
michael@0 2104 func_lo2o "$destfile"
michael@0 2105 staticdest=$func_lo2o_result
michael@0 2106 ;;
michael@0 2107 *.$objext)
michael@0 2108 staticdest="$destfile"
michael@0 2109 destfile=
michael@0 2110 ;;
michael@0 2111 *)
michael@0 2112 func_fatal_help "cannot copy a libtool object to \`$destfile'"
michael@0 2113 ;;
michael@0 2114 esac
michael@0 2115
michael@0 2116 # Install the libtool object if requested.
michael@0 2117 test -n "$destfile" && \
michael@0 2118 func_show_eval "$install_prog $file $destfile" 'exit $?'
michael@0 2119
michael@0 2120 # Install the old object if enabled.
michael@0 2121 if test "$build_old_libs" = yes; then
michael@0 2122 # Deduce the name of the old-style object file.
michael@0 2123 func_lo2o "$file"
michael@0 2124 staticobj=$func_lo2o_result
michael@0 2125 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
michael@0 2126 fi
michael@0 2127 exit $EXIT_SUCCESS
michael@0 2128 ;;
michael@0 2129
michael@0 2130 *)
michael@0 2131 # Figure out destination file name, if it wasn't already specified.
michael@0 2132 if test -n "$destname"; then
michael@0 2133 destfile="$destdir/$destname"
michael@0 2134 else
michael@0 2135 func_basename "$file"
michael@0 2136 destfile="$func_basename_result"
michael@0 2137 destfile="$destdir/$destfile"
michael@0 2138 fi
michael@0 2139
michael@0 2140 # If the file is missing, and there is a .exe on the end, strip it
michael@0 2141 # because it is most likely a libtool script we actually want to
michael@0 2142 # install
michael@0 2143 stripped_ext=""
michael@0 2144 case $file in
michael@0 2145 *.exe)
michael@0 2146 if test ! -f "$file"; then
michael@0 2147 func_stripname '' '.exe' "$file"
michael@0 2148 file=$func_stripname_result
michael@0 2149 stripped_ext=".exe"
michael@0 2150 fi
michael@0 2151 ;;
michael@0 2152 esac
michael@0 2153
michael@0 2154 # Do a test to see if this is really a libtool program.
michael@0 2155 case $host in
michael@0 2156 *cygwin* | *mingw*)
michael@0 2157 if func_ltwrapper_executable_p "$file"; then
michael@0 2158 func_ltwrapper_scriptname "$file"
michael@0 2159 wrapper=$func_ltwrapper_scriptname_result
michael@0 2160 else
michael@0 2161 func_stripname '' '.exe' "$file"
michael@0 2162 wrapper=$func_stripname_result
michael@0 2163 fi
michael@0 2164 ;;
michael@0 2165 *)
michael@0 2166 wrapper=$file
michael@0 2167 ;;
michael@0 2168 esac
michael@0 2169 if func_ltwrapper_script_p "$wrapper"; then
michael@0 2170 notinst_deplibs=
michael@0 2171 relink_command=
michael@0 2172
michael@0 2173 func_source "$wrapper"
michael@0 2174
michael@0 2175 # Check the variables that should have been set.
michael@0 2176 test -z "$generated_by_libtool_version" && \
michael@0 2177 func_fatal_error "invalid libtool wrapper script \`$wrapper'"
michael@0 2178
michael@0 2179 finalize=yes
michael@0 2180 for lib in $notinst_deplibs; do
michael@0 2181 # Check to see that each library is installed.
michael@0 2182 libdir=
michael@0 2183 if test -f "$lib"; then
michael@0 2184 func_source "$lib"
michael@0 2185 fi
michael@0 2186 libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
michael@0 2187 if test -n "$libdir" && test ! -f "$libfile"; then
michael@0 2188 func_warning "\`$lib' has not been installed in \`$libdir'"
michael@0 2189 finalize=no
michael@0 2190 fi
michael@0 2191 done
michael@0 2192
michael@0 2193 relink_command=
michael@0 2194 func_source "$wrapper"
michael@0 2195
michael@0 2196 outputname=
michael@0 2197 if test "$fast_install" = no && test -n "$relink_command"; then
michael@0 2198 $opt_dry_run || {
michael@0 2199 if test "$finalize" = yes; then
michael@0 2200 tmpdir=`func_mktempdir`
michael@0 2201 func_basename "$file$stripped_ext"
michael@0 2202 file="$func_basename_result"
michael@0 2203 outputname="$tmpdir/$file"
michael@0 2204 # Replace the output file specification.
michael@0 2205 relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
michael@0 2206
michael@0 2207 $opt_silent || {
michael@0 2208 func_quote_for_expand "$relink_command"
michael@0 2209 eval "func_echo $func_quote_for_expand_result"
michael@0 2210 }
michael@0 2211 if eval "$relink_command"; then :
michael@0 2212 else
michael@0 2213 func_error "error: relink \`$file' with the above command before installing it"
michael@0 2214 $opt_dry_run || ${RM}r "$tmpdir"
michael@0 2215 continue
michael@0 2216 fi
michael@0 2217 file="$outputname"
michael@0 2218 else
michael@0 2219 func_warning "cannot relink \`$file'"
michael@0 2220 fi
michael@0 2221 }
michael@0 2222 else
michael@0 2223 # Install the binary that we compiled earlier.
michael@0 2224 file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
michael@0 2225 fi
michael@0 2226 fi
michael@0 2227
michael@0 2228 # remove .exe since cygwin /usr/bin/install will append another
michael@0 2229 # one anyway
michael@0 2230 case $install_prog,$host in
michael@0 2231 */usr/bin/install*,*cygwin*)
michael@0 2232 case $file:$destfile in
michael@0 2233 *.exe:*.exe)
michael@0 2234 # this is ok
michael@0 2235 ;;
michael@0 2236 *.exe:*)
michael@0 2237 destfile=$destfile.exe
michael@0 2238 ;;
michael@0 2239 *:*.exe)
michael@0 2240 func_stripname '' '.exe' "$destfile"
michael@0 2241 destfile=$func_stripname_result
michael@0 2242 ;;
michael@0 2243 esac
michael@0 2244 ;;
michael@0 2245 esac
michael@0 2246 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
michael@0 2247 $opt_dry_run || if test -n "$outputname"; then
michael@0 2248 ${RM}r "$tmpdir"
michael@0 2249 fi
michael@0 2250 ;;
michael@0 2251 esac
michael@0 2252 done
michael@0 2253
michael@0 2254 for file in $staticlibs; do
michael@0 2255 func_basename "$file"
michael@0 2256 name="$func_basename_result"
michael@0 2257
michael@0 2258 # Set up the ranlib parameters.
michael@0 2259 oldlib="$destdir/$name"
michael@0 2260
michael@0 2261 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
michael@0 2262
michael@0 2263 if test -n "$stripme" && test -n "$old_striplib"; then
michael@0 2264 func_show_eval "$old_striplib $oldlib" 'exit $?'
michael@0 2265 fi
michael@0 2266
michael@0 2267 # Do each command in the postinstall commands.
michael@0 2268 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
michael@0 2269 done
michael@0 2270
michael@0 2271 test -n "$future_libdirs" && \
michael@0 2272 func_warning "remember to run \`$progname --finish$future_libdirs'"
michael@0 2273
michael@0 2274 if test -n "$current_libdirs"; then
michael@0 2275 # Maybe just do a dry run.
michael@0 2276 $opt_dry_run && current_libdirs=" -n$current_libdirs"
michael@0 2277 exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
michael@0 2278 else
michael@0 2279 exit $EXIT_SUCCESS
michael@0 2280 fi
michael@0 2281 }
michael@0 2282
michael@0 2283 test "$mode" = install && func_mode_install ${1+"$@"}
michael@0 2284
michael@0 2285
michael@0 2286 # func_generate_dlsyms outputname originator pic_p
michael@0 2287 # Extract symbols from dlprefiles and create ${outputname}S.o with
michael@0 2288 # a dlpreopen symbol table.
michael@0 2289 func_generate_dlsyms ()
michael@0 2290 {
michael@0 2291 $opt_debug
michael@0 2292 my_outputname="$1"
michael@0 2293 my_originator="$2"
michael@0 2294 my_pic_p="${3-no}"
michael@0 2295 my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
michael@0 2296 my_dlsyms=
michael@0 2297
michael@0 2298 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
michael@0 2299 if test -n "$NM" && test -n "$global_symbol_pipe"; then
michael@0 2300 my_dlsyms="${my_outputname}S.c"
michael@0 2301 else
michael@0 2302 func_error "not configured to extract global symbols from dlpreopened files"
michael@0 2303 fi
michael@0 2304 fi
michael@0 2305
michael@0 2306 if test -n "$my_dlsyms"; then
michael@0 2307 case $my_dlsyms in
michael@0 2308 "") ;;
michael@0 2309 *.c)
michael@0 2310 # Discover the nlist of each of the dlfiles.
michael@0 2311 nlist="$output_objdir/${my_outputname}.nm"
michael@0 2312
michael@0 2313 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
michael@0 2314
michael@0 2315 # Parse the name list into a source file.
michael@0 2316 func_verbose "creating $output_objdir/$my_dlsyms"
michael@0 2317
michael@0 2318 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
michael@0 2319 /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
michael@0 2320 /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
michael@0 2321
michael@0 2322 #ifdef __cplusplus
michael@0 2323 extern \"C\" {
michael@0 2324 #endif
michael@0 2325
michael@0 2326 /* External symbol declarations for the compiler. */\
michael@0 2327 "
michael@0 2328
michael@0 2329 if test "$dlself" = yes; then
michael@0 2330 func_verbose "generating symbol list for \`$output'"
michael@0 2331
michael@0 2332 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
michael@0 2333
michael@0 2334 # Add our own program objects to the symbol list.
michael@0 2335 progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
michael@0 2336 for progfile in $progfiles; do
michael@0 2337 func_verbose "extracting global C symbols from \`$progfile'"
michael@0 2338 $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
michael@0 2339 done
michael@0 2340
michael@0 2341 if test -n "$exclude_expsyms"; then
michael@0 2342 $opt_dry_run || {
michael@0 2343 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
michael@0 2344 eval '$MV "$nlist"T "$nlist"'
michael@0 2345 }
michael@0 2346 fi
michael@0 2347
michael@0 2348 if test -n "$export_symbols_regex"; then
michael@0 2349 $opt_dry_run || {
michael@0 2350 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
michael@0 2351 eval '$MV "$nlist"T "$nlist"'
michael@0 2352 }
michael@0 2353 fi
michael@0 2354
michael@0 2355 # Prepare the list of exported symbols
michael@0 2356 if test -z "$export_symbols"; then
michael@0 2357 export_symbols="$output_objdir/$outputname.exp"
michael@0 2358 $opt_dry_run || {
michael@0 2359 $RM $export_symbols
michael@0 2360 eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
michael@0 2361 case $host in
michael@0 2362 *cygwin* | *mingw* | *cegcc* )
michael@0 2363 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
michael@0 2364 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
michael@0 2365 ;;
michael@0 2366 esac
michael@0 2367 }
michael@0 2368 else
michael@0 2369 $opt_dry_run || {
michael@0 2370 eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
michael@0 2371 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
michael@0 2372 eval '$MV "$nlist"T "$nlist"'
michael@0 2373 case $host in
michael@0 2374 *cygwin | *mingw* | *cegcc* )
michael@0 2375 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
michael@0 2376 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
michael@0 2377 ;;
michael@0 2378 esac
michael@0 2379 }
michael@0 2380 fi
michael@0 2381 fi
michael@0 2382
michael@0 2383 for dlprefile in $dlprefiles; do
michael@0 2384 func_verbose "extracting global C symbols from \`$dlprefile'"
michael@0 2385 func_basename "$dlprefile"
michael@0 2386 name="$func_basename_result"
michael@0 2387 $opt_dry_run || {
michael@0 2388 eval '$ECHO ": $name " >> "$nlist"'
michael@0 2389 eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
michael@0 2390 }
michael@0 2391 done
michael@0 2392
michael@0 2393 $opt_dry_run || {
michael@0 2394 # Make sure we have at least an empty file.
michael@0 2395 test -f "$nlist" || : > "$nlist"
michael@0 2396
michael@0 2397 if test -n "$exclude_expsyms"; then
michael@0 2398 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
michael@0 2399 $MV "$nlist"T "$nlist"
michael@0 2400 fi
michael@0 2401
michael@0 2402 # Try sorting and uniquifying the output.
michael@0 2403 if $GREP -v "^: " < "$nlist" |
michael@0 2404 if sort -k 3 </dev/null >/dev/null 2>&1; then
michael@0 2405 sort -k 3
michael@0 2406 else
michael@0 2407 sort +2
michael@0 2408 fi |
michael@0 2409 uniq > "$nlist"S; then
michael@0 2410 :
michael@0 2411 else
michael@0 2412 $GREP -v "^: " < "$nlist" > "$nlist"S
michael@0 2413 fi
michael@0 2414
michael@0 2415 if test -f "$nlist"S; then
michael@0 2416 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
michael@0 2417 else
michael@0 2418 $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
michael@0 2419 fi
michael@0 2420
michael@0 2421 $ECHO >> "$output_objdir/$my_dlsyms" "\
michael@0 2422
michael@0 2423 /* The mapping between symbol names and symbols. */
michael@0 2424 typedef struct {
michael@0 2425 const char *name;
michael@0 2426 void *address;
michael@0 2427 } lt_dlsymlist;
michael@0 2428 "
michael@0 2429 case $host in
michael@0 2430 *cygwin* | *mingw* | *cegcc* )
michael@0 2431 $ECHO >> "$output_objdir/$my_dlsyms" "\
michael@0 2432 /* DATA imports from DLLs on WIN32 con't be const, because
michael@0 2433 runtime relocations are performed -- see ld's documentation
michael@0 2434 on pseudo-relocs. */"
michael@0 2435 lt_dlsym_const= ;;
michael@0 2436 *osf5*)
michael@0 2437 echo >> "$output_objdir/$my_dlsyms" "\
michael@0 2438 /* This system does not cope well with relocations in const data */"
michael@0 2439 lt_dlsym_const= ;;
michael@0 2440 *)
michael@0 2441 lt_dlsym_const=const ;;
michael@0 2442 esac
michael@0 2443
michael@0 2444 $ECHO >> "$output_objdir/$my_dlsyms" "\
michael@0 2445 extern $lt_dlsym_const lt_dlsymlist
michael@0 2446 lt_${my_prefix}_LTX_preloaded_symbols[];
michael@0 2447 $lt_dlsym_const lt_dlsymlist
michael@0 2448 lt_${my_prefix}_LTX_preloaded_symbols[] =
michael@0 2449 {\
michael@0 2450 { \"$my_originator\", (void *) 0 },"
michael@0 2451
michael@0 2452 case $need_lib_prefix in
michael@0 2453 no)
michael@0 2454 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
michael@0 2455 ;;
michael@0 2456 *)
michael@0 2457 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
michael@0 2458 ;;
michael@0 2459 esac
michael@0 2460 $ECHO >> "$output_objdir/$my_dlsyms" "\
michael@0 2461 {0, (void *) 0}
michael@0 2462 };
michael@0 2463
michael@0 2464 /* This works around a problem in FreeBSD linker */
michael@0 2465 #ifdef FREEBSD_WORKAROUND
michael@0 2466 static const void *lt_preloaded_setup() {
michael@0 2467 return lt_${my_prefix}_LTX_preloaded_symbols;
michael@0 2468 }
michael@0 2469 #endif
michael@0 2470
michael@0 2471 #ifdef __cplusplus
michael@0 2472 }
michael@0 2473 #endif\
michael@0 2474 "
michael@0 2475 } # !$opt_dry_run
michael@0 2476
michael@0 2477 pic_flag_for_symtable=
michael@0 2478 case "$compile_command " in
michael@0 2479 *" -static "*) ;;
michael@0 2480 *)
michael@0 2481 case $host in
michael@0 2482 # compiling the symbol table file with pic_flag works around
michael@0 2483 # a FreeBSD bug that causes programs to crash when -lm is
michael@0 2484 # linked before any other PIC object. But we must not use
michael@0 2485 # pic_flag when linking with -static. The problem exists in
michael@0 2486 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
michael@0 2487 *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
michael@0 2488 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
michael@0 2489 *-*-hpux*)
michael@0 2490 pic_flag_for_symtable=" $pic_flag" ;;
michael@0 2491 *)
michael@0 2492 if test "X$my_pic_p" != Xno; then
michael@0 2493 pic_flag_for_symtable=" $pic_flag"
michael@0 2494 fi
michael@0 2495 ;;
michael@0 2496 esac
michael@0 2497 ;;
michael@0 2498 esac
michael@0 2499 symtab_cflags=
michael@0 2500 for arg in $LTCFLAGS; do
michael@0 2501 case $arg in
michael@0 2502 -pie | -fpie | -fPIE) ;;
michael@0 2503 *) symtab_cflags="$symtab_cflags $arg" ;;
michael@0 2504 esac
michael@0 2505 done
michael@0 2506
michael@0 2507 # Now compile the dynamic symbol file.
michael@0 2508 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
michael@0 2509
michael@0 2510 # Clean up the generated files.
michael@0 2511 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
michael@0 2512
michael@0 2513 # Transform the symbol file into the correct name.
michael@0 2514 symfileobj="$output_objdir/${my_outputname}S.$objext"
michael@0 2515 case $host in
michael@0 2516 *cygwin* | *mingw* | *cegcc* )
michael@0 2517 if test -f "$output_objdir/$my_outputname.def"; then
michael@0 2518 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
michael@0 2519 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
michael@0 2520 else
michael@0 2521 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
michael@0 2522 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
michael@0 2523 fi
michael@0 2524 ;;
michael@0 2525 *)
michael@0 2526 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
michael@0 2527 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
michael@0 2528 ;;
michael@0 2529 esac
michael@0 2530 ;;
michael@0 2531 *)
michael@0 2532 func_fatal_error "unknown suffix for \`$my_dlsyms'"
michael@0 2533 ;;
michael@0 2534 esac
michael@0 2535 else
michael@0 2536 # We keep going just in case the user didn't refer to
michael@0 2537 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
michael@0 2538 # really was required.
michael@0 2539
michael@0 2540 # Nullify the symbol file.
michael@0 2541 compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
michael@0 2542 finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
michael@0 2543 fi
michael@0 2544 }
michael@0 2545
michael@0 2546 # func_win32_libid arg
michael@0 2547 # return the library type of file 'arg'
michael@0 2548 #
michael@0 2549 # Need a lot of goo to handle *both* DLLs and import libs
michael@0 2550 # Has to be a shell function in order to 'eat' the argument
michael@0 2551 # that is supplied when $file_magic_command is called.
michael@0 2552 func_win32_libid ()
michael@0 2553 {
michael@0 2554 $opt_debug
michael@0 2555 win32_libid_type="unknown"
michael@0 2556 win32_fileres=`file -L $1 2>/dev/null`
michael@0 2557 case $win32_fileres in
michael@0 2558 *ar\ archive\ import\ library*) # definitely import
michael@0 2559 win32_libid_type="x86 archive import"
michael@0 2560 ;;
michael@0 2561 *ar\ archive*) # could be an import, or static
michael@0 2562 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
michael@0 2563 $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
michael@0 2564 win32_nmres=`eval $NM -f posix -A $1 |
michael@0 2565 $SED -n -e '
michael@0 2566 1,100{
michael@0 2567 / I /{
michael@0 2568 s,.*,import,
michael@0 2569 p
michael@0 2570 q
michael@0 2571 }
michael@0 2572 }'`
michael@0 2573 case $win32_nmres in
michael@0 2574 import*) win32_libid_type="x86 archive import";;
michael@0 2575 *) win32_libid_type="x86 archive static";;
michael@0 2576 esac
michael@0 2577 fi
michael@0 2578 ;;
michael@0 2579 *DLL*)
michael@0 2580 win32_libid_type="x86 DLL"
michael@0 2581 ;;
michael@0 2582 *executable*) # but shell scripts are "executable" too...
michael@0 2583 case $win32_fileres in
michael@0 2584 *MS\ Windows\ PE\ Intel*)
michael@0 2585 win32_libid_type="x86 DLL"
michael@0 2586 ;;
michael@0 2587 esac
michael@0 2588 ;;
michael@0 2589 esac
michael@0 2590 $ECHO "$win32_libid_type"
michael@0 2591 }
michael@0 2592
michael@0 2593
michael@0 2594
michael@0 2595 # func_extract_an_archive dir oldlib
michael@0 2596 func_extract_an_archive ()
michael@0 2597 {
michael@0 2598 $opt_debug
michael@0 2599 f_ex_an_ar_dir="$1"; shift
michael@0 2600 f_ex_an_ar_oldlib="$1"
michael@0 2601 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
michael@0 2602 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
michael@0 2603 :
michael@0 2604 else
michael@0 2605 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
michael@0 2606 fi
michael@0 2607 }
michael@0 2608
michael@0 2609
michael@0 2610 # func_extract_archives gentop oldlib ...
michael@0 2611 func_extract_archives ()
michael@0 2612 {
michael@0 2613 $opt_debug
michael@0 2614 my_gentop="$1"; shift
michael@0 2615 my_oldlibs=${1+"$@"}
michael@0 2616 my_oldobjs=""
michael@0 2617 my_xlib=""
michael@0 2618 my_xabs=""
michael@0 2619 my_xdir=""
michael@0 2620
michael@0 2621 for my_xlib in $my_oldlibs; do
michael@0 2622 # Extract the objects.
michael@0 2623 case $my_xlib in
michael@0 2624 [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
michael@0 2625 *) my_xabs=`pwd`"/$my_xlib" ;;
michael@0 2626 esac
michael@0 2627 func_basename "$my_xlib"
michael@0 2628 my_xlib="$func_basename_result"
michael@0 2629 my_xlib_u=$my_xlib
michael@0 2630 while :; do
michael@0 2631 case " $extracted_archives " in
michael@0 2632 *" $my_xlib_u "*)
michael@0 2633 func_arith $extracted_serial + 1
michael@0 2634 extracted_serial=$func_arith_result
michael@0 2635 my_xlib_u=lt$extracted_serial-$my_xlib ;;
michael@0 2636 *) break ;;
michael@0 2637 esac
michael@0 2638 done
michael@0 2639 extracted_archives="$extracted_archives $my_xlib_u"
michael@0 2640 my_xdir="$my_gentop/$my_xlib_u"
michael@0 2641
michael@0 2642 func_mkdir_p "$my_xdir"
michael@0 2643
michael@0 2644 case $host in
michael@0 2645 *-darwin*)
michael@0 2646 func_verbose "Extracting $my_xabs"
michael@0 2647 # Do not bother doing anything if just a dry run
michael@0 2648 $opt_dry_run || {
michael@0 2649 darwin_orig_dir=`pwd`
michael@0 2650 cd $my_xdir || exit $?
michael@0 2651 darwin_archive=$my_xabs
michael@0 2652 darwin_curdir=`pwd`
michael@0 2653 darwin_base_archive=`basename "$darwin_archive"`
michael@0 2654 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
michael@0 2655 if test -n "$darwin_arches"; then
michael@0 2656 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
michael@0 2657 darwin_arch=
michael@0 2658 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
michael@0 2659 for darwin_arch in $darwin_arches ; do
michael@0 2660 func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
michael@0 2661 $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
michael@0 2662 cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
michael@0 2663 func_extract_an_archive "`pwd`" "${darwin_base_archive}"
michael@0 2664 cd "$darwin_curdir"
michael@0 2665 $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
michael@0 2666 done # $darwin_arches
michael@0 2667 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
michael@0 2668 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
michael@0 2669 darwin_file=
michael@0 2670 darwin_files=
michael@0 2671 for darwin_file in $darwin_filelist; do
michael@0 2672 darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
michael@0 2673 $LIPO -create -output "$darwin_file" $darwin_files
michael@0 2674 done # $darwin_filelist
michael@0 2675 $RM -rf unfat-$$
michael@0 2676 cd "$darwin_orig_dir"
michael@0 2677 else
michael@0 2678 cd $darwin_orig_dir
michael@0 2679 func_extract_an_archive "$my_xdir" "$my_xabs"
michael@0 2680 fi # $darwin_arches
michael@0 2681 } # !$opt_dry_run
michael@0 2682 ;;
michael@0 2683 *)
michael@0 2684 func_extract_an_archive "$my_xdir" "$my_xabs"
michael@0 2685 ;;
michael@0 2686 esac
michael@0 2687 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
michael@0 2688 done
michael@0 2689
michael@0 2690 func_extract_archives_result="$my_oldobjs"
michael@0 2691 }
michael@0 2692
michael@0 2693
michael@0 2694
michael@0 2695 # func_emit_wrapper_part1 [arg=no]
michael@0 2696 #
michael@0 2697 # Emit the first part of a libtool wrapper script on stdout.
michael@0 2698 # For more information, see the description associated with
michael@0 2699 # func_emit_wrapper(), below.
michael@0 2700 func_emit_wrapper_part1 ()
michael@0 2701 {
michael@0 2702 func_emit_wrapper_part1_arg1=no
michael@0 2703 if test -n "$1" ; then
michael@0 2704 func_emit_wrapper_part1_arg1=$1
michael@0 2705 fi
michael@0 2706
michael@0 2707 $ECHO "\
michael@0 2708 #! $SHELL
michael@0 2709
michael@0 2710 # $output - temporary wrapper script for $objdir/$outputname
michael@0 2711 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
michael@0 2712 #
michael@0 2713 # The $output program cannot be directly executed until all the libtool
michael@0 2714 # libraries that it depends on are installed.
michael@0 2715 #
michael@0 2716 # This wrapper script should never be moved out of the build directory.
michael@0 2717 # If it is, it will not operate correctly.
michael@0 2718
michael@0 2719 # Sed substitution that helps us do robust quoting. It backslashifies
michael@0 2720 # metacharacters that are still active within double-quoted strings.
michael@0 2721 Xsed='${SED} -e 1s/^X//'
michael@0 2722 sed_quote_subst='$sed_quote_subst'
michael@0 2723
michael@0 2724 # Be Bourne compatible
michael@0 2725 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
michael@0 2726 emulate sh
michael@0 2727 NULLCMD=:
michael@0 2728 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
michael@0 2729 # is contrary to our usage. Disable this feature.
michael@0 2730 alias -g '\${1+\"\$@\"}'='\"\$@\"'
michael@0 2731 setopt NO_GLOB_SUBST
michael@0 2732 else
michael@0 2733 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
michael@0 2734 fi
michael@0 2735 BIN_SH=xpg4; export BIN_SH # for Tru64
michael@0 2736 DUALCASE=1; export DUALCASE # for MKS sh
michael@0 2737
michael@0 2738 # The HP-UX ksh and POSIX shell print the target directory to stdout
michael@0 2739 # if CDPATH is set.
michael@0 2740 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
michael@0 2741
michael@0 2742 relink_command=\"$relink_command\"
michael@0 2743
michael@0 2744 # This environment variable determines our operation mode.
michael@0 2745 if test \"\$libtool_install_magic\" = \"$magic\"; then
michael@0 2746 # install mode needs the following variables:
michael@0 2747 generated_by_libtool_version='$macro_version'
michael@0 2748 notinst_deplibs='$notinst_deplibs'
michael@0 2749 else
michael@0 2750 # When we are sourced in execute mode, \$file and \$ECHO are already set.
michael@0 2751 if test \"\$libtool_execute_magic\" != \"$magic\"; then
michael@0 2752 ECHO=\"$qecho\"
michael@0 2753 file=\"\$0\"
michael@0 2754 # Make sure echo works.
michael@0 2755 if test \"X\$1\" = X--no-reexec; then
michael@0 2756 # Discard the --no-reexec flag, and continue.
michael@0 2757 shift
michael@0 2758 elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
michael@0 2759 # Yippee, \$ECHO works!
michael@0 2760 :
michael@0 2761 else
michael@0 2762 # Restart under the correct shell, and then maybe \$ECHO will work.
michael@0 2763 exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
michael@0 2764 fi
michael@0 2765 fi\
michael@0 2766 "
michael@0 2767 $ECHO "\
michael@0 2768
michael@0 2769 # Find the directory that this script lives in.
michael@0 2770 thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
michael@0 2771 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
michael@0 2772
michael@0 2773 # Follow symbolic links until we get to the real thisdir.
michael@0 2774 file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
michael@0 2775 while test -n \"\$file\"; do
michael@0 2776 destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
michael@0 2777
michael@0 2778 # If there was a directory component, then change thisdir.
michael@0 2779 if test \"x\$destdir\" != \"x\$file\"; then
michael@0 2780 case \"\$destdir\" in
michael@0 2781 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
michael@0 2782 *) thisdir=\"\$thisdir/\$destdir\" ;;
michael@0 2783 esac
michael@0 2784 fi
michael@0 2785
michael@0 2786 file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
michael@0 2787 file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
michael@0 2788 done
michael@0 2789 "
michael@0 2790 }
michael@0 2791 # end: func_emit_wrapper_part1
michael@0 2792
michael@0 2793 # func_emit_wrapper_part2 [arg=no]
michael@0 2794 #
michael@0 2795 # Emit the second part of a libtool wrapper script on stdout.
michael@0 2796 # For more information, see the description associated with
michael@0 2797 # func_emit_wrapper(), below.
michael@0 2798 func_emit_wrapper_part2 ()
michael@0 2799 {
michael@0 2800 func_emit_wrapper_part2_arg1=no
michael@0 2801 if test -n "$1" ; then
michael@0 2802 func_emit_wrapper_part2_arg1=$1
michael@0 2803 fi
michael@0 2804
michael@0 2805 $ECHO "\
michael@0 2806
michael@0 2807 # Usually 'no', except on cygwin/mingw when embedded into
michael@0 2808 # the cwrapper.
michael@0 2809 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
michael@0 2810 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
michael@0 2811 # special case for '.'
michael@0 2812 if test \"\$thisdir\" = \".\"; then
michael@0 2813 thisdir=\`pwd\`
michael@0 2814 fi
michael@0 2815 # remove .libs from thisdir
michael@0 2816 case \"\$thisdir\" in
michael@0 2817 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
michael@0 2818 $objdir ) thisdir=. ;;
michael@0 2819 esac
michael@0 2820 fi
michael@0 2821
michael@0 2822 # Try to get the absolute directory name.
michael@0 2823 absdir=\`cd \"\$thisdir\" && pwd\`
michael@0 2824 test -n \"\$absdir\" && thisdir=\"\$absdir\"
michael@0 2825 "
michael@0 2826
michael@0 2827 if test "$fast_install" = yes; then
michael@0 2828 $ECHO "\
michael@0 2829 program=lt-'$outputname'$exeext
michael@0 2830 progdir=\"\$thisdir/$objdir\"
michael@0 2831
michael@0 2832 if test ! -f \"\$progdir/\$program\" ||
michael@0 2833 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
michael@0 2834 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
michael@0 2835
michael@0 2836 file=\"\$\$-\$program\"
michael@0 2837
michael@0 2838 if test ! -d \"\$progdir\"; then
michael@0 2839 $MKDIR \"\$progdir\"
michael@0 2840 else
michael@0 2841 $RM \"\$progdir/\$file\"
michael@0 2842 fi"
michael@0 2843
michael@0 2844 $ECHO "\
michael@0 2845
michael@0 2846 # relink executable if necessary
michael@0 2847 if test -n \"\$relink_command\"; then
michael@0 2848 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
michael@0 2849 else
michael@0 2850 $ECHO \"\$relink_command_output\" >&2
michael@0 2851 $RM \"\$progdir/\$file\"
michael@0 2852 exit 1
michael@0 2853 fi
michael@0 2854 fi
michael@0 2855
michael@0 2856 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
michael@0 2857 { $RM \"\$progdir/\$program\";
michael@0 2858 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
michael@0 2859 $RM \"\$progdir/\$file\"
michael@0 2860 fi"
michael@0 2861 else
michael@0 2862 $ECHO "\
michael@0 2863 program='$outputname'
michael@0 2864 progdir=\"\$thisdir/$objdir\"
michael@0 2865 "
michael@0 2866 fi
michael@0 2867
michael@0 2868 $ECHO "\
michael@0 2869
michael@0 2870 if test -f \"\$progdir/\$program\"; then"
michael@0 2871
michael@0 2872 # Export our shlibpath_var if we have one.
michael@0 2873 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
michael@0 2874 $ECHO "\
michael@0 2875 # Add our own library path to $shlibpath_var
michael@0 2876 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
michael@0 2877
michael@0 2878 # Some systems cannot cope with colon-terminated $shlibpath_var
michael@0 2879 # The second colon is a workaround for a bug in BeOS R4 sed
michael@0 2880 $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
michael@0 2881
michael@0 2882 export $shlibpath_var
michael@0 2883 "
michael@0 2884 fi
michael@0 2885
michael@0 2886 # fixup the dll searchpath if we need to.
michael@0 2887 if test -n "$dllsearchpath"; then
michael@0 2888 $ECHO "\
michael@0 2889 # Add the dll search path components to the executable PATH
michael@0 2890 PATH=$dllsearchpath:\$PATH
michael@0 2891 "
michael@0 2892 fi
michael@0 2893
michael@0 2894 $ECHO "\
michael@0 2895 if test \"\$libtool_execute_magic\" != \"$magic\"; then
michael@0 2896 # Run the actual program with our arguments.
michael@0 2897 "
michael@0 2898 case $host in
michael@0 2899 # Backslashes separate directories on plain windows
michael@0 2900 *-*-mingw | *-*-os2* | *-cegcc*)
michael@0 2901 $ECHO "\
michael@0 2902 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
michael@0 2903 "
michael@0 2904 ;;
michael@0 2905
michael@0 2906 *)
michael@0 2907 $ECHO "\
michael@0 2908 exec \"\$progdir/\$program\" \${1+\"\$@\"}
michael@0 2909 "
michael@0 2910 ;;
michael@0 2911 esac
michael@0 2912 $ECHO "\
michael@0 2913 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
michael@0 2914 exit 1
michael@0 2915 fi
michael@0 2916 else
michael@0 2917 # The program doesn't exist.
michael@0 2918 \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
michael@0 2919 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
michael@0 2920 $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
michael@0 2921 exit 1
michael@0 2922 fi
michael@0 2923 fi\
michael@0 2924 "
michael@0 2925 }
michael@0 2926 # end: func_emit_wrapper_part2
michael@0 2927
michael@0 2928
michael@0 2929 # func_emit_wrapper [arg=no]
michael@0 2930 #
michael@0 2931 # Emit a libtool wrapper script on stdout.
michael@0 2932 # Don't directly open a file because we may want to
michael@0 2933 # incorporate the script contents within a cygwin/mingw
michael@0 2934 # wrapper executable. Must ONLY be called from within
michael@0 2935 # func_mode_link because it depends on a number of variables
michael@0 2936 # set therein.
michael@0 2937 #
michael@0 2938 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
michael@0 2939 # variable will take. If 'yes', then the emitted script
michael@0 2940 # will assume that the directory in which it is stored is
michael@0 2941 # the $objdir directory. This is a cygwin/mingw-specific
michael@0 2942 # behavior.
michael@0 2943 func_emit_wrapper ()
michael@0 2944 {
michael@0 2945 func_emit_wrapper_arg1=no
michael@0 2946 if test -n "$1" ; then
michael@0 2947 func_emit_wrapper_arg1=$1
michael@0 2948 fi
michael@0 2949
michael@0 2950 # split this up so that func_emit_cwrapperexe_src
michael@0 2951 # can call each part independently.
michael@0 2952 func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
michael@0 2953 func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
michael@0 2954 }
michael@0 2955
michael@0 2956
michael@0 2957 # func_to_host_path arg
michael@0 2958 #
michael@0 2959 # Convert paths to host format when used with build tools.
michael@0 2960 # Intended for use with "native" mingw (where libtool itself
michael@0 2961 # is running under the msys shell), or in the following cross-
michael@0 2962 # build environments:
michael@0 2963 # $build $host
michael@0 2964 # mingw (msys) mingw [e.g. native]
michael@0 2965 # cygwin mingw
michael@0 2966 # *nix + wine mingw
michael@0 2967 # where wine is equipped with the `winepath' executable.
michael@0 2968 # In the native mingw case, the (msys) shell automatically
michael@0 2969 # converts paths for any non-msys applications it launches,
michael@0 2970 # but that facility isn't available from inside the cwrapper.
michael@0 2971 # Similar accommodations are necessary for $host mingw and
michael@0 2972 # $build cygwin. Calling this function does no harm for other
michael@0 2973 # $host/$build combinations not listed above.
michael@0 2974 #
michael@0 2975 # ARG is the path (on $build) that should be converted to
michael@0 2976 # the proper representation for $host. The result is stored
michael@0 2977 # in $func_to_host_path_result.
michael@0 2978 func_to_host_path ()
michael@0 2979 {
michael@0 2980 func_to_host_path_result="$1"
michael@0 2981 if test -n "$1" ; then
michael@0 2982 case $host in
michael@0 2983 *mingw* )
michael@0 2984 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
michael@0 2985 case $build in
michael@0 2986 *mingw* ) # actually, msys
michael@0 2987 # awkward: cmd appends spaces to result
michael@0 2988 lt_sed_strip_trailing_spaces="s/[ ]*\$//"
michael@0 2989 func_to_host_path_tmp1=`( cmd //c echo "$1" |\
michael@0 2990 $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
michael@0 2991 func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
michael@0 2992 $SED -e "$lt_sed_naive_backslashify"`
michael@0 2993 ;;
michael@0 2994 *cygwin* )
michael@0 2995 func_to_host_path_tmp1=`cygpath -w "$1"`
michael@0 2996 func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
michael@0 2997 $SED -e "$lt_sed_naive_backslashify"`
michael@0 2998 ;;
michael@0 2999 * )
michael@0 3000 # Unfortunately, winepath does not exit with a non-zero
michael@0 3001 # error code, so we are forced to check the contents of
michael@0 3002 # stdout. On the other hand, if the command is not
michael@0 3003 # found, the shell will set an exit code of 127 and print
michael@0 3004 # *an error message* to stdout. So we must check for both
michael@0 3005 # error code of zero AND non-empty stdout, which explains
michael@0 3006 # the odd construction:
michael@0 3007 func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
michael@0 3008 if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
michael@0 3009 func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
michael@0 3010 $SED -e "$lt_sed_naive_backslashify"`
michael@0 3011 else
michael@0 3012 # Allow warning below.
michael@0 3013 func_to_host_path_result=""
michael@0 3014 fi
michael@0 3015 ;;
michael@0 3016 esac
michael@0 3017 if test -z "$func_to_host_path_result" ; then
michael@0 3018 func_error "Could not determine host path corresponding to"
michael@0 3019 func_error " '$1'"
michael@0 3020 func_error "Continuing, but uninstalled executables may not work."
michael@0 3021 # Fallback:
michael@0 3022 func_to_host_path_result="$1"
michael@0 3023 fi
michael@0 3024 ;;
michael@0 3025 esac
michael@0 3026 fi
michael@0 3027 }
michael@0 3028 # end: func_to_host_path
michael@0 3029
michael@0 3030 # func_to_host_pathlist arg
michael@0 3031 #
michael@0 3032 # Convert pathlists to host format when used with build tools.
michael@0 3033 # See func_to_host_path(), above. This function supports the
michael@0 3034 # following $build/$host combinations (but does no harm for
michael@0 3035 # combinations not listed here):
michael@0 3036 # $build $host
michael@0 3037 # mingw (msys) mingw [e.g. native]
michael@0 3038 # cygwin mingw
michael@0 3039 # *nix + wine mingw
michael@0 3040 #
michael@0 3041 # Path separators are also converted from $build format to
michael@0 3042 # $host format. If ARG begins or ends with a path separator
michael@0 3043 # character, it is preserved (but converted to $host format)
michael@0 3044 # on output.
michael@0 3045 #
michael@0 3046 # ARG is a pathlist (on $build) that should be converted to
michael@0 3047 # the proper representation on $host. The result is stored
michael@0 3048 # in $func_to_host_pathlist_result.
michael@0 3049 func_to_host_pathlist ()
michael@0 3050 {
michael@0 3051 func_to_host_pathlist_result="$1"
michael@0 3052 if test -n "$1" ; then
michael@0 3053 case $host in
michael@0 3054 *mingw* )
michael@0 3055 lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
michael@0 3056 # Remove leading and trailing path separator characters from
michael@0 3057 # ARG. msys behavior is inconsistent here, cygpath turns them
michael@0 3058 # into '.;' and ';.', and winepath ignores them completely.
michael@0 3059 func_to_host_pathlist_tmp2="$1"
michael@0 3060 # Once set for this call, this variable should not be
michael@0 3061 # reassigned. It is used in tha fallback case.
michael@0 3062 func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
michael@0 3063 $SED -e 's|^:*||' -e 's|:*$||'`
michael@0 3064 case $build in
michael@0 3065 *mingw* ) # Actually, msys.
michael@0 3066 # Awkward: cmd appends spaces to result.
michael@0 3067 lt_sed_strip_trailing_spaces="s/[ ]*\$//"
michael@0 3068 func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
michael@0 3069 $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
michael@0 3070 func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
michael@0 3071 $SED -e "$lt_sed_naive_backslashify"`
michael@0 3072 ;;
michael@0 3073 *cygwin* )
michael@0 3074 func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
michael@0 3075 func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
michael@0 3076 $SED -e "$lt_sed_naive_backslashify"`
michael@0 3077 ;;
michael@0 3078 * )
michael@0 3079 # unfortunately, winepath doesn't convert pathlists
michael@0 3080 func_to_host_pathlist_result=""
michael@0 3081 func_to_host_pathlist_oldIFS=$IFS
michael@0 3082 IFS=:
michael@0 3083 for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
michael@0 3084 IFS=$func_to_host_pathlist_oldIFS
michael@0 3085 if test -n "$func_to_host_pathlist_f" ; then
michael@0 3086 func_to_host_path "$func_to_host_pathlist_f"
michael@0 3087 if test -n "$func_to_host_path_result" ; then
michael@0 3088 if test -z "$func_to_host_pathlist_result" ; then
michael@0 3089 func_to_host_pathlist_result="$func_to_host_path_result"
michael@0 3090 else
michael@0 3091 func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
michael@0 3092 fi
michael@0 3093 fi
michael@0 3094 fi
michael@0 3095 IFS=:
michael@0 3096 done
michael@0 3097 IFS=$func_to_host_pathlist_oldIFS
michael@0 3098 ;;
michael@0 3099 esac
michael@0 3100 if test -z "$func_to_host_pathlist_result" ; then
michael@0 3101 func_error "Could not determine the host path(s) corresponding to"
michael@0 3102 func_error " '$1'"
michael@0 3103 func_error "Continuing, but uninstalled executables may not work."
michael@0 3104 # Fallback. This may break if $1 contains DOS-style drive
michael@0 3105 # specifications. The fix is not to complicate the expression
michael@0 3106 # below, but for the user to provide a working wine installation
michael@0 3107 # with winepath so that path translation in the cross-to-mingw
michael@0 3108 # case works properly.
michael@0 3109 lt_replace_pathsep_nix_to_dos="s|:|;|g"
michael@0 3110 func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
michael@0 3111 $SED -e "$lt_replace_pathsep_nix_to_dos"`
michael@0 3112 fi
michael@0 3113 # Now, add the leading and trailing path separators back
michael@0 3114 case "$1" in
michael@0 3115 :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
michael@0 3116 ;;
michael@0 3117 esac
michael@0 3118 case "$1" in
michael@0 3119 *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
michael@0 3120 ;;
michael@0 3121 esac
michael@0 3122 ;;
michael@0 3123 esac
michael@0 3124 fi
michael@0 3125 }
michael@0 3126 # end: func_to_host_pathlist
michael@0 3127
michael@0 3128 # func_emit_cwrapperexe_src
michael@0 3129 # emit the source code for a wrapper executable on stdout
michael@0 3130 # Must ONLY be called from within func_mode_link because
michael@0 3131 # it depends on a number of variable set therein.
michael@0 3132 func_emit_cwrapperexe_src ()
michael@0 3133 {
michael@0 3134 cat <<EOF
michael@0 3135
michael@0 3136 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
michael@0 3137 Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
michael@0 3138
michael@0 3139 The $output program cannot be directly executed until all the libtool
michael@0 3140 libraries that it depends on are installed.
michael@0 3141
michael@0 3142 This wrapper executable should never be moved out of the build directory.
michael@0 3143 If it is, it will not operate correctly.
michael@0 3144
michael@0 3145 Currently, it simply execs the wrapper *script* "$SHELL $output",
michael@0 3146 but could eventually absorb all of the scripts functionality and
michael@0 3147 exec $objdir/$outputname directly.
michael@0 3148 */
michael@0 3149 EOF
michael@0 3150 cat <<"EOF"
michael@0 3151 #include <stdio.h>
michael@0 3152 #include <stdlib.h>
michael@0 3153 #ifdef _MSC_VER
michael@0 3154 # include <direct.h>
michael@0 3155 # include <process.h>
michael@0 3156 # include <io.h>
michael@0 3157 # define setmode _setmode
michael@0 3158 #else
michael@0 3159 # include <unistd.h>
michael@0 3160 # include <stdint.h>
michael@0 3161 # ifdef __CYGWIN__
michael@0 3162 # include <io.h>
michael@0 3163 # define HAVE_SETENV
michael@0 3164 # ifdef __STRICT_ANSI__
michael@0 3165 char *realpath (const char *, char *);
michael@0 3166 int putenv (char *);
michael@0 3167 int setenv (const char *, const char *, int);
michael@0 3168 # endif
michael@0 3169 # endif
michael@0 3170 #endif
michael@0 3171 #include <malloc.h>
michael@0 3172 #include <stdarg.h>
michael@0 3173 #include <assert.h>
michael@0 3174 #include <string.h>
michael@0 3175 #include <ctype.h>
michael@0 3176 #include <errno.h>
michael@0 3177 #include <fcntl.h>
michael@0 3178 #include <sys/stat.h>
michael@0 3179
michael@0 3180 #if defined(PATH_MAX)
michael@0 3181 # define LT_PATHMAX PATH_MAX
michael@0 3182 #elif defined(MAXPATHLEN)
michael@0 3183 # define LT_PATHMAX MAXPATHLEN
michael@0 3184 #else
michael@0 3185 # define LT_PATHMAX 1024
michael@0 3186 #endif
michael@0 3187
michael@0 3188 #ifndef S_IXOTH
michael@0 3189 # define S_IXOTH 0
michael@0 3190 #endif
michael@0 3191 #ifndef S_IXGRP
michael@0 3192 # define S_IXGRP 0
michael@0 3193 #endif
michael@0 3194
michael@0 3195 #ifdef _MSC_VER
michael@0 3196 # define S_IXUSR _S_IEXEC
michael@0 3197 # define stat _stat
michael@0 3198 # ifndef _INTPTR_T_DEFINED
michael@0 3199 # define intptr_t int
michael@0 3200 # endif
michael@0 3201 #endif
michael@0 3202
michael@0 3203 #ifndef DIR_SEPARATOR
michael@0 3204 # define DIR_SEPARATOR '/'
michael@0 3205 # define PATH_SEPARATOR ':'
michael@0 3206 #endif
michael@0 3207
michael@0 3208 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
michael@0 3209 defined (__OS2__)
michael@0 3210 # define HAVE_DOS_BASED_FILE_SYSTEM
michael@0 3211 # define FOPEN_WB "wb"
michael@0 3212 # ifndef DIR_SEPARATOR_2
michael@0 3213 # define DIR_SEPARATOR_2 '\\'
michael@0 3214 # endif
michael@0 3215 # ifndef PATH_SEPARATOR_2
michael@0 3216 # define PATH_SEPARATOR_2 ';'
michael@0 3217 # endif
michael@0 3218 #endif
michael@0 3219
michael@0 3220 #ifndef DIR_SEPARATOR_2
michael@0 3221 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
michael@0 3222 #else /* DIR_SEPARATOR_2 */
michael@0 3223 # define IS_DIR_SEPARATOR(ch) \
michael@0 3224 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
michael@0 3225 #endif /* DIR_SEPARATOR_2 */
michael@0 3226
michael@0 3227 #ifndef PATH_SEPARATOR_2
michael@0 3228 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
michael@0 3229 #else /* PATH_SEPARATOR_2 */
michael@0 3230 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
michael@0 3231 #endif /* PATH_SEPARATOR_2 */
michael@0 3232
michael@0 3233 #ifdef __CYGWIN__
michael@0 3234 # define FOPEN_WB "wb"
michael@0 3235 #endif
michael@0 3236
michael@0 3237 #ifndef FOPEN_WB
michael@0 3238 # define FOPEN_WB "w"
michael@0 3239 #endif
michael@0 3240 #ifndef _O_BINARY
michael@0 3241 # define _O_BINARY 0
michael@0 3242 #endif
michael@0 3243
michael@0 3244 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
michael@0 3245 #define XFREE(stale) do { \
michael@0 3246 if (stale) { free ((void *) stale); stale = 0; } \
michael@0 3247 } while (0)
michael@0 3248
michael@0 3249 #undef LTWRAPPER_DEBUGPRINTF
michael@0 3250 #if defined DEBUGWRAPPER
michael@0 3251 # define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
michael@0 3252 static void
michael@0 3253 ltwrapper_debugprintf (const char *fmt, ...)
michael@0 3254 {
michael@0 3255 va_list args;
michael@0 3256 va_start (args, fmt);
michael@0 3257 (void) vfprintf (stderr, fmt, args);
michael@0 3258 va_end (args);
michael@0 3259 }
michael@0 3260 #else
michael@0 3261 # define LTWRAPPER_DEBUGPRINTF(args)
michael@0 3262 #endif
michael@0 3263
michael@0 3264 const char *program_name = NULL;
michael@0 3265
michael@0 3266 void *xmalloc (size_t num);
michael@0 3267 char *xstrdup (const char *string);
michael@0 3268 const char *base_name (const char *name);
michael@0 3269 char *find_executable (const char *wrapper);
michael@0 3270 char *chase_symlinks (const char *pathspec);
michael@0 3271 int make_executable (const char *path);
michael@0 3272 int check_executable (const char *path);
michael@0 3273 char *strendzap (char *str, const char *pat);
michael@0 3274 void lt_fatal (const char *message, ...);
michael@0 3275 void lt_setenv (const char *name, const char *value);
michael@0 3276 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
michael@0 3277 void lt_opt_process_env_set (const char *arg);
michael@0 3278 void lt_opt_process_env_prepend (const char *arg);
michael@0 3279 void lt_opt_process_env_append (const char *arg);
michael@0 3280 int lt_split_name_value (const char *arg, char** name, char** value);
michael@0 3281 void lt_update_exe_path (const char *name, const char *value);
michael@0 3282 void lt_update_lib_path (const char *name, const char *value);
michael@0 3283
michael@0 3284 static const char *script_text_part1 =
michael@0 3285 EOF
michael@0 3286
michael@0 3287 func_emit_wrapper_part1 yes |
michael@0 3288 $SED -e 's/\([\\"]\)/\\\1/g' \
michael@0 3289 -e 's/^/ "/' -e 's/$/\\n"/'
michael@0 3290 echo ";"
michael@0 3291 cat <<EOF
michael@0 3292
michael@0 3293 static const char *script_text_part2 =
michael@0 3294 EOF
michael@0 3295 func_emit_wrapper_part2 yes |
michael@0 3296 $SED -e 's/\([\\"]\)/\\\1/g' \
michael@0 3297 -e 's/^/ "/' -e 's/$/\\n"/'
michael@0 3298 echo ";"
michael@0 3299
michael@0 3300 cat <<EOF
michael@0 3301 const char * MAGIC_EXE = "$magic_exe";
michael@0 3302 const char * LIB_PATH_VARNAME = "$shlibpath_var";
michael@0 3303 EOF
michael@0 3304
michael@0 3305 if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
michael@0 3306 func_to_host_pathlist "$temp_rpath"
michael@0 3307 cat <<EOF
michael@0 3308 const char * LIB_PATH_VALUE = "$func_to_host_pathlist_result";
michael@0 3309 EOF
michael@0 3310 else
michael@0 3311 cat <<"EOF"
michael@0 3312 const char * LIB_PATH_VALUE = "";
michael@0 3313 EOF
michael@0 3314 fi
michael@0 3315
michael@0 3316 if test -n "$dllsearchpath"; then
michael@0 3317 func_to_host_pathlist "$dllsearchpath:"
michael@0 3318 cat <<EOF
michael@0 3319 const char * EXE_PATH_VARNAME = "PATH";
michael@0 3320 const char * EXE_PATH_VALUE = "$func_to_host_pathlist_result";
michael@0 3321 EOF
michael@0 3322 else
michael@0 3323 cat <<"EOF"
michael@0 3324 const char * EXE_PATH_VARNAME = "";
michael@0 3325 const char * EXE_PATH_VALUE = "";
michael@0 3326 EOF
michael@0 3327 fi
michael@0 3328
michael@0 3329 if test "$fast_install" = yes; then
michael@0 3330 cat <<EOF
michael@0 3331 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
michael@0 3332 EOF
michael@0 3333 else
michael@0 3334 cat <<EOF
michael@0 3335 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
michael@0 3336 EOF
michael@0 3337 fi
michael@0 3338
michael@0 3339
michael@0 3340 cat <<"EOF"
michael@0 3341
michael@0 3342 #define LTWRAPPER_OPTION_PREFIX "--lt-"
michael@0 3343 #define LTWRAPPER_OPTION_PREFIX_LENGTH 5
michael@0 3344
michael@0 3345 static const size_t opt_prefix_len = LTWRAPPER_OPTION_PREFIX_LENGTH;
michael@0 3346 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
michael@0 3347
michael@0 3348 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
michael@0 3349
michael@0 3350 static const size_t env_set_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
michael@0 3351 static const char *env_set_opt = LTWRAPPER_OPTION_PREFIX "env-set";
michael@0 3352 /* argument is putenv-style "foo=bar", value of foo is set to bar */
michael@0 3353
michael@0 3354 static const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
michael@0 3355 static const char *env_prepend_opt = LTWRAPPER_OPTION_PREFIX "env-prepend";
michael@0 3356 /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
michael@0 3357
michael@0 3358 static const size_t env_append_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
michael@0 3359 static const char *env_append_opt = LTWRAPPER_OPTION_PREFIX "env-append";
michael@0 3360 /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
michael@0 3361
michael@0 3362 int
michael@0 3363 main (int argc, char *argv[])
michael@0 3364 {
michael@0 3365 char **newargz;
michael@0 3366 int newargc;
michael@0 3367 char *tmp_pathspec;
michael@0 3368 char *actual_cwrapper_path;
michael@0 3369 char *actual_cwrapper_name;
michael@0 3370 char *target_name;
michael@0 3371 char *lt_argv_zero;
michael@0 3372 intptr_t rval = 127;
michael@0 3373
michael@0 3374 int i;
michael@0 3375
michael@0 3376 program_name = (char *) xstrdup (base_name (argv[0]));
michael@0 3377 LTWRAPPER_DEBUGPRINTF (("(main) argv[0] : %s\n", argv[0]));
michael@0 3378 LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
michael@0 3379
michael@0 3380 /* very simple arg parsing; don't want to rely on getopt */
michael@0 3381 for (i = 1; i < argc; i++)
michael@0 3382 {
michael@0 3383 if (strcmp (argv[i], dumpscript_opt) == 0)
michael@0 3384 {
michael@0 3385 EOF
michael@0 3386 case "$host" in
michael@0 3387 *mingw* | *cygwin* )
michael@0 3388 # make stdout use "unix" line endings
michael@0 3389 echo " setmode(1,_O_BINARY);"
michael@0 3390 ;;
michael@0 3391 esac
michael@0 3392
michael@0 3393 cat <<"EOF"
michael@0 3394 printf ("%s", script_text_part1);
michael@0 3395 printf ("%s", script_text_part2);
michael@0 3396 return 0;
michael@0 3397 }
michael@0 3398 }
michael@0 3399
michael@0 3400 newargz = XMALLOC (char *, argc + 1);
michael@0 3401 tmp_pathspec = find_executable (argv[0]);
michael@0 3402 if (tmp_pathspec == NULL)
michael@0 3403 lt_fatal ("Couldn't find %s", argv[0]);
michael@0 3404 LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
michael@0 3405 tmp_pathspec));
michael@0 3406
michael@0 3407 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
michael@0 3408 LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
michael@0 3409 actual_cwrapper_path));
michael@0 3410 XFREE (tmp_pathspec);
michael@0 3411
michael@0 3412 actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
michael@0 3413 strendzap (actual_cwrapper_path, actual_cwrapper_name);
michael@0 3414
michael@0 3415 /* wrapper name transforms */
michael@0 3416 strendzap (actual_cwrapper_name, ".exe");
michael@0 3417 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
michael@0 3418 XFREE (actual_cwrapper_name);
michael@0 3419 actual_cwrapper_name = tmp_pathspec;
michael@0 3420 tmp_pathspec = 0;
michael@0 3421
michael@0 3422 /* target_name transforms -- use actual target program name; might have lt- prefix */
michael@0 3423 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
michael@0 3424 strendzap (target_name, ".exe");
michael@0 3425 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
michael@0 3426 XFREE (target_name);
michael@0 3427 target_name = tmp_pathspec;
michael@0 3428 tmp_pathspec = 0;
michael@0 3429
michael@0 3430 LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
michael@0 3431 target_name));
michael@0 3432 EOF
michael@0 3433
michael@0 3434 cat <<EOF
michael@0 3435 newargz[0] =
michael@0 3436 XMALLOC (char, (strlen (actual_cwrapper_path) +
michael@0 3437 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
michael@0 3438 strcpy (newargz[0], actual_cwrapper_path);
michael@0 3439 strcat (newargz[0], "$objdir");
michael@0 3440 strcat (newargz[0], "/");
michael@0 3441 EOF
michael@0 3442
michael@0 3443 cat <<"EOF"
michael@0 3444 /* stop here, and copy so we don't have to do this twice */
michael@0 3445 tmp_pathspec = xstrdup (newargz[0]);
michael@0 3446
michael@0 3447 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
michael@0 3448 strcat (newargz[0], actual_cwrapper_name);
michael@0 3449
michael@0 3450 /* DO want the lt- prefix here if it exists, so use target_name */
michael@0 3451 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
michael@0 3452 XFREE (tmp_pathspec);
michael@0 3453 tmp_pathspec = NULL;
michael@0 3454 EOF
michael@0 3455
michael@0 3456 case $host_os in
michael@0 3457 mingw*)
michael@0 3458 cat <<"EOF"
michael@0 3459 {
michael@0 3460 char* p;
michael@0 3461 while ((p = strchr (newargz[0], '\\')) != NULL)
michael@0 3462 {
michael@0 3463 *p = '/';
michael@0 3464 }
michael@0 3465 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
michael@0 3466 {
michael@0 3467 *p = '/';
michael@0 3468 }
michael@0 3469 }
michael@0 3470 EOF
michael@0 3471 ;;
michael@0 3472 esac
michael@0 3473
michael@0 3474 cat <<"EOF"
michael@0 3475 XFREE (target_name);
michael@0 3476 XFREE (actual_cwrapper_path);
michael@0 3477 XFREE (actual_cwrapper_name);
michael@0 3478
michael@0 3479 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
michael@0 3480 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
michael@0 3481 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
michael@0 3482 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
michael@0 3483
michael@0 3484 newargc=0;
michael@0 3485 for (i = 1; i < argc; i++)
michael@0 3486 {
michael@0 3487 if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
michael@0 3488 {
michael@0 3489 if (argv[i][env_set_opt_len] == '=')
michael@0 3490 {
michael@0 3491 const char *p = argv[i] + env_set_opt_len + 1;
michael@0 3492 lt_opt_process_env_set (p);
michael@0 3493 }
michael@0 3494 else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
michael@0 3495 {
michael@0 3496 lt_opt_process_env_set (argv[++i]); /* don't copy */
michael@0 3497 }
michael@0 3498 else
michael@0 3499 lt_fatal ("%s missing required argument", env_set_opt);
michael@0 3500 continue;
michael@0 3501 }
michael@0 3502 if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
michael@0 3503 {
michael@0 3504 if (argv[i][env_prepend_opt_len] == '=')
michael@0 3505 {
michael@0 3506 const char *p = argv[i] + env_prepend_opt_len + 1;
michael@0 3507 lt_opt_process_env_prepend (p);
michael@0 3508 }
michael@0 3509 else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
michael@0 3510 {
michael@0 3511 lt_opt_process_env_prepend (argv[++i]); /* don't copy */
michael@0 3512 }
michael@0 3513 else
michael@0 3514 lt_fatal ("%s missing required argument", env_prepend_opt);
michael@0 3515 continue;
michael@0 3516 }
michael@0 3517 if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
michael@0 3518 {
michael@0 3519 if (argv[i][env_append_opt_len] == '=')
michael@0 3520 {
michael@0 3521 const char *p = argv[i] + env_append_opt_len + 1;
michael@0 3522 lt_opt_process_env_append (p);
michael@0 3523 }
michael@0 3524 else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
michael@0 3525 {
michael@0 3526 lt_opt_process_env_append (argv[++i]); /* don't copy */
michael@0 3527 }
michael@0 3528 else
michael@0 3529 lt_fatal ("%s missing required argument", env_append_opt);
michael@0 3530 continue;
michael@0 3531 }
michael@0 3532 if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
michael@0 3533 {
michael@0 3534 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
michael@0 3535 namespace, but it is not one of the ones we know about and
michael@0 3536 have already dealt with, above (inluding dump-script), then
michael@0 3537 report an error. Otherwise, targets might begin to believe
michael@0 3538 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
michael@0 3539 namespace. The first time any user complains about this, we'll
michael@0 3540 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
michael@0 3541 or a configure.ac-settable value.
michael@0 3542 */
michael@0 3543 lt_fatal ("Unrecognized option in %s namespace: '%s'",
michael@0 3544 ltwrapper_option_prefix, argv[i]);
michael@0 3545 }
michael@0 3546 /* otherwise ... */
michael@0 3547 newargz[++newargc] = xstrdup (argv[i]);
michael@0 3548 }
michael@0 3549 newargz[++newargc] = NULL;
michael@0 3550
michael@0 3551 LTWRAPPER_DEBUGPRINTF (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
michael@0 3552 for (i = 0; i < newargc; i++)
michael@0 3553 {
michael@0 3554 LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d] : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
michael@0 3555 }
michael@0 3556
michael@0 3557 EOF
michael@0 3558
michael@0 3559 case $host_os in
michael@0 3560 mingw*)
michael@0 3561 cat <<"EOF"
michael@0 3562 /* execv doesn't actually work on mingw as expected on unix */
michael@0 3563 rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
michael@0 3564 if (rval == -1)
michael@0 3565 {
michael@0 3566 /* failed to start process */
michael@0 3567 LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
michael@0 3568 return 127;
michael@0 3569 }
michael@0 3570 return rval;
michael@0 3571 EOF
michael@0 3572 ;;
michael@0 3573 *)
michael@0 3574 cat <<"EOF"
michael@0 3575 execv (lt_argv_zero, newargz);
michael@0 3576 return rval; /* =127, but avoids unused variable warning */
michael@0 3577 EOF
michael@0 3578 ;;
michael@0 3579 esac
michael@0 3580
michael@0 3581 cat <<"EOF"
michael@0 3582 }
michael@0 3583
michael@0 3584 void *
michael@0 3585 xmalloc (size_t num)
michael@0 3586 {
michael@0 3587 void *p = (void *) malloc (num);
michael@0 3588 if (!p)
michael@0 3589 lt_fatal ("Memory exhausted");
michael@0 3590
michael@0 3591 return p;
michael@0 3592 }
michael@0 3593
michael@0 3594 char *
michael@0 3595 xstrdup (const char *string)
michael@0 3596 {
michael@0 3597 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
michael@0 3598 string) : NULL;
michael@0 3599 }
michael@0 3600
michael@0 3601 const char *
michael@0 3602 base_name (const char *name)
michael@0 3603 {
michael@0 3604 const char *base;
michael@0 3605
michael@0 3606 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
michael@0 3607 /* Skip over the disk name in MSDOS pathnames. */
michael@0 3608 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
michael@0 3609 name += 2;
michael@0 3610 #endif
michael@0 3611
michael@0 3612 for (base = name; *name; name++)
michael@0 3613 if (IS_DIR_SEPARATOR (*name))
michael@0 3614 base = name + 1;
michael@0 3615 return base;
michael@0 3616 }
michael@0 3617
michael@0 3618 int
michael@0 3619 check_executable (const char *path)
michael@0 3620 {
michael@0 3621 struct stat st;
michael@0 3622
michael@0 3623 LTWRAPPER_DEBUGPRINTF (("(check_executable) : %s\n",
michael@0 3624 path ? (*path ? path : "EMPTY!") : "NULL!"));
michael@0 3625 if ((!path) || (!*path))
michael@0 3626 return 0;
michael@0 3627
michael@0 3628 if ((stat (path, &st) >= 0)
michael@0 3629 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
michael@0 3630 return 1;
michael@0 3631 else
michael@0 3632 return 0;
michael@0 3633 }
michael@0 3634
michael@0 3635 int
michael@0 3636 make_executable (const char *path)
michael@0 3637 {
michael@0 3638 int rval = 0;
michael@0 3639 struct stat st;
michael@0 3640
michael@0 3641 LTWRAPPER_DEBUGPRINTF (("(make_executable) : %s\n",
michael@0 3642 path ? (*path ? path : "EMPTY!") : "NULL!"));
michael@0 3643 if ((!path) || (!*path))
michael@0 3644 return 0;
michael@0 3645
michael@0 3646 if (stat (path, &st) >= 0)
michael@0 3647 {
michael@0 3648 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
michael@0 3649 }
michael@0 3650 return rval;
michael@0 3651 }
michael@0 3652
michael@0 3653 /* Searches for the full path of the wrapper. Returns
michael@0 3654 newly allocated full path name if found, NULL otherwise
michael@0 3655 Does not chase symlinks, even on platforms that support them.
michael@0 3656 */
michael@0 3657 char *
michael@0 3658 find_executable (const char *wrapper)
michael@0 3659 {
michael@0 3660 int has_slash = 0;
michael@0 3661 const char *p;
michael@0 3662 const char *p_next;
michael@0 3663 /* static buffer for getcwd */
michael@0 3664 char tmp[LT_PATHMAX + 1];
michael@0 3665 int tmp_len;
michael@0 3666 char *concat_name;
michael@0 3667
michael@0 3668 LTWRAPPER_DEBUGPRINTF (("(find_executable) : %s\n",
michael@0 3669 wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
michael@0 3670
michael@0 3671 if ((wrapper == NULL) || (*wrapper == '\0'))
michael@0 3672 return NULL;
michael@0 3673
michael@0 3674 /* Absolute path? */
michael@0 3675 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
michael@0 3676 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
michael@0 3677 {
michael@0 3678 concat_name = xstrdup (wrapper);
michael@0 3679 if (check_executable (concat_name))
michael@0 3680 return concat_name;
michael@0 3681 XFREE (concat_name);
michael@0 3682 }
michael@0 3683 else
michael@0 3684 {
michael@0 3685 #endif
michael@0 3686 if (IS_DIR_SEPARATOR (wrapper[0]))
michael@0 3687 {
michael@0 3688 concat_name = xstrdup (wrapper);
michael@0 3689 if (check_executable (concat_name))
michael@0 3690 return concat_name;
michael@0 3691 XFREE (concat_name);
michael@0 3692 }
michael@0 3693 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
michael@0 3694 }
michael@0 3695 #endif
michael@0 3696
michael@0 3697 for (p = wrapper; *p; p++)
michael@0 3698 if (*p == '/')
michael@0 3699 {
michael@0 3700 has_slash = 1;
michael@0 3701 break;
michael@0 3702 }
michael@0 3703 if (!has_slash)
michael@0 3704 {
michael@0 3705 /* no slashes; search PATH */
michael@0 3706 const char *path = getenv ("PATH");
michael@0 3707 if (path != NULL)
michael@0 3708 {
michael@0 3709 for (p = path; *p; p = p_next)
michael@0 3710 {
michael@0 3711 const char *q;
michael@0 3712 size_t p_len;
michael@0 3713 for (q = p; *q; q++)
michael@0 3714 if (IS_PATH_SEPARATOR (*q))
michael@0 3715 break;
michael@0 3716 p_len = q - p;
michael@0 3717 p_next = (*q == '\0' ? q : q + 1);
michael@0 3718 if (p_len == 0)
michael@0 3719 {
michael@0 3720 /* empty path: current directory */
michael@0 3721 if (getcwd (tmp, LT_PATHMAX) == NULL)
michael@0 3722 lt_fatal ("getcwd failed");
michael@0 3723 tmp_len = strlen (tmp);
michael@0 3724 concat_name =
michael@0 3725 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
michael@0 3726 memcpy (concat_name, tmp, tmp_len);
michael@0 3727 concat_name[tmp_len] = '/';
michael@0 3728 strcpy (concat_name + tmp_len + 1, wrapper);
michael@0 3729 }
michael@0 3730 else
michael@0 3731 {
michael@0 3732 concat_name =
michael@0 3733 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
michael@0 3734 memcpy (concat_name, p, p_len);
michael@0 3735 concat_name[p_len] = '/';
michael@0 3736 strcpy (concat_name + p_len + 1, wrapper);
michael@0 3737 }
michael@0 3738 if (check_executable (concat_name))
michael@0 3739 return concat_name;
michael@0 3740 XFREE (concat_name);
michael@0 3741 }
michael@0 3742 }
michael@0 3743 /* not found in PATH; assume curdir */
michael@0 3744 }
michael@0 3745 /* Relative path | not found in path: prepend cwd */
michael@0 3746 if (getcwd (tmp, LT_PATHMAX) == NULL)
michael@0 3747 lt_fatal ("getcwd failed");
michael@0 3748 tmp_len = strlen (tmp);
michael@0 3749 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
michael@0 3750 memcpy (concat_name, tmp, tmp_len);
michael@0 3751 concat_name[tmp_len] = '/';
michael@0 3752 strcpy (concat_name + tmp_len + 1, wrapper);
michael@0 3753
michael@0 3754 if (check_executable (concat_name))
michael@0 3755 return concat_name;
michael@0 3756 XFREE (concat_name);
michael@0 3757 return NULL;
michael@0 3758 }
michael@0 3759
michael@0 3760 char *
michael@0 3761 chase_symlinks (const char *pathspec)
michael@0 3762 {
michael@0 3763 #ifndef S_ISLNK
michael@0 3764 return xstrdup (pathspec);
michael@0 3765 #else
michael@0 3766 char buf[LT_PATHMAX];
michael@0 3767 struct stat s;
michael@0 3768 char *tmp_pathspec = xstrdup (pathspec);
michael@0 3769 char *p;
michael@0 3770 int has_symlinks = 0;
michael@0 3771 while (strlen (tmp_pathspec) && !has_symlinks)
michael@0 3772 {
michael@0 3773 LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
michael@0 3774 tmp_pathspec));
michael@0 3775 if (lstat (tmp_pathspec, &s) == 0)
michael@0 3776 {
michael@0 3777 if (S_ISLNK (s.st_mode) != 0)
michael@0 3778 {
michael@0 3779 has_symlinks = 1;
michael@0 3780 break;
michael@0 3781 }
michael@0 3782
michael@0 3783 /* search backwards for last DIR_SEPARATOR */
michael@0 3784 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
michael@0 3785 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
michael@0 3786 p--;
michael@0 3787 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
michael@0 3788 {
michael@0 3789 /* no more DIR_SEPARATORS left */
michael@0 3790 break;
michael@0 3791 }
michael@0 3792 *p = '\0';
michael@0 3793 }
michael@0 3794 else
michael@0 3795 {
michael@0 3796 char *errstr = strerror (errno);
michael@0 3797 lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
michael@0 3798 }
michael@0 3799 }
michael@0 3800 XFREE (tmp_pathspec);
michael@0 3801
michael@0 3802 if (!has_symlinks)
michael@0 3803 {
michael@0 3804 return xstrdup (pathspec);
michael@0 3805 }
michael@0 3806
michael@0 3807 tmp_pathspec = realpath (pathspec, buf);
michael@0 3808 if (tmp_pathspec == 0)
michael@0 3809 {
michael@0 3810 lt_fatal ("Could not follow symlinks for %s", pathspec);
michael@0 3811 }
michael@0 3812 return xstrdup (tmp_pathspec);
michael@0 3813 #endif
michael@0 3814 }
michael@0 3815
michael@0 3816 char *
michael@0 3817 strendzap (char *str, const char *pat)
michael@0 3818 {
michael@0 3819 size_t len, patlen;
michael@0 3820
michael@0 3821 assert (str != NULL);
michael@0 3822 assert (pat != NULL);
michael@0 3823
michael@0 3824 len = strlen (str);
michael@0 3825 patlen = strlen (pat);
michael@0 3826
michael@0 3827 if (patlen <= len)
michael@0 3828 {
michael@0 3829 str += len - patlen;
michael@0 3830 if (strcmp (str, pat) == 0)
michael@0 3831 *str = '\0';
michael@0 3832 }
michael@0 3833 return str;
michael@0 3834 }
michael@0 3835
michael@0 3836 static void
michael@0 3837 lt_error_core (int exit_status, const char *mode,
michael@0 3838 const char *message, va_list ap)
michael@0 3839 {
michael@0 3840 fprintf (stderr, "%s: %s: ", program_name, mode);
michael@0 3841 vfprintf (stderr, message, ap);
michael@0 3842 fprintf (stderr, ".\n");
michael@0 3843
michael@0 3844 if (exit_status >= 0)
michael@0 3845 exit (exit_status);
michael@0 3846 }
michael@0 3847
michael@0 3848 void
michael@0 3849 lt_fatal (const char *message, ...)
michael@0 3850 {
michael@0 3851 va_list ap;
michael@0 3852 va_start (ap, message);
michael@0 3853 lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
michael@0 3854 va_end (ap);
michael@0 3855 }
michael@0 3856
michael@0 3857 void
michael@0 3858 lt_setenv (const char *name, const char *value)
michael@0 3859 {
michael@0 3860 LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
michael@0 3861 (name ? name : "<NULL>"),
michael@0 3862 (value ? value : "<NULL>")));
michael@0 3863 {
michael@0 3864 #ifdef HAVE_SETENV
michael@0 3865 /* always make a copy, for consistency with !HAVE_SETENV */
michael@0 3866 char *str = xstrdup (value);
michael@0 3867 setenv (name, str, 1);
michael@0 3868 #else
michael@0 3869 int len = strlen (name) + 1 + strlen (value) + 1;
michael@0 3870 char *str = XMALLOC (char, len);
michael@0 3871 sprintf (str, "%s=%s", name, value);
michael@0 3872 if (putenv (str) != EXIT_SUCCESS)
michael@0 3873 {
michael@0 3874 XFREE (str);
michael@0 3875 }
michael@0 3876 #endif
michael@0 3877 }
michael@0 3878 }
michael@0 3879
michael@0 3880 char *
michael@0 3881 lt_extend_str (const char *orig_value, const char *add, int to_end)
michael@0 3882 {
michael@0 3883 char *new_value;
michael@0 3884 if (orig_value && *orig_value)
michael@0 3885 {
michael@0 3886 int orig_value_len = strlen (orig_value);
michael@0 3887 int add_len = strlen (add);
michael@0 3888 new_value = XMALLOC (char, add_len + orig_value_len + 1);
michael@0 3889 if (to_end)
michael@0 3890 {
michael@0 3891 strcpy (new_value, orig_value);
michael@0 3892 strcpy (new_value + orig_value_len, add);
michael@0 3893 }
michael@0 3894 else
michael@0 3895 {
michael@0 3896 strcpy (new_value, add);
michael@0 3897 strcpy (new_value + add_len, orig_value);
michael@0 3898 }
michael@0 3899 }
michael@0 3900 else
michael@0 3901 {
michael@0 3902 new_value = xstrdup (add);
michael@0 3903 }
michael@0 3904 return new_value;
michael@0 3905 }
michael@0 3906
michael@0 3907 int
michael@0 3908 lt_split_name_value (const char *arg, char** name, char** value)
michael@0 3909 {
michael@0 3910 const char *p;
michael@0 3911 int len;
michael@0 3912 if (!arg || !*arg)
michael@0 3913 return 1;
michael@0 3914
michael@0 3915 p = strchr (arg, (int)'=');
michael@0 3916
michael@0 3917 if (!p)
michael@0 3918 return 1;
michael@0 3919
michael@0 3920 *value = xstrdup (++p);
michael@0 3921
michael@0 3922 len = strlen (arg) - strlen (*value);
michael@0 3923 *name = XMALLOC (char, len);
michael@0 3924 strncpy (*name, arg, len-1);
michael@0 3925 (*name)[len - 1] = '\0';
michael@0 3926
michael@0 3927 return 0;
michael@0 3928 }
michael@0 3929
michael@0 3930 void
michael@0 3931 lt_opt_process_env_set (const char *arg)
michael@0 3932 {
michael@0 3933 char *name = NULL;
michael@0 3934 char *value = NULL;
michael@0 3935
michael@0 3936 if (lt_split_name_value (arg, &name, &value) != 0)
michael@0 3937 {
michael@0 3938 XFREE (name);
michael@0 3939 XFREE (value);
michael@0 3940 lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
michael@0 3941 }
michael@0 3942
michael@0 3943 lt_setenv (name, value);
michael@0 3944 XFREE (name);
michael@0 3945 XFREE (value);
michael@0 3946 }
michael@0 3947
michael@0 3948 void
michael@0 3949 lt_opt_process_env_prepend (const char *arg)
michael@0 3950 {
michael@0 3951 char *name = NULL;
michael@0 3952 char *value = NULL;
michael@0 3953 char *new_value = NULL;
michael@0 3954
michael@0 3955 if (lt_split_name_value (arg, &name, &value) != 0)
michael@0 3956 {
michael@0 3957 XFREE (name);
michael@0 3958 XFREE (value);
michael@0 3959 lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
michael@0 3960 }
michael@0 3961
michael@0 3962 new_value = lt_extend_str (getenv (name), value, 0);
michael@0 3963 lt_setenv (name, new_value);
michael@0 3964 XFREE (new_value);
michael@0 3965 XFREE (name);
michael@0 3966 XFREE (value);
michael@0 3967 }
michael@0 3968
michael@0 3969 void
michael@0 3970 lt_opt_process_env_append (const char *arg)
michael@0 3971 {
michael@0 3972 char *name = NULL;
michael@0 3973 char *value = NULL;
michael@0 3974 char *new_value = NULL;
michael@0 3975
michael@0 3976 if (lt_split_name_value (arg, &name, &value) != 0)
michael@0 3977 {
michael@0 3978 XFREE (name);
michael@0 3979 XFREE (value);
michael@0 3980 lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
michael@0 3981 }
michael@0 3982
michael@0 3983 new_value = lt_extend_str (getenv (name), value, 1);
michael@0 3984 lt_setenv (name, new_value);
michael@0 3985 XFREE (new_value);
michael@0 3986 XFREE (name);
michael@0 3987 XFREE (value);
michael@0 3988 }
michael@0 3989
michael@0 3990 void
michael@0 3991 lt_update_exe_path (const char *name, const char *value)
michael@0 3992 {
michael@0 3993 LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
michael@0 3994 (name ? name : "<NULL>"),
michael@0 3995 (value ? value : "<NULL>")));
michael@0 3996
michael@0 3997 if (name && *name && value && *value)
michael@0 3998 {
michael@0 3999 char *new_value = lt_extend_str (getenv (name), value, 0);
michael@0 4000 /* some systems can't cope with a ':'-terminated path #' */
michael@0 4001 int len = strlen (new_value);
michael@0 4002 while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
michael@0 4003 {
michael@0 4004 new_value[len-1] = '\0';
michael@0 4005 }
michael@0 4006 lt_setenv (name, new_value);
michael@0 4007 XFREE (new_value);
michael@0 4008 }
michael@0 4009 }
michael@0 4010
michael@0 4011 void
michael@0 4012 lt_update_lib_path (const char *name, const char *value)
michael@0 4013 {
michael@0 4014 LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
michael@0 4015 (name ? name : "<NULL>"),
michael@0 4016 (value ? value : "<NULL>")));
michael@0 4017
michael@0 4018 if (name && *name && value && *value)
michael@0 4019 {
michael@0 4020 char *new_value = lt_extend_str (getenv (name), value, 0);
michael@0 4021 lt_setenv (name, new_value);
michael@0 4022 XFREE (new_value);
michael@0 4023 }
michael@0 4024 }
michael@0 4025
michael@0 4026
michael@0 4027 EOF
michael@0 4028 }
michael@0 4029 # end: func_emit_cwrapperexe_src
michael@0 4030
michael@0 4031 # func_mode_link arg...
michael@0 4032 func_mode_link ()
michael@0 4033 {
michael@0 4034 $opt_debug
michael@0 4035 case $host in
michael@0 4036 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
michael@0 4037 # It is impossible to link a dll without this setting, and
michael@0 4038 # we shouldn't force the makefile maintainer to figure out
michael@0 4039 # which system we are compiling for in order to pass an extra
michael@0 4040 # flag for every libtool invocation.
michael@0 4041 # allow_undefined=no
michael@0 4042
michael@0 4043 # FIXME: Unfortunately, there are problems with the above when trying
michael@0 4044 # to make a dll which has undefined symbols, in which case not
michael@0 4045 # even a static library is built. For now, we need to specify
michael@0 4046 # -no-undefined on the libtool link line when we can be certain
michael@0 4047 # that all symbols are satisfied, otherwise we get a static library.
michael@0 4048 allow_undefined=yes
michael@0 4049 ;;
michael@0 4050 *)
michael@0 4051 allow_undefined=yes
michael@0 4052 ;;
michael@0 4053 esac
michael@0 4054 libtool_args=$nonopt
michael@0 4055 base_compile="$nonopt $@"
michael@0 4056 compile_command=$nonopt
michael@0 4057 finalize_command=$nonopt
michael@0 4058
michael@0 4059 compile_rpath=
michael@0 4060 finalize_rpath=
michael@0 4061 compile_shlibpath=
michael@0 4062 finalize_shlibpath=
michael@0 4063 convenience=
michael@0 4064 old_convenience=
michael@0 4065 deplibs=
michael@0 4066 old_deplibs=
michael@0 4067 compiler_flags=
michael@0 4068 linker_flags=
michael@0 4069 dllsearchpath=
michael@0 4070 lib_search_path=`pwd`
michael@0 4071 inst_prefix_dir=
michael@0 4072 new_inherited_linker_flags=
michael@0 4073
michael@0 4074 avoid_version=no
michael@0 4075 dlfiles=
michael@0 4076 dlprefiles=
michael@0 4077 dlself=no
michael@0 4078 export_dynamic=no
michael@0 4079 export_symbols=
michael@0 4080 export_symbols_regex=
michael@0 4081 generated=
michael@0 4082 libobjs=
michael@0 4083 ltlibs=
michael@0 4084 module=no
michael@0 4085 no_install=no
michael@0 4086 objs=
michael@0 4087 non_pic_objects=
michael@0 4088 precious_files_regex=
michael@0 4089 prefer_static_libs=no
michael@0 4090 preload=no
michael@0 4091 prev=
michael@0 4092 prevarg=
michael@0 4093 release=
michael@0 4094 rpath=
michael@0 4095 xrpath=
michael@0 4096 perm_rpath=
michael@0 4097 temp_rpath=
michael@0 4098 thread_safe=no
michael@0 4099 vinfo=
michael@0 4100 vinfo_number=no
michael@0 4101 weak_libs=
michael@0 4102 single_module="${wl}-single_module"
michael@0 4103 func_infer_tag $base_compile
michael@0 4104
michael@0 4105 # We need to know -static, to get the right output filenames.
michael@0 4106 for arg
michael@0 4107 do
michael@0 4108 case $arg in
michael@0 4109 -shared)
michael@0 4110 test "$build_libtool_libs" != yes && \
michael@0 4111 func_fatal_configuration "can not build a shared library"
michael@0 4112 build_old_libs=no
michael@0 4113 break
michael@0 4114 ;;
michael@0 4115 -all-static | -static | -static-libtool-libs)
michael@0 4116 case $arg in
michael@0 4117 -all-static)
michael@0 4118 if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
michael@0 4119 func_warning "complete static linking is impossible in this configuration"
michael@0 4120 fi
michael@0 4121 if test -n "$link_static_flag"; then
michael@0 4122 dlopen_self=$dlopen_self_static
michael@0 4123 fi
michael@0 4124 prefer_static_libs=yes
michael@0 4125 ;;
michael@0 4126 -static)
michael@0 4127 if test -z "$pic_flag" && test -n "$link_static_flag"; then
michael@0 4128 dlopen_self=$dlopen_self_static
michael@0 4129 fi
michael@0 4130 prefer_static_libs=built
michael@0 4131 ;;
michael@0 4132 -static-libtool-libs)
michael@0 4133 if test -z "$pic_flag" && test -n "$link_static_flag"; then
michael@0 4134 dlopen_self=$dlopen_self_static
michael@0 4135 fi
michael@0 4136 prefer_static_libs=yes
michael@0 4137 ;;
michael@0 4138 esac
michael@0 4139 build_libtool_libs=no
michael@0 4140 build_old_libs=yes
michael@0 4141 break
michael@0 4142 ;;
michael@0 4143 esac
michael@0 4144 done
michael@0 4145
michael@0 4146 # See if our shared archives depend on static archives.
michael@0 4147 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
michael@0 4148
michael@0 4149 # Go through the arguments, transforming them on the way.
michael@0 4150 while test "$#" -gt 0; do
michael@0 4151 arg="$1"
michael@0 4152 shift
michael@0 4153 func_quote_for_eval "$arg"
michael@0 4154 qarg=$func_quote_for_eval_unquoted_result
michael@0 4155 func_append libtool_args " $func_quote_for_eval_result"
michael@0 4156
michael@0 4157 # If the previous option needs an argument, assign it.
michael@0 4158 if test -n "$prev"; then
michael@0 4159 case $prev in
michael@0 4160 output)
michael@0 4161 func_append compile_command " @OUTPUT@"
michael@0 4162 func_append finalize_command " @OUTPUT@"
michael@0 4163 ;;
michael@0 4164 esac
michael@0 4165
michael@0 4166 case $prev in
michael@0 4167 dlfiles|dlprefiles)
michael@0 4168 if test "$preload" = no; then
michael@0 4169 # Add the symbol object into the linking commands.
michael@0 4170 func_append compile_command " @SYMFILE@"
michael@0 4171 func_append finalize_command " @SYMFILE@"
michael@0 4172 preload=yes
michael@0 4173 fi
michael@0 4174 case $arg in
michael@0 4175 *.la | *.lo) ;; # We handle these cases below.
michael@0 4176 force)
michael@0 4177 if test "$dlself" = no; then
michael@0 4178 dlself=needless
michael@0 4179 export_dynamic=yes
michael@0 4180 fi
michael@0 4181 prev=
michael@0 4182 continue
michael@0 4183 ;;
michael@0 4184 self)
michael@0 4185 if test "$prev" = dlprefiles; then
michael@0 4186 dlself=yes
michael@0 4187 elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
michael@0 4188 dlself=yes
michael@0 4189 else
michael@0 4190 dlself=needless
michael@0 4191 export_dynamic=yes
michael@0 4192 fi
michael@0 4193 prev=
michael@0 4194 continue
michael@0 4195 ;;
michael@0 4196 *)
michael@0 4197 if test "$prev" = dlfiles; then
michael@0 4198 dlfiles="$dlfiles $arg"
michael@0 4199 else
michael@0 4200 dlprefiles="$dlprefiles $arg"
michael@0 4201 fi
michael@0 4202 prev=
michael@0 4203 continue
michael@0 4204 ;;
michael@0 4205 esac
michael@0 4206 ;;
michael@0 4207 expsyms)
michael@0 4208 export_symbols="$arg"
michael@0 4209 test -f "$arg" \
michael@0 4210 || func_fatal_error "symbol file \`$arg' does not exist"
michael@0 4211 prev=
michael@0 4212 continue
michael@0 4213 ;;
michael@0 4214 expsyms_regex)
michael@0 4215 export_symbols_regex="$arg"
michael@0 4216 prev=
michael@0 4217 continue
michael@0 4218 ;;
michael@0 4219 framework)
michael@0 4220 case $host in
michael@0 4221 *-*-darwin*)
michael@0 4222 case "$deplibs " in
michael@0 4223 *" $qarg.ltframework "*) ;;
michael@0 4224 *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
michael@0 4225 ;;
michael@0 4226 esac
michael@0 4227 ;;
michael@0 4228 esac
michael@0 4229 prev=
michael@0 4230 continue
michael@0 4231 ;;
michael@0 4232 inst_prefix)
michael@0 4233 inst_prefix_dir="$arg"
michael@0 4234 prev=
michael@0 4235 continue
michael@0 4236 ;;
michael@0 4237 objectlist)
michael@0 4238 if test -f "$arg"; then
michael@0 4239 save_arg=$arg
michael@0 4240 moreargs=
michael@0 4241 for fil in `cat "$save_arg"`
michael@0 4242 do
michael@0 4243 # moreargs="$moreargs $fil"
michael@0 4244 arg=$fil
michael@0 4245 # A libtool-controlled object.
michael@0 4246
michael@0 4247 # Check to see that this really is a libtool object.
michael@0 4248 if func_lalib_unsafe_p "$arg"; then
michael@0 4249 pic_object=
michael@0 4250 non_pic_object=
michael@0 4251
michael@0 4252 # Read the .lo file
michael@0 4253 func_source "$arg"
michael@0 4254
michael@0 4255 if test -z "$pic_object" ||
michael@0 4256 test -z "$non_pic_object" ||
michael@0 4257 test "$pic_object" = none &&
michael@0 4258 test "$non_pic_object" = none; then
michael@0 4259 func_fatal_error "cannot find name of object for \`$arg'"
michael@0 4260 fi
michael@0 4261
michael@0 4262 # Extract subdirectory from the argument.
michael@0 4263 func_dirname "$arg" "/" ""
michael@0 4264 xdir="$func_dirname_result"
michael@0 4265
michael@0 4266 if test "$pic_object" != none; then
michael@0 4267 # Prepend the subdirectory the object is found in.
michael@0 4268 pic_object="$xdir$pic_object"
michael@0 4269
michael@0 4270 if test "$prev" = dlfiles; then
michael@0 4271 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
michael@0 4272 dlfiles="$dlfiles $pic_object"
michael@0 4273 prev=
michael@0 4274 continue
michael@0 4275 else
michael@0 4276 # If libtool objects are unsupported, then we need to preload.
michael@0 4277 prev=dlprefiles
michael@0 4278 fi
michael@0 4279 fi
michael@0 4280
michael@0 4281 # CHECK ME: I think I busted this. -Ossama
michael@0 4282 if test "$prev" = dlprefiles; then
michael@0 4283 # Preload the old-style object.
michael@0 4284 dlprefiles="$dlprefiles $pic_object"
michael@0 4285 prev=
michael@0 4286 fi
michael@0 4287
michael@0 4288 # A PIC object.
michael@0 4289 func_append libobjs " $pic_object"
michael@0 4290 arg="$pic_object"
michael@0 4291 fi
michael@0 4292
michael@0 4293 # Non-PIC object.
michael@0 4294 if test "$non_pic_object" != none; then
michael@0 4295 # Prepend the subdirectory the object is found in.
michael@0 4296 non_pic_object="$xdir$non_pic_object"
michael@0 4297
michael@0 4298 # A standard non-PIC object
michael@0 4299 func_append non_pic_objects " $non_pic_object"
michael@0 4300 if test -z "$pic_object" || test "$pic_object" = none ; then
michael@0 4301 arg="$non_pic_object"
michael@0 4302 fi
michael@0 4303 else
michael@0 4304 # If the PIC object exists, use it instead.
michael@0 4305 # $xdir was prepended to $pic_object above.
michael@0 4306 non_pic_object="$pic_object"
michael@0 4307 func_append non_pic_objects " $non_pic_object"
michael@0 4308 fi
michael@0 4309 else
michael@0 4310 # Only an error if not doing a dry-run.
michael@0 4311 if $opt_dry_run; then
michael@0 4312 # Extract subdirectory from the argument.
michael@0 4313 func_dirname "$arg" "/" ""
michael@0 4314 xdir="$func_dirname_result"
michael@0 4315
michael@0 4316 func_lo2o "$arg"
michael@0 4317 pic_object=$xdir$objdir/$func_lo2o_result
michael@0 4318 non_pic_object=$xdir$func_lo2o_result
michael@0 4319 func_append libobjs " $pic_object"
michael@0 4320 func_append non_pic_objects " $non_pic_object"
michael@0 4321 else
michael@0 4322 func_fatal_error "\`$arg' is not a valid libtool object"
michael@0 4323 fi
michael@0 4324 fi
michael@0 4325 done
michael@0 4326 else
michael@0 4327 func_fatal_error "link input file \`$arg' does not exist"
michael@0 4328 fi
michael@0 4329 arg=$save_arg
michael@0 4330 prev=
michael@0 4331 continue
michael@0 4332 ;;
michael@0 4333 precious_regex)
michael@0 4334 precious_files_regex="$arg"
michael@0 4335 prev=
michael@0 4336 continue
michael@0 4337 ;;
michael@0 4338 release)
michael@0 4339 release="-$arg"
michael@0 4340 prev=
michael@0 4341 continue
michael@0 4342 ;;
michael@0 4343 rpath | xrpath)
michael@0 4344 # We need an absolute path.
michael@0 4345 case $arg in
michael@0 4346 [\\/]* | [A-Za-z]:[\\/]*) ;;
michael@0 4347 *)
michael@0 4348 func_fatal_error "only absolute run-paths are allowed"
michael@0 4349 ;;
michael@0 4350 esac
michael@0 4351 if test "$prev" = rpath; then
michael@0 4352 case "$rpath " in
michael@0 4353 *" $arg "*) ;;
michael@0 4354 *) rpath="$rpath $arg" ;;
michael@0 4355 esac
michael@0 4356 else
michael@0 4357 case "$xrpath " in
michael@0 4358 *" $arg "*) ;;
michael@0 4359 *) xrpath="$xrpath $arg" ;;
michael@0 4360 esac
michael@0 4361 fi
michael@0 4362 prev=
michael@0 4363 continue
michael@0 4364 ;;
michael@0 4365 shrext)
michael@0 4366 shrext_cmds="$arg"
michael@0 4367 prev=
michael@0 4368 continue
michael@0 4369 ;;
michael@0 4370 weak)
michael@0 4371 weak_libs="$weak_libs $arg"
michael@0 4372 prev=
michael@0 4373 continue
michael@0 4374 ;;
michael@0 4375 xcclinker)
michael@0 4376 linker_flags="$linker_flags $qarg"
michael@0 4377 compiler_flags="$compiler_flags $qarg"
michael@0 4378 prev=
michael@0 4379 func_append compile_command " $qarg"
michael@0 4380 func_append finalize_command " $qarg"
michael@0 4381 continue
michael@0 4382 ;;
michael@0 4383 xcompiler)
michael@0 4384 compiler_flags="$compiler_flags $qarg"
michael@0 4385 prev=
michael@0 4386 func_append compile_command " $qarg"
michael@0 4387 func_append finalize_command " $qarg"
michael@0 4388 continue
michael@0 4389 ;;
michael@0 4390 xlinker)
michael@0 4391 linker_flags="$linker_flags $qarg"
michael@0 4392 compiler_flags="$compiler_flags $wl$qarg"
michael@0 4393 prev=
michael@0 4394 func_append compile_command " $wl$qarg"
michael@0 4395 func_append finalize_command " $wl$qarg"
michael@0 4396 continue
michael@0 4397 ;;
michael@0 4398 *)
michael@0 4399 eval "$prev=\"\$arg\""
michael@0 4400 prev=
michael@0 4401 continue
michael@0 4402 ;;
michael@0 4403 esac
michael@0 4404 fi # test -n "$prev"
michael@0 4405
michael@0 4406 prevarg="$arg"
michael@0 4407
michael@0 4408 case $arg in
michael@0 4409 -all-static)
michael@0 4410 if test -n "$link_static_flag"; then
michael@0 4411 # See comment for -static flag below, for more details.
michael@0 4412 func_append compile_command " $link_static_flag"
michael@0 4413 func_append finalize_command " $link_static_flag"
michael@0 4414 fi
michael@0 4415 continue
michael@0 4416 ;;
michael@0 4417
michael@0 4418 -allow-undefined)
michael@0 4419 # FIXME: remove this flag sometime in the future.
michael@0 4420 func_fatal_error "\`-allow-undefined' must not be used because it is the default"
michael@0 4421 ;;
michael@0 4422
michael@0 4423 -avoid-version)
michael@0 4424 avoid_version=yes
michael@0 4425 continue
michael@0 4426 ;;
michael@0 4427
michael@0 4428 -dlopen)
michael@0 4429 prev=dlfiles
michael@0 4430 continue
michael@0 4431 ;;
michael@0 4432
michael@0 4433 -dlpreopen)
michael@0 4434 prev=dlprefiles
michael@0 4435 continue
michael@0 4436 ;;
michael@0 4437
michael@0 4438 -export-dynamic)
michael@0 4439 export_dynamic=yes
michael@0 4440 continue
michael@0 4441 ;;
michael@0 4442
michael@0 4443 -export-symbols | -export-symbols-regex)
michael@0 4444 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
michael@0 4445 func_fatal_error "more than one -exported-symbols argument is not allowed"
michael@0 4446 fi
michael@0 4447 if test "X$arg" = "X-export-symbols"; then
michael@0 4448 prev=expsyms
michael@0 4449 else
michael@0 4450 prev=expsyms_regex
michael@0 4451 fi
michael@0 4452 continue
michael@0 4453 ;;
michael@0 4454
michael@0 4455 -framework)
michael@0 4456 prev=framework
michael@0 4457 continue
michael@0 4458 ;;
michael@0 4459
michael@0 4460 -inst-prefix-dir)
michael@0 4461 prev=inst_prefix
michael@0 4462 continue
michael@0 4463 ;;
michael@0 4464
michael@0 4465 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
michael@0 4466 # so, if we see these flags be careful not to treat them like -L
michael@0 4467 -L[A-Z][A-Z]*:*)
michael@0 4468 case $with_gcc/$host in
michael@0 4469 no/*-*-irix* | /*-*-irix*)
michael@0 4470 func_append compile_command " $arg"
michael@0 4471 func_append finalize_command " $arg"
michael@0 4472 ;;
michael@0 4473 esac
michael@0 4474 continue
michael@0 4475 ;;
michael@0 4476
michael@0 4477 -L*)
michael@0 4478 func_stripname '-L' '' "$arg"
michael@0 4479 dir=$func_stripname_result
michael@0 4480 if test -z "$dir"; then
michael@0 4481 if test "$#" -gt 0; then
michael@0 4482 func_fatal_error "require no space between \`-L' and \`$1'"
michael@0 4483 else
michael@0 4484 func_fatal_error "need path for \`-L' option"
michael@0 4485 fi
michael@0 4486 fi
michael@0 4487 # We need an absolute path.
michael@0 4488 case $dir in
michael@0 4489 [\\/]* | [A-Za-z]:[\\/]*) ;;
michael@0 4490 *)
michael@0 4491 absdir=`cd "$dir" && pwd`
michael@0 4492 test -z "$absdir" && \
michael@0 4493 func_fatal_error "cannot determine absolute directory name of \`$dir'"
michael@0 4494 dir="$absdir"
michael@0 4495 ;;
michael@0 4496 esac
michael@0 4497 case "$deplibs " in
michael@0 4498 *" -L$dir "*) ;;
michael@0 4499 *)
michael@0 4500 deplibs="$deplibs -L$dir"
michael@0 4501 lib_search_path="$lib_search_path $dir"
michael@0 4502 ;;
michael@0 4503 esac
michael@0 4504 case $host in
michael@0 4505 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
michael@0 4506 testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
michael@0 4507 case :$dllsearchpath: in
michael@0 4508 *":$dir:"*) ;;
michael@0 4509 ::) dllsearchpath=$dir;;
michael@0 4510 *) dllsearchpath="$dllsearchpath:$dir";;
michael@0 4511 esac
michael@0 4512 case :$dllsearchpath: in
michael@0 4513 *":$testbindir:"*) ;;
michael@0 4514 ::) dllsearchpath=$testbindir;;
michael@0 4515 *) dllsearchpath="$dllsearchpath:$testbindir";;
michael@0 4516 esac
michael@0 4517 ;;
michael@0 4518 esac
michael@0 4519 continue
michael@0 4520 ;;
michael@0 4521
michael@0 4522 -l*)
michael@0 4523 if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
michael@0 4524 case $host in
michael@0 4525 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
michael@0 4526 # These systems don't actually have a C or math library (as such)
michael@0 4527 continue
michael@0 4528 ;;
michael@0 4529 *-*-os2*)
michael@0 4530 # These systems don't actually have a C library (as such)
michael@0 4531 test "X$arg" = "X-lc" && continue
michael@0 4532 ;;
michael@0 4533 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
michael@0 4534 # Do not include libc due to us having libc/libc_r.
michael@0 4535 test "X$arg" = "X-lc" && continue
michael@0 4536 ;;
michael@0 4537 *-*-rhapsody* | *-*-darwin1.[012])
michael@0 4538 # Rhapsody C and math libraries are in the System framework
michael@0 4539 deplibs="$deplibs System.ltframework"
michael@0 4540 continue
michael@0 4541 ;;
michael@0 4542 *-*-sco3.2v5* | *-*-sco5v6*)
michael@0 4543 # Causes problems with __ctype
michael@0 4544 test "X$arg" = "X-lc" && continue
michael@0 4545 ;;
michael@0 4546 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
michael@0 4547 # Compiler inserts libc in the correct place for threads to work
michael@0 4548 test "X$arg" = "X-lc" && continue
michael@0 4549 ;;
michael@0 4550 esac
michael@0 4551 elif test "X$arg" = "X-lc_r"; then
michael@0 4552 case $host in
michael@0 4553 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
michael@0 4554 # Do not include libc_r directly, use -pthread flag.
michael@0 4555 continue
michael@0 4556 ;;
michael@0 4557 esac
michael@0 4558 fi
michael@0 4559 deplibs="$deplibs $arg"
michael@0 4560 continue
michael@0 4561 ;;
michael@0 4562
michael@0 4563 -module)
michael@0 4564 module=yes
michael@0 4565 continue
michael@0 4566 ;;
michael@0 4567
michael@0 4568 # Tru64 UNIX uses -model [arg] to determine the layout of C++
michael@0 4569 # classes, name mangling, and exception handling.
michael@0 4570 # Darwin uses the -arch flag to determine output architecture.
michael@0 4571 -model|-arch|-isysroot)
michael@0 4572 compiler_flags="$compiler_flags $arg"
michael@0 4573 func_append compile_command " $arg"
michael@0 4574 func_append finalize_command " $arg"
michael@0 4575 prev=xcompiler
michael@0 4576 continue
michael@0 4577 ;;
michael@0 4578
michael@0 4579 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
michael@0 4580 compiler_flags="$compiler_flags $arg"
michael@0 4581 func_append compile_command " $arg"
michael@0 4582 func_append finalize_command " $arg"
michael@0 4583 case "$new_inherited_linker_flags " in
michael@0 4584 *" $arg "*) ;;
michael@0 4585 * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
michael@0 4586 esac
michael@0 4587 continue
michael@0 4588 ;;
michael@0 4589
michael@0 4590 -multi_module)
michael@0 4591 single_module="${wl}-multi_module"
michael@0 4592 continue
michael@0 4593 ;;
michael@0 4594
michael@0 4595 -no-fast-install)
michael@0 4596 fast_install=no
michael@0 4597 continue
michael@0 4598 ;;
michael@0 4599
michael@0 4600 -no-install)
michael@0 4601 case $host in
michael@0 4602 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
michael@0 4603 # The PATH hackery in wrapper scripts is required on Windows
michael@0 4604 # and Darwin in order for the loader to find any dlls it needs.
michael@0 4605 func_warning "\`-no-install' is ignored for $host"
michael@0 4606 func_warning "assuming \`-no-fast-install' instead"
michael@0 4607 fast_install=no
michael@0 4608 ;;
michael@0 4609 *) no_install=yes ;;
michael@0 4610 esac
michael@0 4611 continue
michael@0 4612 ;;
michael@0 4613
michael@0 4614 -no-undefined)
michael@0 4615 allow_undefined=no
michael@0 4616 continue
michael@0 4617 ;;
michael@0 4618
michael@0 4619 -objectlist)
michael@0 4620 prev=objectlist
michael@0 4621 continue
michael@0 4622 ;;
michael@0 4623
michael@0 4624 -o) prev=output ;;
michael@0 4625
michael@0 4626 -precious-files-regex)
michael@0 4627 prev=precious_regex
michael@0 4628 continue
michael@0 4629 ;;
michael@0 4630
michael@0 4631 -release)
michael@0 4632 prev=release
michael@0 4633 continue
michael@0 4634 ;;
michael@0 4635
michael@0 4636 -rpath)
michael@0 4637 prev=rpath
michael@0 4638 continue
michael@0 4639 ;;
michael@0 4640
michael@0 4641 -R)
michael@0 4642 prev=xrpath
michael@0 4643 continue
michael@0 4644 ;;
michael@0 4645
michael@0 4646 -R*)
michael@0 4647 func_stripname '-R' '' "$arg"
michael@0 4648 dir=$func_stripname_result
michael@0 4649 # We need an absolute path.
michael@0 4650 case $dir in
michael@0 4651 [\\/]* | [A-Za-z]:[\\/]*) ;;
michael@0 4652 *)
michael@0 4653 func_fatal_error "only absolute run-paths are allowed"
michael@0 4654 ;;
michael@0 4655 esac
michael@0 4656 case "$xrpath " in
michael@0 4657 *" $dir "*) ;;
michael@0 4658 *) xrpath="$xrpath $dir" ;;
michael@0 4659 esac
michael@0 4660 continue
michael@0 4661 ;;
michael@0 4662
michael@0 4663 -shared)
michael@0 4664 # The effects of -shared are defined in a previous loop.
michael@0 4665 continue
michael@0 4666 ;;
michael@0 4667
michael@0 4668 -shrext)
michael@0 4669 prev=shrext
michael@0 4670 continue
michael@0 4671 ;;
michael@0 4672
michael@0 4673 -static | -static-libtool-libs)
michael@0 4674 # The effects of -static are defined in a previous loop.
michael@0 4675 # We used to do the same as -all-static on platforms that
michael@0 4676 # didn't have a PIC flag, but the assumption that the effects
michael@0 4677 # would be equivalent was wrong. It would break on at least
michael@0 4678 # Digital Unix and AIX.
michael@0 4679 continue
michael@0 4680 ;;
michael@0 4681
michael@0 4682 -thread-safe)
michael@0 4683 thread_safe=yes
michael@0 4684 continue
michael@0 4685 ;;
michael@0 4686
michael@0 4687 -version-info)
michael@0 4688 prev=vinfo
michael@0 4689 continue
michael@0 4690 ;;
michael@0 4691
michael@0 4692 -version-number)
michael@0 4693 prev=vinfo
michael@0 4694 vinfo_number=yes
michael@0 4695 continue
michael@0 4696 ;;
michael@0 4697
michael@0 4698 -weak)
michael@0 4699 prev=weak
michael@0 4700 continue
michael@0 4701 ;;
michael@0 4702
michael@0 4703 -Wc,*)
michael@0 4704 func_stripname '-Wc,' '' "$arg"
michael@0 4705 args=$func_stripname_result
michael@0 4706 arg=
michael@0 4707 save_ifs="$IFS"; IFS=','
michael@0 4708 for flag in $args; do
michael@0 4709 IFS="$save_ifs"
michael@0 4710 func_quote_for_eval "$flag"
michael@0 4711 arg="$arg $wl$func_quote_for_eval_result"
michael@0 4712 compiler_flags="$compiler_flags $func_quote_for_eval_result"
michael@0 4713 done
michael@0 4714 IFS="$save_ifs"
michael@0 4715 func_stripname ' ' '' "$arg"
michael@0 4716 arg=$func_stripname_result
michael@0 4717 ;;
michael@0 4718
michael@0 4719 -Wl,*)
michael@0 4720 func_stripname '-Wl,' '' "$arg"
michael@0 4721 args=$func_stripname_result
michael@0 4722 arg=
michael@0 4723 save_ifs="$IFS"; IFS=','
michael@0 4724 for flag in $args; do
michael@0 4725 IFS="$save_ifs"
michael@0 4726 func_quote_for_eval "$flag"
michael@0 4727 arg="$arg $wl$func_quote_for_eval_result"
michael@0 4728 compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
michael@0 4729 linker_flags="$linker_flags $func_quote_for_eval_result"
michael@0 4730 done
michael@0 4731 IFS="$save_ifs"
michael@0 4732 func_stripname ' ' '' "$arg"
michael@0 4733 arg=$func_stripname_result
michael@0 4734 ;;
michael@0 4735
michael@0 4736 -Xcompiler)
michael@0 4737 prev=xcompiler
michael@0 4738 continue
michael@0 4739 ;;
michael@0 4740
michael@0 4741 -Xlinker)
michael@0 4742 prev=xlinker
michael@0 4743 continue
michael@0 4744 ;;
michael@0 4745
michael@0 4746 -XCClinker)
michael@0 4747 prev=xcclinker
michael@0 4748 continue
michael@0 4749 ;;
michael@0 4750
michael@0 4751 # -msg_* for osf cc
michael@0 4752 -msg_*)
michael@0 4753 func_quote_for_eval "$arg"
michael@0 4754 arg="$func_quote_for_eval_result"
michael@0 4755 ;;
michael@0 4756
michael@0 4757 # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
michael@0 4758 # -r[0-9][0-9]* specifies the processor on the SGI compiler
michael@0 4759 # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
michael@0 4760 # +DA*, +DD* enable 64-bit mode on the HP compiler
michael@0 4761 # -q* pass through compiler args for the IBM compiler
michael@0 4762 # -m*, -t[45]*, -txscale* pass through architecture-specific
michael@0 4763 # compiler args for GCC
michael@0 4764 # -F/path gives path to uninstalled frameworks, gcc on darwin
michael@0 4765 # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
michael@0 4766 # @file GCC response files
michael@0 4767 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
michael@0 4768 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
michael@0 4769 func_quote_for_eval "$arg"
michael@0 4770 arg="$func_quote_for_eval_result"
michael@0 4771 func_append compile_command " $arg"
michael@0 4772 func_append finalize_command " $arg"
michael@0 4773 compiler_flags="$compiler_flags $arg"
michael@0 4774 continue
michael@0 4775 ;;
michael@0 4776
michael@0 4777 # Some other compiler flag.
michael@0 4778 -* | +*)
michael@0 4779 func_quote_for_eval "$arg"
michael@0 4780 arg="$func_quote_for_eval_result"
michael@0 4781 ;;
michael@0 4782
michael@0 4783 *.$objext)
michael@0 4784 # A standard object.
michael@0 4785 objs="$objs $arg"
michael@0 4786 ;;
michael@0 4787
michael@0 4788 *.lo)
michael@0 4789 # A libtool-controlled object.
michael@0 4790
michael@0 4791 # Check to see that this really is a libtool object.
michael@0 4792 if func_lalib_unsafe_p "$arg"; then
michael@0 4793 pic_object=
michael@0 4794 non_pic_object=
michael@0 4795
michael@0 4796 # Read the .lo file
michael@0 4797 func_source "$arg"
michael@0 4798
michael@0 4799 if test -z "$pic_object" ||
michael@0 4800 test -z "$non_pic_object" ||
michael@0 4801 test "$pic_object" = none &&
michael@0 4802 test "$non_pic_object" = none; then
michael@0 4803 func_fatal_error "cannot find name of object for \`$arg'"
michael@0 4804 fi
michael@0 4805
michael@0 4806 # Extract subdirectory from the argument.
michael@0 4807 func_dirname "$arg" "/" ""
michael@0 4808 xdir="$func_dirname_result"
michael@0 4809
michael@0 4810 if test "$pic_object" != none; then
michael@0 4811 # Prepend the subdirectory the object is found in.
michael@0 4812 pic_object="$xdir$pic_object"
michael@0 4813
michael@0 4814 if test "$prev" = dlfiles; then
michael@0 4815 if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
michael@0 4816 dlfiles="$dlfiles $pic_object"
michael@0 4817 prev=
michael@0 4818 continue
michael@0 4819 else
michael@0 4820 # If libtool objects are unsupported, then we need to preload.
michael@0 4821 prev=dlprefiles
michael@0 4822 fi
michael@0 4823 fi
michael@0 4824
michael@0 4825 # CHECK ME: I think I busted this. -Ossama
michael@0 4826 if test "$prev" = dlprefiles; then
michael@0 4827 # Preload the old-style object.
michael@0 4828 dlprefiles="$dlprefiles $pic_object"
michael@0 4829 prev=
michael@0 4830 fi
michael@0 4831
michael@0 4832 # A PIC object.
michael@0 4833 func_append libobjs " $pic_object"
michael@0 4834 arg="$pic_object"
michael@0 4835 fi
michael@0 4836
michael@0 4837 # Non-PIC object.
michael@0 4838 if test "$non_pic_object" != none; then
michael@0 4839 # Prepend the subdirectory the object is found in.
michael@0 4840 non_pic_object="$xdir$non_pic_object"
michael@0 4841
michael@0 4842 # A standard non-PIC object
michael@0 4843 func_append non_pic_objects " $non_pic_object"
michael@0 4844 if test -z "$pic_object" || test "$pic_object" = none ; then
michael@0 4845 arg="$non_pic_object"
michael@0 4846 fi
michael@0 4847 else
michael@0 4848 # If the PIC object exists, use it instead.
michael@0 4849 # $xdir was prepended to $pic_object above.
michael@0 4850 non_pic_object="$pic_object"
michael@0 4851 func_append non_pic_objects " $non_pic_object"
michael@0 4852 fi
michael@0 4853 else
michael@0 4854 # Only an error if not doing a dry-run.
michael@0 4855 if $opt_dry_run; then
michael@0 4856 # Extract subdirectory from the argument.
michael@0 4857 func_dirname "$arg" "/" ""
michael@0 4858 xdir="$func_dirname_result"
michael@0 4859
michael@0 4860 func_lo2o "$arg"
michael@0 4861 pic_object=$xdir$objdir/$func_lo2o_result
michael@0 4862 non_pic_object=$xdir$func_lo2o_result
michael@0 4863 func_append libobjs " $pic_object"
michael@0 4864 func_append non_pic_objects " $non_pic_object"
michael@0 4865 else
michael@0 4866 func_fatal_error "\`$arg' is not a valid libtool object"
michael@0 4867 fi
michael@0 4868 fi
michael@0 4869 ;;
michael@0 4870
michael@0 4871 *.$libext)
michael@0 4872 # An archive.
michael@0 4873 deplibs="$deplibs $arg"
michael@0 4874 old_deplibs="$old_deplibs $arg"
michael@0 4875 continue
michael@0 4876 ;;
michael@0 4877
michael@0 4878 *.la)
michael@0 4879 # A libtool-controlled library.
michael@0 4880
michael@0 4881 if test "$prev" = dlfiles; then
michael@0 4882 # This library was specified with -dlopen.
michael@0 4883 dlfiles="$dlfiles $arg"
michael@0 4884 prev=
michael@0 4885 elif test "$prev" = dlprefiles; then
michael@0 4886 # The library was specified with -dlpreopen.
michael@0 4887 dlprefiles="$dlprefiles $arg"
michael@0 4888 prev=
michael@0 4889 else
michael@0 4890 deplibs="$deplibs $arg"
michael@0 4891 fi
michael@0 4892 continue
michael@0 4893 ;;
michael@0 4894
michael@0 4895 # Some other compiler argument.
michael@0 4896 *)
michael@0 4897 # Unknown arguments in both finalize_command and compile_command need
michael@0 4898 # to be aesthetically quoted because they are evaled later.
michael@0 4899 func_quote_for_eval "$arg"
michael@0 4900 arg="$func_quote_for_eval_result"
michael@0 4901 ;;
michael@0 4902 esac # arg
michael@0 4903
michael@0 4904 # Now actually substitute the argument into the commands.
michael@0 4905 if test -n "$arg"; then
michael@0 4906 func_append compile_command " $arg"
michael@0 4907 func_append finalize_command " $arg"
michael@0 4908 fi
michael@0 4909 done # argument parsing loop
michael@0 4910
michael@0 4911 test -n "$prev" && \
michael@0 4912 func_fatal_help "the \`$prevarg' option requires an argument"
michael@0 4913
michael@0 4914 if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
michael@0 4915 eval arg=\"$export_dynamic_flag_spec\"
michael@0 4916 func_append compile_command " $arg"
michael@0 4917 func_append finalize_command " $arg"
michael@0 4918 fi
michael@0 4919
michael@0 4920 oldlibs=
michael@0 4921 # calculate the name of the file, without its directory
michael@0 4922 func_basename "$output"
michael@0 4923 outputname="$func_basename_result"
michael@0 4924 libobjs_save="$libobjs"
michael@0 4925
michael@0 4926 if test -n "$shlibpath_var"; then
michael@0 4927 # get the directories listed in $shlibpath_var
michael@0 4928 eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
michael@0 4929 else
michael@0 4930 shlib_search_path=
michael@0 4931 fi
michael@0 4932 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
michael@0 4933 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
michael@0 4934
michael@0 4935 func_dirname "$output" "/" ""
michael@0 4936 output_objdir="$func_dirname_result$objdir"
michael@0 4937 # Create the object directory.
michael@0 4938 func_mkdir_p "$output_objdir"
michael@0 4939
michael@0 4940 # Determine the type of output
michael@0 4941 case $output in
michael@0 4942 "")
michael@0 4943 func_fatal_help "you must specify an output file"
michael@0 4944 ;;
michael@0 4945 *.$libext) linkmode=oldlib ;;
michael@0 4946 *.lo | *.$objext) linkmode=obj ;;
michael@0 4947 *.la) linkmode=lib ;;
michael@0 4948 *) linkmode=prog ;; # Anything else should be a program.
michael@0 4949 esac
michael@0 4950
michael@0 4951 specialdeplibs=
michael@0 4952
michael@0 4953 libs=
michael@0 4954 # Find all interdependent deplibs by searching for libraries
michael@0 4955 # that are linked more than once (e.g. -la -lb -la)
michael@0 4956 for deplib in $deplibs; do
michael@0 4957 if $opt_duplicate_deps ; then
michael@0 4958 case "$libs " in
michael@0 4959 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
michael@0 4960 esac
michael@0 4961 fi
michael@0 4962 libs="$libs $deplib"
michael@0 4963 done
michael@0 4964
michael@0 4965 if test "$linkmode" = lib; then
michael@0 4966 libs="$predeps $libs $compiler_lib_search_path $postdeps"
michael@0 4967
michael@0 4968 # Compute libraries that are listed more than once in $predeps
michael@0 4969 # $postdeps and mark them as special (i.e., whose duplicates are
michael@0 4970 # not to be eliminated).
michael@0 4971 pre_post_deps=
michael@0 4972 if $opt_duplicate_compiler_generated_deps; then
michael@0 4973 for pre_post_dep in $predeps $postdeps; do
michael@0 4974 case "$pre_post_deps " in
michael@0 4975 *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
michael@0 4976 esac
michael@0 4977 pre_post_deps="$pre_post_deps $pre_post_dep"
michael@0 4978 done
michael@0 4979 fi
michael@0 4980 pre_post_deps=
michael@0 4981 fi
michael@0 4982
michael@0 4983 deplibs=
michael@0 4984 newdependency_libs=
michael@0 4985 newlib_search_path=
michael@0 4986 need_relink=no # whether we're linking any uninstalled libtool libraries
michael@0 4987 notinst_deplibs= # not-installed libtool libraries
michael@0 4988 notinst_path= # paths that contain not-installed libtool libraries
michael@0 4989
michael@0 4990 case $linkmode in
michael@0 4991 lib)
michael@0 4992 passes="conv dlpreopen link"
michael@0 4993 for file in $dlfiles $dlprefiles; do
michael@0 4994 case $file in
michael@0 4995 *.la) ;;
michael@0 4996 *)
michael@0 4997 func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
michael@0 4998 ;;
michael@0 4999 esac
michael@0 5000 done
michael@0 5001 ;;
michael@0 5002 prog)
michael@0 5003 compile_deplibs=
michael@0 5004 finalize_deplibs=
michael@0 5005 alldeplibs=no
michael@0 5006 newdlfiles=
michael@0 5007 newdlprefiles=
michael@0 5008 passes="conv scan dlopen dlpreopen link"
michael@0 5009 ;;
michael@0 5010 *) passes="conv"
michael@0 5011 ;;
michael@0 5012 esac
michael@0 5013
michael@0 5014 for pass in $passes; do
michael@0 5015 # The preopen pass in lib mode reverses $deplibs; put it back here
michael@0 5016 # so that -L comes before libs that need it for instance...
michael@0 5017 if test "$linkmode,$pass" = "lib,link"; then
michael@0 5018 ## FIXME: Find the place where the list is rebuilt in the wrong
michael@0 5019 ## order, and fix it there properly
michael@0 5020 tmp_deplibs=
michael@0 5021 for deplib in $deplibs; do
michael@0 5022 tmp_deplibs="$deplib $tmp_deplibs"
michael@0 5023 done
michael@0 5024 deplibs="$tmp_deplibs"
michael@0 5025 fi
michael@0 5026
michael@0 5027 if test "$linkmode,$pass" = "lib,link" ||
michael@0 5028 test "$linkmode,$pass" = "prog,scan"; then
michael@0 5029 libs="$deplibs"
michael@0 5030 deplibs=
michael@0 5031 fi
michael@0 5032 if test "$linkmode" = prog; then
michael@0 5033 case $pass in
michael@0 5034 dlopen) libs="$dlfiles" ;;
michael@0 5035 dlpreopen) libs="$dlprefiles" ;;
michael@0 5036 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
michael@0 5037 esac
michael@0 5038 fi
michael@0 5039 if test "$linkmode,$pass" = "lib,dlpreopen"; then
michael@0 5040 # Collect and forward deplibs of preopened libtool libs
michael@0 5041 for lib in $dlprefiles; do
michael@0 5042 # Ignore non-libtool-libs
michael@0 5043 dependency_libs=
michael@0 5044 case $lib in
michael@0 5045 *.la) func_source "$lib" ;;
michael@0 5046 esac
michael@0 5047
michael@0 5048 # Collect preopened libtool deplibs, except any this library
michael@0 5049 # has declared as weak libs
michael@0 5050 for deplib in $dependency_libs; do
michael@0 5051 deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
michael@0 5052 case " $weak_libs " in
michael@0 5053 *" $deplib_base "*) ;;
michael@0 5054 *) deplibs="$deplibs $deplib" ;;
michael@0 5055 esac
michael@0 5056 done
michael@0 5057 done
michael@0 5058 libs="$dlprefiles"
michael@0 5059 fi
michael@0 5060 if test "$pass" = dlopen; then
michael@0 5061 # Collect dlpreopened libraries
michael@0 5062 save_deplibs="$deplibs"
michael@0 5063 deplibs=
michael@0 5064 fi
michael@0 5065
michael@0 5066 for deplib in $libs; do
michael@0 5067 lib=
michael@0 5068 found=no
michael@0 5069 case $deplib in
michael@0 5070 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
michael@0 5071 if test "$linkmode,$pass" = "prog,link"; then
michael@0 5072 compile_deplibs="$deplib $compile_deplibs"
michael@0 5073 finalize_deplibs="$deplib $finalize_deplibs"
michael@0 5074 else
michael@0 5075 compiler_flags="$compiler_flags $deplib"
michael@0 5076 if test "$linkmode" = lib ; then
michael@0 5077 case "$new_inherited_linker_flags " in
michael@0 5078 *" $deplib "*) ;;
michael@0 5079 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
michael@0 5080 esac
michael@0 5081 fi
michael@0 5082 fi
michael@0 5083 continue
michael@0 5084 ;;
michael@0 5085 -l*)
michael@0 5086 if test "$linkmode" != lib && test "$linkmode" != prog; then
michael@0 5087 func_warning "\`-l' is ignored for archives/objects"
michael@0 5088 continue
michael@0 5089 fi
michael@0 5090 func_stripname '-l' '' "$deplib"
michael@0 5091 name=$func_stripname_result
michael@0 5092 if test "$linkmode" = lib; then
michael@0 5093 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
michael@0 5094 else
michael@0 5095 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
michael@0 5096 fi
michael@0 5097 for searchdir in $searchdirs; do
michael@0 5098 for search_ext in .la $std_shrext .so .a; do
michael@0 5099 # Search the libtool library
michael@0 5100 lib="$searchdir/lib${name}${search_ext}"
michael@0 5101 if test -f "$lib"; then
michael@0 5102 if test "$search_ext" = ".la"; then
michael@0 5103 found=yes
michael@0 5104 else
michael@0 5105 found=no
michael@0 5106 fi
michael@0 5107 break 2
michael@0 5108 fi
michael@0 5109 done
michael@0 5110 done
michael@0 5111 if test "$found" != yes; then
michael@0 5112 # deplib doesn't seem to be a libtool library
michael@0 5113 if test "$linkmode,$pass" = "prog,link"; then
michael@0 5114 compile_deplibs="$deplib $compile_deplibs"
michael@0 5115 finalize_deplibs="$deplib $finalize_deplibs"
michael@0 5116 else
michael@0 5117 deplibs="$deplib $deplibs"
michael@0 5118 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
michael@0 5119 fi
michael@0 5120 continue
michael@0 5121 else # deplib is a libtool library
michael@0 5122 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
michael@0 5123 # We need to do some special things here, and not later.
michael@0 5124 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
michael@0 5125 case " $predeps $postdeps " in
michael@0 5126 *" $deplib "*)
michael@0 5127 if func_lalib_p "$lib"; then
michael@0 5128 library_names=
michael@0 5129 old_library=
michael@0 5130 func_source "$lib"
michael@0 5131 for l in $old_library $library_names; do
michael@0 5132 ll="$l"
michael@0 5133 done
michael@0 5134 if test "X$ll" = "X$old_library" ; then # only static version available
michael@0 5135 found=no
michael@0 5136 func_dirname "$lib" "" "."
michael@0 5137 ladir="$func_dirname_result"
michael@0 5138 lib=$ladir/$old_library
michael@0 5139 if test "$linkmode,$pass" = "prog,link"; then
michael@0 5140 compile_deplibs="$deplib $compile_deplibs"
michael@0 5141 finalize_deplibs="$deplib $finalize_deplibs"
michael@0 5142 else
michael@0 5143 deplibs="$deplib $deplibs"
michael@0 5144 test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
michael@0 5145 fi
michael@0 5146 continue
michael@0 5147 fi
michael@0 5148 fi
michael@0 5149 ;;
michael@0 5150 *) ;;
michael@0 5151 esac
michael@0 5152 fi
michael@0 5153 fi
michael@0 5154 ;; # -l
michael@0 5155 *.ltframework)
michael@0 5156 if test "$linkmode,$pass" = "prog,link"; then
michael@0 5157 compile_deplibs="$deplib $compile_deplibs"
michael@0 5158 finalize_deplibs="$deplib $finalize_deplibs"
michael@0 5159 else
michael@0 5160 deplibs="$deplib $deplibs"
michael@0 5161 if test "$linkmode" = lib ; then
michael@0 5162 case "$new_inherited_linker_flags " in
michael@0 5163 *" $deplib "*) ;;
michael@0 5164 * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
michael@0 5165 esac
michael@0 5166 fi
michael@0 5167 fi
michael@0 5168 continue
michael@0 5169 ;;
michael@0 5170 -L*)
michael@0 5171 case $linkmode in
michael@0 5172 lib)
michael@0 5173 deplibs="$deplib $deplibs"
michael@0 5174 test "$pass" = conv && continue
michael@0 5175 newdependency_libs="$deplib $newdependency_libs"
michael@0 5176 func_stripname '-L' '' "$deplib"
michael@0 5177 newlib_search_path="$newlib_search_path $func_stripname_result"
michael@0 5178 ;;
michael@0 5179 prog)
michael@0 5180 if test "$pass" = conv; then
michael@0 5181 deplibs="$deplib $deplibs"
michael@0 5182 continue
michael@0 5183 fi
michael@0 5184 if test "$pass" = scan; then
michael@0 5185 deplibs="$deplib $deplibs"
michael@0 5186 else
michael@0 5187 compile_deplibs="$deplib $compile_deplibs"
michael@0 5188 finalize_deplibs="$deplib $finalize_deplibs"
michael@0 5189 fi
michael@0 5190 func_stripname '-L' '' "$deplib"
michael@0 5191 newlib_search_path="$newlib_search_path $func_stripname_result"
michael@0 5192 ;;
michael@0 5193 *)
michael@0 5194 func_warning "\`-L' is ignored for archives/objects"
michael@0 5195 ;;
michael@0 5196 esac # linkmode
michael@0 5197 continue
michael@0 5198 ;; # -L
michael@0 5199 -R*)
michael@0 5200 if test "$pass" = link; then
michael@0 5201 func_stripname '-R' '' "$deplib"
michael@0 5202 dir=$func_stripname_result
michael@0 5203 # Make sure the xrpath contains only unique directories.
michael@0 5204 case "$xrpath " in
michael@0 5205 *" $dir "*) ;;
michael@0 5206 *) xrpath="$xrpath $dir" ;;
michael@0 5207 esac
michael@0 5208 fi
michael@0 5209 deplibs="$deplib $deplibs"
michael@0 5210 continue
michael@0 5211 ;;
michael@0 5212 *.la) lib="$deplib" ;;
michael@0 5213 *.$libext)
michael@0 5214 if test "$pass" = conv; then
michael@0 5215 deplibs="$deplib $deplibs"
michael@0 5216 continue
michael@0 5217 fi
michael@0 5218 case $linkmode in
michael@0 5219 lib)
michael@0 5220 # Linking convenience modules into shared libraries is allowed,
michael@0 5221 # but linking other static libraries is non-portable.
michael@0 5222 case " $dlpreconveniencelibs " in
michael@0 5223 *" $deplib "*) ;;
michael@0 5224 *)
michael@0 5225 valid_a_lib=no
michael@0 5226 case $deplibs_check_method in
michael@0 5227 match_pattern*)
michael@0 5228 set dummy $deplibs_check_method; shift
michael@0 5229 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
michael@0 5230 if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
michael@0 5231 | $EGREP "$match_pattern_regex" > /dev/null; then
michael@0 5232 valid_a_lib=yes
michael@0 5233 fi
michael@0 5234 ;;
michael@0 5235 pass_all)
michael@0 5236 valid_a_lib=yes
michael@0 5237 ;;
michael@0 5238 esac
michael@0 5239 if test "$valid_a_lib" != yes; then
michael@0 5240 $ECHO
michael@0 5241 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
michael@0 5242 $ECHO "*** I have the capability to make that library automatically link in when"
michael@0 5243 $ECHO "*** you link to this library. But I can only do this if you have a"
michael@0 5244 $ECHO "*** shared version of the library, which you do not appear to have"
michael@0 5245 $ECHO "*** because the file extensions .$libext of this argument makes me believe"
michael@0 5246 $ECHO "*** that it is just a static archive that I should not use here."
michael@0 5247 else
michael@0 5248 $ECHO
michael@0 5249 $ECHO "*** Warning: Linking the shared library $output against the"
michael@0 5250 $ECHO "*** static library $deplib is not portable!"
michael@0 5251 deplibs="$deplib $deplibs"
michael@0 5252 fi
michael@0 5253 ;;
michael@0 5254 esac
michael@0 5255 continue
michael@0 5256 ;;
michael@0 5257 prog)
michael@0 5258 if test "$pass" != link; then
michael@0 5259 deplibs="$deplib $deplibs"
michael@0 5260 else
michael@0 5261 compile_deplibs="$deplib $compile_deplibs"
michael@0 5262 finalize_deplibs="$deplib $finalize_deplibs"
michael@0 5263 fi
michael@0 5264 continue
michael@0 5265 ;;
michael@0 5266 esac # linkmode
michael@0 5267 ;; # *.$libext
michael@0 5268 *.lo | *.$objext)
michael@0 5269 if test "$pass" = conv; then
michael@0 5270 deplibs="$deplib $deplibs"
michael@0 5271 elif test "$linkmode" = prog; then
michael@0 5272 if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
michael@0 5273 # If there is no dlopen support or we're linking statically,
michael@0 5274 # we need to preload.
michael@0 5275 newdlprefiles="$newdlprefiles $deplib"
michael@0 5276 compile_deplibs="$deplib $compile_deplibs"
michael@0 5277 finalize_deplibs="$deplib $finalize_deplibs"
michael@0 5278 else
michael@0 5279 newdlfiles="$newdlfiles $deplib"
michael@0 5280 fi
michael@0 5281 fi
michael@0 5282 continue
michael@0 5283 ;;
michael@0 5284 %DEPLIBS%)
michael@0 5285 alldeplibs=yes
michael@0 5286 continue
michael@0 5287 ;;
michael@0 5288 esac # case $deplib
michael@0 5289
michael@0 5290 if test "$found" = yes || test -f "$lib"; then :
michael@0 5291 else
michael@0 5292 func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
michael@0 5293 fi
michael@0 5294
michael@0 5295 # Check to see that this really is a libtool archive.
michael@0 5296 func_lalib_unsafe_p "$lib" \
michael@0 5297 || func_fatal_error "\`$lib' is not a valid libtool archive"
michael@0 5298
michael@0 5299 func_dirname "$lib" "" "."
michael@0 5300 ladir="$func_dirname_result"
michael@0 5301
michael@0 5302 dlname=
michael@0 5303 dlopen=
michael@0 5304 dlpreopen=
michael@0 5305 libdir=
michael@0 5306 library_names=
michael@0 5307 old_library=
michael@0 5308 inherited_linker_flags=
michael@0 5309 # If the library was installed with an old release of libtool,
michael@0 5310 # it will not redefine variables installed, or shouldnotlink
michael@0 5311 installed=yes
michael@0 5312 shouldnotlink=no
michael@0 5313 avoidtemprpath=
michael@0 5314
michael@0 5315
michael@0 5316 # Read the .la file
michael@0 5317 func_source "$lib"
michael@0 5318
michael@0 5319 # Convert "-framework foo" to "foo.ltframework"
michael@0 5320 if test -n "$inherited_linker_flags"; then
michael@0 5321 tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
michael@0 5322 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
michael@0 5323 case " $new_inherited_linker_flags " in
michael@0 5324 *" $tmp_inherited_linker_flag "*) ;;
michael@0 5325 *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
michael@0 5326 esac
michael@0 5327 done
michael@0 5328 fi
michael@0 5329 dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
michael@0 5330 if test "$linkmode,$pass" = "lib,link" ||
michael@0 5331 test "$linkmode,$pass" = "prog,scan" ||
michael@0 5332 { test "$linkmode" != prog && test "$linkmode" != lib; }; then
michael@0 5333 test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
michael@0 5334 test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
michael@0 5335 fi
michael@0 5336
michael@0 5337 if test "$pass" = conv; then
michael@0 5338 # Only check for convenience libraries
michael@0 5339 deplibs="$lib $deplibs"
michael@0 5340 if test -z "$libdir"; then
michael@0 5341 if test -z "$old_library"; then
michael@0 5342 func_fatal_error "cannot find name of link library for \`$lib'"
michael@0 5343 fi
michael@0 5344 # It is a libtool convenience library, so add in its objects.
michael@0 5345 convenience="$convenience $ladir/$objdir/$old_library"
michael@0 5346 old_convenience="$old_convenience $ladir/$objdir/$old_library"
michael@0 5347 elif test "$linkmode" != prog && test "$linkmode" != lib; then
michael@0 5348 func_fatal_error "\`$lib' is not a convenience library"
michael@0 5349 fi
michael@0 5350 tmp_libs=
michael@0 5351 for deplib in $dependency_libs; do
michael@0 5352 deplibs="$deplib $deplibs"
michael@0 5353 if $opt_duplicate_deps ; then
michael@0 5354 case "$tmp_libs " in
michael@0 5355 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
michael@0 5356 esac
michael@0 5357 fi
michael@0 5358 tmp_libs="$tmp_libs $deplib"
michael@0 5359 done
michael@0 5360 continue
michael@0 5361 fi # $pass = conv
michael@0 5362
michael@0 5363
michael@0 5364 # Get the name of the library we link against.
michael@0 5365 linklib=
michael@0 5366 for l in $old_library $library_names; do
michael@0 5367 linklib="$l"
michael@0 5368 done
michael@0 5369 if test -z "$linklib"; then
michael@0 5370 func_fatal_error "cannot find name of link library for \`$lib'"
michael@0 5371 fi
michael@0 5372
michael@0 5373 # This library was specified with -dlopen.
michael@0 5374 if test "$pass" = dlopen; then
michael@0 5375 if test -z "$libdir"; then
michael@0 5376 func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
michael@0 5377 fi
michael@0 5378 if test -z "$dlname" ||
michael@0 5379 test "$dlopen_support" != yes ||
michael@0 5380 test "$build_libtool_libs" = no; then
michael@0 5381 # If there is no dlname, no dlopen support or we're linking
michael@0 5382 # statically, we need to preload. We also need to preload any
michael@0 5383 # dependent libraries so libltdl's deplib preloader doesn't
michael@0 5384 # bomb out in the load deplibs phase.
michael@0 5385 dlprefiles="$dlprefiles $lib $dependency_libs"
michael@0 5386 else
michael@0 5387 newdlfiles="$newdlfiles $lib"
michael@0 5388 fi
michael@0 5389 continue
michael@0 5390 fi # $pass = dlopen
michael@0 5391
michael@0 5392 # We need an absolute path.
michael@0 5393 case $ladir in
michael@0 5394 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
michael@0 5395 *)
michael@0 5396 abs_ladir=`cd "$ladir" && pwd`
michael@0 5397 if test -z "$abs_ladir"; then
michael@0 5398 func_warning "cannot determine absolute directory name of \`$ladir'"
michael@0 5399 func_warning "passing it literally to the linker, although it might fail"
michael@0 5400 abs_ladir="$ladir"
michael@0 5401 fi
michael@0 5402 ;;
michael@0 5403 esac
michael@0 5404 func_basename "$lib"
michael@0 5405 laname="$func_basename_result"
michael@0 5406
michael@0 5407 # Find the relevant object directory and library name.
michael@0 5408 if test "X$installed" = Xyes; then
michael@0 5409 if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
michael@0 5410 func_warning "library \`$lib' was moved."
michael@0 5411 dir="$ladir"
michael@0 5412 absdir="$abs_ladir"
michael@0 5413 libdir="$abs_ladir"
michael@0 5414 else
michael@0 5415 dir="$libdir"
michael@0 5416 absdir="$libdir"
michael@0 5417 fi
michael@0 5418 test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
michael@0 5419 else
michael@0 5420 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
michael@0 5421 dir="$ladir"
michael@0 5422 absdir="$abs_ladir"
michael@0 5423 # Remove this search path later
michael@0 5424 notinst_path="$notinst_path $abs_ladir"
michael@0 5425 else
michael@0 5426 dir="$ladir/$objdir"
michael@0 5427 absdir="$abs_ladir/$objdir"
michael@0 5428 # Remove this search path later
michael@0 5429 notinst_path="$notinst_path $abs_ladir"
michael@0 5430 fi
michael@0 5431 fi # $installed = yes
michael@0 5432 func_stripname 'lib' '.la' "$laname"
michael@0 5433 name=$func_stripname_result
michael@0 5434
michael@0 5435 # This library was specified with -dlpreopen.
michael@0 5436 if test "$pass" = dlpreopen; then
michael@0 5437 if test -z "$libdir" && test "$linkmode" = prog; then
michael@0 5438 func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
michael@0 5439 fi
michael@0 5440 # Prefer using a static library (so that no silly _DYNAMIC symbols
michael@0 5441 # are required to link).
michael@0 5442 if test -n "$old_library"; then
michael@0 5443 newdlprefiles="$newdlprefiles $dir/$old_library"
michael@0 5444 # Keep a list of preopened convenience libraries to check
michael@0 5445 # that they are being used correctly in the link pass.
michael@0 5446 test -z "$libdir" && \
michael@0 5447 dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
michael@0 5448 # Otherwise, use the dlname, so that lt_dlopen finds it.
michael@0 5449 elif test -n "$dlname"; then
michael@0 5450 newdlprefiles="$newdlprefiles $dir/$dlname"
michael@0 5451 else
michael@0 5452 newdlprefiles="$newdlprefiles $dir/$linklib"
michael@0 5453 fi
michael@0 5454 fi # $pass = dlpreopen
michael@0 5455
michael@0 5456 if test -z "$libdir"; then
michael@0 5457 # Link the convenience library
michael@0 5458 if test "$linkmode" = lib; then
michael@0 5459 deplibs="$dir/$old_library $deplibs"
michael@0 5460 elif test "$linkmode,$pass" = "prog,link"; then
michael@0 5461 compile_deplibs="$dir/$old_library $compile_deplibs"
michael@0 5462 finalize_deplibs="$dir/$old_library $finalize_deplibs"
michael@0 5463 else
michael@0 5464 deplibs="$lib $deplibs" # used for prog,scan pass
michael@0 5465 fi
michael@0 5466 continue
michael@0 5467 fi
michael@0 5468
michael@0 5469
michael@0 5470 if test "$linkmode" = prog && test "$pass" != link; then
michael@0 5471 newlib_search_path="$newlib_search_path $ladir"
michael@0 5472 deplibs="$lib $deplibs"
michael@0 5473
michael@0 5474 linkalldeplibs=no
michael@0 5475 if test "$link_all_deplibs" != no || test -z "$library_names" ||
michael@0 5476 test "$build_libtool_libs" = no; then
michael@0 5477 linkalldeplibs=yes
michael@0 5478 fi
michael@0 5479
michael@0 5480 tmp_libs=
michael@0 5481 for deplib in $dependency_libs; do
michael@0 5482 case $deplib in
michael@0 5483 -L*) func_stripname '-L' '' "$deplib"
michael@0 5484 newlib_search_path="$newlib_search_path $func_stripname_result"
michael@0 5485 ;;
michael@0 5486 esac
michael@0 5487 # Need to link against all dependency_libs?
michael@0 5488 if test "$linkalldeplibs" = yes; then
michael@0 5489 deplibs="$deplib $deplibs"
michael@0 5490 else
michael@0 5491 # Need to hardcode shared library paths
michael@0 5492 # or/and link against static libraries
michael@0 5493 newdependency_libs="$deplib $newdependency_libs"
michael@0 5494 fi
michael@0 5495 if $opt_duplicate_deps ; then
michael@0 5496 case "$tmp_libs " in
michael@0 5497 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
michael@0 5498 esac
michael@0 5499 fi
michael@0 5500 tmp_libs="$tmp_libs $deplib"
michael@0 5501 done # for deplib
michael@0 5502 continue
michael@0 5503 fi # $linkmode = prog...
michael@0 5504
michael@0 5505 if test "$linkmode,$pass" = "prog,link"; then
michael@0 5506 if test -n "$library_names" &&
michael@0 5507 { { test "$prefer_static_libs" = no ||
michael@0 5508 test "$prefer_static_libs,$installed" = "built,yes"; } ||
michael@0 5509 test -z "$old_library"; }; then
michael@0 5510 # We need to hardcode the library path
michael@0 5511 if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
michael@0 5512 # Make sure the rpath contains only unique directories.
michael@0 5513 case "$temp_rpath:" in
michael@0 5514 *"$absdir:"*) ;;
michael@0 5515 *) temp_rpath="$temp_rpath$absdir:" ;;
michael@0 5516 esac
michael@0 5517 fi
michael@0 5518
michael@0 5519 # Hardcode the library path.
michael@0 5520 # Skip directories that are in the system default run-time
michael@0 5521 # search path.
michael@0 5522 case " $sys_lib_dlsearch_path " in
michael@0 5523 *" $absdir "*) ;;
michael@0 5524 *)
michael@0 5525 case "$compile_rpath " in
michael@0 5526 *" $absdir "*) ;;
michael@0 5527 *) compile_rpath="$compile_rpath $absdir"
michael@0 5528 esac
michael@0 5529 ;;
michael@0 5530 esac
michael@0 5531 case " $sys_lib_dlsearch_path " in
michael@0 5532 *" $libdir "*) ;;
michael@0 5533 *)
michael@0 5534 case "$finalize_rpath " in
michael@0 5535 *" $libdir "*) ;;
michael@0 5536 *) finalize_rpath="$finalize_rpath $libdir"
michael@0 5537 esac
michael@0 5538 ;;
michael@0 5539 esac
michael@0 5540 fi # $linkmode,$pass = prog,link...
michael@0 5541
michael@0 5542 if test "$alldeplibs" = yes &&
michael@0 5543 { test "$deplibs_check_method" = pass_all ||
michael@0 5544 { test "$build_libtool_libs" = yes &&
michael@0 5545 test -n "$library_names"; }; }; then
michael@0 5546 # We only need to search for static libraries
michael@0 5547 continue
michael@0 5548 fi
michael@0 5549 fi
michael@0 5550
michael@0 5551 link_static=no # Whether the deplib will be linked statically
michael@0 5552 use_static_libs=$prefer_static_libs
michael@0 5553 if test "$use_static_libs" = built && test "$installed" = yes; then
michael@0 5554 use_static_libs=no
michael@0 5555 fi
michael@0 5556 if test -n "$library_names" &&
michael@0 5557 { test "$use_static_libs" = no || test -z "$old_library"; }; then
michael@0 5558 case $host in
michael@0 5559 *cygwin* | *mingw* | *cegcc*)
michael@0 5560 # No point in relinking DLLs because paths are not encoded
michael@0 5561 notinst_deplibs="$notinst_deplibs $lib"
michael@0 5562 need_relink=no
michael@0 5563 ;;
michael@0 5564 *)
michael@0 5565 if test "$installed" = no; then
michael@0 5566 notinst_deplibs="$notinst_deplibs $lib"
michael@0 5567 need_relink=yes
michael@0 5568 fi
michael@0 5569 ;;
michael@0 5570 esac
michael@0 5571 # This is a shared library
michael@0 5572
michael@0 5573 # Warn about portability, can't link against -module's on some
michael@0 5574 # systems (darwin). Don't bleat about dlopened modules though!
michael@0 5575 dlopenmodule=""
michael@0 5576 for dlpremoduletest in $dlprefiles; do
michael@0 5577 if test "X$dlpremoduletest" = "X$lib"; then
michael@0 5578 dlopenmodule="$dlpremoduletest"
michael@0 5579 break
michael@0 5580 fi
michael@0 5581 done
michael@0 5582 if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
michael@0 5583 $ECHO
michael@0 5584 if test "$linkmode" = prog; then
michael@0 5585 $ECHO "*** Warning: Linking the executable $output against the loadable module"
michael@0 5586 else
michael@0 5587 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
michael@0 5588 fi
michael@0 5589 $ECHO "*** $linklib is not portable!"
michael@0 5590 fi
michael@0 5591 if test "$linkmode" = lib &&
michael@0 5592 test "$hardcode_into_libs" = yes; then
michael@0 5593 # Hardcode the library path.
michael@0 5594 # Skip directories that are in the system default run-time
michael@0 5595 # search path.
michael@0 5596 case " $sys_lib_dlsearch_path " in
michael@0 5597 *" $absdir "*) ;;
michael@0 5598 *)
michael@0 5599 case "$compile_rpath " in
michael@0 5600 *" $absdir "*) ;;
michael@0 5601 *) compile_rpath="$compile_rpath $absdir"
michael@0 5602 esac
michael@0 5603 ;;
michael@0 5604 esac
michael@0 5605 case " $sys_lib_dlsearch_path " in
michael@0 5606 *" $libdir "*) ;;
michael@0 5607 *)
michael@0 5608 case "$finalize_rpath " in
michael@0 5609 *" $libdir "*) ;;
michael@0 5610 *) finalize_rpath="$finalize_rpath $libdir"
michael@0 5611 esac
michael@0 5612 ;;
michael@0 5613 esac
michael@0 5614 fi
michael@0 5615
michael@0 5616 if test -n "$old_archive_from_expsyms_cmds"; then
michael@0 5617 # figure out the soname
michael@0 5618 set dummy $library_names
michael@0 5619 shift
michael@0 5620 realname="$1"
michael@0 5621 shift
michael@0 5622 libname=`eval "\\$ECHO \"$libname_spec\""`
michael@0 5623 # use dlname if we got it. it's perfectly good, no?
michael@0 5624 if test -n "$dlname"; then
michael@0 5625 soname="$dlname"
michael@0 5626 elif test -n "$soname_spec"; then
michael@0 5627 # bleh windows
michael@0 5628 case $host in
michael@0 5629 *cygwin* | mingw* | *cegcc*)
michael@0 5630 func_arith $current - $age
michael@0 5631 major=$func_arith_result
michael@0 5632 versuffix="-$major"
michael@0 5633 ;;
michael@0 5634 esac
michael@0 5635 eval soname=\"$soname_spec\"
michael@0 5636 else
michael@0 5637 soname="$realname"
michael@0 5638 fi
michael@0 5639
michael@0 5640 # Make a new name for the extract_expsyms_cmds to use
michael@0 5641 soroot="$soname"
michael@0 5642 func_basename "$soroot"
michael@0 5643 soname="$func_basename_result"
michael@0 5644 func_stripname 'lib' '.dll' "$soname"
michael@0 5645 newlib=libimp-$func_stripname_result.a
michael@0 5646
michael@0 5647 # If the library has no export list, then create one now
michael@0 5648 if test -f "$output_objdir/$soname-def"; then :
michael@0 5649 else
michael@0 5650 func_verbose "extracting exported symbol list from \`$soname'"
michael@0 5651 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
michael@0 5652 fi
michael@0 5653
michael@0 5654 # Create $newlib
michael@0 5655 if test -f "$output_objdir/$newlib"; then :; else
michael@0 5656 func_verbose "generating import library for \`$soname'"
michael@0 5657 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
michael@0 5658 fi
michael@0 5659 # make sure the library variables are pointing to the new library
michael@0 5660 dir=$output_objdir
michael@0 5661 linklib=$newlib
michael@0 5662 fi # test -n "$old_archive_from_expsyms_cmds"
michael@0 5663
michael@0 5664 if test "$linkmode" = prog || test "$mode" != relink; then
michael@0 5665 add_shlibpath=
michael@0 5666 add_dir=
michael@0 5667 add=
michael@0 5668 lib_linked=yes
michael@0 5669 case $hardcode_action in
michael@0 5670 immediate | unsupported)
michael@0 5671 if test "$hardcode_direct" = no; then
michael@0 5672 add="$dir/$linklib"
michael@0 5673 case $host in
michael@0 5674 *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
michael@0 5675 *-*-sysv4*uw2*) add_dir="-L$dir" ;;
michael@0 5676 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
michael@0 5677 *-*-unixware7*) add_dir="-L$dir" ;;
michael@0 5678 *-*-darwin* )
michael@0 5679 # if the lib is a (non-dlopened) module then we can not
michael@0 5680 # link against it, someone is ignoring the earlier warnings
michael@0 5681 if /usr/bin/file -L $add 2> /dev/null |
michael@0 5682 $GREP ": [^:]* bundle" >/dev/null ; then
michael@0 5683 if test "X$dlopenmodule" != "X$lib"; then
michael@0 5684 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
michael@0 5685 if test -z "$old_library" ; then
michael@0 5686 $ECHO
michael@0 5687 $ECHO "*** And there doesn't seem to be a static archive available"
michael@0 5688 $ECHO "*** The link will probably fail, sorry"
michael@0 5689 else
michael@0 5690 add="$dir/$old_library"
michael@0 5691 fi
michael@0 5692 elif test -n "$old_library"; then
michael@0 5693 add="$dir/$old_library"
michael@0 5694 fi
michael@0 5695 fi
michael@0 5696 esac
michael@0 5697 elif test "$hardcode_minus_L" = no; then
michael@0 5698 case $host in
michael@0 5699 *-*-sunos*) add_shlibpath="$dir" ;;
michael@0 5700 esac
michael@0 5701 add_dir="-L$dir"
michael@0 5702 add="-l$name"
michael@0 5703 elif test "$hardcode_shlibpath_var" = no; then
michael@0 5704 add_shlibpath="$dir"
michael@0 5705 add="-l$name"
michael@0 5706 else
michael@0 5707 lib_linked=no
michael@0 5708 fi
michael@0 5709 ;;
michael@0 5710 relink)
michael@0 5711 if test "$hardcode_direct" = yes &&
michael@0 5712 test "$hardcode_direct_absolute" = no; then
michael@0 5713 add="$dir/$linklib"
michael@0 5714 elif test "$hardcode_minus_L" = yes; then
michael@0 5715 add_dir="-L$dir"
michael@0 5716 # Try looking first in the location we're being installed to.
michael@0 5717 if test -n "$inst_prefix_dir"; then
michael@0 5718 case $libdir in
michael@0 5719 [\\/]*)
michael@0 5720 add_dir="$add_dir -L$inst_prefix_dir$libdir"
michael@0 5721 ;;
michael@0 5722 esac
michael@0 5723 fi
michael@0 5724 add="-l$name"
michael@0 5725 elif test "$hardcode_shlibpath_var" = yes; then
michael@0 5726 add_shlibpath="$dir"
michael@0 5727 add="-l$name"
michael@0 5728 else
michael@0 5729 lib_linked=no
michael@0 5730 fi
michael@0 5731 ;;
michael@0 5732 *) lib_linked=no ;;
michael@0 5733 esac
michael@0 5734
michael@0 5735 if test "$lib_linked" != yes; then
michael@0 5736 func_fatal_configuration "unsupported hardcode properties"
michael@0 5737 fi
michael@0 5738
michael@0 5739 if test -n "$add_shlibpath"; then
michael@0 5740 case :$compile_shlibpath: in
michael@0 5741 *":$add_shlibpath:"*) ;;
michael@0 5742 *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
michael@0 5743 esac
michael@0 5744 fi
michael@0 5745 if test "$linkmode" = prog; then
michael@0 5746 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
michael@0 5747 test -n "$add" && compile_deplibs="$add $compile_deplibs"
michael@0 5748 else
michael@0 5749 test -n "$add_dir" && deplibs="$add_dir $deplibs"
michael@0 5750 test -n "$add" && deplibs="$add $deplibs"
michael@0 5751 if test "$hardcode_direct" != yes &&
michael@0 5752 test "$hardcode_minus_L" != yes &&
michael@0 5753 test "$hardcode_shlibpath_var" = yes; then
michael@0 5754 case :$finalize_shlibpath: in
michael@0 5755 *":$libdir:"*) ;;
michael@0 5756 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
michael@0 5757 esac
michael@0 5758 fi
michael@0 5759 fi
michael@0 5760 fi
michael@0 5761
michael@0 5762 if test "$linkmode" = prog || test "$mode" = relink; then
michael@0 5763 add_shlibpath=
michael@0 5764 add_dir=
michael@0 5765 add=
michael@0 5766 # Finalize command for both is simple: just hardcode it.
michael@0 5767 if test "$hardcode_direct" = yes &&
michael@0 5768 test "$hardcode_direct_absolute" = no; then
michael@0 5769 add="$libdir/$linklib"
michael@0 5770 elif test "$hardcode_minus_L" = yes; then
michael@0 5771 add_dir="-L$libdir"
michael@0 5772 add="-l$name"
michael@0 5773 elif test "$hardcode_shlibpath_var" = yes; then
michael@0 5774 case :$finalize_shlibpath: in
michael@0 5775 *":$libdir:"*) ;;
michael@0 5776 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
michael@0 5777 esac
michael@0 5778 add="-l$name"
michael@0 5779 elif test "$hardcode_automatic" = yes; then
michael@0 5780 if test -n "$inst_prefix_dir" &&
michael@0 5781 test -f "$inst_prefix_dir$libdir/$linklib" ; then
michael@0 5782 add="$inst_prefix_dir$libdir/$linklib"
michael@0 5783 else
michael@0 5784 add="$libdir/$linklib"
michael@0 5785 fi
michael@0 5786 else
michael@0 5787 # We cannot seem to hardcode it, guess we'll fake it.
michael@0 5788 add_dir="-L$libdir"
michael@0 5789 # Try looking first in the location we're being installed to.
michael@0 5790 if test -n "$inst_prefix_dir"; then
michael@0 5791 case $libdir in
michael@0 5792 [\\/]*)
michael@0 5793 add_dir="$add_dir -L$inst_prefix_dir$libdir"
michael@0 5794 ;;
michael@0 5795 esac
michael@0 5796 fi
michael@0 5797 add="-l$name"
michael@0 5798 fi
michael@0 5799
michael@0 5800 if test "$linkmode" = prog; then
michael@0 5801 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
michael@0 5802 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
michael@0 5803 else
michael@0 5804 test -n "$add_dir" && deplibs="$add_dir $deplibs"
michael@0 5805 test -n "$add" && deplibs="$add $deplibs"
michael@0 5806 fi
michael@0 5807 fi
michael@0 5808 elif test "$linkmode" = prog; then
michael@0 5809 # Here we assume that one of hardcode_direct or hardcode_minus_L
michael@0 5810 # is not unsupported. This is valid on all known static and
michael@0 5811 # shared platforms.
michael@0 5812 if test "$hardcode_direct" != unsupported; then
michael@0 5813 test -n "$old_library" && linklib="$old_library"
michael@0 5814 compile_deplibs="$dir/$linklib $compile_deplibs"
michael@0 5815 finalize_deplibs="$dir/$linklib $finalize_deplibs"
michael@0 5816 else
michael@0 5817 compile_deplibs="-l$name -L$dir $compile_deplibs"
michael@0 5818 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
michael@0 5819 fi
michael@0 5820 elif test "$build_libtool_libs" = yes; then
michael@0 5821 # Not a shared library
michael@0 5822 if test "$deplibs_check_method" != pass_all; then
michael@0 5823 # We're trying link a shared library against a static one
michael@0 5824 # but the system doesn't support it.
michael@0 5825
michael@0 5826 # Just print a warning and add the library to dependency_libs so
michael@0 5827 # that the program can be linked against the static library.
michael@0 5828 $ECHO
michael@0 5829 $ECHO "*** Warning: This system can not link to static lib archive $lib."
michael@0 5830 $ECHO "*** I have the capability to make that library automatically link in when"
michael@0 5831 $ECHO "*** you link to this library. But I can only do this if you have a"
michael@0 5832 $ECHO "*** shared version of the library, which you do not appear to have."
michael@0 5833 if test "$module" = yes; then
michael@0 5834 $ECHO "*** But as you try to build a module library, libtool will still create "
michael@0 5835 $ECHO "*** a static module, that should work as long as the dlopening application"
michael@0 5836 $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
michael@0 5837 if test -z "$global_symbol_pipe"; then
michael@0 5838 $ECHO
michael@0 5839 $ECHO "*** However, this would only work if libtool was able to extract symbol"
michael@0 5840 $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
michael@0 5841 $ECHO "*** not find such a program. So, this module is probably useless."
michael@0 5842 $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
michael@0 5843 fi
michael@0 5844 if test "$build_old_libs" = no; then
michael@0 5845 build_libtool_libs=module
michael@0 5846 build_old_libs=yes
michael@0 5847 else
michael@0 5848 build_libtool_libs=no
michael@0 5849 fi
michael@0 5850 fi
michael@0 5851 else
michael@0 5852 deplibs="$dir/$old_library $deplibs"
michael@0 5853 link_static=yes
michael@0 5854 fi
michael@0 5855 fi # link shared/static library?
michael@0 5856
michael@0 5857 if test "$linkmode" = lib; then
michael@0 5858 if test -n "$dependency_libs" &&
michael@0 5859 { test "$hardcode_into_libs" != yes ||
michael@0 5860 test "$build_old_libs" = yes ||
michael@0 5861 test "$link_static" = yes; }; then
michael@0 5862 # Extract -R from dependency_libs
michael@0 5863 temp_deplibs=
michael@0 5864 for libdir in $dependency_libs; do
michael@0 5865 case $libdir in
michael@0 5866 -R*) func_stripname '-R' '' "$libdir"
michael@0 5867 temp_xrpath=$func_stripname_result
michael@0 5868 case " $xrpath " in
michael@0 5869 *" $temp_xrpath "*) ;;
michael@0 5870 *) xrpath="$xrpath $temp_xrpath";;
michael@0 5871 esac;;
michael@0 5872 *) temp_deplibs="$temp_deplibs $libdir";;
michael@0 5873 esac
michael@0 5874 done
michael@0 5875 dependency_libs="$temp_deplibs"
michael@0 5876 fi
michael@0 5877
michael@0 5878 newlib_search_path="$newlib_search_path $absdir"
michael@0 5879 # Link against this library
michael@0 5880 test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
michael@0 5881 # ... and its dependency_libs
michael@0 5882 tmp_libs=
michael@0 5883 for deplib in $dependency_libs; do
michael@0 5884 newdependency_libs="$deplib $newdependency_libs"
michael@0 5885 if $opt_duplicate_deps ; then
michael@0 5886 case "$tmp_libs " in
michael@0 5887 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
michael@0 5888 esac
michael@0 5889 fi
michael@0 5890 tmp_libs="$tmp_libs $deplib"
michael@0 5891 done
michael@0 5892
michael@0 5893 if test "$link_all_deplibs" != no; then
michael@0 5894 # Add the search paths of all dependency libraries
michael@0 5895 for deplib in $dependency_libs; do
michael@0 5896 case $deplib in
michael@0 5897 -L*) path="$deplib" ;;
michael@0 5898 *.la)
michael@0 5899 func_dirname "$deplib" "" "."
michael@0 5900 dir="$func_dirname_result"
michael@0 5901 # We need an absolute path.
michael@0 5902 case $dir in
michael@0 5903 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
michael@0 5904 *)
michael@0 5905 absdir=`cd "$dir" && pwd`
michael@0 5906 if test -z "$absdir"; then
michael@0 5907 func_warning "cannot determine absolute directory name of \`$dir'"
michael@0 5908 absdir="$dir"
michael@0 5909 fi
michael@0 5910 ;;
michael@0 5911 esac
michael@0 5912 if $GREP "^installed=no" $deplib > /dev/null; then
michael@0 5913 case $host in
michael@0 5914 *-*-darwin*)
michael@0 5915 depdepl=
michael@0 5916 eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
michael@0 5917 if test -n "$deplibrary_names" ; then
michael@0 5918 for tmp in $deplibrary_names ; do
michael@0 5919 depdepl=$tmp
michael@0 5920 done
michael@0 5921 if test -f "$absdir/$objdir/$depdepl" ; then
michael@0 5922 depdepl="$absdir/$objdir/$depdepl"
michael@0 5923 darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
michael@0 5924 if test -z "$darwin_install_name"; then
michael@0 5925 darwin_install_name=`${OTOOL64} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
michael@0 5926 fi
michael@0 5927 compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
michael@0 5928 linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
michael@0 5929 path=
michael@0 5930 fi
michael@0 5931 fi
michael@0 5932 ;;
michael@0 5933 *)
michael@0 5934 path="-L$absdir/$objdir"
michael@0 5935 ;;
michael@0 5936 esac
michael@0 5937 else
michael@0 5938 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
michael@0 5939 test -z "$libdir" && \
michael@0 5940 func_fatal_error "\`$deplib' is not a valid libtool archive"
michael@0 5941 test "$absdir" != "$libdir" && \
michael@0 5942 func_warning "\`$deplib' seems to be moved"
michael@0 5943
michael@0 5944 path="-L$absdir"
michael@0 5945 fi
michael@0 5946 ;;
michael@0 5947 esac
michael@0 5948 case " $deplibs " in
michael@0 5949 *" $path "*) ;;
michael@0 5950 *) deplibs="$path $deplibs" ;;
michael@0 5951 esac
michael@0 5952 done
michael@0 5953 fi # link_all_deplibs != no
michael@0 5954 fi # linkmode = lib
michael@0 5955 done # for deplib in $libs
michael@0 5956 if test "$pass" = link; then
michael@0 5957 if test "$linkmode" = "prog"; then
michael@0 5958 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
michael@0 5959 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
michael@0 5960 else
michael@0 5961 compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
michael@0 5962 fi
michael@0 5963 fi
michael@0 5964 dependency_libs="$newdependency_libs"
michael@0 5965 if test "$pass" = dlpreopen; then
michael@0 5966 # Link the dlpreopened libraries before other libraries
michael@0 5967 for deplib in $save_deplibs; do
michael@0 5968 deplibs="$deplib $deplibs"
michael@0 5969 done
michael@0 5970 fi
michael@0 5971 if test "$pass" != dlopen; then
michael@0 5972 if test "$pass" != conv; then
michael@0 5973 # Make sure lib_search_path contains only unique directories.
michael@0 5974 lib_search_path=
michael@0 5975 for dir in $newlib_search_path; do
michael@0 5976 case "$lib_search_path " in
michael@0 5977 *" $dir "*) ;;
michael@0 5978 *) lib_search_path="$lib_search_path $dir" ;;
michael@0 5979 esac
michael@0 5980 done
michael@0 5981 newlib_search_path=
michael@0 5982 fi
michael@0 5983
michael@0 5984 if test "$linkmode,$pass" != "prog,link"; then
michael@0 5985 vars="deplibs"
michael@0 5986 else
michael@0 5987 vars="compile_deplibs finalize_deplibs"
michael@0 5988 fi
michael@0 5989 for var in $vars dependency_libs; do
michael@0 5990 # Add libraries to $var in reverse order
michael@0 5991 eval tmp_libs=\"\$$var\"
michael@0 5992 new_libs=
michael@0 5993 for deplib in $tmp_libs; do
michael@0 5994 # FIXME: Pedantically, this is the right thing to do, so
michael@0 5995 # that some nasty dependency loop isn't accidentally
michael@0 5996 # broken:
michael@0 5997 #new_libs="$deplib $new_libs"
michael@0 5998 # Pragmatically, this seems to cause very few problems in
michael@0 5999 # practice:
michael@0 6000 case $deplib in
michael@0 6001 -L*) new_libs="$deplib $new_libs" ;;
michael@0 6002 -R*) ;;
michael@0 6003 *)
michael@0 6004 # And here is the reason: when a library appears more
michael@0 6005 # than once as an explicit dependence of a library, or
michael@0 6006 # is implicitly linked in more than once by the
michael@0 6007 # compiler, it is considered special, and multiple
michael@0 6008 # occurrences thereof are not removed. Compare this
michael@0 6009 # with having the same library being listed as a
michael@0 6010 # dependency of multiple other libraries: in this case,
michael@0 6011 # we know (pedantically, we assume) the library does not
michael@0 6012 # need to be listed more than once, so we keep only the
michael@0 6013 # last copy. This is not always right, but it is rare
michael@0 6014 # enough that we require users that really mean to play
michael@0 6015 # such unportable linking tricks to link the library
michael@0 6016 # using -Wl,-lname, so that libtool does not consider it
michael@0 6017 # for duplicate removal.
michael@0 6018 case " $specialdeplibs " in
michael@0 6019 *" $deplib "*) new_libs="$deplib $new_libs" ;;
michael@0 6020 *)
michael@0 6021 case " $new_libs " in
michael@0 6022 *" $deplib "*) ;;
michael@0 6023 *) new_libs="$deplib $new_libs" ;;
michael@0 6024 esac
michael@0 6025 ;;
michael@0 6026 esac
michael@0 6027 ;;
michael@0 6028 esac
michael@0 6029 done
michael@0 6030 tmp_libs=
michael@0 6031 for deplib in $new_libs; do
michael@0 6032 case $deplib in
michael@0 6033 -L*)
michael@0 6034 case " $tmp_libs " in
michael@0 6035 *" $deplib "*) ;;
michael@0 6036 *) tmp_libs="$tmp_libs $deplib" ;;
michael@0 6037 esac
michael@0 6038 ;;
michael@0 6039 *) tmp_libs="$tmp_libs $deplib" ;;
michael@0 6040 esac
michael@0 6041 done
michael@0 6042 eval $var=\"$tmp_libs\"
michael@0 6043 done # for var
michael@0 6044 fi
michael@0 6045 # Last step: remove runtime libs from dependency_libs
michael@0 6046 # (they stay in deplibs)
michael@0 6047 tmp_libs=
michael@0 6048 for i in $dependency_libs ; do
michael@0 6049 case " $predeps $postdeps $compiler_lib_search_path " in
michael@0 6050 *" $i "*)
michael@0 6051 i=""
michael@0 6052 ;;
michael@0 6053 esac
michael@0 6054 if test -n "$i" ; then
michael@0 6055 tmp_libs="$tmp_libs $i"
michael@0 6056 fi
michael@0 6057 done
michael@0 6058 dependency_libs=$tmp_libs
michael@0 6059 done # for pass
michael@0 6060 if test "$linkmode" = prog; then
michael@0 6061 dlfiles="$newdlfiles"
michael@0 6062 fi
michael@0 6063 if test "$linkmode" = prog || test "$linkmode" = lib; then
michael@0 6064 dlprefiles="$newdlprefiles"
michael@0 6065 fi
michael@0 6066
michael@0 6067 case $linkmode in
michael@0 6068 oldlib)
michael@0 6069 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
michael@0 6070 func_warning "\`-dlopen' is ignored for archives"
michael@0 6071 fi
michael@0 6072
michael@0 6073 case " $deplibs" in
michael@0 6074 *\ -l* | *\ -L*)
michael@0 6075 func_warning "\`-l' and \`-L' are ignored for archives" ;;
michael@0 6076 esac
michael@0 6077
michael@0 6078 test -n "$rpath" && \
michael@0 6079 func_warning "\`-rpath' is ignored for archives"
michael@0 6080
michael@0 6081 test -n "$xrpath" && \
michael@0 6082 func_warning "\`-R' is ignored for archives"
michael@0 6083
michael@0 6084 test -n "$vinfo" && \
michael@0 6085 func_warning "\`-version-info/-version-number' is ignored for archives"
michael@0 6086
michael@0 6087 test -n "$release" && \
michael@0 6088 func_warning "\`-release' is ignored for archives"
michael@0 6089
michael@0 6090 test -n "$export_symbols$export_symbols_regex" && \
michael@0 6091 func_warning "\`-export-symbols' is ignored for archives"
michael@0 6092
michael@0 6093 # Now set the variables for building old libraries.
michael@0 6094 build_libtool_libs=no
michael@0 6095 oldlibs="$output"
michael@0 6096 objs="$objs$old_deplibs"
michael@0 6097 ;;
michael@0 6098
michael@0 6099 lib)
michael@0 6100 # Make sure we only generate libraries of the form `libNAME.la'.
michael@0 6101 case $outputname in
michael@0 6102 lib*)
michael@0 6103 func_stripname 'lib' '.la' "$outputname"
michael@0 6104 name=$func_stripname_result
michael@0 6105 eval shared_ext=\"$shrext_cmds\"
michael@0 6106 eval libname=\"$libname_spec\"
michael@0 6107 ;;
michael@0 6108 *)
michael@0 6109 test "$module" = no && \
michael@0 6110 func_fatal_help "libtool library \`$output' must begin with \`lib'"
michael@0 6111
michael@0 6112 if test "$need_lib_prefix" != no; then
michael@0 6113 # Add the "lib" prefix for modules if required
michael@0 6114 func_stripname '' '.la' "$outputname"
michael@0 6115 name=$func_stripname_result
michael@0 6116 eval shared_ext=\"$shrext_cmds\"
michael@0 6117 eval libname=\"$libname_spec\"
michael@0 6118 else
michael@0 6119 func_stripname '' '.la' "$outputname"
michael@0 6120 libname=$func_stripname_result
michael@0 6121 fi
michael@0 6122 ;;
michael@0 6123 esac
michael@0 6124
michael@0 6125 if test -n "$objs"; then
michael@0 6126 if test "$deplibs_check_method" != pass_all; then
michael@0 6127 func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
michael@0 6128 else
michael@0 6129 $ECHO
michael@0 6130 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
michael@0 6131 $ECHO "*** objects $objs is not portable!"
michael@0 6132 libobjs="$libobjs $objs"
michael@0 6133 fi
michael@0 6134 fi
michael@0 6135
michael@0 6136 test "$dlself" != no && \
michael@0 6137 func_warning "\`-dlopen self' is ignored for libtool libraries"
michael@0 6138
michael@0 6139 set dummy $rpath
michael@0 6140 shift
michael@0 6141 test "$#" -gt 1 && \
michael@0 6142 func_warning "ignoring multiple \`-rpath's for a libtool library"
michael@0 6143
michael@0 6144 install_libdir="$1"
michael@0 6145
michael@0 6146 oldlibs=
michael@0 6147 if test -z "$rpath"; then
michael@0 6148 if test "$build_libtool_libs" = yes; then
michael@0 6149 # Building a libtool convenience library.
michael@0 6150 # Some compilers have problems with a `.al' extension so
michael@0 6151 # convenience libraries should have the same extension an
michael@0 6152 # archive normally would.
michael@0 6153 oldlibs="$output_objdir/$libname.$libext $oldlibs"
michael@0 6154 build_libtool_libs=convenience
michael@0 6155 build_old_libs=yes
michael@0 6156 fi
michael@0 6157
michael@0 6158 test -n "$vinfo" && \
michael@0 6159 func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
michael@0 6160
michael@0 6161 test -n "$release" && \
michael@0 6162 func_warning "\`-release' is ignored for convenience libraries"
michael@0 6163 else
michael@0 6164
michael@0 6165 # Parse the version information argument.
michael@0 6166 save_ifs="$IFS"; IFS=':'
michael@0 6167 set dummy $vinfo 0 0 0
michael@0 6168 shift
michael@0 6169 IFS="$save_ifs"
michael@0 6170
michael@0 6171 test -n "$7" && \
michael@0 6172 func_fatal_help "too many parameters to \`-version-info'"
michael@0 6173
michael@0 6174 # convert absolute version numbers to libtool ages
michael@0 6175 # this retains compatibility with .la files and attempts
michael@0 6176 # to make the code below a bit more comprehensible
michael@0 6177
michael@0 6178 case $vinfo_number in
michael@0 6179 yes)
michael@0 6180 number_major="$1"
michael@0 6181 number_minor="$2"
michael@0 6182 number_revision="$3"
michael@0 6183 #
michael@0 6184 # There are really only two kinds -- those that
michael@0 6185 # use the current revision as the major version
michael@0 6186 # and those that subtract age and use age as
michael@0 6187 # a minor version. But, then there is irix
michael@0 6188 # which has an extra 1 added just for fun
michael@0 6189 #
michael@0 6190 case $version_type in
michael@0 6191 darwin|linux|osf|windows|none)
michael@0 6192 func_arith $number_major + $number_minor
michael@0 6193 current=$func_arith_result
michael@0 6194 age="$number_minor"
michael@0 6195 revision="$number_revision"
michael@0 6196 ;;
michael@0 6197 freebsd-aout|freebsd-elf|sunos)
michael@0 6198 current="$number_major"
michael@0 6199 revision="$number_minor"
michael@0 6200 age="0"
michael@0 6201 ;;
michael@0 6202 irix|nonstopux)
michael@0 6203 func_arith $number_major + $number_minor
michael@0 6204 current=$func_arith_result
michael@0 6205 age="$number_minor"
michael@0 6206 revision="$number_minor"
michael@0 6207 lt_irix_increment=no
michael@0 6208 ;;
michael@0 6209 esac
michael@0 6210 ;;
michael@0 6211 no)
michael@0 6212 current="$1"
michael@0 6213 revision="$2"
michael@0 6214 age="$3"
michael@0 6215 ;;
michael@0 6216 esac
michael@0 6217
michael@0 6218 # Check that each of the things are valid numbers.
michael@0 6219 case $current in
michael@0 6220 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]) ;;
michael@0 6221 *)
michael@0 6222 func_error "CURRENT \`$current' must be a nonnegative integer"
michael@0 6223 func_fatal_error "\`$vinfo' is not valid version information"
michael@0 6224 ;;
michael@0 6225 esac
michael@0 6226
michael@0 6227 case $revision in
michael@0 6228 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]) ;;
michael@0 6229 *)
michael@0 6230 func_error "REVISION \`$revision' must be a nonnegative integer"
michael@0 6231 func_fatal_error "\`$vinfo' is not valid version information"
michael@0 6232 ;;
michael@0 6233 esac
michael@0 6234
michael@0 6235 case $age in
michael@0 6236 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]) ;;
michael@0 6237 *)
michael@0 6238 func_error "AGE \`$age' must be a nonnegative integer"
michael@0 6239 func_fatal_error "\`$vinfo' is not valid version information"
michael@0 6240 ;;
michael@0 6241 esac
michael@0 6242
michael@0 6243 if test "$age" -gt "$current"; then
michael@0 6244 func_error "AGE \`$age' is greater than the current interface number \`$current'"
michael@0 6245 func_fatal_error "\`$vinfo' is not valid version information"
michael@0 6246 fi
michael@0 6247
michael@0 6248 # Calculate the version variables.
michael@0 6249 major=
michael@0 6250 versuffix=
michael@0 6251 verstring=
michael@0 6252 case $version_type in
michael@0 6253 none) ;;
michael@0 6254
michael@0 6255 darwin)
michael@0 6256 # Like Linux, but with the current version available in
michael@0 6257 # verstring for coding it into the library header
michael@0 6258 func_arith $current - $age
michael@0 6259 major=.$func_arith_result
michael@0 6260 versuffix="$major.$age.$revision"
michael@0 6261 # Darwin ld doesn't like 0 for these options...
michael@0 6262 func_arith $current + 1
michael@0 6263 minor_current=$func_arith_result
michael@0 6264 xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
michael@0 6265 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
michael@0 6266 ;;
michael@0 6267
michael@0 6268 freebsd-aout)
michael@0 6269 major=".$current"
michael@0 6270 versuffix=".$current.$revision";
michael@0 6271 ;;
michael@0 6272
michael@0 6273 freebsd-elf)
michael@0 6274 major=".$current"
michael@0 6275 versuffix=".$current"
michael@0 6276 ;;
michael@0 6277
michael@0 6278 irix | nonstopux)
michael@0 6279 if test "X$lt_irix_increment" = "Xno"; then
michael@0 6280 func_arith $current - $age
michael@0 6281 else
michael@0 6282 func_arith $current - $age + 1
michael@0 6283 fi
michael@0 6284 major=$func_arith_result
michael@0 6285
michael@0 6286 case $version_type in
michael@0 6287 nonstopux) verstring_prefix=nonstopux ;;
michael@0 6288 *) verstring_prefix=sgi ;;
michael@0 6289 esac
michael@0 6290 verstring="$verstring_prefix$major.$revision"
michael@0 6291
michael@0 6292 # Add in all the interfaces that we are compatible with.
michael@0 6293 loop=$revision
michael@0 6294 while test "$loop" -ne 0; do
michael@0 6295 func_arith $revision - $loop
michael@0 6296 iface=$func_arith_result
michael@0 6297 func_arith $loop - 1
michael@0 6298 loop=$func_arith_result
michael@0 6299 verstring="$verstring_prefix$major.$iface:$verstring"
michael@0 6300 done
michael@0 6301
michael@0 6302 # Before this point, $major must not contain `.'.
michael@0 6303 major=.$major
michael@0 6304 versuffix="$major.$revision"
michael@0 6305 ;;
michael@0 6306
michael@0 6307 linux)
michael@0 6308 func_arith $current - $age
michael@0 6309 major=.$func_arith_result
michael@0 6310 versuffix="$major.$age.$revision"
michael@0 6311 ;;
michael@0 6312
michael@0 6313 osf)
michael@0 6314 func_arith $current - $age
michael@0 6315 major=.$func_arith_result
michael@0 6316 versuffix=".$current.$age.$revision"
michael@0 6317 verstring="$current.$age.$revision"
michael@0 6318
michael@0 6319 # Add in all the interfaces that we are compatible with.
michael@0 6320 loop=$age
michael@0 6321 while test "$loop" -ne 0; do
michael@0 6322 func_arith $current - $loop
michael@0 6323 iface=$func_arith_result
michael@0 6324 func_arith $loop - 1
michael@0 6325 loop=$func_arith_result
michael@0 6326 verstring="$verstring:${iface}.0"
michael@0 6327 done
michael@0 6328
michael@0 6329 # Make executables depend on our current version.
michael@0 6330 verstring="$verstring:${current}.0"
michael@0 6331 ;;
michael@0 6332
michael@0 6333 qnx)
michael@0 6334 major=".$current"
michael@0 6335 versuffix=".$current"
michael@0 6336 ;;
michael@0 6337
michael@0 6338 sunos)
michael@0 6339 major=".$current"
michael@0 6340 versuffix=".$current.$revision"
michael@0 6341 ;;
michael@0 6342
michael@0 6343 windows)
michael@0 6344 # Use '-' rather than '.', since we only want one
michael@0 6345 # extension on DOS 8.3 filesystems.
michael@0 6346 func_arith $current - $age
michael@0 6347 major=$func_arith_result
michael@0 6348 versuffix="-$major"
michael@0 6349 ;;
michael@0 6350
michael@0 6351 *)
michael@0 6352 func_fatal_configuration "unknown library version type \`$version_type'"
michael@0 6353 ;;
michael@0 6354 esac
michael@0 6355
michael@0 6356 # Clear the version info if we defaulted, and they specified a release.
michael@0 6357 if test -z "$vinfo" && test -n "$release"; then
michael@0 6358 major=
michael@0 6359 case $version_type in
michael@0 6360 darwin)
michael@0 6361 # we can't check for "0.0" in archive_cmds due to quoting
michael@0 6362 # problems, so we reset it completely
michael@0 6363 verstring=
michael@0 6364 ;;
michael@0 6365 *)
michael@0 6366 verstring="0.0"
michael@0 6367 ;;
michael@0 6368 esac
michael@0 6369 if test "$need_version" = no; then
michael@0 6370 versuffix=
michael@0 6371 else
michael@0 6372 versuffix=".0.0"
michael@0 6373 fi
michael@0 6374 fi
michael@0 6375
michael@0 6376 # Remove version info from name if versioning should be avoided
michael@0 6377 if test "$avoid_version" = yes && test "$need_version" = no; then
michael@0 6378 major=
michael@0 6379 versuffix=
michael@0 6380 verstring=""
michael@0 6381 fi
michael@0 6382
michael@0 6383 # Check to see if the archive will have undefined symbols.
michael@0 6384 if test "$allow_undefined" = yes; then
michael@0 6385 if test "$allow_undefined_flag" = unsupported; then
michael@0 6386 func_warning "undefined symbols not allowed in $host shared libraries"
michael@0 6387 build_libtool_libs=no
michael@0 6388 build_old_libs=yes
michael@0 6389 fi
michael@0 6390 else
michael@0 6391 # Don't allow undefined symbols.
michael@0 6392 allow_undefined_flag="$no_undefined_flag"
michael@0 6393 fi
michael@0 6394
michael@0 6395 fi
michael@0 6396
michael@0 6397 func_generate_dlsyms "$libname" "$libname" "yes"
michael@0 6398 libobjs="$libobjs $symfileobj"
michael@0 6399 test "X$libobjs" = "X " && libobjs=
michael@0 6400
michael@0 6401 if test "$mode" != relink; then
michael@0 6402 # Remove our outputs, but don't remove object files since they
michael@0 6403 # may have been created when compiling PIC objects.
michael@0 6404 removelist=
michael@0 6405 tempremovelist=`$ECHO "$output_objdir/*"`
michael@0 6406 for p in $tempremovelist; do
michael@0 6407 case $p in
michael@0 6408 *.$objext | *.gcno)
michael@0 6409 ;;
michael@0 6410 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
michael@0 6411 if test "X$precious_files_regex" != "X"; then
michael@0 6412 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
michael@0 6413 then
michael@0 6414 continue
michael@0 6415 fi
michael@0 6416 fi
michael@0 6417 removelist="$removelist $p"
michael@0 6418 ;;
michael@0 6419 *) ;;
michael@0 6420 esac
michael@0 6421 done
michael@0 6422 test -n "$removelist" && \
michael@0 6423 func_show_eval "${RM}r \$removelist"
michael@0 6424 fi
michael@0 6425
michael@0 6426 # Now set the variables for building old libraries.
michael@0 6427 if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
michael@0 6428 oldlibs="$oldlibs $output_objdir/$libname.$libext"
michael@0 6429
michael@0 6430 # Transform .lo files to .o files.
michael@0 6431 oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
michael@0 6432 fi
michael@0 6433
michael@0 6434 # Eliminate all temporary directories.
michael@0 6435 #for path in $notinst_path; do
michael@0 6436 # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
michael@0 6437 # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
michael@0 6438 # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
michael@0 6439 #done
michael@0 6440
michael@0 6441 if test -n "$xrpath"; then
michael@0 6442 # If the user specified any rpath flags, then add them.
michael@0 6443 temp_xrpath=
michael@0 6444 for libdir in $xrpath; do
michael@0 6445 temp_xrpath="$temp_xrpath -R$libdir"
michael@0 6446 case "$finalize_rpath " in
michael@0 6447 *" $libdir "*) ;;
michael@0 6448 *) finalize_rpath="$finalize_rpath $libdir" ;;
michael@0 6449 esac
michael@0 6450 done
michael@0 6451 if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
michael@0 6452 dependency_libs="$temp_xrpath $dependency_libs"
michael@0 6453 fi
michael@0 6454 fi
michael@0 6455
michael@0 6456 # Make sure dlfiles contains only unique files that won't be dlpreopened
michael@0 6457 old_dlfiles="$dlfiles"
michael@0 6458 dlfiles=
michael@0 6459 for lib in $old_dlfiles; do
michael@0 6460 case " $dlprefiles $dlfiles " in
michael@0 6461 *" $lib "*) ;;
michael@0 6462 *) dlfiles="$dlfiles $lib" ;;
michael@0 6463 esac
michael@0 6464 done
michael@0 6465
michael@0 6466 # Make sure dlprefiles contains only unique files
michael@0 6467 old_dlprefiles="$dlprefiles"
michael@0 6468 dlprefiles=
michael@0 6469 for lib in $old_dlprefiles; do
michael@0 6470 case "$dlprefiles " in
michael@0 6471 *" $lib "*) ;;
michael@0 6472 *) dlprefiles="$dlprefiles $lib" ;;
michael@0 6473 esac
michael@0 6474 done
michael@0 6475
michael@0 6476 if test "$build_libtool_libs" = yes; then
michael@0 6477 if test -n "$rpath"; then
michael@0 6478 case $host in
michael@0 6479 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
michael@0 6480 # these systems don't actually have a c library (as such)!
michael@0 6481 ;;
michael@0 6482 *-*-rhapsody* | *-*-darwin1.[012])
michael@0 6483 # Rhapsody C library is in the System framework
michael@0 6484 deplibs="$deplibs System.ltframework"
michael@0 6485 ;;
michael@0 6486 *-*-netbsd*)
michael@0 6487 # Don't link with libc until the a.out ld.so is fixed.
michael@0 6488 ;;
michael@0 6489 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
michael@0 6490 # Do not include libc due to us having libc/libc_r.
michael@0 6491 ;;
michael@0 6492 *-*-sco3.2v5* | *-*-sco5v6*)
michael@0 6493 # Causes problems with __ctype
michael@0 6494 ;;
michael@0 6495 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
michael@0 6496 # Compiler inserts libc in the correct place for threads to work
michael@0 6497 ;;
michael@0 6498 *)
michael@0 6499 # Add libc to deplibs on all other systems if necessary.
michael@0 6500 if test "$build_libtool_need_lc" = "yes"; then
michael@0 6501 deplibs="$deplibs -lc"
michael@0 6502 fi
michael@0 6503 ;;
michael@0 6504 esac
michael@0 6505 fi
michael@0 6506
michael@0 6507 # Transform deplibs into only deplibs that can be linked in shared.
michael@0 6508 name_save=$name
michael@0 6509 libname_save=$libname
michael@0 6510 release_save=$release
michael@0 6511 versuffix_save=$versuffix
michael@0 6512 major_save=$major
michael@0 6513 # I'm not sure if I'm treating the release correctly. I think
michael@0 6514 # release should show up in the -l (ie -lgmp5) so we don't want to
michael@0 6515 # add it in twice. Is that correct?
michael@0 6516 release=""
michael@0 6517 versuffix=""
michael@0 6518 major=""
michael@0 6519 newdeplibs=
michael@0 6520 droppeddeps=no
michael@0 6521 case $deplibs_check_method in
michael@0 6522 pass_all)
michael@0 6523 # Don't check for shared/static. Everything works.
michael@0 6524 # This might be a little naive. We might want to check
michael@0 6525 # whether the library exists or not. But this is on
michael@0 6526 # osf3 & osf4 and I'm not really sure... Just
michael@0 6527 # implementing what was already the behavior.
michael@0 6528 newdeplibs=$deplibs
michael@0 6529 ;;
michael@0 6530 test_compile)
michael@0 6531 # This code stresses the "libraries are programs" paradigm to its
michael@0 6532 # limits. Maybe even breaks it. We compile a program, linking it
michael@0 6533 # against the deplibs as a proxy for the library. Then we can check
michael@0 6534 # whether they linked in statically or dynamically with ldd.
michael@0 6535 $opt_dry_run || $RM conftest.c
michael@0 6536 cat > conftest.c <<EOF
michael@0 6537 int main() { return 0; }
michael@0 6538 EOF
michael@0 6539 $opt_dry_run || $RM conftest
michael@0 6540 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
michael@0 6541 ldd_output=`ldd conftest`
michael@0 6542 for i in $deplibs; do
michael@0 6543 case $i in
michael@0 6544 -l*)
michael@0 6545 func_stripname -l '' "$i"
michael@0 6546 name=$func_stripname_result
michael@0 6547 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
michael@0 6548 case " $predeps $postdeps " in
michael@0 6549 *" $i "*)
michael@0 6550 newdeplibs="$newdeplibs $i"
michael@0 6551 i=""
michael@0 6552 ;;
michael@0 6553 esac
michael@0 6554 fi
michael@0 6555 if test -n "$i" ; then
michael@0 6556 libname=`eval "\\$ECHO \"$libname_spec\""`
michael@0 6557 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
michael@0 6558 set dummy $deplib_matches; shift
michael@0 6559 deplib_match=$1
michael@0 6560 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
michael@0 6561 newdeplibs="$newdeplibs $i"
michael@0 6562 else
michael@0 6563 droppeddeps=yes
michael@0 6564 $ECHO
michael@0 6565 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
michael@0 6566 $ECHO "*** I have the capability to make that library automatically link in when"
michael@0 6567 $ECHO "*** you link to this library. But I can only do this if you have a"
michael@0 6568 $ECHO "*** shared version of the library, which I believe you do not have"
michael@0 6569 $ECHO "*** because a test_compile did reveal that the linker did not use it for"
michael@0 6570 $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
michael@0 6571 fi
michael@0 6572 fi
michael@0 6573 ;;
michael@0 6574 *)
michael@0 6575 newdeplibs="$newdeplibs $i"
michael@0 6576 ;;
michael@0 6577 esac
michael@0 6578 done
michael@0 6579 else
michael@0 6580 # Error occurred in the first compile. Let's try to salvage
michael@0 6581 # the situation: Compile a separate program for each library.
michael@0 6582 for i in $deplibs; do
michael@0 6583 case $i in
michael@0 6584 -l*)
michael@0 6585 func_stripname -l '' "$i"
michael@0 6586 name=$func_stripname_result
michael@0 6587 $opt_dry_run || $RM conftest
michael@0 6588 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
michael@0 6589 ldd_output=`ldd conftest`
michael@0 6590 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
michael@0 6591 case " $predeps $postdeps " in
michael@0 6592 *" $i "*)
michael@0 6593 newdeplibs="$newdeplibs $i"
michael@0 6594 i=""
michael@0 6595 ;;
michael@0 6596 esac
michael@0 6597 fi
michael@0 6598 if test -n "$i" ; then
michael@0 6599 libname=`eval "\\$ECHO \"$libname_spec\""`
michael@0 6600 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
michael@0 6601 set dummy $deplib_matches; shift
michael@0 6602 deplib_match=$1
michael@0 6603 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
michael@0 6604 newdeplibs="$newdeplibs $i"
michael@0 6605 else
michael@0 6606 droppeddeps=yes
michael@0 6607 $ECHO
michael@0 6608 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
michael@0 6609 $ECHO "*** I have the capability to make that library automatically link in when"
michael@0 6610 $ECHO "*** you link to this library. But I can only do this if you have a"
michael@0 6611 $ECHO "*** shared version of the library, which you do not appear to have"
michael@0 6612 $ECHO "*** because a test_compile did reveal that the linker did not use this one"
michael@0 6613 $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
michael@0 6614 fi
michael@0 6615 fi
michael@0 6616 else
michael@0 6617 droppeddeps=yes
michael@0 6618 $ECHO
michael@0 6619 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
michael@0 6620 $ECHO "*** make it link in! You will probably need to install it or some"
michael@0 6621 $ECHO "*** library that it depends on before this library will be fully"
michael@0 6622 $ECHO "*** functional. Installing it before continuing would be even better."
michael@0 6623 fi
michael@0 6624 ;;
michael@0 6625 *)
michael@0 6626 newdeplibs="$newdeplibs $i"
michael@0 6627 ;;
michael@0 6628 esac
michael@0 6629 done
michael@0 6630 fi
michael@0 6631 ;;
michael@0 6632 file_magic*)
michael@0 6633 set dummy $deplibs_check_method; shift
michael@0 6634 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
michael@0 6635 for a_deplib in $deplibs; do
michael@0 6636 case $a_deplib in
michael@0 6637 -l*)
michael@0 6638 func_stripname -l '' "$a_deplib"
michael@0 6639 name=$func_stripname_result
michael@0 6640 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
michael@0 6641 case " $predeps $postdeps " in
michael@0 6642 *" $a_deplib "*)
michael@0 6643 newdeplibs="$newdeplibs $a_deplib"
michael@0 6644 a_deplib=""
michael@0 6645 ;;
michael@0 6646 esac
michael@0 6647 fi
michael@0 6648 if test -n "$a_deplib" ; then
michael@0 6649 libname=`eval "\\$ECHO \"$libname_spec\""`
michael@0 6650 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
michael@0 6651 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
michael@0 6652 for potent_lib in $potential_libs; do
michael@0 6653 # Follow soft links.
michael@0 6654 if ls -lLd "$potent_lib" 2>/dev/null |
michael@0 6655 $GREP " -> " >/dev/null; then
michael@0 6656 continue
michael@0 6657 fi
michael@0 6658 # The statement above tries to avoid entering an
michael@0 6659 # endless loop below, in case of cyclic links.
michael@0 6660 # We might still enter an endless loop, since a link
michael@0 6661 # loop can be closed while we follow links,
michael@0 6662 # but so what?
michael@0 6663 potlib="$potent_lib"
michael@0 6664 while test -h "$potlib" 2>/dev/null; do
michael@0 6665 potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
michael@0 6666 case $potliblink in
michael@0 6667 [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
michael@0 6668 *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
michael@0 6669 esac
michael@0 6670 done
michael@0 6671 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
michael@0 6672 $SED -e 10q |
michael@0 6673 $EGREP "$file_magic_regex" > /dev/null; then
michael@0 6674 newdeplibs="$newdeplibs $a_deplib"
michael@0 6675 a_deplib=""
michael@0 6676 break 2
michael@0 6677 fi
michael@0 6678 done
michael@0 6679 done
michael@0 6680 fi
michael@0 6681 if test -n "$a_deplib" ; then
michael@0 6682 droppeddeps=yes
michael@0 6683 $ECHO
michael@0 6684 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
michael@0 6685 $ECHO "*** I have the capability to make that library automatically link in when"
michael@0 6686 $ECHO "*** you link to this library. But I can only do this if you have a"
michael@0 6687 $ECHO "*** shared version of the library, which you do not appear to have"
michael@0 6688 $ECHO "*** because I did check the linker path looking for a file starting"
michael@0 6689 if test -z "$potlib" ; then
michael@0 6690 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
michael@0 6691 else
michael@0 6692 $ECHO "*** with $libname and none of the candidates passed a file format test"
michael@0 6693 $ECHO "*** using a file magic. Last file checked: $potlib"
michael@0 6694 fi
michael@0 6695 fi
michael@0 6696 ;;
michael@0 6697 *)
michael@0 6698 # Add a -L argument.
michael@0 6699 newdeplibs="$newdeplibs $a_deplib"
michael@0 6700 ;;
michael@0 6701 esac
michael@0 6702 done # Gone through all deplibs.
michael@0 6703 ;;
michael@0 6704 match_pattern*)
michael@0 6705 set dummy $deplibs_check_method; shift
michael@0 6706 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
michael@0 6707 for a_deplib in $deplibs; do
michael@0 6708 case $a_deplib in
michael@0 6709 -l*)
michael@0 6710 func_stripname -l '' "$a_deplib"
michael@0 6711 name=$func_stripname_result
michael@0 6712 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
michael@0 6713 case " $predeps $postdeps " in
michael@0 6714 *" $a_deplib "*)
michael@0 6715 newdeplibs="$newdeplibs $a_deplib"
michael@0 6716 a_deplib=""
michael@0 6717 ;;
michael@0 6718 esac
michael@0 6719 fi
michael@0 6720 if test -n "$a_deplib" ; then
michael@0 6721 libname=`eval "\\$ECHO \"$libname_spec\""`
michael@0 6722 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
michael@0 6723 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
michael@0 6724 for potent_lib in $potential_libs; do
michael@0 6725 potlib="$potent_lib" # see symlink-check above in file_magic test
michael@0 6726 if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
michael@0 6727 $EGREP "$match_pattern_regex" > /dev/null; then
michael@0 6728 newdeplibs="$newdeplibs $a_deplib"
michael@0 6729 a_deplib=""
michael@0 6730 break 2
michael@0 6731 fi
michael@0 6732 done
michael@0 6733 done
michael@0 6734 fi
michael@0 6735 if test -n "$a_deplib" ; then
michael@0 6736 droppeddeps=yes
michael@0 6737 $ECHO
michael@0 6738 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
michael@0 6739 $ECHO "*** I have the capability to make that library automatically link in when"
michael@0 6740 $ECHO "*** you link to this library. But I can only do this if you have a"
michael@0 6741 $ECHO "*** shared version of the library, which you do not appear to have"
michael@0 6742 $ECHO "*** because I did check the linker path looking for a file starting"
michael@0 6743 if test -z "$potlib" ; then
michael@0 6744 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
michael@0 6745 else
michael@0 6746 $ECHO "*** with $libname and none of the candidates passed a file format test"
michael@0 6747 $ECHO "*** using a regex pattern. Last file checked: $potlib"
michael@0 6748 fi
michael@0 6749 fi
michael@0 6750 ;;
michael@0 6751 *)
michael@0 6752 # Add a -L argument.
michael@0 6753 newdeplibs="$newdeplibs $a_deplib"
michael@0 6754 ;;
michael@0 6755 esac
michael@0 6756 done # Gone through all deplibs.
michael@0 6757 ;;
michael@0 6758 none | unknown | *)
michael@0 6759 newdeplibs=""
michael@0 6760 tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
michael@0 6761 -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
michael@0 6762 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
michael@0 6763 for i in $predeps $postdeps ; do
michael@0 6764 # can't use Xsed below, because $i might contain '/'
michael@0 6765 tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
michael@0 6766 done
michael@0 6767 fi
michael@0 6768 if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[ ]//g' |
michael@0 6769 $GREP . >/dev/null; then
michael@0 6770 $ECHO
michael@0 6771 if test "X$deplibs_check_method" = "Xnone"; then
michael@0 6772 $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
michael@0 6773 else
michael@0 6774 $ECHO "*** Warning: inter-library dependencies are not known to be supported."
michael@0 6775 fi
michael@0 6776 $ECHO "*** All declared inter-library dependencies are being dropped."
michael@0 6777 droppeddeps=yes
michael@0 6778 fi
michael@0 6779 ;;
michael@0 6780 esac
michael@0 6781 versuffix=$versuffix_save
michael@0 6782 major=$major_save
michael@0 6783 release=$release_save
michael@0 6784 libname=$libname_save
michael@0 6785 name=$name_save
michael@0 6786
michael@0 6787 case $host in
michael@0 6788 *-*-rhapsody* | *-*-darwin1.[012])
michael@0 6789 # On Rhapsody replace the C library with the System framework
michael@0 6790 newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
michael@0 6791 ;;
michael@0 6792 esac
michael@0 6793
michael@0 6794 if test "$droppeddeps" = yes; then
michael@0 6795 if test "$module" = yes; then
michael@0 6796 $ECHO
michael@0 6797 $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
michael@0 6798 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
michael@0 6799 $ECHO "*** a static module, that should work as long as the dlopening"
michael@0 6800 $ECHO "*** application is linked with the -dlopen flag."
michael@0 6801 if test -z "$global_symbol_pipe"; then
michael@0 6802 $ECHO
michael@0 6803 $ECHO "*** However, this would only work if libtool was able to extract symbol"
michael@0 6804 $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
michael@0 6805 $ECHO "*** not find such a program. So, this module is probably useless."
michael@0 6806 $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
michael@0 6807 fi
michael@0 6808 if test "$build_old_libs" = no; then
michael@0 6809 oldlibs="$output_objdir/$libname.$libext"
michael@0 6810 build_libtool_libs=module
michael@0 6811 build_old_libs=yes
michael@0 6812 else
michael@0 6813 build_libtool_libs=no
michael@0 6814 fi
michael@0 6815 else
michael@0 6816 $ECHO "*** The inter-library dependencies that have been dropped here will be"
michael@0 6817 $ECHO "*** automatically added whenever a program is linked with this library"
michael@0 6818 $ECHO "*** or is declared to -dlopen it."
michael@0 6819
michael@0 6820 if test "$allow_undefined" = no; then
michael@0 6821 $ECHO
michael@0 6822 $ECHO "*** Since this library must not contain undefined symbols,"
michael@0 6823 $ECHO "*** because either the platform does not support them or"
michael@0 6824 $ECHO "*** it was explicitly requested with -no-undefined,"
michael@0 6825 $ECHO "*** libtool will only create a static version of it."
michael@0 6826 if test "$build_old_libs" = no; then
michael@0 6827 oldlibs="$output_objdir/$libname.$libext"
michael@0 6828 build_libtool_libs=module
michael@0 6829 build_old_libs=yes
michael@0 6830 else
michael@0 6831 build_libtool_libs=no
michael@0 6832 fi
michael@0 6833 fi
michael@0 6834 fi
michael@0 6835 fi
michael@0 6836 # Done checking deplibs!
michael@0 6837 deplibs=$newdeplibs
michael@0 6838 fi
michael@0 6839 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
michael@0 6840 case $host in
michael@0 6841 *-*-darwin*)
michael@0 6842 newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
michael@0 6843 new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
michael@0 6844 deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
michael@0 6845 ;;
michael@0 6846 esac
michael@0 6847
michael@0 6848 # move library search paths that coincide with paths to not yet
michael@0 6849 # installed libraries to the beginning of the library search list
michael@0 6850 new_libs=
michael@0 6851 for path in $notinst_path; do
michael@0 6852 case " $new_libs " in
michael@0 6853 *" -L$path/$objdir "*) ;;
michael@0 6854 *)
michael@0 6855 case " $deplibs " in
michael@0 6856 *" -L$path/$objdir "*)
michael@0 6857 new_libs="$new_libs -L$path/$objdir" ;;
michael@0 6858 esac
michael@0 6859 ;;
michael@0 6860 esac
michael@0 6861 done
michael@0 6862 for deplib in $deplibs; do
michael@0 6863 case $deplib in
michael@0 6864 -L*)
michael@0 6865 case " $new_libs " in
michael@0 6866 *" $deplib "*) ;;
michael@0 6867 *) new_libs="$new_libs $deplib" ;;
michael@0 6868 esac
michael@0 6869 ;;
michael@0 6870 *) new_libs="$new_libs $deplib" ;;
michael@0 6871 esac
michael@0 6872 done
michael@0 6873 deplibs="$new_libs"
michael@0 6874
michael@0 6875 # All the library-specific variables (install_libdir is set above).
michael@0 6876 library_names=
michael@0 6877 old_library=
michael@0 6878 dlname=
michael@0 6879
michael@0 6880 # Test again, we may have decided not to build it any more
michael@0 6881 if test "$build_libtool_libs" = yes; then
michael@0 6882 if test "$hardcode_into_libs" = yes; then
michael@0 6883 # Hardcode the library paths
michael@0 6884 hardcode_libdirs=
michael@0 6885 dep_rpath=
michael@0 6886 rpath="$finalize_rpath"
michael@0 6887 test "$mode" != relink && rpath="$compile_rpath$rpath"
michael@0 6888 for libdir in $rpath; do
michael@0 6889 if test -n "$hardcode_libdir_flag_spec"; then
michael@0 6890 if test -n "$hardcode_libdir_separator"; then
michael@0 6891 if test -z "$hardcode_libdirs"; then
michael@0 6892 hardcode_libdirs="$libdir"
michael@0 6893 else
michael@0 6894 # Just accumulate the unique libdirs.
michael@0 6895 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
michael@0 6896 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
michael@0 6897 ;;
michael@0 6898 *)
michael@0 6899 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
michael@0 6900 ;;
michael@0 6901 esac
michael@0 6902 fi
michael@0 6903 else
michael@0 6904 eval flag=\"$hardcode_libdir_flag_spec\"
michael@0 6905 dep_rpath="$dep_rpath $flag"
michael@0 6906 fi
michael@0 6907 elif test -n "$runpath_var"; then
michael@0 6908 case "$perm_rpath " in
michael@0 6909 *" $libdir "*) ;;
michael@0 6910 *) perm_rpath="$perm_rpath $libdir" ;;
michael@0 6911 esac
michael@0 6912 fi
michael@0 6913 done
michael@0 6914 # Substitute the hardcoded libdirs into the rpath.
michael@0 6915 if test -n "$hardcode_libdir_separator" &&
michael@0 6916 test -n "$hardcode_libdirs"; then
michael@0 6917 libdir="$hardcode_libdirs"
michael@0 6918 if test -n "$hardcode_libdir_flag_spec_ld"; then
michael@0 6919 eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
michael@0 6920 else
michael@0 6921 eval dep_rpath=\"$hardcode_libdir_flag_spec\"
michael@0 6922 fi
michael@0 6923 fi
michael@0 6924 if test -n "$runpath_var" && test -n "$perm_rpath"; then
michael@0 6925 # We should set the runpath_var.
michael@0 6926 rpath=
michael@0 6927 for dir in $perm_rpath; do
michael@0 6928 rpath="$rpath$dir:"
michael@0 6929 done
michael@0 6930 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
michael@0 6931 fi
michael@0 6932 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
michael@0 6933 fi
michael@0 6934
michael@0 6935 shlibpath="$finalize_shlibpath"
michael@0 6936 test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
michael@0 6937 if test -n "$shlibpath"; then
michael@0 6938 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
michael@0 6939 fi
michael@0 6940
michael@0 6941 # Get the real and link names of the library.
michael@0 6942 eval shared_ext=\"$shrext_cmds\"
michael@0 6943 eval library_names=\"$library_names_spec\"
michael@0 6944 set dummy $library_names
michael@0 6945 shift
michael@0 6946 realname="$1"
michael@0 6947 shift
michael@0 6948
michael@0 6949 if test -n "$soname_spec"; then
michael@0 6950 eval soname=\"$soname_spec\"
michael@0 6951 else
michael@0 6952 soname="$realname"
michael@0 6953 fi
michael@0 6954 if test -z "$dlname"; then
michael@0 6955 dlname=$soname
michael@0 6956 fi
michael@0 6957
michael@0 6958 lib="$output_objdir/$realname"
michael@0 6959 linknames=
michael@0 6960 for link
michael@0 6961 do
michael@0 6962 linknames="$linknames $link"
michael@0 6963 done
michael@0 6964
michael@0 6965 # Use standard objects if they are pic
michael@0 6966 test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
michael@0 6967 test "X$libobjs" = "X " && libobjs=
michael@0 6968
michael@0 6969 delfiles=
michael@0 6970 if test -n "$export_symbols" && test -n "$include_expsyms"; then
michael@0 6971 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
michael@0 6972 export_symbols="$output_objdir/$libname.uexp"
michael@0 6973 delfiles="$delfiles $export_symbols"
michael@0 6974 fi
michael@0 6975
michael@0 6976 orig_export_symbols=
michael@0 6977 case $host_os in
michael@0 6978 cygwin* | mingw* | cegcc*)
michael@0 6979 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
michael@0 6980 # exporting using user supplied symfile
michael@0 6981 if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
michael@0 6982 # and it's NOT already a .def file. Must figure out
michael@0 6983 # which of the given symbols are data symbols and tag
michael@0 6984 # them as such. So, trigger use of export_symbols_cmds.
michael@0 6985 # export_symbols gets reassigned inside the "prepare
michael@0 6986 # the list of exported symbols" if statement, so the
michael@0 6987 # include_expsyms logic still works.
michael@0 6988 orig_export_symbols="$export_symbols"
michael@0 6989 export_symbols=
michael@0 6990 always_export_symbols=yes
michael@0 6991 fi
michael@0 6992 fi
michael@0 6993 ;;
michael@0 6994 esac
michael@0 6995
michael@0 6996 # Prepare the list of exported symbols
michael@0 6997 if test -z "$export_symbols"; then
michael@0 6998 if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
michael@0 6999 func_verbose "generating symbol list for \`$libname.la'"
michael@0 7000 export_symbols="$output_objdir/$libname.exp"
michael@0 7001 $opt_dry_run || $RM $export_symbols
michael@0 7002 cmds=$export_symbols_cmds
michael@0 7003 save_ifs="$IFS"; IFS='~'
michael@0 7004 for cmd in $cmds; do
michael@0 7005 IFS="$save_ifs"
michael@0 7006 eval cmd=\"$cmd\"
michael@0 7007 func_len " $cmd"
michael@0 7008 len=$func_len_result
michael@0 7009 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
michael@0 7010 func_show_eval "$cmd" 'exit $?'
michael@0 7011 skipped_export=false
michael@0 7012 else
michael@0 7013 # The command line is too long to execute in one step.
michael@0 7014 func_verbose "using reloadable object file for export list..."
michael@0 7015 skipped_export=:
michael@0 7016 # Break out early, otherwise skipped_export may be
michael@0 7017 # set to false by a later but shorter cmd.
michael@0 7018 break
michael@0 7019 fi
michael@0 7020 done
michael@0 7021 IFS="$save_ifs"
michael@0 7022 if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
michael@0 7023 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
michael@0 7024 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
michael@0 7025 fi
michael@0 7026 fi
michael@0 7027 fi
michael@0 7028
michael@0 7029 if test -n "$export_symbols" && test -n "$include_expsyms"; then
michael@0 7030 tmp_export_symbols="$export_symbols"
michael@0 7031 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
michael@0 7032 $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
michael@0 7033 fi
michael@0 7034
michael@0 7035 if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
michael@0 7036 # The given exports_symbols file has to be filtered, so filter it.
michael@0 7037 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
michael@0 7038 # FIXME: $output_objdir/$libname.filter potentially contains lots of
michael@0 7039 # 's' commands which not all seds can handle. GNU sed should be fine
michael@0 7040 # though. Also, the filter scales superlinearly with the number of
michael@0 7041 # global variables. join(1) would be nice here, but unfortunately
michael@0 7042 # isn't a blessed tool.
michael@0 7043 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
michael@0 7044 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
michael@0 7045 export_symbols=$output_objdir/$libname.def
michael@0 7046 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
michael@0 7047 fi
michael@0 7048
michael@0 7049 tmp_deplibs=
michael@0 7050 for test_deplib in $deplibs; do
michael@0 7051 case " $convenience " in
michael@0 7052 *" $test_deplib "*) ;;
michael@0 7053 *)
michael@0 7054 tmp_deplibs="$tmp_deplibs $test_deplib"
michael@0 7055 ;;
michael@0 7056 esac
michael@0 7057 done
michael@0 7058 deplibs="$tmp_deplibs"
michael@0 7059
michael@0 7060 if test -n "$convenience"; then
michael@0 7061 if test -n "$whole_archive_flag_spec" &&
michael@0 7062 test "$compiler_needs_object" = yes &&
michael@0 7063 test -z "$libobjs"; then
michael@0 7064 # extract the archives, so we have objects to list.
michael@0 7065 # TODO: could optimize this to just extract one archive.
michael@0 7066 whole_archive_flag_spec=
michael@0 7067 fi
michael@0 7068 if test -n "$whole_archive_flag_spec"; then
michael@0 7069 save_libobjs=$libobjs
michael@0 7070 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
michael@0 7071 test "X$libobjs" = "X " && libobjs=
michael@0 7072 else
michael@0 7073 gentop="$output_objdir/${outputname}x"
michael@0 7074 generated="$generated $gentop"
michael@0 7075
michael@0 7076 func_extract_archives $gentop $convenience
michael@0 7077 libobjs="$libobjs $func_extract_archives_result"
michael@0 7078 test "X$libobjs" = "X " && libobjs=
michael@0 7079 fi
michael@0 7080 fi
michael@0 7081
michael@0 7082 if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
michael@0 7083 eval flag=\"$thread_safe_flag_spec\"
michael@0 7084 linker_flags="$linker_flags $flag"
michael@0 7085 fi
michael@0 7086
michael@0 7087 # Make a backup of the uninstalled library when relinking
michael@0 7088 if test "$mode" = relink; then
michael@0 7089 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
michael@0 7090 fi
michael@0 7091
michael@0 7092 # Do each of the archive commands.
michael@0 7093 if test "$module" = yes && test -n "$module_cmds" ; then
michael@0 7094 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
michael@0 7095 eval test_cmds=\"$module_expsym_cmds\"
michael@0 7096 cmds=$module_expsym_cmds
michael@0 7097 else
michael@0 7098 eval test_cmds=\"$module_cmds\"
michael@0 7099 cmds=$module_cmds
michael@0 7100 fi
michael@0 7101 else
michael@0 7102 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
michael@0 7103 eval test_cmds=\"$archive_expsym_cmds\"
michael@0 7104 cmds=$archive_expsym_cmds
michael@0 7105 else
michael@0 7106 eval test_cmds=\"$archive_cmds\"
michael@0 7107 cmds=$archive_cmds
michael@0 7108 fi
michael@0 7109 fi
michael@0 7110
michael@0 7111 if test "X$skipped_export" != "X:" &&
michael@0 7112 func_len " $test_cmds" &&
michael@0 7113 len=$func_len_result &&
michael@0 7114 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
michael@0 7115 :
michael@0 7116 else
michael@0 7117 # The command line is too long to link in one step, link piecewise
michael@0 7118 # or, if using GNU ld and skipped_export is not :, use a linker
michael@0 7119 # script.
michael@0 7120
michael@0 7121 # Save the value of $output and $libobjs because we want to
michael@0 7122 # use them later. If we have whole_archive_flag_spec, we
michael@0 7123 # want to use save_libobjs as it was before
michael@0 7124 # whole_archive_flag_spec was expanded, because we can't
michael@0 7125 # assume the linker understands whole_archive_flag_spec.
michael@0 7126 # This may have to be revisited, in case too many
michael@0 7127 # convenience libraries get linked in and end up exceeding
michael@0 7128 # the spec.
michael@0 7129 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
michael@0 7130 save_libobjs=$libobjs
michael@0 7131 fi
michael@0 7132 save_output=$output
michael@0 7133 output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
michael@0 7134
michael@0 7135 # Clear the reloadable object creation command queue and
michael@0 7136 # initialize k to one.
michael@0 7137 test_cmds=
michael@0 7138 concat_cmds=
michael@0 7139 objlist=
michael@0 7140 last_robj=
michael@0 7141 k=1
michael@0 7142
michael@0 7143 if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
michael@0 7144 output=${output_objdir}/${output_la}.lnkscript
michael@0 7145 func_verbose "creating GNU ld script: $output"
michael@0 7146 $ECHO 'INPUT (' > $output
michael@0 7147 for obj in $save_libobjs
michael@0 7148 do
michael@0 7149 $ECHO "$obj" >> $output
michael@0 7150 done
michael@0 7151 $ECHO ')' >> $output
michael@0 7152 delfiles="$delfiles $output"
michael@0 7153 elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
michael@0 7154 output=${output_objdir}/${output_la}.lnk
michael@0 7155 func_verbose "creating linker input file list: $output"
michael@0 7156 : > $output
michael@0 7157 set x $save_libobjs
michael@0 7158 shift
michael@0 7159 firstobj=
michael@0 7160 if test "$compiler_needs_object" = yes; then
michael@0 7161 firstobj="$1 "
michael@0 7162 shift
michael@0 7163 fi
michael@0 7164 for obj
michael@0 7165 do
michael@0 7166 $ECHO "$obj" >> $output
michael@0 7167 done
michael@0 7168 delfiles="$delfiles $output"
michael@0 7169 output=$firstobj\"$file_list_spec$output\"
michael@0 7170 else
michael@0 7171 if test -n "$save_libobjs"; then
michael@0 7172 func_verbose "creating reloadable object files..."
michael@0 7173 output=$output_objdir/$output_la-${k}.$objext
michael@0 7174 eval test_cmds=\"$reload_cmds\"
michael@0 7175 func_len " $test_cmds"
michael@0 7176 len0=$func_len_result
michael@0 7177 len=$len0
michael@0 7178
michael@0 7179 # Loop over the list of objects to be linked.
michael@0 7180 for obj in $save_libobjs
michael@0 7181 do
michael@0 7182 func_len " $obj"
michael@0 7183 func_arith $len + $func_len_result
michael@0 7184 len=$func_arith_result
michael@0 7185 if test "X$objlist" = X ||
michael@0 7186 test "$len" -lt "$max_cmd_len"; then
michael@0 7187 func_append objlist " $obj"
michael@0 7188 else
michael@0 7189 # The command $test_cmds is almost too long, add a
michael@0 7190 # command to the queue.
michael@0 7191 if test "$k" -eq 1 ; then
michael@0 7192 # The first file doesn't have a previous command to add.
michael@0 7193 eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
michael@0 7194 else
michael@0 7195 # All subsequent reloadable object files will link in
michael@0 7196 # the last one created.
michael@0 7197 eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
michael@0 7198 fi
michael@0 7199 last_robj=$output_objdir/$output_la-${k}.$objext
michael@0 7200 func_arith $k + 1
michael@0 7201 k=$func_arith_result
michael@0 7202 output=$output_objdir/$output_la-${k}.$objext
michael@0 7203 objlist=$obj
michael@0 7204 func_len " $last_robj"
michael@0 7205 func_arith $len0 + $func_len_result
michael@0 7206 len=$func_arith_result
michael@0 7207 fi
michael@0 7208 done
michael@0 7209 # Handle the remaining objects by creating one last
michael@0 7210 # reloadable object file. All subsequent reloadable object
michael@0 7211 # files will link in the last one created.
michael@0 7212 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
michael@0 7213 eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
michael@0 7214 if test -n "$last_robj"; then
michael@0 7215 eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
michael@0 7216 fi
michael@0 7217 delfiles="$delfiles $output"
michael@0 7218
michael@0 7219 else
michael@0 7220 output=
michael@0 7221 fi
michael@0 7222
michael@0 7223 if ${skipped_export-false}; then
michael@0 7224 func_verbose "generating symbol list for \`$libname.la'"
michael@0 7225 export_symbols="$output_objdir/$libname.exp"
michael@0 7226 $opt_dry_run || $RM $export_symbols
michael@0 7227 libobjs=$output
michael@0 7228 # Append the command to create the export file.
michael@0 7229 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
michael@0 7230 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
michael@0 7231 if test -n "$last_robj"; then
michael@0 7232 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
michael@0 7233 fi
michael@0 7234 fi
michael@0 7235
michael@0 7236 test -n "$save_libobjs" &&
michael@0 7237 func_verbose "creating a temporary reloadable object file: $output"
michael@0 7238
michael@0 7239 # Loop through the commands generated above and execute them.
michael@0 7240 save_ifs="$IFS"; IFS='~'
michael@0 7241 for cmd in $concat_cmds; do
michael@0 7242 IFS="$save_ifs"
michael@0 7243 $opt_silent || {
michael@0 7244 func_quote_for_expand "$cmd"
michael@0 7245 eval "func_echo $func_quote_for_expand_result"
michael@0 7246 }
michael@0 7247 $opt_dry_run || eval "$cmd" || {
michael@0 7248 lt_exit=$?
michael@0 7249
michael@0 7250 # Restore the uninstalled library and exit
michael@0 7251 if test "$mode" = relink; then
michael@0 7252 ( cd "$output_objdir" && \
michael@0 7253 $RM "${realname}T" && \
michael@0 7254 $MV "${realname}U" "$realname" )
michael@0 7255 fi
michael@0 7256
michael@0 7257 exit $lt_exit
michael@0 7258 }
michael@0 7259 done
michael@0 7260 IFS="$save_ifs"
michael@0 7261
michael@0 7262 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
michael@0 7263 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
michael@0 7264 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
michael@0 7265 fi
michael@0 7266 fi
michael@0 7267
michael@0 7268 if ${skipped_export-false}; then
michael@0 7269 if test -n "$export_symbols" && test -n "$include_expsyms"; then
michael@0 7270 tmp_export_symbols="$export_symbols"
michael@0 7271 test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
michael@0 7272 $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
michael@0 7273 fi
michael@0 7274
michael@0 7275 if test -n "$orig_export_symbols"; then
michael@0 7276 # The given exports_symbols file has to be filtered, so filter it.
michael@0 7277 func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
michael@0 7278 # FIXME: $output_objdir/$libname.filter potentially contains lots of
michael@0 7279 # 's' commands which not all seds can handle. GNU sed should be fine
michael@0 7280 # though. Also, the filter scales superlinearly with the number of
michael@0 7281 # global variables. join(1) would be nice here, but unfortunately
michael@0 7282 # isn't a blessed tool.
michael@0 7283 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
michael@0 7284 delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
michael@0 7285 export_symbols=$output_objdir/$libname.def
michael@0 7286 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
michael@0 7287 fi
michael@0 7288 fi
michael@0 7289
michael@0 7290 libobjs=$output
michael@0 7291 # Restore the value of output.
michael@0 7292 output=$save_output
michael@0 7293
michael@0 7294 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
michael@0 7295 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
michael@0 7296 test "X$libobjs" = "X " && libobjs=
michael@0 7297 fi
michael@0 7298 # Expand the library linking commands again to reset the
michael@0 7299 # value of $libobjs for piecewise linking.
michael@0 7300
michael@0 7301 # Do each of the archive commands.
michael@0 7302 if test "$module" = yes && test -n "$module_cmds" ; then
michael@0 7303 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
michael@0 7304 cmds=$module_expsym_cmds
michael@0 7305 else
michael@0 7306 cmds=$module_cmds
michael@0 7307 fi
michael@0 7308 else
michael@0 7309 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
michael@0 7310 cmds=$archive_expsym_cmds
michael@0 7311 else
michael@0 7312 cmds=$archive_cmds
michael@0 7313 fi
michael@0 7314 fi
michael@0 7315 fi
michael@0 7316
michael@0 7317 if test -n "$delfiles"; then
michael@0 7318 # Append the command to remove temporary files to $cmds.
michael@0 7319 eval cmds=\"\$cmds~\$RM $delfiles\"
michael@0 7320 fi
michael@0 7321
michael@0 7322 # Add any objects from preloaded convenience libraries
michael@0 7323 if test -n "$dlprefiles"; then
michael@0 7324 gentop="$output_objdir/${outputname}x"
michael@0 7325 generated="$generated $gentop"
michael@0 7326
michael@0 7327 func_extract_archives $gentop $dlprefiles
michael@0 7328 libobjs="$libobjs $func_extract_archives_result"
michael@0 7329 test "X$libobjs" = "X " && libobjs=
michael@0 7330 fi
michael@0 7331
michael@0 7332 save_ifs="$IFS"; IFS='~'
michael@0 7333 for cmd in $cmds; do
michael@0 7334 IFS="$save_ifs"
michael@0 7335 eval cmd=\"$cmd\"
michael@0 7336 $opt_silent || {
michael@0 7337 func_quote_for_expand "$cmd"
michael@0 7338 eval "func_echo $func_quote_for_expand_result"
michael@0 7339 }
michael@0 7340 $opt_dry_run || eval "$cmd" || {
michael@0 7341 lt_exit=$?
michael@0 7342
michael@0 7343 # Restore the uninstalled library and exit
michael@0 7344 if test "$mode" = relink; then
michael@0 7345 ( cd "$output_objdir" && \
michael@0 7346 $RM "${realname}T" && \
michael@0 7347 $MV "${realname}U" "$realname" )
michael@0 7348 fi
michael@0 7349
michael@0 7350 exit $lt_exit
michael@0 7351 }
michael@0 7352 done
michael@0 7353 IFS="$save_ifs"
michael@0 7354
michael@0 7355 # Restore the uninstalled library and exit
michael@0 7356 if test "$mode" = relink; then
michael@0 7357 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
michael@0 7358
michael@0 7359 if test -n "$convenience"; then
michael@0 7360 if test -z "$whole_archive_flag_spec"; then
michael@0 7361 func_show_eval '${RM}r "$gentop"'
michael@0 7362 fi
michael@0 7363 fi
michael@0 7364
michael@0 7365 exit $EXIT_SUCCESS
michael@0 7366 fi
michael@0 7367
michael@0 7368 # Create links to the real library.
michael@0 7369 for linkname in $linknames; do
michael@0 7370 if test "$realname" != "$linkname"; then
michael@0 7371 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
michael@0 7372 fi
michael@0 7373 done
michael@0 7374
michael@0 7375 # If -module or -export-dynamic was specified, set the dlname.
michael@0 7376 if test "$module" = yes || test "$export_dynamic" = yes; then
michael@0 7377 # On all known operating systems, these are identical.
michael@0 7378 dlname="$soname"
michael@0 7379 fi
michael@0 7380 fi
michael@0 7381 ;;
michael@0 7382
michael@0 7383 obj)
michael@0 7384 if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
michael@0 7385 func_warning "\`-dlopen' is ignored for objects"
michael@0 7386 fi
michael@0 7387
michael@0 7388 case " $deplibs" in
michael@0 7389 *\ -l* | *\ -L*)
michael@0 7390 func_warning "\`-l' and \`-L' are ignored for objects" ;;
michael@0 7391 esac
michael@0 7392
michael@0 7393 test -n "$rpath" && \
michael@0 7394 func_warning "\`-rpath' is ignored for objects"
michael@0 7395
michael@0 7396 test -n "$xrpath" && \
michael@0 7397 func_warning "\`-R' is ignored for objects"
michael@0 7398
michael@0 7399 test -n "$vinfo" && \
michael@0 7400 func_warning "\`-version-info' is ignored for objects"
michael@0 7401
michael@0 7402 test -n "$release" && \
michael@0 7403 func_warning "\`-release' is ignored for objects"
michael@0 7404
michael@0 7405 case $output in
michael@0 7406 *.lo)
michael@0 7407 test -n "$objs$old_deplibs" && \
michael@0 7408 func_fatal_error "cannot build library object \`$output' from non-libtool objects"
michael@0 7409
michael@0 7410 libobj=$output
michael@0 7411 func_lo2o "$libobj"
michael@0 7412 obj=$func_lo2o_result
michael@0 7413 ;;
michael@0 7414 *)
michael@0 7415 libobj=
michael@0 7416 obj="$output"
michael@0 7417 ;;
michael@0 7418 esac
michael@0 7419
michael@0 7420 # Delete the old objects.
michael@0 7421 $opt_dry_run || $RM $obj $libobj
michael@0 7422
michael@0 7423 # Objects from convenience libraries. This assumes
michael@0 7424 # single-version convenience libraries. Whenever we create
michael@0 7425 # different ones for PIC/non-PIC, this we'll have to duplicate
michael@0 7426 # the extraction.
michael@0 7427 reload_conv_objs=
michael@0 7428 gentop=
michael@0 7429 # reload_cmds runs $LD directly, so let us get rid of
michael@0 7430 # -Wl from whole_archive_flag_spec and hope we can get by with
michael@0 7431 # turning comma into space..
michael@0 7432 wl=
michael@0 7433
michael@0 7434 if test -n "$convenience"; then
michael@0 7435 if test -n "$whole_archive_flag_spec"; then
michael@0 7436 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
michael@0 7437 reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
michael@0 7438 else
michael@0 7439 gentop="$output_objdir/${obj}x"
michael@0 7440 generated="$generated $gentop"
michael@0 7441
michael@0 7442 func_extract_archives $gentop $convenience
michael@0 7443 reload_conv_objs="$reload_objs $func_extract_archives_result"
michael@0 7444 fi
michael@0 7445 fi
michael@0 7446
michael@0 7447 # Create the old-style object.
michael@0 7448 reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
michael@0 7449
michael@0 7450 output="$obj"
michael@0 7451 func_execute_cmds "$reload_cmds" 'exit $?'
michael@0 7452
michael@0 7453 # Exit if we aren't doing a library object file.
michael@0 7454 if test -z "$libobj"; then
michael@0 7455 if test -n "$gentop"; then
michael@0 7456 func_show_eval '${RM}r "$gentop"'
michael@0 7457 fi
michael@0 7458
michael@0 7459 exit $EXIT_SUCCESS
michael@0 7460 fi
michael@0 7461
michael@0 7462 if test "$build_libtool_libs" != yes; then
michael@0 7463 if test -n "$gentop"; then
michael@0 7464 func_show_eval '${RM}r "$gentop"'
michael@0 7465 fi
michael@0 7466
michael@0 7467 # Create an invalid libtool object if no PIC, so that we don't
michael@0 7468 # accidentally link it into a program.
michael@0 7469 # $show "echo timestamp > $libobj"
michael@0 7470 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
michael@0 7471 exit $EXIT_SUCCESS
michael@0 7472 fi
michael@0 7473
michael@0 7474 if test -n "$pic_flag" || test "$pic_mode" != default; then
michael@0 7475 # Only do commands if we really have different PIC objects.
michael@0 7476 reload_objs="$libobjs $reload_conv_objs"
michael@0 7477 output="$libobj"
michael@0 7478 func_execute_cmds "$reload_cmds" 'exit $?'
michael@0 7479 fi
michael@0 7480
michael@0 7481 if test -n "$gentop"; then
michael@0 7482 func_show_eval '${RM}r "$gentop"'
michael@0 7483 fi
michael@0 7484
michael@0 7485 exit $EXIT_SUCCESS
michael@0 7486 ;;
michael@0 7487
michael@0 7488 prog)
michael@0 7489 case $host in
michael@0 7490 *cygwin*) func_stripname '' '.exe' "$output"
michael@0 7491 output=$func_stripname_result.exe;;
michael@0 7492 esac
michael@0 7493 test -n "$vinfo" && \
michael@0 7494 func_warning "\`-version-info' is ignored for programs"
michael@0 7495
michael@0 7496 test -n "$release" && \
michael@0 7497 func_warning "\`-release' is ignored for programs"
michael@0 7498
michael@0 7499 test "$preload" = yes \
michael@0 7500 && test "$dlopen_support" = unknown \
michael@0 7501 && test "$dlopen_self" = unknown \
michael@0 7502 && test "$dlopen_self_static" = unknown && \
michael@0 7503 func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
michael@0 7504
michael@0 7505 case $host in
michael@0 7506 *-*-rhapsody* | *-*-darwin1.[012])
michael@0 7507 # On Rhapsody replace the C library is the System framework
michael@0 7508 compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
michael@0 7509 finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
michael@0 7510 ;;
michael@0 7511 esac
michael@0 7512
michael@0 7513 case $host in
michael@0 7514 *-*-darwin*)
michael@0 7515 # Don't allow lazy linking, it breaks C++ global constructors
michael@0 7516 # But is supposedly fixed on 10.4 or later (yay!).
michael@0 7517 if test "$tagname" = CXX ; then
michael@0 7518 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
michael@0 7519 10.[0123])
michael@0 7520 compile_command="$compile_command ${wl}-bind_at_load"
michael@0 7521 finalize_command="$finalize_command ${wl}-bind_at_load"
michael@0 7522 ;;
michael@0 7523 esac
michael@0 7524 fi
michael@0 7525 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
michael@0 7526 compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
michael@0 7527 finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
michael@0 7528 ;;
michael@0 7529 esac
michael@0 7530
michael@0 7531
michael@0 7532 # move library search paths that coincide with paths to not yet
michael@0 7533 # installed libraries to the beginning of the library search list
michael@0 7534 new_libs=
michael@0 7535 for path in $notinst_path; do
michael@0 7536 case " $new_libs " in
michael@0 7537 *" -L$path/$objdir "*) ;;
michael@0 7538 *)
michael@0 7539 case " $compile_deplibs " in
michael@0 7540 *" -L$path/$objdir "*)
michael@0 7541 new_libs="$new_libs -L$path/$objdir" ;;
michael@0 7542 esac
michael@0 7543 ;;
michael@0 7544 esac
michael@0 7545 done
michael@0 7546 for deplib in $compile_deplibs; do
michael@0 7547 case $deplib in
michael@0 7548 -L*)
michael@0 7549 case " $new_libs " in
michael@0 7550 *" $deplib "*) ;;
michael@0 7551 *) new_libs="$new_libs $deplib" ;;
michael@0 7552 esac
michael@0 7553 ;;
michael@0 7554 *) new_libs="$new_libs $deplib" ;;
michael@0 7555 esac
michael@0 7556 done
michael@0 7557 compile_deplibs="$new_libs"
michael@0 7558
michael@0 7559
michael@0 7560 compile_command="$compile_command $compile_deplibs"
michael@0 7561 finalize_command="$finalize_command $finalize_deplibs"
michael@0 7562
michael@0 7563 if test -n "$rpath$xrpath"; then
michael@0 7564 # If the user specified any rpath flags, then add them.
michael@0 7565 for libdir in $rpath $xrpath; do
michael@0 7566 # This is the magic to use -rpath.
michael@0 7567 case "$finalize_rpath " in
michael@0 7568 *" $libdir "*) ;;
michael@0 7569 *) finalize_rpath="$finalize_rpath $libdir" ;;
michael@0 7570 esac
michael@0 7571 done
michael@0 7572 fi
michael@0 7573
michael@0 7574 # Now hardcode the library paths
michael@0 7575 rpath=
michael@0 7576 hardcode_libdirs=
michael@0 7577 for libdir in $compile_rpath $finalize_rpath; do
michael@0 7578 if test -n "$hardcode_libdir_flag_spec"; then
michael@0 7579 if test -n "$hardcode_libdir_separator"; then
michael@0 7580 if test -z "$hardcode_libdirs"; then
michael@0 7581 hardcode_libdirs="$libdir"
michael@0 7582 else
michael@0 7583 # Just accumulate the unique libdirs.
michael@0 7584 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
michael@0 7585 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
michael@0 7586 ;;
michael@0 7587 *)
michael@0 7588 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
michael@0 7589 ;;
michael@0 7590 esac
michael@0 7591 fi
michael@0 7592 else
michael@0 7593 eval flag=\"$hardcode_libdir_flag_spec\"
michael@0 7594 rpath="$rpath $flag"
michael@0 7595 fi
michael@0 7596 elif test -n "$runpath_var"; then
michael@0 7597 case "$perm_rpath " in
michael@0 7598 *" $libdir "*) ;;
michael@0 7599 *) perm_rpath="$perm_rpath $libdir" ;;
michael@0 7600 esac
michael@0 7601 fi
michael@0 7602 case $host in
michael@0 7603 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
michael@0 7604 testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
michael@0 7605 case :$dllsearchpath: in
michael@0 7606 *":$libdir:"*) ;;
michael@0 7607 ::) dllsearchpath=$libdir;;
michael@0 7608 *) dllsearchpath="$dllsearchpath:$libdir";;
michael@0 7609 esac
michael@0 7610 case :$dllsearchpath: in
michael@0 7611 *":$testbindir:"*) ;;
michael@0 7612 ::) dllsearchpath=$testbindir;;
michael@0 7613 *) dllsearchpath="$dllsearchpath:$testbindir";;
michael@0 7614 esac
michael@0 7615 ;;
michael@0 7616 esac
michael@0 7617 done
michael@0 7618 # Substitute the hardcoded libdirs into the rpath.
michael@0 7619 if test -n "$hardcode_libdir_separator" &&
michael@0 7620 test -n "$hardcode_libdirs"; then
michael@0 7621 libdir="$hardcode_libdirs"
michael@0 7622 eval rpath=\" $hardcode_libdir_flag_spec\"
michael@0 7623 fi
michael@0 7624 compile_rpath="$rpath"
michael@0 7625
michael@0 7626 rpath=
michael@0 7627 hardcode_libdirs=
michael@0 7628 for libdir in $finalize_rpath; do
michael@0 7629 if test -n "$hardcode_libdir_flag_spec"; then
michael@0 7630 if test -n "$hardcode_libdir_separator"; then
michael@0 7631 if test -z "$hardcode_libdirs"; then
michael@0 7632 hardcode_libdirs="$libdir"
michael@0 7633 else
michael@0 7634 # Just accumulate the unique libdirs.
michael@0 7635 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
michael@0 7636 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
michael@0 7637 ;;
michael@0 7638 *)
michael@0 7639 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
michael@0 7640 ;;
michael@0 7641 esac
michael@0 7642 fi
michael@0 7643 else
michael@0 7644 eval flag=\"$hardcode_libdir_flag_spec\"
michael@0 7645 rpath="$rpath $flag"
michael@0 7646 fi
michael@0 7647 elif test -n "$runpath_var"; then
michael@0 7648 case "$finalize_perm_rpath " in
michael@0 7649 *" $libdir "*) ;;
michael@0 7650 *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
michael@0 7651 esac
michael@0 7652 fi
michael@0 7653 done
michael@0 7654 # Substitute the hardcoded libdirs into the rpath.
michael@0 7655 if test -n "$hardcode_libdir_separator" &&
michael@0 7656 test -n "$hardcode_libdirs"; then
michael@0 7657 libdir="$hardcode_libdirs"
michael@0 7658 eval rpath=\" $hardcode_libdir_flag_spec\"
michael@0 7659 fi
michael@0 7660 finalize_rpath="$rpath"
michael@0 7661
michael@0 7662 if test -n "$libobjs" && test "$build_old_libs" = yes; then
michael@0 7663 # Transform all the library objects into standard objects.
michael@0 7664 compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
michael@0 7665 finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
michael@0 7666 fi
michael@0 7667
michael@0 7668 func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
michael@0 7669
michael@0 7670 # template prelinking step
michael@0 7671 if test -n "$prelink_cmds"; then
michael@0 7672 func_execute_cmds "$prelink_cmds" 'exit $?'
michael@0 7673 fi
michael@0 7674
michael@0 7675 wrappers_required=yes
michael@0 7676 case $host in
michael@0 7677 *cygwin* | *mingw* )
michael@0 7678 if test "$build_libtool_libs" != yes; then
michael@0 7679 wrappers_required=no
michael@0 7680 fi
michael@0 7681 ;;
michael@0 7682 *cegcc)
michael@0 7683 # Disable wrappers for cegcc, we are cross compiling anyway.
michael@0 7684 wrappers_required=no
michael@0 7685 ;;
michael@0 7686 *)
michael@0 7687 if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
michael@0 7688 wrappers_required=no
michael@0 7689 fi
michael@0 7690 ;;
michael@0 7691 esac
michael@0 7692 if test "$wrappers_required" = no; then
michael@0 7693 # Replace the output file specification.
michael@0 7694 compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
michael@0 7695 link_command="$compile_command$compile_rpath"
michael@0 7696
michael@0 7697 # We have no uninstalled library dependencies, so finalize right now.
michael@0 7698 exit_status=0
michael@0 7699 func_show_eval "$link_command" 'exit_status=$?'
michael@0 7700
michael@0 7701 # Delete the generated files.
michael@0 7702 if test -f "$output_objdir/${outputname}S.${objext}"; then
michael@0 7703 func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
michael@0 7704 fi
michael@0 7705
michael@0 7706 exit $exit_status
michael@0 7707 fi
michael@0 7708
michael@0 7709 if test -n "$compile_shlibpath$finalize_shlibpath"; then
michael@0 7710 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
michael@0 7711 fi
michael@0 7712 if test -n "$finalize_shlibpath"; then
michael@0 7713 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
michael@0 7714 fi
michael@0 7715
michael@0 7716 compile_var=
michael@0 7717 finalize_var=
michael@0 7718 if test -n "$runpath_var"; then
michael@0 7719 if test -n "$perm_rpath"; then
michael@0 7720 # We should set the runpath_var.
michael@0 7721 rpath=
michael@0 7722 for dir in $perm_rpath; do
michael@0 7723 rpath="$rpath$dir:"
michael@0 7724 done
michael@0 7725 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
michael@0 7726 fi
michael@0 7727 if test -n "$finalize_perm_rpath"; then
michael@0 7728 # We should set the runpath_var.
michael@0 7729 rpath=
michael@0 7730 for dir in $finalize_perm_rpath; do
michael@0 7731 rpath="$rpath$dir:"
michael@0 7732 done
michael@0 7733 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
michael@0 7734 fi
michael@0 7735 fi
michael@0 7736
michael@0 7737 if test "$no_install" = yes; then
michael@0 7738 # We don't need to create a wrapper script.
michael@0 7739 link_command="$compile_var$compile_command$compile_rpath"
michael@0 7740 # Replace the output file specification.
michael@0 7741 link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
michael@0 7742 # Delete the old output file.
michael@0 7743 $opt_dry_run || $RM $output
michael@0 7744 # Link the executable and exit
michael@0 7745 func_show_eval "$link_command" 'exit $?'
michael@0 7746 exit $EXIT_SUCCESS
michael@0 7747 fi
michael@0 7748
michael@0 7749 if test "$hardcode_action" = relink; then
michael@0 7750 # Fast installation is not supported
michael@0 7751 link_command="$compile_var$compile_command$compile_rpath"
michael@0 7752 relink_command="$finalize_var$finalize_command$finalize_rpath"
michael@0 7753
michael@0 7754 func_warning "this platform does not like uninstalled shared libraries"
michael@0 7755 func_warning "\`$output' will be relinked during installation"
michael@0 7756 else
michael@0 7757 if test "$fast_install" != no; then
michael@0 7758 link_command="$finalize_var$compile_command$finalize_rpath"
michael@0 7759 if test "$fast_install" = yes; then
michael@0 7760 relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
michael@0 7761 else
michael@0 7762 # fast_install is set to needless
michael@0 7763 relink_command=
michael@0 7764 fi
michael@0 7765 else
michael@0 7766 link_command="$compile_var$compile_command$compile_rpath"
michael@0 7767 relink_command="$finalize_var$finalize_command$finalize_rpath"
michael@0 7768 fi
michael@0 7769 fi
michael@0 7770
michael@0 7771 # Replace the output file specification.
michael@0 7772 link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
michael@0 7773
michael@0 7774 # Delete the old output files.
michael@0 7775 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
michael@0 7776
michael@0 7777 func_show_eval "$link_command" 'exit $?'
michael@0 7778
michael@0 7779 # Now create the wrapper script.
michael@0 7780 func_verbose "creating $output"
michael@0 7781
michael@0 7782 # Quote the relink command for shipping.
michael@0 7783 if test -n "$relink_command"; then
michael@0 7784 # Preserve any variables that may affect compiler behavior
michael@0 7785 for var in $variables_saved_for_relink; do
michael@0 7786 if eval test -z \"\${$var+set}\"; then
michael@0 7787 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
michael@0 7788 elif eval var_value=\$$var; test -z "$var_value"; then
michael@0 7789 relink_command="$var=; export $var; $relink_command"
michael@0 7790 else
michael@0 7791 func_quote_for_eval "$var_value"
michael@0 7792 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
michael@0 7793 fi
michael@0 7794 done
michael@0 7795 relink_command="(cd `pwd`; $relink_command)"
michael@0 7796 relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
michael@0 7797 fi
michael@0 7798
michael@0 7799 # Quote $ECHO for shipping.
michael@0 7800 if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
michael@0 7801 case $progpath in
michael@0 7802 [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
michael@0 7803 *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
michael@0 7804 esac
michael@0 7805 qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
michael@0 7806 else
michael@0 7807 qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
michael@0 7808 fi
michael@0 7809
michael@0 7810 # Only actually do things if not in dry run mode.
michael@0 7811 $opt_dry_run || {
michael@0 7812 # win32 will think the script is a binary if it has
michael@0 7813 # a .exe suffix, so we strip it off here.
michael@0 7814 case $output in
michael@0 7815 *.exe) func_stripname '' '.exe' "$output"
michael@0 7816 output=$func_stripname_result ;;
michael@0 7817 esac
michael@0 7818 # test for cygwin because mv fails w/o .exe extensions
michael@0 7819 case $host in
michael@0 7820 *cygwin*)
michael@0 7821 exeext=.exe
michael@0 7822 func_stripname '' '.exe' "$outputname"
michael@0 7823 outputname=$func_stripname_result ;;
michael@0 7824 *) exeext= ;;
michael@0 7825 esac
michael@0 7826 case $host in
michael@0 7827 *cygwin* | *mingw* )
michael@0 7828 func_dirname_and_basename "$output" "" "."
michael@0 7829 output_name=$func_basename_result
michael@0 7830 output_path=$func_dirname_result
michael@0 7831 cwrappersource="$output_path/$objdir/lt-$output_name.c"
michael@0 7832 cwrapper="$output_path/$output_name.exe"
michael@0 7833 $RM $cwrappersource $cwrapper
michael@0 7834 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
michael@0 7835
michael@0 7836 func_emit_cwrapperexe_src > $cwrappersource
michael@0 7837
michael@0 7838 # The wrapper executable is built using the $host compiler,
michael@0 7839 # because it contains $host paths and files. If cross-
michael@0 7840 # compiling, it, like the target executable, must be
michael@0 7841 # executed on the $host or under an emulation environment.
michael@0 7842 $opt_dry_run || {
michael@0 7843 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
michael@0 7844 $STRIP $cwrapper
michael@0 7845 }
michael@0 7846
michael@0 7847 # Now, create the wrapper script for func_source use:
michael@0 7848 func_ltwrapper_scriptname $cwrapper
michael@0 7849 $RM $func_ltwrapper_scriptname_result
michael@0 7850 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
michael@0 7851 $opt_dry_run || {
michael@0 7852 # note: this script will not be executed, so do not chmod.
michael@0 7853 if test "x$build" = "x$host" ; then
michael@0 7854 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
michael@0 7855 else
michael@0 7856 func_emit_wrapper no > $func_ltwrapper_scriptname_result
michael@0 7857 fi
michael@0 7858 }
michael@0 7859 ;;
michael@0 7860 * )
michael@0 7861 $RM $output
michael@0 7862 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
michael@0 7863
michael@0 7864 func_emit_wrapper no > $output
michael@0 7865 chmod +x $output
michael@0 7866 ;;
michael@0 7867 esac
michael@0 7868 }
michael@0 7869 exit $EXIT_SUCCESS
michael@0 7870 ;;
michael@0 7871 esac
michael@0 7872
michael@0 7873 # See if we need to build an old-fashioned archive.
michael@0 7874 for oldlib in $oldlibs; do
michael@0 7875
michael@0 7876 if test "$build_libtool_libs" = convenience; then
michael@0 7877 oldobjs="$libobjs_save $symfileobj"
michael@0 7878 addlibs="$convenience"
michael@0 7879 build_libtool_libs=no
michael@0 7880 else
michael@0 7881 if test "$build_libtool_libs" = module; then
michael@0 7882 oldobjs="$libobjs_save"
michael@0 7883 build_libtool_libs=no
michael@0 7884 else
michael@0 7885 oldobjs="$old_deplibs $non_pic_objects"
michael@0 7886 if test "$preload" = yes && test -f "$symfileobj"; then
michael@0 7887 oldobjs="$oldobjs $symfileobj"
michael@0 7888 fi
michael@0 7889 fi
michael@0 7890 addlibs="$old_convenience"
michael@0 7891 fi
michael@0 7892
michael@0 7893 if test -n "$addlibs"; then
michael@0 7894 gentop="$output_objdir/${outputname}x"
michael@0 7895 generated="$generated $gentop"
michael@0 7896
michael@0 7897 func_extract_archives $gentop $addlibs
michael@0 7898 oldobjs="$oldobjs $func_extract_archives_result"
michael@0 7899 fi
michael@0 7900
michael@0 7901 # Do each command in the archive commands.
michael@0 7902 if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
michael@0 7903 cmds=$old_archive_from_new_cmds
michael@0 7904 else
michael@0 7905
michael@0 7906 # Add any objects from preloaded convenience libraries
michael@0 7907 if test -n "$dlprefiles"; then
michael@0 7908 gentop="$output_objdir/${outputname}x"
michael@0 7909 generated="$generated $gentop"
michael@0 7910
michael@0 7911 func_extract_archives $gentop $dlprefiles
michael@0 7912 oldobjs="$oldobjs $func_extract_archives_result"
michael@0 7913 fi
michael@0 7914
michael@0 7915 # POSIX demands no paths to be encoded in archives. We have
michael@0 7916 # to avoid creating archives with duplicate basenames if we
michael@0 7917 # might have to extract them afterwards, e.g., when creating a
michael@0 7918 # static archive out of a convenience library, or when linking
michael@0 7919 # the entirety of a libtool archive into another (currently
michael@0 7920 # not supported by libtool).
michael@0 7921 if (for obj in $oldobjs
michael@0 7922 do
michael@0 7923 func_basename "$obj"
michael@0 7924 $ECHO "$func_basename_result"
michael@0 7925 done | sort | sort -uc >/dev/null 2>&1); then
michael@0 7926 :
michael@0 7927 else
michael@0 7928 $ECHO "copying selected object files to avoid basename conflicts..."
michael@0 7929 gentop="$output_objdir/${outputname}x"
michael@0 7930 generated="$generated $gentop"
michael@0 7931 func_mkdir_p "$gentop"
michael@0 7932 save_oldobjs=$oldobjs
michael@0 7933 oldobjs=
michael@0 7934 counter=1
michael@0 7935 for obj in $save_oldobjs
michael@0 7936 do
michael@0 7937 func_basename "$obj"
michael@0 7938 objbase="$func_basename_result"
michael@0 7939 case " $oldobjs " in
michael@0 7940 " ") oldobjs=$obj ;;
michael@0 7941 *[\ /]"$objbase "*)
michael@0 7942 while :; do
michael@0 7943 # Make sure we don't pick an alternate name that also
michael@0 7944 # overlaps.
michael@0 7945 newobj=lt$counter-$objbase
michael@0 7946 func_arith $counter + 1
michael@0 7947 counter=$func_arith_result
michael@0 7948 case " $oldobjs " in
michael@0 7949 *[\ /]"$newobj "*) ;;
michael@0 7950 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
michael@0 7951 esac
michael@0 7952 done
michael@0 7953 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
michael@0 7954 oldobjs="$oldobjs $gentop/$newobj"
michael@0 7955 ;;
michael@0 7956 *) oldobjs="$oldobjs $obj" ;;
michael@0 7957 esac
michael@0 7958 done
michael@0 7959 fi
michael@0 7960 eval cmds=\"$old_archive_cmds\"
michael@0 7961
michael@0 7962 func_len " $cmds"
michael@0 7963 len=$func_len_result
michael@0 7964 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
michael@0 7965 cmds=$old_archive_cmds
michael@0 7966 else
michael@0 7967 # the command line is too long to link in one step, link in parts
michael@0 7968 func_verbose "using piecewise archive linking..."
michael@0 7969 save_RANLIB=$RANLIB
michael@0 7970 RANLIB=:
michael@0 7971 objlist=
michael@0 7972 concat_cmds=
michael@0 7973 save_oldobjs=$oldobjs
michael@0 7974 oldobjs=
michael@0 7975 # Is there a better way of finding the last object in the list?
michael@0 7976 for obj in $save_oldobjs
michael@0 7977 do
michael@0 7978 last_oldobj=$obj
michael@0 7979 done
michael@0 7980 eval test_cmds=\"$old_archive_cmds\"
michael@0 7981 func_len " $test_cmds"
michael@0 7982 len0=$func_len_result
michael@0 7983 len=$len0
michael@0 7984 for obj in $save_oldobjs
michael@0 7985 do
michael@0 7986 func_len " $obj"
michael@0 7987 func_arith $len + $func_len_result
michael@0 7988 len=$func_arith_result
michael@0 7989 func_append objlist " $obj"
michael@0 7990 if test "$len" -lt "$max_cmd_len"; then
michael@0 7991 :
michael@0 7992 else
michael@0 7993 # the above command should be used before it gets too long
michael@0 7994 oldobjs=$objlist
michael@0 7995 if test "$obj" = "$last_oldobj" ; then
michael@0 7996 RANLIB=$save_RANLIB
michael@0 7997 fi
michael@0 7998 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
michael@0 7999 eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
michael@0 8000 objlist=
michael@0 8001 len=$len0
michael@0 8002 fi
michael@0 8003 done
michael@0 8004 RANLIB=$save_RANLIB
michael@0 8005 oldobjs=$objlist
michael@0 8006 if test "X$oldobjs" = "X" ; then
michael@0 8007 eval cmds=\"\$concat_cmds\"
michael@0 8008 else
michael@0 8009 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
michael@0 8010 fi
michael@0 8011 fi
michael@0 8012 fi
michael@0 8013 func_execute_cmds "$cmds" 'exit $?'
michael@0 8014 done
michael@0 8015
michael@0 8016 test -n "$generated" && \
michael@0 8017 func_show_eval "${RM}r$generated"
michael@0 8018
michael@0 8019 # Now create the libtool archive.
michael@0 8020 case $output in
michael@0 8021 *.la)
michael@0 8022 old_library=
michael@0 8023 test "$build_old_libs" = yes && old_library="$libname.$libext"
michael@0 8024 func_verbose "creating $output"
michael@0 8025
michael@0 8026 # Preserve any variables that may affect compiler behavior
michael@0 8027 for var in $variables_saved_for_relink; do
michael@0 8028 if eval test -z \"\${$var+set}\"; then
michael@0 8029 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
michael@0 8030 elif eval var_value=\$$var; test -z "$var_value"; then
michael@0 8031 relink_command="$var=; export $var; $relink_command"
michael@0 8032 else
michael@0 8033 func_quote_for_eval "$var_value"
michael@0 8034 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
michael@0 8035 fi
michael@0 8036 done
michael@0 8037 # Quote the link command for shipping.
michael@0 8038 relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
michael@0 8039 relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
michael@0 8040 if test "$hardcode_automatic" = yes ; then
michael@0 8041 relink_command=
michael@0 8042 fi
michael@0 8043
michael@0 8044 # Only create the output if not a dry run.
michael@0 8045 $opt_dry_run || {
michael@0 8046 for installed in no yes; do
michael@0 8047 if test "$installed" = yes; then
michael@0 8048 if test -z "$install_libdir"; then
michael@0 8049 break
michael@0 8050 fi
michael@0 8051 output="$output_objdir/$outputname"i
michael@0 8052 # Replace all uninstalled libtool libraries with the installed ones
michael@0 8053 newdependency_libs=
michael@0 8054 for deplib in $dependency_libs; do
michael@0 8055 case $deplib in
michael@0 8056 *.la)
michael@0 8057 func_basename "$deplib"
michael@0 8058 name="$func_basename_result"
michael@0 8059 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
michael@0 8060 test -z "$libdir" && \
michael@0 8061 func_fatal_error "\`$deplib' is not a valid libtool archive"
michael@0 8062 newdependency_libs="$newdependency_libs $libdir/$name"
michael@0 8063 ;;
michael@0 8064 *) newdependency_libs="$newdependency_libs $deplib" ;;
michael@0 8065 esac
michael@0 8066 done
michael@0 8067 dependency_libs="$newdependency_libs"
michael@0 8068 newdlfiles=
michael@0 8069
michael@0 8070 for lib in $dlfiles; do
michael@0 8071 case $lib in
michael@0 8072 *.la)
michael@0 8073 func_basename "$lib"
michael@0 8074 name="$func_basename_result"
michael@0 8075 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
michael@0 8076 test -z "$libdir" && \
michael@0 8077 func_fatal_error "\`$lib' is not a valid libtool archive"
michael@0 8078 newdlfiles="$newdlfiles $libdir/$name"
michael@0 8079 ;;
michael@0 8080 *) newdlfiles="$newdlfiles $lib" ;;
michael@0 8081 esac
michael@0 8082 done
michael@0 8083 dlfiles="$newdlfiles"
michael@0 8084 newdlprefiles=
michael@0 8085 for lib in $dlprefiles; do
michael@0 8086 case $lib in
michael@0 8087 *.la)
michael@0 8088 # Only pass preopened files to the pseudo-archive (for
michael@0 8089 # eventual linking with the app. that links it) if we
michael@0 8090 # didn't already link the preopened objects directly into
michael@0 8091 # the library:
michael@0 8092 func_basename "$lib"
michael@0 8093 name="$func_basename_result"
michael@0 8094 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
michael@0 8095 test -z "$libdir" && \
michael@0 8096 func_fatal_error "\`$lib' is not a valid libtool archive"
michael@0 8097 newdlprefiles="$newdlprefiles $libdir/$name"
michael@0 8098 ;;
michael@0 8099 esac
michael@0 8100 done
michael@0 8101 dlprefiles="$newdlprefiles"
michael@0 8102 else
michael@0 8103 newdlfiles=
michael@0 8104 for lib in $dlfiles; do
michael@0 8105 case $lib in
michael@0 8106 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
michael@0 8107 *) abs=`pwd`"/$lib" ;;
michael@0 8108 esac
michael@0 8109 newdlfiles="$newdlfiles $abs"
michael@0 8110 done
michael@0 8111 dlfiles="$newdlfiles"
michael@0 8112 newdlprefiles=
michael@0 8113 for lib in $dlprefiles; do
michael@0 8114 case $lib in
michael@0 8115 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
michael@0 8116 *) abs=`pwd`"/$lib" ;;
michael@0 8117 esac
michael@0 8118 newdlprefiles="$newdlprefiles $abs"
michael@0 8119 done
michael@0 8120 dlprefiles="$newdlprefiles"
michael@0 8121 fi
michael@0 8122 $RM $output
michael@0 8123 # place dlname in correct position for cygwin
michael@0 8124 tdlname=$dlname
michael@0 8125 case $host,$output,$installed,$module,$dlname in
michael@0 8126 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
michael@0 8127 esac
michael@0 8128 $ECHO > $output "\
michael@0 8129 # $outputname - a libtool library file
michael@0 8130 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
michael@0 8131 #
michael@0 8132 # Please DO NOT delete this file!
michael@0 8133 # It is necessary for linking the library.
michael@0 8134
michael@0 8135 # The name that we can dlopen(3).
michael@0 8136 dlname='$tdlname'
michael@0 8137
michael@0 8138 # Names of this library.
michael@0 8139 library_names='$library_names'
michael@0 8140
michael@0 8141 # The name of the static archive.
michael@0 8142 old_library='$old_library'
michael@0 8143
michael@0 8144 # Linker flags that can not go in dependency_libs.
michael@0 8145 inherited_linker_flags='$new_inherited_linker_flags'
michael@0 8146
michael@0 8147 # Libraries that this one depends upon.
michael@0 8148 dependency_libs='$dependency_libs'
michael@0 8149
michael@0 8150 # Names of additional weak libraries provided by this library
michael@0 8151 weak_library_names='$weak_libs'
michael@0 8152
michael@0 8153 # Version information for $libname.
michael@0 8154 current=$current
michael@0 8155 age=$age
michael@0 8156 revision=$revision
michael@0 8157
michael@0 8158 # Is this an already installed library?
michael@0 8159 installed=$installed
michael@0 8160
michael@0 8161 # Should we warn about portability when linking against -modules?
michael@0 8162 shouldnotlink=$module
michael@0 8163
michael@0 8164 # Files to dlopen/dlpreopen
michael@0 8165 dlopen='$dlfiles'
michael@0 8166 dlpreopen='$dlprefiles'
michael@0 8167
michael@0 8168 # Directory that this library needs to be installed in:
michael@0 8169 libdir='$install_libdir'"
michael@0 8170 if test "$installed" = no && test "$need_relink" = yes; then
michael@0 8171 $ECHO >> $output "\
michael@0 8172 relink_command=\"$relink_command\""
michael@0 8173 fi
michael@0 8174 done
michael@0 8175 }
michael@0 8176
michael@0 8177 # Do a symbolic link so that the libtool archive can be found in
michael@0 8178 # LD_LIBRARY_PATH before the program is installed.
michael@0 8179 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
michael@0 8180 ;;
michael@0 8181 esac
michael@0 8182 exit $EXIT_SUCCESS
michael@0 8183 }
michael@0 8184
michael@0 8185 { test "$mode" = link || test "$mode" = relink; } &&
michael@0 8186 func_mode_link ${1+"$@"}
michael@0 8187
michael@0 8188
michael@0 8189 # func_mode_uninstall arg...
michael@0 8190 func_mode_uninstall ()
michael@0 8191 {
michael@0 8192 $opt_debug
michael@0 8193 RM="$nonopt"
michael@0 8194 files=
michael@0 8195 rmforce=
michael@0 8196 exit_status=0
michael@0 8197
michael@0 8198 # This variable tells wrapper scripts just to set variables rather
michael@0 8199 # than running their programs.
michael@0 8200 libtool_install_magic="$magic"
michael@0 8201
michael@0 8202 for arg
michael@0 8203 do
michael@0 8204 case $arg in
michael@0 8205 -f) RM="$RM $arg"; rmforce=yes ;;
michael@0 8206 -*) RM="$RM $arg" ;;
michael@0 8207 *) files="$files $arg" ;;
michael@0 8208 esac
michael@0 8209 done
michael@0 8210
michael@0 8211 test -z "$RM" && \
michael@0 8212 func_fatal_help "you must specify an RM program"
michael@0 8213
michael@0 8214 rmdirs=
michael@0 8215
michael@0 8216 origobjdir="$objdir"
michael@0 8217 for file in $files; do
michael@0 8218 func_dirname "$file" "" "."
michael@0 8219 dir="$func_dirname_result"
michael@0 8220 if test "X$dir" = X.; then
michael@0 8221 objdir="$origobjdir"
michael@0 8222 else
michael@0 8223 objdir="$dir/$origobjdir"
michael@0 8224 fi
michael@0 8225 func_basename "$file"
michael@0 8226 name="$func_basename_result"
michael@0 8227 test "$mode" = uninstall && objdir="$dir"
michael@0 8228
michael@0 8229 # Remember objdir for removal later, being careful to avoid duplicates
michael@0 8230 if test "$mode" = clean; then
michael@0 8231 case " $rmdirs " in
michael@0 8232 *" $objdir "*) ;;
michael@0 8233 *) rmdirs="$rmdirs $objdir" ;;
michael@0 8234 esac
michael@0 8235 fi
michael@0 8236
michael@0 8237 # Don't error if the file doesn't exist and rm -f was used.
michael@0 8238 if { test -L "$file"; } >/dev/null 2>&1 ||
michael@0 8239 { test -h "$file"; } >/dev/null 2>&1 ||
michael@0 8240 test -f "$file"; then
michael@0 8241 :
michael@0 8242 elif test -d "$file"; then
michael@0 8243 exit_status=1
michael@0 8244 continue
michael@0 8245 elif test "$rmforce" = yes; then
michael@0 8246 continue
michael@0 8247 fi
michael@0 8248
michael@0 8249 rmfiles="$file"
michael@0 8250
michael@0 8251 case $name in
michael@0 8252 *.la)
michael@0 8253 # Possibly a libtool archive, so verify it.
michael@0 8254 if func_lalib_p "$file"; then
michael@0 8255 func_source $dir/$name
michael@0 8256
michael@0 8257 # Delete the libtool libraries and symlinks.
michael@0 8258 for n in $library_names; do
michael@0 8259 rmfiles="$rmfiles $objdir/$n"
michael@0 8260 done
michael@0 8261 test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
michael@0 8262
michael@0 8263 case "$mode" in
michael@0 8264 clean)
michael@0 8265 case " $library_names " in
michael@0 8266 # " " in the beginning catches empty $dlname
michael@0 8267 *" $dlname "*) ;;
michael@0 8268 *) rmfiles="$rmfiles $objdir/$dlname" ;;
michael@0 8269 esac
michael@0 8270 test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
michael@0 8271 ;;
michael@0 8272 uninstall)
michael@0 8273 if test -n "$library_names"; then
michael@0 8274 # Do each command in the postuninstall commands.
michael@0 8275 func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
michael@0 8276 fi
michael@0 8277
michael@0 8278 if test -n "$old_library"; then
michael@0 8279 # Do each command in the old_postuninstall commands.
michael@0 8280 func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
michael@0 8281 fi
michael@0 8282 # FIXME: should reinstall the best remaining shared library.
michael@0 8283 ;;
michael@0 8284 esac
michael@0 8285 fi
michael@0 8286 ;;
michael@0 8287
michael@0 8288 *.lo)
michael@0 8289 # Possibly a libtool object, so verify it.
michael@0 8290 if func_lalib_p "$file"; then
michael@0 8291
michael@0 8292 # Read the .lo file
michael@0 8293 func_source $dir/$name
michael@0 8294
michael@0 8295 # Add PIC object to the list of files to remove.
michael@0 8296 if test -n "$pic_object" &&
michael@0 8297 test "$pic_object" != none; then
michael@0 8298 rmfiles="$rmfiles $dir/$pic_object"
michael@0 8299 fi
michael@0 8300
michael@0 8301 # Add non-PIC object to the list of files to remove.
michael@0 8302 if test -n "$non_pic_object" &&
michael@0 8303 test "$non_pic_object" != none; then
michael@0 8304 rmfiles="$rmfiles $dir/$non_pic_object"
michael@0 8305 fi
michael@0 8306 fi
michael@0 8307 ;;
michael@0 8308
michael@0 8309 *)
michael@0 8310 if test "$mode" = clean ; then
michael@0 8311 noexename=$name
michael@0 8312 case $file in
michael@0 8313 *.exe)
michael@0 8314 func_stripname '' '.exe' "$file"
michael@0 8315 file=$func_stripname_result
michael@0 8316 func_stripname '' '.exe' "$name"
michael@0 8317 noexename=$func_stripname_result
michael@0 8318 # $file with .exe has already been added to rmfiles,
michael@0 8319 # add $file without .exe
michael@0 8320 rmfiles="$rmfiles $file"
michael@0 8321 ;;
michael@0 8322 esac
michael@0 8323 # Do a test to see if this is a libtool program.
michael@0 8324 if func_ltwrapper_p "$file"; then
michael@0 8325 if func_ltwrapper_executable_p "$file"; then
michael@0 8326 func_ltwrapper_scriptname "$file"
michael@0 8327 relink_command=
michael@0 8328 func_source $func_ltwrapper_scriptname_result
michael@0 8329 rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
michael@0 8330 else
michael@0 8331 relink_command=
michael@0 8332 func_source $dir/$noexename
michael@0 8333 fi
michael@0 8334
michael@0 8335 # note $name still contains .exe if it was in $file originally
michael@0 8336 # as does the version of $file that was added into $rmfiles
michael@0 8337 rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
michael@0 8338 if test "$fast_install" = yes && test -n "$relink_command"; then
michael@0 8339 rmfiles="$rmfiles $objdir/lt-$name"
michael@0 8340 fi
michael@0 8341 if test "X$noexename" != "X$name" ; then
michael@0 8342 rmfiles="$rmfiles $objdir/lt-${noexename}.c"
michael@0 8343 fi
michael@0 8344 fi
michael@0 8345 fi
michael@0 8346 ;;
michael@0 8347 esac
michael@0 8348 func_show_eval "$RM $rmfiles" 'exit_status=1'
michael@0 8349 done
michael@0 8350 objdir="$origobjdir"
michael@0 8351
michael@0 8352 # Try to remove the ${objdir}s in the directories where we deleted files
michael@0 8353 for dir in $rmdirs; do
michael@0 8354 if test -d "$dir"; then
michael@0 8355 func_show_eval "rmdir $dir >/dev/null 2>&1"
michael@0 8356 fi
michael@0 8357 done
michael@0 8358
michael@0 8359 exit $exit_status
michael@0 8360 }
michael@0 8361
michael@0 8362 { test "$mode" = uninstall || test "$mode" = clean; } &&
michael@0 8363 func_mode_uninstall ${1+"$@"}
michael@0 8364
michael@0 8365 test -z "$mode" && {
michael@0 8366 help="$generic_help"
michael@0 8367 func_fatal_help "you must specify a MODE"
michael@0 8368 }
michael@0 8369
michael@0 8370 test -z "$exec_cmd" && \
michael@0 8371 func_fatal_help "invalid operation mode \`$mode'"
michael@0 8372
michael@0 8373 if test -n "$exec_cmd"; then
michael@0 8374 eval exec "$exec_cmd"
michael@0 8375 exit $EXIT_FAILURE
michael@0 8376 fi
michael@0 8377
michael@0 8378 exit $exit_status
michael@0 8379
michael@0 8380
michael@0 8381 # The TAGs below are defined such that we never get into a situation
michael@0 8382 # in which we disable both kinds of libraries. Given conflicting
michael@0 8383 # choices, we go for a static library, that is the most portable,
michael@0 8384 # since we can't tell whether shared libraries were disabled because
michael@0 8385 # the user asked for that or because the platform doesn't support
michael@0 8386 # them. This is particularly important on AIX, because we don't
michael@0 8387 # support having both static and shared libraries enabled at the same
michael@0 8388 # time on that platform, so we default to a shared-only configuration.
michael@0 8389 # If a disable-shared tag is given, we'll fallback to a static-only
michael@0 8390 # configuration. But we'll never go from static-only to shared-only.
michael@0 8391
michael@0 8392 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
michael@0 8393 build_libtool_libs=no
michael@0 8394 build_old_libs=yes
michael@0 8395 # ### END LIBTOOL TAG CONFIG: disable-shared
michael@0 8396
michael@0 8397 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
michael@0 8398 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
michael@0 8399 # ### END LIBTOOL TAG CONFIG: disable-static
michael@0 8400
michael@0 8401 # Local Variables:
michael@0 8402 # mode:shell-script
michael@0 8403 # sh-indentation:2
michael@0 8404 # End:
michael@0 8405 # vi:sw=2
michael@0 8406

mercurial