annotate src/libsamplerate-0.1.9/Cfg/ltmain.sh @ 84:08ae793730bd

Add null config files
author Chris Cannam
date Mon, 02 Mar 2020 14:03:47 +0000
parents 481f5f8c5634
children
rev   line source
Chris@41 1 #! /bin/sh
Chris@41 2 ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
Chris@41 3 ## by inline-source v2014-01-03.01
Chris@41 4
Chris@41 5 # libtool (GNU libtool) 2.4.6
Chris@41 6 # Provide generalized library-building support services.
Chris@41 7 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
Chris@41 8
Chris@41 9 # Copyright (C) 1996-2015 Free Software Foundation, Inc.
Chris@41 10 # This is free software; see the source for copying conditions. There is NO
Chris@41 11 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chris@41 12
Chris@41 13 # GNU Libtool is free software; you can redistribute it and/or modify
Chris@41 14 # it under the terms of the GNU General Public License as published by
Chris@41 15 # the Free Software Foundation; either version 2 of the License, or
Chris@41 16 # (at your option) any later version.
Chris@41 17 #
Chris@41 18 # As a special exception to the GNU General Public License,
Chris@41 19 # if you distribute this file as part of a program or library that
Chris@41 20 # is built using GNU Libtool, you may include this file under the
Chris@41 21 # same distribution terms that you use for the rest of that program.
Chris@41 22 #
Chris@41 23 # GNU Libtool is distributed in the hope that it will be useful, but
Chris@41 24 # WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@41 25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Chris@41 26 # General Public License for more details.
Chris@41 27 #
Chris@41 28 # You should have received a copy of the GNU General Public License
Chris@41 29 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@41 30
Chris@41 31
Chris@41 32 PROGRAM=libtool
Chris@41 33 PACKAGE=libtool
Chris@41 34 VERSION="2.4.6 Debian-2.4.6-2"
Chris@41 35 package_revision=2.4.6
Chris@41 36
Chris@41 37
Chris@41 38 ## ------ ##
Chris@41 39 ## Usage. ##
Chris@41 40 ## ------ ##
Chris@41 41
Chris@41 42 # Run './libtool --help' for help with using this script from the
Chris@41 43 # command line.
Chris@41 44
Chris@41 45
Chris@41 46 ## ------------------------------- ##
Chris@41 47 ## User overridable command paths. ##
Chris@41 48 ## ------------------------------- ##
Chris@41 49
Chris@41 50 # After configure completes, it has a better idea of some of the
Chris@41 51 # shell tools we need than the defaults used by the functions shared
Chris@41 52 # with bootstrap, so set those here where they can still be over-
Chris@41 53 # ridden by the user, but otherwise take precedence.
Chris@41 54
Chris@41 55 : ${AUTOCONF="autoconf"}
Chris@41 56 : ${AUTOMAKE="automake"}
Chris@41 57
Chris@41 58
Chris@41 59 ## -------------------------- ##
Chris@41 60 ## Source external libraries. ##
Chris@41 61 ## -------------------------- ##
Chris@41 62
Chris@41 63 # Much of our low-level functionality needs to be sourced from external
Chris@41 64 # libraries, which are installed to $pkgauxdir.
Chris@41 65
Chris@41 66 # Set a version string for this script.
Chris@41 67 scriptversion=2015-01-20.17; # UTC
Chris@41 68
Chris@41 69 # General shell script boiler plate, and helper functions.
Chris@41 70 # Written by Gary V. Vaughan, 2004
Chris@41 71
Chris@41 72 # Copyright (C) 2004-2015 Free Software Foundation, Inc.
Chris@41 73 # This is free software; see the source for copying conditions. There is NO
Chris@41 74 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chris@41 75
Chris@41 76 # This program is free software; you can redistribute it and/or modify
Chris@41 77 # it under the terms of the GNU General Public License as published by
Chris@41 78 # the Free Software Foundation; either version 3 of the License, or
Chris@41 79 # (at your option) any later version.
Chris@41 80
Chris@41 81 # As a special exception to the GNU General Public License, if you distribute
Chris@41 82 # this file as part of a program or library that is built using GNU Libtool,
Chris@41 83 # you may include this file under the same distribution terms that you use
Chris@41 84 # for the rest of that program.
Chris@41 85
Chris@41 86 # This program is distributed in the hope that it will be useful,
Chris@41 87 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@41 88 # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
Chris@41 89 # General Public License for more details.
Chris@41 90
Chris@41 91 # You should have received a copy of the GNU General Public License
Chris@41 92 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@41 93
Chris@41 94 # Please report bugs or propose patches to gary@gnu.org.
Chris@41 95
Chris@41 96
Chris@41 97 ## ------ ##
Chris@41 98 ## Usage. ##
Chris@41 99 ## ------ ##
Chris@41 100
Chris@41 101 # Evaluate this file near the top of your script to gain access to
Chris@41 102 # the functions and variables defined here:
Chris@41 103 #
Chris@41 104 # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
Chris@41 105 #
Chris@41 106 # If you need to override any of the default environment variable
Chris@41 107 # settings, do that before evaluating this file.
Chris@41 108
Chris@41 109
Chris@41 110 ## -------------------- ##
Chris@41 111 ## Shell normalisation. ##
Chris@41 112 ## -------------------- ##
Chris@41 113
Chris@41 114 # Some shells need a little help to be as Bourne compatible as possible.
Chris@41 115 # Before doing anything else, make sure all that help has been provided!
Chris@41 116
Chris@41 117 DUALCASE=1; export DUALCASE # for MKS sh
Chris@41 118 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
Chris@41 119 emulate sh
Chris@41 120 NULLCMD=:
Chris@41 121 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
Chris@41 122 # is contrary to our usage. Disable this feature.
Chris@41 123 alias -g '${1+"$@"}'='"$@"'
Chris@41 124 setopt NO_GLOB_SUBST
Chris@41 125 else
Chris@41 126 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
Chris@41 127 fi
Chris@41 128
Chris@41 129 # NLS nuisances: We save the old values in case they are required later.
Chris@41 130 _G_user_locale=
Chris@41 131 _G_safe_locale=
Chris@41 132 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
Chris@41 133 do
Chris@41 134 eval "if test set = \"\${$_G_var+set}\"; then
Chris@41 135 save_$_G_var=\$$_G_var
Chris@41 136 $_G_var=C
Chris@41 137 export $_G_var
Chris@41 138 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
Chris@41 139 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
Chris@41 140 fi"
Chris@41 141 done
Chris@41 142
Chris@41 143 # CDPATH.
Chris@41 144 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
Chris@41 145
Chris@41 146 # Make sure IFS has a sensible default
Chris@41 147 sp=' '
Chris@41 148 nl='
Chris@41 149 '
Chris@41 150 IFS="$sp $nl"
Chris@41 151
Chris@41 152 # There are apparently some retarded systems that use ';' as a PATH separator!
Chris@41 153 if test "${PATH_SEPARATOR+set}" != set; then
Chris@41 154 PATH_SEPARATOR=:
Chris@41 155 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
Chris@41 156 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
Chris@41 157 PATH_SEPARATOR=';'
Chris@41 158 }
Chris@41 159 fi
Chris@41 160
Chris@41 161
Chris@41 162
Chris@41 163 ## ------------------------- ##
Chris@41 164 ## Locate command utilities. ##
Chris@41 165 ## ------------------------- ##
Chris@41 166
Chris@41 167
Chris@41 168 # func_executable_p FILE
Chris@41 169 # ----------------------
Chris@41 170 # Check that FILE is an executable regular file.
Chris@41 171 func_executable_p ()
Chris@41 172 {
Chris@41 173 test -f "$1" && test -x "$1"
Chris@41 174 }
Chris@41 175
Chris@41 176
Chris@41 177 # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
Chris@41 178 # --------------------------------------------
Chris@41 179 # Search for either a program that responds to --version with output
Chris@41 180 # containing "GNU", or else returned by CHECK_FUNC otherwise, by
Chris@41 181 # trying all the directories in PATH with each of the elements of
Chris@41 182 # PROGS_LIST.
Chris@41 183 #
Chris@41 184 # CHECK_FUNC should accept the path to a candidate program, and
Chris@41 185 # set $func_check_prog_result if it truncates its output less than
Chris@41 186 # $_G_path_prog_max characters.
Chris@41 187 func_path_progs ()
Chris@41 188 {
Chris@41 189 _G_progs_list=$1
Chris@41 190 _G_check_func=$2
Chris@41 191 _G_PATH=${3-"$PATH"}
Chris@41 192
Chris@41 193 _G_path_prog_max=0
Chris@41 194 _G_path_prog_found=false
Chris@41 195 _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
Chris@41 196 for _G_dir in $_G_PATH; do
Chris@41 197 IFS=$_G_save_IFS
Chris@41 198 test -z "$_G_dir" && _G_dir=.
Chris@41 199 for _G_prog_name in $_G_progs_list; do
Chris@41 200 for _exeext in '' .EXE; do
Chris@41 201 _G_path_prog=$_G_dir/$_G_prog_name$_exeext
Chris@41 202 func_executable_p "$_G_path_prog" || continue
Chris@41 203 case `"$_G_path_prog" --version 2>&1` in
Chris@41 204 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
Chris@41 205 *) $_G_check_func $_G_path_prog
Chris@41 206 func_path_progs_result=$func_check_prog_result
Chris@41 207 ;;
Chris@41 208 esac
Chris@41 209 $_G_path_prog_found && break 3
Chris@41 210 done
Chris@41 211 done
Chris@41 212 done
Chris@41 213 IFS=$_G_save_IFS
Chris@41 214 test -z "$func_path_progs_result" && {
Chris@41 215 echo "no acceptable sed could be found in \$PATH" >&2
Chris@41 216 exit 1
Chris@41 217 }
Chris@41 218 }
Chris@41 219
Chris@41 220
Chris@41 221 # We want to be able to use the functions in this file before configure
Chris@41 222 # has figured out where the best binaries are kept, which means we have
Chris@41 223 # to search for them ourselves - except when the results are already set
Chris@41 224 # where we skip the searches.
Chris@41 225
Chris@41 226 # Unless the user overrides by setting SED, search the path for either GNU
Chris@41 227 # sed, or the sed that truncates its output the least.
Chris@41 228 test -z "$SED" && {
Chris@41 229 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
Chris@41 230 for _G_i in 1 2 3 4 5 6 7; do
Chris@41 231 _G_sed_script=$_G_sed_script$nl$_G_sed_script
Chris@41 232 done
Chris@41 233 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
Chris@41 234 _G_sed_script=
Chris@41 235
Chris@41 236 func_check_prog_sed ()
Chris@41 237 {
Chris@41 238 _G_path_prog=$1
Chris@41 239
Chris@41 240 _G_count=0
Chris@41 241 printf 0123456789 >conftest.in
Chris@41 242 while :
Chris@41 243 do
Chris@41 244 cat conftest.in conftest.in >conftest.tmp
Chris@41 245 mv conftest.tmp conftest.in
Chris@41 246 cp conftest.in conftest.nl
Chris@41 247 echo '' >> conftest.nl
Chris@41 248 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
Chris@41 249 diff conftest.out conftest.nl >/dev/null 2>&1 || break
Chris@41 250 _G_count=`expr $_G_count + 1`
Chris@41 251 if test "$_G_count" -gt "$_G_path_prog_max"; then
Chris@41 252 # Best one so far, save it but keep looking for a better one
Chris@41 253 func_check_prog_result=$_G_path_prog
Chris@41 254 _G_path_prog_max=$_G_count
Chris@41 255 fi
Chris@41 256 # 10*(2^10) chars as input seems more than enough
Chris@41 257 test 10 -lt "$_G_count" && break
Chris@41 258 done
Chris@41 259 rm -f conftest.in conftest.tmp conftest.nl conftest.out
Chris@41 260 }
Chris@41 261
Chris@41 262 func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
Chris@41 263 rm -f conftest.sed
Chris@41 264 SED=$func_path_progs_result
Chris@41 265 }
Chris@41 266
Chris@41 267
Chris@41 268 # Unless the user overrides by setting GREP, search the path for either GNU
Chris@41 269 # grep, or the grep that truncates its output the least.
Chris@41 270 test -z "$GREP" && {
Chris@41 271 func_check_prog_grep ()
Chris@41 272 {
Chris@41 273 _G_path_prog=$1
Chris@41 274
Chris@41 275 _G_count=0
Chris@41 276 _G_path_prog_max=0
Chris@41 277 printf 0123456789 >conftest.in
Chris@41 278 while :
Chris@41 279 do
Chris@41 280 cat conftest.in conftest.in >conftest.tmp
Chris@41 281 mv conftest.tmp conftest.in
Chris@41 282 cp conftest.in conftest.nl
Chris@41 283 echo 'GREP' >> conftest.nl
Chris@41 284 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
Chris@41 285 diff conftest.out conftest.nl >/dev/null 2>&1 || break
Chris@41 286 _G_count=`expr $_G_count + 1`
Chris@41 287 if test "$_G_count" -gt "$_G_path_prog_max"; then
Chris@41 288 # Best one so far, save it but keep looking for a better one
Chris@41 289 func_check_prog_result=$_G_path_prog
Chris@41 290 _G_path_prog_max=$_G_count
Chris@41 291 fi
Chris@41 292 # 10*(2^10) chars as input seems more than enough
Chris@41 293 test 10 -lt "$_G_count" && break
Chris@41 294 done
Chris@41 295 rm -f conftest.in conftest.tmp conftest.nl conftest.out
Chris@41 296 }
Chris@41 297
Chris@41 298 func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
Chris@41 299 GREP=$func_path_progs_result
Chris@41 300 }
Chris@41 301
Chris@41 302
Chris@41 303 ## ------------------------------- ##
Chris@41 304 ## User overridable command paths. ##
Chris@41 305 ## ------------------------------- ##
Chris@41 306
Chris@41 307 # All uppercase variable names are used for environment variables. These
Chris@41 308 # variables can be overridden by the user before calling a script that
Chris@41 309 # uses them if a suitable command of that name is not already available
Chris@41 310 # in the command search PATH.
Chris@41 311
Chris@41 312 : ${CP="cp -f"}
Chris@41 313 : ${ECHO="printf %s\n"}
Chris@41 314 : ${EGREP="$GREP -E"}
Chris@41 315 : ${FGREP="$GREP -F"}
Chris@41 316 : ${LN_S="ln -s"}
Chris@41 317 : ${MAKE="make"}
Chris@41 318 : ${MKDIR="mkdir"}
Chris@41 319 : ${MV="mv -f"}
Chris@41 320 : ${RM="rm -f"}
Chris@41 321 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
Chris@41 322
Chris@41 323
Chris@41 324 ## -------------------- ##
Chris@41 325 ## Useful sed snippets. ##
Chris@41 326 ## -------------------- ##
Chris@41 327
Chris@41 328 sed_dirname='s|/[^/]*$||'
Chris@41 329 sed_basename='s|^.*/||'
Chris@41 330
Chris@41 331 # Sed substitution that helps us do robust quoting. It backslashifies
Chris@41 332 # metacharacters that are still active within double-quoted strings.
Chris@41 333 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
Chris@41 334
Chris@41 335 # Same as above, but do not quote variable references.
Chris@41 336 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
Chris@41 337
Chris@41 338 # Sed substitution that turns a string into a regex matching for the
Chris@41 339 # string literally.
Chris@41 340 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
Chris@41 341
Chris@41 342 # Sed substitution that converts a w32 file name or path
Chris@41 343 # that contains forward slashes, into one that contains
Chris@41 344 # (escaped) backslashes. A very naive implementation.
Chris@41 345 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
Chris@41 346
Chris@41 347 # Re-'\' parameter expansions in output of sed_double_quote_subst that
Chris@41 348 # were '\'-ed in input to the same. If an odd number of '\' preceded a
Chris@41 349 # '$' in input to sed_double_quote_subst, that '$' was protected from
Chris@41 350 # expansion. Since each input '\' is now two '\'s, look for any number
Chris@41 351 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
Chris@41 352 _G_bs='\\'
Chris@41 353 _G_bs2='\\\\'
Chris@41 354 _G_bs4='\\\\\\\\'
Chris@41 355 _G_dollar='\$'
Chris@41 356 sed_double_backslash="\
Chris@41 357 s/$_G_bs4/&\\
Chris@41 358 /g
Chris@41 359 s/^$_G_bs2$_G_dollar/$_G_bs&/
Chris@41 360 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
Chris@41 361 s/\n//g"
Chris@41 362
Chris@41 363
Chris@41 364 ## ----------------- ##
Chris@41 365 ## Global variables. ##
Chris@41 366 ## ----------------- ##
Chris@41 367
Chris@41 368 # Except for the global variables explicitly listed below, the following
Chris@41 369 # functions in the '^func_' namespace, and the '^require_' namespace
Chris@41 370 # variables initialised in the 'Resource management' section, sourcing
Chris@41 371 # this file will not pollute your global namespace with anything
Chris@41 372 # else. There's no portable way to scope variables in Bourne shell
Chris@41 373 # though, so actually running these functions will sometimes place
Chris@41 374 # results into a variable named after the function, and often use
Chris@41 375 # temporary variables in the '^_G_' namespace. If you are careful to
Chris@41 376 # avoid using those namespaces casually in your sourcing script, things
Chris@41 377 # should continue to work as you expect. And, of course, you can freely
Chris@41 378 # overwrite any of the functions or variables defined here before
Chris@41 379 # calling anything to customize them.
Chris@41 380
Chris@41 381 EXIT_SUCCESS=0
Chris@41 382 EXIT_FAILURE=1
Chris@41 383 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
Chris@41 384 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
Chris@41 385
Chris@41 386 # Allow overriding, eg assuming that you follow the convention of
Chris@41 387 # putting '$debug_cmd' at the start of all your functions, you can get
Chris@41 388 # bash to show function call trace with:
Chris@41 389 #
Chris@41 390 # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
Chris@41 391 debug_cmd=${debug_cmd-":"}
Chris@41 392 exit_cmd=:
Chris@41 393
Chris@41 394 # By convention, finish your script with:
Chris@41 395 #
Chris@41 396 # exit $exit_status
Chris@41 397 #
Chris@41 398 # so that you can set exit_status to non-zero if you want to indicate
Chris@41 399 # something went wrong during execution without actually bailing out at
Chris@41 400 # the point of failure.
Chris@41 401 exit_status=$EXIT_SUCCESS
Chris@41 402
Chris@41 403 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
Chris@41 404 # is ksh but when the shell is invoked as "sh" and the current value of
Chris@41 405 # the _XPG environment variable is not equal to 1 (one), the special
Chris@41 406 # positional parameter $0, within a function call, is the name of the
Chris@41 407 # function.
Chris@41 408 progpath=$0
Chris@41 409
Chris@41 410 # The name of this program.
Chris@41 411 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
Chris@41 412
Chris@41 413 # Make sure we have an absolute progpath for reexecution:
Chris@41 414 case $progpath in
Chris@41 415 [\\/]*|[A-Za-z]:\\*) ;;
Chris@41 416 *[\\/]*)
Chris@41 417 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
Chris@41 418 progdir=`cd "$progdir" && pwd`
Chris@41 419 progpath=$progdir/$progname
Chris@41 420 ;;
Chris@41 421 *)
Chris@41 422 _G_IFS=$IFS
Chris@41 423 IFS=${PATH_SEPARATOR-:}
Chris@41 424 for progdir in $PATH; do
Chris@41 425 IFS=$_G_IFS
Chris@41 426 test -x "$progdir/$progname" && break
Chris@41 427 done
Chris@41 428 IFS=$_G_IFS
Chris@41 429 test -n "$progdir" || progdir=`pwd`
Chris@41 430 progpath=$progdir/$progname
Chris@41 431 ;;
Chris@41 432 esac
Chris@41 433
Chris@41 434
Chris@41 435 ## ----------------- ##
Chris@41 436 ## Standard options. ##
Chris@41 437 ## ----------------- ##
Chris@41 438
Chris@41 439 # The following options affect the operation of the functions defined
Chris@41 440 # below, and should be set appropriately depending on run-time para-
Chris@41 441 # meters passed on the command line.
Chris@41 442
Chris@41 443 opt_dry_run=false
Chris@41 444 opt_quiet=false
Chris@41 445 opt_verbose=false
Chris@41 446
Chris@41 447 # Categories 'all' and 'none' are always available. Append any others
Chris@41 448 # you will pass as the first argument to func_warning from your own
Chris@41 449 # code.
Chris@41 450 warning_categories=
Chris@41 451
Chris@41 452 # By default, display warnings according to 'opt_warning_types'. Set
Chris@41 453 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
Chris@41 454 # treat the next displayed warning as a fatal error.
Chris@41 455 warning_func=func_warn_and_continue
Chris@41 456
Chris@41 457 # Set to 'all' to display all warnings, 'none' to suppress all
Chris@41 458 # warnings, or a space delimited list of some subset of
Chris@41 459 # 'warning_categories' to display only the listed warnings.
Chris@41 460 opt_warning_types=all
Chris@41 461
Chris@41 462
Chris@41 463 ## -------------------- ##
Chris@41 464 ## Resource management. ##
Chris@41 465 ## -------------------- ##
Chris@41 466
Chris@41 467 # This section contains definitions for functions that each ensure a
Chris@41 468 # particular resource (a file, or a non-empty configuration variable for
Chris@41 469 # example) is available, and if appropriate to extract default values
Chris@41 470 # from pertinent package files. Call them using their associated
Chris@41 471 # 'require_*' variable to ensure that they are executed, at most, once.
Chris@41 472 #
Chris@41 473 # It's entirely deliberate that calling these functions can set
Chris@41 474 # variables that don't obey the namespace limitations obeyed by the rest
Chris@41 475 # of this file, in order that that they be as useful as possible to
Chris@41 476 # callers.
Chris@41 477
Chris@41 478
Chris@41 479 # require_term_colors
Chris@41 480 # -------------------
Chris@41 481 # Allow display of bold text on terminals that support it.
Chris@41 482 require_term_colors=func_require_term_colors
Chris@41 483 func_require_term_colors ()
Chris@41 484 {
Chris@41 485 $debug_cmd
Chris@41 486
Chris@41 487 test -t 1 && {
Chris@41 488 # COLORTERM and USE_ANSI_COLORS environment variables take
Chris@41 489 # precedence, because most terminfo databases neglect to describe
Chris@41 490 # whether color sequences are supported.
Chris@41 491 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
Chris@41 492
Chris@41 493 if test 1 = "$USE_ANSI_COLORS"; then
Chris@41 494 # Standard ANSI escape sequences
Chris@41 495 tc_reset=''
Chris@41 496 tc_bold=''; tc_standout=''
Chris@41 497 tc_red=''; tc_green=''
Chris@41 498 tc_blue=''; tc_cyan=''
Chris@41 499 else
Chris@41 500 # Otherwise trust the terminfo database after all.
Chris@41 501 test -n "`tput sgr0 2>/dev/null`" && {
Chris@41 502 tc_reset=`tput sgr0`
Chris@41 503 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
Chris@41 504 tc_standout=$tc_bold
Chris@41 505 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
Chris@41 506 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
Chris@41 507 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
Chris@41 508 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
Chris@41 509 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
Chris@41 510 }
Chris@41 511 fi
Chris@41 512 }
Chris@41 513
Chris@41 514 require_term_colors=:
Chris@41 515 }
Chris@41 516
Chris@41 517
Chris@41 518 ## ----------------- ##
Chris@41 519 ## Function library. ##
Chris@41 520 ## ----------------- ##
Chris@41 521
Chris@41 522 # This section contains a variety of useful functions to call in your
Chris@41 523 # scripts. Take note of the portable wrappers for features provided by
Chris@41 524 # some modern shells, which will fall back to slower equivalents on
Chris@41 525 # less featureful shells.
Chris@41 526
Chris@41 527
Chris@41 528 # func_append VAR VALUE
Chris@41 529 # ---------------------
Chris@41 530 # Append VALUE onto the existing contents of VAR.
Chris@41 531
Chris@41 532 # We should try to minimise forks, especially on Windows where they are
Chris@41 533 # unreasonably slow, so skip the feature probes when bash or zsh are
Chris@41 534 # being used:
Chris@41 535 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
Chris@41 536 : ${_G_HAVE_ARITH_OP="yes"}
Chris@41 537 : ${_G_HAVE_XSI_OPS="yes"}
Chris@41 538 # The += operator was introduced in bash 3.1
Chris@41 539 case $BASH_VERSION in
Chris@41 540 [12].* | 3.0 | 3.0*) ;;
Chris@41 541 *)
Chris@41 542 : ${_G_HAVE_PLUSEQ_OP="yes"}
Chris@41 543 ;;
Chris@41 544 esac
Chris@41 545 fi
Chris@41 546
Chris@41 547 # _G_HAVE_PLUSEQ_OP
Chris@41 548 # Can be empty, in which case the shell is probed, "yes" if += is
Chris@41 549 # useable or anything else if it does not work.
Chris@41 550 test -z "$_G_HAVE_PLUSEQ_OP" \
Chris@41 551 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
Chris@41 552 && _G_HAVE_PLUSEQ_OP=yes
Chris@41 553
Chris@41 554 if test yes = "$_G_HAVE_PLUSEQ_OP"
Chris@41 555 then
Chris@41 556 # This is an XSI compatible shell, allowing a faster implementation...
Chris@41 557 eval 'func_append ()
Chris@41 558 {
Chris@41 559 $debug_cmd
Chris@41 560
Chris@41 561 eval "$1+=\$2"
Chris@41 562 }'
Chris@41 563 else
Chris@41 564 # ...otherwise fall back to using expr, which is often a shell builtin.
Chris@41 565 func_append ()
Chris@41 566 {
Chris@41 567 $debug_cmd
Chris@41 568
Chris@41 569 eval "$1=\$$1\$2"
Chris@41 570 }
Chris@41 571 fi
Chris@41 572
Chris@41 573
Chris@41 574 # func_append_quoted VAR VALUE
Chris@41 575 # ----------------------------
Chris@41 576 # Quote VALUE and append to the end of shell variable VAR, separated
Chris@41 577 # by a space.
Chris@41 578 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
Chris@41 579 eval 'func_append_quoted ()
Chris@41 580 {
Chris@41 581 $debug_cmd
Chris@41 582
Chris@41 583 func_quote_for_eval "$2"
Chris@41 584 eval "$1+=\\ \$func_quote_for_eval_result"
Chris@41 585 }'
Chris@41 586 else
Chris@41 587 func_append_quoted ()
Chris@41 588 {
Chris@41 589 $debug_cmd
Chris@41 590
Chris@41 591 func_quote_for_eval "$2"
Chris@41 592 eval "$1=\$$1\\ \$func_quote_for_eval_result"
Chris@41 593 }
Chris@41 594 fi
Chris@41 595
Chris@41 596
Chris@41 597 # func_append_uniq VAR VALUE
Chris@41 598 # --------------------------
Chris@41 599 # Append unique VALUE onto the existing contents of VAR, assuming
Chris@41 600 # entries are delimited by the first character of VALUE. For example:
Chris@41 601 #
Chris@41 602 # func_append_uniq options " --another-option option-argument"
Chris@41 603 #
Chris@41 604 # will only append to $options if " --another-option option-argument "
Chris@41 605 # is not already present somewhere in $options already (note spaces at
Chris@41 606 # each end implied by leading space in second argument).
Chris@41 607 func_append_uniq ()
Chris@41 608 {
Chris@41 609 $debug_cmd
Chris@41 610
Chris@41 611 eval _G_current_value='`$ECHO $'$1'`'
Chris@41 612 _G_delim=`expr "$2" : '\(.\)'`
Chris@41 613
Chris@41 614 case $_G_delim$_G_current_value$_G_delim in
Chris@41 615 *"$2$_G_delim"*) ;;
Chris@41 616 *) func_append "$@" ;;
Chris@41 617 esac
Chris@41 618 }
Chris@41 619
Chris@41 620
Chris@41 621 # func_arith TERM...
Chris@41 622 # ------------------
Chris@41 623 # Set func_arith_result to the result of evaluating TERMs.
Chris@41 624 test -z "$_G_HAVE_ARITH_OP" \
Chris@41 625 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
Chris@41 626 && _G_HAVE_ARITH_OP=yes
Chris@41 627
Chris@41 628 if test yes = "$_G_HAVE_ARITH_OP"; then
Chris@41 629 eval 'func_arith ()
Chris@41 630 {
Chris@41 631 $debug_cmd
Chris@41 632
Chris@41 633 func_arith_result=$(( $* ))
Chris@41 634 }'
Chris@41 635 else
Chris@41 636 func_arith ()
Chris@41 637 {
Chris@41 638 $debug_cmd
Chris@41 639
Chris@41 640 func_arith_result=`expr "$@"`
Chris@41 641 }
Chris@41 642 fi
Chris@41 643
Chris@41 644
Chris@41 645 # func_basename FILE
Chris@41 646 # ------------------
Chris@41 647 # Set func_basename_result to FILE with everything up to and including
Chris@41 648 # the last / stripped.
Chris@41 649 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@41 650 # If this shell supports suffix pattern removal, then use it to avoid
Chris@41 651 # forking. Hide the definitions single quotes in case the shell chokes
Chris@41 652 # on unsupported syntax...
Chris@41 653 _b='func_basename_result=${1##*/}'
Chris@41 654 _d='case $1 in
Chris@41 655 */*) func_dirname_result=${1%/*}$2 ;;
Chris@41 656 * ) func_dirname_result=$3 ;;
Chris@41 657 esac'
Chris@41 658
Chris@41 659 else
Chris@41 660 # ...otherwise fall back to using sed.
Chris@41 661 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
Chris@41 662 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
Chris@41 663 if test "X$func_dirname_result" = "X$1"; then
Chris@41 664 func_dirname_result=$3
Chris@41 665 else
Chris@41 666 func_append func_dirname_result "$2"
Chris@41 667 fi'
Chris@41 668 fi
Chris@41 669
Chris@41 670 eval 'func_basename ()
Chris@41 671 {
Chris@41 672 $debug_cmd
Chris@41 673
Chris@41 674 '"$_b"'
Chris@41 675 }'
Chris@41 676
Chris@41 677
Chris@41 678 # func_dirname FILE APPEND NONDIR_REPLACEMENT
Chris@41 679 # -------------------------------------------
Chris@41 680 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
Chris@41 681 # otherwise set result to NONDIR_REPLACEMENT.
Chris@41 682 eval 'func_dirname ()
Chris@41 683 {
Chris@41 684 $debug_cmd
Chris@41 685
Chris@41 686 '"$_d"'
Chris@41 687 }'
Chris@41 688
Chris@41 689
Chris@41 690 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
Chris@41 691 # --------------------------------------------------------
Chris@41 692 # Perform func_basename and func_dirname in a single function
Chris@41 693 # call:
Chris@41 694 # dirname: Compute the dirname of FILE. If nonempty,
Chris@41 695 # add APPEND to the result, otherwise set result
Chris@41 696 # to NONDIR_REPLACEMENT.
Chris@41 697 # value returned in "$func_dirname_result"
Chris@41 698 # basename: Compute filename of FILE.
Chris@41 699 # value retuned in "$func_basename_result"
Chris@41 700 # For efficiency, we do not delegate to the functions above but instead
Chris@41 701 # duplicate the functionality here.
Chris@41 702 eval 'func_dirname_and_basename ()
Chris@41 703 {
Chris@41 704 $debug_cmd
Chris@41 705
Chris@41 706 '"$_b"'
Chris@41 707 '"$_d"'
Chris@41 708 }'
Chris@41 709
Chris@41 710
Chris@41 711 # func_echo ARG...
Chris@41 712 # ----------------
Chris@41 713 # Echo program name prefixed message.
Chris@41 714 func_echo ()
Chris@41 715 {
Chris@41 716 $debug_cmd
Chris@41 717
Chris@41 718 _G_message=$*
Chris@41 719
Chris@41 720 func_echo_IFS=$IFS
Chris@41 721 IFS=$nl
Chris@41 722 for _G_line in $_G_message; do
Chris@41 723 IFS=$func_echo_IFS
Chris@41 724 $ECHO "$progname: $_G_line"
Chris@41 725 done
Chris@41 726 IFS=$func_echo_IFS
Chris@41 727 }
Chris@41 728
Chris@41 729
Chris@41 730 # func_echo_all ARG...
Chris@41 731 # --------------------
Chris@41 732 # Invoke $ECHO with all args, space-separated.
Chris@41 733 func_echo_all ()
Chris@41 734 {
Chris@41 735 $ECHO "$*"
Chris@41 736 }
Chris@41 737
Chris@41 738
Chris@41 739 # func_echo_infix_1 INFIX ARG...
Chris@41 740 # ------------------------------
Chris@41 741 # Echo program name, followed by INFIX on the first line, with any
Chris@41 742 # additional lines not showing INFIX.
Chris@41 743 func_echo_infix_1 ()
Chris@41 744 {
Chris@41 745 $debug_cmd
Chris@41 746
Chris@41 747 $require_term_colors
Chris@41 748
Chris@41 749 _G_infix=$1; shift
Chris@41 750 _G_indent=$_G_infix
Chris@41 751 _G_prefix="$progname: $_G_infix: "
Chris@41 752 _G_message=$*
Chris@41 753
Chris@41 754 # Strip color escape sequences before counting printable length
Chris@41 755 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
Chris@41 756 do
Chris@41 757 test -n "$_G_tc" && {
Chris@41 758 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
Chris@41 759 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
Chris@41 760 }
Chris@41 761 done
Chris@41 762 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
Chris@41 763
Chris@41 764 func_echo_infix_1_IFS=$IFS
Chris@41 765 IFS=$nl
Chris@41 766 for _G_line in $_G_message; do
Chris@41 767 IFS=$func_echo_infix_1_IFS
Chris@41 768 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
Chris@41 769 _G_prefix=$_G_indent
Chris@41 770 done
Chris@41 771 IFS=$func_echo_infix_1_IFS
Chris@41 772 }
Chris@41 773
Chris@41 774
Chris@41 775 # func_error ARG...
Chris@41 776 # -----------------
Chris@41 777 # Echo program name prefixed message to standard error.
Chris@41 778 func_error ()
Chris@41 779 {
Chris@41 780 $debug_cmd
Chris@41 781
Chris@41 782 $require_term_colors
Chris@41 783
Chris@41 784 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
Chris@41 785 }
Chris@41 786
Chris@41 787
Chris@41 788 # func_fatal_error ARG...
Chris@41 789 # -----------------------
Chris@41 790 # Echo program name prefixed message to standard error, and exit.
Chris@41 791 func_fatal_error ()
Chris@41 792 {
Chris@41 793 $debug_cmd
Chris@41 794
Chris@41 795 func_error "$*"
Chris@41 796 exit $EXIT_FAILURE
Chris@41 797 }
Chris@41 798
Chris@41 799
Chris@41 800 # func_grep EXPRESSION FILENAME
Chris@41 801 # -----------------------------
Chris@41 802 # Check whether EXPRESSION matches any line of FILENAME, without output.
Chris@41 803 func_grep ()
Chris@41 804 {
Chris@41 805 $debug_cmd
Chris@41 806
Chris@41 807 $GREP "$1" "$2" >/dev/null 2>&1
Chris@41 808 }
Chris@41 809
Chris@41 810
Chris@41 811 # func_len STRING
Chris@41 812 # ---------------
Chris@41 813 # Set func_len_result to the length of STRING. STRING may not
Chris@41 814 # start with a hyphen.
Chris@41 815 test -z "$_G_HAVE_XSI_OPS" \
Chris@41 816 && (eval 'x=a/b/c;
Chris@41 817 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
Chris@41 818 && _G_HAVE_XSI_OPS=yes
Chris@41 819
Chris@41 820 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@41 821 eval 'func_len ()
Chris@41 822 {
Chris@41 823 $debug_cmd
Chris@41 824
Chris@41 825 func_len_result=${#1}
Chris@41 826 }'
Chris@41 827 else
Chris@41 828 func_len ()
Chris@41 829 {
Chris@41 830 $debug_cmd
Chris@41 831
Chris@41 832 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
Chris@41 833 }
Chris@41 834 fi
Chris@41 835
Chris@41 836
Chris@41 837 # func_mkdir_p DIRECTORY-PATH
Chris@41 838 # ---------------------------
Chris@41 839 # Make sure the entire path to DIRECTORY-PATH is available.
Chris@41 840 func_mkdir_p ()
Chris@41 841 {
Chris@41 842 $debug_cmd
Chris@41 843
Chris@41 844 _G_directory_path=$1
Chris@41 845 _G_dir_list=
Chris@41 846
Chris@41 847 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
Chris@41 848
Chris@41 849 # Protect directory names starting with '-'
Chris@41 850 case $_G_directory_path in
Chris@41 851 -*) _G_directory_path=./$_G_directory_path ;;
Chris@41 852 esac
Chris@41 853
Chris@41 854 # While some portion of DIR does not yet exist...
Chris@41 855 while test ! -d "$_G_directory_path"; do
Chris@41 856 # ...make a list in topmost first order. Use a colon delimited
Chris@41 857 # list incase some portion of path contains whitespace.
Chris@41 858 _G_dir_list=$_G_directory_path:$_G_dir_list
Chris@41 859
Chris@41 860 # If the last portion added has no slash in it, the list is done
Chris@41 861 case $_G_directory_path in */*) ;; *) break ;; esac
Chris@41 862
Chris@41 863 # ...otherwise throw away the child directory and loop
Chris@41 864 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
Chris@41 865 done
Chris@41 866 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
Chris@41 867
Chris@41 868 func_mkdir_p_IFS=$IFS; IFS=:
Chris@41 869 for _G_dir in $_G_dir_list; do
Chris@41 870 IFS=$func_mkdir_p_IFS
Chris@41 871 # mkdir can fail with a 'File exist' error if two processes
Chris@41 872 # try to create one of the directories concurrently. Don't
Chris@41 873 # stop in that case!
Chris@41 874 $MKDIR "$_G_dir" 2>/dev/null || :
Chris@41 875 done
Chris@41 876 IFS=$func_mkdir_p_IFS
Chris@41 877
Chris@41 878 # Bail out if we (or some other process) failed to create a directory.
Chris@41 879 test -d "$_G_directory_path" || \
Chris@41 880 func_fatal_error "Failed to create '$1'"
Chris@41 881 fi
Chris@41 882 }
Chris@41 883
Chris@41 884
Chris@41 885 # func_mktempdir [BASENAME]
Chris@41 886 # -------------------------
Chris@41 887 # Make a temporary directory that won't clash with other running
Chris@41 888 # libtool processes, and avoids race conditions if possible. If
Chris@41 889 # given, BASENAME is the basename for that directory.
Chris@41 890 func_mktempdir ()
Chris@41 891 {
Chris@41 892 $debug_cmd
Chris@41 893
Chris@41 894 _G_template=${TMPDIR-/tmp}/${1-$progname}
Chris@41 895
Chris@41 896 if test : = "$opt_dry_run"; then
Chris@41 897 # Return a directory name, but don't create it in dry-run mode
Chris@41 898 _G_tmpdir=$_G_template-$$
Chris@41 899 else
Chris@41 900
Chris@41 901 # If mktemp works, use that first and foremost
Chris@41 902 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
Chris@41 903
Chris@41 904 if test ! -d "$_G_tmpdir"; then
Chris@41 905 # Failing that, at least try and use $RANDOM to avoid a race
Chris@41 906 _G_tmpdir=$_G_template-${RANDOM-0}$$
Chris@41 907
Chris@41 908 func_mktempdir_umask=`umask`
Chris@41 909 umask 0077
Chris@41 910 $MKDIR "$_G_tmpdir"
Chris@41 911 umask $func_mktempdir_umask
Chris@41 912 fi
Chris@41 913
Chris@41 914 # If we're not in dry-run mode, bomb out on failure
Chris@41 915 test -d "$_G_tmpdir" || \
Chris@41 916 func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
Chris@41 917 fi
Chris@41 918
Chris@41 919 $ECHO "$_G_tmpdir"
Chris@41 920 }
Chris@41 921
Chris@41 922
Chris@41 923 # func_normal_abspath PATH
Chris@41 924 # ------------------------
Chris@41 925 # Remove doubled-up and trailing slashes, "." path components,
Chris@41 926 # and cancel out any ".." path components in PATH after making
Chris@41 927 # it an absolute path.
Chris@41 928 func_normal_abspath ()
Chris@41 929 {
Chris@41 930 $debug_cmd
Chris@41 931
Chris@41 932 # These SED scripts presuppose an absolute path with a trailing slash.
Chris@41 933 _G_pathcar='s|^/\([^/]*\).*$|\1|'
Chris@41 934 _G_pathcdr='s|^/[^/]*||'
Chris@41 935 _G_removedotparts=':dotsl
Chris@41 936 s|/\./|/|g
Chris@41 937 t dotsl
Chris@41 938 s|/\.$|/|'
Chris@41 939 _G_collapseslashes='s|/\{1,\}|/|g'
Chris@41 940 _G_finalslash='s|/*$|/|'
Chris@41 941
Chris@41 942 # Start from root dir and reassemble the path.
Chris@41 943 func_normal_abspath_result=
Chris@41 944 func_normal_abspath_tpath=$1
Chris@41 945 func_normal_abspath_altnamespace=
Chris@41 946 case $func_normal_abspath_tpath in
Chris@41 947 "")
Chris@41 948 # Empty path, that just means $cwd.
Chris@41 949 func_stripname '' '/' "`pwd`"
Chris@41 950 func_normal_abspath_result=$func_stripname_result
Chris@41 951 return
Chris@41 952 ;;
Chris@41 953 # The next three entries are used to spot a run of precisely
Chris@41 954 # two leading slashes without using negated character classes;
Chris@41 955 # we take advantage of case's first-match behaviour.
Chris@41 956 ///*)
Chris@41 957 # Unusual form of absolute path, do nothing.
Chris@41 958 ;;
Chris@41 959 //*)
Chris@41 960 # Not necessarily an ordinary path; POSIX reserves leading '//'
Chris@41 961 # and for example Cygwin uses it to access remote file shares
Chris@41 962 # over CIFS/SMB, so we conserve a leading double slash if found.
Chris@41 963 func_normal_abspath_altnamespace=/
Chris@41 964 ;;
Chris@41 965 /*)
Chris@41 966 # Absolute path, do nothing.
Chris@41 967 ;;
Chris@41 968 *)
Chris@41 969 # Relative path, prepend $cwd.
Chris@41 970 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
Chris@41 971 ;;
Chris@41 972 esac
Chris@41 973
Chris@41 974 # Cancel out all the simple stuff to save iterations. We also want
Chris@41 975 # the path to end with a slash for ease of parsing, so make sure
Chris@41 976 # there is one (and only one) here.
Chris@41 977 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
Chris@41 978 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
Chris@41 979 while :; do
Chris@41 980 # Processed it all yet?
Chris@41 981 if test / = "$func_normal_abspath_tpath"; then
Chris@41 982 # If we ascended to the root using ".." the result may be empty now.
Chris@41 983 if test -z "$func_normal_abspath_result"; then
Chris@41 984 func_normal_abspath_result=/
Chris@41 985 fi
Chris@41 986 break
Chris@41 987 fi
Chris@41 988 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
Chris@41 989 -e "$_G_pathcar"`
Chris@41 990 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
Chris@41 991 -e "$_G_pathcdr"`
Chris@41 992 # Figure out what to do with it
Chris@41 993 case $func_normal_abspath_tcomponent in
Chris@41 994 "")
Chris@41 995 # Trailing empty path component, ignore it.
Chris@41 996 ;;
Chris@41 997 ..)
Chris@41 998 # Parent dir; strip last assembled component from result.
Chris@41 999 func_dirname "$func_normal_abspath_result"
Chris@41 1000 func_normal_abspath_result=$func_dirname_result
Chris@41 1001 ;;
Chris@41 1002 *)
Chris@41 1003 # Actual path component, append it.
Chris@41 1004 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
Chris@41 1005 ;;
Chris@41 1006 esac
Chris@41 1007 done
Chris@41 1008 # Restore leading double-slash if one was found on entry.
Chris@41 1009 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
Chris@41 1010 }
Chris@41 1011
Chris@41 1012
Chris@41 1013 # func_notquiet ARG...
Chris@41 1014 # --------------------
Chris@41 1015 # Echo program name prefixed message only when not in quiet mode.
Chris@41 1016 func_notquiet ()
Chris@41 1017 {
Chris@41 1018 $debug_cmd
Chris@41 1019
Chris@41 1020 $opt_quiet || func_echo ${1+"$@"}
Chris@41 1021
Chris@41 1022 # A bug in bash halts the script if the last line of a function
Chris@41 1023 # fails when set -e is in force, so we need another command to
Chris@41 1024 # work around that:
Chris@41 1025 :
Chris@41 1026 }
Chris@41 1027
Chris@41 1028
Chris@41 1029 # func_relative_path SRCDIR DSTDIR
Chris@41 1030 # --------------------------------
Chris@41 1031 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
Chris@41 1032 func_relative_path ()
Chris@41 1033 {
Chris@41 1034 $debug_cmd
Chris@41 1035
Chris@41 1036 func_relative_path_result=
Chris@41 1037 func_normal_abspath "$1"
Chris@41 1038 func_relative_path_tlibdir=$func_normal_abspath_result
Chris@41 1039 func_normal_abspath "$2"
Chris@41 1040 func_relative_path_tbindir=$func_normal_abspath_result
Chris@41 1041
Chris@41 1042 # Ascend the tree starting from libdir
Chris@41 1043 while :; do
Chris@41 1044 # check if we have found a prefix of bindir
Chris@41 1045 case $func_relative_path_tbindir in
Chris@41 1046 $func_relative_path_tlibdir)
Chris@41 1047 # found an exact match
Chris@41 1048 func_relative_path_tcancelled=
Chris@41 1049 break
Chris@41 1050 ;;
Chris@41 1051 $func_relative_path_tlibdir*)
Chris@41 1052 # found a matching prefix
Chris@41 1053 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
Chris@41 1054 func_relative_path_tcancelled=$func_stripname_result
Chris@41 1055 if test -z "$func_relative_path_result"; then
Chris@41 1056 func_relative_path_result=.
Chris@41 1057 fi
Chris@41 1058 break
Chris@41 1059 ;;
Chris@41 1060 *)
Chris@41 1061 func_dirname $func_relative_path_tlibdir
Chris@41 1062 func_relative_path_tlibdir=$func_dirname_result
Chris@41 1063 if test -z "$func_relative_path_tlibdir"; then
Chris@41 1064 # Have to descend all the way to the root!
Chris@41 1065 func_relative_path_result=../$func_relative_path_result
Chris@41 1066 func_relative_path_tcancelled=$func_relative_path_tbindir
Chris@41 1067 break
Chris@41 1068 fi
Chris@41 1069 func_relative_path_result=../$func_relative_path_result
Chris@41 1070 ;;
Chris@41 1071 esac
Chris@41 1072 done
Chris@41 1073
Chris@41 1074 # Now calculate path; take care to avoid doubling-up slashes.
Chris@41 1075 func_stripname '' '/' "$func_relative_path_result"
Chris@41 1076 func_relative_path_result=$func_stripname_result
Chris@41 1077 func_stripname '/' '/' "$func_relative_path_tcancelled"
Chris@41 1078 if test -n "$func_stripname_result"; then
Chris@41 1079 func_append func_relative_path_result "/$func_stripname_result"
Chris@41 1080 fi
Chris@41 1081
Chris@41 1082 # Normalisation. If bindir is libdir, return '.' else relative path.
Chris@41 1083 if test -n "$func_relative_path_result"; then
Chris@41 1084 func_stripname './' '' "$func_relative_path_result"
Chris@41 1085 func_relative_path_result=$func_stripname_result
Chris@41 1086 fi
Chris@41 1087
Chris@41 1088 test -n "$func_relative_path_result" || func_relative_path_result=.
Chris@41 1089
Chris@41 1090 :
Chris@41 1091 }
Chris@41 1092
Chris@41 1093
Chris@41 1094 # func_quote_for_eval ARG...
Chris@41 1095 # --------------------------
Chris@41 1096 # Aesthetically quote ARGs to be evaled later.
Chris@41 1097 # This function returns two values:
Chris@41 1098 # i) func_quote_for_eval_result
Chris@41 1099 # double-quoted, suitable for a subsequent eval
Chris@41 1100 # ii) func_quote_for_eval_unquoted_result
Chris@41 1101 # has all characters that are still active within double
Chris@41 1102 # quotes backslashified.
Chris@41 1103 func_quote_for_eval ()
Chris@41 1104 {
Chris@41 1105 $debug_cmd
Chris@41 1106
Chris@41 1107 func_quote_for_eval_unquoted_result=
Chris@41 1108 func_quote_for_eval_result=
Chris@41 1109 while test 0 -lt $#; do
Chris@41 1110 case $1 in
Chris@41 1111 *[\\\`\"\$]*)
Chris@41 1112 _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
Chris@41 1113 *)
Chris@41 1114 _G_unquoted_arg=$1 ;;
Chris@41 1115 esac
Chris@41 1116 if test -n "$func_quote_for_eval_unquoted_result"; then
Chris@41 1117 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
Chris@41 1118 else
Chris@41 1119 func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
Chris@41 1120 fi
Chris@41 1121
Chris@41 1122 case $_G_unquoted_arg in
Chris@41 1123 # Double-quote args containing shell metacharacters to delay
Chris@41 1124 # word splitting, command substitution and variable expansion
Chris@41 1125 # for a subsequent eval.
Chris@41 1126 # Many Bourne shells cannot handle close brackets correctly
Chris@41 1127 # in scan sets, so we specify it separately.
Chris@41 1128 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
Chris@41 1129 _G_quoted_arg=\"$_G_unquoted_arg\"
Chris@41 1130 ;;
Chris@41 1131 *)
Chris@41 1132 _G_quoted_arg=$_G_unquoted_arg
Chris@41 1133 ;;
Chris@41 1134 esac
Chris@41 1135
Chris@41 1136 if test -n "$func_quote_for_eval_result"; then
Chris@41 1137 func_append func_quote_for_eval_result " $_G_quoted_arg"
Chris@41 1138 else
Chris@41 1139 func_append func_quote_for_eval_result "$_G_quoted_arg"
Chris@41 1140 fi
Chris@41 1141 shift
Chris@41 1142 done
Chris@41 1143 }
Chris@41 1144
Chris@41 1145
Chris@41 1146 # func_quote_for_expand ARG
Chris@41 1147 # -------------------------
Chris@41 1148 # Aesthetically quote ARG to be evaled later; same as above,
Chris@41 1149 # but do not quote variable references.
Chris@41 1150 func_quote_for_expand ()
Chris@41 1151 {
Chris@41 1152 $debug_cmd
Chris@41 1153
Chris@41 1154 case $1 in
Chris@41 1155 *[\\\`\"]*)
Chris@41 1156 _G_arg=`$ECHO "$1" | $SED \
Chris@41 1157 -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
Chris@41 1158 *)
Chris@41 1159 _G_arg=$1 ;;
Chris@41 1160 esac
Chris@41 1161
Chris@41 1162 case $_G_arg in
Chris@41 1163 # Double-quote args containing shell metacharacters to delay
Chris@41 1164 # word splitting and command substitution for a subsequent eval.
Chris@41 1165 # Many Bourne shells cannot handle close brackets correctly
Chris@41 1166 # in scan sets, so we specify it separately.
Chris@41 1167 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
Chris@41 1168 _G_arg=\"$_G_arg\"
Chris@41 1169 ;;
Chris@41 1170 esac
Chris@41 1171
Chris@41 1172 func_quote_for_expand_result=$_G_arg
Chris@41 1173 }
Chris@41 1174
Chris@41 1175
Chris@41 1176 # func_stripname PREFIX SUFFIX NAME
Chris@41 1177 # ---------------------------------
Chris@41 1178 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
Chris@41 1179 # PREFIX and SUFFIX must not contain globbing or regex special
Chris@41 1180 # characters, hashes, percent signs, but SUFFIX may contain a leading
Chris@41 1181 # dot (in which case that matches only a dot).
Chris@41 1182 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@41 1183 eval 'func_stripname ()
Chris@41 1184 {
Chris@41 1185 $debug_cmd
Chris@41 1186
Chris@41 1187 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
Chris@41 1188 # positional parameters, so assign one to ordinary variable first.
Chris@41 1189 func_stripname_result=$3
Chris@41 1190 func_stripname_result=${func_stripname_result#"$1"}
Chris@41 1191 func_stripname_result=${func_stripname_result%"$2"}
Chris@41 1192 }'
Chris@41 1193 else
Chris@41 1194 func_stripname ()
Chris@41 1195 {
Chris@41 1196 $debug_cmd
Chris@41 1197
Chris@41 1198 case $2 in
Chris@41 1199 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
Chris@41 1200 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
Chris@41 1201 esac
Chris@41 1202 }
Chris@41 1203 fi
Chris@41 1204
Chris@41 1205
Chris@41 1206 # func_show_eval CMD [FAIL_EXP]
Chris@41 1207 # -----------------------------
Chris@41 1208 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
Chris@41 1209 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
Chris@41 1210 # is given, then evaluate it.
Chris@41 1211 func_show_eval ()
Chris@41 1212 {
Chris@41 1213 $debug_cmd
Chris@41 1214
Chris@41 1215 _G_cmd=$1
Chris@41 1216 _G_fail_exp=${2-':'}
Chris@41 1217
Chris@41 1218 func_quote_for_expand "$_G_cmd"
Chris@41 1219 eval "func_notquiet $func_quote_for_expand_result"
Chris@41 1220
Chris@41 1221 $opt_dry_run || {
Chris@41 1222 eval "$_G_cmd"
Chris@41 1223 _G_status=$?
Chris@41 1224 if test 0 -ne "$_G_status"; then
Chris@41 1225 eval "(exit $_G_status); $_G_fail_exp"
Chris@41 1226 fi
Chris@41 1227 }
Chris@41 1228 }
Chris@41 1229
Chris@41 1230
Chris@41 1231 # func_show_eval_locale CMD [FAIL_EXP]
Chris@41 1232 # ------------------------------------
Chris@41 1233 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
Chris@41 1234 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
Chris@41 1235 # is given, then evaluate it. Use the saved locale for evaluation.
Chris@41 1236 func_show_eval_locale ()
Chris@41 1237 {
Chris@41 1238 $debug_cmd
Chris@41 1239
Chris@41 1240 _G_cmd=$1
Chris@41 1241 _G_fail_exp=${2-':'}
Chris@41 1242
Chris@41 1243 $opt_quiet || {
Chris@41 1244 func_quote_for_expand "$_G_cmd"
Chris@41 1245 eval "func_echo $func_quote_for_expand_result"
Chris@41 1246 }
Chris@41 1247
Chris@41 1248 $opt_dry_run || {
Chris@41 1249 eval "$_G_user_locale
Chris@41 1250 $_G_cmd"
Chris@41 1251 _G_status=$?
Chris@41 1252 eval "$_G_safe_locale"
Chris@41 1253 if test 0 -ne "$_G_status"; then
Chris@41 1254 eval "(exit $_G_status); $_G_fail_exp"
Chris@41 1255 fi
Chris@41 1256 }
Chris@41 1257 }
Chris@41 1258
Chris@41 1259
Chris@41 1260 # func_tr_sh
Chris@41 1261 # ----------
Chris@41 1262 # Turn $1 into a string suitable for a shell variable name.
Chris@41 1263 # Result is stored in $func_tr_sh_result. All characters
Chris@41 1264 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
Chris@41 1265 # if $1 begins with a digit, a '_' is prepended as well.
Chris@41 1266 func_tr_sh ()
Chris@41 1267 {
Chris@41 1268 $debug_cmd
Chris@41 1269
Chris@41 1270 case $1 in
Chris@41 1271 [0-9]* | *[!a-zA-Z0-9_]*)
Chris@41 1272 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
Chris@41 1273 ;;
Chris@41 1274 * )
Chris@41 1275 func_tr_sh_result=$1
Chris@41 1276 ;;
Chris@41 1277 esac
Chris@41 1278 }
Chris@41 1279
Chris@41 1280
Chris@41 1281 # func_verbose ARG...
Chris@41 1282 # -------------------
Chris@41 1283 # Echo program name prefixed message in verbose mode only.
Chris@41 1284 func_verbose ()
Chris@41 1285 {
Chris@41 1286 $debug_cmd
Chris@41 1287
Chris@41 1288 $opt_verbose && func_echo "$*"
Chris@41 1289
Chris@41 1290 :
Chris@41 1291 }
Chris@41 1292
Chris@41 1293
Chris@41 1294 # func_warn_and_continue ARG...
Chris@41 1295 # -----------------------------
Chris@41 1296 # Echo program name prefixed warning message to standard error.
Chris@41 1297 func_warn_and_continue ()
Chris@41 1298 {
Chris@41 1299 $debug_cmd
Chris@41 1300
Chris@41 1301 $require_term_colors
Chris@41 1302
Chris@41 1303 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
Chris@41 1304 }
Chris@41 1305
Chris@41 1306
Chris@41 1307 # func_warning CATEGORY ARG...
Chris@41 1308 # ----------------------------
Chris@41 1309 # Echo program name prefixed warning message to standard error. Warning
Chris@41 1310 # messages can be filtered according to CATEGORY, where this function
Chris@41 1311 # elides messages where CATEGORY is not listed in the global variable
Chris@41 1312 # 'opt_warning_types'.
Chris@41 1313 func_warning ()
Chris@41 1314 {
Chris@41 1315 $debug_cmd
Chris@41 1316
Chris@41 1317 # CATEGORY must be in the warning_categories list!
Chris@41 1318 case " $warning_categories " in
Chris@41 1319 *" $1 "*) ;;
Chris@41 1320 *) func_internal_error "invalid warning category '$1'" ;;
Chris@41 1321 esac
Chris@41 1322
Chris@41 1323 _G_category=$1
Chris@41 1324 shift
Chris@41 1325
Chris@41 1326 case " $opt_warning_types " in
Chris@41 1327 *" $_G_category "*) $warning_func ${1+"$@"} ;;
Chris@41 1328 esac
Chris@41 1329 }
Chris@41 1330
Chris@41 1331
Chris@41 1332 # func_sort_ver VER1 VER2
Chris@41 1333 # -----------------------
Chris@41 1334 # 'sort -V' is not generally available.
Chris@41 1335 # Note this deviates from the version comparison in automake
Chris@41 1336 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
Chris@41 1337 # but this should suffice as we won't be specifying old
Chris@41 1338 # version formats or redundant trailing .0 in bootstrap.conf.
Chris@41 1339 # If we did want full compatibility then we should probably
Chris@41 1340 # use m4_version_compare from autoconf.
Chris@41 1341 func_sort_ver ()
Chris@41 1342 {
Chris@41 1343 $debug_cmd
Chris@41 1344
Chris@41 1345 printf '%s\n%s\n' "$1" "$2" \
Chris@41 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@41 1347 }
Chris@41 1348
Chris@41 1349 # func_lt_ver PREV CURR
Chris@41 1350 # ---------------------
Chris@41 1351 # Return true if PREV and CURR are in the correct order according to
Chris@41 1352 # func_sort_ver, otherwise false. Use it like this:
Chris@41 1353 #
Chris@41 1354 # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
Chris@41 1355 func_lt_ver ()
Chris@41 1356 {
Chris@41 1357 $debug_cmd
Chris@41 1358
Chris@41 1359 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
Chris@41 1360 }
Chris@41 1361
Chris@41 1362
Chris@41 1363 # Local variables:
Chris@41 1364 # mode: shell-script
Chris@41 1365 # sh-indentation: 2
Chris@41 1366 # eval: (add-hook 'before-save-hook 'time-stamp)
Chris@41 1367 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
Chris@41 1368 # time-stamp-time-zone: "UTC"
Chris@41 1369 # End:
Chris@41 1370 #! /bin/sh
Chris@41 1371
Chris@41 1372 # Set a version string for this script.
Chris@41 1373 scriptversion=2014-01-07.03; # UTC
Chris@41 1374
Chris@41 1375 # A portable, pluggable option parser for Bourne shell.
Chris@41 1376 # Written by Gary V. Vaughan, 2010
Chris@41 1377
Chris@41 1378 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
Chris@41 1379 # This is free software; see the source for copying conditions. There is NO
Chris@41 1380 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chris@41 1381
Chris@41 1382 # This program is free software: you can redistribute it and/or modify
Chris@41 1383 # it under the terms of the GNU General Public License as published by
Chris@41 1384 # the Free Software Foundation, either version 3 of the License, or
Chris@41 1385 # (at your option) any later version.
Chris@41 1386
Chris@41 1387 # This program is distributed in the hope that it will be useful,
Chris@41 1388 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@41 1389 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@41 1390 # GNU General Public License for more details.
Chris@41 1391
Chris@41 1392 # You should have received a copy of the GNU General Public License
Chris@41 1393 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@41 1394
Chris@41 1395 # Please report bugs or propose patches to gary@gnu.org.
Chris@41 1396
Chris@41 1397
Chris@41 1398 ## ------ ##
Chris@41 1399 ## Usage. ##
Chris@41 1400 ## ------ ##
Chris@41 1401
Chris@41 1402 # This file is a library for parsing options in your shell scripts along
Chris@41 1403 # with assorted other useful supporting features that you can make use
Chris@41 1404 # of too.
Chris@41 1405 #
Chris@41 1406 # For the simplest scripts you might need only:
Chris@41 1407 #
Chris@41 1408 # #!/bin/sh
Chris@41 1409 # . relative/path/to/funclib.sh
Chris@41 1410 # . relative/path/to/options-parser
Chris@41 1411 # scriptversion=1.0
Chris@41 1412 # func_options ${1+"$@"}
Chris@41 1413 # eval set dummy "$func_options_result"; shift
Chris@41 1414 # ...rest of your script...
Chris@41 1415 #
Chris@41 1416 # In order for the '--version' option to work, you will need to have a
Chris@41 1417 # suitably formatted comment like the one at the top of this file
Chris@41 1418 # starting with '# Written by ' and ending with '# warranty; '.
Chris@41 1419 #
Chris@41 1420 # For '-h' and '--help' to work, you will also need a one line
Chris@41 1421 # description of your script's purpose in a comment directly above the
Chris@41 1422 # '# Written by ' line, like the one at the top of this file.
Chris@41 1423 #
Chris@41 1424 # The default options also support '--debug', which will turn on shell
Chris@41 1425 # execution tracing (see the comment above debug_cmd below for another
Chris@41 1426 # use), and '--verbose' and the func_verbose function to allow your script
Chris@41 1427 # to display verbose messages only when your user has specified
Chris@41 1428 # '--verbose'.
Chris@41 1429 #
Chris@41 1430 # After sourcing this file, you can plug processing for additional
Chris@41 1431 # options by amending the variables from the 'Configuration' section
Chris@41 1432 # below, and following the instructions in the 'Option parsing'
Chris@41 1433 # section further down.
Chris@41 1434
Chris@41 1435 ## -------------- ##
Chris@41 1436 ## Configuration. ##
Chris@41 1437 ## -------------- ##
Chris@41 1438
Chris@41 1439 # You should override these variables in your script after sourcing this
Chris@41 1440 # file so that they reflect the customisations you have added to the
Chris@41 1441 # option parser.
Chris@41 1442
Chris@41 1443 # The usage line for option parsing errors and the start of '-h' and
Chris@41 1444 # '--help' output messages. You can embed shell variables for delayed
Chris@41 1445 # expansion at the time the message is displayed, but you will need to
Chris@41 1446 # quote other shell meta-characters carefully to prevent them being
Chris@41 1447 # expanded when the contents are evaled.
Chris@41 1448 usage='$progpath [OPTION]...'
Chris@41 1449
Chris@41 1450 # Short help message in response to '-h' and '--help'. Add to this or
Chris@41 1451 # override it after sourcing this library to reflect the full set of
Chris@41 1452 # options your script accepts.
Chris@41 1453 usage_message="\
Chris@41 1454 --debug enable verbose shell tracing
Chris@41 1455 -W, --warnings=CATEGORY
Chris@41 1456 report the warnings falling in CATEGORY [all]
Chris@41 1457 -v, --verbose verbosely report processing
Chris@41 1458 --version print version information and exit
Chris@41 1459 -h, --help print short or long help message and exit
Chris@41 1460 "
Chris@41 1461
Chris@41 1462 # Additional text appended to 'usage_message' in response to '--help'.
Chris@41 1463 long_help_message="
Chris@41 1464 Warning categories include:
Chris@41 1465 'all' show all warnings
Chris@41 1466 'none' turn off all the warnings
Chris@41 1467 'error' warnings are treated as fatal errors"
Chris@41 1468
Chris@41 1469 # Help message printed before fatal option parsing errors.
Chris@41 1470 fatal_help="Try '\$progname --help' for more information."
Chris@41 1471
Chris@41 1472
Chris@41 1473
Chris@41 1474 ## ------------------------- ##
Chris@41 1475 ## Hook function management. ##
Chris@41 1476 ## ------------------------- ##
Chris@41 1477
Chris@41 1478 # This section contains functions for adding, removing, and running hooks
Chris@41 1479 # to the main code. A hook is just a named list of of function, that can
Chris@41 1480 # be run in order later on.
Chris@41 1481
Chris@41 1482 # func_hookable FUNC_NAME
Chris@41 1483 # -----------------------
Chris@41 1484 # Declare that FUNC_NAME will run hooks added with
Chris@41 1485 # 'func_add_hook FUNC_NAME ...'.
Chris@41 1486 func_hookable ()
Chris@41 1487 {
Chris@41 1488 $debug_cmd
Chris@41 1489
Chris@41 1490 func_append hookable_fns " $1"
Chris@41 1491 }
Chris@41 1492
Chris@41 1493
Chris@41 1494 # func_add_hook FUNC_NAME HOOK_FUNC
Chris@41 1495 # ---------------------------------
Chris@41 1496 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
Chris@41 1497 # first have been declared "hookable" by a call to 'func_hookable'.
Chris@41 1498 func_add_hook ()
Chris@41 1499 {
Chris@41 1500 $debug_cmd
Chris@41 1501
Chris@41 1502 case " $hookable_fns " in
Chris@41 1503 *" $1 "*) ;;
Chris@41 1504 *) func_fatal_error "'$1' does not accept hook functions." ;;
Chris@41 1505 esac
Chris@41 1506
Chris@41 1507 eval func_append ${1}_hooks '" $2"'
Chris@41 1508 }
Chris@41 1509
Chris@41 1510
Chris@41 1511 # func_remove_hook FUNC_NAME HOOK_FUNC
Chris@41 1512 # ------------------------------------
Chris@41 1513 # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
Chris@41 1514 func_remove_hook ()
Chris@41 1515 {
Chris@41 1516 $debug_cmd
Chris@41 1517
Chris@41 1518 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
Chris@41 1519 }
Chris@41 1520
Chris@41 1521
Chris@41 1522 # func_run_hooks FUNC_NAME [ARG]...
Chris@41 1523 # ---------------------------------
Chris@41 1524 # Run all hook functions registered to FUNC_NAME.
Chris@41 1525 # It is assumed that the list of hook functions contains nothing more
Chris@41 1526 # than a whitespace-delimited list of legal shell function names, and
Chris@41 1527 # no effort is wasted trying to catch shell meta-characters or preserve
Chris@41 1528 # whitespace.
Chris@41 1529 func_run_hooks ()
Chris@41 1530 {
Chris@41 1531 $debug_cmd
Chris@41 1532
Chris@41 1533 case " $hookable_fns " in
Chris@41 1534 *" $1 "*) ;;
Chris@41 1535 *) func_fatal_error "'$1' does not support hook funcions.n" ;;
Chris@41 1536 esac
Chris@41 1537
Chris@41 1538 eval _G_hook_fns=\$$1_hooks; shift
Chris@41 1539
Chris@41 1540 for _G_hook in $_G_hook_fns; do
Chris@41 1541 eval $_G_hook '"$@"'
Chris@41 1542
Chris@41 1543 # store returned options list back into positional
Chris@41 1544 # parameters for next 'cmd' execution.
Chris@41 1545 eval _G_hook_result=\$${_G_hook}_result
Chris@41 1546 eval set dummy "$_G_hook_result"; shift
Chris@41 1547 done
Chris@41 1548
Chris@41 1549 func_quote_for_eval ${1+"$@"}
Chris@41 1550 func_run_hooks_result=$func_quote_for_eval_result
Chris@41 1551 }
Chris@41 1552
Chris@41 1553
Chris@41 1554
Chris@41 1555 ## --------------- ##
Chris@41 1556 ## Option parsing. ##
Chris@41 1557 ## --------------- ##
Chris@41 1558
Chris@41 1559 # In order to add your own option parsing hooks, you must accept the
Chris@41 1560 # full positional parameter list in your hook function, remove any
Chris@41 1561 # options that you action, and then pass back the remaining unprocessed
Chris@41 1562 # options in '<hooked_function_name>_result', escaped suitably for
Chris@41 1563 # 'eval'. Like this:
Chris@41 1564 #
Chris@41 1565 # my_options_prep ()
Chris@41 1566 # {
Chris@41 1567 # $debug_cmd
Chris@41 1568 #
Chris@41 1569 # # Extend the existing usage message.
Chris@41 1570 # usage_message=$usage_message'
Chris@41 1571 # -s, --silent don'\''t print informational messages
Chris@41 1572 # '
Chris@41 1573 #
Chris@41 1574 # func_quote_for_eval ${1+"$@"}
Chris@41 1575 # my_options_prep_result=$func_quote_for_eval_result
Chris@41 1576 # }
Chris@41 1577 # func_add_hook func_options_prep my_options_prep
Chris@41 1578 #
Chris@41 1579 #
Chris@41 1580 # my_silent_option ()
Chris@41 1581 # {
Chris@41 1582 # $debug_cmd
Chris@41 1583 #
Chris@41 1584 # # Note that for efficiency, we parse as many options as we can
Chris@41 1585 # # recognise in a loop before passing the remainder back to the
Chris@41 1586 # # caller on the first unrecognised argument we encounter.
Chris@41 1587 # while test $# -gt 0; do
Chris@41 1588 # opt=$1; shift
Chris@41 1589 # case $opt in
Chris@41 1590 # --silent|-s) opt_silent=: ;;
Chris@41 1591 # # Separate non-argument short options:
Chris@41 1592 # -s*) func_split_short_opt "$_G_opt"
Chris@41 1593 # set dummy "$func_split_short_opt_name" \
Chris@41 1594 # "-$func_split_short_opt_arg" ${1+"$@"}
Chris@41 1595 # shift
Chris@41 1596 # ;;
Chris@41 1597 # *) set dummy "$_G_opt" "$*"; shift; break ;;
Chris@41 1598 # esac
Chris@41 1599 # done
Chris@41 1600 #
Chris@41 1601 # func_quote_for_eval ${1+"$@"}
Chris@41 1602 # my_silent_option_result=$func_quote_for_eval_result
Chris@41 1603 # }
Chris@41 1604 # func_add_hook func_parse_options my_silent_option
Chris@41 1605 #
Chris@41 1606 #
Chris@41 1607 # my_option_validation ()
Chris@41 1608 # {
Chris@41 1609 # $debug_cmd
Chris@41 1610 #
Chris@41 1611 # $opt_silent && $opt_verbose && func_fatal_help "\
Chris@41 1612 # '--silent' and '--verbose' options are mutually exclusive."
Chris@41 1613 #
Chris@41 1614 # func_quote_for_eval ${1+"$@"}
Chris@41 1615 # my_option_validation_result=$func_quote_for_eval_result
Chris@41 1616 # }
Chris@41 1617 # func_add_hook func_validate_options my_option_validation
Chris@41 1618 #
Chris@41 1619 # You'll alse need to manually amend $usage_message to reflect the extra
Chris@41 1620 # options you parse. It's preferable to append if you can, so that
Chris@41 1621 # multiple option parsing hooks can be added safely.
Chris@41 1622
Chris@41 1623
Chris@41 1624 # func_options [ARG]...
Chris@41 1625 # ---------------------
Chris@41 1626 # All the functions called inside func_options are hookable. See the
Chris@41 1627 # individual implementations for details.
Chris@41 1628 func_hookable func_options
Chris@41 1629 func_options ()
Chris@41 1630 {
Chris@41 1631 $debug_cmd
Chris@41 1632
Chris@41 1633 func_options_prep ${1+"$@"}
Chris@41 1634 eval func_parse_options \
Chris@41 1635 ${func_options_prep_result+"$func_options_prep_result"}
Chris@41 1636 eval func_validate_options \
Chris@41 1637 ${func_parse_options_result+"$func_parse_options_result"}
Chris@41 1638
Chris@41 1639 eval func_run_hooks func_options \
Chris@41 1640 ${func_validate_options_result+"$func_validate_options_result"}
Chris@41 1641
Chris@41 1642 # save modified positional parameters for caller
Chris@41 1643 func_options_result=$func_run_hooks_result
Chris@41 1644 }
Chris@41 1645
Chris@41 1646
Chris@41 1647 # func_options_prep [ARG]...
Chris@41 1648 # --------------------------
Chris@41 1649 # All initialisations required before starting the option parse loop.
Chris@41 1650 # Note that when calling hook functions, we pass through the list of
Chris@41 1651 # positional parameters. If a hook function modifies that list, and
Chris@41 1652 # needs to propogate that back to rest of this script, then the complete
Chris@41 1653 # modified list must be put in 'func_run_hooks_result' before
Chris@41 1654 # returning.
Chris@41 1655 func_hookable func_options_prep
Chris@41 1656 func_options_prep ()
Chris@41 1657 {
Chris@41 1658 $debug_cmd
Chris@41 1659
Chris@41 1660 # Option defaults:
Chris@41 1661 opt_verbose=false
Chris@41 1662 opt_warning_types=
Chris@41 1663
Chris@41 1664 func_run_hooks func_options_prep ${1+"$@"}
Chris@41 1665
Chris@41 1666 # save modified positional parameters for caller
Chris@41 1667 func_options_prep_result=$func_run_hooks_result
Chris@41 1668 }
Chris@41 1669
Chris@41 1670
Chris@41 1671 # func_parse_options [ARG]...
Chris@41 1672 # ---------------------------
Chris@41 1673 # The main option parsing loop.
Chris@41 1674 func_hookable func_parse_options
Chris@41 1675 func_parse_options ()
Chris@41 1676 {
Chris@41 1677 $debug_cmd
Chris@41 1678
Chris@41 1679 func_parse_options_result=
Chris@41 1680
Chris@41 1681 # this just eases exit handling
Chris@41 1682 while test $# -gt 0; do
Chris@41 1683 # Defer to hook functions for initial option parsing, so they
Chris@41 1684 # get priority in the event of reusing an option name.
Chris@41 1685 func_run_hooks func_parse_options ${1+"$@"}
Chris@41 1686
Chris@41 1687 # Adjust func_parse_options positional parameters to match
Chris@41 1688 eval set dummy "$func_run_hooks_result"; shift
Chris@41 1689
Chris@41 1690 # Break out of the loop if we already parsed every option.
Chris@41 1691 test $# -gt 0 || break
Chris@41 1692
Chris@41 1693 _G_opt=$1
Chris@41 1694 shift
Chris@41 1695 case $_G_opt in
Chris@41 1696 --debug|-x) debug_cmd='set -x'
Chris@41 1697 func_echo "enabling shell trace mode"
Chris@41 1698 $debug_cmd
Chris@41 1699 ;;
Chris@41 1700
Chris@41 1701 --no-warnings|--no-warning|--no-warn)
Chris@41 1702 set dummy --warnings none ${1+"$@"}
Chris@41 1703 shift
Chris@41 1704 ;;
Chris@41 1705
Chris@41 1706 --warnings|--warning|-W)
Chris@41 1707 test $# = 0 && func_missing_arg $_G_opt && break
Chris@41 1708 case " $warning_categories $1" in
Chris@41 1709 *" $1 "*)
Chris@41 1710 # trailing space prevents matching last $1 above
Chris@41 1711 func_append_uniq opt_warning_types " $1"
Chris@41 1712 ;;
Chris@41 1713 *all)
Chris@41 1714 opt_warning_types=$warning_categories
Chris@41 1715 ;;
Chris@41 1716 *none)
Chris@41 1717 opt_warning_types=none
Chris@41 1718 warning_func=:
Chris@41 1719 ;;
Chris@41 1720 *error)
Chris@41 1721 opt_warning_types=$warning_categories
Chris@41 1722 warning_func=func_fatal_error
Chris@41 1723 ;;
Chris@41 1724 *)
Chris@41 1725 func_fatal_error \
Chris@41 1726 "unsupported warning category: '$1'"
Chris@41 1727 ;;
Chris@41 1728 esac
Chris@41 1729 shift
Chris@41 1730 ;;
Chris@41 1731
Chris@41 1732 --verbose|-v) opt_verbose=: ;;
Chris@41 1733 --version) func_version ;;
Chris@41 1734 -\?|-h) func_usage ;;
Chris@41 1735 --help) func_help ;;
Chris@41 1736
Chris@41 1737 # Separate optargs to long options (plugins may need this):
Chris@41 1738 --*=*) func_split_equals "$_G_opt"
Chris@41 1739 set dummy "$func_split_equals_lhs" \
Chris@41 1740 "$func_split_equals_rhs" ${1+"$@"}
Chris@41 1741 shift
Chris@41 1742 ;;
Chris@41 1743
Chris@41 1744 # Separate optargs to short options:
Chris@41 1745 -W*)
Chris@41 1746 func_split_short_opt "$_G_opt"
Chris@41 1747 set dummy "$func_split_short_opt_name" \
Chris@41 1748 "$func_split_short_opt_arg" ${1+"$@"}
Chris@41 1749 shift
Chris@41 1750 ;;
Chris@41 1751
Chris@41 1752 # Separate non-argument short options:
Chris@41 1753 -\?*|-h*|-v*|-x*)
Chris@41 1754 func_split_short_opt "$_G_opt"
Chris@41 1755 set dummy "$func_split_short_opt_name" \
Chris@41 1756 "-$func_split_short_opt_arg" ${1+"$@"}
Chris@41 1757 shift
Chris@41 1758 ;;
Chris@41 1759
Chris@41 1760 --) break ;;
Chris@41 1761 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
Chris@41 1762 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
Chris@41 1763 esac
Chris@41 1764 done
Chris@41 1765
Chris@41 1766 # save modified positional parameters for caller
Chris@41 1767 func_quote_for_eval ${1+"$@"}
Chris@41 1768 func_parse_options_result=$func_quote_for_eval_result
Chris@41 1769 }
Chris@41 1770
Chris@41 1771
Chris@41 1772 # func_validate_options [ARG]...
Chris@41 1773 # ------------------------------
Chris@41 1774 # Perform any sanity checks on option settings and/or unconsumed
Chris@41 1775 # arguments.
Chris@41 1776 func_hookable func_validate_options
Chris@41 1777 func_validate_options ()
Chris@41 1778 {
Chris@41 1779 $debug_cmd
Chris@41 1780
Chris@41 1781 # Display all warnings if -W was not given.
Chris@41 1782 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
Chris@41 1783
Chris@41 1784 func_run_hooks func_validate_options ${1+"$@"}
Chris@41 1785
Chris@41 1786 # Bail if the options were screwed!
Chris@41 1787 $exit_cmd $EXIT_FAILURE
Chris@41 1788
Chris@41 1789 # save modified positional parameters for caller
Chris@41 1790 func_validate_options_result=$func_run_hooks_result
Chris@41 1791 }
Chris@41 1792
Chris@41 1793
Chris@41 1794
Chris@41 1795 ## ----------------- ##
Chris@41 1796 ## Helper functions. ##
Chris@41 1797 ## ----------------- ##
Chris@41 1798
Chris@41 1799 # This section contains the helper functions used by the rest of the
Chris@41 1800 # hookable option parser framework in ascii-betical order.
Chris@41 1801
Chris@41 1802
Chris@41 1803 # func_fatal_help ARG...
Chris@41 1804 # ----------------------
Chris@41 1805 # Echo program name prefixed message to standard error, followed by
Chris@41 1806 # a help hint, and exit.
Chris@41 1807 func_fatal_help ()
Chris@41 1808 {
Chris@41 1809 $debug_cmd
Chris@41 1810
Chris@41 1811 eval \$ECHO \""Usage: $usage"\"
Chris@41 1812 eval \$ECHO \""$fatal_help"\"
Chris@41 1813 func_error ${1+"$@"}
Chris@41 1814 exit $EXIT_FAILURE
Chris@41 1815 }
Chris@41 1816
Chris@41 1817
Chris@41 1818 # func_help
Chris@41 1819 # ---------
Chris@41 1820 # Echo long help message to standard output and exit.
Chris@41 1821 func_help ()
Chris@41 1822 {
Chris@41 1823 $debug_cmd
Chris@41 1824
Chris@41 1825 func_usage_message
Chris@41 1826 $ECHO "$long_help_message"
Chris@41 1827 exit 0
Chris@41 1828 }
Chris@41 1829
Chris@41 1830
Chris@41 1831 # func_missing_arg ARGNAME
Chris@41 1832 # ------------------------
Chris@41 1833 # Echo program name prefixed message to standard error and set global
Chris@41 1834 # exit_cmd.
Chris@41 1835 func_missing_arg ()
Chris@41 1836 {
Chris@41 1837 $debug_cmd
Chris@41 1838
Chris@41 1839 func_error "Missing argument for '$1'."
Chris@41 1840 exit_cmd=exit
Chris@41 1841 }
Chris@41 1842
Chris@41 1843
Chris@41 1844 # func_split_equals STRING
Chris@41 1845 # ------------------------
Chris@41 1846 # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
Chris@41 1847 # splitting STRING at the '=' sign.
Chris@41 1848 test -z "$_G_HAVE_XSI_OPS" \
Chris@41 1849 && (eval 'x=a/b/c;
Chris@41 1850 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
Chris@41 1851 && _G_HAVE_XSI_OPS=yes
Chris@41 1852
Chris@41 1853 if test yes = "$_G_HAVE_XSI_OPS"
Chris@41 1854 then
Chris@41 1855 # This is an XSI compatible shell, allowing a faster implementation...
Chris@41 1856 eval 'func_split_equals ()
Chris@41 1857 {
Chris@41 1858 $debug_cmd
Chris@41 1859
Chris@41 1860 func_split_equals_lhs=${1%%=*}
Chris@41 1861 func_split_equals_rhs=${1#*=}
Chris@41 1862 test "x$func_split_equals_lhs" = "x$1" \
Chris@41 1863 && func_split_equals_rhs=
Chris@41 1864 }'
Chris@41 1865 else
Chris@41 1866 # ...otherwise fall back to using expr, which is often a shell builtin.
Chris@41 1867 func_split_equals ()
Chris@41 1868 {
Chris@41 1869 $debug_cmd
Chris@41 1870
Chris@41 1871 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
Chris@41 1872 func_split_equals_rhs=
Chris@41 1873 test "x$func_split_equals_lhs" = "x$1" \
Chris@41 1874 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
Chris@41 1875 }
Chris@41 1876 fi #func_split_equals
Chris@41 1877
Chris@41 1878
Chris@41 1879 # func_split_short_opt SHORTOPT
Chris@41 1880 # -----------------------------
Chris@41 1881 # Set func_split_short_opt_name and func_split_short_opt_arg shell
Chris@41 1882 # variables after splitting SHORTOPT after the 2nd character.
Chris@41 1883 if test yes = "$_G_HAVE_XSI_OPS"
Chris@41 1884 then
Chris@41 1885 # This is an XSI compatible shell, allowing a faster implementation...
Chris@41 1886 eval 'func_split_short_opt ()
Chris@41 1887 {
Chris@41 1888 $debug_cmd
Chris@41 1889
Chris@41 1890 func_split_short_opt_arg=${1#??}
Chris@41 1891 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
Chris@41 1892 }'
Chris@41 1893 else
Chris@41 1894 # ...otherwise fall back to using expr, which is often a shell builtin.
Chris@41 1895 func_split_short_opt ()
Chris@41 1896 {
Chris@41 1897 $debug_cmd
Chris@41 1898
Chris@41 1899 func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
Chris@41 1900 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
Chris@41 1901 }
Chris@41 1902 fi #func_split_short_opt
Chris@41 1903
Chris@41 1904
Chris@41 1905 # func_usage
Chris@41 1906 # ----------
Chris@41 1907 # Echo short help message to standard output and exit.
Chris@41 1908 func_usage ()
Chris@41 1909 {
Chris@41 1910 $debug_cmd
Chris@41 1911
Chris@41 1912 func_usage_message
Chris@41 1913 $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
Chris@41 1914 exit 0
Chris@41 1915 }
Chris@41 1916
Chris@41 1917
Chris@41 1918 # func_usage_message
Chris@41 1919 # ------------------
Chris@41 1920 # Echo short help message to standard output.
Chris@41 1921 func_usage_message ()
Chris@41 1922 {
Chris@41 1923 $debug_cmd
Chris@41 1924
Chris@41 1925 eval \$ECHO \""Usage: $usage"\"
Chris@41 1926 echo
Chris@41 1927 $SED -n 's|^# ||
Chris@41 1928 /^Written by/{
Chris@41 1929 x;p;x
Chris@41 1930 }
Chris@41 1931 h
Chris@41 1932 /^Written by/q' < "$progpath"
Chris@41 1933 echo
Chris@41 1934 eval \$ECHO \""$usage_message"\"
Chris@41 1935 }
Chris@41 1936
Chris@41 1937
Chris@41 1938 # func_version
Chris@41 1939 # ------------
Chris@41 1940 # Echo version message to standard output and exit.
Chris@41 1941 func_version ()
Chris@41 1942 {
Chris@41 1943 $debug_cmd
Chris@41 1944
Chris@41 1945 printf '%s\n' "$progname $scriptversion"
Chris@41 1946 $SED -n '
Chris@41 1947 /(C)/!b go
Chris@41 1948 :more
Chris@41 1949 /\./!{
Chris@41 1950 N
Chris@41 1951 s|\n# | |
Chris@41 1952 b more
Chris@41 1953 }
Chris@41 1954 :go
Chris@41 1955 /^# Written by /,/# warranty; / {
Chris@41 1956 s|^# ||
Chris@41 1957 s|^# *$||
Chris@41 1958 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
Chris@41 1959 p
Chris@41 1960 }
Chris@41 1961 /^# Written by / {
Chris@41 1962 s|^# ||
Chris@41 1963 p
Chris@41 1964 }
Chris@41 1965 /^warranty; /q' < "$progpath"
Chris@41 1966
Chris@41 1967 exit $?
Chris@41 1968 }
Chris@41 1969
Chris@41 1970
Chris@41 1971 # Local variables:
Chris@41 1972 # mode: shell-script
Chris@41 1973 # sh-indentation: 2
Chris@41 1974 # eval: (add-hook 'before-save-hook 'time-stamp)
Chris@41 1975 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
Chris@41 1976 # time-stamp-time-zone: "UTC"
Chris@41 1977 # End:
Chris@41 1978
Chris@41 1979 # Set a version string.
Chris@41 1980 scriptversion='(GNU libtool) 2.4.6'
Chris@41 1981
Chris@41 1982
Chris@41 1983 # func_echo ARG...
Chris@41 1984 # ----------------
Chris@41 1985 # Libtool also displays the current mode in messages, so override
Chris@41 1986 # funclib.sh func_echo with this custom definition.
Chris@41 1987 func_echo ()
Chris@41 1988 {
Chris@41 1989 $debug_cmd
Chris@41 1990
Chris@41 1991 _G_message=$*
Chris@41 1992
Chris@41 1993 func_echo_IFS=$IFS
Chris@41 1994 IFS=$nl
Chris@41 1995 for _G_line in $_G_message; do
Chris@41 1996 IFS=$func_echo_IFS
Chris@41 1997 $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
Chris@41 1998 done
Chris@41 1999 IFS=$func_echo_IFS
Chris@41 2000 }
Chris@41 2001
Chris@41 2002
Chris@41 2003 # func_warning ARG...
Chris@41 2004 # -------------------
Chris@41 2005 # Libtool warnings are not categorized, so override funclib.sh
Chris@41 2006 # func_warning with this simpler definition.
Chris@41 2007 func_warning ()
Chris@41 2008 {
Chris@41 2009 $debug_cmd
Chris@41 2010
Chris@41 2011 $warning_func ${1+"$@"}
Chris@41 2012 }
Chris@41 2013
Chris@41 2014
Chris@41 2015 ## ---------------- ##
Chris@41 2016 ## Options parsing. ##
Chris@41 2017 ## ---------------- ##
Chris@41 2018
Chris@41 2019 # Hook in the functions to make sure our own options are parsed during
Chris@41 2020 # the option parsing loop.
Chris@41 2021
Chris@41 2022 usage='$progpath [OPTION]... [MODE-ARG]...'
Chris@41 2023
Chris@41 2024 # Short help message in response to '-h'.
Chris@41 2025 usage_message="Options:
Chris@41 2026 --config show all configuration variables
Chris@41 2027 --debug enable verbose shell tracing
Chris@41 2028 -n, --dry-run display commands without modifying any files
Chris@41 2029 --features display basic configuration information and exit
Chris@41 2030 --mode=MODE use operation mode MODE
Chris@41 2031 --no-warnings equivalent to '-Wnone'
Chris@41 2032 --preserve-dup-deps don't remove duplicate dependency libraries
Chris@41 2033 --quiet, --silent don't print informational messages
Chris@41 2034 --tag=TAG use configuration variables from tag TAG
Chris@41 2035 -v, --verbose print more informational messages than default
Chris@41 2036 --version print version information
Chris@41 2037 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
Chris@41 2038 -h, --help, --help-all print short, long, or detailed help message
Chris@41 2039 "
Chris@41 2040
Chris@41 2041 # Additional text appended to 'usage_message' in response to '--help'.
Chris@41 2042 func_help ()
Chris@41 2043 {
Chris@41 2044 $debug_cmd
Chris@41 2045
Chris@41 2046 func_usage_message
Chris@41 2047 $ECHO "$long_help_message
Chris@41 2048
Chris@41 2049 MODE must be one of the following:
Chris@41 2050
Chris@41 2051 clean remove files from the build directory
Chris@41 2052 compile compile a source file into a libtool object
Chris@41 2053 execute automatically set library path, then run a program
Chris@41 2054 finish complete the installation of libtool libraries
Chris@41 2055 install install libraries or executables
Chris@41 2056 link create a library or an executable
Chris@41 2057 uninstall remove libraries from an installed directory
Chris@41 2058
Chris@41 2059 MODE-ARGS vary depending on the MODE. When passed as first option,
Chris@41 2060 '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
Chris@41 2061 Try '$progname --help --mode=MODE' for a more detailed description of MODE.
Chris@41 2062
Chris@41 2063 When reporting a bug, please describe a test case to reproduce it and
Chris@41 2064 include the following information:
Chris@41 2065
Chris@41 2066 host-triplet: $host
Chris@41 2067 shell: $SHELL
Chris@41 2068 compiler: $LTCC
Chris@41 2069 compiler flags: $LTCFLAGS
Chris@41 2070 linker: $LD (gnu? $with_gnu_ld)
Chris@41 2071 version: $progname $scriptversion Debian-2.4.6-2
Chris@41 2072 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
Chris@41 2073 autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
Chris@41 2074
Chris@41 2075 Report bugs to <bug-libtool@gnu.org>.
Chris@41 2076 GNU libtool home page: <http://www.gnu.org/s/libtool/>.
Chris@41 2077 General help using GNU software: <http://www.gnu.org/gethelp/>."
Chris@41 2078 exit 0
Chris@41 2079 }
Chris@41 2080
Chris@41 2081
Chris@41 2082 # func_lo2o OBJECT-NAME
Chris@41 2083 # ---------------------
Chris@41 2084 # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
Chris@41 2085 # object suffix.
Chris@41 2086
Chris@41 2087 lo2o=s/\\.lo\$/.$objext/
Chris@41 2088 o2lo=s/\\.$objext\$/.lo/
Chris@41 2089
Chris@41 2090 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@41 2091 eval 'func_lo2o ()
Chris@41 2092 {
Chris@41 2093 case $1 in
Chris@41 2094 *.lo) func_lo2o_result=${1%.lo}.$objext ;;
Chris@41 2095 * ) func_lo2o_result=$1 ;;
Chris@41 2096 esac
Chris@41 2097 }'
Chris@41 2098
Chris@41 2099 # func_xform LIBOBJ-OR-SOURCE
Chris@41 2100 # ---------------------------
Chris@41 2101 # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
Chris@41 2102 # suffix to a '.lo' libtool-object suffix.
Chris@41 2103 eval 'func_xform ()
Chris@41 2104 {
Chris@41 2105 func_xform_result=${1%.*}.lo
Chris@41 2106 }'
Chris@41 2107 else
Chris@41 2108 # ...otherwise fall back to using sed.
Chris@41 2109 func_lo2o ()
Chris@41 2110 {
Chris@41 2111 func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
Chris@41 2112 }
Chris@41 2113
Chris@41 2114 func_xform ()
Chris@41 2115 {
Chris@41 2116 func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
Chris@41 2117 }
Chris@41 2118 fi
Chris@41 2119
Chris@41 2120
Chris@41 2121 # func_fatal_configuration ARG...
Chris@41 2122 # -------------------------------
Chris@41 2123 # Echo program name prefixed message to standard error, followed by
Chris@41 2124 # a configuration failure hint, and exit.
Chris@41 2125 func_fatal_configuration ()
Chris@41 2126 {
Chris@41 2127 func__fatal_error ${1+"$@"} \
Chris@41 2128 "See the $PACKAGE documentation for more information." \
Chris@41 2129 "Fatal configuration error."
Chris@41 2130 }
Chris@41 2131
Chris@41 2132
Chris@41 2133 # func_config
Chris@41 2134 # -----------
Chris@41 2135 # Display the configuration for all the tags in this script.
Chris@41 2136 func_config ()
Chris@41 2137 {
Chris@41 2138 re_begincf='^# ### BEGIN LIBTOOL'
Chris@41 2139 re_endcf='^# ### END LIBTOOL'
Chris@41 2140
Chris@41 2141 # Default configuration.
Chris@41 2142 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
Chris@41 2143
Chris@41 2144 # Now print the configurations for the tags.
Chris@41 2145 for tagname in $taglist; do
Chris@41 2146 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
Chris@41 2147 done
Chris@41 2148
Chris@41 2149 exit $?
Chris@41 2150 }
Chris@41 2151
Chris@41 2152
Chris@41 2153 # func_features
Chris@41 2154 # -------------
Chris@41 2155 # Display the features supported by this script.
Chris@41 2156 func_features ()
Chris@41 2157 {
Chris@41 2158 echo "host: $host"
Chris@41 2159 if test yes = "$build_libtool_libs"; then
Chris@41 2160 echo "enable shared libraries"
Chris@41 2161 else
Chris@41 2162 echo "disable shared libraries"
Chris@41 2163 fi
Chris@41 2164 if test yes = "$build_old_libs"; then
Chris@41 2165 echo "enable static libraries"
Chris@41 2166 else
Chris@41 2167 echo "disable static libraries"
Chris@41 2168 fi
Chris@41 2169
Chris@41 2170 exit $?
Chris@41 2171 }
Chris@41 2172
Chris@41 2173
Chris@41 2174 # func_enable_tag TAGNAME
Chris@41 2175 # -----------------------
Chris@41 2176 # Verify that TAGNAME is valid, and either flag an error and exit, or
Chris@41 2177 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
Chris@41 2178 # variable here.
Chris@41 2179 func_enable_tag ()
Chris@41 2180 {
Chris@41 2181 # Global variable:
Chris@41 2182 tagname=$1
Chris@41 2183
Chris@41 2184 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
Chris@41 2185 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
Chris@41 2186 sed_extractcf=/$re_begincf/,/$re_endcf/p
Chris@41 2187
Chris@41 2188 # Validate tagname.
Chris@41 2189 case $tagname in
Chris@41 2190 *[!-_A-Za-z0-9,/]*)
Chris@41 2191 func_fatal_error "invalid tag name: $tagname"
Chris@41 2192 ;;
Chris@41 2193 esac
Chris@41 2194
Chris@41 2195 # Don't test for the "default" C tag, as we know it's
Chris@41 2196 # there but not specially marked.
Chris@41 2197 case $tagname in
Chris@41 2198 CC) ;;
Chris@41 2199 *)
Chris@41 2200 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
Chris@41 2201 taglist="$taglist $tagname"
Chris@41 2202
Chris@41 2203 # Evaluate the configuration. Be careful to quote the path
Chris@41 2204 # and the sed script, to avoid splitting on whitespace, but
Chris@41 2205 # also don't use non-portable quotes within backquotes within
Chris@41 2206 # quotes we have to do it in 2 steps:
Chris@41 2207 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
Chris@41 2208 eval "$extractedcf"
Chris@41 2209 else
Chris@41 2210 func_error "ignoring unknown tag $tagname"
Chris@41 2211 fi
Chris@41 2212 ;;
Chris@41 2213 esac
Chris@41 2214 }
Chris@41 2215
Chris@41 2216
Chris@41 2217 # func_check_version_match
Chris@41 2218 # ------------------------
Chris@41 2219 # Ensure that we are using m4 macros, and libtool script from the same
Chris@41 2220 # release of libtool.
Chris@41 2221 func_check_version_match ()
Chris@41 2222 {
Chris@41 2223 if test "$package_revision" != "$macro_revision"; then
Chris@41 2224 if test "$VERSION" != "$macro_version"; then
Chris@41 2225 if test -z "$macro_version"; then
Chris@41 2226 cat >&2 <<_LT_EOF
Chris@41 2227 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
Chris@41 2228 $progname: definition of this LT_INIT comes from an older release.
Chris@41 2229 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
Chris@41 2230 $progname: and run autoconf again.
Chris@41 2231 _LT_EOF
Chris@41 2232 else
Chris@41 2233 cat >&2 <<_LT_EOF
Chris@41 2234 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
Chris@41 2235 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
Chris@41 2236 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
Chris@41 2237 $progname: and run autoconf again.
Chris@41 2238 _LT_EOF
Chris@41 2239 fi
Chris@41 2240 else
Chris@41 2241 cat >&2 <<_LT_EOF
Chris@41 2242 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
Chris@41 2243 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
Chris@41 2244 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
Chris@41 2245 $progname: of $PACKAGE $VERSION and run autoconf again.
Chris@41 2246 _LT_EOF
Chris@41 2247 fi
Chris@41 2248
Chris@41 2249 exit $EXIT_MISMATCH
Chris@41 2250 fi
Chris@41 2251 }
Chris@41 2252
Chris@41 2253
Chris@41 2254 # libtool_options_prep [ARG]...
Chris@41 2255 # -----------------------------
Chris@41 2256 # Preparation for options parsed by libtool.
Chris@41 2257 libtool_options_prep ()
Chris@41 2258 {
Chris@41 2259 $debug_mode
Chris@41 2260
Chris@41 2261 # Option defaults:
Chris@41 2262 opt_config=false
Chris@41 2263 opt_dlopen=
Chris@41 2264 opt_dry_run=false
Chris@41 2265 opt_help=false
Chris@41 2266 opt_mode=
Chris@41 2267 opt_preserve_dup_deps=false
Chris@41 2268 opt_quiet=false
Chris@41 2269
Chris@41 2270 nonopt=
Chris@41 2271 preserve_args=
Chris@41 2272
Chris@41 2273 # Shorthand for --mode=foo, only valid as the first argument
Chris@41 2274 case $1 in
Chris@41 2275 clean|clea|cle|cl)
Chris@41 2276 shift; set dummy --mode clean ${1+"$@"}; shift
Chris@41 2277 ;;
Chris@41 2278 compile|compil|compi|comp|com|co|c)
Chris@41 2279 shift; set dummy --mode compile ${1+"$@"}; shift
Chris@41 2280 ;;
Chris@41 2281 execute|execut|execu|exec|exe|ex|e)
Chris@41 2282 shift; set dummy --mode execute ${1+"$@"}; shift
Chris@41 2283 ;;
Chris@41 2284 finish|finis|fini|fin|fi|f)
Chris@41 2285 shift; set dummy --mode finish ${1+"$@"}; shift
Chris@41 2286 ;;
Chris@41 2287 install|instal|insta|inst|ins|in|i)
Chris@41 2288 shift; set dummy --mode install ${1+"$@"}; shift
Chris@41 2289 ;;
Chris@41 2290 link|lin|li|l)
Chris@41 2291 shift; set dummy --mode link ${1+"$@"}; shift
Chris@41 2292 ;;
Chris@41 2293 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
Chris@41 2294 shift; set dummy --mode uninstall ${1+"$@"}; shift
Chris@41 2295 ;;
Chris@41 2296 esac
Chris@41 2297
Chris@41 2298 # Pass back the list of options.
Chris@41 2299 func_quote_for_eval ${1+"$@"}
Chris@41 2300 libtool_options_prep_result=$func_quote_for_eval_result
Chris@41 2301 }
Chris@41 2302 func_add_hook func_options_prep libtool_options_prep
Chris@41 2303
Chris@41 2304
Chris@41 2305 # libtool_parse_options [ARG]...
Chris@41 2306 # ---------------------------------
Chris@41 2307 # Provide handling for libtool specific options.
Chris@41 2308 libtool_parse_options ()
Chris@41 2309 {
Chris@41 2310 $debug_cmd
Chris@41 2311
Chris@41 2312 # Perform our own loop to consume as many options as possible in
Chris@41 2313 # each iteration.
Chris@41 2314 while test $# -gt 0; do
Chris@41 2315 _G_opt=$1
Chris@41 2316 shift
Chris@41 2317 case $_G_opt in
Chris@41 2318 --dry-run|--dryrun|-n)
Chris@41 2319 opt_dry_run=:
Chris@41 2320 ;;
Chris@41 2321
Chris@41 2322 --config) func_config ;;
Chris@41 2323
Chris@41 2324 --dlopen|-dlopen)
Chris@41 2325 opt_dlopen="${opt_dlopen+$opt_dlopen
Chris@41 2326 }$1"
Chris@41 2327 shift
Chris@41 2328 ;;
Chris@41 2329
Chris@41 2330 --preserve-dup-deps)
Chris@41 2331 opt_preserve_dup_deps=: ;;
Chris@41 2332
Chris@41 2333 --features) func_features ;;
Chris@41 2334
Chris@41 2335 --finish) set dummy --mode finish ${1+"$@"}; shift ;;
Chris@41 2336
Chris@41 2337 --help) opt_help=: ;;
Chris@41 2338
Chris@41 2339 --help-all) opt_help=': help-all' ;;
Chris@41 2340
Chris@41 2341 --mode) test $# = 0 && func_missing_arg $_G_opt && break
Chris@41 2342 opt_mode=$1
Chris@41 2343 case $1 in
Chris@41 2344 # Valid mode arguments:
Chris@41 2345 clean|compile|execute|finish|install|link|relink|uninstall) ;;
Chris@41 2346
Chris@41 2347 # Catch anything else as an error
Chris@41 2348 *) func_error "invalid argument for $_G_opt"
Chris@41 2349 exit_cmd=exit
Chris@41 2350 break
Chris@41 2351 ;;
Chris@41 2352 esac
Chris@41 2353 shift
Chris@41 2354 ;;
Chris@41 2355
Chris@41 2356 --no-silent|--no-quiet)
Chris@41 2357 opt_quiet=false
Chris@41 2358 func_append preserve_args " $_G_opt"
Chris@41 2359 ;;
Chris@41 2360
Chris@41 2361 --no-warnings|--no-warning|--no-warn)
Chris@41 2362 opt_warning=false
Chris@41 2363 func_append preserve_args " $_G_opt"
Chris@41 2364 ;;
Chris@41 2365
Chris@41 2366 --no-verbose)
Chris@41 2367 opt_verbose=false
Chris@41 2368 func_append preserve_args " $_G_opt"
Chris@41 2369 ;;
Chris@41 2370
Chris@41 2371 --silent|--quiet)
Chris@41 2372 opt_quiet=:
Chris@41 2373 opt_verbose=false
Chris@41 2374 func_append preserve_args " $_G_opt"
Chris@41 2375 ;;
Chris@41 2376
Chris@41 2377 --tag) test $# = 0 && func_missing_arg $_G_opt && break
Chris@41 2378 opt_tag=$1
Chris@41 2379 func_append preserve_args " $_G_opt $1"
Chris@41 2380 func_enable_tag "$1"
Chris@41 2381 shift
Chris@41 2382 ;;
Chris@41 2383
Chris@41 2384 --verbose|-v) opt_quiet=false
Chris@41 2385 opt_verbose=:
Chris@41 2386 func_append preserve_args " $_G_opt"
Chris@41 2387 ;;
Chris@41 2388
Chris@41 2389 # An option not handled by this hook function:
Chris@41 2390 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
Chris@41 2391 esac
Chris@41 2392 done
Chris@41 2393
Chris@41 2394
Chris@41 2395 # save modified positional parameters for caller
Chris@41 2396 func_quote_for_eval ${1+"$@"}
Chris@41 2397 libtool_parse_options_result=$func_quote_for_eval_result
Chris@41 2398 }
Chris@41 2399 func_add_hook func_parse_options libtool_parse_options
Chris@41 2400
Chris@41 2401
Chris@41 2402
Chris@41 2403 # libtool_validate_options [ARG]...
Chris@41 2404 # ---------------------------------
Chris@41 2405 # Perform any sanity checks on option settings and/or unconsumed
Chris@41 2406 # arguments.
Chris@41 2407 libtool_validate_options ()
Chris@41 2408 {
Chris@41 2409 # save first non-option argument
Chris@41 2410 if test 0 -lt $#; then
Chris@41 2411 nonopt=$1
Chris@41 2412 shift
Chris@41 2413 fi
Chris@41 2414
Chris@41 2415 # preserve --debug
Chris@41 2416 test : = "$debug_cmd" || func_append preserve_args " --debug"
Chris@41 2417
Chris@41 2418 case $host in
Chris@41 2419 # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
Chris@41 2420 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
Chris@41 2421 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
Chris@41 2422 # don't eliminate duplications in $postdeps and $predeps
Chris@41 2423 opt_duplicate_compiler_generated_deps=:
Chris@41 2424 ;;
Chris@41 2425 *)
Chris@41 2426 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
Chris@41 2427 ;;
Chris@41 2428 esac
Chris@41 2429
Chris@41 2430 $opt_help || {
Chris@41 2431 # Sanity checks first:
Chris@41 2432 func_check_version_match
Chris@41 2433
Chris@41 2434 test yes != "$build_libtool_libs" \
Chris@41 2435 && test yes != "$build_old_libs" \
Chris@41 2436 && func_fatal_configuration "not configured to build any kind of library"
Chris@41 2437
Chris@41 2438 # Darwin sucks
Chris@41 2439 eval std_shrext=\"$shrext_cmds\"
Chris@41 2440
Chris@41 2441 # Only execute mode is allowed to have -dlopen flags.
Chris@41 2442 if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
Chris@41 2443 func_error "unrecognized option '-dlopen'"
Chris@41 2444 $ECHO "$help" 1>&2
Chris@41 2445 exit $EXIT_FAILURE
Chris@41 2446 fi
Chris@41 2447
Chris@41 2448 # Change the help message to a mode-specific one.
Chris@41 2449 generic_help=$help
Chris@41 2450 help="Try '$progname --help --mode=$opt_mode' for more information."
Chris@41 2451 }
Chris@41 2452
Chris@41 2453 # Pass back the unparsed argument list
Chris@41 2454 func_quote_for_eval ${1+"$@"}
Chris@41 2455 libtool_validate_options_result=$func_quote_for_eval_result
Chris@41 2456 }
Chris@41 2457 func_add_hook func_validate_options libtool_validate_options
Chris@41 2458
Chris@41 2459
Chris@41 2460 # Process options as early as possible so that --help and --version
Chris@41 2461 # can return quickly.
Chris@41 2462 func_options ${1+"$@"}
Chris@41 2463 eval set dummy "$func_options_result"; shift
Chris@41 2464
Chris@41 2465
Chris@41 2466
Chris@41 2467 ## ----------- ##
Chris@41 2468 ## Main. ##
Chris@41 2469 ## ----------- ##
Chris@41 2470
Chris@41 2471 magic='%%%MAGIC variable%%%'
Chris@41 2472 magic_exe='%%%MAGIC EXE variable%%%'
Chris@41 2473
Chris@41 2474 # Global variables.
Chris@41 2475 extracted_archives=
Chris@41 2476 extracted_serial=0
Chris@41 2477
Chris@41 2478 # If this variable is set in any of the actions, the command in it
Chris@41 2479 # will be execed at the end. This prevents here-documents from being
Chris@41 2480 # left over by shells.
Chris@41 2481 exec_cmd=
Chris@41 2482
Chris@41 2483
Chris@41 2484 # A function that is used when there is no print builtin or printf.
Chris@41 2485 func_fallback_echo ()
Chris@41 2486 {
Chris@41 2487 eval 'cat <<_LTECHO_EOF
Chris@41 2488 $1
Chris@41 2489 _LTECHO_EOF'
Chris@41 2490 }
Chris@41 2491
Chris@41 2492 # func_generated_by_libtool
Chris@41 2493 # True iff stdin has been generated by Libtool. This function is only
Chris@41 2494 # a basic sanity check; it will hardly flush out determined imposters.
Chris@41 2495 func_generated_by_libtool_p ()
Chris@41 2496 {
Chris@41 2497 $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
Chris@41 2498 }
Chris@41 2499
Chris@41 2500 # func_lalib_p file
Chris@41 2501 # True iff FILE is a libtool '.la' library or '.lo' object file.
Chris@41 2502 # This function is only a basic sanity check; it will hardly flush out
Chris@41 2503 # determined imposters.
Chris@41 2504 func_lalib_p ()
Chris@41 2505 {
Chris@41 2506 test -f "$1" &&
Chris@41 2507 $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
Chris@41 2508 }
Chris@41 2509
Chris@41 2510 # func_lalib_unsafe_p file
Chris@41 2511 # True iff FILE is a libtool '.la' library or '.lo' object file.
Chris@41 2512 # This function implements the same check as func_lalib_p without
Chris@41 2513 # resorting to external programs. To this end, it redirects stdin and
Chris@41 2514 # closes it afterwards, without saving the original file descriptor.
Chris@41 2515 # As a safety measure, use it only where a negative result would be
Chris@41 2516 # fatal anyway. Works if 'file' does not exist.
Chris@41 2517 func_lalib_unsafe_p ()
Chris@41 2518 {
Chris@41 2519 lalib_p=no
Chris@41 2520 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
Chris@41 2521 for lalib_p_l in 1 2 3 4
Chris@41 2522 do
Chris@41 2523 read lalib_p_line
Chris@41 2524 case $lalib_p_line in
Chris@41 2525 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
Chris@41 2526 esac
Chris@41 2527 done
Chris@41 2528 exec 0<&5 5<&-
Chris@41 2529 fi
Chris@41 2530 test yes = "$lalib_p"
Chris@41 2531 }
Chris@41 2532
Chris@41 2533 # func_ltwrapper_script_p file
Chris@41 2534 # True iff FILE is a libtool wrapper script
Chris@41 2535 # This function is only a basic sanity check; it will hardly flush out
Chris@41 2536 # determined imposters.
Chris@41 2537 func_ltwrapper_script_p ()
Chris@41 2538 {
Chris@41 2539 test -f "$1" &&
Chris@41 2540 $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
Chris@41 2541 }
Chris@41 2542
Chris@41 2543 # func_ltwrapper_executable_p file
Chris@41 2544 # True iff FILE is a libtool wrapper executable
Chris@41 2545 # This function is only a basic sanity check; it will hardly flush out
Chris@41 2546 # determined imposters.
Chris@41 2547 func_ltwrapper_executable_p ()
Chris@41 2548 {
Chris@41 2549 func_ltwrapper_exec_suffix=
Chris@41 2550 case $1 in
Chris@41 2551 *.exe) ;;
Chris@41 2552 *) func_ltwrapper_exec_suffix=.exe ;;
Chris@41 2553 esac
Chris@41 2554 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
Chris@41 2555 }
Chris@41 2556
Chris@41 2557 # func_ltwrapper_scriptname file
Chris@41 2558 # Assumes file is an ltwrapper_executable
Chris@41 2559 # uses $file to determine the appropriate filename for a
Chris@41 2560 # temporary ltwrapper_script.
Chris@41 2561 func_ltwrapper_scriptname ()
Chris@41 2562 {
Chris@41 2563 func_dirname_and_basename "$1" "" "."
Chris@41 2564 func_stripname '' '.exe' "$func_basename_result"
Chris@41 2565 func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
Chris@41 2566 }
Chris@41 2567
Chris@41 2568 # func_ltwrapper_p file
Chris@41 2569 # True iff FILE is a libtool wrapper script or wrapper executable
Chris@41 2570 # This function is only a basic sanity check; it will hardly flush out
Chris@41 2571 # determined imposters.
Chris@41 2572 func_ltwrapper_p ()
Chris@41 2573 {
Chris@41 2574 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
Chris@41 2575 }
Chris@41 2576
Chris@41 2577
Chris@41 2578 # func_execute_cmds commands fail_cmd
Chris@41 2579 # Execute tilde-delimited COMMANDS.
Chris@41 2580 # If FAIL_CMD is given, eval that upon failure.
Chris@41 2581 # FAIL_CMD may read-access the current command in variable CMD!
Chris@41 2582 func_execute_cmds ()
Chris@41 2583 {
Chris@41 2584 $debug_cmd
Chris@41 2585
Chris@41 2586 save_ifs=$IFS; IFS='~'
Chris@41 2587 for cmd in $1; do
Chris@41 2588 IFS=$sp$nl
Chris@41 2589 eval cmd=\"$cmd\"
Chris@41 2590 IFS=$save_ifs
Chris@41 2591 func_show_eval "$cmd" "${2-:}"
Chris@41 2592 done
Chris@41 2593 IFS=$save_ifs
Chris@41 2594 }
Chris@41 2595
Chris@41 2596
Chris@41 2597 # func_source file
Chris@41 2598 # Source FILE, adding directory component if necessary.
Chris@41 2599 # Note that it is not necessary on cygwin/mingw to append a dot to
Chris@41 2600 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
Chris@41 2601 # behavior happens only for exec(3), not for open(2)! Also, sourcing
Chris@41 2602 # 'FILE.' does not work on cygwin managed mounts.
Chris@41 2603 func_source ()
Chris@41 2604 {
Chris@41 2605 $debug_cmd
Chris@41 2606
Chris@41 2607 case $1 in
Chris@41 2608 */* | *\\*) . "$1" ;;
Chris@41 2609 *) . "./$1" ;;
Chris@41 2610 esac
Chris@41 2611 }
Chris@41 2612
Chris@41 2613
Chris@41 2614 # func_resolve_sysroot PATH
Chris@41 2615 # Replace a leading = in PATH with a sysroot. Store the result into
Chris@41 2616 # func_resolve_sysroot_result
Chris@41 2617 func_resolve_sysroot ()
Chris@41 2618 {
Chris@41 2619 func_resolve_sysroot_result=$1
Chris@41 2620 case $func_resolve_sysroot_result in
Chris@41 2621 =*)
Chris@41 2622 func_stripname '=' '' "$func_resolve_sysroot_result"
Chris@41 2623 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
Chris@41 2624 ;;
Chris@41 2625 esac
Chris@41 2626 }
Chris@41 2627
Chris@41 2628 # func_replace_sysroot PATH
Chris@41 2629 # If PATH begins with the sysroot, replace it with = and
Chris@41 2630 # store the result into func_replace_sysroot_result.
Chris@41 2631 func_replace_sysroot ()
Chris@41 2632 {
Chris@41 2633 case $lt_sysroot:$1 in
Chris@41 2634 ?*:"$lt_sysroot"*)
Chris@41 2635 func_stripname "$lt_sysroot" '' "$1"
Chris@41 2636 func_replace_sysroot_result='='$func_stripname_result
Chris@41 2637 ;;
Chris@41 2638 *)
Chris@41 2639 # Including no sysroot.
Chris@41 2640 func_replace_sysroot_result=$1
Chris@41 2641 ;;
Chris@41 2642 esac
Chris@41 2643 }
Chris@41 2644
Chris@41 2645 # func_infer_tag arg
Chris@41 2646 # Infer tagged configuration to use if any are available and
Chris@41 2647 # if one wasn't chosen via the "--tag" command line option.
Chris@41 2648 # Only attempt this if the compiler in the base compile
Chris@41 2649 # command doesn't match the default compiler.
Chris@41 2650 # arg is usually of the form 'gcc ...'
Chris@41 2651 func_infer_tag ()
Chris@41 2652 {
Chris@41 2653 $debug_cmd
Chris@41 2654
Chris@41 2655 if test -n "$available_tags" && test -z "$tagname"; then
Chris@41 2656 CC_quoted=
Chris@41 2657 for arg in $CC; do
Chris@41 2658 func_append_quoted CC_quoted "$arg"
Chris@41 2659 done
Chris@41 2660 CC_expanded=`func_echo_all $CC`
Chris@41 2661 CC_quoted_expanded=`func_echo_all $CC_quoted`
Chris@41 2662 case $@ in
Chris@41 2663 # Blanks in the command may have been stripped by the calling shell,
Chris@41 2664 # but not from the CC environment variable when configure was run.
Chris@41 2665 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
Chris@41 2666 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
Chris@41 2667 # Blanks at the start of $base_compile will cause this to fail
Chris@41 2668 # if we don't check for them as well.
Chris@41 2669 *)
Chris@41 2670 for z in $available_tags; do
Chris@41 2671 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
Chris@41 2672 # Evaluate the configuration.
Chris@41 2673 eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
Chris@41 2674 CC_quoted=
Chris@41 2675 for arg in $CC; do
Chris@41 2676 # Double-quote args containing other shell metacharacters.
Chris@41 2677 func_append_quoted CC_quoted "$arg"
Chris@41 2678 done
Chris@41 2679 CC_expanded=`func_echo_all $CC`
Chris@41 2680 CC_quoted_expanded=`func_echo_all $CC_quoted`
Chris@41 2681 case "$@ " in
Chris@41 2682 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
Chris@41 2683 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
Chris@41 2684 # The compiler in the base compile command matches
Chris@41 2685 # the one in the tagged configuration.
Chris@41 2686 # Assume this is the tagged configuration we want.
Chris@41 2687 tagname=$z
Chris@41 2688 break
Chris@41 2689 ;;
Chris@41 2690 esac
Chris@41 2691 fi
Chris@41 2692 done
Chris@41 2693 # If $tagname still isn't set, then no tagged configuration
Chris@41 2694 # was found and let the user know that the "--tag" command
Chris@41 2695 # line option must be used.
Chris@41 2696 if test -z "$tagname"; then
Chris@41 2697 func_echo "unable to infer tagged configuration"
Chris@41 2698 func_fatal_error "specify a tag with '--tag'"
Chris@41 2699 # else
Chris@41 2700 # func_verbose "using $tagname tagged configuration"
Chris@41 2701 fi
Chris@41 2702 ;;
Chris@41 2703 esac
Chris@41 2704 fi
Chris@41 2705 }
Chris@41 2706
Chris@41 2707
Chris@41 2708
Chris@41 2709 # func_write_libtool_object output_name pic_name nonpic_name
Chris@41 2710 # Create a libtool object file (analogous to a ".la" file),
Chris@41 2711 # but don't create it if we're doing a dry run.
Chris@41 2712 func_write_libtool_object ()
Chris@41 2713 {
Chris@41 2714 write_libobj=$1
Chris@41 2715 if test yes = "$build_libtool_libs"; then
Chris@41 2716 write_lobj=\'$2\'
Chris@41 2717 else
Chris@41 2718 write_lobj=none
Chris@41 2719 fi
Chris@41 2720
Chris@41 2721 if test yes = "$build_old_libs"; then
Chris@41 2722 write_oldobj=\'$3\'
Chris@41 2723 else
Chris@41 2724 write_oldobj=none
Chris@41 2725 fi
Chris@41 2726
Chris@41 2727 $opt_dry_run || {
Chris@41 2728 cat >${write_libobj}T <<EOF
Chris@41 2729 # $write_libobj - a libtool object file
Chris@41 2730 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@41 2731 #
Chris@41 2732 # Please DO NOT delete this file!
Chris@41 2733 # It is necessary for linking the library.
Chris@41 2734
Chris@41 2735 # Name of the PIC object.
Chris@41 2736 pic_object=$write_lobj
Chris@41 2737
Chris@41 2738 # Name of the non-PIC object
Chris@41 2739 non_pic_object=$write_oldobj
Chris@41 2740
Chris@41 2741 EOF
Chris@41 2742 $MV "${write_libobj}T" "$write_libobj"
Chris@41 2743 }
Chris@41 2744 }
Chris@41 2745
Chris@41 2746
Chris@41 2747 ##################################################
Chris@41 2748 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
Chris@41 2749 ##################################################
Chris@41 2750
Chris@41 2751 # func_convert_core_file_wine_to_w32 ARG
Chris@41 2752 # Helper function used by file name conversion functions when $build is *nix,
Chris@41 2753 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
Chris@41 2754 # correctly configured wine environment available, with the winepath program
Chris@41 2755 # in $build's $PATH.
Chris@41 2756 #
Chris@41 2757 # ARG is the $build file name to be converted to w32 format.
Chris@41 2758 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
Chris@41 2759 # be empty on error (or when ARG is empty)
Chris@41 2760 func_convert_core_file_wine_to_w32 ()
Chris@41 2761 {
Chris@41 2762 $debug_cmd
Chris@41 2763
Chris@41 2764 func_convert_core_file_wine_to_w32_result=$1
Chris@41 2765 if test -n "$1"; then
Chris@41 2766 # Unfortunately, winepath does not exit with a non-zero error code, so we
Chris@41 2767 # are forced to check the contents of stdout. On the other hand, if the
Chris@41 2768 # command is not found, the shell will set an exit code of 127 and print
Chris@41 2769 # *an error message* to stdout. So we must check for both error code of
Chris@41 2770 # zero AND non-empty stdout, which explains the odd construction:
Chris@41 2771 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
Chris@41 2772 if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
Chris@41 2773 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
Chris@41 2774 $SED -e "$sed_naive_backslashify"`
Chris@41 2775 else
Chris@41 2776 func_convert_core_file_wine_to_w32_result=
Chris@41 2777 fi
Chris@41 2778 fi
Chris@41 2779 }
Chris@41 2780 # end: func_convert_core_file_wine_to_w32
Chris@41 2781
Chris@41 2782
Chris@41 2783 # func_convert_core_path_wine_to_w32 ARG
Chris@41 2784 # Helper function used by path conversion functions when $build is *nix, and
Chris@41 2785 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
Chris@41 2786 # configured wine environment available, with the winepath program in $build's
Chris@41 2787 # $PATH. Assumes ARG has no leading or trailing path separator characters.
Chris@41 2788 #
Chris@41 2789 # ARG is path to be converted from $build format to win32.
Chris@41 2790 # Result is available in $func_convert_core_path_wine_to_w32_result.
Chris@41 2791 # Unconvertible file (directory) names in ARG are skipped; if no directory names
Chris@41 2792 # are convertible, then the result may be empty.
Chris@41 2793 func_convert_core_path_wine_to_w32 ()
Chris@41 2794 {
Chris@41 2795 $debug_cmd
Chris@41 2796
Chris@41 2797 # unfortunately, winepath doesn't convert paths, only file names
Chris@41 2798 func_convert_core_path_wine_to_w32_result=
Chris@41 2799 if test -n "$1"; then
Chris@41 2800 oldIFS=$IFS
Chris@41 2801 IFS=:
Chris@41 2802 for func_convert_core_path_wine_to_w32_f in $1; do
Chris@41 2803 IFS=$oldIFS
Chris@41 2804 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
Chris@41 2805 if test -n "$func_convert_core_file_wine_to_w32_result"; then
Chris@41 2806 if test -z "$func_convert_core_path_wine_to_w32_result"; then
Chris@41 2807 func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
Chris@41 2808 else
Chris@41 2809 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
Chris@41 2810 fi
Chris@41 2811 fi
Chris@41 2812 done
Chris@41 2813 IFS=$oldIFS
Chris@41 2814 fi
Chris@41 2815 }
Chris@41 2816 # end: func_convert_core_path_wine_to_w32
Chris@41 2817
Chris@41 2818
Chris@41 2819 # func_cygpath ARGS...
Chris@41 2820 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
Chris@41 2821 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
Chris@41 2822 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
Chris@41 2823 # (2), returns the Cygwin file name or path in func_cygpath_result (input
Chris@41 2824 # file name or path is assumed to be in w32 format, as previously converted
Chris@41 2825 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
Chris@41 2826 # or path in func_cygpath_result (input file name or path is assumed to be in
Chris@41 2827 # Cygwin format). Returns an empty string on error.
Chris@41 2828 #
Chris@41 2829 # ARGS are passed to cygpath, with the last one being the file name or path to
Chris@41 2830 # be converted.
Chris@41 2831 #
Chris@41 2832 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
Chris@41 2833 # environment variable; do not put it in $PATH.
Chris@41 2834 func_cygpath ()
Chris@41 2835 {
Chris@41 2836 $debug_cmd
Chris@41 2837
Chris@41 2838 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
Chris@41 2839 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
Chris@41 2840 if test "$?" -ne 0; then
Chris@41 2841 # on failure, ensure result is empty
Chris@41 2842 func_cygpath_result=
Chris@41 2843 fi
Chris@41 2844 else
Chris@41 2845 func_cygpath_result=
Chris@41 2846 func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
Chris@41 2847 fi
Chris@41 2848 }
Chris@41 2849 #end: func_cygpath
Chris@41 2850
Chris@41 2851
Chris@41 2852 # func_convert_core_msys_to_w32 ARG
Chris@41 2853 # Convert file name or path ARG from MSYS format to w32 format. Return
Chris@41 2854 # result in func_convert_core_msys_to_w32_result.
Chris@41 2855 func_convert_core_msys_to_w32 ()
Chris@41 2856 {
Chris@41 2857 $debug_cmd
Chris@41 2858
Chris@41 2859 # awkward: cmd appends spaces to result
Chris@41 2860 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
Chris@41 2861 $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
Chris@41 2862 }
Chris@41 2863 #end: func_convert_core_msys_to_w32
Chris@41 2864
Chris@41 2865
Chris@41 2866 # func_convert_file_check ARG1 ARG2
Chris@41 2867 # Verify that ARG1 (a file name in $build format) was converted to $host
Chris@41 2868 # format in ARG2. Otherwise, emit an error message, but continue (resetting
Chris@41 2869 # func_to_host_file_result to ARG1).
Chris@41 2870 func_convert_file_check ()
Chris@41 2871 {
Chris@41 2872 $debug_cmd
Chris@41 2873
Chris@41 2874 if test -z "$2" && test -n "$1"; then
Chris@41 2875 func_error "Could not determine host file name corresponding to"
Chris@41 2876 func_error " '$1'"
Chris@41 2877 func_error "Continuing, but uninstalled executables may not work."
Chris@41 2878 # Fallback:
Chris@41 2879 func_to_host_file_result=$1
Chris@41 2880 fi
Chris@41 2881 }
Chris@41 2882 # end func_convert_file_check
Chris@41 2883
Chris@41 2884
Chris@41 2885 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
Chris@41 2886 # Verify that FROM_PATH (a path in $build format) was converted to $host
Chris@41 2887 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
Chris@41 2888 # func_to_host_file_result to a simplistic fallback value (see below).
Chris@41 2889 func_convert_path_check ()
Chris@41 2890 {
Chris@41 2891 $debug_cmd
Chris@41 2892
Chris@41 2893 if test -z "$4" && test -n "$3"; then
Chris@41 2894 func_error "Could not determine the host path corresponding to"
Chris@41 2895 func_error " '$3'"
Chris@41 2896 func_error "Continuing, but uninstalled executables may not work."
Chris@41 2897 # Fallback. This is a deliberately simplistic "conversion" and
Chris@41 2898 # should not be "improved". See libtool.info.
Chris@41 2899 if test "x$1" != "x$2"; then
Chris@41 2900 lt_replace_pathsep_chars="s|$1|$2|g"
Chris@41 2901 func_to_host_path_result=`echo "$3" |
Chris@41 2902 $SED -e "$lt_replace_pathsep_chars"`
Chris@41 2903 else
Chris@41 2904 func_to_host_path_result=$3
Chris@41 2905 fi
Chris@41 2906 fi
Chris@41 2907 }
Chris@41 2908 # end func_convert_path_check
Chris@41 2909
Chris@41 2910
Chris@41 2911 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
Chris@41 2912 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
Chris@41 2913 # and appending REPL if ORIG matches BACKPAT.
Chris@41 2914 func_convert_path_front_back_pathsep ()
Chris@41 2915 {
Chris@41 2916 $debug_cmd
Chris@41 2917
Chris@41 2918 case $4 in
Chris@41 2919 $1 ) func_to_host_path_result=$3$func_to_host_path_result
Chris@41 2920 ;;
Chris@41 2921 esac
Chris@41 2922 case $4 in
Chris@41 2923 $2 ) func_append func_to_host_path_result "$3"
Chris@41 2924 ;;
Chris@41 2925 esac
Chris@41 2926 }
Chris@41 2927 # end func_convert_path_front_back_pathsep
Chris@41 2928
Chris@41 2929
Chris@41 2930 ##################################################
Chris@41 2931 # $build to $host FILE NAME CONVERSION FUNCTIONS #
Chris@41 2932 ##################################################
Chris@41 2933 # invoked via '$to_host_file_cmd ARG'
Chris@41 2934 #
Chris@41 2935 # In each case, ARG is the path to be converted from $build to $host format.
Chris@41 2936 # Result will be available in $func_to_host_file_result.
Chris@41 2937
Chris@41 2938
Chris@41 2939 # func_to_host_file ARG
Chris@41 2940 # Converts the file name ARG from $build format to $host format. Return result
Chris@41 2941 # in func_to_host_file_result.
Chris@41 2942 func_to_host_file ()
Chris@41 2943 {
Chris@41 2944 $debug_cmd
Chris@41 2945
Chris@41 2946 $to_host_file_cmd "$1"
Chris@41 2947 }
Chris@41 2948 # end func_to_host_file
Chris@41 2949
Chris@41 2950
Chris@41 2951 # func_to_tool_file ARG LAZY
Chris@41 2952 # converts the file name ARG from $build format to toolchain format. Return
Chris@41 2953 # result in func_to_tool_file_result. If the conversion in use is listed
Chris@41 2954 # in (the comma separated) LAZY, no conversion takes place.
Chris@41 2955 func_to_tool_file ()
Chris@41 2956 {
Chris@41 2957 $debug_cmd
Chris@41 2958
Chris@41 2959 case ,$2, in
Chris@41 2960 *,"$to_tool_file_cmd",*)
Chris@41 2961 func_to_tool_file_result=$1
Chris@41 2962 ;;
Chris@41 2963 *)
Chris@41 2964 $to_tool_file_cmd "$1"
Chris@41 2965 func_to_tool_file_result=$func_to_host_file_result
Chris@41 2966 ;;
Chris@41 2967 esac
Chris@41 2968 }
Chris@41 2969 # end func_to_tool_file
Chris@41 2970
Chris@41 2971
Chris@41 2972 # func_convert_file_noop ARG
Chris@41 2973 # Copy ARG to func_to_host_file_result.
Chris@41 2974 func_convert_file_noop ()
Chris@41 2975 {
Chris@41 2976 func_to_host_file_result=$1
Chris@41 2977 }
Chris@41 2978 # end func_convert_file_noop
Chris@41 2979
Chris@41 2980
Chris@41 2981 # func_convert_file_msys_to_w32 ARG
Chris@41 2982 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
Chris@41 2983 # conversion to w32 is not available inside the cwrapper. Returns result in
Chris@41 2984 # func_to_host_file_result.
Chris@41 2985 func_convert_file_msys_to_w32 ()
Chris@41 2986 {
Chris@41 2987 $debug_cmd
Chris@41 2988
Chris@41 2989 func_to_host_file_result=$1
Chris@41 2990 if test -n "$1"; then
Chris@41 2991 func_convert_core_msys_to_w32 "$1"
Chris@41 2992 func_to_host_file_result=$func_convert_core_msys_to_w32_result
Chris@41 2993 fi
Chris@41 2994 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@41 2995 }
Chris@41 2996 # end func_convert_file_msys_to_w32
Chris@41 2997
Chris@41 2998
Chris@41 2999 # func_convert_file_cygwin_to_w32 ARG
Chris@41 3000 # Convert file name ARG from Cygwin to w32 format. Returns result in
Chris@41 3001 # func_to_host_file_result.
Chris@41 3002 func_convert_file_cygwin_to_w32 ()
Chris@41 3003 {
Chris@41 3004 $debug_cmd
Chris@41 3005
Chris@41 3006 func_to_host_file_result=$1
Chris@41 3007 if test -n "$1"; then
Chris@41 3008 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
Chris@41 3009 # LT_CYGPATH in this case.
Chris@41 3010 func_to_host_file_result=`cygpath -m "$1"`
Chris@41 3011 fi
Chris@41 3012 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@41 3013 }
Chris@41 3014 # end func_convert_file_cygwin_to_w32
Chris@41 3015
Chris@41 3016
Chris@41 3017 # func_convert_file_nix_to_w32 ARG
Chris@41 3018 # Convert file name ARG from *nix to w32 format. Requires a wine environment
Chris@41 3019 # and a working winepath. Returns result in func_to_host_file_result.
Chris@41 3020 func_convert_file_nix_to_w32 ()
Chris@41 3021 {
Chris@41 3022 $debug_cmd
Chris@41 3023
Chris@41 3024 func_to_host_file_result=$1
Chris@41 3025 if test -n "$1"; then
Chris@41 3026 func_convert_core_file_wine_to_w32 "$1"
Chris@41 3027 func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
Chris@41 3028 fi
Chris@41 3029 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@41 3030 }
Chris@41 3031 # end func_convert_file_nix_to_w32
Chris@41 3032
Chris@41 3033
Chris@41 3034 # func_convert_file_msys_to_cygwin ARG
Chris@41 3035 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
Chris@41 3036 # Returns result in func_to_host_file_result.
Chris@41 3037 func_convert_file_msys_to_cygwin ()
Chris@41 3038 {
Chris@41 3039 $debug_cmd
Chris@41 3040
Chris@41 3041 func_to_host_file_result=$1
Chris@41 3042 if test -n "$1"; then
Chris@41 3043 func_convert_core_msys_to_w32 "$1"
Chris@41 3044 func_cygpath -u "$func_convert_core_msys_to_w32_result"
Chris@41 3045 func_to_host_file_result=$func_cygpath_result
Chris@41 3046 fi
Chris@41 3047 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@41 3048 }
Chris@41 3049 # end func_convert_file_msys_to_cygwin
Chris@41 3050
Chris@41 3051
Chris@41 3052 # func_convert_file_nix_to_cygwin ARG
Chris@41 3053 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
Chris@41 3054 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
Chris@41 3055 # in func_to_host_file_result.
Chris@41 3056 func_convert_file_nix_to_cygwin ()
Chris@41 3057 {
Chris@41 3058 $debug_cmd
Chris@41 3059
Chris@41 3060 func_to_host_file_result=$1
Chris@41 3061 if test -n "$1"; then
Chris@41 3062 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
Chris@41 3063 func_convert_core_file_wine_to_w32 "$1"
Chris@41 3064 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
Chris@41 3065 func_to_host_file_result=$func_cygpath_result
Chris@41 3066 fi
Chris@41 3067 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@41 3068 }
Chris@41 3069 # end func_convert_file_nix_to_cygwin
Chris@41 3070
Chris@41 3071
Chris@41 3072 #############################################
Chris@41 3073 # $build to $host PATH CONVERSION FUNCTIONS #
Chris@41 3074 #############################################
Chris@41 3075 # invoked via '$to_host_path_cmd ARG'
Chris@41 3076 #
Chris@41 3077 # In each case, ARG is the path to be converted from $build to $host format.
Chris@41 3078 # The result will be available in $func_to_host_path_result.
Chris@41 3079 #
Chris@41 3080 # Path separators are also converted from $build format to $host format. If
Chris@41 3081 # ARG begins or ends with a path separator character, it is preserved (but
Chris@41 3082 # converted to $host format) on output.
Chris@41 3083 #
Chris@41 3084 # All path conversion functions are named using the following convention:
Chris@41 3085 # file name conversion function : func_convert_file_X_to_Y ()
Chris@41 3086 # path conversion function : func_convert_path_X_to_Y ()
Chris@41 3087 # where, for any given $build/$host combination the 'X_to_Y' value is the
Chris@41 3088 # same. If conversion functions are added for new $build/$host combinations,
Chris@41 3089 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
Chris@41 3090 # will break.
Chris@41 3091
Chris@41 3092
Chris@41 3093 # func_init_to_host_path_cmd
Chris@41 3094 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
Chris@41 3095 # appropriate value, based on the value of $to_host_file_cmd.
Chris@41 3096 to_host_path_cmd=
Chris@41 3097 func_init_to_host_path_cmd ()
Chris@41 3098 {
Chris@41 3099 $debug_cmd
Chris@41 3100
Chris@41 3101 if test -z "$to_host_path_cmd"; then
Chris@41 3102 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
Chris@41 3103 to_host_path_cmd=func_convert_path_$func_stripname_result
Chris@41 3104 fi
Chris@41 3105 }
Chris@41 3106
Chris@41 3107
Chris@41 3108 # func_to_host_path ARG
Chris@41 3109 # Converts the path ARG from $build format to $host format. Return result
Chris@41 3110 # in func_to_host_path_result.
Chris@41 3111 func_to_host_path ()
Chris@41 3112 {
Chris@41 3113 $debug_cmd
Chris@41 3114
Chris@41 3115 func_init_to_host_path_cmd
Chris@41 3116 $to_host_path_cmd "$1"
Chris@41 3117 }
Chris@41 3118 # end func_to_host_path
Chris@41 3119
Chris@41 3120
Chris@41 3121 # func_convert_path_noop ARG
Chris@41 3122 # Copy ARG to func_to_host_path_result.
Chris@41 3123 func_convert_path_noop ()
Chris@41 3124 {
Chris@41 3125 func_to_host_path_result=$1
Chris@41 3126 }
Chris@41 3127 # end func_convert_path_noop
Chris@41 3128
Chris@41 3129
Chris@41 3130 # func_convert_path_msys_to_w32 ARG
Chris@41 3131 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
Chris@41 3132 # conversion to w32 is not available inside the cwrapper. Returns result in
Chris@41 3133 # func_to_host_path_result.
Chris@41 3134 func_convert_path_msys_to_w32 ()
Chris@41 3135 {
Chris@41 3136 $debug_cmd
Chris@41 3137
Chris@41 3138 func_to_host_path_result=$1
Chris@41 3139 if test -n "$1"; then
Chris@41 3140 # Remove leading and trailing path separator characters from ARG. MSYS
Chris@41 3141 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
Chris@41 3142 # and winepath ignores them completely.
Chris@41 3143 func_stripname : : "$1"
Chris@41 3144 func_to_host_path_tmp1=$func_stripname_result
Chris@41 3145 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
Chris@41 3146 func_to_host_path_result=$func_convert_core_msys_to_w32_result
Chris@41 3147 func_convert_path_check : ";" \
Chris@41 3148 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@41 3149 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Chris@41 3150 fi
Chris@41 3151 }
Chris@41 3152 # end func_convert_path_msys_to_w32
Chris@41 3153
Chris@41 3154
Chris@41 3155 # func_convert_path_cygwin_to_w32 ARG
Chris@41 3156 # Convert path ARG from Cygwin to w32 format. Returns result in
Chris@41 3157 # func_to_host_file_result.
Chris@41 3158 func_convert_path_cygwin_to_w32 ()
Chris@41 3159 {
Chris@41 3160 $debug_cmd
Chris@41 3161
Chris@41 3162 func_to_host_path_result=$1
Chris@41 3163 if test -n "$1"; then
Chris@41 3164 # See func_convert_path_msys_to_w32:
Chris@41 3165 func_stripname : : "$1"
Chris@41 3166 func_to_host_path_tmp1=$func_stripname_result
Chris@41 3167 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
Chris@41 3168 func_convert_path_check : ";" \
Chris@41 3169 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@41 3170 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Chris@41 3171 fi
Chris@41 3172 }
Chris@41 3173 # end func_convert_path_cygwin_to_w32
Chris@41 3174
Chris@41 3175
Chris@41 3176 # func_convert_path_nix_to_w32 ARG
Chris@41 3177 # Convert path ARG from *nix to w32 format. Requires a wine environment and
Chris@41 3178 # a working winepath. Returns result in func_to_host_file_result.
Chris@41 3179 func_convert_path_nix_to_w32 ()
Chris@41 3180 {
Chris@41 3181 $debug_cmd
Chris@41 3182
Chris@41 3183 func_to_host_path_result=$1
Chris@41 3184 if test -n "$1"; then
Chris@41 3185 # See func_convert_path_msys_to_w32:
Chris@41 3186 func_stripname : : "$1"
Chris@41 3187 func_to_host_path_tmp1=$func_stripname_result
Chris@41 3188 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
Chris@41 3189 func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
Chris@41 3190 func_convert_path_check : ";" \
Chris@41 3191 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@41 3192 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Chris@41 3193 fi
Chris@41 3194 }
Chris@41 3195 # end func_convert_path_nix_to_w32
Chris@41 3196
Chris@41 3197
Chris@41 3198 # func_convert_path_msys_to_cygwin ARG
Chris@41 3199 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
Chris@41 3200 # Returns result in func_to_host_file_result.
Chris@41 3201 func_convert_path_msys_to_cygwin ()
Chris@41 3202 {
Chris@41 3203 $debug_cmd
Chris@41 3204
Chris@41 3205 func_to_host_path_result=$1
Chris@41 3206 if test -n "$1"; then
Chris@41 3207 # See func_convert_path_msys_to_w32:
Chris@41 3208 func_stripname : : "$1"
Chris@41 3209 func_to_host_path_tmp1=$func_stripname_result
Chris@41 3210 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
Chris@41 3211 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
Chris@41 3212 func_to_host_path_result=$func_cygpath_result
Chris@41 3213 func_convert_path_check : : \
Chris@41 3214 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@41 3215 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
Chris@41 3216 fi
Chris@41 3217 }
Chris@41 3218 # end func_convert_path_msys_to_cygwin
Chris@41 3219
Chris@41 3220
Chris@41 3221 # func_convert_path_nix_to_cygwin ARG
Chris@41 3222 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
Chris@41 3223 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
Chris@41 3224 # func_to_host_file_result.
Chris@41 3225 func_convert_path_nix_to_cygwin ()
Chris@41 3226 {
Chris@41 3227 $debug_cmd
Chris@41 3228
Chris@41 3229 func_to_host_path_result=$1
Chris@41 3230 if test -n "$1"; then
Chris@41 3231 # Remove leading and trailing path separator characters from
Chris@41 3232 # ARG. msys behavior is inconsistent here, cygpath turns them
Chris@41 3233 # into '.;' and ';.', and winepath ignores them completely.
Chris@41 3234 func_stripname : : "$1"
Chris@41 3235 func_to_host_path_tmp1=$func_stripname_result
Chris@41 3236 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
Chris@41 3237 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
Chris@41 3238 func_to_host_path_result=$func_cygpath_result
Chris@41 3239 func_convert_path_check : : \
Chris@41 3240 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@41 3241 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
Chris@41 3242 fi
Chris@41 3243 }
Chris@41 3244 # end func_convert_path_nix_to_cygwin
Chris@41 3245
Chris@41 3246
Chris@41 3247 # func_dll_def_p FILE
Chris@41 3248 # True iff FILE is a Windows DLL '.def' file.
Chris@41 3249 # Keep in sync with _LT_DLL_DEF_P in libtool.m4
Chris@41 3250 func_dll_def_p ()
Chris@41 3251 {
Chris@41 3252 $debug_cmd
Chris@41 3253
Chris@41 3254 func_dll_def_p_tmp=`$SED -n \
Chris@41 3255 -e 's/^[ ]*//' \
Chris@41 3256 -e '/^\(;.*\)*$/d' \
Chris@41 3257 -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
Chris@41 3258 -e q \
Chris@41 3259 "$1"`
Chris@41 3260 test DEF = "$func_dll_def_p_tmp"
Chris@41 3261 }
Chris@41 3262
Chris@41 3263
Chris@41 3264 # func_mode_compile arg...
Chris@41 3265 func_mode_compile ()
Chris@41 3266 {
Chris@41 3267 $debug_cmd
Chris@41 3268
Chris@41 3269 # Get the compilation command and the source file.
Chris@41 3270 base_compile=
Chris@41 3271 srcfile=$nonopt # always keep a non-empty value in "srcfile"
Chris@41 3272 suppress_opt=yes
Chris@41 3273 suppress_output=
Chris@41 3274 arg_mode=normal
Chris@41 3275 libobj=
Chris@41 3276 later=
Chris@41 3277 pie_flag=
Chris@41 3278
Chris@41 3279 for arg
Chris@41 3280 do
Chris@41 3281 case $arg_mode in
Chris@41 3282 arg )
Chris@41 3283 # do not "continue". Instead, add this to base_compile
Chris@41 3284 lastarg=$arg
Chris@41 3285 arg_mode=normal
Chris@41 3286 ;;
Chris@41 3287
Chris@41 3288 target )
Chris@41 3289 libobj=$arg
Chris@41 3290 arg_mode=normal
Chris@41 3291 continue
Chris@41 3292 ;;
Chris@41 3293
Chris@41 3294 normal )
Chris@41 3295 # Accept any command-line options.
Chris@41 3296 case $arg in
Chris@41 3297 -o)
Chris@41 3298 test -n "$libobj" && \
Chris@41 3299 func_fatal_error "you cannot specify '-o' more than once"
Chris@41 3300 arg_mode=target
Chris@41 3301 continue
Chris@41 3302 ;;
Chris@41 3303
Chris@41 3304 -pie | -fpie | -fPIE)
Chris@41 3305 func_append pie_flag " $arg"
Chris@41 3306 continue
Chris@41 3307 ;;
Chris@41 3308
Chris@41 3309 -shared | -static | -prefer-pic | -prefer-non-pic)
Chris@41 3310 func_append later " $arg"
Chris@41 3311 continue
Chris@41 3312 ;;
Chris@41 3313
Chris@41 3314 -no-suppress)
Chris@41 3315 suppress_opt=no
Chris@41 3316 continue
Chris@41 3317 ;;
Chris@41 3318
Chris@41 3319 -Xcompiler)
Chris@41 3320 arg_mode=arg # the next one goes into the "base_compile" arg list
Chris@41 3321 continue # The current "srcfile" will either be retained or
Chris@41 3322 ;; # replaced later. I would guess that would be a bug.
Chris@41 3323
Chris@41 3324 -Wc,*)
Chris@41 3325 func_stripname '-Wc,' '' "$arg"
Chris@41 3326 args=$func_stripname_result
Chris@41 3327 lastarg=
Chris@41 3328 save_ifs=$IFS; IFS=,
Chris@41 3329 for arg in $args; do
Chris@41 3330 IFS=$save_ifs
Chris@41 3331 func_append_quoted lastarg "$arg"
Chris@41 3332 done
Chris@41 3333 IFS=$save_ifs
Chris@41 3334 func_stripname ' ' '' "$lastarg"
Chris@41 3335 lastarg=$func_stripname_result
Chris@41 3336
Chris@41 3337 # Add the arguments to base_compile.
Chris@41 3338 func_append base_compile " $lastarg"
Chris@41 3339 continue
Chris@41 3340 ;;
Chris@41 3341
Chris@41 3342 *)
Chris@41 3343 # Accept the current argument as the source file.
Chris@41 3344 # The previous "srcfile" becomes the current argument.
Chris@41 3345 #
Chris@41 3346 lastarg=$srcfile
Chris@41 3347 srcfile=$arg
Chris@41 3348 ;;
Chris@41 3349 esac # case $arg
Chris@41 3350 ;;
Chris@41 3351 esac # case $arg_mode
Chris@41 3352
Chris@41 3353 # Aesthetically quote the previous argument.
Chris@41 3354 func_append_quoted base_compile "$lastarg"
Chris@41 3355 done # for arg
Chris@41 3356
Chris@41 3357 case $arg_mode in
Chris@41 3358 arg)
Chris@41 3359 func_fatal_error "you must specify an argument for -Xcompile"
Chris@41 3360 ;;
Chris@41 3361 target)
Chris@41 3362 func_fatal_error "you must specify a target with '-o'"
Chris@41 3363 ;;
Chris@41 3364 *)
Chris@41 3365 # Get the name of the library object.
Chris@41 3366 test -z "$libobj" && {
Chris@41 3367 func_basename "$srcfile"
Chris@41 3368 libobj=$func_basename_result
Chris@41 3369 }
Chris@41 3370 ;;
Chris@41 3371 esac
Chris@41 3372
Chris@41 3373 # Recognize several different file suffixes.
Chris@41 3374 # If the user specifies -o file.o, it is replaced with file.lo
Chris@41 3375 case $libobj in
Chris@41 3376 *.[cCFSifmso] | \
Chris@41 3377 *.ada | *.adb | *.ads | *.asm | \
Chris@41 3378 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
Chris@41 3379 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
Chris@41 3380 func_xform "$libobj"
Chris@41 3381 libobj=$func_xform_result
Chris@41 3382 ;;
Chris@41 3383 esac
Chris@41 3384
Chris@41 3385 case $libobj in
Chris@41 3386 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
Chris@41 3387 *)
Chris@41 3388 func_fatal_error "cannot determine name of library object from '$libobj'"
Chris@41 3389 ;;
Chris@41 3390 esac
Chris@41 3391
Chris@41 3392 func_infer_tag $base_compile
Chris@41 3393
Chris@41 3394 for arg in $later; do
Chris@41 3395 case $arg in
Chris@41 3396 -shared)
Chris@41 3397 test yes = "$build_libtool_libs" \
Chris@41 3398 || func_fatal_configuration "cannot build a shared library"
Chris@41 3399 build_old_libs=no
Chris@41 3400 continue
Chris@41 3401 ;;
Chris@41 3402
Chris@41 3403 -static)
Chris@41 3404 build_libtool_libs=no
Chris@41 3405 build_old_libs=yes
Chris@41 3406 continue
Chris@41 3407 ;;
Chris@41 3408
Chris@41 3409 -prefer-pic)
Chris@41 3410 pic_mode=yes
Chris@41 3411 continue
Chris@41 3412 ;;
Chris@41 3413
Chris@41 3414 -prefer-non-pic)
Chris@41 3415 pic_mode=no
Chris@41 3416 continue
Chris@41 3417 ;;
Chris@41 3418 esac
Chris@41 3419 done
Chris@41 3420
Chris@41 3421 func_quote_for_eval "$libobj"
Chris@41 3422 test "X$libobj" != "X$func_quote_for_eval_result" \
Chris@41 3423 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
Chris@41 3424 && func_warning "libobj name '$libobj' may not contain shell special characters."
Chris@41 3425 func_dirname_and_basename "$obj" "/" ""
Chris@41 3426 objname=$func_basename_result
Chris@41 3427 xdir=$func_dirname_result
Chris@41 3428 lobj=$xdir$objdir/$objname
Chris@41 3429
Chris@41 3430 test -z "$base_compile" && \
Chris@41 3431 func_fatal_help "you must specify a compilation command"
Chris@41 3432
Chris@41 3433 # Delete any leftover library objects.
Chris@41 3434 if test yes = "$build_old_libs"; then
Chris@41 3435 removelist="$obj $lobj $libobj ${libobj}T"
Chris@41 3436 else
Chris@41 3437 removelist="$lobj $libobj ${libobj}T"
Chris@41 3438 fi
Chris@41 3439
Chris@41 3440 # On Cygwin there's no "real" PIC flag so we must build both object types
Chris@41 3441 case $host_os in
Chris@41 3442 cygwin* | mingw* | pw32* | os2* | cegcc*)
Chris@41 3443 pic_mode=default
Chris@41 3444 ;;
Chris@41 3445 esac
Chris@41 3446 if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
Chris@41 3447 # non-PIC code in shared libraries is not supported
Chris@41 3448 pic_mode=default
Chris@41 3449 fi
Chris@41 3450
Chris@41 3451 # Calculate the filename of the output object if compiler does
Chris@41 3452 # not support -o with -c
Chris@41 3453 if test no = "$compiler_c_o"; then
Chris@41 3454 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
Chris@41 3455 lockfile=$output_obj.lock
Chris@41 3456 else
Chris@41 3457 output_obj=
Chris@41 3458 need_locks=no
Chris@41 3459 lockfile=
Chris@41 3460 fi
Chris@41 3461
Chris@41 3462 # Lock this critical section if it is needed
Chris@41 3463 # We use this script file to make the link, it avoids creating a new file
Chris@41 3464 if test yes = "$need_locks"; then
Chris@41 3465 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
Chris@41 3466 func_echo "Waiting for $lockfile to be removed"
Chris@41 3467 sleep 2
Chris@41 3468 done
Chris@41 3469 elif test warn = "$need_locks"; then
Chris@41 3470 if test -f "$lockfile"; then
Chris@41 3471 $ECHO "\
Chris@41 3472 *** ERROR, $lockfile exists and contains:
Chris@41 3473 `cat $lockfile 2>/dev/null`
Chris@41 3474
Chris@41 3475 This indicates that another process is trying to use the same
Chris@41 3476 temporary object file, and libtool could not work around it because
Chris@41 3477 your compiler does not support '-c' and '-o' together. If you
Chris@41 3478 repeat this compilation, it may succeed, by chance, but you had better
Chris@41 3479 avoid parallel builds (make -j) in this platform, or get a better
Chris@41 3480 compiler."
Chris@41 3481
Chris@41 3482 $opt_dry_run || $RM $removelist
Chris@41 3483 exit $EXIT_FAILURE
Chris@41 3484 fi
Chris@41 3485 func_append removelist " $output_obj"
Chris@41 3486 $ECHO "$srcfile" > "$lockfile"
Chris@41 3487 fi
Chris@41 3488
Chris@41 3489 $opt_dry_run || $RM $removelist
Chris@41 3490 func_append removelist " $lockfile"
Chris@41 3491 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
Chris@41 3492
Chris@41 3493 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
Chris@41 3494 srcfile=$func_to_tool_file_result
Chris@41 3495 func_quote_for_eval "$srcfile"
Chris@41 3496 qsrcfile=$func_quote_for_eval_result
Chris@41 3497
Chris@41 3498 # Only build a PIC object if we are building libtool libraries.
Chris@41 3499 if test yes = "$build_libtool_libs"; then
Chris@41 3500 # Without this assignment, base_compile gets emptied.
Chris@41 3501 fbsd_hideous_sh_bug=$base_compile
Chris@41 3502
Chris@41 3503 if test no != "$pic_mode"; then
Chris@41 3504 command="$base_compile $qsrcfile $pic_flag"
Chris@41 3505 else
Chris@41 3506 # Don't build PIC code
Chris@41 3507 command="$base_compile $qsrcfile"
Chris@41 3508 fi
Chris@41 3509
Chris@41 3510 func_mkdir_p "$xdir$objdir"
Chris@41 3511
Chris@41 3512 if test -z "$output_obj"; then
Chris@41 3513 # Place PIC objects in $objdir
Chris@41 3514 func_append command " -o $lobj"
Chris@41 3515 fi
Chris@41 3516
Chris@41 3517 func_show_eval_locale "$command" \
Chris@41 3518 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
Chris@41 3519
Chris@41 3520 if test warn = "$need_locks" &&
Chris@41 3521 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
Chris@41 3522 $ECHO "\
Chris@41 3523 *** ERROR, $lockfile contains:
Chris@41 3524 `cat $lockfile 2>/dev/null`
Chris@41 3525
Chris@41 3526 but it should contain:
Chris@41 3527 $srcfile
Chris@41 3528
Chris@41 3529 This indicates that another process is trying to use the same
Chris@41 3530 temporary object file, and libtool could not work around it because
Chris@41 3531 your compiler does not support '-c' and '-o' together. If you
Chris@41 3532 repeat this compilation, it may succeed, by chance, but you had better
Chris@41 3533 avoid parallel builds (make -j) in this platform, or get a better
Chris@41 3534 compiler."
Chris@41 3535
Chris@41 3536 $opt_dry_run || $RM $removelist
Chris@41 3537 exit $EXIT_FAILURE
Chris@41 3538 fi
Chris@41 3539
Chris@41 3540 # Just move the object if needed, then go on to compile the next one
Chris@41 3541 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
Chris@41 3542 func_show_eval '$MV "$output_obj" "$lobj"' \
Chris@41 3543 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
Chris@41 3544 fi
Chris@41 3545
Chris@41 3546 # Allow error messages only from the first compilation.
Chris@41 3547 if test yes = "$suppress_opt"; then
Chris@41 3548 suppress_output=' >/dev/null 2>&1'
Chris@41 3549 fi
Chris@41 3550 fi
Chris@41 3551
Chris@41 3552 # Only build a position-dependent object if we build old libraries.
Chris@41 3553 if test yes = "$build_old_libs"; then
Chris@41 3554 if test yes != "$pic_mode"; then
Chris@41 3555 # Don't build PIC code
Chris@41 3556 command="$base_compile $qsrcfile$pie_flag"
Chris@41 3557 else
Chris@41 3558 command="$base_compile $qsrcfile $pic_flag"
Chris@41 3559 fi
Chris@41 3560 if test yes = "$compiler_c_o"; then
Chris@41 3561 func_append command " -o $obj"
Chris@41 3562 fi
Chris@41 3563
Chris@41 3564 # Suppress compiler output if we already did a PIC compilation.
Chris@41 3565 func_append command "$suppress_output"
Chris@41 3566 func_show_eval_locale "$command" \
Chris@41 3567 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
Chris@41 3568
Chris@41 3569 if test warn = "$need_locks" &&
Chris@41 3570 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
Chris@41 3571 $ECHO "\
Chris@41 3572 *** ERROR, $lockfile contains:
Chris@41 3573 `cat $lockfile 2>/dev/null`
Chris@41 3574
Chris@41 3575 but it should contain:
Chris@41 3576 $srcfile
Chris@41 3577
Chris@41 3578 This indicates that another process is trying to use the same
Chris@41 3579 temporary object file, and libtool could not work around it because
Chris@41 3580 your compiler does not support '-c' and '-o' together. If you
Chris@41 3581 repeat this compilation, it may succeed, by chance, but you had better
Chris@41 3582 avoid parallel builds (make -j) in this platform, or get a better
Chris@41 3583 compiler."
Chris@41 3584
Chris@41 3585 $opt_dry_run || $RM $removelist
Chris@41 3586 exit $EXIT_FAILURE
Chris@41 3587 fi
Chris@41 3588
Chris@41 3589 # Just move the object if needed
Chris@41 3590 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
Chris@41 3591 func_show_eval '$MV "$output_obj" "$obj"' \
Chris@41 3592 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
Chris@41 3593 fi
Chris@41 3594 fi
Chris@41 3595
Chris@41 3596 $opt_dry_run || {
Chris@41 3597 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
Chris@41 3598
Chris@41 3599 # Unlock the critical section if it was locked
Chris@41 3600 if test no != "$need_locks"; then
Chris@41 3601 removelist=$lockfile
Chris@41 3602 $RM "$lockfile"
Chris@41 3603 fi
Chris@41 3604 }
Chris@41 3605
Chris@41 3606 exit $EXIT_SUCCESS
Chris@41 3607 }
Chris@41 3608
Chris@41 3609 $opt_help || {
Chris@41 3610 test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
Chris@41 3611 }
Chris@41 3612
Chris@41 3613 func_mode_help ()
Chris@41 3614 {
Chris@41 3615 # We need to display help for each of the modes.
Chris@41 3616 case $opt_mode in
Chris@41 3617 "")
Chris@41 3618 # Generic help is extracted from the usage comments
Chris@41 3619 # at the start of this file.
Chris@41 3620 func_help
Chris@41 3621 ;;
Chris@41 3622
Chris@41 3623 clean)
Chris@41 3624 $ECHO \
Chris@41 3625 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
Chris@41 3626
Chris@41 3627 Remove files from the build directory.
Chris@41 3628
Chris@41 3629 RM is the name of the program to use to delete files associated with each FILE
Chris@41 3630 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
Chris@41 3631 to RM.
Chris@41 3632
Chris@41 3633 If FILE is a libtool library, object or program, all the files associated
Chris@41 3634 with it are deleted. Otherwise, only FILE itself is deleted using RM."
Chris@41 3635 ;;
Chris@41 3636
Chris@41 3637 compile)
Chris@41 3638 $ECHO \
Chris@41 3639 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
Chris@41 3640
Chris@41 3641 Compile a source file into a libtool library object.
Chris@41 3642
Chris@41 3643 This mode accepts the following additional options:
Chris@41 3644
Chris@41 3645 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
Chris@41 3646 -no-suppress do not suppress compiler output for multiple passes
Chris@41 3647 -prefer-pic try to build PIC objects only
Chris@41 3648 -prefer-non-pic try to build non-PIC objects only
Chris@41 3649 -shared do not build a '.o' file suitable for static linking
Chris@41 3650 -static only build a '.o' file suitable for static linking
Chris@41 3651 -Wc,FLAG pass FLAG directly to the compiler
Chris@41 3652
Chris@41 3653 COMPILE-COMMAND is a command to be used in creating a 'standard' object file
Chris@41 3654 from the given SOURCEFILE.
Chris@41 3655
Chris@41 3656 The output file name is determined by removing the directory component from
Chris@41 3657 SOURCEFILE, then substituting the C source code suffix '.c' with the
Chris@41 3658 library object suffix, '.lo'."
Chris@41 3659 ;;
Chris@41 3660
Chris@41 3661 execute)
Chris@41 3662 $ECHO \
Chris@41 3663 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
Chris@41 3664
Chris@41 3665 Automatically set library path, then run a program.
Chris@41 3666
Chris@41 3667 This mode accepts the following additional options:
Chris@41 3668
Chris@41 3669 -dlopen FILE add the directory containing FILE to the library path
Chris@41 3670
Chris@41 3671 This mode sets the library path environment variable according to '-dlopen'
Chris@41 3672 flags.
Chris@41 3673
Chris@41 3674 If any of the ARGS are libtool executable wrappers, then they are translated
Chris@41 3675 into their corresponding uninstalled binary, and any of their required library
Chris@41 3676 directories are added to the library path.
Chris@41 3677
Chris@41 3678 Then, COMMAND is executed, with ARGS as arguments."
Chris@41 3679 ;;
Chris@41 3680
Chris@41 3681 finish)
Chris@41 3682 $ECHO \
Chris@41 3683 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
Chris@41 3684
Chris@41 3685 Complete the installation of libtool libraries.
Chris@41 3686
Chris@41 3687 Each LIBDIR is a directory that contains libtool libraries.
Chris@41 3688
Chris@41 3689 The commands that this mode executes may require superuser privileges. Use
Chris@41 3690 the '--dry-run' option if you just want to see what would be executed."
Chris@41 3691 ;;
Chris@41 3692
Chris@41 3693 install)
Chris@41 3694 $ECHO \
Chris@41 3695 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
Chris@41 3696
Chris@41 3697 Install executables or libraries.
Chris@41 3698
Chris@41 3699 INSTALL-COMMAND is the installation command. The first component should be
Chris@41 3700 either the 'install' or 'cp' program.
Chris@41 3701
Chris@41 3702 The following components of INSTALL-COMMAND are treated specially:
Chris@41 3703
Chris@41 3704 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
Chris@41 3705
Chris@41 3706 The rest of the components are interpreted as arguments to that command (only
Chris@41 3707 BSD-compatible install options are recognized)."
Chris@41 3708 ;;
Chris@41 3709
Chris@41 3710 link)
Chris@41 3711 $ECHO \
Chris@41 3712 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
Chris@41 3713
Chris@41 3714 Link object files or libraries together to form another library, or to
Chris@41 3715 create an executable program.
Chris@41 3716
Chris@41 3717 LINK-COMMAND is a command using the C compiler that you would use to create
Chris@41 3718 a program from several object files.
Chris@41 3719
Chris@41 3720 The following components of LINK-COMMAND are treated specially:
Chris@41 3721
Chris@41 3722 -all-static do not do any dynamic linking at all
Chris@41 3723 -avoid-version do not add a version suffix if possible
Chris@41 3724 -bindir BINDIR specify path to binaries directory (for systems where
Chris@41 3725 libraries must be found in the PATH setting at runtime)
Chris@41 3726 -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
Chris@41 3727 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
Chris@41 3728 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
Chris@41 3729 -export-symbols SYMFILE
Chris@41 3730 try to export only the symbols listed in SYMFILE
Chris@41 3731 -export-symbols-regex REGEX
Chris@41 3732 try to export only the symbols matching REGEX
Chris@41 3733 -LLIBDIR search LIBDIR for required installed libraries
Chris@41 3734 -lNAME OUTPUT-FILE requires the installed library libNAME
Chris@41 3735 -module build a library that can dlopened
Chris@41 3736 -no-fast-install disable the fast-install mode
Chris@41 3737 -no-install link a not-installable executable
Chris@41 3738 -no-undefined declare that a library does not refer to external symbols
Chris@41 3739 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
Chris@41 3740 -objectlist FILE use a list of object files found in FILE to specify objects
Chris@41 3741 -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
Chris@41 3742 -precious-files-regex REGEX
Chris@41 3743 don't remove output files matching REGEX
Chris@41 3744 -release RELEASE specify package release information
Chris@41 3745 -rpath LIBDIR the created library will eventually be installed in LIBDIR
Chris@41 3746 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
Chris@41 3747 -shared only do dynamic linking of libtool libraries
Chris@41 3748 -shrext SUFFIX override the standard shared library file extension
Chris@41 3749 -static do not do any dynamic linking of uninstalled libtool libraries
Chris@41 3750 -static-libtool-libs
Chris@41 3751 do not do any dynamic linking of libtool libraries
Chris@41 3752 -version-info CURRENT[:REVISION[:AGE]]
Chris@41 3753 specify library version info [each variable defaults to 0]
Chris@41 3754 -weak LIBNAME declare that the target provides the LIBNAME interface
Chris@41 3755 -Wc,FLAG
Chris@41 3756 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
Chris@41 3757 -Wl,FLAG
Chris@41 3758 -Xlinker FLAG pass linker-specific FLAG directly to the linker
Chris@41 3759 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
Chris@41 3760
Chris@41 3761 All other options (arguments beginning with '-') are ignored.
Chris@41 3762
Chris@41 3763 Every other argument is treated as a filename. Files ending in '.la' are
Chris@41 3764 treated as uninstalled libtool libraries, other files are standard or library
Chris@41 3765 object files.
Chris@41 3766
Chris@41 3767 If the OUTPUT-FILE ends in '.la', then a libtool library is created,
Chris@41 3768 only library objects ('.lo' files) may be specified, and '-rpath' is
Chris@41 3769 required, except when creating a convenience library.
Chris@41 3770
Chris@41 3771 If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
Chris@41 3772 using 'ar' and 'ranlib', or on Windows using 'lib'.
Chris@41 3773
Chris@41 3774 If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
Chris@41 3775 is created, otherwise an executable program is created."
Chris@41 3776 ;;
Chris@41 3777
Chris@41 3778 uninstall)
Chris@41 3779 $ECHO \
Chris@41 3780 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
Chris@41 3781
Chris@41 3782 Remove libraries from an installation directory.
Chris@41 3783
Chris@41 3784 RM is the name of the program to use to delete files associated with each FILE
Chris@41 3785 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
Chris@41 3786 to RM.
Chris@41 3787
Chris@41 3788 If FILE is a libtool library, all the files associated with it are deleted.
Chris@41 3789 Otherwise, only FILE itself is deleted using RM."
Chris@41 3790 ;;
Chris@41 3791
Chris@41 3792 *)
Chris@41 3793 func_fatal_help "invalid operation mode '$opt_mode'"
Chris@41 3794 ;;
Chris@41 3795 esac
Chris@41 3796
Chris@41 3797 echo
Chris@41 3798 $ECHO "Try '$progname --help' for more information about other modes."
Chris@41 3799 }
Chris@41 3800
Chris@41 3801 # Now that we've collected a possible --mode arg, show help if necessary
Chris@41 3802 if $opt_help; then
Chris@41 3803 if test : = "$opt_help"; then
Chris@41 3804 func_mode_help
Chris@41 3805 else
Chris@41 3806 {
Chris@41 3807 func_help noexit
Chris@41 3808 for opt_mode in compile link execute install finish uninstall clean; do
Chris@41 3809 func_mode_help
Chris@41 3810 done
Chris@41 3811 } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
Chris@41 3812 {
Chris@41 3813 func_help noexit
Chris@41 3814 for opt_mode in compile link execute install finish uninstall clean; do
Chris@41 3815 echo
Chris@41 3816 func_mode_help
Chris@41 3817 done
Chris@41 3818 } |
Chris@41 3819 $SED '1d
Chris@41 3820 /^When reporting/,/^Report/{
Chris@41 3821 H
Chris@41 3822 d
Chris@41 3823 }
Chris@41 3824 $x
Chris@41 3825 /information about other modes/d
Chris@41 3826 /more detailed .*MODE/d
Chris@41 3827 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
Chris@41 3828 fi
Chris@41 3829 exit $?
Chris@41 3830 fi
Chris@41 3831
Chris@41 3832
Chris@41 3833 # func_mode_execute arg...
Chris@41 3834 func_mode_execute ()
Chris@41 3835 {
Chris@41 3836 $debug_cmd
Chris@41 3837
Chris@41 3838 # The first argument is the command name.
Chris@41 3839 cmd=$nonopt
Chris@41 3840 test -z "$cmd" && \
Chris@41 3841 func_fatal_help "you must specify a COMMAND"
Chris@41 3842
Chris@41 3843 # Handle -dlopen flags immediately.
Chris@41 3844 for file in $opt_dlopen; do
Chris@41 3845 test -f "$file" \
Chris@41 3846 || func_fatal_help "'$file' is not a file"
Chris@41 3847
Chris@41 3848 dir=
Chris@41 3849 case $file in
Chris@41 3850 *.la)
Chris@41 3851 func_resolve_sysroot "$file"
Chris@41 3852 file=$func_resolve_sysroot_result
Chris@41 3853
Chris@41 3854 # Check to see that this really is a libtool archive.
Chris@41 3855 func_lalib_unsafe_p "$file" \
Chris@41 3856 || func_fatal_help "'$lib' is not a valid libtool archive"
Chris@41 3857
Chris@41 3858 # Read the libtool library.
Chris@41 3859 dlname=
Chris@41 3860 library_names=
Chris@41 3861 func_source "$file"
Chris@41 3862
Chris@41 3863 # Skip this library if it cannot be dlopened.
Chris@41 3864 if test -z "$dlname"; then
Chris@41 3865 # Warn if it was a shared library.
Chris@41 3866 test -n "$library_names" && \
Chris@41 3867 func_warning "'$file' was not linked with '-export-dynamic'"
Chris@41 3868 continue
Chris@41 3869 fi
Chris@41 3870
Chris@41 3871 func_dirname "$file" "" "."
Chris@41 3872 dir=$func_dirname_result
Chris@41 3873
Chris@41 3874 if test -f "$dir/$objdir/$dlname"; then
Chris@41 3875 func_append dir "/$objdir"
Chris@41 3876 else
Chris@41 3877 if test ! -f "$dir/$dlname"; then
Chris@41 3878 func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
Chris@41 3879 fi
Chris@41 3880 fi
Chris@41 3881 ;;
Chris@41 3882
Chris@41 3883 *.lo)
Chris@41 3884 # Just add the directory containing the .lo file.
Chris@41 3885 func_dirname "$file" "" "."
Chris@41 3886 dir=$func_dirname_result
Chris@41 3887 ;;
Chris@41 3888
Chris@41 3889 *)
Chris@41 3890 func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
Chris@41 3891 continue
Chris@41 3892 ;;
Chris@41 3893 esac
Chris@41 3894
Chris@41 3895 # Get the absolute pathname.
Chris@41 3896 absdir=`cd "$dir" && pwd`
Chris@41 3897 test -n "$absdir" && dir=$absdir
Chris@41 3898
Chris@41 3899 # Now add the directory to shlibpath_var.
Chris@41 3900 if eval "test -z \"\$$shlibpath_var\""; then
Chris@41 3901 eval "$shlibpath_var=\"\$dir\""
Chris@41 3902 else
Chris@41 3903 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
Chris@41 3904 fi
Chris@41 3905 done
Chris@41 3906
Chris@41 3907 # This variable tells wrapper scripts just to set shlibpath_var
Chris@41 3908 # rather than running their programs.
Chris@41 3909 libtool_execute_magic=$magic
Chris@41 3910
Chris@41 3911 # Check if any of the arguments is a wrapper script.
Chris@41 3912 args=
Chris@41 3913 for file
Chris@41 3914 do
Chris@41 3915 case $file in
Chris@41 3916 -* | *.la | *.lo ) ;;
Chris@41 3917 *)
Chris@41 3918 # Do a test to see if this is really a libtool program.
Chris@41 3919 if func_ltwrapper_script_p "$file"; then
Chris@41 3920 func_source "$file"
Chris@41 3921 # Transform arg to wrapped name.
Chris@41 3922 file=$progdir/$program
Chris@41 3923 elif func_ltwrapper_executable_p "$file"; then
Chris@41 3924 func_ltwrapper_scriptname "$file"
Chris@41 3925 func_source "$func_ltwrapper_scriptname_result"
Chris@41 3926 # Transform arg to wrapped name.
Chris@41 3927 file=$progdir/$program
Chris@41 3928 fi
Chris@41 3929 ;;
Chris@41 3930 esac
Chris@41 3931 # Quote arguments (to preserve shell metacharacters).
Chris@41 3932 func_append_quoted args "$file"
Chris@41 3933 done
Chris@41 3934
Chris@41 3935 if $opt_dry_run; then
Chris@41 3936 # Display what would be done.
Chris@41 3937 if test -n "$shlibpath_var"; then
Chris@41 3938 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
Chris@41 3939 echo "export $shlibpath_var"
Chris@41 3940 fi
Chris@41 3941 $ECHO "$cmd$args"
Chris@41 3942 exit $EXIT_SUCCESS
Chris@41 3943 else
Chris@41 3944 if test -n "$shlibpath_var"; then
Chris@41 3945 # Export the shlibpath_var.
Chris@41 3946 eval "export $shlibpath_var"
Chris@41 3947 fi
Chris@41 3948
Chris@41 3949 # Restore saved environment variables
Chris@41 3950 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
Chris@41 3951 do
Chris@41 3952 eval "if test \"\${save_$lt_var+set}\" = set; then
Chris@41 3953 $lt_var=\$save_$lt_var; export $lt_var
Chris@41 3954 else
Chris@41 3955 $lt_unset $lt_var
Chris@41 3956 fi"
Chris@41 3957 done
Chris@41 3958
Chris@41 3959 # Now prepare to actually exec the command.
Chris@41 3960 exec_cmd=\$cmd$args
Chris@41 3961 fi
Chris@41 3962 }
Chris@41 3963
Chris@41 3964 test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
Chris@41 3965
Chris@41 3966
Chris@41 3967 # func_mode_finish arg...
Chris@41 3968 func_mode_finish ()
Chris@41 3969 {
Chris@41 3970 $debug_cmd
Chris@41 3971
Chris@41 3972 libs=
Chris@41 3973 libdirs=
Chris@41 3974 admincmds=
Chris@41 3975
Chris@41 3976 for opt in "$nonopt" ${1+"$@"}
Chris@41 3977 do
Chris@41 3978 if test -d "$opt"; then
Chris@41 3979 func_append libdirs " $opt"
Chris@41 3980
Chris@41 3981 elif test -f "$opt"; then
Chris@41 3982 if func_lalib_unsafe_p "$opt"; then
Chris@41 3983 func_append libs " $opt"
Chris@41 3984 else
Chris@41 3985 func_warning "'$opt' is not a valid libtool archive"
Chris@41 3986 fi
Chris@41 3987
Chris@41 3988 else
Chris@41 3989 func_fatal_error "invalid argument '$opt'"
Chris@41 3990 fi
Chris@41 3991 done
Chris@41 3992
Chris@41 3993 if test -n "$libs"; then
Chris@41 3994 if test -n "$lt_sysroot"; then
Chris@41 3995 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
Chris@41 3996 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
Chris@41 3997 else
Chris@41 3998 sysroot_cmd=
Chris@41 3999 fi
Chris@41 4000
Chris@41 4001 # Remove sysroot references
Chris@41 4002 if $opt_dry_run; then
Chris@41 4003 for lib in $libs; do
Chris@41 4004 echo "removing references to $lt_sysroot and '=' prefixes from $lib"
Chris@41 4005 done
Chris@41 4006 else
Chris@41 4007 tmpdir=`func_mktempdir`
Chris@41 4008 for lib in $libs; do
Chris@41 4009 $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
Chris@41 4010 > $tmpdir/tmp-la
Chris@41 4011 mv -f $tmpdir/tmp-la $lib
Chris@41 4012 done
Chris@41 4013 ${RM}r "$tmpdir"
Chris@41 4014 fi
Chris@41 4015 fi
Chris@41 4016
Chris@41 4017 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
Chris@41 4018 for libdir in $libdirs; do
Chris@41 4019 if test -n "$finish_cmds"; then
Chris@41 4020 # Do each command in the finish commands.
Chris@41 4021 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
Chris@41 4022 '"$cmd"'"'
Chris@41 4023 fi
Chris@41 4024 if test -n "$finish_eval"; then
Chris@41 4025 # Do the single finish_eval.
Chris@41 4026 eval cmds=\"$finish_eval\"
Chris@41 4027 $opt_dry_run || eval "$cmds" || func_append admincmds "
Chris@41 4028 $cmds"
Chris@41 4029 fi
Chris@41 4030 done
Chris@41 4031 fi
Chris@41 4032
Chris@41 4033 # Exit here if they wanted silent mode.
Chris@41 4034 $opt_quiet && exit $EXIT_SUCCESS
Chris@41 4035
Chris@41 4036 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
Chris@41 4037 echo "----------------------------------------------------------------------"
Chris@41 4038 echo "Libraries have been installed in:"
Chris@41 4039 for libdir in $libdirs; do
Chris@41 4040 $ECHO " $libdir"
Chris@41 4041 done
Chris@41 4042 echo
Chris@41 4043 echo "If you ever happen to want to link against installed libraries"
Chris@41 4044 echo "in a given directory, LIBDIR, you must either use libtool, and"
Chris@41 4045 echo "specify the full pathname of the library, or use the '-LLIBDIR'"
Chris@41 4046 echo "flag during linking and do at least one of the following:"
Chris@41 4047 if test -n "$shlibpath_var"; then
Chris@41 4048 echo " - add LIBDIR to the '$shlibpath_var' environment variable"
Chris@41 4049 echo " during execution"
Chris@41 4050 fi
Chris@41 4051 if test -n "$runpath_var"; then
Chris@41 4052 echo " - add LIBDIR to the '$runpath_var' environment variable"
Chris@41 4053 echo " during linking"
Chris@41 4054 fi
Chris@41 4055 if test -n "$hardcode_libdir_flag_spec"; then
Chris@41 4056 libdir=LIBDIR
Chris@41 4057 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@41 4058
Chris@41 4059 $ECHO " - use the '$flag' linker flag"
Chris@41 4060 fi
Chris@41 4061 if test -n "$admincmds"; then
Chris@41 4062 $ECHO " - have your system administrator run these commands:$admincmds"
Chris@41 4063 fi
Chris@41 4064 if test -f /etc/ld.so.conf; then
Chris@41 4065 echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
Chris@41 4066 fi
Chris@41 4067 echo
Chris@41 4068
Chris@41 4069 echo "See any operating system documentation about shared libraries for"
Chris@41 4070 case $host in
Chris@41 4071 solaris2.[6789]|solaris2.1[0-9])
Chris@41 4072 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
Chris@41 4073 echo "pages."
Chris@41 4074 ;;
Chris@41 4075 *)
Chris@41 4076 echo "more information, such as the ld(1) and ld.so(8) manual pages."
Chris@41 4077 ;;
Chris@41 4078 esac
Chris@41 4079 echo "----------------------------------------------------------------------"
Chris@41 4080 fi
Chris@41 4081 exit $EXIT_SUCCESS
Chris@41 4082 }
Chris@41 4083
Chris@41 4084 test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
Chris@41 4085
Chris@41 4086
Chris@41 4087 # func_mode_install arg...
Chris@41 4088 func_mode_install ()
Chris@41 4089 {
Chris@41 4090 $debug_cmd
Chris@41 4091
Chris@41 4092 # There may be an optional sh(1) argument at the beginning of
Chris@41 4093 # install_prog (especially on Windows NT).
Chris@41 4094 if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
Chris@41 4095 # Allow the use of GNU shtool's install command.
Chris@41 4096 case $nonopt in *shtool*) :;; *) false;; esac
Chris@41 4097 then
Chris@41 4098 # Aesthetically quote it.
Chris@41 4099 func_quote_for_eval "$nonopt"
Chris@41 4100 install_prog="$func_quote_for_eval_result "
Chris@41 4101 arg=$1
Chris@41 4102 shift
Chris@41 4103 else
Chris@41 4104 install_prog=
Chris@41 4105 arg=$nonopt
Chris@41 4106 fi
Chris@41 4107
Chris@41 4108 # The real first argument should be the name of the installation program.
Chris@41 4109 # Aesthetically quote it.
Chris@41 4110 func_quote_for_eval "$arg"
Chris@41 4111 func_append install_prog "$func_quote_for_eval_result"
Chris@41 4112 install_shared_prog=$install_prog
Chris@41 4113 case " $install_prog " in
Chris@41 4114 *[\\\ /]cp\ *) install_cp=: ;;
Chris@41 4115 *) install_cp=false ;;
Chris@41 4116 esac
Chris@41 4117
Chris@41 4118 # We need to accept at least all the BSD install flags.
Chris@41 4119 dest=
Chris@41 4120 files=
Chris@41 4121 opts=
Chris@41 4122 prev=
Chris@41 4123 install_type=
Chris@41 4124 isdir=false
Chris@41 4125 stripme=
Chris@41 4126 no_mode=:
Chris@41 4127 for arg
Chris@41 4128 do
Chris@41 4129 arg2=
Chris@41 4130 if test -n "$dest"; then
Chris@41 4131 func_append files " $dest"
Chris@41 4132 dest=$arg
Chris@41 4133 continue
Chris@41 4134 fi
Chris@41 4135
Chris@41 4136 case $arg in
Chris@41 4137 -d) isdir=: ;;
Chris@41 4138 -f)
Chris@41 4139 if $install_cp; then :; else
Chris@41 4140 prev=$arg
Chris@41 4141 fi
Chris@41 4142 ;;
Chris@41 4143 -g | -m | -o)
Chris@41 4144 prev=$arg
Chris@41 4145 ;;
Chris@41 4146 -s)
Chris@41 4147 stripme=" -s"
Chris@41 4148 continue
Chris@41 4149 ;;
Chris@41 4150 -*)
Chris@41 4151 ;;
Chris@41 4152 *)
Chris@41 4153 # If the previous option needed an argument, then skip it.
Chris@41 4154 if test -n "$prev"; then
Chris@41 4155 if test X-m = "X$prev" && test -n "$install_override_mode"; then
Chris@41 4156 arg2=$install_override_mode
Chris@41 4157 no_mode=false
Chris@41 4158 fi
Chris@41 4159 prev=
Chris@41 4160 else
Chris@41 4161 dest=$arg
Chris@41 4162 continue
Chris@41 4163 fi
Chris@41 4164 ;;
Chris@41 4165 esac
Chris@41 4166
Chris@41 4167 # Aesthetically quote the argument.
Chris@41 4168 func_quote_for_eval "$arg"
Chris@41 4169 func_append install_prog " $func_quote_for_eval_result"
Chris@41 4170 if test -n "$arg2"; then
Chris@41 4171 func_quote_for_eval "$arg2"
Chris@41 4172 fi
Chris@41 4173 func_append install_shared_prog " $func_quote_for_eval_result"
Chris@41 4174 done
Chris@41 4175
Chris@41 4176 test -z "$install_prog" && \
Chris@41 4177 func_fatal_help "you must specify an install program"
Chris@41 4178
Chris@41 4179 test -n "$prev" && \
Chris@41 4180 func_fatal_help "the '$prev' option requires an argument"
Chris@41 4181
Chris@41 4182 if test -n "$install_override_mode" && $no_mode; then
Chris@41 4183 if $install_cp; then :; else
Chris@41 4184 func_quote_for_eval "$install_override_mode"
Chris@41 4185 func_append install_shared_prog " -m $func_quote_for_eval_result"
Chris@41 4186 fi
Chris@41 4187 fi
Chris@41 4188
Chris@41 4189 if test -z "$files"; then
Chris@41 4190 if test -z "$dest"; then
Chris@41 4191 func_fatal_help "no file or destination specified"
Chris@41 4192 else
Chris@41 4193 func_fatal_help "you must specify a destination"
Chris@41 4194 fi
Chris@41 4195 fi
Chris@41 4196
Chris@41 4197 # Strip any trailing slash from the destination.
Chris@41 4198 func_stripname '' '/' "$dest"
Chris@41 4199 dest=$func_stripname_result
Chris@41 4200
Chris@41 4201 # Check to see that the destination is a directory.
Chris@41 4202 test -d "$dest" && isdir=:
Chris@41 4203 if $isdir; then
Chris@41 4204 destdir=$dest
Chris@41 4205 destname=
Chris@41 4206 else
Chris@41 4207 func_dirname_and_basename "$dest" "" "."
Chris@41 4208 destdir=$func_dirname_result
Chris@41 4209 destname=$func_basename_result
Chris@41 4210
Chris@41 4211 # Not a directory, so check to see that there is only one file specified.
Chris@41 4212 set dummy $files; shift
Chris@41 4213 test "$#" -gt 1 && \
Chris@41 4214 func_fatal_help "'$dest' is not a directory"
Chris@41 4215 fi
Chris@41 4216 case $destdir in
Chris@41 4217 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@41 4218 *)
Chris@41 4219 for file in $files; do
Chris@41 4220 case $file in
Chris@41 4221 *.lo) ;;
Chris@41 4222 *)
Chris@41 4223 func_fatal_help "'$destdir' must be an absolute directory name"
Chris@41 4224 ;;
Chris@41 4225 esac
Chris@41 4226 done
Chris@41 4227 ;;
Chris@41 4228 esac
Chris@41 4229
Chris@41 4230 # This variable tells wrapper scripts just to set variables rather
Chris@41 4231 # than running their programs.
Chris@41 4232 libtool_install_magic=$magic
Chris@41 4233
Chris@41 4234 staticlibs=
Chris@41 4235 future_libdirs=
Chris@41 4236 current_libdirs=
Chris@41 4237 for file in $files; do
Chris@41 4238
Chris@41 4239 # Do each installation.
Chris@41 4240 case $file in
Chris@41 4241 *.$libext)
Chris@41 4242 # Do the static libraries later.
Chris@41 4243 func_append staticlibs " $file"
Chris@41 4244 ;;
Chris@41 4245
Chris@41 4246 *.la)
Chris@41 4247 func_resolve_sysroot "$file"
Chris@41 4248 file=$func_resolve_sysroot_result
Chris@41 4249
Chris@41 4250 # Check to see that this really is a libtool archive.
Chris@41 4251 func_lalib_unsafe_p "$file" \
Chris@41 4252 || func_fatal_help "'$file' is not a valid libtool archive"
Chris@41 4253
Chris@41 4254 library_names=
Chris@41 4255 old_library=
Chris@41 4256 relink_command=
Chris@41 4257 func_source "$file"
Chris@41 4258
Chris@41 4259 # Add the libdir to current_libdirs if it is the destination.
Chris@41 4260 if test "X$destdir" = "X$libdir"; then
Chris@41 4261 case "$current_libdirs " in
Chris@41 4262 *" $libdir "*) ;;
Chris@41 4263 *) func_append current_libdirs " $libdir" ;;
Chris@41 4264 esac
Chris@41 4265 else
Chris@41 4266 # Note the libdir as a future libdir.
Chris@41 4267 case "$future_libdirs " in
Chris@41 4268 *" $libdir "*) ;;
Chris@41 4269 *) func_append future_libdirs " $libdir" ;;
Chris@41 4270 esac
Chris@41 4271 fi
Chris@41 4272
Chris@41 4273 func_dirname "$file" "/" ""
Chris@41 4274 dir=$func_dirname_result
Chris@41 4275 func_append dir "$objdir"
Chris@41 4276
Chris@41 4277 if test -n "$relink_command"; then
Chris@41 4278 # Determine the prefix the user has applied to our future dir.
Chris@41 4279 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
Chris@41 4280
Chris@41 4281 # Don't allow the user to place us outside of our expected
Chris@41 4282 # location b/c this prevents finding dependent libraries that
Chris@41 4283 # are installed to the same prefix.
Chris@41 4284 # At present, this check doesn't affect windows .dll's that
Chris@41 4285 # are installed into $libdir/../bin (currently, that works fine)
Chris@41 4286 # but it's something to keep an eye on.
Chris@41 4287 test "$inst_prefix_dir" = "$destdir" && \
Chris@41 4288 func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
Chris@41 4289
Chris@41 4290 if test -n "$inst_prefix_dir"; then
Chris@41 4291 # Stick the inst_prefix_dir data into the link command.
Chris@41 4292 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
Chris@41 4293 else
Chris@41 4294 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
Chris@41 4295 fi
Chris@41 4296
Chris@41 4297 func_warning "relinking '$file'"
Chris@41 4298 func_show_eval "$relink_command" \
Chris@41 4299 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
Chris@41 4300 fi
Chris@41 4301
Chris@41 4302 # See the names of the shared library.
Chris@41 4303 set dummy $library_names; shift
Chris@41 4304 if test -n "$1"; then
Chris@41 4305 realname=$1
Chris@41 4306 shift
Chris@41 4307
Chris@41 4308 srcname=$realname
Chris@41 4309 test -n "$relink_command" && srcname=${realname}T
Chris@41 4310
Chris@41 4311 # Install the shared library and build the symlinks.
Chris@41 4312 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
Chris@41 4313 'exit $?'
Chris@41 4314 tstripme=$stripme
Chris@41 4315 case $host_os in
Chris@41 4316 cygwin* | mingw* | pw32* | cegcc*)
Chris@41 4317 case $realname in
Chris@41 4318 *.dll.a)
Chris@41 4319 tstripme=
Chris@41 4320 ;;
Chris@41 4321 esac
Chris@41 4322 ;;
Chris@41 4323 os2*)
Chris@41 4324 case $realname in
Chris@41 4325 *_dll.a)
Chris@41 4326 tstripme=
Chris@41 4327 ;;
Chris@41 4328 esac
Chris@41 4329 ;;
Chris@41 4330 esac
Chris@41 4331 if test -n "$tstripme" && test -n "$striplib"; then
Chris@41 4332 func_show_eval "$striplib $destdir/$realname" 'exit $?'
Chris@41 4333 fi
Chris@41 4334
Chris@41 4335 if test "$#" -gt 0; then
Chris@41 4336 # Delete the old symlinks, and create new ones.
Chris@41 4337 # Try 'ln -sf' first, because the 'ln' binary might depend on
Chris@41 4338 # the symlink we replace! Solaris /bin/ln does not understand -f,
Chris@41 4339 # so we also need to try rm && ln -s.
Chris@41 4340 for linkname
Chris@41 4341 do
Chris@41 4342 test "$linkname" != "$realname" \
Chris@41 4343 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
Chris@41 4344 done
Chris@41 4345 fi
Chris@41 4346
Chris@41 4347 # Do each command in the postinstall commands.
Chris@41 4348 lib=$destdir/$realname
Chris@41 4349 func_execute_cmds "$postinstall_cmds" 'exit $?'
Chris@41 4350 fi
Chris@41 4351
Chris@41 4352 # Install the pseudo-library for information purposes.
Chris@41 4353 func_basename "$file"
Chris@41 4354 name=$func_basename_result
Chris@41 4355 instname=$dir/${name}i
Chris@41 4356 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
Chris@41 4357
Chris@41 4358 # Maybe install the static library, too.
Chris@41 4359 test -n "$old_library" && func_append staticlibs " $dir/$old_library"
Chris@41 4360 ;;
Chris@41 4361
Chris@41 4362 *.lo)
Chris@41 4363 # Install (i.e. copy) a libtool object.
Chris@41 4364
Chris@41 4365 # Figure out destination file name, if it wasn't already specified.
Chris@41 4366 if test -n "$destname"; then
Chris@41 4367 destfile=$destdir/$destname
Chris@41 4368 else
Chris@41 4369 func_basename "$file"
Chris@41 4370 destfile=$func_basename_result
Chris@41 4371 destfile=$destdir/$destfile
Chris@41 4372 fi
Chris@41 4373
Chris@41 4374 # Deduce the name of the destination old-style object file.
Chris@41 4375 case $destfile in
Chris@41 4376 *.lo)
Chris@41 4377 func_lo2o "$destfile"
Chris@41 4378 staticdest=$func_lo2o_result
Chris@41 4379 ;;
Chris@41 4380 *.$objext)
Chris@41 4381 staticdest=$destfile
Chris@41 4382 destfile=
Chris@41 4383 ;;
Chris@41 4384 *)
Chris@41 4385 func_fatal_help "cannot copy a libtool object to '$destfile'"
Chris@41 4386 ;;
Chris@41 4387 esac
Chris@41 4388
Chris@41 4389 # Install the libtool object if requested.
Chris@41 4390 test -n "$destfile" && \
Chris@41 4391 func_show_eval "$install_prog $file $destfile" 'exit $?'
Chris@41 4392
Chris@41 4393 # Install the old object if enabled.
Chris@41 4394 if test yes = "$build_old_libs"; then
Chris@41 4395 # Deduce the name of the old-style object file.
Chris@41 4396 func_lo2o "$file"
Chris@41 4397 staticobj=$func_lo2o_result
Chris@41 4398 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
Chris@41 4399 fi
Chris@41 4400 exit $EXIT_SUCCESS
Chris@41 4401 ;;
Chris@41 4402
Chris@41 4403 *)
Chris@41 4404 # Figure out destination file name, if it wasn't already specified.
Chris@41 4405 if test -n "$destname"; then
Chris@41 4406 destfile=$destdir/$destname
Chris@41 4407 else
Chris@41 4408 func_basename "$file"
Chris@41 4409 destfile=$func_basename_result
Chris@41 4410 destfile=$destdir/$destfile
Chris@41 4411 fi
Chris@41 4412
Chris@41 4413 # If the file is missing, and there is a .exe on the end, strip it
Chris@41 4414 # because it is most likely a libtool script we actually want to
Chris@41 4415 # install
Chris@41 4416 stripped_ext=
Chris@41 4417 case $file in
Chris@41 4418 *.exe)
Chris@41 4419 if test ! -f "$file"; then
Chris@41 4420 func_stripname '' '.exe' "$file"
Chris@41 4421 file=$func_stripname_result
Chris@41 4422 stripped_ext=.exe
Chris@41 4423 fi
Chris@41 4424 ;;
Chris@41 4425 esac
Chris@41 4426
Chris@41 4427 # Do a test to see if this is really a libtool program.
Chris@41 4428 case $host in
Chris@41 4429 *cygwin* | *mingw*)
Chris@41 4430 if func_ltwrapper_executable_p "$file"; then
Chris@41 4431 func_ltwrapper_scriptname "$file"
Chris@41 4432 wrapper=$func_ltwrapper_scriptname_result
Chris@41 4433 else
Chris@41 4434 func_stripname '' '.exe' "$file"
Chris@41 4435 wrapper=$func_stripname_result
Chris@41 4436 fi
Chris@41 4437 ;;
Chris@41 4438 *)
Chris@41 4439 wrapper=$file
Chris@41 4440 ;;
Chris@41 4441 esac
Chris@41 4442 if func_ltwrapper_script_p "$wrapper"; then
Chris@41 4443 notinst_deplibs=
Chris@41 4444 relink_command=
Chris@41 4445
Chris@41 4446 func_source "$wrapper"
Chris@41 4447
Chris@41 4448 # Check the variables that should have been set.
Chris@41 4449 test -z "$generated_by_libtool_version" && \
Chris@41 4450 func_fatal_error "invalid libtool wrapper script '$wrapper'"
Chris@41 4451
Chris@41 4452 finalize=:
Chris@41 4453 for lib in $notinst_deplibs; do
Chris@41 4454 # Check to see that each library is installed.
Chris@41 4455 libdir=
Chris@41 4456 if test -f "$lib"; then
Chris@41 4457 func_source "$lib"
Chris@41 4458 fi
Chris@41 4459 libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
Chris@41 4460 if test -n "$libdir" && test ! -f "$libfile"; then
Chris@41 4461 func_warning "'$lib' has not been installed in '$libdir'"
Chris@41 4462 finalize=false
Chris@41 4463 fi
Chris@41 4464 done
Chris@41 4465
Chris@41 4466 relink_command=
Chris@41 4467 func_source "$wrapper"
Chris@41 4468
Chris@41 4469 outputname=
Chris@41 4470 if test no = "$fast_install" && test -n "$relink_command"; then
Chris@41 4471 $opt_dry_run || {
Chris@41 4472 if $finalize; then
Chris@41 4473 tmpdir=`func_mktempdir`
Chris@41 4474 func_basename "$file$stripped_ext"
Chris@41 4475 file=$func_basename_result
Chris@41 4476 outputname=$tmpdir/$file
Chris@41 4477 # Replace the output file specification.
Chris@41 4478 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
Chris@41 4479
Chris@41 4480 $opt_quiet || {
Chris@41 4481 func_quote_for_expand "$relink_command"
Chris@41 4482 eval "func_echo $func_quote_for_expand_result"
Chris@41 4483 }
Chris@41 4484 if eval "$relink_command"; then :
Chris@41 4485 else
Chris@41 4486 func_error "error: relink '$file' with the above command before installing it"
Chris@41 4487 $opt_dry_run || ${RM}r "$tmpdir"
Chris@41 4488 continue
Chris@41 4489 fi
Chris@41 4490 file=$outputname
Chris@41 4491 else
Chris@41 4492 func_warning "cannot relink '$file'"
Chris@41 4493 fi
Chris@41 4494 }
Chris@41 4495 else
Chris@41 4496 # Install the binary that we compiled earlier.
Chris@41 4497 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
Chris@41 4498 fi
Chris@41 4499 fi
Chris@41 4500
Chris@41 4501 # remove .exe since cygwin /usr/bin/install will append another
Chris@41 4502 # one anyway
Chris@41 4503 case $install_prog,$host in
Chris@41 4504 */usr/bin/install*,*cygwin*)
Chris@41 4505 case $file:$destfile in
Chris@41 4506 *.exe:*.exe)
Chris@41 4507 # this is ok
Chris@41 4508 ;;
Chris@41 4509 *.exe:*)
Chris@41 4510 destfile=$destfile.exe
Chris@41 4511 ;;
Chris@41 4512 *:*.exe)
Chris@41 4513 func_stripname '' '.exe' "$destfile"
Chris@41 4514 destfile=$func_stripname_result
Chris@41 4515 ;;
Chris@41 4516 esac
Chris@41 4517 ;;
Chris@41 4518 esac
Chris@41 4519 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
Chris@41 4520 $opt_dry_run || if test -n "$outputname"; then
Chris@41 4521 ${RM}r "$tmpdir"
Chris@41 4522 fi
Chris@41 4523 ;;
Chris@41 4524 esac
Chris@41 4525 done
Chris@41 4526
Chris@41 4527 for file in $staticlibs; do
Chris@41 4528 func_basename "$file"
Chris@41 4529 name=$func_basename_result
Chris@41 4530
Chris@41 4531 # Set up the ranlib parameters.
Chris@41 4532 oldlib=$destdir/$name
Chris@41 4533 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
Chris@41 4534 tool_oldlib=$func_to_tool_file_result
Chris@41 4535
Chris@41 4536 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
Chris@41 4537
Chris@41 4538 if test -n "$stripme" && test -n "$old_striplib"; then
Chris@41 4539 func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
Chris@41 4540 fi
Chris@41 4541
Chris@41 4542 # Do each command in the postinstall commands.
Chris@41 4543 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
Chris@41 4544 done
Chris@41 4545
Chris@41 4546 test -n "$future_libdirs" && \
Chris@41 4547 func_warning "remember to run '$progname --finish$future_libdirs'"
Chris@41 4548
Chris@41 4549 if test -n "$current_libdirs"; then
Chris@41 4550 # Maybe just do a dry run.
Chris@41 4551 $opt_dry_run && current_libdirs=" -n$current_libdirs"
Chris@41 4552 exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
Chris@41 4553 else
Chris@41 4554 exit $EXIT_SUCCESS
Chris@41 4555 fi
Chris@41 4556 }
Chris@41 4557
Chris@41 4558 test install = "$opt_mode" && func_mode_install ${1+"$@"}
Chris@41 4559
Chris@41 4560
Chris@41 4561 # func_generate_dlsyms outputname originator pic_p
Chris@41 4562 # Extract symbols from dlprefiles and create ${outputname}S.o with
Chris@41 4563 # a dlpreopen symbol table.
Chris@41 4564 func_generate_dlsyms ()
Chris@41 4565 {
Chris@41 4566 $debug_cmd
Chris@41 4567
Chris@41 4568 my_outputname=$1
Chris@41 4569 my_originator=$2
Chris@41 4570 my_pic_p=${3-false}
Chris@41 4571 my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
Chris@41 4572 my_dlsyms=
Chris@41 4573
Chris@41 4574 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
Chris@41 4575 if test -n "$NM" && test -n "$global_symbol_pipe"; then
Chris@41 4576 my_dlsyms=${my_outputname}S.c
Chris@41 4577 else
Chris@41 4578 func_error "not configured to extract global symbols from dlpreopened files"
Chris@41 4579 fi
Chris@41 4580 fi
Chris@41 4581
Chris@41 4582 if test -n "$my_dlsyms"; then
Chris@41 4583 case $my_dlsyms in
Chris@41 4584 "") ;;
Chris@41 4585 *.c)
Chris@41 4586 # Discover the nlist of each of the dlfiles.
Chris@41 4587 nlist=$output_objdir/$my_outputname.nm
Chris@41 4588
Chris@41 4589 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
Chris@41 4590
Chris@41 4591 # Parse the name list into a source file.
Chris@41 4592 func_verbose "creating $output_objdir/$my_dlsyms"
Chris@41 4593
Chris@41 4594 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
Chris@41 4595 /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
Chris@41 4596 /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
Chris@41 4597
Chris@41 4598 #ifdef __cplusplus
Chris@41 4599 extern \"C\" {
Chris@41 4600 #endif
Chris@41 4601
Chris@41 4602 #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
Chris@41 4603 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
Chris@41 4604 #endif
Chris@41 4605
Chris@41 4606 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
Chris@41 4607 #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
Chris@41 4608 /* DATA imports from DLLs on WIN32 can't be const, because runtime
Chris@41 4609 relocations are performed -- see ld's documentation on pseudo-relocs. */
Chris@41 4610 # define LT_DLSYM_CONST
Chris@41 4611 #elif defined __osf__
Chris@41 4612 /* This system does not cope well with relocations in const data. */
Chris@41 4613 # define LT_DLSYM_CONST
Chris@41 4614 #else
Chris@41 4615 # define LT_DLSYM_CONST const
Chris@41 4616 #endif
Chris@41 4617
Chris@41 4618 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
Chris@41 4619
Chris@41 4620 /* External symbol declarations for the compiler. */\
Chris@41 4621 "
Chris@41 4622
Chris@41 4623 if test yes = "$dlself"; then
Chris@41 4624 func_verbose "generating symbol list for '$output'"
Chris@41 4625
Chris@41 4626 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
Chris@41 4627
Chris@41 4628 # Add our own program objects to the symbol list.
Chris@41 4629 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@41 4630 for progfile in $progfiles; do
Chris@41 4631 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
Chris@41 4632 func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
Chris@41 4633 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
Chris@41 4634 done
Chris@41 4635
Chris@41 4636 if test -n "$exclude_expsyms"; then
Chris@41 4637 $opt_dry_run || {
Chris@41 4638 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
Chris@41 4639 eval '$MV "$nlist"T "$nlist"'
Chris@41 4640 }
Chris@41 4641 fi
Chris@41 4642
Chris@41 4643 if test -n "$export_symbols_regex"; then
Chris@41 4644 $opt_dry_run || {
Chris@41 4645 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
Chris@41 4646 eval '$MV "$nlist"T "$nlist"'
Chris@41 4647 }
Chris@41 4648 fi
Chris@41 4649
Chris@41 4650 # Prepare the list of exported symbols
Chris@41 4651 if test -z "$export_symbols"; then
Chris@41 4652 export_symbols=$output_objdir/$outputname.exp
Chris@41 4653 $opt_dry_run || {
Chris@41 4654 $RM $export_symbols
Chris@41 4655 eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
Chris@41 4656 case $host in
Chris@41 4657 *cygwin* | *mingw* | *cegcc* )
Chris@41 4658 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
Chris@41 4659 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
Chris@41 4660 ;;
Chris@41 4661 esac
Chris@41 4662 }
Chris@41 4663 else
Chris@41 4664 $opt_dry_run || {
Chris@41 4665 eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
Chris@41 4666 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
Chris@41 4667 eval '$MV "$nlist"T "$nlist"'
Chris@41 4668 case $host in
Chris@41 4669 *cygwin* | *mingw* | *cegcc* )
Chris@41 4670 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
Chris@41 4671 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
Chris@41 4672 ;;
Chris@41 4673 esac
Chris@41 4674 }
Chris@41 4675 fi
Chris@41 4676 fi
Chris@41 4677
Chris@41 4678 for dlprefile in $dlprefiles; do
Chris@41 4679 func_verbose "extracting global C symbols from '$dlprefile'"
Chris@41 4680 func_basename "$dlprefile"
Chris@41 4681 name=$func_basename_result
Chris@41 4682 case $host in
Chris@41 4683 *cygwin* | *mingw* | *cegcc* )
Chris@41 4684 # if an import library, we need to obtain dlname
Chris@41 4685 if func_win32_import_lib_p "$dlprefile"; then
Chris@41 4686 func_tr_sh "$dlprefile"
Chris@41 4687 eval "curr_lafile=\$libfile_$func_tr_sh_result"
Chris@41 4688 dlprefile_dlbasename=
Chris@41 4689 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
Chris@41 4690 # Use subshell, to avoid clobbering current variable values
Chris@41 4691 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
Chris@41 4692 if test -n "$dlprefile_dlname"; then
Chris@41 4693 func_basename "$dlprefile_dlname"
Chris@41 4694 dlprefile_dlbasename=$func_basename_result
Chris@41 4695 else
Chris@41 4696 # no lafile. user explicitly requested -dlpreopen <import library>.
Chris@41 4697 $sharedlib_from_linklib_cmd "$dlprefile"
Chris@41 4698 dlprefile_dlbasename=$sharedlib_from_linklib_result
Chris@41 4699 fi
Chris@41 4700 fi
Chris@41 4701 $opt_dry_run || {
Chris@41 4702 if test -n "$dlprefile_dlbasename"; then
Chris@41 4703 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
Chris@41 4704 else
Chris@41 4705 func_warning "Could not compute DLL name from $name"
Chris@41 4706 eval '$ECHO ": $name " >> "$nlist"'
Chris@41 4707 fi
Chris@41 4708 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
Chris@41 4709 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
Chris@41 4710 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
Chris@41 4711 }
Chris@41 4712 else # not an import lib
Chris@41 4713 $opt_dry_run || {
Chris@41 4714 eval '$ECHO ": $name " >> "$nlist"'
Chris@41 4715 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
Chris@41 4716 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
Chris@41 4717 }
Chris@41 4718 fi
Chris@41 4719 ;;
Chris@41 4720 *)
Chris@41 4721 $opt_dry_run || {
Chris@41 4722 eval '$ECHO ": $name " >> "$nlist"'
Chris@41 4723 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
Chris@41 4724 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
Chris@41 4725 }
Chris@41 4726 ;;
Chris@41 4727 esac
Chris@41 4728 done
Chris@41 4729
Chris@41 4730 $opt_dry_run || {
Chris@41 4731 # Make sure we have at least an empty file.
Chris@41 4732 test -f "$nlist" || : > "$nlist"
Chris@41 4733
Chris@41 4734 if test -n "$exclude_expsyms"; then
Chris@41 4735 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
Chris@41 4736 $MV "$nlist"T "$nlist"
Chris@41 4737 fi
Chris@41 4738
Chris@41 4739 # Try sorting and uniquifying the output.
Chris@41 4740 if $GREP -v "^: " < "$nlist" |
Chris@41 4741 if sort -k 3 </dev/null >/dev/null 2>&1; then
Chris@41 4742 sort -k 3
Chris@41 4743 else
Chris@41 4744 sort +2
Chris@41 4745 fi |
Chris@41 4746 uniq > "$nlist"S; then
Chris@41 4747 :
Chris@41 4748 else
Chris@41 4749 $GREP -v "^: " < "$nlist" > "$nlist"S
Chris@41 4750 fi
Chris@41 4751
Chris@41 4752 if test -f "$nlist"S; then
Chris@41 4753 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
Chris@41 4754 else
Chris@41 4755 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
Chris@41 4756 fi
Chris@41 4757
Chris@41 4758 func_show_eval '$RM "${nlist}I"'
Chris@41 4759 if test -n "$global_symbol_to_import"; then
Chris@41 4760 eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
Chris@41 4761 fi
Chris@41 4762
Chris@41 4763 echo >> "$output_objdir/$my_dlsyms" "\
Chris@41 4764
Chris@41 4765 /* The mapping between symbol names and symbols. */
Chris@41 4766 typedef struct {
Chris@41 4767 const char *name;
Chris@41 4768 void *address;
Chris@41 4769 } lt_dlsymlist;
Chris@41 4770 extern LT_DLSYM_CONST lt_dlsymlist
Chris@41 4771 lt_${my_prefix}_LTX_preloaded_symbols[];\
Chris@41 4772 "
Chris@41 4773
Chris@41 4774 if test -s "$nlist"I; then
Chris@41 4775 echo >> "$output_objdir/$my_dlsyms" "\
Chris@41 4776 static void lt_syminit(void)
Chris@41 4777 {
Chris@41 4778 LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
Chris@41 4779 for (; symbol->name; ++symbol)
Chris@41 4780 {"
Chris@41 4781 $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
Chris@41 4782 echo >> "$output_objdir/$my_dlsyms" "\
Chris@41 4783 }
Chris@41 4784 }"
Chris@41 4785 fi
Chris@41 4786 echo >> "$output_objdir/$my_dlsyms" "\
Chris@41 4787 LT_DLSYM_CONST lt_dlsymlist
Chris@41 4788 lt_${my_prefix}_LTX_preloaded_symbols[] =
Chris@41 4789 { {\"$my_originator\", (void *) 0},"
Chris@41 4790
Chris@41 4791 if test -s "$nlist"I; then
Chris@41 4792 echo >> "$output_objdir/$my_dlsyms" "\
Chris@41 4793 {\"@INIT@\", (void *) &lt_syminit},"
Chris@41 4794 fi
Chris@41 4795
Chris@41 4796 case $need_lib_prefix in
Chris@41 4797 no)
Chris@41 4798 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
Chris@41 4799 ;;
Chris@41 4800 *)
Chris@41 4801 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
Chris@41 4802 ;;
Chris@41 4803 esac
Chris@41 4804 echo >> "$output_objdir/$my_dlsyms" "\
Chris@41 4805 {0, (void *) 0}
Chris@41 4806 };
Chris@41 4807
Chris@41 4808 /* This works around a problem in FreeBSD linker */
Chris@41 4809 #ifdef FREEBSD_WORKAROUND
Chris@41 4810 static const void *lt_preloaded_setup() {
Chris@41 4811 return lt_${my_prefix}_LTX_preloaded_symbols;
Chris@41 4812 }
Chris@41 4813 #endif
Chris@41 4814
Chris@41 4815 #ifdef __cplusplus
Chris@41 4816 }
Chris@41 4817 #endif\
Chris@41 4818 "
Chris@41 4819 } # !$opt_dry_run
Chris@41 4820
Chris@41 4821 pic_flag_for_symtable=
Chris@41 4822 case "$compile_command " in
Chris@41 4823 *" -static "*) ;;
Chris@41 4824 *)
Chris@41 4825 case $host in
Chris@41 4826 # compiling the symbol table file with pic_flag works around
Chris@41 4827 # a FreeBSD bug that causes programs to crash when -lm is
Chris@41 4828 # linked before any other PIC object. But we must not use
Chris@41 4829 # pic_flag when linking with -static. The problem exists in
Chris@41 4830 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
Chris@41 4831 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
Chris@41 4832 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
Chris@41 4833 *-*-hpux*)
Chris@41 4834 pic_flag_for_symtable=" $pic_flag" ;;
Chris@41 4835 *)
Chris@41 4836 $my_pic_p && pic_flag_for_symtable=" $pic_flag"
Chris@41 4837 ;;
Chris@41 4838 esac
Chris@41 4839 ;;
Chris@41 4840 esac
Chris@41 4841 symtab_cflags=
Chris@41 4842 for arg in $LTCFLAGS; do
Chris@41 4843 case $arg in
Chris@41 4844 -pie | -fpie | -fPIE) ;;
Chris@41 4845 *) func_append symtab_cflags " $arg" ;;
Chris@41 4846 esac
Chris@41 4847 done
Chris@41 4848
Chris@41 4849 # Now compile the dynamic symbol file.
Chris@41 4850 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
Chris@41 4851
Chris@41 4852 # Clean up the generated files.
Chris@41 4853 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
Chris@41 4854
Chris@41 4855 # Transform the symbol file into the correct name.
Chris@41 4856 symfileobj=$output_objdir/${my_outputname}S.$objext
Chris@41 4857 case $host in
Chris@41 4858 *cygwin* | *mingw* | *cegcc* )
Chris@41 4859 if test -f "$output_objdir/$my_outputname.def"; then
Chris@41 4860 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
Chris@41 4861 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
Chris@41 4862 else
Chris@41 4863 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@41 4864 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@41 4865 fi
Chris@41 4866 ;;
Chris@41 4867 *)
Chris@41 4868 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@41 4869 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@41 4870 ;;
Chris@41 4871 esac
Chris@41 4872 ;;
Chris@41 4873 *)
Chris@41 4874 func_fatal_error "unknown suffix for '$my_dlsyms'"
Chris@41 4875 ;;
Chris@41 4876 esac
Chris@41 4877 else
Chris@41 4878 # We keep going just in case the user didn't refer to
Chris@41 4879 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
Chris@41 4880 # really was required.
Chris@41 4881
Chris@41 4882 # Nullify the symbol file.
Chris@41 4883 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
Chris@41 4884 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
Chris@41 4885 fi
Chris@41 4886 }
Chris@41 4887
Chris@41 4888 # func_cygming_gnu_implib_p ARG
Chris@41 4889 # This predicate returns with zero status (TRUE) if
Chris@41 4890 # ARG is a GNU/binutils-style import library. Returns
Chris@41 4891 # with nonzero status (FALSE) otherwise.
Chris@41 4892 func_cygming_gnu_implib_p ()
Chris@41 4893 {
Chris@41 4894 $debug_cmd
Chris@41 4895
Chris@41 4896 func_to_tool_file "$1" func_convert_file_msys_to_w32
Chris@41 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@41 4898 test -n "$func_cygming_gnu_implib_tmp"
Chris@41 4899 }
Chris@41 4900
Chris@41 4901 # func_cygming_ms_implib_p ARG
Chris@41 4902 # This predicate returns with zero status (TRUE) if
Chris@41 4903 # ARG is an MS-style import library. Returns
Chris@41 4904 # with nonzero status (FALSE) otherwise.
Chris@41 4905 func_cygming_ms_implib_p ()
Chris@41 4906 {
Chris@41 4907 $debug_cmd
Chris@41 4908
Chris@41 4909 func_to_tool_file "$1" func_convert_file_msys_to_w32
Chris@41 4910 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
Chris@41 4911 test -n "$func_cygming_ms_implib_tmp"
Chris@41 4912 }
Chris@41 4913
Chris@41 4914 # func_win32_libid arg
Chris@41 4915 # return the library type of file 'arg'
Chris@41 4916 #
Chris@41 4917 # Need a lot of goo to handle *both* DLLs and import libs
Chris@41 4918 # Has to be a shell function in order to 'eat' the argument
Chris@41 4919 # that is supplied when $file_magic_command is called.
Chris@41 4920 # Despite the name, also deal with 64 bit binaries.
Chris@41 4921 func_win32_libid ()
Chris@41 4922 {
Chris@41 4923 $debug_cmd
Chris@41 4924
Chris@41 4925 win32_libid_type=unknown
Chris@41 4926 win32_fileres=`file -L $1 2>/dev/null`
Chris@41 4927 case $win32_fileres in
Chris@41 4928 *ar\ archive\ import\ library*) # definitely import
Chris@41 4929 win32_libid_type="x86 archive import"
Chris@41 4930 ;;
Chris@41 4931 *ar\ archive*) # could be an import, or static
Chris@41 4932 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
Chris@41 4933 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
Chris@41 4934 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
Chris@41 4935 case $nm_interface in
Chris@41 4936 "MS dumpbin")
Chris@41 4937 if func_cygming_ms_implib_p "$1" ||
Chris@41 4938 func_cygming_gnu_implib_p "$1"
Chris@41 4939 then
Chris@41 4940 win32_nmres=import
Chris@41 4941 else
Chris@41 4942 win32_nmres=
Chris@41 4943 fi
Chris@41 4944 ;;
Chris@41 4945 *)
Chris@41 4946 func_to_tool_file "$1" func_convert_file_msys_to_w32
Chris@41 4947 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
Chris@41 4948 $SED -n -e '
Chris@41 4949 1,100{
Chris@41 4950 / I /{
Chris@41 4951 s|.*|import|
Chris@41 4952 p
Chris@41 4953 q
Chris@41 4954 }
Chris@41 4955 }'`
Chris@41 4956 ;;
Chris@41 4957 esac
Chris@41 4958 case $win32_nmres in
Chris@41 4959 import*) win32_libid_type="x86 archive import";;
Chris@41 4960 *) win32_libid_type="x86 archive static";;
Chris@41 4961 esac
Chris@41 4962 fi
Chris@41 4963 ;;
Chris@41 4964 *DLL*)
Chris@41 4965 win32_libid_type="x86 DLL"
Chris@41 4966 ;;
Chris@41 4967 *executable*) # but shell scripts are "executable" too...
Chris@41 4968 case $win32_fileres in
Chris@41 4969 *MS\ Windows\ PE\ Intel*)
Chris@41 4970 win32_libid_type="x86 DLL"
Chris@41 4971 ;;
Chris@41 4972 esac
Chris@41 4973 ;;
Chris@41 4974 esac
Chris@41 4975 $ECHO "$win32_libid_type"
Chris@41 4976 }
Chris@41 4977
Chris@41 4978 # func_cygming_dll_for_implib ARG
Chris@41 4979 #
Chris@41 4980 # Platform-specific function to extract the
Chris@41 4981 # name of the DLL associated with the specified
Chris@41 4982 # import library ARG.
Chris@41 4983 # Invoked by eval'ing the libtool variable
Chris@41 4984 # $sharedlib_from_linklib_cmd
Chris@41 4985 # Result is available in the variable
Chris@41 4986 # $sharedlib_from_linklib_result
Chris@41 4987 func_cygming_dll_for_implib ()
Chris@41 4988 {
Chris@41 4989 $debug_cmd
Chris@41 4990
Chris@41 4991 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
Chris@41 4992 }
Chris@41 4993
Chris@41 4994 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
Chris@41 4995 #
Chris@41 4996 # The is the core of a fallback implementation of a
Chris@41 4997 # platform-specific function to extract the name of the
Chris@41 4998 # DLL associated with the specified import library LIBNAME.
Chris@41 4999 #
Chris@41 5000 # SECTION_NAME is either .idata$6 or .idata$7, depending
Chris@41 5001 # on the platform and compiler that created the implib.
Chris@41 5002 #
Chris@41 5003 # Echos the name of the DLL associated with the
Chris@41 5004 # specified import library.
Chris@41 5005 func_cygming_dll_for_implib_fallback_core ()
Chris@41 5006 {
Chris@41 5007 $debug_cmd
Chris@41 5008
Chris@41 5009 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
Chris@41 5010 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
Chris@41 5011 $SED '/^Contents of section '"$match_literal"':/{
Chris@41 5012 # Place marker at beginning of archive member dllname section
Chris@41 5013 s/.*/====MARK====/
Chris@41 5014 p
Chris@41 5015 d
Chris@41 5016 }
Chris@41 5017 # These lines can sometimes be longer than 43 characters, but
Chris@41 5018 # are always uninteresting
Chris@41 5019 /:[ ]*file format pe[i]\{,1\}-/d
Chris@41 5020 /^In archive [^:]*:/d
Chris@41 5021 # Ensure marker is printed
Chris@41 5022 /^====MARK====/p
Chris@41 5023 # Remove all lines with less than 43 characters
Chris@41 5024 /^.\{43\}/!d
Chris@41 5025 # From remaining lines, remove first 43 characters
Chris@41 5026 s/^.\{43\}//' |
Chris@41 5027 $SED -n '
Chris@41 5028 # Join marker and all lines until next marker into a single line
Chris@41 5029 /^====MARK====/ b para
Chris@41 5030 H
Chris@41 5031 $ b para
Chris@41 5032 b
Chris@41 5033 :para
Chris@41 5034 x
Chris@41 5035 s/\n//g
Chris@41 5036 # Remove the marker
Chris@41 5037 s/^====MARK====//
Chris@41 5038 # Remove trailing dots and whitespace
Chris@41 5039 s/[\. \t]*$//
Chris@41 5040 # Print
Chris@41 5041 /./p' |
Chris@41 5042 # we now have a list, one entry per line, of the stringified
Chris@41 5043 # contents of the appropriate section of all members of the
Chris@41 5044 # archive that possess that section. Heuristic: eliminate
Chris@41 5045 # all those that have a first or second character that is
Chris@41 5046 # a '.' (that is, objdump's representation of an unprintable
Chris@41 5047 # character.) This should work for all archives with less than
Chris@41 5048 # 0x302f exports -- but will fail for DLLs whose name actually
Chris@41 5049 # begins with a literal '.' or a single character followed by
Chris@41 5050 # a '.'.
Chris@41 5051 #
Chris@41 5052 # Of those that remain, print the first one.
Chris@41 5053 $SED -e '/^\./d;/^.\./d;q'
Chris@41 5054 }
Chris@41 5055
Chris@41 5056 # func_cygming_dll_for_implib_fallback ARG
Chris@41 5057 # Platform-specific function to extract the
Chris@41 5058 # name of the DLL associated with the specified
Chris@41 5059 # import library ARG.
Chris@41 5060 #
Chris@41 5061 # This fallback implementation is for use when $DLLTOOL
Chris@41 5062 # does not support the --identify-strict option.
Chris@41 5063 # Invoked by eval'ing the libtool variable
Chris@41 5064 # $sharedlib_from_linklib_cmd
Chris@41 5065 # Result is available in the variable
Chris@41 5066 # $sharedlib_from_linklib_result
Chris@41 5067 func_cygming_dll_for_implib_fallback ()
Chris@41 5068 {
Chris@41 5069 $debug_cmd
Chris@41 5070
Chris@41 5071 if func_cygming_gnu_implib_p "$1"; then
Chris@41 5072 # binutils import library
Chris@41 5073 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
Chris@41 5074 elif func_cygming_ms_implib_p "$1"; then
Chris@41 5075 # ms-generated import library
Chris@41 5076 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
Chris@41 5077 else
Chris@41 5078 # unknown
Chris@41 5079 sharedlib_from_linklib_result=
Chris@41 5080 fi
Chris@41 5081 }
Chris@41 5082
Chris@41 5083
Chris@41 5084 # func_extract_an_archive dir oldlib
Chris@41 5085 func_extract_an_archive ()
Chris@41 5086 {
Chris@41 5087 $debug_cmd
Chris@41 5088
Chris@41 5089 f_ex_an_ar_dir=$1; shift
Chris@41 5090 f_ex_an_ar_oldlib=$1
Chris@41 5091 if test yes = "$lock_old_archive_extraction"; then
Chris@41 5092 lockfile=$f_ex_an_ar_oldlib.lock
Chris@41 5093 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
Chris@41 5094 func_echo "Waiting for $lockfile to be removed"
Chris@41 5095 sleep 2
Chris@41 5096 done
Chris@41 5097 fi
Chris@41 5098 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
Chris@41 5099 'stat=$?; rm -f "$lockfile"; exit $stat'
Chris@41 5100 if test yes = "$lock_old_archive_extraction"; then
Chris@41 5101 $opt_dry_run || rm -f "$lockfile"
Chris@41 5102 fi
Chris@41 5103 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
Chris@41 5104 :
Chris@41 5105 else
Chris@41 5106 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
Chris@41 5107 fi
Chris@41 5108 }
Chris@41 5109
Chris@41 5110
Chris@41 5111 # func_extract_archives gentop oldlib ...
Chris@41 5112 func_extract_archives ()
Chris@41 5113 {
Chris@41 5114 $debug_cmd
Chris@41 5115
Chris@41 5116 my_gentop=$1; shift
Chris@41 5117 my_oldlibs=${1+"$@"}
Chris@41 5118 my_oldobjs=
Chris@41 5119 my_xlib=
Chris@41 5120 my_xabs=
Chris@41 5121 my_xdir=
Chris@41 5122
Chris@41 5123 for my_xlib in $my_oldlibs; do
Chris@41 5124 # Extract the objects.
Chris@41 5125 case $my_xlib in
Chris@41 5126 [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
Chris@41 5127 *) my_xabs=`pwd`"/$my_xlib" ;;
Chris@41 5128 esac
Chris@41 5129 func_basename "$my_xlib"
Chris@41 5130 my_xlib=$func_basename_result
Chris@41 5131 my_xlib_u=$my_xlib
Chris@41 5132 while :; do
Chris@41 5133 case " $extracted_archives " in
Chris@41 5134 *" $my_xlib_u "*)
Chris@41 5135 func_arith $extracted_serial + 1
Chris@41 5136 extracted_serial=$func_arith_result
Chris@41 5137 my_xlib_u=lt$extracted_serial-$my_xlib ;;
Chris@41 5138 *) break ;;
Chris@41 5139 esac
Chris@41 5140 done
Chris@41 5141 extracted_archives="$extracted_archives $my_xlib_u"
Chris@41 5142 my_xdir=$my_gentop/$my_xlib_u
Chris@41 5143
Chris@41 5144 func_mkdir_p "$my_xdir"
Chris@41 5145
Chris@41 5146 case $host in
Chris@41 5147 *-darwin*)
Chris@41 5148 func_verbose "Extracting $my_xabs"
Chris@41 5149 # Do not bother doing anything if just a dry run
Chris@41 5150 $opt_dry_run || {
Chris@41 5151 darwin_orig_dir=`pwd`
Chris@41 5152 cd $my_xdir || exit $?
Chris@41 5153 darwin_archive=$my_xabs
Chris@41 5154 darwin_curdir=`pwd`
Chris@41 5155 func_basename "$darwin_archive"
Chris@41 5156 darwin_base_archive=$func_basename_result
Chris@41 5157 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
Chris@41 5158 if test -n "$darwin_arches"; then
Chris@41 5159 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
Chris@41 5160 darwin_arch=
Chris@41 5161 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
Chris@41 5162 for darwin_arch in $darwin_arches; do
Chris@41 5163 func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
Chris@41 5164 $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
Chris@41 5165 cd "unfat-$$/$darwin_base_archive-$darwin_arch"
Chris@41 5166 func_extract_an_archive "`pwd`" "$darwin_base_archive"
Chris@41 5167 cd "$darwin_curdir"
Chris@41 5168 $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
Chris@41 5169 done # $darwin_arches
Chris@41 5170 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
Chris@41 5171 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
Chris@41 5172 darwin_file=
Chris@41 5173 darwin_files=
Chris@41 5174 for darwin_file in $darwin_filelist; do
Chris@41 5175 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
Chris@41 5176 $LIPO -create -output "$darwin_file" $darwin_files
Chris@41 5177 done # $darwin_filelist
Chris@41 5178 $RM -rf unfat-$$
Chris@41 5179 cd "$darwin_orig_dir"
Chris@41 5180 else
Chris@41 5181 cd $darwin_orig_dir
Chris@41 5182 func_extract_an_archive "$my_xdir" "$my_xabs"
Chris@41 5183 fi # $darwin_arches
Chris@41 5184 } # !$opt_dry_run
Chris@41 5185 ;;
Chris@41 5186 *)
Chris@41 5187 func_extract_an_archive "$my_xdir" "$my_xabs"
Chris@41 5188 ;;
Chris@41 5189 esac
Chris@41 5190 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
Chris@41 5191 done
Chris@41 5192
Chris@41 5193 func_extract_archives_result=$my_oldobjs
Chris@41 5194 }
Chris@41 5195
Chris@41 5196
Chris@41 5197 # func_emit_wrapper [arg=no]
Chris@41 5198 #
Chris@41 5199 # Emit a libtool wrapper script on stdout.
Chris@41 5200 # Don't directly open a file because we may want to
Chris@41 5201 # incorporate the script contents within a cygwin/mingw
Chris@41 5202 # wrapper executable. Must ONLY be called from within
Chris@41 5203 # func_mode_link because it depends on a number of variables
Chris@41 5204 # set therein.
Chris@41 5205 #
Chris@41 5206 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
Chris@41 5207 # variable will take. If 'yes', then the emitted script
Chris@41 5208 # will assume that the directory where it is stored is
Chris@41 5209 # the $objdir directory. This is a cygwin/mingw-specific
Chris@41 5210 # behavior.
Chris@41 5211 func_emit_wrapper ()
Chris@41 5212 {
Chris@41 5213 func_emit_wrapper_arg1=${1-no}
Chris@41 5214
Chris@41 5215 $ECHO "\
Chris@41 5216 #! $SHELL
Chris@41 5217
Chris@41 5218 # $output - temporary wrapper script for $objdir/$outputname
Chris@41 5219 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@41 5220 #
Chris@41 5221 # The $output program cannot be directly executed until all the libtool
Chris@41 5222 # libraries that it depends on are installed.
Chris@41 5223 #
Chris@41 5224 # This wrapper script should never be moved out of the build directory.
Chris@41 5225 # If it is, it will not operate correctly.
Chris@41 5226
Chris@41 5227 # Sed substitution that helps us do robust quoting. It backslashifies
Chris@41 5228 # metacharacters that are still active within double-quoted strings.
Chris@41 5229 sed_quote_subst='$sed_quote_subst'
Chris@41 5230
Chris@41 5231 # Be Bourne compatible
Chris@41 5232 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
Chris@41 5233 emulate sh
Chris@41 5234 NULLCMD=:
Chris@41 5235 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
Chris@41 5236 # is contrary to our usage. Disable this feature.
Chris@41 5237 alias -g '\${1+\"\$@\"}'='\"\$@\"'
Chris@41 5238 setopt NO_GLOB_SUBST
Chris@41 5239 else
Chris@41 5240 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
Chris@41 5241 fi
Chris@41 5242 BIN_SH=xpg4; export BIN_SH # for Tru64
Chris@41 5243 DUALCASE=1; export DUALCASE # for MKS sh
Chris@41 5244
Chris@41 5245 # The HP-UX ksh and POSIX shell print the target directory to stdout
Chris@41 5246 # if CDPATH is set.
Chris@41 5247 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
Chris@41 5248
Chris@41 5249 relink_command=\"$relink_command\"
Chris@41 5250
Chris@41 5251 # This environment variable determines our operation mode.
Chris@41 5252 if test \"\$libtool_install_magic\" = \"$magic\"; then
Chris@41 5253 # install mode needs the following variables:
Chris@41 5254 generated_by_libtool_version='$macro_version'
Chris@41 5255 notinst_deplibs='$notinst_deplibs'
Chris@41 5256 else
Chris@41 5257 # When we are sourced in execute mode, \$file and \$ECHO are already set.
Chris@41 5258 if test \"\$libtool_execute_magic\" != \"$magic\"; then
Chris@41 5259 file=\"\$0\""
Chris@41 5260
Chris@41 5261 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
Chris@41 5262 $ECHO "\
Chris@41 5263
Chris@41 5264 # A function that is used when there is no print builtin or printf.
Chris@41 5265 func_fallback_echo ()
Chris@41 5266 {
Chris@41 5267 eval 'cat <<_LTECHO_EOF
Chris@41 5268 \$1
Chris@41 5269 _LTECHO_EOF'
Chris@41 5270 }
Chris@41 5271 ECHO=\"$qECHO\"
Chris@41 5272 fi
Chris@41 5273
Chris@41 5274 # Very basic option parsing. These options are (a) specific to
Chris@41 5275 # the libtool wrapper, (b) are identical between the wrapper
Chris@41 5276 # /script/ and the wrapper /executable/ that is used only on
Chris@41 5277 # windows platforms, and (c) all begin with the string "--lt-"
Chris@41 5278 # (application programs are unlikely to have options that match
Chris@41 5279 # this pattern).
Chris@41 5280 #
Chris@41 5281 # There are only two supported options: --lt-debug and
Chris@41 5282 # --lt-dump-script. There is, deliberately, no --lt-help.
Chris@41 5283 #
Chris@41 5284 # The first argument to this parsing function should be the
Chris@41 5285 # script's $0 value, followed by "$@".
Chris@41 5286 lt_option_debug=
Chris@41 5287 func_parse_lt_options ()
Chris@41 5288 {
Chris@41 5289 lt_script_arg0=\$0
Chris@41 5290 shift
Chris@41 5291 for lt_opt
Chris@41 5292 do
Chris@41 5293 case \"\$lt_opt\" in
Chris@41 5294 --lt-debug) lt_option_debug=1 ;;
Chris@41 5295 --lt-dump-script)
Chris@41 5296 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
Chris@41 5297 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
Chris@41 5298 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
Chris@41 5299 cat \"\$lt_dump_D/\$lt_dump_F\"
Chris@41 5300 exit 0
Chris@41 5301 ;;
Chris@41 5302 --lt-*)
Chris@41 5303 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
Chris@41 5304 exit 1
Chris@41 5305 ;;
Chris@41 5306 esac
Chris@41 5307 done
Chris@41 5308
Chris@41 5309 # Print the debug banner immediately:
Chris@41 5310 if test -n \"\$lt_option_debug\"; then
Chris@41 5311 echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
Chris@41 5312 fi
Chris@41 5313 }
Chris@41 5314
Chris@41 5315 # Used when --lt-debug. Prints its arguments to stdout
Chris@41 5316 # (redirection is the responsibility of the caller)
Chris@41 5317 func_lt_dump_args ()
Chris@41 5318 {
Chris@41 5319 lt_dump_args_N=1;
Chris@41 5320 for lt_arg
Chris@41 5321 do
Chris@41 5322 \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
Chris@41 5323 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
Chris@41 5324 done
Chris@41 5325 }
Chris@41 5326
Chris@41 5327 # Core function for launching the target application
Chris@41 5328 func_exec_program_core ()
Chris@41 5329 {
Chris@41 5330 "
Chris@41 5331 case $host in
Chris@41 5332 # Backslashes separate directories on plain windows
Chris@41 5333 *-*-mingw | *-*-os2* | *-cegcc*)
Chris@41 5334 $ECHO "\
Chris@41 5335 if test -n \"\$lt_option_debug\"; then
Chris@41 5336 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
Chris@41 5337 func_lt_dump_args \${1+\"\$@\"} 1>&2
Chris@41 5338 fi
Chris@41 5339 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
Chris@41 5340 "
Chris@41 5341 ;;
Chris@41 5342
Chris@41 5343 *)
Chris@41 5344 $ECHO "\
Chris@41 5345 if test -n \"\$lt_option_debug\"; then
Chris@41 5346 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
Chris@41 5347 func_lt_dump_args \${1+\"\$@\"} 1>&2
Chris@41 5348 fi
Chris@41 5349 exec \"\$progdir/\$program\" \${1+\"\$@\"}
Chris@41 5350 "
Chris@41 5351 ;;
Chris@41 5352 esac
Chris@41 5353 $ECHO "\
Chris@41 5354 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
Chris@41 5355 exit 1
Chris@41 5356 }
Chris@41 5357
Chris@41 5358 # A function to encapsulate launching the target application
Chris@41 5359 # Strips options in the --lt-* namespace from \$@ and
Chris@41 5360 # launches target application with the remaining arguments.
Chris@41 5361 func_exec_program ()
Chris@41 5362 {
Chris@41 5363 case \" \$* \" in
Chris@41 5364 *\\ --lt-*)
Chris@41 5365 for lt_wr_arg
Chris@41 5366 do
Chris@41 5367 case \$lt_wr_arg in
Chris@41 5368 --lt-*) ;;
Chris@41 5369 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
Chris@41 5370 esac
Chris@41 5371 shift
Chris@41 5372 done ;;
Chris@41 5373 esac
Chris@41 5374 func_exec_program_core \${1+\"\$@\"}
Chris@41 5375 }
Chris@41 5376
Chris@41 5377 # Parse options
Chris@41 5378 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
Chris@41 5379
Chris@41 5380 # Find the directory that this script lives in.
Chris@41 5381 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
Chris@41 5382 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
Chris@41 5383
Chris@41 5384 # Follow symbolic links until we get to the real thisdir.
Chris@41 5385 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
Chris@41 5386 while test -n \"\$file\"; do
Chris@41 5387 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
Chris@41 5388
Chris@41 5389 # If there was a directory component, then change thisdir.
Chris@41 5390 if test \"x\$destdir\" != \"x\$file\"; then
Chris@41 5391 case \"\$destdir\" in
Chris@41 5392 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
Chris@41 5393 *) thisdir=\"\$thisdir/\$destdir\" ;;
Chris@41 5394 esac
Chris@41 5395 fi
Chris@41 5396
Chris@41 5397 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
Chris@41 5398 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
Chris@41 5399 done
Chris@41 5400
Chris@41 5401 # Usually 'no', except on cygwin/mingw when embedded into
Chris@41 5402 # the cwrapper.
Chris@41 5403 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
Chris@41 5404 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
Chris@41 5405 # special case for '.'
Chris@41 5406 if test \"\$thisdir\" = \".\"; then
Chris@41 5407 thisdir=\`pwd\`
Chris@41 5408 fi
Chris@41 5409 # remove .libs from thisdir
Chris@41 5410 case \"\$thisdir\" in
Chris@41 5411 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
Chris@41 5412 $objdir ) thisdir=. ;;
Chris@41 5413 esac
Chris@41 5414 fi
Chris@41 5415
Chris@41 5416 # Try to get the absolute directory name.
Chris@41 5417 absdir=\`cd \"\$thisdir\" && pwd\`
Chris@41 5418 test -n \"\$absdir\" && thisdir=\"\$absdir\"
Chris@41 5419 "
Chris@41 5420
Chris@41 5421 if test yes = "$fast_install"; then
Chris@41 5422 $ECHO "\
Chris@41 5423 program=lt-'$outputname'$exeext
Chris@41 5424 progdir=\"\$thisdir/$objdir\"
Chris@41 5425
Chris@41 5426 if test ! -f \"\$progdir/\$program\" ||
Chris@41 5427 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
Chris@41 5428 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
Chris@41 5429
Chris@41 5430 file=\"\$\$-\$program\"
Chris@41 5431
Chris@41 5432 if test ! -d \"\$progdir\"; then
Chris@41 5433 $MKDIR \"\$progdir\"
Chris@41 5434 else
Chris@41 5435 $RM \"\$progdir/\$file\"
Chris@41 5436 fi"
Chris@41 5437
Chris@41 5438 $ECHO "\
Chris@41 5439
Chris@41 5440 # relink executable if necessary
Chris@41 5441 if test -n \"\$relink_command\"; then
Chris@41 5442 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
Chris@41 5443 else
Chris@41 5444 \$ECHO \"\$relink_command_output\" >&2
Chris@41 5445 $RM \"\$progdir/\$file\"
Chris@41 5446 exit 1
Chris@41 5447 fi
Chris@41 5448 fi
Chris@41 5449
Chris@41 5450 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
Chris@41 5451 { $RM \"\$progdir/\$program\";
Chris@41 5452 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
Chris@41 5453 $RM \"\$progdir/\$file\"
Chris@41 5454 fi"
Chris@41 5455 else
Chris@41 5456 $ECHO "\
Chris@41 5457 program='$outputname'
Chris@41 5458 progdir=\"\$thisdir/$objdir\"
Chris@41 5459 "
Chris@41 5460 fi
Chris@41 5461
Chris@41 5462 $ECHO "\
Chris@41 5463
Chris@41 5464 if test -f \"\$progdir/\$program\"; then"
Chris@41 5465
Chris@41 5466 # fixup the dll searchpath if we need to.
Chris@41 5467 #
Chris@41 5468 # Fix the DLL searchpath if we need to. Do this before prepending
Chris@41 5469 # to shlibpath, because on Windows, both are PATH and uninstalled
Chris@41 5470 # libraries must come first.
Chris@41 5471 if test -n "$dllsearchpath"; then
Chris@41 5472 $ECHO "\
Chris@41 5473 # Add the dll search path components to the executable PATH
Chris@41 5474 PATH=$dllsearchpath:\$PATH
Chris@41 5475 "
Chris@41 5476 fi
Chris@41 5477
Chris@41 5478 # Export our shlibpath_var if we have one.
Chris@41 5479 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
Chris@41 5480 $ECHO "\
Chris@41 5481 # Add our own library path to $shlibpath_var
Chris@41 5482 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
Chris@41 5483
Chris@41 5484 # Some systems cannot cope with colon-terminated $shlibpath_var
Chris@41 5485 # The second colon is a workaround for a bug in BeOS R4 sed
Chris@41 5486 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
Chris@41 5487
Chris@41 5488 export $shlibpath_var
Chris@41 5489 "
Chris@41 5490 fi
Chris@41 5491
Chris@41 5492 $ECHO "\
Chris@41 5493 if test \"\$libtool_execute_magic\" != \"$magic\"; then
Chris@41 5494 # Run the actual program with our arguments.
Chris@41 5495 func_exec_program \${1+\"\$@\"}
Chris@41 5496 fi
Chris@41 5497 else
Chris@41 5498 # The program doesn't exist.
Chris@41 5499 \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
Chris@41 5500 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
Chris@41 5501 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
Chris@41 5502 exit 1
Chris@41 5503 fi
Chris@41 5504 fi\
Chris@41 5505 "
Chris@41 5506 }
Chris@41 5507
Chris@41 5508
Chris@41 5509 # func_emit_cwrapperexe_src
Chris@41 5510 # emit the source code for a wrapper executable on stdout
Chris@41 5511 # Must ONLY be called from within func_mode_link because
Chris@41 5512 # it depends on a number of variable set therein.
Chris@41 5513 func_emit_cwrapperexe_src ()
Chris@41 5514 {
Chris@41 5515 cat <<EOF
Chris@41 5516
Chris@41 5517 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
Chris@41 5518 Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@41 5519
Chris@41 5520 The $output program cannot be directly executed until all the libtool
Chris@41 5521 libraries that it depends on are installed.
Chris@41 5522
Chris@41 5523 This wrapper executable should never be moved out of the build directory.
Chris@41 5524 If it is, it will not operate correctly.
Chris@41 5525 */
Chris@41 5526 EOF
Chris@41 5527 cat <<"EOF"
Chris@41 5528 #ifdef _MSC_VER
Chris@41 5529 # define _CRT_SECURE_NO_DEPRECATE 1
Chris@41 5530 #endif
Chris@41 5531 #include <stdio.h>
Chris@41 5532 #include <stdlib.h>
Chris@41 5533 #ifdef _MSC_VER
Chris@41 5534 # include <direct.h>
Chris@41 5535 # include <process.h>
Chris@41 5536 # include <io.h>
Chris@41 5537 #else
Chris@41 5538 # include <unistd.h>
Chris@41 5539 # include <stdint.h>
Chris@41 5540 # ifdef __CYGWIN__
Chris@41 5541 # include <io.h>
Chris@41 5542 # endif
Chris@41 5543 #endif
Chris@41 5544 #include <malloc.h>
Chris@41 5545 #include <stdarg.h>
Chris@41 5546 #include <assert.h>
Chris@41 5547 #include <string.h>
Chris@41 5548 #include <ctype.h>
Chris@41 5549 #include <errno.h>
Chris@41 5550 #include <fcntl.h>
Chris@41 5551 #include <sys/stat.h>
Chris@41 5552
Chris@41 5553 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
Chris@41 5554
Chris@41 5555 /* declarations of non-ANSI functions */
Chris@41 5556 #if defined __MINGW32__
Chris@41 5557 # ifdef __STRICT_ANSI__
Chris@41 5558 int _putenv (const char *);
Chris@41 5559 # endif
Chris@41 5560 #elif defined __CYGWIN__
Chris@41 5561 # ifdef __STRICT_ANSI__
Chris@41 5562 char *realpath (const char *, char *);
Chris@41 5563 int putenv (char *);
Chris@41 5564 int setenv (const char *, const char *, int);
Chris@41 5565 # endif
Chris@41 5566 /* #elif defined other_platform || defined ... */
Chris@41 5567 #endif
Chris@41 5568
Chris@41 5569 /* portability defines, excluding path handling macros */
Chris@41 5570 #if defined _MSC_VER
Chris@41 5571 # define setmode _setmode
Chris@41 5572 # define stat _stat
Chris@41 5573 # define chmod _chmod
Chris@41 5574 # define getcwd _getcwd
Chris@41 5575 # define putenv _putenv
Chris@41 5576 # define S_IXUSR _S_IEXEC
Chris@41 5577 #elif defined __MINGW32__
Chris@41 5578 # define setmode _setmode
Chris@41 5579 # define stat _stat
Chris@41 5580 # define chmod _chmod
Chris@41 5581 # define getcwd _getcwd
Chris@41 5582 # define putenv _putenv
Chris@41 5583 #elif defined __CYGWIN__
Chris@41 5584 # define HAVE_SETENV
Chris@41 5585 # define FOPEN_WB "wb"
Chris@41 5586 /* #elif defined other platforms ... */
Chris@41 5587 #endif
Chris@41 5588
Chris@41 5589 #if defined PATH_MAX
Chris@41 5590 # define LT_PATHMAX PATH_MAX
Chris@41 5591 #elif defined MAXPATHLEN
Chris@41 5592 # define LT_PATHMAX MAXPATHLEN
Chris@41 5593 #else
Chris@41 5594 # define LT_PATHMAX 1024
Chris@41 5595 #endif
Chris@41 5596
Chris@41 5597 #ifndef S_IXOTH
Chris@41 5598 # define S_IXOTH 0
Chris@41 5599 #endif
Chris@41 5600 #ifndef S_IXGRP
Chris@41 5601 # define S_IXGRP 0
Chris@41 5602 #endif
Chris@41 5603
Chris@41 5604 /* path handling portability macros */
Chris@41 5605 #ifndef DIR_SEPARATOR
Chris@41 5606 # define DIR_SEPARATOR '/'
Chris@41 5607 # define PATH_SEPARATOR ':'
Chris@41 5608 #endif
Chris@41 5609
Chris@41 5610 #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
Chris@41 5611 defined __OS2__
Chris@41 5612 # define HAVE_DOS_BASED_FILE_SYSTEM
Chris@41 5613 # define FOPEN_WB "wb"
Chris@41 5614 # ifndef DIR_SEPARATOR_2
Chris@41 5615 # define DIR_SEPARATOR_2 '\\'
Chris@41 5616 # endif
Chris@41 5617 # ifndef PATH_SEPARATOR_2
Chris@41 5618 # define PATH_SEPARATOR_2 ';'
Chris@41 5619 # endif
Chris@41 5620 #endif
Chris@41 5621
Chris@41 5622 #ifndef DIR_SEPARATOR_2
Chris@41 5623 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
Chris@41 5624 #else /* DIR_SEPARATOR_2 */
Chris@41 5625 # define IS_DIR_SEPARATOR(ch) \
Chris@41 5626 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
Chris@41 5627 #endif /* DIR_SEPARATOR_2 */
Chris@41 5628
Chris@41 5629 #ifndef PATH_SEPARATOR_2
Chris@41 5630 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
Chris@41 5631 #else /* PATH_SEPARATOR_2 */
Chris@41 5632 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
Chris@41 5633 #endif /* PATH_SEPARATOR_2 */
Chris@41 5634
Chris@41 5635 #ifndef FOPEN_WB
Chris@41 5636 # define FOPEN_WB "w"
Chris@41 5637 #endif
Chris@41 5638 #ifndef _O_BINARY
Chris@41 5639 # define _O_BINARY 0
Chris@41 5640 #endif
Chris@41 5641
Chris@41 5642 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
Chris@41 5643 #define XFREE(stale) do { \
Chris@41 5644 if (stale) { free (stale); stale = 0; } \
Chris@41 5645 } while (0)
Chris@41 5646
Chris@41 5647 #if defined LT_DEBUGWRAPPER
Chris@41 5648 static int lt_debug = 1;
Chris@41 5649 #else
Chris@41 5650 static int lt_debug = 0;
Chris@41 5651 #endif
Chris@41 5652
Chris@41 5653 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
Chris@41 5654
Chris@41 5655 void *xmalloc (size_t num);
Chris@41 5656 char *xstrdup (const char *string);
Chris@41 5657 const char *base_name (const char *name);
Chris@41 5658 char *find_executable (const char *wrapper);
Chris@41 5659 char *chase_symlinks (const char *pathspec);
Chris@41 5660 int make_executable (const char *path);
Chris@41 5661 int check_executable (const char *path);
Chris@41 5662 char *strendzap (char *str, const char *pat);
Chris@41 5663 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
Chris@41 5664 void lt_fatal (const char *file, int line, const char *message, ...);
Chris@41 5665 static const char *nonnull (const char *s);
Chris@41 5666 static const char *nonempty (const char *s);
Chris@41 5667 void lt_setenv (const char *name, const char *value);
Chris@41 5668 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
Chris@41 5669 void lt_update_exe_path (const char *name, const char *value);
Chris@41 5670 void lt_update_lib_path (const char *name, const char *value);
Chris@41 5671 char **prepare_spawn (char **argv);
Chris@41 5672 void lt_dump_script (FILE *f);
Chris@41 5673 EOF
Chris@41 5674
Chris@41 5675 cat <<EOF
Chris@41 5676 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
Chris@41 5677 # define externally_visible volatile
Chris@41 5678 #else
Chris@41 5679 # define externally_visible __attribute__((externally_visible)) volatile
Chris@41 5680 #endif
Chris@41 5681 externally_visible const char * MAGIC_EXE = "$magic_exe";
Chris@41 5682 const char * LIB_PATH_VARNAME = "$shlibpath_var";
Chris@41 5683 EOF
Chris@41 5684
Chris@41 5685 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
Chris@41 5686 func_to_host_path "$temp_rpath"
Chris@41 5687 cat <<EOF
Chris@41 5688 const char * LIB_PATH_VALUE = "$func_to_host_path_result";
Chris@41 5689 EOF
Chris@41 5690 else
Chris@41 5691 cat <<"EOF"
Chris@41 5692 const char * LIB_PATH_VALUE = "";
Chris@41 5693 EOF
Chris@41 5694 fi
Chris@41 5695
Chris@41 5696 if test -n "$dllsearchpath"; then
Chris@41 5697 func_to_host_path "$dllsearchpath:"
Chris@41 5698 cat <<EOF
Chris@41 5699 const char * EXE_PATH_VARNAME = "PATH";
Chris@41 5700 const char * EXE_PATH_VALUE = "$func_to_host_path_result";
Chris@41 5701 EOF
Chris@41 5702 else
Chris@41 5703 cat <<"EOF"
Chris@41 5704 const char * EXE_PATH_VARNAME = "";
Chris@41 5705 const char * EXE_PATH_VALUE = "";
Chris@41 5706 EOF
Chris@41 5707 fi
Chris@41 5708
Chris@41 5709 if test yes = "$fast_install"; then
Chris@41 5710 cat <<EOF
Chris@41 5711 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
Chris@41 5712 EOF
Chris@41 5713 else
Chris@41 5714 cat <<EOF
Chris@41 5715 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
Chris@41 5716 EOF
Chris@41 5717 fi
Chris@41 5718
Chris@41 5719
Chris@41 5720 cat <<"EOF"
Chris@41 5721
Chris@41 5722 #define LTWRAPPER_OPTION_PREFIX "--lt-"
Chris@41 5723
Chris@41 5724 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
Chris@41 5725 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
Chris@41 5726 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
Chris@41 5727
Chris@41 5728 int
Chris@41 5729 main (int argc, char *argv[])
Chris@41 5730 {
Chris@41 5731 char **newargz;
Chris@41 5732 int newargc;
Chris@41 5733 char *tmp_pathspec;
Chris@41 5734 char *actual_cwrapper_path;
Chris@41 5735 char *actual_cwrapper_name;
Chris@41 5736 char *target_name;
Chris@41 5737 char *lt_argv_zero;
Chris@41 5738 int rval = 127;
Chris@41 5739
Chris@41 5740 int i;
Chris@41 5741
Chris@41 5742 program_name = (char *) xstrdup (base_name (argv[0]));
Chris@41 5743 newargz = XMALLOC (char *, (size_t) argc + 1);
Chris@41 5744
Chris@41 5745 /* very simple arg parsing; don't want to rely on getopt
Chris@41 5746 * also, copy all non cwrapper options to newargz, except
Chris@41 5747 * argz[0], which is handled differently
Chris@41 5748 */
Chris@41 5749 newargc=0;
Chris@41 5750 for (i = 1; i < argc; i++)
Chris@41 5751 {
Chris@41 5752 if (STREQ (argv[i], dumpscript_opt))
Chris@41 5753 {
Chris@41 5754 EOF
Chris@41 5755 case $host in
Chris@41 5756 *mingw* | *cygwin* )
Chris@41 5757 # make stdout use "unix" line endings
Chris@41 5758 echo " setmode(1,_O_BINARY);"
Chris@41 5759 ;;
Chris@41 5760 esac
Chris@41 5761
Chris@41 5762 cat <<"EOF"
Chris@41 5763 lt_dump_script (stdout);
Chris@41 5764 return 0;
Chris@41 5765 }
Chris@41 5766 if (STREQ (argv[i], debug_opt))
Chris@41 5767 {
Chris@41 5768 lt_debug = 1;
Chris@41 5769 continue;
Chris@41 5770 }
Chris@41 5771 if (STREQ (argv[i], ltwrapper_option_prefix))
Chris@41 5772 {
Chris@41 5773 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
Chris@41 5774 namespace, but it is not one of the ones we know about and
Chris@41 5775 have already dealt with, above (inluding dump-script), then
Chris@41 5776 report an error. Otherwise, targets might begin to believe
Chris@41 5777 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
Chris@41 5778 namespace. The first time any user complains about this, we'll
Chris@41 5779 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
Chris@41 5780 or a configure.ac-settable value.
Chris@41 5781 */
Chris@41 5782 lt_fatal (__FILE__, __LINE__,
Chris@41 5783 "unrecognized %s option: '%s'",
Chris@41 5784 ltwrapper_option_prefix, argv[i]);
Chris@41 5785 }
Chris@41 5786 /* otherwise ... */
Chris@41 5787 newargz[++newargc] = xstrdup (argv[i]);
Chris@41 5788 }
Chris@41 5789 newargz[++newargc] = NULL;
Chris@41 5790
Chris@41 5791 EOF
Chris@41 5792 cat <<EOF
Chris@41 5793 /* The GNU banner must be the first non-error debug message */
Chris@41 5794 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
Chris@41 5795 EOF
Chris@41 5796 cat <<"EOF"
Chris@41 5797 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
Chris@41 5798 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
Chris@41 5799
Chris@41 5800 tmp_pathspec = find_executable (argv[0]);
Chris@41 5801 if (tmp_pathspec == NULL)
Chris@41 5802 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
Chris@41 5803 lt_debugprintf (__FILE__, __LINE__,
Chris@41 5804 "(main) found exe (before symlink chase) at: %s\n",
Chris@41 5805 tmp_pathspec);
Chris@41 5806
Chris@41 5807 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
Chris@41 5808 lt_debugprintf (__FILE__, __LINE__,
Chris@41 5809 "(main) found exe (after symlink chase) at: %s\n",
Chris@41 5810 actual_cwrapper_path);
Chris@41 5811 XFREE (tmp_pathspec);
Chris@41 5812
Chris@41 5813 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
Chris@41 5814 strendzap (actual_cwrapper_path, actual_cwrapper_name);
Chris@41 5815
Chris@41 5816 /* wrapper name transforms */
Chris@41 5817 strendzap (actual_cwrapper_name, ".exe");
Chris@41 5818 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
Chris@41 5819 XFREE (actual_cwrapper_name);
Chris@41 5820 actual_cwrapper_name = tmp_pathspec;
Chris@41 5821 tmp_pathspec = 0;
Chris@41 5822
Chris@41 5823 /* target_name transforms -- use actual target program name; might have lt- prefix */
Chris@41 5824 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
Chris@41 5825 strendzap (target_name, ".exe");
Chris@41 5826 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
Chris@41 5827 XFREE (target_name);
Chris@41 5828 target_name = tmp_pathspec;
Chris@41 5829 tmp_pathspec = 0;
Chris@41 5830
Chris@41 5831 lt_debugprintf (__FILE__, __LINE__,
Chris@41 5832 "(main) libtool target name: %s\n",
Chris@41 5833 target_name);
Chris@41 5834 EOF
Chris@41 5835
Chris@41 5836 cat <<EOF
Chris@41 5837 newargz[0] =
Chris@41 5838 XMALLOC (char, (strlen (actual_cwrapper_path) +
Chris@41 5839 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
Chris@41 5840 strcpy (newargz[0], actual_cwrapper_path);
Chris@41 5841 strcat (newargz[0], "$objdir");
Chris@41 5842 strcat (newargz[0], "/");
Chris@41 5843 EOF
Chris@41 5844
Chris@41 5845 cat <<"EOF"
Chris@41 5846 /* stop here, and copy so we don't have to do this twice */
Chris@41 5847 tmp_pathspec = xstrdup (newargz[0]);
Chris@41 5848
Chris@41 5849 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
Chris@41 5850 strcat (newargz[0], actual_cwrapper_name);
Chris@41 5851
Chris@41 5852 /* DO want the lt- prefix here if it exists, so use target_name */
Chris@41 5853 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
Chris@41 5854 XFREE (tmp_pathspec);
Chris@41 5855 tmp_pathspec = NULL;
Chris@41 5856 EOF
Chris@41 5857
Chris@41 5858 case $host_os in
Chris@41 5859 mingw*)
Chris@41 5860 cat <<"EOF"
Chris@41 5861 {
Chris@41 5862 char* p;
Chris@41 5863 while ((p = strchr (newargz[0], '\\')) != NULL)
Chris@41 5864 {
Chris@41 5865 *p = '/';
Chris@41 5866 }
Chris@41 5867 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
Chris@41 5868 {
Chris@41 5869 *p = '/';
Chris@41 5870 }
Chris@41 5871 }
Chris@41 5872 EOF
Chris@41 5873 ;;
Chris@41 5874 esac
Chris@41 5875
Chris@41 5876 cat <<"EOF"
Chris@41 5877 XFREE (target_name);
Chris@41 5878 XFREE (actual_cwrapper_path);
Chris@41 5879 XFREE (actual_cwrapper_name);
Chris@41 5880
Chris@41 5881 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
Chris@41 5882 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
Chris@41 5883 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
Chris@41 5884 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
Chris@41 5885 because on Windows, both *_VARNAMEs are PATH but uninstalled
Chris@41 5886 libraries must come first. */
Chris@41 5887 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
Chris@41 5888 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
Chris@41 5889
Chris@41 5890 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
Chris@41 5891 nonnull (lt_argv_zero));
Chris@41 5892 for (i = 0; i < newargc; i++)
Chris@41 5893 {
Chris@41 5894 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
Chris@41 5895 i, nonnull (newargz[i]));
Chris@41 5896 }
Chris@41 5897
Chris@41 5898 EOF
Chris@41 5899
Chris@41 5900 case $host_os in
Chris@41 5901 mingw*)
Chris@41 5902 cat <<"EOF"
Chris@41 5903 /* execv doesn't actually work on mingw as expected on unix */
Chris@41 5904 newargz = prepare_spawn (newargz);
Chris@41 5905 rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
Chris@41 5906 if (rval == -1)
Chris@41 5907 {
Chris@41 5908 /* failed to start process */
Chris@41 5909 lt_debugprintf (__FILE__, __LINE__,
Chris@41 5910 "(main) failed to launch target \"%s\": %s\n",
Chris@41 5911 lt_argv_zero, nonnull (strerror (errno)));
Chris@41 5912 return 127;
Chris@41 5913 }
Chris@41 5914 return rval;
Chris@41 5915 EOF
Chris@41 5916 ;;
Chris@41 5917 *)
Chris@41 5918 cat <<"EOF"
Chris@41 5919 execv (lt_argv_zero, newargz);
Chris@41 5920 return rval; /* =127, but avoids unused variable warning */
Chris@41 5921 EOF
Chris@41 5922 ;;
Chris@41 5923 esac
Chris@41 5924
Chris@41 5925 cat <<"EOF"
Chris@41 5926 }
Chris@41 5927
Chris@41 5928 void *
Chris@41 5929 xmalloc (size_t num)
Chris@41 5930 {
Chris@41 5931 void *p = (void *) malloc (num);
Chris@41 5932 if (!p)
Chris@41 5933 lt_fatal (__FILE__, __LINE__, "memory exhausted");
Chris@41 5934
Chris@41 5935 return p;
Chris@41 5936 }
Chris@41 5937
Chris@41 5938 char *
Chris@41 5939 xstrdup (const char *string)
Chris@41 5940 {
Chris@41 5941 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
Chris@41 5942 string) : NULL;
Chris@41 5943 }
Chris@41 5944
Chris@41 5945 const char *
Chris@41 5946 base_name (const char *name)
Chris@41 5947 {
Chris@41 5948 const char *base;
Chris@41 5949
Chris@41 5950 #if defined HAVE_DOS_BASED_FILE_SYSTEM
Chris@41 5951 /* Skip over the disk name in MSDOS pathnames. */
Chris@41 5952 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
Chris@41 5953 name += 2;
Chris@41 5954 #endif
Chris@41 5955
Chris@41 5956 for (base = name; *name; name++)
Chris@41 5957 if (IS_DIR_SEPARATOR (*name))
Chris@41 5958 base = name + 1;
Chris@41 5959 return base;
Chris@41 5960 }
Chris@41 5961
Chris@41 5962 int
Chris@41 5963 check_executable (const char *path)
Chris@41 5964 {
Chris@41 5965 struct stat st;
Chris@41 5966
Chris@41 5967 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
Chris@41 5968 nonempty (path));
Chris@41 5969 if ((!path) || (!*path))
Chris@41 5970 return 0;
Chris@41 5971
Chris@41 5972 if ((stat (path, &st) >= 0)
Chris@41 5973 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
Chris@41 5974 return 1;
Chris@41 5975 else
Chris@41 5976 return 0;
Chris@41 5977 }
Chris@41 5978
Chris@41 5979 int
Chris@41 5980 make_executable (const char *path)
Chris@41 5981 {
Chris@41 5982 int rval = 0;
Chris@41 5983 struct stat st;
Chris@41 5984
Chris@41 5985 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
Chris@41 5986 nonempty (path));
Chris@41 5987 if ((!path) || (!*path))
Chris@41 5988 return 0;
Chris@41 5989
Chris@41 5990 if (stat (path, &st) >= 0)
Chris@41 5991 {
Chris@41 5992 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
Chris@41 5993 }
Chris@41 5994 return rval;
Chris@41 5995 }
Chris@41 5996
Chris@41 5997 /* Searches for the full path of the wrapper. Returns
Chris@41 5998 newly allocated full path name if found, NULL otherwise
Chris@41 5999 Does not chase symlinks, even on platforms that support them.
Chris@41 6000 */
Chris@41 6001 char *
Chris@41 6002 find_executable (const char *wrapper)
Chris@41 6003 {
Chris@41 6004 int has_slash = 0;
Chris@41 6005 const char *p;
Chris@41 6006 const char *p_next;
Chris@41 6007 /* static buffer for getcwd */
Chris@41 6008 char tmp[LT_PATHMAX + 1];
Chris@41 6009 size_t tmp_len;
Chris@41 6010 char *concat_name;
Chris@41 6011
Chris@41 6012 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
Chris@41 6013 nonempty (wrapper));
Chris@41 6014
Chris@41 6015 if ((wrapper == NULL) || (*wrapper == '\0'))
Chris@41 6016 return NULL;
Chris@41 6017
Chris@41 6018 /* Absolute path? */
Chris@41 6019 #if defined HAVE_DOS_BASED_FILE_SYSTEM
Chris@41 6020 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
Chris@41 6021 {
Chris@41 6022 concat_name = xstrdup (wrapper);
Chris@41 6023 if (check_executable (concat_name))
Chris@41 6024 return concat_name;
Chris@41 6025 XFREE (concat_name);
Chris@41 6026 }
Chris@41 6027 else
Chris@41 6028 {
Chris@41 6029 #endif
Chris@41 6030 if (IS_DIR_SEPARATOR (wrapper[0]))
Chris@41 6031 {
Chris@41 6032 concat_name = xstrdup (wrapper);
Chris@41 6033 if (check_executable (concat_name))
Chris@41 6034 return concat_name;
Chris@41 6035 XFREE (concat_name);
Chris@41 6036 }
Chris@41 6037 #if defined HAVE_DOS_BASED_FILE_SYSTEM
Chris@41 6038 }
Chris@41 6039 #endif
Chris@41 6040
Chris@41 6041 for (p = wrapper; *p; p++)
Chris@41 6042 if (*p == '/')
Chris@41 6043 {
Chris@41 6044 has_slash = 1;
Chris@41 6045 break;
Chris@41 6046 }
Chris@41 6047 if (!has_slash)
Chris@41 6048 {
Chris@41 6049 /* no slashes; search PATH */
Chris@41 6050 const char *path = getenv ("PATH");
Chris@41 6051 if (path != NULL)
Chris@41 6052 {
Chris@41 6053 for (p = path; *p; p = p_next)
Chris@41 6054 {
Chris@41 6055 const char *q;
Chris@41 6056 size_t p_len;
Chris@41 6057 for (q = p; *q; q++)
Chris@41 6058 if (IS_PATH_SEPARATOR (*q))
Chris@41 6059 break;
Chris@41 6060 p_len = (size_t) (q - p);
Chris@41 6061 p_next = (*q == '\0' ? q : q + 1);
Chris@41 6062 if (p_len == 0)
Chris@41 6063 {
Chris@41 6064 /* empty path: current directory */
Chris@41 6065 if (getcwd (tmp, LT_PATHMAX) == NULL)
Chris@41 6066 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
Chris@41 6067 nonnull (strerror (errno)));
Chris@41 6068 tmp_len = strlen (tmp);
Chris@41 6069 concat_name =
Chris@41 6070 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
Chris@41 6071 memcpy (concat_name, tmp, tmp_len);
Chris@41 6072 concat_name[tmp_len] = '/';
Chris@41 6073 strcpy (concat_name + tmp_len + 1, wrapper);
Chris@41 6074 }
Chris@41 6075 else
Chris@41 6076 {
Chris@41 6077 concat_name =
Chris@41 6078 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
Chris@41 6079 memcpy (concat_name, p, p_len);
Chris@41 6080 concat_name[p_len] = '/';
Chris@41 6081 strcpy (concat_name + p_len + 1, wrapper);
Chris@41 6082 }
Chris@41 6083 if (check_executable (concat_name))
Chris@41 6084 return concat_name;
Chris@41 6085 XFREE (concat_name);
Chris@41 6086 }
Chris@41 6087 }
Chris@41 6088 /* not found in PATH; assume curdir */
Chris@41 6089 }
Chris@41 6090 /* Relative path | not found in path: prepend cwd */
Chris@41 6091 if (getcwd (tmp, LT_PATHMAX) == NULL)
Chris@41 6092 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
Chris@41 6093 nonnull (strerror (errno)));
Chris@41 6094 tmp_len = strlen (tmp);
Chris@41 6095 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
Chris@41 6096 memcpy (concat_name, tmp, tmp_len);
Chris@41 6097 concat_name[tmp_len] = '/';
Chris@41 6098 strcpy (concat_name + tmp_len + 1, wrapper);
Chris@41 6099
Chris@41 6100 if (check_executable (concat_name))
Chris@41 6101 return concat_name;
Chris@41 6102 XFREE (concat_name);
Chris@41 6103 return NULL;
Chris@41 6104 }
Chris@41 6105
Chris@41 6106 char *
Chris@41 6107 chase_symlinks (const char *pathspec)
Chris@41 6108 {
Chris@41 6109 #ifndef S_ISLNK
Chris@41 6110 return xstrdup (pathspec);
Chris@41 6111 #else
Chris@41 6112 char buf[LT_PATHMAX];
Chris@41 6113 struct stat s;
Chris@41 6114 char *tmp_pathspec = xstrdup (pathspec);
Chris@41 6115 char *p;
Chris@41 6116 int has_symlinks = 0;
Chris@41 6117 while (strlen (tmp_pathspec) && !has_symlinks)
Chris@41 6118 {
Chris@41 6119 lt_debugprintf (__FILE__, __LINE__,
Chris@41 6120 "checking path component for symlinks: %s\n",
Chris@41 6121 tmp_pathspec);
Chris@41 6122 if (lstat (tmp_pathspec, &s) == 0)
Chris@41 6123 {
Chris@41 6124 if (S_ISLNK (s.st_mode) != 0)
Chris@41 6125 {
Chris@41 6126 has_symlinks = 1;
Chris@41 6127 break;
Chris@41 6128 }
Chris@41 6129
Chris@41 6130 /* search backwards for last DIR_SEPARATOR */
Chris@41 6131 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
Chris@41 6132 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
Chris@41 6133 p--;
Chris@41 6134 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
Chris@41 6135 {
Chris@41 6136 /* no more DIR_SEPARATORS left */
Chris@41 6137 break;
Chris@41 6138 }
Chris@41 6139 *p = '\0';
Chris@41 6140 }
Chris@41 6141 else
Chris@41 6142 {
Chris@41 6143 lt_fatal (__FILE__, __LINE__,
Chris@41 6144 "error accessing file \"%s\": %s",
Chris@41 6145 tmp_pathspec, nonnull (strerror (errno)));
Chris@41 6146 }
Chris@41 6147 }
Chris@41 6148 XFREE (tmp_pathspec);
Chris@41 6149
Chris@41 6150 if (!has_symlinks)
Chris@41 6151 {
Chris@41 6152 return xstrdup (pathspec);
Chris@41 6153 }
Chris@41 6154
Chris@41 6155 tmp_pathspec = realpath (pathspec, buf);
Chris@41 6156 if (tmp_pathspec == 0)
Chris@41 6157 {
Chris@41 6158 lt_fatal (__FILE__, __LINE__,
Chris@41 6159 "could not follow symlinks for %s", pathspec);
Chris@41 6160 }
Chris@41 6161 return xstrdup (tmp_pathspec);
Chris@41 6162 #endif
Chris@41 6163 }
Chris@41 6164
Chris@41 6165 char *
Chris@41 6166 strendzap (char *str, const char *pat)
Chris@41 6167 {
Chris@41 6168 size_t len, patlen;
Chris@41 6169
Chris@41 6170 assert (str != NULL);
Chris@41 6171 assert (pat != NULL);
Chris@41 6172
Chris@41 6173 len = strlen (str);
Chris@41 6174 patlen = strlen (pat);
Chris@41 6175
Chris@41 6176 if (patlen <= len)
Chris@41 6177 {
Chris@41 6178 str += len - patlen;
Chris@41 6179 if (STREQ (str, pat))
Chris@41 6180 *str = '\0';
Chris@41 6181 }
Chris@41 6182 return str;
Chris@41 6183 }
Chris@41 6184
Chris@41 6185 void
Chris@41 6186 lt_debugprintf (const char *file, int line, const char *fmt, ...)
Chris@41 6187 {
Chris@41 6188 va_list args;
Chris@41 6189 if (lt_debug)
Chris@41 6190 {
Chris@41 6191 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
Chris@41 6192 va_start (args, fmt);
Chris@41 6193 (void) vfprintf (stderr, fmt, args);
Chris@41 6194 va_end (args);
Chris@41 6195 }
Chris@41 6196 }
Chris@41 6197
Chris@41 6198 static void
Chris@41 6199 lt_error_core (int exit_status, const char *file,
Chris@41 6200 int line, const char *mode,
Chris@41 6201 const char *message, va_list ap)
Chris@41 6202 {
Chris@41 6203 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
Chris@41 6204 vfprintf (stderr, message, ap);
Chris@41 6205 fprintf (stderr, ".\n");
Chris@41 6206
Chris@41 6207 if (exit_status >= 0)
Chris@41 6208 exit (exit_status);
Chris@41 6209 }
Chris@41 6210
Chris@41 6211 void
Chris@41 6212 lt_fatal (const char *file, int line, const char *message, ...)
Chris@41 6213 {
Chris@41 6214 va_list ap;
Chris@41 6215 va_start (ap, message);
Chris@41 6216 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
Chris@41 6217 va_end (ap);
Chris@41 6218 }
Chris@41 6219
Chris@41 6220 static const char *
Chris@41 6221 nonnull (const char *s)
Chris@41 6222 {
Chris@41 6223 return s ? s : "(null)";
Chris@41 6224 }
Chris@41 6225
Chris@41 6226 static const char *
Chris@41 6227 nonempty (const char *s)
Chris@41 6228 {
Chris@41 6229 return (s && !*s) ? "(empty)" : nonnull (s);
Chris@41 6230 }
Chris@41 6231
Chris@41 6232 void
Chris@41 6233 lt_setenv (const char *name, const char *value)
Chris@41 6234 {
Chris@41 6235 lt_debugprintf (__FILE__, __LINE__,
Chris@41 6236 "(lt_setenv) setting '%s' to '%s'\n",
Chris@41 6237 nonnull (name), nonnull (value));
Chris@41 6238 {
Chris@41 6239 #ifdef HAVE_SETENV
Chris@41 6240 /* always make a copy, for consistency with !HAVE_SETENV */
Chris@41 6241 char *str = xstrdup (value);
Chris@41 6242 setenv (name, str, 1);
Chris@41 6243 #else
Chris@41 6244 size_t len = strlen (name) + 1 + strlen (value) + 1;
Chris@41 6245 char *str = XMALLOC (char, len);
Chris@41 6246 sprintf (str, "%s=%s", name, value);
Chris@41 6247 if (putenv (str) != EXIT_SUCCESS)
Chris@41 6248 {
Chris@41 6249 XFREE (str);
Chris@41 6250 }
Chris@41 6251 #endif
Chris@41 6252 }
Chris@41 6253 }
Chris@41 6254
Chris@41 6255 char *
Chris@41 6256 lt_extend_str (const char *orig_value, const char *add, int to_end)
Chris@41 6257 {
Chris@41 6258 char *new_value;
Chris@41 6259 if (orig_value && *orig_value)
Chris@41 6260 {
Chris@41 6261 size_t orig_value_len = strlen (orig_value);
Chris@41 6262 size_t add_len = strlen (add);
Chris@41 6263 new_value = XMALLOC (char, add_len + orig_value_len + 1);
Chris@41 6264 if (to_end)
Chris@41 6265 {
Chris@41 6266 strcpy (new_value, orig_value);
Chris@41 6267 strcpy (new_value + orig_value_len, add);
Chris@41 6268 }
Chris@41 6269 else
Chris@41 6270 {
Chris@41 6271 strcpy (new_value, add);
Chris@41 6272 strcpy (new_value + add_len, orig_value);
Chris@41 6273 }
Chris@41 6274 }
Chris@41 6275 else
Chris@41 6276 {
Chris@41 6277 new_value = xstrdup (add);
Chris@41 6278 }
Chris@41 6279 return new_value;
Chris@41 6280 }
Chris@41 6281
Chris@41 6282 void
Chris@41 6283 lt_update_exe_path (const char *name, const char *value)
Chris@41 6284 {
Chris@41 6285 lt_debugprintf (__FILE__, __LINE__,
Chris@41 6286 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
Chris@41 6287 nonnull (name), nonnull (value));
Chris@41 6288
Chris@41 6289 if (name && *name && value && *value)
Chris@41 6290 {
Chris@41 6291 char *new_value = lt_extend_str (getenv (name), value, 0);
Chris@41 6292 /* some systems can't cope with a ':'-terminated path #' */
Chris@41 6293 size_t len = strlen (new_value);
Chris@41 6294 while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
Chris@41 6295 {
Chris@41 6296 new_value[--len] = '\0';
Chris@41 6297 }
Chris@41 6298 lt_setenv (name, new_value);
Chris@41 6299 XFREE (new_value);
Chris@41 6300 }
Chris@41 6301 }
Chris@41 6302
Chris@41 6303 void
Chris@41 6304 lt_update_lib_path (const char *name, const char *value)
Chris@41 6305 {
Chris@41 6306 lt_debugprintf (__FILE__, __LINE__,
Chris@41 6307 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
Chris@41 6308 nonnull (name), nonnull (value));
Chris@41 6309
Chris@41 6310 if (name && *name && value && *value)
Chris@41 6311 {
Chris@41 6312 char *new_value = lt_extend_str (getenv (name), value, 0);
Chris@41 6313 lt_setenv (name, new_value);
Chris@41 6314 XFREE (new_value);
Chris@41 6315 }
Chris@41 6316 }
Chris@41 6317
Chris@41 6318 EOF
Chris@41 6319 case $host_os in
Chris@41 6320 mingw*)
Chris@41 6321 cat <<"EOF"
Chris@41 6322
Chris@41 6323 /* Prepares an argument vector before calling spawn().
Chris@41 6324 Note that spawn() does not by itself call the command interpreter
Chris@41 6325 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
Chris@41 6326 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
Chris@41 6327 GetVersionEx(&v);
Chris@41 6328 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
Chris@41 6329 }) ? "cmd.exe" : "command.com").
Chris@41 6330 Instead it simply concatenates the arguments, separated by ' ', and calls
Chris@41 6331 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
Chris@41 6332 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
Chris@41 6333 special way:
Chris@41 6334 - Space and tab are interpreted as delimiters. They are not treated as
Chris@41 6335 delimiters if they are surrounded by double quotes: "...".
Chris@41 6336 - Unescaped double quotes are removed from the input. Their only effect is
Chris@41 6337 that within double quotes, space and tab are treated like normal
Chris@41 6338 characters.
Chris@41 6339 - Backslashes not followed by double quotes are not special.
Chris@41 6340 - But 2*n+1 backslashes followed by a double quote become
Chris@41 6341 n backslashes followed by a double quote (n >= 0):
Chris@41 6342 \" -> "
Chris@41 6343 \\\" -> \"
Chris@41 6344 \\\\\" -> \\"
Chris@41 6345 */
Chris@41 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@41 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@41 6348 char **
Chris@41 6349 prepare_spawn (char **argv)
Chris@41 6350 {
Chris@41 6351 size_t argc;
Chris@41 6352 char **new_argv;
Chris@41 6353 size_t i;
Chris@41 6354
Chris@41 6355 /* Count number of arguments. */
Chris@41 6356 for (argc = 0; argv[argc] != NULL; argc++)
Chris@41 6357 ;
Chris@41 6358
Chris@41 6359 /* Allocate new argument vector. */
Chris@41 6360 new_argv = XMALLOC (char *, argc + 1);
Chris@41 6361
Chris@41 6362 /* Put quoted arguments into the new argument vector. */
Chris@41 6363 for (i = 0; i < argc; i++)
Chris@41 6364 {
Chris@41 6365 const char *string = argv[i];
Chris@41 6366
Chris@41 6367 if (string[0] == '\0')
Chris@41 6368 new_argv[i] = xstrdup ("\"\"");
Chris@41 6369 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
Chris@41 6370 {
Chris@41 6371 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
Chris@41 6372 size_t length;
Chris@41 6373 unsigned int backslashes;
Chris@41 6374 const char *s;
Chris@41 6375 char *quoted_string;
Chris@41 6376 char *p;
Chris@41 6377
Chris@41 6378 length = 0;
Chris@41 6379 backslashes = 0;
Chris@41 6380 if (quote_around)
Chris@41 6381 length++;
Chris@41 6382 for (s = string; *s != '\0'; s++)
Chris@41 6383 {
Chris@41 6384 char c = *s;
Chris@41 6385 if (c == '"')
Chris@41 6386 length += backslashes + 1;
Chris@41 6387 length++;
Chris@41 6388 if (c == '\\')
Chris@41 6389 backslashes++;
Chris@41 6390 else
Chris@41 6391 backslashes = 0;
Chris@41 6392 }
Chris@41 6393 if (quote_around)
Chris@41 6394 length += backslashes + 1;
Chris@41 6395
Chris@41 6396 quoted_string = XMALLOC (char, length + 1);
Chris@41 6397
Chris@41 6398 p = quoted_string;
Chris@41 6399 backslashes = 0;
Chris@41 6400 if (quote_around)
Chris@41 6401 *p++ = '"';
Chris@41 6402 for (s = string; *s != '\0'; s++)
Chris@41 6403 {
Chris@41 6404 char c = *s;
Chris@41 6405 if (c == '"')
Chris@41 6406 {
Chris@41 6407 unsigned int j;
Chris@41 6408 for (j = backslashes + 1; j > 0; j--)
Chris@41 6409 *p++ = '\\';
Chris@41 6410 }
Chris@41 6411 *p++ = c;
Chris@41 6412 if (c == '\\')
Chris@41 6413 backslashes++;
Chris@41 6414 else
Chris@41 6415 backslashes = 0;
Chris@41 6416 }
Chris@41 6417 if (quote_around)
Chris@41 6418 {
Chris@41 6419 unsigned int j;
Chris@41 6420 for (j = backslashes; j > 0; j--)
Chris@41 6421 *p++ = '\\';
Chris@41 6422 *p++ = '"';
Chris@41 6423 }
Chris@41 6424 *p = '\0';
Chris@41 6425
Chris@41 6426 new_argv[i] = quoted_string;
Chris@41 6427 }
Chris@41 6428 else
Chris@41 6429 new_argv[i] = (char *) string;
Chris@41 6430 }
Chris@41 6431 new_argv[argc] = NULL;
Chris@41 6432
Chris@41 6433 return new_argv;
Chris@41 6434 }
Chris@41 6435 EOF
Chris@41 6436 ;;
Chris@41 6437 esac
Chris@41 6438
Chris@41 6439 cat <<"EOF"
Chris@41 6440 void lt_dump_script (FILE* f)
Chris@41 6441 {
Chris@41 6442 EOF
Chris@41 6443 func_emit_wrapper yes |
Chris@41 6444 $SED -n -e '
Chris@41 6445 s/^\(.\{79\}\)\(..*\)/\1\
Chris@41 6446 \2/
Chris@41 6447 h
Chris@41 6448 s/\([\\"]\)/\\\1/g
Chris@41 6449 s/$/\\n/
Chris@41 6450 s/\([^\n]*\).*/ fputs ("\1", f);/p
Chris@41 6451 g
Chris@41 6452 D'
Chris@41 6453 cat <<"EOF"
Chris@41 6454 }
Chris@41 6455 EOF
Chris@41 6456 }
Chris@41 6457 # end: func_emit_cwrapperexe_src
Chris@41 6458
Chris@41 6459 # func_win32_import_lib_p ARG
Chris@41 6460 # True if ARG is an import lib, as indicated by $file_magic_cmd
Chris@41 6461 func_win32_import_lib_p ()
Chris@41 6462 {
Chris@41 6463 $debug_cmd
Chris@41 6464
Chris@41 6465 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
Chris@41 6466 *import*) : ;;
Chris@41 6467 *) false ;;
Chris@41 6468 esac
Chris@41 6469 }
Chris@41 6470
Chris@41 6471 # func_suncc_cstd_abi
Chris@41 6472 # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
Chris@41 6473 # Several compiler flags select an ABI that is incompatible with the
Chris@41 6474 # Cstd library. Avoid specifying it if any are in CXXFLAGS.
Chris@41 6475 func_suncc_cstd_abi ()
Chris@41 6476 {
Chris@41 6477 $debug_cmd
Chris@41 6478
Chris@41 6479 case " $compile_command " in
Chris@41 6480 *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
Chris@41 6481 suncc_use_cstd_abi=no
Chris@41 6482 ;;
Chris@41 6483 *)
Chris@41 6484 suncc_use_cstd_abi=yes
Chris@41 6485 ;;
Chris@41 6486 esac
Chris@41 6487 }
Chris@41 6488
Chris@41 6489 # func_mode_link arg...
Chris@41 6490 func_mode_link ()
Chris@41 6491 {
Chris@41 6492 $debug_cmd
Chris@41 6493
Chris@41 6494 case $host in
Chris@41 6495 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
Chris@41 6496 # It is impossible to link a dll without this setting, and
Chris@41 6497 # we shouldn't force the makefile maintainer to figure out
Chris@41 6498 # what system we are compiling for in order to pass an extra
Chris@41 6499 # flag for every libtool invocation.
Chris@41 6500 # allow_undefined=no
Chris@41 6501
Chris@41 6502 # FIXME: Unfortunately, there are problems with the above when trying
Chris@41 6503 # to make a dll that has undefined symbols, in which case not
Chris@41 6504 # even a static library is built. For now, we need to specify
Chris@41 6505 # -no-undefined on the libtool link line when we can be certain
Chris@41 6506 # that all symbols are satisfied, otherwise we get a static library.
Chris@41 6507 allow_undefined=yes
Chris@41 6508 ;;
Chris@41 6509 *)
Chris@41 6510 allow_undefined=yes
Chris@41 6511 ;;
Chris@41 6512 esac
Chris@41 6513 libtool_args=$nonopt
Chris@41 6514 base_compile="$nonopt $@"
Chris@41 6515 compile_command=$nonopt
Chris@41 6516 finalize_command=$nonopt
Chris@41 6517
Chris@41 6518 compile_rpath=
Chris@41 6519 finalize_rpath=
Chris@41 6520 compile_shlibpath=
Chris@41 6521 finalize_shlibpath=
Chris@41 6522 convenience=
Chris@41 6523 old_convenience=
Chris@41 6524 deplibs=
Chris@41 6525 old_deplibs=
Chris@41 6526 compiler_flags=
Chris@41 6527 linker_flags=
Chris@41 6528 dllsearchpath=
Chris@41 6529 lib_search_path=`pwd`
Chris@41 6530 inst_prefix_dir=
Chris@41 6531 new_inherited_linker_flags=
Chris@41 6532
Chris@41 6533 avoid_version=no
Chris@41 6534 bindir=
Chris@41 6535 dlfiles=
Chris@41 6536 dlprefiles=
Chris@41 6537 dlself=no
Chris@41 6538 export_dynamic=no
Chris@41 6539 export_symbols=
Chris@41 6540 export_symbols_regex=
Chris@41 6541 generated=
Chris@41 6542 libobjs=
Chris@41 6543 ltlibs=
Chris@41 6544 module=no
Chris@41 6545 no_install=no
Chris@41 6546 objs=
Chris@41 6547 os2dllname=
Chris@41 6548 non_pic_objects=
Chris@41 6549 precious_files_regex=
Chris@41 6550 prefer_static_libs=no
Chris@41 6551 preload=false
Chris@41 6552 prev=
Chris@41 6553 prevarg=
Chris@41 6554 release=
Chris@41 6555 rpath=
Chris@41 6556 xrpath=
Chris@41 6557 perm_rpath=
Chris@41 6558 temp_rpath=
Chris@41 6559 thread_safe=no
Chris@41 6560 vinfo=
Chris@41 6561 vinfo_number=no
Chris@41 6562 weak_libs=
Chris@41 6563 single_module=$wl-single_module
Chris@41 6564 func_infer_tag $base_compile
Chris@41 6565
Chris@41 6566 # We need to know -static, to get the right output filenames.
Chris@41 6567 for arg
Chris@41 6568 do
Chris@41 6569 case $arg in
Chris@41 6570 -shared)
Chris@41 6571 test yes != "$build_libtool_libs" \
Chris@41 6572 && func_fatal_configuration "cannot build a shared library"
Chris@41 6573 build_old_libs=no
Chris@41 6574 break
Chris@41 6575 ;;
Chris@41 6576 -all-static | -static | -static-libtool-libs)
Chris@41 6577 case $arg in
Chris@41 6578 -all-static)
Chris@41 6579 if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
Chris@41 6580 func_warning "complete static linking is impossible in this configuration"
Chris@41 6581 fi
Chris@41 6582 if test -n "$link_static_flag"; then
Chris@41 6583 dlopen_self=$dlopen_self_static
Chris@41 6584 fi
Chris@41 6585 prefer_static_libs=yes
Chris@41 6586 ;;
Chris@41 6587 -static)
Chris@41 6588 if test -z "$pic_flag" && test -n "$link_static_flag"; then
Chris@41 6589 dlopen_self=$dlopen_self_static
Chris@41 6590 fi
Chris@41 6591 prefer_static_libs=built
Chris@41 6592 ;;
Chris@41 6593 -static-libtool-libs)
Chris@41 6594 if test -z "$pic_flag" && test -n "$link_static_flag"; then
Chris@41 6595 dlopen_self=$dlopen_self_static
Chris@41 6596 fi
Chris@41 6597 prefer_static_libs=yes
Chris@41 6598 ;;
Chris@41 6599 esac
Chris@41 6600 build_libtool_libs=no
Chris@41 6601 build_old_libs=yes
Chris@41 6602 break
Chris@41 6603 ;;
Chris@41 6604 esac
Chris@41 6605 done
Chris@41 6606
Chris@41 6607 # See if our shared archives depend on static archives.
Chris@41 6608 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
Chris@41 6609
Chris@41 6610 # Go through the arguments, transforming them on the way.
Chris@41 6611 while test "$#" -gt 0; do
Chris@41 6612 arg=$1
Chris@41 6613 shift
Chris@41 6614 func_quote_for_eval "$arg"
Chris@41 6615 qarg=$func_quote_for_eval_unquoted_result
Chris@41 6616 func_append libtool_args " $func_quote_for_eval_result"
Chris@41 6617
Chris@41 6618 # If the previous option needs an argument, assign it.
Chris@41 6619 if test -n "$prev"; then
Chris@41 6620 case $prev in
Chris@41 6621 output)
Chris@41 6622 func_append compile_command " @OUTPUT@"
Chris@41 6623 func_append finalize_command " @OUTPUT@"
Chris@41 6624 ;;
Chris@41 6625 esac
Chris@41 6626
Chris@41 6627 case $prev in
Chris@41 6628 bindir)
Chris@41 6629 bindir=$arg
Chris@41 6630 prev=
Chris@41 6631 continue
Chris@41 6632 ;;
Chris@41 6633 dlfiles|dlprefiles)
Chris@41 6634 $preload || {
Chris@41 6635 # Add the symbol object into the linking commands.
Chris@41 6636 func_append compile_command " @SYMFILE@"
Chris@41 6637 func_append finalize_command " @SYMFILE@"
Chris@41 6638 preload=:
Chris@41 6639 }
Chris@41 6640 case $arg in
Chris@41 6641 *.la | *.lo) ;; # We handle these cases below.
Chris@41 6642 force)
Chris@41 6643 if test no = "$dlself"; then
Chris@41 6644 dlself=needless
Chris@41 6645 export_dynamic=yes
Chris@41 6646 fi
Chris@41 6647 prev=
Chris@41 6648 continue
Chris@41 6649 ;;
Chris@41 6650 self)
Chris@41 6651 if test dlprefiles = "$prev"; then
Chris@41 6652 dlself=yes
Chris@41 6653 elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
Chris@41 6654 dlself=yes
Chris@41 6655 else
Chris@41 6656 dlself=needless
Chris@41 6657 export_dynamic=yes
Chris@41 6658 fi
Chris@41 6659 prev=
Chris@41 6660 continue
Chris@41 6661 ;;
Chris@41 6662 *)
Chris@41 6663 if test dlfiles = "$prev"; then
Chris@41 6664 func_append dlfiles " $arg"
Chris@41 6665 else
Chris@41 6666 func_append dlprefiles " $arg"
Chris@41 6667 fi
Chris@41 6668 prev=
Chris@41 6669 continue
Chris@41 6670 ;;
Chris@41 6671 esac
Chris@41 6672 ;;
Chris@41 6673 expsyms)
Chris@41 6674 export_symbols=$arg
Chris@41 6675 test -f "$arg" \
Chris@41 6676 || func_fatal_error "symbol file '$arg' does not exist"
Chris@41 6677 prev=
Chris@41 6678 continue
Chris@41 6679 ;;
Chris@41 6680 expsyms_regex)
Chris@41 6681 export_symbols_regex=$arg
Chris@41 6682 prev=
Chris@41 6683 continue
Chris@41 6684 ;;
Chris@41 6685 framework)
Chris@41 6686 case $host in
Chris@41 6687 *-*-darwin*)
Chris@41 6688 case "$deplibs " in
Chris@41 6689 *" $qarg.ltframework "*) ;;
Chris@41 6690 *) func_append deplibs " $qarg.ltframework" # this is fixed later
Chris@41 6691 ;;
Chris@41 6692 esac
Chris@41 6693 ;;
Chris@41 6694 esac
Chris@41 6695 prev=
Chris@41 6696 continue
Chris@41 6697 ;;
Chris@41 6698 inst_prefix)
Chris@41 6699 inst_prefix_dir=$arg
Chris@41 6700 prev=
Chris@41 6701 continue
Chris@41 6702 ;;
Chris@41 6703 mllvm)
Chris@41 6704 # Clang does not use LLVM to link, so we can simply discard any
Chris@41 6705 # '-mllvm $arg' options when doing the link step.
Chris@41 6706 prev=
Chris@41 6707 continue
Chris@41 6708 ;;
Chris@41 6709 objectlist)
Chris@41 6710 if test -f "$arg"; then
Chris@41 6711 save_arg=$arg
Chris@41 6712 moreargs=
Chris@41 6713 for fil in `cat "$save_arg"`
Chris@41 6714 do
Chris@41 6715 # func_append moreargs " $fil"
Chris@41 6716 arg=$fil
Chris@41 6717 # A libtool-controlled object.
Chris@41 6718
Chris@41 6719 # Check to see that this really is a libtool object.
Chris@41 6720 if func_lalib_unsafe_p "$arg"; then
Chris@41 6721 pic_object=
Chris@41 6722 non_pic_object=
Chris@41 6723
Chris@41 6724 # Read the .lo file
Chris@41 6725 func_source "$arg"
Chris@41 6726
Chris@41 6727 if test -z "$pic_object" ||
Chris@41 6728 test -z "$non_pic_object" ||
Chris@41 6729 test none = "$pic_object" &&
Chris@41 6730 test none = "$non_pic_object"; then
Chris@41 6731 func_fatal_error "cannot find name of object for '$arg'"
Chris@41 6732 fi
Chris@41 6733
Chris@41 6734 # Extract subdirectory from the argument.
Chris@41 6735 func_dirname "$arg" "/" ""
Chris@41 6736 xdir=$func_dirname_result
Chris@41 6737
Chris@41 6738 if test none != "$pic_object"; then
Chris@41 6739 # Prepend the subdirectory the object is found in.
Chris@41 6740 pic_object=$xdir$pic_object
Chris@41 6741
Chris@41 6742 if test dlfiles = "$prev"; then
Chris@41 6743 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
Chris@41 6744 func_append dlfiles " $pic_object"
Chris@41 6745 prev=
Chris@41 6746 continue
Chris@41 6747 else
Chris@41 6748 # If libtool objects are unsupported, then we need to preload.
Chris@41 6749 prev=dlprefiles
Chris@41 6750 fi
Chris@41 6751 fi
Chris@41 6752
Chris@41 6753 # CHECK ME: I think I busted this. -Ossama
Chris@41 6754 if test dlprefiles = "$prev"; then
Chris@41 6755 # Preload the old-style object.
Chris@41 6756 func_append dlprefiles " $pic_object"
Chris@41 6757 prev=
Chris@41 6758 fi
Chris@41 6759
Chris@41 6760 # A PIC object.
Chris@41 6761 func_append libobjs " $pic_object"
Chris@41 6762 arg=$pic_object
Chris@41 6763 fi
Chris@41 6764
Chris@41 6765 # Non-PIC object.
Chris@41 6766 if test none != "$non_pic_object"; then
Chris@41 6767 # Prepend the subdirectory the object is found in.
Chris@41 6768 non_pic_object=$xdir$non_pic_object
Chris@41 6769
Chris@41 6770 # A standard non-PIC object
Chris@41 6771 func_append non_pic_objects " $non_pic_object"
Chris@41 6772 if test -z "$pic_object" || test none = "$pic_object"; then
Chris@41 6773 arg=$non_pic_object
Chris@41 6774 fi
Chris@41 6775 else
Chris@41 6776 # If the PIC object exists, use it instead.
Chris@41 6777 # $xdir was prepended to $pic_object above.
Chris@41 6778 non_pic_object=$pic_object
Chris@41 6779 func_append non_pic_objects " $non_pic_object"
Chris@41 6780 fi
Chris@41 6781 else
Chris@41 6782 # Only an error if not doing a dry-run.
Chris@41 6783 if $opt_dry_run; then
Chris@41 6784 # Extract subdirectory from the argument.
Chris@41 6785 func_dirname "$arg" "/" ""
Chris@41 6786 xdir=$func_dirname_result
Chris@41 6787
Chris@41 6788 func_lo2o "$arg"
Chris@41 6789 pic_object=$xdir$objdir/$func_lo2o_result
Chris@41 6790 non_pic_object=$xdir$func_lo2o_result
Chris@41 6791 func_append libobjs " $pic_object"
Chris@41 6792 func_append non_pic_objects " $non_pic_object"
Chris@41 6793 else
Chris@41 6794 func_fatal_error "'$arg' is not a valid libtool object"
Chris@41 6795 fi
Chris@41 6796 fi
Chris@41 6797 done
Chris@41 6798 else
Chris@41 6799 func_fatal_error "link input file '$arg' does not exist"
Chris@41 6800 fi
Chris@41 6801 arg=$save_arg
Chris@41 6802 prev=
Chris@41 6803 continue
Chris@41 6804 ;;
Chris@41 6805 os2dllname)
Chris@41 6806 os2dllname=$arg
Chris@41 6807 prev=
Chris@41 6808 continue
Chris@41 6809 ;;
Chris@41 6810 precious_regex)
Chris@41 6811 precious_files_regex=$arg
Chris@41 6812 prev=
Chris@41 6813 continue
Chris@41 6814 ;;
Chris@41 6815 release)
Chris@41 6816 release=-$arg
Chris@41 6817 prev=
Chris@41 6818 continue
Chris@41 6819 ;;
Chris@41 6820 rpath | xrpath)
Chris@41 6821 # We need an absolute path.
Chris@41 6822 case $arg in
Chris@41 6823 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@41 6824 *)
Chris@41 6825 func_fatal_error "only absolute run-paths are allowed"
Chris@41 6826 ;;
Chris@41 6827 esac
Chris@41 6828 if test rpath = "$prev"; then
Chris@41 6829 case "$rpath " in
Chris@41 6830 *" $arg "*) ;;
Chris@41 6831 *) func_append rpath " $arg" ;;
Chris@41 6832 esac
Chris@41 6833 else
Chris@41 6834 case "$xrpath " in
Chris@41 6835 *" $arg "*) ;;
Chris@41 6836 *) func_append xrpath " $arg" ;;
Chris@41 6837 esac
Chris@41 6838 fi
Chris@41 6839 prev=
Chris@41 6840 continue
Chris@41 6841 ;;
Chris@41 6842 shrext)
Chris@41 6843 shrext_cmds=$arg
Chris@41 6844 prev=
Chris@41 6845 continue
Chris@41 6846 ;;
Chris@41 6847 weak)
Chris@41 6848 func_append weak_libs " $arg"
Chris@41 6849 prev=
Chris@41 6850 continue
Chris@41 6851 ;;
Chris@41 6852 xcclinker)
Chris@41 6853 func_append linker_flags " $qarg"
Chris@41 6854 func_append compiler_flags " $qarg"
Chris@41 6855 prev=
Chris@41 6856 func_append compile_command " $qarg"
Chris@41 6857 func_append finalize_command " $qarg"
Chris@41 6858 continue
Chris@41 6859 ;;
Chris@41 6860 xcompiler)
Chris@41 6861 func_append compiler_flags " $qarg"
Chris@41 6862 prev=
Chris@41 6863 func_append compile_command " $qarg"
Chris@41 6864 func_append finalize_command " $qarg"
Chris@41 6865 continue
Chris@41 6866 ;;
Chris@41 6867 xlinker)
Chris@41 6868 func_append linker_flags " $qarg"
Chris@41 6869 func_append compiler_flags " $wl$qarg"
Chris@41 6870 prev=
Chris@41 6871 func_append compile_command " $wl$qarg"
Chris@41 6872 func_append finalize_command " $wl$qarg"
Chris@41 6873 continue
Chris@41 6874 ;;
Chris@41 6875 *)
Chris@41 6876 eval "$prev=\"\$arg\""
Chris@41 6877 prev=
Chris@41 6878 continue
Chris@41 6879 ;;
Chris@41 6880 esac
Chris@41 6881 fi # test -n "$prev"
Chris@41 6882
Chris@41 6883 prevarg=$arg
Chris@41 6884
Chris@41 6885 case $arg in
Chris@41 6886 -all-static)
Chris@41 6887 if test -n "$link_static_flag"; then
Chris@41 6888 # See comment for -static flag below, for more details.
Chris@41 6889 func_append compile_command " $link_static_flag"
Chris@41 6890 func_append finalize_command " $link_static_flag"
Chris@41 6891 fi
Chris@41 6892 continue
Chris@41 6893 ;;
Chris@41 6894
Chris@41 6895 -allow-undefined)
Chris@41 6896 # FIXME: remove this flag sometime in the future.
Chris@41 6897 func_fatal_error "'-allow-undefined' must not be used because it is the default"
Chris@41 6898 ;;
Chris@41 6899
Chris@41 6900 -avoid-version)
Chris@41 6901 avoid_version=yes
Chris@41 6902 continue
Chris@41 6903 ;;
Chris@41 6904
Chris@41 6905 -bindir)
Chris@41 6906 prev=bindir
Chris@41 6907 continue
Chris@41 6908 ;;
Chris@41 6909
Chris@41 6910 -dlopen)
Chris@41 6911 prev=dlfiles
Chris@41 6912 continue
Chris@41 6913 ;;
Chris@41 6914
Chris@41 6915 -dlpreopen)
Chris@41 6916 prev=dlprefiles
Chris@41 6917 continue
Chris@41 6918 ;;
Chris@41 6919
Chris@41 6920 -export-dynamic)
Chris@41 6921 export_dynamic=yes
Chris@41 6922 continue
Chris@41 6923 ;;
Chris@41 6924
Chris@41 6925 -export-symbols | -export-symbols-regex)
Chris@41 6926 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
Chris@41 6927 func_fatal_error "more than one -exported-symbols argument is not allowed"
Chris@41 6928 fi
Chris@41 6929 if test X-export-symbols = "X$arg"; then
Chris@41 6930 prev=expsyms
Chris@41 6931 else
Chris@41 6932 prev=expsyms_regex
Chris@41 6933 fi
Chris@41 6934 continue
Chris@41 6935 ;;
Chris@41 6936
Chris@41 6937 -framework)
Chris@41 6938 prev=framework
Chris@41 6939 continue
Chris@41 6940 ;;
Chris@41 6941
Chris@41 6942 -inst-prefix-dir)
Chris@41 6943 prev=inst_prefix
Chris@41 6944 continue
Chris@41 6945 ;;
Chris@41 6946
Chris@41 6947 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
Chris@41 6948 # so, if we see these flags be careful not to treat them like -L
Chris@41 6949 -L[A-Z][A-Z]*:*)
Chris@41 6950 case $with_gcc/$host in
Chris@41 6951 no/*-*-irix* | /*-*-irix*)
Chris@41 6952 func_append compile_command " $arg"
Chris@41 6953 func_append finalize_command " $arg"
Chris@41 6954 ;;
Chris@41 6955 esac
Chris@41 6956 continue
Chris@41 6957 ;;
Chris@41 6958
Chris@41 6959 -L*)
Chris@41 6960 func_stripname "-L" '' "$arg"
Chris@41 6961 if test -z "$func_stripname_result"; then
Chris@41 6962 if test "$#" -gt 0; then
Chris@41 6963 func_fatal_error "require no space between '-L' and '$1'"
Chris@41 6964 else
Chris@41 6965 func_fatal_error "need path for '-L' option"
Chris@41 6966 fi
Chris@41 6967 fi
Chris@41 6968 func_resolve_sysroot "$func_stripname_result"
Chris@41 6969 dir=$func_resolve_sysroot_result
Chris@41 6970 # We need an absolute path.
Chris@41 6971 case $dir in
Chris@41 6972 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@41 6973 *)
Chris@41 6974 absdir=`cd "$dir" && pwd`
Chris@41 6975 test -z "$absdir" && \
Chris@41 6976 func_fatal_error "cannot determine absolute directory name of '$dir'"
Chris@41 6977 dir=$absdir
Chris@41 6978 ;;
Chris@41 6979 esac
Chris@41 6980 case "$deplibs " in
Chris@41 6981 *" -L$dir "* | *" $arg "*)
Chris@41 6982 # Will only happen for absolute or sysroot arguments
Chris@41 6983 ;;
Chris@41 6984 *)
Chris@41 6985 # Preserve sysroot, but never include relative directories
Chris@41 6986 case $dir in
Chris@41 6987 [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
Chris@41 6988 *) func_append deplibs " -L$dir" ;;
Chris@41 6989 esac
Chris@41 6990 func_append lib_search_path " $dir"
Chris@41 6991 ;;
Chris@41 6992 esac
Chris@41 6993 case $host in
Chris@41 6994 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
Chris@41 6995 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
Chris@41 6996 case :$dllsearchpath: in
Chris@41 6997 *":$dir:"*) ;;
Chris@41 6998 ::) dllsearchpath=$dir;;
Chris@41 6999 *) func_append dllsearchpath ":$dir";;
Chris@41 7000 esac
Chris@41 7001 case :$dllsearchpath: in
Chris@41 7002 *":$testbindir:"*) ;;
Chris@41 7003 ::) dllsearchpath=$testbindir;;
Chris@41 7004 *) func_append dllsearchpath ":$testbindir";;
Chris@41 7005 esac
Chris@41 7006 ;;
Chris@41 7007 esac
Chris@41 7008 continue
Chris@41 7009 ;;
Chris@41 7010
Chris@41 7011 -l*)
Chris@41 7012 if test X-lc = "X$arg" || test X-lm = "X$arg"; then
Chris@41 7013 case $host in
Chris@41 7014 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
Chris@41 7015 # These systems don't actually have a C or math library (as such)
Chris@41 7016 continue
Chris@41 7017 ;;
Chris@41 7018 *-*-os2*)
Chris@41 7019 # These systems don't actually have a C library (as such)
Chris@41 7020 test X-lc = "X$arg" && continue
Chris@41 7021 ;;
Chris@41 7022 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
Chris@41 7023 # Do not include libc due to us having libc/libc_r.
Chris@41 7024 test X-lc = "X$arg" && continue
Chris@41 7025 ;;
Chris@41 7026 *-*-rhapsody* | *-*-darwin1.[012])
Chris@41 7027 # Rhapsody C and math libraries are in the System framework
Chris@41 7028 func_append deplibs " System.ltframework"
Chris@41 7029 continue
Chris@41 7030 ;;
Chris@41 7031 *-*-sco3.2v5* | *-*-sco5v6*)
Chris@41 7032 # Causes problems with __ctype
Chris@41 7033 test X-lc = "X$arg" && continue
Chris@41 7034 ;;
Chris@41 7035 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
Chris@41 7036 # Compiler inserts libc in the correct place for threads to work
Chris@41 7037 test X-lc = "X$arg" && continue
Chris@41 7038 ;;
Chris@41 7039 esac
Chris@41 7040 elif test X-lc_r = "X$arg"; then
Chris@41 7041 case $host in
Chris@41 7042 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
Chris@41 7043 # Do not include libc_r directly, use -pthread flag.
Chris@41 7044 continue
Chris@41 7045 ;;
Chris@41 7046 esac
Chris@41 7047 fi
Chris@41 7048 func_append deplibs " $arg"
Chris@41 7049 continue
Chris@41 7050 ;;
Chris@41 7051
Chris@41 7052 -mllvm)
Chris@41 7053 prev=mllvm
Chris@41 7054 continue
Chris@41 7055 ;;
Chris@41 7056
Chris@41 7057 -module)
Chris@41 7058 module=yes
Chris@41 7059 continue
Chris@41 7060 ;;
Chris@41 7061
Chris@41 7062 # Tru64 UNIX uses -model [arg] to determine the layout of C++
Chris@41 7063 # classes, name mangling, and exception handling.
Chris@41 7064 # Darwin uses the -arch flag to determine output architecture.
Chris@41 7065 -model|-arch|-isysroot|--sysroot)
Chris@41 7066 func_append compiler_flags " $arg"
Chris@41 7067 func_append compile_command " $arg"
Chris@41 7068 func_append finalize_command " $arg"
Chris@41 7069 prev=xcompiler
Chris@41 7070 continue
Chris@41 7071 ;;
Chris@41 7072
Chris@41 7073 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
Chris@41 7074 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
Chris@41 7075 func_append compiler_flags " $arg"
Chris@41 7076 func_append compile_command " $arg"
Chris@41 7077 func_append finalize_command " $arg"
Chris@41 7078 case "$new_inherited_linker_flags " in
Chris@41 7079 *" $arg "*) ;;
Chris@41 7080 * ) func_append new_inherited_linker_flags " $arg" ;;
Chris@41 7081 esac
Chris@41 7082 continue
Chris@41 7083 ;;
Chris@41 7084
Chris@41 7085 -multi_module)
Chris@41 7086 single_module=$wl-multi_module
Chris@41 7087 continue
Chris@41 7088 ;;
Chris@41 7089
Chris@41 7090 -no-fast-install)
Chris@41 7091 fast_install=no
Chris@41 7092 continue
Chris@41 7093 ;;
Chris@41 7094
Chris@41 7095 -no-install)
Chris@41 7096 case $host in
Chris@41 7097 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
Chris@41 7098 # The PATH hackery in wrapper scripts is required on Windows
Chris@41 7099 # and Darwin in order for the loader to find any dlls it needs.
Chris@41 7100 func_warning "'-no-install' is ignored for $host"
Chris@41 7101 func_warning "assuming '-no-fast-install' instead"
Chris@41 7102 fast_install=no
Chris@41 7103 ;;
Chris@41 7104 *) no_install=yes ;;
Chris@41 7105 esac
Chris@41 7106 continue
Chris@41 7107 ;;
Chris@41 7108
Chris@41 7109 -no-undefined)
Chris@41 7110 allow_undefined=no
Chris@41 7111 continue
Chris@41 7112 ;;
Chris@41 7113
Chris@41 7114 -objectlist)
Chris@41 7115 prev=objectlist
Chris@41 7116 continue
Chris@41 7117 ;;
Chris@41 7118
Chris@41 7119 -os2dllname)
Chris@41 7120 prev=os2dllname
Chris@41 7121 continue
Chris@41 7122 ;;
Chris@41 7123
Chris@41 7124 -o) prev=output ;;
Chris@41 7125
Chris@41 7126 -precious-files-regex)
Chris@41 7127 prev=precious_regex
Chris@41 7128 continue
Chris@41 7129 ;;
Chris@41 7130
Chris@41 7131 -release)
Chris@41 7132 prev=release
Chris@41 7133 continue
Chris@41 7134 ;;
Chris@41 7135
Chris@41 7136 -rpath)
Chris@41 7137 prev=rpath
Chris@41 7138 continue
Chris@41 7139 ;;
Chris@41 7140
Chris@41 7141 -R)
Chris@41 7142 prev=xrpath
Chris@41 7143 continue
Chris@41 7144 ;;
Chris@41 7145
Chris@41 7146 -R*)
Chris@41 7147 func_stripname '-R' '' "$arg"
Chris@41 7148 dir=$func_stripname_result
Chris@41 7149 # We need an absolute path.
Chris@41 7150 case $dir in
Chris@41 7151 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@41 7152 =*)
Chris@41 7153 func_stripname '=' '' "$dir"
Chris@41 7154 dir=$lt_sysroot$func_stripname_result
Chris@41 7155 ;;
Chris@41 7156 *)
Chris@41 7157 func_fatal_error "only absolute run-paths are allowed"
Chris@41 7158 ;;
Chris@41 7159 esac
Chris@41 7160 case "$xrpath " in
Chris@41 7161 *" $dir "*) ;;
Chris@41 7162 *) func_append xrpath " $dir" ;;
Chris@41 7163 esac
Chris@41 7164 continue
Chris@41 7165 ;;
Chris@41 7166
Chris@41 7167 -shared)
Chris@41 7168 # The effects of -shared are defined in a previous loop.
Chris@41 7169 continue
Chris@41 7170 ;;
Chris@41 7171
Chris@41 7172 -shrext)
Chris@41 7173 prev=shrext
Chris@41 7174 continue
Chris@41 7175 ;;
Chris@41 7176
Chris@41 7177 -static | -static-libtool-libs)
Chris@41 7178 # The effects of -static are defined in a previous loop.
Chris@41 7179 # We used to do the same as -all-static on platforms that
Chris@41 7180 # didn't have a PIC flag, but the assumption that the effects
Chris@41 7181 # would be equivalent was wrong. It would break on at least
Chris@41 7182 # Digital Unix and AIX.
Chris@41 7183 continue
Chris@41 7184 ;;
Chris@41 7185
Chris@41 7186 -thread-safe)
Chris@41 7187 thread_safe=yes
Chris@41 7188 continue
Chris@41 7189 ;;
Chris@41 7190
Chris@41 7191 -version-info)
Chris@41 7192 prev=vinfo
Chris@41 7193 continue
Chris@41 7194 ;;
Chris@41 7195
Chris@41 7196 -version-number)
Chris@41 7197 prev=vinfo
Chris@41 7198 vinfo_number=yes
Chris@41 7199 continue
Chris@41 7200 ;;
Chris@41 7201
Chris@41 7202 -weak)
Chris@41 7203 prev=weak
Chris@41 7204 continue
Chris@41 7205 ;;
Chris@41 7206
Chris@41 7207 -Wc,*)
Chris@41 7208 func_stripname '-Wc,' '' "$arg"
Chris@41 7209 args=$func_stripname_result
Chris@41 7210 arg=
Chris@41 7211 save_ifs=$IFS; IFS=,
Chris@41 7212 for flag in $args; do
Chris@41 7213 IFS=$save_ifs
Chris@41 7214 func_quote_for_eval "$flag"
Chris@41 7215 func_append arg " $func_quote_for_eval_result"
Chris@41 7216 func_append compiler_flags " $func_quote_for_eval_result"
Chris@41 7217 done
Chris@41 7218 IFS=$save_ifs
Chris@41 7219 func_stripname ' ' '' "$arg"
Chris@41 7220 arg=$func_stripname_result
Chris@41 7221 ;;
Chris@41 7222
Chris@41 7223 -Wl,*)
Chris@41 7224 func_stripname '-Wl,' '' "$arg"
Chris@41 7225 args=$func_stripname_result
Chris@41 7226 arg=
Chris@41 7227 save_ifs=$IFS; IFS=,
Chris@41 7228 for flag in $args; do
Chris@41 7229 IFS=$save_ifs
Chris@41 7230 func_quote_for_eval "$flag"
Chris@41 7231 func_append arg " $wl$func_quote_for_eval_result"
Chris@41 7232 func_append compiler_flags " $wl$func_quote_for_eval_result"
Chris@41 7233 func_append linker_flags " $func_quote_for_eval_result"
Chris@41 7234 done
Chris@41 7235 IFS=$save_ifs
Chris@41 7236 func_stripname ' ' '' "$arg"
Chris@41 7237 arg=$func_stripname_result
Chris@41 7238 ;;
Chris@41 7239
Chris@41 7240 -Xcompiler)
Chris@41 7241 prev=xcompiler
Chris@41 7242 continue
Chris@41 7243 ;;
Chris@41 7244
Chris@41 7245 -Xlinker)
Chris@41 7246 prev=xlinker
Chris@41 7247 continue
Chris@41 7248 ;;
Chris@41 7249
Chris@41 7250 -XCClinker)
Chris@41 7251 prev=xcclinker
Chris@41 7252 continue
Chris@41 7253 ;;
Chris@41 7254
Chris@41 7255 # -msg_* for osf cc
Chris@41 7256 -msg_*)
Chris@41 7257 func_quote_for_eval "$arg"
Chris@41 7258 arg=$func_quote_for_eval_result
Chris@41 7259 ;;
Chris@41 7260
Chris@41 7261 # Flags to be passed through unchanged, with rationale:
Chris@41 7262 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
Chris@41 7263 # -r[0-9][0-9]* specify processor for the SGI compiler
Chris@41 7264 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
Chris@41 7265 # +DA*, +DD* enable 64-bit mode for the HP compiler
Chris@41 7266 # -q* compiler args for the IBM compiler
Chris@41 7267 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
Chris@41 7268 # -F/path path to uninstalled frameworks, gcc on darwin
Chris@41 7269 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
Chris@41 7270 # -fstack-protector* stack protector flags for GCC
Chris@41 7271 # @file GCC response files
Chris@41 7272 # -tp=* Portland pgcc target processor selection
Chris@41 7273 # --sysroot=* for sysroot support
Chris@41 7274 # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
Chris@41 7275 # -specs=* GCC specs files
Chris@41 7276 # -stdlib=* select c++ std lib with clang
Chris@41 7277 # -fsanitize=* Clang/GCC memory and address sanitizer
Chris@41 7278 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
Chris@41 7279 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
Chris@41 7280 -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
Chris@41 7281 -specs=*|-fsanitize=*)
Chris@41 7282 func_quote_for_eval "$arg"
Chris@41 7283 arg=$func_quote_for_eval_result
Chris@41 7284 func_append compile_command " $arg"
Chris@41 7285 func_append finalize_command " $arg"
Chris@41 7286 func_append compiler_flags " $arg"
Chris@41 7287 continue
Chris@41 7288 ;;
Chris@41 7289
Chris@41 7290 -Z*)
Chris@41 7291 if test os2 = "`expr $host : '.*\(os2\)'`"; then
Chris@41 7292 # OS/2 uses -Zxxx to specify OS/2-specific options
Chris@41 7293 compiler_flags="$compiler_flags $arg"
Chris@41 7294 func_append compile_command " $arg"
Chris@41 7295 func_append finalize_command " $arg"
Chris@41 7296 case $arg in
Chris@41 7297 -Zlinker | -Zstack)
Chris@41 7298 prev=xcompiler
Chris@41 7299 ;;
Chris@41 7300 esac
Chris@41 7301 continue
Chris@41 7302 else
Chris@41 7303 # Otherwise treat like 'Some other compiler flag' below
Chris@41 7304 func_quote_for_eval "$arg"
Chris@41 7305 arg=$func_quote_for_eval_result
Chris@41 7306 fi
Chris@41 7307 ;;
Chris@41 7308
Chris@41 7309 # Some other compiler flag.
Chris@41 7310 -* | +*)
Chris@41 7311 func_quote_for_eval "$arg"
Chris@41 7312 arg=$func_quote_for_eval_result
Chris@41 7313 ;;
Chris@41 7314
Chris@41 7315 *.$objext)
Chris@41 7316 # A standard object.
Chris@41 7317 func_append objs " $arg"
Chris@41 7318 ;;
Chris@41 7319
Chris@41 7320 *.lo)
Chris@41 7321 # A libtool-controlled object.
Chris@41 7322
Chris@41 7323 # Check to see that this really is a libtool object.
Chris@41 7324 if func_lalib_unsafe_p "$arg"; then
Chris@41 7325 pic_object=
Chris@41 7326 non_pic_object=
Chris@41 7327
Chris@41 7328 # Read the .lo file
Chris@41 7329 func_source "$arg"
Chris@41 7330
Chris@41 7331 if test -z "$pic_object" ||
Chris@41 7332 test -z "$non_pic_object" ||
Chris@41 7333 test none = "$pic_object" &&
Chris@41 7334 test none = "$non_pic_object"; then
Chris@41 7335 func_fatal_error "cannot find name of object for '$arg'"
Chris@41 7336 fi
Chris@41 7337
Chris@41 7338 # Extract subdirectory from the argument.
Chris@41 7339 func_dirname "$arg" "/" ""
Chris@41 7340 xdir=$func_dirname_result
Chris@41 7341
Chris@41 7342 test none = "$pic_object" || {
Chris@41 7343 # Prepend the subdirectory the object is found in.
Chris@41 7344 pic_object=$xdir$pic_object
Chris@41 7345
Chris@41 7346 if test dlfiles = "$prev"; then
Chris@41 7347 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
Chris@41 7348 func_append dlfiles " $pic_object"
Chris@41 7349 prev=
Chris@41 7350 continue
Chris@41 7351 else
Chris@41 7352 # If libtool objects are unsupported, then we need to preload.
Chris@41 7353 prev=dlprefiles
Chris@41 7354 fi
Chris@41 7355 fi
Chris@41 7356
Chris@41 7357 # CHECK ME: I think I busted this. -Ossama
Chris@41 7358 if test dlprefiles = "$prev"; then
Chris@41 7359 # Preload the old-style object.
Chris@41 7360 func_append dlprefiles " $pic_object"
Chris@41 7361 prev=
Chris@41 7362 fi
Chris@41 7363
Chris@41 7364 # A PIC object.
Chris@41 7365 func_append libobjs " $pic_object"
Chris@41 7366 arg=$pic_object
Chris@41 7367 }
Chris@41 7368
Chris@41 7369 # Non-PIC object.
Chris@41 7370 if test none != "$non_pic_object"; then
Chris@41 7371 # Prepend the subdirectory the object is found in.
Chris@41 7372 non_pic_object=$xdir$non_pic_object
Chris@41 7373
Chris@41 7374 # A standard non-PIC object
Chris@41 7375 func_append non_pic_objects " $non_pic_object"
Chris@41 7376 if test -z "$pic_object" || test none = "$pic_object"; then
Chris@41 7377 arg=$non_pic_object
Chris@41 7378 fi
Chris@41 7379 else
Chris@41 7380 # If the PIC object exists, use it instead.
Chris@41 7381 # $xdir was prepended to $pic_object above.
Chris@41 7382 non_pic_object=$pic_object
Chris@41 7383 func_append non_pic_objects " $non_pic_object"
Chris@41 7384 fi
Chris@41 7385 else
Chris@41 7386 # Only an error if not doing a dry-run.
Chris@41 7387 if $opt_dry_run; then
Chris@41 7388 # Extract subdirectory from the argument.
Chris@41 7389 func_dirname "$arg" "/" ""
Chris@41 7390 xdir=$func_dirname_result
Chris@41 7391
Chris@41 7392 func_lo2o "$arg"
Chris@41 7393 pic_object=$xdir$objdir/$func_lo2o_result
Chris@41 7394 non_pic_object=$xdir$func_lo2o_result
Chris@41 7395 func_append libobjs " $pic_object"
Chris@41 7396 func_append non_pic_objects " $non_pic_object"
Chris@41 7397 else
Chris@41 7398 func_fatal_error "'$arg' is not a valid libtool object"
Chris@41 7399 fi
Chris@41 7400 fi
Chris@41 7401 ;;
Chris@41 7402
Chris@41 7403 *.$libext)
Chris@41 7404 # An archive.
Chris@41 7405 func_append deplibs " $arg"
Chris@41 7406 func_append old_deplibs " $arg"
Chris@41 7407 continue
Chris@41 7408 ;;
Chris@41 7409
Chris@41 7410 *.la)
Chris@41 7411 # A libtool-controlled library.
Chris@41 7412
Chris@41 7413 func_resolve_sysroot "$arg"
Chris@41 7414 if test dlfiles = "$prev"; then
Chris@41 7415 # This library was specified with -dlopen.
Chris@41 7416 func_append dlfiles " $func_resolve_sysroot_result"
Chris@41 7417 prev=
Chris@41 7418 elif test dlprefiles = "$prev"; then
Chris@41 7419 # The library was specified with -dlpreopen.
Chris@41 7420 func_append dlprefiles " $func_resolve_sysroot_result"
Chris@41 7421 prev=
Chris@41 7422 else
Chris@41 7423 func_append deplibs " $func_resolve_sysroot_result"
Chris@41 7424 fi
Chris@41 7425 continue
Chris@41 7426 ;;
Chris@41 7427
Chris@41 7428 # Some other compiler argument.
Chris@41 7429 *)
Chris@41 7430 # Unknown arguments in both finalize_command and compile_command need
Chris@41 7431 # to be aesthetically quoted because they are evaled later.
Chris@41 7432 func_quote_for_eval "$arg"
Chris@41 7433 arg=$func_quote_for_eval_result
Chris@41 7434 ;;
Chris@41 7435 esac # arg
Chris@41 7436
Chris@41 7437 # Now actually substitute the argument into the commands.
Chris@41 7438 if test -n "$arg"; then
Chris@41 7439 func_append compile_command " $arg"
Chris@41 7440 func_append finalize_command " $arg"
Chris@41 7441 fi
Chris@41 7442 done # argument parsing loop
Chris@41 7443
Chris@41 7444 test -n "$prev" && \
Chris@41 7445 func_fatal_help "the '$prevarg' option requires an argument"
Chris@41 7446
Chris@41 7447 if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
Chris@41 7448 eval arg=\"$export_dynamic_flag_spec\"
Chris@41 7449 func_append compile_command " $arg"
Chris@41 7450 func_append finalize_command " $arg"
Chris@41 7451 fi
Chris@41 7452
Chris@41 7453 oldlibs=
Chris@41 7454 # calculate the name of the file, without its directory
Chris@41 7455 func_basename "$output"
Chris@41 7456 outputname=$func_basename_result
Chris@41 7457 libobjs_save=$libobjs
Chris@41 7458
Chris@41 7459 if test -n "$shlibpath_var"; then
Chris@41 7460 # get the directories listed in $shlibpath_var
Chris@41 7461 eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
Chris@41 7462 else
Chris@41 7463 shlib_search_path=
Chris@41 7464 fi
Chris@41 7465 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
Chris@41 7466 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
Chris@41 7467
Chris@41 7468 # Definition is injected by LT_CONFIG during libtool generation.
Chris@41 7469 func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
Chris@41 7470
Chris@41 7471 func_dirname "$output" "/" ""
Chris@41 7472 output_objdir=$func_dirname_result$objdir
Chris@41 7473 func_to_tool_file "$output_objdir/"
Chris@41 7474 tool_output_objdir=$func_to_tool_file_result
Chris@41 7475 # Create the object directory.
Chris@41 7476 func_mkdir_p "$output_objdir"
Chris@41 7477
Chris@41 7478 # Determine the type of output
Chris@41 7479 case $output in
Chris@41 7480 "")
Chris@41 7481 func_fatal_help "you must specify an output file"
Chris@41 7482 ;;
Chris@41 7483 *.$libext) linkmode=oldlib ;;
Chris@41 7484 *.lo | *.$objext) linkmode=obj ;;
Chris@41 7485 *.la) linkmode=lib ;;
Chris@41 7486 *) linkmode=prog ;; # Anything else should be a program.
Chris@41 7487 esac
Chris@41 7488
Chris@41 7489 specialdeplibs=
Chris@41 7490
Chris@41 7491 libs=
Chris@41 7492 # Find all interdependent deplibs by searching for libraries
Chris@41 7493 # that are linked more than once (e.g. -la -lb -la)
Chris@41 7494 for deplib in $deplibs; do
Chris@41 7495 if $opt_preserve_dup_deps; then
Chris@41 7496 case "$libs " in
Chris@41 7497 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
Chris@41 7498 esac
Chris@41 7499 fi
Chris@41 7500 func_append libs " $deplib"
Chris@41 7501 done
Chris@41 7502
Chris@41 7503 if test lib = "$linkmode"; then
Chris@41 7504 libs="$predeps $libs $compiler_lib_search_path $postdeps"
Chris@41 7505
Chris@41 7506 # Compute libraries that are listed more than once in $predeps
Chris@41 7507 # $postdeps and mark them as special (i.e., whose duplicates are
Chris@41 7508 # not to be eliminated).
Chris@41 7509 pre_post_deps=
Chris@41 7510 if $opt_duplicate_compiler_generated_deps; then
Chris@41 7511 for pre_post_dep in $predeps $postdeps; do
Chris@41 7512 case "$pre_post_deps " in
Chris@41 7513 *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
Chris@41 7514 esac
Chris@41 7515 func_append pre_post_deps " $pre_post_dep"
Chris@41 7516 done
Chris@41 7517 fi
Chris@41 7518 pre_post_deps=
Chris@41 7519 fi
Chris@41 7520
Chris@41 7521 deplibs=
Chris@41 7522 newdependency_libs=
Chris@41 7523 newlib_search_path=
Chris@41 7524 need_relink=no # whether we're linking any uninstalled libtool libraries
Chris@41 7525 notinst_deplibs= # not-installed libtool libraries
Chris@41 7526 notinst_path= # paths that contain not-installed libtool libraries
Chris@41 7527
Chris@41 7528 case $linkmode in
Chris@41 7529 lib)
Chris@41 7530 passes="conv dlpreopen link"
Chris@41 7531 for file in $dlfiles $dlprefiles; do
Chris@41 7532 case $file in
Chris@41 7533 *.la) ;;
Chris@41 7534 *)
Chris@41 7535 func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
Chris@41 7536 ;;
Chris@41 7537 esac
Chris@41 7538 done
Chris@41 7539 ;;
Chris@41 7540 prog)
Chris@41 7541 compile_deplibs=
Chris@41 7542 finalize_deplibs=
Chris@41 7543 alldeplibs=false
Chris@41 7544 newdlfiles=
Chris@41 7545 newdlprefiles=
Chris@41 7546 passes="conv scan dlopen dlpreopen link"
Chris@41 7547 ;;
Chris@41 7548 *) passes="conv"
Chris@41 7549 ;;
Chris@41 7550 esac
Chris@41 7551
Chris@41 7552 for pass in $passes; do
Chris@41 7553 # The preopen pass in lib mode reverses $deplibs; put it back here
Chris@41 7554 # so that -L comes before libs that need it for instance...
Chris@41 7555 if test lib,link = "$linkmode,$pass"; then
Chris@41 7556 ## FIXME: Find the place where the list is rebuilt in the wrong
Chris@41 7557 ## order, and fix it there properly
Chris@41 7558 tmp_deplibs=
Chris@41 7559 for deplib in $deplibs; do
Chris@41 7560 tmp_deplibs="$deplib $tmp_deplibs"
Chris@41 7561 done
Chris@41 7562 deplibs=$tmp_deplibs
Chris@41 7563 fi
Chris@41 7564
Chris@41 7565 if test lib,link = "$linkmode,$pass" ||
Chris@41 7566 test prog,scan = "$linkmode,$pass"; then
Chris@41 7567 libs=$deplibs
Chris@41 7568 deplibs=
Chris@41 7569 fi
Chris@41 7570 if test prog = "$linkmode"; then
Chris@41 7571 case $pass in
Chris@41 7572 dlopen) libs=$dlfiles ;;
Chris@41 7573 dlpreopen) libs=$dlprefiles ;;
Chris@41 7574 link)
Chris@41 7575 libs="$deplibs %DEPLIBS%"
Chris@41 7576 test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
Chris@41 7577 ;;
Chris@41 7578 esac
Chris@41 7579 fi
Chris@41 7580 if test lib,dlpreopen = "$linkmode,$pass"; then
Chris@41 7581 # Collect and forward deplibs of preopened libtool libs
Chris@41 7582 for lib in $dlprefiles; do
Chris@41 7583 # Ignore non-libtool-libs
Chris@41 7584 dependency_libs=
Chris@41 7585 func_resolve_sysroot "$lib"
Chris@41 7586 case $lib in
Chris@41 7587 *.la) func_source "$func_resolve_sysroot_result" ;;
Chris@41 7588 esac
Chris@41 7589
Chris@41 7590 # Collect preopened libtool deplibs, except any this library
Chris@41 7591 # has declared as weak libs
Chris@41 7592 for deplib in $dependency_libs; do
Chris@41 7593 func_basename "$deplib"
Chris@41 7594 deplib_base=$func_basename_result
Chris@41 7595 case " $weak_libs " in
Chris@41 7596 *" $deplib_base "*) ;;
Chris@41 7597 *) func_append deplibs " $deplib" ;;
Chris@41 7598 esac
Chris@41 7599 done
Chris@41 7600 done
Chris@41 7601 libs=$dlprefiles
Chris@41 7602 fi
Chris@41 7603 if test dlopen = "$pass"; then
Chris@41 7604 # Collect dlpreopened libraries
Chris@41 7605 save_deplibs=$deplibs
Chris@41 7606 deplibs=
Chris@41 7607 fi
Chris@41 7608
Chris@41 7609 for deplib in $libs; do
Chris@41 7610 lib=
Chris@41 7611 found=false
Chris@41 7612 case $deplib in
Chris@41 7613 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
Chris@41 7614 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
Chris@41 7615 if test prog,link = "$linkmode,$pass"; then
Chris@41 7616 compile_deplibs="$deplib $compile_deplibs"
Chris@41 7617 finalize_deplibs="$deplib $finalize_deplibs"
Chris@41 7618 else
Chris@41 7619 func_append compiler_flags " $deplib"
Chris@41 7620 if test lib = "$linkmode"; then
Chris@41 7621 case "$new_inherited_linker_flags " in
Chris@41 7622 *" $deplib "*) ;;
Chris@41 7623 * ) func_append new_inherited_linker_flags " $deplib" ;;
Chris@41 7624 esac
Chris@41 7625 fi
Chris@41 7626 fi
Chris@41 7627 continue
Chris@41 7628 ;;
Chris@41 7629 -l*)
Chris@41 7630 if test lib != "$linkmode" && test prog != "$linkmode"; then
Chris@41 7631 func_warning "'-l' is ignored for archives/objects"
Chris@41 7632 continue
Chris@41 7633 fi
Chris@41 7634 func_stripname '-l' '' "$deplib"
Chris@41 7635 name=$func_stripname_result
Chris@41 7636 if test lib = "$linkmode"; then
Chris@41 7637 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
Chris@41 7638 else
Chris@41 7639 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
Chris@41 7640 fi
Chris@41 7641 for searchdir in $searchdirs; do
Chris@41 7642 for search_ext in .la $std_shrext .so .a; do
Chris@41 7643 # Search the libtool library
Chris@41 7644 lib=$searchdir/lib$name$search_ext
Chris@41 7645 if test -f "$lib"; then
Chris@41 7646 if test .la = "$search_ext"; then
Chris@41 7647 found=:
Chris@41 7648 else
Chris@41 7649 found=false
Chris@41 7650 fi
Chris@41 7651 break 2
Chris@41 7652 fi
Chris@41 7653 done
Chris@41 7654 done
Chris@41 7655 if $found; then
Chris@41 7656 # deplib is a libtool library
Chris@41 7657 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
Chris@41 7658 # We need to do some special things here, and not later.
Chris@41 7659 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@41 7660 case " $predeps $postdeps " in
Chris@41 7661 *" $deplib "*)
Chris@41 7662 if func_lalib_p "$lib"; then
Chris@41 7663 library_names=
Chris@41 7664 old_library=
Chris@41 7665 func_source "$lib"
Chris@41 7666 for l in $old_library $library_names; do
Chris@41 7667 ll=$l
Chris@41 7668 done
Chris@41 7669 if test "X$ll" = "X$old_library"; then # only static version available
Chris@41 7670 found=false
Chris@41 7671 func_dirname "$lib" "" "."
Chris@41 7672 ladir=$func_dirname_result
Chris@41 7673 lib=$ladir/$old_library
Chris@41 7674 if test prog,link = "$linkmode,$pass"; then
Chris@41 7675 compile_deplibs="$deplib $compile_deplibs"
Chris@41 7676 finalize_deplibs="$deplib $finalize_deplibs"
Chris@41 7677 else
Chris@41 7678 deplibs="$deplib $deplibs"
Chris@41 7679 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
Chris@41 7680 fi
Chris@41 7681 continue
Chris@41 7682 fi
Chris@41 7683 fi
Chris@41 7684 ;;
Chris@41 7685 *) ;;
Chris@41 7686 esac
Chris@41 7687 fi
Chris@41 7688 else
Chris@41 7689 # deplib doesn't seem to be a libtool library
Chris@41 7690 if test prog,link = "$linkmode,$pass"; then
Chris@41 7691 compile_deplibs="$deplib $compile_deplibs"
Chris@41 7692 finalize_deplibs="$deplib $finalize_deplibs"
Chris@41 7693 else
Chris@41 7694 deplibs="$deplib $deplibs"
Chris@41 7695 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
Chris@41 7696 fi
Chris@41 7697 continue
Chris@41 7698 fi
Chris@41 7699 ;; # -l
Chris@41 7700 *.ltframework)
Chris@41 7701 if test prog,link = "$linkmode,$pass"; then
Chris@41 7702 compile_deplibs="$deplib $compile_deplibs"
Chris@41 7703 finalize_deplibs="$deplib $finalize_deplibs"
Chris@41 7704 else
Chris@41 7705 deplibs="$deplib $deplibs"
Chris@41 7706 if test lib = "$linkmode"; then
Chris@41 7707 case "$new_inherited_linker_flags " in
Chris@41 7708 *" $deplib "*) ;;
Chris@41 7709 * ) func_append new_inherited_linker_flags " $deplib" ;;
Chris@41 7710 esac
Chris@41 7711 fi
Chris@41 7712 fi
Chris@41 7713 continue
Chris@41 7714 ;;
Chris@41 7715 -L*)
Chris@41 7716 case $linkmode in
Chris@41 7717 lib)
Chris@41 7718 deplibs="$deplib $deplibs"
Chris@41 7719 test conv = "$pass" && continue
Chris@41 7720 newdependency_libs="$deplib $newdependency_libs"
Chris@41 7721 func_stripname '-L' '' "$deplib"
Chris@41 7722 func_resolve_sysroot "$func_stripname_result"
Chris@41 7723 func_append newlib_search_path " $func_resolve_sysroot_result"
Chris@41 7724 ;;
Chris@41 7725 prog)
Chris@41 7726 if test conv = "$pass"; then
Chris@41 7727 deplibs="$deplib $deplibs"
Chris@41 7728 continue
Chris@41 7729 fi
Chris@41 7730 if test scan = "$pass"; then
Chris@41 7731 deplibs="$deplib $deplibs"
Chris@41 7732 else
Chris@41 7733 compile_deplibs="$deplib $compile_deplibs"
Chris@41 7734 finalize_deplibs="$deplib $finalize_deplibs"
Chris@41 7735 fi
Chris@41 7736 func_stripname '-L' '' "$deplib"
Chris@41 7737 func_resolve_sysroot "$func_stripname_result"
Chris@41 7738 func_append newlib_search_path " $func_resolve_sysroot_result"
Chris@41 7739 ;;
Chris@41 7740 *)
Chris@41 7741 func_warning "'-L' is ignored for archives/objects"
Chris@41 7742 ;;
Chris@41 7743 esac # linkmode
Chris@41 7744 continue
Chris@41 7745 ;; # -L
Chris@41 7746 -R*)
Chris@41 7747 if test link = "$pass"; then
Chris@41 7748 func_stripname '-R' '' "$deplib"
Chris@41 7749 func_resolve_sysroot "$func_stripname_result"
Chris@41 7750 dir=$func_resolve_sysroot_result
Chris@41 7751 # Make sure the xrpath contains only unique directories.
Chris@41 7752 case "$xrpath " in
Chris@41 7753 *" $dir "*) ;;
Chris@41 7754 *) func_append xrpath " $dir" ;;
Chris@41 7755 esac
Chris@41 7756 fi
Chris@41 7757 deplibs="$deplib $deplibs"
Chris@41 7758 continue
Chris@41 7759 ;;
Chris@41 7760 *.la)
Chris@41 7761 func_resolve_sysroot "$deplib"
Chris@41 7762 lib=$func_resolve_sysroot_result
Chris@41 7763 ;;
Chris@41 7764 *.$libext)
Chris@41 7765 if test conv = "$pass"; then
Chris@41 7766 deplibs="$deplib $deplibs"
Chris@41 7767 continue
Chris@41 7768 fi
Chris@41 7769 case $linkmode in
Chris@41 7770 lib)
Chris@41 7771 # Linking convenience modules into shared libraries is allowed,
Chris@41 7772 # but linking other static libraries is non-portable.
Chris@41 7773 case " $dlpreconveniencelibs " in
Chris@41 7774 *" $deplib "*) ;;
Chris@41 7775 *)
Chris@41 7776 valid_a_lib=false
Chris@41 7777 case $deplibs_check_method in
Chris@41 7778 match_pattern*)
Chris@41 7779 set dummy $deplibs_check_method; shift
Chris@41 7780 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Chris@41 7781 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
Chris@41 7782 | $EGREP "$match_pattern_regex" > /dev/null; then
Chris@41 7783 valid_a_lib=:
Chris@41 7784 fi
Chris@41 7785 ;;
Chris@41 7786 pass_all)
Chris@41 7787 valid_a_lib=:
Chris@41 7788 ;;
Chris@41 7789 esac
Chris@41 7790 if $valid_a_lib; then
Chris@41 7791 echo
Chris@41 7792 $ECHO "*** Warning: Linking the shared library $output against the"
Chris@41 7793 $ECHO "*** static library $deplib is not portable!"
Chris@41 7794 deplibs="$deplib $deplibs"
Chris@41 7795 else
Chris@41 7796 echo
Chris@41 7797 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
Chris@41 7798 echo "*** I have the capability to make that library automatically link in when"
Chris@41 7799 echo "*** you link to this library. But I can only do this if you have a"
Chris@41 7800 echo "*** shared version of the library, which you do not appear to have"
Chris@41 7801 echo "*** because the file extensions .$libext of this argument makes me believe"
Chris@41 7802 echo "*** that it is just a static archive that I should not use here."
Chris@41 7803 fi
Chris@41 7804 ;;
Chris@41 7805 esac
Chris@41 7806 continue
Chris@41 7807 ;;
Chris@41 7808 prog)
Chris@41 7809 if test link != "$pass"; then
Chris@41 7810 deplibs="$deplib $deplibs"
Chris@41 7811 else
Chris@41 7812 compile_deplibs="$deplib $compile_deplibs"
Chris@41 7813 finalize_deplibs="$deplib $finalize_deplibs"
Chris@41 7814 fi
Chris@41 7815 continue
Chris@41 7816 ;;
Chris@41 7817 esac # linkmode
Chris@41 7818 ;; # *.$libext
Chris@41 7819 *.lo | *.$objext)
Chris@41 7820 if test conv = "$pass"; then
Chris@41 7821 deplibs="$deplib $deplibs"
Chris@41 7822 elif test prog = "$linkmode"; then
Chris@41 7823 if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
Chris@41 7824 # If there is no dlopen support or we're linking statically,
Chris@41 7825 # we need to preload.
Chris@41 7826 func_append newdlprefiles " $deplib"
Chris@41 7827 compile_deplibs="$deplib $compile_deplibs"
Chris@41 7828 finalize_deplibs="$deplib $finalize_deplibs"
Chris@41 7829 else
Chris@41 7830 func_append newdlfiles " $deplib"
Chris@41 7831 fi
Chris@41 7832 fi
Chris@41 7833 continue
Chris@41 7834 ;;
Chris@41 7835 %DEPLIBS%)
Chris@41 7836 alldeplibs=:
Chris@41 7837 continue
Chris@41 7838 ;;
Chris@41 7839 esac # case $deplib
Chris@41 7840
Chris@41 7841 $found || test -f "$lib" \
Chris@41 7842 || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
Chris@41 7843
Chris@41 7844 # Check to see that this really is a libtool archive.
Chris@41 7845 func_lalib_unsafe_p "$lib" \
Chris@41 7846 || func_fatal_error "'$lib' is not a valid libtool archive"
Chris@41 7847
Chris@41 7848 func_dirname "$lib" "" "."
Chris@41 7849 ladir=$func_dirname_result
Chris@41 7850
Chris@41 7851 dlname=
Chris@41 7852 dlopen=
Chris@41 7853 dlpreopen=
Chris@41 7854 libdir=
Chris@41 7855 library_names=
Chris@41 7856 old_library=
Chris@41 7857 inherited_linker_flags=
Chris@41 7858 # If the library was installed with an old release of libtool,
Chris@41 7859 # it will not redefine variables installed, or shouldnotlink
Chris@41 7860 installed=yes
Chris@41 7861 shouldnotlink=no
Chris@41 7862 avoidtemprpath=
Chris@41 7863
Chris@41 7864
Chris@41 7865 # Read the .la file
Chris@41 7866 func_source "$lib"
Chris@41 7867
Chris@41 7868 # Convert "-framework foo" to "foo.ltframework"
Chris@41 7869 if test -n "$inherited_linker_flags"; then
Chris@41 7870 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
Chris@41 7871 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
Chris@41 7872 case " $new_inherited_linker_flags " in
Chris@41 7873 *" $tmp_inherited_linker_flag "*) ;;
Chris@41 7874 *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
Chris@41 7875 esac
Chris@41 7876 done
Chris@41 7877 fi
Chris@41 7878 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@41 7879 if test lib,link = "$linkmode,$pass" ||
Chris@41 7880 test prog,scan = "$linkmode,$pass" ||
Chris@41 7881 { test prog != "$linkmode" && test lib != "$linkmode"; }; then
Chris@41 7882 test -n "$dlopen" && func_append dlfiles " $dlopen"
Chris@41 7883 test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
Chris@41 7884 fi
Chris@41 7885
Chris@41 7886 if test conv = "$pass"; then
Chris@41 7887 # Only check for convenience libraries
Chris@41 7888 deplibs="$lib $deplibs"
Chris@41 7889 if test -z "$libdir"; then
Chris@41 7890 if test -z "$old_library"; then
Chris@41 7891 func_fatal_error "cannot find name of link library for '$lib'"
Chris@41 7892 fi
Chris@41 7893 # It is a libtool convenience library, so add in its objects.
Chris@41 7894 func_append convenience " $ladir/$objdir/$old_library"
Chris@41 7895 func_append old_convenience " $ladir/$objdir/$old_library"
Chris@41 7896 tmp_libs=
Chris@41 7897 for deplib in $dependency_libs; do
Chris@41 7898 deplibs="$deplib $deplibs"
Chris@41 7899 if $opt_preserve_dup_deps; then
Chris@41 7900 case "$tmp_libs " in
Chris@41 7901 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
Chris@41 7902 esac
Chris@41 7903 fi
Chris@41 7904 func_append tmp_libs " $deplib"
Chris@41 7905 done
Chris@41 7906 elif test prog != "$linkmode" && test lib != "$linkmode"; then
Chris@41 7907 func_fatal_error "'$lib' is not a convenience library"
Chris@41 7908 fi
Chris@41 7909 continue
Chris@41 7910 fi # $pass = conv
Chris@41 7911
Chris@41 7912
Chris@41 7913 # Get the name of the library we link against.
Chris@41 7914 linklib=
Chris@41 7915 if test -n "$old_library" &&
Chris@41 7916 { test yes = "$prefer_static_libs" ||
Chris@41 7917 test built,no = "$prefer_static_libs,$installed"; }; then
Chris@41 7918 linklib=$old_library
Chris@41 7919 else
Chris@41 7920 for l in $old_library $library_names; do
Chris@41 7921 linklib=$l
Chris@41 7922 done
Chris@41 7923 fi
Chris@41 7924 if test -z "$linklib"; then
Chris@41 7925 func_fatal_error "cannot find name of link library for '$lib'"
Chris@41 7926 fi
Chris@41 7927
Chris@41 7928 # This library was specified with -dlopen.
Chris@41 7929 if test dlopen = "$pass"; then
Chris@41 7930 test -z "$libdir" \
Chris@41 7931 && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
Chris@41 7932 if test -z "$dlname" ||
Chris@41 7933 test yes != "$dlopen_support" ||
Chris@41 7934 test no = "$build_libtool_libs"
Chris@41 7935 then
Chris@41 7936 # If there is no dlname, no dlopen support or we're linking
Chris@41 7937 # statically, we need to preload. We also need to preload any
Chris@41 7938 # dependent libraries so libltdl's deplib preloader doesn't
Chris@41 7939 # bomb out in the load deplibs phase.
Chris@41 7940 func_append dlprefiles " $lib $dependency_libs"
Chris@41 7941 else
Chris@41 7942 func_append newdlfiles " $lib"
Chris@41 7943 fi
Chris@41 7944 continue
Chris@41 7945 fi # $pass = dlopen
Chris@41 7946
Chris@41 7947 # We need an absolute path.
Chris@41 7948 case $ladir in
Chris@41 7949 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
Chris@41 7950 *)
Chris@41 7951 abs_ladir=`cd "$ladir" && pwd`
Chris@41 7952 if test -z "$abs_ladir"; then
Chris@41 7953 func_warning "cannot determine absolute directory name of '$ladir'"
Chris@41 7954 func_warning "passing it literally to the linker, although it might fail"
Chris@41 7955 abs_ladir=$ladir
Chris@41 7956 fi
Chris@41 7957 ;;
Chris@41 7958 esac
Chris@41 7959 func_basename "$lib"
Chris@41 7960 laname=$func_basename_result
Chris@41 7961
Chris@41 7962 # Find the relevant object directory and library name.
Chris@41 7963 if test yes = "$installed"; then
Chris@41 7964 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
Chris@41 7965 func_warning "library '$lib' was moved."
Chris@41 7966 dir=$ladir
Chris@41 7967 absdir=$abs_ladir
Chris@41 7968 libdir=$abs_ladir
Chris@41 7969 else
Chris@41 7970 dir=$lt_sysroot$libdir
Chris@41 7971 absdir=$lt_sysroot$libdir
Chris@41 7972 fi
Chris@41 7973 test yes = "$hardcode_automatic" && avoidtemprpath=yes
Chris@41 7974 else
Chris@41 7975 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
Chris@41 7976 dir=$ladir
Chris@41 7977 absdir=$abs_ladir
Chris@41 7978 # Remove this search path later
Chris@41 7979 func_append notinst_path " $abs_ladir"
Chris@41 7980 else
Chris@41 7981 dir=$ladir/$objdir
Chris@41 7982 absdir=$abs_ladir/$objdir
Chris@41 7983 # Remove this search path later
Chris@41 7984 func_append notinst_path " $abs_ladir"
Chris@41 7985 fi
Chris@41 7986 fi # $installed = yes
Chris@41 7987 func_stripname 'lib' '.la' "$laname"
Chris@41 7988 name=$func_stripname_result
Chris@41 7989
Chris@41 7990 # This library was specified with -dlpreopen.
Chris@41 7991 if test dlpreopen = "$pass"; then
Chris@41 7992 if test -z "$libdir" && test prog = "$linkmode"; then
Chris@41 7993 func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
Chris@41 7994 fi
Chris@41 7995 case $host in
Chris@41 7996 # special handling for platforms with PE-DLLs.
Chris@41 7997 *cygwin* | *mingw* | *cegcc* )
Chris@41 7998 # Linker will automatically link against shared library if both
Chris@41 7999 # static and shared are present. Therefore, ensure we extract
Chris@41 8000 # symbols from the import library if a shared library is present
Chris@41 8001 # (otherwise, the dlopen module name will be incorrect). We do
Chris@41 8002 # this by putting the import library name into $newdlprefiles.
Chris@41 8003 # We recover the dlopen module name by 'saving' the la file
Chris@41 8004 # name in a special purpose variable, and (later) extracting the
Chris@41 8005 # dlname from the la file.
Chris@41 8006 if test -n "$dlname"; then
Chris@41 8007 func_tr_sh "$dir/$linklib"
Chris@41 8008 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
Chris@41 8009 func_append newdlprefiles " $dir/$linklib"
Chris@41 8010 else
Chris@41 8011 func_append newdlprefiles " $dir/$old_library"
Chris@41 8012 # Keep a list of preopened convenience libraries to check
Chris@41 8013 # that they are being used correctly in the link pass.
Chris@41 8014 test -z "$libdir" && \
Chris@41 8015 func_append dlpreconveniencelibs " $dir/$old_library"
Chris@41 8016 fi
Chris@41 8017 ;;
Chris@41 8018 * )
Chris@41 8019 # Prefer using a static library (so that no silly _DYNAMIC symbols
Chris@41 8020 # are required to link).
Chris@41 8021 if test -n "$old_library"; then
Chris@41 8022 func_append newdlprefiles " $dir/$old_library"
Chris@41 8023 # Keep a list of preopened convenience libraries to check
Chris@41 8024 # that they are being used correctly in the link pass.
Chris@41 8025 test -z "$libdir" && \
Chris@41 8026 func_append dlpreconveniencelibs " $dir/$old_library"
Chris@41 8027 # Otherwise, use the dlname, so that lt_dlopen finds it.
Chris@41 8028 elif test -n "$dlname"; then
Chris@41 8029 func_append newdlprefiles " $dir/$dlname"
Chris@41 8030 else
Chris@41 8031 func_append newdlprefiles " $dir/$linklib"
Chris@41 8032 fi
Chris@41 8033 ;;
Chris@41 8034 esac
Chris@41 8035 fi # $pass = dlpreopen
Chris@41 8036
Chris@41 8037 if test -z "$libdir"; then
Chris@41 8038 # Link the convenience library
Chris@41 8039 if test lib = "$linkmode"; then
Chris@41 8040 deplibs="$dir/$old_library $deplibs"
Chris@41 8041 elif test prog,link = "$linkmode,$pass"; then
Chris@41 8042 compile_deplibs="$dir/$old_library $compile_deplibs"
Chris@41 8043 finalize_deplibs="$dir/$old_library $finalize_deplibs"
Chris@41 8044 else
Chris@41 8045 deplibs="$lib $deplibs" # used for prog,scan pass
Chris@41 8046 fi
Chris@41 8047 continue
Chris@41 8048 fi
Chris@41 8049
Chris@41 8050
Chris@41 8051 if test prog = "$linkmode" && test link != "$pass"; then
Chris@41 8052 func_append newlib_search_path " $ladir"
Chris@41 8053 deplibs="$lib $deplibs"
Chris@41 8054
Chris@41 8055 linkalldeplibs=false
Chris@41 8056 if test no != "$link_all_deplibs" || test -z "$library_names" ||
Chris@41 8057 test no = "$build_libtool_libs"; then
Chris@41 8058 linkalldeplibs=:
Chris@41 8059 fi
Chris@41 8060
Chris@41 8061 tmp_libs=
Chris@41 8062 for deplib in $dependency_libs; do
Chris@41 8063 case $deplib in
Chris@41 8064 -L*) func_stripname '-L' '' "$deplib"
Chris@41 8065 func_resolve_sysroot "$func_stripname_result"
Chris@41 8066 func_append newlib_search_path " $func_resolve_sysroot_result"
Chris@41 8067 ;;
Chris@41 8068 esac
Chris@41 8069 # Need to link against all dependency_libs?
Chris@41 8070 if $linkalldeplibs; then
Chris@41 8071 deplibs="$deplib $deplibs"
Chris@41 8072 else
Chris@41 8073 # Need to hardcode shared library paths
Chris@41 8074 # or/and link against static libraries
Chris@41 8075 newdependency_libs="$deplib $newdependency_libs"
Chris@41 8076 fi
Chris@41 8077 if $opt_preserve_dup_deps; then
Chris@41 8078 case "$tmp_libs " in
Chris@41 8079 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
Chris@41 8080 esac
Chris@41 8081 fi
Chris@41 8082 func_append tmp_libs " $deplib"
Chris@41 8083 done # for deplib
Chris@41 8084 continue
Chris@41 8085 fi # $linkmode = prog...
Chris@41 8086
Chris@41 8087 if test prog,link = "$linkmode,$pass"; then
Chris@41 8088 if test -n "$library_names" &&
Chris@41 8089 { { test no = "$prefer_static_libs" ||
Chris@41 8090 test built,yes = "$prefer_static_libs,$installed"; } ||
Chris@41 8091 test -z "$old_library"; }; then
Chris@41 8092 # We need to hardcode the library path
Chris@41 8093 if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
Chris@41 8094 # Make sure the rpath contains only unique directories.
Chris@41 8095 case $temp_rpath: in
Chris@41 8096 *"$absdir:"*) ;;
Chris@41 8097 *) func_append temp_rpath "$absdir:" ;;
Chris@41 8098 esac
Chris@41 8099 fi
Chris@41 8100
Chris@41 8101 # Hardcode the library path.
Chris@41 8102 # Skip directories that are in the system default run-time
Chris@41 8103 # search path.
Chris@41 8104 case " $sys_lib_dlsearch_path " in
Chris@41 8105 *" $absdir "*) ;;
Chris@41 8106 *)
Chris@41 8107 case "$compile_rpath " in
Chris@41 8108 *" $absdir "*) ;;
Chris@41 8109 *) func_append compile_rpath " $absdir" ;;
Chris@41 8110 esac
Chris@41 8111 ;;
Chris@41 8112 esac
Chris@41 8113 case " $sys_lib_dlsearch_path " in
Chris@41 8114 *" $libdir "*) ;;
Chris@41 8115 *)
Chris@41 8116 case "$finalize_rpath " in
Chris@41 8117 *" $libdir "*) ;;
Chris@41 8118 *) func_append finalize_rpath " $libdir" ;;
Chris@41 8119 esac
Chris@41 8120 ;;
Chris@41 8121 esac
Chris@41 8122 fi # $linkmode,$pass = prog,link...
Chris@41 8123
Chris@41 8124 if $alldeplibs &&
Chris@41 8125 { test pass_all = "$deplibs_check_method" ||
Chris@41 8126 { test yes = "$build_libtool_libs" &&
Chris@41 8127 test -n "$library_names"; }; }; then
Chris@41 8128 # We only need to search for static libraries
Chris@41 8129 continue
Chris@41 8130 fi
Chris@41 8131 fi
Chris@41 8132
Chris@41 8133 link_static=no # Whether the deplib will be linked statically
Chris@41 8134 use_static_libs=$prefer_static_libs
Chris@41 8135 if test built = "$use_static_libs" && test yes = "$installed"; then
Chris@41 8136 use_static_libs=no
Chris@41 8137 fi
Chris@41 8138 if test -n "$library_names" &&
Chris@41 8139 { test no = "$use_static_libs" || test -z "$old_library"; }; then
Chris@41 8140 case $host in
Chris@41 8141 *cygwin* | *mingw* | *cegcc* | *os2*)
Chris@41 8142 # No point in relinking DLLs because paths are not encoded
Chris@41 8143 func_append notinst_deplibs " $lib"
Chris@41 8144 need_relink=no
Chris@41 8145 ;;
Chris@41 8146 *)
Chris@41 8147 if test no = "$installed"; then
Chris@41 8148 func_append notinst_deplibs " $lib"
Chris@41 8149 need_relink=yes
Chris@41 8150 fi
Chris@41 8151 ;;
Chris@41 8152 esac
Chris@41 8153 # This is a shared library
Chris@41 8154
Chris@41 8155 # Warn about portability, can't link against -module's on some
Chris@41 8156 # systems (darwin). Don't bleat about dlopened modules though!
Chris@41 8157 dlopenmodule=
Chris@41 8158 for dlpremoduletest in $dlprefiles; do
Chris@41 8159 if test "X$dlpremoduletest" = "X$lib"; then
Chris@41 8160 dlopenmodule=$dlpremoduletest
Chris@41 8161 break
Chris@41 8162 fi
Chris@41 8163 done
Chris@41 8164 if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
Chris@41 8165 echo
Chris@41 8166 if test prog = "$linkmode"; then
Chris@41 8167 $ECHO "*** Warning: Linking the executable $output against the loadable module"
Chris@41 8168 else
Chris@41 8169 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
Chris@41 8170 fi
Chris@41 8171 $ECHO "*** $linklib is not portable!"
Chris@41 8172 fi
Chris@41 8173 if test lib = "$linkmode" &&
Chris@41 8174 test yes = "$hardcode_into_libs"; then
Chris@41 8175 # Hardcode the library path.
Chris@41 8176 # Skip directories that are in the system default run-time
Chris@41 8177 # search path.
Chris@41 8178 case " $sys_lib_dlsearch_path " in
Chris@41 8179 *" $absdir "*) ;;
Chris@41 8180 *)
Chris@41 8181 case "$compile_rpath " in
Chris@41 8182 *" $absdir "*) ;;
Chris@41 8183 *) func_append compile_rpath " $absdir" ;;
Chris@41 8184 esac
Chris@41 8185 ;;
Chris@41 8186 esac
Chris@41 8187 case " $sys_lib_dlsearch_path " in
Chris@41 8188 *" $libdir "*) ;;
Chris@41 8189 *)
Chris@41 8190 case "$finalize_rpath " in
Chris@41 8191 *" $libdir "*) ;;
Chris@41 8192 *) func_append finalize_rpath " $libdir" ;;
Chris@41 8193 esac
Chris@41 8194 ;;
Chris@41 8195 esac
Chris@41 8196 fi
Chris@41 8197
Chris@41 8198 if test -n "$old_archive_from_expsyms_cmds"; then
Chris@41 8199 # figure out the soname
Chris@41 8200 set dummy $library_names
Chris@41 8201 shift
Chris@41 8202 realname=$1
Chris@41 8203 shift
Chris@41 8204 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@41 8205 # use dlname if we got it. it's perfectly good, no?
Chris@41 8206 if test -n "$dlname"; then
Chris@41 8207 soname=$dlname
Chris@41 8208 elif test -n "$soname_spec"; then
Chris@41 8209 # bleh windows
Chris@41 8210 case $host in
Chris@41 8211 *cygwin* | mingw* | *cegcc* | *os2*)
Chris@41 8212 func_arith $current - $age
Chris@41 8213 major=$func_arith_result
Chris@41 8214 versuffix=-$major
Chris@41 8215 ;;
Chris@41 8216 esac
Chris@41 8217 eval soname=\"$soname_spec\"
Chris@41 8218 else
Chris@41 8219 soname=$realname
Chris@41 8220 fi
Chris@41 8221
Chris@41 8222 # Make a new name for the extract_expsyms_cmds to use
Chris@41 8223 soroot=$soname
Chris@41 8224 func_basename "$soroot"
Chris@41 8225 soname=$func_basename_result
Chris@41 8226 func_stripname 'lib' '.dll' "$soname"
Chris@41 8227 newlib=libimp-$func_stripname_result.a
Chris@41 8228
Chris@41 8229 # If the library has no export list, then create one now
Chris@41 8230 if test -f "$output_objdir/$soname-def"; then :
Chris@41 8231 else
Chris@41 8232 func_verbose "extracting exported symbol list from '$soname'"
Chris@41 8233 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
Chris@41 8234 fi
Chris@41 8235
Chris@41 8236 # Create $newlib
Chris@41 8237 if test -f "$output_objdir/$newlib"; then :; else
Chris@41 8238 func_verbose "generating import library for '$soname'"
Chris@41 8239 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
Chris@41 8240 fi
Chris@41 8241 # make sure the library variables are pointing to the new library
Chris@41 8242 dir=$output_objdir
Chris@41 8243 linklib=$newlib
Chris@41 8244 fi # test -n "$old_archive_from_expsyms_cmds"
Chris@41 8245
Chris@41 8246 if test prog = "$linkmode" || test relink != "$opt_mode"; then
Chris@41 8247 add_shlibpath=
Chris@41 8248 add_dir=
Chris@41 8249 add=
Chris@41 8250 lib_linked=yes
Chris@41 8251 case $hardcode_action in
Chris@41 8252 immediate | unsupported)
Chris@41 8253 if test no = "$hardcode_direct"; then
Chris@41 8254 add=$dir/$linklib
Chris@41 8255 case $host in
Chris@41 8256 *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
Chris@41 8257 *-*-sysv4*uw2*) add_dir=-L$dir ;;
Chris@41 8258 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
Chris@41 8259 *-*-unixware7*) add_dir=-L$dir ;;
Chris@41 8260 *-*-darwin* )
Chris@41 8261 # if the lib is a (non-dlopened) module then we cannot
Chris@41 8262 # link against it, someone is ignoring the earlier warnings
Chris@41 8263 if /usr/bin/file -L $add 2> /dev/null |
Chris@41 8264 $GREP ": [^:]* bundle" >/dev/null; then
Chris@41 8265 if test "X$dlopenmodule" != "X$lib"; then
Chris@41 8266 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
Chris@41 8267 if test -z "$old_library"; then
Chris@41 8268 echo
Chris@41 8269 echo "*** And there doesn't seem to be a static archive available"
Chris@41 8270 echo "*** The link will probably fail, sorry"
Chris@41 8271 else
Chris@41 8272 add=$dir/$old_library
Chris@41 8273 fi
Chris@41 8274 elif test -n "$old_library"; then
Chris@41 8275 add=$dir/$old_library
Chris@41 8276 fi
Chris@41 8277 fi
Chris@41 8278 esac
Chris@41 8279 elif test no = "$hardcode_minus_L"; then
Chris@41 8280 case $host in
Chris@41 8281 *-*-sunos*) add_shlibpath=$dir ;;
Chris@41 8282 esac
Chris@41 8283 add_dir=-L$dir
Chris@41 8284 add=-l$name
Chris@41 8285 elif test no = "$hardcode_shlibpath_var"; then
Chris@41 8286 add_shlibpath=$dir
Chris@41 8287 add=-l$name
Chris@41 8288 else
Chris@41 8289 lib_linked=no
Chris@41 8290 fi
Chris@41 8291 ;;
Chris@41 8292 relink)
Chris@41 8293 if test yes = "$hardcode_direct" &&
Chris@41 8294 test no = "$hardcode_direct_absolute"; then
Chris@41 8295 add=$dir/$linklib
Chris@41 8296 elif test yes = "$hardcode_minus_L"; then
Chris@41 8297 add_dir=-L$absdir
Chris@41 8298 # Try looking first in the location we're being installed to.
Chris@41 8299 if test -n "$inst_prefix_dir"; then
Chris@41 8300 case $libdir in
Chris@41 8301 [\\/]*)
Chris@41 8302 func_append add_dir " -L$inst_prefix_dir$libdir"
Chris@41 8303 ;;
Chris@41 8304 esac
Chris@41 8305 fi
Chris@41 8306 add=-l$name
Chris@41 8307 elif test yes = "$hardcode_shlibpath_var"; then
Chris@41 8308 add_shlibpath=$dir
Chris@41 8309 add=-l$name
Chris@41 8310 else
Chris@41 8311 lib_linked=no
Chris@41 8312 fi
Chris@41 8313 ;;
Chris@41 8314 *) lib_linked=no ;;
Chris@41 8315 esac
Chris@41 8316
Chris@41 8317 if test yes != "$lib_linked"; then
Chris@41 8318 func_fatal_configuration "unsupported hardcode properties"
Chris@41 8319 fi
Chris@41 8320
Chris@41 8321 if test -n "$add_shlibpath"; then
Chris@41 8322 case :$compile_shlibpath: in
Chris@41 8323 *":$add_shlibpath:"*) ;;
Chris@41 8324 *) func_append compile_shlibpath "$add_shlibpath:" ;;
Chris@41 8325 esac
Chris@41 8326 fi
Chris@41 8327 if test prog = "$linkmode"; then
Chris@41 8328 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
Chris@41 8329 test -n "$add" && compile_deplibs="$add $compile_deplibs"
Chris@41 8330 else
Chris@41 8331 test -n "$add_dir" && deplibs="$add_dir $deplibs"
Chris@41 8332 test -n "$add" && deplibs="$add $deplibs"
Chris@41 8333 if test yes != "$hardcode_direct" &&
Chris@41 8334 test yes != "$hardcode_minus_L" &&
Chris@41 8335 test yes = "$hardcode_shlibpath_var"; then
Chris@41 8336 case :$finalize_shlibpath: in
Chris@41 8337 *":$libdir:"*) ;;
Chris@41 8338 *) func_append finalize_shlibpath "$libdir:" ;;
Chris@41 8339 esac
Chris@41 8340 fi
Chris@41 8341 fi
Chris@41 8342 fi
Chris@41 8343
Chris@41 8344 if test prog = "$linkmode" || test relink = "$opt_mode"; then
Chris@41 8345 add_shlibpath=
Chris@41 8346 add_dir=
Chris@41 8347 add=
Chris@41 8348 # Finalize command for both is simple: just hardcode it.
Chris@41 8349 if test yes = "$hardcode_direct" &&
Chris@41 8350 test no = "$hardcode_direct_absolute"; then
Chris@41 8351 add=$libdir/$linklib
Chris@41 8352 elif test yes = "$hardcode_minus_L"; then
Chris@41 8353 add_dir=-L$libdir
Chris@41 8354 add=-l$name
Chris@41 8355 elif test yes = "$hardcode_shlibpath_var"; then
Chris@41 8356 case :$finalize_shlibpath: in
Chris@41 8357 *":$libdir:"*) ;;
Chris@41 8358 *) func_append finalize_shlibpath "$libdir:" ;;
Chris@41 8359 esac
Chris@41 8360 add=-l$name
Chris@41 8361 elif test yes = "$hardcode_automatic"; then
Chris@41 8362 if test -n "$inst_prefix_dir" &&
Chris@41 8363 test -f "$inst_prefix_dir$libdir/$linklib"; then
Chris@41 8364 add=$inst_prefix_dir$libdir/$linklib
Chris@41 8365 else
Chris@41 8366 add=$libdir/$linklib
Chris@41 8367 fi
Chris@41 8368 else
Chris@41 8369 # We cannot seem to hardcode it, guess we'll fake it.
Chris@41 8370 add_dir=-L$libdir
Chris@41 8371 # Try looking first in the location we're being installed to.
Chris@41 8372 if test -n "$inst_prefix_dir"; then
Chris@41 8373 case $libdir in
Chris@41 8374 [\\/]*)
Chris@41 8375 func_append add_dir " -L$inst_prefix_dir$libdir"
Chris@41 8376 ;;
Chris@41 8377 esac
Chris@41 8378 fi
Chris@41 8379 add=-l$name
Chris@41 8380 fi
Chris@41 8381
Chris@41 8382 if test prog = "$linkmode"; then
Chris@41 8383 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
Chris@41 8384 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
Chris@41 8385 else
Chris@41 8386 test -n "$add_dir" && deplibs="$add_dir $deplibs"
Chris@41 8387 test -n "$add" && deplibs="$add $deplibs"
Chris@41 8388 fi
Chris@41 8389 fi
Chris@41 8390 elif test prog = "$linkmode"; then
Chris@41 8391 # Here we assume that one of hardcode_direct or hardcode_minus_L
Chris@41 8392 # is not unsupported. This is valid on all known static and
Chris@41 8393 # shared platforms.
Chris@41 8394 if test unsupported != "$hardcode_direct"; then
Chris@41 8395 test -n "$old_library" && linklib=$old_library
Chris@41 8396 compile_deplibs="$dir/$linklib $compile_deplibs"
Chris@41 8397 finalize_deplibs="$dir/$linklib $finalize_deplibs"
Chris@41 8398 else
Chris@41 8399 compile_deplibs="-l$name -L$dir $compile_deplibs"
Chris@41 8400 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
Chris@41 8401 fi
Chris@41 8402 elif test yes = "$build_libtool_libs"; then
Chris@41 8403 # Not a shared library
Chris@41 8404 if test pass_all != "$deplibs_check_method"; then
Chris@41 8405 # We're trying link a shared library against a static one
Chris@41 8406 # but the system doesn't support it.
Chris@41 8407
Chris@41 8408 # Just print a warning and add the library to dependency_libs so
Chris@41 8409 # that the program can be linked against the static library.
Chris@41 8410 echo
Chris@41 8411 $ECHO "*** Warning: This system cannot link to static lib archive $lib."
Chris@41 8412 echo "*** I have the capability to make that library automatically link in when"
Chris@41 8413 echo "*** you link to this library. But I can only do this if you have a"
Chris@41 8414 echo "*** shared version of the library, which you do not appear to have."
Chris@41 8415 if test yes = "$module"; then
Chris@41 8416 echo "*** But as you try to build a module library, libtool will still create "
Chris@41 8417 echo "*** a static module, that should work as long as the dlopening application"
Chris@41 8418 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
Chris@41 8419 if test -z "$global_symbol_pipe"; then
Chris@41 8420 echo
Chris@41 8421 echo "*** However, this would only work if libtool was able to extract symbol"
Chris@41 8422 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
Chris@41 8423 echo "*** not find such a program. So, this module is probably useless."
Chris@41 8424 echo "*** 'nm' from GNU binutils and a full rebuild may help."
Chris@41 8425 fi
Chris@41 8426 if test no = "$build_old_libs"; then
Chris@41 8427 build_libtool_libs=module
Chris@41 8428 build_old_libs=yes
Chris@41 8429 else
Chris@41 8430 build_libtool_libs=no
Chris@41 8431 fi
Chris@41 8432 fi
Chris@41 8433 else
Chris@41 8434 deplibs="$dir/$old_library $deplibs"
Chris@41 8435 link_static=yes
Chris@41 8436 fi
Chris@41 8437 fi # link shared/static library?
Chris@41 8438
Chris@41 8439 if test lib = "$linkmode"; then
Chris@41 8440 if test -n "$dependency_libs" &&
Chris@41 8441 { test yes != "$hardcode_into_libs" ||
Chris@41 8442 test yes = "$build_old_libs" ||
Chris@41 8443 test yes = "$link_static"; }; then
Chris@41 8444 # Extract -R from dependency_libs
Chris@41 8445 temp_deplibs=
Chris@41 8446 for libdir in $dependency_libs; do
Chris@41 8447 case $libdir in
Chris@41 8448 -R*) func_stripname '-R' '' "$libdir"
Chris@41 8449 temp_xrpath=$func_stripname_result
Chris@41 8450 case " $xrpath " in
Chris@41 8451 *" $temp_xrpath "*) ;;
Chris@41 8452 *) func_append xrpath " $temp_xrpath";;
Chris@41 8453 esac;;
Chris@41 8454 *) func_append temp_deplibs " $libdir";;
Chris@41 8455 esac
Chris@41 8456 done
Chris@41 8457 dependency_libs=$temp_deplibs
Chris@41 8458 fi
Chris@41 8459
Chris@41 8460 func_append newlib_search_path " $absdir"
Chris@41 8461 # Link against this library
Chris@41 8462 test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
Chris@41 8463 # ... and its dependency_libs
Chris@41 8464 tmp_libs=
Chris@41 8465 for deplib in $dependency_libs; do
Chris@41 8466 newdependency_libs="$deplib $newdependency_libs"
Chris@41 8467 case $deplib in
Chris@41 8468 -L*) func_stripname '-L' '' "$deplib"
Chris@41 8469 func_resolve_sysroot "$func_stripname_result";;
Chris@41 8470 *) func_resolve_sysroot "$deplib" ;;
Chris@41 8471 esac
Chris@41 8472 if $opt_preserve_dup_deps; then
Chris@41 8473 case "$tmp_libs " in
Chris@41 8474 *" $func_resolve_sysroot_result "*)
Chris@41 8475 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
Chris@41 8476 esac
Chris@41 8477 fi
Chris@41 8478 func_append tmp_libs " $func_resolve_sysroot_result"
Chris@41 8479 done
Chris@41 8480
Chris@41 8481 if test no != "$link_all_deplibs"; then
Chris@41 8482 # Add the search paths of all dependency libraries
Chris@41 8483 for deplib in $dependency_libs; do
Chris@41 8484 path=
Chris@41 8485 case $deplib in
Chris@41 8486 -L*) path=$deplib ;;
Chris@41 8487 *.la)
Chris@41 8488 func_resolve_sysroot "$deplib"
Chris@41 8489 deplib=$func_resolve_sysroot_result
Chris@41 8490 func_dirname "$deplib" "" "."
Chris@41 8491 dir=$func_dirname_result
Chris@41 8492 # We need an absolute path.
Chris@41 8493 case $dir in
Chris@41 8494 [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
Chris@41 8495 *)
Chris@41 8496 absdir=`cd "$dir" && pwd`
Chris@41 8497 if test -z "$absdir"; then
Chris@41 8498 func_warning "cannot determine absolute directory name of '$dir'"
Chris@41 8499 absdir=$dir
Chris@41 8500 fi
Chris@41 8501 ;;
Chris@41 8502 esac
Chris@41 8503 if $GREP "^installed=no" $deplib > /dev/null; then
Chris@41 8504 case $host in
Chris@41 8505 *-*-darwin*)
Chris@41 8506 depdepl=
Chris@41 8507 eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
Chris@41 8508 if test -n "$deplibrary_names"; then
Chris@41 8509 for tmp in $deplibrary_names; do
Chris@41 8510 depdepl=$tmp
Chris@41 8511 done
Chris@41 8512 if test -f "$absdir/$objdir/$depdepl"; then
Chris@41 8513 depdepl=$absdir/$objdir/$depdepl
Chris@41 8514 darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
Chris@41 8515 if test -z "$darwin_install_name"; then
Chris@41 8516 darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
Chris@41 8517 fi
Chris@41 8518 func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
Chris@41 8519 func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
Chris@41 8520 path=
Chris@41 8521 fi
Chris@41 8522 fi
Chris@41 8523 ;;
Chris@41 8524 *)
Chris@41 8525 path=-L$absdir/$objdir
Chris@41 8526 ;;
Chris@41 8527 esac
Chris@41 8528 else
Chris@41 8529 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
Chris@41 8530 test -z "$libdir" && \
Chris@41 8531 func_fatal_error "'$deplib' is not a valid libtool archive"
Chris@41 8532 test "$absdir" != "$libdir" && \
Chris@41 8533 func_warning "'$deplib' seems to be moved"
Chris@41 8534
Chris@41 8535 path=-L$absdir
Chris@41 8536 fi
Chris@41 8537 ;;
Chris@41 8538 esac
Chris@41 8539 case " $deplibs " in
Chris@41 8540 *" $path "*) ;;
Chris@41 8541 *) deplibs="$path $deplibs" ;;
Chris@41 8542 esac
Chris@41 8543 done
Chris@41 8544 fi # link_all_deplibs != no
Chris@41 8545 fi # linkmode = lib
Chris@41 8546 done # for deplib in $libs
Chris@41 8547 if test link = "$pass"; then
Chris@41 8548 if test prog = "$linkmode"; then
Chris@41 8549 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
Chris@41 8550 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
Chris@41 8551 else
Chris@41 8552 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@41 8553 fi
Chris@41 8554 fi
Chris@41 8555 dependency_libs=$newdependency_libs
Chris@41 8556 if test dlpreopen = "$pass"; then
Chris@41 8557 # Link the dlpreopened libraries before other libraries
Chris@41 8558 for deplib in $save_deplibs; do
Chris@41 8559 deplibs="$deplib $deplibs"
Chris@41 8560 done
Chris@41 8561 fi
Chris@41 8562 if test dlopen != "$pass"; then
Chris@41 8563 test conv = "$pass" || {
Chris@41 8564 # Make sure lib_search_path contains only unique directories.
Chris@41 8565 lib_search_path=
Chris@41 8566 for dir in $newlib_search_path; do
Chris@41 8567 case "$lib_search_path " in
Chris@41 8568 *" $dir "*) ;;
Chris@41 8569 *) func_append lib_search_path " $dir" ;;
Chris@41 8570 esac
Chris@41 8571 done
Chris@41 8572 newlib_search_path=
Chris@41 8573 }
Chris@41 8574
Chris@41 8575 if test prog,link = "$linkmode,$pass"; then
Chris@41 8576 vars="compile_deplibs finalize_deplibs"
Chris@41 8577 else
Chris@41 8578 vars=deplibs
Chris@41 8579 fi
Chris@41 8580 for var in $vars dependency_libs; do
Chris@41 8581 # Add libraries to $var in reverse order
Chris@41 8582 eval tmp_libs=\"\$$var\"
Chris@41 8583 new_libs=
Chris@41 8584 for deplib in $tmp_libs; do
Chris@41 8585 # FIXME: Pedantically, this is the right thing to do, so
Chris@41 8586 # that some nasty dependency loop isn't accidentally
Chris@41 8587 # broken:
Chris@41 8588 #new_libs="$deplib $new_libs"
Chris@41 8589 # Pragmatically, this seems to cause very few problems in
Chris@41 8590 # practice:
Chris@41 8591 case $deplib in
Chris@41 8592 -L*) new_libs="$deplib $new_libs" ;;
Chris@41 8593 -R*) ;;
Chris@41 8594 *)
Chris@41 8595 # And here is the reason: when a library appears more
Chris@41 8596 # than once as an explicit dependence of a library, or
Chris@41 8597 # is implicitly linked in more than once by the
Chris@41 8598 # compiler, it is considered special, and multiple
Chris@41 8599 # occurrences thereof are not removed. Compare this
Chris@41 8600 # with having the same library being listed as a
Chris@41 8601 # dependency of multiple other libraries: in this case,
Chris@41 8602 # we know (pedantically, we assume) the library does not
Chris@41 8603 # need to be listed more than once, so we keep only the
Chris@41 8604 # last copy. This is not always right, but it is rare
Chris@41 8605 # enough that we require users that really mean to play
Chris@41 8606 # such unportable linking tricks to link the library
Chris@41 8607 # using -Wl,-lname, so that libtool does not consider it
Chris@41 8608 # for duplicate removal.
Chris@41 8609 case " $specialdeplibs " in
Chris@41 8610 *" $deplib "*) new_libs="$deplib $new_libs" ;;
Chris@41 8611 *)
Chris@41 8612 case " $new_libs " in
Chris@41 8613 *" $deplib "*) ;;
Chris@41 8614 *) new_libs="$deplib $new_libs" ;;
Chris@41 8615 esac
Chris@41 8616 ;;
Chris@41 8617 esac
Chris@41 8618 ;;
Chris@41 8619 esac
Chris@41 8620 done
Chris@41 8621 tmp_libs=
Chris@41 8622 for deplib in $new_libs; do
Chris@41 8623 case $deplib in
Chris@41 8624 -L*)
Chris@41 8625 case " $tmp_libs " in
Chris@41 8626 *" $deplib "*) ;;
Chris@41 8627 *) func_append tmp_libs " $deplib" ;;
Chris@41 8628 esac
Chris@41 8629 ;;
Chris@41 8630 *) func_append tmp_libs " $deplib" ;;
Chris@41 8631 esac
Chris@41 8632 done
Chris@41 8633 eval $var=\"$tmp_libs\"
Chris@41 8634 done # for var
Chris@41 8635 fi
Chris@41 8636
Chris@41 8637 # Add Sun CC postdeps if required:
Chris@41 8638 test CXX = "$tagname" && {
Chris@41 8639 case $host_os in
Chris@41 8640 linux*)
Chris@41 8641 case `$CC -V 2>&1 | sed 5q` in
Chris@41 8642 *Sun\ C*) # Sun C++ 5.9
Chris@41 8643 func_suncc_cstd_abi
Chris@41 8644
Chris@41 8645 if test no != "$suncc_use_cstd_abi"; then
Chris@41 8646 func_append postdeps ' -library=Cstd -library=Crun'
Chris@41 8647 fi
Chris@41 8648 ;;
Chris@41 8649 esac
Chris@41 8650 ;;
Chris@41 8651
Chris@41 8652 solaris*)
Chris@41 8653 func_cc_basename "$CC"
Chris@41 8654 case $func_cc_basename_result in
Chris@41 8655 CC* | sunCC*)
Chris@41 8656 func_suncc_cstd_abi
Chris@41 8657
Chris@41 8658 if test no != "$suncc_use_cstd_abi"; then
Chris@41 8659 func_append postdeps ' -library=Cstd -library=Crun'
Chris@41 8660 fi
Chris@41 8661 ;;
Chris@41 8662 esac
Chris@41 8663 ;;
Chris@41 8664 esac
Chris@41 8665 }
Chris@41 8666
Chris@41 8667 # Last step: remove runtime libs from dependency_libs
Chris@41 8668 # (they stay in deplibs)
Chris@41 8669 tmp_libs=
Chris@41 8670 for i in $dependency_libs; do
Chris@41 8671 case " $predeps $postdeps $compiler_lib_search_path " in
Chris@41 8672 *" $i "*)
Chris@41 8673 i=
Chris@41 8674 ;;
Chris@41 8675 esac
Chris@41 8676 if test -n "$i"; then
Chris@41 8677 func_append tmp_libs " $i"
Chris@41 8678 fi
Chris@41 8679 done
Chris@41 8680 dependency_libs=$tmp_libs
Chris@41 8681 done # for pass
Chris@41 8682 if test prog = "$linkmode"; then
Chris@41 8683 dlfiles=$newdlfiles
Chris@41 8684 fi
Chris@41 8685 if test prog = "$linkmode" || test lib = "$linkmode"; then
Chris@41 8686 dlprefiles=$newdlprefiles
Chris@41 8687 fi
Chris@41 8688
Chris@41 8689 case $linkmode in
Chris@41 8690 oldlib)
Chris@41 8691 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
Chris@41 8692 func_warning "'-dlopen' is ignored for archives"
Chris@41 8693 fi
Chris@41 8694
Chris@41 8695 case " $deplibs" in
Chris@41 8696 *\ -l* | *\ -L*)
Chris@41 8697 func_warning "'-l' and '-L' are ignored for archives" ;;
Chris@41 8698 esac
Chris@41 8699
Chris@41 8700 test -n "$rpath" && \
Chris@41 8701 func_warning "'-rpath' is ignored for archives"
Chris@41 8702
Chris@41 8703 test -n "$xrpath" && \
Chris@41 8704 func_warning "'-R' is ignored for archives"
Chris@41 8705
Chris@41 8706 test -n "$vinfo" && \
Chris@41 8707 func_warning "'-version-info/-version-number' is ignored for archives"
Chris@41 8708
Chris@41 8709 test -n "$release" && \
Chris@41 8710 func_warning "'-release' is ignored for archives"
Chris@41 8711
Chris@41 8712 test -n "$export_symbols$export_symbols_regex" && \
Chris@41 8713 func_warning "'-export-symbols' is ignored for archives"
Chris@41 8714
Chris@41 8715 # Now set the variables for building old libraries.
Chris@41 8716 build_libtool_libs=no
Chris@41 8717 oldlibs=$output
Chris@41 8718 func_append objs "$old_deplibs"
Chris@41 8719 ;;
Chris@41 8720
Chris@41 8721 lib)
Chris@41 8722 # Make sure we only generate libraries of the form 'libNAME.la'.
Chris@41 8723 case $outputname in
Chris@41 8724 lib*)
Chris@41 8725 func_stripname 'lib' '.la' "$outputname"
Chris@41 8726 name=$func_stripname_result
Chris@41 8727 eval shared_ext=\"$shrext_cmds\"
Chris@41 8728 eval libname=\"$libname_spec\"
Chris@41 8729 ;;
Chris@41 8730 *)
Chris@41 8731 test no = "$module" \
Chris@41 8732 && func_fatal_help "libtool library '$output' must begin with 'lib'"
Chris@41 8733
Chris@41 8734 if test no != "$need_lib_prefix"; then
Chris@41 8735 # Add the "lib" prefix for modules if required
Chris@41 8736 func_stripname '' '.la' "$outputname"
Chris@41 8737 name=$func_stripname_result
Chris@41 8738 eval shared_ext=\"$shrext_cmds\"
Chris@41 8739 eval libname=\"$libname_spec\"
Chris@41 8740 else
Chris@41 8741 func_stripname '' '.la' "$outputname"
Chris@41 8742 libname=$func_stripname_result
Chris@41 8743 fi
Chris@41 8744 ;;
Chris@41 8745 esac
Chris@41 8746
Chris@41 8747 if test -n "$objs"; then
Chris@41 8748 if test pass_all != "$deplibs_check_method"; then
Chris@41 8749 func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
Chris@41 8750 else
Chris@41 8751 echo
Chris@41 8752 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
Chris@41 8753 $ECHO "*** objects $objs is not portable!"
Chris@41 8754 func_append libobjs " $objs"
Chris@41 8755 fi
Chris@41 8756 fi
Chris@41 8757
Chris@41 8758 test no = "$dlself" \
Chris@41 8759 || func_warning "'-dlopen self' is ignored for libtool libraries"
Chris@41 8760
Chris@41 8761 set dummy $rpath
Chris@41 8762 shift
Chris@41 8763 test 1 -lt "$#" \
Chris@41 8764 && func_warning "ignoring multiple '-rpath's for a libtool library"
Chris@41 8765
Chris@41 8766 install_libdir=$1
Chris@41 8767
Chris@41 8768 oldlibs=
Chris@41 8769 if test -z "$rpath"; then
Chris@41 8770 if test yes = "$build_libtool_libs"; then
Chris@41 8771 # Building a libtool convenience library.
Chris@41 8772 # Some compilers have problems with a '.al' extension so
Chris@41 8773 # convenience libraries should have the same extension an
Chris@41 8774 # archive normally would.
Chris@41 8775 oldlibs="$output_objdir/$libname.$libext $oldlibs"
Chris@41 8776 build_libtool_libs=convenience
Chris@41 8777 build_old_libs=yes
Chris@41 8778 fi
Chris@41 8779
Chris@41 8780 test -n "$vinfo" && \
Chris@41 8781 func_warning "'-version-info/-version-number' is ignored for convenience libraries"
Chris@41 8782
Chris@41 8783 test -n "$release" && \
Chris@41 8784 func_warning "'-release' is ignored for convenience libraries"
Chris@41 8785 else
Chris@41 8786
Chris@41 8787 # Parse the version information argument.
Chris@41 8788 save_ifs=$IFS; IFS=:
Chris@41 8789 set dummy $vinfo 0 0 0
Chris@41 8790 shift
Chris@41 8791 IFS=$save_ifs
Chris@41 8792
Chris@41 8793 test -n "$7" && \
Chris@41 8794 func_fatal_help "too many parameters to '-version-info'"
Chris@41 8795
Chris@41 8796 # convert absolute version numbers to libtool ages
Chris@41 8797 # this retains compatibility with .la files and attempts
Chris@41 8798 # to make the code below a bit more comprehensible
Chris@41 8799
Chris@41 8800 case $vinfo_number in
Chris@41 8801 yes)
Chris@41 8802 number_major=$1
Chris@41 8803 number_minor=$2
Chris@41 8804 number_revision=$3
Chris@41 8805 #
Chris@41 8806 # There are really only two kinds -- those that
Chris@41 8807 # use the current revision as the major version
Chris@41 8808 # and those that subtract age and use age as
Chris@41 8809 # a minor version. But, then there is irix
Chris@41 8810 # that has an extra 1 added just for fun
Chris@41 8811 #
Chris@41 8812 case $version_type in
Chris@41 8813 # correct linux to gnu/linux during the next big refactor
Chris@41 8814 darwin|freebsd-elf|linux|osf|windows|none)
Chris@41 8815 func_arith $number_major + $number_minor
Chris@41 8816 current=$func_arith_result
Chris@41 8817 age=$number_minor
Chris@41 8818 revision=$number_revision
Chris@41 8819 ;;
Chris@41 8820 freebsd-aout|qnx|sunos)
Chris@41 8821 current=$number_major
Chris@41 8822 revision=$number_minor
Chris@41 8823 age=0
Chris@41 8824 ;;
Chris@41 8825 irix|nonstopux)
Chris@41 8826 func_arith $number_major + $number_minor
Chris@41 8827 current=$func_arith_result
Chris@41 8828 age=$number_minor
Chris@41 8829 revision=$number_minor
Chris@41 8830 lt_irix_increment=no
Chris@41 8831 ;;
Chris@41 8832 *)
Chris@41 8833 func_fatal_configuration "$modename: unknown library version type '$version_type'"
Chris@41 8834 ;;
Chris@41 8835 esac
Chris@41 8836 ;;
Chris@41 8837 no)
Chris@41 8838 current=$1
Chris@41 8839 revision=$2
Chris@41 8840 age=$3
Chris@41 8841 ;;
Chris@41 8842 esac
Chris@41 8843
Chris@41 8844 # Check that each of the things are valid numbers.
Chris@41 8845 case $current in
Chris@41 8846 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@41 8847 *)
Chris@41 8848 func_error "CURRENT '$current' must be a nonnegative integer"
Chris@41 8849 func_fatal_error "'$vinfo' is not valid version information"
Chris@41 8850 ;;
Chris@41 8851 esac
Chris@41 8852
Chris@41 8853 case $revision in
Chris@41 8854 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@41 8855 *)
Chris@41 8856 func_error "REVISION '$revision' must be a nonnegative integer"
Chris@41 8857 func_fatal_error "'$vinfo' is not valid version information"
Chris@41 8858 ;;
Chris@41 8859 esac
Chris@41 8860
Chris@41 8861 case $age in
Chris@41 8862 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@41 8863 *)
Chris@41 8864 func_error "AGE '$age' must be a nonnegative integer"
Chris@41 8865 func_fatal_error "'$vinfo' is not valid version information"
Chris@41 8866 ;;
Chris@41 8867 esac
Chris@41 8868
Chris@41 8869 if test "$age" -gt "$current"; then
Chris@41 8870 func_error "AGE '$age' is greater than the current interface number '$current'"
Chris@41 8871 func_fatal_error "'$vinfo' is not valid version information"
Chris@41 8872 fi
Chris@41 8873
Chris@41 8874 # Calculate the version variables.
Chris@41 8875 major=
Chris@41 8876 versuffix=
Chris@41 8877 verstring=
Chris@41 8878 case $version_type in
Chris@41 8879 none) ;;
Chris@41 8880
Chris@41 8881 darwin)
Chris@41 8882 # Like Linux, but with the current version available in
Chris@41 8883 # verstring for coding it into the library header
Chris@41 8884 func_arith $current - $age
Chris@41 8885 major=.$func_arith_result
Chris@41 8886 versuffix=$major.$age.$revision
Chris@41 8887 # Darwin ld doesn't like 0 for these options...
Chris@41 8888 func_arith $current + 1
Chris@41 8889 minor_current=$func_arith_result
Chris@41 8890 xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
Chris@41 8891 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
Chris@41 8892 # On Darwin other compilers
Chris@41 8893 case $CC in
Chris@41 8894 nagfor*)
Chris@41 8895 verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
Chris@41 8896 ;;
Chris@41 8897 *)
Chris@41 8898 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
Chris@41 8899 ;;
Chris@41 8900 esac
Chris@41 8901 ;;
Chris@41 8902
Chris@41 8903 freebsd-aout)
Chris@41 8904 major=.$current
Chris@41 8905 versuffix=.$current.$revision
Chris@41 8906 ;;
Chris@41 8907
Chris@41 8908 freebsd-elf)
Chris@41 8909 func_arith $current - $age
Chris@41 8910 major=.$func_arith_result
Chris@41 8911 versuffix=$major.$age.$revision
Chris@41 8912 ;;
Chris@41 8913
Chris@41 8914 irix | nonstopux)
Chris@41 8915 if test no = "$lt_irix_increment"; then
Chris@41 8916 func_arith $current - $age
Chris@41 8917 else
Chris@41 8918 func_arith $current - $age + 1
Chris@41 8919 fi
Chris@41 8920 major=$func_arith_result
Chris@41 8921
Chris@41 8922 case $version_type in
Chris@41 8923 nonstopux) verstring_prefix=nonstopux ;;
Chris@41 8924 *) verstring_prefix=sgi ;;
Chris@41 8925 esac
Chris@41 8926 verstring=$verstring_prefix$major.$revision
Chris@41 8927
Chris@41 8928 # Add in all the interfaces that we are compatible with.
Chris@41 8929 loop=$revision
Chris@41 8930 while test 0 -ne "$loop"; do
Chris@41 8931 func_arith $revision - $loop
Chris@41 8932 iface=$func_arith_result
Chris@41 8933 func_arith $loop - 1
Chris@41 8934 loop=$func_arith_result
Chris@41 8935 verstring=$verstring_prefix$major.$iface:$verstring
Chris@41 8936 done
Chris@41 8937
Chris@41 8938 # Before this point, $major must not contain '.'.
Chris@41 8939 major=.$major
Chris@41 8940 versuffix=$major.$revision
Chris@41 8941 ;;
Chris@41 8942
Chris@41 8943 linux) # correct to gnu/linux during the next big refactor
Chris@41 8944 func_arith $current - $age
Chris@41 8945 major=.$func_arith_result
Chris@41 8946 versuffix=$major.$age.$revision
Chris@41 8947 ;;
Chris@41 8948
Chris@41 8949 osf)
Chris@41 8950 func_arith $current - $age
Chris@41 8951 major=.$func_arith_result
Chris@41 8952 versuffix=.$current.$age.$revision
Chris@41 8953 verstring=$current.$age.$revision
Chris@41 8954
Chris@41 8955 # Add in all the interfaces that we are compatible with.
Chris@41 8956 loop=$age
Chris@41 8957 while test 0 -ne "$loop"; do
Chris@41 8958 func_arith $current - $loop
Chris@41 8959 iface=$func_arith_result
Chris@41 8960 func_arith $loop - 1
Chris@41 8961 loop=$func_arith_result
Chris@41 8962 verstring=$verstring:$iface.0
Chris@41 8963 done
Chris@41 8964
Chris@41 8965 # Make executables depend on our current version.
Chris@41 8966 func_append verstring ":$current.0"
Chris@41 8967 ;;
Chris@41 8968
Chris@41 8969 qnx)
Chris@41 8970 major=.$current
Chris@41 8971 versuffix=.$current
Chris@41 8972 ;;
Chris@41 8973
Chris@41 8974 sco)
Chris@41 8975 major=.$current
Chris@41 8976 versuffix=.$current
Chris@41 8977 ;;
Chris@41 8978
Chris@41 8979 sunos)
Chris@41 8980 major=.$current
Chris@41 8981 versuffix=.$current.$revision
Chris@41 8982 ;;
Chris@41 8983
Chris@41 8984 windows)
Chris@41 8985 # Use '-' rather than '.', since we only want one
Chris@41 8986 # extension on DOS 8.3 file systems.
Chris@41 8987 func_arith $current - $age
Chris@41 8988 major=$func_arith_result
Chris@41 8989 versuffix=-$major
Chris@41 8990 ;;
Chris@41 8991
Chris@41 8992 *)
Chris@41 8993 func_fatal_configuration "unknown library version type '$version_type'"
Chris@41 8994 ;;
Chris@41 8995 esac
Chris@41 8996
Chris@41 8997 # Clear the version info if we defaulted, and they specified a release.
Chris@41 8998 if test -z "$vinfo" && test -n "$release"; then
Chris@41 8999 major=
Chris@41 9000 case $version_type in
Chris@41 9001 darwin)
Chris@41 9002 # we can't check for "0.0" in archive_cmds due to quoting
Chris@41 9003 # problems, so we reset it completely
Chris@41 9004 verstring=
Chris@41 9005 ;;
Chris@41 9006 *)
Chris@41 9007 verstring=0.0
Chris@41 9008 ;;
Chris@41 9009 esac
Chris@41 9010 if test no = "$need_version"; then
Chris@41 9011 versuffix=
Chris@41 9012 else
Chris@41 9013 versuffix=.0.0
Chris@41 9014 fi
Chris@41 9015 fi
Chris@41 9016
Chris@41 9017 # Remove version info from name if versioning should be avoided
Chris@41 9018 if test yes,no = "$avoid_version,$need_version"; then
Chris@41 9019 major=
Chris@41 9020 versuffix=
Chris@41 9021 verstring=
Chris@41 9022 fi
Chris@41 9023
Chris@41 9024 # Check to see if the archive will have undefined symbols.
Chris@41 9025 if test yes = "$allow_undefined"; then
Chris@41 9026 if test unsupported = "$allow_undefined_flag"; then
Chris@41 9027 if test yes = "$build_old_libs"; then
Chris@41 9028 func_warning "undefined symbols not allowed in $host shared libraries; building static only"
Chris@41 9029 build_libtool_libs=no
Chris@41 9030 else
Chris@41 9031 func_fatal_error "can't build $host shared library unless -no-undefined is specified"
Chris@41 9032 fi
Chris@41 9033 fi
Chris@41 9034 else
Chris@41 9035 # Don't allow undefined symbols.
Chris@41 9036 allow_undefined_flag=$no_undefined_flag
Chris@41 9037 fi
Chris@41 9038
Chris@41 9039 fi
Chris@41 9040
Chris@41 9041 func_generate_dlsyms "$libname" "$libname" :
Chris@41 9042 func_append libobjs " $symfileobj"
Chris@41 9043 test " " = "$libobjs" && libobjs=
Chris@41 9044
Chris@41 9045 if test relink != "$opt_mode"; then
Chris@41 9046 # Remove our outputs, but don't remove object files since they
Chris@41 9047 # may have been created when compiling PIC objects.
Chris@41 9048 removelist=
Chris@41 9049 tempremovelist=`$ECHO "$output_objdir/*"`
Chris@41 9050 for p in $tempremovelist; do
Chris@41 9051 case $p in
Chris@41 9052 *.$objext | *.gcno)
Chris@41 9053 ;;
Chris@41 9054 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
Chris@41 9055 if test -n "$precious_files_regex"; then
Chris@41 9056 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
Chris@41 9057 then
Chris@41 9058 continue
Chris@41 9059 fi
Chris@41 9060 fi
Chris@41 9061 func_append removelist " $p"
Chris@41 9062 ;;
Chris@41 9063 *) ;;
Chris@41 9064 esac
Chris@41 9065 done
Chris@41 9066 test -n "$removelist" && \
Chris@41 9067 func_show_eval "${RM}r \$removelist"
Chris@41 9068 fi
Chris@41 9069
Chris@41 9070 # Now set the variables for building old libraries.
Chris@41 9071 if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
Chris@41 9072 func_append oldlibs " $output_objdir/$libname.$libext"
Chris@41 9073
Chris@41 9074 # Transform .lo files to .o files.
Chris@41 9075 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
Chris@41 9076 fi
Chris@41 9077
Chris@41 9078 # Eliminate all temporary directories.
Chris@41 9079 #for path in $notinst_path; do
Chris@41 9080 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
Chris@41 9081 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
Chris@41 9082 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
Chris@41 9083 #done
Chris@41 9084
Chris@41 9085 if test -n "$xrpath"; then
Chris@41 9086 # If the user specified any rpath flags, then add them.
Chris@41 9087 temp_xrpath=
Chris@41 9088 for libdir in $xrpath; do
Chris@41 9089 func_replace_sysroot "$libdir"
Chris@41 9090 func_append temp_xrpath " -R$func_replace_sysroot_result"
Chris@41 9091 case "$finalize_rpath " in
Chris@41 9092 *" $libdir "*) ;;
Chris@41 9093 *) func_append finalize_rpath " $libdir" ;;
Chris@41 9094 esac
Chris@41 9095 done
Chris@41 9096 if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
Chris@41 9097 dependency_libs="$temp_xrpath $dependency_libs"
Chris@41 9098 fi
Chris@41 9099 fi
Chris@41 9100
Chris@41 9101 # Make sure dlfiles contains only unique files that won't be dlpreopened
Chris@41 9102 old_dlfiles=$dlfiles
Chris@41 9103 dlfiles=
Chris@41 9104 for lib in $old_dlfiles; do
Chris@41 9105 case " $dlprefiles $dlfiles " in
Chris@41 9106 *" $lib "*) ;;
Chris@41 9107 *) func_append dlfiles " $lib" ;;
Chris@41 9108 esac
Chris@41 9109 done
Chris@41 9110
Chris@41 9111 # Make sure dlprefiles contains only unique files
Chris@41 9112 old_dlprefiles=$dlprefiles
Chris@41 9113 dlprefiles=
Chris@41 9114 for lib in $old_dlprefiles; do
Chris@41 9115 case "$dlprefiles " in
Chris@41 9116 *" $lib "*) ;;
Chris@41 9117 *) func_append dlprefiles " $lib" ;;
Chris@41 9118 esac
Chris@41 9119 done
Chris@41 9120
Chris@41 9121 if test yes = "$build_libtool_libs"; then
Chris@41 9122 if test -n "$rpath"; then
Chris@41 9123 case $host in
Chris@41 9124 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
Chris@41 9125 # these systems don't actually have a c library (as such)!
Chris@41 9126 ;;
Chris@41 9127 *-*-rhapsody* | *-*-darwin1.[012])
Chris@41 9128 # Rhapsody C library is in the System framework
Chris@41 9129 func_append deplibs " System.ltframework"
Chris@41 9130 ;;
Chris@41 9131 *-*-netbsd*)
Chris@41 9132 # Don't link with libc until the a.out ld.so is fixed.
Chris@41 9133 ;;
Chris@41 9134 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
Chris@41 9135 # Do not include libc due to us having libc/libc_r.
Chris@41 9136 ;;
Chris@41 9137 *-*-sco3.2v5* | *-*-sco5v6*)
Chris@41 9138 # Causes problems with __ctype
Chris@41 9139 ;;
Chris@41 9140 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
Chris@41 9141 # Compiler inserts libc in the correct place for threads to work
Chris@41 9142 ;;
Chris@41 9143 *)
Chris@41 9144 # Add libc to deplibs on all other systems if necessary.
Chris@41 9145 if test yes = "$build_libtool_need_lc"; then
Chris@41 9146 func_append deplibs " -lc"
Chris@41 9147 fi
Chris@41 9148 ;;
Chris@41 9149 esac
Chris@41 9150 fi
Chris@41 9151
Chris@41 9152 # Transform deplibs into only deplibs that can be linked in shared.
Chris@41 9153 name_save=$name
Chris@41 9154 libname_save=$libname
Chris@41 9155 release_save=$release
Chris@41 9156 versuffix_save=$versuffix
Chris@41 9157 major_save=$major
Chris@41 9158 # I'm not sure if I'm treating the release correctly. I think
Chris@41 9159 # release should show up in the -l (ie -lgmp5) so we don't want to
Chris@41 9160 # add it in twice. Is that correct?
Chris@41 9161 release=
Chris@41 9162 versuffix=
Chris@41 9163 major=
Chris@41 9164 newdeplibs=
Chris@41 9165 droppeddeps=no
Chris@41 9166 case $deplibs_check_method in
Chris@41 9167 pass_all)
Chris@41 9168 # Don't check for shared/static. Everything works.
Chris@41 9169 # This might be a little naive. We might want to check
Chris@41 9170 # whether the library exists or not. But this is on
Chris@41 9171 # osf3 & osf4 and I'm not really sure... Just
Chris@41 9172 # implementing what was already the behavior.
Chris@41 9173 newdeplibs=$deplibs
Chris@41 9174 ;;
Chris@41 9175 test_compile)
Chris@41 9176 # This code stresses the "libraries are programs" paradigm to its
Chris@41 9177 # limits. Maybe even breaks it. We compile a program, linking it
Chris@41 9178 # against the deplibs as a proxy for the library. Then we can check
Chris@41 9179 # whether they linked in statically or dynamically with ldd.
Chris@41 9180 $opt_dry_run || $RM conftest.c
Chris@41 9181 cat > conftest.c <<EOF
Chris@41 9182 int main() { return 0; }
Chris@41 9183 EOF
Chris@41 9184 $opt_dry_run || $RM conftest
Chris@41 9185 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
Chris@41 9186 ldd_output=`ldd conftest`
Chris@41 9187 for i in $deplibs; do
Chris@41 9188 case $i in
Chris@41 9189 -l*)
Chris@41 9190 func_stripname -l '' "$i"
Chris@41 9191 name=$func_stripname_result
Chris@41 9192 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@41 9193 case " $predeps $postdeps " in
Chris@41 9194 *" $i "*)
Chris@41 9195 func_append newdeplibs " $i"
Chris@41 9196 i=
Chris@41 9197 ;;
Chris@41 9198 esac
Chris@41 9199 fi
Chris@41 9200 if test -n "$i"; then
Chris@41 9201 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@41 9202 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
Chris@41 9203 set dummy $deplib_matches; shift
Chris@41 9204 deplib_match=$1
Chris@41 9205 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
Chris@41 9206 func_append newdeplibs " $i"
Chris@41 9207 else
Chris@41 9208 droppeddeps=yes
Chris@41 9209 echo
Chris@41 9210 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
Chris@41 9211 echo "*** I have the capability to make that library automatically link in when"
Chris@41 9212 echo "*** you link to this library. But I can only do this if you have a"
Chris@41 9213 echo "*** shared version of the library, which I believe you do not have"
Chris@41 9214 echo "*** because a test_compile did reveal that the linker did not use it for"
Chris@41 9215 echo "*** its dynamic dependency list that programs get resolved with at runtime."
Chris@41 9216 fi
Chris@41 9217 fi
Chris@41 9218 ;;
Chris@41 9219 *)
Chris@41 9220 func_append newdeplibs " $i"
Chris@41 9221 ;;
Chris@41 9222 esac
Chris@41 9223 done
Chris@41 9224 else
Chris@41 9225 # Error occurred in the first compile. Let's try to salvage
Chris@41 9226 # the situation: Compile a separate program for each library.
Chris@41 9227 for i in $deplibs; do
Chris@41 9228 case $i in
Chris@41 9229 -l*)
Chris@41 9230 func_stripname -l '' "$i"
Chris@41 9231 name=$func_stripname_result
Chris@41 9232 $opt_dry_run || $RM conftest
Chris@41 9233 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
Chris@41 9234 ldd_output=`ldd conftest`
Chris@41 9235 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@41 9236 case " $predeps $postdeps " in
Chris@41 9237 *" $i "*)
Chris@41 9238 func_append newdeplibs " $i"
Chris@41 9239 i=
Chris@41 9240 ;;
Chris@41 9241 esac
Chris@41 9242 fi
Chris@41 9243 if test -n "$i"; then
Chris@41 9244 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@41 9245 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
Chris@41 9246 set dummy $deplib_matches; shift
Chris@41 9247 deplib_match=$1
Chris@41 9248 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
Chris@41 9249 func_append newdeplibs " $i"
Chris@41 9250 else
Chris@41 9251 droppeddeps=yes
Chris@41 9252 echo
Chris@41 9253 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
Chris@41 9254 echo "*** I have the capability to make that library automatically link in when"
Chris@41 9255 echo "*** you link to this library. But I can only do this if you have a"
Chris@41 9256 echo "*** shared version of the library, which you do not appear to have"
Chris@41 9257 echo "*** because a test_compile did reveal that the linker did not use this one"
Chris@41 9258 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
Chris@41 9259 fi
Chris@41 9260 fi
Chris@41 9261 else
Chris@41 9262 droppeddeps=yes
Chris@41 9263 echo
Chris@41 9264 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
Chris@41 9265 echo "*** make it link in! You will probably need to install it or some"
Chris@41 9266 echo "*** library that it depends on before this library will be fully"
Chris@41 9267 echo "*** functional. Installing it before continuing would be even better."
Chris@41 9268 fi
Chris@41 9269 ;;
Chris@41 9270 *)
Chris@41 9271 func_append newdeplibs " $i"
Chris@41 9272 ;;
Chris@41 9273 esac
Chris@41 9274 done
Chris@41 9275 fi
Chris@41 9276 ;;
Chris@41 9277 file_magic*)
Chris@41 9278 set dummy $deplibs_check_method; shift
Chris@41 9279 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Chris@41 9280 for a_deplib in $deplibs; do
Chris@41 9281 case $a_deplib in
Chris@41 9282 -l*)
Chris@41 9283 func_stripname -l '' "$a_deplib"
Chris@41 9284 name=$func_stripname_result
Chris@41 9285 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@41 9286 case " $predeps $postdeps " in
Chris@41 9287 *" $a_deplib "*)
Chris@41 9288 func_append newdeplibs " $a_deplib"
Chris@41 9289 a_deplib=
Chris@41 9290 ;;
Chris@41 9291 esac
Chris@41 9292 fi
Chris@41 9293 if test -n "$a_deplib"; then
Chris@41 9294 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@41 9295 if test -n "$file_magic_glob"; then
Chris@41 9296 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
Chris@41 9297 else
Chris@41 9298 libnameglob=$libname
Chris@41 9299 fi
Chris@41 9300 test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
Chris@41 9301 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
Chris@41 9302 if test yes = "$want_nocaseglob"; then
Chris@41 9303 shopt -s nocaseglob
Chris@41 9304 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
Chris@41 9305 $nocaseglob
Chris@41 9306 else
Chris@41 9307 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
Chris@41 9308 fi
Chris@41 9309 for potent_lib in $potential_libs; do
Chris@41 9310 # Follow soft links.
Chris@41 9311 if ls -lLd "$potent_lib" 2>/dev/null |
Chris@41 9312 $GREP " -> " >/dev/null; then
Chris@41 9313 continue
Chris@41 9314 fi
Chris@41 9315 # The statement above tries to avoid entering an
Chris@41 9316 # endless loop below, in case of cyclic links.
Chris@41 9317 # We might still enter an endless loop, since a link
Chris@41 9318 # loop can be closed while we follow links,
Chris@41 9319 # but so what?
Chris@41 9320 potlib=$potent_lib
Chris@41 9321 while test -h "$potlib" 2>/dev/null; do
Chris@41 9322 potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
Chris@41 9323 case $potliblink in
Chris@41 9324 [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
Chris@41 9325 *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
Chris@41 9326 esac
Chris@41 9327 done
Chris@41 9328 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
Chris@41 9329 $SED -e 10q |
Chris@41 9330 $EGREP "$file_magic_regex" > /dev/null; then
Chris@41 9331 func_append newdeplibs " $a_deplib"
Chris@41 9332 a_deplib=
Chris@41 9333 break 2
Chris@41 9334 fi
Chris@41 9335 done
Chris@41 9336 done
Chris@41 9337 fi
Chris@41 9338 if test -n "$a_deplib"; then
Chris@41 9339 droppeddeps=yes
Chris@41 9340 echo
Chris@41 9341 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
Chris@41 9342 echo "*** I have the capability to make that library automatically link in when"
Chris@41 9343 echo "*** you link to this library. But I can only do this if you have a"
Chris@41 9344 echo "*** shared version of the library, which you do not appear to have"
Chris@41 9345 echo "*** because I did check the linker path looking for a file starting"
Chris@41 9346 if test -z "$potlib"; then
Chris@41 9347 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
Chris@41 9348 else
Chris@41 9349 $ECHO "*** with $libname and none of the candidates passed a file format test"
Chris@41 9350 $ECHO "*** using a file magic. Last file checked: $potlib"
Chris@41 9351 fi
Chris@41 9352 fi
Chris@41 9353 ;;
Chris@41 9354 *)
Chris@41 9355 # Add a -L argument.
Chris@41 9356 func_append newdeplibs " $a_deplib"
Chris@41 9357 ;;
Chris@41 9358 esac
Chris@41 9359 done # Gone through all deplibs.
Chris@41 9360 ;;
Chris@41 9361 match_pattern*)
Chris@41 9362 set dummy $deplibs_check_method; shift
Chris@41 9363 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Chris@41 9364 for a_deplib in $deplibs; do
Chris@41 9365 case $a_deplib in
Chris@41 9366 -l*)
Chris@41 9367 func_stripname -l '' "$a_deplib"
Chris@41 9368 name=$func_stripname_result
Chris@41 9369 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@41 9370 case " $predeps $postdeps " in
Chris@41 9371 *" $a_deplib "*)
Chris@41 9372 func_append newdeplibs " $a_deplib"
Chris@41 9373 a_deplib=
Chris@41 9374 ;;
Chris@41 9375 esac
Chris@41 9376 fi
Chris@41 9377 if test -n "$a_deplib"; then
Chris@41 9378 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@41 9379 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
Chris@41 9380 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
Chris@41 9381 for potent_lib in $potential_libs; do
Chris@41 9382 potlib=$potent_lib # see symlink-check above in file_magic test
Chris@41 9383 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
Chris@41 9384 $EGREP "$match_pattern_regex" > /dev/null; then
Chris@41 9385 func_append newdeplibs " $a_deplib"
Chris@41 9386 a_deplib=
Chris@41 9387 break 2
Chris@41 9388 fi
Chris@41 9389 done
Chris@41 9390 done
Chris@41 9391 fi
Chris@41 9392 if test -n "$a_deplib"; then
Chris@41 9393 droppeddeps=yes
Chris@41 9394 echo
Chris@41 9395 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
Chris@41 9396 echo "*** I have the capability to make that library automatically link in when"
Chris@41 9397 echo "*** you link to this library. But I can only do this if you have a"
Chris@41 9398 echo "*** shared version of the library, which you do not appear to have"
Chris@41 9399 echo "*** because I did check the linker path looking for a file starting"
Chris@41 9400 if test -z "$potlib"; then
Chris@41 9401 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
Chris@41 9402 else
Chris@41 9403 $ECHO "*** with $libname and none of the candidates passed a file format test"
Chris@41 9404 $ECHO "*** using a regex pattern. Last file checked: $potlib"
Chris@41 9405 fi
Chris@41 9406 fi
Chris@41 9407 ;;
Chris@41 9408 *)
Chris@41 9409 # Add a -L argument.
Chris@41 9410 func_append newdeplibs " $a_deplib"
Chris@41 9411 ;;
Chris@41 9412 esac
Chris@41 9413 done # Gone through all deplibs.
Chris@41 9414 ;;
Chris@41 9415 none | unknown | *)
Chris@41 9416 newdeplibs=
Chris@41 9417 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
Chris@41 9418 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@41 9419 for i in $predeps $postdeps; do
Chris@41 9420 # can't use Xsed below, because $i might contain '/'
Chris@41 9421 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
Chris@41 9422 done
Chris@41 9423 fi
Chris@41 9424 case $tmp_deplibs in
Chris@41 9425 *[!\ \ ]*)
Chris@41 9426 echo
Chris@41 9427 if test none = "$deplibs_check_method"; then
Chris@41 9428 echo "*** Warning: inter-library dependencies are not supported in this platform."
Chris@41 9429 else
Chris@41 9430 echo "*** Warning: inter-library dependencies are not known to be supported."
Chris@41 9431 fi
Chris@41 9432 echo "*** All declared inter-library dependencies are being dropped."
Chris@41 9433 droppeddeps=yes
Chris@41 9434 ;;
Chris@41 9435 esac
Chris@41 9436 ;;
Chris@41 9437 esac
Chris@41 9438 versuffix=$versuffix_save
Chris@41 9439 major=$major_save
Chris@41 9440 release=$release_save
Chris@41 9441 libname=$libname_save
Chris@41 9442 name=$name_save
Chris@41 9443
Chris@41 9444 case $host in
Chris@41 9445 *-*-rhapsody* | *-*-darwin1.[012])
Chris@41 9446 # On Rhapsody replace the C library with the System framework
Chris@41 9447 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
Chris@41 9448 ;;
Chris@41 9449 esac
Chris@41 9450
Chris@41 9451 if test yes = "$droppeddeps"; then
Chris@41 9452 if test yes = "$module"; then
Chris@41 9453 echo
Chris@41 9454 echo "*** Warning: libtool could not satisfy all declared inter-library"
Chris@41 9455 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
Chris@41 9456 echo "*** a static module, that should work as long as the dlopening"
Chris@41 9457 echo "*** application is linked with the -dlopen flag."
Chris@41 9458 if test -z "$global_symbol_pipe"; then
Chris@41 9459 echo
Chris@41 9460 echo "*** However, this would only work if libtool was able to extract symbol"
Chris@41 9461 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
Chris@41 9462 echo "*** not find such a program. So, this module is probably useless."
Chris@41 9463 echo "*** 'nm' from GNU binutils and a full rebuild may help."
Chris@41 9464 fi
Chris@41 9465 if test no = "$build_old_libs"; then
Chris@41 9466 oldlibs=$output_objdir/$libname.$libext
Chris@41 9467 build_libtool_libs=module
Chris@41 9468 build_old_libs=yes
Chris@41 9469 else
Chris@41 9470 build_libtool_libs=no
Chris@41 9471 fi
Chris@41 9472 else
Chris@41 9473 echo "*** The inter-library dependencies that have been dropped here will be"
Chris@41 9474 echo "*** automatically added whenever a program is linked with this library"
Chris@41 9475 echo "*** or is declared to -dlopen it."
Chris@41 9476
Chris@41 9477 if test no = "$allow_undefined"; then
Chris@41 9478 echo
Chris@41 9479 echo "*** Since this library must not contain undefined symbols,"
Chris@41 9480 echo "*** because either the platform does not support them or"
Chris@41 9481 echo "*** it was explicitly requested with -no-undefined,"
Chris@41 9482 echo "*** libtool will only create a static version of it."
Chris@41 9483 if test no = "$build_old_libs"; then
Chris@41 9484 oldlibs=$output_objdir/$libname.$libext
Chris@41 9485 build_libtool_libs=module
Chris@41 9486 build_old_libs=yes
Chris@41 9487 else
Chris@41 9488 build_libtool_libs=no
Chris@41 9489 fi
Chris@41 9490 fi
Chris@41 9491 fi
Chris@41 9492 fi
Chris@41 9493 # Done checking deplibs!
Chris@41 9494 deplibs=$newdeplibs
Chris@41 9495 fi
Chris@41 9496 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
Chris@41 9497 case $host in
Chris@41 9498 *-*-darwin*)
Chris@41 9499 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@41 9500 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@41 9501 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@41 9502 ;;
Chris@41 9503 esac
Chris@41 9504
Chris@41 9505 # move library search paths that coincide with paths to not yet
Chris@41 9506 # installed libraries to the beginning of the library search list
Chris@41 9507 new_libs=
Chris@41 9508 for path in $notinst_path; do
Chris@41 9509 case " $new_libs " in
Chris@41 9510 *" -L$path/$objdir "*) ;;
Chris@41 9511 *)
Chris@41 9512 case " $deplibs " in
Chris@41 9513 *" -L$path/$objdir "*)
Chris@41 9514 func_append new_libs " -L$path/$objdir" ;;
Chris@41 9515 esac
Chris@41 9516 ;;
Chris@41 9517 esac
Chris@41 9518 done
Chris@41 9519 for deplib in $deplibs; do
Chris@41 9520 case $deplib in
Chris@41 9521 -L*)
Chris@41 9522 case " $new_libs " in
Chris@41 9523 *" $deplib "*) ;;
Chris@41 9524 *) func_append new_libs " $deplib" ;;
Chris@41 9525 esac
Chris@41 9526 ;;
Chris@41 9527 *) func_append new_libs " $deplib" ;;
Chris@41 9528 esac
Chris@41 9529 done
Chris@41 9530 deplibs=$new_libs
Chris@41 9531
Chris@41 9532 # All the library-specific variables (install_libdir is set above).
Chris@41 9533 library_names=
Chris@41 9534 old_library=
Chris@41 9535 dlname=
Chris@41 9536
Chris@41 9537 # Test again, we may have decided not to build it any more
Chris@41 9538 if test yes = "$build_libtool_libs"; then
Chris@41 9539 # Remove $wl instances when linking with ld.
Chris@41 9540 # FIXME: should test the right _cmds variable.
Chris@41 9541 case $archive_cmds in
Chris@41 9542 *\$LD\ *) wl= ;;
Chris@41 9543 esac
Chris@41 9544 if test yes = "$hardcode_into_libs"; then
Chris@41 9545 # Hardcode the library paths
Chris@41 9546 hardcode_libdirs=
Chris@41 9547 dep_rpath=
Chris@41 9548 rpath=$finalize_rpath
Chris@41 9549 test relink = "$opt_mode" || rpath=$compile_rpath$rpath
Chris@41 9550 for libdir in $rpath; do
Chris@41 9551 if test -n "$hardcode_libdir_flag_spec"; then
Chris@41 9552 if test -n "$hardcode_libdir_separator"; then
Chris@41 9553 func_replace_sysroot "$libdir"
Chris@41 9554 libdir=$func_replace_sysroot_result
Chris@41 9555 if test -z "$hardcode_libdirs"; then
Chris@41 9556 hardcode_libdirs=$libdir
Chris@41 9557 else
Chris@41 9558 # Just accumulate the unique libdirs.
Chris@41 9559 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Chris@41 9560 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
Chris@41 9561 ;;
Chris@41 9562 *)
Chris@41 9563 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
Chris@41 9564 ;;
Chris@41 9565 esac
Chris@41 9566 fi
Chris@41 9567 else
Chris@41 9568 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@41 9569 func_append dep_rpath " $flag"
Chris@41 9570 fi
Chris@41 9571 elif test -n "$runpath_var"; then
Chris@41 9572 case "$perm_rpath " in
Chris@41 9573 *" $libdir "*) ;;
Chris@41 9574 *) func_append perm_rpath " $libdir" ;;
Chris@41 9575 esac
Chris@41 9576 fi
Chris@41 9577 done
Chris@41 9578 # Substitute the hardcoded libdirs into the rpath.
Chris@41 9579 if test -n "$hardcode_libdir_separator" &&
Chris@41 9580 test -n "$hardcode_libdirs"; then
Chris@41 9581 libdir=$hardcode_libdirs
Chris@41 9582 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
Chris@41 9583 fi
Chris@41 9584 if test -n "$runpath_var" && test -n "$perm_rpath"; then
Chris@41 9585 # We should set the runpath_var.
Chris@41 9586 rpath=
Chris@41 9587 for dir in $perm_rpath; do
Chris@41 9588 func_append rpath "$dir:"
Chris@41 9589 done
Chris@41 9590 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
Chris@41 9591 fi
Chris@41 9592 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
Chris@41 9593 fi
Chris@41 9594
Chris@41 9595 shlibpath=$finalize_shlibpath
Chris@41 9596 test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
Chris@41 9597 if test -n "$shlibpath"; then
Chris@41 9598 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
Chris@41 9599 fi
Chris@41 9600
Chris@41 9601 # Get the real and link names of the library.
Chris@41 9602 eval shared_ext=\"$shrext_cmds\"
Chris@41 9603 eval library_names=\"$library_names_spec\"
Chris@41 9604 set dummy $library_names
Chris@41 9605 shift
Chris@41 9606 realname=$1
Chris@41 9607 shift
Chris@41 9608
Chris@41 9609 if test -n "$soname_spec"; then
Chris@41 9610 eval soname=\"$soname_spec\"
Chris@41 9611 else
Chris@41 9612 soname=$realname
Chris@41 9613 fi
Chris@41 9614 if test -z "$dlname"; then
Chris@41 9615 dlname=$soname
Chris@41 9616 fi
Chris@41 9617
Chris@41 9618 lib=$output_objdir/$realname
Chris@41 9619 linknames=
Chris@41 9620 for link
Chris@41 9621 do
Chris@41 9622 func_append linknames " $link"
Chris@41 9623 done
Chris@41 9624
Chris@41 9625 # Use standard objects if they are pic
Chris@41 9626 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@41 9627 test "X$libobjs" = "X " && libobjs=
Chris@41 9628
Chris@41 9629 delfiles=
Chris@41 9630 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Chris@41 9631 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
Chris@41 9632 export_symbols=$output_objdir/$libname.uexp
Chris@41 9633 func_append delfiles " $export_symbols"
Chris@41 9634 fi
Chris@41 9635
Chris@41 9636 orig_export_symbols=
Chris@41 9637 case $host_os in
Chris@41 9638 cygwin* | mingw* | cegcc*)
Chris@41 9639 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
Chris@41 9640 # exporting using user supplied symfile
Chris@41 9641 func_dll_def_p "$export_symbols" || {
Chris@41 9642 # and it's NOT already a .def file. Must figure out
Chris@41 9643 # which of the given symbols are data symbols and tag
Chris@41 9644 # them as such. So, trigger use of export_symbols_cmds.
Chris@41 9645 # export_symbols gets reassigned inside the "prepare
Chris@41 9646 # the list of exported symbols" if statement, so the
Chris@41 9647 # include_expsyms logic still works.
Chris@41 9648 orig_export_symbols=$export_symbols
Chris@41 9649 export_symbols=
Chris@41 9650 always_export_symbols=yes
Chris@41 9651 }
Chris@41 9652 fi
Chris@41 9653 ;;
Chris@41 9654 esac
Chris@41 9655
Chris@41 9656 # Prepare the list of exported symbols
Chris@41 9657 if test -z "$export_symbols"; then
Chris@41 9658 if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
Chris@41 9659 func_verbose "generating symbol list for '$libname.la'"
Chris@41 9660 export_symbols=$output_objdir/$libname.exp
Chris@41 9661 $opt_dry_run || $RM $export_symbols
Chris@41 9662 cmds=$export_symbols_cmds
Chris@41 9663 save_ifs=$IFS; IFS='~'
Chris@41 9664 for cmd1 in $cmds; do
Chris@41 9665 IFS=$save_ifs
Chris@41 9666 # Take the normal branch if the nm_file_list_spec branch
Chris@41 9667 # doesn't work or if tool conversion is not needed.
Chris@41 9668 case $nm_file_list_spec~$to_tool_file_cmd in
Chris@41 9669 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
Chris@41 9670 try_normal_branch=yes
Chris@41 9671 eval cmd=\"$cmd1\"
Chris@41 9672 func_len " $cmd"
Chris@41 9673 len=$func_len_result
Chris@41 9674 ;;
Chris@41 9675 *)
Chris@41 9676 try_normal_branch=no
Chris@41 9677 ;;
Chris@41 9678 esac
Chris@41 9679 if test yes = "$try_normal_branch" \
Chris@41 9680 && { test "$len" -lt "$max_cmd_len" \
Chris@41 9681 || test "$max_cmd_len" -le -1; }
Chris@41 9682 then
Chris@41 9683 func_show_eval "$cmd" 'exit $?'
Chris@41 9684 skipped_export=false
Chris@41 9685 elif test -n "$nm_file_list_spec"; then
Chris@41 9686 func_basename "$output"
Chris@41 9687 output_la=$func_basename_result
Chris@41 9688 save_libobjs=$libobjs
Chris@41 9689 save_output=$output
Chris@41 9690 output=$output_objdir/$output_la.nm
Chris@41 9691 func_to_tool_file "$output"
Chris@41 9692 libobjs=$nm_file_list_spec$func_to_tool_file_result
Chris@41 9693 func_append delfiles " $output"
Chris@41 9694 func_verbose "creating $NM input file list: $output"
Chris@41 9695 for obj in $save_libobjs; do
Chris@41 9696 func_to_tool_file "$obj"
Chris@41 9697 $ECHO "$func_to_tool_file_result"
Chris@41 9698 done > "$output"
Chris@41 9699 eval cmd=\"$cmd1\"
Chris@41 9700 func_show_eval "$cmd" 'exit $?'
Chris@41 9701 output=$save_output
Chris@41 9702 libobjs=$save_libobjs
Chris@41 9703 skipped_export=false
Chris@41 9704 else
Chris@41 9705 # The command line is too long to execute in one step.
Chris@41 9706 func_verbose "using reloadable object file for export list..."
Chris@41 9707 skipped_export=:
Chris@41 9708 # Break out early, otherwise skipped_export may be
Chris@41 9709 # set to false by a later but shorter cmd.
Chris@41 9710 break
Chris@41 9711 fi
Chris@41 9712 done
Chris@41 9713 IFS=$save_ifs
Chris@41 9714 if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
Chris@41 9715 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
Chris@41 9716 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
Chris@41 9717 fi
Chris@41 9718 fi
Chris@41 9719 fi
Chris@41 9720
Chris@41 9721 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Chris@41 9722 tmp_export_symbols=$export_symbols
Chris@41 9723 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
Chris@41 9724 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
Chris@41 9725 fi
Chris@41 9726
Chris@41 9727 if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
Chris@41 9728 # The given exports_symbols file has to be filtered, so filter it.
Chris@41 9729 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
Chris@41 9730 # FIXME: $output_objdir/$libname.filter potentially contains lots of
Chris@41 9731 # 's' commands, which not all seds can handle. GNU sed should be fine
Chris@41 9732 # though. Also, the filter scales superlinearly with the number of
Chris@41 9733 # global variables. join(1) would be nice here, but unfortunately
Chris@41 9734 # isn't a blessed tool.
Chris@41 9735 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
Chris@41 9736 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
Chris@41 9737 export_symbols=$output_objdir/$libname.def
Chris@41 9738 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
Chris@41 9739 fi
Chris@41 9740
Chris@41 9741 tmp_deplibs=
Chris@41 9742 for test_deplib in $deplibs; do
Chris@41 9743 case " $convenience " in
Chris@41 9744 *" $test_deplib "*) ;;
Chris@41 9745 *)
Chris@41 9746 func_append tmp_deplibs " $test_deplib"
Chris@41 9747 ;;
Chris@41 9748 esac
Chris@41 9749 done
Chris@41 9750 deplibs=$tmp_deplibs
Chris@41 9751
Chris@41 9752 if test -n "$convenience"; then
Chris@41 9753 if test -n "$whole_archive_flag_spec" &&
Chris@41 9754 test yes = "$compiler_needs_object" &&
Chris@41 9755 test -z "$libobjs"; then
Chris@41 9756 # extract the archives, so we have objects to list.
Chris@41 9757 # TODO: could optimize this to just extract one archive.
Chris@41 9758 whole_archive_flag_spec=
Chris@41 9759 fi
Chris@41 9760 if test -n "$whole_archive_flag_spec"; then
Chris@41 9761 save_libobjs=$libobjs
Chris@41 9762 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
Chris@41 9763 test "X$libobjs" = "X " && libobjs=
Chris@41 9764 else
Chris@41 9765 gentop=$output_objdir/${outputname}x
Chris@41 9766 func_append generated " $gentop"
Chris@41 9767
Chris@41 9768 func_extract_archives $gentop $convenience
Chris@41 9769 func_append libobjs " $func_extract_archives_result"
Chris@41 9770 test "X$libobjs" = "X " && libobjs=
Chris@41 9771 fi
Chris@41 9772 fi
Chris@41 9773
Chris@41 9774 if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
Chris@41 9775 eval flag=\"$thread_safe_flag_spec\"
Chris@41 9776 func_append linker_flags " $flag"
Chris@41 9777 fi
Chris@41 9778
Chris@41 9779 # Make a backup of the uninstalled library when relinking
Chris@41 9780 if test relink = "$opt_mode"; then
Chris@41 9781 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
Chris@41 9782 fi
Chris@41 9783
Chris@41 9784 # Do each of the archive commands.
Chris@41 9785 if test yes = "$module" && test -n "$module_cmds"; then
Chris@41 9786 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
Chris@41 9787 eval test_cmds=\"$module_expsym_cmds\"
Chris@41 9788 cmds=$module_expsym_cmds
Chris@41 9789 else
Chris@41 9790 eval test_cmds=\"$module_cmds\"
Chris@41 9791 cmds=$module_cmds
Chris@41 9792 fi
Chris@41 9793 else
Chris@41 9794 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
Chris@41 9795 eval test_cmds=\"$archive_expsym_cmds\"
Chris@41 9796 cmds=$archive_expsym_cmds
Chris@41 9797 else
Chris@41 9798 eval test_cmds=\"$archive_cmds\"
Chris@41 9799 cmds=$archive_cmds
Chris@41 9800 fi
Chris@41 9801 fi
Chris@41 9802
Chris@41 9803 if test : != "$skipped_export" &&
Chris@41 9804 func_len " $test_cmds" &&
Chris@41 9805 len=$func_len_result &&
Chris@41 9806 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
Chris@41 9807 :
Chris@41 9808 else
Chris@41 9809 # The command line is too long to link in one step, link piecewise
Chris@41 9810 # or, if using GNU ld and skipped_export is not :, use a linker
Chris@41 9811 # script.
Chris@41 9812
Chris@41 9813 # Save the value of $output and $libobjs because we want to
Chris@41 9814 # use them later. If we have whole_archive_flag_spec, we
Chris@41 9815 # want to use save_libobjs as it was before
Chris@41 9816 # whole_archive_flag_spec was expanded, because we can't
Chris@41 9817 # assume the linker understands whole_archive_flag_spec.
Chris@41 9818 # This may have to be revisited, in case too many
Chris@41 9819 # convenience libraries get linked in and end up exceeding
Chris@41 9820 # the spec.
Chris@41 9821 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
Chris@41 9822 save_libobjs=$libobjs
Chris@41 9823 fi
Chris@41 9824 save_output=$output
Chris@41 9825 func_basename "$output"
Chris@41 9826 output_la=$func_basename_result
Chris@41 9827
Chris@41 9828 # Clear the reloadable object creation command queue and
Chris@41 9829 # initialize k to one.
Chris@41 9830 test_cmds=
Chris@41 9831 concat_cmds=
Chris@41 9832 objlist=
Chris@41 9833 last_robj=
Chris@41 9834 k=1
Chris@41 9835
Chris@41 9836 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
Chris@41 9837 output=$output_objdir/$output_la.lnkscript
Chris@41 9838 func_verbose "creating GNU ld script: $output"
Chris@41 9839 echo 'INPUT (' > $output
Chris@41 9840 for obj in $save_libobjs
Chris@41 9841 do
Chris@41 9842 func_to_tool_file "$obj"
Chris@41 9843 $ECHO "$func_to_tool_file_result" >> $output
Chris@41 9844 done
Chris@41 9845 echo ')' >> $output
Chris@41 9846 func_append delfiles " $output"
Chris@41 9847 func_to_tool_file "$output"
Chris@41 9848 output=$func_to_tool_file_result
Chris@41 9849 elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
Chris@41 9850 output=$output_objdir/$output_la.lnk
Chris@41 9851 func_verbose "creating linker input file list: $output"
Chris@41 9852 : > $output
Chris@41 9853 set x $save_libobjs
Chris@41 9854 shift
Chris@41 9855 firstobj=
Chris@41 9856 if test yes = "$compiler_needs_object"; then
Chris@41 9857 firstobj="$1 "
Chris@41 9858 shift
Chris@41 9859 fi
Chris@41 9860 for obj
Chris@41 9861 do
Chris@41 9862 func_to_tool_file "$obj"
Chris@41 9863 $ECHO "$func_to_tool_file_result" >> $output
Chris@41 9864 done
Chris@41 9865 func_append delfiles " $output"
Chris@41 9866 func_to_tool_file "$output"
Chris@41 9867 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
Chris@41 9868 else
Chris@41 9869 if test -n "$save_libobjs"; then
Chris@41 9870 func_verbose "creating reloadable object files..."
Chris@41 9871 output=$output_objdir/$output_la-$k.$objext
Chris@41 9872 eval test_cmds=\"$reload_cmds\"
Chris@41 9873 func_len " $test_cmds"
Chris@41 9874 len0=$func_len_result
Chris@41 9875 len=$len0
Chris@41 9876
Chris@41 9877 # Loop over the list of objects to be linked.
Chris@41 9878 for obj in $save_libobjs
Chris@41 9879 do
Chris@41 9880 func_len " $obj"
Chris@41 9881 func_arith $len + $func_len_result
Chris@41 9882 len=$func_arith_result
Chris@41 9883 if test -z "$objlist" ||
Chris@41 9884 test "$len" -lt "$max_cmd_len"; then
Chris@41 9885 func_append objlist " $obj"
Chris@41 9886 else
Chris@41 9887 # The command $test_cmds is almost too long, add a
Chris@41 9888 # command to the queue.
Chris@41 9889 if test 1 -eq "$k"; then
Chris@41 9890 # The first file doesn't have a previous command to add.
Chris@41 9891 reload_objs=$objlist
Chris@41 9892 eval concat_cmds=\"$reload_cmds\"
Chris@41 9893 else
Chris@41 9894 # All subsequent reloadable object files will link in
Chris@41 9895 # the last one created.
Chris@41 9896 reload_objs="$objlist $last_robj"
Chris@41 9897 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
Chris@41 9898 fi
Chris@41 9899 last_robj=$output_objdir/$output_la-$k.$objext
Chris@41 9900 func_arith $k + 1
Chris@41 9901 k=$func_arith_result
Chris@41 9902 output=$output_objdir/$output_la-$k.$objext
Chris@41 9903 objlist=" $obj"
Chris@41 9904 func_len " $last_robj"
Chris@41 9905 func_arith $len0 + $func_len_result
Chris@41 9906 len=$func_arith_result
Chris@41 9907 fi
Chris@41 9908 done
Chris@41 9909 # Handle the remaining objects by creating one last
Chris@41 9910 # reloadable object file. All subsequent reloadable object
Chris@41 9911 # files will link in the last one created.
Chris@41 9912 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Chris@41 9913 reload_objs="$objlist $last_robj"
Chris@41 9914 eval concat_cmds=\"\$concat_cmds$reload_cmds\"
Chris@41 9915 if test -n "$last_robj"; then
Chris@41 9916 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
Chris@41 9917 fi
Chris@41 9918 func_append delfiles " $output"
Chris@41 9919
Chris@41 9920 else
Chris@41 9921 output=
Chris@41 9922 fi
Chris@41 9923
Chris@41 9924 ${skipped_export-false} && {
Chris@41 9925 func_verbose "generating symbol list for '$libname.la'"
Chris@41 9926 export_symbols=$output_objdir/$libname.exp
Chris@41 9927 $opt_dry_run || $RM $export_symbols
Chris@41 9928 libobjs=$output
Chris@41 9929 # Append the command to create the export file.
Chris@41 9930 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Chris@41 9931 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
Chris@41 9932 if test -n "$last_robj"; then
Chris@41 9933 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
Chris@41 9934 fi
Chris@41 9935 }
Chris@41 9936
Chris@41 9937 test -n "$save_libobjs" &&
Chris@41 9938 func_verbose "creating a temporary reloadable object file: $output"
Chris@41 9939
Chris@41 9940 # Loop through the commands generated above and execute them.
Chris@41 9941 save_ifs=$IFS; IFS='~'
Chris@41 9942 for cmd in $concat_cmds; do
Chris@41 9943 IFS=$save_ifs
Chris@41 9944 $opt_quiet || {
Chris@41 9945 func_quote_for_expand "$cmd"
Chris@41 9946 eval "func_echo $func_quote_for_expand_result"
Chris@41 9947 }
Chris@41 9948 $opt_dry_run || eval "$cmd" || {
Chris@41 9949 lt_exit=$?
Chris@41 9950
Chris@41 9951 # Restore the uninstalled library and exit
Chris@41 9952 if test relink = "$opt_mode"; then
Chris@41 9953 ( cd "$output_objdir" && \
Chris@41 9954 $RM "${realname}T" && \
Chris@41 9955 $MV "${realname}U" "$realname" )
Chris@41 9956 fi
Chris@41 9957
Chris@41 9958 exit $lt_exit
Chris@41 9959 }
Chris@41 9960 done
Chris@41 9961 IFS=$save_ifs
Chris@41 9962
Chris@41 9963 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
Chris@41 9964 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
Chris@41 9965 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
Chris@41 9966 fi
Chris@41 9967 fi
Chris@41 9968
Chris@41 9969 ${skipped_export-false} && {
Chris@41 9970 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Chris@41 9971 tmp_export_symbols=$export_symbols
Chris@41 9972 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
Chris@41 9973 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
Chris@41 9974 fi
Chris@41 9975
Chris@41 9976 if test -n "$orig_export_symbols"; then
Chris@41 9977 # The given exports_symbols file has to be filtered, so filter it.
Chris@41 9978 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
Chris@41 9979 # FIXME: $output_objdir/$libname.filter potentially contains lots of
Chris@41 9980 # 's' commands, which not all seds can handle. GNU sed should be fine
Chris@41 9981 # though. Also, the filter scales superlinearly with the number of
Chris@41 9982 # global variables. join(1) would be nice here, but unfortunately
Chris@41 9983 # isn't a blessed tool.
Chris@41 9984 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
Chris@41 9985 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
Chris@41 9986 export_symbols=$output_objdir/$libname.def
Chris@41 9987 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
Chris@41 9988 fi
Chris@41 9989 }
Chris@41 9990
Chris@41 9991 libobjs=$output
Chris@41 9992 # Restore the value of output.
Chris@41 9993 output=$save_output
Chris@41 9994
Chris@41 9995 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
Chris@41 9996 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
Chris@41 9997 test "X$libobjs" = "X " && libobjs=
Chris@41 9998 fi
Chris@41 9999 # Expand the library linking commands again to reset the
Chris@41 10000 # value of $libobjs for piecewise linking.
Chris@41 10001
Chris@41 10002 # Do each of the archive commands.
Chris@41 10003 if test yes = "$module" && test -n "$module_cmds"; then
Chris@41 10004 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
Chris@41 10005 cmds=$module_expsym_cmds
Chris@41 10006 else
Chris@41 10007 cmds=$module_cmds
Chris@41 10008 fi
Chris@41 10009 else
Chris@41 10010 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
Chris@41 10011 cmds=$archive_expsym_cmds
Chris@41 10012 else
Chris@41 10013 cmds=$archive_cmds
Chris@41 10014 fi
Chris@41 10015 fi
Chris@41 10016 fi
Chris@41 10017
Chris@41 10018 if test -n "$delfiles"; then
Chris@41 10019 # Append the command to remove temporary files to $cmds.
Chris@41 10020 eval cmds=\"\$cmds~\$RM $delfiles\"
Chris@41 10021 fi
Chris@41 10022
Chris@41 10023 # Add any objects from preloaded convenience libraries
Chris@41 10024 if test -n "$dlprefiles"; then
Chris@41 10025 gentop=$output_objdir/${outputname}x
Chris@41 10026 func_append generated " $gentop"
Chris@41 10027
Chris@41 10028 func_extract_archives $gentop $dlprefiles
Chris@41 10029 func_append libobjs " $func_extract_archives_result"
Chris@41 10030 test "X$libobjs" = "X " && libobjs=
Chris@41 10031 fi
Chris@41 10032
Chris@41 10033 save_ifs=$IFS; IFS='~'
Chris@41 10034 for cmd in $cmds; do
Chris@41 10035 IFS=$sp$nl
Chris@41 10036 eval cmd=\"$cmd\"
Chris@41 10037 IFS=$save_ifs
Chris@41 10038 $opt_quiet || {
Chris@41 10039 func_quote_for_expand "$cmd"
Chris@41 10040 eval "func_echo $func_quote_for_expand_result"
Chris@41 10041 }
Chris@41 10042 $opt_dry_run || eval "$cmd" || {
Chris@41 10043 lt_exit=$?
Chris@41 10044
Chris@41 10045 # Restore the uninstalled library and exit
Chris@41 10046 if test relink = "$opt_mode"; then
Chris@41 10047 ( cd "$output_objdir" && \
Chris@41 10048 $RM "${realname}T" && \
Chris@41 10049 $MV "${realname}U" "$realname" )
Chris@41 10050 fi
Chris@41 10051
Chris@41 10052 exit $lt_exit
Chris@41 10053 }
Chris@41 10054 done
Chris@41 10055 IFS=$save_ifs
Chris@41 10056
Chris@41 10057 # Restore the uninstalled library and exit
Chris@41 10058 if test relink = "$opt_mode"; then
Chris@41 10059 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
Chris@41 10060
Chris@41 10061 if test -n "$convenience"; then
Chris@41 10062 if test -z "$whole_archive_flag_spec"; then
Chris@41 10063 func_show_eval '${RM}r "$gentop"'
Chris@41 10064 fi
Chris@41 10065 fi
Chris@41 10066
Chris@41 10067 exit $EXIT_SUCCESS
Chris@41 10068 fi
Chris@41 10069
Chris@41 10070 # Create links to the real library.
Chris@41 10071 for linkname in $linknames; do
Chris@41 10072 if test "$realname" != "$linkname"; then
Chris@41 10073 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
Chris@41 10074 fi
Chris@41 10075 done
Chris@41 10076
Chris@41 10077 # If -module or -export-dynamic was specified, set the dlname.
Chris@41 10078 if test yes = "$module" || test yes = "$export_dynamic"; then
Chris@41 10079 # On all known operating systems, these are identical.
Chris@41 10080 dlname=$soname
Chris@41 10081 fi
Chris@41 10082 fi
Chris@41 10083 ;;
Chris@41 10084
Chris@41 10085 obj)
Chris@41 10086 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
Chris@41 10087 func_warning "'-dlopen' is ignored for objects"
Chris@41 10088 fi
Chris@41 10089
Chris@41 10090 case " $deplibs" in
Chris@41 10091 *\ -l* | *\ -L*)
Chris@41 10092 func_warning "'-l' and '-L' are ignored for objects" ;;
Chris@41 10093 esac
Chris@41 10094
Chris@41 10095 test -n "$rpath" && \
Chris@41 10096 func_warning "'-rpath' is ignored for objects"
Chris@41 10097
Chris@41 10098 test -n "$xrpath" && \
Chris@41 10099 func_warning "'-R' is ignored for objects"
Chris@41 10100
Chris@41 10101 test -n "$vinfo" && \
Chris@41 10102 func_warning "'-version-info' is ignored for objects"
Chris@41 10103
Chris@41 10104 test -n "$release" && \
Chris@41 10105 func_warning "'-release' is ignored for objects"
Chris@41 10106
Chris@41 10107 case $output in
Chris@41 10108 *.lo)
Chris@41 10109 test -n "$objs$old_deplibs" && \
Chris@41 10110 func_fatal_error "cannot build library object '$output' from non-libtool objects"
Chris@41 10111
Chris@41 10112 libobj=$output
Chris@41 10113 func_lo2o "$libobj"
Chris@41 10114 obj=$func_lo2o_result
Chris@41 10115 ;;
Chris@41 10116 *)
Chris@41 10117 libobj=
Chris@41 10118 obj=$output
Chris@41 10119 ;;
Chris@41 10120 esac
Chris@41 10121
Chris@41 10122 # Delete the old objects.
Chris@41 10123 $opt_dry_run || $RM $obj $libobj
Chris@41 10124
Chris@41 10125 # Objects from convenience libraries. This assumes
Chris@41 10126 # single-version convenience libraries. Whenever we create
Chris@41 10127 # different ones for PIC/non-PIC, this we'll have to duplicate
Chris@41 10128 # the extraction.
Chris@41 10129 reload_conv_objs=
Chris@41 10130 gentop=
Chris@41 10131 # if reload_cmds runs $LD directly, get rid of -Wl from
Chris@41 10132 # whole_archive_flag_spec and hope we can get by with turning comma
Chris@41 10133 # into space.
Chris@41 10134 case $reload_cmds in
Chris@41 10135 *\$LD[\ \$]*) wl= ;;
Chris@41 10136 esac
Chris@41 10137 if test -n "$convenience"; then
Chris@41 10138 if test -n "$whole_archive_flag_spec"; then
Chris@41 10139 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
Chris@41 10140 test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
Chris@41 10141 reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
Chris@41 10142 else
Chris@41 10143 gentop=$output_objdir/${obj}x
Chris@41 10144 func_append generated " $gentop"
Chris@41 10145
Chris@41 10146 func_extract_archives $gentop $convenience
Chris@41 10147 reload_conv_objs="$reload_objs $func_extract_archives_result"
Chris@41 10148 fi
Chris@41 10149 fi
Chris@41 10150
Chris@41 10151 # If we're not building shared, we need to use non_pic_objs
Chris@41 10152 test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
Chris@41 10153
Chris@41 10154 # Create the old-style object.
Chris@41 10155 reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
Chris@41 10156
Chris@41 10157 output=$obj
Chris@41 10158 func_execute_cmds "$reload_cmds" 'exit $?'
Chris@41 10159
Chris@41 10160 # Exit if we aren't doing a library object file.
Chris@41 10161 if test -z "$libobj"; then
Chris@41 10162 if test -n "$gentop"; then
Chris@41 10163 func_show_eval '${RM}r "$gentop"'
Chris@41 10164 fi
Chris@41 10165
Chris@41 10166 exit $EXIT_SUCCESS
Chris@41 10167 fi
Chris@41 10168
Chris@41 10169 test yes = "$build_libtool_libs" || {
Chris@41 10170 if test -n "$gentop"; then
Chris@41 10171 func_show_eval '${RM}r "$gentop"'
Chris@41 10172 fi
Chris@41 10173
Chris@41 10174 # Create an invalid libtool object if no PIC, so that we don't
Chris@41 10175 # accidentally link it into a program.
Chris@41 10176 # $show "echo timestamp > $libobj"
Chris@41 10177 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
Chris@41 10178 exit $EXIT_SUCCESS
Chris@41 10179 }
Chris@41 10180
Chris@41 10181 if test -n "$pic_flag" || test default != "$pic_mode"; then
Chris@41 10182 # Only do commands if we really have different PIC objects.
Chris@41 10183 reload_objs="$libobjs $reload_conv_objs"
Chris@41 10184 output=$libobj
Chris@41 10185 func_execute_cmds "$reload_cmds" 'exit $?'
Chris@41 10186 fi
Chris@41 10187
Chris@41 10188 if test -n "$gentop"; then
Chris@41 10189 func_show_eval '${RM}r "$gentop"'
Chris@41 10190 fi
Chris@41 10191
Chris@41 10192 exit $EXIT_SUCCESS
Chris@41 10193 ;;
Chris@41 10194
Chris@41 10195 prog)
Chris@41 10196 case $host in
Chris@41 10197 *cygwin*) func_stripname '' '.exe' "$output"
Chris@41 10198 output=$func_stripname_result.exe;;
Chris@41 10199 esac
Chris@41 10200 test -n "$vinfo" && \
Chris@41 10201 func_warning "'-version-info' is ignored for programs"
Chris@41 10202
Chris@41 10203 test -n "$release" && \
Chris@41 10204 func_warning "'-release' is ignored for programs"
Chris@41 10205
Chris@41 10206 $preload \
Chris@41 10207 && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
Chris@41 10208 && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
Chris@41 10209
Chris@41 10210 case $host in
Chris@41 10211 *-*-rhapsody* | *-*-darwin1.[012])
Chris@41 10212 # On Rhapsody replace the C library is the System framework
Chris@41 10213 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
Chris@41 10214 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
Chris@41 10215 ;;
Chris@41 10216 esac
Chris@41 10217
Chris@41 10218 case $host in
Chris@41 10219 *-*-darwin*)
Chris@41 10220 # Don't allow lazy linking, it breaks C++ global constructors
Chris@41 10221 # But is supposedly fixed on 10.4 or later (yay!).
Chris@41 10222 if test CXX = "$tagname"; then
Chris@41 10223 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
Chris@41 10224 10.[0123])
Chris@41 10225 func_append compile_command " $wl-bind_at_load"
Chris@41 10226 func_append finalize_command " $wl-bind_at_load"
Chris@41 10227 ;;
Chris@41 10228 esac
Chris@41 10229 fi
Chris@41 10230 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
Chris@41 10231 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@41 10232 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@41 10233 ;;
Chris@41 10234 esac
Chris@41 10235
Chris@41 10236
Chris@41 10237 # move library search paths that coincide with paths to not yet
Chris@41 10238 # installed libraries to the beginning of the library search list
Chris@41 10239 new_libs=
Chris@41 10240 for path in $notinst_path; do
Chris@41 10241 case " $new_libs " in
Chris@41 10242 *" -L$path/$objdir "*) ;;
Chris@41 10243 *)
Chris@41 10244 case " $compile_deplibs " in
Chris@41 10245 *" -L$path/$objdir "*)
Chris@41 10246 func_append new_libs " -L$path/$objdir" ;;
Chris@41 10247 esac
Chris@41 10248 ;;
Chris@41 10249 esac
Chris@41 10250 done
Chris@41 10251 for deplib in $compile_deplibs; do
Chris@41 10252 case $deplib in
Chris@41 10253 -L*)
Chris@41 10254 case " $new_libs " in
Chris@41 10255 *" $deplib "*) ;;
Chris@41 10256 *) func_append new_libs " $deplib" ;;
Chris@41 10257 esac
Chris@41 10258 ;;
Chris@41 10259 *) func_append new_libs " $deplib" ;;
Chris@41 10260 esac
Chris@41 10261 done
Chris@41 10262 compile_deplibs=$new_libs
Chris@41 10263
Chris@41 10264
Chris@41 10265 func_append compile_command " $compile_deplibs"
Chris@41 10266 func_append finalize_command " $finalize_deplibs"
Chris@41 10267
Chris@41 10268 if test -n "$rpath$xrpath"; then
Chris@41 10269 # If the user specified any rpath flags, then add them.
Chris@41 10270 for libdir in $rpath $xrpath; do
Chris@41 10271 # This is the magic to use -rpath.
Chris@41 10272 case "$finalize_rpath " in
Chris@41 10273 *" $libdir "*) ;;
Chris@41 10274 *) func_append finalize_rpath " $libdir" ;;
Chris@41 10275 esac
Chris@41 10276 done
Chris@41 10277 fi
Chris@41 10278
Chris@41 10279 # Now hardcode the library paths
Chris@41 10280 rpath=
Chris@41 10281 hardcode_libdirs=
Chris@41 10282 for libdir in $compile_rpath $finalize_rpath; do
Chris@41 10283 if test -n "$hardcode_libdir_flag_spec"; then
Chris@41 10284 if test -n "$hardcode_libdir_separator"; then
Chris@41 10285 if test -z "$hardcode_libdirs"; then
Chris@41 10286 hardcode_libdirs=$libdir
Chris@41 10287 else
Chris@41 10288 # Just accumulate the unique libdirs.
Chris@41 10289 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Chris@41 10290 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
Chris@41 10291 ;;
Chris@41 10292 *)
Chris@41 10293 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
Chris@41 10294 ;;
Chris@41 10295 esac
Chris@41 10296 fi
Chris@41 10297 else
Chris@41 10298 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@41 10299 func_append rpath " $flag"
Chris@41 10300 fi
Chris@41 10301 elif test -n "$runpath_var"; then
Chris@41 10302 case "$perm_rpath " in
Chris@41 10303 *" $libdir "*) ;;
Chris@41 10304 *) func_append perm_rpath " $libdir" ;;
Chris@41 10305 esac
Chris@41 10306 fi
Chris@41 10307 case $host in
Chris@41 10308 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
Chris@41 10309 testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
Chris@41 10310 case :$dllsearchpath: in
Chris@41 10311 *":$libdir:"*) ;;
Chris@41 10312 ::) dllsearchpath=$libdir;;
Chris@41 10313 *) func_append dllsearchpath ":$libdir";;
Chris@41 10314 esac
Chris@41 10315 case :$dllsearchpath: in
Chris@41 10316 *":$testbindir:"*) ;;
Chris@41 10317 ::) dllsearchpath=$testbindir;;
Chris@41 10318 *) func_append dllsearchpath ":$testbindir";;
Chris@41 10319 esac
Chris@41 10320 ;;
Chris@41 10321 esac
Chris@41 10322 done
Chris@41 10323 # Substitute the hardcoded libdirs into the rpath.
Chris@41 10324 if test -n "$hardcode_libdir_separator" &&
Chris@41 10325 test -n "$hardcode_libdirs"; then
Chris@41 10326 libdir=$hardcode_libdirs
Chris@41 10327 eval rpath=\" $hardcode_libdir_flag_spec\"
Chris@41 10328 fi
Chris@41 10329 compile_rpath=$rpath
Chris@41 10330
Chris@41 10331 rpath=
Chris@41 10332 hardcode_libdirs=
Chris@41 10333 for libdir in $finalize_rpath; do
Chris@41 10334 if test -n "$hardcode_libdir_flag_spec"; then
Chris@41 10335 if test -n "$hardcode_libdir_separator"; then
Chris@41 10336 if test -z "$hardcode_libdirs"; then
Chris@41 10337 hardcode_libdirs=$libdir
Chris@41 10338 else
Chris@41 10339 # Just accumulate the unique libdirs.
Chris@41 10340 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Chris@41 10341 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
Chris@41 10342 ;;
Chris@41 10343 *)
Chris@41 10344 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
Chris@41 10345 ;;
Chris@41 10346 esac
Chris@41 10347 fi
Chris@41 10348 else
Chris@41 10349 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@41 10350 func_append rpath " $flag"
Chris@41 10351 fi
Chris@41 10352 elif test -n "$runpath_var"; then
Chris@41 10353 case "$finalize_perm_rpath " in
Chris@41 10354 *" $libdir "*) ;;
Chris@41 10355 *) func_append finalize_perm_rpath " $libdir" ;;
Chris@41 10356 esac
Chris@41 10357 fi
Chris@41 10358 done
Chris@41 10359 # Substitute the hardcoded libdirs into the rpath.
Chris@41 10360 if test -n "$hardcode_libdir_separator" &&
Chris@41 10361 test -n "$hardcode_libdirs"; then
Chris@41 10362 libdir=$hardcode_libdirs
Chris@41 10363 eval rpath=\" $hardcode_libdir_flag_spec\"
Chris@41 10364 fi
Chris@41 10365 finalize_rpath=$rpath
Chris@41 10366
Chris@41 10367 if test -n "$libobjs" && test yes = "$build_old_libs"; then
Chris@41 10368 # Transform all the library objects into standard objects.
Chris@41 10369 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@41 10370 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@41 10371 fi
Chris@41 10372
Chris@41 10373 func_generate_dlsyms "$outputname" "@PROGRAM@" false
Chris@41 10374
Chris@41 10375 # template prelinking step
Chris@41 10376 if test -n "$prelink_cmds"; then
Chris@41 10377 func_execute_cmds "$prelink_cmds" 'exit $?'
Chris@41 10378 fi
Chris@41 10379
Chris@41 10380 wrappers_required=:
Chris@41 10381 case $host in
Chris@41 10382 *cegcc* | *mingw32ce*)
Chris@41 10383 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
Chris@41 10384 wrappers_required=false
Chris@41 10385 ;;
Chris@41 10386 *cygwin* | *mingw* )
Chris@41 10387 test yes = "$build_libtool_libs" || wrappers_required=false
Chris@41 10388 ;;
Chris@41 10389 *)
Chris@41 10390 if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
Chris@41 10391 wrappers_required=false
Chris@41 10392 fi
Chris@41 10393 ;;
Chris@41 10394 esac
Chris@41 10395 $wrappers_required || {
Chris@41 10396 # Replace the output file specification.
Chris@41 10397 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
Chris@41 10398 link_command=$compile_command$compile_rpath
Chris@41 10399
Chris@41 10400 # We have no uninstalled library dependencies, so finalize right now.
Chris@41 10401 exit_status=0
Chris@41 10402 func_show_eval "$link_command" 'exit_status=$?'
Chris@41 10403
Chris@41 10404 if test -n "$postlink_cmds"; then
Chris@41 10405 func_to_tool_file "$output"
Chris@41 10406 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
Chris@41 10407 func_execute_cmds "$postlink_cmds" 'exit $?'
Chris@41 10408 fi
Chris@41 10409
Chris@41 10410 # Delete the generated files.
Chris@41 10411 if test -f "$output_objdir/${outputname}S.$objext"; then
Chris@41 10412 func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
Chris@41 10413 fi
Chris@41 10414
Chris@41 10415 exit $exit_status
Chris@41 10416 }
Chris@41 10417
Chris@41 10418 if test -n "$compile_shlibpath$finalize_shlibpath"; then
Chris@41 10419 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
Chris@41 10420 fi
Chris@41 10421 if test -n "$finalize_shlibpath"; then
Chris@41 10422 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
Chris@41 10423 fi
Chris@41 10424
Chris@41 10425 compile_var=
Chris@41 10426 finalize_var=
Chris@41 10427 if test -n "$runpath_var"; then
Chris@41 10428 if test -n "$perm_rpath"; then
Chris@41 10429 # We should set the runpath_var.
Chris@41 10430 rpath=
Chris@41 10431 for dir in $perm_rpath; do
Chris@41 10432 func_append rpath "$dir:"
Chris@41 10433 done
Chris@41 10434 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
Chris@41 10435 fi
Chris@41 10436 if test -n "$finalize_perm_rpath"; then
Chris@41 10437 # We should set the runpath_var.
Chris@41 10438 rpath=
Chris@41 10439 for dir in $finalize_perm_rpath; do
Chris@41 10440 func_append rpath "$dir:"
Chris@41 10441 done
Chris@41 10442 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
Chris@41 10443 fi
Chris@41 10444 fi
Chris@41 10445
Chris@41 10446 if test yes = "$no_install"; then
Chris@41 10447 # We don't need to create a wrapper script.
Chris@41 10448 link_command=$compile_var$compile_command$compile_rpath
Chris@41 10449 # Replace the output file specification.
Chris@41 10450 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
Chris@41 10451 # Delete the old output file.
Chris@41 10452 $opt_dry_run || $RM $output
Chris@41 10453 # Link the executable and exit
Chris@41 10454 func_show_eval "$link_command" 'exit $?'
Chris@41 10455
Chris@41 10456 if test -n "$postlink_cmds"; then
Chris@41 10457 func_to_tool_file "$output"
Chris@41 10458 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
Chris@41 10459 func_execute_cmds "$postlink_cmds" 'exit $?'
Chris@41 10460 fi
Chris@41 10461
Chris@41 10462 exit $EXIT_SUCCESS
Chris@41 10463 fi
Chris@41 10464
Chris@41 10465 case $hardcode_action,$fast_install in
Chris@41 10466 relink,*)
Chris@41 10467 # Fast installation is not supported
Chris@41 10468 link_command=$compile_var$compile_command$compile_rpath
Chris@41 10469 relink_command=$finalize_var$finalize_command$finalize_rpath
Chris@41 10470
Chris@41 10471 func_warning "this platform does not like uninstalled shared libraries"
Chris@41 10472 func_warning "'$output' will be relinked during installation"
Chris@41 10473 ;;
Chris@41 10474 *,yes)
Chris@41 10475 link_command=$finalize_var$compile_command$finalize_rpath
Chris@41 10476 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
Chris@41 10477 ;;
Chris@41 10478 *,no)
Chris@41 10479 link_command=$compile_var$compile_command$compile_rpath
Chris@41 10480 relink_command=$finalize_var$finalize_command$finalize_rpath
Chris@41 10481 ;;
Chris@41 10482 *,needless)
Chris@41 10483 link_command=$finalize_var$compile_command$finalize_rpath
Chris@41 10484 relink_command=
Chris@41 10485 ;;
Chris@41 10486 esac
Chris@41 10487
Chris@41 10488 # Replace the output file specification.
Chris@41 10489 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
Chris@41 10490
Chris@41 10491 # Delete the old output files.
Chris@41 10492 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
Chris@41 10493
Chris@41 10494 func_show_eval "$link_command" 'exit $?'
Chris@41 10495
Chris@41 10496 if test -n "$postlink_cmds"; then
Chris@41 10497 func_to_tool_file "$output_objdir/$outputname"
Chris@41 10498 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@41 10499 func_execute_cmds "$postlink_cmds" 'exit $?'
Chris@41 10500 fi
Chris@41 10501
Chris@41 10502 # Now create the wrapper script.
Chris@41 10503 func_verbose "creating $output"
Chris@41 10504
Chris@41 10505 # Quote the relink command for shipping.
Chris@41 10506 if test -n "$relink_command"; then
Chris@41 10507 # Preserve any variables that may affect compiler behavior
Chris@41 10508 for var in $variables_saved_for_relink; do
Chris@41 10509 if eval test -z \"\${$var+set}\"; then
Chris@41 10510 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
Chris@41 10511 elif eval var_value=\$$var; test -z "$var_value"; then
Chris@41 10512 relink_command="$var=; export $var; $relink_command"
Chris@41 10513 else
Chris@41 10514 func_quote_for_eval "$var_value"
Chris@41 10515 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
Chris@41 10516 fi
Chris@41 10517 done
Chris@41 10518 relink_command="(cd `pwd`; $relink_command)"
Chris@41 10519 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
Chris@41 10520 fi
Chris@41 10521
Chris@41 10522 # Only actually do things if not in dry run mode.
Chris@41 10523 $opt_dry_run || {
Chris@41 10524 # win32 will think the script is a binary if it has
Chris@41 10525 # a .exe suffix, so we strip it off here.
Chris@41 10526 case $output in
Chris@41 10527 *.exe) func_stripname '' '.exe' "$output"
Chris@41 10528 output=$func_stripname_result ;;
Chris@41 10529 esac
Chris@41 10530 # test for cygwin because mv fails w/o .exe extensions
Chris@41 10531 case $host in
Chris@41 10532 *cygwin*)
Chris@41 10533 exeext=.exe
Chris@41 10534 func_stripname '' '.exe' "$outputname"
Chris@41 10535 outputname=$func_stripname_result ;;
Chris@41 10536 *) exeext= ;;
Chris@41 10537 esac
Chris@41 10538 case $host in
Chris@41 10539 *cygwin* | *mingw* )
Chris@41 10540 func_dirname_and_basename "$output" "" "."
Chris@41 10541 output_name=$func_basename_result
Chris@41 10542 output_path=$func_dirname_result
Chris@41 10543 cwrappersource=$output_path/$objdir/lt-$output_name.c
Chris@41 10544 cwrapper=$output_path/$output_name.exe
Chris@41 10545 $RM $cwrappersource $cwrapper
Chris@41 10546 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
Chris@41 10547
Chris@41 10548 func_emit_cwrapperexe_src > $cwrappersource
Chris@41 10549
Chris@41 10550 # The wrapper executable is built using the $host compiler,
Chris@41 10551 # because it contains $host paths and files. If cross-
Chris@41 10552 # compiling, it, like the target executable, must be
Chris@41 10553 # executed on the $host or under an emulation environment.
Chris@41 10554 $opt_dry_run || {
Chris@41 10555 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
Chris@41 10556 $STRIP $cwrapper
Chris@41 10557 }
Chris@41 10558
Chris@41 10559 # Now, create the wrapper script for func_source use:
Chris@41 10560 func_ltwrapper_scriptname $cwrapper
Chris@41 10561 $RM $func_ltwrapper_scriptname_result
Chris@41 10562 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
Chris@41 10563 $opt_dry_run || {
Chris@41 10564 # note: this script will not be executed, so do not chmod.
Chris@41 10565 if test "x$build" = "x$host"; then
Chris@41 10566 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
Chris@41 10567 else
Chris@41 10568 func_emit_wrapper no > $func_ltwrapper_scriptname_result
Chris@41 10569 fi
Chris@41 10570 }
Chris@41 10571 ;;
Chris@41 10572 * )
Chris@41 10573 $RM $output
Chris@41 10574 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
Chris@41 10575
Chris@41 10576 func_emit_wrapper no > $output
Chris@41 10577 chmod +x $output
Chris@41 10578 ;;
Chris@41 10579 esac
Chris@41 10580 }
Chris@41 10581 exit $EXIT_SUCCESS
Chris@41 10582 ;;
Chris@41 10583 esac
Chris@41 10584
Chris@41 10585 # See if we need to build an old-fashioned archive.
Chris@41 10586 for oldlib in $oldlibs; do
Chris@41 10587
Chris@41 10588 case $build_libtool_libs in
Chris@41 10589 convenience)
Chris@41 10590 oldobjs="$libobjs_save $symfileobj"
Chris@41 10591 addlibs=$convenience
Chris@41 10592 build_libtool_libs=no
Chris@41 10593 ;;
Chris@41 10594 module)
Chris@41 10595 oldobjs=$libobjs_save
Chris@41 10596 addlibs=$old_convenience
Chris@41 10597 build_libtool_libs=no
Chris@41 10598 ;;
Chris@41 10599 *)
Chris@41 10600 oldobjs="$old_deplibs $non_pic_objects"
Chris@41 10601 $preload && test -f "$symfileobj" \
Chris@41 10602 && func_append oldobjs " $symfileobj"
Chris@41 10603 addlibs=$old_convenience
Chris@41 10604 ;;
Chris@41 10605 esac
Chris@41 10606
Chris@41 10607 if test -n "$addlibs"; then
Chris@41 10608 gentop=$output_objdir/${outputname}x
Chris@41 10609 func_append generated " $gentop"
Chris@41 10610
Chris@41 10611 func_extract_archives $gentop $addlibs
Chris@41 10612 func_append oldobjs " $func_extract_archives_result"
Chris@41 10613 fi
Chris@41 10614
Chris@41 10615 # Do each command in the archive commands.
Chris@41 10616 if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
Chris@41 10617 cmds=$old_archive_from_new_cmds
Chris@41 10618 else
Chris@41 10619
Chris@41 10620 # Add any objects from preloaded convenience libraries
Chris@41 10621 if test -n "$dlprefiles"; then
Chris@41 10622 gentop=$output_objdir/${outputname}x
Chris@41 10623 func_append generated " $gentop"
Chris@41 10624
Chris@41 10625 func_extract_archives $gentop $dlprefiles
Chris@41 10626 func_append oldobjs " $func_extract_archives_result"
Chris@41 10627 fi
Chris@41 10628
Chris@41 10629 # POSIX demands no paths to be encoded in archives. We have
Chris@41 10630 # to avoid creating archives with duplicate basenames if we
Chris@41 10631 # might have to extract them afterwards, e.g., when creating a
Chris@41 10632 # static archive out of a convenience library, or when linking
Chris@41 10633 # the entirety of a libtool archive into another (currently
Chris@41 10634 # not supported by libtool).
Chris@41 10635 if (for obj in $oldobjs
Chris@41 10636 do
Chris@41 10637 func_basename "$obj"
Chris@41 10638 $ECHO "$func_basename_result"
Chris@41 10639 done | sort | sort -uc >/dev/null 2>&1); then
Chris@41 10640 :
Chris@41 10641 else
Chris@41 10642 echo "copying selected object files to avoid basename conflicts..."
Chris@41 10643 gentop=$output_objdir/${outputname}x
Chris@41 10644 func_append generated " $gentop"
Chris@41 10645 func_mkdir_p "$gentop"
Chris@41 10646 save_oldobjs=$oldobjs
Chris@41 10647 oldobjs=
Chris@41 10648 counter=1
Chris@41 10649 for obj in $save_oldobjs
Chris@41 10650 do
Chris@41 10651 func_basename "$obj"
Chris@41 10652 objbase=$func_basename_result
Chris@41 10653 case " $oldobjs " in
Chris@41 10654 " ") oldobjs=$obj ;;
Chris@41 10655 *[\ /]"$objbase "*)
Chris@41 10656 while :; do
Chris@41 10657 # Make sure we don't pick an alternate name that also
Chris@41 10658 # overlaps.
Chris@41 10659 newobj=lt$counter-$objbase
Chris@41 10660 func_arith $counter + 1
Chris@41 10661 counter=$func_arith_result
Chris@41 10662 case " $oldobjs " in
Chris@41 10663 *[\ /]"$newobj "*) ;;
Chris@41 10664 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
Chris@41 10665 esac
Chris@41 10666 done
Chris@41 10667 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
Chris@41 10668 func_append oldobjs " $gentop/$newobj"
Chris@41 10669 ;;
Chris@41 10670 *) func_append oldobjs " $obj" ;;
Chris@41 10671 esac
Chris@41 10672 done
Chris@41 10673 fi
Chris@41 10674 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
Chris@41 10675 tool_oldlib=$func_to_tool_file_result
Chris@41 10676 eval cmds=\"$old_archive_cmds\"
Chris@41 10677
Chris@41 10678 func_len " $cmds"
Chris@41 10679 len=$func_len_result
Chris@41 10680 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
Chris@41 10681 cmds=$old_archive_cmds
Chris@41 10682 elif test -n "$archiver_list_spec"; then
Chris@41 10683 func_verbose "using command file archive linking..."
Chris@41 10684 for obj in $oldobjs
Chris@41 10685 do
Chris@41 10686 func_to_tool_file "$obj"
Chris@41 10687 $ECHO "$func_to_tool_file_result"
Chris@41 10688 done > $output_objdir/$libname.libcmd
Chris@41 10689 func_to_tool_file "$output_objdir/$libname.libcmd"
Chris@41 10690 oldobjs=" $archiver_list_spec$func_to_tool_file_result"
Chris@41 10691 cmds=$old_archive_cmds
Chris@41 10692 else
Chris@41 10693 # the command line is too long to link in one step, link in parts
Chris@41 10694 func_verbose "using piecewise archive linking..."
Chris@41 10695 save_RANLIB=$RANLIB
Chris@41 10696 RANLIB=:
Chris@41 10697 objlist=
Chris@41 10698 concat_cmds=
Chris@41 10699 save_oldobjs=$oldobjs
Chris@41 10700 oldobjs=
Chris@41 10701 # Is there a better way of finding the last object in the list?
Chris@41 10702 for obj in $save_oldobjs
Chris@41 10703 do
Chris@41 10704 last_oldobj=$obj
Chris@41 10705 done
Chris@41 10706 eval test_cmds=\"$old_archive_cmds\"
Chris@41 10707 func_len " $test_cmds"
Chris@41 10708 len0=$func_len_result
Chris@41 10709 len=$len0
Chris@41 10710 for obj in $save_oldobjs
Chris@41 10711 do
Chris@41 10712 func_len " $obj"
Chris@41 10713 func_arith $len + $func_len_result
Chris@41 10714 len=$func_arith_result
Chris@41 10715 func_append objlist " $obj"
Chris@41 10716 if test "$len" -lt "$max_cmd_len"; then
Chris@41 10717 :
Chris@41 10718 else
Chris@41 10719 # the above command should be used before it gets too long
Chris@41 10720 oldobjs=$objlist
Chris@41 10721 if test "$obj" = "$last_oldobj"; then
Chris@41 10722 RANLIB=$save_RANLIB
Chris@41 10723 fi
Chris@41 10724 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Chris@41 10725 eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
Chris@41 10726 objlist=
Chris@41 10727 len=$len0
Chris@41 10728 fi
Chris@41 10729 done
Chris@41 10730 RANLIB=$save_RANLIB
Chris@41 10731 oldobjs=$objlist
Chris@41 10732 if test -z "$oldobjs"; then
Chris@41 10733 eval cmds=\"\$concat_cmds\"
Chris@41 10734 else
Chris@41 10735 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
Chris@41 10736 fi
Chris@41 10737 fi
Chris@41 10738 fi
Chris@41 10739 func_execute_cmds "$cmds" 'exit $?'
Chris@41 10740 done
Chris@41 10741
Chris@41 10742 test -n "$generated" && \
Chris@41 10743 func_show_eval "${RM}r$generated"
Chris@41 10744
Chris@41 10745 # Now create the libtool archive.
Chris@41 10746 case $output in
Chris@41 10747 *.la)
Chris@41 10748 old_library=
Chris@41 10749 test yes = "$build_old_libs" && old_library=$libname.$libext
Chris@41 10750 func_verbose "creating $output"
Chris@41 10751
Chris@41 10752 # Preserve any variables that may affect compiler behavior
Chris@41 10753 for var in $variables_saved_for_relink; do
Chris@41 10754 if eval test -z \"\${$var+set}\"; then
Chris@41 10755 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
Chris@41 10756 elif eval var_value=\$$var; test -z "$var_value"; then
Chris@41 10757 relink_command="$var=; export $var; $relink_command"
Chris@41 10758 else
Chris@41 10759 func_quote_for_eval "$var_value"
Chris@41 10760 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
Chris@41 10761 fi
Chris@41 10762 done
Chris@41 10763 # Quote the link command for shipping.
Chris@41 10764 relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
Chris@41 10765 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
Chris@41 10766 if test yes = "$hardcode_automatic"; then
Chris@41 10767 relink_command=
Chris@41 10768 fi
Chris@41 10769
Chris@41 10770 # Only create the output if not a dry run.
Chris@41 10771 $opt_dry_run || {
Chris@41 10772 for installed in no yes; do
Chris@41 10773 if test yes = "$installed"; then
Chris@41 10774 if test -z "$install_libdir"; then
Chris@41 10775 break
Chris@41 10776 fi
Chris@41 10777 output=$output_objdir/${outputname}i
Chris@41 10778 # Replace all uninstalled libtool libraries with the installed ones
Chris@41 10779 newdependency_libs=
Chris@41 10780 for deplib in $dependency_libs; do
Chris@41 10781 case $deplib in
Chris@41 10782 *.la)
Chris@41 10783 func_basename "$deplib"
Chris@41 10784 name=$func_basename_result
Chris@41 10785 func_resolve_sysroot "$deplib"
Chris@41 10786 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
Chris@41 10787 test -z "$libdir" && \
Chris@41 10788 func_fatal_error "'$deplib' is not a valid libtool archive"
Chris@41 10789 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
Chris@41 10790 ;;
Chris@41 10791 -L*)
Chris@41 10792 func_stripname -L '' "$deplib"
Chris@41 10793 func_replace_sysroot "$func_stripname_result"
Chris@41 10794 func_append newdependency_libs " -L$func_replace_sysroot_result"
Chris@41 10795 ;;
Chris@41 10796 -R*)
Chris@41 10797 func_stripname -R '' "$deplib"
Chris@41 10798 func_replace_sysroot "$func_stripname_result"
Chris@41 10799 func_append newdependency_libs " -R$func_replace_sysroot_result"
Chris@41 10800 ;;
Chris@41 10801 *) func_append newdependency_libs " $deplib" ;;
Chris@41 10802 esac
Chris@41 10803 done
Chris@41 10804 dependency_libs=$newdependency_libs
Chris@41 10805 newdlfiles=
Chris@41 10806
Chris@41 10807 for lib in $dlfiles; do
Chris@41 10808 case $lib in
Chris@41 10809 *.la)
Chris@41 10810 func_basename "$lib"
Chris@41 10811 name=$func_basename_result
Chris@41 10812 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
Chris@41 10813 test -z "$libdir" && \
Chris@41 10814 func_fatal_error "'$lib' is not a valid libtool archive"
Chris@41 10815 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
Chris@41 10816 ;;
Chris@41 10817 *) func_append newdlfiles " $lib" ;;
Chris@41 10818 esac
Chris@41 10819 done
Chris@41 10820 dlfiles=$newdlfiles
Chris@41 10821 newdlprefiles=
Chris@41 10822 for lib in $dlprefiles; do
Chris@41 10823 case $lib in
Chris@41 10824 *.la)
Chris@41 10825 # Only pass preopened files to the pseudo-archive (for
Chris@41 10826 # eventual linking with the app. that links it) if we
Chris@41 10827 # didn't already link the preopened objects directly into
Chris@41 10828 # the library:
Chris@41 10829 func_basename "$lib"
Chris@41 10830 name=$func_basename_result
Chris@41 10831 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
Chris@41 10832 test -z "$libdir" && \
Chris@41 10833 func_fatal_error "'$lib' is not a valid libtool archive"
Chris@41 10834 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
Chris@41 10835 ;;
Chris@41 10836 esac
Chris@41 10837 done
Chris@41 10838 dlprefiles=$newdlprefiles
Chris@41 10839 else
Chris@41 10840 newdlfiles=
Chris@41 10841 for lib in $dlfiles; do
Chris@41 10842 case $lib in
Chris@41 10843 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
Chris@41 10844 *) abs=`pwd`"/$lib" ;;
Chris@41 10845 esac
Chris@41 10846 func_append newdlfiles " $abs"
Chris@41 10847 done
Chris@41 10848 dlfiles=$newdlfiles
Chris@41 10849 newdlprefiles=
Chris@41 10850 for lib in $dlprefiles; do
Chris@41 10851 case $lib in
Chris@41 10852 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
Chris@41 10853 *) abs=`pwd`"/$lib" ;;
Chris@41 10854 esac
Chris@41 10855 func_append newdlprefiles " $abs"
Chris@41 10856 done
Chris@41 10857 dlprefiles=$newdlprefiles
Chris@41 10858 fi
Chris@41 10859 $RM $output
Chris@41 10860 # place dlname in correct position for cygwin
Chris@41 10861 # In fact, it would be nice if we could use this code for all target
Chris@41 10862 # systems that can't hard-code library paths into their executables
Chris@41 10863 # and that have no shared library path variable independent of PATH,
Chris@41 10864 # but it turns out we can't easily determine that from inspecting
Chris@41 10865 # libtool variables, so we have to hard-code the OSs to which it
Chris@41 10866 # applies here; at the moment, that means platforms that use the PE
Chris@41 10867 # object format with DLL files. See the long comment at the top of
Chris@41 10868 # tests/bindir.at for full details.
Chris@41 10869 tdlname=$dlname
Chris@41 10870 case $host,$output,$installed,$module,$dlname in
Chris@41 10871 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
Chris@41 10872 # If a -bindir argument was supplied, place the dll there.
Chris@41 10873 if test -n "$bindir"; then
Chris@41 10874 func_relative_path "$install_libdir" "$bindir"
Chris@41 10875 tdlname=$func_relative_path_result/$dlname
Chris@41 10876 else
Chris@41 10877 # Otherwise fall back on heuristic.
Chris@41 10878 tdlname=../bin/$dlname
Chris@41 10879 fi
Chris@41 10880 ;;
Chris@41 10881 esac
Chris@41 10882 $ECHO > $output "\
Chris@41 10883 # $outputname - a libtool library file
Chris@41 10884 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@41 10885 #
Chris@41 10886 # Please DO NOT delete this file!
Chris@41 10887 # It is necessary for linking the library.
Chris@41 10888
Chris@41 10889 # The name that we can dlopen(3).
Chris@41 10890 dlname='$tdlname'
Chris@41 10891
Chris@41 10892 # Names of this library.
Chris@41 10893 library_names='$library_names'
Chris@41 10894
Chris@41 10895 # The name of the static archive.
Chris@41 10896 old_library='$old_library'
Chris@41 10897
Chris@41 10898 # Linker flags that cannot go in dependency_libs.
Chris@41 10899 inherited_linker_flags='$new_inherited_linker_flags'
Chris@41 10900
Chris@41 10901 # Libraries that this one depends upon.
Chris@41 10902 dependency_libs='$dependency_libs'
Chris@41 10903
Chris@41 10904 # Names of additional weak libraries provided by this library
Chris@41 10905 weak_library_names='$weak_libs'
Chris@41 10906
Chris@41 10907 # Version information for $libname.
Chris@41 10908 current=$current
Chris@41 10909 age=$age
Chris@41 10910 revision=$revision
Chris@41 10911
Chris@41 10912 # Is this an already installed library?
Chris@41 10913 installed=$installed
Chris@41 10914
Chris@41 10915 # Should we warn about portability when linking against -modules?
Chris@41 10916 shouldnotlink=$module
Chris@41 10917
Chris@41 10918 # Files to dlopen/dlpreopen
Chris@41 10919 dlopen='$dlfiles'
Chris@41 10920 dlpreopen='$dlprefiles'
Chris@41 10921
Chris@41 10922 # Directory that this library needs to be installed in:
Chris@41 10923 libdir='$install_libdir'"
Chris@41 10924 if test no,yes = "$installed,$need_relink"; then
Chris@41 10925 $ECHO >> $output "\
Chris@41 10926 relink_command=\"$relink_command\""
Chris@41 10927 fi
Chris@41 10928 done
Chris@41 10929 }
Chris@41 10930
Chris@41 10931 # Do a symbolic link so that the libtool archive can be found in
Chris@41 10932 # LD_LIBRARY_PATH before the program is installed.
Chris@41 10933 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
Chris@41 10934 ;;
Chris@41 10935 esac
Chris@41 10936 exit $EXIT_SUCCESS
Chris@41 10937 }
Chris@41 10938
Chris@41 10939 if test link = "$opt_mode" || test relink = "$opt_mode"; then
Chris@41 10940 func_mode_link ${1+"$@"}
Chris@41 10941 fi
Chris@41 10942
Chris@41 10943
Chris@41 10944 # func_mode_uninstall arg...
Chris@41 10945 func_mode_uninstall ()
Chris@41 10946 {
Chris@41 10947 $debug_cmd
Chris@41 10948
Chris@41 10949 RM=$nonopt
Chris@41 10950 files=
Chris@41 10951 rmforce=false
Chris@41 10952 exit_status=0
Chris@41 10953
Chris@41 10954 # This variable tells wrapper scripts just to set variables rather
Chris@41 10955 # than running their programs.
Chris@41 10956 libtool_install_magic=$magic
Chris@41 10957
Chris@41 10958 for arg
Chris@41 10959 do
Chris@41 10960 case $arg in
Chris@41 10961 -f) func_append RM " $arg"; rmforce=: ;;
Chris@41 10962 -*) func_append RM " $arg" ;;
Chris@41 10963 *) func_append files " $arg" ;;
Chris@41 10964 esac
Chris@41 10965 done
Chris@41 10966
Chris@41 10967 test -z "$RM" && \
Chris@41 10968 func_fatal_help "you must specify an RM program"
Chris@41 10969
Chris@41 10970 rmdirs=
Chris@41 10971
Chris@41 10972 for file in $files; do
Chris@41 10973 func_dirname "$file" "" "."
Chris@41 10974 dir=$func_dirname_result
Chris@41 10975 if test . = "$dir"; then
Chris@41 10976 odir=$objdir
Chris@41 10977 else
Chris@41 10978 odir=$dir/$objdir
Chris@41 10979 fi
Chris@41 10980 func_basename "$file"
Chris@41 10981 name=$func_basename_result
Chris@41 10982 test uninstall = "$opt_mode" && odir=$dir
Chris@41 10983
Chris@41 10984 # Remember odir for removal later, being careful to avoid duplicates
Chris@41 10985 if test clean = "$opt_mode"; then
Chris@41 10986 case " $rmdirs " in
Chris@41 10987 *" $odir "*) ;;
Chris@41 10988 *) func_append rmdirs " $odir" ;;
Chris@41 10989 esac
Chris@41 10990 fi
Chris@41 10991
Chris@41 10992 # Don't error if the file doesn't exist and rm -f was used.
Chris@41 10993 if { test -L "$file"; } >/dev/null 2>&1 ||
Chris@41 10994 { test -h "$file"; } >/dev/null 2>&1 ||
Chris@41 10995 test -f "$file"; then
Chris@41 10996 :
Chris@41 10997 elif test -d "$file"; then
Chris@41 10998 exit_status=1
Chris@41 10999 continue
Chris@41 11000 elif $rmforce; then
Chris@41 11001 continue
Chris@41 11002 fi
Chris@41 11003
Chris@41 11004 rmfiles=$file
Chris@41 11005
Chris@41 11006 case $name in
Chris@41 11007 *.la)
Chris@41 11008 # Possibly a libtool archive, so verify it.
Chris@41 11009 if func_lalib_p "$file"; then
Chris@41 11010 func_source $dir/$name
Chris@41 11011
Chris@41 11012 # Delete the libtool libraries and symlinks.
Chris@41 11013 for n in $library_names; do
Chris@41 11014 func_append rmfiles " $odir/$n"
Chris@41 11015 done
Chris@41 11016 test -n "$old_library" && func_append rmfiles " $odir/$old_library"
Chris@41 11017
Chris@41 11018 case $opt_mode in
Chris@41 11019 clean)
Chris@41 11020 case " $library_names " in
Chris@41 11021 *" $dlname "*) ;;
Chris@41 11022 *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
Chris@41 11023 esac
Chris@41 11024 test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
Chris@41 11025 ;;
Chris@41 11026 uninstall)
Chris@41 11027 if test -n "$library_names"; then
Chris@41 11028 # Do each command in the postuninstall commands.
Chris@41 11029 func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
Chris@41 11030 fi
Chris@41 11031
Chris@41 11032 if test -n "$old_library"; then
Chris@41 11033 # Do each command in the old_postuninstall commands.
Chris@41 11034 func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
Chris@41 11035 fi
Chris@41 11036 # FIXME: should reinstall the best remaining shared library.
Chris@41 11037 ;;
Chris@41 11038 esac
Chris@41 11039 fi
Chris@41 11040 ;;
Chris@41 11041
Chris@41 11042 *.lo)
Chris@41 11043 # Possibly a libtool object, so verify it.
Chris@41 11044 if func_lalib_p "$file"; then
Chris@41 11045
Chris@41 11046 # Read the .lo file
Chris@41 11047 func_source $dir/$name
Chris@41 11048
Chris@41 11049 # Add PIC object to the list of files to remove.
Chris@41 11050 if test -n "$pic_object" && test none != "$pic_object"; then
Chris@41 11051 func_append rmfiles " $dir/$pic_object"
Chris@41 11052 fi
Chris@41 11053
Chris@41 11054 # Add non-PIC object to the list of files to remove.
Chris@41 11055 if test -n "$non_pic_object" && test none != "$non_pic_object"; then
Chris@41 11056 func_append rmfiles " $dir/$non_pic_object"
Chris@41 11057 fi
Chris@41 11058 fi
Chris@41 11059 ;;
Chris@41 11060
Chris@41 11061 *)
Chris@41 11062 if test clean = "$opt_mode"; then
Chris@41 11063 noexename=$name
Chris@41 11064 case $file in
Chris@41 11065 *.exe)
Chris@41 11066 func_stripname '' '.exe' "$file"
Chris@41 11067 file=$func_stripname_result
Chris@41 11068 func_stripname '' '.exe' "$name"
Chris@41 11069 noexename=$func_stripname_result
Chris@41 11070 # $file with .exe has already been added to rmfiles,
Chris@41 11071 # add $file without .exe
Chris@41 11072 func_append rmfiles " $file"
Chris@41 11073 ;;
Chris@41 11074 esac
Chris@41 11075 # Do a test to see if this is a libtool program.
Chris@41 11076 if func_ltwrapper_p "$file"; then
Chris@41 11077 if func_ltwrapper_executable_p "$file"; then
Chris@41 11078 func_ltwrapper_scriptname "$file"
Chris@41 11079 relink_command=
Chris@41 11080 func_source $func_ltwrapper_scriptname_result
Chris@41 11081 func_append rmfiles " $func_ltwrapper_scriptname_result"
Chris@41 11082 else
Chris@41 11083 relink_command=
Chris@41 11084 func_source $dir/$noexename
Chris@41 11085 fi
Chris@41 11086
Chris@41 11087 # note $name still contains .exe if it was in $file originally
Chris@41 11088 # as does the version of $file that was added into $rmfiles
Chris@41 11089 func_append rmfiles " $odir/$name $odir/${name}S.$objext"
Chris@41 11090 if test yes = "$fast_install" && test -n "$relink_command"; then
Chris@41 11091 func_append rmfiles " $odir/lt-$name"
Chris@41 11092 fi
Chris@41 11093 if test "X$noexename" != "X$name"; then
Chris@41 11094 func_append rmfiles " $odir/lt-$noexename.c"
Chris@41 11095 fi
Chris@41 11096 fi
Chris@41 11097 fi
Chris@41 11098 ;;
Chris@41 11099 esac
Chris@41 11100 func_show_eval "$RM $rmfiles" 'exit_status=1'
Chris@41 11101 done
Chris@41 11102
Chris@41 11103 # Try to remove the $objdir's in the directories where we deleted files
Chris@41 11104 for dir in $rmdirs; do
Chris@41 11105 if test -d "$dir"; then
Chris@41 11106 func_show_eval "rmdir $dir >/dev/null 2>&1"
Chris@41 11107 fi
Chris@41 11108 done
Chris@41 11109
Chris@41 11110 exit $exit_status
Chris@41 11111 }
Chris@41 11112
Chris@41 11113 if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
Chris@41 11114 func_mode_uninstall ${1+"$@"}
Chris@41 11115 fi
Chris@41 11116
Chris@41 11117 test -z "$opt_mode" && {
Chris@41 11118 help=$generic_help
Chris@41 11119 func_fatal_help "you must specify a MODE"
Chris@41 11120 }
Chris@41 11121
Chris@41 11122 test -z "$exec_cmd" && \
Chris@41 11123 func_fatal_help "invalid operation mode '$opt_mode'"
Chris@41 11124
Chris@41 11125 if test -n "$exec_cmd"; then
Chris@41 11126 eval exec "$exec_cmd"
Chris@41 11127 exit $EXIT_FAILURE
Chris@41 11128 fi
Chris@41 11129
Chris@41 11130 exit $exit_status
Chris@41 11131
Chris@41 11132
Chris@41 11133 # The TAGs below are defined such that we never get into a situation
Chris@41 11134 # where we disable both kinds of libraries. Given conflicting
Chris@41 11135 # choices, we go for a static library, that is the most portable,
Chris@41 11136 # since we can't tell whether shared libraries were disabled because
Chris@41 11137 # the user asked for that or because the platform doesn't support
Chris@41 11138 # them. This is particularly important on AIX, because we don't
Chris@41 11139 # support having both static and shared libraries enabled at the same
Chris@41 11140 # time on that platform, so we default to a shared-only configuration.
Chris@41 11141 # If a disable-shared tag is given, we'll fallback to a static-only
Chris@41 11142 # configuration. But we'll never go from static-only to shared-only.
Chris@41 11143
Chris@41 11144 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
Chris@41 11145 build_libtool_libs=no
Chris@41 11146 build_old_libs=yes
Chris@41 11147 # ### END LIBTOOL TAG CONFIG: disable-shared
Chris@41 11148
Chris@41 11149 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
Chris@41 11150 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
Chris@41 11151 # ### END LIBTOOL TAG CONFIG: disable-static
Chris@41 11152
Chris@41 11153 # Local Variables:
Chris@41 11154 # mode:shell-script
Chris@41 11155 # sh-indentation:2
Chris@41 11156 # End: