annotate src/opusfile-0.9/ltmain.sh @ 83:ae30d91d2ffe

Replace these with versions built using an older toolset (so as to avoid ABI compatibilities when linking on Ubuntu 14.04 for packaging purposes)
author Chris Cannam
date Fri, 07 Feb 2020 11:51:13 +0000
parents 7aeed7906520
children
rev   line source
Chris@69 1 #! /bin/sh
Chris@69 2 ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
Chris@69 3 ## by inline-source v2014-01-03.01
Chris@69 4
Chris@69 5 # libtool (GNU libtool) 2.4.6
Chris@69 6 # Provide generalized library-building support services.
Chris@69 7 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
Chris@69 8
Chris@69 9 # Copyright (C) 1996-2015 Free Software Foundation, Inc.
Chris@69 10 # This is free software; see the source for copying conditions. There is NO
Chris@69 11 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chris@69 12
Chris@69 13 # GNU Libtool is free software; you can redistribute it and/or modify
Chris@69 14 # it under the terms of the GNU General Public License as published by
Chris@69 15 # the Free Software Foundation; either version 2 of the License, or
Chris@69 16 # (at your option) any later version.
Chris@69 17 #
Chris@69 18 # As a special exception to the GNU General Public License,
Chris@69 19 # if you distribute this file as part of a program or library that
Chris@69 20 # is built using GNU Libtool, you may include this file under the
Chris@69 21 # same distribution terms that you use for the rest of that program.
Chris@69 22 #
Chris@69 23 # GNU Libtool is distributed in the hope that it will be useful, but
Chris@69 24 # WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@69 25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Chris@69 26 # General Public License for more details.
Chris@69 27 #
Chris@69 28 # You should have received a copy of the GNU General Public License
Chris@69 29 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@69 30
Chris@69 31
Chris@69 32 PROGRAM=libtool
Chris@69 33 PACKAGE=libtool
Chris@69 34 VERSION=2.4.6
Chris@69 35 package_revision=2.4.6
Chris@69 36
Chris@69 37
Chris@69 38 ## ------ ##
Chris@69 39 ## Usage. ##
Chris@69 40 ## ------ ##
Chris@69 41
Chris@69 42 # Run './libtool --help' for help with using this script from the
Chris@69 43 # command line.
Chris@69 44
Chris@69 45
Chris@69 46 ## ------------------------------- ##
Chris@69 47 ## User overridable command paths. ##
Chris@69 48 ## ------------------------------- ##
Chris@69 49
Chris@69 50 # After configure completes, it has a better idea of some of the
Chris@69 51 # shell tools we need than the defaults used by the functions shared
Chris@69 52 # with bootstrap, so set those here where they can still be over-
Chris@69 53 # ridden by the user, but otherwise take precedence.
Chris@69 54
Chris@69 55 : ${AUTOCONF="autoconf"}
Chris@69 56 : ${AUTOMAKE="automake"}
Chris@69 57
Chris@69 58
Chris@69 59 ## -------------------------- ##
Chris@69 60 ## Source external libraries. ##
Chris@69 61 ## -------------------------- ##
Chris@69 62
Chris@69 63 # Much of our low-level functionality needs to be sourced from external
Chris@69 64 # libraries, which are installed to $pkgauxdir.
Chris@69 65
Chris@69 66 # Set a version string for this script.
Chris@69 67 scriptversion=2015-01-20.17; # UTC
Chris@69 68
Chris@69 69 # General shell script boiler plate, and helper functions.
Chris@69 70 # Written by Gary V. Vaughan, 2004
Chris@69 71
Chris@69 72 # Copyright (C) 2004-2015 Free Software Foundation, Inc.
Chris@69 73 # This is free software; see the source for copying conditions. There is NO
Chris@69 74 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chris@69 75
Chris@69 76 # This program is free software; you can redistribute it and/or modify
Chris@69 77 # it under the terms of the GNU General Public License as published by
Chris@69 78 # the Free Software Foundation; either version 3 of the License, or
Chris@69 79 # (at your option) any later version.
Chris@69 80
Chris@69 81 # As a special exception to the GNU General Public License, if you distribute
Chris@69 82 # this file as part of a program or library that is built using GNU Libtool,
Chris@69 83 # you may include this file under the same distribution terms that you use
Chris@69 84 # for the rest of that program.
Chris@69 85
Chris@69 86 # This program is distributed in the hope that it will be useful,
Chris@69 87 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@69 88 # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
Chris@69 89 # General Public License for more details.
Chris@69 90
Chris@69 91 # You should have received a copy of the GNU General Public License
Chris@69 92 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@69 93
Chris@69 94 # Please report bugs or propose patches to gary@gnu.org.
Chris@69 95
Chris@69 96
Chris@69 97 ## ------ ##
Chris@69 98 ## Usage. ##
Chris@69 99 ## ------ ##
Chris@69 100
Chris@69 101 # Evaluate this file near the top of your script to gain access to
Chris@69 102 # the functions and variables defined here:
Chris@69 103 #
Chris@69 104 # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
Chris@69 105 #
Chris@69 106 # If you need to override any of the default environment variable
Chris@69 107 # settings, do that before evaluating this file.
Chris@69 108
Chris@69 109
Chris@69 110 ## -------------------- ##
Chris@69 111 ## Shell normalisation. ##
Chris@69 112 ## -------------------- ##
Chris@69 113
Chris@69 114 # Some shells need a little help to be as Bourne compatible as possible.
Chris@69 115 # Before doing anything else, make sure all that help has been provided!
Chris@69 116
Chris@69 117 DUALCASE=1; export DUALCASE # for MKS sh
Chris@69 118 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
Chris@69 119 emulate sh
Chris@69 120 NULLCMD=:
Chris@69 121 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
Chris@69 122 # is contrary to our usage. Disable this feature.
Chris@69 123 alias -g '${1+"$@"}'='"$@"'
Chris@69 124 setopt NO_GLOB_SUBST
Chris@69 125 else
Chris@69 126 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
Chris@69 127 fi
Chris@69 128
Chris@69 129 # NLS nuisances: We save the old values in case they are required later.
Chris@69 130 _G_user_locale=
Chris@69 131 _G_safe_locale=
Chris@69 132 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
Chris@69 133 do
Chris@69 134 eval "if test set = \"\${$_G_var+set}\"; then
Chris@69 135 save_$_G_var=\$$_G_var
Chris@69 136 $_G_var=C
Chris@69 137 export $_G_var
Chris@69 138 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
Chris@69 139 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
Chris@69 140 fi"
Chris@69 141 done
Chris@69 142
Chris@69 143 # CDPATH.
Chris@69 144 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
Chris@69 145
Chris@69 146 # Make sure IFS has a sensible default
Chris@69 147 sp=' '
Chris@69 148 nl='
Chris@69 149 '
Chris@69 150 IFS="$sp $nl"
Chris@69 151
Chris@69 152 # There are apparently some retarded systems that use ';' as a PATH separator!
Chris@69 153 if test "${PATH_SEPARATOR+set}" != set; then
Chris@69 154 PATH_SEPARATOR=:
Chris@69 155 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
Chris@69 156 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
Chris@69 157 PATH_SEPARATOR=';'
Chris@69 158 }
Chris@69 159 fi
Chris@69 160
Chris@69 161
Chris@69 162
Chris@69 163 ## ------------------------- ##
Chris@69 164 ## Locate command utilities. ##
Chris@69 165 ## ------------------------- ##
Chris@69 166
Chris@69 167
Chris@69 168 # func_executable_p FILE
Chris@69 169 # ----------------------
Chris@69 170 # Check that FILE is an executable regular file.
Chris@69 171 func_executable_p ()
Chris@69 172 {
Chris@69 173 test -f "$1" && test -x "$1"
Chris@69 174 }
Chris@69 175
Chris@69 176
Chris@69 177 # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
Chris@69 178 # --------------------------------------------
Chris@69 179 # Search for either a program that responds to --version with output
Chris@69 180 # containing "GNU", or else returned by CHECK_FUNC otherwise, by
Chris@69 181 # trying all the directories in PATH with each of the elements of
Chris@69 182 # PROGS_LIST.
Chris@69 183 #
Chris@69 184 # CHECK_FUNC should accept the path to a candidate program, and
Chris@69 185 # set $func_check_prog_result if it truncates its output less than
Chris@69 186 # $_G_path_prog_max characters.
Chris@69 187 func_path_progs ()
Chris@69 188 {
Chris@69 189 _G_progs_list=$1
Chris@69 190 _G_check_func=$2
Chris@69 191 _G_PATH=${3-"$PATH"}
Chris@69 192
Chris@69 193 _G_path_prog_max=0
Chris@69 194 _G_path_prog_found=false
Chris@69 195 _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
Chris@69 196 for _G_dir in $_G_PATH; do
Chris@69 197 IFS=$_G_save_IFS
Chris@69 198 test -z "$_G_dir" && _G_dir=.
Chris@69 199 for _G_prog_name in $_G_progs_list; do
Chris@69 200 for _exeext in '' .EXE; do
Chris@69 201 _G_path_prog=$_G_dir/$_G_prog_name$_exeext
Chris@69 202 func_executable_p "$_G_path_prog" || continue
Chris@69 203 case `"$_G_path_prog" --version 2>&1` in
Chris@69 204 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
Chris@69 205 *) $_G_check_func $_G_path_prog
Chris@69 206 func_path_progs_result=$func_check_prog_result
Chris@69 207 ;;
Chris@69 208 esac
Chris@69 209 $_G_path_prog_found && break 3
Chris@69 210 done
Chris@69 211 done
Chris@69 212 done
Chris@69 213 IFS=$_G_save_IFS
Chris@69 214 test -z "$func_path_progs_result" && {
Chris@69 215 echo "no acceptable sed could be found in \$PATH" >&2
Chris@69 216 exit 1
Chris@69 217 }
Chris@69 218 }
Chris@69 219
Chris@69 220
Chris@69 221 # We want to be able to use the functions in this file before configure
Chris@69 222 # has figured out where the best binaries are kept, which means we have
Chris@69 223 # to search for them ourselves - except when the results are already set
Chris@69 224 # where we skip the searches.
Chris@69 225
Chris@69 226 # Unless the user overrides by setting SED, search the path for either GNU
Chris@69 227 # sed, or the sed that truncates its output the least.
Chris@69 228 test -z "$SED" && {
Chris@69 229 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
Chris@69 230 for _G_i in 1 2 3 4 5 6 7; do
Chris@69 231 _G_sed_script=$_G_sed_script$nl$_G_sed_script
Chris@69 232 done
Chris@69 233 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
Chris@69 234 _G_sed_script=
Chris@69 235
Chris@69 236 func_check_prog_sed ()
Chris@69 237 {
Chris@69 238 _G_path_prog=$1
Chris@69 239
Chris@69 240 _G_count=0
Chris@69 241 printf 0123456789 >conftest.in
Chris@69 242 while :
Chris@69 243 do
Chris@69 244 cat conftest.in conftest.in >conftest.tmp
Chris@69 245 mv conftest.tmp conftest.in
Chris@69 246 cp conftest.in conftest.nl
Chris@69 247 echo '' >> conftest.nl
Chris@69 248 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
Chris@69 249 diff conftest.out conftest.nl >/dev/null 2>&1 || break
Chris@69 250 _G_count=`expr $_G_count + 1`
Chris@69 251 if test "$_G_count" -gt "$_G_path_prog_max"; then
Chris@69 252 # Best one so far, save it but keep looking for a better one
Chris@69 253 func_check_prog_result=$_G_path_prog
Chris@69 254 _G_path_prog_max=$_G_count
Chris@69 255 fi
Chris@69 256 # 10*(2^10) chars as input seems more than enough
Chris@69 257 test 10 -lt "$_G_count" && break
Chris@69 258 done
Chris@69 259 rm -f conftest.in conftest.tmp conftest.nl conftest.out
Chris@69 260 }
Chris@69 261
Chris@69 262 func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
Chris@69 263 rm -f conftest.sed
Chris@69 264 SED=$func_path_progs_result
Chris@69 265 }
Chris@69 266
Chris@69 267
Chris@69 268 # Unless the user overrides by setting GREP, search the path for either GNU
Chris@69 269 # grep, or the grep that truncates its output the least.
Chris@69 270 test -z "$GREP" && {
Chris@69 271 func_check_prog_grep ()
Chris@69 272 {
Chris@69 273 _G_path_prog=$1
Chris@69 274
Chris@69 275 _G_count=0
Chris@69 276 _G_path_prog_max=0
Chris@69 277 printf 0123456789 >conftest.in
Chris@69 278 while :
Chris@69 279 do
Chris@69 280 cat conftest.in conftest.in >conftest.tmp
Chris@69 281 mv conftest.tmp conftest.in
Chris@69 282 cp conftest.in conftest.nl
Chris@69 283 echo 'GREP' >> conftest.nl
Chris@69 284 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
Chris@69 285 diff conftest.out conftest.nl >/dev/null 2>&1 || break
Chris@69 286 _G_count=`expr $_G_count + 1`
Chris@69 287 if test "$_G_count" -gt "$_G_path_prog_max"; then
Chris@69 288 # Best one so far, save it but keep looking for a better one
Chris@69 289 func_check_prog_result=$_G_path_prog
Chris@69 290 _G_path_prog_max=$_G_count
Chris@69 291 fi
Chris@69 292 # 10*(2^10) chars as input seems more than enough
Chris@69 293 test 10 -lt "$_G_count" && break
Chris@69 294 done
Chris@69 295 rm -f conftest.in conftest.tmp conftest.nl conftest.out
Chris@69 296 }
Chris@69 297
Chris@69 298 func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
Chris@69 299 GREP=$func_path_progs_result
Chris@69 300 }
Chris@69 301
Chris@69 302
Chris@69 303 ## ------------------------------- ##
Chris@69 304 ## User overridable command paths. ##
Chris@69 305 ## ------------------------------- ##
Chris@69 306
Chris@69 307 # All uppercase variable names are used for environment variables. These
Chris@69 308 # variables can be overridden by the user before calling a script that
Chris@69 309 # uses them if a suitable command of that name is not already available
Chris@69 310 # in the command search PATH.
Chris@69 311
Chris@69 312 : ${CP="cp -f"}
Chris@69 313 : ${ECHO="printf %s\n"}
Chris@69 314 : ${EGREP="$GREP -E"}
Chris@69 315 : ${FGREP="$GREP -F"}
Chris@69 316 : ${LN_S="ln -s"}
Chris@69 317 : ${MAKE="make"}
Chris@69 318 : ${MKDIR="mkdir"}
Chris@69 319 : ${MV="mv -f"}
Chris@69 320 : ${RM="rm -f"}
Chris@69 321 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
Chris@69 322
Chris@69 323
Chris@69 324 ## -------------------- ##
Chris@69 325 ## Useful sed snippets. ##
Chris@69 326 ## -------------------- ##
Chris@69 327
Chris@69 328 sed_dirname='s|/[^/]*$||'
Chris@69 329 sed_basename='s|^.*/||'
Chris@69 330
Chris@69 331 # Sed substitution that helps us do robust quoting. It backslashifies
Chris@69 332 # metacharacters that are still active within double-quoted strings.
Chris@69 333 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
Chris@69 334
Chris@69 335 # Same as above, but do not quote variable references.
Chris@69 336 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
Chris@69 337
Chris@69 338 # Sed substitution that turns a string into a regex matching for the
Chris@69 339 # string literally.
Chris@69 340 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
Chris@69 341
Chris@69 342 # Sed substitution that converts a w32 file name or path
Chris@69 343 # that contains forward slashes, into one that contains
Chris@69 344 # (escaped) backslashes. A very naive implementation.
Chris@69 345 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
Chris@69 346
Chris@69 347 # Re-'\' parameter expansions in output of sed_double_quote_subst that
Chris@69 348 # were '\'-ed in input to the same. If an odd number of '\' preceded a
Chris@69 349 # '$' in input to sed_double_quote_subst, that '$' was protected from
Chris@69 350 # expansion. Since each input '\' is now two '\'s, look for any number
Chris@69 351 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
Chris@69 352 _G_bs='\\'
Chris@69 353 _G_bs2='\\\\'
Chris@69 354 _G_bs4='\\\\\\\\'
Chris@69 355 _G_dollar='\$'
Chris@69 356 sed_double_backslash="\
Chris@69 357 s/$_G_bs4/&\\
Chris@69 358 /g
Chris@69 359 s/^$_G_bs2$_G_dollar/$_G_bs&/
Chris@69 360 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
Chris@69 361 s/\n//g"
Chris@69 362
Chris@69 363
Chris@69 364 ## ----------------- ##
Chris@69 365 ## Global variables. ##
Chris@69 366 ## ----------------- ##
Chris@69 367
Chris@69 368 # Except for the global variables explicitly listed below, the following
Chris@69 369 # functions in the '^func_' namespace, and the '^require_' namespace
Chris@69 370 # variables initialised in the 'Resource management' section, sourcing
Chris@69 371 # this file will not pollute your global namespace with anything
Chris@69 372 # else. There's no portable way to scope variables in Bourne shell
Chris@69 373 # though, so actually running these functions will sometimes place
Chris@69 374 # results into a variable named after the function, and often use
Chris@69 375 # temporary variables in the '^_G_' namespace. If you are careful to
Chris@69 376 # avoid using those namespaces casually in your sourcing script, things
Chris@69 377 # should continue to work as you expect. And, of course, you can freely
Chris@69 378 # overwrite any of the functions or variables defined here before
Chris@69 379 # calling anything to customize them.
Chris@69 380
Chris@69 381 EXIT_SUCCESS=0
Chris@69 382 EXIT_FAILURE=1
Chris@69 383 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
Chris@69 384 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
Chris@69 385
Chris@69 386 # Allow overriding, eg assuming that you follow the convention of
Chris@69 387 # putting '$debug_cmd' at the start of all your functions, you can get
Chris@69 388 # bash to show function call trace with:
Chris@69 389 #
Chris@69 390 # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
Chris@69 391 debug_cmd=${debug_cmd-":"}
Chris@69 392 exit_cmd=:
Chris@69 393
Chris@69 394 # By convention, finish your script with:
Chris@69 395 #
Chris@69 396 # exit $exit_status
Chris@69 397 #
Chris@69 398 # so that you can set exit_status to non-zero if you want to indicate
Chris@69 399 # something went wrong during execution without actually bailing out at
Chris@69 400 # the point of failure.
Chris@69 401 exit_status=$EXIT_SUCCESS
Chris@69 402
Chris@69 403 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
Chris@69 404 # is ksh but when the shell is invoked as "sh" and the current value of
Chris@69 405 # the _XPG environment variable is not equal to 1 (one), the special
Chris@69 406 # positional parameter $0, within a function call, is the name of the
Chris@69 407 # function.
Chris@69 408 progpath=$0
Chris@69 409
Chris@69 410 # The name of this program.
Chris@69 411 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
Chris@69 412
Chris@69 413 # Make sure we have an absolute progpath for reexecution:
Chris@69 414 case $progpath in
Chris@69 415 [\\/]*|[A-Za-z]:\\*) ;;
Chris@69 416 *[\\/]*)
Chris@69 417 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
Chris@69 418 progdir=`cd "$progdir" && pwd`
Chris@69 419 progpath=$progdir/$progname
Chris@69 420 ;;
Chris@69 421 *)
Chris@69 422 _G_IFS=$IFS
Chris@69 423 IFS=${PATH_SEPARATOR-:}
Chris@69 424 for progdir in $PATH; do
Chris@69 425 IFS=$_G_IFS
Chris@69 426 test -x "$progdir/$progname" && break
Chris@69 427 done
Chris@69 428 IFS=$_G_IFS
Chris@69 429 test -n "$progdir" || progdir=`pwd`
Chris@69 430 progpath=$progdir/$progname
Chris@69 431 ;;
Chris@69 432 esac
Chris@69 433
Chris@69 434
Chris@69 435 ## ----------------- ##
Chris@69 436 ## Standard options. ##
Chris@69 437 ## ----------------- ##
Chris@69 438
Chris@69 439 # The following options affect the operation of the functions defined
Chris@69 440 # below, and should be set appropriately depending on run-time para-
Chris@69 441 # meters passed on the command line.
Chris@69 442
Chris@69 443 opt_dry_run=false
Chris@69 444 opt_quiet=false
Chris@69 445 opt_verbose=false
Chris@69 446
Chris@69 447 # Categories 'all' and 'none' are always available. Append any others
Chris@69 448 # you will pass as the first argument to func_warning from your own
Chris@69 449 # code.
Chris@69 450 warning_categories=
Chris@69 451
Chris@69 452 # By default, display warnings according to 'opt_warning_types'. Set
Chris@69 453 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
Chris@69 454 # treat the next displayed warning as a fatal error.
Chris@69 455 warning_func=func_warn_and_continue
Chris@69 456
Chris@69 457 # Set to 'all' to display all warnings, 'none' to suppress all
Chris@69 458 # warnings, or a space delimited list of some subset of
Chris@69 459 # 'warning_categories' to display only the listed warnings.
Chris@69 460 opt_warning_types=all
Chris@69 461
Chris@69 462
Chris@69 463 ## -------------------- ##
Chris@69 464 ## Resource management. ##
Chris@69 465 ## -------------------- ##
Chris@69 466
Chris@69 467 # This section contains definitions for functions that each ensure a
Chris@69 468 # particular resource (a file, or a non-empty configuration variable for
Chris@69 469 # example) is available, and if appropriate to extract default values
Chris@69 470 # from pertinent package files. Call them using their associated
Chris@69 471 # 'require_*' variable to ensure that they are executed, at most, once.
Chris@69 472 #
Chris@69 473 # It's entirely deliberate that calling these functions can set
Chris@69 474 # variables that don't obey the namespace limitations obeyed by the rest
Chris@69 475 # of this file, in order that that they be as useful as possible to
Chris@69 476 # callers.
Chris@69 477
Chris@69 478
Chris@69 479 # require_term_colors
Chris@69 480 # -------------------
Chris@69 481 # Allow display of bold text on terminals that support it.
Chris@69 482 require_term_colors=func_require_term_colors
Chris@69 483 func_require_term_colors ()
Chris@69 484 {
Chris@69 485 $debug_cmd
Chris@69 486
Chris@69 487 test -t 1 && {
Chris@69 488 # COLORTERM and USE_ANSI_COLORS environment variables take
Chris@69 489 # precedence, because most terminfo databases neglect to describe
Chris@69 490 # whether color sequences are supported.
Chris@69 491 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
Chris@69 492
Chris@69 493 if test 1 = "$USE_ANSI_COLORS"; then
Chris@69 494 # Standard ANSI escape sequences
Chris@69 495 tc_reset=''
Chris@69 496 tc_bold=''; tc_standout=''
Chris@69 497 tc_red=''; tc_green=''
Chris@69 498 tc_blue=''; tc_cyan=''
Chris@69 499 else
Chris@69 500 # Otherwise trust the terminfo database after all.
Chris@69 501 test -n "`tput sgr0 2>/dev/null`" && {
Chris@69 502 tc_reset=`tput sgr0`
Chris@69 503 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
Chris@69 504 tc_standout=$tc_bold
Chris@69 505 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
Chris@69 506 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
Chris@69 507 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
Chris@69 508 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
Chris@69 509 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
Chris@69 510 }
Chris@69 511 fi
Chris@69 512 }
Chris@69 513
Chris@69 514 require_term_colors=:
Chris@69 515 }
Chris@69 516
Chris@69 517
Chris@69 518 ## ----------------- ##
Chris@69 519 ## Function library. ##
Chris@69 520 ## ----------------- ##
Chris@69 521
Chris@69 522 # This section contains a variety of useful functions to call in your
Chris@69 523 # scripts. Take note of the portable wrappers for features provided by
Chris@69 524 # some modern shells, which will fall back to slower equivalents on
Chris@69 525 # less featureful shells.
Chris@69 526
Chris@69 527
Chris@69 528 # func_append VAR VALUE
Chris@69 529 # ---------------------
Chris@69 530 # Append VALUE onto the existing contents of VAR.
Chris@69 531
Chris@69 532 # We should try to minimise forks, especially on Windows where they are
Chris@69 533 # unreasonably slow, so skip the feature probes when bash or zsh are
Chris@69 534 # being used:
Chris@69 535 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
Chris@69 536 : ${_G_HAVE_ARITH_OP="yes"}
Chris@69 537 : ${_G_HAVE_XSI_OPS="yes"}
Chris@69 538 # The += operator was introduced in bash 3.1
Chris@69 539 case $BASH_VERSION in
Chris@69 540 [12].* | 3.0 | 3.0*) ;;
Chris@69 541 *)
Chris@69 542 : ${_G_HAVE_PLUSEQ_OP="yes"}
Chris@69 543 ;;
Chris@69 544 esac
Chris@69 545 fi
Chris@69 546
Chris@69 547 # _G_HAVE_PLUSEQ_OP
Chris@69 548 # Can be empty, in which case the shell is probed, "yes" if += is
Chris@69 549 # useable or anything else if it does not work.
Chris@69 550 test -z "$_G_HAVE_PLUSEQ_OP" \
Chris@69 551 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
Chris@69 552 && _G_HAVE_PLUSEQ_OP=yes
Chris@69 553
Chris@69 554 if test yes = "$_G_HAVE_PLUSEQ_OP"
Chris@69 555 then
Chris@69 556 # This is an XSI compatible shell, allowing a faster implementation...
Chris@69 557 eval 'func_append ()
Chris@69 558 {
Chris@69 559 $debug_cmd
Chris@69 560
Chris@69 561 eval "$1+=\$2"
Chris@69 562 }'
Chris@69 563 else
Chris@69 564 # ...otherwise fall back to using expr, which is often a shell builtin.
Chris@69 565 func_append ()
Chris@69 566 {
Chris@69 567 $debug_cmd
Chris@69 568
Chris@69 569 eval "$1=\$$1\$2"
Chris@69 570 }
Chris@69 571 fi
Chris@69 572
Chris@69 573
Chris@69 574 # func_append_quoted VAR VALUE
Chris@69 575 # ----------------------------
Chris@69 576 # Quote VALUE and append to the end of shell variable VAR, separated
Chris@69 577 # by a space.
Chris@69 578 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
Chris@69 579 eval 'func_append_quoted ()
Chris@69 580 {
Chris@69 581 $debug_cmd
Chris@69 582
Chris@69 583 func_quote_for_eval "$2"
Chris@69 584 eval "$1+=\\ \$func_quote_for_eval_result"
Chris@69 585 }'
Chris@69 586 else
Chris@69 587 func_append_quoted ()
Chris@69 588 {
Chris@69 589 $debug_cmd
Chris@69 590
Chris@69 591 func_quote_for_eval "$2"
Chris@69 592 eval "$1=\$$1\\ \$func_quote_for_eval_result"
Chris@69 593 }
Chris@69 594 fi
Chris@69 595
Chris@69 596
Chris@69 597 # func_append_uniq VAR VALUE
Chris@69 598 # --------------------------
Chris@69 599 # Append unique VALUE onto the existing contents of VAR, assuming
Chris@69 600 # entries are delimited by the first character of VALUE. For example:
Chris@69 601 #
Chris@69 602 # func_append_uniq options " --another-option option-argument"
Chris@69 603 #
Chris@69 604 # will only append to $options if " --another-option option-argument "
Chris@69 605 # is not already present somewhere in $options already (note spaces at
Chris@69 606 # each end implied by leading space in second argument).
Chris@69 607 func_append_uniq ()
Chris@69 608 {
Chris@69 609 $debug_cmd
Chris@69 610
Chris@69 611 eval _G_current_value='`$ECHO $'$1'`'
Chris@69 612 _G_delim=`expr "$2" : '\(.\)'`
Chris@69 613
Chris@69 614 case $_G_delim$_G_current_value$_G_delim in
Chris@69 615 *"$2$_G_delim"*) ;;
Chris@69 616 *) func_append "$@" ;;
Chris@69 617 esac
Chris@69 618 }
Chris@69 619
Chris@69 620
Chris@69 621 # func_arith TERM...
Chris@69 622 # ------------------
Chris@69 623 # Set func_arith_result to the result of evaluating TERMs.
Chris@69 624 test -z "$_G_HAVE_ARITH_OP" \
Chris@69 625 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
Chris@69 626 && _G_HAVE_ARITH_OP=yes
Chris@69 627
Chris@69 628 if test yes = "$_G_HAVE_ARITH_OP"; then
Chris@69 629 eval 'func_arith ()
Chris@69 630 {
Chris@69 631 $debug_cmd
Chris@69 632
Chris@69 633 func_arith_result=$(( $* ))
Chris@69 634 }'
Chris@69 635 else
Chris@69 636 func_arith ()
Chris@69 637 {
Chris@69 638 $debug_cmd
Chris@69 639
Chris@69 640 func_arith_result=`expr "$@"`
Chris@69 641 }
Chris@69 642 fi
Chris@69 643
Chris@69 644
Chris@69 645 # func_basename FILE
Chris@69 646 # ------------------
Chris@69 647 # Set func_basename_result to FILE with everything up to and including
Chris@69 648 # the last / stripped.
Chris@69 649 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@69 650 # If this shell supports suffix pattern removal, then use it to avoid
Chris@69 651 # forking. Hide the definitions single quotes in case the shell chokes
Chris@69 652 # on unsupported syntax...
Chris@69 653 _b='func_basename_result=${1##*/}'
Chris@69 654 _d='case $1 in
Chris@69 655 */*) func_dirname_result=${1%/*}$2 ;;
Chris@69 656 * ) func_dirname_result=$3 ;;
Chris@69 657 esac'
Chris@69 658
Chris@69 659 else
Chris@69 660 # ...otherwise fall back to using sed.
Chris@69 661 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
Chris@69 662 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
Chris@69 663 if test "X$func_dirname_result" = "X$1"; then
Chris@69 664 func_dirname_result=$3
Chris@69 665 else
Chris@69 666 func_append func_dirname_result "$2"
Chris@69 667 fi'
Chris@69 668 fi
Chris@69 669
Chris@69 670 eval 'func_basename ()
Chris@69 671 {
Chris@69 672 $debug_cmd
Chris@69 673
Chris@69 674 '"$_b"'
Chris@69 675 }'
Chris@69 676
Chris@69 677
Chris@69 678 # func_dirname FILE APPEND NONDIR_REPLACEMENT
Chris@69 679 # -------------------------------------------
Chris@69 680 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
Chris@69 681 # otherwise set result to NONDIR_REPLACEMENT.
Chris@69 682 eval 'func_dirname ()
Chris@69 683 {
Chris@69 684 $debug_cmd
Chris@69 685
Chris@69 686 '"$_d"'
Chris@69 687 }'
Chris@69 688
Chris@69 689
Chris@69 690 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
Chris@69 691 # --------------------------------------------------------
Chris@69 692 # Perform func_basename and func_dirname in a single function
Chris@69 693 # call:
Chris@69 694 # dirname: Compute the dirname of FILE. If nonempty,
Chris@69 695 # add APPEND to the result, otherwise set result
Chris@69 696 # to NONDIR_REPLACEMENT.
Chris@69 697 # value returned in "$func_dirname_result"
Chris@69 698 # basename: Compute filename of FILE.
Chris@69 699 # value retuned in "$func_basename_result"
Chris@69 700 # For efficiency, we do not delegate to the functions above but instead
Chris@69 701 # duplicate the functionality here.
Chris@69 702 eval 'func_dirname_and_basename ()
Chris@69 703 {
Chris@69 704 $debug_cmd
Chris@69 705
Chris@69 706 '"$_b"'
Chris@69 707 '"$_d"'
Chris@69 708 }'
Chris@69 709
Chris@69 710
Chris@69 711 # func_echo ARG...
Chris@69 712 # ----------------
Chris@69 713 # Echo program name prefixed message.
Chris@69 714 func_echo ()
Chris@69 715 {
Chris@69 716 $debug_cmd
Chris@69 717
Chris@69 718 _G_message=$*
Chris@69 719
Chris@69 720 func_echo_IFS=$IFS
Chris@69 721 IFS=$nl
Chris@69 722 for _G_line in $_G_message; do
Chris@69 723 IFS=$func_echo_IFS
Chris@69 724 $ECHO "$progname: $_G_line"
Chris@69 725 done
Chris@69 726 IFS=$func_echo_IFS
Chris@69 727 }
Chris@69 728
Chris@69 729
Chris@69 730 # func_echo_all ARG...
Chris@69 731 # --------------------
Chris@69 732 # Invoke $ECHO with all args, space-separated.
Chris@69 733 func_echo_all ()
Chris@69 734 {
Chris@69 735 $ECHO "$*"
Chris@69 736 }
Chris@69 737
Chris@69 738
Chris@69 739 # func_echo_infix_1 INFIX ARG...
Chris@69 740 # ------------------------------
Chris@69 741 # Echo program name, followed by INFIX on the first line, with any
Chris@69 742 # additional lines not showing INFIX.
Chris@69 743 func_echo_infix_1 ()
Chris@69 744 {
Chris@69 745 $debug_cmd
Chris@69 746
Chris@69 747 $require_term_colors
Chris@69 748
Chris@69 749 _G_infix=$1; shift
Chris@69 750 _G_indent=$_G_infix
Chris@69 751 _G_prefix="$progname: $_G_infix: "
Chris@69 752 _G_message=$*
Chris@69 753
Chris@69 754 # Strip color escape sequences before counting printable length
Chris@69 755 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
Chris@69 756 do
Chris@69 757 test -n "$_G_tc" && {
Chris@69 758 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
Chris@69 759 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
Chris@69 760 }
Chris@69 761 done
Chris@69 762 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
Chris@69 763
Chris@69 764 func_echo_infix_1_IFS=$IFS
Chris@69 765 IFS=$nl
Chris@69 766 for _G_line in $_G_message; do
Chris@69 767 IFS=$func_echo_infix_1_IFS
Chris@69 768 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
Chris@69 769 _G_prefix=$_G_indent
Chris@69 770 done
Chris@69 771 IFS=$func_echo_infix_1_IFS
Chris@69 772 }
Chris@69 773
Chris@69 774
Chris@69 775 # func_error ARG...
Chris@69 776 # -----------------
Chris@69 777 # Echo program name prefixed message to standard error.
Chris@69 778 func_error ()
Chris@69 779 {
Chris@69 780 $debug_cmd
Chris@69 781
Chris@69 782 $require_term_colors
Chris@69 783
Chris@69 784 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
Chris@69 785 }
Chris@69 786
Chris@69 787
Chris@69 788 # func_fatal_error ARG...
Chris@69 789 # -----------------------
Chris@69 790 # Echo program name prefixed message to standard error, and exit.
Chris@69 791 func_fatal_error ()
Chris@69 792 {
Chris@69 793 $debug_cmd
Chris@69 794
Chris@69 795 func_error "$*"
Chris@69 796 exit $EXIT_FAILURE
Chris@69 797 }
Chris@69 798
Chris@69 799
Chris@69 800 # func_grep EXPRESSION FILENAME
Chris@69 801 # -----------------------------
Chris@69 802 # Check whether EXPRESSION matches any line of FILENAME, without output.
Chris@69 803 func_grep ()
Chris@69 804 {
Chris@69 805 $debug_cmd
Chris@69 806
Chris@69 807 $GREP "$1" "$2" >/dev/null 2>&1
Chris@69 808 }
Chris@69 809
Chris@69 810
Chris@69 811 # func_len STRING
Chris@69 812 # ---------------
Chris@69 813 # Set func_len_result to the length of STRING. STRING may not
Chris@69 814 # start with a hyphen.
Chris@69 815 test -z "$_G_HAVE_XSI_OPS" \
Chris@69 816 && (eval 'x=a/b/c;
Chris@69 817 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
Chris@69 818 && _G_HAVE_XSI_OPS=yes
Chris@69 819
Chris@69 820 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@69 821 eval 'func_len ()
Chris@69 822 {
Chris@69 823 $debug_cmd
Chris@69 824
Chris@69 825 func_len_result=${#1}
Chris@69 826 }'
Chris@69 827 else
Chris@69 828 func_len ()
Chris@69 829 {
Chris@69 830 $debug_cmd
Chris@69 831
Chris@69 832 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
Chris@69 833 }
Chris@69 834 fi
Chris@69 835
Chris@69 836
Chris@69 837 # func_mkdir_p DIRECTORY-PATH
Chris@69 838 # ---------------------------
Chris@69 839 # Make sure the entire path to DIRECTORY-PATH is available.
Chris@69 840 func_mkdir_p ()
Chris@69 841 {
Chris@69 842 $debug_cmd
Chris@69 843
Chris@69 844 _G_directory_path=$1
Chris@69 845 _G_dir_list=
Chris@69 846
Chris@69 847 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
Chris@69 848
Chris@69 849 # Protect directory names starting with '-'
Chris@69 850 case $_G_directory_path in
Chris@69 851 -*) _G_directory_path=./$_G_directory_path ;;
Chris@69 852 esac
Chris@69 853
Chris@69 854 # While some portion of DIR does not yet exist...
Chris@69 855 while test ! -d "$_G_directory_path"; do
Chris@69 856 # ...make a list in topmost first order. Use a colon delimited
Chris@69 857 # list incase some portion of path contains whitespace.
Chris@69 858 _G_dir_list=$_G_directory_path:$_G_dir_list
Chris@69 859
Chris@69 860 # If the last portion added has no slash in it, the list is done
Chris@69 861 case $_G_directory_path in */*) ;; *) break ;; esac
Chris@69 862
Chris@69 863 # ...otherwise throw away the child directory and loop
Chris@69 864 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
Chris@69 865 done
Chris@69 866 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
Chris@69 867
Chris@69 868 func_mkdir_p_IFS=$IFS; IFS=:
Chris@69 869 for _G_dir in $_G_dir_list; do
Chris@69 870 IFS=$func_mkdir_p_IFS
Chris@69 871 # mkdir can fail with a 'File exist' error if two processes
Chris@69 872 # try to create one of the directories concurrently. Don't
Chris@69 873 # stop in that case!
Chris@69 874 $MKDIR "$_G_dir" 2>/dev/null || :
Chris@69 875 done
Chris@69 876 IFS=$func_mkdir_p_IFS
Chris@69 877
Chris@69 878 # Bail out if we (or some other process) failed to create a directory.
Chris@69 879 test -d "$_G_directory_path" || \
Chris@69 880 func_fatal_error "Failed to create '$1'"
Chris@69 881 fi
Chris@69 882 }
Chris@69 883
Chris@69 884
Chris@69 885 # func_mktempdir [BASENAME]
Chris@69 886 # -------------------------
Chris@69 887 # Make a temporary directory that won't clash with other running
Chris@69 888 # libtool processes, and avoids race conditions if possible. If
Chris@69 889 # given, BASENAME is the basename for that directory.
Chris@69 890 func_mktempdir ()
Chris@69 891 {
Chris@69 892 $debug_cmd
Chris@69 893
Chris@69 894 _G_template=${TMPDIR-/tmp}/${1-$progname}
Chris@69 895
Chris@69 896 if test : = "$opt_dry_run"; then
Chris@69 897 # Return a directory name, but don't create it in dry-run mode
Chris@69 898 _G_tmpdir=$_G_template-$$
Chris@69 899 else
Chris@69 900
Chris@69 901 # If mktemp works, use that first and foremost
Chris@69 902 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
Chris@69 903
Chris@69 904 if test ! -d "$_G_tmpdir"; then
Chris@69 905 # Failing that, at least try and use $RANDOM to avoid a race
Chris@69 906 _G_tmpdir=$_G_template-${RANDOM-0}$$
Chris@69 907
Chris@69 908 func_mktempdir_umask=`umask`
Chris@69 909 umask 0077
Chris@69 910 $MKDIR "$_G_tmpdir"
Chris@69 911 umask $func_mktempdir_umask
Chris@69 912 fi
Chris@69 913
Chris@69 914 # If we're not in dry-run mode, bomb out on failure
Chris@69 915 test -d "$_G_tmpdir" || \
Chris@69 916 func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
Chris@69 917 fi
Chris@69 918
Chris@69 919 $ECHO "$_G_tmpdir"
Chris@69 920 }
Chris@69 921
Chris@69 922
Chris@69 923 # func_normal_abspath PATH
Chris@69 924 # ------------------------
Chris@69 925 # Remove doubled-up and trailing slashes, "." path components,
Chris@69 926 # and cancel out any ".." path components in PATH after making
Chris@69 927 # it an absolute path.
Chris@69 928 func_normal_abspath ()
Chris@69 929 {
Chris@69 930 $debug_cmd
Chris@69 931
Chris@69 932 # These SED scripts presuppose an absolute path with a trailing slash.
Chris@69 933 _G_pathcar='s|^/\([^/]*\).*$|\1|'
Chris@69 934 _G_pathcdr='s|^/[^/]*||'
Chris@69 935 _G_removedotparts=':dotsl
Chris@69 936 s|/\./|/|g
Chris@69 937 t dotsl
Chris@69 938 s|/\.$|/|'
Chris@69 939 _G_collapseslashes='s|/\{1,\}|/|g'
Chris@69 940 _G_finalslash='s|/*$|/|'
Chris@69 941
Chris@69 942 # Start from root dir and reassemble the path.
Chris@69 943 func_normal_abspath_result=
Chris@69 944 func_normal_abspath_tpath=$1
Chris@69 945 func_normal_abspath_altnamespace=
Chris@69 946 case $func_normal_abspath_tpath in
Chris@69 947 "")
Chris@69 948 # Empty path, that just means $cwd.
Chris@69 949 func_stripname '' '/' "`pwd`"
Chris@69 950 func_normal_abspath_result=$func_stripname_result
Chris@69 951 return
Chris@69 952 ;;
Chris@69 953 # The next three entries are used to spot a run of precisely
Chris@69 954 # two leading slashes without using negated character classes;
Chris@69 955 # we take advantage of case's first-match behaviour.
Chris@69 956 ///*)
Chris@69 957 # Unusual form of absolute path, do nothing.
Chris@69 958 ;;
Chris@69 959 //*)
Chris@69 960 # Not necessarily an ordinary path; POSIX reserves leading '//'
Chris@69 961 # and for example Cygwin uses it to access remote file shares
Chris@69 962 # over CIFS/SMB, so we conserve a leading double slash if found.
Chris@69 963 func_normal_abspath_altnamespace=/
Chris@69 964 ;;
Chris@69 965 /*)
Chris@69 966 # Absolute path, do nothing.
Chris@69 967 ;;
Chris@69 968 *)
Chris@69 969 # Relative path, prepend $cwd.
Chris@69 970 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
Chris@69 971 ;;
Chris@69 972 esac
Chris@69 973
Chris@69 974 # Cancel out all the simple stuff to save iterations. We also want
Chris@69 975 # the path to end with a slash for ease of parsing, so make sure
Chris@69 976 # there is one (and only one) here.
Chris@69 977 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
Chris@69 978 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
Chris@69 979 while :; do
Chris@69 980 # Processed it all yet?
Chris@69 981 if test / = "$func_normal_abspath_tpath"; then
Chris@69 982 # If we ascended to the root using ".." the result may be empty now.
Chris@69 983 if test -z "$func_normal_abspath_result"; then
Chris@69 984 func_normal_abspath_result=/
Chris@69 985 fi
Chris@69 986 break
Chris@69 987 fi
Chris@69 988 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
Chris@69 989 -e "$_G_pathcar"`
Chris@69 990 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
Chris@69 991 -e "$_G_pathcdr"`
Chris@69 992 # Figure out what to do with it
Chris@69 993 case $func_normal_abspath_tcomponent in
Chris@69 994 "")
Chris@69 995 # Trailing empty path component, ignore it.
Chris@69 996 ;;
Chris@69 997 ..)
Chris@69 998 # Parent dir; strip last assembled component from result.
Chris@69 999 func_dirname "$func_normal_abspath_result"
Chris@69 1000 func_normal_abspath_result=$func_dirname_result
Chris@69 1001 ;;
Chris@69 1002 *)
Chris@69 1003 # Actual path component, append it.
Chris@69 1004 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
Chris@69 1005 ;;
Chris@69 1006 esac
Chris@69 1007 done
Chris@69 1008 # Restore leading double-slash if one was found on entry.
Chris@69 1009 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
Chris@69 1010 }
Chris@69 1011
Chris@69 1012
Chris@69 1013 # func_notquiet ARG...
Chris@69 1014 # --------------------
Chris@69 1015 # Echo program name prefixed message only when not in quiet mode.
Chris@69 1016 func_notquiet ()
Chris@69 1017 {
Chris@69 1018 $debug_cmd
Chris@69 1019
Chris@69 1020 $opt_quiet || func_echo ${1+"$@"}
Chris@69 1021
Chris@69 1022 # A bug in bash halts the script if the last line of a function
Chris@69 1023 # fails when set -e is in force, so we need another command to
Chris@69 1024 # work around that:
Chris@69 1025 :
Chris@69 1026 }
Chris@69 1027
Chris@69 1028
Chris@69 1029 # func_relative_path SRCDIR DSTDIR
Chris@69 1030 # --------------------------------
Chris@69 1031 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
Chris@69 1032 func_relative_path ()
Chris@69 1033 {
Chris@69 1034 $debug_cmd
Chris@69 1035
Chris@69 1036 func_relative_path_result=
Chris@69 1037 func_normal_abspath "$1"
Chris@69 1038 func_relative_path_tlibdir=$func_normal_abspath_result
Chris@69 1039 func_normal_abspath "$2"
Chris@69 1040 func_relative_path_tbindir=$func_normal_abspath_result
Chris@69 1041
Chris@69 1042 # Ascend the tree starting from libdir
Chris@69 1043 while :; do
Chris@69 1044 # check if we have found a prefix of bindir
Chris@69 1045 case $func_relative_path_tbindir in
Chris@69 1046 $func_relative_path_tlibdir)
Chris@69 1047 # found an exact match
Chris@69 1048 func_relative_path_tcancelled=
Chris@69 1049 break
Chris@69 1050 ;;
Chris@69 1051 $func_relative_path_tlibdir*)
Chris@69 1052 # found a matching prefix
Chris@69 1053 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
Chris@69 1054 func_relative_path_tcancelled=$func_stripname_result
Chris@69 1055 if test -z "$func_relative_path_result"; then
Chris@69 1056 func_relative_path_result=.
Chris@69 1057 fi
Chris@69 1058 break
Chris@69 1059 ;;
Chris@69 1060 *)
Chris@69 1061 func_dirname $func_relative_path_tlibdir
Chris@69 1062 func_relative_path_tlibdir=$func_dirname_result
Chris@69 1063 if test -z "$func_relative_path_tlibdir"; then
Chris@69 1064 # Have to descend all the way to the root!
Chris@69 1065 func_relative_path_result=../$func_relative_path_result
Chris@69 1066 func_relative_path_tcancelled=$func_relative_path_tbindir
Chris@69 1067 break
Chris@69 1068 fi
Chris@69 1069 func_relative_path_result=../$func_relative_path_result
Chris@69 1070 ;;
Chris@69 1071 esac
Chris@69 1072 done
Chris@69 1073
Chris@69 1074 # Now calculate path; take care to avoid doubling-up slashes.
Chris@69 1075 func_stripname '' '/' "$func_relative_path_result"
Chris@69 1076 func_relative_path_result=$func_stripname_result
Chris@69 1077 func_stripname '/' '/' "$func_relative_path_tcancelled"
Chris@69 1078 if test -n "$func_stripname_result"; then
Chris@69 1079 func_append func_relative_path_result "/$func_stripname_result"
Chris@69 1080 fi
Chris@69 1081
Chris@69 1082 # Normalisation. If bindir is libdir, return '.' else relative path.
Chris@69 1083 if test -n "$func_relative_path_result"; then
Chris@69 1084 func_stripname './' '' "$func_relative_path_result"
Chris@69 1085 func_relative_path_result=$func_stripname_result
Chris@69 1086 fi
Chris@69 1087
Chris@69 1088 test -n "$func_relative_path_result" || func_relative_path_result=.
Chris@69 1089
Chris@69 1090 :
Chris@69 1091 }
Chris@69 1092
Chris@69 1093
Chris@69 1094 # func_quote_for_eval ARG...
Chris@69 1095 # --------------------------
Chris@69 1096 # Aesthetically quote ARGs to be evaled later.
Chris@69 1097 # This function returns two values:
Chris@69 1098 # i) func_quote_for_eval_result
Chris@69 1099 # double-quoted, suitable for a subsequent eval
Chris@69 1100 # ii) func_quote_for_eval_unquoted_result
Chris@69 1101 # has all characters that are still active within double
Chris@69 1102 # quotes backslashified.
Chris@69 1103 func_quote_for_eval ()
Chris@69 1104 {
Chris@69 1105 $debug_cmd
Chris@69 1106
Chris@69 1107 func_quote_for_eval_unquoted_result=
Chris@69 1108 func_quote_for_eval_result=
Chris@69 1109 while test 0 -lt $#; do
Chris@69 1110 case $1 in
Chris@69 1111 *[\\\`\"\$]*)
Chris@69 1112 _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
Chris@69 1113 *)
Chris@69 1114 _G_unquoted_arg=$1 ;;
Chris@69 1115 esac
Chris@69 1116 if test -n "$func_quote_for_eval_unquoted_result"; then
Chris@69 1117 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
Chris@69 1118 else
Chris@69 1119 func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
Chris@69 1120 fi
Chris@69 1121
Chris@69 1122 case $_G_unquoted_arg in
Chris@69 1123 # Double-quote args containing shell metacharacters to delay
Chris@69 1124 # word splitting, command substitution and variable expansion
Chris@69 1125 # for a subsequent eval.
Chris@69 1126 # Many Bourne shells cannot handle close brackets correctly
Chris@69 1127 # in scan sets, so we specify it separately.
Chris@69 1128 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
Chris@69 1129 _G_quoted_arg=\"$_G_unquoted_arg\"
Chris@69 1130 ;;
Chris@69 1131 *)
Chris@69 1132 _G_quoted_arg=$_G_unquoted_arg
Chris@69 1133 ;;
Chris@69 1134 esac
Chris@69 1135
Chris@69 1136 if test -n "$func_quote_for_eval_result"; then
Chris@69 1137 func_append func_quote_for_eval_result " $_G_quoted_arg"
Chris@69 1138 else
Chris@69 1139 func_append func_quote_for_eval_result "$_G_quoted_arg"
Chris@69 1140 fi
Chris@69 1141 shift
Chris@69 1142 done
Chris@69 1143 }
Chris@69 1144
Chris@69 1145
Chris@69 1146 # func_quote_for_expand ARG
Chris@69 1147 # -------------------------
Chris@69 1148 # Aesthetically quote ARG to be evaled later; same as above,
Chris@69 1149 # but do not quote variable references.
Chris@69 1150 func_quote_for_expand ()
Chris@69 1151 {
Chris@69 1152 $debug_cmd
Chris@69 1153
Chris@69 1154 case $1 in
Chris@69 1155 *[\\\`\"]*)
Chris@69 1156 _G_arg=`$ECHO "$1" | $SED \
Chris@69 1157 -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
Chris@69 1158 *)
Chris@69 1159 _G_arg=$1 ;;
Chris@69 1160 esac
Chris@69 1161
Chris@69 1162 case $_G_arg in
Chris@69 1163 # Double-quote args containing shell metacharacters to delay
Chris@69 1164 # word splitting and command substitution for a subsequent eval.
Chris@69 1165 # Many Bourne shells cannot handle close brackets correctly
Chris@69 1166 # in scan sets, so we specify it separately.
Chris@69 1167 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
Chris@69 1168 _G_arg=\"$_G_arg\"
Chris@69 1169 ;;
Chris@69 1170 esac
Chris@69 1171
Chris@69 1172 func_quote_for_expand_result=$_G_arg
Chris@69 1173 }
Chris@69 1174
Chris@69 1175
Chris@69 1176 # func_stripname PREFIX SUFFIX NAME
Chris@69 1177 # ---------------------------------
Chris@69 1178 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
Chris@69 1179 # PREFIX and SUFFIX must not contain globbing or regex special
Chris@69 1180 # characters, hashes, percent signs, but SUFFIX may contain a leading
Chris@69 1181 # dot (in which case that matches only a dot).
Chris@69 1182 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@69 1183 eval 'func_stripname ()
Chris@69 1184 {
Chris@69 1185 $debug_cmd
Chris@69 1186
Chris@69 1187 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
Chris@69 1188 # positional parameters, so assign one to ordinary variable first.
Chris@69 1189 func_stripname_result=$3
Chris@69 1190 func_stripname_result=${func_stripname_result#"$1"}
Chris@69 1191 func_stripname_result=${func_stripname_result%"$2"}
Chris@69 1192 }'
Chris@69 1193 else
Chris@69 1194 func_stripname ()
Chris@69 1195 {
Chris@69 1196 $debug_cmd
Chris@69 1197
Chris@69 1198 case $2 in
Chris@69 1199 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
Chris@69 1200 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
Chris@69 1201 esac
Chris@69 1202 }
Chris@69 1203 fi
Chris@69 1204
Chris@69 1205
Chris@69 1206 # func_show_eval CMD [FAIL_EXP]
Chris@69 1207 # -----------------------------
Chris@69 1208 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
Chris@69 1209 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
Chris@69 1210 # is given, then evaluate it.
Chris@69 1211 func_show_eval ()
Chris@69 1212 {
Chris@69 1213 $debug_cmd
Chris@69 1214
Chris@69 1215 _G_cmd=$1
Chris@69 1216 _G_fail_exp=${2-':'}
Chris@69 1217
Chris@69 1218 func_quote_for_expand "$_G_cmd"
Chris@69 1219 eval "func_notquiet $func_quote_for_expand_result"
Chris@69 1220
Chris@69 1221 $opt_dry_run || {
Chris@69 1222 eval "$_G_cmd"
Chris@69 1223 _G_status=$?
Chris@69 1224 if test 0 -ne "$_G_status"; then
Chris@69 1225 eval "(exit $_G_status); $_G_fail_exp"
Chris@69 1226 fi
Chris@69 1227 }
Chris@69 1228 }
Chris@69 1229
Chris@69 1230
Chris@69 1231 # func_show_eval_locale CMD [FAIL_EXP]
Chris@69 1232 # ------------------------------------
Chris@69 1233 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
Chris@69 1234 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
Chris@69 1235 # is given, then evaluate it. Use the saved locale for evaluation.
Chris@69 1236 func_show_eval_locale ()
Chris@69 1237 {
Chris@69 1238 $debug_cmd
Chris@69 1239
Chris@69 1240 _G_cmd=$1
Chris@69 1241 _G_fail_exp=${2-':'}
Chris@69 1242
Chris@69 1243 $opt_quiet || {
Chris@69 1244 func_quote_for_expand "$_G_cmd"
Chris@69 1245 eval "func_echo $func_quote_for_expand_result"
Chris@69 1246 }
Chris@69 1247
Chris@69 1248 $opt_dry_run || {
Chris@69 1249 eval "$_G_user_locale
Chris@69 1250 $_G_cmd"
Chris@69 1251 _G_status=$?
Chris@69 1252 eval "$_G_safe_locale"
Chris@69 1253 if test 0 -ne "$_G_status"; then
Chris@69 1254 eval "(exit $_G_status); $_G_fail_exp"
Chris@69 1255 fi
Chris@69 1256 }
Chris@69 1257 }
Chris@69 1258
Chris@69 1259
Chris@69 1260 # func_tr_sh
Chris@69 1261 # ----------
Chris@69 1262 # Turn $1 into a string suitable for a shell variable name.
Chris@69 1263 # Result is stored in $func_tr_sh_result. All characters
Chris@69 1264 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
Chris@69 1265 # if $1 begins with a digit, a '_' is prepended as well.
Chris@69 1266 func_tr_sh ()
Chris@69 1267 {
Chris@69 1268 $debug_cmd
Chris@69 1269
Chris@69 1270 case $1 in
Chris@69 1271 [0-9]* | *[!a-zA-Z0-9_]*)
Chris@69 1272 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
Chris@69 1273 ;;
Chris@69 1274 * )
Chris@69 1275 func_tr_sh_result=$1
Chris@69 1276 ;;
Chris@69 1277 esac
Chris@69 1278 }
Chris@69 1279
Chris@69 1280
Chris@69 1281 # func_verbose ARG...
Chris@69 1282 # -------------------
Chris@69 1283 # Echo program name prefixed message in verbose mode only.
Chris@69 1284 func_verbose ()
Chris@69 1285 {
Chris@69 1286 $debug_cmd
Chris@69 1287
Chris@69 1288 $opt_verbose && func_echo "$*"
Chris@69 1289
Chris@69 1290 :
Chris@69 1291 }
Chris@69 1292
Chris@69 1293
Chris@69 1294 # func_warn_and_continue ARG...
Chris@69 1295 # -----------------------------
Chris@69 1296 # Echo program name prefixed warning message to standard error.
Chris@69 1297 func_warn_and_continue ()
Chris@69 1298 {
Chris@69 1299 $debug_cmd
Chris@69 1300
Chris@69 1301 $require_term_colors
Chris@69 1302
Chris@69 1303 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
Chris@69 1304 }
Chris@69 1305
Chris@69 1306
Chris@69 1307 # func_warning CATEGORY ARG...
Chris@69 1308 # ----------------------------
Chris@69 1309 # Echo program name prefixed warning message to standard error. Warning
Chris@69 1310 # messages can be filtered according to CATEGORY, where this function
Chris@69 1311 # elides messages where CATEGORY is not listed in the global variable
Chris@69 1312 # 'opt_warning_types'.
Chris@69 1313 func_warning ()
Chris@69 1314 {
Chris@69 1315 $debug_cmd
Chris@69 1316
Chris@69 1317 # CATEGORY must be in the warning_categories list!
Chris@69 1318 case " $warning_categories " in
Chris@69 1319 *" $1 "*) ;;
Chris@69 1320 *) func_internal_error "invalid warning category '$1'" ;;
Chris@69 1321 esac
Chris@69 1322
Chris@69 1323 _G_category=$1
Chris@69 1324 shift
Chris@69 1325
Chris@69 1326 case " $opt_warning_types " in
Chris@69 1327 *" $_G_category "*) $warning_func ${1+"$@"} ;;
Chris@69 1328 esac
Chris@69 1329 }
Chris@69 1330
Chris@69 1331
Chris@69 1332 # func_sort_ver VER1 VER2
Chris@69 1333 # -----------------------
Chris@69 1334 # 'sort -V' is not generally available.
Chris@69 1335 # Note this deviates from the version comparison in automake
Chris@69 1336 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
Chris@69 1337 # but this should suffice as we won't be specifying old
Chris@69 1338 # version formats or redundant trailing .0 in bootstrap.conf.
Chris@69 1339 # If we did want full compatibility then we should probably
Chris@69 1340 # use m4_version_compare from autoconf.
Chris@69 1341 func_sort_ver ()
Chris@69 1342 {
Chris@69 1343 $debug_cmd
Chris@69 1344
Chris@69 1345 printf '%s\n%s\n' "$1" "$2" \
Chris@69 1346 | sort -t. -k 1,1n -k 2,2n -k 3,3n -k 4,4n -k 5,5n -k 6,6n -k 7,7n -k 8,8n -k 9,9n
Chris@69 1347 }
Chris@69 1348
Chris@69 1349 # func_lt_ver PREV CURR
Chris@69 1350 # ---------------------
Chris@69 1351 # Return true if PREV and CURR are in the correct order according to
Chris@69 1352 # func_sort_ver, otherwise false. Use it like this:
Chris@69 1353 #
Chris@69 1354 # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
Chris@69 1355 func_lt_ver ()
Chris@69 1356 {
Chris@69 1357 $debug_cmd
Chris@69 1358
Chris@69 1359 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
Chris@69 1360 }
Chris@69 1361
Chris@69 1362
Chris@69 1363 # Local variables:
Chris@69 1364 # mode: shell-script
Chris@69 1365 # sh-indentation: 2
Chris@69 1366 # eval: (add-hook 'before-save-hook 'time-stamp)
Chris@69 1367 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
Chris@69 1368 # time-stamp-time-zone: "UTC"
Chris@69 1369 # End:
Chris@69 1370 #! /bin/sh
Chris@69 1371
Chris@69 1372 # Set a version string for this script.
Chris@69 1373 scriptversion=2014-01-07.03; # UTC
Chris@69 1374
Chris@69 1375 # A portable, pluggable option parser for Bourne shell.
Chris@69 1376 # Written by Gary V. Vaughan, 2010
Chris@69 1377
Chris@69 1378 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
Chris@69 1379 # This is free software; see the source for copying conditions. There is NO
Chris@69 1380 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chris@69 1381
Chris@69 1382 # This program is free software: you can redistribute it and/or modify
Chris@69 1383 # it under the terms of the GNU General Public License as published by
Chris@69 1384 # the Free Software Foundation, either version 3 of the License, or
Chris@69 1385 # (at your option) any later version.
Chris@69 1386
Chris@69 1387 # This program is distributed in the hope that it will be useful,
Chris@69 1388 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@69 1389 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@69 1390 # GNU General Public License for more details.
Chris@69 1391
Chris@69 1392 # You should have received a copy of the GNU General Public License
Chris@69 1393 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@69 1394
Chris@69 1395 # Please report bugs or propose patches to gary@gnu.org.
Chris@69 1396
Chris@69 1397
Chris@69 1398 ## ------ ##
Chris@69 1399 ## Usage. ##
Chris@69 1400 ## ------ ##
Chris@69 1401
Chris@69 1402 # This file is a library for parsing options in your shell scripts along
Chris@69 1403 # with assorted other useful supporting features that you can make use
Chris@69 1404 # of too.
Chris@69 1405 #
Chris@69 1406 # For the simplest scripts you might need only:
Chris@69 1407 #
Chris@69 1408 # #!/bin/sh
Chris@69 1409 # . relative/path/to/funclib.sh
Chris@69 1410 # . relative/path/to/options-parser
Chris@69 1411 # scriptversion=1.0
Chris@69 1412 # func_options ${1+"$@"}
Chris@69 1413 # eval set dummy "$func_options_result"; shift
Chris@69 1414 # ...rest of your script...
Chris@69 1415 #
Chris@69 1416 # In order for the '--version' option to work, you will need to have a
Chris@69 1417 # suitably formatted comment like the one at the top of this file
Chris@69 1418 # starting with '# Written by ' and ending with '# warranty; '.
Chris@69 1419 #
Chris@69 1420 # For '-h' and '--help' to work, you will also need a one line
Chris@69 1421 # description of your script's purpose in a comment directly above the
Chris@69 1422 # '# Written by ' line, like the one at the top of this file.
Chris@69 1423 #
Chris@69 1424 # The default options also support '--debug', which will turn on shell
Chris@69 1425 # execution tracing (see the comment above debug_cmd below for another
Chris@69 1426 # use), and '--verbose' and the func_verbose function to allow your script
Chris@69 1427 # to display verbose messages only when your user has specified
Chris@69 1428 # '--verbose'.
Chris@69 1429 #
Chris@69 1430 # After sourcing this file, you can plug processing for additional
Chris@69 1431 # options by amending the variables from the 'Configuration' section
Chris@69 1432 # below, and following the instructions in the 'Option parsing'
Chris@69 1433 # section further down.
Chris@69 1434
Chris@69 1435 ## -------------- ##
Chris@69 1436 ## Configuration. ##
Chris@69 1437 ## -------------- ##
Chris@69 1438
Chris@69 1439 # You should override these variables in your script after sourcing this
Chris@69 1440 # file so that they reflect the customisations you have added to the
Chris@69 1441 # option parser.
Chris@69 1442
Chris@69 1443 # The usage line for option parsing errors and the start of '-h' and
Chris@69 1444 # '--help' output messages. You can embed shell variables for delayed
Chris@69 1445 # expansion at the time the message is displayed, but you will need to
Chris@69 1446 # quote other shell meta-characters carefully to prevent them being
Chris@69 1447 # expanded when the contents are evaled.
Chris@69 1448 usage='$progpath [OPTION]...'
Chris@69 1449
Chris@69 1450 # Short help message in response to '-h' and '--help'. Add to this or
Chris@69 1451 # override it after sourcing this library to reflect the full set of
Chris@69 1452 # options your script accepts.
Chris@69 1453 usage_message="\
Chris@69 1454 --debug enable verbose shell tracing
Chris@69 1455 -W, --warnings=CATEGORY
Chris@69 1456 report the warnings falling in CATEGORY [all]
Chris@69 1457 -v, --verbose verbosely report processing
Chris@69 1458 --version print version information and exit
Chris@69 1459 -h, --help print short or long help message and exit
Chris@69 1460 "
Chris@69 1461
Chris@69 1462 # Additional text appended to 'usage_message' in response to '--help'.
Chris@69 1463 long_help_message="
Chris@69 1464 Warning categories include:
Chris@69 1465 'all' show all warnings
Chris@69 1466 'none' turn off all the warnings
Chris@69 1467 'error' warnings are treated as fatal errors"
Chris@69 1468
Chris@69 1469 # Help message printed before fatal option parsing errors.
Chris@69 1470 fatal_help="Try '\$progname --help' for more information."
Chris@69 1471
Chris@69 1472
Chris@69 1473
Chris@69 1474 ## ------------------------- ##
Chris@69 1475 ## Hook function management. ##
Chris@69 1476 ## ------------------------- ##
Chris@69 1477
Chris@69 1478 # This section contains functions for adding, removing, and running hooks
Chris@69 1479 # to the main code. A hook is just a named list of of function, that can
Chris@69 1480 # be run in order later on.
Chris@69 1481
Chris@69 1482 # func_hookable FUNC_NAME
Chris@69 1483 # -----------------------
Chris@69 1484 # Declare that FUNC_NAME will run hooks added with
Chris@69 1485 # 'func_add_hook FUNC_NAME ...'.
Chris@69 1486 func_hookable ()
Chris@69 1487 {
Chris@69 1488 $debug_cmd
Chris@69 1489
Chris@69 1490 func_append hookable_fns " $1"
Chris@69 1491 }
Chris@69 1492
Chris@69 1493
Chris@69 1494 # func_add_hook FUNC_NAME HOOK_FUNC
Chris@69 1495 # ---------------------------------
Chris@69 1496 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
Chris@69 1497 # first have been declared "hookable" by a call to 'func_hookable'.
Chris@69 1498 func_add_hook ()
Chris@69 1499 {
Chris@69 1500 $debug_cmd
Chris@69 1501
Chris@69 1502 case " $hookable_fns " in
Chris@69 1503 *" $1 "*) ;;
Chris@69 1504 *) func_fatal_error "'$1' does not accept hook functions." ;;
Chris@69 1505 esac
Chris@69 1506
Chris@69 1507 eval func_append ${1}_hooks '" $2"'
Chris@69 1508 }
Chris@69 1509
Chris@69 1510
Chris@69 1511 # func_remove_hook FUNC_NAME HOOK_FUNC
Chris@69 1512 # ------------------------------------
Chris@69 1513 # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
Chris@69 1514 func_remove_hook ()
Chris@69 1515 {
Chris@69 1516 $debug_cmd
Chris@69 1517
Chris@69 1518 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
Chris@69 1519 }
Chris@69 1520
Chris@69 1521
Chris@69 1522 # func_run_hooks FUNC_NAME [ARG]...
Chris@69 1523 # ---------------------------------
Chris@69 1524 # Run all hook functions registered to FUNC_NAME.
Chris@69 1525 # It is assumed that the list of hook functions contains nothing more
Chris@69 1526 # than a whitespace-delimited list of legal shell function names, and
Chris@69 1527 # no effort is wasted trying to catch shell meta-characters or preserve
Chris@69 1528 # whitespace.
Chris@69 1529 func_run_hooks ()
Chris@69 1530 {
Chris@69 1531 $debug_cmd
Chris@69 1532
Chris@69 1533 case " $hookable_fns " in
Chris@69 1534 *" $1 "*) ;;
Chris@69 1535 *) func_fatal_error "'$1' does not support hook funcions.n" ;;
Chris@69 1536 esac
Chris@69 1537
Chris@69 1538 eval _G_hook_fns=\$$1_hooks; shift
Chris@69 1539
Chris@69 1540 for _G_hook in $_G_hook_fns; do
Chris@69 1541 eval $_G_hook '"$@"'
Chris@69 1542
Chris@69 1543 # store returned options list back into positional
Chris@69 1544 # parameters for next 'cmd' execution.
Chris@69 1545 eval _G_hook_result=\$${_G_hook}_result
Chris@69 1546 eval set dummy "$_G_hook_result"; shift
Chris@69 1547 done
Chris@69 1548
Chris@69 1549 func_quote_for_eval ${1+"$@"}
Chris@69 1550 func_run_hooks_result=$func_quote_for_eval_result
Chris@69 1551 }
Chris@69 1552
Chris@69 1553
Chris@69 1554
Chris@69 1555 ## --------------- ##
Chris@69 1556 ## Option parsing. ##
Chris@69 1557 ## --------------- ##
Chris@69 1558
Chris@69 1559 # In order to add your own option parsing hooks, you must accept the
Chris@69 1560 # full positional parameter list in your hook function, remove any
Chris@69 1561 # options that you action, and then pass back the remaining unprocessed
Chris@69 1562 # options in '<hooked_function_name>_result', escaped suitably for
Chris@69 1563 # 'eval'. Like this:
Chris@69 1564 #
Chris@69 1565 # my_options_prep ()
Chris@69 1566 # {
Chris@69 1567 # $debug_cmd
Chris@69 1568 #
Chris@69 1569 # # Extend the existing usage message.
Chris@69 1570 # usage_message=$usage_message'
Chris@69 1571 # -s, --silent don'\''t print informational messages
Chris@69 1572 # '
Chris@69 1573 #
Chris@69 1574 # func_quote_for_eval ${1+"$@"}
Chris@69 1575 # my_options_prep_result=$func_quote_for_eval_result
Chris@69 1576 # }
Chris@69 1577 # func_add_hook func_options_prep my_options_prep
Chris@69 1578 #
Chris@69 1579 #
Chris@69 1580 # my_silent_option ()
Chris@69 1581 # {
Chris@69 1582 # $debug_cmd
Chris@69 1583 #
Chris@69 1584 # # Note that for efficiency, we parse as many options as we can
Chris@69 1585 # # recognise in a loop before passing the remainder back to the
Chris@69 1586 # # caller on the first unrecognised argument we encounter.
Chris@69 1587 # while test $# -gt 0; do
Chris@69 1588 # opt=$1; shift
Chris@69 1589 # case $opt in
Chris@69 1590 # --silent|-s) opt_silent=: ;;
Chris@69 1591 # # Separate non-argument short options:
Chris@69 1592 # -s*) func_split_short_opt "$_G_opt"
Chris@69 1593 # set dummy "$func_split_short_opt_name" \
Chris@69 1594 # "-$func_split_short_opt_arg" ${1+"$@"}
Chris@69 1595 # shift
Chris@69 1596 # ;;
Chris@69 1597 # *) set dummy "$_G_opt" "$*"; shift; break ;;
Chris@69 1598 # esac
Chris@69 1599 # done
Chris@69 1600 #
Chris@69 1601 # func_quote_for_eval ${1+"$@"}
Chris@69 1602 # my_silent_option_result=$func_quote_for_eval_result
Chris@69 1603 # }
Chris@69 1604 # func_add_hook func_parse_options my_silent_option
Chris@69 1605 #
Chris@69 1606 #
Chris@69 1607 # my_option_validation ()
Chris@69 1608 # {
Chris@69 1609 # $debug_cmd
Chris@69 1610 #
Chris@69 1611 # $opt_silent && $opt_verbose && func_fatal_help "\
Chris@69 1612 # '--silent' and '--verbose' options are mutually exclusive."
Chris@69 1613 #
Chris@69 1614 # func_quote_for_eval ${1+"$@"}
Chris@69 1615 # my_option_validation_result=$func_quote_for_eval_result
Chris@69 1616 # }
Chris@69 1617 # func_add_hook func_validate_options my_option_validation
Chris@69 1618 #
Chris@69 1619 # You'll alse need to manually amend $usage_message to reflect the extra
Chris@69 1620 # options you parse. It's preferable to append if you can, so that
Chris@69 1621 # multiple option parsing hooks can be added safely.
Chris@69 1622
Chris@69 1623
Chris@69 1624 # func_options [ARG]...
Chris@69 1625 # ---------------------
Chris@69 1626 # All the functions called inside func_options are hookable. See the
Chris@69 1627 # individual implementations for details.
Chris@69 1628 func_hookable func_options
Chris@69 1629 func_options ()
Chris@69 1630 {
Chris@69 1631 $debug_cmd
Chris@69 1632
Chris@69 1633 func_options_prep ${1+"$@"}
Chris@69 1634 eval func_parse_options \
Chris@69 1635 ${func_options_prep_result+"$func_options_prep_result"}
Chris@69 1636 eval func_validate_options \
Chris@69 1637 ${func_parse_options_result+"$func_parse_options_result"}
Chris@69 1638
Chris@69 1639 eval func_run_hooks func_options \
Chris@69 1640 ${func_validate_options_result+"$func_validate_options_result"}
Chris@69 1641
Chris@69 1642 # save modified positional parameters for caller
Chris@69 1643 func_options_result=$func_run_hooks_result
Chris@69 1644 }
Chris@69 1645
Chris@69 1646
Chris@69 1647 # func_options_prep [ARG]...
Chris@69 1648 # --------------------------
Chris@69 1649 # All initialisations required before starting the option parse loop.
Chris@69 1650 # Note that when calling hook functions, we pass through the list of
Chris@69 1651 # positional parameters. If a hook function modifies that list, and
Chris@69 1652 # needs to propogate that back to rest of this script, then the complete
Chris@69 1653 # modified list must be put in 'func_run_hooks_result' before
Chris@69 1654 # returning.
Chris@69 1655 func_hookable func_options_prep
Chris@69 1656 func_options_prep ()
Chris@69 1657 {
Chris@69 1658 $debug_cmd
Chris@69 1659
Chris@69 1660 # Option defaults:
Chris@69 1661 opt_verbose=false
Chris@69 1662 opt_warning_types=
Chris@69 1663
Chris@69 1664 func_run_hooks func_options_prep ${1+"$@"}
Chris@69 1665
Chris@69 1666 # save modified positional parameters for caller
Chris@69 1667 func_options_prep_result=$func_run_hooks_result
Chris@69 1668 }
Chris@69 1669
Chris@69 1670
Chris@69 1671 # func_parse_options [ARG]...
Chris@69 1672 # ---------------------------
Chris@69 1673 # The main option parsing loop.
Chris@69 1674 func_hookable func_parse_options
Chris@69 1675 func_parse_options ()
Chris@69 1676 {
Chris@69 1677 $debug_cmd
Chris@69 1678
Chris@69 1679 func_parse_options_result=
Chris@69 1680
Chris@69 1681 # this just eases exit handling
Chris@69 1682 while test $# -gt 0; do
Chris@69 1683 # Defer to hook functions for initial option parsing, so they
Chris@69 1684 # get priority in the event of reusing an option name.
Chris@69 1685 func_run_hooks func_parse_options ${1+"$@"}
Chris@69 1686
Chris@69 1687 # Adjust func_parse_options positional parameters to match
Chris@69 1688 eval set dummy "$func_run_hooks_result"; shift
Chris@69 1689
Chris@69 1690 # Break out of the loop if we already parsed every option.
Chris@69 1691 test $# -gt 0 || break
Chris@69 1692
Chris@69 1693 _G_opt=$1
Chris@69 1694 shift
Chris@69 1695 case $_G_opt in
Chris@69 1696 --debug|-x) debug_cmd='set -x'
Chris@69 1697 func_echo "enabling shell trace mode"
Chris@69 1698 $debug_cmd
Chris@69 1699 ;;
Chris@69 1700
Chris@69 1701 --no-warnings|--no-warning|--no-warn)
Chris@69 1702 set dummy --warnings none ${1+"$@"}
Chris@69 1703 shift
Chris@69 1704 ;;
Chris@69 1705
Chris@69 1706 --warnings|--warning|-W)
Chris@69 1707 test $# = 0 && func_missing_arg $_G_opt && break
Chris@69 1708 case " $warning_categories $1" in
Chris@69 1709 *" $1 "*)
Chris@69 1710 # trailing space prevents matching last $1 above
Chris@69 1711 func_append_uniq opt_warning_types " $1"
Chris@69 1712 ;;
Chris@69 1713 *all)
Chris@69 1714 opt_warning_types=$warning_categories
Chris@69 1715 ;;
Chris@69 1716 *none)
Chris@69 1717 opt_warning_types=none
Chris@69 1718 warning_func=:
Chris@69 1719 ;;
Chris@69 1720 *error)
Chris@69 1721 opt_warning_types=$warning_categories
Chris@69 1722 warning_func=func_fatal_error
Chris@69 1723 ;;
Chris@69 1724 *)
Chris@69 1725 func_fatal_error \
Chris@69 1726 "unsupported warning category: '$1'"
Chris@69 1727 ;;
Chris@69 1728 esac
Chris@69 1729 shift
Chris@69 1730 ;;
Chris@69 1731
Chris@69 1732 --verbose|-v) opt_verbose=: ;;
Chris@69 1733 --version) func_version ;;
Chris@69 1734 -\?|-h) func_usage ;;
Chris@69 1735 --help) func_help ;;
Chris@69 1736
Chris@69 1737 # Separate optargs to long options (plugins may need this):
Chris@69 1738 --*=*) func_split_equals "$_G_opt"
Chris@69 1739 set dummy "$func_split_equals_lhs" \
Chris@69 1740 "$func_split_equals_rhs" ${1+"$@"}
Chris@69 1741 shift
Chris@69 1742 ;;
Chris@69 1743
Chris@69 1744 # Separate optargs to short options:
Chris@69 1745 -W*)
Chris@69 1746 func_split_short_opt "$_G_opt"
Chris@69 1747 set dummy "$func_split_short_opt_name" \
Chris@69 1748 "$func_split_short_opt_arg" ${1+"$@"}
Chris@69 1749 shift
Chris@69 1750 ;;
Chris@69 1751
Chris@69 1752 # Separate non-argument short options:
Chris@69 1753 -\?*|-h*|-v*|-x*)
Chris@69 1754 func_split_short_opt "$_G_opt"
Chris@69 1755 set dummy "$func_split_short_opt_name" \
Chris@69 1756 "-$func_split_short_opt_arg" ${1+"$@"}
Chris@69 1757 shift
Chris@69 1758 ;;
Chris@69 1759
Chris@69 1760 --) break ;;
Chris@69 1761 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
Chris@69 1762 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
Chris@69 1763 esac
Chris@69 1764 done
Chris@69 1765
Chris@69 1766 # save modified positional parameters for caller
Chris@69 1767 func_quote_for_eval ${1+"$@"}
Chris@69 1768 func_parse_options_result=$func_quote_for_eval_result
Chris@69 1769 }
Chris@69 1770
Chris@69 1771
Chris@69 1772 # func_validate_options [ARG]...
Chris@69 1773 # ------------------------------
Chris@69 1774 # Perform any sanity checks on option settings and/or unconsumed
Chris@69 1775 # arguments.
Chris@69 1776 func_hookable func_validate_options
Chris@69 1777 func_validate_options ()
Chris@69 1778 {
Chris@69 1779 $debug_cmd
Chris@69 1780
Chris@69 1781 # Display all warnings if -W was not given.
Chris@69 1782 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
Chris@69 1783
Chris@69 1784 func_run_hooks func_validate_options ${1+"$@"}
Chris@69 1785
Chris@69 1786 # Bail if the options were screwed!
Chris@69 1787 $exit_cmd $EXIT_FAILURE
Chris@69 1788
Chris@69 1789 # save modified positional parameters for caller
Chris@69 1790 func_validate_options_result=$func_run_hooks_result
Chris@69 1791 }
Chris@69 1792
Chris@69 1793
Chris@69 1794
Chris@69 1795 ## ----------------- ##
Chris@69 1796 ## Helper functions. ##
Chris@69 1797 ## ----------------- ##
Chris@69 1798
Chris@69 1799 # This section contains the helper functions used by the rest of the
Chris@69 1800 # hookable option parser framework in ascii-betical order.
Chris@69 1801
Chris@69 1802
Chris@69 1803 # func_fatal_help ARG...
Chris@69 1804 # ----------------------
Chris@69 1805 # Echo program name prefixed message to standard error, followed by
Chris@69 1806 # a help hint, and exit.
Chris@69 1807 func_fatal_help ()
Chris@69 1808 {
Chris@69 1809 $debug_cmd
Chris@69 1810
Chris@69 1811 eval \$ECHO \""Usage: $usage"\"
Chris@69 1812 eval \$ECHO \""$fatal_help"\"
Chris@69 1813 func_error ${1+"$@"}
Chris@69 1814 exit $EXIT_FAILURE
Chris@69 1815 }
Chris@69 1816
Chris@69 1817
Chris@69 1818 # func_help
Chris@69 1819 # ---------
Chris@69 1820 # Echo long help message to standard output and exit.
Chris@69 1821 func_help ()
Chris@69 1822 {
Chris@69 1823 $debug_cmd
Chris@69 1824
Chris@69 1825 func_usage_message
Chris@69 1826 $ECHO "$long_help_message"
Chris@69 1827 exit 0
Chris@69 1828 }
Chris@69 1829
Chris@69 1830
Chris@69 1831 # func_missing_arg ARGNAME
Chris@69 1832 # ------------------------
Chris@69 1833 # Echo program name prefixed message to standard error and set global
Chris@69 1834 # exit_cmd.
Chris@69 1835 func_missing_arg ()
Chris@69 1836 {
Chris@69 1837 $debug_cmd
Chris@69 1838
Chris@69 1839 func_error "Missing argument for '$1'."
Chris@69 1840 exit_cmd=exit
Chris@69 1841 }
Chris@69 1842
Chris@69 1843
Chris@69 1844 # func_split_equals STRING
Chris@69 1845 # ------------------------
Chris@69 1846 # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
Chris@69 1847 # splitting STRING at the '=' sign.
Chris@69 1848 test -z "$_G_HAVE_XSI_OPS" \
Chris@69 1849 && (eval 'x=a/b/c;
Chris@69 1850 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
Chris@69 1851 && _G_HAVE_XSI_OPS=yes
Chris@69 1852
Chris@69 1853 if test yes = "$_G_HAVE_XSI_OPS"
Chris@69 1854 then
Chris@69 1855 # This is an XSI compatible shell, allowing a faster implementation...
Chris@69 1856 eval 'func_split_equals ()
Chris@69 1857 {
Chris@69 1858 $debug_cmd
Chris@69 1859
Chris@69 1860 func_split_equals_lhs=${1%%=*}
Chris@69 1861 func_split_equals_rhs=${1#*=}
Chris@69 1862 test "x$func_split_equals_lhs" = "x$1" \
Chris@69 1863 && func_split_equals_rhs=
Chris@69 1864 }'
Chris@69 1865 else
Chris@69 1866 # ...otherwise fall back to using expr, which is often a shell builtin.
Chris@69 1867 func_split_equals ()
Chris@69 1868 {
Chris@69 1869 $debug_cmd
Chris@69 1870
Chris@69 1871 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
Chris@69 1872 func_split_equals_rhs=
Chris@69 1873 test "x$func_split_equals_lhs" = "x$1" \
Chris@69 1874 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
Chris@69 1875 }
Chris@69 1876 fi #func_split_equals
Chris@69 1877
Chris@69 1878
Chris@69 1879 # func_split_short_opt SHORTOPT
Chris@69 1880 # -----------------------------
Chris@69 1881 # Set func_split_short_opt_name and func_split_short_opt_arg shell
Chris@69 1882 # variables after splitting SHORTOPT after the 2nd character.
Chris@69 1883 if test yes = "$_G_HAVE_XSI_OPS"
Chris@69 1884 then
Chris@69 1885 # This is an XSI compatible shell, allowing a faster implementation...
Chris@69 1886 eval 'func_split_short_opt ()
Chris@69 1887 {
Chris@69 1888 $debug_cmd
Chris@69 1889
Chris@69 1890 func_split_short_opt_arg=${1#??}
Chris@69 1891 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
Chris@69 1892 }'
Chris@69 1893 else
Chris@69 1894 # ...otherwise fall back to using expr, which is often a shell builtin.
Chris@69 1895 func_split_short_opt ()
Chris@69 1896 {
Chris@69 1897 $debug_cmd
Chris@69 1898
Chris@69 1899 func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
Chris@69 1900 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
Chris@69 1901 }
Chris@69 1902 fi #func_split_short_opt
Chris@69 1903
Chris@69 1904
Chris@69 1905 # func_usage
Chris@69 1906 # ----------
Chris@69 1907 # Echo short help message to standard output and exit.
Chris@69 1908 func_usage ()
Chris@69 1909 {
Chris@69 1910 $debug_cmd
Chris@69 1911
Chris@69 1912 func_usage_message
Chris@69 1913 $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
Chris@69 1914 exit 0
Chris@69 1915 }
Chris@69 1916
Chris@69 1917
Chris@69 1918 # func_usage_message
Chris@69 1919 # ------------------
Chris@69 1920 # Echo short help message to standard output.
Chris@69 1921 func_usage_message ()
Chris@69 1922 {
Chris@69 1923 $debug_cmd
Chris@69 1924
Chris@69 1925 eval \$ECHO \""Usage: $usage"\"
Chris@69 1926 echo
Chris@69 1927 $SED -n 's|^# ||
Chris@69 1928 /^Written by/{
Chris@69 1929 x;p;x
Chris@69 1930 }
Chris@69 1931 h
Chris@69 1932 /^Written by/q' < "$progpath"
Chris@69 1933 echo
Chris@69 1934 eval \$ECHO \""$usage_message"\"
Chris@69 1935 }
Chris@69 1936
Chris@69 1937
Chris@69 1938 # func_version
Chris@69 1939 # ------------
Chris@69 1940 # Echo version message to standard output and exit.
Chris@69 1941 func_version ()
Chris@69 1942 {
Chris@69 1943 $debug_cmd
Chris@69 1944
Chris@69 1945 printf '%s\n' "$progname $scriptversion"
Chris@69 1946 $SED -n '
Chris@69 1947 /(C)/!b go
Chris@69 1948 :more
Chris@69 1949 /\./!{
Chris@69 1950 N
Chris@69 1951 s|\n# | |
Chris@69 1952 b more
Chris@69 1953 }
Chris@69 1954 :go
Chris@69 1955 /^# Written by /,/# warranty; / {
Chris@69 1956 s|^# ||
Chris@69 1957 s|^# *$||
Chris@69 1958 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
Chris@69 1959 p
Chris@69 1960 }
Chris@69 1961 /^# Written by / {
Chris@69 1962 s|^# ||
Chris@69 1963 p
Chris@69 1964 }
Chris@69 1965 /^warranty; /q' < "$progpath"
Chris@69 1966
Chris@69 1967 exit $?
Chris@69 1968 }
Chris@69 1969
Chris@69 1970
Chris@69 1971 # Local variables:
Chris@69 1972 # mode: shell-script
Chris@69 1973 # sh-indentation: 2
Chris@69 1974 # eval: (add-hook 'before-save-hook 'time-stamp)
Chris@69 1975 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
Chris@69 1976 # time-stamp-time-zone: "UTC"
Chris@69 1977 # End:
Chris@69 1978
Chris@69 1979 # Set a version string.
Chris@69 1980 scriptversion='(GNU libtool) 2.4.6'
Chris@69 1981
Chris@69 1982
Chris@69 1983 # func_echo ARG...
Chris@69 1984 # ----------------
Chris@69 1985 # Libtool also displays the current mode in messages, so override
Chris@69 1986 # funclib.sh func_echo with this custom definition.
Chris@69 1987 func_echo ()
Chris@69 1988 {
Chris@69 1989 $debug_cmd
Chris@69 1990
Chris@69 1991 _G_message=$*
Chris@69 1992
Chris@69 1993 func_echo_IFS=$IFS
Chris@69 1994 IFS=$nl
Chris@69 1995 for _G_line in $_G_message; do
Chris@69 1996 IFS=$func_echo_IFS
Chris@69 1997 $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
Chris@69 1998 done
Chris@69 1999 IFS=$func_echo_IFS
Chris@69 2000 }
Chris@69 2001
Chris@69 2002
Chris@69 2003 # func_warning ARG...
Chris@69 2004 # -------------------
Chris@69 2005 # Libtool warnings are not categorized, so override funclib.sh
Chris@69 2006 # func_warning with this simpler definition.
Chris@69 2007 func_warning ()
Chris@69 2008 {
Chris@69 2009 $debug_cmd
Chris@69 2010
Chris@69 2011 $warning_func ${1+"$@"}
Chris@69 2012 }
Chris@69 2013
Chris@69 2014
Chris@69 2015 ## ---------------- ##
Chris@69 2016 ## Options parsing. ##
Chris@69 2017 ## ---------------- ##
Chris@69 2018
Chris@69 2019 # Hook in the functions to make sure our own options are parsed during
Chris@69 2020 # the option parsing loop.
Chris@69 2021
Chris@69 2022 usage='$progpath [OPTION]... [MODE-ARG]...'
Chris@69 2023
Chris@69 2024 # Short help message in response to '-h'.
Chris@69 2025 usage_message="Options:
Chris@69 2026 --config show all configuration variables
Chris@69 2027 --debug enable verbose shell tracing
Chris@69 2028 -n, --dry-run display commands without modifying any files
Chris@69 2029 --features display basic configuration information and exit
Chris@69 2030 --mode=MODE use operation mode MODE
Chris@69 2031 --no-warnings equivalent to '-Wnone'
Chris@69 2032 --preserve-dup-deps don't remove duplicate dependency libraries
Chris@69 2033 --quiet, --silent don't print informational messages
Chris@69 2034 --tag=TAG use configuration variables from tag TAG
Chris@69 2035 -v, --verbose print more informational messages than default
Chris@69 2036 --version print version information
Chris@69 2037 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
Chris@69 2038 -h, --help, --help-all print short, long, or detailed help message
Chris@69 2039 "
Chris@69 2040
Chris@69 2041 # Additional text appended to 'usage_message' in response to '--help'.
Chris@69 2042 func_help ()
Chris@69 2043 {
Chris@69 2044 $debug_cmd
Chris@69 2045
Chris@69 2046 func_usage_message
Chris@69 2047 $ECHO "$long_help_message
Chris@69 2048
Chris@69 2049 MODE must be one of the following:
Chris@69 2050
Chris@69 2051 clean remove files from the build directory
Chris@69 2052 compile compile a source file into a libtool object
Chris@69 2053 execute automatically set library path, then run a program
Chris@69 2054 finish complete the installation of libtool libraries
Chris@69 2055 install install libraries or executables
Chris@69 2056 link create a library or an executable
Chris@69 2057 uninstall remove libraries from an installed directory
Chris@69 2058
Chris@69 2059 MODE-ARGS vary depending on the MODE. When passed as first option,
Chris@69 2060 '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
Chris@69 2061 Try '$progname --help --mode=MODE' for a more detailed description of MODE.
Chris@69 2062
Chris@69 2063 When reporting a bug, please describe a test case to reproduce it and
Chris@69 2064 include the following information:
Chris@69 2065
Chris@69 2066 host-triplet: $host
Chris@69 2067 shell: $SHELL
Chris@69 2068 compiler: $LTCC
Chris@69 2069 compiler flags: $LTCFLAGS
Chris@69 2070 linker: $LD (gnu? $with_gnu_ld)
Chris@69 2071 version: $progname (GNU libtool) 2.4.6
Chris@69 2072 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
Chris@69 2073 autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
Chris@69 2074
Chris@69 2075 Report bugs to <bug-libtool@gnu.org>.
Chris@69 2076 GNU libtool home page: <http://www.gnu.org/software/libtool/>.
Chris@69 2077 General help using GNU software: <http://www.gnu.org/gethelp/>."
Chris@69 2078 exit 0
Chris@69 2079 }
Chris@69 2080
Chris@69 2081
Chris@69 2082 # func_lo2o OBJECT-NAME
Chris@69 2083 # ---------------------
Chris@69 2084 # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
Chris@69 2085 # object suffix.
Chris@69 2086
Chris@69 2087 lo2o=s/\\.lo\$/.$objext/
Chris@69 2088 o2lo=s/\\.$objext\$/.lo/
Chris@69 2089
Chris@69 2090 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@69 2091 eval 'func_lo2o ()
Chris@69 2092 {
Chris@69 2093 case $1 in
Chris@69 2094 *.lo) func_lo2o_result=${1%.lo}.$objext ;;
Chris@69 2095 * ) func_lo2o_result=$1 ;;
Chris@69 2096 esac
Chris@69 2097 }'
Chris@69 2098
Chris@69 2099 # func_xform LIBOBJ-OR-SOURCE
Chris@69 2100 # ---------------------------
Chris@69 2101 # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
Chris@69 2102 # suffix to a '.lo' libtool-object suffix.
Chris@69 2103 eval 'func_xform ()
Chris@69 2104 {
Chris@69 2105 func_xform_result=${1%.*}.lo
Chris@69 2106 }'
Chris@69 2107 else
Chris@69 2108 # ...otherwise fall back to using sed.
Chris@69 2109 func_lo2o ()
Chris@69 2110 {
Chris@69 2111 func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
Chris@69 2112 }
Chris@69 2113
Chris@69 2114 func_xform ()
Chris@69 2115 {
Chris@69 2116 func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
Chris@69 2117 }
Chris@69 2118 fi
Chris@69 2119
Chris@69 2120
Chris@69 2121 # func_fatal_configuration ARG...
Chris@69 2122 # -------------------------------
Chris@69 2123 # Echo program name prefixed message to standard error, followed by
Chris@69 2124 # a configuration failure hint, and exit.
Chris@69 2125 func_fatal_configuration ()
Chris@69 2126 {
Chris@69 2127 func__fatal_error ${1+"$@"} \
Chris@69 2128 "See the $PACKAGE documentation for more information." \
Chris@69 2129 "Fatal configuration error."
Chris@69 2130 }
Chris@69 2131
Chris@69 2132
Chris@69 2133 # func_config
Chris@69 2134 # -----------
Chris@69 2135 # Display the configuration for all the tags in this script.
Chris@69 2136 func_config ()
Chris@69 2137 {
Chris@69 2138 re_begincf='^# ### BEGIN LIBTOOL'
Chris@69 2139 re_endcf='^# ### END LIBTOOL'
Chris@69 2140
Chris@69 2141 # Default configuration.
Chris@69 2142 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
Chris@69 2143
Chris@69 2144 # Now print the configurations for the tags.
Chris@69 2145 for tagname in $taglist; do
Chris@69 2146 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
Chris@69 2147 done
Chris@69 2148
Chris@69 2149 exit $?
Chris@69 2150 }
Chris@69 2151
Chris@69 2152
Chris@69 2153 # func_features
Chris@69 2154 # -------------
Chris@69 2155 # Display the features supported by this script.
Chris@69 2156 func_features ()
Chris@69 2157 {
Chris@69 2158 echo "host: $host"
Chris@69 2159 if test yes = "$build_libtool_libs"; then
Chris@69 2160 echo "enable shared libraries"
Chris@69 2161 else
Chris@69 2162 echo "disable shared libraries"
Chris@69 2163 fi
Chris@69 2164 if test yes = "$build_old_libs"; then
Chris@69 2165 echo "enable static libraries"
Chris@69 2166 else
Chris@69 2167 echo "disable static libraries"
Chris@69 2168 fi
Chris@69 2169
Chris@69 2170 exit $?
Chris@69 2171 }
Chris@69 2172
Chris@69 2173
Chris@69 2174 # func_enable_tag TAGNAME
Chris@69 2175 # -----------------------
Chris@69 2176 # Verify that TAGNAME is valid, and either flag an error and exit, or
Chris@69 2177 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
Chris@69 2178 # variable here.
Chris@69 2179 func_enable_tag ()
Chris@69 2180 {
Chris@69 2181 # Global variable:
Chris@69 2182 tagname=$1
Chris@69 2183
Chris@69 2184 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
Chris@69 2185 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
Chris@69 2186 sed_extractcf=/$re_begincf/,/$re_endcf/p
Chris@69 2187
Chris@69 2188 # Validate tagname.
Chris@69 2189 case $tagname in
Chris@69 2190 *[!-_A-Za-z0-9,/]*)
Chris@69 2191 func_fatal_error "invalid tag name: $tagname"
Chris@69 2192 ;;
Chris@69 2193 esac
Chris@69 2194
Chris@69 2195 # Don't test for the "default" C tag, as we know it's
Chris@69 2196 # there but not specially marked.
Chris@69 2197 case $tagname in
Chris@69 2198 CC) ;;
Chris@69 2199 *)
Chris@69 2200 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
Chris@69 2201 taglist="$taglist $tagname"
Chris@69 2202
Chris@69 2203 # Evaluate the configuration. Be careful to quote the path
Chris@69 2204 # and the sed script, to avoid splitting on whitespace, but
Chris@69 2205 # also don't use non-portable quotes within backquotes within
Chris@69 2206 # quotes we have to do it in 2 steps:
Chris@69 2207 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
Chris@69 2208 eval "$extractedcf"
Chris@69 2209 else
Chris@69 2210 func_error "ignoring unknown tag $tagname"
Chris@69 2211 fi
Chris@69 2212 ;;
Chris@69 2213 esac
Chris@69 2214 }
Chris@69 2215
Chris@69 2216
Chris@69 2217 # func_check_version_match
Chris@69 2218 # ------------------------
Chris@69 2219 # Ensure that we are using m4 macros, and libtool script from the same
Chris@69 2220 # release of libtool.
Chris@69 2221 func_check_version_match ()
Chris@69 2222 {
Chris@69 2223 if test "$package_revision" != "$macro_revision"; then
Chris@69 2224 if test "$VERSION" != "$macro_version"; then
Chris@69 2225 if test -z "$macro_version"; then
Chris@69 2226 cat >&2 <<_LT_EOF
Chris@69 2227 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
Chris@69 2228 $progname: definition of this LT_INIT comes from an older release.
Chris@69 2229 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
Chris@69 2230 $progname: and run autoconf again.
Chris@69 2231 _LT_EOF
Chris@69 2232 else
Chris@69 2233 cat >&2 <<_LT_EOF
Chris@69 2234 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
Chris@69 2235 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
Chris@69 2236 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
Chris@69 2237 $progname: and run autoconf again.
Chris@69 2238 _LT_EOF
Chris@69 2239 fi
Chris@69 2240 else
Chris@69 2241 cat >&2 <<_LT_EOF
Chris@69 2242 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
Chris@69 2243 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
Chris@69 2244 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
Chris@69 2245 $progname: of $PACKAGE $VERSION and run autoconf again.
Chris@69 2246 _LT_EOF
Chris@69 2247 fi
Chris@69 2248
Chris@69 2249 exit $EXIT_MISMATCH
Chris@69 2250 fi
Chris@69 2251 }
Chris@69 2252
Chris@69 2253
Chris@69 2254 # libtool_options_prep [ARG]...
Chris@69 2255 # -----------------------------
Chris@69 2256 # Preparation for options parsed by libtool.
Chris@69 2257 libtool_options_prep ()
Chris@69 2258 {
Chris@69 2259 $debug_mode
Chris@69 2260
Chris@69 2261 # Option defaults:
Chris@69 2262 opt_config=false
Chris@69 2263 opt_dlopen=
Chris@69 2264 opt_dry_run=false
Chris@69 2265 opt_help=false
Chris@69 2266 opt_mode=
Chris@69 2267 opt_preserve_dup_deps=false
Chris@69 2268 opt_quiet=false
Chris@69 2269
Chris@69 2270 nonopt=
Chris@69 2271 preserve_args=
Chris@69 2272
Chris@69 2273 # Shorthand for --mode=foo, only valid as the first argument
Chris@69 2274 case $1 in
Chris@69 2275 clean|clea|cle|cl)
Chris@69 2276 shift; set dummy --mode clean ${1+"$@"}; shift
Chris@69 2277 ;;
Chris@69 2278 compile|compil|compi|comp|com|co|c)
Chris@69 2279 shift; set dummy --mode compile ${1+"$@"}; shift
Chris@69 2280 ;;
Chris@69 2281 execute|execut|execu|exec|exe|ex|e)
Chris@69 2282 shift; set dummy --mode execute ${1+"$@"}; shift
Chris@69 2283 ;;
Chris@69 2284 finish|finis|fini|fin|fi|f)
Chris@69 2285 shift; set dummy --mode finish ${1+"$@"}; shift
Chris@69 2286 ;;
Chris@69 2287 install|instal|insta|inst|ins|in|i)
Chris@69 2288 shift; set dummy --mode install ${1+"$@"}; shift
Chris@69 2289 ;;
Chris@69 2290 link|lin|li|l)
Chris@69 2291 shift; set dummy --mode link ${1+"$@"}; shift
Chris@69 2292 ;;
Chris@69 2293 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
Chris@69 2294 shift; set dummy --mode uninstall ${1+"$@"}; shift
Chris@69 2295 ;;
Chris@69 2296 esac
Chris@69 2297
Chris@69 2298 # Pass back the list of options.
Chris@69 2299 func_quote_for_eval ${1+"$@"}
Chris@69 2300 libtool_options_prep_result=$func_quote_for_eval_result
Chris@69 2301 }
Chris@69 2302 func_add_hook func_options_prep libtool_options_prep
Chris@69 2303
Chris@69 2304
Chris@69 2305 # libtool_parse_options [ARG]...
Chris@69 2306 # ---------------------------------
Chris@69 2307 # Provide handling for libtool specific options.
Chris@69 2308 libtool_parse_options ()
Chris@69 2309 {
Chris@69 2310 $debug_cmd
Chris@69 2311
Chris@69 2312 # Perform our own loop to consume as many options as possible in
Chris@69 2313 # each iteration.
Chris@69 2314 while test $# -gt 0; do
Chris@69 2315 _G_opt=$1
Chris@69 2316 shift
Chris@69 2317 case $_G_opt in
Chris@69 2318 --dry-run|--dryrun|-n)
Chris@69 2319 opt_dry_run=:
Chris@69 2320 ;;
Chris@69 2321
Chris@69 2322 --config) func_config ;;
Chris@69 2323
Chris@69 2324 --dlopen|-dlopen)
Chris@69 2325 opt_dlopen="${opt_dlopen+$opt_dlopen
Chris@69 2326 }$1"
Chris@69 2327 shift
Chris@69 2328 ;;
Chris@69 2329
Chris@69 2330 --preserve-dup-deps)
Chris@69 2331 opt_preserve_dup_deps=: ;;
Chris@69 2332
Chris@69 2333 --features) func_features ;;
Chris@69 2334
Chris@69 2335 --finish) set dummy --mode finish ${1+"$@"}; shift ;;
Chris@69 2336
Chris@69 2337 --help) opt_help=: ;;
Chris@69 2338
Chris@69 2339 --help-all) opt_help=': help-all' ;;
Chris@69 2340
Chris@69 2341 --mode) test $# = 0 && func_missing_arg $_G_opt && break
Chris@69 2342 opt_mode=$1
Chris@69 2343 case $1 in
Chris@69 2344 # Valid mode arguments:
Chris@69 2345 clean|compile|execute|finish|install|link|relink|uninstall) ;;
Chris@69 2346
Chris@69 2347 # Catch anything else as an error
Chris@69 2348 *) func_error "invalid argument for $_G_opt"
Chris@69 2349 exit_cmd=exit
Chris@69 2350 break
Chris@69 2351 ;;
Chris@69 2352 esac
Chris@69 2353 shift
Chris@69 2354 ;;
Chris@69 2355
Chris@69 2356 --no-silent|--no-quiet)
Chris@69 2357 opt_quiet=false
Chris@69 2358 func_append preserve_args " $_G_opt"
Chris@69 2359 ;;
Chris@69 2360
Chris@69 2361 --no-warnings|--no-warning|--no-warn)
Chris@69 2362 opt_warning=false
Chris@69 2363 func_append preserve_args " $_G_opt"
Chris@69 2364 ;;
Chris@69 2365
Chris@69 2366 --no-verbose)
Chris@69 2367 opt_verbose=false
Chris@69 2368 func_append preserve_args " $_G_opt"
Chris@69 2369 ;;
Chris@69 2370
Chris@69 2371 --silent|--quiet)
Chris@69 2372 opt_quiet=:
Chris@69 2373 opt_verbose=false
Chris@69 2374 func_append preserve_args " $_G_opt"
Chris@69 2375 ;;
Chris@69 2376
Chris@69 2377 --tag) test $# = 0 && func_missing_arg $_G_opt && break
Chris@69 2378 opt_tag=$1
Chris@69 2379 func_append preserve_args " $_G_opt $1"
Chris@69 2380 func_enable_tag "$1"
Chris@69 2381 shift
Chris@69 2382 ;;
Chris@69 2383
Chris@69 2384 --verbose|-v) opt_quiet=false
Chris@69 2385 opt_verbose=:
Chris@69 2386 func_append preserve_args " $_G_opt"
Chris@69 2387 ;;
Chris@69 2388
Chris@69 2389 # An option not handled by this hook function:
Chris@69 2390 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
Chris@69 2391 esac
Chris@69 2392 done
Chris@69 2393
Chris@69 2394
Chris@69 2395 # save modified positional parameters for caller
Chris@69 2396 func_quote_for_eval ${1+"$@"}
Chris@69 2397 libtool_parse_options_result=$func_quote_for_eval_result
Chris@69 2398 }
Chris@69 2399 func_add_hook func_parse_options libtool_parse_options
Chris@69 2400
Chris@69 2401
Chris@69 2402
Chris@69 2403 # libtool_validate_options [ARG]...
Chris@69 2404 # ---------------------------------
Chris@69 2405 # Perform any sanity checks on option settings and/or unconsumed
Chris@69 2406 # arguments.
Chris@69 2407 libtool_validate_options ()
Chris@69 2408 {
Chris@69 2409 # save first non-option argument
Chris@69 2410 if test 0 -lt $#; then
Chris@69 2411 nonopt=$1
Chris@69 2412 shift
Chris@69 2413 fi
Chris@69 2414
Chris@69 2415 # preserve --debug
Chris@69 2416 test : = "$debug_cmd" || func_append preserve_args " --debug"
Chris@69 2417
Chris@69 2418 case $host in
Chris@69 2419 # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
Chris@69 2420 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
Chris@69 2421 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
Chris@69 2422 # don't eliminate duplications in $postdeps and $predeps
Chris@69 2423 opt_duplicate_compiler_generated_deps=:
Chris@69 2424 ;;
Chris@69 2425 *)
Chris@69 2426 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
Chris@69 2427 ;;
Chris@69 2428 esac
Chris@69 2429
Chris@69 2430 $opt_help || {
Chris@69 2431 # Sanity checks first:
Chris@69 2432 func_check_version_match
Chris@69 2433
Chris@69 2434 test yes != "$build_libtool_libs" \
Chris@69 2435 && test yes != "$build_old_libs" \
Chris@69 2436 && func_fatal_configuration "not configured to build any kind of library"
Chris@69 2437
Chris@69 2438 # Darwin sucks
Chris@69 2439 eval std_shrext=\"$shrext_cmds\"
Chris@69 2440
Chris@69 2441 # Only execute mode is allowed to have -dlopen flags.
Chris@69 2442 if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
Chris@69 2443 func_error "unrecognized option '-dlopen'"
Chris@69 2444 $ECHO "$help" 1>&2
Chris@69 2445 exit $EXIT_FAILURE
Chris@69 2446 fi
Chris@69 2447
Chris@69 2448 # Change the help message to a mode-specific one.
Chris@69 2449 generic_help=$help
Chris@69 2450 help="Try '$progname --help --mode=$opt_mode' for more information."
Chris@69 2451 }
Chris@69 2452
Chris@69 2453 # Pass back the unparsed argument list
Chris@69 2454 func_quote_for_eval ${1+"$@"}
Chris@69 2455 libtool_validate_options_result=$func_quote_for_eval_result
Chris@69 2456 }
Chris@69 2457 func_add_hook func_validate_options libtool_validate_options
Chris@69 2458
Chris@69 2459
Chris@69 2460 # Process options as early as possible so that --help and --version
Chris@69 2461 # can return quickly.
Chris@69 2462 func_options ${1+"$@"}
Chris@69 2463 eval set dummy "$func_options_result"; shift
Chris@69 2464
Chris@69 2465
Chris@69 2466
Chris@69 2467 ## ----------- ##
Chris@69 2468 ## Main. ##
Chris@69 2469 ## ----------- ##
Chris@69 2470
Chris@69 2471 magic='%%%MAGIC variable%%%'
Chris@69 2472 magic_exe='%%%MAGIC EXE variable%%%'
Chris@69 2473
Chris@69 2474 # Global variables.
Chris@69 2475 extracted_archives=
Chris@69 2476 extracted_serial=0
Chris@69 2477
Chris@69 2478 # If this variable is set in any of the actions, the command in it
Chris@69 2479 # will be execed at the end. This prevents here-documents from being
Chris@69 2480 # left over by shells.
Chris@69 2481 exec_cmd=
Chris@69 2482
Chris@69 2483
Chris@69 2484 # A function that is used when there is no print builtin or printf.
Chris@69 2485 func_fallback_echo ()
Chris@69 2486 {
Chris@69 2487 eval 'cat <<_LTECHO_EOF
Chris@69 2488 $1
Chris@69 2489 _LTECHO_EOF'
Chris@69 2490 }
Chris@69 2491
Chris@69 2492 # func_generated_by_libtool
Chris@69 2493 # True iff stdin has been generated by Libtool. This function is only
Chris@69 2494 # a basic sanity check; it will hardly flush out determined imposters.
Chris@69 2495 func_generated_by_libtool_p ()
Chris@69 2496 {
Chris@69 2497 $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
Chris@69 2498 }
Chris@69 2499
Chris@69 2500 # func_lalib_p file
Chris@69 2501 # True iff FILE is a libtool '.la' library or '.lo' object file.
Chris@69 2502 # This function is only a basic sanity check; it will hardly flush out
Chris@69 2503 # determined imposters.
Chris@69 2504 func_lalib_p ()
Chris@69 2505 {
Chris@69 2506 test -f "$1" &&
Chris@69 2507 $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
Chris@69 2508 }
Chris@69 2509
Chris@69 2510 # func_lalib_unsafe_p file
Chris@69 2511 # True iff FILE is a libtool '.la' library or '.lo' object file.
Chris@69 2512 # This function implements the same check as func_lalib_p without
Chris@69 2513 # resorting to external programs. To this end, it redirects stdin and
Chris@69 2514 # closes it afterwards, without saving the original file descriptor.
Chris@69 2515 # As a safety measure, use it only where a negative result would be
Chris@69 2516 # fatal anyway. Works if 'file' does not exist.
Chris@69 2517 func_lalib_unsafe_p ()
Chris@69 2518 {
Chris@69 2519 lalib_p=no
Chris@69 2520 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
Chris@69 2521 for lalib_p_l in 1 2 3 4
Chris@69 2522 do
Chris@69 2523 read lalib_p_line
Chris@69 2524 case $lalib_p_line in
Chris@69 2525 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
Chris@69 2526 esac
Chris@69 2527 done
Chris@69 2528 exec 0<&5 5<&-
Chris@69 2529 fi
Chris@69 2530 test yes = "$lalib_p"
Chris@69 2531 }
Chris@69 2532
Chris@69 2533 # func_ltwrapper_script_p file
Chris@69 2534 # True iff FILE is a libtool wrapper script
Chris@69 2535 # This function is only a basic sanity check; it will hardly flush out
Chris@69 2536 # determined imposters.
Chris@69 2537 func_ltwrapper_script_p ()
Chris@69 2538 {
Chris@69 2539 test -f "$1" &&
Chris@69 2540 $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
Chris@69 2541 }
Chris@69 2542
Chris@69 2543 # func_ltwrapper_executable_p file
Chris@69 2544 # True iff FILE is a libtool wrapper executable
Chris@69 2545 # This function is only a basic sanity check; it will hardly flush out
Chris@69 2546 # determined imposters.
Chris@69 2547 func_ltwrapper_executable_p ()
Chris@69 2548 {
Chris@69 2549 func_ltwrapper_exec_suffix=
Chris@69 2550 case $1 in
Chris@69 2551 *.exe) ;;
Chris@69 2552 *) func_ltwrapper_exec_suffix=.exe ;;
Chris@69 2553 esac
Chris@69 2554 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
Chris@69 2555 }
Chris@69 2556
Chris@69 2557 # func_ltwrapper_scriptname file
Chris@69 2558 # Assumes file is an ltwrapper_executable
Chris@69 2559 # uses $file to determine the appropriate filename for a
Chris@69 2560 # temporary ltwrapper_script.
Chris@69 2561 func_ltwrapper_scriptname ()
Chris@69 2562 {
Chris@69 2563 func_dirname_and_basename "$1" "" "."
Chris@69 2564 func_stripname '' '.exe' "$func_basename_result"
Chris@69 2565 func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
Chris@69 2566 }
Chris@69 2567
Chris@69 2568 # func_ltwrapper_p file
Chris@69 2569 # True iff FILE is a libtool wrapper script or wrapper executable
Chris@69 2570 # This function is only a basic sanity check; it will hardly flush out
Chris@69 2571 # determined imposters.
Chris@69 2572 func_ltwrapper_p ()
Chris@69 2573 {
Chris@69 2574 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
Chris@69 2575 }
Chris@69 2576
Chris@69 2577
Chris@69 2578 # func_execute_cmds commands fail_cmd
Chris@69 2579 # Execute tilde-delimited COMMANDS.
Chris@69 2580 # If FAIL_CMD is given, eval that upon failure.
Chris@69 2581 # FAIL_CMD may read-access the current command in variable CMD!
Chris@69 2582 func_execute_cmds ()
Chris@69 2583 {
Chris@69 2584 $debug_cmd
Chris@69 2585
Chris@69 2586 save_ifs=$IFS; IFS='~'
Chris@69 2587 for cmd in $1; do
Chris@69 2588 IFS=$sp$nl
Chris@69 2589 eval cmd=\"$cmd\"
Chris@69 2590 IFS=$save_ifs
Chris@69 2591 func_show_eval "$cmd" "${2-:}"
Chris@69 2592 done
Chris@69 2593 IFS=$save_ifs
Chris@69 2594 }
Chris@69 2595
Chris@69 2596
Chris@69 2597 # func_source file
Chris@69 2598 # Source FILE, adding directory component if necessary.
Chris@69 2599 # Note that it is not necessary on cygwin/mingw to append a dot to
Chris@69 2600 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
Chris@69 2601 # behavior happens only for exec(3), not for open(2)! Also, sourcing
Chris@69 2602 # 'FILE.' does not work on cygwin managed mounts.
Chris@69 2603 func_source ()
Chris@69 2604 {
Chris@69 2605 $debug_cmd
Chris@69 2606
Chris@69 2607 case $1 in
Chris@69 2608 */* | *\\*) . "$1" ;;
Chris@69 2609 *) . "./$1" ;;
Chris@69 2610 esac
Chris@69 2611 }
Chris@69 2612
Chris@69 2613
Chris@69 2614 # func_resolve_sysroot PATH
Chris@69 2615 # Replace a leading = in PATH with a sysroot. Store the result into
Chris@69 2616 # func_resolve_sysroot_result
Chris@69 2617 func_resolve_sysroot ()
Chris@69 2618 {
Chris@69 2619 func_resolve_sysroot_result=$1
Chris@69 2620 case $func_resolve_sysroot_result in
Chris@69 2621 =*)
Chris@69 2622 func_stripname '=' '' "$func_resolve_sysroot_result"
Chris@69 2623 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
Chris@69 2624 ;;
Chris@69 2625 esac
Chris@69 2626 }
Chris@69 2627
Chris@69 2628 # func_replace_sysroot PATH
Chris@69 2629 # If PATH begins with the sysroot, replace it with = and
Chris@69 2630 # store the result into func_replace_sysroot_result.
Chris@69 2631 func_replace_sysroot ()
Chris@69 2632 {
Chris@69 2633 case $lt_sysroot:$1 in
Chris@69 2634 ?*:"$lt_sysroot"*)
Chris@69 2635 func_stripname "$lt_sysroot" '' "$1"
Chris@69 2636 func_replace_sysroot_result='='$func_stripname_result
Chris@69 2637 ;;
Chris@69 2638 *)
Chris@69 2639 # Including no sysroot.
Chris@69 2640 func_replace_sysroot_result=$1
Chris@69 2641 ;;
Chris@69 2642 esac
Chris@69 2643 }
Chris@69 2644
Chris@69 2645 # func_infer_tag arg
Chris@69 2646 # Infer tagged configuration to use if any are available and
Chris@69 2647 # if one wasn't chosen via the "--tag" command line option.
Chris@69 2648 # Only attempt this if the compiler in the base compile
Chris@69 2649 # command doesn't match the default compiler.
Chris@69 2650 # arg is usually of the form 'gcc ...'
Chris@69 2651 func_infer_tag ()
Chris@69 2652 {
Chris@69 2653 $debug_cmd
Chris@69 2654
Chris@69 2655 if test -n "$available_tags" && test -z "$tagname"; then
Chris@69 2656 CC_quoted=
Chris@69 2657 for arg in $CC; do
Chris@69 2658 func_append_quoted CC_quoted "$arg"
Chris@69 2659 done
Chris@69 2660 CC_expanded=`func_echo_all $CC`
Chris@69 2661 CC_quoted_expanded=`func_echo_all $CC_quoted`
Chris@69 2662 case $@ in
Chris@69 2663 # Blanks in the command may have been stripped by the calling shell,
Chris@69 2664 # but not from the CC environment variable when configure was run.
Chris@69 2665 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
Chris@69 2666 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
Chris@69 2667 # Blanks at the start of $base_compile will cause this to fail
Chris@69 2668 # if we don't check for them as well.
Chris@69 2669 *)
Chris@69 2670 for z in $available_tags; do
Chris@69 2671 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
Chris@69 2672 # Evaluate the configuration.
Chris@69 2673 eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
Chris@69 2674 CC_quoted=
Chris@69 2675 for arg in $CC; do
Chris@69 2676 # Double-quote args containing other shell metacharacters.
Chris@69 2677 func_append_quoted CC_quoted "$arg"
Chris@69 2678 done
Chris@69 2679 CC_expanded=`func_echo_all $CC`
Chris@69 2680 CC_quoted_expanded=`func_echo_all $CC_quoted`
Chris@69 2681 case "$@ " in
Chris@69 2682 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
Chris@69 2683 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
Chris@69 2684 # The compiler in the base compile command matches
Chris@69 2685 # the one in the tagged configuration.
Chris@69 2686 # Assume this is the tagged configuration we want.
Chris@69 2687 tagname=$z
Chris@69 2688 break
Chris@69 2689 ;;
Chris@69 2690 esac
Chris@69 2691 fi
Chris@69 2692 done
Chris@69 2693 # If $tagname still isn't set, then no tagged configuration
Chris@69 2694 # was found and let the user know that the "--tag" command
Chris@69 2695 # line option must be used.
Chris@69 2696 if test -z "$tagname"; then
Chris@69 2697 func_echo "unable to infer tagged configuration"
Chris@69 2698 func_fatal_error "specify a tag with '--tag'"
Chris@69 2699 # else
Chris@69 2700 # func_verbose "using $tagname tagged configuration"
Chris@69 2701 fi
Chris@69 2702 ;;
Chris@69 2703 esac
Chris@69 2704 fi
Chris@69 2705 }
Chris@69 2706
Chris@69 2707
Chris@69 2708
Chris@69 2709 # func_write_libtool_object output_name pic_name nonpic_name
Chris@69 2710 # Create a libtool object file (analogous to a ".la" file),
Chris@69 2711 # but don't create it if we're doing a dry run.
Chris@69 2712 func_write_libtool_object ()
Chris@69 2713 {
Chris@69 2714 write_libobj=$1
Chris@69 2715 if test yes = "$build_libtool_libs"; then
Chris@69 2716 write_lobj=\'$2\'
Chris@69 2717 else
Chris@69 2718 write_lobj=none
Chris@69 2719 fi
Chris@69 2720
Chris@69 2721 if test yes = "$build_old_libs"; then
Chris@69 2722 write_oldobj=\'$3\'
Chris@69 2723 else
Chris@69 2724 write_oldobj=none
Chris@69 2725 fi
Chris@69 2726
Chris@69 2727 $opt_dry_run || {
Chris@69 2728 cat >${write_libobj}T <<EOF
Chris@69 2729 # $write_libobj - a libtool object file
Chris@69 2730 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@69 2731 #
Chris@69 2732 # Please DO NOT delete this file!
Chris@69 2733 # It is necessary for linking the library.
Chris@69 2734
Chris@69 2735 # Name of the PIC object.
Chris@69 2736 pic_object=$write_lobj
Chris@69 2737
Chris@69 2738 # Name of the non-PIC object
Chris@69 2739 non_pic_object=$write_oldobj
Chris@69 2740
Chris@69 2741 EOF
Chris@69 2742 $MV "${write_libobj}T" "$write_libobj"
Chris@69 2743 }
Chris@69 2744 }
Chris@69 2745
Chris@69 2746
Chris@69 2747 ##################################################
Chris@69 2748 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
Chris@69 2749 ##################################################
Chris@69 2750
Chris@69 2751 # func_convert_core_file_wine_to_w32 ARG
Chris@69 2752 # Helper function used by file name conversion functions when $build is *nix,
Chris@69 2753 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
Chris@69 2754 # correctly configured wine environment available, with the winepath program
Chris@69 2755 # in $build's $PATH.
Chris@69 2756 #
Chris@69 2757 # ARG is the $build file name to be converted to w32 format.
Chris@69 2758 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
Chris@69 2759 # be empty on error (or when ARG is empty)
Chris@69 2760 func_convert_core_file_wine_to_w32 ()
Chris@69 2761 {
Chris@69 2762 $debug_cmd
Chris@69 2763
Chris@69 2764 func_convert_core_file_wine_to_w32_result=$1
Chris@69 2765 if test -n "$1"; then
Chris@69 2766 # Unfortunately, winepath does not exit with a non-zero error code, so we
Chris@69 2767 # are forced to check the contents of stdout. On the other hand, if the
Chris@69 2768 # command is not found, the shell will set an exit code of 127 and print
Chris@69 2769 # *an error message* to stdout. So we must check for both error code of
Chris@69 2770 # zero AND non-empty stdout, which explains the odd construction:
Chris@69 2771 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
Chris@69 2772 if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
Chris@69 2773 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
Chris@69 2774 $SED -e "$sed_naive_backslashify"`
Chris@69 2775 else
Chris@69 2776 func_convert_core_file_wine_to_w32_result=
Chris@69 2777 fi
Chris@69 2778 fi
Chris@69 2779 }
Chris@69 2780 # end: func_convert_core_file_wine_to_w32
Chris@69 2781
Chris@69 2782
Chris@69 2783 # func_convert_core_path_wine_to_w32 ARG
Chris@69 2784 # Helper function used by path conversion functions when $build is *nix, and
Chris@69 2785 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
Chris@69 2786 # configured wine environment available, with the winepath program in $build's
Chris@69 2787 # $PATH. Assumes ARG has no leading or trailing path separator characters.
Chris@69 2788 #
Chris@69 2789 # ARG is path to be converted from $build format to win32.
Chris@69 2790 # Result is available in $func_convert_core_path_wine_to_w32_result.
Chris@69 2791 # Unconvertible file (directory) names in ARG are skipped; if no directory names
Chris@69 2792 # are convertible, then the result may be empty.
Chris@69 2793 func_convert_core_path_wine_to_w32 ()
Chris@69 2794 {
Chris@69 2795 $debug_cmd
Chris@69 2796
Chris@69 2797 # unfortunately, winepath doesn't convert paths, only file names
Chris@69 2798 func_convert_core_path_wine_to_w32_result=
Chris@69 2799 if test -n "$1"; then
Chris@69 2800 oldIFS=$IFS
Chris@69 2801 IFS=:
Chris@69 2802 for func_convert_core_path_wine_to_w32_f in $1; do
Chris@69 2803 IFS=$oldIFS
Chris@69 2804 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
Chris@69 2805 if test -n "$func_convert_core_file_wine_to_w32_result"; then
Chris@69 2806 if test -z "$func_convert_core_path_wine_to_w32_result"; then
Chris@69 2807 func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
Chris@69 2808 else
Chris@69 2809 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
Chris@69 2810 fi
Chris@69 2811 fi
Chris@69 2812 done
Chris@69 2813 IFS=$oldIFS
Chris@69 2814 fi
Chris@69 2815 }
Chris@69 2816 # end: func_convert_core_path_wine_to_w32
Chris@69 2817
Chris@69 2818
Chris@69 2819 # func_cygpath ARGS...
Chris@69 2820 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
Chris@69 2821 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
Chris@69 2822 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
Chris@69 2823 # (2), returns the Cygwin file name or path in func_cygpath_result (input
Chris@69 2824 # file name or path is assumed to be in w32 format, as previously converted
Chris@69 2825 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
Chris@69 2826 # or path in func_cygpath_result (input file name or path is assumed to be in
Chris@69 2827 # Cygwin format). Returns an empty string on error.
Chris@69 2828 #
Chris@69 2829 # ARGS are passed to cygpath, with the last one being the file name or path to
Chris@69 2830 # be converted.
Chris@69 2831 #
Chris@69 2832 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
Chris@69 2833 # environment variable; do not put it in $PATH.
Chris@69 2834 func_cygpath ()
Chris@69 2835 {
Chris@69 2836 $debug_cmd
Chris@69 2837
Chris@69 2838 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
Chris@69 2839 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
Chris@69 2840 if test "$?" -ne 0; then
Chris@69 2841 # on failure, ensure result is empty
Chris@69 2842 func_cygpath_result=
Chris@69 2843 fi
Chris@69 2844 else
Chris@69 2845 func_cygpath_result=
Chris@69 2846 func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
Chris@69 2847 fi
Chris@69 2848 }
Chris@69 2849 #end: func_cygpath
Chris@69 2850
Chris@69 2851
Chris@69 2852 # func_convert_core_msys_to_w32 ARG
Chris@69 2853 # Convert file name or path ARG from MSYS format to w32 format. Return
Chris@69 2854 # result in func_convert_core_msys_to_w32_result.
Chris@69 2855 func_convert_core_msys_to_w32 ()
Chris@69 2856 {
Chris@69 2857 $debug_cmd
Chris@69 2858
Chris@69 2859 # awkward: cmd appends spaces to result
Chris@69 2860 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
Chris@69 2861 $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
Chris@69 2862 }
Chris@69 2863 #end: func_convert_core_msys_to_w32
Chris@69 2864
Chris@69 2865
Chris@69 2866 # func_convert_file_check ARG1 ARG2
Chris@69 2867 # Verify that ARG1 (a file name in $build format) was converted to $host
Chris@69 2868 # format in ARG2. Otherwise, emit an error message, but continue (resetting
Chris@69 2869 # func_to_host_file_result to ARG1).
Chris@69 2870 func_convert_file_check ()
Chris@69 2871 {
Chris@69 2872 $debug_cmd
Chris@69 2873
Chris@69 2874 if test -z "$2" && test -n "$1"; then
Chris@69 2875 func_error "Could not determine host file name corresponding to"
Chris@69 2876 func_error " '$1'"
Chris@69 2877 func_error "Continuing, but uninstalled executables may not work."
Chris@69 2878 # Fallback:
Chris@69 2879 func_to_host_file_result=$1
Chris@69 2880 fi
Chris@69 2881 }
Chris@69 2882 # end func_convert_file_check
Chris@69 2883
Chris@69 2884
Chris@69 2885 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
Chris@69 2886 # Verify that FROM_PATH (a path in $build format) was converted to $host
Chris@69 2887 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
Chris@69 2888 # func_to_host_file_result to a simplistic fallback value (see below).
Chris@69 2889 func_convert_path_check ()
Chris@69 2890 {
Chris@69 2891 $debug_cmd
Chris@69 2892
Chris@69 2893 if test -z "$4" && test -n "$3"; then
Chris@69 2894 func_error "Could not determine the host path corresponding to"
Chris@69 2895 func_error " '$3'"
Chris@69 2896 func_error "Continuing, but uninstalled executables may not work."
Chris@69 2897 # Fallback. This is a deliberately simplistic "conversion" and
Chris@69 2898 # should not be "improved". See libtool.info.
Chris@69 2899 if test "x$1" != "x$2"; then
Chris@69 2900 lt_replace_pathsep_chars="s|$1|$2|g"
Chris@69 2901 func_to_host_path_result=`echo "$3" |
Chris@69 2902 $SED -e "$lt_replace_pathsep_chars"`
Chris@69 2903 else
Chris@69 2904 func_to_host_path_result=$3
Chris@69 2905 fi
Chris@69 2906 fi
Chris@69 2907 }
Chris@69 2908 # end func_convert_path_check
Chris@69 2909
Chris@69 2910
Chris@69 2911 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
Chris@69 2912 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
Chris@69 2913 # and appending REPL if ORIG matches BACKPAT.
Chris@69 2914 func_convert_path_front_back_pathsep ()
Chris@69 2915 {
Chris@69 2916 $debug_cmd
Chris@69 2917
Chris@69 2918 case $4 in
Chris@69 2919 $1 ) func_to_host_path_result=$3$func_to_host_path_result
Chris@69 2920 ;;
Chris@69 2921 esac
Chris@69 2922 case $4 in
Chris@69 2923 $2 ) func_append func_to_host_path_result "$3"
Chris@69 2924 ;;
Chris@69 2925 esac
Chris@69 2926 }
Chris@69 2927 # end func_convert_path_front_back_pathsep
Chris@69 2928
Chris@69 2929
Chris@69 2930 ##################################################
Chris@69 2931 # $build to $host FILE NAME CONVERSION FUNCTIONS #
Chris@69 2932 ##################################################
Chris@69 2933 # invoked via '$to_host_file_cmd ARG'
Chris@69 2934 #
Chris@69 2935 # In each case, ARG is the path to be converted from $build to $host format.
Chris@69 2936 # Result will be available in $func_to_host_file_result.
Chris@69 2937
Chris@69 2938
Chris@69 2939 # func_to_host_file ARG
Chris@69 2940 # Converts the file name ARG from $build format to $host format. Return result
Chris@69 2941 # in func_to_host_file_result.
Chris@69 2942 func_to_host_file ()
Chris@69 2943 {
Chris@69 2944 $debug_cmd
Chris@69 2945
Chris@69 2946 $to_host_file_cmd "$1"
Chris@69 2947 }
Chris@69 2948 # end func_to_host_file
Chris@69 2949
Chris@69 2950
Chris@69 2951 # func_to_tool_file ARG LAZY
Chris@69 2952 # converts the file name ARG from $build format to toolchain format. Return
Chris@69 2953 # result in func_to_tool_file_result. If the conversion in use is listed
Chris@69 2954 # in (the comma separated) LAZY, no conversion takes place.
Chris@69 2955 func_to_tool_file ()
Chris@69 2956 {
Chris@69 2957 $debug_cmd
Chris@69 2958
Chris@69 2959 case ,$2, in
Chris@69 2960 *,"$to_tool_file_cmd",*)
Chris@69 2961 func_to_tool_file_result=$1
Chris@69 2962 ;;
Chris@69 2963 *)
Chris@69 2964 $to_tool_file_cmd "$1"
Chris@69 2965 func_to_tool_file_result=$func_to_host_file_result
Chris@69 2966 ;;
Chris@69 2967 esac
Chris@69 2968 }
Chris@69 2969 # end func_to_tool_file
Chris@69 2970
Chris@69 2971
Chris@69 2972 # func_convert_file_noop ARG
Chris@69 2973 # Copy ARG to func_to_host_file_result.
Chris@69 2974 func_convert_file_noop ()
Chris@69 2975 {
Chris@69 2976 func_to_host_file_result=$1
Chris@69 2977 }
Chris@69 2978 # end func_convert_file_noop
Chris@69 2979
Chris@69 2980
Chris@69 2981 # func_convert_file_msys_to_w32 ARG
Chris@69 2982 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
Chris@69 2983 # conversion to w32 is not available inside the cwrapper. Returns result in
Chris@69 2984 # func_to_host_file_result.
Chris@69 2985 func_convert_file_msys_to_w32 ()
Chris@69 2986 {
Chris@69 2987 $debug_cmd
Chris@69 2988
Chris@69 2989 func_to_host_file_result=$1
Chris@69 2990 if test -n "$1"; then
Chris@69 2991 func_convert_core_msys_to_w32 "$1"
Chris@69 2992 func_to_host_file_result=$func_convert_core_msys_to_w32_result
Chris@69 2993 fi
Chris@69 2994 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@69 2995 }
Chris@69 2996 # end func_convert_file_msys_to_w32
Chris@69 2997
Chris@69 2998
Chris@69 2999 # func_convert_file_cygwin_to_w32 ARG
Chris@69 3000 # Convert file name ARG from Cygwin to w32 format. Returns result in
Chris@69 3001 # func_to_host_file_result.
Chris@69 3002 func_convert_file_cygwin_to_w32 ()
Chris@69 3003 {
Chris@69 3004 $debug_cmd
Chris@69 3005
Chris@69 3006 func_to_host_file_result=$1
Chris@69 3007 if test -n "$1"; then
Chris@69 3008 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
Chris@69 3009 # LT_CYGPATH in this case.
Chris@69 3010 func_to_host_file_result=`cygpath -m "$1"`
Chris@69 3011 fi
Chris@69 3012 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@69 3013 }
Chris@69 3014 # end func_convert_file_cygwin_to_w32
Chris@69 3015
Chris@69 3016
Chris@69 3017 # func_convert_file_nix_to_w32 ARG
Chris@69 3018 # Convert file name ARG from *nix to w32 format. Requires a wine environment
Chris@69 3019 # and a working winepath. Returns result in func_to_host_file_result.
Chris@69 3020 func_convert_file_nix_to_w32 ()
Chris@69 3021 {
Chris@69 3022 $debug_cmd
Chris@69 3023
Chris@69 3024 func_to_host_file_result=$1
Chris@69 3025 if test -n "$1"; then
Chris@69 3026 func_convert_core_file_wine_to_w32 "$1"
Chris@69 3027 func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
Chris@69 3028 fi
Chris@69 3029 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@69 3030 }
Chris@69 3031 # end func_convert_file_nix_to_w32
Chris@69 3032
Chris@69 3033
Chris@69 3034 # func_convert_file_msys_to_cygwin ARG
Chris@69 3035 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
Chris@69 3036 # Returns result in func_to_host_file_result.
Chris@69 3037 func_convert_file_msys_to_cygwin ()
Chris@69 3038 {
Chris@69 3039 $debug_cmd
Chris@69 3040
Chris@69 3041 func_to_host_file_result=$1
Chris@69 3042 if test -n "$1"; then
Chris@69 3043 func_convert_core_msys_to_w32 "$1"
Chris@69 3044 func_cygpath -u "$func_convert_core_msys_to_w32_result"
Chris@69 3045 func_to_host_file_result=$func_cygpath_result
Chris@69 3046 fi
Chris@69 3047 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@69 3048 }
Chris@69 3049 # end func_convert_file_msys_to_cygwin
Chris@69 3050
Chris@69 3051
Chris@69 3052 # func_convert_file_nix_to_cygwin ARG
Chris@69 3053 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
Chris@69 3054 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
Chris@69 3055 # in func_to_host_file_result.
Chris@69 3056 func_convert_file_nix_to_cygwin ()
Chris@69 3057 {
Chris@69 3058 $debug_cmd
Chris@69 3059
Chris@69 3060 func_to_host_file_result=$1
Chris@69 3061 if test -n "$1"; then
Chris@69 3062 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
Chris@69 3063 func_convert_core_file_wine_to_w32 "$1"
Chris@69 3064 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
Chris@69 3065 func_to_host_file_result=$func_cygpath_result
Chris@69 3066 fi
Chris@69 3067 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@69 3068 }
Chris@69 3069 # end func_convert_file_nix_to_cygwin
Chris@69 3070
Chris@69 3071
Chris@69 3072 #############################################
Chris@69 3073 # $build to $host PATH CONVERSION FUNCTIONS #
Chris@69 3074 #############################################
Chris@69 3075 # invoked via '$to_host_path_cmd ARG'
Chris@69 3076 #
Chris@69 3077 # In each case, ARG is the path to be converted from $build to $host format.
Chris@69 3078 # The result will be available in $func_to_host_path_result.
Chris@69 3079 #
Chris@69 3080 # Path separators are also converted from $build format to $host format. If
Chris@69 3081 # ARG begins or ends with a path separator character, it is preserved (but
Chris@69 3082 # converted to $host format) on output.
Chris@69 3083 #
Chris@69 3084 # All path conversion functions are named using the following convention:
Chris@69 3085 # file name conversion function : func_convert_file_X_to_Y ()
Chris@69 3086 # path conversion function : func_convert_path_X_to_Y ()
Chris@69 3087 # where, for any given $build/$host combination the 'X_to_Y' value is the
Chris@69 3088 # same. If conversion functions are added for new $build/$host combinations,
Chris@69 3089 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
Chris@69 3090 # will break.
Chris@69 3091
Chris@69 3092
Chris@69 3093 # func_init_to_host_path_cmd
Chris@69 3094 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
Chris@69 3095 # appropriate value, based on the value of $to_host_file_cmd.
Chris@69 3096 to_host_path_cmd=
Chris@69 3097 func_init_to_host_path_cmd ()
Chris@69 3098 {
Chris@69 3099 $debug_cmd
Chris@69 3100
Chris@69 3101 if test -z "$to_host_path_cmd"; then
Chris@69 3102 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
Chris@69 3103 to_host_path_cmd=func_convert_path_$func_stripname_result
Chris@69 3104 fi
Chris@69 3105 }
Chris@69 3106
Chris@69 3107
Chris@69 3108 # func_to_host_path ARG
Chris@69 3109 # Converts the path ARG from $build format to $host format. Return result
Chris@69 3110 # in func_to_host_path_result.
Chris@69 3111 func_to_host_path ()
Chris@69 3112 {
Chris@69 3113 $debug_cmd
Chris@69 3114
Chris@69 3115 func_init_to_host_path_cmd
Chris@69 3116 $to_host_path_cmd "$1"
Chris@69 3117 }
Chris@69 3118 # end func_to_host_path
Chris@69 3119
Chris@69 3120
Chris@69 3121 # func_convert_path_noop ARG
Chris@69 3122 # Copy ARG to func_to_host_path_result.
Chris@69 3123 func_convert_path_noop ()
Chris@69 3124 {
Chris@69 3125 func_to_host_path_result=$1
Chris@69 3126 }
Chris@69 3127 # end func_convert_path_noop
Chris@69 3128
Chris@69 3129
Chris@69 3130 # func_convert_path_msys_to_w32 ARG
Chris@69 3131 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
Chris@69 3132 # conversion to w32 is not available inside the cwrapper. Returns result in
Chris@69 3133 # func_to_host_path_result.
Chris@69 3134 func_convert_path_msys_to_w32 ()
Chris@69 3135 {
Chris@69 3136 $debug_cmd
Chris@69 3137
Chris@69 3138 func_to_host_path_result=$1
Chris@69 3139 if test -n "$1"; then
Chris@69 3140 # Remove leading and trailing path separator characters from ARG. MSYS
Chris@69 3141 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
Chris@69 3142 # and winepath ignores them completely.
Chris@69 3143 func_stripname : : "$1"
Chris@69 3144 func_to_host_path_tmp1=$func_stripname_result
Chris@69 3145 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
Chris@69 3146 func_to_host_path_result=$func_convert_core_msys_to_w32_result
Chris@69 3147 func_convert_path_check : ";" \
Chris@69 3148 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@69 3149 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Chris@69 3150 fi
Chris@69 3151 }
Chris@69 3152 # end func_convert_path_msys_to_w32
Chris@69 3153
Chris@69 3154
Chris@69 3155 # func_convert_path_cygwin_to_w32 ARG
Chris@69 3156 # Convert path ARG from Cygwin to w32 format. Returns result in
Chris@69 3157 # func_to_host_file_result.
Chris@69 3158 func_convert_path_cygwin_to_w32 ()
Chris@69 3159 {
Chris@69 3160 $debug_cmd
Chris@69 3161
Chris@69 3162 func_to_host_path_result=$1
Chris@69 3163 if test -n "$1"; then
Chris@69 3164 # See func_convert_path_msys_to_w32:
Chris@69 3165 func_stripname : : "$1"
Chris@69 3166 func_to_host_path_tmp1=$func_stripname_result
Chris@69 3167 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
Chris@69 3168 func_convert_path_check : ";" \
Chris@69 3169 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@69 3170 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Chris@69 3171 fi
Chris@69 3172 }
Chris@69 3173 # end func_convert_path_cygwin_to_w32
Chris@69 3174
Chris@69 3175
Chris@69 3176 # func_convert_path_nix_to_w32 ARG
Chris@69 3177 # Convert path ARG from *nix to w32 format. Requires a wine environment and
Chris@69 3178 # a working winepath. Returns result in func_to_host_file_result.
Chris@69 3179 func_convert_path_nix_to_w32 ()
Chris@69 3180 {
Chris@69 3181 $debug_cmd
Chris@69 3182
Chris@69 3183 func_to_host_path_result=$1
Chris@69 3184 if test -n "$1"; then
Chris@69 3185 # See func_convert_path_msys_to_w32:
Chris@69 3186 func_stripname : : "$1"
Chris@69 3187 func_to_host_path_tmp1=$func_stripname_result
Chris@69 3188 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
Chris@69 3189 func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
Chris@69 3190 func_convert_path_check : ";" \
Chris@69 3191 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@69 3192 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Chris@69 3193 fi
Chris@69 3194 }
Chris@69 3195 # end func_convert_path_nix_to_w32
Chris@69 3196
Chris@69 3197
Chris@69 3198 # func_convert_path_msys_to_cygwin ARG
Chris@69 3199 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
Chris@69 3200 # Returns result in func_to_host_file_result.
Chris@69 3201 func_convert_path_msys_to_cygwin ()
Chris@69 3202 {
Chris@69 3203 $debug_cmd
Chris@69 3204
Chris@69 3205 func_to_host_path_result=$1
Chris@69 3206 if test -n "$1"; then
Chris@69 3207 # See func_convert_path_msys_to_w32:
Chris@69 3208 func_stripname : : "$1"
Chris@69 3209 func_to_host_path_tmp1=$func_stripname_result
Chris@69 3210 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
Chris@69 3211 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
Chris@69 3212 func_to_host_path_result=$func_cygpath_result
Chris@69 3213 func_convert_path_check : : \
Chris@69 3214 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@69 3215 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
Chris@69 3216 fi
Chris@69 3217 }
Chris@69 3218 # end func_convert_path_msys_to_cygwin
Chris@69 3219
Chris@69 3220
Chris@69 3221 # func_convert_path_nix_to_cygwin ARG
Chris@69 3222 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
Chris@69 3223 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
Chris@69 3224 # func_to_host_file_result.
Chris@69 3225 func_convert_path_nix_to_cygwin ()
Chris@69 3226 {
Chris@69 3227 $debug_cmd
Chris@69 3228
Chris@69 3229 func_to_host_path_result=$1
Chris@69 3230 if test -n "$1"; then
Chris@69 3231 # Remove leading and trailing path separator characters from
Chris@69 3232 # ARG. msys behavior is inconsistent here, cygpath turns them
Chris@69 3233 # into '.;' and ';.', and winepath ignores them completely.
Chris@69 3234 func_stripname : : "$1"
Chris@69 3235 func_to_host_path_tmp1=$func_stripname_result
Chris@69 3236 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
Chris@69 3237 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
Chris@69 3238 func_to_host_path_result=$func_cygpath_result
Chris@69 3239 func_convert_path_check : : \
Chris@69 3240 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@69 3241 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
Chris@69 3242 fi
Chris@69 3243 }
Chris@69 3244 # end func_convert_path_nix_to_cygwin
Chris@69 3245
Chris@69 3246
Chris@69 3247 # func_dll_def_p FILE
Chris@69 3248 # True iff FILE is a Windows DLL '.def' file.
Chris@69 3249 # Keep in sync with _LT_DLL_DEF_P in libtool.m4
Chris@69 3250 func_dll_def_p ()
Chris@69 3251 {
Chris@69 3252 $debug_cmd
Chris@69 3253
Chris@69 3254 func_dll_def_p_tmp=`$SED -n \
Chris@69 3255 -e 's/^[ ]*//' \
Chris@69 3256 -e '/^\(;.*\)*$/d' \
Chris@69 3257 -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
Chris@69 3258 -e q \
Chris@69 3259 "$1"`
Chris@69 3260 test DEF = "$func_dll_def_p_tmp"
Chris@69 3261 }
Chris@69 3262
Chris@69 3263
Chris@69 3264 # func_mode_compile arg...
Chris@69 3265 func_mode_compile ()
Chris@69 3266 {
Chris@69 3267 $debug_cmd
Chris@69 3268
Chris@69 3269 # Get the compilation command and the source file.
Chris@69 3270 base_compile=
Chris@69 3271 srcfile=$nonopt # always keep a non-empty value in "srcfile"
Chris@69 3272 suppress_opt=yes
Chris@69 3273 suppress_output=
Chris@69 3274 arg_mode=normal
Chris@69 3275 libobj=
Chris@69 3276 later=
Chris@69 3277 pie_flag=
Chris@69 3278
Chris@69 3279 for arg
Chris@69 3280 do
Chris@69 3281 case $arg_mode in
Chris@69 3282 arg )
Chris@69 3283 # do not "continue". Instead, add this to base_compile
Chris@69 3284 lastarg=$arg
Chris@69 3285 arg_mode=normal
Chris@69 3286 ;;
Chris@69 3287
Chris@69 3288 target )
Chris@69 3289 libobj=$arg
Chris@69 3290 arg_mode=normal
Chris@69 3291 continue
Chris@69 3292 ;;
Chris@69 3293
Chris@69 3294 normal )
Chris@69 3295 # Accept any command-line options.
Chris@69 3296 case $arg in
Chris@69 3297 -o)
Chris@69 3298 test -n "$libobj" && \
Chris@69 3299 func_fatal_error "you cannot specify '-o' more than once"
Chris@69 3300 arg_mode=target
Chris@69 3301 continue
Chris@69 3302 ;;
Chris@69 3303
Chris@69 3304 -pie | -fpie | -fPIE)
Chris@69 3305 func_append pie_flag " $arg"
Chris@69 3306 continue
Chris@69 3307 ;;
Chris@69 3308
Chris@69 3309 -shared | -static | -prefer-pic | -prefer-non-pic)
Chris@69 3310 func_append later " $arg"
Chris@69 3311 continue
Chris@69 3312 ;;
Chris@69 3313
Chris@69 3314 -no-suppress)
Chris@69 3315 suppress_opt=no
Chris@69 3316 continue
Chris@69 3317 ;;
Chris@69 3318
Chris@69 3319 -Xcompiler)
Chris@69 3320 arg_mode=arg # the next one goes into the "base_compile" arg list
Chris@69 3321 continue # The current "srcfile" will either be retained or
Chris@69 3322 ;; # replaced later. I would guess that would be a bug.
Chris@69 3323
Chris@69 3324 -Wc,*)
Chris@69 3325 func_stripname '-Wc,' '' "$arg"
Chris@69 3326 args=$func_stripname_result
Chris@69 3327 lastarg=
Chris@69 3328 save_ifs=$IFS; IFS=,
Chris@69 3329 for arg in $args; do
Chris@69 3330 IFS=$save_ifs
Chris@69 3331 func_append_quoted lastarg "$arg"
Chris@69 3332 done
Chris@69 3333 IFS=$save_ifs
Chris@69 3334 func_stripname ' ' '' "$lastarg"
Chris@69 3335 lastarg=$func_stripname_result
Chris@69 3336
Chris@69 3337 # Add the arguments to base_compile.
Chris@69 3338 func_append base_compile " $lastarg"
Chris@69 3339 continue
Chris@69 3340 ;;
Chris@69 3341
Chris@69 3342 *)
Chris@69 3343 # Accept the current argument as the source file.
Chris@69 3344 # The previous "srcfile" becomes the current argument.
Chris@69 3345 #
Chris@69 3346 lastarg=$srcfile
Chris@69 3347 srcfile=$arg
Chris@69 3348 ;;
Chris@69 3349 esac # case $arg
Chris@69 3350 ;;
Chris@69 3351 esac # case $arg_mode
Chris@69 3352
Chris@69 3353 # Aesthetically quote the previous argument.
Chris@69 3354 func_append_quoted base_compile "$lastarg"
Chris@69 3355 done # for arg
Chris@69 3356
Chris@69 3357 case $arg_mode in
Chris@69 3358 arg)
Chris@69 3359 func_fatal_error "you must specify an argument for -Xcompile"
Chris@69 3360 ;;
Chris@69 3361 target)
Chris@69 3362 func_fatal_error "you must specify a target with '-o'"
Chris@69 3363 ;;
Chris@69 3364 *)
Chris@69 3365 # Get the name of the library object.
Chris@69 3366 test -z "$libobj" && {
Chris@69 3367 func_basename "$srcfile"
Chris@69 3368 libobj=$func_basename_result
Chris@69 3369 }
Chris@69 3370 ;;
Chris@69 3371 esac
Chris@69 3372
Chris@69 3373 # Recognize several different file suffixes.
Chris@69 3374 # If the user specifies -o file.o, it is replaced with file.lo
Chris@69 3375 case $libobj in
Chris@69 3376 *.[cCFSifmso] | \
Chris@69 3377 *.ada | *.adb | *.ads | *.asm | \
Chris@69 3378 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
Chris@69 3379 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
Chris@69 3380 func_xform "$libobj"
Chris@69 3381 libobj=$func_xform_result
Chris@69 3382 ;;
Chris@69 3383 esac
Chris@69 3384
Chris@69 3385 case $libobj in
Chris@69 3386 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
Chris@69 3387 *)
Chris@69 3388 func_fatal_error "cannot determine name of library object from '$libobj'"
Chris@69 3389 ;;
Chris@69 3390 esac
Chris@69 3391
Chris@69 3392 func_infer_tag $base_compile
Chris@69 3393
Chris@69 3394 for arg in $later; do
Chris@69 3395 case $arg in
Chris@69 3396 -shared)
Chris@69 3397 test yes = "$build_libtool_libs" \
Chris@69 3398 || func_fatal_configuration "cannot build a shared library"
Chris@69 3399 build_old_libs=no
Chris@69 3400 continue
Chris@69 3401 ;;
Chris@69 3402
Chris@69 3403 -static)
Chris@69 3404 build_libtool_libs=no
Chris@69 3405 build_old_libs=yes
Chris@69 3406 continue
Chris@69 3407 ;;
Chris@69 3408
Chris@69 3409 -prefer-pic)
Chris@69 3410 pic_mode=yes
Chris@69 3411 continue
Chris@69 3412 ;;
Chris@69 3413
Chris@69 3414 -prefer-non-pic)
Chris@69 3415 pic_mode=no
Chris@69 3416 continue
Chris@69 3417 ;;
Chris@69 3418 esac
Chris@69 3419 done
Chris@69 3420
Chris@69 3421 func_quote_for_eval "$libobj"
Chris@69 3422 test "X$libobj" != "X$func_quote_for_eval_result" \
Chris@69 3423 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
Chris@69 3424 && func_warning "libobj name '$libobj' may not contain shell special characters."
Chris@69 3425 func_dirname_and_basename "$obj" "/" ""
Chris@69 3426 objname=$func_basename_result
Chris@69 3427 xdir=$func_dirname_result
Chris@69 3428 lobj=$xdir$objdir/$objname
Chris@69 3429
Chris@69 3430 test -z "$base_compile" && \
Chris@69 3431 func_fatal_help "you must specify a compilation command"
Chris@69 3432
Chris@69 3433 # Delete any leftover library objects.
Chris@69 3434 if test yes = "$build_old_libs"; then
Chris@69 3435 removelist="$obj $lobj $libobj ${libobj}T"
Chris@69 3436 else
Chris@69 3437 removelist="$lobj $libobj ${libobj}T"
Chris@69 3438 fi
Chris@69 3439
Chris@69 3440 # On Cygwin there's no "real" PIC flag so we must build both object types
Chris@69 3441 case $host_os in
Chris@69 3442 cygwin* | mingw* | pw32* | os2* | cegcc*)
Chris@69 3443 pic_mode=default
Chris@69 3444 ;;
Chris@69 3445 esac
Chris@69 3446 if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
Chris@69 3447 # non-PIC code in shared libraries is not supported
Chris@69 3448 pic_mode=default
Chris@69 3449 fi
Chris@69 3450
Chris@69 3451 # Calculate the filename of the output object if compiler does
Chris@69 3452 # not support -o with -c
Chris@69 3453 if test no = "$compiler_c_o"; then
Chris@69 3454 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
Chris@69 3455 lockfile=$output_obj.lock
Chris@69 3456 else
Chris@69 3457 output_obj=
Chris@69 3458 need_locks=no
Chris@69 3459 lockfile=
Chris@69 3460 fi
Chris@69 3461
Chris@69 3462 # Lock this critical section if it is needed
Chris@69 3463 # We use this script file to make the link, it avoids creating a new file
Chris@69 3464 if test yes = "$need_locks"; then
Chris@69 3465 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
Chris@69 3466 func_echo "Waiting for $lockfile to be removed"
Chris@69 3467 sleep 2
Chris@69 3468 done
Chris@69 3469 elif test warn = "$need_locks"; then
Chris@69 3470 if test -f "$lockfile"; then
Chris@69 3471 $ECHO "\
Chris@69 3472 *** ERROR, $lockfile exists and contains:
Chris@69 3473 `cat $lockfile 2>/dev/null`
Chris@69 3474
Chris@69 3475 This indicates that another process is trying to use the same
Chris@69 3476 temporary object file, and libtool could not work around it because
Chris@69 3477 your compiler does not support '-c' and '-o' together. If you
Chris@69 3478 repeat this compilation, it may succeed, by chance, but you had better
Chris@69 3479 avoid parallel builds (make -j) in this platform, or get a better
Chris@69 3480 compiler."
Chris@69 3481
Chris@69 3482 $opt_dry_run || $RM $removelist
Chris@69 3483 exit $EXIT_FAILURE
Chris@69 3484 fi
Chris@69 3485 func_append removelist " $output_obj"
Chris@69 3486 $ECHO "$srcfile" > "$lockfile"
Chris@69 3487 fi
Chris@69 3488
Chris@69 3489 $opt_dry_run || $RM $removelist
Chris@69 3490 func_append removelist " $lockfile"
Chris@69 3491 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
Chris@69 3492
Chris@69 3493 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
Chris@69 3494 srcfile=$func_to_tool_file_result
Chris@69 3495 func_quote_for_eval "$srcfile"
Chris@69 3496 qsrcfile=$func_quote_for_eval_result
Chris@69 3497
Chris@69 3498 # Only build a PIC object if we are building libtool libraries.
Chris@69 3499 if test yes = "$build_libtool_libs"; then
Chris@69 3500 # Without this assignment, base_compile gets emptied.
Chris@69 3501 fbsd_hideous_sh_bug=$base_compile
Chris@69 3502
Chris@69 3503 if test no != "$pic_mode"; then
Chris@69 3504 command="$base_compile $qsrcfile $pic_flag"
Chris@69 3505 else
Chris@69 3506 # Don't build PIC code
Chris@69 3507 command="$base_compile $qsrcfile"
Chris@69 3508 fi
Chris@69 3509
Chris@69 3510 func_mkdir_p "$xdir$objdir"
Chris@69 3511
Chris@69 3512 if test -z "$output_obj"; then
Chris@69 3513 # Place PIC objects in $objdir
Chris@69 3514 func_append command " -o $lobj"
Chris@69 3515 fi
Chris@69 3516
Chris@69 3517 func_show_eval_locale "$command" \
Chris@69 3518 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
Chris@69 3519
Chris@69 3520 if test warn = "$need_locks" &&
Chris@69 3521 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
Chris@69 3522 $ECHO "\
Chris@69 3523 *** ERROR, $lockfile contains:
Chris@69 3524 `cat $lockfile 2>/dev/null`
Chris@69 3525
Chris@69 3526 but it should contain:
Chris@69 3527 $srcfile
Chris@69 3528
Chris@69 3529 This indicates that another process is trying to use the same
Chris@69 3530 temporary object file, and libtool could not work around it because
Chris@69 3531 your compiler does not support '-c' and '-o' together. If you
Chris@69 3532 repeat this compilation, it may succeed, by chance, but you had better
Chris@69 3533 avoid parallel builds (make -j) in this platform, or get a better
Chris@69 3534 compiler."
Chris@69 3535
Chris@69 3536 $opt_dry_run || $RM $removelist
Chris@69 3537 exit $EXIT_FAILURE
Chris@69 3538 fi
Chris@69 3539
Chris@69 3540 # Just move the object if needed, then go on to compile the next one
Chris@69 3541 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
Chris@69 3542 func_show_eval '$MV "$output_obj" "$lobj"' \
Chris@69 3543 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
Chris@69 3544 fi
Chris@69 3545
Chris@69 3546 # Allow error messages only from the first compilation.
Chris@69 3547 if test yes = "$suppress_opt"; then
Chris@69 3548 suppress_output=' >/dev/null 2>&1'
Chris@69 3549 fi
Chris@69 3550 fi
Chris@69 3551
Chris@69 3552 # Only build a position-dependent object if we build old libraries.
Chris@69 3553 if test yes = "$build_old_libs"; then
Chris@69 3554 if test yes != "$pic_mode"; then
Chris@69 3555 # Don't build PIC code
Chris@69 3556 command="$base_compile $qsrcfile$pie_flag"
Chris@69 3557 else
Chris@69 3558 command="$base_compile $qsrcfile $pic_flag"
Chris@69 3559 fi
Chris@69 3560 if test yes = "$compiler_c_o"; then
Chris@69 3561 func_append command " -o $obj"
Chris@69 3562 fi
Chris@69 3563
Chris@69 3564 # Suppress compiler output if we already did a PIC compilation.
Chris@69 3565 func_append command "$suppress_output"
Chris@69 3566 func_show_eval_locale "$command" \
Chris@69 3567 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
Chris@69 3568
Chris@69 3569 if test warn = "$need_locks" &&
Chris@69 3570 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
Chris@69 3571 $ECHO "\
Chris@69 3572 *** ERROR, $lockfile contains:
Chris@69 3573 `cat $lockfile 2>/dev/null`
Chris@69 3574
Chris@69 3575 but it should contain:
Chris@69 3576 $srcfile
Chris@69 3577
Chris@69 3578 This indicates that another process is trying to use the same
Chris@69 3579 temporary object file, and libtool could not work around it because
Chris@69 3580 your compiler does not support '-c' and '-o' together. If you
Chris@69 3581 repeat this compilation, it may succeed, by chance, but you had better
Chris@69 3582 avoid parallel builds (make -j) in this platform, or get a better
Chris@69 3583 compiler."
Chris@69 3584
Chris@69 3585 $opt_dry_run || $RM $removelist
Chris@69 3586 exit $EXIT_FAILURE
Chris@69 3587 fi
Chris@69 3588
Chris@69 3589 # Just move the object if needed
Chris@69 3590 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
Chris@69 3591 func_show_eval '$MV "$output_obj" "$obj"' \
Chris@69 3592 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
Chris@69 3593 fi
Chris@69 3594 fi
Chris@69 3595
Chris@69 3596 $opt_dry_run || {
Chris@69 3597 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
Chris@69 3598
Chris@69 3599 # Unlock the critical section if it was locked
Chris@69 3600 if test no != "$need_locks"; then
Chris@69 3601 removelist=$lockfile
Chris@69 3602 $RM "$lockfile"
Chris@69 3603 fi
Chris@69 3604 }
Chris@69 3605
Chris@69 3606 exit $EXIT_SUCCESS
Chris@69 3607 }
Chris@69 3608
Chris@69 3609 $opt_help || {
Chris@69 3610 test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
Chris@69 3611 }
Chris@69 3612
Chris@69 3613 func_mode_help ()
Chris@69 3614 {
Chris@69 3615 # We need to display help for each of the modes.
Chris@69 3616 case $opt_mode in
Chris@69 3617 "")
Chris@69 3618 # Generic help is extracted from the usage comments
Chris@69 3619 # at the start of this file.
Chris@69 3620 func_help
Chris@69 3621 ;;
Chris@69 3622
Chris@69 3623 clean)
Chris@69 3624 $ECHO \
Chris@69 3625 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
Chris@69 3626
Chris@69 3627 Remove files from the build directory.
Chris@69 3628
Chris@69 3629 RM is the name of the program to use to delete files associated with each FILE
Chris@69 3630 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
Chris@69 3631 to RM.
Chris@69 3632
Chris@69 3633 If FILE is a libtool library, object or program, all the files associated
Chris@69 3634 with it are deleted. Otherwise, only FILE itself is deleted using RM."
Chris@69 3635 ;;
Chris@69 3636
Chris@69 3637 compile)
Chris@69 3638 $ECHO \
Chris@69 3639 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
Chris@69 3640
Chris@69 3641 Compile a source file into a libtool library object.
Chris@69 3642
Chris@69 3643 This mode accepts the following additional options:
Chris@69 3644
Chris@69 3645 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
Chris@69 3646 -no-suppress do not suppress compiler output for multiple passes
Chris@69 3647 -prefer-pic try to build PIC objects only
Chris@69 3648 -prefer-non-pic try to build non-PIC objects only
Chris@69 3649 -shared do not build a '.o' file suitable for static linking
Chris@69 3650 -static only build a '.o' file suitable for static linking
Chris@69 3651 -Wc,FLAG pass FLAG directly to the compiler
Chris@69 3652
Chris@69 3653 COMPILE-COMMAND is a command to be used in creating a 'standard' object file
Chris@69 3654 from the given SOURCEFILE.
Chris@69 3655
Chris@69 3656 The output file name is determined by removing the directory component from
Chris@69 3657 SOURCEFILE, then substituting the C source code suffix '.c' with the
Chris@69 3658 library object suffix, '.lo'."
Chris@69 3659 ;;
Chris@69 3660
Chris@69 3661 execute)
Chris@69 3662 $ECHO \
Chris@69 3663 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
Chris@69 3664
Chris@69 3665 Automatically set library path, then run a program.
Chris@69 3666
Chris@69 3667 This mode accepts the following additional options:
Chris@69 3668
Chris@69 3669 -dlopen FILE add the directory containing FILE to the library path
Chris@69 3670
Chris@69 3671 This mode sets the library path environment variable according to '-dlopen'
Chris@69 3672 flags.
Chris@69 3673
Chris@69 3674 If any of the ARGS are libtool executable wrappers, then they are translated
Chris@69 3675 into their corresponding uninstalled binary, and any of their required library
Chris@69 3676 directories are added to the library path.
Chris@69 3677
Chris@69 3678 Then, COMMAND is executed, with ARGS as arguments."
Chris@69 3679 ;;
Chris@69 3680
Chris@69 3681 finish)
Chris@69 3682 $ECHO \
Chris@69 3683 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
Chris@69 3684
Chris@69 3685 Complete the installation of libtool libraries.
Chris@69 3686
Chris@69 3687 Each LIBDIR is a directory that contains libtool libraries.
Chris@69 3688
Chris@69 3689 The commands that this mode executes may require superuser privileges. Use
Chris@69 3690 the '--dry-run' option if you just want to see what would be executed."
Chris@69 3691 ;;
Chris@69 3692
Chris@69 3693 install)
Chris@69 3694 $ECHO \
Chris@69 3695 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
Chris@69 3696
Chris@69 3697 Install executables or libraries.
Chris@69 3698
Chris@69 3699 INSTALL-COMMAND is the installation command. The first component should be
Chris@69 3700 either the 'install' or 'cp' program.
Chris@69 3701
Chris@69 3702 The following components of INSTALL-COMMAND are treated specially:
Chris@69 3703
Chris@69 3704 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
Chris@69 3705
Chris@69 3706 The rest of the components are interpreted as arguments to that command (only
Chris@69 3707 BSD-compatible install options are recognized)."
Chris@69 3708 ;;
Chris@69 3709
Chris@69 3710 link)
Chris@69 3711 $ECHO \
Chris@69 3712 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
Chris@69 3713
Chris@69 3714 Link object files or libraries together to form another library, or to
Chris@69 3715 create an executable program.
Chris@69 3716
Chris@69 3717 LINK-COMMAND is a command using the C compiler that you would use to create
Chris@69 3718 a program from several object files.
Chris@69 3719
Chris@69 3720 The following components of LINK-COMMAND are treated specially:
Chris@69 3721
Chris@69 3722 -all-static do not do any dynamic linking at all
Chris@69 3723 -avoid-version do not add a version suffix if possible
Chris@69 3724 -bindir BINDIR specify path to binaries directory (for systems where
Chris@69 3725 libraries must be found in the PATH setting at runtime)
Chris@69 3726 -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
Chris@69 3727 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
Chris@69 3728 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
Chris@69 3729 -export-symbols SYMFILE
Chris@69 3730 try to export only the symbols listed in SYMFILE
Chris@69 3731 -export-symbols-regex REGEX
Chris@69 3732 try to export only the symbols matching REGEX
Chris@69 3733 -LLIBDIR search LIBDIR for required installed libraries
Chris@69 3734 -lNAME OUTPUT-FILE requires the installed library libNAME
Chris@69 3735 -module build a library that can dlopened
Chris@69 3736 -no-fast-install disable the fast-install mode
Chris@69 3737 -no-install link a not-installable executable
Chris@69 3738 -no-undefined declare that a library does not refer to external symbols
Chris@69 3739 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
Chris@69 3740 -objectlist FILE use a list of object files found in FILE to specify objects
Chris@69 3741 -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
Chris@69 3742 -precious-files-regex REGEX
Chris@69 3743 don't remove output files matching REGEX
Chris@69 3744 -release RELEASE specify package release information
Chris@69 3745 -rpath LIBDIR the created library will eventually be installed in LIBDIR
Chris@69 3746 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
Chris@69 3747 -shared only do dynamic linking of libtool libraries
Chris@69 3748 -shrext SUFFIX override the standard shared library file extension
Chris@69 3749 -static do not do any dynamic linking of uninstalled libtool libraries
Chris@69 3750 -static-libtool-libs
Chris@69 3751 do not do any dynamic linking of libtool libraries
Chris@69 3752 -version-info CURRENT[:REVISION[:AGE]]
Chris@69 3753 specify library version info [each variable defaults to 0]
Chris@69 3754 -weak LIBNAME declare that the target provides the LIBNAME interface
Chris@69 3755 -Wc,FLAG
Chris@69 3756 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
Chris@69 3757 -Wl,FLAG
Chris@69 3758 -Xlinker FLAG pass linker-specific FLAG directly to the linker
Chris@69 3759 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
Chris@69 3760
Chris@69 3761 All other options (arguments beginning with '-') are ignored.
Chris@69 3762
Chris@69 3763 Every other argument is treated as a filename. Files ending in '.la' are
Chris@69 3764 treated as uninstalled libtool libraries, other files are standard or library
Chris@69 3765 object files.
Chris@69 3766
Chris@69 3767 If the OUTPUT-FILE ends in '.la', then a libtool library is created,
Chris@69 3768 only library objects ('.lo' files) may be specified, and '-rpath' is
Chris@69 3769 required, except when creating a convenience library.
Chris@69 3770
Chris@69 3771 If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
Chris@69 3772 using 'ar' and 'ranlib', or on Windows using 'lib'.
Chris@69 3773
Chris@69 3774 If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
Chris@69 3775 is created, otherwise an executable program is created."
Chris@69 3776 ;;
Chris@69 3777
Chris@69 3778 uninstall)
Chris@69 3779 $ECHO \
Chris@69 3780 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
Chris@69 3781
Chris@69 3782 Remove libraries from an installation directory.
Chris@69 3783
Chris@69 3784 RM is the name of the program to use to delete files associated with each FILE
Chris@69 3785 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
Chris@69 3786 to RM.
Chris@69 3787
Chris@69 3788 If FILE is a libtool library, all the files associated with it are deleted.
Chris@69 3789 Otherwise, only FILE itself is deleted using RM."
Chris@69 3790 ;;
Chris@69 3791
Chris@69 3792 *)
Chris@69 3793 func_fatal_help "invalid operation mode '$opt_mode'"
Chris@69 3794 ;;
Chris@69 3795 esac
Chris@69 3796
Chris@69 3797 echo
Chris@69 3798 $ECHO "Try '$progname --help' for more information about other modes."
Chris@69 3799 }
Chris@69 3800
Chris@69 3801 # Now that we've collected a possible --mode arg, show help if necessary
Chris@69 3802 if $opt_help; then
Chris@69 3803 if test : = "$opt_help"; then
Chris@69 3804 func_mode_help
Chris@69 3805 else
Chris@69 3806 {
Chris@69 3807 func_help noexit
Chris@69 3808 for opt_mode in compile link execute install finish uninstall clean; do
Chris@69 3809 func_mode_help
Chris@69 3810 done
Chris@69 3811 } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
Chris@69 3812 {
Chris@69 3813 func_help noexit
Chris@69 3814 for opt_mode in compile link execute install finish uninstall clean; do
Chris@69 3815 echo
Chris@69 3816 func_mode_help
Chris@69 3817 done
Chris@69 3818 } |
Chris@69 3819 $SED '1d
Chris@69 3820 /^When reporting/,/^Report/{
Chris@69 3821 H
Chris@69 3822 d
Chris@69 3823 }
Chris@69 3824 $x
Chris@69 3825 /information about other modes/d
Chris@69 3826 /more detailed .*MODE/d
Chris@69 3827 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
Chris@69 3828 fi
Chris@69 3829 exit $?
Chris@69 3830 fi
Chris@69 3831
Chris@69 3832
Chris@69 3833 # func_mode_execute arg...
Chris@69 3834 func_mode_execute ()
Chris@69 3835 {
Chris@69 3836 $debug_cmd
Chris@69 3837
Chris@69 3838 # The first argument is the command name.
Chris@69 3839 cmd=$nonopt
Chris@69 3840 test -z "$cmd" && \
Chris@69 3841 func_fatal_help "you must specify a COMMAND"
Chris@69 3842
Chris@69 3843 # Handle -dlopen flags immediately.
Chris@69 3844 for file in $opt_dlopen; do
Chris@69 3845 test -f "$file" \
Chris@69 3846 || func_fatal_help "'$file' is not a file"
Chris@69 3847
Chris@69 3848 dir=
Chris@69 3849 case $file in
Chris@69 3850 *.la)
Chris@69 3851 func_resolve_sysroot "$file"
Chris@69 3852 file=$func_resolve_sysroot_result
Chris@69 3853
Chris@69 3854 # Check to see that this really is a libtool archive.
Chris@69 3855 func_lalib_unsafe_p "$file" \
Chris@69 3856 || func_fatal_help "'$lib' is not a valid libtool archive"
Chris@69 3857
Chris@69 3858 # Read the libtool library.
Chris@69 3859 dlname=
Chris@69 3860 library_names=
Chris@69 3861 func_source "$file"
Chris@69 3862
Chris@69 3863 # Skip this library if it cannot be dlopened.
Chris@69 3864 if test -z "$dlname"; then
Chris@69 3865 # Warn if it was a shared library.
Chris@69 3866 test -n "$library_names" && \
Chris@69 3867 func_warning "'$file' was not linked with '-export-dynamic'"
Chris@69 3868 continue
Chris@69 3869 fi
Chris@69 3870
Chris@69 3871 func_dirname "$file" "" "."
Chris@69 3872 dir=$func_dirname_result
Chris@69 3873
Chris@69 3874 if test -f "$dir/$objdir/$dlname"; then
Chris@69 3875 func_append dir "/$objdir"
Chris@69 3876 else
Chris@69 3877 if test ! -f "$dir/$dlname"; then
Chris@69 3878 func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
Chris@69 3879 fi
Chris@69 3880 fi
Chris@69 3881 ;;
Chris@69 3882
Chris@69 3883 *.lo)
Chris@69 3884 # Just add the directory containing the .lo file.
Chris@69 3885 func_dirname "$file" "" "."
Chris@69 3886 dir=$func_dirname_result
Chris@69 3887 ;;
Chris@69 3888
Chris@69 3889 *)
Chris@69 3890 func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
Chris@69 3891 continue
Chris@69 3892 ;;
Chris@69 3893 esac
Chris@69 3894
Chris@69 3895 # Get the absolute pathname.
Chris@69 3896 absdir=`cd "$dir" && pwd`
Chris@69 3897 test -n "$absdir" && dir=$absdir
Chris@69 3898
Chris@69 3899 # Now add the directory to shlibpath_var.
Chris@69 3900 if eval "test -z \"\$$shlibpath_var\""; then
Chris@69 3901 eval "$shlibpath_var=\"\$dir\""
Chris@69 3902 else
Chris@69 3903 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
Chris@69 3904 fi
Chris@69 3905 done
Chris@69 3906
Chris@69 3907 # This variable tells wrapper scripts just to set shlibpath_var
Chris@69 3908 # rather than running their programs.
Chris@69 3909 libtool_execute_magic=$magic
Chris@69 3910
Chris@69 3911 # Check if any of the arguments is a wrapper script.
Chris@69 3912 args=
Chris@69 3913 for file
Chris@69 3914 do
Chris@69 3915 case $file in
Chris@69 3916 -* | *.la | *.lo ) ;;
Chris@69 3917 *)
Chris@69 3918 # Do a test to see if this is really a libtool program.
Chris@69 3919 if func_ltwrapper_script_p "$file"; then
Chris@69 3920 func_source "$file"
Chris@69 3921 # Transform arg to wrapped name.
Chris@69 3922 file=$progdir/$program
Chris@69 3923 elif func_ltwrapper_executable_p "$file"; then
Chris@69 3924 func_ltwrapper_scriptname "$file"
Chris@69 3925 func_source "$func_ltwrapper_scriptname_result"
Chris@69 3926 # Transform arg to wrapped name.
Chris@69 3927 file=$progdir/$program
Chris@69 3928 fi
Chris@69 3929 ;;
Chris@69 3930 esac
Chris@69 3931 # Quote arguments (to preserve shell metacharacters).
Chris@69 3932 func_append_quoted args "$file"
Chris@69 3933 done
Chris@69 3934
Chris@69 3935 if $opt_dry_run; then
Chris@69 3936 # Display what would be done.
Chris@69 3937 if test -n "$shlibpath_var"; then
Chris@69 3938 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
Chris@69 3939 echo "export $shlibpath_var"
Chris@69 3940 fi
Chris@69 3941 $ECHO "$cmd$args"
Chris@69 3942 exit $EXIT_SUCCESS
Chris@69 3943 else
Chris@69 3944 if test -n "$shlibpath_var"; then
Chris@69 3945 # Export the shlibpath_var.
Chris@69 3946 eval "export $shlibpath_var"
Chris@69 3947 fi
Chris@69 3948
Chris@69 3949 # Restore saved environment variables
Chris@69 3950 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
Chris@69 3951 do
Chris@69 3952 eval "if test \"\${save_$lt_var+set}\" = set; then
Chris@69 3953 $lt_var=\$save_$lt_var; export $lt_var
Chris@69 3954 else
Chris@69 3955 $lt_unset $lt_var
Chris@69 3956 fi"
Chris@69 3957 done
Chris@69 3958
Chris@69 3959 # Now prepare to actually exec the command.
Chris@69 3960 exec_cmd=\$cmd$args
Chris@69 3961 fi
Chris@69 3962 }
Chris@69 3963
Chris@69 3964 test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
Chris@69 3965
Chris@69 3966
Chris@69 3967 # func_mode_finish arg...
Chris@69 3968 func_mode_finish ()
Chris@69 3969 {
Chris@69 3970 $debug_cmd
Chris@69 3971
Chris@69 3972 libs=
Chris@69 3973 libdirs=
Chris@69 3974 admincmds=
Chris@69 3975
Chris@69 3976 for opt in "$nonopt" ${1+"$@"}
Chris@69 3977 do
Chris@69 3978 if test -d "$opt"; then
Chris@69 3979 func_append libdirs " $opt"
Chris@69 3980
Chris@69 3981 elif test -f "$opt"; then
Chris@69 3982 if func_lalib_unsafe_p "$opt"; then
Chris@69 3983 func_append libs " $opt"
Chris@69 3984 else
Chris@69 3985 func_warning "'$opt' is not a valid libtool archive"
Chris@69 3986 fi
Chris@69 3987
Chris@69 3988 else
Chris@69 3989 func_fatal_error "invalid argument '$opt'"
Chris@69 3990 fi
Chris@69 3991 done
Chris@69 3992
Chris@69 3993 if test -n "$libs"; then
Chris@69 3994 if test -n "$lt_sysroot"; then
Chris@69 3995 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
Chris@69 3996 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
Chris@69 3997 else
Chris@69 3998 sysroot_cmd=
Chris@69 3999 fi
Chris@69 4000
Chris@69 4001 # Remove sysroot references
Chris@69 4002 if $opt_dry_run; then
Chris@69 4003 for lib in $libs; do
Chris@69 4004 echo "removing references to $lt_sysroot and '=' prefixes from $lib"
Chris@69 4005 done
Chris@69 4006 else
Chris@69 4007 tmpdir=`func_mktempdir`
Chris@69 4008 for lib in $libs; do
Chris@69 4009 $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
Chris@69 4010 > $tmpdir/tmp-la
Chris@69 4011 mv -f $tmpdir/tmp-la $lib
Chris@69 4012 done
Chris@69 4013 ${RM}r "$tmpdir"
Chris@69 4014 fi
Chris@69 4015 fi
Chris@69 4016
Chris@69 4017 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
Chris@69 4018 for libdir in $libdirs; do
Chris@69 4019 if test -n "$finish_cmds"; then
Chris@69 4020 # Do each command in the finish commands.
Chris@69 4021 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
Chris@69 4022 '"$cmd"'"'
Chris@69 4023 fi
Chris@69 4024 if test -n "$finish_eval"; then
Chris@69 4025 # Do the single finish_eval.
Chris@69 4026 eval cmds=\"$finish_eval\"
Chris@69 4027 $opt_dry_run || eval "$cmds" || func_append admincmds "
Chris@69 4028 $cmds"
Chris@69 4029 fi
Chris@69 4030 done
Chris@69 4031 fi
Chris@69 4032
Chris@69 4033 # Exit here if they wanted silent mode.
Chris@69 4034 $opt_quiet && exit $EXIT_SUCCESS
Chris@69 4035
Chris@69 4036 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
Chris@69 4037 echo "----------------------------------------------------------------------"
Chris@69 4038 echo "Libraries have been installed in:"
Chris@69 4039 for libdir in $libdirs; do
Chris@69 4040 $ECHO " $libdir"
Chris@69 4041 done
Chris@69 4042 echo
Chris@69 4043 echo "If you ever happen to want to link against installed libraries"
Chris@69 4044 echo "in a given directory, LIBDIR, you must either use libtool, and"
Chris@69 4045 echo "specify the full pathname of the library, or use the '-LLIBDIR'"
Chris@69 4046 echo "flag during linking and do at least one of the following:"
Chris@69 4047 if test -n "$shlibpath_var"; then
Chris@69 4048 echo " - add LIBDIR to the '$shlibpath_var' environment variable"
Chris@69 4049 echo " during execution"
Chris@69 4050 fi
Chris@69 4051 if test -n "$runpath_var"; then
Chris@69 4052 echo " - add LIBDIR to the '$runpath_var' environment variable"
Chris@69 4053 echo " during linking"
Chris@69 4054 fi
Chris@69 4055 if test -n "$hardcode_libdir_flag_spec"; then
Chris@69 4056 libdir=LIBDIR
Chris@69 4057 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@69 4058
Chris@69 4059 $ECHO " - use the '$flag' linker flag"
Chris@69 4060 fi
Chris@69 4061 if test -n "$admincmds"; then
Chris@69 4062 $ECHO " - have your system administrator run these commands:$admincmds"
Chris@69 4063 fi
Chris@69 4064 if test -f /etc/ld.so.conf; then
Chris@69 4065 echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
Chris@69 4066 fi
Chris@69 4067 echo
Chris@69 4068
Chris@69 4069 echo "See any operating system documentation about shared libraries for"
Chris@69 4070 case $host in
Chris@69 4071 solaris2.[6789]|solaris2.1[0-9])
Chris@69 4072 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
Chris@69 4073 echo "pages."
Chris@69 4074 ;;
Chris@69 4075 *)
Chris@69 4076 echo "more information, such as the ld(1) and ld.so(8) manual pages."
Chris@69 4077 ;;
Chris@69 4078 esac
Chris@69 4079 echo "----------------------------------------------------------------------"
Chris@69 4080 fi
Chris@69 4081 exit $EXIT_SUCCESS
Chris@69 4082 }
Chris@69 4083
Chris@69 4084 test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
Chris@69 4085
Chris@69 4086
Chris@69 4087 # func_mode_install arg...
Chris@69 4088 func_mode_install ()
Chris@69 4089 {
Chris@69 4090 $debug_cmd
Chris@69 4091
Chris@69 4092 # There may be an optional sh(1) argument at the beginning of
Chris@69 4093 # install_prog (especially on Windows NT).
Chris@69 4094 if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
Chris@69 4095 # Allow the use of GNU shtool's install command.
Chris@69 4096 case $nonopt in *shtool*) :;; *) false;; esac
Chris@69 4097 then
Chris@69 4098 # Aesthetically quote it.
Chris@69 4099 func_quote_for_eval "$nonopt"
Chris@69 4100 install_prog="$func_quote_for_eval_result "
Chris@69 4101 arg=$1
Chris@69 4102 shift
Chris@69 4103 else
Chris@69 4104 install_prog=
Chris@69 4105 arg=$nonopt
Chris@69 4106 fi
Chris@69 4107
Chris@69 4108 # The real first argument should be the name of the installation program.
Chris@69 4109 # Aesthetically quote it.
Chris@69 4110 func_quote_for_eval "$arg"
Chris@69 4111 func_append install_prog "$func_quote_for_eval_result"
Chris@69 4112 install_shared_prog=$install_prog
Chris@69 4113 case " $install_prog " in
Chris@69 4114 *[\\\ /]cp\ *) install_cp=: ;;
Chris@69 4115 *) install_cp=false ;;
Chris@69 4116 esac
Chris@69 4117
Chris@69 4118 # We need to accept at least all the BSD install flags.
Chris@69 4119 dest=
Chris@69 4120 files=
Chris@69 4121 opts=
Chris@69 4122 prev=
Chris@69 4123 install_type=
Chris@69 4124 isdir=false
Chris@69 4125 stripme=
Chris@69 4126 no_mode=:
Chris@69 4127 for arg
Chris@69 4128 do
Chris@69 4129 arg2=
Chris@69 4130 if test -n "$dest"; then
Chris@69 4131 func_append files " $dest"
Chris@69 4132 dest=$arg
Chris@69 4133 continue
Chris@69 4134 fi
Chris@69 4135
Chris@69 4136 case $arg in
Chris@69 4137 -d) isdir=: ;;
Chris@69 4138 -f)
Chris@69 4139 if $install_cp; then :; else
Chris@69 4140 prev=$arg
Chris@69 4141 fi
Chris@69 4142 ;;
Chris@69 4143 -g | -m | -o)
Chris@69 4144 prev=$arg
Chris@69 4145 ;;
Chris@69 4146 -s)
Chris@69 4147 stripme=" -s"
Chris@69 4148 continue
Chris@69 4149 ;;
Chris@69 4150 -*)
Chris@69 4151 ;;
Chris@69 4152 *)
Chris@69 4153 # If the previous option needed an argument, then skip it.
Chris@69 4154 if test -n "$prev"; then
Chris@69 4155 if test X-m = "X$prev" && test -n "$install_override_mode"; then
Chris@69 4156 arg2=$install_override_mode
Chris@69 4157 no_mode=false
Chris@69 4158 fi
Chris@69 4159 prev=
Chris@69 4160 else
Chris@69 4161 dest=$arg
Chris@69 4162 continue
Chris@69 4163 fi
Chris@69 4164 ;;
Chris@69 4165 esac
Chris@69 4166
Chris@69 4167 # Aesthetically quote the argument.
Chris@69 4168 func_quote_for_eval "$arg"
Chris@69 4169 func_append install_prog " $func_quote_for_eval_result"
Chris@69 4170 if test -n "$arg2"; then
Chris@69 4171 func_quote_for_eval "$arg2"
Chris@69 4172 fi
Chris@69 4173 func_append install_shared_prog " $func_quote_for_eval_result"
Chris@69 4174 done
Chris@69 4175
Chris@69 4176 test -z "$install_prog" && \
Chris@69 4177 func_fatal_help "you must specify an install program"
Chris@69 4178
Chris@69 4179 test -n "$prev" && \
Chris@69 4180 func_fatal_help "the '$prev' option requires an argument"
Chris@69 4181
Chris@69 4182 if test -n "$install_override_mode" && $no_mode; then
Chris@69 4183 if $install_cp; then :; else
Chris@69 4184 func_quote_for_eval "$install_override_mode"
Chris@69 4185 func_append install_shared_prog " -m $func_quote_for_eval_result"
Chris@69 4186 fi
Chris@69 4187 fi
Chris@69 4188
Chris@69 4189 if test -z "$files"; then
Chris@69 4190 if test -z "$dest"; then
Chris@69 4191 func_fatal_help "no file or destination specified"
Chris@69 4192 else
Chris@69 4193 func_fatal_help "you must specify a destination"
Chris@69 4194 fi
Chris@69 4195 fi
Chris@69 4196
Chris@69 4197 # Strip any trailing slash from the destination.
Chris@69 4198 func_stripname '' '/' "$dest"
Chris@69 4199 dest=$func_stripname_result
Chris@69 4200
Chris@69 4201 # Check to see that the destination is a directory.
Chris@69 4202 test -d "$dest" && isdir=:
Chris@69 4203 if $isdir; then
Chris@69 4204 destdir=$dest
Chris@69 4205 destname=
Chris@69 4206 else
Chris@69 4207 func_dirname_and_basename "$dest" "" "."
Chris@69 4208 destdir=$func_dirname_result
Chris@69 4209 destname=$func_basename_result
Chris@69 4210
Chris@69 4211 # Not a directory, so check to see that there is only one file specified.
Chris@69 4212 set dummy $files; shift
Chris@69 4213 test "$#" -gt 1 && \
Chris@69 4214 func_fatal_help "'$dest' is not a directory"
Chris@69 4215 fi
Chris@69 4216 case $destdir in
Chris@69 4217 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@69 4218 *)
Chris@69 4219 for file in $files; do
Chris@69 4220 case $file in
Chris@69 4221 *.lo) ;;
Chris@69 4222 *)
Chris@69 4223 func_fatal_help "'$destdir' must be an absolute directory name"
Chris@69 4224 ;;
Chris@69 4225 esac
Chris@69 4226 done
Chris@69 4227 ;;
Chris@69 4228 esac
Chris@69 4229
Chris@69 4230 # This variable tells wrapper scripts just to set variables rather
Chris@69 4231 # than running their programs.
Chris@69 4232 libtool_install_magic=$magic
Chris@69 4233
Chris@69 4234 staticlibs=
Chris@69 4235 future_libdirs=
Chris@69 4236 current_libdirs=
Chris@69 4237 for file in $files; do
Chris@69 4238
Chris@69 4239 # Do each installation.
Chris@69 4240 case $file in
Chris@69 4241 *.$libext)
Chris@69 4242 # Do the static libraries later.
Chris@69 4243 func_append staticlibs " $file"
Chris@69 4244 ;;
Chris@69 4245
Chris@69 4246 *.la)
Chris@69 4247 func_resolve_sysroot "$file"
Chris@69 4248 file=$func_resolve_sysroot_result
Chris@69 4249
Chris@69 4250 # Check to see that this really is a libtool archive.
Chris@69 4251 func_lalib_unsafe_p "$file" \
Chris@69 4252 || func_fatal_help "'$file' is not a valid libtool archive"
Chris@69 4253
Chris@69 4254 library_names=
Chris@69 4255 old_library=
Chris@69 4256 relink_command=
Chris@69 4257 func_source "$file"
Chris@69 4258
Chris@69 4259 # Add the libdir to current_libdirs if it is the destination.
Chris@69 4260 if test "X$destdir" = "X$libdir"; then
Chris@69 4261 case "$current_libdirs " in
Chris@69 4262 *" $libdir "*) ;;
Chris@69 4263 *) func_append current_libdirs " $libdir" ;;
Chris@69 4264 esac
Chris@69 4265 else
Chris@69 4266 # Note the libdir as a future libdir.
Chris@69 4267 case "$future_libdirs " in
Chris@69 4268 *" $libdir "*) ;;
Chris@69 4269 *) func_append future_libdirs " $libdir" ;;
Chris@69 4270 esac
Chris@69 4271 fi
Chris@69 4272
Chris@69 4273 func_dirname "$file" "/" ""
Chris@69 4274 dir=$func_dirname_result
Chris@69 4275 func_append dir "$objdir"
Chris@69 4276
Chris@69 4277 if test -n "$relink_command"; then
Chris@69 4278 # Determine the prefix the user has applied to our future dir.
Chris@69 4279 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
Chris@69 4280
Chris@69 4281 # Don't allow the user to place us outside of our expected
Chris@69 4282 # location b/c this prevents finding dependent libraries that
Chris@69 4283 # are installed to the same prefix.
Chris@69 4284 # At present, this check doesn't affect windows .dll's that
Chris@69 4285 # are installed into $libdir/../bin (currently, that works fine)
Chris@69 4286 # but it's something to keep an eye on.
Chris@69 4287 test "$inst_prefix_dir" = "$destdir" && \
Chris@69 4288 func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
Chris@69 4289
Chris@69 4290 if test -n "$inst_prefix_dir"; then
Chris@69 4291 # Stick the inst_prefix_dir data into the link command.
Chris@69 4292 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
Chris@69 4293 else
Chris@69 4294 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
Chris@69 4295 fi
Chris@69 4296
Chris@69 4297 func_warning "relinking '$file'"
Chris@69 4298 func_show_eval "$relink_command" \
Chris@69 4299 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
Chris@69 4300 fi
Chris@69 4301
Chris@69 4302 # See the names of the shared library.
Chris@69 4303 set dummy $library_names; shift
Chris@69 4304 if test -n "$1"; then
Chris@69 4305 realname=$1
Chris@69 4306 shift
Chris@69 4307
Chris@69 4308 srcname=$realname
Chris@69 4309 test -n "$relink_command" && srcname=${realname}T
Chris@69 4310
Chris@69 4311 # Install the shared library and build the symlinks.
Chris@69 4312 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
Chris@69 4313 'exit $?'
Chris@69 4314 tstripme=$stripme
Chris@69 4315 case $host_os in
Chris@69 4316 cygwin* | mingw* | pw32* | cegcc*)
Chris@69 4317 case $realname in
Chris@69 4318 *.dll.a)
Chris@69 4319 tstripme=
Chris@69 4320 ;;
Chris@69 4321 esac
Chris@69 4322 ;;
Chris@69 4323 os2*)
Chris@69 4324 case $realname in
Chris@69 4325 *_dll.a)
Chris@69 4326 tstripme=
Chris@69 4327 ;;
Chris@69 4328 esac
Chris@69 4329 ;;
Chris@69 4330 esac
Chris@69 4331 if test -n "$tstripme" && test -n "$striplib"; then
Chris@69 4332 func_show_eval "$striplib $destdir/$realname" 'exit $?'
Chris@69 4333 fi
Chris@69 4334
Chris@69 4335 if test "$#" -gt 0; then
Chris@69 4336 # Delete the old symlinks, and create new ones.
Chris@69 4337 # Try 'ln -sf' first, because the 'ln' binary might depend on
Chris@69 4338 # the symlink we replace! Solaris /bin/ln does not understand -f,
Chris@69 4339 # so we also need to try rm && ln -s.
Chris@69 4340 for linkname
Chris@69 4341 do
Chris@69 4342 test "$linkname" != "$realname" \
Chris@69 4343 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
Chris@69 4344 done
Chris@69 4345 fi
Chris@69 4346
Chris@69 4347 # Do each command in the postinstall commands.
Chris@69 4348 lib=$destdir/$realname
Chris@69 4349 func_execute_cmds "$postinstall_cmds" 'exit $?'
Chris@69 4350 fi
Chris@69 4351
Chris@69 4352 # Install the pseudo-library for information purposes.
Chris@69 4353 func_basename "$file"
Chris@69 4354 name=$func_basename_result
Chris@69 4355 instname=$dir/${name}i
Chris@69 4356 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
Chris@69 4357
Chris@69 4358 # Maybe install the static library, too.
Chris@69 4359 test -n "$old_library" && func_append staticlibs " $dir/$old_library"
Chris@69 4360 ;;
Chris@69 4361
Chris@69 4362 *.lo)
Chris@69 4363 # Install (i.e. copy) a libtool object.
Chris@69 4364
Chris@69 4365 # Figure out destination file name, if it wasn't already specified.
Chris@69 4366 if test -n "$destname"; then
Chris@69 4367 destfile=$destdir/$destname
Chris@69 4368 else
Chris@69 4369 func_basename "$file"
Chris@69 4370 destfile=$func_basename_result
Chris@69 4371 destfile=$destdir/$destfile
Chris@69 4372 fi
Chris@69 4373
Chris@69 4374 # Deduce the name of the destination old-style object file.
Chris@69 4375 case $destfile in
Chris@69 4376 *.lo)
Chris@69 4377 func_lo2o "$destfile"
Chris@69 4378 staticdest=$func_lo2o_result
Chris@69 4379 ;;
Chris@69 4380 *.$objext)
Chris@69 4381 staticdest=$destfile
Chris@69 4382 destfile=
Chris@69 4383 ;;
Chris@69 4384 *)
Chris@69 4385 func_fatal_help "cannot copy a libtool object to '$destfile'"
Chris@69 4386 ;;
Chris@69 4387 esac
Chris@69 4388
Chris@69 4389 # Install the libtool object if requested.
Chris@69 4390 test -n "$destfile" && \
Chris@69 4391 func_show_eval "$install_prog $file $destfile" 'exit $?'
Chris@69 4392
Chris@69 4393 # Install the old object if enabled.
Chris@69 4394 if test yes = "$build_old_libs"; then
Chris@69 4395 # Deduce the name of the old-style object file.
Chris@69 4396 func_lo2o "$file"
Chris@69 4397 staticobj=$func_lo2o_result
Chris@69 4398 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
Chris@69 4399 fi
Chris@69 4400 exit $EXIT_SUCCESS
Chris@69 4401 ;;
Chris@69 4402
Chris@69 4403 *)
Chris@69 4404 # Figure out destination file name, if it wasn't already specified.
Chris@69 4405 if test -n "$destname"; then
Chris@69 4406 destfile=$destdir/$destname
Chris@69 4407 else
Chris@69 4408 func_basename "$file"
Chris@69 4409 destfile=$func_basename_result
Chris@69 4410 destfile=$destdir/$destfile
Chris@69 4411 fi
Chris@69 4412
Chris@69 4413 # If the file is missing, and there is a .exe on the end, strip it
Chris@69 4414 # because it is most likely a libtool script we actually want to
Chris@69 4415 # install
Chris@69 4416 stripped_ext=
Chris@69 4417 case $file in
Chris@69 4418 *.exe)
Chris@69 4419 if test ! -f "$file"; then
Chris@69 4420 func_stripname '' '.exe' "$file"
Chris@69 4421 file=$func_stripname_result
Chris@69 4422 stripped_ext=.exe
Chris@69 4423 fi
Chris@69 4424 ;;
Chris@69 4425 esac
Chris@69 4426
Chris@69 4427 # Do a test to see if this is really a libtool program.
Chris@69 4428 case $host in
Chris@69 4429 *cygwin* | *mingw*)
Chris@69 4430 if func_ltwrapper_executable_p "$file"; then
Chris@69 4431 func_ltwrapper_scriptname "$file"
Chris@69 4432 wrapper=$func_ltwrapper_scriptname_result
Chris@69 4433 else
Chris@69 4434 func_stripname '' '.exe' "$file"
Chris@69 4435 wrapper=$func_stripname_result
Chris@69 4436 fi
Chris@69 4437 ;;
Chris@69 4438 *)
Chris@69 4439 wrapper=$file
Chris@69 4440 ;;
Chris@69 4441 esac
Chris@69 4442 if func_ltwrapper_script_p "$wrapper"; then
Chris@69 4443 notinst_deplibs=
Chris@69 4444 relink_command=
Chris@69 4445
Chris@69 4446 func_source "$wrapper"
Chris@69 4447
Chris@69 4448 # Check the variables that should have been set.
Chris@69 4449 test -z "$generated_by_libtool_version" && \
Chris@69 4450 func_fatal_error "invalid libtool wrapper script '$wrapper'"
Chris@69 4451
Chris@69 4452 finalize=:
Chris@69 4453 for lib in $notinst_deplibs; do
Chris@69 4454 # Check to see that each library is installed.
Chris@69 4455 libdir=
Chris@69 4456 if test -f "$lib"; then
Chris@69 4457 func_source "$lib"
Chris@69 4458 fi
Chris@69 4459 libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
Chris@69 4460 if test -n "$libdir" && test ! -f "$libfile"; then
Chris@69 4461 func_warning "'$lib' has not been installed in '$libdir'"
Chris@69 4462 finalize=false
Chris@69 4463 fi
Chris@69 4464 done
Chris@69 4465
Chris@69 4466 relink_command=
Chris@69 4467 func_source "$wrapper"
Chris@69 4468
Chris@69 4469 outputname=
Chris@69 4470 if test no = "$fast_install" && test -n "$relink_command"; then
Chris@69 4471 $opt_dry_run || {
Chris@69 4472 if $finalize; then
Chris@69 4473 tmpdir=`func_mktempdir`
Chris@69 4474 func_basename "$file$stripped_ext"
Chris@69 4475 file=$func_basename_result
Chris@69 4476 outputname=$tmpdir/$file
Chris@69 4477 # Replace the output file specification.
Chris@69 4478 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
Chris@69 4479
Chris@69 4480 $opt_quiet || {
Chris@69 4481 func_quote_for_expand "$relink_command"
Chris@69 4482 eval "func_echo $func_quote_for_expand_result"
Chris@69 4483 }
Chris@69 4484 if eval "$relink_command"; then :
Chris@69 4485 else
Chris@69 4486 func_error "error: relink '$file' with the above command before installing it"
Chris@69 4487 $opt_dry_run || ${RM}r "$tmpdir"
Chris@69 4488 continue
Chris@69 4489 fi
Chris@69 4490 file=$outputname
Chris@69 4491 else
Chris@69 4492 func_warning "cannot relink '$file'"
Chris@69 4493 fi
Chris@69 4494 }
Chris@69 4495 else
Chris@69 4496 # Install the binary that we compiled earlier.
Chris@69 4497 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
Chris@69 4498 fi
Chris@69 4499 fi
Chris@69 4500
Chris@69 4501 # remove .exe since cygwin /usr/bin/install will append another
Chris@69 4502 # one anyway
Chris@69 4503 case $install_prog,$host in
Chris@69 4504 */usr/bin/install*,*cygwin*)
Chris@69 4505 case $file:$destfile in
Chris@69 4506 *.exe:*.exe)
Chris@69 4507 # this is ok
Chris@69 4508 ;;
Chris@69 4509 *.exe:*)
Chris@69 4510 destfile=$destfile.exe
Chris@69 4511 ;;
Chris@69 4512 *:*.exe)
Chris@69 4513 func_stripname '' '.exe' "$destfile"
Chris@69 4514 destfile=$func_stripname_result
Chris@69 4515 ;;
Chris@69 4516 esac
Chris@69 4517 ;;
Chris@69 4518 esac
Chris@69 4519 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
Chris@69 4520 $opt_dry_run || if test -n "$outputname"; then
Chris@69 4521 ${RM}r "$tmpdir"
Chris@69 4522 fi
Chris@69 4523 ;;
Chris@69 4524 esac
Chris@69 4525 done
Chris@69 4526
Chris@69 4527 for file in $staticlibs; do
Chris@69 4528 func_basename "$file"
Chris@69 4529 name=$func_basename_result
Chris@69 4530
Chris@69 4531 # Set up the ranlib parameters.
Chris@69 4532 oldlib=$destdir/$name
Chris@69 4533 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
Chris@69 4534 tool_oldlib=$func_to_tool_file_result
Chris@69 4535
Chris@69 4536 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
Chris@69 4537
Chris@69 4538 if test -n "$stripme" && test -n "$old_striplib"; then
Chris@69 4539 func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
Chris@69 4540 fi
Chris@69 4541
Chris@69 4542 # Do each command in the postinstall commands.
Chris@69 4543 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
Chris@69 4544 done
Chris@69 4545
Chris@69 4546 test -n "$future_libdirs" && \
Chris@69 4547 func_warning "remember to run '$progname --finish$future_libdirs'"
Chris@69 4548
Chris@69 4549 if test -n "$current_libdirs"; then
Chris@69 4550 # Maybe just do a dry run.
Chris@69 4551 $opt_dry_run && current_libdirs=" -n$current_libdirs"
Chris@69 4552 exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
Chris@69 4553 else
Chris@69 4554 exit $EXIT_SUCCESS
Chris@69 4555 fi
Chris@69 4556 }
Chris@69 4557
Chris@69 4558 test install = "$opt_mode" && func_mode_install ${1+"$@"}
Chris@69 4559
Chris@69 4560
Chris@69 4561 # func_generate_dlsyms outputname originator pic_p
Chris@69 4562 # Extract symbols from dlprefiles and create ${outputname}S.o with
Chris@69 4563 # a dlpreopen symbol table.
Chris@69 4564 func_generate_dlsyms ()
Chris@69 4565 {
Chris@69 4566 $debug_cmd
Chris@69 4567
Chris@69 4568 my_outputname=$1
Chris@69 4569 my_originator=$2
Chris@69 4570 my_pic_p=${3-false}
Chris@69 4571 my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
Chris@69 4572 my_dlsyms=
Chris@69 4573
Chris@69 4574 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
Chris@69 4575 if test -n "$NM" && test -n "$global_symbol_pipe"; then
Chris@69 4576 my_dlsyms=${my_outputname}S.c
Chris@69 4577 else
Chris@69 4578 func_error "not configured to extract global symbols from dlpreopened files"
Chris@69 4579 fi
Chris@69 4580 fi
Chris@69 4581
Chris@69 4582 if test -n "$my_dlsyms"; then
Chris@69 4583 case $my_dlsyms in
Chris@69 4584 "") ;;
Chris@69 4585 *.c)
Chris@69 4586 # Discover the nlist of each of the dlfiles.
Chris@69 4587 nlist=$output_objdir/$my_outputname.nm
Chris@69 4588
Chris@69 4589 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
Chris@69 4590
Chris@69 4591 # Parse the name list into a source file.
Chris@69 4592 func_verbose "creating $output_objdir/$my_dlsyms"
Chris@69 4593
Chris@69 4594 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
Chris@69 4595 /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
Chris@69 4596 /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
Chris@69 4597
Chris@69 4598 #ifdef __cplusplus
Chris@69 4599 extern \"C\" {
Chris@69 4600 #endif
Chris@69 4601
Chris@69 4602 #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
Chris@69 4603 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
Chris@69 4604 #endif
Chris@69 4605
Chris@69 4606 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
Chris@69 4607 #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
Chris@69 4608 /* DATA imports from DLLs on WIN32 can't be const, because runtime
Chris@69 4609 relocations are performed -- see ld's documentation on pseudo-relocs. */
Chris@69 4610 # define LT_DLSYM_CONST
Chris@69 4611 #elif defined __osf__
Chris@69 4612 /* This system does not cope well with relocations in const data. */
Chris@69 4613 # define LT_DLSYM_CONST
Chris@69 4614 #else
Chris@69 4615 # define LT_DLSYM_CONST const
Chris@69 4616 #endif
Chris@69 4617
Chris@69 4618 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
Chris@69 4619
Chris@69 4620 /* External symbol declarations for the compiler. */\
Chris@69 4621 "
Chris@69 4622
Chris@69 4623 if test yes = "$dlself"; then
Chris@69 4624 func_verbose "generating symbol list for '$output'"
Chris@69 4625
Chris@69 4626 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
Chris@69 4627
Chris@69 4628 # Add our own program objects to the symbol list.
Chris@69 4629 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@69 4630 for progfile in $progfiles; do
Chris@69 4631 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
Chris@69 4632 func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
Chris@69 4633 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
Chris@69 4634 done
Chris@69 4635
Chris@69 4636 if test -n "$exclude_expsyms"; then
Chris@69 4637 $opt_dry_run || {
Chris@69 4638 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
Chris@69 4639 eval '$MV "$nlist"T "$nlist"'
Chris@69 4640 }
Chris@69 4641 fi
Chris@69 4642
Chris@69 4643 if test -n "$export_symbols_regex"; then
Chris@69 4644 $opt_dry_run || {
Chris@69 4645 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
Chris@69 4646 eval '$MV "$nlist"T "$nlist"'
Chris@69 4647 }
Chris@69 4648 fi
Chris@69 4649
Chris@69 4650 # Prepare the list of exported symbols
Chris@69 4651 if test -z "$export_symbols"; then
Chris@69 4652 export_symbols=$output_objdir/$outputname.exp
Chris@69 4653 $opt_dry_run || {
Chris@69 4654 $RM $export_symbols
Chris@69 4655 eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
Chris@69 4656 case $host in
Chris@69 4657 *cygwin* | *mingw* | *cegcc* )
Chris@69 4658 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
Chris@69 4659 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
Chris@69 4660 ;;
Chris@69 4661 esac
Chris@69 4662 }
Chris@69 4663 else
Chris@69 4664 $opt_dry_run || {
Chris@69 4665 eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
Chris@69 4666 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
Chris@69 4667 eval '$MV "$nlist"T "$nlist"'
Chris@69 4668 case $host in
Chris@69 4669 *cygwin* | *mingw* | *cegcc* )
Chris@69 4670 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
Chris@69 4671 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
Chris@69 4672 ;;
Chris@69 4673 esac
Chris@69 4674 }
Chris@69 4675 fi
Chris@69 4676 fi
Chris@69 4677
Chris@69 4678 for dlprefile in $dlprefiles; do
Chris@69 4679 func_verbose "extracting global C symbols from '$dlprefile'"
Chris@69 4680 func_basename "$dlprefile"
Chris@69 4681 name=$func_basename_result
Chris@69 4682 case $host in
Chris@69 4683 *cygwin* | *mingw* | *cegcc* )
Chris@69 4684 # if an import library, we need to obtain dlname
Chris@69 4685 if func_win32_import_lib_p "$dlprefile"; then
Chris@69 4686 func_tr_sh "$dlprefile"
Chris@69 4687 eval "curr_lafile=\$libfile_$func_tr_sh_result"
Chris@69 4688 dlprefile_dlbasename=
Chris@69 4689 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
Chris@69 4690 # Use subshell, to avoid clobbering current variable values
Chris@69 4691 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
Chris@69 4692 if test -n "$dlprefile_dlname"; then
Chris@69 4693 func_basename "$dlprefile_dlname"
Chris@69 4694 dlprefile_dlbasename=$func_basename_result
Chris@69 4695 else
Chris@69 4696 # no lafile. user explicitly requested -dlpreopen <import library>.
Chris@69 4697 $sharedlib_from_linklib_cmd "$dlprefile"
Chris@69 4698 dlprefile_dlbasename=$sharedlib_from_linklib_result
Chris@69 4699 fi
Chris@69 4700 fi
Chris@69 4701 $opt_dry_run || {
Chris@69 4702 if test -n "$dlprefile_dlbasename"; then
Chris@69 4703 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
Chris@69 4704 else
Chris@69 4705 func_warning "Could not compute DLL name from $name"
Chris@69 4706 eval '$ECHO ": $name " >> "$nlist"'
Chris@69 4707 fi
Chris@69 4708 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
Chris@69 4709 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
Chris@69 4710 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
Chris@69 4711 }
Chris@69 4712 else # not an import lib
Chris@69 4713 $opt_dry_run || {
Chris@69 4714 eval '$ECHO ": $name " >> "$nlist"'
Chris@69 4715 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
Chris@69 4716 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
Chris@69 4717 }
Chris@69 4718 fi
Chris@69 4719 ;;
Chris@69 4720 *)
Chris@69 4721 $opt_dry_run || {
Chris@69 4722 eval '$ECHO ": $name " >> "$nlist"'
Chris@69 4723 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
Chris@69 4724 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
Chris@69 4725 }
Chris@69 4726 ;;
Chris@69 4727 esac
Chris@69 4728 done
Chris@69 4729
Chris@69 4730 $opt_dry_run || {
Chris@69 4731 # Make sure we have at least an empty file.
Chris@69 4732 test -f "$nlist" || : > "$nlist"
Chris@69 4733
Chris@69 4734 if test -n "$exclude_expsyms"; then
Chris@69 4735 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
Chris@69 4736 $MV "$nlist"T "$nlist"
Chris@69 4737 fi
Chris@69 4738
Chris@69 4739 # Try sorting and uniquifying the output.
Chris@69 4740 if $GREP -v "^: " < "$nlist" |
Chris@69 4741 if sort -k 3 </dev/null >/dev/null 2>&1; then
Chris@69 4742 sort -k 3
Chris@69 4743 else
Chris@69 4744 sort +2
Chris@69 4745 fi |
Chris@69 4746 uniq > "$nlist"S; then
Chris@69 4747 :
Chris@69 4748 else
Chris@69 4749 $GREP -v "^: " < "$nlist" > "$nlist"S
Chris@69 4750 fi
Chris@69 4751
Chris@69 4752 if test -f "$nlist"S; then
Chris@69 4753 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
Chris@69 4754 else
Chris@69 4755 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
Chris@69 4756 fi
Chris@69 4757
Chris@69 4758 func_show_eval '$RM "${nlist}I"'
Chris@69 4759 if test -n "$global_symbol_to_import"; then
Chris@69 4760 eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
Chris@69 4761 fi
Chris@69 4762
Chris@69 4763 echo >> "$output_objdir/$my_dlsyms" "\
Chris@69 4764
Chris@69 4765 /* The mapping between symbol names and symbols. */
Chris@69 4766 typedef struct {
Chris@69 4767 const char *name;
Chris@69 4768 void *address;
Chris@69 4769 } lt_dlsymlist;
Chris@69 4770 extern LT_DLSYM_CONST lt_dlsymlist
Chris@69 4771 lt_${my_prefix}_LTX_preloaded_symbols[];\
Chris@69 4772 "
Chris@69 4773
Chris@69 4774 if test -s "$nlist"I; then
Chris@69 4775 echo >> "$output_objdir/$my_dlsyms" "\
Chris@69 4776 static void lt_syminit(void)
Chris@69 4777 {
Chris@69 4778 LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
Chris@69 4779 for (; symbol->name; ++symbol)
Chris@69 4780 {"
Chris@69 4781 $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
Chris@69 4782 echo >> "$output_objdir/$my_dlsyms" "\
Chris@69 4783 }
Chris@69 4784 }"
Chris@69 4785 fi
Chris@69 4786 echo >> "$output_objdir/$my_dlsyms" "\
Chris@69 4787 LT_DLSYM_CONST lt_dlsymlist
Chris@69 4788 lt_${my_prefix}_LTX_preloaded_symbols[] =
Chris@69 4789 { {\"$my_originator\", (void *) 0},"
Chris@69 4790
Chris@69 4791 if test -s "$nlist"I; then
Chris@69 4792 echo >> "$output_objdir/$my_dlsyms" "\
Chris@69 4793 {\"@INIT@\", (void *) &lt_syminit},"
Chris@69 4794 fi
Chris@69 4795
Chris@69 4796 case $need_lib_prefix in
Chris@69 4797 no)
Chris@69 4798 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
Chris@69 4799 ;;
Chris@69 4800 *)
Chris@69 4801 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
Chris@69 4802 ;;
Chris@69 4803 esac
Chris@69 4804 echo >> "$output_objdir/$my_dlsyms" "\
Chris@69 4805 {0, (void *) 0}
Chris@69 4806 };
Chris@69 4807
Chris@69 4808 /* This works around a problem in FreeBSD linker */
Chris@69 4809 #ifdef FREEBSD_WORKAROUND
Chris@69 4810 static const void *lt_preloaded_setup() {
Chris@69 4811 return lt_${my_prefix}_LTX_preloaded_symbols;
Chris@69 4812 }
Chris@69 4813 #endif
Chris@69 4814
Chris@69 4815 #ifdef __cplusplus
Chris@69 4816 }
Chris@69 4817 #endif\
Chris@69 4818 "
Chris@69 4819 } # !$opt_dry_run
Chris@69 4820
Chris@69 4821 pic_flag_for_symtable=
Chris@69 4822 case "$compile_command " in
Chris@69 4823 *" -static "*) ;;
Chris@69 4824 *)
Chris@69 4825 case $host in
Chris@69 4826 # compiling the symbol table file with pic_flag works around
Chris@69 4827 # a FreeBSD bug that causes programs to crash when -lm is
Chris@69 4828 # linked before any other PIC object. But we must not use
Chris@69 4829 # pic_flag when linking with -static. The problem exists in
Chris@69 4830 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
Chris@69 4831 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
Chris@69 4832 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
Chris@69 4833 *-*-hpux*)
Chris@69 4834 pic_flag_for_symtable=" $pic_flag" ;;
Chris@69 4835 *)
Chris@69 4836 $my_pic_p && pic_flag_for_symtable=" $pic_flag"
Chris@69 4837 ;;
Chris@69 4838 esac
Chris@69 4839 ;;
Chris@69 4840 esac
Chris@69 4841 symtab_cflags=
Chris@69 4842 for arg in $LTCFLAGS; do
Chris@69 4843 case $arg in
Chris@69 4844 -pie | -fpie | -fPIE) ;;
Chris@69 4845 *) func_append symtab_cflags " $arg" ;;
Chris@69 4846 esac
Chris@69 4847 done
Chris@69 4848
Chris@69 4849 # Now compile the dynamic symbol file.
Chris@69 4850 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
Chris@69 4851
Chris@69 4852 # Clean up the generated files.
Chris@69 4853 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
Chris@69 4854
Chris@69 4855 # Transform the symbol file into the correct name.
Chris@69 4856 symfileobj=$output_objdir/${my_outputname}S.$objext
Chris@69 4857 case $host in
Chris@69 4858 *cygwin* | *mingw* | *cegcc* )
Chris@69 4859 if test -f "$output_objdir/$my_outputname.def"; then
Chris@69 4860 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
Chris@69 4861 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
Chris@69 4862 else
Chris@69 4863 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@69 4864 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@69 4865 fi
Chris@69 4866 ;;
Chris@69 4867 *)
Chris@69 4868 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@69 4869 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@69 4870 ;;
Chris@69 4871 esac
Chris@69 4872 ;;
Chris@69 4873 *)
Chris@69 4874 func_fatal_error "unknown suffix for '$my_dlsyms'"
Chris@69 4875 ;;
Chris@69 4876 esac
Chris@69 4877 else
Chris@69 4878 # We keep going just in case the user didn't refer to
Chris@69 4879 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
Chris@69 4880 # really was required.
Chris@69 4881
Chris@69 4882 # Nullify the symbol file.
Chris@69 4883 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
Chris@69 4884 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
Chris@69 4885 fi
Chris@69 4886 }
Chris@69 4887
Chris@69 4888 # func_cygming_gnu_implib_p ARG
Chris@69 4889 # This predicate returns with zero status (TRUE) if
Chris@69 4890 # ARG is a GNU/binutils-style import library. Returns
Chris@69 4891 # with nonzero status (FALSE) otherwise.
Chris@69 4892 func_cygming_gnu_implib_p ()
Chris@69 4893 {
Chris@69 4894 $debug_cmd
Chris@69 4895
Chris@69 4896 func_to_tool_file "$1" func_convert_file_msys_to_w32
Chris@69 4897 func_cygming_gnu_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $EGREP ' (_head_[A-Za-z0-9_]+_[ad]l*|[A-Za-z0-9_]+_[ad]l*_iname)$'`
Chris@69 4898 test -n "$func_cygming_gnu_implib_tmp"
Chris@69 4899 }
Chris@69 4900
Chris@69 4901 # func_cygming_ms_implib_p ARG
Chris@69 4902 # This predicate returns with zero status (TRUE) if
Chris@69 4903 # ARG is an MS-style import library. Returns
Chris@69 4904 # with nonzero status (FALSE) otherwise.
Chris@69 4905 func_cygming_ms_implib_p ()
Chris@69 4906 {
Chris@69 4907 $debug_cmd
Chris@69 4908
Chris@69 4909 func_to_tool_file "$1" func_convert_file_msys_to_w32
Chris@69 4910 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
Chris@69 4911 test -n "$func_cygming_ms_implib_tmp"
Chris@69 4912 }
Chris@69 4913
Chris@69 4914 # func_win32_libid arg
Chris@69 4915 # return the library type of file 'arg'
Chris@69 4916 #
Chris@69 4917 # Need a lot of goo to handle *both* DLLs and import libs
Chris@69 4918 # Has to be a shell function in order to 'eat' the argument
Chris@69 4919 # that is supplied when $file_magic_command is called.
Chris@69 4920 # Despite the name, also deal with 64 bit binaries.
Chris@69 4921 func_win32_libid ()
Chris@69 4922 {
Chris@69 4923 $debug_cmd
Chris@69 4924
Chris@69 4925 win32_libid_type=unknown
Chris@69 4926 win32_fileres=`file -L $1 2>/dev/null`
Chris@69 4927 case $win32_fileres in
Chris@69 4928 *ar\ archive\ import\ library*) # definitely import
Chris@69 4929 win32_libid_type="x86 archive import"
Chris@69 4930 ;;
Chris@69 4931 *ar\ archive*) # could be an import, or static
Chris@69 4932 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
Chris@69 4933 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
Chris@69 4934 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
Chris@69 4935 case $nm_interface in
Chris@69 4936 "MS dumpbin")
Chris@69 4937 if func_cygming_ms_implib_p "$1" ||
Chris@69 4938 func_cygming_gnu_implib_p "$1"
Chris@69 4939 then
Chris@69 4940 win32_nmres=import
Chris@69 4941 else
Chris@69 4942 win32_nmres=
Chris@69 4943 fi
Chris@69 4944 ;;
Chris@69 4945 *)
Chris@69 4946 func_to_tool_file "$1" func_convert_file_msys_to_w32
Chris@69 4947 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
Chris@69 4948 $SED -n -e '
Chris@69 4949 1,100{
Chris@69 4950 / I /{
Chris@69 4951 s|.*|import|
Chris@69 4952 p
Chris@69 4953 q
Chris@69 4954 }
Chris@69 4955 }'`
Chris@69 4956 ;;
Chris@69 4957 esac
Chris@69 4958 case $win32_nmres in
Chris@69 4959 import*) win32_libid_type="x86 archive import";;
Chris@69 4960 *) win32_libid_type="x86 archive static";;
Chris@69 4961 esac
Chris@69 4962 fi
Chris@69 4963 ;;
Chris@69 4964 *DLL*)
Chris@69 4965 win32_libid_type="x86 DLL"
Chris@69 4966 ;;
Chris@69 4967 *executable*) # but shell scripts are "executable" too...
Chris@69 4968 case $win32_fileres in
Chris@69 4969 *MS\ Windows\ PE\ Intel*)
Chris@69 4970 win32_libid_type="x86 DLL"
Chris@69 4971 ;;
Chris@69 4972 esac
Chris@69 4973 ;;
Chris@69 4974 esac
Chris@69 4975 $ECHO "$win32_libid_type"
Chris@69 4976 }
Chris@69 4977
Chris@69 4978 # func_cygming_dll_for_implib ARG
Chris@69 4979 #
Chris@69 4980 # Platform-specific function to extract the
Chris@69 4981 # name of the DLL associated with the specified
Chris@69 4982 # import library ARG.
Chris@69 4983 # Invoked by eval'ing the libtool variable
Chris@69 4984 # $sharedlib_from_linklib_cmd
Chris@69 4985 # Result is available in the variable
Chris@69 4986 # $sharedlib_from_linklib_result
Chris@69 4987 func_cygming_dll_for_implib ()
Chris@69 4988 {
Chris@69 4989 $debug_cmd
Chris@69 4990
Chris@69 4991 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
Chris@69 4992 }
Chris@69 4993
Chris@69 4994 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
Chris@69 4995 #
Chris@69 4996 # The is the core of a fallback implementation of a
Chris@69 4997 # platform-specific function to extract the name of the
Chris@69 4998 # DLL associated with the specified import library LIBNAME.
Chris@69 4999 #
Chris@69 5000 # SECTION_NAME is either .idata$6 or .idata$7, depending
Chris@69 5001 # on the platform and compiler that created the implib.
Chris@69 5002 #
Chris@69 5003 # Echos the name of the DLL associated with the
Chris@69 5004 # specified import library.
Chris@69 5005 func_cygming_dll_for_implib_fallback_core ()
Chris@69 5006 {
Chris@69 5007 $debug_cmd
Chris@69 5008
Chris@69 5009 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
Chris@69 5010 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
Chris@69 5011 $SED '/^Contents of section '"$match_literal"':/{
Chris@69 5012 # Place marker at beginning of archive member dllname section
Chris@69 5013 s/.*/====MARK====/
Chris@69 5014 p
Chris@69 5015 d
Chris@69 5016 }
Chris@69 5017 # These lines can sometimes be longer than 43 characters, but
Chris@69 5018 # are always uninteresting
Chris@69 5019 /:[ ]*file format pe[i]\{,1\}-/d
Chris@69 5020 /^In archive [^:]*:/d
Chris@69 5021 # Ensure marker is printed
Chris@69 5022 /^====MARK====/p
Chris@69 5023 # Remove all lines with less than 43 characters
Chris@69 5024 /^.\{43\}/!d
Chris@69 5025 # From remaining lines, remove first 43 characters
Chris@69 5026 s/^.\{43\}//' |
Chris@69 5027 $SED -n '
Chris@69 5028 # Join marker and all lines until next marker into a single line
Chris@69 5029 /^====MARK====/ b para
Chris@69 5030 H
Chris@69 5031 $ b para
Chris@69 5032 b
Chris@69 5033 :para
Chris@69 5034 x
Chris@69 5035 s/\n//g
Chris@69 5036 # Remove the marker
Chris@69 5037 s/^====MARK====//
Chris@69 5038 # Remove trailing dots and whitespace
Chris@69 5039 s/[\. \t]*$//
Chris@69 5040 # Print
Chris@69 5041 /./p' |
Chris@69 5042 # we now have a list, one entry per line, of the stringified
Chris@69 5043 # contents of the appropriate section of all members of the
Chris@69 5044 # archive that possess that section. Heuristic: eliminate
Chris@69 5045 # all those that have a first or second character that is
Chris@69 5046 # a '.' (that is, objdump's representation of an unprintable
Chris@69 5047 # character.) This should work for all archives with less than
Chris@69 5048 # 0x302f exports -- but will fail for DLLs whose name actually
Chris@69 5049 # begins with a literal '.' or a single character followed by
Chris@69 5050 # a '.'.
Chris@69 5051 #
Chris@69 5052 # Of those that remain, print the first one.
Chris@69 5053 $SED -e '/^\./d;/^.\./d;q'
Chris@69 5054 }
Chris@69 5055
Chris@69 5056 # func_cygming_dll_for_implib_fallback ARG
Chris@69 5057 # Platform-specific function to extract the
Chris@69 5058 # name of the DLL associated with the specified
Chris@69 5059 # import library ARG.
Chris@69 5060 #
Chris@69 5061 # This fallback implementation is for use when $DLLTOOL
Chris@69 5062 # does not support the --identify-strict option.
Chris@69 5063 # Invoked by eval'ing the libtool variable
Chris@69 5064 # $sharedlib_from_linklib_cmd
Chris@69 5065 # Result is available in the variable
Chris@69 5066 # $sharedlib_from_linklib_result
Chris@69 5067 func_cygming_dll_for_implib_fallback ()
Chris@69 5068 {
Chris@69 5069 $debug_cmd
Chris@69 5070
Chris@69 5071 if func_cygming_gnu_implib_p "$1"; then
Chris@69 5072 # binutils import library
Chris@69 5073 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
Chris@69 5074 elif func_cygming_ms_implib_p "$1"; then
Chris@69 5075 # ms-generated import library
Chris@69 5076 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
Chris@69 5077 else
Chris@69 5078 # unknown
Chris@69 5079 sharedlib_from_linklib_result=
Chris@69 5080 fi
Chris@69 5081 }
Chris@69 5082
Chris@69 5083
Chris@69 5084 # func_extract_an_archive dir oldlib
Chris@69 5085 func_extract_an_archive ()
Chris@69 5086 {
Chris@69 5087 $debug_cmd
Chris@69 5088
Chris@69 5089 f_ex_an_ar_dir=$1; shift
Chris@69 5090 f_ex_an_ar_oldlib=$1
Chris@69 5091 if test yes = "$lock_old_archive_extraction"; then
Chris@69 5092 lockfile=$f_ex_an_ar_oldlib.lock
Chris@69 5093 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
Chris@69 5094 func_echo "Waiting for $lockfile to be removed"
Chris@69 5095 sleep 2
Chris@69 5096 done
Chris@69 5097 fi
Chris@69 5098 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
Chris@69 5099 'stat=$?; rm -f "$lockfile"; exit $stat'
Chris@69 5100 if test yes = "$lock_old_archive_extraction"; then
Chris@69 5101 $opt_dry_run || rm -f "$lockfile"
Chris@69 5102 fi
Chris@69 5103 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
Chris@69 5104 :
Chris@69 5105 else
Chris@69 5106 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
Chris@69 5107 fi
Chris@69 5108 }
Chris@69 5109
Chris@69 5110
Chris@69 5111 # func_extract_archives gentop oldlib ...
Chris@69 5112 func_extract_archives ()
Chris@69 5113 {
Chris@69 5114 $debug_cmd
Chris@69 5115
Chris@69 5116 my_gentop=$1; shift
Chris@69 5117 my_oldlibs=${1+"$@"}
Chris@69 5118 my_oldobjs=
Chris@69 5119 my_xlib=
Chris@69 5120 my_xabs=
Chris@69 5121 my_xdir=
Chris@69 5122
Chris@69 5123 for my_xlib in $my_oldlibs; do
Chris@69 5124 # Extract the objects.
Chris@69 5125 case $my_xlib in
Chris@69 5126 [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
Chris@69 5127 *) my_xabs=`pwd`"/$my_xlib" ;;
Chris@69 5128 esac
Chris@69 5129 func_basename "$my_xlib"
Chris@69 5130 my_xlib=$func_basename_result
Chris@69 5131 my_xlib_u=$my_xlib
Chris@69 5132 while :; do
Chris@69 5133 case " $extracted_archives " in
Chris@69 5134 *" $my_xlib_u "*)
Chris@69 5135 func_arith $extracted_serial + 1
Chris@69 5136 extracted_serial=$func_arith_result
Chris@69 5137 my_xlib_u=lt$extracted_serial-$my_xlib ;;
Chris@69 5138 *) break ;;
Chris@69 5139 esac
Chris@69 5140 done
Chris@69 5141 extracted_archives="$extracted_archives $my_xlib_u"
Chris@69 5142 my_xdir=$my_gentop/$my_xlib_u
Chris@69 5143
Chris@69 5144 func_mkdir_p "$my_xdir"
Chris@69 5145
Chris@69 5146 case $host in
Chris@69 5147 *-darwin*)
Chris@69 5148 func_verbose "Extracting $my_xabs"
Chris@69 5149 # Do not bother doing anything if just a dry run
Chris@69 5150 $opt_dry_run || {
Chris@69 5151 darwin_orig_dir=`pwd`
Chris@69 5152 cd $my_xdir || exit $?
Chris@69 5153 darwin_archive=$my_xabs
Chris@69 5154 darwin_curdir=`pwd`
Chris@69 5155 func_basename "$darwin_archive"
Chris@69 5156 darwin_base_archive=$func_basename_result
Chris@69 5157 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
Chris@69 5158 if test -n "$darwin_arches"; then
Chris@69 5159 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
Chris@69 5160 darwin_arch=
Chris@69 5161 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
Chris@69 5162 for darwin_arch in $darwin_arches; do
Chris@69 5163 func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
Chris@69 5164 $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
Chris@69 5165 cd "unfat-$$/$darwin_base_archive-$darwin_arch"
Chris@69 5166 func_extract_an_archive "`pwd`" "$darwin_base_archive"
Chris@69 5167 cd "$darwin_curdir"
Chris@69 5168 $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
Chris@69 5169 done # $darwin_arches
Chris@69 5170 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
Chris@69 5171 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
Chris@69 5172 darwin_file=
Chris@69 5173 darwin_files=
Chris@69 5174 for darwin_file in $darwin_filelist; do
Chris@69 5175 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
Chris@69 5176 $LIPO -create -output "$darwin_file" $darwin_files
Chris@69 5177 done # $darwin_filelist
Chris@69 5178 $RM -rf unfat-$$
Chris@69 5179 cd "$darwin_orig_dir"
Chris@69 5180 else
Chris@69 5181 cd $darwin_orig_dir
Chris@69 5182 func_extract_an_archive "$my_xdir" "$my_xabs"
Chris@69 5183 fi # $darwin_arches
Chris@69 5184 } # !$opt_dry_run
Chris@69 5185 ;;
Chris@69 5186 *)
Chris@69 5187 func_extract_an_archive "$my_xdir" "$my_xabs"
Chris@69 5188 ;;
Chris@69 5189 esac
Chris@69 5190 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
Chris@69 5191 done
Chris@69 5192
Chris@69 5193 func_extract_archives_result=$my_oldobjs
Chris@69 5194 }
Chris@69 5195
Chris@69 5196
Chris@69 5197 # func_emit_wrapper [arg=no]
Chris@69 5198 #
Chris@69 5199 # Emit a libtool wrapper script on stdout.
Chris@69 5200 # Don't directly open a file because we may want to
Chris@69 5201 # incorporate the script contents within a cygwin/mingw
Chris@69 5202 # wrapper executable. Must ONLY be called from within
Chris@69 5203 # func_mode_link because it depends on a number of variables
Chris@69 5204 # set therein.
Chris@69 5205 #
Chris@69 5206 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
Chris@69 5207 # variable will take. If 'yes', then the emitted script
Chris@69 5208 # will assume that the directory where it is stored is
Chris@69 5209 # the $objdir directory. This is a cygwin/mingw-specific
Chris@69 5210 # behavior.
Chris@69 5211 func_emit_wrapper ()
Chris@69 5212 {
Chris@69 5213 func_emit_wrapper_arg1=${1-no}
Chris@69 5214
Chris@69 5215 $ECHO "\
Chris@69 5216 #! $SHELL
Chris@69 5217
Chris@69 5218 # $output - temporary wrapper script for $objdir/$outputname
Chris@69 5219 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@69 5220 #
Chris@69 5221 # The $output program cannot be directly executed until all the libtool
Chris@69 5222 # libraries that it depends on are installed.
Chris@69 5223 #
Chris@69 5224 # This wrapper script should never be moved out of the build directory.
Chris@69 5225 # If it is, it will not operate correctly.
Chris@69 5226
Chris@69 5227 # Sed substitution that helps us do robust quoting. It backslashifies
Chris@69 5228 # metacharacters that are still active within double-quoted strings.
Chris@69 5229 sed_quote_subst='$sed_quote_subst'
Chris@69 5230
Chris@69 5231 # Be Bourne compatible
Chris@69 5232 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
Chris@69 5233 emulate sh
Chris@69 5234 NULLCMD=:
Chris@69 5235 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
Chris@69 5236 # is contrary to our usage. Disable this feature.
Chris@69 5237 alias -g '\${1+\"\$@\"}'='\"\$@\"'
Chris@69 5238 setopt NO_GLOB_SUBST
Chris@69 5239 else
Chris@69 5240 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
Chris@69 5241 fi
Chris@69 5242 BIN_SH=xpg4; export BIN_SH # for Tru64
Chris@69 5243 DUALCASE=1; export DUALCASE # for MKS sh
Chris@69 5244
Chris@69 5245 # The HP-UX ksh and POSIX shell print the target directory to stdout
Chris@69 5246 # if CDPATH is set.
Chris@69 5247 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
Chris@69 5248
Chris@69 5249 relink_command=\"$relink_command\"
Chris@69 5250
Chris@69 5251 # This environment variable determines our operation mode.
Chris@69 5252 if test \"\$libtool_install_magic\" = \"$magic\"; then
Chris@69 5253 # install mode needs the following variables:
Chris@69 5254 generated_by_libtool_version='$macro_version'
Chris@69 5255 notinst_deplibs='$notinst_deplibs'
Chris@69 5256 else
Chris@69 5257 # When we are sourced in execute mode, \$file and \$ECHO are already set.
Chris@69 5258 if test \"\$libtool_execute_magic\" != \"$magic\"; then
Chris@69 5259 file=\"\$0\""
Chris@69 5260
Chris@69 5261 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
Chris@69 5262 $ECHO "\
Chris@69 5263
Chris@69 5264 # A function that is used when there is no print builtin or printf.
Chris@69 5265 func_fallback_echo ()
Chris@69 5266 {
Chris@69 5267 eval 'cat <<_LTECHO_EOF
Chris@69 5268 \$1
Chris@69 5269 _LTECHO_EOF'
Chris@69 5270 }
Chris@69 5271 ECHO=\"$qECHO\"
Chris@69 5272 fi
Chris@69 5273
Chris@69 5274 # Very basic option parsing. These options are (a) specific to
Chris@69 5275 # the libtool wrapper, (b) are identical between the wrapper
Chris@69 5276 # /script/ and the wrapper /executable/ that is used only on
Chris@69 5277 # windows platforms, and (c) all begin with the string "--lt-"
Chris@69 5278 # (application programs are unlikely to have options that match
Chris@69 5279 # this pattern).
Chris@69 5280 #
Chris@69 5281 # There are only two supported options: --lt-debug and
Chris@69 5282 # --lt-dump-script. There is, deliberately, no --lt-help.
Chris@69 5283 #
Chris@69 5284 # The first argument to this parsing function should be the
Chris@69 5285 # script's $0 value, followed by "$@".
Chris@69 5286 lt_option_debug=
Chris@69 5287 func_parse_lt_options ()
Chris@69 5288 {
Chris@69 5289 lt_script_arg0=\$0
Chris@69 5290 shift
Chris@69 5291 for lt_opt
Chris@69 5292 do
Chris@69 5293 case \"\$lt_opt\" in
Chris@69 5294 --lt-debug) lt_option_debug=1 ;;
Chris@69 5295 --lt-dump-script)
Chris@69 5296 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
Chris@69 5297 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
Chris@69 5298 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
Chris@69 5299 cat \"\$lt_dump_D/\$lt_dump_F\"
Chris@69 5300 exit 0
Chris@69 5301 ;;
Chris@69 5302 --lt-*)
Chris@69 5303 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
Chris@69 5304 exit 1
Chris@69 5305 ;;
Chris@69 5306 esac
Chris@69 5307 done
Chris@69 5308
Chris@69 5309 # Print the debug banner immediately:
Chris@69 5310 if test -n \"\$lt_option_debug\"; then
Chris@69 5311 echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
Chris@69 5312 fi
Chris@69 5313 }
Chris@69 5314
Chris@69 5315 # Used when --lt-debug. Prints its arguments to stdout
Chris@69 5316 # (redirection is the responsibility of the caller)
Chris@69 5317 func_lt_dump_args ()
Chris@69 5318 {
Chris@69 5319 lt_dump_args_N=1;
Chris@69 5320 for lt_arg
Chris@69 5321 do
Chris@69 5322 \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
Chris@69 5323 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
Chris@69 5324 done
Chris@69 5325 }
Chris@69 5326
Chris@69 5327 # Core function for launching the target application
Chris@69 5328 func_exec_program_core ()
Chris@69 5329 {
Chris@69 5330 "
Chris@69 5331 case $host in
Chris@69 5332 # Backslashes separate directories on plain windows
Chris@69 5333 *-*-mingw | *-*-os2* | *-cegcc*)
Chris@69 5334 $ECHO "\
Chris@69 5335 if test -n \"\$lt_option_debug\"; then
Chris@69 5336 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
Chris@69 5337 func_lt_dump_args \${1+\"\$@\"} 1>&2
Chris@69 5338 fi
Chris@69 5339 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
Chris@69 5340 "
Chris@69 5341 ;;
Chris@69 5342
Chris@69 5343 *)
Chris@69 5344 $ECHO "\
Chris@69 5345 if test -n \"\$lt_option_debug\"; then
Chris@69 5346 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
Chris@69 5347 func_lt_dump_args \${1+\"\$@\"} 1>&2
Chris@69 5348 fi
Chris@69 5349 exec \"\$progdir/\$program\" \${1+\"\$@\"}
Chris@69 5350 "
Chris@69 5351 ;;
Chris@69 5352 esac
Chris@69 5353 $ECHO "\
Chris@69 5354 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
Chris@69 5355 exit 1
Chris@69 5356 }
Chris@69 5357
Chris@69 5358 # A function to encapsulate launching the target application
Chris@69 5359 # Strips options in the --lt-* namespace from \$@ and
Chris@69 5360 # launches target application with the remaining arguments.
Chris@69 5361 func_exec_program ()
Chris@69 5362 {
Chris@69 5363 case \" \$* \" in
Chris@69 5364 *\\ --lt-*)
Chris@69 5365 for lt_wr_arg
Chris@69 5366 do
Chris@69 5367 case \$lt_wr_arg in
Chris@69 5368 --lt-*) ;;
Chris@69 5369 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
Chris@69 5370 esac
Chris@69 5371 shift
Chris@69 5372 done ;;
Chris@69 5373 esac
Chris@69 5374 func_exec_program_core \${1+\"\$@\"}
Chris@69 5375 }
Chris@69 5376
Chris@69 5377 # Parse options
Chris@69 5378 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
Chris@69 5379
Chris@69 5380 # Find the directory that this script lives in.
Chris@69 5381 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
Chris@69 5382 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
Chris@69 5383
Chris@69 5384 # Follow symbolic links until we get to the real thisdir.
Chris@69 5385 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
Chris@69 5386 while test -n \"\$file\"; do
Chris@69 5387 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
Chris@69 5388
Chris@69 5389 # If there was a directory component, then change thisdir.
Chris@69 5390 if test \"x\$destdir\" != \"x\$file\"; then
Chris@69 5391 case \"\$destdir\" in
Chris@69 5392 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
Chris@69 5393 *) thisdir=\"\$thisdir/\$destdir\" ;;
Chris@69 5394 esac
Chris@69 5395 fi
Chris@69 5396
Chris@69 5397 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
Chris@69 5398 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
Chris@69 5399 done
Chris@69 5400
Chris@69 5401 # Usually 'no', except on cygwin/mingw when embedded into
Chris@69 5402 # the cwrapper.
Chris@69 5403 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
Chris@69 5404 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
Chris@69 5405 # special case for '.'
Chris@69 5406 if test \"\$thisdir\" = \".\"; then
Chris@69 5407 thisdir=\`pwd\`
Chris@69 5408 fi
Chris@69 5409 # remove .libs from thisdir
Chris@69 5410 case \"\$thisdir\" in
Chris@69 5411 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
Chris@69 5412 $objdir ) thisdir=. ;;
Chris@69 5413 esac
Chris@69 5414 fi
Chris@69 5415
Chris@69 5416 # Try to get the absolute directory name.
Chris@69 5417 absdir=\`cd \"\$thisdir\" && pwd\`
Chris@69 5418 test -n \"\$absdir\" && thisdir=\"\$absdir\"
Chris@69 5419 "
Chris@69 5420
Chris@69 5421 if test yes = "$fast_install"; then
Chris@69 5422 $ECHO "\
Chris@69 5423 program=lt-'$outputname'$exeext
Chris@69 5424 progdir=\"\$thisdir/$objdir\"
Chris@69 5425
Chris@69 5426 if test ! -f \"\$progdir/\$program\" ||
Chris@69 5427 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
Chris@69 5428 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
Chris@69 5429
Chris@69 5430 file=\"\$\$-\$program\"
Chris@69 5431
Chris@69 5432 if test ! -d \"\$progdir\"; then
Chris@69 5433 $MKDIR \"\$progdir\"
Chris@69 5434 else
Chris@69 5435 $RM \"\$progdir/\$file\"
Chris@69 5436 fi"
Chris@69 5437
Chris@69 5438 $ECHO "\
Chris@69 5439
Chris@69 5440 # relink executable if necessary
Chris@69 5441 if test -n \"\$relink_command\"; then
Chris@69 5442 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
Chris@69 5443 else
Chris@69 5444 \$ECHO \"\$relink_command_output\" >&2
Chris@69 5445 $RM \"\$progdir/\$file\"
Chris@69 5446 exit 1
Chris@69 5447 fi
Chris@69 5448 fi
Chris@69 5449
Chris@69 5450 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
Chris@69 5451 { $RM \"\$progdir/\$program\";
Chris@69 5452 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
Chris@69 5453 $RM \"\$progdir/\$file\"
Chris@69 5454 fi"
Chris@69 5455 else
Chris@69 5456 $ECHO "\
Chris@69 5457 program='$outputname'
Chris@69 5458 progdir=\"\$thisdir/$objdir\"
Chris@69 5459 "
Chris@69 5460 fi
Chris@69 5461
Chris@69 5462 $ECHO "\
Chris@69 5463
Chris@69 5464 if test -f \"\$progdir/\$program\"; then"
Chris@69 5465
Chris@69 5466 # fixup the dll searchpath if we need to.
Chris@69 5467 #
Chris@69 5468 # Fix the DLL searchpath if we need to. Do this before prepending
Chris@69 5469 # to shlibpath, because on Windows, both are PATH and uninstalled
Chris@69 5470 # libraries must come first.
Chris@69 5471 if test -n "$dllsearchpath"; then
Chris@69 5472 $ECHO "\
Chris@69 5473 # Add the dll search path components to the executable PATH
Chris@69 5474 PATH=$dllsearchpath:\$PATH
Chris@69 5475 "
Chris@69 5476 fi
Chris@69 5477
Chris@69 5478 # Export our shlibpath_var if we have one.
Chris@69 5479 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
Chris@69 5480 $ECHO "\
Chris@69 5481 # Add our own library path to $shlibpath_var
Chris@69 5482 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
Chris@69 5483
Chris@69 5484 # Some systems cannot cope with colon-terminated $shlibpath_var
Chris@69 5485 # The second colon is a workaround for a bug in BeOS R4 sed
Chris@69 5486 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
Chris@69 5487
Chris@69 5488 export $shlibpath_var
Chris@69 5489 "
Chris@69 5490 fi
Chris@69 5491
Chris@69 5492 $ECHO "\
Chris@69 5493 if test \"\$libtool_execute_magic\" != \"$magic\"; then
Chris@69 5494 # Run the actual program with our arguments.
Chris@69 5495 func_exec_program \${1+\"\$@\"}
Chris@69 5496 fi
Chris@69 5497 else
Chris@69 5498 # The program doesn't exist.
Chris@69 5499 \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
Chris@69 5500 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
Chris@69 5501 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
Chris@69 5502 exit 1
Chris@69 5503 fi
Chris@69 5504 fi\
Chris@69 5505 "
Chris@69 5506 }
Chris@69 5507
Chris@69 5508
Chris@69 5509 # func_emit_cwrapperexe_src
Chris@69 5510 # emit the source code for a wrapper executable on stdout
Chris@69 5511 # Must ONLY be called from within func_mode_link because
Chris@69 5512 # it depends on a number of variable set therein.
Chris@69 5513 func_emit_cwrapperexe_src ()
Chris@69 5514 {
Chris@69 5515 cat <<EOF
Chris@69 5516
Chris@69 5517 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
Chris@69 5518 Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@69 5519
Chris@69 5520 The $output program cannot be directly executed until all the libtool
Chris@69 5521 libraries that it depends on are installed.
Chris@69 5522
Chris@69 5523 This wrapper executable should never be moved out of the build directory.
Chris@69 5524 If it is, it will not operate correctly.
Chris@69 5525 */
Chris@69 5526 EOF
Chris@69 5527 cat <<"EOF"
Chris@69 5528 #ifdef _MSC_VER
Chris@69 5529 # define _CRT_SECURE_NO_DEPRECATE 1
Chris@69 5530 #endif
Chris@69 5531 #include <stdio.h>
Chris@69 5532 #include <stdlib.h>
Chris@69 5533 #ifdef _MSC_VER
Chris@69 5534 # include <direct.h>
Chris@69 5535 # include <process.h>
Chris@69 5536 # include <io.h>
Chris@69 5537 #else
Chris@69 5538 # include <unistd.h>
Chris@69 5539 # include <stdint.h>
Chris@69 5540 # ifdef __CYGWIN__
Chris@69 5541 # include <io.h>
Chris@69 5542 # endif
Chris@69 5543 #endif
Chris@69 5544 #include <malloc.h>
Chris@69 5545 #include <stdarg.h>
Chris@69 5546 #include <assert.h>
Chris@69 5547 #include <string.h>
Chris@69 5548 #include <ctype.h>
Chris@69 5549 #include <errno.h>
Chris@69 5550 #include <fcntl.h>
Chris@69 5551 #include <sys/stat.h>
Chris@69 5552
Chris@69 5553 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
Chris@69 5554
Chris@69 5555 /* declarations of non-ANSI functions */
Chris@69 5556 #if defined __MINGW32__
Chris@69 5557 # ifdef __STRICT_ANSI__
Chris@69 5558 int _putenv (const char *);
Chris@69 5559 # endif
Chris@69 5560 #elif defined __CYGWIN__
Chris@69 5561 # ifdef __STRICT_ANSI__
Chris@69 5562 char *realpath (const char *, char *);
Chris@69 5563 int putenv (char *);
Chris@69 5564 int setenv (const char *, const char *, int);
Chris@69 5565 # endif
Chris@69 5566 /* #elif defined other_platform || defined ... */
Chris@69 5567 #endif
Chris@69 5568
Chris@69 5569 /* portability defines, excluding path handling macros */
Chris@69 5570 #if defined _MSC_VER
Chris@69 5571 # define setmode _setmode
Chris@69 5572 # define stat _stat
Chris@69 5573 # define chmod _chmod
Chris@69 5574 # define getcwd _getcwd
Chris@69 5575 # define putenv _putenv
Chris@69 5576 # define S_IXUSR _S_IEXEC
Chris@69 5577 #elif defined __MINGW32__
Chris@69 5578 # define setmode _setmode
Chris@69 5579 # define stat _stat
Chris@69 5580 # define chmod _chmod
Chris@69 5581 # define getcwd _getcwd
Chris@69 5582 # define putenv _putenv
Chris@69 5583 #elif defined __CYGWIN__
Chris@69 5584 # define HAVE_SETENV
Chris@69 5585 # define FOPEN_WB "wb"
Chris@69 5586 /* #elif defined other platforms ... */
Chris@69 5587 #endif
Chris@69 5588
Chris@69 5589 #if defined PATH_MAX
Chris@69 5590 # define LT_PATHMAX PATH_MAX
Chris@69 5591 #elif defined MAXPATHLEN
Chris@69 5592 # define LT_PATHMAX MAXPATHLEN
Chris@69 5593 #else
Chris@69 5594 # define LT_PATHMAX 1024
Chris@69 5595 #endif
Chris@69 5596
Chris@69 5597 #ifndef S_IXOTH
Chris@69 5598 # define S_IXOTH 0
Chris@69 5599 #endif
Chris@69 5600 #ifndef S_IXGRP
Chris@69 5601 # define S_IXGRP 0
Chris@69 5602 #endif
Chris@69 5603
Chris@69 5604 /* path handling portability macros */
Chris@69 5605 #ifndef DIR_SEPARATOR
Chris@69 5606 # define DIR_SEPARATOR '/'
Chris@69 5607 # define PATH_SEPARATOR ':'
Chris@69 5608 #endif
Chris@69 5609
Chris@69 5610 #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
Chris@69 5611 defined __OS2__
Chris@69 5612 # define HAVE_DOS_BASED_FILE_SYSTEM
Chris@69 5613 # define FOPEN_WB "wb"
Chris@69 5614 # ifndef DIR_SEPARATOR_2
Chris@69 5615 # define DIR_SEPARATOR_2 '\\'
Chris@69 5616 # endif
Chris@69 5617 # ifndef PATH_SEPARATOR_2
Chris@69 5618 # define PATH_SEPARATOR_2 ';'
Chris@69 5619 # endif
Chris@69 5620 #endif
Chris@69 5621
Chris@69 5622 #ifndef DIR_SEPARATOR_2
Chris@69 5623 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
Chris@69 5624 #else /* DIR_SEPARATOR_2 */
Chris@69 5625 # define IS_DIR_SEPARATOR(ch) \
Chris@69 5626 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
Chris@69 5627 #endif /* DIR_SEPARATOR_2 */
Chris@69 5628
Chris@69 5629 #ifndef PATH_SEPARATOR_2
Chris@69 5630 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
Chris@69 5631 #else /* PATH_SEPARATOR_2 */
Chris@69 5632 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
Chris@69 5633 #endif /* PATH_SEPARATOR_2 */
Chris@69 5634
Chris@69 5635 #ifndef FOPEN_WB
Chris@69 5636 # define FOPEN_WB "w"
Chris@69 5637 #endif
Chris@69 5638 #ifndef _O_BINARY
Chris@69 5639 # define _O_BINARY 0
Chris@69 5640 #endif
Chris@69 5641
Chris@69 5642 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
Chris@69 5643 #define XFREE(stale) do { \
Chris@69 5644 if (stale) { free (stale); stale = 0; } \
Chris@69 5645 } while (0)
Chris@69 5646
Chris@69 5647 #if defined LT_DEBUGWRAPPER
Chris@69 5648 static int lt_debug = 1;
Chris@69 5649 #else
Chris@69 5650 static int lt_debug = 0;
Chris@69 5651 #endif
Chris@69 5652
Chris@69 5653 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
Chris@69 5654
Chris@69 5655 void *xmalloc (size_t num);
Chris@69 5656 char *xstrdup (const char *string);
Chris@69 5657 const char *base_name (const char *name);
Chris@69 5658 char *find_executable (const char *wrapper);
Chris@69 5659 char *chase_symlinks (const char *pathspec);
Chris@69 5660 int make_executable (const char *path);
Chris@69 5661 int check_executable (const char *path);
Chris@69 5662 char *strendzap (char *str, const char *pat);
Chris@69 5663 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
Chris@69 5664 void lt_fatal (const char *file, int line, const char *message, ...);
Chris@69 5665 static const char *nonnull (const char *s);
Chris@69 5666 static const char *nonempty (const char *s);
Chris@69 5667 void lt_setenv (const char *name, const char *value);
Chris@69 5668 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
Chris@69 5669 void lt_update_exe_path (const char *name, const char *value);
Chris@69 5670 void lt_update_lib_path (const char *name, const char *value);
Chris@69 5671 char **prepare_spawn (char **argv);
Chris@69 5672 void lt_dump_script (FILE *f);
Chris@69 5673 EOF
Chris@69 5674
Chris@69 5675 cat <<EOF
Chris@69 5676 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
Chris@69 5677 # define externally_visible volatile
Chris@69 5678 #else
Chris@69 5679 # define externally_visible __attribute__((externally_visible)) volatile
Chris@69 5680 #endif
Chris@69 5681 externally_visible const char * MAGIC_EXE = "$magic_exe";
Chris@69 5682 const char * LIB_PATH_VARNAME = "$shlibpath_var";
Chris@69 5683 EOF
Chris@69 5684
Chris@69 5685 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
Chris@69 5686 func_to_host_path "$temp_rpath"
Chris@69 5687 cat <<EOF
Chris@69 5688 const char * LIB_PATH_VALUE = "$func_to_host_path_result";
Chris@69 5689 EOF
Chris@69 5690 else
Chris@69 5691 cat <<"EOF"
Chris@69 5692 const char * LIB_PATH_VALUE = "";
Chris@69 5693 EOF
Chris@69 5694 fi
Chris@69 5695
Chris@69 5696 if test -n "$dllsearchpath"; then
Chris@69 5697 func_to_host_path "$dllsearchpath:"
Chris@69 5698 cat <<EOF
Chris@69 5699 const char * EXE_PATH_VARNAME = "PATH";
Chris@69 5700 const char * EXE_PATH_VALUE = "$func_to_host_path_result";
Chris@69 5701 EOF
Chris@69 5702 else
Chris@69 5703 cat <<"EOF"
Chris@69 5704 const char * EXE_PATH_VARNAME = "";
Chris@69 5705 const char * EXE_PATH_VALUE = "";
Chris@69 5706 EOF
Chris@69 5707 fi
Chris@69 5708
Chris@69 5709 if test yes = "$fast_install"; then
Chris@69 5710 cat <<EOF
Chris@69 5711 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
Chris@69 5712 EOF
Chris@69 5713 else
Chris@69 5714 cat <<EOF
Chris@69 5715 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
Chris@69 5716 EOF
Chris@69 5717 fi
Chris@69 5718
Chris@69 5719
Chris@69 5720 cat <<"EOF"
Chris@69 5721
Chris@69 5722 #define LTWRAPPER_OPTION_PREFIX "--lt-"
Chris@69 5723
Chris@69 5724 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
Chris@69 5725 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
Chris@69 5726 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
Chris@69 5727
Chris@69 5728 int
Chris@69 5729 main (int argc, char *argv[])
Chris@69 5730 {
Chris@69 5731 char **newargz;
Chris@69 5732 int newargc;
Chris@69 5733 char *tmp_pathspec;
Chris@69 5734 char *actual_cwrapper_path;
Chris@69 5735 char *actual_cwrapper_name;
Chris@69 5736 char *target_name;
Chris@69 5737 char *lt_argv_zero;
Chris@69 5738 int rval = 127;
Chris@69 5739
Chris@69 5740 int i;
Chris@69 5741
Chris@69 5742 program_name = (char *) xstrdup (base_name (argv[0]));
Chris@69 5743 newargz = XMALLOC (char *, (size_t) argc + 1);
Chris@69 5744
Chris@69 5745 /* very simple arg parsing; don't want to rely on getopt
Chris@69 5746 * also, copy all non cwrapper options to newargz, except
Chris@69 5747 * argz[0], which is handled differently
Chris@69 5748 */
Chris@69 5749 newargc=0;
Chris@69 5750 for (i = 1; i < argc; i++)
Chris@69 5751 {
Chris@69 5752 if (STREQ (argv[i], dumpscript_opt))
Chris@69 5753 {
Chris@69 5754 EOF
Chris@69 5755 case $host in
Chris@69 5756 *mingw* | *cygwin* )
Chris@69 5757 # make stdout use "unix" line endings
Chris@69 5758 echo " setmode(1,_O_BINARY);"
Chris@69 5759 ;;
Chris@69 5760 esac
Chris@69 5761
Chris@69 5762 cat <<"EOF"
Chris@69 5763 lt_dump_script (stdout);
Chris@69 5764 return 0;
Chris@69 5765 }
Chris@69 5766 if (STREQ (argv[i], debug_opt))
Chris@69 5767 {
Chris@69 5768 lt_debug = 1;
Chris@69 5769 continue;
Chris@69 5770 }
Chris@69 5771 if (STREQ (argv[i], ltwrapper_option_prefix))
Chris@69 5772 {
Chris@69 5773 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
Chris@69 5774 namespace, but it is not one of the ones we know about and
Chris@69 5775 have already dealt with, above (inluding dump-script), then
Chris@69 5776 report an error. Otherwise, targets might begin to believe
Chris@69 5777 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
Chris@69 5778 namespace. The first time any user complains about this, we'll
Chris@69 5779 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
Chris@69 5780 or a configure.ac-settable value.
Chris@69 5781 */
Chris@69 5782 lt_fatal (__FILE__, __LINE__,
Chris@69 5783 "unrecognized %s option: '%s'",
Chris@69 5784 ltwrapper_option_prefix, argv[i]);
Chris@69 5785 }
Chris@69 5786 /* otherwise ... */
Chris@69 5787 newargz[++newargc] = xstrdup (argv[i]);
Chris@69 5788 }
Chris@69 5789 newargz[++newargc] = NULL;
Chris@69 5790
Chris@69 5791 EOF
Chris@69 5792 cat <<EOF
Chris@69 5793 /* The GNU banner must be the first non-error debug message */
Chris@69 5794 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
Chris@69 5795 EOF
Chris@69 5796 cat <<"EOF"
Chris@69 5797 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
Chris@69 5798 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
Chris@69 5799
Chris@69 5800 tmp_pathspec = find_executable (argv[0]);
Chris@69 5801 if (tmp_pathspec == NULL)
Chris@69 5802 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
Chris@69 5803 lt_debugprintf (__FILE__, __LINE__,
Chris@69 5804 "(main) found exe (before symlink chase) at: %s\n",
Chris@69 5805 tmp_pathspec);
Chris@69 5806
Chris@69 5807 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
Chris@69 5808 lt_debugprintf (__FILE__, __LINE__,
Chris@69 5809 "(main) found exe (after symlink chase) at: %s\n",
Chris@69 5810 actual_cwrapper_path);
Chris@69 5811 XFREE (tmp_pathspec);
Chris@69 5812
Chris@69 5813 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
Chris@69 5814 strendzap (actual_cwrapper_path, actual_cwrapper_name);
Chris@69 5815
Chris@69 5816 /* wrapper name transforms */
Chris@69 5817 strendzap (actual_cwrapper_name, ".exe");
Chris@69 5818 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
Chris@69 5819 XFREE (actual_cwrapper_name);
Chris@69 5820 actual_cwrapper_name = tmp_pathspec;
Chris@69 5821 tmp_pathspec = 0;
Chris@69 5822
Chris@69 5823 /* target_name transforms -- use actual target program name; might have lt- prefix */
Chris@69 5824 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
Chris@69 5825 strendzap (target_name, ".exe");
Chris@69 5826 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
Chris@69 5827 XFREE (target_name);
Chris@69 5828 target_name = tmp_pathspec;
Chris@69 5829 tmp_pathspec = 0;
Chris@69 5830
Chris@69 5831 lt_debugprintf (__FILE__, __LINE__,
Chris@69 5832 "(main) libtool target name: %s\n",
Chris@69 5833 target_name);
Chris@69 5834 EOF
Chris@69 5835
Chris@69 5836 cat <<EOF
Chris@69 5837 newargz[0] =
Chris@69 5838 XMALLOC (char, (strlen (actual_cwrapper_path) +
Chris@69 5839 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
Chris@69 5840 strcpy (newargz[0], actual_cwrapper_path);
Chris@69 5841 strcat (newargz[0], "$objdir");
Chris@69 5842 strcat (newargz[0], "/");
Chris@69 5843 EOF
Chris@69 5844
Chris@69 5845 cat <<"EOF"
Chris@69 5846 /* stop here, and copy so we don't have to do this twice */
Chris@69 5847 tmp_pathspec = xstrdup (newargz[0]);
Chris@69 5848
Chris@69 5849 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
Chris@69 5850 strcat (newargz[0], actual_cwrapper_name);
Chris@69 5851
Chris@69 5852 /* DO want the lt- prefix here if it exists, so use target_name */
Chris@69 5853 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
Chris@69 5854 XFREE (tmp_pathspec);
Chris@69 5855 tmp_pathspec = NULL;
Chris@69 5856 EOF
Chris@69 5857
Chris@69 5858 case $host_os in
Chris@69 5859 mingw*)
Chris@69 5860 cat <<"EOF"
Chris@69 5861 {
Chris@69 5862 char* p;
Chris@69 5863 while ((p = strchr (newargz[0], '\\')) != NULL)
Chris@69 5864 {
Chris@69 5865 *p = '/';
Chris@69 5866 }
Chris@69 5867 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
Chris@69 5868 {
Chris@69 5869 *p = '/';
Chris@69 5870 }
Chris@69 5871 }
Chris@69 5872 EOF
Chris@69 5873 ;;
Chris@69 5874 esac
Chris@69 5875
Chris@69 5876 cat <<"EOF"
Chris@69 5877 XFREE (target_name);
Chris@69 5878 XFREE (actual_cwrapper_path);
Chris@69 5879 XFREE (actual_cwrapper_name);
Chris@69 5880
Chris@69 5881 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
Chris@69 5882 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
Chris@69 5883 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
Chris@69 5884 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
Chris@69 5885 because on Windows, both *_VARNAMEs are PATH but uninstalled
Chris@69 5886 libraries must come first. */
Chris@69 5887 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
Chris@69 5888 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
Chris@69 5889
Chris@69 5890 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
Chris@69 5891 nonnull (lt_argv_zero));
Chris@69 5892 for (i = 0; i < newargc; i++)
Chris@69 5893 {
Chris@69 5894 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
Chris@69 5895 i, nonnull (newargz[i]));
Chris@69 5896 }
Chris@69 5897
Chris@69 5898 EOF
Chris@69 5899
Chris@69 5900 case $host_os in
Chris@69 5901 mingw*)
Chris@69 5902 cat <<"EOF"
Chris@69 5903 /* execv doesn't actually work on mingw as expected on unix */
Chris@69 5904 newargz = prepare_spawn (newargz);
Chris@69 5905 rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
Chris@69 5906 if (rval == -1)
Chris@69 5907 {
Chris@69 5908 /* failed to start process */
Chris@69 5909 lt_debugprintf (__FILE__, __LINE__,
Chris@69 5910 "(main) failed to launch target \"%s\": %s\n",
Chris@69 5911 lt_argv_zero, nonnull (strerror (errno)));
Chris@69 5912 return 127;
Chris@69 5913 }
Chris@69 5914 return rval;
Chris@69 5915 EOF
Chris@69 5916 ;;
Chris@69 5917 *)
Chris@69 5918 cat <<"EOF"
Chris@69 5919 execv (lt_argv_zero, newargz);
Chris@69 5920 return rval; /* =127, but avoids unused variable warning */
Chris@69 5921 EOF
Chris@69 5922 ;;
Chris@69 5923 esac
Chris@69 5924
Chris@69 5925 cat <<"EOF"
Chris@69 5926 }
Chris@69 5927
Chris@69 5928 void *
Chris@69 5929 xmalloc (size_t num)
Chris@69 5930 {
Chris@69 5931 void *p = (void *) malloc (num);
Chris@69 5932 if (!p)
Chris@69 5933 lt_fatal (__FILE__, __LINE__, "memory exhausted");
Chris@69 5934
Chris@69 5935 return p;
Chris@69 5936 }
Chris@69 5937
Chris@69 5938 char *
Chris@69 5939 xstrdup (const char *string)
Chris@69 5940 {
Chris@69 5941 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
Chris@69 5942 string) : NULL;
Chris@69 5943 }
Chris@69 5944
Chris@69 5945 const char *
Chris@69 5946 base_name (const char *name)
Chris@69 5947 {
Chris@69 5948 const char *base;
Chris@69 5949
Chris@69 5950 #if defined HAVE_DOS_BASED_FILE_SYSTEM
Chris@69 5951 /* Skip over the disk name in MSDOS pathnames. */
Chris@69 5952 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
Chris@69 5953 name += 2;
Chris@69 5954 #endif
Chris@69 5955
Chris@69 5956 for (base = name; *name; name++)
Chris@69 5957 if (IS_DIR_SEPARATOR (*name))
Chris@69 5958 base = name + 1;
Chris@69 5959 return base;
Chris@69 5960 }
Chris@69 5961
Chris@69 5962 int
Chris@69 5963 check_executable (const char *path)
Chris@69 5964 {
Chris@69 5965 struct stat st;
Chris@69 5966
Chris@69 5967 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
Chris@69 5968 nonempty (path));
Chris@69 5969 if ((!path) || (!*path))
Chris@69 5970 return 0;
Chris@69 5971
Chris@69 5972 if ((stat (path, &st) >= 0)
Chris@69 5973 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
Chris@69 5974 return 1;
Chris@69 5975 else
Chris@69 5976 return 0;
Chris@69 5977 }
Chris@69 5978
Chris@69 5979 int
Chris@69 5980 make_executable (const char *path)
Chris@69 5981 {
Chris@69 5982 int rval = 0;
Chris@69 5983 struct stat st;
Chris@69 5984
Chris@69 5985 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
Chris@69 5986 nonempty (path));
Chris@69 5987 if ((!path) || (!*path))
Chris@69 5988 return 0;
Chris@69 5989
Chris@69 5990 if (stat (path, &st) >= 0)
Chris@69 5991 {
Chris@69 5992 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
Chris@69 5993 }
Chris@69 5994 return rval;
Chris@69 5995 }
Chris@69 5996
Chris@69 5997 /* Searches for the full path of the wrapper. Returns
Chris@69 5998 newly allocated full path name if found, NULL otherwise
Chris@69 5999 Does not chase symlinks, even on platforms that support them.
Chris@69 6000 */
Chris@69 6001 char *
Chris@69 6002 find_executable (const char *wrapper)
Chris@69 6003 {
Chris@69 6004 int has_slash = 0;
Chris@69 6005 const char *p;
Chris@69 6006 const char *p_next;
Chris@69 6007 /* static buffer for getcwd */
Chris@69 6008 char tmp[LT_PATHMAX + 1];
Chris@69 6009 size_t tmp_len;
Chris@69 6010 char *concat_name;
Chris@69 6011
Chris@69 6012 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
Chris@69 6013 nonempty (wrapper));
Chris@69 6014
Chris@69 6015 if ((wrapper == NULL) || (*wrapper == '\0'))
Chris@69 6016 return NULL;
Chris@69 6017
Chris@69 6018 /* Absolute path? */
Chris@69 6019 #if defined HAVE_DOS_BASED_FILE_SYSTEM
Chris@69 6020 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
Chris@69 6021 {
Chris@69 6022 concat_name = xstrdup (wrapper);
Chris@69 6023 if (check_executable (concat_name))
Chris@69 6024 return concat_name;
Chris@69 6025 XFREE (concat_name);
Chris@69 6026 }
Chris@69 6027 else
Chris@69 6028 {
Chris@69 6029 #endif
Chris@69 6030 if (IS_DIR_SEPARATOR (wrapper[0]))
Chris@69 6031 {
Chris@69 6032 concat_name = xstrdup (wrapper);
Chris@69 6033 if (check_executable (concat_name))
Chris@69 6034 return concat_name;
Chris@69 6035 XFREE (concat_name);
Chris@69 6036 }
Chris@69 6037 #if defined HAVE_DOS_BASED_FILE_SYSTEM
Chris@69 6038 }
Chris@69 6039 #endif
Chris@69 6040
Chris@69 6041 for (p = wrapper; *p; p++)
Chris@69 6042 if (*p == '/')
Chris@69 6043 {
Chris@69 6044 has_slash = 1;
Chris@69 6045 break;
Chris@69 6046 }
Chris@69 6047 if (!has_slash)
Chris@69 6048 {
Chris@69 6049 /* no slashes; search PATH */
Chris@69 6050 const char *path = getenv ("PATH");
Chris@69 6051 if (path != NULL)
Chris@69 6052 {
Chris@69 6053 for (p = path; *p; p = p_next)
Chris@69 6054 {
Chris@69 6055 const char *q;
Chris@69 6056 size_t p_len;
Chris@69 6057 for (q = p; *q; q++)
Chris@69 6058 if (IS_PATH_SEPARATOR (*q))
Chris@69 6059 break;
Chris@69 6060 p_len = (size_t) (q - p);
Chris@69 6061 p_next = (*q == '\0' ? q : q + 1);
Chris@69 6062 if (p_len == 0)
Chris@69 6063 {
Chris@69 6064 /* empty path: current directory */
Chris@69 6065 if (getcwd (tmp, LT_PATHMAX) == NULL)
Chris@69 6066 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
Chris@69 6067 nonnull (strerror (errno)));
Chris@69 6068 tmp_len = strlen (tmp);
Chris@69 6069 concat_name =
Chris@69 6070 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
Chris@69 6071 memcpy (concat_name, tmp, tmp_len);
Chris@69 6072 concat_name[tmp_len] = '/';
Chris@69 6073 strcpy (concat_name + tmp_len + 1, wrapper);
Chris@69 6074 }
Chris@69 6075 else
Chris@69 6076 {
Chris@69 6077 concat_name =
Chris@69 6078 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
Chris@69 6079 memcpy (concat_name, p, p_len);
Chris@69 6080 concat_name[p_len] = '/';
Chris@69 6081 strcpy (concat_name + p_len + 1, wrapper);
Chris@69 6082 }
Chris@69 6083 if (check_executable (concat_name))
Chris@69 6084 return concat_name;
Chris@69 6085 XFREE (concat_name);
Chris@69 6086 }
Chris@69 6087 }
Chris@69 6088 /* not found in PATH; assume curdir */
Chris@69 6089 }
Chris@69 6090 /* Relative path | not found in path: prepend cwd */
Chris@69 6091 if (getcwd (tmp, LT_PATHMAX) == NULL)
Chris@69 6092 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
Chris@69 6093 nonnull (strerror (errno)));
Chris@69 6094 tmp_len = strlen (tmp);
Chris@69 6095 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
Chris@69 6096 memcpy (concat_name, tmp, tmp_len);
Chris@69 6097 concat_name[tmp_len] = '/';
Chris@69 6098 strcpy (concat_name + tmp_len + 1, wrapper);
Chris@69 6099
Chris@69 6100 if (check_executable (concat_name))
Chris@69 6101 return concat_name;
Chris@69 6102 XFREE (concat_name);
Chris@69 6103 return NULL;
Chris@69 6104 }
Chris@69 6105
Chris@69 6106 char *
Chris@69 6107 chase_symlinks (const char *pathspec)
Chris@69 6108 {
Chris@69 6109 #ifndef S_ISLNK
Chris@69 6110 return xstrdup (pathspec);
Chris@69 6111 #else
Chris@69 6112 char buf[LT_PATHMAX];
Chris@69 6113 struct stat s;
Chris@69 6114 char *tmp_pathspec = xstrdup (pathspec);
Chris@69 6115 char *p;
Chris@69 6116 int has_symlinks = 0;
Chris@69 6117 while (strlen (tmp_pathspec) && !has_symlinks)
Chris@69 6118 {
Chris@69 6119 lt_debugprintf (__FILE__, __LINE__,
Chris@69 6120 "checking path component for symlinks: %s\n",
Chris@69 6121 tmp_pathspec);
Chris@69 6122 if (lstat (tmp_pathspec, &s) == 0)
Chris@69 6123 {
Chris@69 6124 if (S_ISLNK (s.st_mode) != 0)
Chris@69 6125 {
Chris@69 6126 has_symlinks = 1;
Chris@69 6127 break;
Chris@69 6128 }
Chris@69 6129
Chris@69 6130 /* search backwards for last DIR_SEPARATOR */
Chris@69 6131 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
Chris@69 6132 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
Chris@69 6133 p--;
Chris@69 6134 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
Chris@69 6135 {
Chris@69 6136 /* no more DIR_SEPARATORS left */
Chris@69 6137 break;
Chris@69 6138 }
Chris@69 6139 *p = '\0';
Chris@69 6140 }
Chris@69 6141 else
Chris@69 6142 {
Chris@69 6143 lt_fatal (__FILE__, __LINE__,
Chris@69 6144 "error accessing file \"%s\": %s",
Chris@69 6145 tmp_pathspec, nonnull (strerror (errno)));
Chris@69 6146 }
Chris@69 6147 }
Chris@69 6148 XFREE (tmp_pathspec);
Chris@69 6149
Chris@69 6150 if (!has_symlinks)
Chris@69 6151 {
Chris@69 6152 return xstrdup (pathspec);
Chris@69 6153 }
Chris@69 6154
Chris@69 6155 tmp_pathspec = realpath (pathspec, buf);
Chris@69 6156 if (tmp_pathspec == 0)
Chris@69 6157 {
Chris@69 6158 lt_fatal (__FILE__, __LINE__,
Chris@69 6159 "could not follow symlinks for %s", pathspec);
Chris@69 6160 }
Chris@69 6161 return xstrdup (tmp_pathspec);
Chris@69 6162 #endif
Chris@69 6163 }
Chris@69 6164
Chris@69 6165 char *
Chris@69 6166 strendzap (char *str, const char *pat)
Chris@69 6167 {
Chris@69 6168 size_t len, patlen;
Chris@69 6169
Chris@69 6170 assert (str != NULL);
Chris@69 6171 assert (pat != NULL);
Chris@69 6172
Chris@69 6173 len = strlen (str);
Chris@69 6174 patlen = strlen (pat);
Chris@69 6175
Chris@69 6176 if (patlen <= len)
Chris@69 6177 {
Chris@69 6178 str += len - patlen;
Chris@69 6179 if (STREQ (str, pat))
Chris@69 6180 *str = '\0';
Chris@69 6181 }
Chris@69 6182 return str;
Chris@69 6183 }
Chris@69 6184
Chris@69 6185 void
Chris@69 6186 lt_debugprintf (const char *file, int line, const char *fmt, ...)
Chris@69 6187 {
Chris@69 6188 va_list args;
Chris@69 6189 if (lt_debug)
Chris@69 6190 {
Chris@69 6191 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
Chris@69 6192 va_start (args, fmt);
Chris@69 6193 (void) vfprintf (stderr, fmt, args);
Chris@69 6194 va_end (args);
Chris@69 6195 }
Chris@69 6196 }
Chris@69 6197
Chris@69 6198 static void
Chris@69 6199 lt_error_core (int exit_status, const char *file,
Chris@69 6200 int line, const char *mode,
Chris@69 6201 const char *message, va_list ap)
Chris@69 6202 {
Chris@69 6203 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
Chris@69 6204 vfprintf (stderr, message, ap);
Chris@69 6205 fprintf (stderr, ".\n");
Chris@69 6206
Chris@69 6207 if (exit_status >= 0)
Chris@69 6208 exit (exit_status);
Chris@69 6209 }
Chris@69 6210
Chris@69 6211 void
Chris@69 6212 lt_fatal (const char *file, int line, const char *message, ...)
Chris@69 6213 {
Chris@69 6214 va_list ap;
Chris@69 6215 va_start (ap, message);
Chris@69 6216 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
Chris@69 6217 va_end (ap);
Chris@69 6218 }
Chris@69 6219
Chris@69 6220 static const char *
Chris@69 6221 nonnull (const char *s)
Chris@69 6222 {
Chris@69 6223 return s ? s : "(null)";
Chris@69 6224 }
Chris@69 6225
Chris@69 6226 static const char *
Chris@69 6227 nonempty (const char *s)
Chris@69 6228 {
Chris@69 6229 return (s && !*s) ? "(empty)" : nonnull (s);
Chris@69 6230 }
Chris@69 6231
Chris@69 6232 void
Chris@69 6233 lt_setenv (const char *name, const char *value)
Chris@69 6234 {
Chris@69 6235 lt_debugprintf (__FILE__, __LINE__,
Chris@69 6236 "(lt_setenv) setting '%s' to '%s'\n",
Chris@69 6237 nonnull (name), nonnull (value));
Chris@69 6238 {
Chris@69 6239 #ifdef HAVE_SETENV
Chris@69 6240 /* always make a copy, for consistency with !HAVE_SETENV */
Chris@69 6241 char *str = xstrdup (value);
Chris@69 6242 setenv (name, str, 1);
Chris@69 6243 #else
Chris@69 6244 size_t len = strlen (name) + 1 + strlen (value) + 1;
Chris@69 6245 char *str = XMALLOC (char, len);
Chris@69 6246 sprintf (str, "%s=%s", name, value);
Chris@69 6247 if (putenv (str) != EXIT_SUCCESS)
Chris@69 6248 {
Chris@69 6249 XFREE (str);
Chris@69 6250 }
Chris@69 6251 #endif
Chris@69 6252 }
Chris@69 6253 }
Chris@69 6254
Chris@69 6255 char *
Chris@69 6256 lt_extend_str (const char *orig_value, const char *add, int to_end)
Chris@69 6257 {
Chris@69 6258 char *new_value;
Chris@69 6259 if (orig_value && *orig_value)
Chris@69 6260 {
Chris@69 6261 size_t orig_value_len = strlen (orig_value);
Chris@69 6262 size_t add_len = strlen (add);
Chris@69 6263 new_value = XMALLOC (char, add_len + orig_value_len + 1);
Chris@69 6264 if (to_end)
Chris@69 6265 {
Chris@69 6266 strcpy (new_value, orig_value);
Chris@69 6267 strcpy (new_value + orig_value_len, add);
Chris@69 6268 }
Chris@69 6269 else
Chris@69 6270 {
Chris@69 6271 strcpy (new_value, add);
Chris@69 6272 strcpy (new_value + add_len, orig_value);
Chris@69 6273 }
Chris@69 6274 }
Chris@69 6275 else
Chris@69 6276 {
Chris@69 6277 new_value = xstrdup (add);
Chris@69 6278 }
Chris@69 6279 return new_value;
Chris@69 6280 }
Chris@69 6281
Chris@69 6282 void
Chris@69 6283 lt_update_exe_path (const char *name, const char *value)
Chris@69 6284 {
Chris@69 6285 lt_debugprintf (__FILE__, __LINE__,
Chris@69 6286 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
Chris@69 6287 nonnull (name), nonnull (value));
Chris@69 6288
Chris@69 6289 if (name && *name && value && *value)
Chris@69 6290 {
Chris@69 6291 char *new_value = lt_extend_str (getenv (name), value, 0);
Chris@69 6292 /* some systems can't cope with a ':'-terminated path #' */
Chris@69 6293 size_t len = strlen (new_value);
Chris@69 6294 while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
Chris@69 6295 {
Chris@69 6296 new_value[--len] = '\0';
Chris@69 6297 }
Chris@69 6298 lt_setenv (name, new_value);
Chris@69 6299 XFREE (new_value);
Chris@69 6300 }
Chris@69 6301 }
Chris@69 6302
Chris@69 6303 void
Chris@69 6304 lt_update_lib_path (const char *name, const char *value)
Chris@69 6305 {
Chris@69 6306 lt_debugprintf (__FILE__, __LINE__,
Chris@69 6307 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
Chris@69 6308 nonnull (name), nonnull (value));
Chris@69 6309
Chris@69 6310 if (name && *name && value && *value)
Chris@69 6311 {
Chris@69 6312 char *new_value = lt_extend_str (getenv (name), value, 0);
Chris@69 6313 lt_setenv (name, new_value);
Chris@69 6314 XFREE (new_value);
Chris@69 6315 }
Chris@69 6316 }
Chris@69 6317
Chris@69 6318 EOF
Chris@69 6319 case $host_os in
Chris@69 6320 mingw*)
Chris@69 6321 cat <<"EOF"
Chris@69 6322
Chris@69 6323 /* Prepares an argument vector before calling spawn().
Chris@69 6324 Note that spawn() does not by itself call the command interpreter
Chris@69 6325 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
Chris@69 6326 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
Chris@69 6327 GetVersionEx(&v);
Chris@69 6328 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
Chris@69 6329 }) ? "cmd.exe" : "command.com").
Chris@69 6330 Instead it simply concatenates the arguments, separated by ' ', and calls
Chris@69 6331 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
Chris@69 6332 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
Chris@69 6333 special way:
Chris@69 6334 - Space and tab are interpreted as delimiters. They are not treated as
Chris@69 6335 delimiters if they are surrounded by double quotes: "...".
Chris@69 6336 - Unescaped double quotes are removed from the input. Their only effect is
Chris@69 6337 that within double quotes, space and tab are treated like normal
Chris@69 6338 characters.
Chris@69 6339 - Backslashes not followed by double quotes are not special.
Chris@69 6340 - But 2*n+1 backslashes followed by a double quote become
Chris@69 6341 n backslashes followed by a double quote (n >= 0):
Chris@69 6342 \" -> "
Chris@69 6343 \\\" -> \"
Chris@69 6344 \\\\\" -> \\"
Chris@69 6345 */
Chris@69 6346 #define SHELL_SPECIAL_CHARS "\"\\ \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
Chris@69 6347 #define SHELL_SPACE_CHARS " \001\002\003\004\005\006\007\010\011\012\013\014\015\016\017\020\021\022\023\024\025\026\027\030\031\032\033\034\035\036\037"
Chris@69 6348 char **
Chris@69 6349 prepare_spawn (char **argv)
Chris@69 6350 {
Chris@69 6351 size_t argc;
Chris@69 6352 char **new_argv;
Chris@69 6353 size_t i;
Chris@69 6354
Chris@69 6355 /* Count number of arguments. */
Chris@69 6356 for (argc = 0; argv[argc] != NULL; argc++)
Chris@69 6357 ;
Chris@69 6358
Chris@69 6359 /* Allocate new argument vector. */
Chris@69 6360 new_argv = XMALLOC (char *, argc + 1);
Chris@69 6361
Chris@69 6362 /* Put quoted arguments into the new argument vector. */
Chris@69 6363 for (i = 0; i < argc; i++)
Chris@69 6364 {
Chris@69 6365 const char *string = argv[i];
Chris@69 6366
Chris@69 6367 if (string[0] == '\0')
Chris@69 6368 new_argv[i] = xstrdup ("\"\"");
Chris@69 6369 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
Chris@69 6370 {
Chris@69 6371 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
Chris@69 6372 size_t length;
Chris@69 6373 unsigned int backslashes;
Chris@69 6374 const char *s;
Chris@69 6375 char *quoted_string;
Chris@69 6376 char *p;
Chris@69 6377
Chris@69 6378 length = 0;
Chris@69 6379 backslashes = 0;
Chris@69 6380 if (quote_around)
Chris@69 6381 length++;
Chris@69 6382 for (s = string; *s != '\0'; s++)
Chris@69 6383 {
Chris@69 6384 char c = *s;
Chris@69 6385 if (c == '"')
Chris@69 6386 length += backslashes + 1;
Chris@69 6387 length++;
Chris@69 6388 if (c == '\\')
Chris@69 6389 backslashes++;
Chris@69 6390 else
Chris@69 6391 backslashes = 0;
Chris@69 6392 }
Chris@69 6393 if (quote_around)
Chris@69 6394 length += backslashes + 1;
Chris@69 6395
Chris@69 6396 quoted_string = XMALLOC (char, length + 1);
Chris@69 6397
Chris@69 6398 p = quoted_string;
Chris@69 6399 backslashes = 0;
Chris@69 6400 if (quote_around)
Chris@69 6401 *p++ = '"';
Chris@69 6402 for (s = string; *s != '\0'; s++)
Chris@69 6403 {
Chris@69 6404 char c = *s;
Chris@69 6405 if (c == '"')
Chris@69 6406 {
Chris@69 6407 unsigned int j;
Chris@69 6408 for (j = backslashes + 1; j > 0; j--)
Chris@69 6409 *p++ = '\\';
Chris@69 6410 }
Chris@69 6411 *p++ = c;
Chris@69 6412 if (c == '\\')
Chris@69 6413 backslashes++;
Chris@69 6414 else
Chris@69 6415 backslashes = 0;
Chris@69 6416 }
Chris@69 6417 if (quote_around)
Chris@69 6418 {
Chris@69 6419 unsigned int j;
Chris@69 6420 for (j = backslashes; j > 0; j--)
Chris@69 6421 *p++ = '\\';
Chris@69 6422 *p++ = '"';
Chris@69 6423 }
Chris@69 6424 *p = '\0';
Chris@69 6425
Chris@69 6426 new_argv[i] = quoted_string;
Chris@69 6427 }
Chris@69 6428 else
Chris@69 6429 new_argv[i] = (char *) string;
Chris@69 6430 }
Chris@69 6431 new_argv[argc] = NULL;
Chris@69 6432
Chris@69 6433 return new_argv;
Chris@69 6434 }
Chris@69 6435 EOF
Chris@69 6436 ;;
Chris@69 6437 esac
Chris@69 6438
Chris@69 6439 cat <<"EOF"
Chris@69 6440 void lt_dump_script (FILE* f)
Chris@69 6441 {
Chris@69 6442 EOF
Chris@69 6443 func_emit_wrapper yes |
Chris@69 6444 $SED -n -e '
Chris@69 6445 s/^\(.\{79\}\)\(..*\)/\1\
Chris@69 6446 \2/
Chris@69 6447 h
Chris@69 6448 s/\([\\"]\)/\\\1/g
Chris@69 6449 s/$/\\n/
Chris@69 6450 s/\([^\n]*\).*/ fputs ("\1", f);/p
Chris@69 6451 g
Chris@69 6452 D'
Chris@69 6453 cat <<"EOF"
Chris@69 6454 }
Chris@69 6455 EOF
Chris@69 6456 }
Chris@69 6457 # end: func_emit_cwrapperexe_src
Chris@69 6458
Chris@69 6459 # func_win32_import_lib_p ARG
Chris@69 6460 # True if ARG is an import lib, as indicated by $file_magic_cmd
Chris@69 6461 func_win32_import_lib_p ()
Chris@69 6462 {
Chris@69 6463 $debug_cmd
Chris@69 6464
Chris@69 6465 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
Chris@69 6466 *import*) : ;;
Chris@69 6467 *) false ;;
Chris@69 6468 esac
Chris@69 6469 }
Chris@69 6470
Chris@69 6471 # func_suncc_cstd_abi
Chris@69 6472 # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
Chris@69 6473 # Several compiler flags select an ABI that is incompatible with the
Chris@69 6474 # Cstd library. Avoid specifying it if any are in CXXFLAGS.
Chris@69 6475 func_suncc_cstd_abi ()
Chris@69 6476 {
Chris@69 6477 $debug_cmd
Chris@69 6478
Chris@69 6479 case " $compile_command " in
Chris@69 6480 *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
Chris@69 6481 suncc_use_cstd_abi=no
Chris@69 6482 ;;
Chris@69 6483 *)
Chris@69 6484 suncc_use_cstd_abi=yes
Chris@69 6485 ;;
Chris@69 6486 esac
Chris@69 6487 }
Chris@69 6488
Chris@69 6489 # func_mode_link arg...
Chris@69 6490 func_mode_link ()
Chris@69 6491 {
Chris@69 6492 $debug_cmd
Chris@69 6493
Chris@69 6494 case $host in
Chris@69 6495 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
Chris@69 6496 # It is impossible to link a dll without this setting, and
Chris@69 6497 # we shouldn't force the makefile maintainer to figure out
Chris@69 6498 # what system we are compiling for in order to pass an extra
Chris@69 6499 # flag for every libtool invocation.
Chris@69 6500 # allow_undefined=no
Chris@69 6501
Chris@69 6502 # FIXME: Unfortunately, there are problems with the above when trying
Chris@69 6503 # to make a dll that has undefined symbols, in which case not
Chris@69 6504 # even a static library is built. For now, we need to specify
Chris@69 6505 # -no-undefined on the libtool link line when we can be certain
Chris@69 6506 # that all symbols are satisfied, otherwise we get a static library.
Chris@69 6507 allow_undefined=yes
Chris@69 6508 ;;
Chris@69 6509 *)
Chris@69 6510 allow_undefined=yes
Chris@69 6511 ;;
Chris@69 6512 esac
Chris@69 6513 libtool_args=$nonopt
Chris@69 6514 base_compile="$nonopt $@"
Chris@69 6515 compile_command=$nonopt
Chris@69 6516 finalize_command=$nonopt
Chris@69 6517
Chris@69 6518 compile_rpath=
Chris@69 6519 finalize_rpath=
Chris@69 6520 compile_shlibpath=
Chris@69 6521 finalize_shlibpath=
Chris@69 6522 convenience=
Chris@69 6523 old_convenience=
Chris@69 6524 deplibs=
Chris@69 6525 old_deplibs=
Chris@69 6526 compiler_flags=
Chris@69 6527 linker_flags=
Chris@69 6528 dllsearchpath=
Chris@69 6529 lib_search_path=`pwd`
Chris@69 6530 inst_prefix_dir=
Chris@69 6531 new_inherited_linker_flags=
Chris@69 6532
Chris@69 6533 avoid_version=no
Chris@69 6534 bindir=
Chris@69 6535 dlfiles=
Chris@69 6536 dlprefiles=
Chris@69 6537 dlself=no
Chris@69 6538 export_dynamic=no
Chris@69 6539 export_symbols=
Chris@69 6540 export_symbols_regex=
Chris@69 6541 generated=
Chris@69 6542 libobjs=
Chris@69 6543 ltlibs=
Chris@69 6544 module=no
Chris@69 6545 no_install=no
Chris@69 6546 objs=
Chris@69 6547 os2dllname=
Chris@69 6548 non_pic_objects=
Chris@69 6549 precious_files_regex=
Chris@69 6550 prefer_static_libs=no
Chris@69 6551 preload=false
Chris@69 6552 prev=
Chris@69 6553 prevarg=
Chris@69 6554 release=
Chris@69 6555 rpath=
Chris@69 6556 xrpath=
Chris@69 6557 perm_rpath=
Chris@69 6558 temp_rpath=
Chris@69 6559 thread_safe=no
Chris@69 6560 vinfo=
Chris@69 6561 vinfo_number=no
Chris@69 6562 weak_libs=
Chris@69 6563 single_module=$wl-single_module
Chris@69 6564 func_infer_tag $base_compile
Chris@69 6565
Chris@69 6566 # We need to know -static, to get the right output filenames.
Chris@69 6567 for arg
Chris@69 6568 do
Chris@69 6569 case $arg in
Chris@69 6570 -shared)
Chris@69 6571 test yes != "$build_libtool_libs" \
Chris@69 6572 && func_fatal_configuration "cannot build a shared library"
Chris@69 6573 build_old_libs=no
Chris@69 6574 break
Chris@69 6575 ;;
Chris@69 6576 -all-static | -static | -static-libtool-libs)
Chris@69 6577 case $arg in
Chris@69 6578 -all-static)
Chris@69 6579 if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
Chris@69 6580 func_warning "complete static linking is impossible in this configuration"
Chris@69 6581 fi
Chris@69 6582 if test -n "$link_static_flag"; then
Chris@69 6583 dlopen_self=$dlopen_self_static
Chris@69 6584 fi
Chris@69 6585 prefer_static_libs=yes
Chris@69 6586 ;;
Chris@69 6587 -static)
Chris@69 6588 if test -z "$pic_flag" && test -n "$link_static_flag"; then
Chris@69 6589 dlopen_self=$dlopen_self_static
Chris@69 6590 fi
Chris@69 6591 prefer_static_libs=built
Chris@69 6592 ;;
Chris@69 6593 -static-libtool-libs)
Chris@69 6594 if test -z "$pic_flag" && test -n "$link_static_flag"; then
Chris@69 6595 dlopen_self=$dlopen_self_static
Chris@69 6596 fi
Chris@69 6597 prefer_static_libs=yes
Chris@69 6598 ;;
Chris@69 6599 esac
Chris@69 6600 build_libtool_libs=no
Chris@69 6601 build_old_libs=yes
Chris@69 6602 break
Chris@69 6603 ;;
Chris@69 6604 esac
Chris@69 6605 done
Chris@69 6606
Chris@69 6607 # See if our shared archives depend on static archives.
Chris@69 6608 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
Chris@69 6609
Chris@69 6610 # Go through the arguments, transforming them on the way.
Chris@69 6611 while test "$#" -gt 0; do
Chris@69 6612 arg=$1
Chris@69 6613 shift
Chris@69 6614 func_quote_for_eval "$arg"
Chris@69 6615 qarg=$func_quote_for_eval_unquoted_result
Chris@69 6616 func_append libtool_args " $func_quote_for_eval_result"
Chris@69 6617
Chris@69 6618 # If the previous option needs an argument, assign it.
Chris@69 6619 if test -n "$prev"; then
Chris@69 6620 case $prev in
Chris@69 6621 output)
Chris@69 6622 func_append compile_command " @OUTPUT@"
Chris@69 6623 func_append finalize_command " @OUTPUT@"
Chris@69 6624 ;;
Chris@69 6625 esac
Chris@69 6626
Chris@69 6627 case $prev in
Chris@69 6628 bindir)
Chris@69 6629 bindir=$arg
Chris@69 6630 prev=
Chris@69 6631 continue
Chris@69 6632 ;;
Chris@69 6633 dlfiles|dlprefiles)
Chris@69 6634 $preload || {
Chris@69 6635 # Add the symbol object into the linking commands.
Chris@69 6636 func_append compile_command " @SYMFILE@"
Chris@69 6637 func_append finalize_command " @SYMFILE@"
Chris@69 6638 preload=:
Chris@69 6639 }
Chris@69 6640 case $arg in
Chris@69 6641 *.la | *.lo) ;; # We handle these cases below.
Chris@69 6642 force)
Chris@69 6643 if test no = "$dlself"; then
Chris@69 6644 dlself=needless
Chris@69 6645 export_dynamic=yes
Chris@69 6646 fi
Chris@69 6647 prev=
Chris@69 6648 continue
Chris@69 6649 ;;
Chris@69 6650 self)
Chris@69 6651 if test dlprefiles = "$prev"; then
Chris@69 6652 dlself=yes
Chris@69 6653 elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
Chris@69 6654 dlself=yes
Chris@69 6655 else
Chris@69 6656 dlself=needless
Chris@69 6657 export_dynamic=yes
Chris@69 6658 fi
Chris@69 6659 prev=
Chris@69 6660 continue
Chris@69 6661 ;;
Chris@69 6662 *)
Chris@69 6663 if test dlfiles = "$prev"; then
Chris@69 6664 func_append dlfiles " $arg"
Chris@69 6665 else
Chris@69 6666 func_append dlprefiles " $arg"
Chris@69 6667 fi
Chris@69 6668 prev=
Chris@69 6669 continue
Chris@69 6670 ;;
Chris@69 6671 esac
Chris@69 6672 ;;
Chris@69 6673 expsyms)
Chris@69 6674 export_symbols=$arg
Chris@69 6675 test -f "$arg" \
Chris@69 6676 || func_fatal_error "symbol file '$arg' does not exist"
Chris@69 6677 prev=
Chris@69 6678 continue
Chris@69 6679 ;;
Chris@69 6680 expsyms_regex)
Chris@69 6681 export_symbols_regex=$arg
Chris@69 6682 prev=
Chris@69 6683 continue
Chris@69 6684 ;;
Chris@69 6685 framework)
Chris@69 6686 case $host in
Chris@69 6687 *-*-darwin*)
Chris@69 6688 case "$deplibs " in
Chris@69 6689 *" $qarg.ltframework "*) ;;
Chris@69 6690 *) func_append deplibs " $qarg.ltframework" # this is fixed later
Chris@69 6691 ;;
Chris@69 6692 esac
Chris@69 6693 ;;
Chris@69 6694 esac
Chris@69 6695 prev=
Chris@69 6696 continue
Chris@69 6697 ;;
Chris@69 6698 inst_prefix)
Chris@69 6699 inst_prefix_dir=$arg
Chris@69 6700 prev=
Chris@69 6701 continue
Chris@69 6702 ;;
Chris@69 6703 mllvm)
Chris@69 6704 # Clang does not use LLVM to link, so we can simply discard any
Chris@69 6705 # '-mllvm $arg' options when doing the link step.
Chris@69 6706 prev=
Chris@69 6707 continue
Chris@69 6708 ;;
Chris@69 6709 objectlist)
Chris@69 6710 if test -f "$arg"; then
Chris@69 6711 save_arg=$arg
Chris@69 6712 moreargs=
Chris@69 6713 for fil in `cat "$save_arg"`
Chris@69 6714 do
Chris@69 6715 # func_append moreargs " $fil"
Chris@69 6716 arg=$fil
Chris@69 6717 # A libtool-controlled object.
Chris@69 6718
Chris@69 6719 # Check to see that this really is a libtool object.
Chris@69 6720 if func_lalib_unsafe_p "$arg"; then
Chris@69 6721 pic_object=
Chris@69 6722 non_pic_object=
Chris@69 6723
Chris@69 6724 # Read the .lo file
Chris@69 6725 func_source "$arg"
Chris@69 6726
Chris@69 6727 if test -z "$pic_object" ||
Chris@69 6728 test -z "$non_pic_object" ||
Chris@69 6729 test none = "$pic_object" &&
Chris@69 6730 test none = "$non_pic_object"; then
Chris@69 6731 func_fatal_error "cannot find name of object for '$arg'"
Chris@69 6732 fi
Chris@69 6733
Chris@69 6734 # Extract subdirectory from the argument.
Chris@69 6735 func_dirname "$arg" "/" ""
Chris@69 6736 xdir=$func_dirname_result
Chris@69 6737
Chris@69 6738 if test none != "$pic_object"; then
Chris@69 6739 # Prepend the subdirectory the object is found in.
Chris@69 6740 pic_object=$xdir$pic_object
Chris@69 6741
Chris@69 6742 if test dlfiles = "$prev"; then
Chris@69 6743 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
Chris@69 6744 func_append dlfiles " $pic_object"
Chris@69 6745 prev=
Chris@69 6746 continue
Chris@69 6747 else
Chris@69 6748 # If libtool objects are unsupported, then we need to preload.
Chris@69 6749 prev=dlprefiles
Chris@69 6750 fi
Chris@69 6751 fi
Chris@69 6752
Chris@69 6753 # CHECK ME: I think I busted this. -Ossama
Chris@69 6754 if test dlprefiles = "$prev"; then
Chris@69 6755 # Preload the old-style object.
Chris@69 6756 func_append dlprefiles " $pic_object"
Chris@69 6757 prev=
Chris@69 6758 fi
Chris@69 6759
Chris@69 6760 # A PIC object.
Chris@69 6761 func_append libobjs " $pic_object"
Chris@69 6762 arg=$pic_object
Chris@69 6763 fi
Chris@69 6764
Chris@69 6765 # Non-PIC object.
Chris@69 6766 if test none != "$non_pic_object"; then
Chris@69 6767 # Prepend the subdirectory the object is found in.
Chris@69 6768 non_pic_object=$xdir$non_pic_object
Chris@69 6769
Chris@69 6770 # A standard non-PIC object
Chris@69 6771 func_append non_pic_objects " $non_pic_object"
Chris@69 6772 if test -z "$pic_object" || test none = "$pic_object"; then
Chris@69 6773 arg=$non_pic_object
Chris@69 6774 fi
Chris@69 6775 else
Chris@69 6776 # If the PIC object exists, use it instead.
Chris@69 6777 # $xdir was prepended to $pic_object above.
Chris@69 6778 non_pic_object=$pic_object
Chris@69 6779 func_append non_pic_objects " $non_pic_object"
Chris@69 6780 fi
Chris@69 6781 else
Chris@69 6782 # Only an error if not doing a dry-run.
Chris@69 6783 if $opt_dry_run; then
Chris@69 6784 # Extract subdirectory from the argument.
Chris@69 6785 func_dirname "$arg" "/" ""
Chris@69 6786 xdir=$func_dirname_result
Chris@69 6787
Chris@69 6788 func_lo2o "$arg"
Chris@69 6789 pic_object=$xdir$objdir/$func_lo2o_result
Chris@69 6790 non_pic_object=$xdir$func_lo2o_result
Chris@69 6791 func_append libobjs " $pic_object"
Chris@69 6792 func_append non_pic_objects " $non_pic_object"
Chris@69 6793 else
Chris@69 6794 func_fatal_error "'$arg' is not a valid libtool object"
Chris@69 6795 fi
Chris@69 6796 fi
Chris@69 6797 done
Chris@69 6798 else
Chris@69 6799 func_fatal_error "link input file '$arg' does not exist"
Chris@69 6800 fi
Chris@69 6801 arg=$save_arg
Chris@69 6802 prev=
Chris@69 6803 continue
Chris@69 6804 ;;
Chris@69 6805 os2dllname)
Chris@69 6806 os2dllname=$arg
Chris@69 6807 prev=
Chris@69 6808 continue
Chris@69 6809 ;;
Chris@69 6810 precious_regex)
Chris@69 6811 precious_files_regex=$arg
Chris@69 6812 prev=
Chris@69 6813 continue
Chris@69 6814 ;;
Chris@69 6815 release)
Chris@69 6816 release=-$arg
Chris@69 6817 prev=
Chris@69 6818 continue
Chris@69 6819 ;;
Chris@69 6820 rpath | xrpath)
Chris@69 6821 # We need an absolute path.
Chris@69 6822 case $arg in
Chris@69 6823 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@69 6824 *)
Chris@69 6825 func_fatal_error "only absolute run-paths are allowed"
Chris@69 6826 ;;
Chris@69 6827 esac
Chris@69 6828 if test rpath = "$prev"; then
Chris@69 6829 case "$rpath " in
Chris@69 6830 *" $arg "*) ;;
Chris@69 6831 *) func_append rpath " $arg" ;;
Chris@69 6832 esac
Chris@69 6833 else
Chris@69 6834 case "$xrpath " in
Chris@69 6835 *" $arg "*) ;;
Chris@69 6836 *) func_append xrpath " $arg" ;;
Chris@69 6837 esac
Chris@69 6838 fi
Chris@69 6839 prev=
Chris@69 6840 continue
Chris@69 6841 ;;
Chris@69 6842 shrext)
Chris@69 6843 shrext_cmds=$arg
Chris@69 6844 prev=
Chris@69 6845 continue
Chris@69 6846 ;;
Chris@69 6847 weak)
Chris@69 6848 func_append weak_libs " $arg"
Chris@69 6849 prev=
Chris@69 6850 continue
Chris@69 6851 ;;
Chris@69 6852 xcclinker)
Chris@69 6853 func_append linker_flags " $qarg"
Chris@69 6854 func_append compiler_flags " $qarg"
Chris@69 6855 prev=
Chris@69 6856 func_append compile_command " $qarg"
Chris@69 6857 func_append finalize_command " $qarg"
Chris@69 6858 continue
Chris@69 6859 ;;
Chris@69 6860 xcompiler)
Chris@69 6861 func_append compiler_flags " $qarg"
Chris@69 6862 prev=
Chris@69 6863 func_append compile_command " $qarg"
Chris@69 6864 func_append finalize_command " $qarg"
Chris@69 6865 continue
Chris@69 6866 ;;
Chris@69 6867 xlinker)
Chris@69 6868 func_append linker_flags " $qarg"
Chris@69 6869 func_append compiler_flags " $wl$qarg"
Chris@69 6870 prev=
Chris@69 6871 func_append compile_command " $wl$qarg"
Chris@69 6872 func_append finalize_command " $wl$qarg"
Chris@69 6873 continue
Chris@69 6874 ;;
Chris@69 6875 *)
Chris@69 6876 eval "$prev=\"\$arg\""
Chris@69 6877 prev=
Chris@69 6878 continue
Chris@69 6879 ;;
Chris@69 6880 esac
Chris@69 6881 fi # test -n "$prev"
Chris@69 6882
Chris@69 6883 prevarg=$arg
Chris@69 6884
Chris@69 6885 case $arg in
Chris@69 6886 -all-static)
Chris@69 6887 if test -n "$link_static_flag"; then
Chris@69 6888 # See comment for -static flag below, for more details.
Chris@69 6889 func_append compile_command " $link_static_flag"
Chris@69 6890 func_append finalize_command " $link_static_flag"
Chris@69 6891 fi
Chris@69 6892 continue
Chris@69 6893 ;;
Chris@69 6894
Chris@69 6895 -allow-undefined)
Chris@69 6896 # FIXME: remove this flag sometime in the future.
Chris@69 6897 func_fatal_error "'-allow-undefined' must not be used because it is the default"
Chris@69 6898 ;;
Chris@69 6899
Chris@69 6900 -avoid-version)
Chris@69 6901 avoid_version=yes
Chris@69 6902 continue
Chris@69 6903 ;;
Chris@69 6904
Chris@69 6905 -bindir)
Chris@69 6906 prev=bindir
Chris@69 6907 continue
Chris@69 6908 ;;
Chris@69 6909
Chris@69 6910 -dlopen)
Chris@69 6911 prev=dlfiles
Chris@69 6912 continue
Chris@69 6913 ;;
Chris@69 6914
Chris@69 6915 -dlpreopen)
Chris@69 6916 prev=dlprefiles
Chris@69 6917 continue
Chris@69 6918 ;;
Chris@69 6919
Chris@69 6920 -export-dynamic)
Chris@69 6921 export_dynamic=yes
Chris@69 6922 continue
Chris@69 6923 ;;
Chris@69 6924
Chris@69 6925 -export-symbols | -export-symbols-regex)
Chris@69 6926 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
Chris@69 6927 func_fatal_error "more than one -exported-symbols argument is not allowed"
Chris@69 6928 fi
Chris@69 6929 if test X-export-symbols = "X$arg"; then
Chris@69 6930 prev=expsyms
Chris@69 6931 else
Chris@69 6932 prev=expsyms_regex
Chris@69 6933 fi
Chris@69 6934 continue
Chris@69 6935 ;;
Chris@69 6936
Chris@69 6937 -framework)
Chris@69 6938 prev=framework
Chris@69 6939 continue
Chris@69 6940 ;;
Chris@69 6941
Chris@69 6942 -inst-prefix-dir)
Chris@69 6943 prev=inst_prefix
Chris@69 6944 continue
Chris@69 6945 ;;
Chris@69 6946
Chris@69 6947 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
Chris@69 6948 # so, if we see these flags be careful not to treat them like -L
Chris@69 6949 -L[A-Z][A-Z]*:*)
Chris@69 6950 case $with_gcc/$host in
Chris@69 6951 no/*-*-irix* | /*-*-irix*)
Chris@69 6952 func_append compile_command " $arg"
Chris@69 6953 func_append finalize_command " $arg"
Chris@69 6954 ;;
Chris@69 6955 esac
Chris@69 6956 continue
Chris@69 6957 ;;
Chris@69 6958
Chris@69 6959 -L*)
Chris@69 6960 func_stripname "-L" '' "$arg"
Chris@69 6961 if test -z "$func_stripname_result"; then
Chris@69 6962 if test "$#" -gt 0; then
Chris@69 6963 func_fatal_error "require no space between '-L' and '$1'"
Chris@69 6964 else
Chris@69 6965 func_fatal_error "need path for '-L' option"
Chris@69 6966 fi
Chris@69 6967 fi
Chris@69 6968 func_resolve_sysroot "$func_stripname_result"
Chris@69 6969 dir=$func_resolve_sysroot_result
Chris@69 6970 # We need an absolute path.
Chris@69 6971 case $dir in
Chris@69 6972 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@69 6973 *)
Chris@69 6974 absdir=`cd "$dir" && pwd`
Chris@69 6975 test -z "$absdir" && \
Chris@69 6976 func_fatal_error "cannot determine absolute directory name of '$dir'"
Chris@69 6977 dir=$absdir
Chris@69 6978 ;;
Chris@69 6979 esac
Chris@69 6980 case "$deplibs " in
Chris@69 6981 *" -L$dir "* | *" $arg "*)
Chris@69 6982 # Will only happen for absolute or sysroot arguments
Chris@69 6983 ;;
Chris@69 6984 *)
Chris@69 6985 # Preserve sysroot, but never include relative directories
Chris@69 6986 case $dir in
Chris@69 6987 [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
Chris@69 6988 *) func_append deplibs " -L$dir" ;;
Chris@69 6989 esac
Chris@69 6990 func_append lib_search_path " $dir"
Chris@69 6991 ;;
Chris@69 6992 esac
Chris@69 6993 case $host in
Chris@69 6994 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
Chris@69 6995 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
Chris@69 6996 case :$dllsearchpath: in
Chris@69 6997 *":$dir:"*) ;;
Chris@69 6998 ::) dllsearchpath=$dir;;
Chris@69 6999 *) func_append dllsearchpath ":$dir";;
Chris@69 7000 esac
Chris@69 7001 case :$dllsearchpath: in
Chris@69 7002 *":$testbindir:"*) ;;
Chris@69 7003 ::) dllsearchpath=$testbindir;;
Chris@69 7004 *) func_append dllsearchpath ":$testbindir";;
Chris@69 7005 esac
Chris@69 7006 ;;
Chris@69 7007 esac
Chris@69 7008 continue
Chris@69 7009 ;;
Chris@69 7010
Chris@69 7011 -l*)
Chris@69 7012 if test X-lc = "X$arg" || test X-lm = "X$arg"; then
Chris@69 7013 case $host in
Chris@69 7014 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
Chris@69 7015 # These systems don't actually have a C or math library (as such)
Chris@69 7016 continue
Chris@69 7017 ;;
Chris@69 7018 *-*-os2*)
Chris@69 7019 # These systems don't actually have a C library (as such)
Chris@69 7020 test X-lc = "X$arg" && continue
Chris@69 7021 ;;
Chris@69 7022 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
Chris@69 7023 # Do not include libc due to us having libc/libc_r.
Chris@69 7024 test X-lc = "X$arg" && continue
Chris@69 7025 ;;
Chris@69 7026 *-*-rhapsody* | *-*-darwin1.[012])
Chris@69 7027 # Rhapsody C and math libraries are in the System framework
Chris@69 7028 func_append deplibs " System.ltframework"
Chris@69 7029 continue
Chris@69 7030 ;;
Chris@69 7031 *-*-sco3.2v5* | *-*-sco5v6*)
Chris@69 7032 # Causes problems with __ctype
Chris@69 7033 test X-lc = "X$arg" && continue
Chris@69 7034 ;;
Chris@69 7035 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
Chris@69 7036 # Compiler inserts libc in the correct place for threads to work
Chris@69 7037 test X-lc = "X$arg" && continue
Chris@69 7038 ;;
Chris@69 7039 esac
Chris@69 7040 elif test X-lc_r = "X$arg"; then
Chris@69 7041 case $host in
Chris@69 7042 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
Chris@69 7043 # Do not include libc_r directly, use -pthread flag.
Chris@69 7044 continue
Chris@69 7045 ;;
Chris@69 7046 esac
Chris@69 7047 fi
Chris@69 7048 func_append deplibs " $arg"
Chris@69 7049 continue
Chris@69 7050 ;;
Chris@69 7051
Chris@69 7052 -mllvm)
Chris@69 7053 prev=mllvm
Chris@69 7054 continue
Chris@69 7055 ;;
Chris@69 7056
Chris@69 7057 -module)
Chris@69 7058 module=yes
Chris@69 7059 continue
Chris@69 7060 ;;
Chris@69 7061
Chris@69 7062 # Tru64 UNIX uses -model [arg] to determine the layout of C++
Chris@69 7063 # classes, name mangling, and exception handling.
Chris@69 7064 # Darwin uses the -arch flag to determine output architecture.
Chris@69 7065 -model|-arch|-isysroot|--sysroot)
Chris@69 7066 func_append compiler_flags " $arg"
Chris@69 7067 func_append compile_command " $arg"
Chris@69 7068 func_append finalize_command " $arg"
Chris@69 7069 prev=xcompiler
Chris@69 7070 continue
Chris@69 7071 ;;
Chris@69 7072
Chris@69 7073 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
Chris@69 7074 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
Chris@69 7075 func_append compiler_flags " $arg"
Chris@69 7076 func_append compile_command " $arg"
Chris@69 7077 func_append finalize_command " $arg"
Chris@69 7078 case "$new_inherited_linker_flags " in
Chris@69 7079 *" $arg "*) ;;
Chris@69 7080 * ) func_append new_inherited_linker_flags " $arg" ;;
Chris@69 7081 esac
Chris@69 7082 continue
Chris@69 7083 ;;
Chris@69 7084
Chris@69 7085 -multi_module)
Chris@69 7086 single_module=$wl-multi_module
Chris@69 7087 continue
Chris@69 7088 ;;
Chris@69 7089
Chris@69 7090 -no-fast-install)
Chris@69 7091 fast_install=no
Chris@69 7092 continue
Chris@69 7093 ;;
Chris@69 7094
Chris@69 7095 -no-install)
Chris@69 7096 case $host in
Chris@69 7097 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
Chris@69 7098 # The PATH hackery in wrapper scripts is required on Windows
Chris@69 7099 # and Darwin in order for the loader to find any dlls it needs.
Chris@69 7100 func_warning "'-no-install' is ignored for $host"
Chris@69 7101 func_warning "assuming '-no-fast-install' instead"
Chris@69 7102 fast_install=no
Chris@69 7103 ;;
Chris@69 7104 *) no_install=yes ;;
Chris@69 7105 esac
Chris@69 7106 continue
Chris@69 7107 ;;
Chris@69 7108
Chris@69 7109 -no-undefined)
Chris@69 7110 allow_undefined=no
Chris@69 7111 continue
Chris@69 7112 ;;
Chris@69 7113
Chris@69 7114 -objectlist)
Chris@69 7115 prev=objectlist
Chris@69 7116 continue
Chris@69 7117 ;;
Chris@69 7118
Chris@69 7119 -os2dllname)
Chris@69 7120 prev=os2dllname
Chris@69 7121 continue
Chris@69 7122 ;;
Chris@69 7123
Chris@69 7124 -o) prev=output ;;
Chris@69 7125
Chris@69 7126 -precious-files-regex)
Chris@69 7127 prev=precious_regex
Chris@69 7128 continue
Chris@69 7129 ;;
Chris@69 7130
Chris@69 7131 -release)
Chris@69 7132 prev=release
Chris@69 7133 continue
Chris@69 7134 ;;
Chris@69 7135
Chris@69 7136 -rpath)
Chris@69 7137 prev=rpath
Chris@69 7138 continue
Chris@69 7139 ;;
Chris@69 7140
Chris@69 7141 -R)
Chris@69 7142 prev=xrpath
Chris@69 7143 continue
Chris@69 7144 ;;
Chris@69 7145
Chris@69 7146 -R*)
Chris@69 7147 func_stripname '-R' '' "$arg"
Chris@69 7148 dir=$func_stripname_result
Chris@69 7149 # We need an absolute path.
Chris@69 7150 case $dir in
Chris@69 7151 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@69 7152 =*)
Chris@69 7153 func_stripname '=' '' "$dir"
Chris@69 7154 dir=$lt_sysroot$func_stripname_result
Chris@69 7155 ;;
Chris@69 7156 *)
Chris@69 7157 func_fatal_error "only absolute run-paths are allowed"
Chris@69 7158 ;;
Chris@69 7159 esac
Chris@69 7160 case "$xrpath " in
Chris@69 7161 *" $dir "*) ;;
Chris@69 7162 *) func_append xrpath " $dir" ;;
Chris@69 7163 esac
Chris@69 7164 continue
Chris@69 7165 ;;
Chris@69 7166
Chris@69 7167 -shared)
Chris@69 7168 # The effects of -shared are defined in a previous loop.
Chris@69 7169 continue
Chris@69 7170 ;;
Chris@69 7171
Chris@69 7172 -shrext)
Chris@69 7173 prev=shrext
Chris@69 7174 continue
Chris@69 7175 ;;
Chris@69 7176
Chris@69 7177 -static | -static-libtool-libs)
Chris@69 7178 # The effects of -static are defined in a previous loop.
Chris@69 7179 # We used to do the same as -all-static on platforms that
Chris@69 7180 # didn't have a PIC flag, but the assumption that the effects
Chris@69 7181 # would be equivalent was wrong. It would break on at least
Chris@69 7182 # Digital Unix and AIX.
Chris@69 7183 continue
Chris@69 7184 ;;
Chris@69 7185
Chris@69 7186 -thread-safe)
Chris@69 7187 thread_safe=yes
Chris@69 7188 continue
Chris@69 7189 ;;
Chris@69 7190
Chris@69 7191 -version-info)
Chris@69 7192 prev=vinfo
Chris@69 7193 continue
Chris@69 7194 ;;
Chris@69 7195
Chris@69 7196 -version-number)
Chris@69 7197 prev=vinfo
Chris@69 7198 vinfo_number=yes
Chris@69 7199 continue
Chris@69 7200 ;;
Chris@69 7201
Chris@69 7202 -weak)
Chris@69 7203 prev=weak
Chris@69 7204 continue
Chris@69 7205 ;;
Chris@69 7206
Chris@69 7207 -Wc,*)
Chris@69 7208 func_stripname '-Wc,' '' "$arg"
Chris@69 7209 args=$func_stripname_result
Chris@69 7210 arg=
Chris@69 7211 save_ifs=$IFS; IFS=,
Chris@69 7212 for flag in $args; do
Chris@69 7213 IFS=$save_ifs
Chris@69 7214 func_quote_for_eval "$flag"
Chris@69 7215 func_append arg " $func_quote_for_eval_result"
Chris@69 7216 func_append compiler_flags " $func_quote_for_eval_result"
Chris@69 7217 done
Chris@69 7218 IFS=$save_ifs
Chris@69 7219 func_stripname ' ' '' "$arg"
Chris@69 7220 arg=$func_stripname_result
Chris@69 7221 ;;
Chris@69 7222
Chris@69 7223 -Wl,*)
Chris@69 7224 func_stripname '-Wl,' '' "$arg"
Chris@69 7225 args=$func_stripname_result
Chris@69 7226 arg=
Chris@69 7227 save_ifs=$IFS; IFS=,
Chris@69 7228 for flag in $args; do
Chris@69 7229 IFS=$save_ifs
Chris@69 7230 func_quote_for_eval "$flag"
Chris@69 7231 func_append arg " $wl$func_quote_for_eval_result"
Chris@69 7232 func_append compiler_flags " $wl$func_quote_for_eval_result"
Chris@69 7233 func_append linker_flags " $func_quote_for_eval_result"
Chris@69 7234 done
Chris@69 7235 IFS=$save_ifs
Chris@69 7236 func_stripname ' ' '' "$arg"
Chris@69 7237 arg=$func_stripname_result
Chris@69 7238 ;;
Chris@69 7239
Chris@69 7240 -Xcompiler)
Chris@69 7241 prev=xcompiler
Chris@69 7242 continue
Chris@69 7243 ;;
Chris@69 7244
Chris@69 7245 -Xlinker)
Chris@69 7246 prev=xlinker
Chris@69 7247 continue
Chris@69 7248 ;;
Chris@69 7249
Chris@69 7250 -XCClinker)
Chris@69 7251 prev=xcclinker
Chris@69 7252 continue
Chris@69 7253 ;;
Chris@69 7254
Chris@69 7255 # -msg_* for osf cc
Chris@69 7256 -msg_*)
Chris@69 7257 func_quote_for_eval "$arg"
Chris@69 7258 arg=$func_quote_for_eval_result
Chris@69 7259 ;;
Chris@69 7260
Chris@69 7261 # Flags to be passed through unchanged, with rationale:
Chris@69 7262 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
Chris@69 7263 # -r[0-9][0-9]* specify processor for the SGI compiler
Chris@69 7264 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
Chris@69 7265 # +DA*, +DD* enable 64-bit mode for the HP compiler
Chris@69 7266 # -q* compiler args for the IBM compiler
Chris@69 7267 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
Chris@69 7268 # -F/path path to uninstalled frameworks, gcc on darwin
Chris@69 7269 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
Chris@69 7270 # -fstack-protector* stack protector flags for GCC
Chris@69 7271 # @file GCC response files
Chris@69 7272 # -tp=* Portland pgcc target processor selection
Chris@69 7273 # --sysroot=* for sysroot support
Chris@69 7274 # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
Chris@69 7275 # -stdlib=* select c++ std lib with clang
Chris@69 7276 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
Chris@69 7277 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
Chris@69 7278 -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*)
Chris@69 7279 func_quote_for_eval "$arg"
Chris@69 7280 arg=$func_quote_for_eval_result
Chris@69 7281 func_append compile_command " $arg"
Chris@69 7282 func_append finalize_command " $arg"
Chris@69 7283 func_append compiler_flags " $arg"
Chris@69 7284 continue
Chris@69 7285 ;;
Chris@69 7286
Chris@69 7287 -Z*)
Chris@69 7288 if test os2 = "`expr $host : '.*\(os2\)'`"; then
Chris@69 7289 # OS/2 uses -Zxxx to specify OS/2-specific options
Chris@69 7290 compiler_flags="$compiler_flags $arg"
Chris@69 7291 func_append compile_command " $arg"
Chris@69 7292 func_append finalize_command " $arg"
Chris@69 7293 case $arg in
Chris@69 7294 -Zlinker | -Zstack)
Chris@69 7295 prev=xcompiler
Chris@69 7296 ;;
Chris@69 7297 esac
Chris@69 7298 continue
Chris@69 7299 else
Chris@69 7300 # Otherwise treat like 'Some other compiler flag' below
Chris@69 7301 func_quote_for_eval "$arg"
Chris@69 7302 arg=$func_quote_for_eval_result
Chris@69 7303 fi
Chris@69 7304 ;;
Chris@69 7305
Chris@69 7306 # Some other compiler flag.
Chris@69 7307 -* | +*)
Chris@69 7308 func_quote_for_eval "$arg"
Chris@69 7309 arg=$func_quote_for_eval_result
Chris@69 7310 ;;
Chris@69 7311
Chris@69 7312 *.$objext)
Chris@69 7313 # A standard object.
Chris@69 7314 func_append objs " $arg"
Chris@69 7315 ;;
Chris@69 7316
Chris@69 7317 *.lo)
Chris@69 7318 # A libtool-controlled object.
Chris@69 7319
Chris@69 7320 # Check to see that this really is a libtool object.
Chris@69 7321 if func_lalib_unsafe_p "$arg"; then
Chris@69 7322 pic_object=
Chris@69 7323 non_pic_object=
Chris@69 7324
Chris@69 7325 # Read the .lo file
Chris@69 7326 func_source "$arg"
Chris@69 7327
Chris@69 7328 if test -z "$pic_object" ||
Chris@69 7329 test -z "$non_pic_object" ||
Chris@69 7330 test none = "$pic_object" &&
Chris@69 7331 test none = "$non_pic_object"; then
Chris@69 7332 func_fatal_error "cannot find name of object for '$arg'"
Chris@69 7333 fi
Chris@69 7334
Chris@69 7335 # Extract subdirectory from the argument.
Chris@69 7336 func_dirname "$arg" "/" ""
Chris@69 7337 xdir=$func_dirname_result
Chris@69 7338
Chris@69 7339 test none = "$pic_object" || {
Chris@69 7340 # Prepend the subdirectory the object is found in.
Chris@69 7341 pic_object=$xdir$pic_object
Chris@69 7342
Chris@69 7343 if test dlfiles = "$prev"; then
Chris@69 7344 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
Chris@69 7345 func_append dlfiles " $pic_object"
Chris@69 7346 prev=
Chris@69 7347 continue
Chris@69 7348 else
Chris@69 7349 # If libtool objects are unsupported, then we need to preload.
Chris@69 7350 prev=dlprefiles
Chris@69 7351 fi
Chris@69 7352 fi
Chris@69 7353
Chris@69 7354 # CHECK ME: I think I busted this. -Ossama
Chris@69 7355 if test dlprefiles = "$prev"; then
Chris@69 7356 # Preload the old-style object.
Chris@69 7357 func_append dlprefiles " $pic_object"
Chris@69 7358 prev=
Chris@69 7359 fi
Chris@69 7360
Chris@69 7361 # A PIC object.
Chris@69 7362 func_append libobjs " $pic_object"
Chris@69 7363 arg=$pic_object
Chris@69 7364 }
Chris@69 7365
Chris@69 7366 # Non-PIC object.
Chris@69 7367 if test none != "$non_pic_object"; then
Chris@69 7368 # Prepend the subdirectory the object is found in.
Chris@69 7369 non_pic_object=$xdir$non_pic_object
Chris@69 7370
Chris@69 7371 # A standard non-PIC object
Chris@69 7372 func_append non_pic_objects " $non_pic_object"
Chris@69 7373 if test -z "$pic_object" || test none = "$pic_object"; then
Chris@69 7374 arg=$non_pic_object
Chris@69 7375 fi
Chris@69 7376 else
Chris@69 7377 # If the PIC object exists, use it instead.
Chris@69 7378 # $xdir was prepended to $pic_object above.
Chris@69 7379 non_pic_object=$pic_object
Chris@69 7380 func_append non_pic_objects " $non_pic_object"
Chris@69 7381 fi
Chris@69 7382 else
Chris@69 7383 # Only an error if not doing a dry-run.
Chris@69 7384 if $opt_dry_run; then
Chris@69 7385 # Extract subdirectory from the argument.
Chris@69 7386 func_dirname "$arg" "/" ""
Chris@69 7387 xdir=$func_dirname_result
Chris@69 7388
Chris@69 7389 func_lo2o "$arg"
Chris@69 7390 pic_object=$xdir$objdir/$func_lo2o_result
Chris@69 7391 non_pic_object=$xdir$func_lo2o_result
Chris@69 7392 func_append libobjs " $pic_object"
Chris@69 7393 func_append non_pic_objects " $non_pic_object"
Chris@69 7394 else
Chris@69 7395 func_fatal_error "'$arg' is not a valid libtool object"
Chris@69 7396 fi
Chris@69 7397 fi
Chris@69 7398 ;;
Chris@69 7399
Chris@69 7400 *.$libext)
Chris@69 7401 # An archive.
Chris@69 7402 func_append deplibs " $arg"
Chris@69 7403 func_append old_deplibs " $arg"
Chris@69 7404 continue
Chris@69 7405 ;;
Chris@69 7406
Chris@69 7407 *.la)
Chris@69 7408 # A libtool-controlled library.
Chris@69 7409
Chris@69 7410 func_resolve_sysroot "$arg"
Chris@69 7411 if test dlfiles = "$prev"; then
Chris@69 7412 # This library was specified with -dlopen.
Chris@69 7413 func_append dlfiles " $func_resolve_sysroot_result"
Chris@69 7414 prev=
Chris@69 7415 elif test dlprefiles = "$prev"; then
Chris@69 7416 # The library was specified with -dlpreopen.
Chris@69 7417 func_append dlprefiles " $func_resolve_sysroot_result"
Chris@69 7418 prev=
Chris@69 7419 else
Chris@69 7420 func_append deplibs " $func_resolve_sysroot_result"
Chris@69 7421 fi
Chris@69 7422 continue
Chris@69 7423 ;;
Chris@69 7424
Chris@69 7425 # Some other compiler argument.
Chris@69 7426 *)
Chris@69 7427 # Unknown arguments in both finalize_command and compile_command need
Chris@69 7428 # to be aesthetically quoted because they are evaled later.
Chris@69 7429 func_quote_for_eval "$arg"
Chris@69 7430 arg=$func_quote_for_eval_result
Chris@69 7431 ;;
Chris@69 7432 esac # arg
Chris@69 7433
Chris@69 7434 # Now actually substitute the argument into the commands.
Chris@69 7435 if test -n "$arg"; then
Chris@69 7436 func_append compile_command " $arg"
Chris@69 7437 func_append finalize_command " $arg"
Chris@69 7438 fi
Chris@69 7439 done # argument parsing loop
Chris@69 7440
Chris@69 7441 test -n "$prev" && \
Chris@69 7442 func_fatal_help "the '$prevarg' option requires an argument"
Chris@69 7443
Chris@69 7444 if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
Chris@69 7445 eval arg=\"$export_dynamic_flag_spec\"
Chris@69 7446 func_append compile_command " $arg"
Chris@69 7447 func_append finalize_command " $arg"
Chris@69 7448 fi
Chris@69 7449
Chris@69 7450 oldlibs=
Chris@69 7451 # calculate the name of the file, without its directory
Chris@69 7452 func_basename "$output"
Chris@69 7453 outputname=$func_basename_result
Chris@69 7454 libobjs_save=$libobjs
Chris@69 7455
Chris@69 7456 if test -n "$shlibpath_var"; then
Chris@69 7457 # get the directories listed in $shlibpath_var
Chris@69 7458 eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
Chris@69 7459 else
Chris@69 7460 shlib_search_path=
Chris@69 7461 fi
Chris@69 7462 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
Chris@69 7463 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
Chris@69 7464
Chris@69 7465 # Definition is injected by LT_CONFIG during libtool generation.
Chris@69 7466 func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
Chris@69 7467
Chris@69 7468 func_dirname "$output" "/" ""
Chris@69 7469 output_objdir=$func_dirname_result$objdir
Chris@69 7470 func_to_tool_file "$output_objdir/"
Chris@69 7471 tool_output_objdir=$func_to_tool_file_result
Chris@69 7472 # Create the object directory.
Chris@69 7473 func_mkdir_p "$output_objdir"
Chris@69 7474
Chris@69 7475 # Determine the type of output
Chris@69 7476 case $output in
Chris@69 7477 "")
Chris@69 7478 func_fatal_help "you must specify an output file"
Chris@69 7479 ;;
Chris@69 7480 *.$libext) linkmode=oldlib ;;
Chris@69 7481 *.lo | *.$objext) linkmode=obj ;;
Chris@69 7482 *.la) linkmode=lib ;;
Chris@69 7483 *) linkmode=prog ;; # Anything else should be a program.
Chris@69 7484 esac
Chris@69 7485
Chris@69 7486 specialdeplibs=
Chris@69 7487
Chris@69 7488 libs=
Chris@69 7489 # Find all interdependent deplibs by searching for libraries
Chris@69 7490 # that are linked more than once (e.g. -la -lb -la)
Chris@69 7491 for deplib in $deplibs; do
Chris@69 7492 if $opt_preserve_dup_deps; then
Chris@69 7493 case "$libs " in
Chris@69 7494 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
Chris@69 7495 esac
Chris@69 7496 fi
Chris@69 7497 func_append libs " $deplib"
Chris@69 7498 done
Chris@69 7499
Chris@69 7500 if test lib = "$linkmode"; then
Chris@69 7501 libs="$predeps $libs $compiler_lib_search_path $postdeps"
Chris@69 7502
Chris@69 7503 # Compute libraries that are listed more than once in $predeps
Chris@69 7504 # $postdeps and mark them as special (i.e., whose duplicates are
Chris@69 7505 # not to be eliminated).
Chris@69 7506 pre_post_deps=
Chris@69 7507 if $opt_duplicate_compiler_generated_deps; then
Chris@69 7508 for pre_post_dep in $predeps $postdeps; do
Chris@69 7509 case "$pre_post_deps " in
Chris@69 7510 *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
Chris@69 7511 esac
Chris@69 7512 func_append pre_post_deps " $pre_post_dep"
Chris@69 7513 done
Chris@69 7514 fi
Chris@69 7515 pre_post_deps=
Chris@69 7516 fi
Chris@69 7517
Chris@69 7518 deplibs=
Chris@69 7519 newdependency_libs=
Chris@69 7520 newlib_search_path=
Chris@69 7521 need_relink=no # whether we're linking any uninstalled libtool libraries
Chris@69 7522 notinst_deplibs= # not-installed libtool libraries
Chris@69 7523 notinst_path= # paths that contain not-installed libtool libraries
Chris@69 7524
Chris@69 7525 case $linkmode in
Chris@69 7526 lib)
Chris@69 7527 passes="conv dlpreopen link"
Chris@69 7528 for file in $dlfiles $dlprefiles; do
Chris@69 7529 case $file in
Chris@69 7530 *.la) ;;
Chris@69 7531 *)
Chris@69 7532 func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
Chris@69 7533 ;;
Chris@69 7534 esac
Chris@69 7535 done
Chris@69 7536 ;;
Chris@69 7537 prog)
Chris@69 7538 compile_deplibs=
Chris@69 7539 finalize_deplibs=
Chris@69 7540 alldeplibs=false
Chris@69 7541 newdlfiles=
Chris@69 7542 newdlprefiles=
Chris@69 7543 passes="conv scan dlopen dlpreopen link"
Chris@69 7544 ;;
Chris@69 7545 *) passes="conv"
Chris@69 7546 ;;
Chris@69 7547 esac
Chris@69 7548
Chris@69 7549 for pass in $passes; do
Chris@69 7550 # The preopen pass in lib mode reverses $deplibs; put it back here
Chris@69 7551 # so that -L comes before libs that need it for instance...
Chris@69 7552 if test lib,link = "$linkmode,$pass"; then
Chris@69 7553 ## FIXME: Find the place where the list is rebuilt in the wrong
Chris@69 7554 ## order, and fix it there properly
Chris@69 7555 tmp_deplibs=
Chris@69 7556 for deplib in $deplibs; do
Chris@69 7557 tmp_deplibs="$deplib $tmp_deplibs"
Chris@69 7558 done
Chris@69 7559 deplibs=$tmp_deplibs
Chris@69 7560 fi
Chris@69 7561
Chris@69 7562 if test lib,link = "$linkmode,$pass" ||
Chris@69 7563 test prog,scan = "$linkmode,$pass"; then
Chris@69 7564 libs=$deplibs
Chris@69 7565 deplibs=
Chris@69 7566 fi
Chris@69 7567 if test prog = "$linkmode"; then
Chris@69 7568 case $pass in
Chris@69 7569 dlopen) libs=$dlfiles ;;
Chris@69 7570 dlpreopen) libs=$dlprefiles ;;
Chris@69 7571 link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
Chris@69 7572 esac
Chris@69 7573 fi
Chris@69 7574 if test lib,dlpreopen = "$linkmode,$pass"; then
Chris@69 7575 # Collect and forward deplibs of preopened libtool libs
Chris@69 7576 for lib in $dlprefiles; do
Chris@69 7577 # Ignore non-libtool-libs
Chris@69 7578 dependency_libs=
Chris@69 7579 func_resolve_sysroot "$lib"
Chris@69 7580 case $lib in
Chris@69 7581 *.la) func_source "$func_resolve_sysroot_result" ;;
Chris@69 7582 esac
Chris@69 7583
Chris@69 7584 # Collect preopened libtool deplibs, except any this library
Chris@69 7585 # has declared as weak libs
Chris@69 7586 for deplib in $dependency_libs; do
Chris@69 7587 func_basename "$deplib"
Chris@69 7588 deplib_base=$func_basename_result
Chris@69 7589 case " $weak_libs " in
Chris@69 7590 *" $deplib_base "*) ;;
Chris@69 7591 *) func_append deplibs " $deplib" ;;
Chris@69 7592 esac
Chris@69 7593 done
Chris@69 7594 done
Chris@69 7595 libs=$dlprefiles
Chris@69 7596 fi
Chris@69 7597 if test dlopen = "$pass"; then
Chris@69 7598 # Collect dlpreopened libraries
Chris@69 7599 save_deplibs=$deplibs
Chris@69 7600 deplibs=
Chris@69 7601 fi
Chris@69 7602
Chris@69 7603 for deplib in $libs; do
Chris@69 7604 lib=
Chris@69 7605 found=false
Chris@69 7606 case $deplib in
Chris@69 7607 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
Chris@69 7608 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
Chris@69 7609 if test prog,link = "$linkmode,$pass"; then
Chris@69 7610 compile_deplibs="$deplib $compile_deplibs"
Chris@69 7611 finalize_deplibs="$deplib $finalize_deplibs"
Chris@69 7612 else
Chris@69 7613 func_append compiler_flags " $deplib"
Chris@69 7614 if test lib = "$linkmode"; then
Chris@69 7615 case "$new_inherited_linker_flags " in
Chris@69 7616 *" $deplib "*) ;;
Chris@69 7617 * ) func_append new_inherited_linker_flags " $deplib" ;;
Chris@69 7618 esac
Chris@69 7619 fi
Chris@69 7620 fi
Chris@69 7621 continue
Chris@69 7622 ;;
Chris@69 7623 -l*)
Chris@69 7624 if test lib != "$linkmode" && test prog != "$linkmode"; then
Chris@69 7625 func_warning "'-l' is ignored for archives/objects"
Chris@69 7626 continue
Chris@69 7627 fi
Chris@69 7628 func_stripname '-l' '' "$deplib"
Chris@69 7629 name=$func_stripname_result
Chris@69 7630 if test lib = "$linkmode"; then
Chris@69 7631 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
Chris@69 7632 else
Chris@69 7633 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
Chris@69 7634 fi
Chris@69 7635 for searchdir in $searchdirs; do
Chris@69 7636 for search_ext in .la $std_shrext .so .a; do
Chris@69 7637 # Search the libtool library
Chris@69 7638 lib=$searchdir/lib$name$search_ext
Chris@69 7639 if test -f "$lib"; then
Chris@69 7640 if test .la = "$search_ext"; then
Chris@69 7641 found=:
Chris@69 7642 else
Chris@69 7643 found=false
Chris@69 7644 fi
Chris@69 7645 break 2
Chris@69 7646 fi
Chris@69 7647 done
Chris@69 7648 done
Chris@69 7649 if $found; then
Chris@69 7650 # deplib is a libtool library
Chris@69 7651 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
Chris@69 7652 # We need to do some special things here, and not later.
Chris@69 7653 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@69 7654 case " $predeps $postdeps " in
Chris@69 7655 *" $deplib "*)
Chris@69 7656 if func_lalib_p "$lib"; then
Chris@69 7657 library_names=
Chris@69 7658 old_library=
Chris@69 7659 func_source "$lib"
Chris@69 7660 for l in $old_library $library_names; do
Chris@69 7661 ll=$l
Chris@69 7662 done
Chris@69 7663 if test "X$ll" = "X$old_library"; then # only static version available
Chris@69 7664 found=false
Chris@69 7665 func_dirname "$lib" "" "."
Chris@69 7666 ladir=$func_dirname_result
Chris@69 7667 lib=$ladir/$old_library
Chris@69 7668 if test prog,link = "$linkmode,$pass"; then
Chris@69 7669 compile_deplibs="$deplib $compile_deplibs"
Chris@69 7670 finalize_deplibs="$deplib $finalize_deplibs"
Chris@69 7671 else
Chris@69 7672 deplibs="$deplib $deplibs"
Chris@69 7673 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
Chris@69 7674 fi
Chris@69 7675 continue
Chris@69 7676 fi
Chris@69 7677 fi
Chris@69 7678 ;;
Chris@69 7679 *) ;;
Chris@69 7680 esac
Chris@69 7681 fi
Chris@69 7682 else
Chris@69 7683 # deplib doesn't seem to be a libtool library
Chris@69 7684 if test prog,link = "$linkmode,$pass"; then
Chris@69 7685 compile_deplibs="$deplib $compile_deplibs"
Chris@69 7686 finalize_deplibs="$deplib $finalize_deplibs"
Chris@69 7687 else
Chris@69 7688 deplibs="$deplib $deplibs"
Chris@69 7689 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
Chris@69 7690 fi
Chris@69 7691 continue
Chris@69 7692 fi
Chris@69 7693 ;; # -l
Chris@69 7694 *.ltframework)
Chris@69 7695 if test prog,link = "$linkmode,$pass"; then
Chris@69 7696 compile_deplibs="$deplib $compile_deplibs"
Chris@69 7697 finalize_deplibs="$deplib $finalize_deplibs"
Chris@69 7698 else
Chris@69 7699 deplibs="$deplib $deplibs"
Chris@69 7700 if test lib = "$linkmode"; then
Chris@69 7701 case "$new_inherited_linker_flags " in
Chris@69 7702 *" $deplib "*) ;;
Chris@69 7703 * ) func_append new_inherited_linker_flags " $deplib" ;;
Chris@69 7704 esac
Chris@69 7705 fi
Chris@69 7706 fi
Chris@69 7707 continue
Chris@69 7708 ;;
Chris@69 7709 -L*)
Chris@69 7710 case $linkmode in
Chris@69 7711 lib)
Chris@69 7712 deplibs="$deplib $deplibs"
Chris@69 7713 test conv = "$pass" && continue
Chris@69 7714 newdependency_libs="$deplib $newdependency_libs"
Chris@69 7715 func_stripname '-L' '' "$deplib"
Chris@69 7716 func_resolve_sysroot "$func_stripname_result"
Chris@69 7717 func_append newlib_search_path " $func_resolve_sysroot_result"
Chris@69 7718 ;;
Chris@69 7719 prog)
Chris@69 7720 if test conv = "$pass"; then
Chris@69 7721 deplibs="$deplib $deplibs"
Chris@69 7722 continue
Chris@69 7723 fi
Chris@69 7724 if test scan = "$pass"; then
Chris@69 7725 deplibs="$deplib $deplibs"
Chris@69 7726 else
Chris@69 7727 compile_deplibs="$deplib $compile_deplibs"
Chris@69 7728 finalize_deplibs="$deplib $finalize_deplibs"
Chris@69 7729 fi
Chris@69 7730 func_stripname '-L' '' "$deplib"
Chris@69 7731 func_resolve_sysroot "$func_stripname_result"
Chris@69 7732 func_append newlib_search_path " $func_resolve_sysroot_result"
Chris@69 7733 ;;
Chris@69 7734 *)
Chris@69 7735 func_warning "'-L' is ignored for archives/objects"
Chris@69 7736 ;;
Chris@69 7737 esac # linkmode
Chris@69 7738 continue
Chris@69 7739 ;; # -L
Chris@69 7740 -R*)
Chris@69 7741 if test link = "$pass"; then
Chris@69 7742 func_stripname '-R' '' "$deplib"
Chris@69 7743 func_resolve_sysroot "$func_stripname_result"
Chris@69 7744 dir=$func_resolve_sysroot_result
Chris@69 7745 # Make sure the xrpath contains only unique directories.
Chris@69 7746 case "$xrpath " in
Chris@69 7747 *" $dir "*) ;;
Chris@69 7748 *) func_append xrpath " $dir" ;;
Chris@69 7749 esac
Chris@69 7750 fi
Chris@69 7751 deplibs="$deplib $deplibs"
Chris@69 7752 continue
Chris@69 7753 ;;
Chris@69 7754 *.la)
Chris@69 7755 func_resolve_sysroot "$deplib"
Chris@69 7756 lib=$func_resolve_sysroot_result
Chris@69 7757 ;;
Chris@69 7758 *.$libext)
Chris@69 7759 if test conv = "$pass"; then
Chris@69 7760 deplibs="$deplib $deplibs"
Chris@69 7761 continue
Chris@69 7762 fi
Chris@69 7763 case $linkmode in
Chris@69 7764 lib)
Chris@69 7765 # Linking convenience modules into shared libraries is allowed,
Chris@69 7766 # but linking other static libraries is non-portable.
Chris@69 7767 case " $dlpreconveniencelibs " in
Chris@69 7768 *" $deplib "*) ;;
Chris@69 7769 *)
Chris@69 7770 valid_a_lib=false
Chris@69 7771 case $deplibs_check_method in
Chris@69 7772 match_pattern*)
Chris@69 7773 set dummy $deplibs_check_method; shift
Chris@69 7774 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Chris@69 7775 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
Chris@69 7776 | $EGREP "$match_pattern_regex" > /dev/null; then
Chris@69 7777 valid_a_lib=:
Chris@69 7778 fi
Chris@69 7779 ;;
Chris@69 7780 pass_all)
Chris@69 7781 valid_a_lib=:
Chris@69 7782 ;;
Chris@69 7783 esac
Chris@69 7784 if $valid_a_lib; then
Chris@69 7785 echo
Chris@69 7786 $ECHO "*** Warning: Linking the shared library $output against the"
Chris@69 7787 $ECHO "*** static library $deplib is not portable!"
Chris@69 7788 deplibs="$deplib $deplibs"
Chris@69 7789 else
Chris@69 7790 echo
Chris@69 7791 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
Chris@69 7792 echo "*** I have the capability to make that library automatically link in when"
Chris@69 7793 echo "*** you link to this library. But I can only do this if you have a"
Chris@69 7794 echo "*** shared version of the library, which you do not appear to have"
Chris@69 7795 echo "*** because the file extensions .$libext of this argument makes me believe"
Chris@69 7796 echo "*** that it is just a static archive that I should not use here."
Chris@69 7797 fi
Chris@69 7798 ;;
Chris@69 7799 esac
Chris@69 7800 continue
Chris@69 7801 ;;
Chris@69 7802 prog)
Chris@69 7803 if test link != "$pass"; then
Chris@69 7804 deplibs="$deplib $deplibs"
Chris@69 7805 else
Chris@69 7806 compile_deplibs="$deplib $compile_deplibs"
Chris@69 7807 finalize_deplibs="$deplib $finalize_deplibs"
Chris@69 7808 fi
Chris@69 7809 continue
Chris@69 7810 ;;
Chris@69 7811 esac # linkmode
Chris@69 7812 ;; # *.$libext
Chris@69 7813 *.lo | *.$objext)
Chris@69 7814 if test conv = "$pass"; then
Chris@69 7815 deplibs="$deplib $deplibs"
Chris@69 7816 elif test prog = "$linkmode"; then
Chris@69 7817 if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
Chris@69 7818 # If there is no dlopen support or we're linking statically,
Chris@69 7819 # we need to preload.
Chris@69 7820 func_append newdlprefiles " $deplib"
Chris@69 7821 compile_deplibs="$deplib $compile_deplibs"
Chris@69 7822 finalize_deplibs="$deplib $finalize_deplibs"
Chris@69 7823 else
Chris@69 7824 func_append newdlfiles " $deplib"
Chris@69 7825 fi
Chris@69 7826 fi
Chris@69 7827 continue
Chris@69 7828 ;;
Chris@69 7829 %DEPLIBS%)
Chris@69 7830 alldeplibs=:
Chris@69 7831 continue
Chris@69 7832 ;;
Chris@69 7833 esac # case $deplib
Chris@69 7834
Chris@69 7835 $found || test -f "$lib" \
Chris@69 7836 || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
Chris@69 7837
Chris@69 7838 # Check to see that this really is a libtool archive.
Chris@69 7839 func_lalib_unsafe_p "$lib" \
Chris@69 7840 || func_fatal_error "'$lib' is not a valid libtool archive"
Chris@69 7841
Chris@69 7842 func_dirname "$lib" "" "."
Chris@69 7843 ladir=$func_dirname_result
Chris@69 7844
Chris@69 7845 dlname=
Chris@69 7846 dlopen=
Chris@69 7847 dlpreopen=
Chris@69 7848 libdir=
Chris@69 7849 library_names=
Chris@69 7850 old_library=
Chris@69 7851 inherited_linker_flags=
Chris@69 7852 # If the library was installed with an old release of libtool,
Chris@69 7853 # it will not redefine variables installed, or shouldnotlink
Chris@69 7854 installed=yes
Chris@69 7855 shouldnotlink=no
Chris@69 7856 avoidtemprpath=
Chris@69 7857
Chris@69 7858
Chris@69 7859 # Read the .la file
Chris@69 7860 func_source "$lib"
Chris@69 7861
Chris@69 7862 # Convert "-framework foo" to "foo.ltframework"
Chris@69 7863 if test -n "$inherited_linker_flags"; then
Chris@69 7864 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
Chris@69 7865 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
Chris@69 7866 case " $new_inherited_linker_flags " in
Chris@69 7867 *" $tmp_inherited_linker_flag "*) ;;
Chris@69 7868 *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
Chris@69 7869 esac
Chris@69 7870 done
Chris@69 7871 fi
Chris@69 7872 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@69 7873 if test lib,link = "$linkmode,$pass" ||
Chris@69 7874 test prog,scan = "$linkmode,$pass" ||
Chris@69 7875 { test prog != "$linkmode" && test lib != "$linkmode"; }; then
Chris@69 7876 test -n "$dlopen" && func_append dlfiles " $dlopen"
Chris@69 7877 test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
Chris@69 7878 fi
Chris@69 7879
Chris@69 7880 if test conv = "$pass"; then
Chris@69 7881 # Only check for convenience libraries
Chris@69 7882 deplibs="$lib $deplibs"
Chris@69 7883 if test -z "$libdir"; then
Chris@69 7884 if test -z "$old_library"; then
Chris@69 7885 func_fatal_error "cannot find name of link library for '$lib'"
Chris@69 7886 fi
Chris@69 7887 # It is a libtool convenience library, so add in its objects.
Chris@69 7888 func_append convenience " $ladir/$objdir/$old_library"
Chris@69 7889 func_append old_convenience " $ladir/$objdir/$old_library"
Chris@69 7890 elif test prog != "$linkmode" && test lib != "$linkmode"; then
Chris@69 7891 func_fatal_error "'$lib' is not a convenience library"
Chris@69 7892 fi
Chris@69 7893 tmp_libs=
Chris@69 7894 for deplib in $dependency_libs; do
Chris@69 7895 deplibs="$deplib $deplibs"
Chris@69 7896 if $opt_preserve_dup_deps; then
Chris@69 7897 case "$tmp_libs " in
Chris@69 7898 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
Chris@69 7899 esac
Chris@69 7900 fi
Chris@69 7901 func_append tmp_libs " $deplib"
Chris@69 7902 done
Chris@69 7903 continue
Chris@69 7904 fi # $pass = conv
Chris@69 7905
Chris@69 7906
Chris@69 7907 # Get the name of the library we link against.
Chris@69 7908 linklib=
Chris@69 7909 if test -n "$old_library" &&
Chris@69 7910 { test yes = "$prefer_static_libs" ||
Chris@69 7911 test built,no = "$prefer_static_libs,$installed"; }; then
Chris@69 7912 linklib=$old_library
Chris@69 7913 else
Chris@69 7914 for l in $old_library $library_names; do
Chris@69 7915 linklib=$l
Chris@69 7916 done
Chris@69 7917 fi
Chris@69 7918 if test -z "$linklib"; then
Chris@69 7919 func_fatal_error "cannot find name of link library for '$lib'"
Chris@69 7920 fi
Chris@69 7921
Chris@69 7922 # This library was specified with -dlopen.
Chris@69 7923 if test dlopen = "$pass"; then
Chris@69 7924 test -z "$libdir" \
Chris@69 7925 && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
Chris@69 7926 if test -z "$dlname" ||
Chris@69 7927 test yes != "$dlopen_support" ||
Chris@69 7928 test no = "$build_libtool_libs"
Chris@69 7929 then
Chris@69 7930 # If there is no dlname, no dlopen support or we're linking
Chris@69 7931 # statically, we need to preload. We also need to preload any
Chris@69 7932 # dependent libraries so libltdl's deplib preloader doesn't
Chris@69 7933 # bomb out in the load deplibs phase.
Chris@69 7934 func_append dlprefiles " $lib $dependency_libs"
Chris@69 7935 else
Chris@69 7936 func_append newdlfiles " $lib"
Chris@69 7937 fi
Chris@69 7938 continue
Chris@69 7939 fi # $pass = dlopen
Chris@69 7940
Chris@69 7941 # We need an absolute path.
Chris@69 7942 case $ladir in
Chris@69 7943 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
Chris@69 7944 *)
Chris@69 7945 abs_ladir=`cd "$ladir" && pwd`
Chris@69 7946 if test -z "$abs_ladir"; then
Chris@69 7947 func_warning "cannot determine absolute directory name of '$ladir'"
Chris@69 7948 func_warning "passing it literally to the linker, although it might fail"
Chris@69 7949 abs_ladir=$ladir
Chris@69 7950 fi
Chris@69 7951 ;;
Chris@69 7952 esac
Chris@69 7953 func_basename "$lib"
Chris@69 7954 laname=$func_basename_result
Chris@69 7955
Chris@69 7956 # Find the relevant object directory and library name.
Chris@69 7957 if test yes = "$installed"; then
Chris@69 7958 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
Chris@69 7959 func_warning "library '$lib' was moved."
Chris@69 7960 dir=$ladir
Chris@69 7961 absdir=$abs_ladir
Chris@69 7962 libdir=$abs_ladir
Chris@69 7963 else
Chris@69 7964 dir=$lt_sysroot$libdir
Chris@69 7965 absdir=$lt_sysroot$libdir
Chris@69 7966 fi
Chris@69 7967 test yes = "$hardcode_automatic" && avoidtemprpath=yes
Chris@69 7968 else
Chris@69 7969 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
Chris@69 7970 dir=$ladir
Chris@69 7971 absdir=$abs_ladir
Chris@69 7972 # Remove this search path later
Chris@69 7973 func_append notinst_path " $abs_ladir"
Chris@69 7974 else
Chris@69 7975 dir=$ladir/$objdir
Chris@69 7976 absdir=$abs_ladir/$objdir
Chris@69 7977 # Remove this search path later
Chris@69 7978 func_append notinst_path " $abs_ladir"
Chris@69 7979 fi
Chris@69 7980 fi # $installed = yes
Chris@69 7981 func_stripname 'lib' '.la' "$laname"
Chris@69 7982 name=$func_stripname_result
Chris@69 7983
Chris@69 7984 # This library was specified with -dlpreopen.
Chris@69 7985 if test dlpreopen = "$pass"; then
Chris@69 7986 if test -z "$libdir" && test prog = "$linkmode"; then
Chris@69 7987 func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
Chris@69 7988 fi
Chris@69 7989 case $host in
Chris@69 7990 # special handling for platforms with PE-DLLs.
Chris@69 7991 *cygwin* | *mingw* | *cegcc* )
Chris@69 7992 # Linker will automatically link against shared library if both
Chris@69 7993 # static and shared are present. Therefore, ensure we extract
Chris@69 7994 # symbols from the import library if a shared library is present
Chris@69 7995 # (otherwise, the dlopen module name will be incorrect). We do
Chris@69 7996 # this by putting the import library name into $newdlprefiles.
Chris@69 7997 # We recover the dlopen module name by 'saving' the la file
Chris@69 7998 # name in a special purpose variable, and (later) extracting the
Chris@69 7999 # dlname from the la file.
Chris@69 8000 if test -n "$dlname"; then
Chris@69 8001 func_tr_sh "$dir/$linklib"
Chris@69 8002 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
Chris@69 8003 func_append newdlprefiles " $dir/$linklib"
Chris@69 8004 else
Chris@69 8005 func_append newdlprefiles " $dir/$old_library"
Chris@69 8006 # Keep a list of preopened convenience libraries to check
Chris@69 8007 # that they are being used correctly in the link pass.
Chris@69 8008 test -z "$libdir" && \
Chris@69 8009 func_append dlpreconveniencelibs " $dir/$old_library"
Chris@69 8010 fi
Chris@69 8011 ;;
Chris@69 8012 * )
Chris@69 8013 # Prefer using a static library (so that no silly _DYNAMIC symbols
Chris@69 8014 # are required to link).
Chris@69 8015 if test -n "$old_library"; then
Chris@69 8016 func_append newdlprefiles " $dir/$old_library"
Chris@69 8017 # Keep a list of preopened convenience libraries to check
Chris@69 8018 # that they are being used correctly in the link pass.
Chris@69 8019 test -z "$libdir" && \
Chris@69 8020 func_append dlpreconveniencelibs " $dir/$old_library"
Chris@69 8021 # Otherwise, use the dlname, so that lt_dlopen finds it.
Chris@69 8022 elif test -n "$dlname"; then
Chris@69 8023 func_append newdlprefiles " $dir/$dlname"
Chris@69 8024 else
Chris@69 8025 func_append newdlprefiles " $dir/$linklib"
Chris@69 8026 fi
Chris@69 8027 ;;
Chris@69 8028 esac
Chris@69 8029 fi # $pass = dlpreopen
Chris@69 8030
Chris@69 8031 if test -z "$libdir"; then
Chris@69 8032 # Link the convenience library
Chris@69 8033 if test lib = "$linkmode"; then
Chris@69 8034 deplibs="$dir/$old_library $deplibs"
Chris@69 8035 elif test prog,link = "$linkmode,$pass"; then
Chris@69 8036 compile_deplibs="$dir/$old_library $compile_deplibs"
Chris@69 8037 finalize_deplibs="$dir/$old_library $finalize_deplibs"
Chris@69 8038 else
Chris@69 8039 deplibs="$lib $deplibs" # used for prog,scan pass
Chris@69 8040 fi
Chris@69 8041 continue
Chris@69 8042 fi
Chris@69 8043
Chris@69 8044
Chris@69 8045 if test prog = "$linkmode" && test link != "$pass"; then
Chris@69 8046 func_append newlib_search_path " $ladir"
Chris@69 8047 deplibs="$lib $deplibs"
Chris@69 8048
Chris@69 8049 linkalldeplibs=false
Chris@69 8050 if test no != "$link_all_deplibs" || test -z "$library_names" ||
Chris@69 8051 test no = "$build_libtool_libs"; then
Chris@69 8052 linkalldeplibs=:
Chris@69 8053 fi
Chris@69 8054
Chris@69 8055 tmp_libs=
Chris@69 8056 for deplib in $dependency_libs; do
Chris@69 8057 case $deplib in
Chris@69 8058 -L*) func_stripname '-L' '' "$deplib"
Chris@69 8059 func_resolve_sysroot "$func_stripname_result"
Chris@69 8060 func_append newlib_search_path " $func_resolve_sysroot_result"
Chris@69 8061 ;;
Chris@69 8062 esac
Chris@69 8063 # Need to link against all dependency_libs?
Chris@69 8064 if $linkalldeplibs; then
Chris@69 8065 deplibs="$deplib $deplibs"
Chris@69 8066 else
Chris@69 8067 # Need to hardcode shared library paths
Chris@69 8068 # or/and link against static libraries
Chris@69 8069 newdependency_libs="$deplib $newdependency_libs"
Chris@69 8070 fi
Chris@69 8071 if $opt_preserve_dup_deps; then
Chris@69 8072 case "$tmp_libs " in
Chris@69 8073 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
Chris@69 8074 esac
Chris@69 8075 fi
Chris@69 8076 func_append tmp_libs " $deplib"
Chris@69 8077 done # for deplib
Chris@69 8078 continue
Chris@69 8079 fi # $linkmode = prog...
Chris@69 8080
Chris@69 8081 if test prog,link = "$linkmode,$pass"; then
Chris@69 8082 if test -n "$library_names" &&
Chris@69 8083 { { test no = "$prefer_static_libs" ||
Chris@69 8084 test built,yes = "$prefer_static_libs,$installed"; } ||
Chris@69 8085 test -z "$old_library"; }; then
Chris@69 8086 # We need to hardcode the library path
Chris@69 8087 if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
Chris@69 8088 # Make sure the rpath contains only unique directories.
Chris@69 8089 case $temp_rpath: in
Chris@69 8090 *"$absdir:"*) ;;
Chris@69 8091 *) func_append temp_rpath "$absdir:" ;;
Chris@69 8092 esac
Chris@69 8093 fi
Chris@69 8094
Chris@69 8095 # Hardcode the library path.
Chris@69 8096 # Skip directories that are in the system default run-time
Chris@69 8097 # search path.
Chris@69 8098 case " $sys_lib_dlsearch_path " in
Chris@69 8099 *" $absdir "*) ;;
Chris@69 8100 *)
Chris@69 8101 case "$compile_rpath " in
Chris@69 8102 *" $absdir "*) ;;
Chris@69 8103 *) func_append compile_rpath " $absdir" ;;
Chris@69 8104 esac
Chris@69 8105 ;;
Chris@69 8106 esac
Chris@69 8107 case " $sys_lib_dlsearch_path " in
Chris@69 8108 *" $libdir "*) ;;
Chris@69 8109 *)
Chris@69 8110 case "$finalize_rpath " in
Chris@69 8111 *" $libdir "*) ;;
Chris@69 8112 *) func_append finalize_rpath " $libdir" ;;
Chris@69 8113 esac
Chris@69 8114 ;;
Chris@69 8115 esac
Chris@69 8116 fi # $linkmode,$pass = prog,link...
Chris@69 8117
Chris@69 8118 if $alldeplibs &&
Chris@69 8119 { test pass_all = "$deplibs_check_method" ||
Chris@69 8120 { test yes = "$build_libtool_libs" &&
Chris@69 8121 test -n "$library_names"; }; }; then
Chris@69 8122 # We only need to search for static libraries
Chris@69 8123 continue
Chris@69 8124 fi
Chris@69 8125 fi
Chris@69 8126
Chris@69 8127 link_static=no # Whether the deplib will be linked statically
Chris@69 8128 use_static_libs=$prefer_static_libs
Chris@69 8129 if test built = "$use_static_libs" && test yes = "$installed"; then
Chris@69 8130 use_static_libs=no
Chris@69 8131 fi
Chris@69 8132 if test -n "$library_names" &&
Chris@69 8133 { test no = "$use_static_libs" || test -z "$old_library"; }; then
Chris@69 8134 case $host in
Chris@69 8135 *cygwin* | *mingw* | *cegcc* | *os2*)
Chris@69 8136 # No point in relinking DLLs because paths are not encoded
Chris@69 8137 func_append notinst_deplibs " $lib"
Chris@69 8138 need_relink=no
Chris@69 8139 ;;
Chris@69 8140 *)
Chris@69 8141 if test no = "$installed"; then
Chris@69 8142 func_append notinst_deplibs " $lib"
Chris@69 8143 need_relink=yes
Chris@69 8144 fi
Chris@69 8145 ;;
Chris@69 8146 esac
Chris@69 8147 # This is a shared library
Chris@69 8148
Chris@69 8149 # Warn about portability, can't link against -module's on some
Chris@69 8150 # systems (darwin). Don't bleat about dlopened modules though!
Chris@69 8151 dlopenmodule=
Chris@69 8152 for dlpremoduletest in $dlprefiles; do
Chris@69 8153 if test "X$dlpremoduletest" = "X$lib"; then
Chris@69 8154 dlopenmodule=$dlpremoduletest
Chris@69 8155 break
Chris@69 8156 fi
Chris@69 8157 done
Chris@69 8158 if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
Chris@69 8159 echo
Chris@69 8160 if test prog = "$linkmode"; then
Chris@69 8161 $ECHO "*** Warning: Linking the executable $output against the loadable module"
Chris@69 8162 else
Chris@69 8163 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
Chris@69 8164 fi
Chris@69 8165 $ECHO "*** $linklib is not portable!"
Chris@69 8166 fi
Chris@69 8167 if test lib = "$linkmode" &&
Chris@69 8168 test yes = "$hardcode_into_libs"; then
Chris@69 8169 # Hardcode the library path.
Chris@69 8170 # Skip directories that are in the system default run-time
Chris@69 8171 # search path.
Chris@69 8172 case " $sys_lib_dlsearch_path " in
Chris@69 8173 *" $absdir "*) ;;
Chris@69 8174 *)
Chris@69 8175 case "$compile_rpath " in
Chris@69 8176 *" $absdir "*) ;;
Chris@69 8177 *) func_append compile_rpath " $absdir" ;;
Chris@69 8178 esac
Chris@69 8179 ;;
Chris@69 8180 esac
Chris@69 8181 case " $sys_lib_dlsearch_path " in
Chris@69 8182 *" $libdir "*) ;;
Chris@69 8183 *)
Chris@69 8184 case "$finalize_rpath " in
Chris@69 8185 *" $libdir "*) ;;
Chris@69 8186 *) func_append finalize_rpath " $libdir" ;;
Chris@69 8187 esac
Chris@69 8188 ;;
Chris@69 8189 esac
Chris@69 8190 fi
Chris@69 8191
Chris@69 8192 if test -n "$old_archive_from_expsyms_cmds"; then
Chris@69 8193 # figure out the soname
Chris@69 8194 set dummy $library_names
Chris@69 8195 shift
Chris@69 8196 realname=$1
Chris@69 8197 shift
Chris@69 8198 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@69 8199 # use dlname if we got it. it's perfectly good, no?
Chris@69 8200 if test -n "$dlname"; then
Chris@69 8201 soname=$dlname
Chris@69 8202 elif test -n "$soname_spec"; then
Chris@69 8203 # bleh windows
Chris@69 8204 case $host in
Chris@69 8205 *cygwin* | mingw* | *cegcc* | *os2*)
Chris@69 8206 func_arith $current - $age
Chris@69 8207 major=$func_arith_result
Chris@69 8208 versuffix=-$major
Chris@69 8209 ;;
Chris@69 8210 esac
Chris@69 8211 eval soname=\"$soname_spec\"
Chris@69 8212 else
Chris@69 8213 soname=$realname
Chris@69 8214 fi
Chris@69 8215
Chris@69 8216 # Make a new name for the extract_expsyms_cmds to use
Chris@69 8217 soroot=$soname
Chris@69 8218 func_basename "$soroot"
Chris@69 8219 soname=$func_basename_result
Chris@69 8220 func_stripname 'lib' '.dll' "$soname"
Chris@69 8221 newlib=libimp-$func_stripname_result.a
Chris@69 8222
Chris@69 8223 # If the library has no export list, then create one now
Chris@69 8224 if test -f "$output_objdir/$soname-def"; then :
Chris@69 8225 else
Chris@69 8226 func_verbose "extracting exported symbol list from '$soname'"
Chris@69 8227 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
Chris@69 8228 fi
Chris@69 8229
Chris@69 8230 # Create $newlib
Chris@69 8231 if test -f "$output_objdir/$newlib"; then :; else
Chris@69 8232 func_verbose "generating import library for '$soname'"
Chris@69 8233 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
Chris@69 8234 fi
Chris@69 8235 # make sure the library variables are pointing to the new library
Chris@69 8236 dir=$output_objdir
Chris@69 8237 linklib=$newlib
Chris@69 8238 fi # test -n "$old_archive_from_expsyms_cmds"
Chris@69 8239
Chris@69 8240 if test prog = "$linkmode" || test relink != "$opt_mode"; then
Chris@69 8241 add_shlibpath=
Chris@69 8242 add_dir=
Chris@69 8243 add=
Chris@69 8244 lib_linked=yes
Chris@69 8245 case $hardcode_action in
Chris@69 8246 immediate | unsupported)
Chris@69 8247 if test no = "$hardcode_direct"; then
Chris@69 8248 add=$dir/$linklib
Chris@69 8249 case $host in
Chris@69 8250 *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
Chris@69 8251 *-*-sysv4*uw2*) add_dir=-L$dir ;;
Chris@69 8252 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
Chris@69 8253 *-*-unixware7*) add_dir=-L$dir ;;
Chris@69 8254 *-*-darwin* )
Chris@69 8255 # if the lib is a (non-dlopened) module then we cannot
Chris@69 8256 # link against it, someone is ignoring the earlier warnings
Chris@69 8257 if /usr/bin/file -L $add 2> /dev/null |
Chris@69 8258 $GREP ": [^:]* bundle" >/dev/null; then
Chris@69 8259 if test "X$dlopenmodule" != "X$lib"; then
Chris@69 8260 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
Chris@69 8261 if test -z "$old_library"; then
Chris@69 8262 echo
Chris@69 8263 echo "*** And there doesn't seem to be a static archive available"
Chris@69 8264 echo "*** The link will probably fail, sorry"
Chris@69 8265 else
Chris@69 8266 add=$dir/$old_library
Chris@69 8267 fi
Chris@69 8268 elif test -n "$old_library"; then
Chris@69 8269 add=$dir/$old_library
Chris@69 8270 fi
Chris@69 8271 fi
Chris@69 8272 esac
Chris@69 8273 elif test no = "$hardcode_minus_L"; then
Chris@69 8274 case $host in
Chris@69 8275 *-*-sunos*) add_shlibpath=$dir ;;
Chris@69 8276 esac
Chris@69 8277 add_dir=-L$dir
Chris@69 8278 add=-l$name
Chris@69 8279 elif test no = "$hardcode_shlibpath_var"; then
Chris@69 8280 add_shlibpath=$dir
Chris@69 8281 add=-l$name
Chris@69 8282 else
Chris@69 8283 lib_linked=no
Chris@69 8284 fi
Chris@69 8285 ;;
Chris@69 8286 relink)
Chris@69 8287 if test yes = "$hardcode_direct" &&
Chris@69 8288 test no = "$hardcode_direct_absolute"; then
Chris@69 8289 add=$dir/$linklib
Chris@69 8290 elif test yes = "$hardcode_minus_L"; then
Chris@69 8291 add_dir=-L$absdir
Chris@69 8292 # Try looking first in the location we're being installed to.
Chris@69 8293 if test -n "$inst_prefix_dir"; then
Chris@69 8294 case $libdir in
Chris@69 8295 [\\/]*)
Chris@69 8296 func_append add_dir " -L$inst_prefix_dir$libdir"
Chris@69 8297 ;;
Chris@69 8298 esac
Chris@69 8299 fi
Chris@69 8300 add=-l$name
Chris@69 8301 elif test yes = "$hardcode_shlibpath_var"; then
Chris@69 8302 add_shlibpath=$dir
Chris@69 8303 add=-l$name
Chris@69 8304 else
Chris@69 8305 lib_linked=no
Chris@69 8306 fi
Chris@69 8307 ;;
Chris@69 8308 *) lib_linked=no ;;
Chris@69 8309 esac
Chris@69 8310
Chris@69 8311 if test yes != "$lib_linked"; then
Chris@69 8312 func_fatal_configuration "unsupported hardcode properties"
Chris@69 8313 fi
Chris@69 8314
Chris@69 8315 if test -n "$add_shlibpath"; then
Chris@69 8316 case :$compile_shlibpath: in
Chris@69 8317 *":$add_shlibpath:"*) ;;
Chris@69 8318 *) func_append compile_shlibpath "$add_shlibpath:" ;;
Chris@69 8319 esac
Chris@69 8320 fi
Chris@69 8321 if test prog = "$linkmode"; then
Chris@69 8322 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
Chris@69 8323 test -n "$add" && compile_deplibs="$add $compile_deplibs"
Chris@69 8324 else
Chris@69 8325 test -n "$add_dir" && deplibs="$add_dir $deplibs"
Chris@69 8326 test -n "$add" && deplibs="$add $deplibs"
Chris@69 8327 if test yes != "$hardcode_direct" &&
Chris@69 8328 test yes != "$hardcode_minus_L" &&
Chris@69 8329 test yes = "$hardcode_shlibpath_var"; then
Chris@69 8330 case :$finalize_shlibpath: in
Chris@69 8331 *":$libdir:"*) ;;
Chris@69 8332 *) func_append finalize_shlibpath "$libdir:" ;;
Chris@69 8333 esac
Chris@69 8334 fi
Chris@69 8335 fi
Chris@69 8336 fi
Chris@69 8337
Chris@69 8338 if test prog = "$linkmode" || test relink = "$opt_mode"; then
Chris@69 8339 add_shlibpath=
Chris@69 8340 add_dir=
Chris@69 8341 add=
Chris@69 8342 # Finalize command for both is simple: just hardcode it.
Chris@69 8343 if test yes = "$hardcode_direct" &&
Chris@69 8344 test no = "$hardcode_direct_absolute"; then
Chris@69 8345 add=$libdir/$linklib
Chris@69 8346 elif test yes = "$hardcode_minus_L"; then
Chris@69 8347 add_dir=-L$libdir
Chris@69 8348 add=-l$name
Chris@69 8349 elif test yes = "$hardcode_shlibpath_var"; then
Chris@69 8350 case :$finalize_shlibpath: in
Chris@69 8351 *":$libdir:"*) ;;
Chris@69 8352 *) func_append finalize_shlibpath "$libdir:" ;;
Chris@69 8353 esac
Chris@69 8354 add=-l$name
Chris@69 8355 elif test yes = "$hardcode_automatic"; then
Chris@69 8356 if test -n "$inst_prefix_dir" &&
Chris@69 8357 test -f "$inst_prefix_dir$libdir/$linklib"; then
Chris@69 8358 add=$inst_prefix_dir$libdir/$linklib
Chris@69 8359 else
Chris@69 8360 add=$libdir/$linklib
Chris@69 8361 fi
Chris@69 8362 else
Chris@69 8363 # We cannot seem to hardcode it, guess we'll fake it.
Chris@69 8364 add_dir=-L$libdir
Chris@69 8365 # Try looking first in the location we're being installed to.
Chris@69 8366 if test -n "$inst_prefix_dir"; then
Chris@69 8367 case $libdir in
Chris@69 8368 [\\/]*)
Chris@69 8369 func_append add_dir " -L$inst_prefix_dir$libdir"
Chris@69 8370 ;;
Chris@69 8371 esac
Chris@69 8372 fi
Chris@69 8373 add=-l$name
Chris@69 8374 fi
Chris@69 8375
Chris@69 8376 if test prog = "$linkmode"; then
Chris@69 8377 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
Chris@69 8378 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
Chris@69 8379 else
Chris@69 8380 test -n "$add_dir" && deplibs="$add_dir $deplibs"
Chris@69 8381 test -n "$add" && deplibs="$add $deplibs"
Chris@69 8382 fi
Chris@69 8383 fi
Chris@69 8384 elif test prog = "$linkmode"; then
Chris@69 8385 # Here we assume that one of hardcode_direct or hardcode_minus_L
Chris@69 8386 # is not unsupported. This is valid on all known static and
Chris@69 8387 # shared platforms.
Chris@69 8388 if test unsupported != "$hardcode_direct"; then
Chris@69 8389 test -n "$old_library" && linklib=$old_library
Chris@69 8390 compile_deplibs="$dir/$linklib $compile_deplibs"
Chris@69 8391 finalize_deplibs="$dir/$linklib $finalize_deplibs"
Chris@69 8392 else
Chris@69 8393 compile_deplibs="-l$name -L$dir $compile_deplibs"
Chris@69 8394 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
Chris@69 8395 fi
Chris@69 8396 elif test yes = "$build_libtool_libs"; then
Chris@69 8397 # Not a shared library
Chris@69 8398 if test pass_all != "$deplibs_check_method"; then
Chris@69 8399 # We're trying link a shared library against a static one
Chris@69 8400 # but the system doesn't support it.
Chris@69 8401
Chris@69 8402 # Just print a warning and add the library to dependency_libs so
Chris@69 8403 # that the program can be linked against the static library.
Chris@69 8404 echo
Chris@69 8405 $ECHO "*** Warning: This system cannot link to static lib archive $lib."
Chris@69 8406 echo "*** I have the capability to make that library automatically link in when"
Chris@69 8407 echo "*** you link to this library. But I can only do this if you have a"
Chris@69 8408 echo "*** shared version of the library, which you do not appear to have."
Chris@69 8409 if test yes = "$module"; then
Chris@69 8410 echo "*** But as you try to build a module library, libtool will still create "
Chris@69 8411 echo "*** a static module, that should work as long as the dlopening application"
Chris@69 8412 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
Chris@69 8413 if test -z "$global_symbol_pipe"; then
Chris@69 8414 echo
Chris@69 8415 echo "*** However, this would only work if libtool was able to extract symbol"
Chris@69 8416 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
Chris@69 8417 echo "*** not find such a program. So, this module is probably useless."
Chris@69 8418 echo "*** 'nm' from GNU binutils and a full rebuild may help."
Chris@69 8419 fi
Chris@69 8420 if test no = "$build_old_libs"; then
Chris@69 8421 build_libtool_libs=module
Chris@69 8422 build_old_libs=yes
Chris@69 8423 else
Chris@69 8424 build_libtool_libs=no
Chris@69 8425 fi
Chris@69 8426 fi
Chris@69 8427 else
Chris@69 8428 deplibs="$dir/$old_library $deplibs"
Chris@69 8429 link_static=yes
Chris@69 8430 fi
Chris@69 8431 fi # link shared/static library?
Chris@69 8432
Chris@69 8433 if test lib = "$linkmode"; then
Chris@69 8434 if test -n "$dependency_libs" &&
Chris@69 8435 { test yes != "$hardcode_into_libs" ||
Chris@69 8436 test yes = "$build_old_libs" ||
Chris@69 8437 test yes = "$link_static"; }; then
Chris@69 8438 # Extract -R from dependency_libs
Chris@69 8439 temp_deplibs=
Chris@69 8440 for libdir in $dependency_libs; do
Chris@69 8441 case $libdir in
Chris@69 8442 -R*) func_stripname '-R' '' "$libdir"
Chris@69 8443 temp_xrpath=$func_stripname_result
Chris@69 8444 case " $xrpath " in
Chris@69 8445 *" $temp_xrpath "*) ;;
Chris@69 8446 *) func_append xrpath " $temp_xrpath";;
Chris@69 8447 esac;;
Chris@69 8448 *) func_append temp_deplibs " $libdir";;
Chris@69 8449 esac
Chris@69 8450 done
Chris@69 8451 dependency_libs=$temp_deplibs
Chris@69 8452 fi
Chris@69 8453
Chris@69 8454 func_append newlib_search_path " $absdir"
Chris@69 8455 # Link against this library
Chris@69 8456 test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
Chris@69 8457 # ... and its dependency_libs
Chris@69 8458 tmp_libs=
Chris@69 8459 for deplib in $dependency_libs; do
Chris@69 8460 newdependency_libs="$deplib $newdependency_libs"
Chris@69 8461 case $deplib in
Chris@69 8462 -L*) func_stripname '-L' '' "$deplib"
Chris@69 8463 func_resolve_sysroot "$func_stripname_result";;
Chris@69 8464 *) func_resolve_sysroot "$deplib" ;;
Chris@69 8465 esac
Chris@69 8466 if $opt_preserve_dup_deps; then
Chris@69 8467 case "$tmp_libs " in
Chris@69 8468 *" $func_resolve_sysroot_result "*)
Chris@69 8469 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
Chris@69 8470 esac
Chris@69 8471 fi
Chris@69 8472 func_append tmp_libs " $func_resolve_sysroot_result"
Chris@69 8473 done
Chris@69 8474
Chris@69 8475 if test no != "$link_all_deplibs"; then
Chris@69 8476 # Add the search paths of all dependency libraries
Chris@69 8477 for deplib in $dependency_libs; do
Chris@69 8478 path=
Chris@69 8479 case $deplib in
Chris@69 8480 -L*) path=$deplib ;;
Chris@69 8481 *.la)
Chris@69 8482 func_resolve_sysroot "$deplib"
Chris@69 8483 deplib=$func_resolve_sysroot_result
Chris@69 8484 func_dirname "$deplib" "" "."
Chris@69 8485 dir=$func_dirname_result
Chris@69 8486 # We need an absolute path.
Chris@69 8487 case $dir in
Chris@69 8488 [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
Chris@69 8489 *)
Chris@69 8490 absdir=`cd "$dir" && pwd`
Chris@69 8491 if test -z "$absdir"; then
Chris@69 8492 func_warning "cannot determine absolute directory name of '$dir'"
Chris@69 8493 absdir=$dir
Chris@69 8494 fi
Chris@69 8495 ;;
Chris@69 8496 esac
Chris@69 8497 if $GREP "^installed=no" $deplib > /dev/null; then
Chris@69 8498 case $host in
Chris@69 8499 *-*-darwin*)
Chris@69 8500 depdepl=
Chris@69 8501 eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
Chris@69 8502 if test -n "$deplibrary_names"; then
Chris@69 8503 for tmp in $deplibrary_names; do
Chris@69 8504 depdepl=$tmp
Chris@69 8505 done
Chris@69 8506 if test -f "$absdir/$objdir/$depdepl"; then
Chris@69 8507 depdepl=$absdir/$objdir/$depdepl
Chris@69 8508 darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
Chris@69 8509 if test -z "$darwin_install_name"; then
Chris@69 8510 darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
Chris@69 8511 fi
Chris@69 8512 func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
Chris@69 8513 func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
Chris@69 8514 path=
Chris@69 8515 fi
Chris@69 8516 fi
Chris@69 8517 ;;
Chris@69 8518 *)
Chris@69 8519 path=-L$absdir/$objdir
Chris@69 8520 ;;
Chris@69 8521 esac
Chris@69 8522 else
Chris@69 8523 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
Chris@69 8524 test -z "$libdir" && \
Chris@69 8525 func_fatal_error "'$deplib' is not a valid libtool archive"
Chris@69 8526 test "$absdir" != "$libdir" && \
Chris@69 8527 func_warning "'$deplib' seems to be moved"
Chris@69 8528
Chris@69 8529 path=-L$absdir
Chris@69 8530 fi
Chris@69 8531 ;;
Chris@69 8532 esac
Chris@69 8533 case " $deplibs " in
Chris@69 8534 *" $path "*) ;;
Chris@69 8535 *) deplibs="$path $deplibs" ;;
Chris@69 8536 esac
Chris@69 8537 done
Chris@69 8538 fi # link_all_deplibs != no
Chris@69 8539 fi # linkmode = lib
Chris@69 8540 done # for deplib in $libs
Chris@69 8541 if test link = "$pass"; then
Chris@69 8542 if test prog = "$linkmode"; then
Chris@69 8543 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
Chris@69 8544 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
Chris@69 8545 else
Chris@69 8546 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@69 8547 fi
Chris@69 8548 fi
Chris@69 8549 dependency_libs=$newdependency_libs
Chris@69 8550 if test dlpreopen = "$pass"; then
Chris@69 8551 # Link the dlpreopened libraries before other libraries
Chris@69 8552 for deplib in $save_deplibs; do
Chris@69 8553 deplibs="$deplib $deplibs"
Chris@69 8554 done
Chris@69 8555 fi
Chris@69 8556 if test dlopen != "$pass"; then
Chris@69 8557 test conv = "$pass" || {
Chris@69 8558 # Make sure lib_search_path contains only unique directories.
Chris@69 8559 lib_search_path=
Chris@69 8560 for dir in $newlib_search_path; do
Chris@69 8561 case "$lib_search_path " in
Chris@69 8562 *" $dir "*) ;;
Chris@69 8563 *) func_append lib_search_path " $dir" ;;
Chris@69 8564 esac
Chris@69 8565 done
Chris@69 8566 newlib_search_path=
Chris@69 8567 }
Chris@69 8568
Chris@69 8569 if test prog,link = "$linkmode,$pass"; then
Chris@69 8570 vars="compile_deplibs finalize_deplibs"
Chris@69 8571 else
Chris@69 8572 vars=deplibs
Chris@69 8573 fi
Chris@69 8574 for var in $vars dependency_libs; do
Chris@69 8575 # Add libraries to $var in reverse order
Chris@69 8576 eval tmp_libs=\"\$$var\"
Chris@69 8577 new_libs=
Chris@69 8578 for deplib in $tmp_libs; do
Chris@69 8579 # FIXME: Pedantically, this is the right thing to do, so
Chris@69 8580 # that some nasty dependency loop isn't accidentally
Chris@69 8581 # broken:
Chris@69 8582 #new_libs="$deplib $new_libs"
Chris@69 8583 # Pragmatically, this seems to cause very few problems in
Chris@69 8584 # practice:
Chris@69 8585 case $deplib in
Chris@69 8586 -L*) new_libs="$deplib $new_libs" ;;
Chris@69 8587 -R*) ;;
Chris@69 8588 *)
Chris@69 8589 # And here is the reason: when a library appears more
Chris@69 8590 # than once as an explicit dependence of a library, or
Chris@69 8591 # is implicitly linked in more than once by the
Chris@69 8592 # compiler, it is considered special, and multiple
Chris@69 8593 # occurrences thereof are not removed. Compare this
Chris@69 8594 # with having the same library being listed as a
Chris@69 8595 # dependency of multiple other libraries: in this case,
Chris@69 8596 # we know (pedantically, we assume) the library does not
Chris@69 8597 # need to be listed more than once, so we keep only the
Chris@69 8598 # last copy. This is not always right, but it is rare
Chris@69 8599 # enough that we require users that really mean to play
Chris@69 8600 # such unportable linking tricks to link the library
Chris@69 8601 # using -Wl,-lname, so that libtool does not consider it
Chris@69 8602 # for duplicate removal.
Chris@69 8603 case " $specialdeplibs " in
Chris@69 8604 *" $deplib "*) new_libs="$deplib $new_libs" ;;
Chris@69 8605 *)
Chris@69 8606 case " $new_libs " in
Chris@69 8607 *" $deplib "*) ;;
Chris@69 8608 *) new_libs="$deplib $new_libs" ;;
Chris@69 8609 esac
Chris@69 8610 ;;
Chris@69 8611 esac
Chris@69 8612 ;;
Chris@69 8613 esac
Chris@69 8614 done
Chris@69 8615 tmp_libs=
Chris@69 8616 for deplib in $new_libs; do
Chris@69 8617 case $deplib in
Chris@69 8618 -L*)
Chris@69 8619 case " $tmp_libs " in
Chris@69 8620 *" $deplib "*) ;;
Chris@69 8621 *) func_append tmp_libs " $deplib" ;;
Chris@69 8622 esac
Chris@69 8623 ;;
Chris@69 8624 *) func_append tmp_libs " $deplib" ;;
Chris@69 8625 esac
Chris@69 8626 done
Chris@69 8627 eval $var=\"$tmp_libs\"
Chris@69 8628 done # for var
Chris@69 8629 fi
Chris@69 8630
Chris@69 8631 # Add Sun CC postdeps if required:
Chris@69 8632 test CXX = "$tagname" && {
Chris@69 8633 case $host_os in
Chris@69 8634 linux*)
Chris@69 8635 case `$CC -V 2>&1 | sed 5q` in
Chris@69 8636 *Sun\ C*) # Sun C++ 5.9
Chris@69 8637 func_suncc_cstd_abi
Chris@69 8638
Chris@69 8639 if test no != "$suncc_use_cstd_abi"; then
Chris@69 8640 func_append postdeps ' -library=Cstd -library=Crun'
Chris@69 8641 fi
Chris@69 8642 ;;
Chris@69 8643 esac
Chris@69 8644 ;;
Chris@69 8645
Chris@69 8646 solaris*)
Chris@69 8647 func_cc_basename "$CC"
Chris@69 8648 case $func_cc_basename_result in
Chris@69 8649 CC* | sunCC*)
Chris@69 8650 func_suncc_cstd_abi
Chris@69 8651
Chris@69 8652 if test no != "$suncc_use_cstd_abi"; then
Chris@69 8653 func_append postdeps ' -library=Cstd -library=Crun'
Chris@69 8654 fi
Chris@69 8655 ;;
Chris@69 8656 esac
Chris@69 8657 ;;
Chris@69 8658 esac
Chris@69 8659 }
Chris@69 8660
Chris@69 8661 # Last step: remove runtime libs from dependency_libs
Chris@69 8662 # (they stay in deplibs)
Chris@69 8663 tmp_libs=
Chris@69 8664 for i in $dependency_libs; do
Chris@69 8665 case " $predeps $postdeps $compiler_lib_search_path " in
Chris@69 8666 *" $i "*)
Chris@69 8667 i=
Chris@69 8668 ;;
Chris@69 8669 esac
Chris@69 8670 if test -n "$i"; then
Chris@69 8671 func_append tmp_libs " $i"
Chris@69 8672 fi
Chris@69 8673 done
Chris@69 8674 dependency_libs=$tmp_libs
Chris@69 8675 done # for pass
Chris@69 8676 if test prog = "$linkmode"; then
Chris@69 8677 dlfiles=$newdlfiles
Chris@69 8678 fi
Chris@69 8679 if test prog = "$linkmode" || test lib = "$linkmode"; then
Chris@69 8680 dlprefiles=$newdlprefiles
Chris@69 8681 fi
Chris@69 8682
Chris@69 8683 case $linkmode in
Chris@69 8684 oldlib)
Chris@69 8685 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
Chris@69 8686 func_warning "'-dlopen' is ignored for archives"
Chris@69 8687 fi
Chris@69 8688
Chris@69 8689 case " $deplibs" in
Chris@69 8690 *\ -l* | *\ -L*)
Chris@69 8691 func_warning "'-l' and '-L' are ignored for archives" ;;
Chris@69 8692 esac
Chris@69 8693
Chris@69 8694 test -n "$rpath" && \
Chris@69 8695 func_warning "'-rpath' is ignored for archives"
Chris@69 8696
Chris@69 8697 test -n "$xrpath" && \
Chris@69 8698 func_warning "'-R' is ignored for archives"
Chris@69 8699
Chris@69 8700 test -n "$vinfo" && \
Chris@69 8701 func_warning "'-version-info/-version-number' is ignored for archives"
Chris@69 8702
Chris@69 8703 test -n "$release" && \
Chris@69 8704 func_warning "'-release' is ignored for archives"
Chris@69 8705
Chris@69 8706 test -n "$export_symbols$export_symbols_regex" && \
Chris@69 8707 func_warning "'-export-symbols' is ignored for archives"
Chris@69 8708
Chris@69 8709 # Now set the variables for building old libraries.
Chris@69 8710 build_libtool_libs=no
Chris@69 8711 oldlibs=$output
Chris@69 8712 func_append objs "$old_deplibs"
Chris@69 8713 ;;
Chris@69 8714
Chris@69 8715 lib)
Chris@69 8716 # Make sure we only generate libraries of the form 'libNAME.la'.
Chris@69 8717 case $outputname in
Chris@69 8718 lib*)
Chris@69 8719 func_stripname 'lib' '.la' "$outputname"
Chris@69 8720 name=$func_stripname_result
Chris@69 8721 eval shared_ext=\"$shrext_cmds\"
Chris@69 8722 eval libname=\"$libname_spec\"
Chris@69 8723 ;;
Chris@69 8724 *)
Chris@69 8725 test no = "$module" \
Chris@69 8726 && func_fatal_help "libtool library '$output' must begin with 'lib'"
Chris@69 8727
Chris@69 8728 if test no != "$need_lib_prefix"; then
Chris@69 8729 # Add the "lib" prefix for modules if required
Chris@69 8730 func_stripname '' '.la' "$outputname"
Chris@69 8731 name=$func_stripname_result
Chris@69 8732 eval shared_ext=\"$shrext_cmds\"
Chris@69 8733 eval libname=\"$libname_spec\"
Chris@69 8734 else
Chris@69 8735 func_stripname '' '.la' "$outputname"
Chris@69 8736 libname=$func_stripname_result
Chris@69 8737 fi
Chris@69 8738 ;;
Chris@69 8739 esac
Chris@69 8740
Chris@69 8741 if test -n "$objs"; then
Chris@69 8742 if test pass_all != "$deplibs_check_method"; then
Chris@69 8743 func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
Chris@69 8744 else
Chris@69 8745 echo
Chris@69 8746 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
Chris@69 8747 $ECHO "*** objects $objs is not portable!"
Chris@69 8748 func_append libobjs " $objs"
Chris@69 8749 fi
Chris@69 8750 fi
Chris@69 8751
Chris@69 8752 test no = "$dlself" \
Chris@69 8753 || func_warning "'-dlopen self' is ignored for libtool libraries"
Chris@69 8754
Chris@69 8755 set dummy $rpath
Chris@69 8756 shift
Chris@69 8757 test 1 -lt "$#" \
Chris@69 8758 && func_warning "ignoring multiple '-rpath's for a libtool library"
Chris@69 8759
Chris@69 8760 install_libdir=$1
Chris@69 8761
Chris@69 8762 oldlibs=
Chris@69 8763 if test -z "$rpath"; then
Chris@69 8764 if test yes = "$build_libtool_libs"; then
Chris@69 8765 # Building a libtool convenience library.
Chris@69 8766 # Some compilers have problems with a '.al' extension so
Chris@69 8767 # convenience libraries should have the same extension an
Chris@69 8768 # archive normally would.
Chris@69 8769 oldlibs="$output_objdir/$libname.$libext $oldlibs"
Chris@69 8770 build_libtool_libs=convenience
Chris@69 8771 build_old_libs=yes
Chris@69 8772 fi
Chris@69 8773
Chris@69 8774 test -n "$vinfo" && \
Chris@69 8775 func_warning "'-version-info/-version-number' is ignored for convenience libraries"
Chris@69 8776
Chris@69 8777 test -n "$release" && \
Chris@69 8778 func_warning "'-release' is ignored for convenience libraries"
Chris@69 8779 else
Chris@69 8780
Chris@69 8781 # Parse the version information argument.
Chris@69 8782 save_ifs=$IFS; IFS=:
Chris@69 8783 set dummy $vinfo 0 0 0
Chris@69 8784 shift
Chris@69 8785 IFS=$save_ifs
Chris@69 8786
Chris@69 8787 test -n "$7" && \
Chris@69 8788 func_fatal_help "too many parameters to '-version-info'"
Chris@69 8789
Chris@69 8790 # convert absolute version numbers to libtool ages
Chris@69 8791 # this retains compatibility with .la files and attempts
Chris@69 8792 # to make the code below a bit more comprehensible
Chris@69 8793
Chris@69 8794 case $vinfo_number in
Chris@69 8795 yes)
Chris@69 8796 number_major=$1
Chris@69 8797 number_minor=$2
Chris@69 8798 number_revision=$3
Chris@69 8799 #
Chris@69 8800 # There are really only two kinds -- those that
Chris@69 8801 # use the current revision as the major version
Chris@69 8802 # and those that subtract age and use age as
Chris@69 8803 # a minor version. But, then there is irix
Chris@69 8804 # that has an extra 1 added just for fun
Chris@69 8805 #
Chris@69 8806 case $version_type in
Chris@69 8807 # correct linux to gnu/linux during the next big refactor
Chris@69 8808 darwin|freebsd-elf|linux|osf|windows|none)
Chris@69 8809 func_arith $number_major + $number_minor
Chris@69 8810 current=$func_arith_result
Chris@69 8811 age=$number_minor
Chris@69 8812 revision=$number_revision
Chris@69 8813 ;;
Chris@69 8814 freebsd-aout|qnx|sunos)
Chris@69 8815 current=$number_major
Chris@69 8816 revision=$number_minor
Chris@69 8817 age=0
Chris@69 8818 ;;
Chris@69 8819 irix|nonstopux)
Chris@69 8820 func_arith $number_major + $number_minor
Chris@69 8821 current=$func_arith_result
Chris@69 8822 age=$number_minor
Chris@69 8823 revision=$number_minor
Chris@69 8824 lt_irix_increment=no
Chris@69 8825 ;;
Chris@69 8826 esac
Chris@69 8827 ;;
Chris@69 8828 no)
Chris@69 8829 current=$1
Chris@69 8830 revision=$2
Chris@69 8831 age=$3
Chris@69 8832 ;;
Chris@69 8833 esac
Chris@69 8834
Chris@69 8835 # Check that each of the things are valid numbers.
Chris@69 8836 case $current in
Chris@69 8837 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]) ;;
Chris@69 8838 *)
Chris@69 8839 func_error "CURRENT '$current' must be a nonnegative integer"
Chris@69 8840 func_fatal_error "'$vinfo' is not valid version information"
Chris@69 8841 ;;
Chris@69 8842 esac
Chris@69 8843
Chris@69 8844 case $revision in
Chris@69 8845 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]) ;;
Chris@69 8846 *)
Chris@69 8847 func_error "REVISION '$revision' must be a nonnegative integer"
Chris@69 8848 func_fatal_error "'$vinfo' is not valid version information"
Chris@69 8849 ;;
Chris@69 8850 esac
Chris@69 8851
Chris@69 8852 case $age in
Chris@69 8853 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]) ;;
Chris@69 8854 *)
Chris@69 8855 func_error "AGE '$age' must be a nonnegative integer"
Chris@69 8856 func_fatal_error "'$vinfo' is not valid version information"
Chris@69 8857 ;;
Chris@69 8858 esac
Chris@69 8859
Chris@69 8860 if test "$age" -gt "$current"; then
Chris@69 8861 func_error "AGE '$age' is greater than the current interface number '$current'"
Chris@69 8862 func_fatal_error "'$vinfo' is not valid version information"
Chris@69 8863 fi
Chris@69 8864
Chris@69 8865 # Calculate the version variables.
Chris@69 8866 major=
Chris@69 8867 versuffix=
Chris@69 8868 verstring=
Chris@69 8869 case $version_type in
Chris@69 8870 none) ;;
Chris@69 8871
Chris@69 8872 darwin)
Chris@69 8873 # Like Linux, but with the current version available in
Chris@69 8874 # verstring for coding it into the library header
Chris@69 8875 func_arith $current - $age
Chris@69 8876 major=.$func_arith_result
Chris@69 8877 versuffix=$major.$age.$revision
Chris@69 8878 # Darwin ld doesn't like 0 for these options...
Chris@69 8879 func_arith $current + 1
Chris@69 8880 minor_current=$func_arith_result
Chris@69 8881 xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
Chris@69 8882 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
Chris@69 8883 # On Darwin other compilers
Chris@69 8884 case $CC in
Chris@69 8885 nagfor*)
Chris@69 8886 verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
Chris@69 8887 ;;
Chris@69 8888 *)
Chris@69 8889 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
Chris@69 8890 ;;
Chris@69 8891 esac
Chris@69 8892 ;;
Chris@69 8893
Chris@69 8894 freebsd-aout)
Chris@69 8895 major=.$current
Chris@69 8896 versuffix=.$current.$revision
Chris@69 8897 ;;
Chris@69 8898
Chris@69 8899 freebsd-elf)
Chris@69 8900 func_arith $current - $age
Chris@69 8901 major=.$func_arith_result
Chris@69 8902 versuffix=$major.$age.$revision
Chris@69 8903 ;;
Chris@69 8904
Chris@69 8905 irix | nonstopux)
Chris@69 8906 if test no = "$lt_irix_increment"; then
Chris@69 8907 func_arith $current - $age
Chris@69 8908 else
Chris@69 8909 func_arith $current - $age + 1
Chris@69 8910 fi
Chris@69 8911 major=$func_arith_result
Chris@69 8912
Chris@69 8913 case $version_type in
Chris@69 8914 nonstopux) verstring_prefix=nonstopux ;;
Chris@69 8915 *) verstring_prefix=sgi ;;
Chris@69 8916 esac
Chris@69 8917 verstring=$verstring_prefix$major.$revision
Chris@69 8918
Chris@69 8919 # Add in all the interfaces that we are compatible with.
Chris@69 8920 loop=$revision
Chris@69 8921 while test 0 -ne "$loop"; do
Chris@69 8922 func_arith $revision - $loop
Chris@69 8923 iface=$func_arith_result
Chris@69 8924 func_arith $loop - 1
Chris@69 8925 loop=$func_arith_result
Chris@69 8926 verstring=$verstring_prefix$major.$iface:$verstring
Chris@69 8927 done
Chris@69 8928
Chris@69 8929 # Before this point, $major must not contain '.'.
Chris@69 8930 major=.$major
Chris@69 8931 versuffix=$major.$revision
Chris@69 8932 ;;
Chris@69 8933
Chris@69 8934 linux) # correct to gnu/linux during the next big refactor
Chris@69 8935 func_arith $current - $age
Chris@69 8936 major=.$func_arith_result
Chris@69 8937 versuffix=$major.$age.$revision
Chris@69 8938 ;;
Chris@69 8939
Chris@69 8940 osf)
Chris@69 8941 func_arith $current - $age
Chris@69 8942 major=.$func_arith_result
Chris@69 8943 versuffix=.$current.$age.$revision
Chris@69 8944 verstring=$current.$age.$revision
Chris@69 8945
Chris@69 8946 # Add in all the interfaces that we are compatible with.
Chris@69 8947 loop=$age
Chris@69 8948 while test 0 -ne "$loop"; do
Chris@69 8949 func_arith $current - $loop
Chris@69 8950 iface=$func_arith_result
Chris@69 8951 func_arith $loop - 1
Chris@69 8952 loop=$func_arith_result
Chris@69 8953 verstring=$verstring:$iface.0
Chris@69 8954 done
Chris@69 8955
Chris@69 8956 # Make executables depend on our current version.
Chris@69 8957 func_append verstring ":$current.0"
Chris@69 8958 ;;
Chris@69 8959
Chris@69 8960 qnx)
Chris@69 8961 major=.$current
Chris@69 8962 versuffix=.$current
Chris@69 8963 ;;
Chris@69 8964
Chris@69 8965 sco)
Chris@69 8966 major=.$current
Chris@69 8967 versuffix=.$current
Chris@69 8968 ;;
Chris@69 8969
Chris@69 8970 sunos)
Chris@69 8971 major=.$current
Chris@69 8972 versuffix=.$current.$revision
Chris@69 8973 ;;
Chris@69 8974
Chris@69 8975 windows)
Chris@69 8976 # Use '-' rather than '.', since we only want one
Chris@69 8977 # extension on DOS 8.3 file systems.
Chris@69 8978 func_arith $current - $age
Chris@69 8979 major=$func_arith_result
Chris@69 8980 versuffix=-$major
Chris@69 8981 ;;
Chris@69 8982
Chris@69 8983 *)
Chris@69 8984 func_fatal_configuration "unknown library version type '$version_type'"
Chris@69 8985 ;;
Chris@69 8986 esac
Chris@69 8987
Chris@69 8988 # Clear the version info if we defaulted, and they specified a release.
Chris@69 8989 if test -z "$vinfo" && test -n "$release"; then
Chris@69 8990 major=
Chris@69 8991 case $version_type in
Chris@69 8992 darwin)
Chris@69 8993 # we can't check for "0.0" in archive_cmds due to quoting
Chris@69 8994 # problems, so we reset it completely
Chris@69 8995 verstring=
Chris@69 8996 ;;
Chris@69 8997 *)
Chris@69 8998 verstring=0.0
Chris@69 8999 ;;
Chris@69 9000 esac
Chris@69 9001 if test no = "$need_version"; then
Chris@69 9002 versuffix=
Chris@69 9003 else
Chris@69 9004 versuffix=.0.0
Chris@69 9005 fi
Chris@69 9006 fi
Chris@69 9007
Chris@69 9008 # Remove version info from name if versioning should be avoided
Chris@69 9009 if test yes,no = "$avoid_version,$need_version"; then
Chris@69 9010 major=
Chris@69 9011 versuffix=
Chris@69 9012 verstring=
Chris@69 9013 fi
Chris@69 9014
Chris@69 9015 # Check to see if the archive will have undefined symbols.
Chris@69 9016 if test yes = "$allow_undefined"; then
Chris@69 9017 if test unsupported = "$allow_undefined_flag"; then
Chris@69 9018 if test yes = "$build_old_libs"; then
Chris@69 9019 func_warning "undefined symbols not allowed in $host shared libraries; building static only"
Chris@69 9020 build_libtool_libs=no
Chris@69 9021 else
Chris@69 9022 func_fatal_error "can't build $host shared library unless -no-undefined is specified"
Chris@69 9023 fi
Chris@69 9024 fi
Chris@69 9025 else
Chris@69 9026 # Don't allow undefined symbols.
Chris@69 9027 allow_undefined_flag=$no_undefined_flag
Chris@69 9028 fi
Chris@69 9029
Chris@69 9030 fi
Chris@69 9031
Chris@69 9032 func_generate_dlsyms "$libname" "$libname" :
Chris@69 9033 func_append libobjs " $symfileobj"
Chris@69 9034 test " " = "$libobjs" && libobjs=
Chris@69 9035
Chris@69 9036 if test relink != "$opt_mode"; then
Chris@69 9037 # Remove our outputs, but don't remove object files since they
Chris@69 9038 # may have been created when compiling PIC objects.
Chris@69 9039 removelist=
Chris@69 9040 tempremovelist=`$ECHO "$output_objdir/*"`
Chris@69 9041 for p in $tempremovelist; do
Chris@69 9042 case $p in
Chris@69 9043 *.$objext | *.gcno)
Chris@69 9044 ;;
Chris@69 9045 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
Chris@69 9046 if test -n "$precious_files_regex"; then
Chris@69 9047 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
Chris@69 9048 then
Chris@69 9049 continue
Chris@69 9050 fi
Chris@69 9051 fi
Chris@69 9052 func_append removelist " $p"
Chris@69 9053 ;;
Chris@69 9054 *) ;;
Chris@69 9055 esac
Chris@69 9056 done
Chris@69 9057 test -n "$removelist" && \
Chris@69 9058 func_show_eval "${RM}r \$removelist"
Chris@69 9059 fi
Chris@69 9060
Chris@69 9061 # Now set the variables for building old libraries.
Chris@69 9062 if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
Chris@69 9063 func_append oldlibs " $output_objdir/$libname.$libext"
Chris@69 9064
Chris@69 9065 # Transform .lo files to .o files.
Chris@69 9066 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
Chris@69 9067 fi
Chris@69 9068
Chris@69 9069 # Eliminate all temporary directories.
Chris@69 9070 #for path in $notinst_path; do
Chris@69 9071 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
Chris@69 9072 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
Chris@69 9073 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
Chris@69 9074 #done
Chris@69 9075
Chris@69 9076 if test -n "$xrpath"; then
Chris@69 9077 # If the user specified any rpath flags, then add them.
Chris@69 9078 temp_xrpath=
Chris@69 9079 for libdir in $xrpath; do
Chris@69 9080 func_replace_sysroot "$libdir"
Chris@69 9081 func_append temp_xrpath " -R$func_replace_sysroot_result"
Chris@69 9082 case "$finalize_rpath " in
Chris@69 9083 *" $libdir "*) ;;
Chris@69 9084 *) func_append finalize_rpath " $libdir" ;;
Chris@69 9085 esac
Chris@69 9086 done
Chris@69 9087 if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
Chris@69 9088 dependency_libs="$temp_xrpath $dependency_libs"
Chris@69 9089 fi
Chris@69 9090 fi
Chris@69 9091
Chris@69 9092 # Make sure dlfiles contains only unique files that won't be dlpreopened
Chris@69 9093 old_dlfiles=$dlfiles
Chris@69 9094 dlfiles=
Chris@69 9095 for lib in $old_dlfiles; do
Chris@69 9096 case " $dlprefiles $dlfiles " in
Chris@69 9097 *" $lib "*) ;;
Chris@69 9098 *) func_append dlfiles " $lib" ;;
Chris@69 9099 esac
Chris@69 9100 done
Chris@69 9101
Chris@69 9102 # Make sure dlprefiles contains only unique files
Chris@69 9103 old_dlprefiles=$dlprefiles
Chris@69 9104 dlprefiles=
Chris@69 9105 for lib in $old_dlprefiles; do
Chris@69 9106 case "$dlprefiles " in
Chris@69 9107 *" $lib "*) ;;
Chris@69 9108 *) func_append dlprefiles " $lib" ;;
Chris@69 9109 esac
Chris@69 9110 done
Chris@69 9111
Chris@69 9112 if test yes = "$build_libtool_libs"; then
Chris@69 9113 if test -n "$rpath"; then
Chris@69 9114 case $host in
Chris@69 9115 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
Chris@69 9116 # these systems don't actually have a c library (as such)!
Chris@69 9117 ;;
Chris@69 9118 *-*-rhapsody* | *-*-darwin1.[012])
Chris@69 9119 # Rhapsody C library is in the System framework
Chris@69 9120 func_append deplibs " System.ltframework"
Chris@69 9121 ;;
Chris@69 9122 *-*-netbsd*)
Chris@69 9123 # Don't link with libc until the a.out ld.so is fixed.
Chris@69 9124 ;;
Chris@69 9125 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
Chris@69 9126 # Do not include libc due to us having libc/libc_r.
Chris@69 9127 ;;
Chris@69 9128 *-*-sco3.2v5* | *-*-sco5v6*)
Chris@69 9129 # Causes problems with __ctype
Chris@69 9130 ;;
Chris@69 9131 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
Chris@69 9132 # Compiler inserts libc in the correct place for threads to work
Chris@69 9133 ;;
Chris@69 9134 *)
Chris@69 9135 # Add libc to deplibs on all other systems if necessary.
Chris@69 9136 if test yes = "$build_libtool_need_lc"; then
Chris@69 9137 func_append deplibs " -lc"
Chris@69 9138 fi
Chris@69 9139 ;;
Chris@69 9140 esac
Chris@69 9141 fi
Chris@69 9142
Chris@69 9143 # Transform deplibs into only deplibs that can be linked in shared.
Chris@69 9144 name_save=$name
Chris@69 9145 libname_save=$libname
Chris@69 9146 release_save=$release
Chris@69 9147 versuffix_save=$versuffix
Chris@69 9148 major_save=$major
Chris@69 9149 # I'm not sure if I'm treating the release correctly. I think
Chris@69 9150 # release should show up in the -l (ie -lgmp5) so we don't want to
Chris@69 9151 # add it in twice. Is that correct?
Chris@69 9152 release=
Chris@69 9153 versuffix=
Chris@69 9154 major=
Chris@69 9155 newdeplibs=
Chris@69 9156 droppeddeps=no
Chris@69 9157 case $deplibs_check_method in
Chris@69 9158 pass_all)
Chris@69 9159 # Don't check for shared/static. Everything works.
Chris@69 9160 # This might be a little naive. We might want to check
Chris@69 9161 # whether the library exists or not. But this is on
Chris@69 9162 # osf3 & osf4 and I'm not really sure... Just
Chris@69 9163 # implementing what was already the behavior.
Chris@69 9164 newdeplibs=$deplibs
Chris@69 9165 ;;
Chris@69 9166 test_compile)
Chris@69 9167 # This code stresses the "libraries are programs" paradigm to its
Chris@69 9168 # limits. Maybe even breaks it. We compile a program, linking it
Chris@69 9169 # against the deplibs as a proxy for the library. Then we can check
Chris@69 9170 # whether they linked in statically or dynamically with ldd.
Chris@69 9171 $opt_dry_run || $RM conftest.c
Chris@69 9172 cat > conftest.c <<EOF
Chris@69 9173 int main() { return 0; }
Chris@69 9174 EOF
Chris@69 9175 $opt_dry_run || $RM conftest
Chris@69 9176 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
Chris@69 9177 ldd_output=`ldd conftest`
Chris@69 9178 for i in $deplibs; do
Chris@69 9179 case $i in
Chris@69 9180 -l*)
Chris@69 9181 func_stripname -l '' "$i"
Chris@69 9182 name=$func_stripname_result
Chris@69 9183 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@69 9184 case " $predeps $postdeps " in
Chris@69 9185 *" $i "*)
Chris@69 9186 func_append newdeplibs " $i"
Chris@69 9187 i=
Chris@69 9188 ;;
Chris@69 9189 esac
Chris@69 9190 fi
Chris@69 9191 if test -n "$i"; then
Chris@69 9192 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@69 9193 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
Chris@69 9194 set dummy $deplib_matches; shift
Chris@69 9195 deplib_match=$1
Chris@69 9196 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
Chris@69 9197 func_append newdeplibs " $i"
Chris@69 9198 else
Chris@69 9199 droppeddeps=yes
Chris@69 9200 echo
Chris@69 9201 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
Chris@69 9202 echo "*** I have the capability to make that library automatically link in when"
Chris@69 9203 echo "*** you link to this library. But I can only do this if you have a"
Chris@69 9204 echo "*** shared version of the library, which I believe you do not have"
Chris@69 9205 echo "*** because a test_compile did reveal that the linker did not use it for"
Chris@69 9206 echo "*** its dynamic dependency list that programs get resolved with at runtime."
Chris@69 9207 fi
Chris@69 9208 fi
Chris@69 9209 ;;
Chris@69 9210 *)
Chris@69 9211 func_append newdeplibs " $i"
Chris@69 9212 ;;
Chris@69 9213 esac
Chris@69 9214 done
Chris@69 9215 else
Chris@69 9216 # Error occurred in the first compile. Let's try to salvage
Chris@69 9217 # the situation: Compile a separate program for each library.
Chris@69 9218 for i in $deplibs; do
Chris@69 9219 case $i in
Chris@69 9220 -l*)
Chris@69 9221 func_stripname -l '' "$i"
Chris@69 9222 name=$func_stripname_result
Chris@69 9223 $opt_dry_run || $RM conftest
Chris@69 9224 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
Chris@69 9225 ldd_output=`ldd conftest`
Chris@69 9226 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@69 9227 case " $predeps $postdeps " in
Chris@69 9228 *" $i "*)
Chris@69 9229 func_append newdeplibs " $i"
Chris@69 9230 i=
Chris@69 9231 ;;
Chris@69 9232 esac
Chris@69 9233 fi
Chris@69 9234 if test -n "$i"; then
Chris@69 9235 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@69 9236 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
Chris@69 9237 set dummy $deplib_matches; shift
Chris@69 9238 deplib_match=$1
Chris@69 9239 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
Chris@69 9240 func_append newdeplibs " $i"
Chris@69 9241 else
Chris@69 9242 droppeddeps=yes
Chris@69 9243 echo
Chris@69 9244 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
Chris@69 9245 echo "*** I have the capability to make that library automatically link in when"
Chris@69 9246 echo "*** you link to this library. But I can only do this if you have a"
Chris@69 9247 echo "*** shared version of the library, which you do not appear to have"
Chris@69 9248 echo "*** because a test_compile did reveal that the linker did not use this one"
Chris@69 9249 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
Chris@69 9250 fi
Chris@69 9251 fi
Chris@69 9252 else
Chris@69 9253 droppeddeps=yes
Chris@69 9254 echo
Chris@69 9255 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
Chris@69 9256 echo "*** make it link in! You will probably need to install it or some"
Chris@69 9257 echo "*** library that it depends on before this library will be fully"
Chris@69 9258 echo "*** functional. Installing it before continuing would be even better."
Chris@69 9259 fi
Chris@69 9260 ;;
Chris@69 9261 *)
Chris@69 9262 func_append newdeplibs " $i"
Chris@69 9263 ;;
Chris@69 9264 esac
Chris@69 9265 done
Chris@69 9266 fi
Chris@69 9267 ;;
Chris@69 9268 file_magic*)
Chris@69 9269 set dummy $deplibs_check_method; shift
Chris@69 9270 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Chris@69 9271 for a_deplib in $deplibs; do
Chris@69 9272 case $a_deplib in
Chris@69 9273 -l*)
Chris@69 9274 func_stripname -l '' "$a_deplib"
Chris@69 9275 name=$func_stripname_result
Chris@69 9276 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@69 9277 case " $predeps $postdeps " in
Chris@69 9278 *" $a_deplib "*)
Chris@69 9279 func_append newdeplibs " $a_deplib"
Chris@69 9280 a_deplib=
Chris@69 9281 ;;
Chris@69 9282 esac
Chris@69 9283 fi
Chris@69 9284 if test -n "$a_deplib"; then
Chris@69 9285 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@69 9286 if test -n "$file_magic_glob"; then
Chris@69 9287 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
Chris@69 9288 else
Chris@69 9289 libnameglob=$libname
Chris@69 9290 fi
Chris@69 9291 test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
Chris@69 9292 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
Chris@69 9293 if test yes = "$want_nocaseglob"; then
Chris@69 9294 shopt -s nocaseglob
Chris@69 9295 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
Chris@69 9296 $nocaseglob
Chris@69 9297 else
Chris@69 9298 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
Chris@69 9299 fi
Chris@69 9300 for potent_lib in $potential_libs; do
Chris@69 9301 # Follow soft links.
Chris@69 9302 if ls -lLd "$potent_lib" 2>/dev/null |
Chris@69 9303 $GREP " -> " >/dev/null; then
Chris@69 9304 continue
Chris@69 9305 fi
Chris@69 9306 # The statement above tries to avoid entering an
Chris@69 9307 # endless loop below, in case of cyclic links.
Chris@69 9308 # We might still enter an endless loop, since a link
Chris@69 9309 # loop can be closed while we follow links,
Chris@69 9310 # but so what?
Chris@69 9311 potlib=$potent_lib
Chris@69 9312 while test -h "$potlib" 2>/dev/null; do
Chris@69 9313 potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
Chris@69 9314 case $potliblink in
Chris@69 9315 [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
Chris@69 9316 *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
Chris@69 9317 esac
Chris@69 9318 done
Chris@69 9319 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
Chris@69 9320 $SED -e 10q |
Chris@69 9321 $EGREP "$file_magic_regex" > /dev/null; then
Chris@69 9322 func_append newdeplibs " $a_deplib"
Chris@69 9323 a_deplib=
Chris@69 9324 break 2
Chris@69 9325 fi
Chris@69 9326 done
Chris@69 9327 done
Chris@69 9328 fi
Chris@69 9329 if test -n "$a_deplib"; then
Chris@69 9330 droppeddeps=yes
Chris@69 9331 echo
Chris@69 9332 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
Chris@69 9333 echo "*** I have the capability to make that library automatically link in when"
Chris@69 9334 echo "*** you link to this library. But I can only do this if you have a"
Chris@69 9335 echo "*** shared version of the library, which you do not appear to have"
Chris@69 9336 echo "*** because I did check the linker path looking for a file starting"
Chris@69 9337 if test -z "$potlib"; then
Chris@69 9338 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
Chris@69 9339 else
Chris@69 9340 $ECHO "*** with $libname and none of the candidates passed a file format test"
Chris@69 9341 $ECHO "*** using a file magic. Last file checked: $potlib"
Chris@69 9342 fi
Chris@69 9343 fi
Chris@69 9344 ;;
Chris@69 9345 *)
Chris@69 9346 # Add a -L argument.
Chris@69 9347 func_append newdeplibs " $a_deplib"
Chris@69 9348 ;;
Chris@69 9349 esac
Chris@69 9350 done # Gone through all deplibs.
Chris@69 9351 ;;
Chris@69 9352 match_pattern*)
Chris@69 9353 set dummy $deplibs_check_method; shift
Chris@69 9354 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Chris@69 9355 for a_deplib in $deplibs; do
Chris@69 9356 case $a_deplib in
Chris@69 9357 -l*)
Chris@69 9358 func_stripname -l '' "$a_deplib"
Chris@69 9359 name=$func_stripname_result
Chris@69 9360 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@69 9361 case " $predeps $postdeps " in
Chris@69 9362 *" $a_deplib "*)
Chris@69 9363 func_append newdeplibs " $a_deplib"
Chris@69 9364 a_deplib=
Chris@69 9365 ;;
Chris@69 9366 esac
Chris@69 9367 fi
Chris@69 9368 if test -n "$a_deplib"; then
Chris@69 9369 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@69 9370 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
Chris@69 9371 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
Chris@69 9372 for potent_lib in $potential_libs; do
Chris@69 9373 potlib=$potent_lib # see symlink-check above in file_magic test
Chris@69 9374 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
Chris@69 9375 $EGREP "$match_pattern_regex" > /dev/null; then
Chris@69 9376 func_append newdeplibs " $a_deplib"
Chris@69 9377 a_deplib=
Chris@69 9378 break 2
Chris@69 9379 fi
Chris@69 9380 done
Chris@69 9381 done
Chris@69 9382 fi
Chris@69 9383 if test -n "$a_deplib"; then
Chris@69 9384 droppeddeps=yes
Chris@69 9385 echo
Chris@69 9386 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
Chris@69 9387 echo "*** I have the capability to make that library automatically link in when"
Chris@69 9388 echo "*** you link to this library. But I can only do this if you have a"
Chris@69 9389 echo "*** shared version of the library, which you do not appear to have"
Chris@69 9390 echo "*** because I did check the linker path looking for a file starting"
Chris@69 9391 if test -z "$potlib"; then
Chris@69 9392 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
Chris@69 9393 else
Chris@69 9394 $ECHO "*** with $libname and none of the candidates passed a file format test"
Chris@69 9395 $ECHO "*** using a regex pattern. Last file checked: $potlib"
Chris@69 9396 fi
Chris@69 9397 fi
Chris@69 9398 ;;
Chris@69 9399 *)
Chris@69 9400 # Add a -L argument.
Chris@69 9401 func_append newdeplibs " $a_deplib"
Chris@69 9402 ;;
Chris@69 9403 esac
Chris@69 9404 done # Gone through all deplibs.
Chris@69 9405 ;;
Chris@69 9406 none | unknown | *)
Chris@69 9407 newdeplibs=
Chris@69 9408 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
Chris@69 9409 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@69 9410 for i in $predeps $postdeps; do
Chris@69 9411 # can't use Xsed below, because $i might contain '/'
Chris@69 9412 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
Chris@69 9413 done
Chris@69 9414 fi
Chris@69 9415 case $tmp_deplibs in
Chris@69 9416 *[!\ \ ]*)
Chris@69 9417 echo
Chris@69 9418 if test none = "$deplibs_check_method"; then
Chris@69 9419 echo "*** Warning: inter-library dependencies are not supported in this platform."
Chris@69 9420 else
Chris@69 9421 echo "*** Warning: inter-library dependencies are not known to be supported."
Chris@69 9422 fi
Chris@69 9423 echo "*** All declared inter-library dependencies are being dropped."
Chris@69 9424 droppeddeps=yes
Chris@69 9425 ;;
Chris@69 9426 esac
Chris@69 9427 ;;
Chris@69 9428 esac
Chris@69 9429 versuffix=$versuffix_save
Chris@69 9430 major=$major_save
Chris@69 9431 release=$release_save
Chris@69 9432 libname=$libname_save
Chris@69 9433 name=$name_save
Chris@69 9434
Chris@69 9435 case $host in
Chris@69 9436 *-*-rhapsody* | *-*-darwin1.[012])
Chris@69 9437 # On Rhapsody replace the C library with the System framework
Chris@69 9438 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
Chris@69 9439 ;;
Chris@69 9440 esac
Chris@69 9441
Chris@69 9442 if test yes = "$droppeddeps"; then
Chris@69 9443 if test yes = "$module"; then
Chris@69 9444 echo
Chris@69 9445 echo "*** Warning: libtool could not satisfy all declared inter-library"
Chris@69 9446 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
Chris@69 9447 echo "*** a static module, that should work as long as the dlopening"
Chris@69 9448 echo "*** application is linked with the -dlopen flag."
Chris@69 9449 if test -z "$global_symbol_pipe"; then
Chris@69 9450 echo
Chris@69 9451 echo "*** However, this would only work if libtool was able to extract symbol"
Chris@69 9452 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
Chris@69 9453 echo "*** not find such a program. So, this module is probably useless."
Chris@69 9454 echo "*** 'nm' from GNU binutils and a full rebuild may help."
Chris@69 9455 fi
Chris@69 9456 if test no = "$build_old_libs"; then
Chris@69 9457 oldlibs=$output_objdir/$libname.$libext
Chris@69 9458 build_libtool_libs=module
Chris@69 9459 build_old_libs=yes
Chris@69 9460 else
Chris@69 9461 build_libtool_libs=no
Chris@69 9462 fi
Chris@69 9463 else
Chris@69 9464 echo "*** The inter-library dependencies that have been dropped here will be"
Chris@69 9465 echo "*** automatically added whenever a program is linked with this library"
Chris@69 9466 echo "*** or is declared to -dlopen it."
Chris@69 9467
Chris@69 9468 if test no = "$allow_undefined"; then
Chris@69 9469 echo
Chris@69 9470 echo "*** Since this library must not contain undefined symbols,"
Chris@69 9471 echo "*** because either the platform does not support them or"
Chris@69 9472 echo "*** it was explicitly requested with -no-undefined,"
Chris@69 9473 echo "*** libtool will only create a static version of it."
Chris@69 9474 if test no = "$build_old_libs"; then
Chris@69 9475 oldlibs=$output_objdir/$libname.$libext
Chris@69 9476 build_libtool_libs=module
Chris@69 9477 build_old_libs=yes
Chris@69 9478 else
Chris@69 9479 build_libtool_libs=no
Chris@69 9480 fi
Chris@69 9481 fi
Chris@69 9482 fi
Chris@69 9483 fi
Chris@69 9484 # Done checking deplibs!
Chris@69 9485 deplibs=$newdeplibs
Chris@69 9486 fi
Chris@69 9487 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
Chris@69 9488 case $host in
Chris@69 9489 *-*-darwin*)
Chris@69 9490 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@69 9491 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@69 9492 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@69 9493 ;;
Chris@69 9494 esac
Chris@69 9495
Chris@69 9496 # move library search paths that coincide with paths to not yet
Chris@69 9497 # installed libraries to the beginning of the library search list
Chris@69 9498 new_libs=
Chris@69 9499 for path in $notinst_path; do
Chris@69 9500 case " $new_libs " in
Chris@69 9501 *" -L$path/$objdir "*) ;;
Chris@69 9502 *)
Chris@69 9503 case " $deplibs " in
Chris@69 9504 *" -L$path/$objdir "*)
Chris@69 9505 func_append new_libs " -L$path/$objdir" ;;
Chris@69 9506 esac
Chris@69 9507 ;;
Chris@69 9508 esac
Chris@69 9509 done
Chris@69 9510 for deplib in $deplibs; do
Chris@69 9511 case $deplib in
Chris@69 9512 -L*)
Chris@69 9513 case " $new_libs " in
Chris@69 9514 *" $deplib "*) ;;
Chris@69 9515 *) func_append new_libs " $deplib" ;;
Chris@69 9516 esac
Chris@69 9517 ;;
Chris@69 9518 *) func_append new_libs " $deplib" ;;
Chris@69 9519 esac
Chris@69 9520 done
Chris@69 9521 deplibs=$new_libs
Chris@69 9522
Chris@69 9523 # All the library-specific variables (install_libdir is set above).
Chris@69 9524 library_names=
Chris@69 9525 old_library=
Chris@69 9526 dlname=
Chris@69 9527
Chris@69 9528 # Test again, we may have decided not to build it any more
Chris@69 9529 if test yes = "$build_libtool_libs"; then
Chris@69 9530 # Remove $wl instances when linking with ld.
Chris@69 9531 # FIXME: should test the right _cmds variable.
Chris@69 9532 case $archive_cmds in
Chris@69 9533 *\$LD\ *) wl= ;;
Chris@69 9534 esac
Chris@69 9535 if test yes = "$hardcode_into_libs"; then
Chris@69 9536 # Hardcode the library paths
Chris@69 9537 hardcode_libdirs=
Chris@69 9538 dep_rpath=
Chris@69 9539 rpath=$finalize_rpath
Chris@69 9540 test relink = "$opt_mode" || rpath=$compile_rpath$rpath
Chris@69 9541 for libdir in $rpath; do
Chris@69 9542 if test -n "$hardcode_libdir_flag_spec"; then
Chris@69 9543 if test -n "$hardcode_libdir_separator"; then
Chris@69 9544 func_replace_sysroot "$libdir"
Chris@69 9545 libdir=$func_replace_sysroot_result
Chris@69 9546 if test -z "$hardcode_libdirs"; then
Chris@69 9547 hardcode_libdirs=$libdir
Chris@69 9548 else
Chris@69 9549 # Just accumulate the unique libdirs.
Chris@69 9550 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Chris@69 9551 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
Chris@69 9552 ;;
Chris@69 9553 *)
Chris@69 9554 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
Chris@69 9555 ;;
Chris@69 9556 esac
Chris@69 9557 fi
Chris@69 9558 else
Chris@69 9559 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@69 9560 func_append dep_rpath " $flag"
Chris@69 9561 fi
Chris@69 9562 elif test -n "$runpath_var"; then
Chris@69 9563 case "$perm_rpath " in
Chris@69 9564 *" $libdir "*) ;;
Chris@69 9565 *) func_append perm_rpath " $libdir" ;;
Chris@69 9566 esac
Chris@69 9567 fi
Chris@69 9568 done
Chris@69 9569 # Substitute the hardcoded libdirs into the rpath.
Chris@69 9570 if test -n "$hardcode_libdir_separator" &&
Chris@69 9571 test -n "$hardcode_libdirs"; then
Chris@69 9572 libdir=$hardcode_libdirs
Chris@69 9573 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
Chris@69 9574 fi
Chris@69 9575 if test -n "$runpath_var" && test -n "$perm_rpath"; then
Chris@69 9576 # We should set the runpath_var.
Chris@69 9577 rpath=
Chris@69 9578 for dir in $perm_rpath; do
Chris@69 9579 func_append rpath "$dir:"
Chris@69 9580 done
Chris@69 9581 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
Chris@69 9582 fi
Chris@69 9583 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
Chris@69 9584 fi
Chris@69 9585
Chris@69 9586 shlibpath=$finalize_shlibpath
Chris@69 9587 test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
Chris@69 9588 if test -n "$shlibpath"; then
Chris@69 9589 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
Chris@69 9590 fi
Chris@69 9591
Chris@69 9592 # Get the real and link names of the library.
Chris@69 9593 eval shared_ext=\"$shrext_cmds\"
Chris@69 9594 eval library_names=\"$library_names_spec\"
Chris@69 9595 set dummy $library_names
Chris@69 9596 shift
Chris@69 9597 realname=$1
Chris@69 9598 shift
Chris@69 9599
Chris@69 9600 if test -n "$soname_spec"; then
Chris@69 9601 eval soname=\"$soname_spec\"
Chris@69 9602 else
Chris@69 9603 soname=$realname
Chris@69 9604 fi
Chris@69 9605 if test -z "$dlname"; then
Chris@69 9606 dlname=$soname
Chris@69 9607 fi
Chris@69 9608
Chris@69 9609 lib=$output_objdir/$realname
Chris@69 9610 linknames=
Chris@69 9611 for link
Chris@69 9612 do
Chris@69 9613 func_append linknames " $link"
Chris@69 9614 done
Chris@69 9615
Chris@69 9616 # Use standard objects if they are pic
Chris@69 9617 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@69 9618 test "X$libobjs" = "X " && libobjs=
Chris@69 9619
Chris@69 9620 delfiles=
Chris@69 9621 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Chris@69 9622 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
Chris@69 9623 export_symbols=$output_objdir/$libname.uexp
Chris@69 9624 func_append delfiles " $export_symbols"
Chris@69 9625 fi
Chris@69 9626
Chris@69 9627 orig_export_symbols=
Chris@69 9628 case $host_os in
Chris@69 9629 cygwin* | mingw* | cegcc*)
Chris@69 9630 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
Chris@69 9631 # exporting using user supplied symfile
Chris@69 9632 func_dll_def_p "$export_symbols" || {
Chris@69 9633 # and it's NOT already a .def file. Must figure out
Chris@69 9634 # which of the given symbols are data symbols and tag
Chris@69 9635 # them as such. So, trigger use of export_symbols_cmds.
Chris@69 9636 # export_symbols gets reassigned inside the "prepare
Chris@69 9637 # the list of exported symbols" if statement, so the
Chris@69 9638 # include_expsyms logic still works.
Chris@69 9639 orig_export_symbols=$export_symbols
Chris@69 9640 export_symbols=
Chris@69 9641 always_export_symbols=yes
Chris@69 9642 }
Chris@69 9643 fi
Chris@69 9644 ;;
Chris@69 9645 esac
Chris@69 9646
Chris@69 9647 # Prepare the list of exported symbols
Chris@69 9648 if test -z "$export_symbols"; then
Chris@69 9649 if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
Chris@69 9650 func_verbose "generating symbol list for '$libname.la'"
Chris@69 9651 export_symbols=$output_objdir/$libname.exp
Chris@69 9652 $opt_dry_run || $RM $export_symbols
Chris@69 9653 cmds=$export_symbols_cmds
Chris@69 9654 save_ifs=$IFS; IFS='~'
Chris@69 9655 for cmd1 in $cmds; do
Chris@69 9656 IFS=$save_ifs
Chris@69 9657 # Take the normal branch if the nm_file_list_spec branch
Chris@69 9658 # doesn't work or if tool conversion is not needed.
Chris@69 9659 case $nm_file_list_spec~$to_tool_file_cmd in
Chris@69 9660 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
Chris@69 9661 try_normal_branch=yes
Chris@69 9662 eval cmd=\"$cmd1\"
Chris@69 9663 func_len " $cmd"
Chris@69 9664 len=$func_len_result
Chris@69 9665 ;;
Chris@69 9666 *)
Chris@69 9667 try_normal_branch=no
Chris@69 9668 ;;
Chris@69 9669 esac
Chris@69 9670 if test yes = "$try_normal_branch" \
Chris@69 9671 && { test "$len" -lt "$max_cmd_len" \
Chris@69 9672 || test "$max_cmd_len" -le -1; }
Chris@69 9673 then
Chris@69 9674 func_show_eval "$cmd" 'exit $?'
Chris@69 9675 skipped_export=false
Chris@69 9676 elif test -n "$nm_file_list_spec"; then
Chris@69 9677 func_basename "$output"
Chris@69 9678 output_la=$func_basename_result
Chris@69 9679 save_libobjs=$libobjs
Chris@69 9680 save_output=$output
Chris@69 9681 output=$output_objdir/$output_la.nm
Chris@69 9682 func_to_tool_file "$output"
Chris@69 9683 libobjs=$nm_file_list_spec$func_to_tool_file_result
Chris@69 9684 func_append delfiles " $output"
Chris@69 9685 func_verbose "creating $NM input file list: $output"
Chris@69 9686 for obj in $save_libobjs; do
Chris@69 9687 func_to_tool_file "$obj"
Chris@69 9688 $ECHO "$func_to_tool_file_result"
Chris@69 9689 done > "$output"
Chris@69 9690 eval cmd=\"$cmd1\"
Chris@69 9691 func_show_eval "$cmd" 'exit $?'
Chris@69 9692 output=$save_output
Chris@69 9693 libobjs=$save_libobjs
Chris@69 9694 skipped_export=false
Chris@69 9695 else
Chris@69 9696 # The command line is too long to execute in one step.
Chris@69 9697 func_verbose "using reloadable object file for export list..."
Chris@69 9698 skipped_export=:
Chris@69 9699 # Break out early, otherwise skipped_export may be
Chris@69 9700 # set to false by a later but shorter cmd.
Chris@69 9701 break
Chris@69 9702 fi
Chris@69 9703 done
Chris@69 9704 IFS=$save_ifs
Chris@69 9705 if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
Chris@69 9706 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
Chris@69 9707 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
Chris@69 9708 fi
Chris@69 9709 fi
Chris@69 9710 fi
Chris@69 9711
Chris@69 9712 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Chris@69 9713 tmp_export_symbols=$export_symbols
Chris@69 9714 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
Chris@69 9715 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
Chris@69 9716 fi
Chris@69 9717
Chris@69 9718 if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
Chris@69 9719 # The given exports_symbols file has to be filtered, so filter it.
Chris@69 9720 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
Chris@69 9721 # FIXME: $output_objdir/$libname.filter potentially contains lots of
Chris@69 9722 # 's' commands, which not all seds can handle. GNU sed should be fine
Chris@69 9723 # though. Also, the filter scales superlinearly with the number of
Chris@69 9724 # global variables. join(1) would be nice here, but unfortunately
Chris@69 9725 # isn't a blessed tool.
Chris@69 9726 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
Chris@69 9727 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
Chris@69 9728 export_symbols=$output_objdir/$libname.def
Chris@69 9729 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
Chris@69 9730 fi
Chris@69 9731
Chris@69 9732 tmp_deplibs=
Chris@69 9733 for test_deplib in $deplibs; do
Chris@69 9734 case " $convenience " in
Chris@69 9735 *" $test_deplib "*) ;;
Chris@69 9736 *)
Chris@69 9737 func_append tmp_deplibs " $test_deplib"
Chris@69 9738 ;;
Chris@69 9739 esac
Chris@69 9740 done
Chris@69 9741 deplibs=$tmp_deplibs
Chris@69 9742
Chris@69 9743 if test -n "$convenience"; then
Chris@69 9744 if test -n "$whole_archive_flag_spec" &&
Chris@69 9745 test yes = "$compiler_needs_object" &&
Chris@69 9746 test -z "$libobjs"; then
Chris@69 9747 # extract the archives, so we have objects to list.
Chris@69 9748 # TODO: could optimize this to just extract one archive.
Chris@69 9749 whole_archive_flag_spec=
Chris@69 9750 fi
Chris@69 9751 if test -n "$whole_archive_flag_spec"; then
Chris@69 9752 save_libobjs=$libobjs
Chris@69 9753 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
Chris@69 9754 test "X$libobjs" = "X " && libobjs=
Chris@69 9755 else
Chris@69 9756 gentop=$output_objdir/${outputname}x
Chris@69 9757 func_append generated " $gentop"
Chris@69 9758
Chris@69 9759 func_extract_archives $gentop $convenience
Chris@69 9760 func_append libobjs " $func_extract_archives_result"
Chris@69 9761 test "X$libobjs" = "X " && libobjs=
Chris@69 9762 fi
Chris@69 9763 fi
Chris@69 9764
Chris@69 9765 if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
Chris@69 9766 eval flag=\"$thread_safe_flag_spec\"
Chris@69 9767 func_append linker_flags " $flag"
Chris@69 9768 fi
Chris@69 9769
Chris@69 9770 # Make a backup of the uninstalled library when relinking
Chris@69 9771 if test relink = "$opt_mode"; then
Chris@69 9772 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
Chris@69 9773 fi
Chris@69 9774
Chris@69 9775 # Do each of the archive commands.
Chris@69 9776 if test yes = "$module" && test -n "$module_cmds"; then
Chris@69 9777 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
Chris@69 9778 eval test_cmds=\"$module_expsym_cmds\"
Chris@69 9779 cmds=$module_expsym_cmds
Chris@69 9780 else
Chris@69 9781 eval test_cmds=\"$module_cmds\"
Chris@69 9782 cmds=$module_cmds
Chris@69 9783 fi
Chris@69 9784 else
Chris@69 9785 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
Chris@69 9786 eval test_cmds=\"$archive_expsym_cmds\"
Chris@69 9787 cmds=$archive_expsym_cmds
Chris@69 9788 else
Chris@69 9789 eval test_cmds=\"$archive_cmds\"
Chris@69 9790 cmds=$archive_cmds
Chris@69 9791 fi
Chris@69 9792 fi
Chris@69 9793
Chris@69 9794 if test : != "$skipped_export" &&
Chris@69 9795 func_len " $test_cmds" &&
Chris@69 9796 len=$func_len_result &&
Chris@69 9797 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
Chris@69 9798 :
Chris@69 9799 else
Chris@69 9800 # The command line is too long to link in one step, link piecewise
Chris@69 9801 # or, if using GNU ld and skipped_export is not :, use a linker
Chris@69 9802 # script.
Chris@69 9803
Chris@69 9804 # Save the value of $output and $libobjs because we want to
Chris@69 9805 # use them later. If we have whole_archive_flag_spec, we
Chris@69 9806 # want to use save_libobjs as it was before
Chris@69 9807 # whole_archive_flag_spec was expanded, because we can't
Chris@69 9808 # assume the linker understands whole_archive_flag_spec.
Chris@69 9809 # This may have to be revisited, in case too many
Chris@69 9810 # convenience libraries get linked in and end up exceeding
Chris@69 9811 # the spec.
Chris@69 9812 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
Chris@69 9813 save_libobjs=$libobjs
Chris@69 9814 fi
Chris@69 9815 save_output=$output
Chris@69 9816 func_basename "$output"
Chris@69 9817 output_la=$func_basename_result
Chris@69 9818
Chris@69 9819 # Clear the reloadable object creation command queue and
Chris@69 9820 # initialize k to one.
Chris@69 9821 test_cmds=
Chris@69 9822 concat_cmds=
Chris@69 9823 objlist=
Chris@69 9824 last_robj=
Chris@69 9825 k=1
Chris@69 9826
Chris@69 9827 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
Chris@69 9828 output=$output_objdir/$output_la.lnkscript
Chris@69 9829 func_verbose "creating GNU ld script: $output"
Chris@69 9830 echo 'INPUT (' > $output
Chris@69 9831 for obj in $save_libobjs
Chris@69 9832 do
Chris@69 9833 func_to_tool_file "$obj"
Chris@69 9834 $ECHO "$func_to_tool_file_result" >> $output
Chris@69 9835 done
Chris@69 9836 echo ')' >> $output
Chris@69 9837 func_append delfiles " $output"
Chris@69 9838 func_to_tool_file "$output"
Chris@69 9839 output=$func_to_tool_file_result
Chris@69 9840 elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
Chris@69 9841 output=$output_objdir/$output_la.lnk
Chris@69 9842 func_verbose "creating linker input file list: $output"
Chris@69 9843 : > $output
Chris@69 9844 set x $save_libobjs
Chris@69 9845 shift
Chris@69 9846 firstobj=
Chris@69 9847 if test yes = "$compiler_needs_object"; then
Chris@69 9848 firstobj="$1 "
Chris@69 9849 shift
Chris@69 9850 fi
Chris@69 9851 for obj
Chris@69 9852 do
Chris@69 9853 func_to_tool_file "$obj"
Chris@69 9854 $ECHO "$func_to_tool_file_result" >> $output
Chris@69 9855 done
Chris@69 9856 func_append delfiles " $output"
Chris@69 9857 func_to_tool_file "$output"
Chris@69 9858 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
Chris@69 9859 else
Chris@69 9860 if test -n "$save_libobjs"; then
Chris@69 9861 func_verbose "creating reloadable object files..."
Chris@69 9862 output=$output_objdir/$output_la-$k.$objext
Chris@69 9863 eval test_cmds=\"$reload_cmds\"
Chris@69 9864 func_len " $test_cmds"
Chris@69 9865 len0=$func_len_result
Chris@69 9866 len=$len0
Chris@69 9867
Chris@69 9868 # Loop over the list of objects to be linked.
Chris@69 9869 for obj in $save_libobjs
Chris@69 9870 do
Chris@69 9871 func_len " $obj"
Chris@69 9872 func_arith $len + $func_len_result
Chris@69 9873 len=$func_arith_result
Chris@69 9874 if test -z "$objlist" ||
Chris@69 9875 test "$len" -lt "$max_cmd_len"; then
Chris@69 9876 func_append objlist " $obj"
Chris@69 9877 else
Chris@69 9878 # The command $test_cmds is almost too long, add a
Chris@69 9879 # command to the queue.
Chris@69 9880 if test 1 -eq "$k"; then
Chris@69 9881 # The first file doesn't have a previous command to add.
Chris@69 9882 reload_objs=$objlist
Chris@69 9883 eval concat_cmds=\"$reload_cmds\"
Chris@69 9884 else
Chris@69 9885 # All subsequent reloadable object files will link in
Chris@69 9886 # the last one created.
Chris@69 9887 reload_objs="$objlist $last_robj"
Chris@69 9888 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
Chris@69 9889 fi
Chris@69 9890 last_robj=$output_objdir/$output_la-$k.$objext
Chris@69 9891 func_arith $k + 1
Chris@69 9892 k=$func_arith_result
Chris@69 9893 output=$output_objdir/$output_la-$k.$objext
Chris@69 9894 objlist=" $obj"
Chris@69 9895 func_len " $last_robj"
Chris@69 9896 func_arith $len0 + $func_len_result
Chris@69 9897 len=$func_arith_result
Chris@69 9898 fi
Chris@69 9899 done
Chris@69 9900 # Handle the remaining objects by creating one last
Chris@69 9901 # reloadable object file. All subsequent reloadable object
Chris@69 9902 # files will link in the last one created.
Chris@69 9903 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Chris@69 9904 reload_objs="$objlist $last_robj"
Chris@69 9905 eval concat_cmds=\"\$concat_cmds$reload_cmds\"
Chris@69 9906 if test -n "$last_robj"; then
Chris@69 9907 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
Chris@69 9908 fi
Chris@69 9909 func_append delfiles " $output"
Chris@69 9910
Chris@69 9911 else
Chris@69 9912 output=
Chris@69 9913 fi
Chris@69 9914
Chris@69 9915 ${skipped_export-false} && {
Chris@69 9916 func_verbose "generating symbol list for '$libname.la'"
Chris@69 9917 export_symbols=$output_objdir/$libname.exp
Chris@69 9918 $opt_dry_run || $RM $export_symbols
Chris@69 9919 libobjs=$output
Chris@69 9920 # Append the command to create the export file.
Chris@69 9921 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Chris@69 9922 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
Chris@69 9923 if test -n "$last_robj"; then
Chris@69 9924 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
Chris@69 9925 fi
Chris@69 9926 }
Chris@69 9927
Chris@69 9928 test -n "$save_libobjs" &&
Chris@69 9929 func_verbose "creating a temporary reloadable object file: $output"
Chris@69 9930
Chris@69 9931 # Loop through the commands generated above and execute them.
Chris@69 9932 save_ifs=$IFS; IFS='~'
Chris@69 9933 for cmd in $concat_cmds; do
Chris@69 9934 IFS=$save_ifs
Chris@69 9935 $opt_quiet || {
Chris@69 9936 func_quote_for_expand "$cmd"
Chris@69 9937 eval "func_echo $func_quote_for_expand_result"
Chris@69 9938 }
Chris@69 9939 $opt_dry_run || eval "$cmd" || {
Chris@69 9940 lt_exit=$?
Chris@69 9941
Chris@69 9942 # Restore the uninstalled library and exit
Chris@69 9943 if test relink = "$opt_mode"; then
Chris@69 9944 ( cd "$output_objdir" && \
Chris@69 9945 $RM "${realname}T" && \
Chris@69 9946 $MV "${realname}U" "$realname" )
Chris@69 9947 fi
Chris@69 9948
Chris@69 9949 exit $lt_exit
Chris@69 9950 }
Chris@69 9951 done
Chris@69 9952 IFS=$save_ifs
Chris@69 9953
Chris@69 9954 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
Chris@69 9955 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
Chris@69 9956 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
Chris@69 9957 fi
Chris@69 9958 fi
Chris@69 9959
Chris@69 9960 ${skipped_export-false} && {
Chris@69 9961 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Chris@69 9962 tmp_export_symbols=$export_symbols
Chris@69 9963 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
Chris@69 9964 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
Chris@69 9965 fi
Chris@69 9966
Chris@69 9967 if test -n "$orig_export_symbols"; then
Chris@69 9968 # The given exports_symbols file has to be filtered, so filter it.
Chris@69 9969 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
Chris@69 9970 # FIXME: $output_objdir/$libname.filter potentially contains lots of
Chris@69 9971 # 's' commands, which not all seds can handle. GNU sed should be fine
Chris@69 9972 # though. Also, the filter scales superlinearly with the number of
Chris@69 9973 # global variables. join(1) would be nice here, but unfortunately
Chris@69 9974 # isn't a blessed tool.
Chris@69 9975 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
Chris@69 9976 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
Chris@69 9977 export_symbols=$output_objdir/$libname.def
Chris@69 9978 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
Chris@69 9979 fi
Chris@69 9980 }
Chris@69 9981
Chris@69 9982 libobjs=$output
Chris@69 9983 # Restore the value of output.
Chris@69 9984 output=$save_output
Chris@69 9985
Chris@69 9986 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
Chris@69 9987 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
Chris@69 9988 test "X$libobjs" = "X " && libobjs=
Chris@69 9989 fi
Chris@69 9990 # Expand the library linking commands again to reset the
Chris@69 9991 # value of $libobjs for piecewise linking.
Chris@69 9992
Chris@69 9993 # Do each of the archive commands.
Chris@69 9994 if test yes = "$module" && test -n "$module_cmds"; then
Chris@69 9995 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
Chris@69 9996 cmds=$module_expsym_cmds
Chris@69 9997 else
Chris@69 9998 cmds=$module_cmds
Chris@69 9999 fi
Chris@69 10000 else
Chris@69 10001 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
Chris@69 10002 cmds=$archive_expsym_cmds
Chris@69 10003 else
Chris@69 10004 cmds=$archive_cmds
Chris@69 10005 fi
Chris@69 10006 fi
Chris@69 10007 fi
Chris@69 10008
Chris@69 10009 if test -n "$delfiles"; then
Chris@69 10010 # Append the command to remove temporary files to $cmds.
Chris@69 10011 eval cmds=\"\$cmds~\$RM $delfiles\"
Chris@69 10012 fi
Chris@69 10013
Chris@69 10014 # Add any objects from preloaded convenience libraries
Chris@69 10015 if test -n "$dlprefiles"; then
Chris@69 10016 gentop=$output_objdir/${outputname}x
Chris@69 10017 func_append generated " $gentop"
Chris@69 10018
Chris@69 10019 func_extract_archives $gentop $dlprefiles
Chris@69 10020 func_append libobjs " $func_extract_archives_result"
Chris@69 10021 test "X$libobjs" = "X " && libobjs=
Chris@69 10022 fi
Chris@69 10023
Chris@69 10024 save_ifs=$IFS; IFS='~'
Chris@69 10025 for cmd in $cmds; do
Chris@69 10026 IFS=$sp$nl
Chris@69 10027 eval cmd=\"$cmd\"
Chris@69 10028 IFS=$save_ifs
Chris@69 10029 $opt_quiet || {
Chris@69 10030 func_quote_for_expand "$cmd"
Chris@69 10031 eval "func_echo $func_quote_for_expand_result"
Chris@69 10032 }
Chris@69 10033 $opt_dry_run || eval "$cmd" || {
Chris@69 10034 lt_exit=$?
Chris@69 10035
Chris@69 10036 # Restore the uninstalled library and exit
Chris@69 10037 if test relink = "$opt_mode"; then
Chris@69 10038 ( cd "$output_objdir" && \
Chris@69 10039 $RM "${realname}T" && \
Chris@69 10040 $MV "${realname}U" "$realname" )
Chris@69 10041 fi
Chris@69 10042
Chris@69 10043 exit $lt_exit
Chris@69 10044 }
Chris@69 10045 done
Chris@69 10046 IFS=$save_ifs
Chris@69 10047
Chris@69 10048 # Restore the uninstalled library and exit
Chris@69 10049 if test relink = "$opt_mode"; then
Chris@69 10050 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
Chris@69 10051
Chris@69 10052 if test -n "$convenience"; then
Chris@69 10053 if test -z "$whole_archive_flag_spec"; then
Chris@69 10054 func_show_eval '${RM}r "$gentop"'
Chris@69 10055 fi
Chris@69 10056 fi
Chris@69 10057
Chris@69 10058 exit $EXIT_SUCCESS
Chris@69 10059 fi
Chris@69 10060
Chris@69 10061 # Create links to the real library.
Chris@69 10062 for linkname in $linknames; do
Chris@69 10063 if test "$realname" != "$linkname"; then
Chris@69 10064 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
Chris@69 10065 fi
Chris@69 10066 done
Chris@69 10067
Chris@69 10068 # If -module or -export-dynamic was specified, set the dlname.
Chris@69 10069 if test yes = "$module" || test yes = "$export_dynamic"; then
Chris@69 10070 # On all known operating systems, these are identical.
Chris@69 10071 dlname=$soname
Chris@69 10072 fi
Chris@69 10073 fi
Chris@69 10074 ;;
Chris@69 10075
Chris@69 10076 obj)
Chris@69 10077 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
Chris@69 10078 func_warning "'-dlopen' is ignored for objects"
Chris@69 10079 fi
Chris@69 10080
Chris@69 10081 case " $deplibs" in
Chris@69 10082 *\ -l* | *\ -L*)
Chris@69 10083 func_warning "'-l' and '-L' are ignored for objects" ;;
Chris@69 10084 esac
Chris@69 10085
Chris@69 10086 test -n "$rpath" && \
Chris@69 10087 func_warning "'-rpath' is ignored for objects"
Chris@69 10088
Chris@69 10089 test -n "$xrpath" && \
Chris@69 10090 func_warning "'-R' is ignored for objects"
Chris@69 10091
Chris@69 10092 test -n "$vinfo" && \
Chris@69 10093 func_warning "'-version-info' is ignored for objects"
Chris@69 10094
Chris@69 10095 test -n "$release" && \
Chris@69 10096 func_warning "'-release' is ignored for objects"
Chris@69 10097
Chris@69 10098 case $output in
Chris@69 10099 *.lo)
Chris@69 10100 test -n "$objs$old_deplibs" && \
Chris@69 10101 func_fatal_error "cannot build library object '$output' from non-libtool objects"
Chris@69 10102
Chris@69 10103 libobj=$output
Chris@69 10104 func_lo2o "$libobj"
Chris@69 10105 obj=$func_lo2o_result
Chris@69 10106 ;;
Chris@69 10107 *)
Chris@69 10108 libobj=
Chris@69 10109 obj=$output
Chris@69 10110 ;;
Chris@69 10111 esac
Chris@69 10112
Chris@69 10113 # Delete the old objects.
Chris@69 10114 $opt_dry_run || $RM $obj $libobj
Chris@69 10115
Chris@69 10116 # Objects from convenience libraries. This assumes
Chris@69 10117 # single-version convenience libraries. Whenever we create
Chris@69 10118 # different ones for PIC/non-PIC, this we'll have to duplicate
Chris@69 10119 # the extraction.
Chris@69 10120 reload_conv_objs=
Chris@69 10121 gentop=
Chris@69 10122 # if reload_cmds runs $LD directly, get rid of -Wl from
Chris@69 10123 # whole_archive_flag_spec and hope we can get by with turning comma
Chris@69 10124 # into space.
Chris@69 10125 case $reload_cmds in
Chris@69 10126 *\$LD[\ \$]*) wl= ;;
Chris@69 10127 esac
Chris@69 10128 if test -n "$convenience"; then
Chris@69 10129 if test -n "$whole_archive_flag_spec"; then
Chris@69 10130 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
Chris@69 10131 test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
Chris@69 10132 reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
Chris@69 10133 else
Chris@69 10134 gentop=$output_objdir/${obj}x
Chris@69 10135 func_append generated " $gentop"
Chris@69 10136
Chris@69 10137 func_extract_archives $gentop $convenience
Chris@69 10138 reload_conv_objs="$reload_objs $func_extract_archives_result"
Chris@69 10139 fi
Chris@69 10140 fi
Chris@69 10141
Chris@69 10142 # If we're not building shared, we need to use non_pic_objs
Chris@69 10143 test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
Chris@69 10144
Chris@69 10145 # Create the old-style object.
Chris@69 10146 reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
Chris@69 10147
Chris@69 10148 output=$obj
Chris@69 10149 func_execute_cmds "$reload_cmds" 'exit $?'
Chris@69 10150
Chris@69 10151 # Exit if we aren't doing a library object file.
Chris@69 10152 if test -z "$libobj"; then
Chris@69 10153 if test -n "$gentop"; then
Chris@69 10154 func_show_eval '${RM}r "$gentop"'
Chris@69 10155 fi
Chris@69 10156
Chris@69 10157 exit $EXIT_SUCCESS
Chris@69 10158 fi
Chris@69 10159
Chris@69 10160 test yes = "$build_libtool_libs" || {
Chris@69 10161 if test -n "$gentop"; then
Chris@69 10162 func_show_eval '${RM}r "$gentop"'
Chris@69 10163 fi
Chris@69 10164
Chris@69 10165 # Create an invalid libtool object if no PIC, so that we don't
Chris@69 10166 # accidentally link it into a program.
Chris@69 10167 # $show "echo timestamp > $libobj"
Chris@69 10168 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
Chris@69 10169 exit $EXIT_SUCCESS
Chris@69 10170 }
Chris@69 10171
Chris@69 10172 if test -n "$pic_flag" || test default != "$pic_mode"; then
Chris@69 10173 # Only do commands if we really have different PIC objects.
Chris@69 10174 reload_objs="$libobjs $reload_conv_objs"
Chris@69 10175 output=$libobj
Chris@69 10176 func_execute_cmds "$reload_cmds" 'exit $?'
Chris@69 10177 fi
Chris@69 10178
Chris@69 10179 if test -n "$gentop"; then
Chris@69 10180 func_show_eval '${RM}r "$gentop"'
Chris@69 10181 fi
Chris@69 10182
Chris@69 10183 exit $EXIT_SUCCESS
Chris@69 10184 ;;
Chris@69 10185
Chris@69 10186 prog)
Chris@69 10187 case $host in
Chris@69 10188 *cygwin*) func_stripname '' '.exe' "$output"
Chris@69 10189 output=$func_stripname_result.exe;;
Chris@69 10190 esac
Chris@69 10191 test -n "$vinfo" && \
Chris@69 10192 func_warning "'-version-info' is ignored for programs"
Chris@69 10193
Chris@69 10194 test -n "$release" && \
Chris@69 10195 func_warning "'-release' is ignored for programs"
Chris@69 10196
Chris@69 10197 $preload \
Chris@69 10198 && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
Chris@69 10199 && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
Chris@69 10200
Chris@69 10201 case $host in
Chris@69 10202 *-*-rhapsody* | *-*-darwin1.[012])
Chris@69 10203 # On Rhapsody replace the C library is the System framework
Chris@69 10204 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
Chris@69 10205 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
Chris@69 10206 ;;
Chris@69 10207 esac
Chris@69 10208
Chris@69 10209 case $host in
Chris@69 10210 *-*-darwin*)
Chris@69 10211 # Don't allow lazy linking, it breaks C++ global constructors
Chris@69 10212 # But is supposedly fixed on 10.4 or later (yay!).
Chris@69 10213 if test CXX = "$tagname"; then
Chris@69 10214 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
Chris@69 10215 10.[0123])
Chris@69 10216 func_append compile_command " $wl-bind_at_load"
Chris@69 10217 func_append finalize_command " $wl-bind_at_load"
Chris@69 10218 ;;
Chris@69 10219 esac
Chris@69 10220 fi
Chris@69 10221 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
Chris@69 10222 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@69 10223 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@69 10224 ;;
Chris@69 10225 esac
Chris@69 10226
Chris@69 10227
Chris@69 10228 # move library search paths that coincide with paths to not yet
Chris@69 10229 # installed libraries to the beginning of the library search list
Chris@69 10230 new_libs=
Chris@69 10231 for path in $notinst_path; do
Chris@69 10232 case " $new_libs " in
Chris@69 10233 *" -L$path/$objdir "*) ;;
Chris@69 10234 *)
Chris@69 10235 case " $compile_deplibs " in
Chris@69 10236 *" -L$path/$objdir "*)
Chris@69 10237 func_append new_libs " -L$path/$objdir" ;;
Chris@69 10238 esac
Chris@69 10239 ;;
Chris@69 10240 esac
Chris@69 10241 done
Chris@69 10242 for deplib in $compile_deplibs; do
Chris@69 10243 case $deplib in
Chris@69 10244 -L*)
Chris@69 10245 case " $new_libs " in
Chris@69 10246 *" $deplib "*) ;;
Chris@69 10247 *) func_append new_libs " $deplib" ;;
Chris@69 10248 esac
Chris@69 10249 ;;
Chris@69 10250 *) func_append new_libs " $deplib" ;;
Chris@69 10251 esac
Chris@69 10252 done
Chris@69 10253 compile_deplibs=$new_libs
Chris@69 10254
Chris@69 10255
Chris@69 10256 func_append compile_command " $compile_deplibs"
Chris@69 10257 func_append finalize_command " $finalize_deplibs"
Chris@69 10258
Chris@69 10259 if test -n "$rpath$xrpath"; then
Chris@69 10260 # If the user specified any rpath flags, then add them.
Chris@69 10261 for libdir in $rpath $xrpath; do
Chris@69 10262 # This is the magic to use -rpath.
Chris@69 10263 case "$finalize_rpath " in
Chris@69 10264 *" $libdir "*) ;;
Chris@69 10265 *) func_append finalize_rpath " $libdir" ;;
Chris@69 10266 esac
Chris@69 10267 done
Chris@69 10268 fi
Chris@69 10269
Chris@69 10270 # Now hardcode the library paths
Chris@69 10271 rpath=
Chris@69 10272 hardcode_libdirs=
Chris@69 10273 for libdir in $compile_rpath $finalize_rpath; do
Chris@69 10274 if test -n "$hardcode_libdir_flag_spec"; then
Chris@69 10275 if test -n "$hardcode_libdir_separator"; then
Chris@69 10276 if test -z "$hardcode_libdirs"; then
Chris@69 10277 hardcode_libdirs=$libdir
Chris@69 10278 else
Chris@69 10279 # Just accumulate the unique libdirs.
Chris@69 10280 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Chris@69 10281 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
Chris@69 10282 ;;
Chris@69 10283 *)
Chris@69 10284 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
Chris@69 10285 ;;
Chris@69 10286 esac
Chris@69 10287 fi
Chris@69 10288 else
Chris@69 10289 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@69 10290 func_append rpath " $flag"
Chris@69 10291 fi
Chris@69 10292 elif test -n "$runpath_var"; then
Chris@69 10293 case "$perm_rpath " in
Chris@69 10294 *" $libdir "*) ;;
Chris@69 10295 *) func_append perm_rpath " $libdir" ;;
Chris@69 10296 esac
Chris@69 10297 fi
Chris@69 10298 case $host in
Chris@69 10299 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
Chris@69 10300 testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
Chris@69 10301 case :$dllsearchpath: in
Chris@69 10302 *":$libdir:"*) ;;
Chris@69 10303 ::) dllsearchpath=$libdir;;
Chris@69 10304 *) func_append dllsearchpath ":$libdir";;
Chris@69 10305 esac
Chris@69 10306 case :$dllsearchpath: in
Chris@69 10307 *":$testbindir:"*) ;;
Chris@69 10308 ::) dllsearchpath=$testbindir;;
Chris@69 10309 *) func_append dllsearchpath ":$testbindir";;
Chris@69 10310 esac
Chris@69 10311 ;;
Chris@69 10312 esac
Chris@69 10313 done
Chris@69 10314 # Substitute the hardcoded libdirs into the rpath.
Chris@69 10315 if test -n "$hardcode_libdir_separator" &&
Chris@69 10316 test -n "$hardcode_libdirs"; then
Chris@69 10317 libdir=$hardcode_libdirs
Chris@69 10318 eval rpath=\" $hardcode_libdir_flag_spec\"
Chris@69 10319 fi
Chris@69 10320 compile_rpath=$rpath
Chris@69 10321
Chris@69 10322 rpath=
Chris@69 10323 hardcode_libdirs=
Chris@69 10324 for libdir in $finalize_rpath; do
Chris@69 10325 if test -n "$hardcode_libdir_flag_spec"; then
Chris@69 10326 if test -n "$hardcode_libdir_separator"; then
Chris@69 10327 if test -z "$hardcode_libdirs"; then
Chris@69 10328 hardcode_libdirs=$libdir
Chris@69 10329 else
Chris@69 10330 # Just accumulate the unique libdirs.
Chris@69 10331 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Chris@69 10332 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
Chris@69 10333 ;;
Chris@69 10334 *)
Chris@69 10335 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
Chris@69 10336 ;;
Chris@69 10337 esac
Chris@69 10338 fi
Chris@69 10339 else
Chris@69 10340 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@69 10341 func_append rpath " $flag"
Chris@69 10342 fi
Chris@69 10343 elif test -n "$runpath_var"; then
Chris@69 10344 case "$finalize_perm_rpath " in
Chris@69 10345 *" $libdir "*) ;;
Chris@69 10346 *) func_append finalize_perm_rpath " $libdir" ;;
Chris@69 10347 esac
Chris@69 10348 fi
Chris@69 10349 done
Chris@69 10350 # Substitute the hardcoded libdirs into the rpath.
Chris@69 10351 if test -n "$hardcode_libdir_separator" &&
Chris@69 10352 test -n "$hardcode_libdirs"; then
Chris@69 10353 libdir=$hardcode_libdirs
Chris@69 10354 eval rpath=\" $hardcode_libdir_flag_spec\"
Chris@69 10355 fi
Chris@69 10356 finalize_rpath=$rpath
Chris@69 10357
Chris@69 10358 if test -n "$libobjs" && test yes = "$build_old_libs"; then
Chris@69 10359 # Transform all the library objects into standard objects.
Chris@69 10360 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@69 10361 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@69 10362 fi
Chris@69 10363
Chris@69 10364 func_generate_dlsyms "$outputname" "@PROGRAM@" false
Chris@69 10365
Chris@69 10366 # template prelinking step
Chris@69 10367 if test -n "$prelink_cmds"; then
Chris@69 10368 func_execute_cmds "$prelink_cmds" 'exit $?'
Chris@69 10369 fi
Chris@69 10370
Chris@69 10371 wrappers_required=:
Chris@69 10372 case $host in
Chris@69 10373 *cegcc* | *mingw32ce*)
Chris@69 10374 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
Chris@69 10375 wrappers_required=false
Chris@69 10376 ;;
Chris@69 10377 *cygwin* | *mingw* )
Chris@69 10378 test yes = "$build_libtool_libs" || wrappers_required=false
Chris@69 10379 ;;
Chris@69 10380 *)
Chris@69 10381 if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
Chris@69 10382 wrappers_required=false
Chris@69 10383 fi
Chris@69 10384 ;;
Chris@69 10385 esac
Chris@69 10386 $wrappers_required || {
Chris@69 10387 # Replace the output file specification.
Chris@69 10388 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
Chris@69 10389 link_command=$compile_command$compile_rpath
Chris@69 10390
Chris@69 10391 # We have no uninstalled library dependencies, so finalize right now.
Chris@69 10392 exit_status=0
Chris@69 10393 func_show_eval "$link_command" 'exit_status=$?'
Chris@69 10394
Chris@69 10395 if test -n "$postlink_cmds"; then
Chris@69 10396 func_to_tool_file "$output"
Chris@69 10397 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
Chris@69 10398 func_execute_cmds "$postlink_cmds" 'exit $?'
Chris@69 10399 fi
Chris@69 10400
Chris@69 10401 # Delete the generated files.
Chris@69 10402 if test -f "$output_objdir/${outputname}S.$objext"; then
Chris@69 10403 func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
Chris@69 10404 fi
Chris@69 10405
Chris@69 10406 exit $exit_status
Chris@69 10407 }
Chris@69 10408
Chris@69 10409 if test -n "$compile_shlibpath$finalize_shlibpath"; then
Chris@69 10410 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
Chris@69 10411 fi
Chris@69 10412 if test -n "$finalize_shlibpath"; then
Chris@69 10413 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
Chris@69 10414 fi
Chris@69 10415
Chris@69 10416 compile_var=
Chris@69 10417 finalize_var=
Chris@69 10418 if test -n "$runpath_var"; then
Chris@69 10419 if test -n "$perm_rpath"; then
Chris@69 10420 # We should set the runpath_var.
Chris@69 10421 rpath=
Chris@69 10422 for dir in $perm_rpath; do
Chris@69 10423 func_append rpath "$dir:"
Chris@69 10424 done
Chris@69 10425 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
Chris@69 10426 fi
Chris@69 10427 if test -n "$finalize_perm_rpath"; then
Chris@69 10428 # We should set the runpath_var.
Chris@69 10429 rpath=
Chris@69 10430 for dir in $finalize_perm_rpath; do
Chris@69 10431 func_append rpath "$dir:"
Chris@69 10432 done
Chris@69 10433 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
Chris@69 10434 fi
Chris@69 10435 fi
Chris@69 10436
Chris@69 10437 if test yes = "$no_install"; then
Chris@69 10438 # We don't need to create a wrapper script.
Chris@69 10439 link_command=$compile_var$compile_command$compile_rpath
Chris@69 10440 # Replace the output file specification.
Chris@69 10441 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
Chris@69 10442 # Delete the old output file.
Chris@69 10443 $opt_dry_run || $RM $output
Chris@69 10444 # Link the executable and exit
Chris@69 10445 func_show_eval "$link_command" 'exit $?'
Chris@69 10446
Chris@69 10447 if test -n "$postlink_cmds"; then
Chris@69 10448 func_to_tool_file "$output"
Chris@69 10449 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
Chris@69 10450 func_execute_cmds "$postlink_cmds" 'exit $?'
Chris@69 10451 fi
Chris@69 10452
Chris@69 10453 exit $EXIT_SUCCESS
Chris@69 10454 fi
Chris@69 10455
Chris@69 10456 case $hardcode_action,$fast_install in
Chris@69 10457 relink,*)
Chris@69 10458 # Fast installation is not supported
Chris@69 10459 link_command=$compile_var$compile_command$compile_rpath
Chris@69 10460 relink_command=$finalize_var$finalize_command$finalize_rpath
Chris@69 10461
Chris@69 10462 func_warning "this platform does not like uninstalled shared libraries"
Chris@69 10463 func_warning "'$output' will be relinked during installation"
Chris@69 10464 ;;
Chris@69 10465 *,yes)
Chris@69 10466 link_command=$finalize_var$compile_command$finalize_rpath
Chris@69 10467 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
Chris@69 10468 ;;
Chris@69 10469 *,no)
Chris@69 10470 link_command=$compile_var$compile_command$compile_rpath
Chris@69 10471 relink_command=$finalize_var$finalize_command$finalize_rpath
Chris@69 10472 ;;
Chris@69 10473 *,needless)
Chris@69 10474 link_command=$finalize_var$compile_command$finalize_rpath
Chris@69 10475 relink_command=
Chris@69 10476 ;;
Chris@69 10477 esac
Chris@69 10478
Chris@69 10479 # Replace the output file specification.
Chris@69 10480 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
Chris@69 10481
Chris@69 10482 # Delete the old output files.
Chris@69 10483 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
Chris@69 10484
Chris@69 10485 func_show_eval "$link_command" 'exit $?'
Chris@69 10486
Chris@69 10487 if test -n "$postlink_cmds"; then
Chris@69 10488 func_to_tool_file "$output_objdir/$outputname"
Chris@69 10489 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
Chris@69 10490 func_execute_cmds "$postlink_cmds" 'exit $?'
Chris@69 10491 fi
Chris@69 10492
Chris@69 10493 # Now create the wrapper script.
Chris@69 10494 func_verbose "creating $output"
Chris@69 10495
Chris@69 10496 # Quote the relink command for shipping.
Chris@69 10497 if test -n "$relink_command"; then
Chris@69 10498 # Preserve any variables that may affect compiler behavior
Chris@69 10499 for var in $variables_saved_for_relink; do
Chris@69 10500 if eval test -z \"\${$var+set}\"; then
Chris@69 10501 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
Chris@69 10502 elif eval var_value=\$$var; test -z "$var_value"; then
Chris@69 10503 relink_command="$var=; export $var; $relink_command"
Chris@69 10504 else
Chris@69 10505 func_quote_for_eval "$var_value"
Chris@69 10506 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
Chris@69 10507 fi
Chris@69 10508 done
Chris@69 10509 relink_command="(cd `pwd`; $relink_command)"
Chris@69 10510 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
Chris@69 10511 fi
Chris@69 10512
Chris@69 10513 # Only actually do things if not in dry run mode.
Chris@69 10514 $opt_dry_run || {
Chris@69 10515 # win32 will think the script is a binary if it has
Chris@69 10516 # a .exe suffix, so we strip it off here.
Chris@69 10517 case $output in
Chris@69 10518 *.exe) func_stripname '' '.exe' "$output"
Chris@69 10519 output=$func_stripname_result ;;
Chris@69 10520 esac
Chris@69 10521 # test for cygwin because mv fails w/o .exe extensions
Chris@69 10522 case $host in
Chris@69 10523 *cygwin*)
Chris@69 10524 exeext=.exe
Chris@69 10525 func_stripname '' '.exe' "$outputname"
Chris@69 10526 outputname=$func_stripname_result ;;
Chris@69 10527 *) exeext= ;;
Chris@69 10528 esac
Chris@69 10529 case $host in
Chris@69 10530 *cygwin* | *mingw* )
Chris@69 10531 func_dirname_and_basename "$output" "" "."
Chris@69 10532 output_name=$func_basename_result
Chris@69 10533 output_path=$func_dirname_result
Chris@69 10534 cwrappersource=$output_path/$objdir/lt-$output_name.c
Chris@69 10535 cwrapper=$output_path/$output_name.exe
Chris@69 10536 $RM $cwrappersource $cwrapper
Chris@69 10537 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
Chris@69 10538
Chris@69 10539 func_emit_cwrapperexe_src > $cwrappersource
Chris@69 10540
Chris@69 10541 # The wrapper executable is built using the $host compiler,
Chris@69 10542 # because it contains $host paths and files. If cross-
Chris@69 10543 # compiling, it, like the target executable, must be
Chris@69 10544 # executed on the $host or under an emulation environment.
Chris@69 10545 $opt_dry_run || {
Chris@69 10546 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
Chris@69 10547 $STRIP $cwrapper
Chris@69 10548 }
Chris@69 10549
Chris@69 10550 # Now, create the wrapper script for func_source use:
Chris@69 10551 func_ltwrapper_scriptname $cwrapper
Chris@69 10552 $RM $func_ltwrapper_scriptname_result
Chris@69 10553 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
Chris@69 10554 $opt_dry_run || {
Chris@69 10555 # note: this script will not be executed, so do not chmod.
Chris@69 10556 if test "x$build" = "x$host"; then
Chris@69 10557 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
Chris@69 10558 else
Chris@69 10559 func_emit_wrapper no > $func_ltwrapper_scriptname_result
Chris@69 10560 fi
Chris@69 10561 }
Chris@69 10562 ;;
Chris@69 10563 * )
Chris@69 10564 $RM $output
Chris@69 10565 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
Chris@69 10566
Chris@69 10567 func_emit_wrapper no > $output
Chris@69 10568 chmod +x $output
Chris@69 10569 ;;
Chris@69 10570 esac
Chris@69 10571 }
Chris@69 10572 exit $EXIT_SUCCESS
Chris@69 10573 ;;
Chris@69 10574 esac
Chris@69 10575
Chris@69 10576 # See if we need to build an old-fashioned archive.
Chris@69 10577 for oldlib in $oldlibs; do
Chris@69 10578
Chris@69 10579 case $build_libtool_libs in
Chris@69 10580 convenience)
Chris@69 10581 oldobjs="$libobjs_save $symfileobj"
Chris@69 10582 addlibs=$convenience
Chris@69 10583 build_libtool_libs=no
Chris@69 10584 ;;
Chris@69 10585 module)
Chris@69 10586 oldobjs=$libobjs_save
Chris@69 10587 addlibs=$old_convenience
Chris@69 10588 build_libtool_libs=no
Chris@69 10589 ;;
Chris@69 10590 *)
Chris@69 10591 oldobjs="$old_deplibs $non_pic_objects"
Chris@69 10592 $preload && test -f "$symfileobj" \
Chris@69 10593 && func_append oldobjs " $symfileobj"
Chris@69 10594 addlibs=$old_convenience
Chris@69 10595 ;;
Chris@69 10596 esac
Chris@69 10597
Chris@69 10598 if test -n "$addlibs"; then
Chris@69 10599 gentop=$output_objdir/${outputname}x
Chris@69 10600 func_append generated " $gentop"
Chris@69 10601
Chris@69 10602 func_extract_archives $gentop $addlibs
Chris@69 10603 func_append oldobjs " $func_extract_archives_result"
Chris@69 10604 fi
Chris@69 10605
Chris@69 10606 # Do each command in the archive commands.
Chris@69 10607 if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
Chris@69 10608 cmds=$old_archive_from_new_cmds
Chris@69 10609 else
Chris@69 10610
Chris@69 10611 # Add any objects from preloaded convenience libraries
Chris@69 10612 if test -n "$dlprefiles"; then
Chris@69 10613 gentop=$output_objdir/${outputname}x
Chris@69 10614 func_append generated " $gentop"
Chris@69 10615
Chris@69 10616 func_extract_archives $gentop $dlprefiles
Chris@69 10617 func_append oldobjs " $func_extract_archives_result"
Chris@69 10618 fi
Chris@69 10619
Chris@69 10620 # POSIX demands no paths to be encoded in archives. We have
Chris@69 10621 # to avoid creating archives with duplicate basenames if we
Chris@69 10622 # might have to extract them afterwards, e.g., when creating a
Chris@69 10623 # static archive out of a convenience library, or when linking
Chris@69 10624 # the entirety of a libtool archive into another (currently
Chris@69 10625 # not supported by libtool).
Chris@69 10626 if (for obj in $oldobjs
Chris@69 10627 do
Chris@69 10628 func_basename "$obj"
Chris@69 10629 $ECHO "$func_basename_result"
Chris@69 10630 done | sort | sort -uc >/dev/null 2>&1); then
Chris@69 10631 :
Chris@69 10632 else
Chris@69 10633 echo "copying selected object files to avoid basename conflicts..."
Chris@69 10634 gentop=$output_objdir/${outputname}x
Chris@69 10635 func_append generated " $gentop"
Chris@69 10636 func_mkdir_p "$gentop"
Chris@69 10637 save_oldobjs=$oldobjs
Chris@69 10638 oldobjs=
Chris@69 10639 counter=1
Chris@69 10640 for obj in $save_oldobjs
Chris@69 10641 do
Chris@69 10642 func_basename "$obj"
Chris@69 10643 objbase=$func_basename_result
Chris@69 10644 case " $oldobjs " in
Chris@69 10645 " ") oldobjs=$obj ;;
Chris@69 10646 *[\ /]"$objbase "*)
Chris@69 10647 while :; do
Chris@69 10648 # Make sure we don't pick an alternate name that also
Chris@69 10649 # overlaps.
Chris@69 10650 newobj=lt$counter-$objbase
Chris@69 10651 func_arith $counter + 1
Chris@69 10652 counter=$func_arith_result
Chris@69 10653 case " $oldobjs " in
Chris@69 10654 *[\ /]"$newobj "*) ;;
Chris@69 10655 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
Chris@69 10656 esac
Chris@69 10657 done
Chris@69 10658 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
Chris@69 10659 func_append oldobjs " $gentop/$newobj"
Chris@69 10660 ;;
Chris@69 10661 *) func_append oldobjs " $obj" ;;
Chris@69 10662 esac
Chris@69 10663 done
Chris@69 10664 fi
Chris@69 10665 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
Chris@69 10666 tool_oldlib=$func_to_tool_file_result
Chris@69 10667 eval cmds=\"$old_archive_cmds\"
Chris@69 10668
Chris@69 10669 func_len " $cmds"
Chris@69 10670 len=$func_len_result
Chris@69 10671 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
Chris@69 10672 cmds=$old_archive_cmds
Chris@69 10673 elif test -n "$archiver_list_spec"; then
Chris@69 10674 func_verbose "using command file archive linking..."
Chris@69 10675 for obj in $oldobjs
Chris@69 10676 do
Chris@69 10677 func_to_tool_file "$obj"
Chris@69 10678 $ECHO "$func_to_tool_file_result"
Chris@69 10679 done > $output_objdir/$libname.libcmd
Chris@69 10680 func_to_tool_file "$output_objdir/$libname.libcmd"
Chris@69 10681 oldobjs=" $archiver_list_spec$func_to_tool_file_result"
Chris@69 10682 cmds=$old_archive_cmds
Chris@69 10683 else
Chris@69 10684 # the command line is too long to link in one step, link in parts
Chris@69 10685 func_verbose "using piecewise archive linking..."
Chris@69 10686 save_RANLIB=$RANLIB
Chris@69 10687 RANLIB=:
Chris@69 10688 objlist=
Chris@69 10689 concat_cmds=
Chris@69 10690 save_oldobjs=$oldobjs
Chris@69 10691 oldobjs=
Chris@69 10692 # Is there a better way of finding the last object in the list?
Chris@69 10693 for obj in $save_oldobjs
Chris@69 10694 do
Chris@69 10695 last_oldobj=$obj
Chris@69 10696 done
Chris@69 10697 eval test_cmds=\"$old_archive_cmds\"
Chris@69 10698 func_len " $test_cmds"
Chris@69 10699 len0=$func_len_result
Chris@69 10700 len=$len0
Chris@69 10701 for obj in $save_oldobjs
Chris@69 10702 do
Chris@69 10703 func_len " $obj"
Chris@69 10704 func_arith $len + $func_len_result
Chris@69 10705 len=$func_arith_result
Chris@69 10706 func_append objlist " $obj"
Chris@69 10707 if test "$len" -lt "$max_cmd_len"; then
Chris@69 10708 :
Chris@69 10709 else
Chris@69 10710 # the above command should be used before it gets too long
Chris@69 10711 oldobjs=$objlist
Chris@69 10712 if test "$obj" = "$last_oldobj"; then
Chris@69 10713 RANLIB=$save_RANLIB
Chris@69 10714 fi
Chris@69 10715 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Chris@69 10716 eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
Chris@69 10717 objlist=
Chris@69 10718 len=$len0
Chris@69 10719 fi
Chris@69 10720 done
Chris@69 10721 RANLIB=$save_RANLIB
Chris@69 10722 oldobjs=$objlist
Chris@69 10723 if test -z "$oldobjs"; then
Chris@69 10724 eval cmds=\"\$concat_cmds\"
Chris@69 10725 else
Chris@69 10726 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
Chris@69 10727 fi
Chris@69 10728 fi
Chris@69 10729 fi
Chris@69 10730 func_execute_cmds "$cmds" 'exit $?'
Chris@69 10731 done
Chris@69 10732
Chris@69 10733 test -n "$generated" && \
Chris@69 10734 func_show_eval "${RM}r$generated"
Chris@69 10735
Chris@69 10736 # Now create the libtool archive.
Chris@69 10737 case $output in
Chris@69 10738 *.la)
Chris@69 10739 old_library=
Chris@69 10740 test yes = "$build_old_libs" && old_library=$libname.$libext
Chris@69 10741 func_verbose "creating $output"
Chris@69 10742
Chris@69 10743 # Preserve any variables that may affect compiler behavior
Chris@69 10744 for var in $variables_saved_for_relink; do
Chris@69 10745 if eval test -z \"\${$var+set}\"; then
Chris@69 10746 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
Chris@69 10747 elif eval var_value=\$$var; test -z "$var_value"; then
Chris@69 10748 relink_command="$var=; export $var; $relink_command"
Chris@69 10749 else
Chris@69 10750 func_quote_for_eval "$var_value"
Chris@69 10751 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
Chris@69 10752 fi
Chris@69 10753 done
Chris@69 10754 # Quote the link command for shipping.
Chris@69 10755 relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
Chris@69 10756 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
Chris@69 10757 if test yes = "$hardcode_automatic"; then
Chris@69 10758 relink_command=
Chris@69 10759 fi
Chris@69 10760
Chris@69 10761 # Only create the output if not a dry run.
Chris@69 10762 $opt_dry_run || {
Chris@69 10763 for installed in no yes; do
Chris@69 10764 if test yes = "$installed"; then
Chris@69 10765 if test -z "$install_libdir"; then
Chris@69 10766 break
Chris@69 10767 fi
Chris@69 10768 output=$output_objdir/${outputname}i
Chris@69 10769 # Replace all uninstalled libtool libraries with the installed ones
Chris@69 10770 newdependency_libs=
Chris@69 10771 for deplib in $dependency_libs; do
Chris@69 10772 case $deplib in
Chris@69 10773 *.la)
Chris@69 10774 func_basename "$deplib"
Chris@69 10775 name=$func_basename_result
Chris@69 10776 func_resolve_sysroot "$deplib"
Chris@69 10777 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
Chris@69 10778 test -z "$libdir" && \
Chris@69 10779 func_fatal_error "'$deplib' is not a valid libtool archive"
Chris@69 10780 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
Chris@69 10781 ;;
Chris@69 10782 -L*)
Chris@69 10783 func_stripname -L '' "$deplib"
Chris@69 10784 func_replace_sysroot "$func_stripname_result"
Chris@69 10785 func_append newdependency_libs " -L$func_replace_sysroot_result"
Chris@69 10786 ;;
Chris@69 10787 -R*)
Chris@69 10788 func_stripname -R '' "$deplib"
Chris@69 10789 func_replace_sysroot "$func_stripname_result"
Chris@69 10790 func_append newdependency_libs " -R$func_replace_sysroot_result"
Chris@69 10791 ;;
Chris@69 10792 *) func_append newdependency_libs " $deplib" ;;
Chris@69 10793 esac
Chris@69 10794 done
Chris@69 10795 dependency_libs=$newdependency_libs
Chris@69 10796 newdlfiles=
Chris@69 10797
Chris@69 10798 for lib in $dlfiles; do
Chris@69 10799 case $lib in
Chris@69 10800 *.la)
Chris@69 10801 func_basename "$lib"
Chris@69 10802 name=$func_basename_result
Chris@69 10803 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
Chris@69 10804 test -z "$libdir" && \
Chris@69 10805 func_fatal_error "'$lib' is not a valid libtool archive"
Chris@69 10806 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
Chris@69 10807 ;;
Chris@69 10808 *) func_append newdlfiles " $lib" ;;
Chris@69 10809 esac
Chris@69 10810 done
Chris@69 10811 dlfiles=$newdlfiles
Chris@69 10812 newdlprefiles=
Chris@69 10813 for lib in $dlprefiles; do
Chris@69 10814 case $lib in
Chris@69 10815 *.la)
Chris@69 10816 # Only pass preopened files to the pseudo-archive (for
Chris@69 10817 # eventual linking with the app. that links it) if we
Chris@69 10818 # didn't already link the preopened objects directly into
Chris@69 10819 # the library:
Chris@69 10820 func_basename "$lib"
Chris@69 10821 name=$func_basename_result
Chris@69 10822 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
Chris@69 10823 test -z "$libdir" && \
Chris@69 10824 func_fatal_error "'$lib' is not a valid libtool archive"
Chris@69 10825 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
Chris@69 10826 ;;
Chris@69 10827 esac
Chris@69 10828 done
Chris@69 10829 dlprefiles=$newdlprefiles
Chris@69 10830 else
Chris@69 10831 newdlfiles=
Chris@69 10832 for lib in $dlfiles; do
Chris@69 10833 case $lib in
Chris@69 10834 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
Chris@69 10835 *) abs=`pwd`"/$lib" ;;
Chris@69 10836 esac
Chris@69 10837 func_append newdlfiles " $abs"
Chris@69 10838 done
Chris@69 10839 dlfiles=$newdlfiles
Chris@69 10840 newdlprefiles=
Chris@69 10841 for lib in $dlprefiles; do
Chris@69 10842 case $lib in
Chris@69 10843 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
Chris@69 10844 *) abs=`pwd`"/$lib" ;;
Chris@69 10845 esac
Chris@69 10846 func_append newdlprefiles " $abs"
Chris@69 10847 done
Chris@69 10848 dlprefiles=$newdlprefiles
Chris@69 10849 fi
Chris@69 10850 $RM $output
Chris@69 10851 # place dlname in correct position for cygwin
Chris@69 10852 # In fact, it would be nice if we could use this code for all target
Chris@69 10853 # systems that can't hard-code library paths into their executables
Chris@69 10854 # and that have no shared library path variable independent of PATH,
Chris@69 10855 # but it turns out we can't easily determine that from inspecting
Chris@69 10856 # libtool variables, so we have to hard-code the OSs to which it
Chris@69 10857 # applies here; at the moment, that means platforms that use the PE
Chris@69 10858 # object format with DLL files. See the long comment at the top of
Chris@69 10859 # tests/bindir.at for full details.
Chris@69 10860 tdlname=$dlname
Chris@69 10861 case $host,$output,$installed,$module,$dlname in
Chris@69 10862 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
Chris@69 10863 # If a -bindir argument was supplied, place the dll there.
Chris@69 10864 if test -n "$bindir"; then
Chris@69 10865 func_relative_path "$install_libdir" "$bindir"
Chris@69 10866 tdlname=$func_relative_path_result/$dlname
Chris@69 10867 else
Chris@69 10868 # Otherwise fall back on heuristic.
Chris@69 10869 tdlname=../bin/$dlname
Chris@69 10870 fi
Chris@69 10871 ;;
Chris@69 10872 esac
Chris@69 10873 $ECHO > $output "\
Chris@69 10874 # $outputname - a libtool library file
Chris@69 10875 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@69 10876 #
Chris@69 10877 # Please DO NOT delete this file!
Chris@69 10878 # It is necessary for linking the library.
Chris@69 10879
Chris@69 10880 # The name that we can dlopen(3).
Chris@69 10881 dlname='$tdlname'
Chris@69 10882
Chris@69 10883 # Names of this library.
Chris@69 10884 library_names='$library_names'
Chris@69 10885
Chris@69 10886 # The name of the static archive.
Chris@69 10887 old_library='$old_library'
Chris@69 10888
Chris@69 10889 # Linker flags that cannot go in dependency_libs.
Chris@69 10890 inherited_linker_flags='$new_inherited_linker_flags'
Chris@69 10891
Chris@69 10892 # Libraries that this one depends upon.
Chris@69 10893 dependency_libs='$dependency_libs'
Chris@69 10894
Chris@69 10895 # Names of additional weak libraries provided by this library
Chris@69 10896 weak_library_names='$weak_libs'
Chris@69 10897
Chris@69 10898 # Version information for $libname.
Chris@69 10899 current=$current
Chris@69 10900 age=$age
Chris@69 10901 revision=$revision
Chris@69 10902
Chris@69 10903 # Is this an already installed library?
Chris@69 10904 installed=$installed
Chris@69 10905
Chris@69 10906 # Should we warn about portability when linking against -modules?
Chris@69 10907 shouldnotlink=$module
Chris@69 10908
Chris@69 10909 # Files to dlopen/dlpreopen
Chris@69 10910 dlopen='$dlfiles'
Chris@69 10911 dlpreopen='$dlprefiles'
Chris@69 10912
Chris@69 10913 # Directory that this library needs to be installed in:
Chris@69 10914 libdir='$install_libdir'"
Chris@69 10915 if test no,yes = "$installed,$need_relink"; then
Chris@69 10916 $ECHO >> $output "\
Chris@69 10917 relink_command=\"$relink_command\""
Chris@69 10918 fi
Chris@69 10919 done
Chris@69 10920 }
Chris@69 10921
Chris@69 10922 # Do a symbolic link so that the libtool archive can be found in
Chris@69 10923 # LD_LIBRARY_PATH before the program is installed.
Chris@69 10924 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
Chris@69 10925 ;;
Chris@69 10926 esac
Chris@69 10927 exit $EXIT_SUCCESS
Chris@69 10928 }
Chris@69 10929
Chris@69 10930 if test link = "$opt_mode" || test relink = "$opt_mode"; then
Chris@69 10931 func_mode_link ${1+"$@"}
Chris@69 10932 fi
Chris@69 10933
Chris@69 10934
Chris@69 10935 # func_mode_uninstall arg...
Chris@69 10936 func_mode_uninstall ()
Chris@69 10937 {
Chris@69 10938 $debug_cmd
Chris@69 10939
Chris@69 10940 RM=$nonopt
Chris@69 10941 files=
Chris@69 10942 rmforce=false
Chris@69 10943 exit_status=0
Chris@69 10944
Chris@69 10945 # This variable tells wrapper scripts just to set variables rather
Chris@69 10946 # than running their programs.
Chris@69 10947 libtool_install_magic=$magic
Chris@69 10948
Chris@69 10949 for arg
Chris@69 10950 do
Chris@69 10951 case $arg in
Chris@69 10952 -f) func_append RM " $arg"; rmforce=: ;;
Chris@69 10953 -*) func_append RM " $arg" ;;
Chris@69 10954 *) func_append files " $arg" ;;
Chris@69 10955 esac
Chris@69 10956 done
Chris@69 10957
Chris@69 10958 test -z "$RM" && \
Chris@69 10959 func_fatal_help "you must specify an RM program"
Chris@69 10960
Chris@69 10961 rmdirs=
Chris@69 10962
Chris@69 10963 for file in $files; do
Chris@69 10964 func_dirname "$file" "" "."
Chris@69 10965 dir=$func_dirname_result
Chris@69 10966 if test . = "$dir"; then
Chris@69 10967 odir=$objdir
Chris@69 10968 else
Chris@69 10969 odir=$dir/$objdir
Chris@69 10970 fi
Chris@69 10971 func_basename "$file"
Chris@69 10972 name=$func_basename_result
Chris@69 10973 test uninstall = "$opt_mode" && odir=$dir
Chris@69 10974
Chris@69 10975 # Remember odir for removal later, being careful to avoid duplicates
Chris@69 10976 if test clean = "$opt_mode"; then
Chris@69 10977 case " $rmdirs " in
Chris@69 10978 *" $odir "*) ;;
Chris@69 10979 *) func_append rmdirs " $odir" ;;
Chris@69 10980 esac
Chris@69 10981 fi
Chris@69 10982
Chris@69 10983 # Don't error if the file doesn't exist and rm -f was used.
Chris@69 10984 if { test -L "$file"; } >/dev/null 2>&1 ||
Chris@69 10985 { test -h "$file"; } >/dev/null 2>&1 ||
Chris@69 10986 test -f "$file"; then
Chris@69 10987 :
Chris@69 10988 elif test -d "$file"; then
Chris@69 10989 exit_status=1
Chris@69 10990 continue
Chris@69 10991 elif $rmforce; then
Chris@69 10992 continue
Chris@69 10993 fi
Chris@69 10994
Chris@69 10995 rmfiles=$file
Chris@69 10996
Chris@69 10997 case $name in
Chris@69 10998 *.la)
Chris@69 10999 # Possibly a libtool archive, so verify it.
Chris@69 11000 if func_lalib_p "$file"; then
Chris@69 11001 func_source $dir/$name
Chris@69 11002
Chris@69 11003 # Delete the libtool libraries and symlinks.
Chris@69 11004 for n in $library_names; do
Chris@69 11005 func_append rmfiles " $odir/$n"
Chris@69 11006 done
Chris@69 11007 test -n "$old_library" && func_append rmfiles " $odir/$old_library"
Chris@69 11008
Chris@69 11009 case $opt_mode in
Chris@69 11010 clean)
Chris@69 11011 case " $library_names " in
Chris@69 11012 *" $dlname "*) ;;
Chris@69 11013 *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
Chris@69 11014 esac
Chris@69 11015 test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
Chris@69 11016 ;;
Chris@69 11017 uninstall)
Chris@69 11018 if test -n "$library_names"; then
Chris@69 11019 # Do each command in the postuninstall commands.
Chris@69 11020 func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
Chris@69 11021 fi
Chris@69 11022
Chris@69 11023 if test -n "$old_library"; then
Chris@69 11024 # Do each command in the old_postuninstall commands.
Chris@69 11025 func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
Chris@69 11026 fi
Chris@69 11027 # FIXME: should reinstall the best remaining shared library.
Chris@69 11028 ;;
Chris@69 11029 esac
Chris@69 11030 fi
Chris@69 11031 ;;
Chris@69 11032
Chris@69 11033 *.lo)
Chris@69 11034 # Possibly a libtool object, so verify it.
Chris@69 11035 if func_lalib_p "$file"; then
Chris@69 11036
Chris@69 11037 # Read the .lo file
Chris@69 11038 func_source $dir/$name
Chris@69 11039
Chris@69 11040 # Add PIC object to the list of files to remove.
Chris@69 11041 if test -n "$pic_object" && test none != "$pic_object"; then
Chris@69 11042 func_append rmfiles " $dir/$pic_object"
Chris@69 11043 fi
Chris@69 11044
Chris@69 11045 # Add non-PIC object to the list of files to remove.
Chris@69 11046 if test -n "$non_pic_object" && test none != "$non_pic_object"; then
Chris@69 11047 func_append rmfiles " $dir/$non_pic_object"
Chris@69 11048 fi
Chris@69 11049 fi
Chris@69 11050 ;;
Chris@69 11051
Chris@69 11052 *)
Chris@69 11053 if test clean = "$opt_mode"; then
Chris@69 11054 noexename=$name
Chris@69 11055 case $file in
Chris@69 11056 *.exe)
Chris@69 11057 func_stripname '' '.exe' "$file"
Chris@69 11058 file=$func_stripname_result
Chris@69 11059 func_stripname '' '.exe' "$name"
Chris@69 11060 noexename=$func_stripname_result
Chris@69 11061 # $file with .exe has already been added to rmfiles,
Chris@69 11062 # add $file without .exe
Chris@69 11063 func_append rmfiles " $file"
Chris@69 11064 ;;
Chris@69 11065 esac
Chris@69 11066 # Do a test to see if this is a libtool program.
Chris@69 11067 if func_ltwrapper_p "$file"; then
Chris@69 11068 if func_ltwrapper_executable_p "$file"; then
Chris@69 11069 func_ltwrapper_scriptname "$file"
Chris@69 11070 relink_command=
Chris@69 11071 func_source $func_ltwrapper_scriptname_result
Chris@69 11072 func_append rmfiles " $func_ltwrapper_scriptname_result"
Chris@69 11073 else
Chris@69 11074 relink_command=
Chris@69 11075 func_source $dir/$noexename
Chris@69 11076 fi
Chris@69 11077
Chris@69 11078 # note $name still contains .exe if it was in $file originally
Chris@69 11079 # as does the version of $file that was added into $rmfiles
Chris@69 11080 func_append rmfiles " $odir/$name $odir/${name}S.$objext"
Chris@69 11081 if test yes = "$fast_install" && test -n "$relink_command"; then
Chris@69 11082 func_append rmfiles " $odir/lt-$name"
Chris@69 11083 fi
Chris@69 11084 if test "X$noexename" != "X$name"; then
Chris@69 11085 func_append rmfiles " $odir/lt-$noexename.c"
Chris@69 11086 fi
Chris@69 11087 fi
Chris@69 11088 fi
Chris@69 11089 ;;
Chris@69 11090 esac
Chris@69 11091 func_show_eval "$RM $rmfiles" 'exit_status=1'
Chris@69 11092 done
Chris@69 11093
Chris@69 11094 # Try to remove the $objdir's in the directories where we deleted files
Chris@69 11095 for dir in $rmdirs; do
Chris@69 11096 if test -d "$dir"; then
Chris@69 11097 func_show_eval "rmdir $dir >/dev/null 2>&1"
Chris@69 11098 fi
Chris@69 11099 done
Chris@69 11100
Chris@69 11101 exit $exit_status
Chris@69 11102 }
Chris@69 11103
Chris@69 11104 if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
Chris@69 11105 func_mode_uninstall ${1+"$@"}
Chris@69 11106 fi
Chris@69 11107
Chris@69 11108 test -z "$opt_mode" && {
Chris@69 11109 help=$generic_help
Chris@69 11110 func_fatal_help "you must specify a MODE"
Chris@69 11111 }
Chris@69 11112
Chris@69 11113 test -z "$exec_cmd" && \
Chris@69 11114 func_fatal_help "invalid operation mode '$opt_mode'"
Chris@69 11115
Chris@69 11116 if test -n "$exec_cmd"; then
Chris@69 11117 eval exec "$exec_cmd"
Chris@69 11118 exit $EXIT_FAILURE
Chris@69 11119 fi
Chris@69 11120
Chris@69 11121 exit $exit_status
Chris@69 11122
Chris@69 11123
Chris@69 11124 # The TAGs below are defined such that we never get into a situation
Chris@69 11125 # where we disable both kinds of libraries. Given conflicting
Chris@69 11126 # choices, we go for a static library, that is the most portable,
Chris@69 11127 # since we can't tell whether shared libraries were disabled because
Chris@69 11128 # the user asked for that or because the platform doesn't support
Chris@69 11129 # them. This is particularly important on AIX, because we don't
Chris@69 11130 # support having both static and shared libraries enabled at the same
Chris@69 11131 # time on that platform, so we default to a shared-only configuration.
Chris@69 11132 # If a disable-shared tag is given, we'll fallback to a static-only
Chris@69 11133 # configuration. But we'll never go from static-only to shared-only.
Chris@69 11134
Chris@69 11135 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
Chris@69 11136 build_libtool_libs=no
Chris@69 11137 build_old_libs=yes
Chris@69 11138 # ### END LIBTOOL TAG CONFIG: disable-shared
Chris@69 11139
Chris@69 11140 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
Chris@69 11141 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
Chris@69 11142 # ### END LIBTOOL TAG CONFIG: disable-static
Chris@69 11143
Chris@69 11144 # Local Variables:
Chris@69 11145 # mode:shell-script
Chris@69 11146 # sh-indentation:2
Chris@69 11147 # End: