annotate src/libsndfile-1.0.27/Cfg/ltmain.sh @ 84:08ae793730bd

Add null config files
author Chris Cannam
date Mon, 02 Mar 2020 14:03:47 +0000
parents 1df64224f5ac
children
rev   line source
Chris@40 1 #! /bin/sh
Chris@40 2 ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
Chris@40 3 ## by inline-source v2014-01-03.01
Chris@40 4
Chris@40 5 # libtool (GNU libtool) 2.4.6
Chris@40 6 # Provide generalized library-building support services.
Chris@40 7 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
Chris@40 8
Chris@40 9 # Copyright (C) 1996-2015 Free Software Foundation, Inc.
Chris@40 10 # This is free software; see the source for copying conditions. There is NO
Chris@40 11 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chris@40 12
Chris@40 13 # GNU Libtool is free software; you can redistribute it and/or modify
Chris@40 14 # it under the terms of the GNU General Public License as published by
Chris@40 15 # the Free Software Foundation; either version 2 of the License, or
Chris@40 16 # (at your option) any later version.
Chris@40 17 #
Chris@40 18 # As a special exception to the GNU General Public License,
Chris@40 19 # if you distribute this file as part of a program or library that
Chris@40 20 # is built using GNU Libtool, you may include this file under the
Chris@40 21 # same distribution terms that you use for the rest of that program.
Chris@40 22 #
Chris@40 23 # GNU Libtool is distributed in the hope that it will be useful, but
Chris@40 24 # WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@40 25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Chris@40 26 # General Public License for more details.
Chris@40 27 #
Chris@40 28 # You should have received a copy of the GNU General Public License
Chris@40 29 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@40 30
Chris@40 31
Chris@40 32 PROGRAM=libtool
Chris@40 33 PACKAGE=libtool
Chris@40 34 VERSION="2.4.6 Debian-2.4.6-0.1"
Chris@40 35 package_revision=2.4.6
Chris@40 36
Chris@40 37
Chris@40 38 ## ------ ##
Chris@40 39 ## Usage. ##
Chris@40 40 ## ------ ##
Chris@40 41
Chris@40 42 # Run './libtool --help' for help with using this script from the
Chris@40 43 # command line.
Chris@40 44
Chris@40 45
Chris@40 46 ## ------------------------------- ##
Chris@40 47 ## User overridable command paths. ##
Chris@40 48 ## ------------------------------- ##
Chris@40 49
Chris@40 50 # After configure completes, it has a better idea of some of the
Chris@40 51 # shell tools we need than the defaults used by the functions shared
Chris@40 52 # with bootstrap, so set those here where they can still be over-
Chris@40 53 # ridden by the user, but otherwise take precedence.
Chris@40 54
Chris@40 55 : ${AUTOCONF="autoconf"}
Chris@40 56 : ${AUTOMAKE="automake"}
Chris@40 57
Chris@40 58
Chris@40 59 ## -------------------------- ##
Chris@40 60 ## Source external libraries. ##
Chris@40 61 ## -------------------------- ##
Chris@40 62
Chris@40 63 # Much of our low-level functionality needs to be sourced from external
Chris@40 64 # libraries, which are installed to $pkgauxdir.
Chris@40 65
Chris@40 66 # Set a version string for this script.
Chris@40 67 scriptversion=2015-01-20.17; # UTC
Chris@40 68
Chris@40 69 # General shell script boiler plate, and helper functions.
Chris@40 70 # Written by Gary V. Vaughan, 2004
Chris@40 71
Chris@40 72 # Copyright (C) 2004-2015 Free Software Foundation, Inc.
Chris@40 73 # This is free software; see the source for copying conditions. There is NO
Chris@40 74 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chris@40 75
Chris@40 76 # This program is free software; you can redistribute it and/or modify
Chris@40 77 # it under the terms of the GNU General Public License as published by
Chris@40 78 # the Free Software Foundation; either version 3 of the License, or
Chris@40 79 # (at your option) any later version.
Chris@40 80
Chris@40 81 # As a special exception to the GNU General Public License, if you distribute
Chris@40 82 # this file as part of a program or library that is built using GNU Libtool,
Chris@40 83 # you may include this file under the same distribution terms that you use
Chris@40 84 # for the rest of that program.
Chris@40 85
Chris@40 86 # This program is distributed in the hope that it will be useful,
Chris@40 87 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@40 88 # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
Chris@40 89 # General Public License for more details.
Chris@40 90
Chris@40 91 # You should have received a copy of the GNU General Public License
Chris@40 92 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@40 93
Chris@40 94 # Please report bugs or propose patches to gary@gnu.org.
Chris@40 95
Chris@40 96
Chris@40 97 ## ------ ##
Chris@40 98 ## Usage. ##
Chris@40 99 ## ------ ##
Chris@40 100
Chris@40 101 # Evaluate this file near the top of your script to gain access to
Chris@40 102 # the functions and variables defined here:
Chris@40 103 #
Chris@40 104 # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
Chris@40 105 #
Chris@40 106 # If you need to override any of the default environment variable
Chris@40 107 # settings, do that before evaluating this file.
Chris@40 108
Chris@40 109
Chris@40 110 ## -------------------- ##
Chris@40 111 ## Shell normalisation. ##
Chris@40 112 ## -------------------- ##
Chris@40 113
Chris@40 114 # Some shells need a little help to be as Bourne compatible as possible.
Chris@40 115 # Before doing anything else, make sure all that help has been provided!
Chris@40 116
Chris@40 117 DUALCASE=1; export DUALCASE # for MKS sh
Chris@40 118 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
Chris@40 119 emulate sh
Chris@40 120 NULLCMD=:
Chris@40 121 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
Chris@40 122 # is contrary to our usage. Disable this feature.
Chris@40 123 alias -g '${1+"$@"}'='"$@"'
Chris@40 124 setopt NO_GLOB_SUBST
Chris@40 125 else
Chris@40 126 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
Chris@40 127 fi
Chris@40 128
Chris@40 129 # NLS nuisances: We save the old values in case they are required later.
Chris@40 130 _G_user_locale=
Chris@40 131 _G_safe_locale=
Chris@40 132 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
Chris@40 133 do
Chris@40 134 eval "if test set = \"\${$_G_var+set}\"; then
Chris@40 135 save_$_G_var=\$$_G_var
Chris@40 136 $_G_var=C
Chris@40 137 export $_G_var
Chris@40 138 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
Chris@40 139 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
Chris@40 140 fi"
Chris@40 141 done
Chris@40 142
Chris@40 143 # CDPATH.
Chris@40 144 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
Chris@40 145
Chris@40 146 # Make sure IFS has a sensible default
Chris@40 147 sp=' '
Chris@40 148 nl='
Chris@40 149 '
Chris@40 150 IFS="$sp $nl"
Chris@40 151
Chris@40 152 # There are apparently some retarded systems that use ';' as a PATH separator!
Chris@40 153 if test "${PATH_SEPARATOR+set}" != set; then
Chris@40 154 PATH_SEPARATOR=:
Chris@40 155 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
Chris@40 156 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
Chris@40 157 PATH_SEPARATOR=';'
Chris@40 158 }
Chris@40 159 fi
Chris@40 160
Chris@40 161
Chris@40 162
Chris@40 163 ## ------------------------- ##
Chris@40 164 ## Locate command utilities. ##
Chris@40 165 ## ------------------------- ##
Chris@40 166
Chris@40 167
Chris@40 168 # func_executable_p FILE
Chris@40 169 # ----------------------
Chris@40 170 # Check that FILE is an executable regular file.
Chris@40 171 func_executable_p ()
Chris@40 172 {
Chris@40 173 test -f "$1" && test -x "$1"
Chris@40 174 }
Chris@40 175
Chris@40 176
Chris@40 177 # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
Chris@40 178 # --------------------------------------------
Chris@40 179 # Search for either a program that responds to --version with output
Chris@40 180 # containing "GNU", or else returned by CHECK_FUNC otherwise, by
Chris@40 181 # trying all the directories in PATH with each of the elements of
Chris@40 182 # PROGS_LIST.
Chris@40 183 #
Chris@40 184 # CHECK_FUNC should accept the path to a candidate program, and
Chris@40 185 # set $func_check_prog_result if it truncates its output less than
Chris@40 186 # $_G_path_prog_max characters.
Chris@40 187 func_path_progs ()
Chris@40 188 {
Chris@40 189 _G_progs_list=$1
Chris@40 190 _G_check_func=$2
Chris@40 191 _G_PATH=${3-"$PATH"}
Chris@40 192
Chris@40 193 _G_path_prog_max=0
Chris@40 194 _G_path_prog_found=false
Chris@40 195 _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
Chris@40 196 for _G_dir in $_G_PATH; do
Chris@40 197 IFS=$_G_save_IFS
Chris@40 198 test -z "$_G_dir" && _G_dir=.
Chris@40 199 for _G_prog_name in $_G_progs_list; do
Chris@40 200 for _exeext in '' .EXE; do
Chris@40 201 _G_path_prog=$_G_dir/$_G_prog_name$_exeext
Chris@40 202 func_executable_p "$_G_path_prog" || continue
Chris@40 203 case `"$_G_path_prog" --version 2>&1` in
Chris@40 204 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
Chris@40 205 *) $_G_check_func $_G_path_prog
Chris@40 206 func_path_progs_result=$func_check_prog_result
Chris@40 207 ;;
Chris@40 208 esac
Chris@40 209 $_G_path_prog_found && break 3
Chris@40 210 done
Chris@40 211 done
Chris@40 212 done
Chris@40 213 IFS=$_G_save_IFS
Chris@40 214 test -z "$func_path_progs_result" && {
Chris@40 215 echo "no acceptable sed could be found in \$PATH" >&2
Chris@40 216 exit 1
Chris@40 217 }
Chris@40 218 }
Chris@40 219
Chris@40 220
Chris@40 221 # We want to be able to use the functions in this file before configure
Chris@40 222 # has figured out where the best binaries are kept, which means we have
Chris@40 223 # to search for them ourselves - except when the results are already set
Chris@40 224 # where we skip the searches.
Chris@40 225
Chris@40 226 # Unless the user overrides by setting SED, search the path for either GNU
Chris@40 227 # sed, or the sed that truncates its output the least.
Chris@40 228 test -z "$SED" && {
Chris@40 229 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
Chris@40 230 for _G_i in 1 2 3 4 5 6 7; do
Chris@40 231 _G_sed_script=$_G_sed_script$nl$_G_sed_script
Chris@40 232 done
Chris@40 233 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
Chris@40 234 _G_sed_script=
Chris@40 235
Chris@40 236 func_check_prog_sed ()
Chris@40 237 {
Chris@40 238 _G_path_prog=$1
Chris@40 239
Chris@40 240 _G_count=0
Chris@40 241 printf 0123456789 >conftest.in
Chris@40 242 while :
Chris@40 243 do
Chris@40 244 cat conftest.in conftest.in >conftest.tmp
Chris@40 245 mv conftest.tmp conftest.in
Chris@40 246 cp conftest.in conftest.nl
Chris@40 247 echo '' >> conftest.nl
Chris@40 248 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
Chris@40 249 diff conftest.out conftest.nl >/dev/null 2>&1 || break
Chris@40 250 _G_count=`expr $_G_count + 1`
Chris@40 251 if test "$_G_count" -gt "$_G_path_prog_max"; then
Chris@40 252 # Best one so far, save it but keep looking for a better one
Chris@40 253 func_check_prog_result=$_G_path_prog
Chris@40 254 _G_path_prog_max=$_G_count
Chris@40 255 fi
Chris@40 256 # 10*(2^10) chars as input seems more than enough
Chris@40 257 test 10 -lt "$_G_count" && break
Chris@40 258 done
Chris@40 259 rm -f conftest.in conftest.tmp conftest.nl conftest.out
Chris@40 260 }
Chris@40 261
Chris@40 262 func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
Chris@40 263 rm -f conftest.sed
Chris@40 264 SED=$func_path_progs_result
Chris@40 265 }
Chris@40 266
Chris@40 267
Chris@40 268 # Unless the user overrides by setting GREP, search the path for either GNU
Chris@40 269 # grep, or the grep that truncates its output the least.
Chris@40 270 test -z "$GREP" && {
Chris@40 271 func_check_prog_grep ()
Chris@40 272 {
Chris@40 273 _G_path_prog=$1
Chris@40 274
Chris@40 275 _G_count=0
Chris@40 276 _G_path_prog_max=0
Chris@40 277 printf 0123456789 >conftest.in
Chris@40 278 while :
Chris@40 279 do
Chris@40 280 cat conftest.in conftest.in >conftest.tmp
Chris@40 281 mv conftest.tmp conftest.in
Chris@40 282 cp conftest.in conftest.nl
Chris@40 283 echo 'GREP' >> conftest.nl
Chris@40 284 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
Chris@40 285 diff conftest.out conftest.nl >/dev/null 2>&1 || break
Chris@40 286 _G_count=`expr $_G_count + 1`
Chris@40 287 if test "$_G_count" -gt "$_G_path_prog_max"; then
Chris@40 288 # Best one so far, save it but keep looking for a better one
Chris@40 289 func_check_prog_result=$_G_path_prog
Chris@40 290 _G_path_prog_max=$_G_count
Chris@40 291 fi
Chris@40 292 # 10*(2^10) chars as input seems more than enough
Chris@40 293 test 10 -lt "$_G_count" && break
Chris@40 294 done
Chris@40 295 rm -f conftest.in conftest.tmp conftest.nl conftest.out
Chris@40 296 }
Chris@40 297
Chris@40 298 func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
Chris@40 299 GREP=$func_path_progs_result
Chris@40 300 }
Chris@40 301
Chris@40 302
Chris@40 303 ## ------------------------------- ##
Chris@40 304 ## User overridable command paths. ##
Chris@40 305 ## ------------------------------- ##
Chris@40 306
Chris@40 307 # All uppercase variable names are used for environment variables. These
Chris@40 308 # variables can be overridden by the user before calling a script that
Chris@40 309 # uses them if a suitable command of that name is not already available
Chris@40 310 # in the command search PATH.
Chris@40 311
Chris@40 312 : ${CP="cp -f"}
Chris@40 313 : ${ECHO="printf %s\n"}
Chris@40 314 : ${EGREP="$GREP -E"}
Chris@40 315 : ${FGREP="$GREP -F"}
Chris@40 316 : ${LN_S="ln -s"}
Chris@40 317 : ${MAKE="make"}
Chris@40 318 : ${MKDIR="mkdir"}
Chris@40 319 : ${MV="mv -f"}
Chris@40 320 : ${RM="rm -f"}
Chris@40 321 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
Chris@40 322
Chris@40 323
Chris@40 324 ## -------------------- ##
Chris@40 325 ## Useful sed snippets. ##
Chris@40 326 ## -------------------- ##
Chris@40 327
Chris@40 328 sed_dirname='s|/[^/]*$||'
Chris@40 329 sed_basename='s|^.*/||'
Chris@40 330
Chris@40 331 # Sed substitution that helps us do robust quoting. It backslashifies
Chris@40 332 # metacharacters that are still active within double-quoted strings.
Chris@40 333 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
Chris@40 334
Chris@40 335 # Same as above, but do not quote variable references.
Chris@40 336 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
Chris@40 337
Chris@40 338 # Sed substitution that turns a string into a regex matching for the
Chris@40 339 # string literally.
Chris@40 340 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
Chris@40 341
Chris@40 342 # Sed substitution that converts a w32 file name or path
Chris@40 343 # that contains forward slashes, into one that contains
Chris@40 344 # (escaped) backslashes. A very naive implementation.
Chris@40 345 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
Chris@40 346
Chris@40 347 # Re-'\' parameter expansions in output of sed_double_quote_subst that
Chris@40 348 # were '\'-ed in input to the same. If an odd number of '\' preceded a
Chris@40 349 # '$' in input to sed_double_quote_subst, that '$' was protected from
Chris@40 350 # expansion. Since each input '\' is now two '\'s, look for any number
Chris@40 351 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
Chris@40 352 _G_bs='\\'
Chris@40 353 _G_bs2='\\\\'
Chris@40 354 _G_bs4='\\\\\\\\'
Chris@40 355 _G_dollar='\$'
Chris@40 356 sed_double_backslash="\
Chris@40 357 s/$_G_bs4/&\\
Chris@40 358 /g
Chris@40 359 s/^$_G_bs2$_G_dollar/$_G_bs&/
Chris@40 360 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
Chris@40 361 s/\n//g"
Chris@40 362
Chris@40 363
Chris@40 364 ## ----------------- ##
Chris@40 365 ## Global variables. ##
Chris@40 366 ## ----------------- ##
Chris@40 367
Chris@40 368 # Except for the global variables explicitly listed below, the following
Chris@40 369 # functions in the '^func_' namespace, and the '^require_' namespace
Chris@40 370 # variables initialised in the 'Resource management' section, sourcing
Chris@40 371 # this file will not pollute your global namespace with anything
Chris@40 372 # else. There's no portable way to scope variables in Bourne shell
Chris@40 373 # though, so actually running these functions will sometimes place
Chris@40 374 # results into a variable named after the function, and often use
Chris@40 375 # temporary variables in the '^_G_' namespace. If you are careful to
Chris@40 376 # avoid using those namespaces casually in your sourcing script, things
Chris@40 377 # should continue to work as you expect. And, of course, you can freely
Chris@40 378 # overwrite any of the functions or variables defined here before
Chris@40 379 # calling anything to customize them.
Chris@40 380
Chris@40 381 EXIT_SUCCESS=0
Chris@40 382 EXIT_FAILURE=1
Chris@40 383 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
Chris@40 384 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
Chris@40 385
Chris@40 386 # Allow overriding, eg assuming that you follow the convention of
Chris@40 387 # putting '$debug_cmd' at the start of all your functions, you can get
Chris@40 388 # bash to show function call trace with:
Chris@40 389 #
Chris@40 390 # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
Chris@40 391 debug_cmd=${debug_cmd-":"}
Chris@40 392 exit_cmd=:
Chris@40 393
Chris@40 394 # By convention, finish your script with:
Chris@40 395 #
Chris@40 396 # exit $exit_status
Chris@40 397 #
Chris@40 398 # so that you can set exit_status to non-zero if you want to indicate
Chris@40 399 # something went wrong during execution without actually bailing out at
Chris@40 400 # the point of failure.
Chris@40 401 exit_status=$EXIT_SUCCESS
Chris@40 402
Chris@40 403 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
Chris@40 404 # is ksh but when the shell is invoked as "sh" and the current value of
Chris@40 405 # the _XPG environment variable is not equal to 1 (one), the special
Chris@40 406 # positional parameter $0, within a function call, is the name of the
Chris@40 407 # function.
Chris@40 408 progpath=$0
Chris@40 409
Chris@40 410 # The name of this program.
Chris@40 411 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
Chris@40 412
Chris@40 413 # Make sure we have an absolute progpath for reexecution:
Chris@40 414 case $progpath in
Chris@40 415 [\\/]*|[A-Za-z]:\\*) ;;
Chris@40 416 *[\\/]*)
Chris@40 417 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
Chris@40 418 progdir=`cd "$progdir" && pwd`
Chris@40 419 progpath=$progdir/$progname
Chris@40 420 ;;
Chris@40 421 *)
Chris@40 422 _G_IFS=$IFS
Chris@40 423 IFS=${PATH_SEPARATOR-:}
Chris@40 424 for progdir in $PATH; do
Chris@40 425 IFS=$_G_IFS
Chris@40 426 test -x "$progdir/$progname" && break
Chris@40 427 done
Chris@40 428 IFS=$_G_IFS
Chris@40 429 test -n "$progdir" || progdir=`pwd`
Chris@40 430 progpath=$progdir/$progname
Chris@40 431 ;;
Chris@40 432 esac
Chris@40 433
Chris@40 434
Chris@40 435 ## ----------------- ##
Chris@40 436 ## Standard options. ##
Chris@40 437 ## ----------------- ##
Chris@40 438
Chris@40 439 # The following options affect the operation of the functions defined
Chris@40 440 # below, and should be set appropriately depending on run-time para-
Chris@40 441 # meters passed on the command line.
Chris@40 442
Chris@40 443 opt_dry_run=false
Chris@40 444 opt_quiet=false
Chris@40 445 opt_verbose=false
Chris@40 446
Chris@40 447 # Categories 'all' and 'none' are always available. Append any others
Chris@40 448 # you will pass as the first argument to func_warning from your own
Chris@40 449 # code.
Chris@40 450 warning_categories=
Chris@40 451
Chris@40 452 # By default, display warnings according to 'opt_warning_types'. Set
Chris@40 453 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
Chris@40 454 # treat the next displayed warning as a fatal error.
Chris@40 455 warning_func=func_warn_and_continue
Chris@40 456
Chris@40 457 # Set to 'all' to display all warnings, 'none' to suppress all
Chris@40 458 # warnings, or a space delimited list of some subset of
Chris@40 459 # 'warning_categories' to display only the listed warnings.
Chris@40 460 opt_warning_types=all
Chris@40 461
Chris@40 462
Chris@40 463 ## -------------------- ##
Chris@40 464 ## Resource management. ##
Chris@40 465 ## -------------------- ##
Chris@40 466
Chris@40 467 # This section contains definitions for functions that each ensure a
Chris@40 468 # particular resource (a file, or a non-empty configuration variable for
Chris@40 469 # example) is available, and if appropriate to extract default values
Chris@40 470 # from pertinent package files. Call them using their associated
Chris@40 471 # 'require_*' variable to ensure that they are executed, at most, once.
Chris@40 472 #
Chris@40 473 # It's entirely deliberate that calling these functions can set
Chris@40 474 # variables that don't obey the namespace limitations obeyed by the rest
Chris@40 475 # of this file, in order that that they be as useful as possible to
Chris@40 476 # callers.
Chris@40 477
Chris@40 478
Chris@40 479 # require_term_colors
Chris@40 480 # -------------------
Chris@40 481 # Allow display of bold text on terminals that support it.
Chris@40 482 require_term_colors=func_require_term_colors
Chris@40 483 func_require_term_colors ()
Chris@40 484 {
Chris@40 485 $debug_cmd
Chris@40 486
Chris@40 487 test -t 1 && {
Chris@40 488 # COLORTERM and USE_ANSI_COLORS environment variables take
Chris@40 489 # precedence, because most terminfo databases neglect to describe
Chris@40 490 # whether color sequences are supported.
Chris@40 491 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
Chris@40 492
Chris@40 493 if test 1 = "$USE_ANSI_COLORS"; then
Chris@40 494 # Standard ANSI escape sequences
Chris@40 495 tc_reset=''
Chris@40 496 tc_bold=''; tc_standout=''
Chris@40 497 tc_red=''; tc_green=''
Chris@40 498 tc_blue=''; tc_cyan=''
Chris@40 499 else
Chris@40 500 # Otherwise trust the terminfo database after all.
Chris@40 501 test -n "`tput sgr0 2>/dev/null`" && {
Chris@40 502 tc_reset=`tput sgr0`
Chris@40 503 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
Chris@40 504 tc_standout=$tc_bold
Chris@40 505 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
Chris@40 506 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
Chris@40 507 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
Chris@40 508 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
Chris@40 509 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
Chris@40 510 }
Chris@40 511 fi
Chris@40 512 }
Chris@40 513
Chris@40 514 require_term_colors=:
Chris@40 515 }
Chris@40 516
Chris@40 517
Chris@40 518 ## ----------------- ##
Chris@40 519 ## Function library. ##
Chris@40 520 ## ----------------- ##
Chris@40 521
Chris@40 522 # This section contains a variety of useful functions to call in your
Chris@40 523 # scripts. Take note of the portable wrappers for features provided by
Chris@40 524 # some modern shells, which will fall back to slower equivalents on
Chris@40 525 # less featureful shells.
Chris@40 526
Chris@40 527
Chris@40 528 # func_append VAR VALUE
Chris@40 529 # ---------------------
Chris@40 530 # Append VALUE onto the existing contents of VAR.
Chris@40 531
Chris@40 532 # We should try to minimise forks, especially on Windows where they are
Chris@40 533 # unreasonably slow, so skip the feature probes when bash or zsh are
Chris@40 534 # being used:
Chris@40 535 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
Chris@40 536 : ${_G_HAVE_ARITH_OP="yes"}
Chris@40 537 : ${_G_HAVE_XSI_OPS="yes"}
Chris@40 538 # The += operator was introduced in bash 3.1
Chris@40 539 case $BASH_VERSION in
Chris@40 540 [12].* | 3.0 | 3.0*) ;;
Chris@40 541 *)
Chris@40 542 : ${_G_HAVE_PLUSEQ_OP="yes"}
Chris@40 543 ;;
Chris@40 544 esac
Chris@40 545 fi
Chris@40 546
Chris@40 547 # _G_HAVE_PLUSEQ_OP
Chris@40 548 # Can be empty, in which case the shell is probed, "yes" if += is
Chris@40 549 # useable or anything else if it does not work.
Chris@40 550 test -z "$_G_HAVE_PLUSEQ_OP" \
Chris@40 551 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
Chris@40 552 && _G_HAVE_PLUSEQ_OP=yes
Chris@40 553
Chris@40 554 if test yes = "$_G_HAVE_PLUSEQ_OP"
Chris@40 555 then
Chris@40 556 # This is an XSI compatible shell, allowing a faster implementation...
Chris@40 557 eval 'func_append ()
Chris@40 558 {
Chris@40 559 $debug_cmd
Chris@40 560
Chris@40 561 eval "$1+=\$2"
Chris@40 562 }'
Chris@40 563 else
Chris@40 564 # ...otherwise fall back to using expr, which is often a shell builtin.
Chris@40 565 func_append ()
Chris@40 566 {
Chris@40 567 $debug_cmd
Chris@40 568
Chris@40 569 eval "$1=\$$1\$2"
Chris@40 570 }
Chris@40 571 fi
Chris@40 572
Chris@40 573
Chris@40 574 # func_append_quoted VAR VALUE
Chris@40 575 # ----------------------------
Chris@40 576 # Quote VALUE and append to the end of shell variable VAR, separated
Chris@40 577 # by a space.
Chris@40 578 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
Chris@40 579 eval 'func_append_quoted ()
Chris@40 580 {
Chris@40 581 $debug_cmd
Chris@40 582
Chris@40 583 func_quote_for_eval "$2"
Chris@40 584 eval "$1+=\\ \$func_quote_for_eval_result"
Chris@40 585 }'
Chris@40 586 else
Chris@40 587 func_append_quoted ()
Chris@40 588 {
Chris@40 589 $debug_cmd
Chris@40 590
Chris@40 591 func_quote_for_eval "$2"
Chris@40 592 eval "$1=\$$1\\ \$func_quote_for_eval_result"
Chris@40 593 }
Chris@40 594 fi
Chris@40 595
Chris@40 596
Chris@40 597 # func_append_uniq VAR VALUE
Chris@40 598 # --------------------------
Chris@40 599 # Append unique VALUE onto the existing contents of VAR, assuming
Chris@40 600 # entries are delimited by the first character of VALUE. For example:
Chris@40 601 #
Chris@40 602 # func_append_uniq options " --another-option option-argument"
Chris@40 603 #
Chris@40 604 # will only append to $options if " --another-option option-argument "
Chris@40 605 # is not already present somewhere in $options already (note spaces at
Chris@40 606 # each end implied by leading space in second argument).
Chris@40 607 func_append_uniq ()
Chris@40 608 {
Chris@40 609 $debug_cmd
Chris@40 610
Chris@40 611 eval _G_current_value='`$ECHO $'$1'`'
Chris@40 612 _G_delim=`expr "$2" : '\(.\)'`
Chris@40 613
Chris@40 614 case $_G_delim$_G_current_value$_G_delim in
Chris@40 615 *"$2$_G_delim"*) ;;
Chris@40 616 *) func_append "$@" ;;
Chris@40 617 esac
Chris@40 618 }
Chris@40 619
Chris@40 620
Chris@40 621 # func_arith TERM...
Chris@40 622 # ------------------
Chris@40 623 # Set func_arith_result to the result of evaluating TERMs.
Chris@40 624 test -z "$_G_HAVE_ARITH_OP" \
Chris@40 625 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
Chris@40 626 && _G_HAVE_ARITH_OP=yes
Chris@40 627
Chris@40 628 if test yes = "$_G_HAVE_ARITH_OP"; then
Chris@40 629 eval 'func_arith ()
Chris@40 630 {
Chris@40 631 $debug_cmd
Chris@40 632
Chris@40 633 func_arith_result=$(( $* ))
Chris@40 634 }'
Chris@40 635 else
Chris@40 636 func_arith ()
Chris@40 637 {
Chris@40 638 $debug_cmd
Chris@40 639
Chris@40 640 func_arith_result=`expr "$@"`
Chris@40 641 }
Chris@40 642 fi
Chris@40 643
Chris@40 644
Chris@40 645 # func_basename FILE
Chris@40 646 # ------------------
Chris@40 647 # Set func_basename_result to FILE with everything up to and including
Chris@40 648 # the last / stripped.
Chris@40 649 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@40 650 # If this shell supports suffix pattern removal, then use it to avoid
Chris@40 651 # forking. Hide the definitions single quotes in case the shell chokes
Chris@40 652 # on unsupported syntax...
Chris@40 653 _b='func_basename_result=${1##*/}'
Chris@40 654 _d='case $1 in
Chris@40 655 */*) func_dirname_result=${1%/*}$2 ;;
Chris@40 656 * ) func_dirname_result=$3 ;;
Chris@40 657 esac'
Chris@40 658
Chris@40 659 else
Chris@40 660 # ...otherwise fall back to using sed.
Chris@40 661 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
Chris@40 662 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
Chris@40 663 if test "X$func_dirname_result" = "X$1"; then
Chris@40 664 func_dirname_result=$3
Chris@40 665 else
Chris@40 666 func_append func_dirname_result "$2"
Chris@40 667 fi'
Chris@40 668 fi
Chris@40 669
Chris@40 670 eval 'func_basename ()
Chris@40 671 {
Chris@40 672 $debug_cmd
Chris@40 673
Chris@40 674 '"$_b"'
Chris@40 675 }'
Chris@40 676
Chris@40 677
Chris@40 678 # func_dirname FILE APPEND NONDIR_REPLACEMENT
Chris@40 679 # -------------------------------------------
Chris@40 680 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
Chris@40 681 # otherwise set result to NONDIR_REPLACEMENT.
Chris@40 682 eval 'func_dirname ()
Chris@40 683 {
Chris@40 684 $debug_cmd
Chris@40 685
Chris@40 686 '"$_d"'
Chris@40 687 }'
Chris@40 688
Chris@40 689
Chris@40 690 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
Chris@40 691 # --------------------------------------------------------
Chris@40 692 # Perform func_basename and func_dirname in a single function
Chris@40 693 # call:
Chris@40 694 # dirname: Compute the dirname of FILE. If nonempty,
Chris@40 695 # add APPEND to the result, otherwise set result
Chris@40 696 # to NONDIR_REPLACEMENT.
Chris@40 697 # value returned in "$func_dirname_result"
Chris@40 698 # basename: Compute filename of FILE.
Chris@40 699 # value retuned in "$func_basename_result"
Chris@40 700 # For efficiency, we do not delegate to the functions above but instead
Chris@40 701 # duplicate the functionality here.
Chris@40 702 eval 'func_dirname_and_basename ()
Chris@40 703 {
Chris@40 704 $debug_cmd
Chris@40 705
Chris@40 706 '"$_b"'
Chris@40 707 '"$_d"'
Chris@40 708 }'
Chris@40 709
Chris@40 710
Chris@40 711 # func_echo ARG...
Chris@40 712 # ----------------
Chris@40 713 # Echo program name prefixed message.
Chris@40 714 func_echo ()
Chris@40 715 {
Chris@40 716 $debug_cmd
Chris@40 717
Chris@40 718 _G_message=$*
Chris@40 719
Chris@40 720 func_echo_IFS=$IFS
Chris@40 721 IFS=$nl
Chris@40 722 for _G_line in $_G_message; do
Chris@40 723 IFS=$func_echo_IFS
Chris@40 724 $ECHO "$progname: $_G_line"
Chris@40 725 done
Chris@40 726 IFS=$func_echo_IFS
Chris@40 727 }
Chris@40 728
Chris@40 729
Chris@40 730 # func_echo_all ARG...
Chris@40 731 # --------------------
Chris@40 732 # Invoke $ECHO with all args, space-separated.
Chris@40 733 func_echo_all ()
Chris@40 734 {
Chris@40 735 $ECHO "$*"
Chris@40 736 }
Chris@40 737
Chris@40 738
Chris@40 739 # func_echo_infix_1 INFIX ARG...
Chris@40 740 # ------------------------------
Chris@40 741 # Echo program name, followed by INFIX on the first line, with any
Chris@40 742 # additional lines not showing INFIX.
Chris@40 743 func_echo_infix_1 ()
Chris@40 744 {
Chris@40 745 $debug_cmd
Chris@40 746
Chris@40 747 $require_term_colors
Chris@40 748
Chris@40 749 _G_infix=$1; shift
Chris@40 750 _G_indent=$_G_infix
Chris@40 751 _G_prefix="$progname: $_G_infix: "
Chris@40 752 _G_message=$*
Chris@40 753
Chris@40 754 # Strip color escape sequences before counting printable length
Chris@40 755 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
Chris@40 756 do
Chris@40 757 test -n "$_G_tc" && {
Chris@40 758 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
Chris@40 759 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
Chris@40 760 }
Chris@40 761 done
Chris@40 762 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
Chris@40 763
Chris@40 764 func_echo_infix_1_IFS=$IFS
Chris@40 765 IFS=$nl
Chris@40 766 for _G_line in $_G_message; do
Chris@40 767 IFS=$func_echo_infix_1_IFS
Chris@40 768 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
Chris@40 769 _G_prefix=$_G_indent
Chris@40 770 done
Chris@40 771 IFS=$func_echo_infix_1_IFS
Chris@40 772 }
Chris@40 773
Chris@40 774
Chris@40 775 # func_error ARG...
Chris@40 776 # -----------------
Chris@40 777 # Echo program name prefixed message to standard error.
Chris@40 778 func_error ()
Chris@40 779 {
Chris@40 780 $debug_cmd
Chris@40 781
Chris@40 782 $require_term_colors
Chris@40 783
Chris@40 784 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
Chris@40 785 }
Chris@40 786
Chris@40 787
Chris@40 788 # func_fatal_error ARG...
Chris@40 789 # -----------------------
Chris@40 790 # Echo program name prefixed message to standard error, and exit.
Chris@40 791 func_fatal_error ()
Chris@40 792 {
Chris@40 793 $debug_cmd
Chris@40 794
Chris@40 795 func_error "$*"
Chris@40 796 exit $EXIT_FAILURE
Chris@40 797 }
Chris@40 798
Chris@40 799
Chris@40 800 # func_grep EXPRESSION FILENAME
Chris@40 801 # -----------------------------
Chris@40 802 # Check whether EXPRESSION matches any line of FILENAME, without output.
Chris@40 803 func_grep ()
Chris@40 804 {
Chris@40 805 $debug_cmd
Chris@40 806
Chris@40 807 $GREP "$1" "$2" >/dev/null 2>&1
Chris@40 808 }
Chris@40 809
Chris@40 810
Chris@40 811 # func_len STRING
Chris@40 812 # ---------------
Chris@40 813 # Set func_len_result to the length of STRING. STRING may not
Chris@40 814 # start with a hyphen.
Chris@40 815 test -z "$_G_HAVE_XSI_OPS" \
Chris@40 816 && (eval 'x=a/b/c;
Chris@40 817 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
Chris@40 818 && _G_HAVE_XSI_OPS=yes
Chris@40 819
Chris@40 820 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@40 821 eval 'func_len ()
Chris@40 822 {
Chris@40 823 $debug_cmd
Chris@40 824
Chris@40 825 func_len_result=${#1}
Chris@40 826 }'
Chris@40 827 else
Chris@40 828 func_len ()
Chris@40 829 {
Chris@40 830 $debug_cmd
Chris@40 831
Chris@40 832 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
Chris@40 833 }
Chris@40 834 fi
Chris@40 835
Chris@40 836
Chris@40 837 # func_mkdir_p DIRECTORY-PATH
Chris@40 838 # ---------------------------
Chris@40 839 # Make sure the entire path to DIRECTORY-PATH is available.
Chris@40 840 func_mkdir_p ()
Chris@40 841 {
Chris@40 842 $debug_cmd
Chris@40 843
Chris@40 844 _G_directory_path=$1
Chris@40 845 _G_dir_list=
Chris@40 846
Chris@40 847 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
Chris@40 848
Chris@40 849 # Protect directory names starting with '-'
Chris@40 850 case $_G_directory_path in
Chris@40 851 -*) _G_directory_path=./$_G_directory_path ;;
Chris@40 852 esac
Chris@40 853
Chris@40 854 # While some portion of DIR does not yet exist...
Chris@40 855 while test ! -d "$_G_directory_path"; do
Chris@40 856 # ...make a list in topmost first order. Use a colon delimited
Chris@40 857 # list incase some portion of path contains whitespace.
Chris@40 858 _G_dir_list=$_G_directory_path:$_G_dir_list
Chris@40 859
Chris@40 860 # If the last portion added has no slash in it, the list is done
Chris@40 861 case $_G_directory_path in */*) ;; *) break ;; esac
Chris@40 862
Chris@40 863 # ...otherwise throw away the child directory and loop
Chris@40 864 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
Chris@40 865 done
Chris@40 866 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
Chris@40 867
Chris@40 868 func_mkdir_p_IFS=$IFS; IFS=:
Chris@40 869 for _G_dir in $_G_dir_list; do
Chris@40 870 IFS=$func_mkdir_p_IFS
Chris@40 871 # mkdir can fail with a 'File exist' error if two processes
Chris@40 872 # try to create one of the directories concurrently. Don't
Chris@40 873 # stop in that case!
Chris@40 874 $MKDIR "$_G_dir" 2>/dev/null || :
Chris@40 875 done
Chris@40 876 IFS=$func_mkdir_p_IFS
Chris@40 877
Chris@40 878 # Bail out if we (or some other process) failed to create a directory.
Chris@40 879 test -d "$_G_directory_path" || \
Chris@40 880 func_fatal_error "Failed to create '$1'"
Chris@40 881 fi
Chris@40 882 }
Chris@40 883
Chris@40 884
Chris@40 885 # func_mktempdir [BASENAME]
Chris@40 886 # -------------------------
Chris@40 887 # Make a temporary directory that won't clash with other running
Chris@40 888 # libtool processes, and avoids race conditions if possible. If
Chris@40 889 # given, BASENAME is the basename for that directory.
Chris@40 890 func_mktempdir ()
Chris@40 891 {
Chris@40 892 $debug_cmd
Chris@40 893
Chris@40 894 _G_template=${TMPDIR-/tmp}/${1-$progname}
Chris@40 895
Chris@40 896 if test : = "$opt_dry_run"; then
Chris@40 897 # Return a directory name, but don't create it in dry-run mode
Chris@40 898 _G_tmpdir=$_G_template-$$
Chris@40 899 else
Chris@40 900
Chris@40 901 # If mktemp works, use that first and foremost
Chris@40 902 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
Chris@40 903
Chris@40 904 if test ! -d "$_G_tmpdir"; then
Chris@40 905 # Failing that, at least try and use $RANDOM to avoid a race
Chris@40 906 _G_tmpdir=$_G_template-${RANDOM-0}$$
Chris@40 907
Chris@40 908 func_mktempdir_umask=`umask`
Chris@40 909 umask 0077
Chris@40 910 $MKDIR "$_G_tmpdir"
Chris@40 911 umask $func_mktempdir_umask
Chris@40 912 fi
Chris@40 913
Chris@40 914 # If we're not in dry-run mode, bomb out on failure
Chris@40 915 test -d "$_G_tmpdir" || \
Chris@40 916 func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
Chris@40 917 fi
Chris@40 918
Chris@40 919 $ECHO "$_G_tmpdir"
Chris@40 920 }
Chris@40 921
Chris@40 922
Chris@40 923 # func_normal_abspath PATH
Chris@40 924 # ------------------------
Chris@40 925 # Remove doubled-up and trailing slashes, "." path components,
Chris@40 926 # and cancel out any ".." path components in PATH after making
Chris@40 927 # it an absolute path.
Chris@40 928 func_normal_abspath ()
Chris@40 929 {
Chris@40 930 $debug_cmd
Chris@40 931
Chris@40 932 # These SED scripts presuppose an absolute path with a trailing slash.
Chris@40 933 _G_pathcar='s|^/\([^/]*\).*$|\1|'
Chris@40 934 _G_pathcdr='s|^/[^/]*||'
Chris@40 935 _G_removedotparts=':dotsl
Chris@40 936 s|/\./|/|g
Chris@40 937 t dotsl
Chris@40 938 s|/\.$|/|'
Chris@40 939 _G_collapseslashes='s|/\{1,\}|/|g'
Chris@40 940 _G_finalslash='s|/*$|/|'
Chris@40 941
Chris@40 942 # Start from root dir and reassemble the path.
Chris@40 943 func_normal_abspath_result=
Chris@40 944 func_normal_abspath_tpath=$1
Chris@40 945 func_normal_abspath_altnamespace=
Chris@40 946 case $func_normal_abspath_tpath in
Chris@40 947 "")
Chris@40 948 # Empty path, that just means $cwd.
Chris@40 949 func_stripname '' '/' "`pwd`"
Chris@40 950 func_normal_abspath_result=$func_stripname_result
Chris@40 951 return
Chris@40 952 ;;
Chris@40 953 # The next three entries are used to spot a run of precisely
Chris@40 954 # two leading slashes without using negated character classes;
Chris@40 955 # we take advantage of case's first-match behaviour.
Chris@40 956 ///*)
Chris@40 957 # Unusual form of absolute path, do nothing.
Chris@40 958 ;;
Chris@40 959 //*)
Chris@40 960 # Not necessarily an ordinary path; POSIX reserves leading '//'
Chris@40 961 # and for example Cygwin uses it to access remote file shares
Chris@40 962 # over CIFS/SMB, so we conserve a leading double slash if found.
Chris@40 963 func_normal_abspath_altnamespace=/
Chris@40 964 ;;
Chris@40 965 /*)
Chris@40 966 # Absolute path, do nothing.
Chris@40 967 ;;
Chris@40 968 *)
Chris@40 969 # Relative path, prepend $cwd.
Chris@40 970 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
Chris@40 971 ;;
Chris@40 972 esac
Chris@40 973
Chris@40 974 # Cancel out all the simple stuff to save iterations. We also want
Chris@40 975 # the path to end with a slash for ease of parsing, so make sure
Chris@40 976 # there is one (and only one) here.
Chris@40 977 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
Chris@40 978 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
Chris@40 979 while :; do
Chris@40 980 # Processed it all yet?
Chris@40 981 if test / = "$func_normal_abspath_tpath"; then
Chris@40 982 # If we ascended to the root using ".." the result may be empty now.
Chris@40 983 if test -z "$func_normal_abspath_result"; then
Chris@40 984 func_normal_abspath_result=/
Chris@40 985 fi
Chris@40 986 break
Chris@40 987 fi
Chris@40 988 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
Chris@40 989 -e "$_G_pathcar"`
Chris@40 990 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
Chris@40 991 -e "$_G_pathcdr"`
Chris@40 992 # Figure out what to do with it
Chris@40 993 case $func_normal_abspath_tcomponent in
Chris@40 994 "")
Chris@40 995 # Trailing empty path component, ignore it.
Chris@40 996 ;;
Chris@40 997 ..)
Chris@40 998 # Parent dir; strip last assembled component from result.
Chris@40 999 func_dirname "$func_normal_abspath_result"
Chris@40 1000 func_normal_abspath_result=$func_dirname_result
Chris@40 1001 ;;
Chris@40 1002 *)
Chris@40 1003 # Actual path component, append it.
Chris@40 1004 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
Chris@40 1005 ;;
Chris@40 1006 esac
Chris@40 1007 done
Chris@40 1008 # Restore leading double-slash if one was found on entry.
Chris@40 1009 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
Chris@40 1010 }
Chris@40 1011
Chris@40 1012
Chris@40 1013 # func_notquiet ARG...
Chris@40 1014 # --------------------
Chris@40 1015 # Echo program name prefixed message only when not in quiet mode.
Chris@40 1016 func_notquiet ()
Chris@40 1017 {
Chris@40 1018 $debug_cmd
Chris@40 1019
Chris@40 1020 $opt_quiet || func_echo ${1+"$@"}
Chris@40 1021
Chris@40 1022 # A bug in bash halts the script if the last line of a function
Chris@40 1023 # fails when set -e is in force, so we need another command to
Chris@40 1024 # work around that:
Chris@40 1025 :
Chris@40 1026 }
Chris@40 1027
Chris@40 1028
Chris@40 1029 # func_relative_path SRCDIR DSTDIR
Chris@40 1030 # --------------------------------
Chris@40 1031 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
Chris@40 1032 func_relative_path ()
Chris@40 1033 {
Chris@40 1034 $debug_cmd
Chris@40 1035
Chris@40 1036 func_relative_path_result=
Chris@40 1037 func_normal_abspath "$1"
Chris@40 1038 func_relative_path_tlibdir=$func_normal_abspath_result
Chris@40 1039 func_normal_abspath "$2"
Chris@40 1040 func_relative_path_tbindir=$func_normal_abspath_result
Chris@40 1041
Chris@40 1042 # Ascend the tree starting from libdir
Chris@40 1043 while :; do
Chris@40 1044 # check if we have found a prefix of bindir
Chris@40 1045 case $func_relative_path_tbindir in
Chris@40 1046 $func_relative_path_tlibdir)
Chris@40 1047 # found an exact match
Chris@40 1048 func_relative_path_tcancelled=
Chris@40 1049 break
Chris@40 1050 ;;
Chris@40 1051 $func_relative_path_tlibdir*)
Chris@40 1052 # found a matching prefix
Chris@40 1053 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
Chris@40 1054 func_relative_path_tcancelled=$func_stripname_result
Chris@40 1055 if test -z "$func_relative_path_result"; then
Chris@40 1056 func_relative_path_result=.
Chris@40 1057 fi
Chris@40 1058 break
Chris@40 1059 ;;
Chris@40 1060 *)
Chris@40 1061 func_dirname $func_relative_path_tlibdir
Chris@40 1062 func_relative_path_tlibdir=$func_dirname_result
Chris@40 1063 if test -z "$func_relative_path_tlibdir"; then
Chris@40 1064 # Have to descend all the way to the root!
Chris@40 1065 func_relative_path_result=../$func_relative_path_result
Chris@40 1066 func_relative_path_tcancelled=$func_relative_path_tbindir
Chris@40 1067 break
Chris@40 1068 fi
Chris@40 1069 func_relative_path_result=../$func_relative_path_result
Chris@40 1070 ;;
Chris@40 1071 esac
Chris@40 1072 done
Chris@40 1073
Chris@40 1074 # Now calculate path; take care to avoid doubling-up slashes.
Chris@40 1075 func_stripname '' '/' "$func_relative_path_result"
Chris@40 1076 func_relative_path_result=$func_stripname_result
Chris@40 1077 func_stripname '/' '/' "$func_relative_path_tcancelled"
Chris@40 1078 if test -n "$func_stripname_result"; then
Chris@40 1079 func_append func_relative_path_result "/$func_stripname_result"
Chris@40 1080 fi
Chris@40 1081
Chris@40 1082 # Normalisation. If bindir is libdir, return '.' else relative path.
Chris@40 1083 if test -n "$func_relative_path_result"; then
Chris@40 1084 func_stripname './' '' "$func_relative_path_result"
Chris@40 1085 func_relative_path_result=$func_stripname_result
Chris@40 1086 fi
Chris@40 1087
Chris@40 1088 test -n "$func_relative_path_result" || func_relative_path_result=.
Chris@40 1089
Chris@40 1090 :
Chris@40 1091 }
Chris@40 1092
Chris@40 1093
Chris@40 1094 # func_quote_for_eval ARG...
Chris@40 1095 # --------------------------
Chris@40 1096 # Aesthetically quote ARGs to be evaled later.
Chris@40 1097 # This function returns two values:
Chris@40 1098 # i) func_quote_for_eval_result
Chris@40 1099 # double-quoted, suitable for a subsequent eval
Chris@40 1100 # ii) func_quote_for_eval_unquoted_result
Chris@40 1101 # has all characters that are still active within double
Chris@40 1102 # quotes backslashified.
Chris@40 1103 func_quote_for_eval ()
Chris@40 1104 {
Chris@40 1105 $debug_cmd
Chris@40 1106
Chris@40 1107 func_quote_for_eval_unquoted_result=
Chris@40 1108 func_quote_for_eval_result=
Chris@40 1109 while test 0 -lt $#; do
Chris@40 1110 case $1 in
Chris@40 1111 *[\\\`\"\$]*)
Chris@40 1112 _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
Chris@40 1113 *)
Chris@40 1114 _G_unquoted_arg=$1 ;;
Chris@40 1115 esac
Chris@40 1116 if test -n "$func_quote_for_eval_unquoted_result"; then
Chris@40 1117 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
Chris@40 1118 else
Chris@40 1119 func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
Chris@40 1120 fi
Chris@40 1121
Chris@40 1122 case $_G_unquoted_arg in
Chris@40 1123 # Double-quote args containing shell metacharacters to delay
Chris@40 1124 # word splitting, command substitution and variable expansion
Chris@40 1125 # for a subsequent eval.
Chris@40 1126 # Many Bourne shells cannot handle close brackets correctly
Chris@40 1127 # in scan sets, so we specify it separately.
Chris@40 1128 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
Chris@40 1129 _G_quoted_arg=\"$_G_unquoted_arg\"
Chris@40 1130 ;;
Chris@40 1131 *)
Chris@40 1132 _G_quoted_arg=$_G_unquoted_arg
Chris@40 1133 ;;
Chris@40 1134 esac
Chris@40 1135
Chris@40 1136 if test -n "$func_quote_for_eval_result"; then
Chris@40 1137 func_append func_quote_for_eval_result " $_G_quoted_arg"
Chris@40 1138 else
Chris@40 1139 func_append func_quote_for_eval_result "$_G_quoted_arg"
Chris@40 1140 fi
Chris@40 1141 shift
Chris@40 1142 done
Chris@40 1143 }
Chris@40 1144
Chris@40 1145
Chris@40 1146 # func_quote_for_expand ARG
Chris@40 1147 # -------------------------
Chris@40 1148 # Aesthetically quote ARG to be evaled later; same as above,
Chris@40 1149 # but do not quote variable references.
Chris@40 1150 func_quote_for_expand ()
Chris@40 1151 {
Chris@40 1152 $debug_cmd
Chris@40 1153
Chris@40 1154 case $1 in
Chris@40 1155 *[\\\`\"]*)
Chris@40 1156 _G_arg=`$ECHO "$1" | $SED \
Chris@40 1157 -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
Chris@40 1158 *)
Chris@40 1159 _G_arg=$1 ;;
Chris@40 1160 esac
Chris@40 1161
Chris@40 1162 case $_G_arg in
Chris@40 1163 # Double-quote args containing shell metacharacters to delay
Chris@40 1164 # word splitting and command substitution for a subsequent eval.
Chris@40 1165 # Many Bourne shells cannot handle close brackets correctly
Chris@40 1166 # in scan sets, so we specify it separately.
Chris@40 1167 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
Chris@40 1168 _G_arg=\"$_G_arg\"
Chris@40 1169 ;;
Chris@40 1170 esac
Chris@40 1171
Chris@40 1172 func_quote_for_expand_result=$_G_arg
Chris@40 1173 }
Chris@40 1174
Chris@40 1175
Chris@40 1176 # func_stripname PREFIX SUFFIX NAME
Chris@40 1177 # ---------------------------------
Chris@40 1178 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
Chris@40 1179 # PREFIX and SUFFIX must not contain globbing or regex special
Chris@40 1180 # characters, hashes, percent signs, but SUFFIX may contain a leading
Chris@40 1181 # dot (in which case that matches only a dot).
Chris@40 1182 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@40 1183 eval 'func_stripname ()
Chris@40 1184 {
Chris@40 1185 $debug_cmd
Chris@40 1186
Chris@40 1187 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
Chris@40 1188 # positional parameters, so assign one to ordinary variable first.
Chris@40 1189 func_stripname_result=$3
Chris@40 1190 func_stripname_result=${func_stripname_result#"$1"}
Chris@40 1191 func_stripname_result=${func_stripname_result%"$2"}
Chris@40 1192 }'
Chris@40 1193 else
Chris@40 1194 func_stripname ()
Chris@40 1195 {
Chris@40 1196 $debug_cmd
Chris@40 1197
Chris@40 1198 case $2 in
Chris@40 1199 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
Chris@40 1200 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
Chris@40 1201 esac
Chris@40 1202 }
Chris@40 1203 fi
Chris@40 1204
Chris@40 1205
Chris@40 1206 # func_show_eval CMD [FAIL_EXP]
Chris@40 1207 # -----------------------------
Chris@40 1208 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
Chris@40 1209 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
Chris@40 1210 # is given, then evaluate it.
Chris@40 1211 func_show_eval ()
Chris@40 1212 {
Chris@40 1213 $debug_cmd
Chris@40 1214
Chris@40 1215 _G_cmd=$1
Chris@40 1216 _G_fail_exp=${2-':'}
Chris@40 1217
Chris@40 1218 func_quote_for_expand "$_G_cmd"
Chris@40 1219 eval "func_notquiet $func_quote_for_expand_result"
Chris@40 1220
Chris@40 1221 $opt_dry_run || {
Chris@40 1222 eval "$_G_cmd"
Chris@40 1223 _G_status=$?
Chris@40 1224 if test 0 -ne "$_G_status"; then
Chris@40 1225 eval "(exit $_G_status); $_G_fail_exp"
Chris@40 1226 fi
Chris@40 1227 }
Chris@40 1228 }
Chris@40 1229
Chris@40 1230
Chris@40 1231 # func_show_eval_locale CMD [FAIL_EXP]
Chris@40 1232 # ------------------------------------
Chris@40 1233 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
Chris@40 1234 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
Chris@40 1235 # is given, then evaluate it. Use the saved locale for evaluation.
Chris@40 1236 func_show_eval_locale ()
Chris@40 1237 {
Chris@40 1238 $debug_cmd
Chris@40 1239
Chris@40 1240 _G_cmd=$1
Chris@40 1241 _G_fail_exp=${2-':'}
Chris@40 1242
Chris@40 1243 $opt_quiet || {
Chris@40 1244 func_quote_for_expand "$_G_cmd"
Chris@40 1245 eval "func_echo $func_quote_for_expand_result"
Chris@40 1246 }
Chris@40 1247
Chris@40 1248 $opt_dry_run || {
Chris@40 1249 eval "$_G_user_locale
Chris@40 1250 $_G_cmd"
Chris@40 1251 _G_status=$?
Chris@40 1252 eval "$_G_safe_locale"
Chris@40 1253 if test 0 -ne "$_G_status"; then
Chris@40 1254 eval "(exit $_G_status); $_G_fail_exp"
Chris@40 1255 fi
Chris@40 1256 }
Chris@40 1257 }
Chris@40 1258
Chris@40 1259
Chris@40 1260 # func_tr_sh
Chris@40 1261 # ----------
Chris@40 1262 # Turn $1 into a string suitable for a shell variable name.
Chris@40 1263 # Result is stored in $func_tr_sh_result. All characters
Chris@40 1264 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
Chris@40 1265 # if $1 begins with a digit, a '_' is prepended as well.
Chris@40 1266 func_tr_sh ()
Chris@40 1267 {
Chris@40 1268 $debug_cmd
Chris@40 1269
Chris@40 1270 case $1 in
Chris@40 1271 [0-9]* | *[!a-zA-Z0-9_]*)
Chris@40 1272 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
Chris@40 1273 ;;
Chris@40 1274 * )
Chris@40 1275 func_tr_sh_result=$1
Chris@40 1276 ;;
Chris@40 1277 esac
Chris@40 1278 }
Chris@40 1279
Chris@40 1280
Chris@40 1281 # func_verbose ARG...
Chris@40 1282 # -------------------
Chris@40 1283 # Echo program name prefixed message in verbose mode only.
Chris@40 1284 func_verbose ()
Chris@40 1285 {
Chris@40 1286 $debug_cmd
Chris@40 1287
Chris@40 1288 $opt_verbose && func_echo "$*"
Chris@40 1289
Chris@40 1290 :
Chris@40 1291 }
Chris@40 1292
Chris@40 1293
Chris@40 1294 # func_warn_and_continue ARG...
Chris@40 1295 # -----------------------------
Chris@40 1296 # Echo program name prefixed warning message to standard error.
Chris@40 1297 func_warn_and_continue ()
Chris@40 1298 {
Chris@40 1299 $debug_cmd
Chris@40 1300
Chris@40 1301 $require_term_colors
Chris@40 1302
Chris@40 1303 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
Chris@40 1304 }
Chris@40 1305
Chris@40 1306
Chris@40 1307 # func_warning CATEGORY ARG...
Chris@40 1308 # ----------------------------
Chris@40 1309 # Echo program name prefixed warning message to standard error. Warning
Chris@40 1310 # messages can be filtered according to CATEGORY, where this function
Chris@40 1311 # elides messages where CATEGORY is not listed in the global variable
Chris@40 1312 # 'opt_warning_types'.
Chris@40 1313 func_warning ()
Chris@40 1314 {
Chris@40 1315 $debug_cmd
Chris@40 1316
Chris@40 1317 # CATEGORY must be in the warning_categories list!
Chris@40 1318 case " $warning_categories " in
Chris@40 1319 *" $1 "*) ;;
Chris@40 1320 *) func_internal_error "invalid warning category '$1'" ;;
Chris@40 1321 esac
Chris@40 1322
Chris@40 1323 _G_category=$1
Chris@40 1324 shift
Chris@40 1325
Chris@40 1326 case " $opt_warning_types " in
Chris@40 1327 *" $_G_category "*) $warning_func ${1+"$@"} ;;
Chris@40 1328 esac
Chris@40 1329 }
Chris@40 1330
Chris@40 1331
Chris@40 1332 # func_sort_ver VER1 VER2
Chris@40 1333 # -----------------------
Chris@40 1334 # 'sort -V' is not generally available.
Chris@40 1335 # Note this deviates from the version comparison in automake
Chris@40 1336 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
Chris@40 1337 # but this should suffice as we won't be specifying old
Chris@40 1338 # version formats or redundant trailing .0 in bootstrap.conf.
Chris@40 1339 # If we did want full compatibility then we should probably
Chris@40 1340 # use m4_version_compare from autoconf.
Chris@40 1341 func_sort_ver ()
Chris@40 1342 {
Chris@40 1343 $debug_cmd
Chris@40 1344
Chris@40 1345 printf '%s\n%s\n' "$1" "$2" \
Chris@40 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@40 1347 }
Chris@40 1348
Chris@40 1349 # func_lt_ver PREV CURR
Chris@40 1350 # ---------------------
Chris@40 1351 # Return true if PREV and CURR are in the correct order according to
Chris@40 1352 # func_sort_ver, otherwise false. Use it like this:
Chris@40 1353 #
Chris@40 1354 # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
Chris@40 1355 func_lt_ver ()
Chris@40 1356 {
Chris@40 1357 $debug_cmd
Chris@40 1358
Chris@40 1359 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
Chris@40 1360 }
Chris@40 1361
Chris@40 1362
Chris@40 1363 # Local variables:
Chris@40 1364 # mode: shell-script
Chris@40 1365 # sh-indentation: 2
Chris@40 1366 # eval: (add-hook 'before-save-hook 'time-stamp)
Chris@40 1367 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
Chris@40 1368 # time-stamp-time-zone: "UTC"
Chris@40 1369 # End:
Chris@40 1370 #! /bin/sh
Chris@40 1371
Chris@40 1372 # Set a version string for this script.
Chris@40 1373 scriptversion=2014-01-07.03; # UTC
Chris@40 1374
Chris@40 1375 # A portable, pluggable option parser for Bourne shell.
Chris@40 1376 # Written by Gary V. Vaughan, 2010
Chris@40 1377
Chris@40 1378 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
Chris@40 1379 # This is free software; see the source for copying conditions. There is NO
Chris@40 1380 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chris@40 1381
Chris@40 1382 # This program is free software: you can redistribute it and/or modify
Chris@40 1383 # it under the terms of the GNU General Public License as published by
Chris@40 1384 # the Free Software Foundation, either version 3 of the License, or
Chris@40 1385 # (at your option) any later version.
Chris@40 1386
Chris@40 1387 # This program is distributed in the hope that it will be useful,
Chris@40 1388 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@40 1389 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@40 1390 # GNU General Public License for more details.
Chris@40 1391
Chris@40 1392 # You should have received a copy of the GNU General Public License
Chris@40 1393 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@40 1394
Chris@40 1395 # Please report bugs or propose patches to gary@gnu.org.
Chris@40 1396
Chris@40 1397
Chris@40 1398 ## ------ ##
Chris@40 1399 ## Usage. ##
Chris@40 1400 ## ------ ##
Chris@40 1401
Chris@40 1402 # This file is a library for parsing options in your shell scripts along
Chris@40 1403 # with assorted other useful supporting features that you can make use
Chris@40 1404 # of too.
Chris@40 1405 #
Chris@40 1406 # For the simplest scripts you might need only:
Chris@40 1407 #
Chris@40 1408 # #!/bin/sh
Chris@40 1409 # . relative/path/to/funclib.sh
Chris@40 1410 # . relative/path/to/options-parser
Chris@40 1411 # scriptversion=1.0
Chris@40 1412 # func_options ${1+"$@"}
Chris@40 1413 # eval set dummy "$func_options_result"; shift
Chris@40 1414 # ...rest of your script...
Chris@40 1415 #
Chris@40 1416 # In order for the '--version' option to work, you will need to have a
Chris@40 1417 # suitably formatted comment like the one at the top of this file
Chris@40 1418 # starting with '# Written by ' and ending with '# warranty; '.
Chris@40 1419 #
Chris@40 1420 # For '-h' and '--help' to work, you will also need a one line
Chris@40 1421 # description of your script's purpose in a comment directly above the
Chris@40 1422 # '# Written by ' line, like the one at the top of this file.
Chris@40 1423 #
Chris@40 1424 # The default options also support '--debug', which will turn on shell
Chris@40 1425 # execution tracing (see the comment above debug_cmd below for another
Chris@40 1426 # use), and '--verbose' and the func_verbose function to allow your script
Chris@40 1427 # to display verbose messages only when your user has specified
Chris@40 1428 # '--verbose'.
Chris@40 1429 #
Chris@40 1430 # After sourcing this file, you can plug processing for additional
Chris@40 1431 # options by amending the variables from the 'Configuration' section
Chris@40 1432 # below, and following the instructions in the 'Option parsing'
Chris@40 1433 # section further down.
Chris@40 1434
Chris@40 1435 ## -------------- ##
Chris@40 1436 ## Configuration. ##
Chris@40 1437 ## -------------- ##
Chris@40 1438
Chris@40 1439 # You should override these variables in your script after sourcing this
Chris@40 1440 # file so that they reflect the customisations you have added to the
Chris@40 1441 # option parser.
Chris@40 1442
Chris@40 1443 # The usage line for option parsing errors and the start of '-h' and
Chris@40 1444 # '--help' output messages. You can embed shell variables for delayed
Chris@40 1445 # expansion at the time the message is displayed, but you will need to
Chris@40 1446 # quote other shell meta-characters carefully to prevent them being
Chris@40 1447 # expanded when the contents are evaled.
Chris@40 1448 usage='$progpath [OPTION]...'
Chris@40 1449
Chris@40 1450 # Short help message in response to '-h' and '--help'. Add to this or
Chris@40 1451 # override it after sourcing this library to reflect the full set of
Chris@40 1452 # options your script accepts.
Chris@40 1453 usage_message="\
Chris@40 1454 --debug enable verbose shell tracing
Chris@40 1455 -W, --warnings=CATEGORY
Chris@40 1456 report the warnings falling in CATEGORY [all]
Chris@40 1457 -v, --verbose verbosely report processing
Chris@40 1458 --version print version information and exit
Chris@40 1459 -h, --help print short or long help message and exit
Chris@40 1460 "
Chris@40 1461
Chris@40 1462 # Additional text appended to 'usage_message' in response to '--help'.
Chris@40 1463 long_help_message="
Chris@40 1464 Warning categories include:
Chris@40 1465 'all' show all warnings
Chris@40 1466 'none' turn off all the warnings
Chris@40 1467 'error' warnings are treated as fatal errors"
Chris@40 1468
Chris@40 1469 # Help message printed before fatal option parsing errors.
Chris@40 1470 fatal_help="Try '\$progname --help' for more information."
Chris@40 1471
Chris@40 1472
Chris@40 1473
Chris@40 1474 ## ------------------------- ##
Chris@40 1475 ## Hook function management. ##
Chris@40 1476 ## ------------------------- ##
Chris@40 1477
Chris@40 1478 # This section contains functions for adding, removing, and running hooks
Chris@40 1479 # to the main code. A hook is just a named list of of function, that can
Chris@40 1480 # be run in order later on.
Chris@40 1481
Chris@40 1482 # func_hookable FUNC_NAME
Chris@40 1483 # -----------------------
Chris@40 1484 # Declare that FUNC_NAME will run hooks added with
Chris@40 1485 # 'func_add_hook FUNC_NAME ...'.
Chris@40 1486 func_hookable ()
Chris@40 1487 {
Chris@40 1488 $debug_cmd
Chris@40 1489
Chris@40 1490 func_append hookable_fns " $1"
Chris@40 1491 }
Chris@40 1492
Chris@40 1493
Chris@40 1494 # func_add_hook FUNC_NAME HOOK_FUNC
Chris@40 1495 # ---------------------------------
Chris@40 1496 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
Chris@40 1497 # first have been declared "hookable" by a call to 'func_hookable'.
Chris@40 1498 func_add_hook ()
Chris@40 1499 {
Chris@40 1500 $debug_cmd
Chris@40 1501
Chris@40 1502 case " $hookable_fns " in
Chris@40 1503 *" $1 "*) ;;
Chris@40 1504 *) func_fatal_error "'$1' does not accept hook functions." ;;
Chris@40 1505 esac
Chris@40 1506
Chris@40 1507 eval func_append ${1}_hooks '" $2"'
Chris@40 1508 }
Chris@40 1509
Chris@40 1510
Chris@40 1511 # func_remove_hook FUNC_NAME HOOK_FUNC
Chris@40 1512 # ------------------------------------
Chris@40 1513 # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
Chris@40 1514 func_remove_hook ()
Chris@40 1515 {
Chris@40 1516 $debug_cmd
Chris@40 1517
Chris@40 1518 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
Chris@40 1519 }
Chris@40 1520
Chris@40 1521
Chris@40 1522 # func_run_hooks FUNC_NAME [ARG]...
Chris@40 1523 # ---------------------------------
Chris@40 1524 # Run all hook functions registered to FUNC_NAME.
Chris@40 1525 # It is assumed that the list of hook functions contains nothing more
Chris@40 1526 # than a whitespace-delimited list of legal shell function names, and
Chris@40 1527 # no effort is wasted trying to catch shell meta-characters or preserve
Chris@40 1528 # whitespace.
Chris@40 1529 func_run_hooks ()
Chris@40 1530 {
Chris@40 1531 $debug_cmd
Chris@40 1532
Chris@40 1533 case " $hookable_fns " in
Chris@40 1534 *" $1 "*) ;;
Chris@40 1535 *) func_fatal_error "'$1' does not support hook funcions.n" ;;
Chris@40 1536 esac
Chris@40 1537
Chris@40 1538 eval _G_hook_fns=\$$1_hooks; shift
Chris@40 1539
Chris@40 1540 for _G_hook in $_G_hook_fns; do
Chris@40 1541 eval $_G_hook '"$@"'
Chris@40 1542
Chris@40 1543 # store returned options list back into positional
Chris@40 1544 # parameters for next 'cmd' execution.
Chris@40 1545 eval _G_hook_result=\$${_G_hook}_result
Chris@40 1546 eval set dummy "$_G_hook_result"; shift
Chris@40 1547 done
Chris@40 1548
Chris@40 1549 func_quote_for_eval ${1+"$@"}
Chris@40 1550 func_run_hooks_result=$func_quote_for_eval_result
Chris@40 1551 }
Chris@40 1552
Chris@40 1553
Chris@40 1554
Chris@40 1555 ## --------------- ##
Chris@40 1556 ## Option parsing. ##
Chris@40 1557 ## --------------- ##
Chris@40 1558
Chris@40 1559 # In order to add your own option parsing hooks, you must accept the
Chris@40 1560 # full positional parameter list in your hook function, remove any
Chris@40 1561 # options that you action, and then pass back the remaining unprocessed
Chris@40 1562 # options in '<hooked_function_name>_result', escaped suitably for
Chris@40 1563 # 'eval'. Like this:
Chris@40 1564 #
Chris@40 1565 # my_options_prep ()
Chris@40 1566 # {
Chris@40 1567 # $debug_cmd
Chris@40 1568 #
Chris@40 1569 # # Extend the existing usage message.
Chris@40 1570 # usage_message=$usage_message'
Chris@40 1571 # -s, --silent don'\''t print informational messages
Chris@40 1572 # '
Chris@40 1573 #
Chris@40 1574 # func_quote_for_eval ${1+"$@"}
Chris@40 1575 # my_options_prep_result=$func_quote_for_eval_result
Chris@40 1576 # }
Chris@40 1577 # func_add_hook func_options_prep my_options_prep
Chris@40 1578 #
Chris@40 1579 #
Chris@40 1580 # my_silent_option ()
Chris@40 1581 # {
Chris@40 1582 # $debug_cmd
Chris@40 1583 #
Chris@40 1584 # # Note that for efficiency, we parse as many options as we can
Chris@40 1585 # # recognise in a loop before passing the remainder back to the
Chris@40 1586 # # caller on the first unrecognised argument we encounter.
Chris@40 1587 # while test $# -gt 0; do
Chris@40 1588 # opt=$1; shift
Chris@40 1589 # case $opt in
Chris@40 1590 # --silent|-s) opt_silent=: ;;
Chris@40 1591 # # Separate non-argument short options:
Chris@40 1592 # -s*) func_split_short_opt "$_G_opt"
Chris@40 1593 # set dummy "$func_split_short_opt_name" \
Chris@40 1594 # "-$func_split_short_opt_arg" ${1+"$@"}
Chris@40 1595 # shift
Chris@40 1596 # ;;
Chris@40 1597 # *) set dummy "$_G_opt" "$*"; shift; break ;;
Chris@40 1598 # esac
Chris@40 1599 # done
Chris@40 1600 #
Chris@40 1601 # func_quote_for_eval ${1+"$@"}
Chris@40 1602 # my_silent_option_result=$func_quote_for_eval_result
Chris@40 1603 # }
Chris@40 1604 # func_add_hook func_parse_options my_silent_option
Chris@40 1605 #
Chris@40 1606 #
Chris@40 1607 # my_option_validation ()
Chris@40 1608 # {
Chris@40 1609 # $debug_cmd
Chris@40 1610 #
Chris@40 1611 # $opt_silent && $opt_verbose && func_fatal_help "\
Chris@40 1612 # '--silent' and '--verbose' options are mutually exclusive."
Chris@40 1613 #
Chris@40 1614 # func_quote_for_eval ${1+"$@"}
Chris@40 1615 # my_option_validation_result=$func_quote_for_eval_result
Chris@40 1616 # }
Chris@40 1617 # func_add_hook func_validate_options my_option_validation
Chris@40 1618 #
Chris@40 1619 # You'll alse need to manually amend $usage_message to reflect the extra
Chris@40 1620 # options you parse. It's preferable to append if you can, so that
Chris@40 1621 # multiple option parsing hooks can be added safely.
Chris@40 1622
Chris@40 1623
Chris@40 1624 # func_options [ARG]...
Chris@40 1625 # ---------------------
Chris@40 1626 # All the functions called inside func_options are hookable. See the
Chris@40 1627 # individual implementations for details.
Chris@40 1628 func_hookable func_options
Chris@40 1629 func_options ()
Chris@40 1630 {
Chris@40 1631 $debug_cmd
Chris@40 1632
Chris@40 1633 func_options_prep ${1+"$@"}
Chris@40 1634 eval func_parse_options \
Chris@40 1635 ${func_options_prep_result+"$func_options_prep_result"}
Chris@40 1636 eval func_validate_options \
Chris@40 1637 ${func_parse_options_result+"$func_parse_options_result"}
Chris@40 1638
Chris@40 1639 eval func_run_hooks func_options \
Chris@40 1640 ${func_validate_options_result+"$func_validate_options_result"}
Chris@40 1641
Chris@40 1642 # save modified positional parameters for caller
Chris@40 1643 func_options_result=$func_run_hooks_result
Chris@40 1644 }
Chris@40 1645
Chris@40 1646
Chris@40 1647 # func_options_prep [ARG]...
Chris@40 1648 # --------------------------
Chris@40 1649 # All initialisations required before starting the option parse loop.
Chris@40 1650 # Note that when calling hook functions, we pass through the list of
Chris@40 1651 # positional parameters. If a hook function modifies that list, and
Chris@40 1652 # needs to propogate that back to rest of this script, then the complete
Chris@40 1653 # modified list must be put in 'func_run_hooks_result' before
Chris@40 1654 # returning.
Chris@40 1655 func_hookable func_options_prep
Chris@40 1656 func_options_prep ()
Chris@40 1657 {
Chris@40 1658 $debug_cmd
Chris@40 1659
Chris@40 1660 # Option defaults:
Chris@40 1661 opt_verbose=false
Chris@40 1662 opt_warning_types=
Chris@40 1663
Chris@40 1664 func_run_hooks func_options_prep ${1+"$@"}
Chris@40 1665
Chris@40 1666 # save modified positional parameters for caller
Chris@40 1667 func_options_prep_result=$func_run_hooks_result
Chris@40 1668 }
Chris@40 1669
Chris@40 1670
Chris@40 1671 # func_parse_options [ARG]...
Chris@40 1672 # ---------------------------
Chris@40 1673 # The main option parsing loop.
Chris@40 1674 func_hookable func_parse_options
Chris@40 1675 func_parse_options ()
Chris@40 1676 {
Chris@40 1677 $debug_cmd
Chris@40 1678
Chris@40 1679 func_parse_options_result=
Chris@40 1680
Chris@40 1681 # this just eases exit handling
Chris@40 1682 while test $# -gt 0; do
Chris@40 1683 # Defer to hook functions for initial option parsing, so they
Chris@40 1684 # get priority in the event of reusing an option name.
Chris@40 1685 func_run_hooks func_parse_options ${1+"$@"}
Chris@40 1686
Chris@40 1687 # Adjust func_parse_options positional parameters to match
Chris@40 1688 eval set dummy "$func_run_hooks_result"; shift
Chris@40 1689
Chris@40 1690 # Break out of the loop if we already parsed every option.
Chris@40 1691 test $# -gt 0 || break
Chris@40 1692
Chris@40 1693 _G_opt=$1
Chris@40 1694 shift
Chris@40 1695 case $_G_opt in
Chris@40 1696 --debug|-x) debug_cmd='set -x'
Chris@40 1697 func_echo "enabling shell trace mode"
Chris@40 1698 $debug_cmd
Chris@40 1699 ;;
Chris@40 1700
Chris@40 1701 --no-warnings|--no-warning|--no-warn)
Chris@40 1702 set dummy --warnings none ${1+"$@"}
Chris@40 1703 shift
Chris@40 1704 ;;
Chris@40 1705
Chris@40 1706 --warnings|--warning|-W)
Chris@40 1707 test $# = 0 && func_missing_arg $_G_opt && break
Chris@40 1708 case " $warning_categories $1" in
Chris@40 1709 *" $1 "*)
Chris@40 1710 # trailing space prevents matching last $1 above
Chris@40 1711 func_append_uniq opt_warning_types " $1"
Chris@40 1712 ;;
Chris@40 1713 *all)
Chris@40 1714 opt_warning_types=$warning_categories
Chris@40 1715 ;;
Chris@40 1716 *none)
Chris@40 1717 opt_warning_types=none
Chris@40 1718 warning_func=:
Chris@40 1719 ;;
Chris@40 1720 *error)
Chris@40 1721 opt_warning_types=$warning_categories
Chris@40 1722 warning_func=func_fatal_error
Chris@40 1723 ;;
Chris@40 1724 *)
Chris@40 1725 func_fatal_error \
Chris@40 1726 "unsupported warning category: '$1'"
Chris@40 1727 ;;
Chris@40 1728 esac
Chris@40 1729 shift
Chris@40 1730 ;;
Chris@40 1731
Chris@40 1732 --verbose|-v) opt_verbose=: ;;
Chris@40 1733 --version) func_version ;;
Chris@40 1734 -\?|-h) func_usage ;;
Chris@40 1735 --help) func_help ;;
Chris@40 1736
Chris@40 1737 # Separate optargs to long options (plugins may need this):
Chris@40 1738 --*=*) func_split_equals "$_G_opt"
Chris@40 1739 set dummy "$func_split_equals_lhs" \
Chris@40 1740 "$func_split_equals_rhs" ${1+"$@"}
Chris@40 1741 shift
Chris@40 1742 ;;
Chris@40 1743
Chris@40 1744 # Separate optargs to short options:
Chris@40 1745 -W*)
Chris@40 1746 func_split_short_opt "$_G_opt"
Chris@40 1747 set dummy "$func_split_short_opt_name" \
Chris@40 1748 "$func_split_short_opt_arg" ${1+"$@"}
Chris@40 1749 shift
Chris@40 1750 ;;
Chris@40 1751
Chris@40 1752 # Separate non-argument short options:
Chris@40 1753 -\?*|-h*|-v*|-x*)
Chris@40 1754 func_split_short_opt "$_G_opt"
Chris@40 1755 set dummy "$func_split_short_opt_name" \
Chris@40 1756 "-$func_split_short_opt_arg" ${1+"$@"}
Chris@40 1757 shift
Chris@40 1758 ;;
Chris@40 1759
Chris@40 1760 --) break ;;
Chris@40 1761 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
Chris@40 1762 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
Chris@40 1763 esac
Chris@40 1764 done
Chris@40 1765
Chris@40 1766 # save modified positional parameters for caller
Chris@40 1767 func_quote_for_eval ${1+"$@"}
Chris@40 1768 func_parse_options_result=$func_quote_for_eval_result
Chris@40 1769 }
Chris@40 1770
Chris@40 1771
Chris@40 1772 # func_validate_options [ARG]...
Chris@40 1773 # ------------------------------
Chris@40 1774 # Perform any sanity checks on option settings and/or unconsumed
Chris@40 1775 # arguments.
Chris@40 1776 func_hookable func_validate_options
Chris@40 1777 func_validate_options ()
Chris@40 1778 {
Chris@40 1779 $debug_cmd
Chris@40 1780
Chris@40 1781 # Display all warnings if -W was not given.
Chris@40 1782 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
Chris@40 1783
Chris@40 1784 func_run_hooks func_validate_options ${1+"$@"}
Chris@40 1785
Chris@40 1786 # Bail if the options were screwed!
Chris@40 1787 $exit_cmd $EXIT_FAILURE
Chris@40 1788
Chris@40 1789 # save modified positional parameters for caller
Chris@40 1790 func_validate_options_result=$func_run_hooks_result
Chris@40 1791 }
Chris@40 1792
Chris@40 1793
Chris@40 1794
Chris@40 1795 ## ----------------- ##
Chris@40 1796 ## Helper functions. ##
Chris@40 1797 ## ----------------- ##
Chris@40 1798
Chris@40 1799 # This section contains the helper functions used by the rest of the
Chris@40 1800 # hookable option parser framework in ascii-betical order.
Chris@40 1801
Chris@40 1802
Chris@40 1803 # func_fatal_help ARG...
Chris@40 1804 # ----------------------
Chris@40 1805 # Echo program name prefixed message to standard error, followed by
Chris@40 1806 # a help hint, and exit.
Chris@40 1807 func_fatal_help ()
Chris@40 1808 {
Chris@40 1809 $debug_cmd
Chris@40 1810
Chris@40 1811 eval \$ECHO \""Usage: $usage"\"
Chris@40 1812 eval \$ECHO \""$fatal_help"\"
Chris@40 1813 func_error ${1+"$@"}
Chris@40 1814 exit $EXIT_FAILURE
Chris@40 1815 }
Chris@40 1816
Chris@40 1817
Chris@40 1818 # func_help
Chris@40 1819 # ---------
Chris@40 1820 # Echo long help message to standard output and exit.
Chris@40 1821 func_help ()
Chris@40 1822 {
Chris@40 1823 $debug_cmd
Chris@40 1824
Chris@40 1825 func_usage_message
Chris@40 1826 $ECHO "$long_help_message"
Chris@40 1827 exit 0
Chris@40 1828 }
Chris@40 1829
Chris@40 1830
Chris@40 1831 # func_missing_arg ARGNAME
Chris@40 1832 # ------------------------
Chris@40 1833 # Echo program name prefixed message to standard error and set global
Chris@40 1834 # exit_cmd.
Chris@40 1835 func_missing_arg ()
Chris@40 1836 {
Chris@40 1837 $debug_cmd
Chris@40 1838
Chris@40 1839 func_error "Missing argument for '$1'."
Chris@40 1840 exit_cmd=exit
Chris@40 1841 }
Chris@40 1842
Chris@40 1843
Chris@40 1844 # func_split_equals STRING
Chris@40 1845 # ------------------------
Chris@40 1846 # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
Chris@40 1847 # splitting STRING at the '=' sign.
Chris@40 1848 test -z "$_G_HAVE_XSI_OPS" \
Chris@40 1849 && (eval 'x=a/b/c;
Chris@40 1850 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
Chris@40 1851 && _G_HAVE_XSI_OPS=yes
Chris@40 1852
Chris@40 1853 if test yes = "$_G_HAVE_XSI_OPS"
Chris@40 1854 then
Chris@40 1855 # This is an XSI compatible shell, allowing a faster implementation...
Chris@40 1856 eval 'func_split_equals ()
Chris@40 1857 {
Chris@40 1858 $debug_cmd
Chris@40 1859
Chris@40 1860 func_split_equals_lhs=${1%%=*}
Chris@40 1861 func_split_equals_rhs=${1#*=}
Chris@40 1862 test "x$func_split_equals_lhs" = "x$1" \
Chris@40 1863 && func_split_equals_rhs=
Chris@40 1864 }'
Chris@40 1865 else
Chris@40 1866 # ...otherwise fall back to using expr, which is often a shell builtin.
Chris@40 1867 func_split_equals ()
Chris@40 1868 {
Chris@40 1869 $debug_cmd
Chris@40 1870
Chris@40 1871 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
Chris@40 1872 func_split_equals_rhs=
Chris@40 1873 test "x$func_split_equals_lhs" = "x$1" \
Chris@40 1874 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
Chris@40 1875 }
Chris@40 1876 fi #func_split_equals
Chris@40 1877
Chris@40 1878
Chris@40 1879 # func_split_short_opt SHORTOPT
Chris@40 1880 # -----------------------------
Chris@40 1881 # Set func_split_short_opt_name and func_split_short_opt_arg shell
Chris@40 1882 # variables after splitting SHORTOPT after the 2nd character.
Chris@40 1883 if test yes = "$_G_HAVE_XSI_OPS"
Chris@40 1884 then
Chris@40 1885 # This is an XSI compatible shell, allowing a faster implementation...
Chris@40 1886 eval 'func_split_short_opt ()
Chris@40 1887 {
Chris@40 1888 $debug_cmd
Chris@40 1889
Chris@40 1890 func_split_short_opt_arg=${1#??}
Chris@40 1891 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
Chris@40 1892 }'
Chris@40 1893 else
Chris@40 1894 # ...otherwise fall back to using expr, which is often a shell builtin.
Chris@40 1895 func_split_short_opt ()
Chris@40 1896 {
Chris@40 1897 $debug_cmd
Chris@40 1898
Chris@40 1899 func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
Chris@40 1900 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
Chris@40 1901 }
Chris@40 1902 fi #func_split_short_opt
Chris@40 1903
Chris@40 1904
Chris@40 1905 # func_usage
Chris@40 1906 # ----------
Chris@40 1907 # Echo short help message to standard output and exit.
Chris@40 1908 func_usage ()
Chris@40 1909 {
Chris@40 1910 $debug_cmd
Chris@40 1911
Chris@40 1912 func_usage_message
Chris@40 1913 $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
Chris@40 1914 exit 0
Chris@40 1915 }
Chris@40 1916
Chris@40 1917
Chris@40 1918 # func_usage_message
Chris@40 1919 # ------------------
Chris@40 1920 # Echo short help message to standard output.
Chris@40 1921 func_usage_message ()
Chris@40 1922 {
Chris@40 1923 $debug_cmd
Chris@40 1924
Chris@40 1925 eval \$ECHO \""Usage: $usage"\"
Chris@40 1926 echo
Chris@40 1927 $SED -n 's|^# ||
Chris@40 1928 /^Written by/{
Chris@40 1929 x;p;x
Chris@40 1930 }
Chris@40 1931 h
Chris@40 1932 /^Written by/q' < "$progpath"
Chris@40 1933 echo
Chris@40 1934 eval \$ECHO \""$usage_message"\"
Chris@40 1935 }
Chris@40 1936
Chris@40 1937
Chris@40 1938 # func_version
Chris@40 1939 # ------------
Chris@40 1940 # Echo version message to standard output and exit.
Chris@40 1941 func_version ()
Chris@40 1942 {
Chris@40 1943 $debug_cmd
Chris@40 1944
Chris@40 1945 printf '%s\n' "$progname $scriptversion"
Chris@40 1946 $SED -n '
Chris@40 1947 /(C)/!b go
Chris@40 1948 :more
Chris@40 1949 /\./!{
Chris@40 1950 N
Chris@40 1951 s|\n# | |
Chris@40 1952 b more
Chris@40 1953 }
Chris@40 1954 :go
Chris@40 1955 /^# Written by /,/# warranty; / {
Chris@40 1956 s|^# ||
Chris@40 1957 s|^# *$||
Chris@40 1958 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
Chris@40 1959 p
Chris@40 1960 }
Chris@40 1961 /^# Written by / {
Chris@40 1962 s|^# ||
Chris@40 1963 p
Chris@40 1964 }
Chris@40 1965 /^warranty; /q' < "$progpath"
Chris@40 1966
Chris@40 1967 exit $?
Chris@40 1968 }
Chris@40 1969
Chris@40 1970
Chris@40 1971 # Local variables:
Chris@40 1972 # mode: shell-script
Chris@40 1973 # sh-indentation: 2
Chris@40 1974 # eval: (add-hook 'before-save-hook 'time-stamp)
Chris@40 1975 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
Chris@40 1976 # time-stamp-time-zone: "UTC"
Chris@40 1977 # End:
Chris@40 1978
Chris@40 1979 # Set a version string.
Chris@40 1980 scriptversion='(GNU libtool) 2.4.6'
Chris@40 1981
Chris@40 1982
Chris@40 1983 # func_echo ARG...
Chris@40 1984 # ----------------
Chris@40 1985 # Libtool also displays the current mode in messages, so override
Chris@40 1986 # funclib.sh func_echo with this custom definition.
Chris@40 1987 func_echo ()
Chris@40 1988 {
Chris@40 1989 $debug_cmd
Chris@40 1990
Chris@40 1991 _G_message=$*
Chris@40 1992
Chris@40 1993 func_echo_IFS=$IFS
Chris@40 1994 IFS=$nl
Chris@40 1995 for _G_line in $_G_message; do
Chris@40 1996 IFS=$func_echo_IFS
Chris@40 1997 $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
Chris@40 1998 done
Chris@40 1999 IFS=$func_echo_IFS
Chris@40 2000 }
Chris@40 2001
Chris@40 2002
Chris@40 2003 # func_warning ARG...
Chris@40 2004 # -------------------
Chris@40 2005 # Libtool warnings are not categorized, so override funclib.sh
Chris@40 2006 # func_warning with this simpler definition.
Chris@40 2007 func_warning ()
Chris@40 2008 {
Chris@40 2009 $debug_cmd
Chris@40 2010
Chris@40 2011 $warning_func ${1+"$@"}
Chris@40 2012 }
Chris@40 2013
Chris@40 2014
Chris@40 2015 ## ---------------- ##
Chris@40 2016 ## Options parsing. ##
Chris@40 2017 ## ---------------- ##
Chris@40 2018
Chris@40 2019 # Hook in the functions to make sure our own options are parsed during
Chris@40 2020 # the option parsing loop.
Chris@40 2021
Chris@40 2022 usage='$progpath [OPTION]... [MODE-ARG]...'
Chris@40 2023
Chris@40 2024 # Short help message in response to '-h'.
Chris@40 2025 usage_message="Options:
Chris@40 2026 --config show all configuration variables
Chris@40 2027 --debug enable verbose shell tracing
Chris@40 2028 -n, --dry-run display commands without modifying any files
Chris@40 2029 --features display basic configuration information and exit
Chris@40 2030 --mode=MODE use operation mode MODE
Chris@40 2031 --no-warnings equivalent to '-Wnone'
Chris@40 2032 --preserve-dup-deps don't remove duplicate dependency libraries
Chris@40 2033 --quiet, --silent don't print informational messages
Chris@40 2034 --tag=TAG use configuration variables from tag TAG
Chris@40 2035 -v, --verbose print more informational messages than default
Chris@40 2036 --version print version information
Chris@40 2037 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
Chris@40 2038 -h, --help, --help-all print short, long, or detailed help message
Chris@40 2039 "
Chris@40 2040
Chris@40 2041 # Additional text appended to 'usage_message' in response to '--help'.
Chris@40 2042 func_help ()
Chris@40 2043 {
Chris@40 2044 $debug_cmd
Chris@40 2045
Chris@40 2046 func_usage_message
Chris@40 2047 $ECHO "$long_help_message
Chris@40 2048
Chris@40 2049 MODE must be one of the following:
Chris@40 2050
Chris@40 2051 clean remove files from the build directory
Chris@40 2052 compile compile a source file into a libtool object
Chris@40 2053 execute automatically set library path, then run a program
Chris@40 2054 finish complete the installation of libtool libraries
Chris@40 2055 install install libraries or executables
Chris@40 2056 link create a library or an executable
Chris@40 2057 uninstall remove libraries from an installed directory
Chris@40 2058
Chris@40 2059 MODE-ARGS vary depending on the MODE. When passed as first option,
Chris@40 2060 '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
Chris@40 2061 Try '$progname --help --mode=MODE' for a more detailed description of MODE.
Chris@40 2062
Chris@40 2063 When reporting a bug, please describe a test case to reproduce it and
Chris@40 2064 include the following information:
Chris@40 2065
Chris@40 2066 host-triplet: $host
Chris@40 2067 shell: $SHELL
Chris@40 2068 compiler: $LTCC
Chris@40 2069 compiler flags: $LTCFLAGS
Chris@40 2070 linker: $LD (gnu? $with_gnu_ld)
Chris@40 2071 version: $progname (GNU libtool) 2.4.6
Chris@40 2072 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
Chris@40 2073 autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
Chris@40 2074
Chris@40 2075 Report bugs to <bug-libtool@gnu.org>.
Chris@40 2076 GNU libtool home page: <http://www.gnu.org/s/libtool/>.
Chris@40 2077 General help using GNU software: <http://www.gnu.org/gethelp/>."
Chris@40 2078 exit 0
Chris@40 2079 }
Chris@40 2080
Chris@40 2081
Chris@40 2082 # func_lo2o OBJECT-NAME
Chris@40 2083 # ---------------------
Chris@40 2084 # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
Chris@40 2085 # object suffix.
Chris@40 2086
Chris@40 2087 lo2o=s/\\.lo\$/.$objext/
Chris@40 2088 o2lo=s/\\.$objext\$/.lo/
Chris@40 2089
Chris@40 2090 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@40 2091 eval 'func_lo2o ()
Chris@40 2092 {
Chris@40 2093 case $1 in
Chris@40 2094 *.lo) func_lo2o_result=${1%.lo}.$objext ;;
Chris@40 2095 * ) func_lo2o_result=$1 ;;
Chris@40 2096 esac
Chris@40 2097 }'
Chris@40 2098
Chris@40 2099 # func_xform LIBOBJ-OR-SOURCE
Chris@40 2100 # ---------------------------
Chris@40 2101 # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
Chris@40 2102 # suffix to a '.lo' libtool-object suffix.
Chris@40 2103 eval 'func_xform ()
Chris@40 2104 {
Chris@40 2105 func_xform_result=${1%.*}.lo
Chris@40 2106 }'
Chris@40 2107 else
Chris@40 2108 # ...otherwise fall back to using sed.
Chris@40 2109 func_lo2o ()
Chris@40 2110 {
Chris@40 2111 func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
Chris@40 2112 }
Chris@40 2113
Chris@40 2114 func_xform ()
Chris@40 2115 {
Chris@40 2116 func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
Chris@40 2117 }
Chris@40 2118 fi
Chris@40 2119
Chris@40 2120
Chris@40 2121 # func_fatal_configuration ARG...
Chris@40 2122 # -------------------------------
Chris@40 2123 # Echo program name prefixed message to standard error, followed by
Chris@40 2124 # a configuration failure hint, and exit.
Chris@40 2125 func_fatal_configuration ()
Chris@40 2126 {
Chris@40 2127 func__fatal_error ${1+"$@"} \
Chris@40 2128 "See the $PACKAGE documentation for more information." \
Chris@40 2129 "Fatal configuration error."
Chris@40 2130 }
Chris@40 2131
Chris@40 2132
Chris@40 2133 # func_config
Chris@40 2134 # -----------
Chris@40 2135 # Display the configuration for all the tags in this script.
Chris@40 2136 func_config ()
Chris@40 2137 {
Chris@40 2138 re_begincf='^# ### BEGIN LIBTOOL'
Chris@40 2139 re_endcf='^# ### END LIBTOOL'
Chris@40 2140
Chris@40 2141 # Default configuration.
Chris@40 2142 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
Chris@40 2143
Chris@40 2144 # Now print the configurations for the tags.
Chris@40 2145 for tagname in $taglist; do
Chris@40 2146 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
Chris@40 2147 done
Chris@40 2148
Chris@40 2149 exit $?
Chris@40 2150 }
Chris@40 2151
Chris@40 2152
Chris@40 2153 # func_features
Chris@40 2154 # -------------
Chris@40 2155 # Display the features supported by this script.
Chris@40 2156 func_features ()
Chris@40 2157 {
Chris@40 2158 echo "host: $host"
Chris@40 2159 if test yes = "$build_libtool_libs"; then
Chris@40 2160 echo "enable shared libraries"
Chris@40 2161 else
Chris@40 2162 echo "disable shared libraries"
Chris@40 2163 fi
Chris@40 2164 if test yes = "$build_old_libs"; then
Chris@40 2165 echo "enable static libraries"
Chris@40 2166 else
Chris@40 2167 echo "disable static libraries"
Chris@40 2168 fi
Chris@40 2169
Chris@40 2170 exit $?
Chris@40 2171 }
Chris@40 2172
Chris@40 2173
Chris@40 2174 # func_enable_tag TAGNAME
Chris@40 2175 # -----------------------
Chris@40 2176 # Verify that TAGNAME is valid, and either flag an error and exit, or
Chris@40 2177 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
Chris@40 2178 # variable here.
Chris@40 2179 func_enable_tag ()
Chris@40 2180 {
Chris@40 2181 # Global variable:
Chris@40 2182 tagname=$1
Chris@40 2183
Chris@40 2184 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
Chris@40 2185 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
Chris@40 2186 sed_extractcf=/$re_begincf/,/$re_endcf/p
Chris@40 2187
Chris@40 2188 # Validate tagname.
Chris@40 2189 case $tagname in
Chris@40 2190 *[!-_A-Za-z0-9,/]*)
Chris@40 2191 func_fatal_error "invalid tag name: $tagname"
Chris@40 2192 ;;
Chris@40 2193 esac
Chris@40 2194
Chris@40 2195 # Don't test for the "default" C tag, as we know it's
Chris@40 2196 # there but not specially marked.
Chris@40 2197 case $tagname in
Chris@40 2198 CC) ;;
Chris@40 2199 *)
Chris@40 2200 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
Chris@40 2201 taglist="$taglist $tagname"
Chris@40 2202
Chris@40 2203 # Evaluate the configuration. Be careful to quote the path
Chris@40 2204 # and the sed script, to avoid splitting on whitespace, but
Chris@40 2205 # also don't use non-portable quotes within backquotes within
Chris@40 2206 # quotes we have to do it in 2 steps:
Chris@40 2207 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
Chris@40 2208 eval "$extractedcf"
Chris@40 2209 else
Chris@40 2210 func_error "ignoring unknown tag $tagname"
Chris@40 2211 fi
Chris@40 2212 ;;
Chris@40 2213 esac
Chris@40 2214 }
Chris@40 2215
Chris@40 2216
Chris@40 2217 # func_check_version_match
Chris@40 2218 # ------------------------
Chris@40 2219 # Ensure that we are using m4 macros, and libtool script from the same
Chris@40 2220 # release of libtool.
Chris@40 2221 func_check_version_match ()
Chris@40 2222 {
Chris@40 2223 if test "$package_revision" != "$macro_revision"; then
Chris@40 2224 if test "$VERSION" != "$macro_version"; then
Chris@40 2225 if test -z "$macro_version"; then
Chris@40 2226 cat >&2 <<_LT_EOF
Chris@40 2227 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
Chris@40 2228 $progname: definition of this LT_INIT comes from an older release.
Chris@40 2229 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
Chris@40 2230 $progname: and run autoconf again.
Chris@40 2231 _LT_EOF
Chris@40 2232 else
Chris@40 2233 cat >&2 <<_LT_EOF
Chris@40 2234 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
Chris@40 2235 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
Chris@40 2236 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
Chris@40 2237 $progname: and run autoconf again.
Chris@40 2238 _LT_EOF
Chris@40 2239 fi
Chris@40 2240 else
Chris@40 2241 cat >&2 <<_LT_EOF
Chris@40 2242 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
Chris@40 2243 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
Chris@40 2244 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
Chris@40 2245 $progname: of $PACKAGE $VERSION and run autoconf again.
Chris@40 2246 _LT_EOF
Chris@40 2247 fi
Chris@40 2248
Chris@40 2249 exit $EXIT_MISMATCH
Chris@40 2250 fi
Chris@40 2251 }
Chris@40 2252
Chris@40 2253
Chris@40 2254 # libtool_options_prep [ARG]...
Chris@40 2255 # -----------------------------
Chris@40 2256 # Preparation for options parsed by libtool.
Chris@40 2257 libtool_options_prep ()
Chris@40 2258 {
Chris@40 2259 $debug_mode
Chris@40 2260
Chris@40 2261 # Option defaults:
Chris@40 2262 opt_config=false
Chris@40 2263 opt_dlopen=
Chris@40 2264 opt_dry_run=false
Chris@40 2265 opt_help=false
Chris@40 2266 opt_mode=
Chris@40 2267 opt_preserve_dup_deps=false
Chris@40 2268 opt_quiet=false
Chris@40 2269
Chris@40 2270 nonopt=
Chris@40 2271 preserve_args=
Chris@40 2272
Chris@40 2273 # Shorthand for --mode=foo, only valid as the first argument
Chris@40 2274 case $1 in
Chris@40 2275 clean|clea|cle|cl)
Chris@40 2276 shift; set dummy --mode clean ${1+"$@"}; shift
Chris@40 2277 ;;
Chris@40 2278 compile|compil|compi|comp|com|co|c)
Chris@40 2279 shift; set dummy --mode compile ${1+"$@"}; shift
Chris@40 2280 ;;
Chris@40 2281 execute|execut|execu|exec|exe|ex|e)
Chris@40 2282 shift; set dummy --mode execute ${1+"$@"}; shift
Chris@40 2283 ;;
Chris@40 2284 finish|finis|fini|fin|fi|f)
Chris@40 2285 shift; set dummy --mode finish ${1+"$@"}; shift
Chris@40 2286 ;;
Chris@40 2287 install|instal|insta|inst|ins|in|i)
Chris@40 2288 shift; set dummy --mode install ${1+"$@"}; shift
Chris@40 2289 ;;
Chris@40 2290 link|lin|li|l)
Chris@40 2291 shift; set dummy --mode link ${1+"$@"}; shift
Chris@40 2292 ;;
Chris@40 2293 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
Chris@40 2294 shift; set dummy --mode uninstall ${1+"$@"}; shift
Chris@40 2295 ;;
Chris@40 2296 esac
Chris@40 2297
Chris@40 2298 # Pass back the list of options.
Chris@40 2299 func_quote_for_eval ${1+"$@"}
Chris@40 2300 libtool_options_prep_result=$func_quote_for_eval_result
Chris@40 2301 }
Chris@40 2302 func_add_hook func_options_prep libtool_options_prep
Chris@40 2303
Chris@40 2304
Chris@40 2305 # libtool_parse_options [ARG]...
Chris@40 2306 # ---------------------------------
Chris@40 2307 # Provide handling for libtool specific options.
Chris@40 2308 libtool_parse_options ()
Chris@40 2309 {
Chris@40 2310 $debug_cmd
Chris@40 2311
Chris@40 2312 # Perform our own loop to consume as many options as possible in
Chris@40 2313 # each iteration.
Chris@40 2314 while test $# -gt 0; do
Chris@40 2315 _G_opt=$1
Chris@40 2316 shift
Chris@40 2317 case $_G_opt in
Chris@40 2318 --dry-run|--dryrun|-n)
Chris@40 2319 opt_dry_run=:
Chris@40 2320 ;;
Chris@40 2321
Chris@40 2322 --config) func_config ;;
Chris@40 2323
Chris@40 2324 --dlopen|-dlopen)
Chris@40 2325 opt_dlopen="${opt_dlopen+$opt_dlopen
Chris@40 2326 }$1"
Chris@40 2327 shift
Chris@40 2328 ;;
Chris@40 2329
Chris@40 2330 --preserve-dup-deps)
Chris@40 2331 opt_preserve_dup_deps=: ;;
Chris@40 2332
Chris@40 2333 --features) func_features ;;
Chris@40 2334
Chris@40 2335 --finish) set dummy --mode finish ${1+"$@"}; shift ;;
Chris@40 2336
Chris@40 2337 --help) opt_help=: ;;
Chris@40 2338
Chris@40 2339 --help-all) opt_help=': help-all' ;;
Chris@40 2340
Chris@40 2341 --mode) test $# = 0 && func_missing_arg $_G_opt && break
Chris@40 2342 opt_mode=$1
Chris@40 2343 case $1 in
Chris@40 2344 # Valid mode arguments:
Chris@40 2345 clean|compile|execute|finish|install|link|relink|uninstall) ;;
Chris@40 2346
Chris@40 2347 # Catch anything else as an error
Chris@40 2348 *) func_error "invalid argument for $_G_opt"
Chris@40 2349 exit_cmd=exit
Chris@40 2350 break
Chris@40 2351 ;;
Chris@40 2352 esac
Chris@40 2353 shift
Chris@40 2354 ;;
Chris@40 2355
Chris@40 2356 --no-silent|--no-quiet)
Chris@40 2357 opt_quiet=false
Chris@40 2358 func_append preserve_args " $_G_opt"
Chris@40 2359 ;;
Chris@40 2360
Chris@40 2361 --no-warnings|--no-warning|--no-warn)
Chris@40 2362 opt_warning=false
Chris@40 2363 func_append preserve_args " $_G_opt"
Chris@40 2364 ;;
Chris@40 2365
Chris@40 2366 --no-verbose)
Chris@40 2367 opt_verbose=false
Chris@40 2368 func_append preserve_args " $_G_opt"
Chris@40 2369 ;;
Chris@40 2370
Chris@40 2371 --silent|--quiet)
Chris@40 2372 opt_quiet=:
Chris@40 2373 opt_verbose=false
Chris@40 2374 func_append preserve_args " $_G_opt"
Chris@40 2375 ;;
Chris@40 2376
Chris@40 2377 --tag) test $# = 0 && func_missing_arg $_G_opt && break
Chris@40 2378 opt_tag=$1
Chris@40 2379 func_append preserve_args " $_G_opt $1"
Chris@40 2380 func_enable_tag "$1"
Chris@40 2381 shift
Chris@40 2382 ;;
Chris@40 2383
Chris@40 2384 --verbose|-v) opt_quiet=false
Chris@40 2385 opt_verbose=:
Chris@40 2386 func_append preserve_args " $_G_opt"
Chris@40 2387 ;;
Chris@40 2388
Chris@40 2389 # An option not handled by this hook function:
Chris@40 2390 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
Chris@40 2391 esac
Chris@40 2392 done
Chris@40 2393
Chris@40 2394
Chris@40 2395 # save modified positional parameters for caller
Chris@40 2396 func_quote_for_eval ${1+"$@"}
Chris@40 2397 libtool_parse_options_result=$func_quote_for_eval_result
Chris@40 2398 }
Chris@40 2399 func_add_hook func_parse_options libtool_parse_options
Chris@40 2400
Chris@40 2401
Chris@40 2402
Chris@40 2403 # libtool_validate_options [ARG]...
Chris@40 2404 # ---------------------------------
Chris@40 2405 # Perform any sanity checks on option settings and/or unconsumed
Chris@40 2406 # arguments.
Chris@40 2407 libtool_validate_options ()
Chris@40 2408 {
Chris@40 2409 # save first non-option argument
Chris@40 2410 if test 0 -lt $#; then
Chris@40 2411 nonopt=$1
Chris@40 2412 shift
Chris@40 2413 fi
Chris@40 2414
Chris@40 2415 # preserve --debug
Chris@40 2416 test : = "$debug_cmd" || func_append preserve_args " --debug"
Chris@40 2417
Chris@40 2418 case $host in
Chris@40 2419 # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
Chris@40 2420 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
Chris@40 2421 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
Chris@40 2422 # don't eliminate duplications in $postdeps and $predeps
Chris@40 2423 opt_duplicate_compiler_generated_deps=:
Chris@40 2424 ;;
Chris@40 2425 *)
Chris@40 2426 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
Chris@40 2427 ;;
Chris@40 2428 esac
Chris@40 2429
Chris@40 2430 $opt_help || {
Chris@40 2431 # Sanity checks first:
Chris@40 2432 func_check_version_match
Chris@40 2433
Chris@40 2434 test yes != "$build_libtool_libs" \
Chris@40 2435 && test yes != "$build_old_libs" \
Chris@40 2436 && func_fatal_configuration "not configured to build any kind of library"
Chris@40 2437
Chris@40 2438 # Darwin sucks
Chris@40 2439 eval std_shrext=\"$shrext_cmds\"
Chris@40 2440
Chris@40 2441 # Only execute mode is allowed to have -dlopen flags.
Chris@40 2442 if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
Chris@40 2443 func_error "unrecognized option '-dlopen'"
Chris@40 2444 $ECHO "$help" 1>&2
Chris@40 2445 exit $EXIT_FAILURE
Chris@40 2446 fi
Chris@40 2447
Chris@40 2448 # Change the help message to a mode-specific one.
Chris@40 2449 generic_help=$help
Chris@40 2450 help="Try '$progname --help --mode=$opt_mode' for more information."
Chris@40 2451 }
Chris@40 2452
Chris@40 2453 # Pass back the unparsed argument list
Chris@40 2454 func_quote_for_eval ${1+"$@"}
Chris@40 2455 libtool_validate_options_result=$func_quote_for_eval_result
Chris@40 2456 }
Chris@40 2457 func_add_hook func_validate_options libtool_validate_options
Chris@40 2458
Chris@40 2459
Chris@40 2460 # Process options as early as possible so that --help and --version
Chris@40 2461 # can return quickly.
Chris@40 2462 func_options ${1+"$@"}
Chris@40 2463 eval set dummy "$func_options_result"; shift
Chris@40 2464
Chris@40 2465
Chris@40 2466
Chris@40 2467 ## ----------- ##
Chris@40 2468 ## Main. ##
Chris@40 2469 ## ----------- ##
Chris@40 2470
Chris@40 2471 magic='%%%MAGIC variable%%%'
Chris@40 2472 magic_exe='%%%MAGIC EXE variable%%%'
Chris@40 2473
Chris@40 2474 # Global variables.
Chris@40 2475 extracted_archives=
Chris@40 2476 extracted_serial=0
Chris@40 2477
Chris@40 2478 # If this variable is set in any of the actions, the command in it
Chris@40 2479 # will be execed at the end. This prevents here-documents from being
Chris@40 2480 # left over by shells.
Chris@40 2481 exec_cmd=
Chris@40 2482
Chris@40 2483
Chris@40 2484 # A function that is used when there is no print builtin or printf.
Chris@40 2485 func_fallback_echo ()
Chris@40 2486 {
Chris@40 2487 eval 'cat <<_LTECHO_EOF
Chris@40 2488 $1
Chris@40 2489 _LTECHO_EOF'
Chris@40 2490 }
Chris@40 2491
Chris@40 2492 # func_generated_by_libtool
Chris@40 2493 # True iff stdin has been generated by Libtool. This function is only
Chris@40 2494 # a basic sanity check; it will hardly flush out determined imposters.
Chris@40 2495 func_generated_by_libtool_p ()
Chris@40 2496 {
Chris@40 2497 $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
Chris@40 2498 }
Chris@40 2499
Chris@40 2500 # func_lalib_p file
Chris@40 2501 # True iff FILE is a libtool '.la' library or '.lo' object file.
Chris@40 2502 # This function is only a basic sanity check; it will hardly flush out
Chris@40 2503 # determined imposters.
Chris@40 2504 func_lalib_p ()
Chris@40 2505 {
Chris@40 2506 test -f "$1" &&
Chris@40 2507 $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
Chris@40 2508 }
Chris@40 2509
Chris@40 2510 # func_lalib_unsafe_p file
Chris@40 2511 # True iff FILE is a libtool '.la' library or '.lo' object file.
Chris@40 2512 # This function implements the same check as func_lalib_p without
Chris@40 2513 # resorting to external programs. To this end, it redirects stdin and
Chris@40 2514 # closes it afterwards, without saving the original file descriptor.
Chris@40 2515 # As a safety measure, use it only where a negative result would be
Chris@40 2516 # fatal anyway. Works if 'file' does not exist.
Chris@40 2517 func_lalib_unsafe_p ()
Chris@40 2518 {
Chris@40 2519 lalib_p=no
Chris@40 2520 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
Chris@40 2521 for lalib_p_l in 1 2 3 4
Chris@40 2522 do
Chris@40 2523 read lalib_p_line
Chris@40 2524 case $lalib_p_line in
Chris@40 2525 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
Chris@40 2526 esac
Chris@40 2527 done
Chris@40 2528 exec 0<&5 5<&-
Chris@40 2529 fi
Chris@40 2530 test yes = "$lalib_p"
Chris@40 2531 }
Chris@40 2532
Chris@40 2533 # func_ltwrapper_script_p file
Chris@40 2534 # True iff FILE is a libtool wrapper script
Chris@40 2535 # This function is only a basic sanity check; it will hardly flush out
Chris@40 2536 # determined imposters.
Chris@40 2537 func_ltwrapper_script_p ()
Chris@40 2538 {
Chris@40 2539 test -f "$1" &&
Chris@40 2540 $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
Chris@40 2541 }
Chris@40 2542
Chris@40 2543 # func_ltwrapper_executable_p file
Chris@40 2544 # True iff FILE is a libtool wrapper executable
Chris@40 2545 # This function is only a basic sanity check; it will hardly flush out
Chris@40 2546 # determined imposters.
Chris@40 2547 func_ltwrapper_executable_p ()
Chris@40 2548 {
Chris@40 2549 func_ltwrapper_exec_suffix=
Chris@40 2550 case $1 in
Chris@40 2551 *.exe) ;;
Chris@40 2552 *) func_ltwrapper_exec_suffix=.exe ;;
Chris@40 2553 esac
Chris@40 2554 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
Chris@40 2555 }
Chris@40 2556
Chris@40 2557 # func_ltwrapper_scriptname file
Chris@40 2558 # Assumes file is an ltwrapper_executable
Chris@40 2559 # uses $file to determine the appropriate filename for a
Chris@40 2560 # temporary ltwrapper_script.
Chris@40 2561 func_ltwrapper_scriptname ()
Chris@40 2562 {
Chris@40 2563 func_dirname_and_basename "$1" "" "."
Chris@40 2564 func_stripname '' '.exe' "$func_basename_result"
Chris@40 2565 func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
Chris@40 2566 }
Chris@40 2567
Chris@40 2568 # func_ltwrapper_p file
Chris@40 2569 # True iff FILE is a libtool wrapper script or wrapper executable
Chris@40 2570 # This function is only a basic sanity check; it will hardly flush out
Chris@40 2571 # determined imposters.
Chris@40 2572 func_ltwrapper_p ()
Chris@40 2573 {
Chris@40 2574 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
Chris@40 2575 }
Chris@40 2576
Chris@40 2577
Chris@40 2578 # func_execute_cmds commands fail_cmd
Chris@40 2579 # Execute tilde-delimited COMMANDS.
Chris@40 2580 # If FAIL_CMD is given, eval that upon failure.
Chris@40 2581 # FAIL_CMD may read-access the current command in variable CMD!
Chris@40 2582 func_execute_cmds ()
Chris@40 2583 {
Chris@40 2584 $debug_cmd
Chris@40 2585
Chris@40 2586 save_ifs=$IFS; IFS='~'
Chris@40 2587 for cmd in $1; do
Chris@40 2588 IFS=$sp$nl
Chris@40 2589 eval cmd=\"$cmd\"
Chris@40 2590 IFS=$save_ifs
Chris@40 2591 func_show_eval "$cmd" "${2-:}"
Chris@40 2592 done
Chris@40 2593 IFS=$save_ifs
Chris@40 2594 }
Chris@40 2595
Chris@40 2596
Chris@40 2597 # func_source file
Chris@40 2598 # Source FILE, adding directory component if necessary.
Chris@40 2599 # Note that it is not necessary on cygwin/mingw to append a dot to
Chris@40 2600 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
Chris@40 2601 # behavior happens only for exec(3), not for open(2)! Also, sourcing
Chris@40 2602 # 'FILE.' does not work on cygwin managed mounts.
Chris@40 2603 func_source ()
Chris@40 2604 {
Chris@40 2605 $debug_cmd
Chris@40 2606
Chris@40 2607 case $1 in
Chris@40 2608 */* | *\\*) . "$1" ;;
Chris@40 2609 *) . "./$1" ;;
Chris@40 2610 esac
Chris@40 2611 }
Chris@40 2612
Chris@40 2613
Chris@40 2614 # func_resolve_sysroot PATH
Chris@40 2615 # Replace a leading = in PATH with a sysroot. Store the result into
Chris@40 2616 # func_resolve_sysroot_result
Chris@40 2617 func_resolve_sysroot ()
Chris@40 2618 {
Chris@40 2619 func_resolve_sysroot_result=$1
Chris@40 2620 case $func_resolve_sysroot_result in
Chris@40 2621 =*)
Chris@40 2622 func_stripname '=' '' "$func_resolve_sysroot_result"
Chris@40 2623 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
Chris@40 2624 ;;
Chris@40 2625 esac
Chris@40 2626 }
Chris@40 2627
Chris@40 2628 # func_replace_sysroot PATH
Chris@40 2629 # If PATH begins with the sysroot, replace it with = and
Chris@40 2630 # store the result into func_replace_sysroot_result.
Chris@40 2631 func_replace_sysroot ()
Chris@40 2632 {
Chris@40 2633 case $lt_sysroot:$1 in
Chris@40 2634 ?*:"$lt_sysroot"*)
Chris@40 2635 func_stripname "$lt_sysroot" '' "$1"
Chris@40 2636 func_replace_sysroot_result='='$func_stripname_result
Chris@40 2637 ;;
Chris@40 2638 *)
Chris@40 2639 # Including no sysroot.
Chris@40 2640 func_replace_sysroot_result=$1
Chris@40 2641 ;;
Chris@40 2642 esac
Chris@40 2643 }
Chris@40 2644
Chris@40 2645 # func_infer_tag arg
Chris@40 2646 # Infer tagged configuration to use if any are available and
Chris@40 2647 # if one wasn't chosen via the "--tag" command line option.
Chris@40 2648 # Only attempt this if the compiler in the base compile
Chris@40 2649 # command doesn't match the default compiler.
Chris@40 2650 # arg is usually of the form 'gcc ...'
Chris@40 2651 func_infer_tag ()
Chris@40 2652 {
Chris@40 2653 $debug_cmd
Chris@40 2654
Chris@40 2655 if test -n "$available_tags" && test -z "$tagname"; then
Chris@40 2656 CC_quoted=
Chris@40 2657 for arg in $CC; do
Chris@40 2658 func_append_quoted CC_quoted "$arg"
Chris@40 2659 done
Chris@40 2660 CC_expanded=`func_echo_all $CC`
Chris@40 2661 CC_quoted_expanded=`func_echo_all $CC_quoted`
Chris@40 2662 case $@ in
Chris@40 2663 # Blanks in the command may have been stripped by the calling shell,
Chris@40 2664 # but not from the CC environment variable when configure was run.
Chris@40 2665 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
Chris@40 2666 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
Chris@40 2667 # Blanks at the start of $base_compile will cause this to fail
Chris@40 2668 # if we don't check for them as well.
Chris@40 2669 *)
Chris@40 2670 for z in $available_tags; do
Chris@40 2671 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
Chris@40 2672 # Evaluate the configuration.
Chris@40 2673 eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
Chris@40 2674 CC_quoted=
Chris@40 2675 for arg in $CC; do
Chris@40 2676 # Double-quote args containing other shell metacharacters.
Chris@40 2677 func_append_quoted CC_quoted "$arg"
Chris@40 2678 done
Chris@40 2679 CC_expanded=`func_echo_all $CC`
Chris@40 2680 CC_quoted_expanded=`func_echo_all $CC_quoted`
Chris@40 2681 case "$@ " in
Chris@40 2682 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
Chris@40 2683 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
Chris@40 2684 # The compiler in the base compile command matches
Chris@40 2685 # the one in the tagged configuration.
Chris@40 2686 # Assume this is the tagged configuration we want.
Chris@40 2687 tagname=$z
Chris@40 2688 break
Chris@40 2689 ;;
Chris@40 2690 esac
Chris@40 2691 fi
Chris@40 2692 done
Chris@40 2693 # If $tagname still isn't set, then no tagged configuration
Chris@40 2694 # was found and let the user know that the "--tag" command
Chris@40 2695 # line option must be used.
Chris@40 2696 if test -z "$tagname"; then
Chris@40 2697 func_echo "unable to infer tagged configuration"
Chris@40 2698 func_fatal_error "specify a tag with '--tag'"
Chris@40 2699 # else
Chris@40 2700 # func_verbose "using $tagname tagged configuration"
Chris@40 2701 fi
Chris@40 2702 ;;
Chris@40 2703 esac
Chris@40 2704 fi
Chris@40 2705 }
Chris@40 2706
Chris@40 2707
Chris@40 2708
Chris@40 2709 # func_write_libtool_object output_name pic_name nonpic_name
Chris@40 2710 # Create a libtool object file (analogous to a ".la" file),
Chris@40 2711 # but don't create it if we're doing a dry run.
Chris@40 2712 func_write_libtool_object ()
Chris@40 2713 {
Chris@40 2714 write_libobj=$1
Chris@40 2715 if test yes = "$build_libtool_libs"; then
Chris@40 2716 write_lobj=\'$2\'
Chris@40 2717 else
Chris@40 2718 write_lobj=none
Chris@40 2719 fi
Chris@40 2720
Chris@40 2721 if test yes = "$build_old_libs"; then
Chris@40 2722 write_oldobj=\'$3\'
Chris@40 2723 else
Chris@40 2724 write_oldobj=none
Chris@40 2725 fi
Chris@40 2726
Chris@40 2727 $opt_dry_run || {
Chris@40 2728 cat >${write_libobj}T <<EOF
Chris@40 2729 # $write_libobj - a libtool object file
Chris@40 2730 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@40 2731 #
Chris@40 2732 # Please DO NOT delete this file!
Chris@40 2733 # It is necessary for linking the library.
Chris@40 2734
Chris@40 2735 # Name of the PIC object.
Chris@40 2736 pic_object=$write_lobj
Chris@40 2737
Chris@40 2738 # Name of the non-PIC object
Chris@40 2739 non_pic_object=$write_oldobj
Chris@40 2740
Chris@40 2741 EOF
Chris@40 2742 $MV "${write_libobj}T" "$write_libobj"
Chris@40 2743 }
Chris@40 2744 }
Chris@40 2745
Chris@40 2746
Chris@40 2747 ##################################################
Chris@40 2748 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
Chris@40 2749 ##################################################
Chris@40 2750
Chris@40 2751 # func_convert_core_file_wine_to_w32 ARG
Chris@40 2752 # Helper function used by file name conversion functions when $build is *nix,
Chris@40 2753 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
Chris@40 2754 # correctly configured wine environment available, with the winepath program
Chris@40 2755 # in $build's $PATH.
Chris@40 2756 #
Chris@40 2757 # ARG is the $build file name to be converted to w32 format.
Chris@40 2758 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
Chris@40 2759 # be empty on error (or when ARG is empty)
Chris@40 2760 func_convert_core_file_wine_to_w32 ()
Chris@40 2761 {
Chris@40 2762 $debug_cmd
Chris@40 2763
Chris@40 2764 func_convert_core_file_wine_to_w32_result=$1
Chris@40 2765 if test -n "$1"; then
Chris@40 2766 # Unfortunately, winepath does not exit with a non-zero error code, so we
Chris@40 2767 # are forced to check the contents of stdout. On the other hand, if the
Chris@40 2768 # command is not found, the shell will set an exit code of 127 and print
Chris@40 2769 # *an error message* to stdout. So we must check for both error code of
Chris@40 2770 # zero AND non-empty stdout, which explains the odd construction:
Chris@40 2771 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
Chris@40 2772 if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
Chris@40 2773 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
Chris@40 2774 $SED -e "$sed_naive_backslashify"`
Chris@40 2775 else
Chris@40 2776 func_convert_core_file_wine_to_w32_result=
Chris@40 2777 fi
Chris@40 2778 fi
Chris@40 2779 }
Chris@40 2780 # end: func_convert_core_file_wine_to_w32
Chris@40 2781
Chris@40 2782
Chris@40 2783 # func_convert_core_path_wine_to_w32 ARG
Chris@40 2784 # Helper function used by path conversion functions when $build is *nix, and
Chris@40 2785 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
Chris@40 2786 # configured wine environment available, with the winepath program in $build's
Chris@40 2787 # $PATH. Assumes ARG has no leading or trailing path separator characters.
Chris@40 2788 #
Chris@40 2789 # ARG is path to be converted from $build format to win32.
Chris@40 2790 # Result is available in $func_convert_core_path_wine_to_w32_result.
Chris@40 2791 # Unconvertible file (directory) names in ARG are skipped; if no directory names
Chris@40 2792 # are convertible, then the result may be empty.
Chris@40 2793 func_convert_core_path_wine_to_w32 ()
Chris@40 2794 {
Chris@40 2795 $debug_cmd
Chris@40 2796
Chris@40 2797 # unfortunately, winepath doesn't convert paths, only file names
Chris@40 2798 func_convert_core_path_wine_to_w32_result=
Chris@40 2799 if test -n "$1"; then
Chris@40 2800 oldIFS=$IFS
Chris@40 2801 IFS=:
Chris@40 2802 for func_convert_core_path_wine_to_w32_f in $1; do
Chris@40 2803 IFS=$oldIFS
Chris@40 2804 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
Chris@40 2805 if test -n "$func_convert_core_file_wine_to_w32_result"; then
Chris@40 2806 if test -z "$func_convert_core_path_wine_to_w32_result"; then
Chris@40 2807 func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
Chris@40 2808 else
Chris@40 2809 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
Chris@40 2810 fi
Chris@40 2811 fi
Chris@40 2812 done
Chris@40 2813 IFS=$oldIFS
Chris@40 2814 fi
Chris@40 2815 }
Chris@40 2816 # end: func_convert_core_path_wine_to_w32
Chris@40 2817
Chris@40 2818
Chris@40 2819 # func_cygpath ARGS...
Chris@40 2820 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
Chris@40 2821 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
Chris@40 2822 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
Chris@40 2823 # (2), returns the Cygwin file name or path in func_cygpath_result (input
Chris@40 2824 # file name or path is assumed to be in w32 format, as previously converted
Chris@40 2825 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
Chris@40 2826 # or path in func_cygpath_result (input file name or path is assumed to be in
Chris@40 2827 # Cygwin format). Returns an empty string on error.
Chris@40 2828 #
Chris@40 2829 # ARGS are passed to cygpath, with the last one being the file name or path to
Chris@40 2830 # be converted.
Chris@40 2831 #
Chris@40 2832 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
Chris@40 2833 # environment variable; do not put it in $PATH.
Chris@40 2834 func_cygpath ()
Chris@40 2835 {
Chris@40 2836 $debug_cmd
Chris@40 2837
Chris@40 2838 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
Chris@40 2839 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
Chris@40 2840 if test "$?" -ne 0; then
Chris@40 2841 # on failure, ensure result is empty
Chris@40 2842 func_cygpath_result=
Chris@40 2843 fi
Chris@40 2844 else
Chris@40 2845 func_cygpath_result=
Chris@40 2846 func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
Chris@40 2847 fi
Chris@40 2848 }
Chris@40 2849 #end: func_cygpath
Chris@40 2850
Chris@40 2851
Chris@40 2852 # func_convert_core_msys_to_w32 ARG
Chris@40 2853 # Convert file name or path ARG from MSYS format to w32 format. Return
Chris@40 2854 # result in func_convert_core_msys_to_w32_result.
Chris@40 2855 func_convert_core_msys_to_w32 ()
Chris@40 2856 {
Chris@40 2857 $debug_cmd
Chris@40 2858
Chris@40 2859 # awkward: cmd appends spaces to result
Chris@40 2860 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
Chris@40 2861 $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
Chris@40 2862 }
Chris@40 2863 #end: func_convert_core_msys_to_w32
Chris@40 2864
Chris@40 2865
Chris@40 2866 # func_convert_file_check ARG1 ARG2
Chris@40 2867 # Verify that ARG1 (a file name in $build format) was converted to $host
Chris@40 2868 # format in ARG2. Otherwise, emit an error message, but continue (resetting
Chris@40 2869 # func_to_host_file_result to ARG1).
Chris@40 2870 func_convert_file_check ()
Chris@40 2871 {
Chris@40 2872 $debug_cmd
Chris@40 2873
Chris@40 2874 if test -z "$2" && test -n "$1"; then
Chris@40 2875 func_error "Could not determine host file name corresponding to"
Chris@40 2876 func_error " '$1'"
Chris@40 2877 func_error "Continuing, but uninstalled executables may not work."
Chris@40 2878 # Fallback:
Chris@40 2879 func_to_host_file_result=$1
Chris@40 2880 fi
Chris@40 2881 }
Chris@40 2882 # end func_convert_file_check
Chris@40 2883
Chris@40 2884
Chris@40 2885 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
Chris@40 2886 # Verify that FROM_PATH (a path in $build format) was converted to $host
Chris@40 2887 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
Chris@40 2888 # func_to_host_file_result to a simplistic fallback value (see below).
Chris@40 2889 func_convert_path_check ()
Chris@40 2890 {
Chris@40 2891 $debug_cmd
Chris@40 2892
Chris@40 2893 if test -z "$4" && test -n "$3"; then
Chris@40 2894 func_error "Could not determine the host path corresponding to"
Chris@40 2895 func_error " '$3'"
Chris@40 2896 func_error "Continuing, but uninstalled executables may not work."
Chris@40 2897 # Fallback. This is a deliberately simplistic "conversion" and
Chris@40 2898 # should not be "improved". See libtool.info.
Chris@40 2899 if test "x$1" != "x$2"; then
Chris@40 2900 lt_replace_pathsep_chars="s|$1|$2|g"
Chris@40 2901 func_to_host_path_result=`echo "$3" |
Chris@40 2902 $SED -e "$lt_replace_pathsep_chars"`
Chris@40 2903 else
Chris@40 2904 func_to_host_path_result=$3
Chris@40 2905 fi
Chris@40 2906 fi
Chris@40 2907 }
Chris@40 2908 # end func_convert_path_check
Chris@40 2909
Chris@40 2910
Chris@40 2911 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
Chris@40 2912 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
Chris@40 2913 # and appending REPL if ORIG matches BACKPAT.
Chris@40 2914 func_convert_path_front_back_pathsep ()
Chris@40 2915 {
Chris@40 2916 $debug_cmd
Chris@40 2917
Chris@40 2918 case $4 in
Chris@40 2919 $1 ) func_to_host_path_result=$3$func_to_host_path_result
Chris@40 2920 ;;
Chris@40 2921 esac
Chris@40 2922 case $4 in
Chris@40 2923 $2 ) func_append func_to_host_path_result "$3"
Chris@40 2924 ;;
Chris@40 2925 esac
Chris@40 2926 }
Chris@40 2927 # end func_convert_path_front_back_pathsep
Chris@40 2928
Chris@40 2929
Chris@40 2930 ##################################################
Chris@40 2931 # $build to $host FILE NAME CONVERSION FUNCTIONS #
Chris@40 2932 ##################################################
Chris@40 2933 # invoked via '$to_host_file_cmd ARG'
Chris@40 2934 #
Chris@40 2935 # In each case, ARG is the path to be converted from $build to $host format.
Chris@40 2936 # Result will be available in $func_to_host_file_result.
Chris@40 2937
Chris@40 2938
Chris@40 2939 # func_to_host_file ARG
Chris@40 2940 # Converts the file name ARG from $build format to $host format. Return result
Chris@40 2941 # in func_to_host_file_result.
Chris@40 2942 func_to_host_file ()
Chris@40 2943 {
Chris@40 2944 $debug_cmd
Chris@40 2945
Chris@40 2946 $to_host_file_cmd "$1"
Chris@40 2947 }
Chris@40 2948 # end func_to_host_file
Chris@40 2949
Chris@40 2950
Chris@40 2951 # func_to_tool_file ARG LAZY
Chris@40 2952 # converts the file name ARG from $build format to toolchain format. Return
Chris@40 2953 # result in func_to_tool_file_result. If the conversion in use is listed
Chris@40 2954 # in (the comma separated) LAZY, no conversion takes place.
Chris@40 2955 func_to_tool_file ()
Chris@40 2956 {
Chris@40 2957 $debug_cmd
Chris@40 2958
Chris@40 2959 case ,$2, in
Chris@40 2960 *,"$to_tool_file_cmd",*)
Chris@40 2961 func_to_tool_file_result=$1
Chris@40 2962 ;;
Chris@40 2963 *)
Chris@40 2964 $to_tool_file_cmd "$1"
Chris@40 2965 func_to_tool_file_result=$func_to_host_file_result
Chris@40 2966 ;;
Chris@40 2967 esac
Chris@40 2968 }
Chris@40 2969 # end func_to_tool_file
Chris@40 2970
Chris@40 2971
Chris@40 2972 # func_convert_file_noop ARG
Chris@40 2973 # Copy ARG to func_to_host_file_result.
Chris@40 2974 func_convert_file_noop ()
Chris@40 2975 {
Chris@40 2976 func_to_host_file_result=$1
Chris@40 2977 }
Chris@40 2978 # end func_convert_file_noop
Chris@40 2979
Chris@40 2980
Chris@40 2981 # func_convert_file_msys_to_w32 ARG
Chris@40 2982 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
Chris@40 2983 # conversion to w32 is not available inside the cwrapper. Returns result in
Chris@40 2984 # func_to_host_file_result.
Chris@40 2985 func_convert_file_msys_to_w32 ()
Chris@40 2986 {
Chris@40 2987 $debug_cmd
Chris@40 2988
Chris@40 2989 func_to_host_file_result=$1
Chris@40 2990 if test -n "$1"; then
Chris@40 2991 func_convert_core_msys_to_w32 "$1"
Chris@40 2992 func_to_host_file_result=$func_convert_core_msys_to_w32_result
Chris@40 2993 fi
Chris@40 2994 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@40 2995 }
Chris@40 2996 # end func_convert_file_msys_to_w32
Chris@40 2997
Chris@40 2998
Chris@40 2999 # func_convert_file_cygwin_to_w32 ARG
Chris@40 3000 # Convert file name ARG from Cygwin to w32 format. Returns result in
Chris@40 3001 # func_to_host_file_result.
Chris@40 3002 func_convert_file_cygwin_to_w32 ()
Chris@40 3003 {
Chris@40 3004 $debug_cmd
Chris@40 3005
Chris@40 3006 func_to_host_file_result=$1
Chris@40 3007 if test -n "$1"; then
Chris@40 3008 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
Chris@40 3009 # LT_CYGPATH in this case.
Chris@40 3010 func_to_host_file_result=`cygpath -m "$1"`
Chris@40 3011 fi
Chris@40 3012 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@40 3013 }
Chris@40 3014 # end func_convert_file_cygwin_to_w32
Chris@40 3015
Chris@40 3016
Chris@40 3017 # func_convert_file_nix_to_w32 ARG
Chris@40 3018 # Convert file name ARG from *nix to w32 format. Requires a wine environment
Chris@40 3019 # and a working winepath. Returns result in func_to_host_file_result.
Chris@40 3020 func_convert_file_nix_to_w32 ()
Chris@40 3021 {
Chris@40 3022 $debug_cmd
Chris@40 3023
Chris@40 3024 func_to_host_file_result=$1
Chris@40 3025 if test -n "$1"; then
Chris@40 3026 func_convert_core_file_wine_to_w32 "$1"
Chris@40 3027 func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
Chris@40 3028 fi
Chris@40 3029 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@40 3030 }
Chris@40 3031 # end func_convert_file_nix_to_w32
Chris@40 3032
Chris@40 3033
Chris@40 3034 # func_convert_file_msys_to_cygwin ARG
Chris@40 3035 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
Chris@40 3036 # Returns result in func_to_host_file_result.
Chris@40 3037 func_convert_file_msys_to_cygwin ()
Chris@40 3038 {
Chris@40 3039 $debug_cmd
Chris@40 3040
Chris@40 3041 func_to_host_file_result=$1
Chris@40 3042 if test -n "$1"; then
Chris@40 3043 func_convert_core_msys_to_w32 "$1"
Chris@40 3044 func_cygpath -u "$func_convert_core_msys_to_w32_result"
Chris@40 3045 func_to_host_file_result=$func_cygpath_result
Chris@40 3046 fi
Chris@40 3047 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@40 3048 }
Chris@40 3049 # end func_convert_file_msys_to_cygwin
Chris@40 3050
Chris@40 3051
Chris@40 3052 # func_convert_file_nix_to_cygwin ARG
Chris@40 3053 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
Chris@40 3054 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
Chris@40 3055 # in func_to_host_file_result.
Chris@40 3056 func_convert_file_nix_to_cygwin ()
Chris@40 3057 {
Chris@40 3058 $debug_cmd
Chris@40 3059
Chris@40 3060 func_to_host_file_result=$1
Chris@40 3061 if test -n "$1"; then
Chris@40 3062 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
Chris@40 3063 func_convert_core_file_wine_to_w32 "$1"
Chris@40 3064 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
Chris@40 3065 func_to_host_file_result=$func_cygpath_result
Chris@40 3066 fi
Chris@40 3067 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@40 3068 }
Chris@40 3069 # end func_convert_file_nix_to_cygwin
Chris@40 3070
Chris@40 3071
Chris@40 3072 #############################################
Chris@40 3073 # $build to $host PATH CONVERSION FUNCTIONS #
Chris@40 3074 #############################################
Chris@40 3075 # invoked via '$to_host_path_cmd ARG'
Chris@40 3076 #
Chris@40 3077 # In each case, ARG is the path to be converted from $build to $host format.
Chris@40 3078 # The result will be available in $func_to_host_path_result.
Chris@40 3079 #
Chris@40 3080 # Path separators are also converted from $build format to $host format. If
Chris@40 3081 # ARG begins or ends with a path separator character, it is preserved (but
Chris@40 3082 # converted to $host format) on output.
Chris@40 3083 #
Chris@40 3084 # All path conversion functions are named using the following convention:
Chris@40 3085 # file name conversion function : func_convert_file_X_to_Y ()
Chris@40 3086 # path conversion function : func_convert_path_X_to_Y ()
Chris@40 3087 # where, for any given $build/$host combination the 'X_to_Y' value is the
Chris@40 3088 # same. If conversion functions are added for new $build/$host combinations,
Chris@40 3089 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
Chris@40 3090 # will break.
Chris@40 3091
Chris@40 3092
Chris@40 3093 # func_init_to_host_path_cmd
Chris@40 3094 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
Chris@40 3095 # appropriate value, based on the value of $to_host_file_cmd.
Chris@40 3096 to_host_path_cmd=
Chris@40 3097 func_init_to_host_path_cmd ()
Chris@40 3098 {
Chris@40 3099 $debug_cmd
Chris@40 3100
Chris@40 3101 if test -z "$to_host_path_cmd"; then
Chris@40 3102 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
Chris@40 3103 to_host_path_cmd=func_convert_path_$func_stripname_result
Chris@40 3104 fi
Chris@40 3105 }
Chris@40 3106
Chris@40 3107
Chris@40 3108 # func_to_host_path ARG
Chris@40 3109 # Converts the path ARG from $build format to $host format. Return result
Chris@40 3110 # in func_to_host_path_result.
Chris@40 3111 func_to_host_path ()
Chris@40 3112 {
Chris@40 3113 $debug_cmd
Chris@40 3114
Chris@40 3115 func_init_to_host_path_cmd
Chris@40 3116 $to_host_path_cmd "$1"
Chris@40 3117 }
Chris@40 3118 # end func_to_host_path
Chris@40 3119
Chris@40 3120
Chris@40 3121 # func_convert_path_noop ARG
Chris@40 3122 # Copy ARG to func_to_host_path_result.
Chris@40 3123 func_convert_path_noop ()
Chris@40 3124 {
Chris@40 3125 func_to_host_path_result=$1
Chris@40 3126 }
Chris@40 3127 # end func_convert_path_noop
Chris@40 3128
Chris@40 3129
Chris@40 3130 # func_convert_path_msys_to_w32 ARG
Chris@40 3131 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
Chris@40 3132 # conversion to w32 is not available inside the cwrapper. Returns result in
Chris@40 3133 # func_to_host_path_result.
Chris@40 3134 func_convert_path_msys_to_w32 ()
Chris@40 3135 {
Chris@40 3136 $debug_cmd
Chris@40 3137
Chris@40 3138 func_to_host_path_result=$1
Chris@40 3139 if test -n "$1"; then
Chris@40 3140 # Remove leading and trailing path separator characters from ARG. MSYS
Chris@40 3141 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
Chris@40 3142 # and winepath ignores them completely.
Chris@40 3143 func_stripname : : "$1"
Chris@40 3144 func_to_host_path_tmp1=$func_stripname_result
Chris@40 3145 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
Chris@40 3146 func_to_host_path_result=$func_convert_core_msys_to_w32_result
Chris@40 3147 func_convert_path_check : ";" \
Chris@40 3148 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@40 3149 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Chris@40 3150 fi
Chris@40 3151 }
Chris@40 3152 # end func_convert_path_msys_to_w32
Chris@40 3153
Chris@40 3154
Chris@40 3155 # func_convert_path_cygwin_to_w32 ARG
Chris@40 3156 # Convert path ARG from Cygwin to w32 format. Returns result in
Chris@40 3157 # func_to_host_file_result.
Chris@40 3158 func_convert_path_cygwin_to_w32 ()
Chris@40 3159 {
Chris@40 3160 $debug_cmd
Chris@40 3161
Chris@40 3162 func_to_host_path_result=$1
Chris@40 3163 if test -n "$1"; then
Chris@40 3164 # See func_convert_path_msys_to_w32:
Chris@40 3165 func_stripname : : "$1"
Chris@40 3166 func_to_host_path_tmp1=$func_stripname_result
Chris@40 3167 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
Chris@40 3168 func_convert_path_check : ";" \
Chris@40 3169 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@40 3170 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Chris@40 3171 fi
Chris@40 3172 }
Chris@40 3173 # end func_convert_path_cygwin_to_w32
Chris@40 3174
Chris@40 3175
Chris@40 3176 # func_convert_path_nix_to_w32 ARG
Chris@40 3177 # Convert path ARG from *nix to w32 format. Requires a wine environment and
Chris@40 3178 # a working winepath. Returns result in func_to_host_file_result.
Chris@40 3179 func_convert_path_nix_to_w32 ()
Chris@40 3180 {
Chris@40 3181 $debug_cmd
Chris@40 3182
Chris@40 3183 func_to_host_path_result=$1
Chris@40 3184 if test -n "$1"; then
Chris@40 3185 # See func_convert_path_msys_to_w32:
Chris@40 3186 func_stripname : : "$1"
Chris@40 3187 func_to_host_path_tmp1=$func_stripname_result
Chris@40 3188 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
Chris@40 3189 func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
Chris@40 3190 func_convert_path_check : ";" \
Chris@40 3191 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@40 3192 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Chris@40 3193 fi
Chris@40 3194 }
Chris@40 3195 # end func_convert_path_nix_to_w32
Chris@40 3196
Chris@40 3197
Chris@40 3198 # func_convert_path_msys_to_cygwin ARG
Chris@40 3199 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
Chris@40 3200 # Returns result in func_to_host_file_result.
Chris@40 3201 func_convert_path_msys_to_cygwin ()
Chris@40 3202 {
Chris@40 3203 $debug_cmd
Chris@40 3204
Chris@40 3205 func_to_host_path_result=$1
Chris@40 3206 if test -n "$1"; then
Chris@40 3207 # See func_convert_path_msys_to_w32:
Chris@40 3208 func_stripname : : "$1"
Chris@40 3209 func_to_host_path_tmp1=$func_stripname_result
Chris@40 3210 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
Chris@40 3211 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
Chris@40 3212 func_to_host_path_result=$func_cygpath_result
Chris@40 3213 func_convert_path_check : : \
Chris@40 3214 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@40 3215 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
Chris@40 3216 fi
Chris@40 3217 }
Chris@40 3218 # end func_convert_path_msys_to_cygwin
Chris@40 3219
Chris@40 3220
Chris@40 3221 # func_convert_path_nix_to_cygwin ARG
Chris@40 3222 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
Chris@40 3223 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
Chris@40 3224 # func_to_host_file_result.
Chris@40 3225 func_convert_path_nix_to_cygwin ()
Chris@40 3226 {
Chris@40 3227 $debug_cmd
Chris@40 3228
Chris@40 3229 func_to_host_path_result=$1
Chris@40 3230 if test -n "$1"; then
Chris@40 3231 # Remove leading and trailing path separator characters from
Chris@40 3232 # ARG. msys behavior is inconsistent here, cygpath turns them
Chris@40 3233 # into '.;' and ';.', and winepath ignores them completely.
Chris@40 3234 func_stripname : : "$1"
Chris@40 3235 func_to_host_path_tmp1=$func_stripname_result
Chris@40 3236 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
Chris@40 3237 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
Chris@40 3238 func_to_host_path_result=$func_cygpath_result
Chris@40 3239 func_convert_path_check : : \
Chris@40 3240 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@40 3241 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
Chris@40 3242 fi
Chris@40 3243 }
Chris@40 3244 # end func_convert_path_nix_to_cygwin
Chris@40 3245
Chris@40 3246
Chris@40 3247 # func_dll_def_p FILE
Chris@40 3248 # True iff FILE is a Windows DLL '.def' file.
Chris@40 3249 # Keep in sync with _LT_DLL_DEF_P in libtool.m4
Chris@40 3250 func_dll_def_p ()
Chris@40 3251 {
Chris@40 3252 $debug_cmd
Chris@40 3253
Chris@40 3254 func_dll_def_p_tmp=`$SED -n \
Chris@40 3255 -e 's/^[ ]*//' \
Chris@40 3256 -e '/^\(;.*\)*$/d' \
Chris@40 3257 -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
Chris@40 3258 -e q \
Chris@40 3259 "$1"`
Chris@40 3260 test DEF = "$func_dll_def_p_tmp"
Chris@40 3261 }
Chris@40 3262
Chris@40 3263
Chris@40 3264 # func_mode_compile arg...
Chris@40 3265 func_mode_compile ()
Chris@40 3266 {
Chris@40 3267 $debug_cmd
Chris@40 3268
Chris@40 3269 # Get the compilation command and the source file.
Chris@40 3270 base_compile=
Chris@40 3271 srcfile=$nonopt # always keep a non-empty value in "srcfile"
Chris@40 3272 suppress_opt=yes
Chris@40 3273 suppress_output=
Chris@40 3274 arg_mode=normal
Chris@40 3275 libobj=
Chris@40 3276 later=
Chris@40 3277 pie_flag=
Chris@40 3278
Chris@40 3279 for arg
Chris@40 3280 do
Chris@40 3281 case $arg_mode in
Chris@40 3282 arg )
Chris@40 3283 # do not "continue". Instead, add this to base_compile
Chris@40 3284 lastarg=$arg
Chris@40 3285 arg_mode=normal
Chris@40 3286 ;;
Chris@40 3287
Chris@40 3288 target )
Chris@40 3289 libobj=$arg
Chris@40 3290 arg_mode=normal
Chris@40 3291 continue
Chris@40 3292 ;;
Chris@40 3293
Chris@40 3294 normal )
Chris@40 3295 # Accept any command-line options.
Chris@40 3296 case $arg in
Chris@40 3297 -o)
Chris@40 3298 test -n "$libobj" && \
Chris@40 3299 func_fatal_error "you cannot specify '-o' more than once"
Chris@40 3300 arg_mode=target
Chris@40 3301 continue
Chris@40 3302 ;;
Chris@40 3303
Chris@40 3304 -pie | -fpie | -fPIE)
Chris@40 3305 func_append pie_flag " $arg"
Chris@40 3306 continue
Chris@40 3307 ;;
Chris@40 3308
Chris@40 3309 -shared | -static | -prefer-pic | -prefer-non-pic)
Chris@40 3310 func_append later " $arg"
Chris@40 3311 continue
Chris@40 3312 ;;
Chris@40 3313
Chris@40 3314 -no-suppress)
Chris@40 3315 suppress_opt=no
Chris@40 3316 continue
Chris@40 3317 ;;
Chris@40 3318
Chris@40 3319 -Xcompiler)
Chris@40 3320 arg_mode=arg # the next one goes into the "base_compile" arg list
Chris@40 3321 continue # The current "srcfile" will either be retained or
Chris@40 3322 ;; # replaced later. I would guess that would be a bug.
Chris@40 3323
Chris@40 3324 -Wc,*)
Chris@40 3325 func_stripname '-Wc,' '' "$arg"
Chris@40 3326 args=$func_stripname_result
Chris@40 3327 lastarg=
Chris@40 3328 save_ifs=$IFS; IFS=,
Chris@40 3329 for arg in $args; do
Chris@40 3330 IFS=$save_ifs
Chris@40 3331 func_append_quoted lastarg "$arg"
Chris@40 3332 done
Chris@40 3333 IFS=$save_ifs
Chris@40 3334 func_stripname ' ' '' "$lastarg"
Chris@40 3335 lastarg=$func_stripname_result
Chris@40 3336
Chris@40 3337 # Add the arguments to base_compile.
Chris@40 3338 func_append base_compile " $lastarg"
Chris@40 3339 continue
Chris@40 3340 ;;
Chris@40 3341
Chris@40 3342 *)
Chris@40 3343 # Accept the current argument as the source file.
Chris@40 3344 # The previous "srcfile" becomes the current argument.
Chris@40 3345 #
Chris@40 3346 lastarg=$srcfile
Chris@40 3347 srcfile=$arg
Chris@40 3348 ;;
Chris@40 3349 esac # case $arg
Chris@40 3350 ;;
Chris@40 3351 esac # case $arg_mode
Chris@40 3352
Chris@40 3353 # Aesthetically quote the previous argument.
Chris@40 3354 func_append_quoted base_compile "$lastarg"
Chris@40 3355 done # for arg
Chris@40 3356
Chris@40 3357 case $arg_mode in
Chris@40 3358 arg)
Chris@40 3359 func_fatal_error "you must specify an argument for -Xcompile"
Chris@40 3360 ;;
Chris@40 3361 target)
Chris@40 3362 func_fatal_error "you must specify a target with '-o'"
Chris@40 3363 ;;
Chris@40 3364 *)
Chris@40 3365 # Get the name of the library object.
Chris@40 3366 test -z "$libobj" && {
Chris@40 3367 func_basename "$srcfile"
Chris@40 3368 libobj=$func_basename_result
Chris@40 3369 }
Chris@40 3370 ;;
Chris@40 3371 esac
Chris@40 3372
Chris@40 3373 # Recognize several different file suffixes.
Chris@40 3374 # If the user specifies -o file.o, it is replaced with file.lo
Chris@40 3375 case $libobj in
Chris@40 3376 *.[cCFSifmso] | \
Chris@40 3377 *.ada | *.adb | *.ads | *.asm | \
Chris@40 3378 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
Chris@40 3379 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
Chris@40 3380 func_xform "$libobj"
Chris@40 3381 libobj=$func_xform_result
Chris@40 3382 ;;
Chris@40 3383 esac
Chris@40 3384
Chris@40 3385 case $libobj in
Chris@40 3386 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
Chris@40 3387 *)
Chris@40 3388 func_fatal_error "cannot determine name of library object from '$libobj'"
Chris@40 3389 ;;
Chris@40 3390 esac
Chris@40 3391
Chris@40 3392 func_infer_tag $base_compile
Chris@40 3393
Chris@40 3394 for arg in $later; do
Chris@40 3395 case $arg in
Chris@40 3396 -shared)
Chris@40 3397 test yes = "$build_libtool_libs" \
Chris@40 3398 || func_fatal_configuration "cannot build a shared library"
Chris@40 3399 build_old_libs=no
Chris@40 3400 continue
Chris@40 3401 ;;
Chris@40 3402
Chris@40 3403 -static)
Chris@40 3404 build_libtool_libs=no
Chris@40 3405 build_old_libs=yes
Chris@40 3406 continue
Chris@40 3407 ;;
Chris@40 3408
Chris@40 3409 -prefer-pic)
Chris@40 3410 pic_mode=yes
Chris@40 3411 continue
Chris@40 3412 ;;
Chris@40 3413
Chris@40 3414 -prefer-non-pic)
Chris@40 3415 pic_mode=no
Chris@40 3416 continue
Chris@40 3417 ;;
Chris@40 3418 esac
Chris@40 3419 done
Chris@40 3420
Chris@40 3421 func_quote_for_eval "$libobj"
Chris@40 3422 test "X$libobj" != "X$func_quote_for_eval_result" \
Chris@40 3423 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
Chris@40 3424 && func_warning "libobj name '$libobj' may not contain shell special characters."
Chris@40 3425 func_dirname_and_basename "$obj" "/" ""
Chris@40 3426 objname=$func_basename_result
Chris@40 3427 xdir=$func_dirname_result
Chris@40 3428 lobj=$xdir$objdir/$objname
Chris@40 3429
Chris@40 3430 test -z "$base_compile" && \
Chris@40 3431 func_fatal_help "you must specify a compilation command"
Chris@40 3432
Chris@40 3433 # Delete any leftover library objects.
Chris@40 3434 if test yes = "$build_old_libs"; then
Chris@40 3435 removelist="$obj $lobj $libobj ${libobj}T"
Chris@40 3436 else
Chris@40 3437 removelist="$lobj $libobj ${libobj}T"
Chris@40 3438 fi
Chris@40 3439
Chris@40 3440 # On Cygwin there's no "real" PIC flag so we must build both object types
Chris@40 3441 case $host_os in
Chris@40 3442 cygwin* | mingw* | pw32* | os2* | cegcc*)
Chris@40 3443 pic_mode=default
Chris@40 3444 ;;
Chris@40 3445 esac
Chris@40 3446 if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
Chris@40 3447 # non-PIC code in shared libraries is not supported
Chris@40 3448 pic_mode=default
Chris@40 3449 fi
Chris@40 3450
Chris@40 3451 # Calculate the filename of the output object if compiler does
Chris@40 3452 # not support -o with -c
Chris@40 3453 if test no = "$compiler_c_o"; then
Chris@40 3454 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
Chris@40 3455 lockfile=$output_obj.lock
Chris@40 3456 else
Chris@40 3457 output_obj=
Chris@40 3458 need_locks=no
Chris@40 3459 lockfile=
Chris@40 3460 fi
Chris@40 3461
Chris@40 3462 # Lock this critical section if it is needed
Chris@40 3463 # We use this script file to make the link, it avoids creating a new file
Chris@40 3464 if test yes = "$need_locks"; then
Chris@40 3465 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
Chris@40 3466 func_echo "Waiting for $lockfile to be removed"
Chris@40 3467 sleep 2
Chris@40 3468 done
Chris@40 3469 elif test warn = "$need_locks"; then
Chris@40 3470 if test -f "$lockfile"; then
Chris@40 3471 $ECHO "\
Chris@40 3472 *** ERROR, $lockfile exists and contains:
Chris@40 3473 `cat $lockfile 2>/dev/null`
Chris@40 3474
Chris@40 3475 This indicates that another process is trying to use the same
Chris@40 3476 temporary object file, and libtool could not work around it because
Chris@40 3477 your compiler does not support '-c' and '-o' together. If you
Chris@40 3478 repeat this compilation, it may succeed, by chance, but you had better
Chris@40 3479 avoid parallel builds (make -j) in this platform, or get a better
Chris@40 3480 compiler."
Chris@40 3481
Chris@40 3482 $opt_dry_run || $RM $removelist
Chris@40 3483 exit $EXIT_FAILURE
Chris@40 3484 fi
Chris@40 3485 func_append removelist " $output_obj"
Chris@40 3486 $ECHO "$srcfile" > "$lockfile"
Chris@40 3487 fi
Chris@40 3488
Chris@40 3489 $opt_dry_run || $RM $removelist
Chris@40 3490 func_append removelist " $lockfile"
Chris@40 3491 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
Chris@40 3492
Chris@40 3493 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
Chris@40 3494 srcfile=$func_to_tool_file_result
Chris@40 3495 func_quote_for_eval "$srcfile"
Chris@40 3496 qsrcfile=$func_quote_for_eval_result
Chris@40 3497
Chris@40 3498 # Only build a PIC object if we are building libtool libraries.
Chris@40 3499 if test yes = "$build_libtool_libs"; then
Chris@40 3500 # Without this assignment, base_compile gets emptied.
Chris@40 3501 fbsd_hideous_sh_bug=$base_compile
Chris@40 3502
Chris@40 3503 if test no != "$pic_mode"; then
Chris@40 3504 command="$base_compile $qsrcfile $pic_flag"
Chris@40 3505 else
Chris@40 3506 # Don't build PIC code
Chris@40 3507 command="$base_compile $qsrcfile"
Chris@40 3508 fi
Chris@40 3509
Chris@40 3510 func_mkdir_p "$xdir$objdir"
Chris@40 3511
Chris@40 3512 if test -z "$output_obj"; then
Chris@40 3513 # Place PIC objects in $objdir
Chris@40 3514 func_append command " -o $lobj"
Chris@40 3515 fi
Chris@40 3516
Chris@40 3517 func_show_eval_locale "$command" \
Chris@40 3518 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
Chris@40 3519
Chris@40 3520 if test warn = "$need_locks" &&
Chris@40 3521 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
Chris@40 3522 $ECHO "\
Chris@40 3523 *** ERROR, $lockfile contains:
Chris@40 3524 `cat $lockfile 2>/dev/null`
Chris@40 3525
Chris@40 3526 but it should contain:
Chris@40 3527 $srcfile
Chris@40 3528
Chris@40 3529 This indicates that another process is trying to use the same
Chris@40 3530 temporary object file, and libtool could not work around it because
Chris@40 3531 your compiler does not support '-c' and '-o' together. If you
Chris@40 3532 repeat this compilation, it may succeed, by chance, but you had better
Chris@40 3533 avoid parallel builds (make -j) in this platform, or get a better
Chris@40 3534 compiler."
Chris@40 3535
Chris@40 3536 $opt_dry_run || $RM $removelist
Chris@40 3537 exit $EXIT_FAILURE
Chris@40 3538 fi
Chris@40 3539
Chris@40 3540 # Just move the object if needed, then go on to compile the next one
Chris@40 3541 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
Chris@40 3542 func_show_eval '$MV "$output_obj" "$lobj"' \
Chris@40 3543 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
Chris@40 3544 fi
Chris@40 3545
Chris@40 3546 # Allow error messages only from the first compilation.
Chris@40 3547 if test yes = "$suppress_opt"; then
Chris@40 3548 suppress_output=' >/dev/null 2>&1'
Chris@40 3549 fi
Chris@40 3550 fi
Chris@40 3551
Chris@40 3552 # Only build a position-dependent object if we build old libraries.
Chris@40 3553 if test yes = "$build_old_libs"; then
Chris@40 3554 if test yes != "$pic_mode"; then
Chris@40 3555 # Don't build PIC code
Chris@40 3556 command="$base_compile $qsrcfile$pie_flag"
Chris@40 3557 else
Chris@40 3558 command="$base_compile $qsrcfile $pic_flag"
Chris@40 3559 fi
Chris@40 3560 if test yes = "$compiler_c_o"; then
Chris@40 3561 func_append command " -o $obj"
Chris@40 3562 fi
Chris@40 3563
Chris@40 3564 # Suppress compiler output if we already did a PIC compilation.
Chris@40 3565 func_append command "$suppress_output"
Chris@40 3566 func_show_eval_locale "$command" \
Chris@40 3567 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
Chris@40 3568
Chris@40 3569 if test warn = "$need_locks" &&
Chris@40 3570 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
Chris@40 3571 $ECHO "\
Chris@40 3572 *** ERROR, $lockfile contains:
Chris@40 3573 `cat $lockfile 2>/dev/null`
Chris@40 3574
Chris@40 3575 but it should contain:
Chris@40 3576 $srcfile
Chris@40 3577
Chris@40 3578 This indicates that another process is trying to use the same
Chris@40 3579 temporary object file, and libtool could not work around it because
Chris@40 3580 your compiler does not support '-c' and '-o' together. If you
Chris@40 3581 repeat this compilation, it may succeed, by chance, but you had better
Chris@40 3582 avoid parallel builds (make -j) in this platform, or get a better
Chris@40 3583 compiler."
Chris@40 3584
Chris@40 3585 $opt_dry_run || $RM $removelist
Chris@40 3586 exit $EXIT_FAILURE
Chris@40 3587 fi
Chris@40 3588
Chris@40 3589 # Just move the object if needed
Chris@40 3590 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
Chris@40 3591 func_show_eval '$MV "$output_obj" "$obj"' \
Chris@40 3592 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
Chris@40 3593 fi
Chris@40 3594 fi
Chris@40 3595
Chris@40 3596 $opt_dry_run || {
Chris@40 3597 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
Chris@40 3598
Chris@40 3599 # Unlock the critical section if it was locked
Chris@40 3600 if test no != "$need_locks"; then
Chris@40 3601 removelist=$lockfile
Chris@40 3602 $RM "$lockfile"
Chris@40 3603 fi
Chris@40 3604 }
Chris@40 3605
Chris@40 3606 exit $EXIT_SUCCESS
Chris@40 3607 }
Chris@40 3608
Chris@40 3609 $opt_help || {
Chris@40 3610 test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
Chris@40 3611 }
Chris@40 3612
Chris@40 3613 func_mode_help ()
Chris@40 3614 {
Chris@40 3615 # We need to display help for each of the modes.
Chris@40 3616 case $opt_mode in
Chris@40 3617 "")
Chris@40 3618 # Generic help is extracted from the usage comments
Chris@40 3619 # at the start of this file.
Chris@40 3620 func_help
Chris@40 3621 ;;
Chris@40 3622
Chris@40 3623 clean)
Chris@40 3624 $ECHO \
Chris@40 3625 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
Chris@40 3626
Chris@40 3627 Remove files from the build directory.
Chris@40 3628
Chris@40 3629 RM is the name of the program to use to delete files associated with each FILE
Chris@40 3630 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
Chris@40 3631 to RM.
Chris@40 3632
Chris@40 3633 If FILE is a libtool library, object or program, all the files associated
Chris@40 3634 with it are deleted. Otherwise, only FILE itself is deleted using RM."
Chris@40 3635 ;;
Chris@40 3636
Chris@40 3637 compile)
Chris@40 3638 $ECHO \
Chris@40 3639 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
Chris@40 3640
Chris@40 3641 Compile a source file into a libtool library object.
Chris@40 3642
Chris@40 3643 This mode accepts the following additional options:
Chris@40 3644
Chris@40 3645 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
Chris@40 3646 -no-suppress do not suppress compiler output for multiple passes
Chris@40 3647 -prefer-pic try to build PIC objects only
Chris@40 3648 -prefer-non-pic try to build non-PIC objects only
Chris@40 3649 -shared do not build a '.o' file suitable for static linking
Chris@40 3650 -static only build a '.o' file suitable for static linking
Chris@40 3651 -Wc,FLAG pass FLAG directly to the compiler
Chris@40 3652
Chris@40 3653 COMPILE-COMMAND is a command to be used in creating a 'standard' object file
Chris@40 3654 from the given SOURCEFILE.
Chris@40 3655
Chris@40 3656 The output file name is determined by removing the directory component from
Chris@40 3657 SOURCEFILE, then substituting the C source code suffix '.c' with the
Chris@40 3658 library object suffix, '.lo'."
Chris@40 3659 ;;
Chris@40 3660
Chris@40 3661 execute)
Chris@40 3662 $ECHO \
Chris@40 3663 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
Chris@40 3664
Chris@40 3665 Automatically set library path, then run a program.
Chris@40 3666
Chris@40 3667 This mode accepts the following additional options:
Chris@40 3668
Chris@40 3669 -dlopen FILE add the directory containing FILE to the library path
Chris@40 3670
Chris@40 3671 This mode sets the library path environment variable according to '-dlopen'
Chris@40 3672 flags.
Chris@40 3673
Chris@40 3674 If any of the ARGS are libtool executable wrappers, then they are translated
Chris@40 3675 into their corresponding uninstalled binary, and any of their required library
Chris@40 3676 directories are added to the library path.
Chris@40 3677
Chris@40 3678 Then, COMMAND is executed, with ARGS as arguments."
Chris@40 3679 ;;
Chris@40 3680
Chris@40 3681 finish)
Chris@40 3682 $ECHO \
Chris@40 3683 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
Chris@40 3684
Chris@40 3685 Complete the installation of libtool libraries.
Chris@40 3686
Chris@40 3687 Each LIBDIR is a directory that contains libtool libraries.
Chris@40 3688
Chris@40 3689 The commands that this mode executes may require superuser privileges. Use
Chris@40 3690 the '--dry-run' option if you just want to see what would be executed."
Chris@40 3691 ;;
Chris@40 3692
Chris@40 3693 install)
Chris@40 3694 $ECHO \
Chris@40 3695 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
Chris@40 3696
Chris@40 3697 Install executables or libraries.
Chris@40 3698
Chris@40 3699 INSTALL-COMMAND is the installation command. The first component should be
Chris@40 3700 either the 'install' or 'cp' program.
Chris@40 3701
Chris@40 3702 The following components of INSTALL-COMMAND are treated specially:
Chris@40 3703
Chris@40 3704 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
Chris@40 3705
Chris@40 3706 The rest of the components are interpreted as arguments to that command (only
Chris@40 3707 BSD-compatible install options are recognized)."
Chris@40 3708 ;;
Chris@40 3709
Chris@40 3710 link)
Chris@40 3711 $ECHO \
Chris@40 3712 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
Chris@40 3713
Chris@40 3714 Link object files or libraries together to form another library, or to
Chris@40 3715 create an executable program.
Chris@40 3716
Chris@40 3717 LINK-COMMAND is a command using the C compiler that you would use to create
Chris@40 3718 a program from several object files.
Chris@40 3719
Chris@40 3720 The following components of LINK-COMMAND are treated specially:
Chris@40 3721
Chris@40 3722 -all-static do not do any dynamic linking at all
Chris@40 3723 -avoid-version do not add a version suffix if possible
Chris@40 3724 -bindir BINDIR specify path to binaries directory (for systems where
Chris@40 3725 libraries must be found in the PATH setting at runtime)
Chris@40 3726 -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
Chris@40 3727 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
Chris@40 3728 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
Chris@40 3729 -export-symbols SYMFILE
Chris@40 3730 try to export only the symbols listed in SYMFILE
Chris@40 3731 -export-symbols-regex REGEX
Chris@40 3732 try to export only the symbols matching REGEX
Chris@40 3733 -LLIBDIR search LIBDIR for required installed libraries
Chris@40 3734 -lNAME OUTPUT-FILE requires the installed library libNAME
Chris@40 3735 -module build a library that can dlopened
Chris@40 3736 -no-fast-install disable the fast-install mode
Chris@40 3737 -no-install link a not-installable executable
Chris@40 3738 -no-undefined declare that a library does not refer to external symbols
Chris@40 3739 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
Chris@40 3740 -objectlist FILE use a list of object files found in FILE to specify objects
Chris@40 3741 -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
Chris@40 3742 -precious-files-regex REGEX
Chris@40 3743 don't remove output files matching REGEX
Chris@40 3744 -release RELEASE specify package release information
Chris@40 3745 -rpath LIBDIR the created library will eventually be installed in LIBDIR
Chris@40 3746 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
Chris@40 3747 -shared only do dynamic linking of libtool libraries
Chris@40 3748 -shrext SUFFIX override the standard shared library file extension
Chris@40 3749 -static do not do any dynamic linking of uninstalled libtool libraries
Chris@40 3750 -static-libtool-libs
Chris@40 3751 do not do any dynamic linking of libtool libraries
Chris@40 3752 -version-info CURRENT[:REVISION[:AGE]]
Chris@40 3753 specify library version info [each variable defaults to 0]
Chris@40 3754 -weak LIBNAME declare that the target provides the LIBNAME interface
Chris@40 3755 -Wc,FLAG
Chris@40 3756 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
Chris@40 3757 -Wl,FLAG
Chris@40 3758 -Xlinker FLAG pass linker-specific FLAG directly to the linker
Chris@40 3759 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
Chris@40 3760
Chris@40 3761 All other options (arguments beginning with '-') are ignored.
Chris@40 3762
Chris@40 3763 Every other argument is treated as a filename. Files ending in '.la' are
Chris@40 3764 treated as uninstalled libtool libraries, other files are standard or library
Chris@40 3765 object files.
Chris@40 3766
Chris@40 3767 If the OUTPUT-FILE ends in '.la', then a libtool library is created,
Chris@40 3768 only library objects ('.lo' files) may be specified, and '-rpath' is
Chris@40 3769 required, except when creating a convenience library.
Chris@40 3770
Chris@40 3771 If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
Chris@40 3772 using 'ar' and 'ranlib', or on Windows using 'lib'.
Chris@40 3773
Chris@40 3774 If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
Chris@40 3775 is created, otherwise an executable program is created."
Chris@40 3776 ;;
Chris@40 3777
Chris@40 3778 uninstall)
Chris@40 3779 $ECHO \
Chris@40 3780 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
Chris@40 3781
Chris@40 3782 Remove libraries from an installation directory.
Chris@40 3783
Chris@40 3784 RM is the name of the program to use to delete files associated with each FILE
Chris@40 3785 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
Chris@40 3786 to RM.
Chris@40 3787
Chris@40 3788 If FILE is a libtool library, all the files associated with it are deleted.
Chris@40 3789 Otherwise, only FILE itself is deleted using RM."
Chris@40 3790 ;;
Chris@40 3791
Chris@40 3792 *)
Chris@40 3793 func_fatal_help "invalid operation mode '$opt_mode'"
Chris@40 3794 ;;
Chris@40 3795 esac
Chris@40 3796
Chris@40 3797 echo
Chris@40 3798 $ECHO "Try '$progname --help' for more information about other modes."
Chris@40 3799 }
Chris@40 3800
Chris@40 3801 # Now that we've collected a possible --mode arg, show help if necessary
Chris@40 3802 if $opt_help; then
Chris@40 3803 if test : = "$opt_help"; then
Chris@40 3804 func_mode_help
Chris@40 3805 else
Chris@40 3806 {
Chris@40 3807 func_help noexit
Chris@40 3808 for opt_mode in compile link execute install finish uninstall clean; do
Chris@40 3809 func_mode_help
Chris@40 3810 done
Chris@40 3811 } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
Chris@40 3812 {
Chris@40 3813 func_help noexit
Chris@40 3814 for opt_mode in compile link execute install finish uninstall clean; do
Chris@40 3815 echo
Chris@40 3816 func_mode_help
Chris@40 3817 done
Chris@40 3818 } |
Chris@40 3819 $SED '1d
Chris@40 3820 /^When reporting/,/^Report/{
Chris@40 3821 H
Chris@40 3822 d
Chris@40 3823 }
Chris@40 3824 $x
Chris@40 3825 /information about other modes/d
Chris@40 3826 /more detailed .*MODE/d
Chris@40 3827 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
Chris@40 3828 fi
Chris@40 3829 exit $?
Chris@40 3830 fi
Chris@40 3831
Chris@40 3832
Chris@40 3833 # func_mode_execute arg...
Chris@40 3834 func_mode_execute ()
Chris@40 3835 {
Chris@40 3836 $debug_cmd
Chris@40 3837
Chris@40 3838 # The first argument is the command name.
Chris@40 3839 cmd=$nonopt
Chris@40 3840 test -z "$cmd" && \
Chris@40 3841 func_fatal_help "you must specify a COMMAND"
Chris@40 3842
Chris@40 3843 # Handle -dlopen flags immediately.
Chris@40 3844 for file in $opt_dlopen; do
Chris@40 3845 test -f "$file" \
Chris@40 3846 || func_fatal_help "'$file' is not a file"
Chris@40 3847
Chris@40 3848 dir=
Chris@40 3849 case $file in
Chris@40 3850 *.la)
Chris@40 3851 func_resolve_sysroot "$file"
Chris@40 3852 file=$func_resolve_sysroot_result
Chris@40 3853
Chris@40 3854 # Check to see that this really is a libtool archive.
Chris@40 3855 func_lalib_unsafe_p "$file" \
Chris@40 3856 || func_fatal_help "'$lib' is not a valid libtool archive"
Chris@40 3857
Chris@40 3858 # Read the libtool library.
Chris@40 3859 dlname=
Chris@40 3860 library_names=
Chris@40 3861 func_source "$file"
Chris@40 3862
Chris@40 3863 # Skip this library if it cannot be dlopened.
Chris@40 3864 if test -z "$dlname"; then
Chris@40 3865 # Warn if it was a shared library.
Chris@40 3866 test -n "$library_names" && \
Chris@40 3867 func_warning "'$file' was not linked with '-export-dynamic'"
Chris@40 3868 continue
Chris@40 3869 fi
Chris@40 3870
Chris@40 3871 func_dirname "$file" "" "."
Chris@40 3872 dir=$func_dirname_result
Chris@40 3873
Chris@40 3874 if test -f "$dir/$objdir/$dlname"; then
Chris@40 3875 func_append dir "/$objdir"
Chris@40 3876 else
Chris@40 3877 if test ! -f "$dir/$dlname"; then
Chris@40 3878 func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
Chris@40 3879 fi
Chris@40 3880 fi
Chris@40 3881 ;;
Chris@40 3882
Chris@40 3883 *.lo)
Chris@40 3884 # Just add the directory containing the .lo file.
Chris@40 3885 func_dirname "$file" "" "."
Chris@40 3886 dir=$func_dirname_result
Chris@40 3887 ;;
Chris@40 3888
Chris@40 3889 *)
Chris@40 3890 func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
Chris@40 3891 continue
Chris@40 3892 ;;
Chris@40 3893 esac
Chris@40 3894
Chris@40 3895 # Get the absolute pathname.
Chris@40 3896 absdir=`cd "$dir" && pwd`
Chris@40 3897 test -n "$absdir" && dir=$absdir
Chris@40 3898
Chris@40 3899 # Now add the directory to shlibpath_var.
Chris@40 3900 if eval "test -z \"\$$shlibpath_var\""; then
Chris@40 3901 eval "$shlibpath_var=\"\$dir\""
Chris@40 3902 else
Chris@40 3903 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
Chris@40 3904 fi
Chris@40 3905 done
Chris@40 3906
Chris@40 3907 # This variable tells wrapper scripts just to set shlibpath_var
Chris@40 3908 # rather than running their programs.
Chris@40 3909 libtool_execute_magic=$magic
Chris@40 3910
Chris@40 3911 # Check if any of the arguments is a wrapper script.
Chris@40 3912 args=
Chris@40 3913 for file
Chris@40 3914 do
Chris@40 3915 case $file in
Chris@40 3916 -* | *.la | *.lo ) ;;
Chris@40 3917 *)
Chris@40 3918 # Do a test to see if this is really a libtool program.
Chris@40 3919 if func_ltwrapper_script_p "$file"; then
Chris@40 3920 func_source "$file"
Chris@40 3921 # Transform arg to wrapped name.
Chris@40 3922 file=$progdir/$program
Chris@40 3923 elif func_ltwrapper_executable_p "$file"; then
Chris@40 3924 func_ltwrapper_scriptname "$file"
Chris@40 3925 func_source "$func_ltwrapper_scriptname_result"
Chris@40 3926 # Transform arg to wrapped name.
Chris@40 3927 file=$progdir/$program
Chris@40 3928 fi
Chris@40 3929 ;;
Chris@40 3930 esac
Chris@40 3931 # Quote arguments (to preserve shell metacharacters).
Chris@40 3932 func_append_quoted args "$file"
Chris@40 3933 done
Chris@40 3934
Chris@40 3935 if $opt_dry_run; then
Chris@40 3936 # Display what would be done.
Chris@40 3937 if test -n "$shlibpath_var"; then
Chris@40 3938 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
Chris@40 3939 echo "export $shlibpath_var"
Chris@40 3940 fi
Chris@40 3941 $ECHO "$cmd$args"
Chris@40 3942 exit $EXIT_SUCCESS
Chris@40 3943 else
Chris@40 3944 if test -n "$shlibpath_var"; then
Chris@40 3945 # Export the shlibpath_var.
Chris@40 3946 eval "export $shlibpath_var"
Chris@40 3947 fi
Chris@40 3948
Chris@40 3949 # Restore saved environment variables
Chris@40 3950 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
Chris@40 3951 do
Chris@40 3952 eval "if test \"\${save_$lt_var+set}\" = set; then
Chris@40 3953 $lt_var=\$save_$lt_var; export $lt_var
Chris@40 3954 else
Chris@40 3955 $lt_unset $lt_var
Chris@40 3956 fi"
Chris@40 3957 done
Chris@40 3958
Chris@40 3959 # Now prepare to actually exec the command.
Chris@40 3960 exec_cmd=\$cmd$args
Chris@40 3961 fi
Chris@40 3962 }
Chris@40 3963
Chris@40 3964 test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
Chris@40 3965
Chris@40 3966
Chris@40 3967 # func_mode_finish arg...
Chris@40 3968 func_mode_finish ()
Chris@40 3969 {
Chris@40 3970 $debug_cmd
Chris@40 3971
Chris@40 3972 libs=
Chris@40 3973 libdirs=
Chris@40 3974 admincmds=
Chris@40 3975
Chris@40 3976 for opt in "$nonopt" ${1+"$@"}
Chris@40 3977 do
Chris@40 3978 if test -d "$opt"; then
Chris@40 3979 func_append libdirs " $opt"
Chris@40 3980
Chris@40 3981 elif test -f "$opt"; then
Chris@40 3982 if func_lalib_unsafe_p "$opt"; then
Chris@40 3983 func_append libs " $opt"
Chris@40 3984 else
Chris@40 3985 func_warning "'$opt' is not a valid libtool archive"
Chris@40 3986 fi
Chris@40 3987
Chris@40 3988 else
Chris@40 3989 func_fatal_error "invalid argument '$opt'"
Chris@40 3990 fi
Chris@40 3991 done
Chris@40 3992
Chris@40 3993 if test -n "$libs"; then
Chris@40 3994 if test -n "$lt_sysroot"; then
Chris@40 3995 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
Chris@40 3996 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
Chris@40 3997 else
Chris@40 3998 sysroot_cmd=
Chris@40 3999 fi
Chris@40 4000
Chris@40 4001 # Remove sysroot references
Chris@40 4002 if $opt_dry_run; then
Chris@40 4003 for lib in $libs; do
Chris@40 4004 echo "removing references to $lt_sysroot and '=' prefixes from $lib"
Chris@40 4005 done
Chris@40 4006 else
Chris@40 4007 tmpdir=`func_mktempdir`
Chris@40 4008 for lib in $libs; do
Chris@40 4009 $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
Chris@40 4010 > $tmpdir/tmp-la
Chris@40 4011 mv -f $tmpdir/tmp-la $lib
Chris@40 4012 done
Chris@40 4013 ${RM}r "$tmpdir"
Chris@40 4014 fi
Chris@40 4015 fi
Chris@40 4016
Chris@40 4017 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
Chris@40 4018 for libdir in $libdirs; do
Chris@40 4019 if test -n "$finish_cmds"; then
Chris@40 4020 # Do each command in the finish commands.
Chris@40 4021 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
Chris@40 4022 '"$cmd"'"'
Chris@40 4023 fi
Chris@40 4024 if test -n "$finish_eval"; then
Chris@40 4025 # Do the single finish_eval.
Chris@40 4026 eval cmds=\"$finish_eval\"
Chris@40 4027 $opt_dry_run || eval "$cmds" || func_append admincmds "
Chris@40 4028 $cmds"
Chris@40 4029 fi
Chris@40 4030 done
Chris@40 4031 fi
Chris@40 4032
Chris@40 4033 # Exit here if they wanted silent mode.
Chris@40 4034 $opt_quiet && exit $EXIT_SUCCESS
Chris@40 4035
Chris@40 4036 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
Chris@40 4037 echo "----------------------------------------------------------------------"
Chris@40 4038 echo "Libraries have been installed in:"
Chris@40 4039 for libdir in $libdirs; do
Chris@40 4040 $ECHO " $libdir"
Chris@40 4041 done
Chris@40 4042 echo
Chris@40 4043 echo "If you ever happen to want to link against installed libraries"
Chris@40 4044 echo "in a given directory, LIBDIR, you must either use libtool, and"
Chris@40 4045 echo "specify the full pathname of the library, or use the '-LLIBDIR'"
Chris@40 4046 echo "flag during linking and do at least one of the following:"
Chris@40 4047 if test -n "$shlibpath_var"; then
Chris@40 4048 echo " - add LIBDIR to the '$shlibpath_var' environment variable"
Chris@40 4049 echo " during execution"
Chris@40 4050 fi
Chris@40 4051 if test -n "$runpath_var"; then
Chris@40 4052 echo " - add LIBDIR to the '$runpath_var' environment variable"
Chris@40 4053 echo " during linking"
Chris@40 4054 fi
Chris@40 4055 if test -n "$hardcode_libdir_flag_spec"; then
Chris@40 4056 libdir=LIBDIR
Chris@40 4057 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@40 4058
Chris@40 4059 $ECHO " - use the '$flag' linker flag"
Chris@40 4060 fi
Chris@40 4061 if test -n "$admincmds"; then
Chris@40 4062 $ECHO " - have your system administrator run these commands:$admincmds"
Chris@40 4063 fi
Chris@40 4064 if test -f /etc/ld.so.conf; then
Chris@40 4065 echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
Chris@40 4066 fi
Chris@40 4067 echo
Chris@40 4068
Chris@40 4069 echo "See any operating system documentation about shared libraries for"
Chris@40 4070 case $host in
Chris@40 4071 solaris2.[6789]|solaris2.1[0-9])
Chris@40 4072 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
Chris@40 4073 echo "pages."
Chris@40 4074 ;;
Chris@40 4075 *)
Chris@40 4076 echo "more information, such as the ld(1) and ld.so(8) manual pages."
Chris@40 4077 ;;
Chris@40 4078 esac
Chris@40 4079 echo "----------------------------------------------------------------------"
Chris@40 4080 fi
Chris@40 4081 exit $EXIT_SUCCESS
Chris@40 4082 }
Chris@40 4083
Chris@40 4084 test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
Chris@40 4085
Chris@40 4086
Chris@40 4087 # func_mode_install arg...
Chris@40 4088 func_mode_install ()
Chris@40 4089 {
Chris@40 4090 $debug_cmd
Chris@40 4091
Chris@40 4092 # There may be an optional sh(1) argument at the beginning of
Chris@40 4093 # install_prog (especially on Windows NT).
Chris@40 4094 if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
Chris@40 4095 # Allow the use of GNU shtool's install command.
Chris@40 4096 case $nonopt in *shtool*) :;; *) false;; esac
Chris@40 4097 then
Chris@40 4098 # Aesthetically quote it.
Chris@40 4099 func_quote_for_eval "$nonopt"
Chris@40 4100 install_prog="$func_quote_for_eval_result "
Chris@40 4101 arg=$1
Chris@40 4102 shift
Chris@40 4103 else
Chris@40 4104 install_prog=
Chris@40 4105 arg=$nonopt
Chris@40 4106 fi
Chris@40 4107
Chris@40 4108 # The real first argument should be the name of the installation program.
Chris@40 4109 # Aesthetically quote it.
Chris@40 4110 func_quote_for_eval "$arg"
Chris@40 4111 func_append install_prog "$func_quote_for_eval_result"
Chris@40 4112 install_shared_prog=$install_prog
Chris@40 4113 case " $install_prog " in
Chris@40 4114 *[\\\ /]cp\ *) install_cp=: ;;
Chris@40 4115 *) install_cp=false ;;
Chris@40 4116 esac
Chris@40 4117
Chris@40 4118 # We need to accept at least all the BSD install flags.
Chris@40 4119 dest=
Chris@40 4120 files=
Chris@40 4121 opts=
Chris@40 4122 prev=
Chris@40 4123 install_type=
Chris@40 4124 isdir=false
Chris@40 4125 stripme=
Chris@40 4126 no_mode=:
Chris@40 4127 for arg
Chris@40 4128 do
Chris@40 4129 arg2=
Chris@40 4130 if test -n "$dest"; then
Chris@40 4131 func_append files " $dest"
Chris@40 4132 dest=$arg
Chris@40 4133 continue
Chris@40 4134 fi
Chris@40 4135
Chris@40 4136 case $arg in
Chris@40 4137 -d) isdir=: ;;
Chris@40 4138 -f)
Chris@40 4139 if $install_cp; then :; else
Chris@40 4140 prev=$arg
Chris@40 4141 fi
Chris@40 4142 ;;
Chris@40 4143 -g | -m | -o)
Chris@40 4144 prev=$arg
Chris@40 4145 ;;
Chris@40 4146 -s)
Chris@40 4147 stripme=" -s"
Chris@40 4148 continue
Chris@40 4149 ;;
Chris@40 4150 -*)
Chris@40 4151 ;;
Chris@40 4152 *)
Chris@40 4153 # If the previous option needed an argument, then skip it.
Chris@40 4154 if test -n "$prev"; then
Chris@40 4155 if test X-m = "X$prev" && test -n "$install_override_mode"; then
Chris@40 4156 arg2=$install_override_mode
Chris@40 4157 no_mode=false
Chris@40 4158 fi
Chris@40 4159 prev=
Chris@40 4160 else
Chris@40 4161 dest=$arg
Chris@40 4162 continue
Chris@40 4163 fi
Chris@40 4164 ;;
Chris@40 4165 esac
Chris@40 4166
Chris@40 4167 # Aesthetically quote the argument.
Chris@40 4168 func_quote_for_eval "$arg"
Chris@40 4169 func_append install_prog " $func_quote_for_eval_result"
Chris@40 4170 if test -n "$arg2"; then
Chris@40 4171 func_quote_for_eval "$arg2"
Chris@40 4172 fi
Chris@40 4173 func_append install_shared_prog " $func_quote_for_eval_result"
Chris@40 4174 done
Chris@40 4175
Chris@40 4176 test -z "$install_prog" && \
Chris@40 4177 func_fatal_help "you must specify an install program"
Chris@40 4178
Chris@40 4179 test -n "$prev" && \
Chris@40 4180 func_fatal_help "the '$prev' option requires an argument"
Chris@40 4181
Chris@40 4182 if test -n "$install_override_mode" && $no_mode; then
Chris@40 4183 if $install_cp; then :; else
Chris@40 4184 func_quote_for_eval "$install_override_mode"
Chris@40 4185 func_append install_shared_prog " -m $func_quote_for_eval_result"
Chris@40 4186 fi
Chris@40 4187 fi
Chris@40 4188
Chris@40 4189 if test -z "$files"; then
Chris@40 4190 if test -z "$dest"; then
Chris@40 4191 func_fatal_help "no file or destination specified"
Chris@40 4192 else
Chris@40 4193 func_fatal_help "you must specify a destination"
Chris@40 4194 fi
Chris@40 4195 fi
Chris@40 4196
Chris@40 4197 # Strip any trailing slash from the destination.
Chris@40 4198 func_stripname '' '/' "$dest"
Chris@40 4199 dest=$func_stripname_result
Chris@40 4200
Chris@40 4201 # Check to see that the destination is a directory.
Chris@40 4202 test -d "$dest" && isdir=:
Chris@40 4203 if $isdir; then
Chris@40 4204 destdir=$dest
Chris@40 4205 destname=
Chris@40 4206 else
Chris@40 4207 func_dirname_and_basename "$dest" "" "."
Chris@40 4208 destdir=$func_dirname_result
Chris@40 4209 destname=$func_basename_result
Chris@40 4210
Chris@40 4211 # Not a directory, so check to see that there is only one file specified.
Chris@40 4212 set dummy $files; shift
Chris@40 4213 test "$#" -gt 1 && \
Chris@40 4214 func_fatal_help "'$dest' is not a directory"
Chris@40 4215 fi
Chris@40 4216 case $destdir in
Chris@40 4217 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@40 4218 *)
Chris@40 4219 for file in $files; do
Chris@40 4220 case $file in
Chris@40 4221 *.lo) ;;
Chris@40 4222 *)
Chris@40 4223 func_fatal_help "'$destdir' must be an absolute directory name"
Chris@40 4224 ;;
Chris@40 4225 esac
Chris@40 4226 done
Chris@40 4227 ;;
Chris@40 4228 esac
Chris@40 4229
Chris@40 4230 # This variable tells wrapper scripts just to set variables rather
Chris@40 4231 # than running their programs.
Chris@40 4232 libtool_install_magic=$magic
Chris@40 4233
Chris@40 4234 staticlibs=
Chris@40 4235 future_libdirs=
Chris@40 4236 current_libdirs=
Chris@40 4237 for file in $files; do
Chris@40 4238
Chris@40 4239 # Do each installation.
Chris@40 4240 case $file in
Chris@40 4241 *.$libext)
Chris@40 4242 # Do the static libraries later.
Chris@40 4243 func_append staticlibs " $file"
Chris@40 4244 ;;
Chris@40 4245
Chris@40 4246 *.la)
Chris@40 4247 func_resolve_sysroot "$file"
Chris@40 4248 file=$func_resolve_sysroot_result
Chris@40 4249
Chris@40 4250 # Check to see that this really is a libtool archive.
Chris@40 4251 func_lalib_unsafe_p "$file" \
Chris@40 4252 || func_fatal_help "'$file' is not a valid libtool archive"
Chris@40 4253
Chris@40 4254 library_names=
Chris@40 4255 old_library=
Chris@40 4256 relink_command=
Chris@40 4257 func_source "$file"
Chris@40 4258
Chris@40 4259 # Add the libdir to current_libdirs if it is the destination.
Chris@40 4260 if test "X$destdir" = "X$libdir"; then
Chris@40 4261 case "$current_libdirs " in
Chris@40 4262 *" $libdir "*) ;;
Chris@40 4263 *) func_append current_libdirs " $libdir" ;;
Chris@40 4264 esac
Chris@40 4265 else
Chris@40 4266 # Note the libdir as a future libdir.
Chris@40 4267 case "$future_libdirs " in
Chris@40 4268 *" $libdir "*) ;;
Chris@40 4269 *) func_append future_libdirs " $libdir" ;;
Chris@40 4270 esac
Chris@40 4271 fi
Chris@40 4272
Chris@40 4273 func_dirname "$file" "/" ""
Chris@40 4274 dir=$func_dirname_result
Chris@40 4275 func_append dir "$objdir"
Chris@40 4276
Chris@40 4277 if test -n "$relink_command"; then
Chris@40 4278 # Determine the prefix the user has applied to our future dir.
Chris@40 4279 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
Chris@40 4280
Chris@40 4281 # Don't allow the user to place us outside of our expected
Chris@40 4282 # location b/c this prevents finding dependent libraries that
Chris@40 4283 # are installed to the same prefix.
Chris@40 4284 # At present, this check doesn't affect windows .dll's that
Chris@40 4285 # are installed into $libdir/../bin (currently, that works fine)
Chris@40 4286 # but it's something to keep an eye on.
Chris@40 4287 test "$inst_prefix_dir" = "$destdir" && \
Chris@40 4288 func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
Chris@40 4289
Chris@40 4290 if test -n "$inst_prefix_dir"; then
Chris@40 4291 # Stick the inst_prefix_dir data into the link command.
Chris@40 4292 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
Chris@40 4293 else
Chris@40 4294 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
Chris@40 4295 fi
Chris@40 4296
Chris@40 4297 func_warning "relinking '$file'"
Chris@40 4298 func_show_eval "$relink_command" \
Chris@40 4299 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
Chris@40 4300 fi
Chris@40 4301
Chris@40 4302 # See the names of the shared library.
Chris@40 4303 set dummy $library_names; shift
Chris@40 4304 if test -n "$1"; then
Chris@40 4305 realname=$1
Chris@40 4306 shift
Chris@40 4307
Chris@40 4308 srcname=$realname
Chris@40 4309 test -n "$relink_command" && srcname=${realname}T
Chris@40 4310
Chris@40 4311 # Install the shared library and build the symlinks.
Chris@40 4312 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
Chris@40 4313 'exit $?'
Chris@40 4314 tstripme=$stripme
Chris@40 4315 case $host_os in
Chris@40 4316 cygwin* | mingw* | pw32* | cegcc*)
Chris@40 4317 case $realname in
Chris@40 4318 *.dll.a)
Chris@40 4319 tstripme=
Chris@40 4320 ;;
Chris@40 4321 esac
Chris@40 4322 ;;
Chris@40 4323 os2*)
Chris@40 4324 case $realname in
Chris@40 4325 *_dll.a)
Chris@40 4326 tstripme=
Chris@40 4327 ;;
Chris@40 4328 esac
Chris@40 4329 ;;
Chris@40 4330 esac
Chris@40 4331 if test -n "$tstripme" && test -n "$striplib"; then
Chris@40 4332 func_show_eval "$striplib $destdir/$realname" 'exit $?'
Chris@40 4333 fi
Chris@40 4334
Chris@40 4335 if test "$#" -gt 0; then
Chris@40 4336 # Delete the old symlinks, and create new ones.
Chris@40 4337 # Try 'ln -sf' first, because the 'ln' binary might depend on
Chris@40 4338 # the symlink we replace! Solaris /bin/ln does not understand -f,
Chris@40 4339 # so we also need to try rm && ln -s.
Chris@40 4340 for linkname
Chris@40 4341 do
Chris@40 4342 test "$linkname" != "$realname" \
Chris@40 4343 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
Chris@40 4344 done
Chris@40 4345 fi
Chris@40 4346
Chris@40 4347 # Do each command in the postinstall commands.
Chris@40 4348 lib=$destdir/$realname
Chris@40 4349 func_execute_cmds "$postinstall_cmds" 'exit $?'
Chris@40 4350 fi
Chris@40 4351
Chris@40 4352 # Install the pseudo-library for information purposes.
Chris@40 4353 func_basename "$file"
Chris@40 4354 name=$func_basename_result
Chris@40 4355 instname=$dir/${name}i
Chris@40 4356 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
Chris@40 4357
Chris@40 4358 # Maybe install the static library, too.
Chris@40 4359 test -n "$old_library" && func_append staticlibs " $dir/$old_library"
Chris@40 4360 ;;
Chris@40 4361
Chris@40 4362 *.lo)
Chris@40 4363 # Install (i.e. copy) a libtool object.
Chris@40 4364
Chris@40 4365 # Figure out destination file name, if it wasn't already specified.
Chris@40 4366 if test -n "$destname"; then
Chris@40 4367 destfile=$destdir/$destname
Chris@40 4368 else
Chris@40 4369 func_basename "$file"
Chris@40 4370 destfile=$func_basename_result
Chris@40 4371 destfile=$destdir/$destfile
Chris@40 4372 fi
Chris@40 4373
Chris@40 4374 # Deduce the name of the destination old-style object file.
Chris@40 4375 case $destfile in
Chris@40 4376 *.lo)
Chris@40 4377 func_lo2o "$destfile"
Chris@40 4378 staticdest=$func_lo2o_result
Chris@40 4379 ;;
Chris@40 4380 *.$objext)
Chris@40 4381 staticdest=$destfile
Chris@40 4382 destfile=
Chris@40 4383 ;;
Chris@40 4384 *)
Chris@40 4385 func_fatal_help "cannot copy a libtool object to '$destfile'"
Chris@40 4386 ;;
Chris@40 4387 esac
Chris@40 4388
Chris@40 4389 # Install the libtool object if requested.
Chris@40 4390 test -n "$destfile" && \
Chris@40 4391 func_show_eval "$install_prog $file $destfile" 'exit $?'
Chris@40 4392
Chris@40 4393 # Install the old object if enabled.
Chris@40 4394 if test yes = "$build_old_libs"; then
Chris@40 4395 # Deduce the name of the old-style object file.
Chris@40 4396 func_lo2o "$file"
Chris@40 4397 staticobj=$func_lo2o_result
Chris@40 4398 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
Chris@40 4399 fi
Chris@40 4400 exit $EXIT_SUCCESS
Chris@40 4401 ;;
Chris@40 4402
Chris@40 4403 *)
Chris@40 4404 # Figure out destination file name, if it wasn't already specified.
Chris@40 4405 if test -n "$destname"; then
Chris@40 4406 destfile=$destdir/$destname
Chris@40 4407 else
Chris@40 4408 func_basename "$file"
Chris@40 4409 destfile=$func_basename_result
Chris@40 4410 destfile=$destdir/$destfile
Chris@40 4411 fi
Chris@40 4412
Chris@40 4413 # If the file is missing, and there is a .exe on the end, strip it
Chris@40 4414 # because it is most likely a libtool script we actually want to
Chris@40 4415 # install
Chris@40 4416 stripped_ext=
Chris@40 4417 case $file in
Chris@40 4418 *.exe)
Chris@40 4419 if test ! -f "$file"; then
Chris@40 4420 func_stripname '' '.exe' "$file"
Chris@40 4421 file=$func_stripname_result
Chris@40 4422 stripped_ext=.exe
Chris@40 4423 fi
Chris@40 4424 ;;
Chris@40 4425 esac
Chris@40 4426
Chris@40 4427 # Do a test to see if this is really a libtool program.
Chris@40 4428 case $host in
Chris@40 4429 *cygwin* | *mingw*)
Chris@40 4430 if func_ltwrapper_executable_p "$file"; then
Chris@40 4431 func_ltwrapper_scriptname "$file"
Chris@40 4432 wrapper=$func_ltwrapper_scriptname_result
Chris@40 4433 else
Chris@40 4434 func_stripname '' '.exe' "$file"
Chris@40 4435 wrapper=$func_stripname_result
Chris@40 4436 fi
Chris@40 4437 ;;
Chris@40 4438 *)
Chris@40 4439 wrapper=$file
Chris@40 4440 ;;
Chris@40 4441 esac
Chris@40 4442 if func_ltwrapper_script_p "$wrapper"; then
Chris@40 4443 notinst_deplibs=
Chris@40 4444 relink_command=
Chris@40 4445
Chris@40 4446 func_source "$wrapper"
Chris@40 4447
Chris@40 4448 # Check the variables that should have been set.
Chris@40 4449 test -z "$generated_by_libtool_version" && \
Chris@40 4450 func_fatal_error "invalid libtool wrapper script '$wrapper'"
Chris@40 4451
Chris@40 4452 finalize=:
Chris@40 4453 for lib in $notinst_deplibs; do
Chris@40 4454 # Check to see that each library is installed.
Chris@40 4455 libdir=
Chris@40 4456 if test -f "$lib"; then
Chris@40 4457 func_source "$lib"
Chris@40 4458 fi
Chris@40 4459 libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
Chris@40 4460 if test -n "$libdir" && test ! -f "$libfile"; then
Chris@40 4461 func_warning "'$lib' has not been installed in '$libdir'"
Chris@40 4462 finalize=false
Chris@40 4463 fi
Chris@40 4464 done
Chris@40 4465
Chris@40 4466 relink_command=
Chris@40 4467 func_source "$wrapper"
Chris@40 4468
Chris@40 4469 outputname=
Chris@40 4470 if test no = "$fast_install" && test -n "$relink_command"; then
Chris@40 4471 $opt_dry_run || {
Chris@40 4472 if $finalize; then
Chris@40 4473 tmpdir=`func_mktempdir`
Chris@40 4474 func_basename "$file$stripped_ext"
Chris@40 4475 file=$func_basename_result
Chris@40 4476 outputname=$tmpdir/$file
Chris@40 4477 # Replace the output file specification.
Chris@40 4478 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
Chris@40 4479
Chris@40 4480 $opt_quiet || {
Chris@40 4481 func_quote_for_expand "$relink_command"
Chris@40 4482 eval "func_echo $func_quote_for_expand_result"
Chris@40 4483 }
Chris@40 4484 if eval "$relink_command"; then :
Chris@40 4485 else
Chris@40 4486 func_error "error: relink '$file' with the above command before installing it"
Chris@40 4487 $opt_dry_run || ${RM}r "$tmpdir"
Chris@40 4488 continue
Chris@40 4489 fi
Chris@40 4490 file=$outputname
Chris@40 4491 else
Chris@40 4492 func_warning "cannot relink '$file'"
Chris@40 4493 fi
Chris@40 4494 }
Chris@40 4495 else
Chris@40 4496 # Install the binary that we compiled earlier.
Chris@40 4497 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
Chris@40 4498 fi
Chris@40 4499 fi
Chris@40 4500
Chris@40 4501 # remove .exe since cygwin /usr/bin/install will append another
Chris@40 4502 # one anyway
Chris@40 4503 case $install_prog,$host in
Chris@40 4504 */usr/bin/install*,*cygwin*)
Chris@40 4505 case $file:$destfile in
Chris@40 4506 *.exe:*.exe)
Chris@40 4507 # this is ok
Chris@40 4508 ;;
Chris@40 4509 *.exe:*)
Chris@40 4510 destfile=$destfile.exe
Chris@40 4511 ;;
Chris@40 4512 *:*.exe)
Chris@40 4513 func_stripname '' '.exe' "$destfile"
Chris@40 4514 destfile=$func_stripname_result
Chris@40 4515 ;;
Chris@40 4516 esac
Chris@40 4517 ;;
Chris@40 4518 esac
Chris@40 4519 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
Chris@40 4520 $opt_dry_run || if test -n "$outputname"; then
Chris@40 4521 ${RM}r "$tmpdir"
Chris@40 4522 fi
Chris@40 4523 ;;
Chris@40 4524 esac
Chris@40 4525 done
Chris@40 4526
Chris@40 4527 for file in $staticlibs; do
Chris@40 4528 func_basename "$file"
Chris@40 4529 name=$func_basename_result
Chris@40 4530
Chris@40 4531 # Set up the ranlib parameters.
Chris@40 4532 oldlib=$destdir/$name
Chris@40 4533 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
Chris@40 4534 tool_oldlib=$func_to_tool_file_result
Chris@40 4535
Chris@40 4536 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
Chris@40 4537
Chris@40 4538 if test -n "$stripme" && test -n "$old_striplib"; then
Chris@40 4539 func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
Chris@40 4540 fi
Chris@40 4541
Chris@40 4542 # Do each command in the postinstall commands.
Chris@40 4543 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
Chris@40 4544 done
Chris@40 4545
Chris@40 4546 test -n "$future_libdirs" && \
Chris@40 4547 func_warning "remember to run '$progname --finish$future_libdirs'"
Chris@40 4548
Chris@40 4549 if test -n "$current_libdirs"; then
Chris@40 4550 # Maybe just do a dry run.
Chris@40 4551 $opt_dry_run && current_libdirs=" -n$current_libdirs"
Chris@40 4552 exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
Chris@40 4553 else
Chris@40 4554 exit $EXIT_SUCCESS
Chris@40 4555 fi
Chris@40 4556 }
Chris@40 4557
Chris@40 4558 test install = "$opt_mode" && func_mode_install ${1+"$@"}
Chris@40 4559
Chris@40 4560
Chris@40 4561 # func_generate_dlsyms outputname originator pic_p
Chris@40 4562 # Extract symbols from dlprefiles and create ${outputname}S.o with
Chris@40 4563 # a dlpreopen symbol table.
Chris@40 4564 func_generate_dlsyms ()
Chris@40 4565 {
Chris@40 4566 $debug_cmd
Chris@40 4567
Chris@40 4568 my_outputname=$1
Chris@40 4569 my_originator=$2
Chris@40 4570 my_pic_p=${3-false}
Chris@40 4571 my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
Chris@40 4572 my_dlsyms=
Chris@40 4573
Chris@40 4574 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
Chris@40 4575 if test -n "$NM" && test -n "$global_symbol_pipe"; then
Chris@40 4576 my_dlsyms=${my_outputname}S.c
Chris@40 4577 else
Chris@40 4578 func_error "not configured to extract global symbols from dlpreopened files"
Chris@40 4579 fi
Chris@40 4580 fi
Chris@40 4581
Chris@40 4582 if test -n "$my_dlsyms"; then
Chris@40 4583 case $my_dlsyms in
Chris@40 4584 "") ;;
Chris@40 4585 *.c)
Chris@40 4586 # Discover the nlist of each of the dlfiles.
Chris@40 4587 nlist=$output_objdir/$my_outputname.nm
Chris@40 4588
Chris@40 4589 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
Chris@40 4590
Chris@40 4591 # Parse the name list into a source file.
Chris@40 4592 func_verbose "creating $output_objdir/$my_dlsyms"
Chris@40 4593
Chris@40 4594 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
Chris@40 4595 /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
Chris@40 4596 /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
Chris@40 4597
Chris@40 4598 #ifdef __cplusplus
Chris@40 4599 extern \"C\" {
Chris@40 4600 #endif
Chris@40 4601
Chris@40 4602 #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
Chris@40 4603 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
Chris@40 4604 #endif
Chris@40 4605
Chris@40 4606 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
Chris@40 4607 #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
Chris@40 4608 /* DATA imports from DLLs on WIN32 can't be const, because runtime
Chris@40 4609 relocations are performed -- see ld's documentation on pseudo-relocs. */
Chris@40 4610 # define LT_DLSYM_CONST
Chris@40 4611 #elif defined __osf__
Chris@40 4612 /* This system does not cope well with relocations in const data. */
Chris@40 4613 # define LT_DLSYM_CONST
Chris@40 4614 #else
Chris@40 4615 # define LT_DLSYM_CONST const
Chris@40 4616 #endif
Chris@40 4617
Chris@40 4618 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
Chris@40 4619
Chris@40 4620 /* External symbol declarations for the compiler. */\
Chris@40 4621 "
Chris@40 4622
Chris@40 4623 if test yes = "$dlself"; then
Chris@40 4624 func_verbose "generating symbol list for '$output'"
Chris@40 4625
Chris@40 4626 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
Chris@40 4627
Chris@40 4628 # Add our own program objects to the symbol list.
Chris@40 4629 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@40 4630 for progfile in $progfiles; do
Chris@40 4631 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
Chris@40 4632 func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
Chris@40 4633 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
Chris@40 4634 done
Chris@40 4635
Chris@40 4636 if test -n "$exclude_expsyms"; then
Chris@40 4637 $opt_dry_run || {
Chris@40 4638 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
Chris@40 4639 eval '$MV "$nlist"T "$nlist"'
Chris@40 4640 }
Chris@40 4641 fi
Chris@40 4642
Chris@40 4643 if test -n "$export_symbols_regex"; then
Chris@40 4644 $opt_dry_run || {
Chris@40 4645 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
Chris@40 4646 eval '$MV "$nlist"T "$nlist"'
Chris@40 4647 }
Chris@40 4648 fi
Chris@40 4649
Chris@40 4650 # Prepare the list of exported symbols
Chris@40 4651 if test -z "$export_symbols"; then
Chris@40 4652 export_symbols=$output_objdir/$outputname.exp
Chris@40 4653 $opt_dry_run || {
Chris@40 4654 $RM $export_symbols
Chris@40 4655 eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
Chris@40 4656 case $host in
Chris@40 4657 *cygwin* | *mingw* | *cegcc* )
Chris@40 4658 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
Chris@40 4659 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
Chris@40 4660 ;;
Chris@40 4661 esac
Chris@40 4662 }
Chris@40 4663 else
Chris@40 4664 $opt_dry_run || {
Chris@40 4665 eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
Chris@40 4666 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
Chris@40 4667 eval '$MV "$nlist"T "$nlist"'
Chris@40 4668 case $host in
Chris@40 4669 *cygwin* | *mingw* | *cegcc* )
Chris@40 4670 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
Chris@40 4671 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
Chris@40 4672 ;;
Chris@40 4673 esac
Chris@40 4674 }
Chris@40 4675 fi
Chris@40 4676 fi
Chris@40 4677
Chris@40 4678 for dlprefile in $dlprefiles; do
Chris@40 4679 func_verbose "extracting global C symbols from '$dlprefile'"
Chris@40 4680 func_basename "$dlprefile"
Chris@40 4681 name=$func_basename_result
Chris@40 4682 case $host in
Chris@40 4683 *cygwin* | *mingw* | *cegcc* )
Chris@40 4684 # if an import library, we need to obtain dlname
Chris@40 4685 if func_win32_import_lib_p "$dlprefile"; then
Chris@40 4686 func_tr_sh "$dlprefile"
Chris@40 4687 eval "curr_lafile=\$libfile_$func_tr_sh_result"
Chris@40 4688 dlprefile_dlbasename=
Chris@40 4689 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
Chris@40 4690 # Use subshell, to avoid clobbering current variable values
Chris@40 4691 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
Chris@40 4692 if test -n "$dlprefile_dlname"; then
Chris@40 4693 func_basename "$dlprefile_dlname"
Chris@40 4694 dlprefile_dlbasename=$func_basename_result
Chris@40 4695 else
Chris@40 4696 # no lafile. user explicitly requested -dlpreopen <import library>.
Chris@40 4697 $sharedlib_from_linklib_cmd "$dlprefile"
Chris@40 4698 dlprefile_dlbasename=$sharedlib_from_linklib_result
Chris@40 4699 fi
Chris@40 4700 fi
Chris@40 4701 $opt_dry_run || {
Chris@40 4702 if test -n "$dlprefile_dlbasename"; then
Chris@40 4703 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
Chris@40 4704 else
Chris@40 4705 func_warning "Could not compute DLL name from $name"
Chris@40 4706 eval '$ECHO ": $name " >> "$nlist"'
Chris@40 4707 fi
Chris@40 4708 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
Chris@40 4709 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
Chris@40 4710 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
Chris@40 4711 }
Chris@40 4712 else # not an import lib
Chris@40 4713 $opt_dry_run || {
Chris@40 4714 eval '$ECHO ": $name " >> "$nlist"'
Chris@40 4715 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
Chris@40 4716 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
Chris@40 4717 }
Chris@40 4718 fi
Chris@40 4719 ;;
Chris@40 4720 *)
Chris@40 4721 $opt_dry_run || {
Chris@40 4722 eval '$ECHO ": $name " >> "$nlist"'
Chris@40 4723 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
Chris@40 4724 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
Chris@40 4725 }
Chris@40 4726 ;;
Chris@40 4727 esac
Chris@40 4728 done
Chris@40 4729
Chris@40 4730 $opt_dry_run || {
Chris@40 4731 # Make sure we have at least an empty file.
Chris@40 4732 test -f "$nlist" || : > "$nlist"
Chris@40 4733
Chris@40 4734 if test -n "$exclude_expsyms"; then
Chris@40 4735 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
Chris@40 4736 $MV "$nlist"T "$nlist"
Chris@40 4737 fi
Chris@40 4738
Chris@40 4739 # Try sorting and uniquifying the output.
Chris@40 4740 if $GREP -v "^: " < "$nlist" |
Chris@40 4741 if sort -k 3 </dev/null >/dev/null 2>&1; then
Chris@40 4742 sort -k 3
Chris@40 4743 else
Chris@40 4744 sort +2
Chris@40 4745 fi |
Chris@40 4746 uniq > "$nlist"S; then
Chris@40 4747 :
Chris@40 4748 else
Chris@40 4749 $GREP -v "^: " < "$nlist" > "$nlist"S
Chris@40 4750 fi
Chris@40 4751
Chris@40 4752 if test -f "$nlist"S; then
Chris@40 4753 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
Chris@40 4754 else
Chris@40 4755 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
Chris@40 4756 fi
Chris@40 4757
Chris@40 4758 func_show_eval '$RM "${nlist}I"'
Chris@40 4759 if test -n "$global_symbol_to_import"; then
Chris@40 4760 eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
Chris@40 4761 fi
Chris@40 4762
Chris@40 4763 echo >> "$output_objdir/$my_dlsyms" "\
Chris@40 4764
Chris@40 4765 /* The mapping between symbol names and symbols. */
Chris@40 4766 typedef struct {
Chris@40 4767 const char *name;
Chris@40 4768 void *address;
Chris@40 4769 } lt_dlsymlist;
Chris@40 4770 extern LT_DLSYM_CONST lt_dlsymlist
Chris@40 4771 lt_${my_prefix}_LTX_preloaded_symbols[];\
Chris@40 4772 "
Chris@40 4773
Chris@40 4774 if test -s "$nlist"I; then
Chris@40 4775 echo >> "$output_objdir/$my_dlsyms" "\
Chris@40 4776 static void lt_syminit(void)
Chris@40 4777 {
Chris@40 4778 LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
Chris@40 4779 for (; symbol->name; ++symbol)
Chris@40 4780 {"
Chris@40 4781 $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
Chris@40 4782 echo >> "$output_objdir/$my_dlsyms" "\
Chris@40 4783 }
Chris@40 4784 }"
Chris@40 4785 fi
Chris@40 4786 echo >> "$output_objdir/$my_dlsyms" "\
Chris@40 4787 LT_DLSYM_CONST lt_dlsymlist
Chris@40 4788 lt_${my_prefix}_LTX_preloaded_symbols[] =
Chris@40 4789 { {\"$my_originator\", (void *) 0},"
Chris@40 4790
Chris@40 4791 if test -s "$nlist"I; then
Chris@40 4792 echo >> "$output_objdir/$my_dlsyms" "\
Chris@40 4793 {\"@INIT@\", (void *) &lt_syminit},"
Chris@40 4794 fi
Chris@40 4795
Chris@40 4796 case $need_lib_prefix in
Chris@40 4797 no)
Chris@40 4798 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
Chris@40 4799 ;;
Chris@40 4800 *)
Chris@40 4801 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
Chris@40 4802 ;;
Chris@40 4803 esac
Chris@40 4804 echo >> "$output_objdir/$my_dlsyms" "\
Chris@40 4805 {0, (void *) 0}
Chris@40 4806 };
Chris@40 4807
Chris@40 4808 /* This works around a problem in FreeBSD linker */
Chris@40 4809 #ifdef FREEBSD_WORKAROUND
Chris@40 4810 static const void *lt_preloaded_setup() {
Chris@40 4811 return lt_${my_prefix}_LTX_preloaded_symbols;
Chris@40 4812 }
Chris@40 4813 #endif
Chris@40 4814
Chris@40 4815 #ifdef __cplusplus
Chris@40 4816 }
Chris@40 4817 #endif\
Chris@40 4818 "
Chris@40 4819 } # !$opt_dry_run
Chris@40 4820
Chris@40 4821 pic_flag_for_symtable=
Chris@40 4822 case "$compile_command " in
Chris@40 4823 *" -static "*) ;;
Chris@40 4824 *)
Chris@40 4825 case $host in
Chris@40 4826 # compiling the symbol table file with pic_flag works around
Chris@40 4827 # a FreeBSD bug that causes programs to crash when -lm is
Chris@40 4828 # linked before any other PIC object. But we must not use
Chris@40 4829 # pic_flag when linking with -static. The problem exists in
Chris@40 4830 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
Chris@40 4831 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
Chris@40 4832 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
Chris@40 4833 *-*-hpux*)
Chris@40 4834 pic_flag_for_symtable=" $pic_flag" ;;
Chris@40 4835 *)
Chris@40 4836 $my_pic_p && pic_flag_for_symtable=" $pic_flag"
Chris@40 4837 ;;
Chris@40 4838 esac
Chris@40 4839 ;;
Chris@40 4840 esac
Chris@40 4841 symtab_cflags=
Chris@40 4842 for arg in $LTCFLAGS; do
Chris@40 4843 case $arg in
Chris@40 4844 -pie | -fpie | -fPIE) ;;
Chris@40 4845 *) func_append symtab_cflags " $arg" ;;
Chris@40 4846 esac
Chris@40 4847 done
Chris@40 4848
Chris@40 4849 # Now compile the dynamic symbol file.
Chris@40 4850 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
Chris@40 4851
Chris@40 4852 # Clean up the generated files.
Chris@40 4853 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
Chris@40 4854
Chris@40 4855 # Transform the symbol file into the correct name.
Chris@40 4856 symfileobj=$output_objdir/${my_outputname}S.$objext
Chris@40 4857 case $host in
Chris@40 4858 *cygwin* | *mingw* | *cegcc* )
Chris@40 4859 if test -f "$output_objdir/$my_outputname.def"; then
Chris@40 4860 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
Chris@40 4861 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
Chris@40 4862 else
Chris@40 4863 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@40 4864 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@40 4865 fi
Chris@40 4866 ;;
Chris@40 4867 *)
Chris@40 4868 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@40 4869 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@40 4870 ;;
Chris@40 4871 esac
Chris@40 4872 ;;
Chris@40 4873 *)
Chris@40 4874 func_fatal_error "unknown suffix for '$my_dlsyms'"
Chris@40 4875 ;;
Chris@40 4876 esac
Chris@40 4877 else
Chris@40 4878 # We keep going just in case the user didn't refer to
Chris@40 4879 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
Chris@40 4880 # really was required.
Chris@40 4881
Chris@40 4882 # Nullify the symbol file.
Chris@40 4883 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
Chris@40 4884 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
Chris@40 4885 fi
Chris@40 4886 }
Chris@40 4887
Chris@40 4888 # func_cygming_gnu_implib_p ARG
Chris@40 4889 # This predicate returns with zero status (TRUE) if
Chris@40 4890 # ARG is a GNU/binutils-style import library. Returns
Chris@40 4891 # with nonzero status (FALSE) otherwise.
Chris@40 4892 func_cygming_gnu_implib_p ()
Chris@40 4893 {
Chris@40 4894 $debug_cmd
Chris@40 4895
Chris@40 4896 func_to_tool_file "$1" func_convert_file_msys_to_w32
Chris@40 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@40 4898 test -n "$func_cygming_gnu_implib_tmp"
Chris@40 4899 }
Chris@40 4900
Chris@40 4901 # func_cygming_ms_implib_p ARG
Chris@40 4902 # This predicate returns with zero status (TRUE) if
Chris@40 4903 # ARG is an MS-style import library. Returns
Chris@40 4904 # with nonzero status (FALSE) otherwise.
Chris@40 4905 func_cygming_ms_implib_p ()
Chris@40 4906 {
Chris@40 4907 $debug_cmd
Chris@40 4908
Chris@40 4909 func_to_tool_file "$1" func_convert_file_msys_to_w32
Chris@40 4910 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
Chris@40 4911 test -n "$func_cygming_ms_implib_tmp"
Chris@40 4912 }
Chris@40 4913
Chris@40 4914 # func_win32_libid arg
Chris@40 4915 # return the library type of file 'arg'
Chris@40 4916 #
Chris@40 4917 # Need a lot of goo to handle *both* DLLs and import libs
Chris@40 4918 # Has to be a shell function in order to 'eat' the argument
Chris@40 4919 # that is supplied when $file_magic_command is called.
Chris@40 4920 # Despite the name, also deal with 64 bit binaries.
Chris@40 4921 func_win32_libid ()
Chris@40 4922 {
Chris@40 4923 $debug_cmd
Chris@40 4924
Chris@40 4925 win32_libid_type=unknown
Chris@40 4926 win32_fileres=`file -L $1 2>/dev/null`
Chris@40 4927 case $win32_fileres in
Chris@40 4928 *ar\ archive\ import\ library*) # definitely import
Chris@40 4929 win32_libid_type="x86 archive import"
Chris@40 4930 ;;
Chris@40 4931 *ar\ archive*) # could be an import, or static
Chris@40 4932 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
Chris@40 4933 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
Chris@40 4934 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
Chris@40 4935 case $nm_interface in
Chris@40 4936 "MS dumpbin")
Chris@40 4937 if func_cygming_ms_implib_p "$1" ||
Chris@40 4938 func_cygming_gnu_implib_p "$1"
Chris@40 4939 then
Chris@40 4940 win32_nmres=import
Chris@40 4941 else
Chris@40 4942 win32_nmres=
Chris@40 4943 fi
Chris@40 4944 ;;
Chris@40 4945 *)
Chris@40 4946 func_to_tool_file "$1" func_convert_file_msys_to_w32
Chris@40 4947 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
Chris@40 4948 $SED -n -e '
Chris@40 4949 1,100{
Chris@40 4950 / I /{
Chris@40 4951 s|.*|import|
Chris@40 4952 p
Chris@40 4953 q
Chris@40 4954 }
Chris@40 4955 }'`
Chris@40 4956 ;;
Chris@40 4957 esac
Chris@40 4958 case $win32_nmres in
Chris@40 4959 import*) win32_libid_type="x86 archive import";;
Chris@40 4960 *) win32_libid_type="x86 archive static";;
Chris@40 4961 esac
Chris@40 4962 fi
Chris@40 4963 ;;
Chris@40 4964 *DLL*)
Chris@40 4965 win32_libid_type="x86 DLL"
Chris@40 4966 ;;
Chris@40 4967 *executable*) # but shell scripts are "executable" too...
Chris@40 4968 case $win32_fileres in
Chris@40 4969 *MS\ Windows\ PE\ Intel*)
Chris@40 4970 win32_libid_type="x86 DLL"
Chris@40 4971 ;;
Chris@40 4972 esac
Chris@40 4973 ;;
Chris@40 4974 esac
Chris@40 4975 $ECHO "$win32_libid_type"
Chris@40 4976 }
Chris@40 4977
Chris@40 4978 # func_cygming_dll_for_implib ARG
Chris@40 4979 #
Chris@40 4980 # Platform-specific function to extract the
Chris@40 4981 # name of the DLL associated with the specified
Chris@40 4982 # import library ARG.
Chris@40 4983 # Invoked by eval'ing the libtool variable
Chris@40 4984 # $sharedlib_from_linklib_cmd
Chris@40 4985 # Result is available in the variable
Chris@40 4986 # $sharedlib_from_linklib_result
Chris@40 4987 func_cygming_dll_for_implib ()
Chris@40 4988 {
Chris@40 4989 $debug_cmd
Chris@40 4990
Chris@40 4991 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
Chris@40 4992 }
Chris@40 4993
Chris@40 4994 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
Chris@40 4995 #
Chris@40 4996 # The is the core of a fallback implementation of a
Chris@40 4997 # platform-specific function to extract the name of the
Chris@40 4998 # DLL associated with the specified import library LIBNAME.
Chris@40 4999 #
Chris@40 5000 # SECTION_NAME is either .idata$6 or .idata$7, depending
Chris@40 5001 # on the platform and compiler that created the implib.
Chris@40 5002 #
Chris@40 5003 # Echos the name of the DLL associated with the
Chris@40 5004 # specified import library.
Chris@40 5005 func_cygming_dll_for_implib_fallback_core ()
Chris@40 5006 {
Chris@40 5007 $debug_cmd
Chris@40 5008
Chris@40 5009 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
Chris@40 5010 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
Chris@40 5011 $SED '/^Contents of section '"$match_literal"':/{
Chris@40 5012 # Place marker at beginning of archive member dllname section
Chris@40 5013 s/.*/====MARK====/
Chris@40 5014 p
Chris@40 5015 d
Chris@40 5016 }
Chris@40 5017 # These lines can sometimes be longer than 43 characters, but
Chris@40 5018 # are always uninteresting
Chris@40 5019 /:[ ]*file format pe[i]\{,1\}-/d
Chris@40 5020 /^In archive [^:]*:/d
Chris@40 5021 # Ensure marker is printed
Chris@40 5022 /^====MARK====/p
Chris@40 5023 # Remove all lines with less than 43 characters
Chris@40 5024 /^.\{43\}/!d
Chris@40 5025 # From remaining lines, remove first 43 characters
Chris@40 5026 s/^.\{43\}//' |
Chris@40 5027 $SED -n '
Chris@40 5028 # Join marker and all lines until next marker into a single line
Chris@40 5029 /^====MARK====/ b para
Chris@40 5030 H
Chris@40 5031 $ b para
Chris@40 5032 b
Chris@40 5033 :para
Chris@40 5034 x
Chris@40 5035 s/\n//g
Chris@40 5036 # Remove the marker
Chris@40 5037 s/^====MARK====//
Chris@40 5038 # Remove trailing dots and whitespace
Chris@40 5039 s/[\. \t]*$//
Chris@40 5040 # Print
Chris@40 5041 /./p' |
Chris@40 5042 # we now have a list, one entry per line, of the stringified
Chris@40 5043 # contents of the appropriate section of all members of the
Chris@40 5044 # archive that possess that section. Heuristic: eliminate
Chris@40 5045 # all those that have a first or second character that is
Chris@40 5046 # a '.' (that is, objdump's representation of an unprintable
Chris@40 5047 # character.) This should work for all archives with less than
Chris@40 5048 # 0x302f exports -- but will fail for DLLs whose name actually
Chris@40 5049 # begins with a literal '.' or a single character followed by
Chris@40 5050 # a '.'.
Chris@40 5051 #
Chris@40 5052 # Of those that remain, print the first one.
Chris@40 5053 $SED -e '/^\./d;/^.\./d;q'
Chris@40 5054 }
Chris@40 5055
Chris@40 5056 # func_cygming_dll_for_implib_fallback ARG
Chris@40 5057 # Platform-specific function to extract the
Chris@40 5058 # name of the DLL associated with the specified
Chris@40 5059 # import library ARG.
Chris@40 5060 #
Chris@40 5061 # This fallback implementation is for use when $DLLTOOL
Chris@40 5062 # does not support the --identify-strict option.
Chris@40 5063 # Invoked by eval'ing the libtool variable
Chris@40 5064 # $sharedlib_from_linklib_cmd
Chris@40 5065 # Result is available in the variable
Chris@40 5066 # $sharedlib_from_linklib_result
Chris@40 5067 func_cygming_dll_for_implib_fallback ()
Chris@40 5068 {
Chris@40 5069 $debug_cmd
Chris@40 5070
Chris@40 5071 if func_cygming_gnu_implib_p "$1"; then
Chris@40 5072 # binutils import library
Chris@40 5073 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
Chris@40 5074 elif func_cygming_ms_implib_p "$1"; then
Chris@40 5075 # ms-generated import library
Chris@40 5076 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
Chris@40 5077 else
Chris@40 5078 # unknown
Chris@40 5079 sharedlib_from_linklib_result=
Chris@40 5080 fi
Chris@40 5081 }
Chris@40 5082
Chris@40 5083
Chris@40 5084 # func_extract_an_archive dir oldlib
Chris@40 5085 func_extract_an_archive ()
Chris@40 5086 {
Chris@40 5087 $debug_cmd
Chris@40 5088
Chris@40 5089 f_ex_an_ar_dir=$1; shift
Chris@40 5090 f_ex_an_ar_oldlib=$1
Chris@40 5091 if test yes = "$lock_old_archive_extraction"; then
Chris@40 5092 lockfile=$f_ex_an_ar_oldlib.lock
Chris@40 5093 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
Chris@40 5094 func_echo "Waiting for $lockfile to be removed"
Chris@40 5095 sleep 2
Chris@40 5096 done
Chris@40 5097 fi
Chris@40 5098 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
Chris@40 5099 'stat=$?; rm -f "$lockfile"; exit $stat'
Chris@40 5100 if test yes = "$lock_old_archive_extraction"; then
Chris@40 5101 $opt_dry_run || rm -f "$lockfile"
Chris@40 5102 fi
Chris@40 5103 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
Chris@40 5104 :
Chris@40 5105 else
Chris@40 5106 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
Chris@40 5107 fi
Chris@40 5108 }
Chris@40 5109
Chris@40 5110
Chris@40 5111 # func_extract_archives gentop oldlib ...
Chris@40 5112 func_extract_archives ()
Chris@40 5113 {
Chris@40 5114 $debug_cmd
Chris@40 5115
Chris@40 5116 my_gentop=$1; shift
Chris@40 5117 my_oldlibs=${1+"$@"}
Chris@40 5118 my_oldobjs=
Chris@40 5119 my_xlib=
Chris@40 5120 my_xabs=
Chris@40 5121 my_xdir=
Chris@40 5122
Chris@40 5123 for my_xlib in $my_oldlibs; do
Chris@40 5124 # Extract the objects.
Chris@40 5125 case $my_xlib in
Chris@40 5126 [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
Chris@40 5127 *) my_xabs=`pwd`"/$my_xlib" ;;
Chris@40 5128 esac
Chris@40 5129 func_basename "$my_xlib"
Chris@40 5130 my_xlib=$func_basename_result
Chris@40 5131 my_xlib_u=$my_xlib
Chris@40 5132 while :; do
Chris@40 5133 case " $extracted_archives " in
Chris@40 5134 *" $my_xlib_u "*)
Chris@40 5135 func_arith $extracted_serial + 1
Chris@40 5136 extracted_serial=$func_arith_result
Chris@40 5137 my_xlib_u=lt$extracted_serial-$my_xlib ;;
Chris@40 5138 *) break ;;
Chris@40 5139 esac
Chris@40 5140 done
Chris@40 5141 extracted_archives="$extracted_archives $my_xlib_u"
Chris@40 5142 my_xdir=$my_gentop/$my_xlib_u
Chris@40 5143
Chris@40 5144 func_mkdir_p "$my_xdir"
Chris@40 5145
Chris@40 5146 case $host in
Chris@40 5147 *-darwin*)
Chris@40 5148 func_verbose "Extracting $my_xabs"
Chris@40 5149 # Do not bother doing anything if just a dry run
Chris@40 5150 $opt_dry_run || {
Chris@40 5151 darwin_orig_dir=`pwd`
Chris@40 5152 cd $my_xdir || exit $?
Chris@40 5153 darwin_archive=$my_xabs
Chris@40 5154 darwin_curdir=`pwd`
Chris@40 5155 func_basename "$darwin_archive"
Chris@40 5156 darwin_base_archive=$func_basename_result
Chris@40 5157 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
Chris@40 5158 if test -n "$darwin_arches"; then
Chris@40 5159 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
Chris@40 5160 darwin_arch=
Chris@40 5161 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
Chris@40 5162 for darwin_arch in $darwin_arches; do
Chris@40 5163 func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
Chris@40 5164 $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
Chris@40 5165 cd "unfat-$$/$darwin_base_archive-$darwin_arch"
Chris@40 5166 func_extract_an_archive "`pwd`" "$darwin_base_archive"
Chris@40 5167 cd "$darwin_curdir"
Chris@40 5168 $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
Chris@40 5169 done # $darwin_arches
Chris@40 5170 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
Chris@40 5171 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
Chris@40 5172 darwin_file=
Chris@40 5173 darwin_files=
Chris@40 5174 for darwin_file in $darwin_filelist; do
Chris@40 5175 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
Chris@40 5176 $LIPO -create -output "$darwin_file" $darwin_files
Chris@40 5177 done # $darwin_filelist
Chris@40 5178 $RM -rf unfat-$$
Chris@40 5179 cd "$darwin_orig_dir"
Chris@40 5180 else
Chris@40 5181 cd $darwin_orig_dir
Chris@40 5182 func_extract_an_archive "$my_xdir" "$my_xabs"
Chris@40 5183 fi # $darwin_arches
Chris@40 5184 } # !$opt_dry_run
Chris@40 5185 ;;
Chris@40 5186 *)
Chris@40 5187 func_extract_an_archive "$my_xdir" "$my_xabs"
Chris@40 5188 ;;
Chris@40 5189 esac
Chris@40 5190 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
Chris@40 5191 done
Chris@40 5192
Chris@40 5193 func_extract_archives_result=$my_oldobjs
Chris@40 5194 }
Chris@40 5195
Chris@40 5196
Chris@40 5197 # func_emit_wrapper [arg=no]
Chris@40 5198 #
Chris@40 5199 # Emit a libtool wrapper script on stdout.
Chris@40 5200 # Don't directly open a file because we may want to
Chris@40 5201 # incorporate the script contents within a cygwin/mingw
Chris@40 5202 # wrapper executable. Must ONLY be called from within
Chris@40 5203 # func_mode_link because it depends on a number of variables
Chris@40 5204 # set therein.
Chris@40 5205 #
Chris@40 5206 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
Chris@40 5207 # variable will take. If 'yes', then the emitted script
Chris@40 5208 # will assume that the directory where it is stored is
Chris@40 5209 # the $objdir directory. This is a cygwin/mingw-specific
Chris@40 5210 # behavior.
Chris@40 5211 func_emit_wrapper ()
Chris@40 5212 {
Chris@40 5213 func_emit_wrapper_arg1=${1-no}
Chris@40 5214
Chris@40 5215 $ECHO "\
Chris@40 5216 #! $SHELL
Chris@40 5217
Chris@40 5218 # $output - temporary wrapper script for $objdir/$outputname
Chris@40 5219 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@40 5220 #
Chris@40 5221 # The $output program cannot be directly executed until all the libtool
Chris@40 5222 # libraries that it depends on are installed.
Chris@40 5223 #
Chris@40 5224 # This wrapper script should never be moved out of the build directory.
Chris@40 5225 # If it is, it will not operate correctly.
Chris@40 5226
Chris@40 5227 # Sed substitution that helps us do robust quoting. It backslashifies
Chris@40 5228 # metacharacters that are still active within double-quoted strings.
Chris@40 5229 sed_quote_subst='$sed_quote_subst'
Chris@40 5230
Chris@40 5231 # Be Bourne compatible
Chris@40 5232 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
Chris@40 5233 emulate sh
Chris@40 5234 NULLCMD=:
Chris@40 5235 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
Chris@40 5236 # is contrary to our usage. Disable this feature.
Chris@40 5237 alias -g '\${1+\"\$@\"}'='\"\$@\"'
Chris@40 5238 setopt NO_GLOB_SUBST
Chris@40 5239 else
Chris@40 5240 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
Chris@40 5241 fi
Chris@40 5242 BIN_SH=xpg4; export BIN_SH # for Tru64
Chris@40 5243 DUALCASE=1; export DUALCASE # for MKS sh
Chris@40 5244
Chris@40 5245 # The HP-UX ksh and POSIX shell print the target directory to stdout
Chris@40 5246 # if CDPATH is set.
Chris@40 5247 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
Chris@40 5248
Chris@40 5249 relink_command=\"$relink_command\"
Chris@40 5250
Chris@40 5251 # This environment variable determines our operation mode.
Chris@40 5252 if test \"\$libtool_install_magic\" = \"$magic\"; then
Chris@40 5253 # install mode needs the following variables:
Chris@40 5254 generated_by_libtool_version='$macro_version'
Chris@40 5255 notinst_deplibs='$notinst_deplibs'
Chris@40 5256 else
Chris@40 5257 # When we are sourced in execute mode, \$file and \$ECHO are already set.
Chris@40 5258 if test \"\$libtool_execute_magic\" != \"$magic\"; then
Chris@40 5259 file=\"\$0\""
Chris@40 5260
Chris@40 5261 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
Chris@40 5262 $ECHO "\
Chris@40 5263
Chris@40 5264 # A function that is used when there is no print builtin or printf.
Chris@40 5265 func_fallback_echo ()
Chris@40 5266 {
Chris@40 5267 eval 'cat <<_LTECHO_EOF
Chris@40 5268 \$1
Chris@40 5269 _LTECHO_EOF'
Chris@40 5270 }
Chris@40 5271 ECHO=\"$qECHO\"
Chris@40 5272 fi
Chris@40 5273
Chris@40 5274 # Very basic option parsing. These options are (a) specific to
Chris@40 5275 # the libtool wrapper, (b) are identical between the wrapper
Chris@40 5276 # /script/ and the wrapper /executable/ that is used only on
Chris@40 5277 # windows platforms, and (c) all begin with the string "--lt-"
Chris@40 5278 # (application programs are unlikely to have options that match
Chris@40 5279 # this pattern).
Chris@40 5280 #
Chris@40 5281 # There are only two supported options: --lt-debug and
Chris@40 5282 # --lt-dump-script. There is, deliberately, no --lt-help.
Chris@40 5283 #
Chris@40 5284 # The first argument to this parsing function should be the
Chris@40 5285 # script's $0 value, followed by "$@".
Chris@40 5286 lt_option_debug=
Chris@40 5287 func_parse_lt_options ()
Chris@40 5288 {
Chris@40 5289 lt_script_arg0=\$0
Chris@40 5290 shift
Chris@40 5291 for lt_opt
Chris@40 5292 do
Chris@40 5293 case \"\$lt_opt\" in
Chris@40 5294 --lt-debug) lt_option_debug=1 ;;
Chris@40 5295 --lt-dump-script)
Chris@40 5296 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
Chris@40 5297 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
Chris@40 5298 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
Chris@40 5299 cat \"\$lt_dump_D/\$lt_dump_F\"
Chris@40 5300 exit 0
Chris@40 5301 ;;
Chris@40 5302 --lt-*)
Chris@40 5303 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
Chris@40 5304 exit 1
Chris@40 5305 ;;
Chris@40 5306 esac
Chris@40 5307 done
Chris@40 5308
Chris@40 5309 # Print the debug banner immediately:
Chris@40 5310 if test -n \"\$lt_option_debug\"; then
Chris@40 5311 echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
Chris@40 5312 fi
Chris@40 5313 }
Chris@40 5314
Chris@40 5315 # Used when --lt-debug. Prints its arguments to stdout
Chris@40 5316 # (redirection is the responsibility of the caller)
Chris@40 5317 func_lt_dump_args ()
Chris@40 5318 {
Chris@40 5319 lt_dump_args_N=1;
Chris@40 5320 for lt_arg
Chris@40 5321 do
Chris@40 5322 \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
Chris@40 5323 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
Chris@40 5324 done
Chris@40 5325 }
Chris@40 5326
Chris@40 5327 # Core function for launching the target application
Chris@40 5328 func_exec_program_core ()
Chris@40 5329 {
Chris@40 5330 "
Chris@40 5331 case $host in
Chris@40 5332 # Backslashes separate directories on plain windows
Chris@40 5333 *-*-mingw | *-*-os2* | *-cegcc*)
Chris@40 5334 $ECHO "\
Chris@40 5335 if test -n \"\$lt_option_debug\"; then
Chris@40 5336 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
Chris@40 5337 func_lt_dump_args \${1+\"\$@\"} 1>&2
Chris@40 5338 fi
Chris@40 5339 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
Chris@40 5340 "
Chris@40 5341 ;;
Chris@40 5342
Chris@40 5343 *)
Chris@40 5344 $ECHO "\
Chris@40 5345 if test -n \"\$lt_option_debug\"; then
Chris@40 5346 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
Chris@40 5347 func_lt_dump_args \${1+\"\$@\"} 1>&2
Chris@40 5348 fi
Chris@40 5349 exec \"\$progdir/\$program\" \${1+\"\$@\"}
Chris@40 5350 "
Chris@40 5351 ;;
Chris@40 5352 esac
Chris@40 5353 $ECHO "\
Chris@40 5354 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
Chris@40 5355 exit 1
Chris@40 5356 }
Chris@40 5357
Chris@40 5358 # A function to encapsulate launching the target application
Chris@40 5359 # Strips options in the --lt-* namespace from \$@ and
Chris@40 5360 # launches target application with the remaining arguments.
Chris@40 5361 func_exec_program ()
Chris@40 5362 {
Chris@40 5363 case \" \$* \" in
Chris@40 5364 *\\ --lt-*)
Chris@40 5365 for lt_wr_arg
Chris@40 5366 do
Chris@40 5367 case \$lt_wr_arg in
Chris@40 5368 --lt-*) ;;
Chris@40 5369 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
Chris@40 5370 esac
Chris@40 5371 shift
Chris@40 5372 done ;;
Chris@40 5373 esac
Chris@40 5374 func_exec_program_core \${1+\"\$@\"}
Chris@40 5375 }
Chris@40 5376
Chris@40 5377 # Parse options
Chris@40 5378 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
Chris@40 5379
Chris@40 5380 # Find the directory that this script lives in.
Chris@40 5381 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
Chris@40 5382 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
Chris@40 5383
Chris@40 5384 # Follow symbolic links until we get to the real thisdir.
Chris@40 5385 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
Chris@40 5386 while test -n \"\$file\"; do
Chris@40 5387 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
Chris@40 5388
Chris@40 5389 # If there was a directory component, then change thisdir.
Chris@40 5390 if test \"x\$destdir\" != \"x\$file\"; then
Chris@40 5391 case \"\$destdir\" in
Chris@40 5392 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
Chris@40 5393 *) thisdir=\"\$thisdir/\$destdir\" ;;
Chris@40 5394 esac
Chris@40 5395 fi
Chris@40 5396
Chris@40 5397 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
Chris@40 5398 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
Chris@40 5399 done
Chris@40 5400
Chris@40 5401 # Usually 'no', except on cygwin/mingw when embedded into
Chris@40 5402 # the cwrapper.
Chris@40 5403 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
Chris@40 5404 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
Chris@40 5405 # special case for '.'
Chris@40 5406 if test \"\$thisdir\" = \".\"; then
Chris@40 5407 thisdir=\`pwd\`
Chris@40 5408 fi
Chris@40 5409 # remove .libs from thisdir
Chris@40 5410 case \"\$thisdir\" in
Chris@40 5411 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
Chris@40 5412 $objdir ) thisdir=. ;;
Chris@40 5413 esac
Chris@40 5414 fi
Chris@40 5415
Chris@40 5416 # Try to get the absolute directory name.
Chris@40 5417 absdir=\`cd \"\$thisdir\" && pwd\`
Chris@40 5418 test -n \"\$absdir\" && thisdir=\"\$absdir\"
Chris@40 5419 "
Chris@40 5420
Chris@40 5421 if test yes = "$fast_install"; then
Chris@40 5422 $ECHO "\
Chris@40 5423 program=lt-'$outputname'$exeext
Chris@40 5424 progdir=\"\$thisdir/$objdir\"
Chris@40 5425
Chris@40 5426 if test ! -f \"\$progdir/\$program\" ||
Chris@40 5427 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
Chris@40 5428 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
Chris@40 5429
Chris@40 5430 file=\"\$\$-\$program\"
Chris@40 5431
Chris@40 5432 if test ! -d \"\$progdir\"; then
Chris@40 5433 $MKDIR \"\$progdir\"
Chris@40 5434 else
Chris@40 5435 $RM \"\$progdir/\$file\"
Chris@40 5436 fi"
Chris@40 5437
Chris@40 5438 $ECHO "\
Chris@40 5439
Chris@40 5440 # relink executable if necessary
Chris@40 5441 if test -n \"\$relink_command\"; then
Chris@40 5442 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
Chris@40 5443 else
Chris@40 5444 \$ECHO \"\$relink_command_output\" >&2
Chris@40 5445 $RM \"\$progdir/\$file\"
Chris@40 5446 exit 1
Chris@40 5447 fi
Chris@40 5448 fi
Chris@40 5449
Chris@40 5450 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
Chris@40 5451 { $RM \"\$progdir/\$program\";
Chris@40 5452 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
Chris@40 5453 $RM \"\$progdir/\$file\"
Chris@40 5454 fi"
Chris@40 5455 else
Chris@40 5456 $ECHO "\
Chris@40 5457 program='$outputname'
Chris@40 5458 progdir=\"\$thisdir/$objdir\"
Chris@40 5459 "
Chris@40 5460 fi
Chris@40 5461
Chris@40 5462 $ECHO "\
Chris@40 5463
Chris@40 5464 if test -f \"\$progdir/\$program\"; then"
Chris@40 5465
Chris@40 5466 # fixup the dll searchpath if we need to.
Chris@40 5467 #
Chris@40 5468 # Fix the DLL searchpath if we need to. Do this before prepending
Chris@40 5469 # to shlibpath, because on Windows, both are PATH and uninstalled
Chris@40 5470 # libraries must come first.
Chris@40 5471 if test -n "$dllsearchpath"; then
Chris@40 5472 $ECHO "\
Chris@40 5473 # Add the dll search path components to the executable PATH
Chris@40 5474 PATH=$dllsearchpath:\$PATH
Chris@40 5475 "
Chris@40 5476 fi
Chris@40 5477
Chris@40 5478 # Export our shlibpath_var if we have one.
Chris@40 5479 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
Chris@40 5480 $ECHO "\
Chris@40 5481 # Add our own library path to $shlibpath_var
Chris@40 5482 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
Chris@40 5483
Chris@40 5484 # Some systems cannot cope with colon-terminated $shlibpath_var
Chris@40 5485 # The second colon is a workaround for a bug in BeOS R4 sed
Chris@40 5486 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
Chris@40 5487
Chris@40 5488 export $shlibpath_var
Chris@40 5489 "
Chris@40 5490 fi
Chris@40 5491
Chris@40 5492 $ECHO "\
Chris@40 5493 if test \"\$libtool_execute_magic\" != \"$magic\"; then
Chris@40 5494 # Run the actual program with our arguments.
Chris@40 5495 func_exec_program \${1+\"\$@\"}
Chris@40 5496 fi
Chris@40 5497 else
Chris@40 5498 # The program doesn't exist.
Chris@40 5499 \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
Chris@40 5500 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
Chris@40 5501 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
Chris@40 5502 exit 1
Chris@40 5503 fi
Chris@40 5504 fi\
Chris@40 5505 "
Chris@40 5506 }
Chris@40 5507
Chris@40 5508
Chris@40 5509 # func_emit_cwrapperexe_src
Chris@40 5510 # emit the source code for a wrapper executable on stdout
Chris@40 5511 # Must ONLY be called from within func_mode_link because
Chris@40 5512 # it depends on a number of variable set therein.
Chris@40 5513 func_emit_cwrapperexe_src ()
Chris@40 5514 {
Chris@40 5515 cat <<EOF
Chris@40 5516
Chris@40 5517 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
Chris@40 5518 Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@40 5519
Chris@40 5520 The $output program cannot be directly executed until all the libtool
Chris@40 5521 libraries that it depends on are installed.
Chris@40 5522
Chris@40 5523 This wrapper executable should never be moved out of the build directory.
Chris@40 5524 If it is, it will not operate correctly.
Chris@40 5525 */
Chris@40 5526 EOF
Chris@40 5527 cat <<"EOF"
Chris@40 5528 #ifdef _MSC_VER
Chris@40 5529 # define _CRT_SECURE_NO_DEPRECATE 1
Chris@40 5530 #endif
Chris@40 5531 #include <stdio.h>
Chris@40 5532 #include <stdlib.h>
Chris@40 5533 #ifdef _MSC_VER
Chris@40 5534 # include <direct.h>
Chris@40 5535 # include <process.h>
Chris@40 5536 # include <io.h>
Chris@40 5537 #else
Chris@40 5538 # include <unistd.h>
Chris@40 5539 # include <stdint.h>
Chris@40 5540 # ifdef __CYGWIN__
Chris@40 5541 # include <io.h>
Chris@40 5542 # endif
Chris@40 5543 #endif
Chris@40 5544 #include <malloc.h>
Chris@40 5545 #include <stdarg.h>
Chris@40 5546 #include <assert.h>
Chris@40 5547 #include <string.h>
Chris@40 5548 #include <ctype.h>
Chris@40 5549 #include <errno.h>
Chris@40 5550 #include <fcntl.h>
Chris@40 5551 #include <sys/stat.h>
Chris@40 5552
Chris@40 5553 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
Chris@40 5554
Chris@40 5555 /* declarations of non-ANSI functions */
Chris@40 5556 #if defined __MINGW32__
Chris@40 5557 # ifdef __STRICT_ANSI__
Chris@40 5558 int _putenv (const char *);
Chris@40 5559 # endif
Chris@40 5560 #elif defined __CYGWIN__
Chris@40 5561 # ifdef __STRICT_ANSI__
Chris@40 5562 char *realpath (const char *, char *);
Chris@40 5563 int putenv (char *);
Chris@40 5564 int setenv (const char *, const char *, int);
Chris@40 5565 # endif
Chris@40 5566 /* #elif defined other_platform || defined ... */
Chris@40 5567 #endif
Chris@40 5568
Chris@40 5569 /* portability defines, excluding path handling macros */
Chris@40 5570 #if defined _MSC_VER
Chris@40 5571 # define setmode _setmode
Chris@40 5572 # define stat _stat
Chris@40 5573 # define chmod _chmod
Chris@40 5574 # define getcwd _getcwd
Chris@40 5575 # define putenv _putenv
Chris@40 5576 # define S_IXUSR _S_IEXEC
Chris@40 5577 #elif defined __MINGW32__
Chris@40 5578 # define setmode _setmode
Chris@40 5579 # define stat _stat
Chris@40 5580 # define chmod _chmod
Chris@40 5581 # define getcwd _getcwd
Chris@40 5582 # define putenv _putenv
Chris@40 5583 #elif defined __CYGWIN__
Chris@40 5584 # define HAVE_SETENV
Chris@40 5585 # define FOPEN_WB "wb"
Chris@40 5586 /* #elif defined other platforms ... */
Chris@40 5587 #endif
Chris@40 5588
Chris@40 5589 #if defined PATH_MAX
Chris@40 5590 # define LT_PATHMAX PATH_MAX
Chris@40 5591 #elif defined MAXPATHLEN
Chris@40 5592 # define LT_PATHMAX MAXPATHLEN
Chris@40 5593 #else
Chris@40 5594 # define LT_PATHMAX 1024
Chris@40 5595 #endif
Chris@40 5596
Chris@40 5597 #ifndef S_IXOTH
Chris@40 5598 # define S_IXOTH 0
Chris@40 5599 #endif
Chris@40 5600 #ifndef S_IXGRP
Chris@40 5601 # define S_IXGRP 0
Chris@40 5602 #endif
Chris@40 5603
Chris@40 5604 /* path handling portability macros */
Chris@40 5605 #ifndef DIR_SEPARATOR
Chris@40 5606 # define DIR_SEPARATOR '/'
Chris@40 5607 # define PATH_SEPARATOR ':'
Chris@40 5608 #endif
Chris@40 5609
Chris@40 5610 #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
Chris@40 5611 defined __OS2__
Chris@40 5612 # define HAVE_DOS_BASED_FILE_SYSTEM
Chris@40 5613 # define FOPEN_WB "wb"
Chris@40 5614 # ifndef DIR_SEPARATOR_2
Chris@40 5615 # define DIR_SEPARATOR_2 '\\'
Chris@40 5616 # endif
Chris@40 5617 # ifndef PATH_SEPARATOR_2
Chris@40 5618 # define PATH_SEPARATOR_2 ';'
Chris@40 5619 # endif
Chris@40 5620 #endif
Chris@40 5621
Chris@40 5622 #ifndef DIR_SEPARATOR_2
Chris@40 5623 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
Chris@40 5624 #else /* DIR_SEPARATOR_2 */
Chris@40 5625 # define IS_DIR_SEPARATOR(ch) \
Chris@40 5626 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
Chris@40 5627 #endif /* DIR_SEPARATOR_2 */
Chris@40 5628
Chris@40 5629 #ifndef PATH_SEPARATOR_2
Chris@40 5630 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
Chris@40 5631 #else /* PATH_SEPARATOR_2 */
Chris@40 5632 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
Chris@40 5633 #endif /* PATH_SEPARATOR_2 */
Chris@40 5634
Chris@40 5635 #ifndef FOPEN_WB
Chris@40 5636 # define FOPEN_WB "w"
Chris@40 5637 #endif
Chris@40 5638 #ifndef _O_BINARY
Chris@40 5639 # define _O_BINARY 0
Chris@40 5640 #endif
Chris@40 5641
Chris@40 5642 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
Chris@40 5643 #define XFREE(stale) do { \
Chris@40 5644 if (stale) { free (stale); stale = 0; } \
Chris@40 5645 } while (0)
Chris@40 5646
Chris@40 5647 #if defined LT_DEBUGWRAPPER
Chris@40 5648 static int lt_debug = 1;
Chris@40 5649 #else
Chris@40 5650 static int lt_debug = 0;
Chris@40 5651 #endif
Chris@40 5652
Chris@40 5653 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
Chris@40 5654
Chris@40 5655 void *xmalloc (size_t num);
Chris@40 5656 char *xstrdup (const char *string);
Chris@40 5657 const char *base_name (const char *name);
Chris@40 5658 char *find_executable (const char *wrapper);
Chris@40 5659 char *chase_symlinks (const char *pathspec);
Chris@40 5660 int make_executable (const char *path);
Chris@40 5661 int check_executable (const char *path);
Chris@40 5662 char *strendzap (char *str, const char *pat);
Chris@40 5663 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
Chris@40 5664 void lt_fatal (const char *file, int line, const char *message, ...);
Chris@40 5665 static const char *nonnull (const char *s);
Chris@40 5666 static const char *nonempty (const char *s);
Chris@40 5667 void lt_setenv (const char *name, const char *value);
Chris@40 5668 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
Chris@40 5669 void lt_update_exe_path (const char *name, const char *value);
Chris@40 5670 void lt_update_lib_path (const char *name, const char *value);
Chris@40 5671 char **prepare_spawn (char **argv);
Chris@40 5672 void lt_dump_script (FILE *f);
Chris@40 5673 EOF
Chris@40 5674
Chris@40 5675 cat <<EOF
Chris@40 5676 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
Chris@40 5677 # define externally_visible volatile
Chris@40 5678 #else
Chris@40 5679 # define externally_visible __attribute__((externally_visible)) volatile
Chris@40 5680 #endif
Chris@40 5681 externally_visible const char * MAGIC_EXE = "$magic_exe";
Chris@40 5682 const char * LIB_PATH_VARNAME = "$shlibpath_var";
Chris@40 5683 EOF
Chris@40 5684
Chris@40 5685 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
Chris@40 5686 func_to_host_path "$temp_rpath"
Chris@40 5687 cat <<EOF
Chris@40 5688 const char * LIB_PATH_VALUE = "$func_to_host_path_result";
Chris@40 5689 EOF
Chris@40 5690 else
Chris@40 5691 cat <<"EOF"
Chris@40 5692 const char * LIB_PATH_VALUE = "";
Chris@40 5693 EOF
Chris@40 5694 fi
Chris@40 5695
Chris@40 5696 if test -n "$dllsearchpath"; then
Chris@40 5697 func_to_host_path "$dllsearchpath:"
Chris@40 5698 cat <<EOF
Chris@40 5699 const char * EXE_PATH_VARNAME = "PATH";
Chris@40 5700 const char * EXE_PATH_VALUE = "$func_to_host_path_result";
Chris@40 5701 EOF
Chris@40 5702 else
Chris@40 5703 cat <<"EOF"
Chris@40 5704 const char * EXE_PATH_VARNAME = "";
Chris@40 5705 const char * EXE_PATH_VALUE = "";
Chris@40 5706 EOF
Chris@40 5707 fi
Chris@40 5708
Chris@40 5709 if test yes = "$fast_install"; then
Chris@40 5710 cat <<EOF
Chris@40 5711 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
Chris@40 5712 EOF
Chris@40 5713 else
Chris@40 5714 cat <<EOF
Chris@40 5715 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
Chris@40 5716 EOF
Chris@40 5717 fi
Chris@40 5718
Chris@40 5719
Chris@40 5720 cat <<"EOF"
Chris@40 5721
Chris@40 5722 #define LTWRAPPER_OPTION_PREFIX "--lt-"
Chris@40 5723
Chris@40 5724 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
Chris@40 5725 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
Chris@40 5726 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
Chris@40 5727
Chris@40 5728 int
Chris@40 5729 main (int argc, char *argv[])
Chris@40 5730 {
Chris@40 5731 char **newargz;
Chris@40 5732 int newargc;
Chris@40 5733 char *tmp_pathspec;
Chris@40 5734 char *actual_cwrapper_path;
Chris@40 5735 char *actual_cwrapper_name;
Chris@40 5736 char *target_name;
Chris@40 5737 char *lt_argv_zero;
Chris@40 5738 int rval = 127;
Chris@40 5739
Chris@40 5740 int i;
Chris@40 5741
Chris@40 5742 program_name = (char *) xstrdup (base_name (argv[0]));
Chris@40 5743 newargz = XMALLOC (char *, (size_t) argc + 1);
Chris@40 5744
Chris@40 5745 /* very simple arg parsing; don't want to rely on getopt
Chris@40 5746 * also, copy all non cwrapper options to newargz, except
Chris@40 5747 * argz[0], which is handled differently
Chris@40 5748 */
Chris@40 5749 newargc=0;
Chris@40 5750 for (i = 1; i < argc; i++)
Chris@40 5751 {
Chris@40 5752 if (STREQ (argv[i], dumpscript_opt))
Chris@40 5753 {
Chris@40 5754 EOF
Chris@40 5755 case $host in
Chris@40 5756 *mingw* | *cygwin* )
Chris@40 5757 # make stdout use "unix" line endings
Chris@40 5758 echo " setmode(1,_O_BINARY);"
Chris@40 5759 ;;
Chris@40 5760 esac
Chris@40 5761
Chris@40 5762 cat <<"EOF"
Chris@40 5763 lt_dump_script (stdout);
Chris@40 5764 return 0;
Chris@40 5765 }
Chris@40 5766 if (STREQ (argv[i], debug_opt))
Chris@40 5767 {
Chris@40 5768 lt_debug = 1;
Chris@40 5769 continue;
Chris@40 5770 }
Chris@40 5771 if (STREQ (argv[i], ltwrapper_option_prefix))
Chris@40 5772 {
Chris@40 5773 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
Chris@40 5774 namespace, but it is not one of the ones we know about and
Chris@40 5775 have already dealt with, above (inluding dump-script), then
Chris@40 5776 report an error. Otherwise, targets might begin to believe
Chris@40 5777 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
Chris@40 5778 namespace. The first time any user complains about this, we'll
Chris@40 5779 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
Chris@40 5780 or a configure.ac-settable value.
Chris@40 5781 */
Chris@40 5782 lt_fatal (__FILE__, __LINE__,
Chris@40 5783 "unrecognized %s option: '%s'",
Chris@40 5784 ltwrapper_option_prefix, argv[i]);
Chris@40 5785 }
Chris@40 5786 /* otherwise ... */
Chris@40 5787 newargz[++newargc] = xstrdup (argv[i]);
Chris@40 5788 }
Chris@40 5789 newargz[++newargc] = NULL;
Chris@40 5790
Chris@40 5791 EOF
Chris@40 5792 cat <<EOF
Chris@40 5793 /* The GNU banner must be the first non-error debug message */
Chris@40 5794 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
Chris@40 5795 EOF
Chris@40 5796 cat <<"EOF"
Chris@40 5797 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
Chris@40 5798 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
Chris@40 5799
Chris@40 5800 tmp_pathspec = find_executable (argv[0]);
Chris@40 5801 if (tmp_pathspec == NULL)
Chris@40 5802 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
Chris@40 5803 lt_debugprintf (__FILE__, __LINE__,
Chris@40 5804 "(main) found exe (before symlink chase) at: %s\n",
Chris@40 5805 tmp_pathspec);
Chris@40 5806
Chris@40 5807 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
Chris@40 5808 lt_debugprintf (__FILE__, __LINE__,
Chris@40 5809 "(main) found exe (after symlink chase) at: %s\n",
Chris@40 5810 actual_cwrapper_path);
Chris@40 5811 XFREE (tmp_pathspec);
Chris@40 5812
Chris@40 5813 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
Chris@40 5814 strendzap (actual_cwrapper_path, actual_cwrapper_name);
Chris@40 5815
Chris@40 5816 /* wrapper name transforms */
Chris@40 5817 strendzap (actual_cwrapper_name, ".exe");
Chris@40 5818 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
Chris@40 5819 XFREE (actual_cwrapper_name);
Chris@40 5820 actual_cwrapper_name = tmp_pathspec;
Chris@40 5821 tmp_pathspec = 0;
Chris@40 5822
Chris@40 5823 /* target_name transforms -- use actual target program name; might have lt- prefix */
Chris@40 5824 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
Chris@40 5825 strendzap (target_name, ".exe");
Chris@40 5826 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
Chris@40 5827 XFREE (target_name);
Chris@40 5828 target_name = tmp_pathspec;
Chris@40 5829 tmp_pathspec = 0;
Chris@40 5830
Chris@40 5831 lt_debugprintf (__FILE__, __LINE__,
Chris@40 5832 "(main) libtool target name: %s\n",
Chris@40 5833 target_name);
Chris@40 5834 EOF
Chris@40 5835
Chris@40 5836 cat <<EOF
Chris@40 5837 newargz[0] =
Chris@40 5838 XMALLOC (char, (strlen (actual_cwrapper_path) +
Chris@40 5839 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
Chris@40 5840 strcpy (newargz[0], actual_cwrapper_path);
Chris@40 5841 strcat (newargz[0], "$objdir");
Chris@40 5842 strcat (newargz[0], "/");
Chris@40 5843 EOF
Chris@40 5844
Chris@40 5845 cat <<"EOF"
Chris@40 5846 /* stop here, and copy so we don't have to do this twice */
Chris@40 5847 tmp_pathspec = xstrdup (newargz[0]);
Chris@40 5848
Chris@40 5849 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
Chris@40 5850 strcat (newargz[0], actual_cwrapper_name);
Chris@40 5851
Chris@40 5852 /* DO want the lt- prefix here if it exists, so use target_name */
Chris@40 5853 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
Chris@40 5854 XFREE (tmp_pathspec);
Chris@40 5855 tmp_pathspec = NULL;
Chris@40 5856 EOF
Chris@40 5857
Chris@40 5858 case $host_os in
Chris@40 5859 mingw*)
Chris@40 5860 cat <<"EOF"
Chris@40 5861 {
Chris@40 5862 char* p;
Chris@40 5863 while ((p = strchr (newargz[0], '\\')) != NULL)
Chris@40 5864 {
Chris@40 5865 *p = '/';
Chris@40 5866 }
Chris@40 5867 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
Chris@40 5868 {
Chris@40 5869 *p = '/';
Chris@40 5870 }
Chris@40 5871 }
Chris@40 5872 EOF
Chris@40 5873 ;;
Chris@40 5874 esac
Chris@40 5875
Chris@40 5876 cat <<"EOF"
Chris@40 5877 XFREE (target_name);
Chris@40 5878 XFREE (actual_cwrapper_path);
Chris@40 5879 XFREE (actual_cwrapper_name);
Chris@40 5880
Chris@40 5881 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
Chris@40 5882 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
Chris@40 5883 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
Chris@40 5884 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
Chris@40 5885 because on Windows, both *_VARNAMEs are PATH but uninstalled
Chris@40 5886 libraries must come first. */
Chris@40 5887 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
Chris@40 5888 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
Chris@40 5889
Chris@40 5890 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
Chris@40 5891 nonnull (lt_argv_zero));
Chris@40 5892 for (i = 0; i < newargc; i++)
Chris@40 5893 {
Chris@40 5894 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
Chris@40 5895 i, nonnull (newargz[i]));
Chris@40 5896 }
Chris@40 5897
Chris@40 5898 EOF
Chris@40 5899
Chris@40 5900 case $host_os in
Chris@40 5901 mingw*)
Chris@40 5902 cat <<"EOF"
Chris@40 5903 /* execv doesn't actually work on mingw as expected on unix */
Chris@40 5904 newargz = prepare_spawn (newargz);
Chris@40 5905 rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
Chris@40 5906 if (rval == -1)
Chris@40 5907 {
Chris@40 5908 /* failed to start process */
Chris@40 5909 lt_debugprintf (__FILE__, __LINE__,
Chris@40 5910 "(main) failed to launch target \"%s\": %s\n",
Chris@40 5911 lt_argv_zero, nonnull (strerror (errno)));
Chris@40 5912 return 127;
Chris@40 5913 }
Chris@40 5914 return rval;
Chris@40 5915 EOF
Chris@40 5916 ;;
Chris@40 5917 *)
Chris@40 5918 cat <<"EOF"
Chris@40 5919 execv (lt_argv_zero, newargz);
Chris@40 5920 return rval; /* =127, but avoids unused variable warning */
Chris@40 5921 EOF
Chris@40 5922 ;;
Chris@40 5923 esac
Chris@40 5924
Chris@40 5925 cat <<"EOF"
Chris@40 5926 }
Chris@40 5927
Chris@40 5928 void *
Chris@40 5929 xmalloc (size_t num)
Chris@40 5930 {
Chris@40 5931 void *p = (void *) malloc (num);
Chris@40 5932 if (!p)
Chris@40 5933 lt_fatal (__FILE__, __LINE__, "memory exhausted");
Chris@40 5934
Chris@40 5935 return p;
Chris@40 5936 }
Chris@40 5937
Chris@40 5938 char *
Chris@40 5939 xstrdup (const char *string)
Chris@40 5940 {
Chris@40 5941 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
Chris@40 5942 string) : NULL;
Chris@40 5943 }
Chris@40 5944
Chris@40 5945 const char *
Chris@40 5946 base_name (const char *name)
Chris@40 5947 {
Chris@40 5948 const char *base;
Chris@40 5949
Chris@40 5950 #if defined HAVE_DOS_BASED_FILE_SYSTEM
Chris@40 5951 /* Skip over the disk name in MSDOS pathnames. */
Chris@40 5952 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
Chris@40 5953 name += 2;
Chris@40 5954 #endif
Chris@40 5955
Chris@40 5956 for (base = name; *name; name++)
Chris@40 5957 if (IS_DIR_SEPARATOR (*name))
Chris@40 5958 base = name + 1;
Chris@40 5959 return base;
Chris@40 5960 }
Chris@40 5961
Chris@40 5962 int
Chris@40 5963 check_executable (const char *path)
Chris@40 5964 {
Chris@40 5965 struct stat st;
Chris@40 5966
Chris@40 5967 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
Chris@40 5968 nonempty (path));
Chris@40 5969 if ((!path) || (!*path))
Chris@40 5970 return 0;
Chris@40 5971
Chris@40 5972 if ((stat (path, &st) >= 0)
Chris@40 5973 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
Chris@40 5974 return 1;
Chris@40 5975 else
Chris@40 5976 return 0;
Chris@40 5977 }
Chris@40 5978
Chris@40 5979 int
Chris@40 5980 make_executable (const char *path)
Chris@40 5981 {
Chris@40 5982 int rval = 0;
Chris@40 5983 struct stat st;
Chris@40 5984
Chris@40 5985 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
Chris@40 5986 nonempty (path));
Chris@40 5987 if ((!path) || (!*path))
Chris@40 5988 return 0;
Chris@40 5989
Chris@40 5990 if (stat (path, &st) >= 0)
Chris@40 5991 {
Chris@40 5992 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
Chris@40 5993 }
Chris@40 5994 return rval;
Chris@40 5995 }
Chris@40 5996
Chris@40 5997 /* Searches for the full path of the wrapper. Returns
Chris@40 5998 newly allocated full path name if found, NULL otherwise
Chris@40 5999 Does not chase symlinks, even on platforms that support them.
Chris@40 6000 */
Chris@40 6001 char *
Chris@40 6002 find_executable (const char *wrapper)
Chris@40 6003 {
Chris@40 6004 int has_slash = 0;
Chris@40 6005 const char *p;
Chris@40 6006 const char *p_next;
Chris@40 6007 /* static buffer for getcwd */
Chris@40 6008 char tmp[LT_PATHMAX + 1];
Chris@40 6009 size_t tmp_len;
Chris@40 6010 char *concat_name;
Chris@40 6011
Chris@40 6012 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
Chris@40 6013 nonempty (wrapper));
Chris@40 6014
Chris@40 6015 if ((wrapper == NULL) || (*wrapper == '\0'))
Chris@40 6016 return NULL;
Chris@40 6017
Chris@40 6018 /* Absolute path? */
Chris@40 6019 #if defined HAVE_DOS_BASED_FILE_SYSTEM
Chris@40 6020 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
Chris@40 6021 {
Chris@40 6022 concat_name = xstrdup (wrapper);
Chris@40 6023 if (check_executable (concat_name))
Chris@40 6024 return concat_name;
Chris@40 6025 XFREE (concat_name);
Chris@40 6026 }
Chris@40 6027 else
Chris@40 6028 {
Chris@40 6029 #endif
Chris@40 6030 if (IS_DIR_SEPARATOR (wrapper[0]))
Chris@40 6031 {
Chris@40 6032 concat_name = xstrdup (wrapper);
Chris@40 6033 if (check_executable (concat_name))
Chris@40 6034 return concat_name;
Chris@40 6035 XFREE (concat_name);
Chris@40 6036 }
Chris@40 6037 #if defined HAVE_DOS_BASED_FILE_SYSTEM
Chris@40 6038 }
Chris@40 6039 #endif
Chris@40 6040
Chris@40 6041 for (p = wrapper; *p; p++)
Chris@40 6042 if (*p == '/')
Chris@40 6043 {
Chris@40 6044 has_slash = 1;
Chris@40 6045 break;
Chris@40 6046 }
Chris@40 6047 if (!has_slash)
Chris@40 6048 {
Chris@40 6049 /* no slashes; search PATH */
Chris@40 6050 const char *path = getenv ("PATH");
Chris@40 6051 if (path != NULL)
Chris@40 6052 {
Chris@40 6053 for (p = path; *p; p = p_next)
Chris@40 6054 {
Chris@40 6055 const char *q;
Chris@40 6056 size_t p_len;
Chris@40 6057 for (q = p; *q; q++)
Chris@40 6058 if (IS_PATH_SEPARATOR (*q))
Chris@40 6059 break;
Chris@40 6060 p_len = (size_t) (q - p);
Chris@40 6061 p_next = (*q == '\0' ? q : q + 1);
Chris@40 6062 if (p_len == 0)
Chris@40 6063 {
Chris@40 6064 /* empty path: current directory */
Chris@40 6065 if (getcwd (tmp, LT_PATHMAX) == NULL)
Chris@40 6066 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
Chris@40 6067 nonnull (strerror (errno)));
Chris@40 6068 tmp_len = strlen (tmp);
Chris@40 6069 concat_name =
Chris@40 6070 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
Chris@40 6071 memcpy (concat_name, tmp, tmp_len);
Chris@40 6072 concat_name[tmp_len] = '/';
Chris@40 6073 strcpy (concat_name + tmp_len + 1, wrapper);
Chris@40 6074 }
Chris@40 6075 else
Chris@40 6076 {
Chris@40 6077 concat_name =
Chris@40 6078 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
Chris@40 6079 memcpy (concat_name, p, p_len);
Chris@40 6080 concat_name[p_len] = '/';
Chris@40 6081 strcpy (concat_name + p_len + 1, wrapper);
Chris@40 6082 }
Chris@40 6083 if (check_executable (concat_name))
Chris@40 6084 return concat_name;
Chris@40 6085 XFREE (concat_name);
Chris@40 6086 }
Chris@40 6087 }
Chris@40 6088 /* not found in PATH; assume curdir */
Chris@40 6089 }
Chris@40 6090 /* Relative path | not found in path: prepend cwd */
Chris@40 6091 if (getcwd (tmp, LT_PATHMAX) == NULL)
Chris@40 6092 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
Chris@40 6093 nonnull (strerror (errno)));
Chris@40 6094 tmp_len = strlen (tmp);
Chris@40 6095 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
Chris@40 6096 memcpy (concat_name, tmp, tmp_len);
Chris@40 6097 concat_name[tmp_len] = '/';
Chris@40 6098 strcpy (concat_name + tmp_len + 1, wrapper);
Chris@40 6099
Chris@40 6100 if (check_executable (concat_name))
Chris@40 6101 return concat_name;
Chris@40 6102 XFREE (concat_name);
Chris@40 6103 return NULL;
Chris@40 6104 }
Chris@40 6105
Chris@40 6106 char *
Chris@40 6107 chase_symlinks (const char *pathspec)
Chris@40 6108 {
Chris@40 6109 #ifndef S_ISLNK
Chris@40 6110 return xstrdup (pathspec);
Chris@40 6111 #else
Chris@40 6112 char buf[LT_PATHMAX];
Chris@40 6113 struct stat s;
Chris@40 6114 char *tmp_pathspec = xstrdup (pathspec);
Chris@40 6115 char *p;
Chris@40 6116 int has_symlinks = 0;
Chris@40 6117 while (strlen (tmp_pathspec) && !has_symlinks)
Chris@40 6118 {
Chris@40 6119 lt_debugprintf (__FILE__, __LINE__,
Chris@40 6120 "checking path component for symlinks: %s\n",
Chris@40 6121 tmp_pathspec);
Chris@40 6122 if (lstat (tmp_pathspec, &s) == 0)
Chris@40 6123 {
Chris@40 6124 if (S_ISLNK (s.st_mode) != 0)
Chris@40 6125 {
Chris@40 6126 has_symlinks = 1;
Chris@40 6127 break;
Chris@40 6128 }
Chris@40 6129
Chris@40 6130 /* search backwards for last DIR_SEPARATOR */
Chris@40 6131 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
Chris@40 6132 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
Chris@40 6133 p--;
Chris@40 6134 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
Chris@40 6135 {
Chris@40 6136 /* no more DIR_SEPARATORS left */
Chris@40 6137 break;
Chris@40 6138 }
Chris@40 6139 *p = '\0';
Chris@40 6140 }
Chris@40 6141 else
Chris@40 6142 {
Chris@40 6143 lt_fatal (__FILE__, __LINE__,
Chris@40 6144 "error accessing file \"%s\": %s",
Chris@40 6145 tmp_pathspec, nonnull (strerror (errno)));
Chris@40 6146 }
Chris@40 6147 }
Chris@40 6148 XFREE (tmp_pathspec);
Chris@40 6149
Chris@40 6150 if (!has_symlinks)
Chris@40 6151 {
Chris@40 6152 return xstrdup (pathspec);
Chris@40 6153 }
Chris@40 6154
Chris@40 6155 tmp_pathspec = realpath (pathspec, buf);
Chris@40 6156 if (tmp_pathspec == 0)
Chris@40 6157 {
Chris@40 6158 lt_fatal (__FILE__, __LINE__,
Chris@40 6159 "could not follow symlinks for %s", pathspec);
Chris@40 6160 }
Chris@40 6161 return xstrdup (tmp_pathspec);
Chris@40 6162 #endif
Chris@40 6163 }
Chris@40 6164
Chris@40 6165 char *
Chris@40 6166 strendzap (char *str, const char *pat)
Chris@40 6167 {
Chris@40 6168 size_t len, patlen;
Chris@40 6169
Chris@40 6170 assert (str != NULL);
Chris@40 6171 assert (pat != NULL);
Chris@40 6172
Chris@40 6173 len = strlen (str);
Chris@40 6174 patlen = strlen (pat);
Chris@40 6175
Chris@40 6176 if (patlen <= len)
Chris@40 6177 {
Chris@40 6178 str += len - patlen;
Chris@40 6179 if (STREQ (str, pat))
Chris@40 6180 *str = '\0';
Chris@40 6181 }
Chris@40 6182 return str;
Chris@40 6183 }
Chris@40 6184
Chris@40 6185 void
Chris@40 6186 lt_debugprintf (const char *file, int line, const char *fmt, ...)
Chris@40 6187 {
Chris@40 6188 va_list args;
Chris@40 6189 if (lt_debug)
Chris@40 6190 {
Chris@40 6191 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
Chris@40 6192 va_start (args, fmt);
Chris@40 6193 (void) vfprintf (stderr, fmt, args);
Chris@40 6194 va_end (args);
Chris@40 6195 }
Chris@40 6196 }
Chris@40 6197
Chris@40 6198 static void
Chris@40 6199 lt_error_core (int exit_status, const char *file,
Chris@40 6200 int line, const char *mode,
Chris@40 6201 const char *message, va_list ap)
Chris@40 6202 {
Chris@40 6203 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
Chris@40 6204 vfprintf (stderr, message, ap);
Chris@40 6205 fprintf (stderr, ".\n");
Chris@40 6206
Chris@40 6207 if (exit_status >= 0)
Chris@40 6208 exit (exit_status);
Chris@40 6209 }
Chris@40 6210
Chris@40 6211 void
Chris@40 6212 lt_fatal (const char *file, int line, const char *message, ...)
Chris@40 6213 {
Chris@40 6214 va_list ap;
Chris@40 6215 va_start (ap, message);
Chris@40 6216 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
Chris@40 6217 va_end (ap);
Chris@40 6218 }
Chris@40 6219
Chris@40 6220 static const char *
Chris@40 6221 nonnull (const char *s)
Chris@40 6222 {
Chris@40 6223 return s ? s : "(null)";
Chris@40 6224 }
Chris@40 6225
Chris@40 6226 static const char *
Chris@40 6227 nonempty (const char *s)
Chris@40 6228 {
Chris@40 6229 return (s && !*s) ? "(empty)" : nonnull (s);
Chris@40 6230 }
Chris@40 6231
Chris@40 6232 void
Chris@40 6233 lt_setenv (const char *name, const char *value)
Chris@40 6234 {
Chris@40 6235 lt_debugprintf (__FILE__, __LINE__,
Chris@40 6236 "(lt_setenv) setting '%s' to '%s'\n",
Chris@40 6237 nonnull (name), nonnull (value));
Chris@40 6238 {
Chris@40 6239 #ifdef HAVE_SETENV
Chris@40 6240 /* always make a copy, for consistency with !HAVE_SETENV */
Chris@40 6241 char *str = xstrdup (value);
Chris@40 6242 setenv (name, str, 1);
Chris@40 6243 #else
Chris@40 6244 size_t len = strlen (name) + 1 + strlen (value) + 1;
Chris@40 6245 char *str = XMALLOC (char, len);
Chris@40 6246 sprintf (str, "%s=%s", name, value);
Chris@40 6247 if (putenv (str) != EXIT_SUCCESS)
Chris@40 6248 {
Chris@40 6249 XFREE (str);
Chris@40 6250 }
Chris@40 6251 #endif
Chris@40 6252 }
Chris@40 6253 }
Chris@40 6254
Chris@40 6255 char *
Chris@40 6256 lt_extend_str (const char *orig_value, const char *add, int to_end)
Chris@40 6257 {
Chris@40 6258 char *new_value;
Chris@40 6259 if (orig_value && *orig_value)
Chris@40 6260 {
Chris@40 6261 size_t orig_value_len = strlen (orig_value);
Chris@40 6262 size_t add_len = strlen (add);
Chris@40 6263 new_value = XMALLOC (char, add_len + orig_value_len + 1);
Chris@40 6264 if (to_end)
Chris@40 6265 {
Chris@40 6266 strcpy (new_value, orig_value);
Chris@40 6267 strcpy (new_value + orig_value_len, add);
Chris@40 6268 }
Chris@40 6269 else
Chris@40 6270 {
Chris@40 6271 strcpy (new_value, add);
Chris@40 6272 strcpy (new_value + add_len, orig_value);
Chris@40 6273 }
Chris@40 6274 }
Chris@40 6275 else
Chris@40 6276 {
Chris@40 6277 new_value = xstrdup (add);
Chris@40 6278 }
Chris@40 6279 return new_value;
Chris@40 6280 }
Chris@40 6281
Chris@40 6282 void
Chris@40 6283 lt_update_exe_path (const char *name, const char *value)
Chris@40 6284 {
Chris@40 6285 lt_debugprintf (__FILE__, __LINE__,
Chris@40 6286 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
Chris@40 6287 nonnull (name), nonnull (value));
Chris@40 6288
Chris@40 6289 if (name && *name && value && *value)
Chris@40 6290 {
Chris@40 6291 char *new_value = lt_extend_str (getenv (name), value, 0);
Chris@40 6292 /* some systems can't cope with a ':'-terminated path #' */
Chris@40 6293 size_t len = strlen (new_value);
Chris@40 6294 while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
Chris@40 6295 {
Chris@40 6296 new_value[--len] = '\0';
Chris@40 6297 }
Chris@40 6298 lt_setenv (name, new_value);
Chris@40 6299 XFREE (new_value);
Chris@40 6300 }
Chris@40 6301 }
Chris@40 6302
Chris@40 6303 void
Chris@40 6304 lt_update_lib_path (const char *name, const char *value)
Chris@40 6305 {
Chris@40 6306 lt_debugprintf (__FILE__, __LINE__,
Chris@40 6307 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
Chris@40 6308 nonnull (name), nonnull (value));
Chris@40 6309
Chris@40 6310 if (name && *name && value && *value)
Chris@40 6311 {
Chris@40 6312 char *new_value = lt_extend_str (getenv (name), value, 0);
Chris@40 6313 lt_setenv (name, new_value);
Chris@40 6314 XFREE (new_value);
Chris@40 6315 }
Chris@40 6316 }
Chris@40 6317
Chris@40 6318 EOF
Chris@40 6319 case $host_os in
Chris@40 6320 mingw*)
Chris@40 6321 cat <<"EOF"
Chris@40 6322
Chris@40 6323 /* Prepares an argument vector before calling spawn().
Chris@40 6324 Note that spawn() does not by itself call the command interpreter
Chris@40 6325 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
Chris@40 6326 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
Chris@40 6327 GetVersionEx(&v);
Chris@40 6328 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
Chris@40 6329 }) ? "cmd.exe" : "command.com").
Chris@40 6330 Instead it simply concatenates the arguments, separated by ' ', and calls
Chris@40 6331 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
Chris@40 6332 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
Chris@40 6333 special way:
Chris@40 6334 - Space and tab are interpreted as delimiters. They are not treated as
Chris@40 6335 delimiters if they are surrounded by double quotes: "...".
Chris@40 6336 - Unescaped double quotes are removed from the input. Their only effect is
Chris@40 6337 that within double quotes, space and tab are treated like normal
Chris@40 6338 characters.
Chris@40 6339 - Backslashes not followed by double quotes are not special.
Chris@40 6340 - But 2*n+1 backslashes followed by a double quote become
Chris@40 6341 n backslashes followed by a double quote (n >= 0):
Chris@40 6342 \" -> "
Chris@40 6343 \\\" -> \"
Chris@40 6344 \\\\\" -> \\"
Chris@40 6345 */
Chris@40 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@40 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@40 6348 char **
Chris@40 6349 prepare_spawn (char **argv)
Chris@40 6350 {
Chris@40 6351 size_t argc;
Chris@40 6352 char **new_argv;
Chris@40 6353 size_t i;
Chris@40 6354
Chris@40 6355 /* Count number of arguments. */
Chris@40 6356 for (argc = 0; argv[argc] != NULL; argc++)
Chris@40 6357 ;
Chris@40 6358
Chris@40 6359 /* Allocate new argument vector. */
Chris@40 6360 new_argv = XMALLOC (char *, argc + 1);
Chris@40 6361
Chris@40 6362 /* Put quoted arguments into the new argument vector. */
Chris@40 6363 for (i = 0; i < argc; i++)
Chris@40 6364 {
Chris@40 6365 const char *string = argv[i];
Chris@40 6366
Chris@40 6367 if (string[0] == '\0')
Chris@40 6368 new_argv[i] = xstrdup ("\"\"");
Chris@40 6369 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
Chris@40 6370 {
Chris@40 6371 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
Chris@40 6372 size_t length;
Chris@40 6373 unsigned int backslashes;
Chris@40 6374 const char *s;
Chris@40 6375 char *quoted_string;
Chris@40 6376 char *p;
Chris@40 6377
Chris@40 6378 length = 0;
Chris@40 6379 backslashes = 0;
Chris@40 6380 if (quote_around)
Chris@40 6381 length++;
Chris@40 6382 for (s = string; *s != '\0'; s++)
Chris@40 6383 {
Chris@40 6384 char c = *s;
Chris@40 6385 if (c == '"')
Chris@40 6386 length += backslashes + 1;
Chris@40 6387 length++;
Chris@40 6388 if (c == '\\')
Chris@40 6389 backslashes++;
Chris@40 6390 else
Chris@40 6391 backslashes = 0;
Chris@40 6392 }
Chris@40 6393 if (quote_around)
Chris@40 6394 length += backslashes + 1;
Chris@40 6395
Chris@40 6396 quoted_string = XMALLOC (char, length + 1);
Chris@40 6397
Chris@40 6398 p = quoted_string;
Chris@40 6399 backslashes = 0;
Chris@40 6400 if (quote_around)
Chris@40 6401 *p++ = '"';
Chris@40 6402 for (s = string; *s != '\0'; s++)
Chris@40 6403 {
Chris@40 6404 char c = *s;
Chris@40 6405 if (c == '"')
Chris@40 6406 {
Chris@40 6407 unsigned int j;
Chris@40 6408 for (j = backslashes + 1; j > 0; j--)
Chris@40 6409 *p++ = '\\';
Chris@40 6410 }
Chris@40 6411 *p++ = c;
Chris@40 6412 if (c == '\\')
Chris@40 6413 backslashes++;
Chris@40 6414 else
Chris@40 6415 backslashes = 0;
Chris@40 6416 }
Chris@40 6417 if (quote_around)
Chris@40 6418 {
Chris@40 6419 unsigned int j;
Chris@40 6420 for (j = backslashes; j > 0; j--)
Chris@40 6421 *p++ = '\\';
Chris@40 6422 *p++ = '"';
Chris@40 6423 }
Chris@40 6424 *p = '\0';
Chris@40 6425
Chris@40 6426 new_argv[i] = quoted_string;
Chris@40 6427 }
Chris@40 6428 else
Chris@40 6429 new_argv[i] = (char *) string;
Chris@40 6430 }
Chris@40 6431 new_argv[argc] = NULL;
Chris@40 6432
Chris@40 6433 return new_argv;
Chris@40 6434 }
Chris@40 6435 EOF
Chris@40 6436 ;;
Chris@40 6437 esac
Chris@40 6438
Chris@40 6439 cat <<"EOF"
Chris@40 6440 void lt_dump_script (FILE* f)
Chris@40 6441 {
Chris@40 6442 EOF
Chris@40 6443 func_emit_wrapper yes |
Chris@40 6444 $SED -n -e '
Chris@40 6445 s/^\(.\{79\}\)\(..*\)/\1\
Chris@40 6446 \2/
Chris@40 6447 h
Chris@40 6448 s/\([\\"]\)/\\\1/g
Chris@40 6449 s/$/\\n/
Chris@40 6450 s/\([^\n]*\).*/ fputs ("\1", f);/p
Chris@40 6451 g
Chris@40 6452 D'
Chris@40 6453 cat <<"EOF"
Chris@40 6454 }
Chris@40 6455 EOF
Chris@40 6456 }
Chris@40 6457 # end: func_emit_cwrapperexe_src
Chris@40 6458
Chris@40 6459 # func_win32_import_lib_p ARG
Chris@40 6460 # True if ARG is an import lib, as indicated by $file_magic_cmd
Chris@40 6461 func_win32_import_lib_p ()
Chris@40 6462 {
Chris@40 6463 $debug_cmd
Chris@40 6464
Chris@40 6465 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
Chris@40 6466 *import*) : ;;
Chris@40 6467 *) false ;;
Chris@40 6468 esac
Chris@40 6469 }
Chris@40 6470
Chris@40 6471 # func_suncc_cstd_abi
Chris@40 6472 # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
Chris@40 6473 # Several compiler flags select an ABI that is incompatible with the
Chris@40 6474 # Cstd library. Avoid specifying it if any are in CXXFLAGS.
Chris@40 6475 func_suncc_cstd_abi ()
Chris@40 6476 {
Chris@40 6477 $debug_cmd
Chris@40 6478
Chris@40 6479 case " $compile_command " in
Chris@40 6480 *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
Chris@40 6481 suncc_use_cstd_abi=no
Chris@40 6482 ;;
Chris@40 6483 *)
Chris@40 6484 suncc_use_cstd_abi=yes
Chris@40 6485 ;;
Chris@40 6486 esac
Chris@40 6487 }
Chris@40 6488
Chris@40 6489 # func_mode_link arg...
Chris@40 6490 func_mode_link ()
Chris@40 6491 {
Chris@40 6492 $debug_cmd
Chris@40 6493
Chris@40 6494 case $host in
Chris@40 6495 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
Chris@40 6496 # It is impossible to link a dll without this setting, and
Chris@40 6497 # we shouldn't force the makefile maintainer to figure out
Chris@40 6498 # what system we are compiling for in order to pass an extra
Chris@40 6499 # flag for every libtool invocation.
Chris@40 6500 # allow_undefined=no
Chris@40 6501
Chris@40 6502 # FIXME: Unfortunately, there are problems with the above when trying
Chris@40 6503 # to make a dll that has undefined symbols, in which case not
Chris@40 6504 # even a static library is built. For now, we need to specify
Chris@40 6505 # -no-undefined on the libtool link line when we can be certain
Chris@40 6506 # that all symbols are satisfied, otherwise we get a static library.
Chris@40 6507 allow_undefined=yes
Chris@40 6508 ;;
Chris@40 6509 *)
Chris@40 6510 allow_undefined=yes
Chris@40 6511 ;;
Chris@40 6512 esac
Chris@40 6513 libtool_args=$nonopt
Chris@40 6514 base_compile="$nonopt $@"
Chris@40 6515 compile_command=$nonopt
Chris@40 6516 finalize_command=$nonopt
Chris@40 6517
Chris@40 6518 compile_rpath=
Chris@40 6519 finalize_rpath=
Chris@40 6520 compile_shlibpath=
Chris@40 6521 finalize_shlibpath=
Chris@40 6522 convenience=
Chris@40 6523 old_convenience=
Chris@40 6524 deplibs=
Chris@40 6525 old_deplibs=
Chris@40 6526 compiler_flags=
Chris@40 6527 linker_flags=
Chris@40 6528 dllsearchpath=
Chris@40 6529 lib_search_path=`pwd`
Chris@40 6530 inst_prefix_dir=
Chris@40 6531 new_inherited_linker_flags=
Chris@40 6532
Chris@40 6533 avoid_version=no
Chris@40 6534 bindir=
Chris@40 6535 dlfiles=
Chris@40 6536 dlprefiles=
Chris@40 6537 dlself=no
Chris@40 6538 export_dynamic=no
Chris@40 6539 export_symbols=
Chris@40 6540 export_symbols_regex=
Chris@40 6541 generated=
Chris@40 6542 libobjs=
Chris@40 6543 ltlibs=
Chris@40 6544 module=no
Chris@40 6545 no_install=no
Chris@40 6546 objs=
Chris@40 6547 os2dllname=
Chris@40 6548 non_pic_objects=
Chris@40 6549 precious_files_regex=
Chris@40 6550 prefer_static_libs=no
Chris@40 6551 preload=false
Chris@40 6552 prev=
Chris@40 6553 prevarg=
Chris@40 6554 release=
Chris@40 6555 rpath=
Chris@40 6556 xrpath=
Chris@40 6557 perm_rpath=
Chris@40 6558 temp_rpath=
Chris@40 6559 thread_safe=no
Chris@40 6560 vinfo=
Chris@40 6561 vinfo_number=no
Chris@40 6562 weak_libs=
Chris@40 6563 single_module=$wl-single_module
Chris@40 6564 func_infer_tag $base_compile
Chris@40 6565
Chris@40 6566 # We need to know -static, to get the right output filenames.
Chris@40 6567 for arg
Chris@40 6568 do
Chris@40 6569 case $arg in
Chris@40 6570 -shared)
Chris@40 6571 test yes != "$build_libtool_libs" \
Chris@40 6572 && func_fatal_configuration "cannot build a shared library"
Chris@40 6573 build_old_libs=no
Chris@40 6574 break
Chris@40 6575 ;;
Chris@40 6576 -all-static | -static | -static-libtool-libs)
Chris@40 6577 case $arg in
Chris@40 6578 -all-static)
Chris@40 6579 if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
Chris@40 6580 func_warning "complete static linking is impossible in this configuration"
Chris@40 6581 fi
Chris@40 6582 if test -n "$link_static_flag"; then
Chris@40 6583 dlopen_self=$dlopen_self_static
Chris@40 6584 fi
Chris@40 6585 prefer_static_libs=yes
Chris@40 6586 ;;
Chris@40 6587 -static)
Chris@40 6588 if test -z "$pic_flag" && test -n "$link_static_flag"; then
Chris@40 6589 dlopen_self=$dlopen_self_static
Chris@40 6590 fi
Chris@40 6591 prefer_static_libs=built
Chris@40 6592 ;;
Chris@40 6593 -static-libtool-libs)
Chris@40 6594 if test -z "$pic_flag" && test -n "$link_static_flag"; then
Chris@40 6595 dlopen_self=$dlopen_self_static
Chris@40 6596 fi
Chris@40 6597 prefer_static_libs=yes
Chris@40 6598 ;;
Chris@40 6599 esac
Chris@40 6600 build_libtool_libs=no
Chris@40 6601 build_old_libs=yes
Chris@40 6602 break
Chris@40 6603 ;;
Chris@40 6604 esac
Chris@40 6605 done
Chris@40 6606
Chris@40 6607 # See if our shared archives depend on static archives.
Chris@40 6608 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
Chris@40 6609
Chris@40 6610 # Go through the arguments, transforming them on the way.
Chris@40 6611 while test "$#" -gt 0; do
Chris@40 6612 arg=$1
Chris@40 6613 shift
Chris@40 6614 func_quote_for_eval "$arg"
Chris@40 6615 qarg=$func_quote_for_eval_unquoted_result
Chris@40 6616 func_append libtool_args " $func_quote_for_eval_result"
Chris@40 6617
Chris@40 6618 # If the previous option needs an argument, assign it.
Chris@40 6619 if test -n "$prev"; then
Chris@40 6620 case $prev in
Chris@40 6621 output)
Chris@40 6622 func_append compile_command " @OUTPUT@"
Chris@40 6623 func_append finalize_command " @OUTPUT@"
Chris@40 6624 ;;
Chris@40 6625 esac
Chris@40 6626
Chris@40 6627 case $prev in
Chris@40 6628 bindir)
Chris@40 6629 bindir=$arg
Chris@40 6630 prev=
Chris@40 6631 continue
Chris@40 6632 ;;
Chris@40 6633 dlfiles|dlprefiles)
Chris@40 6634 $preload || {
Chris@40 6635 # Add the symbol object into the linking commands.
Chris@40 6636 func_append compile_command " @SYMFILE@"
Chris@40 6637 func_append finalize_command " @SYMFILE@"
Chris@40 6638 preload=:
Chris@40 6639 }
Chris@40 6640 case $arg in
Chris@40 6641 *.la | *.lo) ;; # We handle these cases below.
Chris@40 6642 force)
Chris@40 6643 if test no = "$dlself"; then
Chris@40 6644 dlself=needless
Chris@40 6645 export_dynamic=yes
Chris@40 6646 fi
Chris@40 6647 prev=
Chris@40 6648 continue
Chris@40 6649 ;;
Chris@40 6650 self)
Chris@40 6651 if test dlprefiles = "$prev"; then
Chris@40 6652 dlself=yes
Chris@40 6653 elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
Chris@40 6654 dlself=yes
Chris@40 6655 else
Chris@40 6656 dlself=needless
Chris@40 6657 export_dynamic=yes
Chris@40 6658 fi
Chris@40 6659 prev=
Chris@40 6660 continue
Chris@40 6661 ;;
Chris@40 6662 *)
Chris@40 6663 if test dlfiles = "$prev"; then
Chris@40 6664 func_append dlfiles " $arg"
Chris@40 6665 else
Chris@40 6666 func_append dlprefiles " $arg"
Chris@40 6667 fi
Chris@40 6668 prev=
Chris@40 6669 continue
Chris@40 6670 ;;
Chris@40 6671 esac
Chris@40 6672 ;;
Chris@40 6673 expsyms)
Chris@40 6674 export_symbols=$arg
Chris@40 6675 test -f "$arg" \
Chris@40 6676 || func_fatal_error "symbol file '$arg' does not exist"
Chris@40 6677 prev=
Chris@40 6678 continue
Chris@40 6679 ;;
Chris@40 6680 expsyms_regex)
Chris@40 6681 export_symbols_regex=$arg
Chris@40 6682 prev=
Chris@40 6683 continue
Chris@40 6684 ;;
Chris@40 6685 framework)
Chris@40 6686 case $host in
Chris@40 6687 *-*-darwin*)
Chris@40 6688 case "$deplibs " in
Chris@40 6689 *" $qarg.ltframework "*) ;;
Chris@40 6690 *) func_append deplibs " $qarg.ltframework" # this is fixed later
Chris@40 6691 ;;
Chris@40 6692 esac
Chris@40 6693 ;;
Chris@40 6694 esac
Chris@40 6695 prev=
Chris@40 6696 continue
Chris@40 6697 ;;
Chris@40 6698 inst_prefix)
Chris@40 6699 inst_prefix_dir=$arg
Chris@40 6700 prev=
Chris@40 6701 continue
Chris@40 6702 ;;
Chris@40 6703 mllvm)
Chris@40 6704 # Clang does not use LLVM to link, so we can simply discard any
Chris@40 6705 # '-mllvm $arg' options when doing the link step.
Chris@40 6706 prev=
Chris@40 6707 continue
Chris@40 6708 ;;
Chris@40 6709 objectlist)
Chris@40 6710 if test -f "$arg"; then
Chris@40 6711 save_arg=$arg
Chris@40 6712 moreargs=
Chris@40 6713 for fil in `cat "$save_arg"`
Chris@40 6714 do
Chris@40 6715 # func_append moreargs " $fil"
Chris@40 6716 arg=$fil
Chris@40 6717 # A libtool-controlled object.
Chris@40 6718
Chris@40 6719 # Check to see that this really is a libtool object.
Chris@40 6720 if func_lalib_unsafe_p "$arg"; then
Chris@40 6721 pic_object=
Chris@40 6722 non_pic_object=
Chris@40 6723
Chris@40 6724 # Read the .lo file
Chris@40 6725 func_source "$arg"
Chris@40 6726
Chris@40 6727 if test -z "$pic_object" ||
Chris@40 6728 test -z "$non_pic_object" ||
Chris@40 6729 test none = "$pic_object" &&
Chris@40 6730 test none = "$non_pic_object"; then
Chris@40 6731 func_fatal_error "cannot find name of object for '$arg'"
Chris@40 6732 fi
Chris@40 6733
Chris@40 6734 # Extract subdirectory from the argument.
Chris@40 6735 func_dirname "$arg" "/" ""
Chris@40 6736 xdir=$func_dirname_result
Chris@40 6737
Chris@40 6738 if test none != "$pic_object"; then
Chris@40 6739 # Prepend the subdirectory the object is found in.
Chris@40 6740 pic_object=$xdir$pic_object
Chris@40 6741
Chris@40 6742 if test dlfiles = "$prev"; then
Chris@40 6743 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
Chris@40 6744 func_append dlfiles " $pic_object"
Chris@40 6745 prev=
Chris@40 6746 continue
Chris@40 6747 else
Chris@40 6748 # If libtool objects are unsupported, then we need to preload.
Chris@40 6749 prev=dlprefiles
Chris@40 6750 fi
Chris@40 6751 fi
Chris@40 6752
Chris@40 6753 # CHECK ME: I think I busted this. -Ossama
Chris@40 6754 if test dlprefiles = "$prev"; then
Chris@40 6755 # Preload the old-style object.
Chris@40 6756 func_append dlprefiles " $pic_object"
Chris@40 6757 prev=
Chris@40 6758 fi
Chris@40 6759
Chris@40 6760 # A PIC object.
Chris@40 6761 func_append libobjs " $pic_object"
Chris@40 6762 arg=$pic_object
Chris@40 6763 fi
Chris@40 6764
Chris@40 6765 # Non-PIC object.
Chris@40 6766 if test none != "$non_pic_object"; then
Chris@40 6767 # Prepend the subdirectory the object is found in.
Chris@40 6768 non_pic_object=$xdir$non_pic_object
Chris@40 6769
Chris@40 6770 # A standard non-PIC object
Chris@40 6771 func_append non_pic_objects " $non_pic_object"
Chris@40 6772 if test -z "$pic_object" || test none = "$pic_object"; then
Chris@40 6773 arg=$non_pic_object
Chris@40 6774 fi
Chris@40 6775 else
Chris@40 6776 # If the PIC object exists, use it instead.
Chris@40 6777 # $xdir was prepended to $pic_object above.
Chris@40 6778 non_pic_object=$pic_object
Chris@40 6779 func_append non_pic_objects " $non_pic_object"
Chris@40 6780 fi
Chris@40 6781 else
Chris@40 6782 # Only an error if not doing a dry-run.
Chris@40 6783 if $opt_dry_run; then
Chris@40 6784 # Extract subdirectory from the argument.
Chris@40 6785 func_dirname "$arg" "/" ""
Chris@40 6786 xdir=$func_dirname_result
Chris@40 6787
Chris@40 6788 func_lo2o "$arg"
Chris@40 6789 pic_object=$xdir$objdir/$func_lo2o_result
Chris@40 6790 non_pic_object=$xdir$func_lo2o_result
Chris@40 6791 func_append libobjs " $pic_object"
Chris@40 6792 func_append non_pic_objects " $non_pic_object"
Chris@40 6793 else
Chris@40 6794 func_fatal_error "'$arg' is not a valid libtool object"
Chris@40 6795 fi
Chris@40 6796 fi
Chris@40 6797 done
Chris@40 6798 else
Chris@40 6799 func_fatal_error "link input file '$arg' does not exist"
Chris@40 6800 fi
Chris@40 6801 arg=$save_arg
Chris@40 6802 prev=
Chris@40 6803 continue
Chris@40 6804 ;;
Chris@40 6805 os2dllname)
Chris@40 6806 os2dllname=$arg
Chris@40 6807 prev=
Chris@40 6808 continue
Chris@40 6809 ;;
Chris@40 6810 precious_regex)
Chris@40 6811 precious_files_regex=$arg
Chris@40 6812 prev=
Chris@40 6813 continue
Chris@40 6814 ;;
Chris@40 6815 release)
Chris@40 6816 release=-$arg
Chris@40 6817 prev=
Chris@40 6818 continue
Chris@40 6819 ;;
Chris@40 6820 rpath | xrpath)
Chris@40 6821 # We need an absolute path.
Chris@40 6822 case $arg in
Chris@40 6823 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@40 6824 *)
Chris@40 6825 func_fatal_error "only absolute run-paths are allowed"
Chris@40 6826 ;;
Chris@40 6827 esac
Chris@40 6828 if test rpath = "$prev"; then
Chris@40 6829 case "$rpath " in
Chris@40 6830 *" $arg "*) ;;
Chris@40 6831 *) func_append rpath " $arg" ;;
Chris@40 6832 esac
Chris@40 6833 else
Chris@40 6834 case "$xrpath " in
Chris@40 6835 *" $arg "*) ;;
Chris@40 6836 *) func_append xrpath " $arg" ;;
Chris@40 6837 esac
Chris@40 6838 fi
Chris@40 6839 prev=
Chris@40 6840 continue
Chris@40 6841 ;;
Chris@40 6842 shrext)
Chris@40 6843 shrext_cmds=$arg
Chris@40 6844 prev=
Chris@40 6845 continue
Chris@40 6846 ;;
Chris@40 6847 weak)
Chris@40 6848 func_append weak_libs " $arg"
Chris@40 6849 prev=
Chris@40 6850 continue
Chris@40 6851 ;;
Chris@40 6852 xcclinker)
Chris@40 6853 func_append linker_flags " $qarg"
Chris@40 6854 func_append compiler_flags " $qarg"
Chris@40 6855 prev=
Chris@40 6856 func_append compile_command " $qarg"
Chris@40 6857 func_append finalize_command " $qarg"
Chris@40 6858 continue
Chris@40 6859 ;;
Chris@40 6860 xcompiler)
Chris@40 6861 func_append compiler_flags " $qarg"
Chris@40 6862 prev=
Chris@40 6863 func_append compile_command " $qarg"
Chris@40 6864 func_append finalize_command " $qarg"
Chris@40 6865 continue
Chris@40 6866 ;;
Chris@40 6867 xlinker)
Chris@40 6868 func_append linker_flags " $qarg"
Chris@40 6869 func_append compiler_flags " $wl$qarg"
Chris@40 6870 prev=
Chris@40 6871 func_append compile_command " $wl$qarg"
Chris@40 6872 func_append finalize_command " $wl$qarg"
Chris@40 6873 continue
Chris@40 6874 ;;
Chris@40 6875 *)
Chris@40 6876 eval "$prev=\"\$arg\""
Chris@40 6877 prev=
Chris@40 6878 continue
Chris@40 6879 ;;
Chris@40 6880 esac
Chris@40 6881 fi # test -n "$prev"
Chris@40 6882
Chris@40 6883 prevarg=$arg
Chris@40 6884
Chris@40 6885 case $arg in
Chris@40 6886 -all-static)
Chris@40 6887 if test -n "$link_static_flag"; then
Chris@40 6888 # See comment for -static flag below, for more details.
Chris@40 6889 func_append compile_command " $link_static_flag"
Chris@40 6890 func_append finalize_command " $link_static_flag"
Chris@40 6891 fi
Chris@40 6892 continue
Chris@40 6893 ;;
Chris@40 6894
Chris@40 6895 -allow-undefined)
Chris@40 6896 # FIXME: remove this flag sometime in the future.
Chris@40 6897 func_fatal_error "'-allow-undefined' must not be used because it is the default"
Chris@40 6898 ;;
Chris@40 6899
Chris@40 6900 -avoid-version)
Chris@40 6901 avoid_version=yes
Chris@40 6902 continue
Chris@40 6903 ;;
Chris@40 6904
Chris@40 6905 -bindir)
Chris@40 6906 prev=bindir
Chris@40 6907 continue
Chris@40 6908 ;;
Chris@40 6909
Chris@40 6910 -dlopen)
Chris@40 6911 prev=dlfiles
Chris@40 6912 continue
Chris@40 6913 ;;
Chris@40 6914
Chris@40 6915 -dlpreopen)
Chris@40 6916 prev=dlprefiles
Chris@40 6917 continue
Chris@40 6918 ;;
Chris@40 6919
Chris@40 6920 -export-dynamic)
Chris@40 6921 export_dynamic=yes
Chris@40 6922 continue
Chris@40 6923 ;;
Chris@40 6924
Chris@40 6925 -export-symbols | -export-symbols-regex)
Chris@40 6926 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
Chris@40 6927 func_fatal_error "more than one -exported-symbols argument is not allowed"
Chris@40 6928 fi
Chris@40 6929 if test X-export-symbols = "X$arg"; then
Chris@40 6930 prev=expsyms
Chris@40 6931 else
Chris@40 6932 prev=expsyms_regex
Chris@40 6933 fi
Chris@40 6934 continue
Chris@40 6935 ;;
Chris@40 6936
Chris@40 6937 -framework)
Chris@40 6938 prev=framework
Chris@40 6939 continue
Chris@40 6940 ;;
Chris@40 6941
Chris@40 6942 -inst-prefix-dir)
Chris@40 6943 prev=inst_prefix
Chris@40 6944 continue
Chris@40 6945 ;;
Chris@40 6946
Chris@40 6947 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
Chris@40 6948 # so, if we see these flags be careful not to treat them like -L
Chris@40 6949 -L[A-Z][A-Z]*:*)
Chris@40 6950 case $with_gcc/$host in
Chris@40 6951 no/*-*-irix* | /*-*-irix*)
Chris@40 6952 func_append compile_command " $arg"
Chris@40 6953 func_append finalize_command " $arg"
Chris@40 6954 ;;
Chris@40 6955 esac
Chris@40 6956 continue
Chris@40 6957 ;;
Chris@40 6958
Chris@40 6959 -L*)
Chris@40 6960 func_stripname "-L" '' "$arg"
Chris@40 6961 if test -z "$func_stripname_result"; then
Chris@40 6962 if test "$#" -gt 0; then
Chris@40 6963 func_fatal_error "require no space between '-L' and '$1'"
Chris@40 6964 else
Chris@40 6965 func_fatal_error "need path for '-L' option"
Chris@40 6966 fi
Chris@40 6967 fi
Chris@40 6968 func_resolve_sysroot "$func_stripname_result"
Chris@40 6969 dir=$func_resolve_sysroot_result
Chris@40 6970 # We need an absolute path.
Chris@40 6971 case $dir in
Chris@40 6972 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@40 6973 *)
Chris@40 6974 absdir=`cd "$dir" && pwd`
Chris@40 6975 test -z "$absdir" && \
Chris@40 6976 func_fatal_error "cannot determine absolute directory name of '$dir'"
Chris@40 6977 dir=$absdir
Chris@40 6978 ;;
Chris@40 6979 esac
Chris@40 6980 case "$deplibs " in
Chris@40 6981 *" -L$dir "* | *" $arg "*)
Chris@40 6982 # Will only happen for absolute or sysroot arguments
Chris@40 6983 ;;
Chris@40 6984 *)
Chris@40 6985 # Preserve sysroot, but never include relative directories
Chris@40 6986 case $dir in
Chris@40 6987 [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
Chris@40 6988 *) func_append deplibs " -L$dir" ;;
Chris@40 6989 esac
Chris@40 6990 func_append lib_search_path " $dir"
Chris@40 6991 ;;
Chris@40 6992 esac
Chris@40 6993 case $host in
Chris@40 6994 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
Chris@40 6995 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
Chris@40 6996 case :$dllsearchpath: in
Chris@40 6997 *":$dir:"*) ;;
Chris@40 6998 ::) dllsearchpath=$dir;;
Chris@40 6999 *) func_append dllsearchpath ":$dir";;
Chris@40 7000 esac
Chris@40 7001 case :$dllsearchpath: in
Chris@40 7002 *":$testbindir:"*) ;;
Chris@40 7003 ::) dllsearchpath=$testbindir;;
Chris@40 7004 *) func_append dllsearchpath ":$testbindir";;
Chris@40 7005 esac
Chris@40 7006 ;;
Chris@40 7007 esac
Chris@40 7008 continue
Chris@40 7009 ;;
Chris@40 7010
Chris@40 7011 -l*)
Chris@40 7012 if test X-lc = "X$arg" || test X-lm = "X$arg"; then
Chris@40 7013 case $host in
Chris@40 7014 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
Chris@40 7015 # These systems don't actually have a C or math library (as such)
Chris@40 7016 continue
Chris@40 7017 ;;
Chris@40 7018 *-*-os2*)
Chris@40 7019 # These systems don't actually have a C library (as such)
Chris@40 7020 test X-lc = "X$arg" && continue
Chris@40 7021 ;;
Chris@40 7022 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
Chris@40 7023 # Do not include libc due to us having libc/libc_r.
Chris@40 7024 test X-lc = "X$arg" && continue
Chris@40 7025 ;;
Chris@40 7026 *-*-rhapsody* | *-*-darwin1.[012])
Chris@40 7027 # Rhapsody C and math libraries are in the System framework
Chris@40 7028 func_append deplibs " System.ltframework"
Chris@40 7029 continue
Chris@40 7030 ;;
Chris@40 7031 *-*-sco3.2v5* | *-*-sco5v6*)
Chris@40 7032 # Causes problems with __ctype
Chris@40 7033 test X-lc = "X$arg" && continue
Chris@40 7034 ;;
Chris@40 7035 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
Chris@40 7036 # Compiler inserts libc in the correct place for threads to work
Chris@40 7037 test X-lc = "X$arg" && continue
Chris@40 7038 ;;
Chris@40 7039 esac
Chris@40 7040 elif test X-lc_r = "X$arg"; then
Chris@40 7041 case $host in
Chris@40 7042 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
Chris@40 7043 # Do not include libc_r directly, use -pthread flag.
Chris@40 7044 continue
Chris@40 7045 ;;
Chris@40 7046 esac
Chris@40 7047 fi
Chris@40 7048 func_append deplibs " $arg"
Chris@40 7049 continue
Chris@40 7050 ;;
Chris@40 7051
Chris@40 7052 -mllvm)
Chris@40 7053 prev=mllvm
Chris@40 7054 continue
Chris@40 7055 ;;
Chris@40 7056
Chris@40 7057 -module)
Chris@40 7058 module=yes
Chris@40 7059 continue
Chris@40 7060 ;;
Chris@40 7061
Chris@40 7062 # Tru64 UNIX uses -model [arg] to determine the layout of C++
Chris@40 7063 # classes, name mangling, and exception handling.
Chris@40 7064 # Darwin uses the -arch flag to determine output architecture.
Chris@40 7065 -model|-arch|-isysroot|--sysroot)
Chris@40 7066 func_append compiler_flags " $arg"
Chris@40 7067 func_append compile_command " $arg"
Chris@40 7068 func_append finalize_command " $arg"
Chris@40 7069 prev=xcompiler
Chris@40 7070 continue
Chris@40 7071 ;;
Chris@40 7072
Chris@40 7073 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
Chris@40 7074 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
Chris@40 7075 func_append compiler_flags " $arg"
Chris@40 7076 func_append compile_command " $arg"
Chris@40 7077 func_append finalize_command " $arg"
Chris@40 7078 case "$new_inherited_linker_flags " in
Chris@40 7079 *" $arg "*) ;;
Chris@40 7080 * ) func_append new_inherited_linker_flags " $arg" ;;
Chris@40 7081 esac
Chris@40 7082 continue
Chris@40 7083 ;;
Chris@40 7084
Chris@40 7085 -multi_module)
Chris@40 7086 single_module=$wl-multi_module
Chris@40 7087 continue
Chris@40 7088 ;;
Chris@40 7089
Chris@40 7090 -no-fast-install)
Chris@40 7091 fast_install=no
Chris@40 7092 continue
Chris@40 7093 ;;
Chris@40 7094
Chris@40 7095 -no-install)
Chris@40 7096 case $host in
Chris@40 7097 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
Chris@40 7098 # The PATH hackery in wrapper scripts is required on Windows
Chris@40 7099 # and Darwin in order for the loader to find any dlls it needs.
Chris@40 7100 func_warning "'-no-install' is ignored for $host"
Chris@40 7101 func_warning "assuming '-no-fast-install' instead"
Chris@40 7102 fast_install=no
Chris@40 7103 ;;
Chris@40 7104 *) no_install=yes ;;
Chris@40 7105 esac
Chris@40 7106 continue
Chris@40 7107 ;;
Chris@40 7108
Chris@40 7109 -no-undefined)
Chris@40 7110 allow_undefined=no
Chris@40 7111 continue
Chris@40 7112 ;;
Chris@40 7113
Chris@40 7114 -objectlist)
Chris@40 7115 prev=objectlist
Chris@40 7116 continue
Chris@40 7117 ;;
Chris@40 7118
Chris@40 7119 -os2dllname)
Chris@40 7120 prev=os2dllname
Chris@40 7121 continue
Chris@40 7122 ;;
Chris@40 7123
Chris@40 7124 -o) prev=output ;;
Chris@40 7125
Chris@40 7126 -precious-files-regex)
Chris@40 7127 prev=precious_regex
Chris@40 7128 continue
Chris@40 7129 ;;
Chris@40 7130
Chris@40 7131 -release)
Chris@40 7132 prev=release
Chris@40 7133 continue
Chris@40 7134 ;;
Chris@40 7135
Chris@40 7136 -rpath)
Chris@40 7137 prev=rpath
Chris@40 7138 continue
Chris@40 7139 ;;
Chris@40 7140
Chris@40 7141 -R)
Chris@40 7142 prev=xrpath
Chris@40 7143 continue
Chris@40 7144 ;;
Chris@40 7145
Chris@40 7146 -R*)
Chris@40 7147 func_stripname '-R' '' "$arg"
Chris@40 7148 dir=$func_stripname_result
Chris@40 7149 # We need an absolute path.
Chris@40 7150 case $dir in
Chris@40 7151 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@40 7152 =*)
Chris@40 7153 func_stripname '=' '' "$dir"
Chris@40 7154 dir=$lt_sysroot$func_stripname_result
Chris@40 7155 ;;
Chris@40 7156 *)
Chris@40 7157 func_fatal_error "only absolute run-paths are allowed"
Chris@40 7158 ;;
Chris@40 7159 esac
Chris@40 7160 case "$xrpath " in
Chris@40 7161 *" $dir "*) ;;
Chris@40 7162 *) func_append xrpath " $dir" ;;
Chris@40 7163 esac
Chris@40 7164 continue
Chris@40 7165 ;;
Chris@40 7166
Chris@40 7167 -shared)
Chris@40 7168 # The effects of -shared are defined in a previous loop.
Chris@40 7169 continue
Chris@40 7170 ;;
Chris@40 7171
Chris@40 7172 -shrext)
Chris@40 7173 prev=shrext
Chris@40 7174 continue
Chris@40 7175 ;;
Chris@40 7176
Chris@40 7177 -static | -static-libtool-libs)
Chris@40 7178 # The effects of -static are defined in a previous loop.
Chris@40 7179 # We used to do the same as -all-static on platforms that
Chris@40 7180 # didn't have a PIC flag, but the assumption that the effects
Chris@40 7181 # would be equivalent was wrong. It would break on at least
Chris@40 7182 # Digital Unix and AIX.
Chris@40 7183 continue
Chris@40 7184 ;;
Chris@40 7185
Chris@40 7186 -thread-safe)
Chris@40 7187 thread_safe=yes
Chris@40 7188 continue
Chris@40 7189 ;;
Chris@40 7190
Chris@40 7191 -version-info)
Chris@40 7192 prev=vinfo
Chris@40 7193 continue
Chris@40 7194 ;;
Chris@40 7195
Chris@40 7196 -version-number)
Chris@40 7197 prev=vinfo
Chris@40 7198 vinfo_number=yes
Chris@40 7199 continue
Chris@40 7200 ;;
Chris@40 7201
Chris@40 7202 -weak)
Chris@40 7203 prev=weak
Chris@40 7204 continue
Chris@40 7205 ;;
Chris@40 7206
Chris@40 7207 -Wc,*)
Chris@40 7208 func_stripname '-Wc,' '' "$arg"
Chris@40 7209 args=$func_stripname_result
Chris@40 7210 arg=
Chris@40 7211 save_ifs=$IFS; IFS=,
Chris@40 7212 for flag in $args; do
Chris@40 7213 IFS=$save_ifs
Chris@40 7214 func_quote_for_eval "$flag"
Chris@40 7215 func_append arg " $func_quote_for_eval_result"
Chris@40 7216 func_append compiler_flags " $func_quote_for_eval_result"
Chris@40 7217 done
Chris@40 7218 IFS=$save_ifs
Chris@40 7219 func_stripname ' ' '' "$arg"
Chris@40 7220 arg=$func_stripname_result
Chris@40 7221 ;;
Chris@40 7222
Chris@40 7223 -Wl,*)
Chris@40 7224 func_stripname '-Wl,' '' "$arg"
Chris@40 7225 args=$func_stripname_result
Chris@40 7226 arg=
Chris@40 7227 save_ifs=$IFS; IFS=,
Chris@40 7228 for flag in $args; do
Chris@40 7229 IFS=$save_ifs
Chris@40 7230 func_quote_for_eval "$flag"
Chris@40 7231 func_append arg " $wl$func_quote_for_eval_result"
Chris@40 7232 func_append compiler_flags " $wl$func_quote_for_eval_result"
Chris@40 7233 func_append linker_flags " $func_quote_for_eval_result"
Chris@40 7234 done
Chris@40 7235 IFS=$save_ifs
Chris@40 7236 func_stripname ' ' '' "$arg"
Chris@40 7237 arg=$func_stripname_result
Chris@40 7238 ;;
Chris@40 7239
Chris@40 7240 -Xcompiler)
Chris@40 7241 prev=xcompiler
Chris@40 7242 continue
Chris@40 7243 ;;
Chris@40 7244
Chris@40 7245 -Xlinker)
Chris@40 7246 prev=xlinker
Chris@40 7247 continue
Chris@40 7248 ;;
Chris@40 7249
Chris@40 7250 -XCClinker)
Chris@40 7251 prev=xcclinker
Chris@40 7252 continue
Chris@40 7253 ;;
Chris@40 7254
Chris@40 7255 # -msg_* for osf cc
Chris@40 7256 -msg_*)
Chris@40 7257 func_quote_for_eval "$arg"
Chris@40 7258 arg=$func_quote_for_eval_result
Chris@40 7259 ;;
Chris@40 7260
Chris@40 7261 # Flags to be passed through unchanged, with rationale:
Chris@40 7262 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
Chris@40 7263 # -r[0-9][0-9]* specify processor for the SGI compiler
Chris@40 7264 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
Chris@40 7265 # +DA*, +DD* enable 64-bit mode for the HP compiler
Chris@40 7266 # -q* compiler args for the IBM compiler
Chris@40 7267 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
Chris@40 7268 # -F/path path to uninstalled frameworks, gcc on darwin
Chris@40 7269 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
Chris@40 7270 # -fstack-protector* stack protector flags for GCC
Chris@40 7271 # @file GCC response files
Chris@40 7272 # -tp=* Portland pgcc target processor selection
Chris@40 7273 # --sysroot=* for sysroot support
Chris@40 7274 # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
Chris@40 7275 # -specs=* GCC specs files
Chris@40 7276 # -stdlib=* select c++ std lib with clang
Chris@40 7277 # -fsanitize=* Clang/GCC memory and address sanitizer
Chris@40 7278 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
Chris@40 7279 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
Chris@40 7280 -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
Chris@40 7281 -specs=*|-fsanitize=*)
Chris@40 7282 func_quote_for_eval "$arg"
Chris@40 7283 arg=$func_quote_for_eval_result
Chris@40 7284 func_append compile_command " $arg"
Chris@40 7285 func_append finalize_command " $arg"
Chris@40 7286 func_append compiler_flags " $arg"
Chris@40 7287 continue
Chris@40 7288 ;;
Chris@40 7289
Chris@40 7290 -Z*)
Chris@40 7291 if test os2 = "`expr $host : '.*\(os2\)'`"; then
Chris@40 7292 # OS/2 uses -Zxxx to specify OS/2-specific options
Chris@40 7293 compiler_flags="$compiler_flags $arg"
Chris@40 7294 func_append compile_command " $arg"
Chris@40 7295 func_append finalize_command " $arg"
Chris@40 7296 case $arg in
Chris@40 7297 -Zlinker | -Zstack)
Chris@40 7298 prev=xcompiler
Chris@40 7299 ;;
Chris@40 7300 esac
Chris@40 7301 continue
Chris@40 7302 else
Chris@40 7303 # Otherwise treat like 'Some other compiler flag' below
Chris@40 7304 func_quote_for_eval "$arg"
Chris@40 7305 arg=$func_quote_for_eval_result
Chris@40 7306 fi
Chris@40 7307 ;;
Chris@40 7308
Chris@40 7309 # Some other compiler flag.
Chris@40 7310 -* | +*)
Chris@40 7311 func_quote_for_eval "$arg"
Chris@40 7312 arg=$func_quote_for_eval_result
Chris@40 7313 ;;
Chris@40 7314
Chris@40 7315 *.$objext)
Chris@40 7316 # A standard object.
Chris@40 7317 func_append objs " $arg"
Chris@40 7318 ;;
Chris@40 7319
Chris@40 7320 *.lo)
Chris@40 7321 # A libtool-controlled object.
Chris@40 7322
Chris@40 7323 # Check to see that this really is a libtool object.
Chris@40 7324 if func_lalib_unsafe_p "$arg"; then
Chris@40 7325 pic_object=
Chris@40 7326 non_pic_object=
Chris@40 7327
Chris@40 7328 # Read the .lo file
Chris@40 7329 func_source "$arg"
Chris@40 7330
Chris@40 7331 if test -z "$pic_object" ||
Chris@40 7332 test -z "$non_pic_object" ||
Chris@40 7333 test none = "$pic_object" &&
Chris@40 7334 test none = "$non_pic_object"; then
Chris@40 7335 func_fatal_error "cannot find name of object for '$arg'"
Chris@40 7336 fi
Chris@40 7337
Chris@40 7338 # Extract subdirectory from the argument.
Chris@40 7339 func_dirname "$arg" "/" ""
Chris@40 7340 xdir=$func_dirname_result
Chris@40 7341
Chris@40 7342 test none = "$pic_object" || {
Chris@40 7343 # Prepend the subdirectory the object is found in.
Chris@40 7344 pic_object=$xdir$pic_object
Chris@40 7345
Chris@40 7346 if test dlfiles = "$prev"; then
Chris@40 7347 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
Chris@40 7348 func_append dlfiles " $pic_object"
Chris@40 7349 prev=
Chris@40 7350 continue
Chris@40 7351 else
Chris@40 7352 # If libtool objects are unsupported, then we need to preload.
Chris@40 7353 prev=dlprefiles
Chris@40 7354 fi
Chris@40 7355 fi
Chris@40 7356
Chris@40 7357 # CHECK ME: I think I busted this. -Ossama
Chris@40 7358 if test dlprefiles = "$prev"; then
Chris@40 7359 # Preload the old-style object.
Chris@40 7360 func_append dlprefiles " $pic_object"
Chris@40 7361 prev=
Chris@40 7362 fi
Chris@40 7363
Chris@40 7364 # A PIC object.
Chris@40 7365 func_append libobjs " $pic_object"
Chris@40 7366 arg=$pic_object
Chris@40 7367 }
Chris@40 7368
Chris@40 7369 # Non-PIC object.
Chris@40 7370 if test none != "$non_pic_object"; then
Chris@40 7371 # Prepend the subdirectory the object is found in.
Chris@40 7372 non_pic_object=$xdir$non_pic_object
Chris@40 7373
Chris@40 7374 # A standard non-PIC object
Chris@40 7375 func_append non_pic_objects " $non_pic_object"
Chris@40 7376 if test -z "$pic_object" || test none = "$pic_object"; then
Chris@40 7377 arg=$non_pic_object
Chris@40 7378 fi
Chris@40 7379 else
Chris@40 7380 # If the PIC object exists, use it instead.
Chris@40 7381 # $xdir was prepended to $pic_object above.
Chris@40 7382 non_pic_object=$pic_object
Chris@40 7383 func_append non_pic_objects " $non_pic_object"
Chris@40 7384 fi
Chris@40 7385 else
Chris@40 7386 # Only an error if not doing a dry-run.
Chris@40 7387 if $opt_dry_run; then
Chris@40 7388 # Extract subdirectory from the argument.
Chris@40 7389 func_dirname "$arg" "/" ""
Chris@40 7390 xdir=$func_dirname_result
Chris@40 7391
Chris@40 7392 func_lo2o "$arg"
Chris@40 7393 pic_object=$xdir$objdir/$func_lo2o_result
Chris@40 7394 non_pic_object=$xdir$func_lo2o_result
Chris@40 7395 func_append libobjs " $pic_object"
Chris@40 7396 func_append non_pic_objects " $non_pic_object"
Chris@40 7397 else
Chris@40 7398 func_fatal_error "'$arg' is not a valid libtool object"
Chris@40 7399 fi
Chris@40 7400 fi
Chris@40 7401 ;;
Chris@40 7402
Chris@40 7403 *.$libext)
Chris@40 7404 # An archive.
Chris@40 7405 func_append deplibs " $arg"
Chris@40 7406 func_append old_deplibs " $arg"
Chris@40 7407 continue
Chris@40 7408 ;;
Chris@40 7409
Chris@40 7410 *.la)
Chris@40 7411 # A libtool-controlled library.
Chris@40 7412
Chris@40 7413 func_resolve_sysroot "$arg"
Chris@40 7414 if test dlfiles = "$prev"; then
Chris@40 7415 # This library was specified with -dlopen.
Chris@40 7416 func_append dlfiles " $func_resolve_sysroot_result"
Chris@40 7417 prev=
Chris@40 7418 elif test dlprefiles = "$prev"; then
Chris@40 7419 # The library was specified with -dlpreopen.
Chris@40 7420 func_append dlprefiles " $func_resolve_sysroot_result"
Chris@40 7421 prev=
Chris@40 7422 else
Chris@40 7423 func_append deplibs " $func_resolve_sysroot_result"
Chris@40 7424 fi
Chris@40 7425 continue
Chris@40 7426 ;;
Chris@40 7427
Chris@40 7428 # Some other compiler argument.
Chris@40 7429 *)
Chris@40 7430 # Unknown arguments in both finalize_command and compile_command need
Chris@40 7431 # to be aesthetically quoted because they are evaled later.
Chris@40 7432 func_quote_for_eval "$arg"
Chris@40 7433 arg=$func_quote_for_eval_result
Chris@40 7434 ;;
Chris@40 7435 esac # arg
Chris@40 7436
Chris@40 7437 # Now actually substitute the argument into the commands.
Chris@40 7438 if test -n "$arg"; then
Chris@40 7439 func_append compile_command " $arg"
Chris@40 7440 func_append finalize_command " $arg"
Chris@40 7441 fi
Chris@40 7442 done # argument parsing loop
Chris@40 7443
Chris@40 7444 test -n "$prev" && \
Chris@40 7445 func_fatal_help "the '$prevarg' option requires an argument"
Chris@40 7446
Chris@40 7447 if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
Chris@40 7448 eval arg=\"$export_dynamic_flag_spec\"
Chris@40 7449 func_append compile_command " $arg"
Chris@40 7450 func_append finalize_command " $arg"
Chris@40 7451 fi
Chris@40 7452
Chris@40 7453 oldlibs=
Chris@40 7454 # calculate the name of the file, without its directory
Chris@40 7455 func_basename "$output"
Chris@40 7456 outputname=$func_basename_result
Chris@40 7457 libobjs_save=$libobjs
Chris@40 7458
Chris@40 7459 if test -n "$shlibpath_var"; then
Chris@40 7460 # get the directories listed in $shlibpath_var
Chris@40 7461 eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
Chris@40 7462 else
Chris@40 7463 shlib_search_path=
Chris@40 7464 fi
Chris@40 7465 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
Chris@40 7466 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
Chris@40 7467
Chris@40 7468 # Definition is injected by LT_CONFIG during libtool generation.
Chris@40 7469 func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
Chris@40 7470
Chris@40 7471 func_dirname "$output" "/" ""
Chris@40 7472 output_objdir=$func_dirname_result$objdir
Chris@40 7473 func_to_tool_file "$output_objdir/"
Chris@40 7474 tool_output_objdir=$func_to_tool_file_result
Chris@40 7475 # Create the object directory.
Chris@40 7476 func_mkdir_p "$output_objdir"
Chris@40 7477
Chris@40 7478 # Determine the type of output
Chris@40 7479 case $output in
Chris@40 7480 "")
Chris@40 7481 func_fatal_help "you must specify an output file"
Chris@40 7482 ;;
Chris@40 7483 *.$libext) linkmode=oldlib ;;
Chris@40 7484 *.lo | *.$objext) linkmode=obj ;;
Chris@40 7485 *.la) linkmode=lib ;;
Chris@40 7486 *) linkmode=prog ;; # Anything else should be a program.
Chris@40 7487 esac
Chris@40 7488
Chris@40 7489 specialdeplibs=
Chris@40 7490
Chris@40 7491 libs=
Chris@40 7492 # Find all interdependent deplibs by searching for libraries
Chris@40 7493 # that are linked more than once (e.g. -la -lb -la)
Chris@40 7494 for deplib in $deplibs; do
Chris@40 7495 if $opt_preserve_dup_deps; then
Chris@40 7496 case "$libs " in
Chris@40 7497 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
Chris@40 7498 esac
Chris@40 7499 fi
Chris@40 7500 func_append libs " $deplib"
Chris@40 7501 done
Chris@40 7502
Chris@40 7503 if test lib = "$linkmode"; then
Chris@40 7504 libs="$predeps $libs $compiler_lib_search_path $postdeps"
Chris@40 7505
Chris@40 7506 # Compute libraries that are listed more than once in $predeps
Chris@40 7507 # $postdeps and mark them as special (i.e., whose duplicates are
Chris@40 7508 # not to be eliminated).
Chris@40 7509 pre_post_deps=
Chris@40 7510 if $opt_duplicate_compiler_generated_deps; then
Chris@40 7511 for pre_post_dep in $predeps $postdeps; do
Chris@40 7512 case "$pre_post_deps " in
Chris@40 7513 *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
Chris@40 7514 esac
Chris@40 7515 func_append pre_post_deps " $pre_post_dep"
Chris@40 7516 done
Chris@40 7517 fi
Chris@40 7518 pre_post_deps=
Chris@40 7519 fi
Chris@40 7520
Chris@40 7521 deplibs=
Chris@40 7522 newdependency_libs=
Chris@40 7523 newlib_search_path=
Chris@40 7524 need_relink=no # whether we're linking any uninstalled libtool libraries
Chris@40 7525 notinst_deplibs= # not-installed libtool libraries
Chris@40 7526 notinst_path= # paths that contain not-installed libtool libraries
Chris@40 7527
Chris@40 7528 case $linkmode in
Chris@40 7529 lib)
Chris@40 7530 passes="conv dlpreopen link"
Chris@40 7531 for file in $dlfiles $dlprefiles; do
Chris@40 7532 case $file in
Chris@40 7533 *.la) ;;
Chris@40 7534 *)
Chris@40 7535 func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
Chris@40 7536 ;;
Chris@40 7537 esac
Chris@40 7538 done
Chris@40 7539 ;;
Chris@40 7540 prog)
Chris@40 7541 compile_deplibs=
Chris@40 7542 finalize_deplibs=
Chris@40 7543 alldeplibs=false
Chris@40 7544 newdlfiles=
Chris@40 7545 newdlprefiles=
Chris@40 7546 passes="conv scan dlopen dlpreopen link"
Chris@40 7547 ;;
Chris@40 7548 *) passes="conv"
Chris@40 7549 ;;
Chris@40 7550 esac
Chris@40 7551
Chris@40 7552 for pass in $passes; do
Chris@40 7553 # The preopen pass in lib mode reverses $deplibs; put it back here
Chris@40 7554 # so that -L comes before libs that need it for instance...
Chris@40 7555 if test lib,link = "$linkmode,$pass"; then
Chris@40 7556 ## FIXME: Find the place where the list is rebuilt in the wrong
Chris@40 7557 ## order, and fix it there properly
Chris@40 7558 tmp_deplibs=
Chris@40 7559 for deplib in $deplibs; do
Chris@40 7560 tmp_deplibs="$deplib $tmp_deplibs"
Chris@40 7561 done
Chris@40 7562 deplibs=$tmp_deplibs
Chris@40 7563 fi
Chris@40 7564
Chris@40 7565 if test lib,link = "$linkmode,$pass" ||
Chris@40 7566 test prog,scan = "$linkmode,$pass"; then
Chris@40 7567 libs=$deplibs
Chris@40 7568 deplibs=
Chris@40 7569 fi
Chris@40 7570 if test prog = "$linkmode"; then
Chris@40 7571 case $pass in
Chris@40 7572 dlopen) libs=$dlfiles ;;
Chris@40 7573 dlpreopen) libs=$dlprefiles ;;
Chris@40 7574 link)
Chris@40 7575 libs="$deplibs %DEPLIBS%"
Chris@40 7576 test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
Chris@40 7577 ;;
Chris@40 7578 esac
Chris@40 7579 fi
Chris@40 7580 if test lib,dlpreopen = "$linkmode,$pass"; then
Chris@40 7581 # Collect and forward deplibs of preopened libtool libs
Chris@40 7582 for lib in $dlprefiles; do
Chris@40 7583 # Ignore non-libtool-libs
Chris@40 7584 dependency_libs=
Chris@40 7585 func_resolve_sysroot "$lib"
Chris@40 7586 case $lib in
Chris@40 7587 *.la) func_source "$func_resolve_sysroot_result" ;;
Chris@40 7588 esac
Chris@40 7589
Chris@40 7590 # Collect preopened libtool deplibs, except any this library
Chris@40 7591 # has declared as weak libs
Chris@40 7592 for deplib in $dependency_libs; do
Chris@40 7593 func_basename "$deplib"
Chris@40 7594 deplib_base=$func_basename_result
Chris@40 7595 case " $weak_libs " in
Chris@40 7596 *" $deplib_base "*) ;;
Chris@40 7597 *) func_append deplibs " $deplib" ;;
Chris@40 7598 esac
Chris@40 7599 done
Chris@40 7600 done
Chris@40 7601 libs=$dlprefiles
Chris@40 7602 fi
Chris@40 7603 if test dlopen = "$pass"; then
Chris@40 7604 # Collect dlpreopened libraries
Chris@40 7605 save_deplibs=$deplibs
Chris@40 7606 deplibs=
Chris@40 7607 fi
Chris@40 7608
Chris@40 7609 for deplib in $libs; do
Chris@40 7610 lib=
Chris@40 7611 found=false
Chris@40 7612 case $deplib in
Chris@40 7613 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
Chris@40 7614 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
Chris@40 7615 if test prog,link = "$linkmode,$pass"; then
Chris@40 7616 compile_deplibs="$deplib $compile_deplibs"
Chris@40 7617 finalize_deplibs="$deplib $finalize_deplibs"
Chris@40 7618 else
Chris@40 7619 func_append compiler_flags " $deplib"
Chris@40 7620 if test lib = "$linkmode"; then
Chris@40 7621 case "$new_inherited_linker_flags " in
Chris@40 7622 *" $deplib "*) ;;
Chris@40 7623 * ) func_append new_inherited_linker_flags " $deplib" ;;
Chris@40 7624 esac
Chris@40 7625 fi
Chris@40 7626 fi
Chris@40 7627 continue
Chris@40 7628 ;;
Chris@40 7629 -l*)
Chris@40 7630 if test lib != "$linkmode" && test prog != "$linkmode"; then
Chris@40 7631 func_warning "'-l' is ignored for archives/objects"
Chris@40 7632 continue
Chris@40 7633 fi
Chris@40 7634 func_stripname '-l' '' "$deplib"
Chris@40 7635 name=$func_stripname_result
Chris@40 7636 if test lib = "$linkmode"; then
Chris@40 7637 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
Chris@40 7638 else
Chris@40 7639 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
Chris@40 7640 fi
Chris@40 7641 for searchdir in $searchdirs; do
Chris@40 7642 for search_ext in .la $std_shrext .so .a; do
Chris@40 7643 # Search the libtool library
Chris@40 7644 lib=$searchdir/lib$name$search_ext
Chris@40 7645 if test -f "$lib"; then
Chris@40 7646 if test .la = "$search_ext"; then
Chris@40 7647 found=:
Chris@40 7648 else
Chris@40 7649 found=false
Chris@40 7650 fi
Chris@40 7651 break 2
Chris@40 7652 fi
Chris@40 7653 done
Chris@40 7654 done
Chris@40 7655 if $found; then
Chris@40 7656 # deplib is a libtool library
Chris@40 7657 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
Chris@40 7658 # We need to do some special things here, and not later.
Chris@40 7659 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@40 7660 case " $predeps $postdeps " in
Chris@40 7661 *" $deplib "*)
Chris@40 7662 if func_lalib_p "$lib"; then
Chris@40 7663 library_names=
Chris@40 7664 old_library=
Chris@40 7665 func_source "$lib"
Chris@40 7666 for l in $old_library $library_names; do
Chris@40 7667 ll=$l
Chris@40 7668 done
Chris@40 7669 if test "X$ll" = "X$old_library"; then # only static version available
Chris@40 7670 found=false
Chris@40 7671 func_dirname "$lib" "" "."
Chris@40 7672 ladir=$func_dirname_result
Chris@40 7673 lib=$ladir/$old_library
Chris@40 7674 if test prog,link = "$linkmode,$pass"; then
Chris@40 7675 compile_deplibs="$deplib $compile_deplibs"
Chris@40 7676 finalize_deplibs="$deplib $finalize_deplibs"
Chris@40 7677 else
Chris@40 7678 deplibs="$deplib $deplibs"
Chris@40 7679 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
Chris@40 7680 fi
Chris@40 7681 continue
Chris@40 7682 fi
Chris@40 7683 fi
Chris@40 7684 ;;
Chris@40 7685 *) ;;
Chris@40 7686 esac
Chris@40 7687 fi
Chris@40 7688 else
Chris@40 7689 # deplib doesn't seem to be a libtool library
Chris@40 7690 if test prog,link = "$linkmode,$pass"; then
Chris@40 7691 compile_deplibs="$deplib $compile_deplibs"
Chris@40 7692 finalize_deplibs="$deplib $finalize_deplibs"
Chris@40 7693 else
Chris@40 7694 deplibs="$deplib $deplibs"
Chris@40 7695 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
Chris@40 7696 fi
Chris@40 7697 continue
Chris@40 7698 fi
Chris@40 7699 ;; # -l
Chris@40 7700 *.ltframework)
Chris@40 7701 if test prog,link = "$linkmode,$pass"; then
Chris@40 7702 compile_deplibs="$deplib $compile_deplibs"
Chris@40 7703 finalize_deplibs="$deplib $finalize_deplibs"
Chris@40 7704 else
Chris@40 7705 deplibs="$deplib $deplibs"
Chris@40 7706 if test lib = "$linkmode"; then
Chris@40 7707 case "$new_inherited_linker_flags " in
Chris@40 7708 *" $deplib "*) ;;
Chris@40 7709 * ) func_append new_inherited_linker_flags " $deplib" ;;
Chris@40 7710 esac
Chris@40 7711 fi
Chris@40 7712 fi
Chris@40 7713 continue
Chris@40 7714 ;;
Chris@40 7715 -L*)
Chris@40 7716 case $linkmode in
Chris@40 7717 lib)
Chris@40 7718 deplibs="$deplib $deplibs"
Chris@40 7719 test conv = "$pass" && continue
Chris@40 7720 newdependency_libs="$deplib $newdependency_libs"
Chris@40 7721 func_stripname '-L' '' "$deplib"
Chris@40 7722 func_resolve_sysroot "$func_stripname_result"
Chris@40 7723 func_append newlib_search_path " $func_resolve_sysroot_result"
Chris@40 7724 ;;
Chris@40 7725 prog)
Chris@40 7726 if test conv = "$pass"; then
Chris@40 7727 deplibs="$deplib $deplibs"
Chris@40 7728 continue
Chris@40 7729 fi
Chris@40 7730 if test scan = "$pass"; then
Chris@40 7731 deplibs="$deplib $deplibs"
Chris@40 7732 else
Chris@40 7733 compile_deplibs="$deplib $compile_deplibs"
Chris@40 7734 finalize_deplibs="$deplib $finalize_deplibs"
Chris@40 7735 fi
Chris@40 7736 func_stripname '-L' '' "$deplib"
Chris@40 7737 func_resolve_sysroot "$func_stripname_result"
Chris@40 7738 func_append newlib_search_path " $func_resolve_sysroot_result"
Chris@40 7739 ;;
Chris@40 7740 *)
Chris@40 7741 func_warning "'-L' is ignored for archives/objects"
Chris@40 7742 ;;
Chris@40 7743 esac # linkmode
Chris@40 7744 continue
Chris@40 7745 ;; # -L
Chris@40 7746 -R*)
Chris@40 7747 if test link = "$pass"; then
Chris@40 7748 func_stripname '-R' '' "$deplib"
Chris@40 7749 func_resolve_sysroot "$func_stripname_result"
Chris@40 7750 dir=$func_resolve_sysroot_result
Chris@40 7751 # Make sure the xrpath contains only unique directories.
Chris@40 7752 case "$xrpath " in
Chris@40 7753 *" $dir "*) ;;
Chris@40 7754 *) func_append xrpath " $dir" ;;
Chris@40 7755 esac
Chris@40 7756 fi
Chris@40 7757 deplibs="$deplib $deplibs"
Chris@40 7758 continue
Chris@40 7759 ;;
Chris@40 7760 *.la)
Chris@40 7761 func_resolve_sysroot "$deplib"
Chris@40 7762 lib=$func_resolve_sysroot_result
Chris@40 7763 ;;
Chris@40 7764 *.$libext)
Chris@40 7765 if test conv = "$pass"; then
Chris@40 7766 deplibs="$deplib $deplibs"
Chris@40 7767 continue
Chris@40 7768 fi
Chris@40 7769 case $linkmode in
Chris@40 7770 lib)
Chris@40 7771 # Linking convenience modules into shared libraries is allowed,
Chris@40 7772 # but linking other static libraries is non-portable.
Chris@40 7773 case " $dlpreconveniencelibs " in
Chris@40 7774 *" $deplib "*) ;;
Chris@40 7775 *)
Chris@40 7776 valid_a_lib=false
Chris@40 7777 case $deplibs_check_method in
Chris@40 7778 match_pattern*)
Chris@40 7779 set dummy $deplibs_check_method; shift
Chris@40 7780 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Chris@40 7781 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
Chris@40 7782 | $EGREP "$match_pattern_regex" > /dev/null; then
Chris@40 7783 valid_a_lib=:
Chris@40 7784 fi
Chris@40 7785 ;;
Chris@40 7786 pass_all)
Chris@40 7787 valid_a_lib=:
Chris@40 7788 ;;
Chris@40 7789 esac
Chris@40 7790 if $valid_a_lib; then
Chris@40 7791 echo
Chris@40 7792 $ECHO "*** Warning: Linking the shared library $output against the"
Chris@40 7793 $ECHO "*** static library $deplib is not portable!"
Chris@40 7794 deplibs="$deplib $deplibs"
Chris@40 7795 else
Chris@40 7796 echo
Chris@40 7797 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
Chris@40 7798 echo "*** I have the capability to make that library automatically link in when"
Chris@40 7799 echo "*** you link to this library. But I can only do this if you have a"
Chris@40 7800 echo "*** shared version of the library, which you do not appear to have"
Chris@40 7801 echo "*** because the file extensions .$libext of this argument makes me believe"
Chris@40 7802 echo "*** that it is just a static archive that I should not use here."
Chris@40 7803 fi
Chris@40 7804 ;;
Chris@40 7805 esac
Chris@40 7806 continue
Chris@40 7807 ;;
Chris@40 7808 prog)
Chris@40 7809 if test link != "$pass"; then
Chris@40 7810 deplibs="$deplib $deplibs"
Chris@40 7811 else
Chris@40 7812 compile_deplibs="$deplib $compile_deplibs"
Chris@40 7813 finalize_deplibs="$deplib $finalize_deplibs"
Chris@40 7814 fi
Chris@40 7815 continue
Chris@40 7816 ;;
Chris@40 7817 esac # linkmode
Chris@40 7818 ;; # *.$libext
Chris@40 7819 *.lo | *.$objext)
Chris@40 7820 if test conv = "$pass"; then
Chris@40 7821 deplibs="$deplib $deplibs"
Chris@40 7822 elif test prog = "$linkmode"; then
Chris@40 7823 if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
Chris@40 7824 # If there is no dlopen support or we're linking statically,
Chris@40 7825 # we need to preload.
Chris@40 7826 func_append newdlprefiles " $deplib"
Chris@40 7827 compile_deplibs="$deplib $compile_deplibs"
Chris@40 7828 finalize_deplibs="$deplib $finalize_deplibs"
Chris@40 7829 else
Chris@40 7830 func_append newdlfiles " $deplib"
Chris@40 7831 fi
Chris@40 7832 fi
Chris@40 7833 continue
Chris@40 7834 ;;
Chris@40 7835 %DEPLIBS%)
Chris@40 7836 alldeplibs=:
Chris@40 7837 continue
Chris@40 7838 ;;
Chris@40 7839 esac # case $deplib
Chris@40 7840
Chris@40 7841 $found || test -f "$lib" \
Chris@40 7842 || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
Chris@40 7843
Chris@40 7844 # Check to see that this really is a libtool archive.
Chris@40 7845 func_lalib_unsafe_p "$lib" \
Chris@40 7846 || func_fatal_error "'$lib' is not a valid libtool archive"
Chris@40 7847
Chris@40 7848 func_dirname "$lib" "" "."
Chris@40 7849 ladir=$func_dirname_result
Chris@40 7850
Chris@40 7851 dlname=
Chris@40 7852 dlopen=
Chris@40 7853 dlpreopen=
Chris@40 7854 libdir=
Chris@40 7855 library_names=
Chris@40 7856 old_library=
Chris@40 7857 inherited_linker_flags=
Chris@40 7858 # If the library was installed with an old release of libtool,
Chris@40 7859 # it will not redefine variables installed, or shouldnotlink
Chris@40 7860 installed=yes
Chris@40 7861 shouldnotlink=no
Chris@40 7862 avoidtemprpath=
Chris@40 7863
Chris@40 7864
Chris@40 7865 # Read the .la file
Chris@40 7866 func_source "$lib"
Chris@40 7867
Chris@40 7868 # Convert "-framework foo" to "foo.ltframework"
Chris@40 7869 if test -n "$inherited_linker_flags"; then
Chris@40 7870 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
Chris@40 7871 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
Chris@40 7872 case " $new_inherited_linker_flags " in
Chris@40 7873 *" $tmp_inherited_linker_flag "*) ;;
Chris@40 7874 *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
Chris@40 7875 esac
Chris@40 7876 done
Chris@40 7877 fi
Chris@40 7878 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@40 7879 if test lib,link = "$linkmode,$pass" ||
Chris@40 7880 test prog,scan = "$linkmode,$pass" ||
Chris@40 7881 { test prog != "$linkmode" && test lib != "$linkmode"; }; then
Chris@40 7882 test -n "$dlopen" && func_append dlfiles " $dlopen"
Chris@40 7883 test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
Chris@40 7884 fi
Chris@40 7885
Chris@40 7886 if test conv = "$pass"; then
Chris@40 7887 # Only check for convenience libraries
Chris@40 7888 deplibs="$lib $deplibs"
Chris@40 7889 if test -z "$libdir"; then
Chris@40 7890 if test -z "$old_library"; then
Chris@40 7891 func_fatal_error "cannot find name of link library for '$lib'"
Chris@40 7892 fi
Chris@40 7893 # It is a libtool convenience library, so add in its objects.
Chris@40 7894 func_append convenience " $ladir/$objdir/$old_library"
Chris@40 7895 func_append old_convenience " $ladir/$objdir/$old_library"
Chris@40 7896 tmp_libs=
Chris@40 7897 for deplib in $dependency_libs; do
Chris@40 7898 deplibs="$deplib $deplibs"
Chris@40 7899 if $opt_preserve_dup_deps; then
Chris@40 7900 case "$tmp_libs " in
Chris@40 7901 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
Chris@40 7902 esac
Chris@40 7903 fi
Chris@40 7904 func_append tmp_libs " $deplib"
Chris@40 7905 done
Chris@40 7906 elif test prog != "$linkmode" && test lib != "$linkmode"; then
Chris@40 7907 func_fatal_error "'$lib' is not a convenience library"
Chris@40 7908 fi
Chris@40 7909 continue
Chris@40 7910 fi # $pass = conv
Chris@40 7911
Chris@40 7912
Chris@40 7913 # Get the name of the library we link against.
Chris@40 7914 linklib=
Chris@40 7915 if test -n "$old_library" &&
Chris@40 7916 { test yes = "$prefer_static_libs" ||
Chris@40 7917 test built,no = "$prefer_static_libs,$installed"; }; then
Chris@40 7918 linklib=$old_library
Chris@40 7919 else
Chris@40 7920 for l in $old_library $library_names; do
Chris@40 7921 linklib=$l
Chris@40 7922 done
Chris@40 7923 fi
Chris@40 7924 if test -z "$linklib"; then
Chris@40 7925 func_fatal_error "cannot find name of link library for '$lib'"
Chris@40 7926 fi
Chris@40 7927
Chris@40 7928 # This library was specified with -dlopen.
Chris@40 7929 if test dlopen = "$pass"; then
Chris@40 7930 test -z "$libdir" \
Chris@40 7931 && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
Chris@40 7932 if test -z "$dlname" ||
Chris@40 7933 test yes != "$dlopen_support" ||
Chris@40 7934 test no = "$build_libtool_libs"
Chris@40 7935 then
Chris@40 7936 # If there is no dlname, no dlopen support or we're linking
Chris@40 7937 # statically, we need to preload. We also need to preload any
Chris@40 7938 # dependent libraries so libltdl's deplib preloader doesn't
Chris@40 7939 # bomb out in the load deplibs phase.
Chris@40 7940 func_append dlprefiles " $lib $dependency_libs"
Chris@40 7941 else
Chris@40 7942 func_append newdlfiles " $lib"
Chris@40 7943 fi
Chris@40 7944 continue
Chris@40 7945 fi # $pass = dlopen
Chris@40 7946
Chris@40 7947 # We need an absolute path.
Chris@40 7948 case $ladir in
Chris@40 7949 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
Chris@40 7950 *)
Chris@40 7951 abs_ladir=`cd "$ladir" && pwd`
Chris@40 7952 if test -z "$abs_ladir"; then
Chris@40 7953 func_warning "cannot determine absolute directory name of '$ladir'"
Chris@40 7954 func_warning "passing it literally to the linker, although it might fail"
Chris@40 7955 abs_ladir=$ladir
Chris@40 7956 fi
Chris@40 7957 ;;
Chris@40 7958 esac
Chris@40 7959 func_basename "$lib"
Chris@40 7960 laname=$func_basename_result
Chris@40 7961
Chris@40 7962 # Find the relevant object directory and library name.
Chris@40 7963 if test yes = "$installed"; then
Chris@40 7964 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
Chris@40 7965 func_warning "library '$lib' was moved."
Chris@40 7966 dir=$ladir
Chris@40 7967 absdir=$abs_ladir
Chris@40 7968 libdir=$abs_ladir
Chris@40 7969 else
Chris@40 7970 dir=$lt_sysroot$libdir
Chris@40 7971 absdir=$lt_sysroot$libdir
Chris@40 7972 fi
Chris@40 7973 test yes = "$hardcode_automatic" && avoidtemprpath=yes
Chris@40 7974 else
Chris@40 7975 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
Chris@40 7976 dir=$ladir
Chris@40 7977 absdir=$abs_ladir
Chris@40 7978 # Remove this search path later
Chris@40 7979 func_append notinst_path " $abs_ladir"
Chris@40 7980 else
Chris@40 7981 dir=$ladir/$objdir
Chris@40 7982 absdir=$abs_ladir/$objdir
Chris@40 7983 # Remove this search path later
Chris@40 7984 func_append notinst_path " $abs_ladir"
Chris@40 7985 fi
Chris@40 7986 fi # $installed = yes
Chris@40 7987 func_stripname 'lib' '.la' "$laname"
Chris@40 7988 name=$func_stripname_result
Chris@40 7989
Chris@40 7990 # This library was specified with -dlpreopen.
Chris@40 7991 if test dlpreopen = "$pass"; then
Chris@40 7992 if test -z "$libdir" && test prog = "$linkmode"; then
Chris@40 7993 func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
Chris@40 7994 fi
Chris@40 7995 case $host in
Chris@40 7996 # special handling for platforms with PE-DLLs.
Chris@40 7997 *cygwin* | *mingw* | *cegcc* )
Chris@40 7998 # Linker will automatically link against shared library if both
Chris@40 7999 # static and shared are present. Therefore, ensure we extract
Chris@40 8000 # symbols from the import library if a shared library is present
Chris@40 8001 # (otherwise, the dlopen module name will be incorrect). We do
Chris@40 8002 # this by putting the import library name into $newdlprefiles.
Chris@40 8003 # We recover the dlopen module name by 'saving' the la file
Chris@40 8004 # name in a special purpose variable, and (later) extracting the
Chris@40 8005 # dlname from the la file.
Chris@40 8006 if test -n "$dlname"; then
Chris@40 8007 func_tr_sh "$dir/$linklib"
Chris@40 8008 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
Chris@40 8009 func_append newdlprefiles " $dir/$linklib"
Chris@40 8010 else
Chris@40 8011 func_append newdlprefiles " $dir/$old_library"
Chris@40 8012 # Keep a list of preopened convenience libraries to check
Chris@40 8013 # that they are being used correctly in the link pass.
Chris@40 8014 test -z "$libdir" && \
Chris@40 8015 func_append dlpreconveniencelibs " $dir/$old_library"
Chris@40 8016 fi
Chris@40 8017 ;;
Chris@40 8018 * )
Chris@40 8019 # Prefer using a static library (so that no silly _DYNAMIC symbols
Chris@40 8020 # are required to link).
Chris@40 8021 if test -n "$old_library"; then
Chris@40 8022 func_append newdlprefiles " $dir/$old_library"
Chris@40 8023 # Keep a list of preopened convenience libraries to check
Chris@40 8024 # that they are being used correctly in the link pass.
Chris@40 8025 test -z "$libdir" && \
Chris@40 8026 func_append dlpreconveniencelibs " $dir/$old_library"
Chris@40 8027 # Otherwise, use the dlname, so that lt_dlopen finds it.
Chris@40 8028 elif test -n "$dlname"; then
Chris@40 8029 func_append newdlprefiles " $dir/$dlname"
Chris@40 8030 else
Chris@40 8031 func_append newdlprefiles " $dir/$linklib"
Chris@40 8032 fi
Chris@40 8033 ;;
Chris@40 8034 esac
Chris@40 8035 fi # $pass = dlpreopen
Chris@40 8036
Chris@40 8037 if test -z "$libdir"; then
Chris@40 8038 # Link the convenience library
Chris@40 8039 if test lib = "$linkmode"; then
Chris@40 8040 deplibs="$dir/$old_library $deplibs"
Chris@40 8041 elif test prog,link = "$linkmode,$pass"; then
Chris@40 8042 compile_deplibs="$dir/$old_library $compile_deplibs"
Chris@40 8043 finalize_deplibs="$dir/$old_library $finalize_deplibs"
Chris@40 8044 else
Chris@40 8045 deplibs="$lib $deplibs" # used for prog,scan pass
Chris@40 8046 fi
Chris@40 8047 continue
Chris@40 8048 fi
Chris@40 8049
Chris@40 8050
Chris@40 8051 if test prog = "$linkmode" && test link != "$pass"; then
Chris@40 8052 func_append newlib_search_path " $ladir"
Chris@40 8053 deplibs="$lib $deplibs"
Chris@40 8054
Chris@40 8055 linkalldeplibs=false
Chris@40 8056 if test no != "$link_all_deplibs" || test -z "$library_names" ||
Chris@40 8057 test no = "$build_libtool_libs"; then
Chris@40 8058 linkalldeplibs=:
Chris@40 8059 fi
Chris@40 8060
Chris@40 8061 tmp_libs=
Chris@40 8062 for deplib in $dependency_libs; do
Chris@40 8063 case $deplib in
Chris@40 8064 -L*) func_stripname '-L' '' "$deplib"
Chris@40 8065 func_resolve_sysroot "$func_stripname_result"
Chris@40 8066 func_append newlib_search_path " $func_resolve_sysroot_result"
Chris@40 8067 ;;
Chris@40 8068 esac
Chris@40 8069 # Need to link against all dependency_libs?
Chris@40 8070 if $linkalldeplibs; then
Chris@40 8071 deplibs="$deplib $deplibs"
Chris@40 8072 else
Chris@40 8073 # Need to hardcode shared library paths
Chris@40 8074 # or/and link against static libraries
Chris@40 8075 newdependency_libs="$deplib $newdependency_libs"
Chris@40 8076 fi
Chris@40 8077 if $opt_preserve_dup_deps; then
Chris@40 8078 case "$tmp_libs " in
Chris@40 8079 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
Chris@40 8080 esac
Chris@40 8081 fi
Chris@40 8082 func_append tmp_libs " $deplib"
Chris@40 8083 done # for deplib
Chris@40 8084 continue
Chris@40 8085 fi # $linkmode = prog...
Chris@40 8086
Chris@40 8087 if test prog,link = "$linkmode,$pass"; then
Chris@40 8088 if test -n "$library_names" &&
Chris@40 8089 { { test no = "$prefer_static_libs" ||
Chris@40 8090 test built,yes = "$prefer_static_libs,$installed"; } ||
Chris@40 8091 test -z "$old_library"; }; then
Chris@40 8092 # We need to hardcode the library path
Chris@40 8093 if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
Chris@40 8094 # Make sure the rpath contains only unique directories.
Chris@40 8095 case $temp_rpath: in
Chris@40 8096 *"$absdir:"*) ;;
Chris@40 8097 *) func_append temp_rpath "$absdir:" ;;
Chris@40 8098 esac
Chris@40 8099 fi
Chris@40 8100
Chris@40 8101 # Hardcode the library path.
Chris@40 8102 # Skip directories that are in the system default run-time
Chris@40 8103 # search path.
Chris@40 8104 case " $sys_lib_dlsearch_path " in
Chris@40 8105 *" $absdir "*) ;;
Chris@40 8106 *)
Chris@40 8107 case "$compile_rpath " in
Chris@40 8108 *" $absdir "*) ;;
Chris@40 8109 *) func_append compile_rpath " $absdir" ;;
Chris@40 8110 esac
Chris@40 8111 ;;
Chris@40 8112 esac
Chris@40 8113 case " $sys_lib_dlsearch_path " in
Chris@40 8114 *" $libdir "*) ;;
Chris@40 8115 *)
Chris@40 8116 case "$finalize_rpath " in
Chris@40 8117 *" $libdir "*) ;;
Chris@40 8118 *) func_append finalize_rpath " $libdir" ;;
Chris@40 8119 esac
Chris@40 8120 ;;
Chris@40 8121 esac
Chris@40 8122 fi # $linkmode,$pass = prog,link...
Chris@40 8123
Chris@40 8124 if $alldeplibs &&
Chris@40 8125 { test pass_all = "$deplibs_check_method" ||
Chris@40 8126 { test yes = "$build_libtool_libs" &&
Chris@40 8127 test -n "$library_names"; }; }; then
Chris@40 8128 # We only need to search for static libraries
Chris@40 8129 continue
Chris@40 8130 fi
Chris@40 8131 fi
Chris@40 8132
Chris@40 8133 link_static=no # Whether the deplib will be linked statically
Chris@40 8134 use_static_libs=$prefer_static_libs
Chris@40 8135 if test built = "$use_static_libs" && test yes = "$installed"; then
Chris@40 8136 use_static_libs=no
Chris@40 8137 fi
Chris@40 8138 if test -n "$library_names" &&
Chris@40 8139 { test no = "$use_static_libs" || test -z "$old_library"; }; then
Chris@40 8140 case $host in
Chris@40 8141 *cygwin* | *mingw* | *cegcc* | *os2*)
Chris@40 8142 # No point in relinking DLLs because paths are not encoded
Chris@40 8143 func_append notinst_deplibs " $lib"
Chris@40 8144 need_relink=no
Chris@40 8145 ;;
Chris@40 8146 *)
Chris@40 8147 if test no = "$installed"; then
Chris@40 8148 func_append notinst_deplibs " $lib"
Chris@40 8149 need_relink=yes
Chris@40 8150 fi
Chris@40 8151 ;;
Chris@40 8152 esac
Chris@40 8153 # This is a shared library
Chris@40 8154
Chris@40 8155 # Warn about portability, can't link against -module's on some
Chris@40 8156 # systems (darwin). Don't bleat about dlopened modules though!
Chris@40 8157 dlopenmodule=
Chris@40 8158 for dlpremoduletest in $dlprefiles; do
Chris@40 8159 if test "X$dlpremoduletest" = "X$lib"; then
Chris@40 8160 dlopenmodule=$dlpremoduletest
Chris@40 8161 break
Chris@40 8162 fi
Chris@40 8163 done
Chris@40 8164 if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
Chris@40 8165 echo
Chris@40 8166 if test prog = "$linkmode"; then
Chris@40 8167 $ECHO "*** Warning: Linking the executable $output against the loadable module"
Chris@40 8168 else
Chris@40 8169 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
Chris@40 8170 fi
Chris@40 8171 $ECHO "*** $linklib is not portable!"
Chris@40 8172 fi
Chris@40 8173 if test lib = "$linkmode" &&
Chris@40 8174 test yes = "$hardcode_into_libs"; then
Chris@40 8175 # Hardcode the library path.
Chris@40 8176 # Skip directories that are in the system default run-time
Chris@40 8177 # search path.
Chris@40 8178 case " $sys_lib_dlsearch_path " in
Chris@40 8179 *" $absdir "*) ;;
Chris@40 8180 *)
Chris@40 8181 case "$compile_rpath " in
Chris@40 8182 *" $absdir "*) ;;
Chris@40 8183 *) func_append compile_rpath " $absdir" ;;
Chris@40 8184 esac
Chris@40 8185 ;;
Chris@40 8186 esac
Chris@40 8187 case " $sys_lib_dlsearch_path " in
Chris@40 8188 *" $libdir "*) ;;
Chris@40 8189 *)
Chris@40 8190 case "$finalize_rpath " in
Chris@40 8191 *" $libdir "*) ;;
Chris@40 8192 *) func_append finalize_rpath " $libdir" ;;
Chris@40 8193 esac
Chris@40 8194 ;;
Chris@40 8195 esac
Chris@40 8196 fi
Chris@40 8197
Chris@40 8198 if test -n "$old_archive_from_expsyms_cmds"; then
Chris@40 8199 # figure out the soname
Chris@40 8200 set dummy $library_names
Chris@40 8201 shift
Chris@40 8202 realname=$1
Chris@40 8203 shift
Chris@40 8204 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@40 8205 # use dlname if we got it. it's perfectly good, no?
Chris@40 8206 if test -n "$dlname"; then
Chris@40 8207 soname=$dlname
Chris@40 8208 elif test -n "$soname_spec"; then
Chris@40 8209 # bleh windows
Chris@40 8210 case $host in
Chris@40 8211 *cygwin* | mingw* | *cegcc* | *os2*)
Chris@40 8212 func_arith $current - $age
Chris@40 8213 major=$func_arith_result
Chris@40 8214 versuffix=-$major
Chris@40 8215 ;;
Chris@40 8216 esac
Chris@40 8217 eval soname=\"$soname_spec\"
Chris@40 8218 else
Chris@40 8219 soname=$realname
Chris@40 8220 fi
Chris@40 8221
Chris@40 8222 # Make a new name for the extract_expsyms_cmds to use
Chris@40 8223 soroot=$soname
Chris@40 8224 func_basename "$soroot"
Chris@40 8225 soname=$func_basename_result
Chris@40 8226 func_stripname 'lib' '.dll' "$soname"
Chris@40 8227 newlib=libimp-$func_stripname_result.a
Chris@40 8228
Chris@40 8229 # If the library has no export list, then create one now
Chris@40 8230 if test -f "$output_objdir/$soname-def"; then :
Chris@40 8231 else
Chris@40 8232 func_verbose "extracting exported symbol list from '$soname'"
Chris@40 8233 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
Chris@40 8234 fi
Chris@40 8235
Chris@40 8236 # Create $newlib
Chris@40 8237 if test -f "$output_objdir/$newlib"; then :; else
Chris@40 8238 func_verbose "generating import library for '$soname'"
Chris@40 8239 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
Chris@40 8240 fi
Chris@40 8241 # make sure the library variables are pointing to the new library
Chris@40 8242 dir=$output_objdir
Chris@40 8243 linklib=$newlib
Chris@40 8244 fi # test -n "$old_archive_from_expsyms_cmds"
Chris@40 8245
Chris@40 8246 if test prog = "$linkmode" || test relink != "$opt_mode"; then
Chris@40 8247 add_shlibpath=
Chris@40 8248 add_dir=
Chris@40 8249 add=
Chris@40 8250 lib_linked=yes
Chris@40 8251 case $hardcode_action in
Chris@40 8252 immediate | unsupported)
Chris@40 8253 if test no = "$hardcode_direct"; then
Chris@40 8254 add=$dir/$linklib
Chris@40 8255 case $host in
Chris@40 8256 *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
Chris@40 8257 *-*-sysv4*uw2*) add_dir=-L$dir ;;
Chris@40 8258 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
Chris@40 8259 *-*-unixware7*) add_dir=-L$dir ;;
Chris@40 8260 *-*-darwin* )
Chris@40 8261 # if the lib is a (non-dlopened) module then we cannot
Chris@40 8262 # link against it, someone is ignoring the earlier warnings
Chris@40 8263 if /usr/bin/file -L $add 2> /dev/null |
Chris@40 8264 $GREP ": [^:]* bundle" >/dev/null; then
Chris@40 8265 if test "X$dlopenmodule" != "X$lib"; then
Chris@40 8266 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
Chris@40 8267 if test -z "$old_library"; then
Chris@40 8268 echo
Chris@40 8269 echo "*** And there doesn't seem to be a static archive available"
Chris@40 8270 echo "*** The link will probably fail, sorry"
Chris@40 8271 else
Chris@40 8272 add=$dir/$old_library
Chris@40 8273 fi
Chris@40 8274 elif test -n "$old_library"; then
Chris@40 8275 add=$dir/$old_library
Chris@40 8276 fi
Chris@40 8277 fi
Chris@40 8278 esac
Chris@40 8279 elif test no = "$hardcode_minus_L"; then
Chris@40 8280 case $host in
Chris@40 8281 *-*-sunos*) add_shlibpath=$dir ;;
Chris@40 8282 esac
Chris@40 8283 add_dir=-L$dir
Chris@40 8284 add=-l$name
Chris@40 8285 elif test no = "$hardcode_shlibpath_var"; then
Chris@40 8286 add_shlibpath=$dir
Chris@40 8287 add=-l$name
Chris@40 8288 else
Chris@40 8289 lib_linked=no
Chris@40 8290 fi
Chris@40 8291 ;;
Chris@40 8292 relink)
Chris@40 8293 if test yes = "$hardcode_direct" &&
Chris@40 8294 test no = "$hardcode_direct_absolute"; then
Chris@40 8295 add=$dir/$linklib
Chris@40 8296 elif test yes = "$hardcode_minus_L"; then
Chris@40 8297 add_dir=-L$absdir
Chris@40 8298 # Try looking first in the location we're being installed to.
Chris@40 8299 if test -n "$inst_prefix_dir"; then
Chris@40 8300 case $libdir in
Chris@40 8301 [\\/]*)
Chris@40 8302 func_append add_dir " -L$inst_prefix_dir$libdir"
Chris@40 8303 ;;
Chris@40 8304 esac
Chris@40 8305 fi
Chris@40 8306 add=-l$name
Chris@40 8307 elif test yes = "$hardcode_shlibpath_var"; then
Chris@40 8308 add_shlibpath=$dir
Chris@40 8309 add=-l$name
Chris@40 8310 else
Chris@40 8311 lib_linked=no
Chris@40 8312 fi
Chris@40 8313 ;;
Chris@40 8314 *) lib_linked=no ;;
Chris@40 8315 esac
Chris@40 8316
Chris@40 8317 if test yes != "$lib_linked"; then
Chris@40 8318 func_fatal_configuration "unsupported hardcode properties"
Chris@40 8319 fi
Chris@40 8320
Chris@40 8321 if test -n "$add_shlibpath"; then
Chris@40 8322 case :$compile_shlibpath: in
Chris@40 8323 *":$add_shlibpath:"*) ;;
Chris@40 8324 *) func_append compile_shlibpath "$add_shlibpath:" ;;
Chris@40 8325 esac
Chris@40 8326 fi
Chris@40 8327 if test prog = "$linkmode"; then
Chris@40 8328 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
Chris@40 8329 test -n "$add" && compile_deplibs="$add $compile_deplibs"
Chris@40 8330 else
Chris@40 8331 test -n "$add_dir" && deplibs="$add_dir $deplibs"
Chris@40 8332 test -n "$add" && deplibs="$add $deplibs"
Chris@40 8333 if test yes != "$hardcode_direct" &&
Chris@40 8334 test yes != "$hardcode_minus_L" &&
Chris@40 8335 test yes = "$hardcode_shlibpath_var"; then
Chris@40 8336 case :$finalize_shlibpath: in
Chris@40 8337 *":$libdir:"*) ;;
Chris@40 8338 *) func_append finalize_shlibpath "$libdir:" ;;
Chris@40 8339 esac
Chris@40 8340 fi
Chris@40 8341 fi
Chris@40 8342 fi
Chris@40 8343
Chris@40 8344 if test prog = "$linkmode" || test relink = "$opt_mode"; then
Chris@40 8345 add_shlibpath=
Chris@40 8346 add_dir=
Chris@40 8347 add=
Chris@40 8348 # Finalize command for both is simple: just hardcode it.
Chris@40 8349 if test yes = "$hardcode_direct" &&
Chris@40 8350 test no = "$hardcode_direct_absolute"; then
Chris@40 8351 add=$libdir/$linklib
Chris@40 8352 elif test yes = "$hardcode_minus_L"; then
Chris@40 8353 add_dir=-L$libdir
Chris@40 8354 add=-l$name
Chris@40 8355 elif test yes = "$hardcode_shlibpath_var"; then
Chris@40 8356 case :$finalize_shlibpath: in
Chris@40 8357 *":$libdir:"*) ;;
Chris@40 8358 *) func_append finalize_shlibpath "$libdir:" ;;
Chris@40 8359 esac
Chris@40 8360 add=-l$name
Chris@40 8361 elif test yes = "$hardcode_automatic"; then
Chris@40 8362 if test -n "$inst_prefix_dir" &&
Chris@40 8363 test -f "$inst_prefix_dir$libdir/$linklib"; then
Chris@40 8364 add=$inst_prefix_dir$libdir/$linklib
Chris@40 8365 else
Chris@40 8366 add=$libdir/$linklib
Chris@40 8367 fi
Chris@40 8368 else
Chris@40 8369 # We cannot seem to hardcode it, guess we'll fake it.
Chris@40 8370 add_dir=-L$libdir
Chris@40 8371 # Try looking first in the location we're being installed to.
Chris@40 8372 if test -n "$inst_prefix_dir"; then
Chris@40 8373 case $libdir in
Chris@40 8374 [\\/]*)
Chris@40 8375 func_append add_dir " -L$inst_prefix_dir$libdir"
Chris@40 8376 ;;
Chris@40 8377 esac
Chris@40 8378 fi
Chris@40 8379 add=-l$name
Chris@40 8380 fi
Chris@40 8381
Chris@40 8382 if test prog = "$linkmode"; then
Chris@40 8383 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
Chris@40 8384 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
Chris@40 8385 else
Chris@40 8386 test -n "$add_dir" && deplibs="$add_dir $deplibs"
Chris@40 8387 test -n "$add" && deplibs="$add $deplibs"
Chris@40 8388 fi
Chris@40 8389 fi
Chris@40 8390 elif test prog = "$linkmode"; then
Chris@40 8391 # Here we assume that one of hardcode_direct or hardcode_minus_L
Chris@40 8392 # is not unsupported. This is valid on all known static and
Chris@40 8393 # shared platforms.
Chris@40 8394 if test unsupported != "$hardcode_direct"; then
Chris@40 8395 test -n "$old_library" && linklib=$old_library
Chris@40 8396 compile_deplibs="$dir/$linklib $compile_deplibs"
Chris@40 8397 finalize_deplibs="$dir/$linklib $finalize_deplibs"
Chris@40 8398 else
Chris@40 8399 compile_deplibs="-l$name -L$dir $compile_deplibs"
Chris@40 8400 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
Chris@40 8401 fi
Chris@40 8402 elif test yes = "$build_libtool_libs"; then
Chris@40 8403 # Not a shared library
Chris@40 8404 if test pass_all != "$deplibs_check_method"; then
Chris@40 8405 # We're trying link a shared library against a static one
Chris@40 8406 # but the system doesn't support it.
Chris@40 8407
Chris@40 8408 # Just print a warning and add the library to dependency_libs so
Chris@40 8409 # that the program can be linked against the static library.
Chris@40 8410 echo
Chris@40 8411 $ECHO "*** Warning: This system cannot link to static lib archive $lib."
Chris@40 8412 echo "*** I have the capability to make that library automatically link in when"
Chris@40 8413 echo "*** you link to this library. But I can only do this if you have a"
Chris@40 8414 echo "*** shared version of the library, which you do not appear to have."
Chris@40 8415 if test yes = "$module"; then
Chris@40 8416 echo "*** But as you try to build a module library, libtool will still create "
Chris@40 8417 echo "*** a static module, that should work as long as the dlopening application"
Chris@40 8418 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
Chris@40 8419 if test -z "$global_symbol_pipe"; then
Chris@40 8420 echo
Chris@40 8421 echo "*** However, this would only work if libtool was able to extract symbol"
Chris@40 8422 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
Chris@40 8423 echo "*** not find such a program. So, this module is probably useless."
Chris@40 8424 echo "*** 'nm' from GNU binutils and a full rebuild may help."
Chris@40 8425 fi
Chris@40 8426 if test no = "$build_old_libs"; then
Chris@40 8427 build_libtool_libs=module
Chris@40 8428 build_old_libs=yes
Chris@40 8429 else
Chris@40 8430 build_libtool_libs=no
Chris@40 8431 fi
Chris@40 8432 fi
Chris@40 8433 else
Chris@40 8434 deplibs="$dir/$old_library $deplibs"
Chris@40 8435 link_static=yes
Chris@40 8436 fi
Chris@40 8437 fi # link shared/static library?
Chris@40 8438
Chris@40 8439 if test lib = "$linkmode"; then
Chris@40 8440 if test -n "$dependency_libs" &&
Chris@40 8441 { test yes != "$hardcode_into_libs" ||
Chris@40 8442 test yes = "$build_old_libs" ||
Chris@40 8443 test yes = "$link_static"; }; then
Chris@40 8444 # Extract -R from dependency_libs
Chris@40 8445 temp_deplibs=
Chris@40 8446 for libdir in $dependency_libs; do
Chris@40 8447 case $libdir in
Chris@40 8448 -R*) func_stripname '-R' '' "$libdir"
Chris@40 8449 temp_xrpath=$func_stripname_result
Chris@40 8450 case " $xrpath " in
Chris@40 8451 *" $temp_xrpath "*) ;;
Chris@40 8452 *) func_append xrpath " $temp_xrpath";;
Chris@40 8453 esac;;
Chris@40 8454 *) func_append temp_deplibs " $libdir";;
Chris@40 8455 esac
Chris@40 8456 done
Chris@40 8457 dependency_libs=$temp_deplibs
Chris@40 8458 fi
Chris@40 8459
Chris@40 8460 func_append newlib_search_path " $absdir"
Chris@40 8461 # Link against this library
Chris@40 8462 test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
Chris@40 8463 # ... and its dependency_libs
Chris@40 8464 tmp_libs=
Chris@40 8465 for deplib in $dependency_libs; do
Chris@40 8466 newdependency_libs="$deplib $newdependency_libs"
Chris@40 8467 case $deplib in
Chris@40 8468 -L*) func_stripname '-L' '' "$deplib"
Chris@40 8469 func_resolve_sysroot "$func_stripname_result";;
Chris@40 8470 *) func_resolve_sysroot "$deplib" ;;
Chris@40 8471 esac
Chris@40 8472 if $opt_preserve_dup_deps; then
Chris@40 8473 case "$tmp_libs " in
Chris@40 8474 *" $func_resolve_sysroot_result "*)
Chris@40 8475 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
Chris@40 8476 esac
Chris@40 8477 fi
Chris@40 8478 func_append tmp_libs " $func_resolve_sysroot_result"
Chris@40 8479 done
Chris@40 8480
Chris@40 8481 if test no != "$link_all_deplibs"; then
Chris@40 8482 # Add the search paths of all dependency libraries
Chris@40 8483 for deplib in $dependency_libs; do
Chris@40 8484 path=
Chris@40 8485 case $deplib in
Chris@40 8486 -L*) path=$deplib ;;
Chris@40 8487 *.la)
Chris@40 8488 func_resolve_sysroot "$deplib"
Chris@40 8489 deplib=$func_resolve_sysroot_result
Chris@40 8490 func_dirname "$deplib" "" "."
Chris@40 8491 dir=$func_dirname_result
Chris@40 8492 # We need an absolute path.
Chris@40 8493 case $dir in
Chris@40 8494 [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
Chris@40 8495 *)
Chris@40 8496 absdir=`cd "$dir" && pwd`
Chris@40 8497 if test -z "$absdir"; then
Chris@40 8498 func_warning "cannot determine absolute directory name of '$dir'"
Chris@40 8499 absdir=$dir
Chris@40 8500 fi
Chris@40 8501 ;;
Chris@40 8502 esac
Chris@40 8503 if $GREP "^installed=no" $deplib > /dev/null; then
Chris@40 8504 case $host in
Chris@40 8505 *-*-darwin*)
Chris@40 8506 depdepl=
Chris@40 8507 eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
Chris@40 8508 if test -n "$deplibrary_names"; then
Chris@40 8509 for tmp in $deplibrary_names; do
Chris@40 8510 depdepl=$tmp
Chris@40 8511 done
Chris@40 8512 if test -f "$absdir/$objdir/$depdepl"; then
Chris@40 8513 depdepl=$absdir/$objdir/$depdepl
Chris@40 8514 darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
Chris@40 8515 if test -z "$darwin_install_name"; then
Chris@40 8516 darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
Chris@40 8517 fi
Chris@40 8518 func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
Chris@40 8519 func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
Chris@40 8520 path=
Chris@40 8521 fi
Chris@40 8522 fi
Chris@40 8523 ;;
Chris@40 8524 *)
Chris@40 8525 path=-L$absdir/$objdir
Chris@40 8526 ;;
Chris@40 8527 esac
Chris@40 8528 else
Chris@40 8529 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
Chris@40 8530 test -z "$libdir" && \
Chris@40 8531 func_fatal_error "'$deplib' is not a valid libtool archive"
Chris@40 8532 test "$absdir" != "$libdir" && \
Chris@40 8533 func_warning "'$deplib' seems to be moved"
Chris@40 8534
Chris@40 8535 path=-L$absdir
Chris@40 8536 fi
Chris@40 8537 ;;
Chris@40 8538 esac
Chris@40 8539 case " $deplibs " in
Chris@40 8540 *" $path "*) ;;
Chris@40 8541 *) deplibs="$path $deplibs" ;;
Chris@40 8542 esac
Chris@40 8543 done
Chris@40 8544 fi # link_all_deplibs != no
Chris@40 8545 fi # linkmode = lib
Chris@40 8546 done # for deplib in $libs
Chris@40 8547 if test link = "$pass"; then
Chris@40 8548 if test prog = "$linkmode"; then
Chris@40 8549 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
Chris@40 8550 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
Chris@40 8551 else
Chris@40 8552 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@40 8553 fi
Chris@40 8554 fi
Chris@40 8555 dependency_libs=$newdependency_libs
Chris@40 8556 if test dlpreopen = "$pass"; then
Chris@40 8557 # Link the dlpreopened libraries before other libraries
Chris@40 8558 for deplib in $save_deplibs; do
Chris@40 8559 deplibs="$deplib $deplibs"
Chris@40 8560 done
Chris@40 8561 fi
Chris@40 8562 if test dlopen != "$pass"; then
Chris@40 8563 test conv = "$pass" || {
Chris@40 8564 # Make sure lib_search_path contains only unique directories.
Chris@40 8565 lib_search_path=
Chris@40 8566 for dir in $newlib_search_path; do
Chris@40 8567 case "$lib_search_path " in
Chris@40 8568 *" $dir "*) ;;
Chris@40 8569 *) func_append lib_search_path " $dir" ;;
Chris@40 8570 esac
Chris@40 8571 done
Chris@40 8572 newlib_search_path=
Chris@40 8573 }
Chris@40 8574
Chris@40 8575 if test prog,link = "$linkmode,$pass"; then
Chris@40 8576 vars="compile_deplibs finalize_deplibs"
Chris@40 8577 else
Chris@40 8578 vars=deplibs
Chris@40 8579 fi
Chris@40 8580 for var in $vars dependency_libs; do
Chris@40 8581 # Add libraries to $var in reverse order
Chris@40 8582 eval tmp_libs=\"\$$var\"
Chris@40 8583 new_libs=
Chris@40 8584 for deplib in $tmp_libs; do
Chris@40 8585 # FIXME: Pedantically, this is the right thing to do, so
Chris@40 8586 # that some nasty dependency loop isn't accidentally
Chris@40 8587 # broken:
Chris@40 8588 #new_libs="$deplib $new_libs"
Chris@40 8589 # Pragmatically, this seems to cause very few problems in
Chris@40 8590 # practice:
Chris@40 8591 case $deplib in
Chris@40 8592 -L*) new_libs="$deplib $new_libs" ;;
Chris@40 8593 -R*) ;;
Chris@40 8594 *)
Chris@40 8595 # And here is the reason: when a library appears more
Chris@40 8596 # than once as an explicit dependence of a library, or
Chris@40 8597 # is implicitly linked in more than once by the
Chris@40 8598 # compiler, it is considered special, and multiple
Chris@40 8599 # occurrences thereof are not removed. Compare this
Chris@40 8600 # with having the same library being listed as a
Chris@40 8601 # dependency of multiple other libraries: in this case,
Chris@40 8602 # we know (pedantically, we assume) the library does not
Chris@40 8603 # need to be listed more than once, so we keep only the
Chris@40 8604 # last copy. This is not always right, but it is rare
Chris@40 8605 # enough that we require users that really mean to play
Chris@40 8606 # such unportable linking tricks to link the library
Chris@40 8607 # using -Wl,-lname, so that libtool does not consider it
Chris@40 8608 # for duplicate removal.
Chris@40 8609 case " $specialdeplibs " in
Chris@40 8610 *" $deplib "*) new_libs="$deplib $new_libs" ;;
Chris@40 8611 *)
Chris@40 8612 case " $new_libs " in
Chris@40 8613 *" $deplib "*) ;;
Chris@40 8614 *) new_libs="$deplib $new_libs" ;;
Chris@40 8615 esac
Chris@40 8616 ;;
Chris@40 8617 esac
Chris@40 8618 ;;
Chris@40 8619 esac
Chris@40 8620 done
Chris@40 8621 tmp_libs=
Chris@40 8622 for deplib in $new_libs; do
Chris@40 8623 case $deplib in
Chris@40 8624 -L*)
Chris@40 8625 case " $tmp_libs " in
Chris@40 8626 *" $deplib "*) ;;
Chris@40 8627 *) func_append tmp_libs " $deplib" ;;
Chris@40 8628 esac
Chris@40 8629 ;;
Chris@40 8630 *) func_append tmp_libs " $deplib" ;;
Chris@40 8631 esac
Chris@40 8632 done
Chris@40 8633 eval $var=\"$tmp_libs\"
Chris@40 8634 done # for var
Chris@40 8635 fi
Chris@40 8636
Chris@40 8637 # Add Sun CC postdeps if required:
Chris@40 8638 test CXX = "$tagname" && {
Chris@40 8639 case $host_os in
Chris@40 8640 linux*)
Chris@40 8641 case `$CC -V 2>&1 | sed 5q` in
Chris@40 8642 *Sun\ C*) # Sun C++ 5.9
Chris@40 8643 func_suncc_cstd_abi
Chris@40 8644
Chris@40 8645 if test no != "$suncc_use_cstd_abi"; then
Chris@40 8646 func_append postdeps ' -library=Cstd -library=Crun'
Chris@40 8647 fi
Chris@40 8648 ;;
Chris@40 8649 esac
Chris@40 8650 ;;
Chris@40 8651
Chris@40 8652 solaris*)
Chris@40 8653 func_cc_basename "$CC"
Chris@40 8654 case $func_cc_basename_result in
Chris@40 8655 CC* | sunCC*)
Chris@40 8656 func_suncc_cstd_abi
Chris@40 8657
Chris@40 8658 if test no != "$suncc_use_cstd_abi"; then
Chris@40 8659 func_append postdeps ' -library=Cstd -library=Crun'
Chris@40 8660 fi
Chris@40 8661 ;;
Chris@40 8662 esac
Chris@40 8663 ;;
Chris@40 8664 esac
Chris@40 8665 }
Chris@40 8666
Chris@40 8667 # Last step: remove runtime libs from dependency_libs
Chris@40 8668 # (they stay in deplibs)
Chris@40 8669 tmp_libs=
Chris@40 8670 for i in $dependency_libs; do
Chris@40 8671 case " $predeps $postdeps $compiler_lib_search_path " in
Chris@40 8672 *" $i "*)
Chris@40 8673 i=
Chris@40 8674 ;;
Chris@40 8675 esac
Chris@40 8676 if test -n "$i"; then
Chris@40 8677 func_append tmp_libs " $i"
Chris@40 8678 fi
Chris@40 8679 done
Chris@40 8680 dependency_libs=$tmp_libs
Chris@40 8681 done # for pass
Chris@40 8682 if test prog = "$linkmode"; then
Chris@40 8683 dlfiles=$newdlfiles
Chris@40 8684 fi
Chris@40 8685 if test prog = "$linkmode" || test lib = "$linkmode"; then
Chris@40 8686 dlprefiles=$newdlprefiles
Chris@40 8687 fi
Chris@40 8688
Chris@40 8689 case $linkmode in
Chris@40 8690 oldlib)
Chris@40 8691 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
Chris@40 8692 func_warning "'-dlopen' is ignored for archives"
Chris@40 8693 fi
Chris@40 8694
Chris@40 8695 case " $deplibs" in
Chris@40 8696 *\ -l* | *\ -L*)
Chris@40 8697 func_warning "'-l' and '-L' are ignored for archives" ;;
Chris@40 8698 esac
Chris@40 8699
Chris@40 8700 test -n "$rpath" && \
Chris@40 8701 func_warning "'-rpath' is ignored for archives"
Chris@40 8702
Chris@40 8703 test -n "$xrpath" && \
Chris@40 8704 func_warning "'-R' is ignored for archives"
Chris@40 8705
Chris@40 8706 test -n "$vinfo" && \
Chris@40 8707 func_warning "'-version-info/-version-number' is ignored for archives"
Chris@40 8708
Chris@40 8709 test -n "$release" && \
Chris@40 8710 func_warning "'-release' is ignored for archives"
Chris@40 8711
Chris@40 8712 test -n "$export_symbols$export_symbols_regex" && \
Chris@40 8713 func_warning "'-export-symbols' is ignored for archives"
Chris@40 8714
Chris@40 8715 # Now set the variables for building old libraries.
Chris@40 8716 build_libtool_libs=no
Chris@40 8717 oldlibs=$output
Chris@40 8718 func_append objs "$old_deplibs"
Chris@40 8719 ;;
Chris@40 8720
Chris@40 8721 lib)
Chris@40 8722 # Make sure we only generate libraries of the form 'libNAME.la'.
Chris@40 8723 case $outputname in
Chris@40 8724 lib*)
Chris@40 8725 func_stripname 'lib' '.la' "$outputname"
Chris@40 8726 name=$func_stripname_result
Chris@40 8727 eval shared_ext=\"$shrext_cmds\"
Chris@40 8728 eval libname=\"$libname_spec\"
Chris@40 8729 ;;
Chris@40 8730 *)
Chris@40 8731 test no = "$module" \
Chris@40 8732 && func_fatal_help "libtool library '$output' must begin with 'lib'"
Chris@40 8733
Chris@40 8734 if test no != "$need_lib_prefix"; then
Chris@40 8735 # Add the "lib" prefix for modules if required
Chris@40 8736 func_stripname '' '.la' "$outputname"
Chris@40 8737 name=$func_stripname_result
Chris@40 8738 eval shared_ext=\"$shrext_cmds\"
Chris@40 8739 eval libname=\"$libname_spec\"
Chris@40 8740 else
Chris@40 8741 func_stripname '' '.la' "$outputname"
Chris@40 8742 libname=$func_stripname_result
Chris@40 8743 fi
Chris@40 8744 ;;
Chris@40 8745 esac
Chris@40 8746
Chris@40 8747 if test -n "$objs"; then
Chris@40 8748 if test pass_all != "$deplibs_check_method"; then
Chris@40 8749 func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
Chris@40 8750 else
Chris@40 8751 echo
Chris@40 8752 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
Chris@40 8753 $ECHO "*** objects $objs is not portable!"
Chris@40 8754 func_append libobjs " $objs"
Chris@40 8755 fi
Chris@40 8756 fi
Chris@40 8757
Chris@40 8758 test no = "$dlself" \
Chris@40 8759 || func_warning "'-dlopen self' is ignored for libtool libraries"
Chris@40 8760
Chris@40 8761 set dummy $rpath
Chris@40 8762 shift
Chris@40 8763 test 1 -lt "$#" \
Chris@40 8764 && func_warning "ignoring multiple '-rpath's for a libtool library"
Chris@40 8765
Chris@40 8766 install_libdir=$1
Chris@40 8767
Chris@40 8768 oldlibs=
Chris@40 8769 if test -z "$rpath"; then
Chris@40 8770 if test yes = "$build_libtool_libs"; then
Chris@40 8771 # Building a libtool convenience library.
Chris@40 8772 # Some compilers have problems with a '.al' extension so
Chris@40 8773 # convenience libraries should have the same extension an
Chris@40 8774 # archive normally would.
Chris@40 8775 oldlibs="$output_objdir/$libname.$libext $oldlibs"
Chris@40 8776 build_libtool_libs=convenience
Chris@40 8777 build_old_libs=yes
Chris@40 8778 fi
Chris@40 8779
Chris@40 8780 test -n "$vinfo" && \
Chris@40 8781 func_warning "'-version-info/-version-number' is ignored for convenience libraries"
Chris@40 8782
Chris@40 8783 test -n "$release" && \
Chris@40 8784 func_warning "'-release' is ignored for convenience libraries"
Chris@40 8785 else
Chris@40 8786
Chris@40 8787 # Parse the version information argument.
Chris@40 8788 save_ifs=$IFS; IFS=:
Chris@40 8789 set dummy $vinfo 0 0 0
Chris@40 8790 shift
Chris@40 8791 IFS=$save_ifs
Chris@40 8792
Chris@40 8793 test -n "$7" && \
Chris@40 8794 func_fatal_help "too many parameters to '-version-info'"
Chris@40 8795
Chris@40 8796 # convert absolute version numbers to libtool ages
Chris@40 8797 # this retains compatibility with .la files and attempts
Chris@40 8798 # to make the code below a bit more comprehensible
Chris@40 8799
Chris@40 8800 case $vinfo_number in
Chris@40 8801 yes)
Chris@40 8802 number_major=$1
Chris@40 8803 number_minor=$2
Chris@40 8804 number_revision=$3
Chris@40 8805 #
Chris@40 8806 # There are really only two kinds -- those that
Chris@40 8807 # use the current revision as the major version
Chris@40 8808 # and those that subtract age and use age as
Chris@40 8809 # a minor version. But, then there is irix
Chris@40 8810 # that has an extra 1 added just for fun
Chris@40 8811 #
Chris@40 8812 case $version_type in
Chris@40 8813 # correct linux to gnu/linux during the next big refactor
Chris@40 8814 darwin|freebsd-elf|linux|osf|windows|none)
Chris@40 8815 func_arith $number_major + $number_minor
Chris@40 8816 current=$func_arith_result
Chris@40 8817 age=$number_minor
Chris@40 8818 revision=$number_revision
Chris@40 8819 ;;
Chris@40 8820 freebsd-aout|qnx|sunos)
Chris@40 8821 current=$number_major
Chris@40 8822 revision=$number_minor
Chris@40 8823 age=0
Chris@40 8824 ;;
Chris@40 8825 irix|nonstopux)
Chris@40 8826 func_arith $number_major + $number_minor
Chris@40 8827 current=$func_arith_result
Chris@40 8828 age=$number_minor
Chris@40 8829 revision=$number_minor
Chris@40 8830 lt_irix_increment=no
Chris@40 8831 ;;
Chris@40 8832 *)
Chris@40 8833 func_fatal_configuration "$modename: unknown library version type '$version_type'"
Chris@40 8834 ;;
Chris@40 8835 esac
Chris@40 8836 ;;
Chris@40 8837 no)
Chris@40 8838 current=$1
Chris@40 8839 revision=$2
Chris@40 8840 age=$3
Chris@40 8841 ;;
Chris@40 8842 esac
Chris@40 8843
Chris@40 8844 # Check that each of the things are valid numbers.
Chris@40 8845 case $current in
Chris@40 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@40 8847 *)
Chris@40 8848 func_error "CURRENT '$current' must be a nonnegative integer"
Chris@40 8849 func_fatal_error "'$vinfo' is not valid version information"
Chris@40 8850 ;;
Chris@40 8851 esac
Chris@40 8852
Chris@40 8853 case $revision in
Chris@40 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@40 8855 *)
Chris@40 8856 func_error "REVISION '$revision' must be a nonnegative integer"
Chris@40 8857 func_fatal_error "'$vinfo' is not valid version information"
Chris@40 8858 ;;
Chris@40 8859 esac
Chris@40 8860
Chris@40 8861 case $age in
Chris@40 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@40 8863 *)
Chris@40 8864 func_error "AGE '$age' must be a nonnegative integer"
Chris@40 8865 func_fatal_error "'$vinfo' is not valid version information"
Chris@40 8866 ;;
Chris@40 8867 esac
Chris@40 8868
Chris@40 8869 if test "$age" -gt "$current"; then
Chris@40 8870 func_error "AGE '$age' is greater than the current interface number '$current'"
Chris@40 8871 func_fatal_error "'$vinfo' is not valid version information"
Chris@40 8872 fi
Chris@40 8873
Chris@40 8874 # Calculate the version variables.
Chris@40 8875 major=
Chris@40 8876 versuffix=
Chris@40 8877 verstring=
Chris@40 8878 case $version_type in
Chris@40 8879 none) ;;
Chris@40 8880
Chris@40 8881 darwin)
Chris@40 8882 # Like Linux, but with the current version available in
Chris@40 8883 # verstring for coding it into the library header
Chris@40 8884 func_arith $current - $age
Chris@40 8885 major=.$func_arith_result
Chris@40 8886 versuffix=$major.$age.$revision
Chris@40 8887 # Darwin ld doesn't like 0 for these options...
Chris@40 8888 func_arith $current + 1
Chris@40 8889 minor_current=$func_arith_result
Chris@40 8890 xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
Chris@40 8891 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
Chris@40 8892 # On Darwin other compilers
Chris@40 8893 case $CC in
Chris@40 8894 nagfor*)
Chris@40 8895 verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
Chris@40 8896 ;;
Chris@40 8897 *)
Chris@40 8898 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
Chris@40 8899 ;;
Chris@40 8900 esac
Chris@40 8901 ;;
Chris@40 8902
Chris@40 8903 freebsd-aout)
Chris@40 8904 major=.$current
Chris@40 8905 versuffix=.$current.$revision
Chris@40 8906 ;;
Chris@40 8907
Chris@40 8908 freebsd-elf)
Chris@40 8909 func_arith $current - $age
Chris@40 8910 major=.$func_arith_result
Chris@40 8911 versuffix=$major.$age.$revision
Chris@40 8912 ;;
Chris@40 8913
Chris@40 8914 irix | nonstopux)
Chris@40 8915 if test no = "$lt_irix_increment"; then
Chris@40 8916 func_arith $current - $age
Chris@40 8917 else
Chris@40 8918 func_arith $current - $age + 1
Chris@40 8919 fi
Chris@40 8920 major=$func_arith_result
Chris@40 8921
Chris@40 8922 case $version_type in
Chris@40 8923 nonstopux) verstring_prefix=nonstopux ;;
Chris@40 8924 *) verstring_prefix=sgi ;;
Chris@40 8925 esac
Chris@40 8926 verstring=$verstring_prefix$major.$revision
Chris@40 8927
Chris@40 8928 # Add in all the interfaces that we are compatible with.
Chris@40 8929 loop=$revision
Chris@40 8930 while test 0 -ne "$loop"; do
Chris@40 8931 func_arith $revision - $loop
Chris@40 8932 iface=$func_arith_result
Chris@40 8933 func_arith $loop - 1
Chris@40 8934 loop=$func_arith_result
Chris@40 8935 verstring=$verstring_prefix$major.$iface:$verstring
Chris@40 8936 done
Chris@40 8937
Chris@40 8938 # Before this point, $major must not contain '.'.
Chris@40 8939 major=.$major
Chris@40 8940 versuffix=$major.$revision
Chris@40 8941 ;;
Chris@40 8942
Chris@40 8943 linux) # correct to gnu/linux during the next big refactor
Chris@40 8944 func_arith $current - $age
Chris@40 8945 major=.$func_arith_result
Chris@40 8946 versuffix=$major.$age.$revision
Chris@40 8947 ;;
Chris@40 8948
Chris@40 8949 osf)
Chris@40 8950 func_arith $current - $age
Chris@40 8951 major=.$func_arith_result
Chris@40 8952 versuffix=.$current.$age.$revision
Chris@40 8953 verstring=$current.$age.$revision
Chris@40 8954
Chris@40 8955 # Add in all the interfaces that we are compatible with.
Chris@40 8956 loop=$age
Chris@40 8957 while test 0 -ne "$loop"; do
Chris@40 8958 func_arith $current - $loop
Chris@40 8959 iface=$func_arith_result
Chris@40 8960 func_arith $loop - 1
Chris@40 8961 loop=$func_arith_result
Chris@40 8962 verstring=$verstring:$iface.0
Chris@40 8963 done
Chris@40 8964
Chris@40 8965 # Make executables depend on our current version.
Chris@40 8966 func_append verstring ":$current.0"
Chris@40 8967 ;;
Chris@40 8968
Chris@40 8969 qnx)
Chris@40 8970 major=.$current
Chris@40 8971 versuffix=.$current
Chris@40 8972 ;;
Chris@40 8973
Chris@40 8974 sco)
Chris@40 8975 major=.$current
Chris@40 8976 versuffix=.$current
Chris@40 8977 ;;
Chris@40 8978
Chris@40 8979 sunos)
Chris@40 8980 major=.$current
Chris@40 8981 versuffix=.$current.$revision
Chris@40 8982 ;;
Chris@40 8983
Chris@40 8984 windows)
Chris@40 8985 # Use '-' rather than '.', since we only want one
Chris@40 8986 # extension on DOS 8.3 file systems.
Chris@40 8987 func_arith $current - $age
Chris@40 8988 major=$func_arith_result
Chris@40 8989 versuffix=-$major
Chris@40 8990 ;;
Chris@40 8991
Chris@40 8992 *)
Chris@40 8993 func_fatal_configuration "unknown library version type '$version_type'"
Chris@40 8994 ;;
Chris@40 8995 esac
Chris@40 8996
Chris@40 8997 # Clear the version info if we defaulted, and they specified a release.
Chris@40 8998 if test -z "$vinfo" && test -n "$release"; then
Chris@40 8999 major=
Chris@40 9000 case $version_type in
Chris@40 9001 darwin)
Chris@40 9002 # we can't check for "0.0" in archive_cmds due to quoting
Chris@40 9003 # problems, so we reset it completely
Chris@40 9004 verstring=
Chris@40 9005 ;;
Chris@40 9006 *)
Chris@40 9007 verstring=0.0
Chris@40 9008 ;;
Chris@40 9009 esac
Chris@40 9010 if test no = "$need_version"; then
Chris@40 9011 versuffix=
Chris@40 9012 else
Chris@40 9013 versuffix=.0.0
Chris@40 9014 fi
Chris@40 9015 fi
Chris@40 9016
Chris@40 9017 # Remove version info from name if versioning should be avoided
Chris@40 9018 if test yes,no = "$avoid_version,$need_version"; then
Chris@40 9019 major=
Chris@40 9020 versuffix=
Chris@40 9021 verstring=
Chris@40 9022 fi
Chris@40 9023
Chris@40 9024 # Check to see if the archive will have undefined symbols.
Chris@40 9025 if test yes = "$allow_undefined"; then
Chris@40 9026 if test unsupported = "$allow_undefined_flag"; then
Chris@40 9027 if test yes = "$build_old_libs"; then
Chris@40 9028 func_warning "undefined symbols not allowed in $host shared libraries; building static only"
Chris@40 9029 build_libtool_libs=no
Chris@40 9030 else
Chris@40 9031 func_fatal_error "can't build $host shared library unless -no-undefined is specified"
Chris@40 9032 fi
Chris@40 9033 fi
Chris@40 9034 else
Chris@40 9035 # Don't allow undefined symbols.
Chris@40 9036 allow_undefined_flag=$no_undefined_flag
Chris@40 9037 fi
Chris@40 9038
Chris@40 9039 fi
Chris@40 9040
Chris@40 9041 func_generate_dlsyms "$libname" "$libname" :
Chris@40 9042 func_append libobjs " $symfileobj"
Chris@40 9043 test " " = "$libobjs" && libobjs=
Chris@40 9044
Chris@40 9045 if test relink != "$opt_mode"; then
Chris@40 9046 # Remove our outputs, but don't remove object files since they
Chris@40 9047 # may have been created when compiling PIC objects.
Chris@40 9048 removelist=
Chris@40 9049 tempremovelist=`$ECHO "$output_objdir/*"`
Chris@40 9050 for p in $tempremovelist; do
Chris@40 9051 case $p in
Chris@40 9052 *.$objext | *.gcno)
Chris@40 9053 ;;
Chris@40 9054 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
Chris@40 9055 if test -n "$precious_files_regex"; then
Chris@40 9056 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
Chris@40 9057 then
Chris@40 9058 continue
Chris@40 9059 fi
Chris@40 9060 fi
Chris@40 9061 func_append removelist " $p"
Chris@40 9062 ;;
Chris@40 9063 *) ;;
Chris@40 9064 esac
Chris@40 9065 done
Chris@40 9066 test -n "$removelist" && \
Chris@40 9067 func_show_eval "${RM}r \$removelist"
Chris@40 9068 fi
Chris@40 9069
Chris@40 9070 # Now set the variables for building old libraries.
Chris@40 9071 if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
Chris@40 9072 func_append oldlibs " $output_objdir/$libname.$libext"
Chris@40 9073
Chris@40 9074 # Transform .lo files to .o files.
Chris@40 9075 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
Chris@40 9076 fi
Chris@40 9077
Chris@40 9078 # Eliminate all temporary directories.
Chris@40 9079 #for path in $notinst_path; do
Chris@40 9080 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
Chris@40 9081 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
Chris@40 9082 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
Chris@40 9083 #done
Chris@40 9084
Chris@40 9085 if test -n "$xrpath"; then
Chris@40 9086 # If the user specified any rpath flags, then add them.
Chris@40 9087 temp_xrpath=
Chris@40 9088 for libdir in $xrpath; do
Chris@40 9089 func_replace_sysroot "$libdir"
Chris@40 9090 func_append temp_xrpath " -R$func_replace_sysroot_result"
Chris@40 9091 case "$finalize_rpath " in
Chris@40 9092 *" $libdir "*) ;;
Chris@40 9093 *) func_append finalize_rpath " $libdir" ;;
Chris@40 9094 esac
Chris@40 9095 done
Chris@40 9096 if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
Chris@40 9097 dependency_libs="$temp_xrpath $dependency_libs"
Chris@40 9098 fi
Chris@40 9099 fi
Chris@40 9100
Chris@40 9101 # Make sure dlfiles contains only unique files that won't be dlpreopened
Chris@40 9102 old_dlfiles=$dlfiles
Chris@40 9103 dlfiles=
Chris@40 9104 for lib in $old_dlfiles; do
Chris@40 9105 case " $dlprefiles $dlfiles " in
Chris@40 9106 *" $lib "*) ;;
Chris@40 9107 *) func_append dlfiles " $lib" ;;
Chris@40 9108 esac
Chris@40 9109 done
Chris@40 9110
Chris@40 9111 # Make sure dlprefiles contains only unique files
Chris@40 9112 old_dlprefiles=$dlprefiles
Chris@40 9113 dlprefiles=
Chris@40 9114 for lib in $old_dlprefiles; do
Chris@40 9115 case "$dlprefiles " in
Chris@40 9116 *" $lib "*) ;;
Chris@40 9117 *) func_append dlprefiles " $lib" ;;
Chris@40 9118 esac
Chris@40 9119 done
Chris@40 9120
Chris@40 9121 if test yes = "$build_libtool_libs"; then
Chris@40 9122 if test -n "$rpath"; then
Chris@40 9123 case $host in
Chris@40 9124 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
Chris@40 9125 # these systems don't actually have a c library (as such)!
Chris@40 9126 ;;
Chris@40 9127 *-*-rhapsody* | *-*-darwin1.[012])
Chris@40 9128 # Rhapsody C library is in the System framework
Chris@40 9129 func_append deplibs " System.ltframework"
Chris@40 9130 ;;
Chris@40 9131 *-*-netbsd*)
Chris@40 9132 # Don't link with libc until the a.out ld.so is fixed.
Chris@40 9133 ;;
Chris@40 9134 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
Chris@40 9135 # Do not include libc due to us having libc/libc_r.
Chris@40 9136 ;;
Chris@40 9137 *-*-sco3.2v5* | *-*-sco5v6*)
Chris@40 9138 # Causes problems with __ctype
Chris@40 9139 ;;
Chris@40 9140 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
Chris@40 9141 # Compiler inserts libc in the correct place for threads to work
Chris@40 9142 ;;
Chris@40 9143 *)
Chris@40 9144 # Add libc to deplibs on all other systems if necessary.
Chris@40 9145 if test yes = "$build_libtool_need_lc"; then
Chris@40 9146 func_append deplibs " -lc"
Chris@40 9147 fi
Chris@40 9148 ;;
Chris@40 9149 esac
Chris@40 9150 fi
Chris@40 9151
Chris@40 9152 # Transform deplibs into only deplibs that can be linked in shared.
Chris@40 9153 name_save=$name
Chris@40 9154 libname_save=$libname
Chris@40 9155 release_save=$release
Chris@40 9156 versuffix_save=$versuffix
Chris@40 9157 major_save=$major
Chris@40 9158 # I'm not sure if I'm treating the release correctly. I think
Chris@40 9159 # release should show up in the -l (ie -lgmp5) so we don't want to
Chris@40 9160 # add it in twice. Is that correct?
Chris@40 9161 release=
Chris@40 9162 versuffix=
Chris@40 9163 major=
Chris@40 9164 newdeplibs=
Chris@40 9165 droppeddeps=no
Chris@40 9166 case $deplibs_check_method in
Chris@40 9167 pass_all)
Chris@40 9168 # Don't check for shared/static. Everything works.
Chris@40 9169 # This might be a little naive. We might want to check
Chris@40 9170 # whether the library exists or not. But this is on
Chris@40 9171 # osf3 & osf4 and I'm not really sure... Just
Chris@40 9172 # implementing what was already the behavior.
Chris@40 9173 newdeplibs=$deplibs
Chris@40 9174 ;;
Chris@40 9175 test_compile)
Chris@40 9176 # This code stresses the "libraries are programs" paradigm to its
Chris@40 9177 # limits. Maybe even breaks it. We compile a program, linking it
Chris@40 9178 # against the deplibs as a proxy for the library. Then we can check
Chris@40 9179 # whether they linked in statically or dynamically with ldd.
Chris@40 9180 $opt_dry_run || $RM conftest.c
Chris@40 9181 cat > conftest.c <<EOF
Chris@40 9182 int main() { return 0; }
Chris@40 9183 EOF
Chris@40 9184 $opt_dry_run || $RM conftest
Chris@40 9185 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
Chris@40 9186 ldd_output=`ldd conftest`
Chris@40 9187 for i in $deplibs; do
Chris@40 9188 case $i in
Chris@40 9189 -l*)
Chris@40 9190 func_stripname -l '' "$i"
Chris@40 9191 name=$func_stripname_result
Chris@40 9192 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@40 9193 case " $predeps $postdeps " in
Chris@40 9194 *" $i "*)
Chris@40 9195 func_append newdeplibs " $i"
Chris@40 9196 i=
Chris@40 9197 ;;
Chris@40 9198 esac
Chris@40 9199 fi
Chris@40 9200 if test -n "$i"; then
Chris@40 9201 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@40 9202 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
Chris@40 9203 set dummy $deplib_matches; shift
Chris@40 9204 deplib_match=$1
Chris@40 9205 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
Chris@40 9206 func_append newdeplibs " $i"
Chris@40 9207 else
Chris@40 9208 droppeddeps=yes
Chris@40 9209 echo
Chris@40 9210 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
Chris@40 9211 echo "*** I have the capability to make that library automatically link in when"
Chris@40 9212 echo "*** you link to this library. But I can only do this if you have a"
Chris@40 9213 echo "*** shared version of the library, which I believe you do not have"
Chris@40 9214 echo "*** because a test_compile did reveal that the linker did not use it for"
Chris@40 9215 echo "*** its dynamic dependency list that programs get resolved with at runtime."
Chris@40 9216 fi
Chris@40 9217 fi
Chris@40 9218 ;;
Chris@40 9219 *)
Chris@40 9220 func_append newdeplibs " $i"
Chris@40 9221 ;;
Chris@40 9222 esac
Chris@40 9223 done
Chris@40 9224 else
Chris@40 9225 # Error occurred in the first compile. Let's try to salvage
Chris@40 9226 # the situation: Compile a separate program for each library.
Chris@40 9227 for i in $deplibs; do
Chris@40 9228 case $i in
Chris@40 9229 -l*)
Chris@40 9230 func_stripname -l '' "$i"
Chris@40 9231 name=$func_stripname_result
Chris@40 9232 $opt_dry_run || $RM conftest
Chris@40 9233 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
Chris@40 9234 ldd_output=`ldd conftest`
Chris@40 9235 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@40 9236 case " $predeps $postdeps " in
Chris@40 9237 *" $i "*)
Chris@40 9238 func_append newdeplibs " $i"
Chris@40 9239 i=
Chris@40 9240 ;;
Chris@40 9241 esac
Chris@40 9242 fi
Chris@40 9243 if test -n "$i"; then
Chris@40 9244 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@40 9245 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
Chris@40 9246 set dummy $deplib_matches; shift
Chris@40 9247 deplib_match=$1
Chris@40 9248 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
Chris@40 9249 func_append newdeplibs " $i"
Chris@40 9250 else
Chris@40 9251 droppeddeps=yes
Chris@40 9252 echo
Chris@40 9253 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
Chris@40 9254 echo "*** I have the capability to make that library automatically link in when"
Chris@40 9255 echo "*** you link to this library. But I can only do this if you have a"
Chris@40 9256 echo "*** shared version of the library, which you do not appear to have"
Chris@40 9257 echo "*** because a test_compile did reveal that the linker did not use this one"
Chris@40 9258 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
Chris@40 9259 fi
Chris@40 9260 fi
Chris@40 9261 else
Chris@40 9262 droppeddeps=yes
Chris@40 9263 echo
Chris@40 9264 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
Chris@40 9265 echo "*** make it link in! You will probably need to install it or some"
Chris@40 9266 echo "*** library that it depends on before this library will be fully"
Chris@40 9267 echo "*** functional. Installing it before continuing would be even better."
Chris@40 9268 fi
Chris@40 9269 ;;
Chris@40 9270 *)
Chris@40 9271 func_append newdeplibs " $i"
Chris@40 9272 ;;
Chris@40 9273 esac
Chris@40 9274 done
Chris@40 9275 fi
Chris@40 9276 ;;
Chris@40 9277 file_magic*)
Chris@40 9278 set dummy $deplibs_check_method; shift
Chris@40 9279 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Chris@40 9280 for a_deplib in $deplibs; do
Chris@40 9281 case $a_deplib in
Chris@40 9282 -l*)
Chris@40 9283 func_stripname -l '' "$a_deplib"
Chris@40 9284 name=$func_stripname_result
Chris@40 9285 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@40 9286 case " $predeps $postdeps " in
Chris@40 9287 *" $a_deplib "*)
Chris@40 9288 func_append newdeplibs " $a_deplib"
Chris@40 9289 a_deplib=
Chris@40 9290 ;;
Chris@40 9291 esac
Chris@40 9292 fi
Chris@40 9293 if test -n "$a_deplib"; then
Chris@40 9294 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@40 9295 if test -n "$file_magic_glob"; then
Chris@40 9296 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
Chris@40 9297 else
Chris@40 9298 libnameglob=$libname
Chris@40 9299 fi
Chris@40 9300 test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
Chris@40 9301 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
Chris@40 9302 if test yes = "$want_nocaseglob"; then
Chris@40 9303 shopt -s nocaseglob
Chris@40 9304 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
Chris@40 9305 $nocaseglob
Chris@40 9306 else
Chris@40 9307 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
Chris@40 9308 fi
Chris@40 9309 for potent_lib in $potential_libs; do
Chris@40 9310 # Follow soft links.
Chris@40 9311 if ls -lLd "$potent_lib" 2>/dev/null |
Chris@40 9312 $GREP " -> " >/dev/null; then
Chris@40 9313 continue
Chris@40 9314 fi
Chris@40 9315 # The statement above tries to avoid entering an
Chris@40 9316 # endless loop below, in case of cyclic links.
Chris@40 9317 # We might still enter an endless loop, since a link
Chris@40 9318 # loop can be closed while we follow links,
Chris@40 9319 # but so what?
Chris@40 9320 potlib=$potent_lib
Chris@40 9321 while test -h "$potlib" 2>/dev/null; do
Chris@40 9322 potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
Chris@40 9323 case $potliblink in
Chris@40 9324 [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
Chris@40 9325 *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
Chris@40 9326 esac
Chris@40 9327 done
Chris@40 9328 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
Chris@40 9329 $SED -e 10q |
Chris@40 9330 $EGREP "$file_magic_regex" > /dev/null; then
Chris@40 9331 func_append newdeplibs " $a_deplib"
Chris@40 9332 a_deplib=
Chris@40 9333 break 2
Chris@40 9334 fi
Chris@40 9335 done
Chris@40 9336 done
Chris@40 9337 fi
Chris@40 9338 if test -n "$a_deplib"; then
Chris@40 9339 droppeddeps=yes
Chris@40 9340 echo
Chris@40 9341 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
Chris@40 9342 echo "*** I have the capability to make that library automatically link in when"
Chris@40 9343 echo "*** you link to this library. But I can only do this if you have a"
Chris@40 9344 echo "*** shared version of the library, which you do not appear to have"
Chris@40 9345 echo "*** because I did check the linker path looking for a file starting"
Chris@40 9346 if test -z "$potlib"; then
Chris@40 9347 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
Chris@40 9348 else
Chris@40 9349 $ECHO "*** with $libname and none of the candidates passed a file format test"
Chris@40 9350 $ECHO "*** using a file magic. Last file checked: $potlib"
Chris@40 9351 fi
Chris@40 9352 fi
Chris@40 9353 ;;
Chris@40 9354 *)
Chris@40 9355 # Add a -L argument.
Chris@40 9356 func_append newdeplibs " $a_deplib"
Chris@40 9357 ;;
Chris@40 9358 esac
Chris@40 9359 done # Gone through all deplibs.
Chris@40 9360 ;;
Chris@40 9361 match_pattern*)
Chris@40 9362 set dummy $deplibs_check_method; shift
Chris@40 9363 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Chris@40 9364 for a_deplib in $deplibs; do
Chris@40 9365 case $a_deplib in
Chris@40 9366 -l*)
Chris@40 9367 func_stripname -l '' "$a_deplib"
Chris@40 9368 name=$func_stripname_result
Chris@40 9369 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@40 9370 case " $predeps $postdeps " in
Chris@40 9371 *" $a_deplib "*)
Chris@40 9372 func_append newdeplibs " $a_deplib"
Chris@40 9373 a_deplib=
Chris@40 9374 ;;
Chris@40 9375 esac
Chris@40 9376 fi
Chris@40 9377 if test -n "$a_deplib"; then
Chris@40 9378 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@40 9379 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
Chris@40 9380 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
Chris@40 9381 for potent_lib in $potential_libs; do
Chris@40 9382 potlib=$potent_lib # see symlink-check above in file_magic test
Chris@40 9383 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
Chris@40 9384 $EGREP "$match_pattern_regex" > /dev/null; then
Chris@40 9385 func_append newdeplibs " $a_deplib"
Chris@40 9386 a_deplib=
Chris@40 9387 break 2
Chris@40 9388 fi
Chris@40 9389 done
Chris@40 9390 done
Chris@40 9391 fi
Chris@40 9392 if test -n "$a_deplib"; then
Chris@40 9393 droppeddeps=yes
Chris@40 9394 echo
Chris@40 9395 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
Chris@40 9396 echo "*** I have the capability to make that library automatically link in when"
Chris@40 9397 echo "*** you link to this library. But I can only do this if you have a"
Chris@40 9398 echo "*** shared version of the library, which you do not appear to have"
Chris@40 9399 echo "*** because I did check the linker path looking for a file starting"
Chris@40 9400 if test -z "$potlib"; then
Chris@40 9401 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
Chris@40 9402 else
Chris@40 9403 $ECHO "*** with $libname and none of the candidates passed a file format test"
Chris@40 9404 $ECHO "*** using a regex pattern. Last file checked: $potlib"
Chris@40 9405 fi
Chris@40 9406 fi
Chris@40 9407 ;;
Chris@40 9408 *)
Chris@40 9409 # Add a -L argument.
Chris@40 9410 func_append newdeplibs " $a_deplib"
Chris@40 9411 ;;
Chris@40 9412 esac
Chris@40 9413 done # Gone through all deplibs.
Chris@40 9414 ;;
Chris@40 9415 none | unknown | *)
Chris@40 9416 newdeplibs=
Chris@40 9417 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
Chris@40 9418 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@40 9419 for i in $predeps $postdeps; do
Chris@40 9420 # can't use Xsed below, because $i might contain '/'
Chris@40 9421 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
Chris@40 9422 done
Chris@40 9423 fi
Chris@40 9424 case $tmp_deplibs in
Chris@40 9425 *[!\ \ ]*)
Chris@40 9426 echo
Chris@40 9427 if test none = "$deplibs_check_method"; then
Chris@40 9428 echo "*** Warning: inter-library dependencies are not supported in this platform."
Chris@40 9429 else
Chris@40 9430 echo "*** Warning: inter-library dependencies are not known to be supported."
Chris@40 9431 fi
Chris@40 9432 echo "*** All declared inter-library dependencies are being dropped."
Chris@40 9433 droppeddeps=yes
Chris@40 9434 ;;
Chris@40 9435 esac
Chris@40 9436 ;;
Chris@40 9437 esac
Chris@40 9438 versuffix=$versuffix_save
Chris@40 9439 major=$major_save
Chris@40 9440 release=$release_save
Chris@40 9441 libname=$libname_save
Chris@40 9442 name=$name_save
Chris@40 9443
Chris@40 9444 case $host in
Chris@40 9445 *-*-rhapsody* | *-*-darwin1.[012])
Chris@40 9446 # On Rhapsody replace the C library with the System framework
Chris@40 9447 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
Chris@40 9448 ;;
Chris@40 9449 esac
Chris@40 9450
Chris@40 9451 if test yes = "$droppeddeps"; then
Chris@40 9452 if test yes = "$module"; then
Chris@40 9453 echo
Chris@40 9454 echo "*** Warning: libtool could not satisfy all declared inter-library"
Chris@40 9455 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
Chris@40 9456 echo "*** a static module, that should work as long as the dlopening"
Chris@40 9457 echo "*** application is linked with the -dlopen flag."
Chris@40 9458 if test -z "$global_symbol_pipe"; then
Chris@40 9459 echo
Chris@40 9460 echo "*** However, this would only work if libtool was able to extract symbol"
Chris@40 9461 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
Chris@40 9462 echo "*** not find such a program. So, this module is probably useless."
Chris@40 9463 echo "*** 'nm' from GNU binutils and a full rebuild may help."
Chris@40 9464 fi
Chris@40 9465 if test no = "$build_old_libs"; then
Chris@40 9466 oldlibs=$output_objdir/$libname.$libext
Chris@40 9467 build_libtool_libs=module
Chris@40 9468 build_old_libs=yes
Chris@40 9469 else
Chris@40 9470 build_libtool_libs=no
Chris@40 9471 fi
Chris@40 9472 else
Chris@40 9473 echo "*** The inter-library dependencies that have been dropped here will be"
Chris@40 9474 echo "*** automatically added whenever a program is linked with this library"
Chris@40 9475 echo "*** or is declared to -dlopen it."
Chris@40 9476
Chris@40 9477 if test no = "$allow_undefined"; then
Chris@40 9478 echo
Chris@40 9479 echo "*** Since this library must not contain undefined symbols,"
Chris@40 9480 echo "*** because either the platform does not support them or"
Chris@40 9481 echo "*** it was explicitly requested with -no-undefined,"
Chris@40 9482 echo "*** libtool will only create a static version of it."
Chris@40 9483 if test no = "$build_old_libs"; then
Chris@40 9484 oldlibs=$output_objdir/$libname.$libext
Chris@40 9485 build_libtool_libs=module
Chris@40 9486 build_old_libs=yes
Chris@40 9487 else
Chris@40 9488 build_libtool_libs=no
Chris@40 9489 fi
Chris@40 9490 fi
Chris@40 9491 fi
Chris@40 9492 fi
Chris@40 9493 # Done checking deplibs!
Chris@40 9494 deplibs=$newdeplibs
Chris@40 9495 fi
Chris@40 9496 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
Chris@40 9497 case $host in
Chris@40 9498 *-*-darwin*)
Chris@40 9499 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@40 9500 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@40 9501 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@40 9502 ;;
Chris@40 9503 esac
Chris@40 9504
Chris@40 9505 # move library search paths that coincide with paths to not yet
Chris@40 9506 # installed libraries to the beginning of the library search list
Chris@40 9507 new_libs=
Chris@40 9508 for path in $notinst_path; do
Chris@40 9509 case " $new_libs " in
Chris@40 9510 *" -L$path/$objdir "*) ;;
Chris@40 9511 *)
Chris@40 9512 case " $deplibs " in
Chris@40 9513 *" -L$path/$objdir "*)
Chris@40 9514 func_append new_libs " -L$path/$objdir" ;;
Chris@40 9515 esac
Chris@40 9516 ;;
Chris@40 9517 esac
Chris@40 9518 done
Chris@40 9519 for deplib in $deplibs; do
Chris@40 9520 case $deplib in
Chris@40 9521 -L*)
Chris@40 9522 case " $new_libs " in
Chris@40 9523 *" $deplib "*) ;;
Chris@40 9524 *) func_append new_libs " $deplib" ;;
Chris@40 9525 esac
Chris@40 9526 ;;
Chris@40 9527 *) func_append new_libs " $deplib" ;;
Chris@40 9528 esac
Chris@40 9529 done
Chris@40 9530 deplibs=$new_libs
Chris@40 9531
Chris@40 9532 # All the library-specific variables (install_libdir is set above).
Chris@40 9533 library_names=
Chris@40 9534 old_library=
Chris@40 9535 dlname=
Chris@40 9536
Chris@40 9537 # Test again, we may have decided not to build it any more
Chris@40 9538 if test yes = "$build_libtool_libs"; then
Chris@40 9539 # Remove $wl instances when linking with ld.
Chris@40 9540 # FIXME: should test the right _cmds variable.
Chris@40 9541 case $archive_cmds in
Chris@40 9542 *\$LD\ *) wl= ;;
Chris@40 9543 esac
Chris@40 9544 if test yes = "$hardcode_into_libs"; then
Chris@40 9545 # Hardcode the library paths
Chris@40 9546 hardcode_libdirs=
Chris@40 9547 dep_rpath=
Chris@40 9548 rpath=$finalize_rpath
Chris@40 9549 test relink = "$opt_mode" || rpath=$compile_rpath$rpath
Chris@40 9550 for libdir in $rpath; do
Chris@40 9551 if test -n "$hardcode_libdir_flag_spec"; then
Chris@40 9552 if test -n "$hardcode_libdir_separator"; then
Chris@40 9553 func_replace_sysroot "$libdir"
Chris@40 9554 libdir=$func_replace_sysroot_result
Chris@40 9555 if test -z "$hardcode_libdirs"; then
Chris@40 9556 hardcode_libdirs=$libdir
Chris@40 9557 else
Chris@40 9558 # Just accumulate the unique libdirs.
Chris@40 9559 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Chris@40 9560 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
Chris@40 9561 ;;
Chris@40 9562 *)
Chris@40 9563 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
Chris@40 9564 ;;
Chris@40 9565 esac
Chris@40 9566 fi
Chris@40 9567 else
Chris@40 9568 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@40 9569 func_append dep_rpath " $flag"
Chris@40 9570 fi
Chris@40 9571 elif test -n "$runpath_var"; then
Chris@40 9572 case "$perm_rpath " in
Chris@40 9573 *" $libdir "*) ;;
Chris@40 9574 *) func_append perm_rpath " $libdir" ;;
Chris@40 9575 esac
Chris@40 9576 fi
Chris@40 9577 done
Chris@40 9578 # Substitute the hardcoded libdirs into the rpath.
Chris@40 9579 if test -n "$hardcode_libdir_separator" &&
Chris@40 9580 test -n "$hardcode_libdirs"; then
Chris@40 9581 libdir=$hardcode_libdirs
Chris@40 9582 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
Chris@40 9583 fi
Chris@40 9584 if test -n "$runpath_var" && test -n "$perm_rpath"; then
Chris@40 9585 # We should set the runpath_var.
Chris@40 9586 rpath=
Chris@40 9587 for dir in $perm_rpath; do
Chris@40 9588 func_append rpath "$dir:"
Chris@40 9589 done
Chris@40 9590 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
Chris@40 9591 fi
Chris@40 9592 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
Chris@40 9593 fi
Chris@40 9594
Chris@40 9595 shlibpath=$finalize_shlibpath
Chris@40 9596 test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
Chris@40 9597 if test -n "$shlibpath"; then
Chris@40 9598 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
Chris@40 9599 fi
Chris@40 9600
Chris@40 9601 # Get the real and link names of the library.
Chris@40 9602 eval shared_ext=\"$shrext_cmds\"
Chris@40 9603 eval library_names=\"$library_names_spec\"
Chris@40 9604 set dummy $library_names
Chris@40 9605 shift
Chris@40 9606 realname=$1
Chris@40 9607 shift
Chris@40 9608
Chris@40 9609 if test -n "$soname_spec"; then
Chris@40 9610 eval soname=\"$soname_spec\"
Chris@40 9611 else
Chris@40 9612 soname=$realname
Chris@40 9613 fi
Chris@40 9614 if test -z "$dlname"; then
Chris@40 9615 dlname=$soname
Chris@40 9616 fi
Chris@40 9617
Chris@40 9618 lib=$output_objdir/$realname
Chris@40 9619 linknames=
Chris@40 9620 for link
Chris@40 9621 do
Chris@40 9622 func_append linknames " $link"
Chris@40 9623 done
Chris@40 9624
Chris@40 9625 # Use standard objects if they are pic
Chris@40 9626 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@40 9627 test "X$libobjs" = "X " && libobjs=
Chris@40 9628
Chris@40 9629 delfiles=
Chris@40 9630 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Chris@40 9631 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
Chris@40 9632 export_symbols=$output_objdir/$libname.uexp
Chris@40 9633 func_append delfiles " $export_symbols"
Chris@40 9634 fi
Chris@40 9635
Chris@40 9636 orig_export_symbols=
Chris@40 9637 case $host_os in
Chris@40 9638 cygwin* | mingw* | cegcc*)
Chris@40 9639 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
Chris@40 9640 # exporting using user supplied symfile
Chris@40 9641 func_dll_def_p "$export_symbols" || {
Chris@40 9642 # and it's NOT already a .def file. Must figure out
Chris@40 9643 # which of the given symbols are data symbols and tag
Chris@40 9644 # them as such. So, trigger use of export_symbols_cmds.
Chris@40 9645 # export_symbols gets reassigned inside the "prepare
Chris@40 9646 # the list of exported symbols" if statement, so the
Chris@40 9647 # include_expsyms logic still works.
Chris@40 9648 orig_export_symbols=$export_symbols
Chris@40 9649 export_symbols=
Chris@40 9650 always_export_symbols=yes
Chris@40 9651 }
Chris@40 9652 fi
Chris@40 9653 ;;
Chris@40 9654 esac
Chris@40 9655
Chris@40 9656 # Prepare the list of exported symbols
Chris@40 9657 if test -z "$export_symbols"; then
Chris@40 9658 if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
Chris@40 9659 func_verbose "generating symbol list for '$libname.la'"
Chris@40 9660 export_symbols=$output_objdir/$libname.exp
Chris@40 9661 $opt_dry_run || $RM $export_symbols
Chris@40 9662 cmds=$export_symbols_cmds
Chris@40 9663 save_ifs=$IFS; IFS='~'
Chris@40 9664 for cmd1 in $cmds; do
Chris@40 9665 IFS=$save_ifs
Chris@40 9666 # Take the normal branch if the nm_file_list_spec branch
Chris@40 9667 # doesn't work or if tool conversion is not needed.
Chris@40 9668 case $nm_file_list_spec~$to_tool_file_cmd in
Chris@40 9669 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
Chris@40 9670 try_normal_branch=yes
Chris@40 9671 eval cmd=\"$cmd1\"
Chris@40 9672 func_len " $cmd"
Chris@40 9673 len=$func_len_result
Chris@40 9674 ;;
Chris@40 9675 *)
Chris@40 9676 try_normal_branch=no
Chris@40 9677 ;;
Chris@40 9678 esac
Chris@40 9679 if test yes = "$try_normal_branch" \
Chris@40 9680 && { test "$len" -lt "$max_cmd_len" \
Chris@40 9681 || test "$max_cmd_len" -le -1; }
Chris@40 9682 then
Chris@40 9683 func_show_eval "$cmd" 'exit $?'
Chris@40 9684 skipped_export=false
Chris@40 9685 elif test -n "$nm_file_list_spec"; then
Chris@40 9686 func_basename "$output"
Chris@40 9687 output_la=$func_basename_result
Chris@40 9688 save_libobjs=$libobjs
Chris@40 9689 save_output=$output
Chris@40 9690 output=$output_objdir/$output_la.nm
Chris@40 9691 func_to_tool_file "$output"
Chris@40 9692 libobjs=$nm_file_list_spec$func_to_tool_file_result
Chris@40 9693 func_append delfiles " $output"
Chris@40 9694 func_verbose "creating $NM input file list: $output"
Chris@40 9695 for obj in $save_libobjs; do
Chris@40 9696 func_to_tool_file "$obj"
Chris@40 9697 $ECHO "$func_to_tool_file_result"
Chris@40 9698 done > "$output"
Chris@40 9699 eval cmd=\"$cmd1\"
Chris@40 9700 func_show_eval "$cmd" 'exit $?'
Chris@40 9701 output=$save_output
Chris@40 9702 libobjs=$save_libobjs
Chris@40 9703 skipped_export=false
Chris@40 9704 else
Chris@40 9705 # The command line is too long to execute in one step.
Chris@40 9706 func_verbose "using reloadable object file for export list..."
Chris@40 9707 skipped_export=:
Chris@40 9708 # Break out early, otherwise skipped_export may be
Chris@40 9709 # set to false by a later but shorter cmd.
Chris@40 9710 break
Chris@40 9711 fi
Chris@40 9712 done
Chris@40 9713 IFS=$save_ifs
Chris@40 9714 if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
Chris@40 9715 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
Chris@40 9716 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
Chris@40 9717 fi
Chris@40 9718 fi
Chris@40 9719 fi
Chris@40 9720
Chris@40 9721 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Chris@40 9722 tmp_export_symbols=$export_symbols
Chris@40 9723 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
Chris@40 9724 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
Chris@40 9725 fi
Chris@40 9726
Chris@40 9727 if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
Chris@40 9728 # The given exports_symbols file has to be filtered, so filter it.
Chris@40 9729 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
Chris@40 9730 # FIXME: $output_objdir/$libname.filter potentially contains lots of
Chris@40 9731 # 's' commands, which not all seds can handle. GNU sed should be fine
Chris@40 9732 # though. Also, the filter scales superlinearly with the number of
Chris@40 9733 # global variables. join(1) would be nice here, but unfortunately
Chris@40 9734 # isn't a blessed tool.
Chris@40 9735 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
Chris@40 9736 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
Chris@40 9737 export_symbols=$output_objdir/$libname.def
Chris@40 9738 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
Chris@40 9739 fi
Chris@40 9740
Chris@40 9741 tmp_deplibs=
Chris@40 9742 for test_deplib in $deplibs; do
Chris@40 9743 case " $convenience " in
Chris@40 9744 *" $test_deplib "*) ;;
Chris@40 9745 *)
Chris@40 9746 func_append tmp_deplibs " $test_deplib"
Chris@40 9747 ;;
Chris@40 9748 esac
Chris@40 9749 done
Chris@40 9750 deplibs=$tmp_deplibs
Chris@40 9751
Chris@40 9752 if test -n "$convenience"; then
Chris@40 9753 if test -n "$whole_archive_flag_spec" &&
Chris@40 9754 test yes = "$compiler_needs_object" &&
Chris@40 9755 test -z "$libobjs"; then
Chris@40 9756 # extract the archives, so we have objects to list.
Chris@40 9757 # TODO: could optimize this to just extract one archive.
Chris@40 9758 whole_archive_flag_spec=
Chris@40 9759 fi
Chris@40 9760 if test -n "$whole_archive_flag_spec"; then
Chris@40 9761 save_libobjs=$libobjs
Chris@40 9762 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
Chris@40 9763 test "X$libobjs" = "X " && libobjs=
Chris@40 9764 else
Chris@40 9765 gentop=$output_objdir/${outputname}x
Chris@40 9766 func_append generated " $gentop"
Chris@40 9767
Chris@40 9768 func_extract_archives $gentop $convenience
Chris@40 9769 func_append libobjs " $func_extract_archives_result"
Chris@40 9770 test "X$libobjs" = "X " && libobjs=
Chris@40 9771 fi
Chris@40 9772 fi
Chris@40 9773
Chris@40 9774 if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
Chris@40 9775 eval flag=\"$thread_safe_flag_spec\"
Chris@40 9776 func_append linker_flags " $flag"
Chris@40 9777 fi
Chris@40 9778
Chris@40 9779 # Make a backup of the uninstalled library when relinking
Chris@40 9780 if test relink = "$opt_mode"; then
Chris@40 9781 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
Chris@40 9782 fi
Chris@40 9783
Chris@40 9784 # Do each of the archive commands.
Chris@40 9785 if test yes = "$module" && test -n "$module_cmds"; then
Chris@40 9786 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
Chris@40 9787 eval test_cmds=\"$module_expsym_cmds\"
Chris@40 9788 cmds=$module_expsym_cmds
Chris@40 9789 else
Chris@40 9790 eval test_cmds=\"$module_cmds\"
Chris@40 9791 cmds=$module_cmds
Chris@40 9792 fi
Chris@40 9793 else
Chris@40 9794 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
Chris@40 9795 eval test_cmds=\"$archive_expsym_cmds\"
Chris@40 9796 cmds=$archive_expsym_cmds
Chris@40 9797 else
Chris@40 9798 eval test_cmds=\"$archive_cmds\"
Chris@40 9799 cmds=$archive_cmds
Chris@40 9800 fi
Chris@40 9801 fi
Chris@40 9802
Chris@40 9803 if test : != "$skipped_export" &&
Chris@40 9804 func_len " $test_cmds" &&
Chris@40 9805 len=$func_len_result &&
Chris@40 9806 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
Chris@40 9807 :
Chris@40 9808 else
Chris@40 9809 # The command line is too long to link in one step, link piecewise
Chris@40 9810 # or, if using GNU ld and skipped_export is not :, use a linker
Chris@40 9811 # script.
Chris@40 9812
Chris@40 9813 # Save the value of $output and $libobjs because we want to
Chris@40 9814 # use them later. If we have whole_archive_flag_spec, we
Chris@40 9815 # want to use save_libobjs as it was before
Chris@40 9816 # whole_archive_flag_spec was expanded, because we can't
Chris@40 9817 # assume the linker understands whole_archive_flag_spec.
Chris@40 9818 # This may have to be revisited, in case too many
Chris@40 9819 # convenience libraries get linked in and end up exceeding
Chris@40 9820 # the spec.
Chris@40 9821 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
Chris@40 9822 save_libobjs=$libobjs
Chris@40 9823 fi
Chris@40 9824 save_output=$output
Chris@40 9825 func_basename "$output"
Chris@40 9826 output_la=$func_basename_result
Chris@40 9827
Chris@40 9828 # Clear the reloadable object creation command queue and
Chris@40 9829 # initialize k to one.
Chris@40 9830 test_cmds=
Chris@40 9831 concat_cmds=
Chris@40 9832 objlist=
Chris@40 9833 last_robj=
Chris@40 9834 k=1
Chris@40 9835
Chris@40 9836 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
Chris@40 9837 output=$output_objdir/$output_la.lnkscript
Chris@40 9838 func_verbose "creating GNU ld script: $output"
Chris@40 9839 echo 'INPUT (' > $output
Chris@40 9840 for obj in $save_libobjs
Chris@40 9841 do
Chris@40 9842 func_to_tool_file "$obj"
Chris@40 9843 $ECHO "$func_to_tool_file_result" >> $output
Chris@40 9844 done
Chris@40 9845 echo ')' >> $output
Chris@40 9846 func_append delfiles " $output"
Chris@40 9847 func_to_tool_file "$output"
Chris@40 9848 output=$func_to_tool_file_result
Chris@40 9849 elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
Chris@40 9850 output=$output_objdir/$output_la.lnk
Chris@40 9851 func_verbose "creating linker input file list: $output"
Chris@40 9852 : > $output
Chris@40 9853 set x $save_libobjs
Chris@40 9854 shift
Chris@40 9855 firstobj=
Chris@40 9856 if test yes = "$compiler_needs_object"; then
Chris@40 9857 firstobj="$1 "
Chris@40 9858 shift
Chris@40 9859 fi
Chris@40 9860 for obj
Chris@40 9861 do
Chris@40 9862 func_to_tool_file "$obj"
Chris@40 9863 $ECHO "$func_to_tool_file_result" >> $output
Chris@40 9864 done
Chris@40 9865 func_append delfiles " $output"
Chris@40 9866 func_to_tool_file "$output"
Chris@40 9867 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
Chris@40 9868 else
Chris@40 9869 if test -n "$save_libobjs"; then
Chris@40 9870 func_verbose "creating reloadable object files..."
Chris@40 9871 output=$output_objdir/$output_la-$k.$objext
Chris@40 9872 eval test_cmds=\"$reload_cmds\"
Chris@40 9873 func_len " $test_cmds"
Chris@40 9874 len0=$func_len_result
Chris@40 9875 len=$len0
Chris@40 9876
Chris@40 9877 # Loop over the list of objects to be linked.
Chris@40 9878 for obj in $save_libobjs
Chris@40 9879 do
Chris@40 9880 func_len " $obj"
Chris@40 9881 func_arith $len + $func_len_result
Chris@40 9882 len=$func_arith_result
Chris@40 9883 if test -z "$objlist" ||
Chris@40 9884 test "$len" -lt "$max_cmd_len"; then
Chris@40 9885 func_append objlist " $obj"
Chris@40 9886 else
Chris@40 9887 # The command $test_cmds is almost too long, add a
Chris@40 9888 # command to the queue.
Chris@40 9889 if test 1 -eq "$k"; then
Chris@40 9890 # The first file doesn't have a previous command to add.
Chris@40 9891 reload_objs=$objlist
Chris@40 9892 eval concat_cmds=\"$reload_cmds\"
Chris@40 9893 else
Chris@40 9894 # All subsequent reloadable object files will link in
Chris@40 9895 # the last one created.
Chris@40 9896 reload_objs="$objlist $last_robj"
Chris@40 9897 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
Chris@40 9898 fi
Chris@40 9899 last_robj=$output_objdir/$output_la-$k.$objext
Chris@40 9900 func_arith $k + 1
Chris@40 9901 k=$func_arith_result
Chris@40 9902 output=$output_objdir/$output_la-$k.$objext
Chris@40 9903 objlist=" $obj"
Chris@40 9904 func_len " $last_robj"
Chris@40 9905 func_arith $len0 + $func_len_result
Chris@40 9906 len=$func_arith_result
Chris@40 9907 fi
Chris@40 9908 done
Chris@40 9909 # Handle the remaining objects by creating one last
Chris@40 9910 # reloadable object file. All subsequent reloadable object
Chris@40 9911 # files will link in the last one created.
Chris@40 9912 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Chris@40 9913 reload_objs="$objlist $last_robj"
Chris@40 9914 eval concat_cmds=\"\$concat_cmds$reload_cmds\"
Chris@40 9915 if test -n "$last_robj"; then
Chris@40 9916 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
Chris@40 9917 fi
Chris@40 9918 func_append delfiles " $output"
Chris@40 9919
Chris@40 9920 else
Chris@40 9921 output=
Chris@40 9922 fi
Chris@40 9923
Chris@40 9924 ${skipped_export-false} && {
Chris@40 9925 func_verbose "generating symbol list for '$libname.la'"
Chris@40 9926 export_symbols=$output_objdir/$libname.exp
Chris@40 9927 $opt_dry_run || $RM $export_symbols
Chris@40 9928 libobjs=$output
Chris@40 9929 # Append the command to create the export file.
Chris@40 9930 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Chris@40 9931 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
Chris@40 9932 if test -n "$last_robj"; then
Chris@40 9933 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
Chris@40 9934 fi
Chris@40 9935 }
Chris@40 9936
Chris@40 9937 test -n "$save_libobjs" &&
Chris@40 9938 func_verbose "creating a temporary reloadable object file: $output"
Chris@40 9939
Chris@40 9940 # Loop through the commands generated above and execute them.
Chris@40 9941 save_ifs=$IFS; IFS='~'
Chris@40 9942 for cmd in $concat_cmds; do
Chris@40 9943 IFS=$save_ifs
Chris@40 9944 $opt_quiet || {
Chris@40 9945 func_quote_for_expand "$cmd"
Chris@40 9946 eval "func_echo $func_quote_for_expand_result"
Chris@40 9947 }
Chris@40 9948 $opt_dry_run || eval "$cmd" || {
Chris@40 9949 lt_exit=$?
Chris@40 9950
Chris@40 9951 # Restore the uninstalled library and exit
Chris@40 9952 if test relink = "$opt_mode"; then
Chris@40 9953 ( cd "$output_objdir" && \
Chris@40 9954 $RM "${realname}T" && \
Chris@40 9955 $MV "${realname}U" "$realname" )
Chris@40 9956 fi
Chris@40 9957
Chris@40 9958 exit $lt_exit
Chris@40 9959 }
Chris@40 9960 done
Chris@40 9961 IFS=$save_ifs
Chris@40 9962
Chris@40 9963 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
Chris@40 9964 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
Chris@40 9965 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
Chris@40 9966 fi
Chris@40 9967 fi
Chris@40 9968
Chris@40 9969 ${skipped_export-false} && {
Chris@40 9970 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Chris@40 9971 tmp_export_symbols=$export_symbols
Chris@40 9972 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
Chris@40 9973 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
Chris@40 9974 fi
Chris@40 9975
Chris@40 9976 if test -n "$orig_export_symbols"; then
Chris@40 9977 # The given exports_symbols file has to be filtered, so filter it.
Chris@40 9978 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
Chris@40 9979 # FIXME: $output_objdir/$libname.filter potentially contains lots of
Chris@40 9980 # 's' commands, which not all seds can handle. GNU sed should be fine
Chris@40 9981 # though. Also, the filter scales superlinearly with the number of
Chris@40 9982 # global variables. join(1) would be nice here, but unfortunately
Chris@40 9983 # isn't a blessed tool.
Chris@40 9984 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
Chris@40 9985 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
Chris@40 9986 export_symbols=$output_objdir/$libname.def
Chris@40 9987 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
Chris@40 9988 fi
Chris@40 9989 }
Chris@40 9990
Chris@40 9991 libobjs=$output
Chris@40 9992 # Restore the value of output.
Chris@40 9993 output=$save_output
Chris@40 9994
Chris@40 9995 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
Chris@40 9996 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
Chris@40 9997 test "X$libobjs" = "X " && libobjs=
Chris@40 9998 fi
Chris@40 9999 # Expand the library linking commands again to reset the
Chris@40 10000 # value of $libobjs for piecewise linking.
Chris@40 10001
Chris@40 10002 # Do each of the archive commands.
Chris@40 10003 if test yes = "$module" && test -n "$module_cmds"; then
Chris@40 10004 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
Chris@40 10005 cmds=$module_expsym_cmds
Chris@40 10006 else
Chris@40 10007 cmds=$module_cmds
Chris@40 10008 fi
Chris@40 10009 else
Chris@40 10010 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
Chris@40 10011 cmds=$archive_expsym_cmds
Chris@40 10012 else
Chris@40 10013 cmds=$archive_cmds
Chris@40 10014 fi
Chris@40 10015 fi
Chris@40 10016 fi
Chris@40 10017
Chris@40 10018 if test -n "$delfiles"; then
Chris@40 10019 # Append the command to remove temporary files to $cmds.
Chris@40 10020 eval cmds=\"\$cmds~\$RM $delfiles\"
Chris@40 10021 fi
Chris@40 10022
Chris@40 10023 # Add any objects from preloaded convenience libraries
Chris@40 10024 if test -n "$dlprefiles"; then
Chris@40 10025 gentop=$output_objdir/${outputname}x
Chris@40 10026 func_append generated " $gentop"
Chris@40 10027
Chris@40 10028 func_extract_archives $gentop $dlprefiles
Chris@40 10029 func_append libobjs " $func_extract_archives_result"
Chris@40 10030 test "X$libobjs" = "X " && libobjs=
Chris@40 10031 fi
Chris@40 10032
Chris@40 10033 save_ifs=$IFS; IFS='~'
Chris@40 10034 for cmd in $cmds; do
Chris@40 10035 IFS=$sp$nl
Chris@40 10036 eval cmd=\"$cmd\"
Chris@40 10037 IFS=$save_ifs
Chris@40 10038 $opt_quiet || {
Chris@40 10039 func_quote_for_expand "$cmd"
Chris@40 10040 eval "func_echo $func_quote_for_expand_result"
Chris@40 10041 }
Chris@40 10042 $opt_dry_run || eval "$cmd" || {
Chris@40 10043 lt_exit=$?
Chris@40 10044
Chris@40 10045 # Restore the uninstalled library and exit
Chris@40 10046 if test relink = "$opt_mode"; then
Chris@40 10047 ( cd "$output_objdir" && \
Chris@40 10048 $RM "${realname}T" && \
Chris@40 10049 $MV "${realname}U" "$realname" )
Chris@40 10050 fi
Chris@40 10051
Chris@40 10052 exit $lt_exit
Chris@40 10053 }
Chris@40 10054 done
Chris@40 10055 IFS=$save_ifs
Chris@40 10056
Chris@40 10057 # Restore the uninstalled library and exit
Chris@40 10058 if test relink = "$opt_mode"; then
Chris@40 10059 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
Chris@40 10060
Chris@40 10061 if test -n "$convenience"; then
Chris@40 10062 if test -z "$whole_archive_flag_spec"; then
Chris@40 10063 func_show_eval '${RM}r "$gentop"'
Chris@40 10064 fi
Chris@40 10065 fi
Chris@40 10066
Chris@40 10067 exit $EXIT_SUCCESS
Chris@40 10068 fi
Chris@40 10069
Chris@40 10070 # Create links to the real library.
Chris@40 10071 for linkname in $linknames; do
Chris@40 10072 if test "$realname" != "$linkname"; then
Chris@40 10073 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
Chris@40 10074 fi
Chris@40 10075 done
Chris@40 10076
Chris@40 10077 # If -module or -export-dynamic was specified, set the dlname.
Chris@40 10078 if test yes = "$module" || test yes = "$export_dynamic"; then
Chris@40 10079 # On all known operating systems, these are identical.
Chris@40 10080 dlname=$soname
Chris@40 10081 fi
Chris@40 10082 fi
Chris@40 10083 ;;
Chris@40 10084
Chris@40 10085 obj)
Chris@40 10086 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
Chris@40 10087 func_warning "'-dlopen' is ignored for objects"
Chris@40 10088 fi
Chris@40 10089
Chris@40 10090 case " $deplibs" in
Chris@40 10091 *\ -l* | *\ -L*)
Chris@40 10092 func_warning "'-l' and '-L' are ignored for objects" ;;
Chris@40 10093 esac
Chris@40 10094
Chris@40 10095 test -n "$rpath" && \
Chris@40 10096 func_warning "'-rpath' is ignored for objects"
Chris@40 10097
Chris@40 10098 test -n "$xrpath" && \
Chris@40 10099 func_warning "'-R' is ignored for objects"
Chris@40 10100
Chris@40 10101 test -n "$vinfo" && \
Chris@40 10102 func_warning "'-version-info' is ignored for objects"
Chris@40 10103
Chris@40 10104 test -n "$release" && \
Chris@40 10105 func_warning "'-release' is ignored for objects"
Chris@40 10106
Chris@40 10107 case $output in
Chris@40 10108 *.lo)
Chris@40 10109 test -n "$objs$old_deplibs" && \
Chris@40 10110 func_fatal_error "cannot build library object '$output' from non-libtool objects"
Chris@40 10111
Chris@40 10112 libobj=$output
Chris@40 10113 func_lo2o "$libobj"
Chris@40 10114 obj=$func_lo2o_result
Chris@40 10115 ;;
Chris@40 10116 *)
Chris@40 10117 libobj=
Chris@40 10118 obj=$output
Chris@40 10119 ;;
Chris@40 10120 esac
Chris@40 10121
Chris@40 10122 # Delete the old objects.
Chris@40 10123 $opt_dry_run || $RM $obj $libobj
Chris@40 10124
Chris@40 10125 # Objects from convenience libraries. This assumes
Chris@40 10126 # single-version convenience libraries. Whenever we create
Chris@40 10127 # different ones for PIC/non-PIC, this we'll have to duplicate
Chris@40 10128 # the extraction.
Chris@40 10129 reload_conv_objs=
Chris@40 10130 gentop=
Chris@40 10131 # if reload_cmds runs $LD directly, get rid of -Wl from
Chris@40 10132 # whole_archive_flag_spec and hope we can get by with turning comma
Chris@40 10133 # into space.
Chris@40 10134 case $reload_cmds in
Chris@40 10135 *\$LD[\ \$]*) wl= ;;
Chris@40 10136 esac
Chris@40 10137 if test -n "$convenience"; then
Chris@40 10138 if test -n "$whole_archive_flag_spec"; then
Chris@40 10139 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
Chris@40 10140 test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
Chris@40 10141 reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
Chris@40 10142 else
Chris@40 10143 gentop=$output_objdir/${obj}x
Chris@40 10144 func_append generated " $gentop"
Chris@40 10145
Chris@40 10146 func_extract_archives $gentop $convenience
Chris@40 10147 reload_conv_objs="$reload_objs $func_extract_archives_result"
Chris@40 10148 fi
Chris@40 10149 fi
Chris@40 10150
Chris@40 10151 # If we're not building shared, we need to use non_pic_objs
Chris@40 10152 test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
Chris@40 10153
Chris@40 10154 # Create the old-style object.
Chris@40 10155 reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
Chris@40 10156
Chris@40 10157 output=$obj
Chris@40 10158 func_execute_cmds "$reload_cmds" 'exit $?'
Chris@40 10159
Chris@40 10160 # Exit if we aren't doing a library object file.
Chris@40 10161 if test -z "$libobj"; then
Chris@40 10162 if test -n "$gentop"; then
Chris@40 10163 func_show_eval '${RM}r "$gentop"'
Chris@40 10164 fi
Chris@40 10165
Chris@40 10166 exit $EXIT_SUCCESS
Chris@40 10167 fi
Chris@40 10168
Chris@40 10169 test yes = "$build_libtool_libs" || {
Chris@40 10170 if test -n "$gentop"; then
Chris@40 10171 func_show_eval '${RM}r "$gentop"'
Chris@40 10172 fi
Chris@40 10173
Chris@40 10174 # Create an invalid libtool object if no PIC, so that we don't
Chris@40 10175 # accidentally link it into a program.
Chris@40 10176 # $show "echo timestamp > $libobj"
Chris@40 10177 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
Chris@40 10178 exit $EXIT_SUCCESS
Chris@40 10179 }
Chris@40 10180
Chris@40 10181 if test -n "$pic_flag" || test default != "$pic_mode"; then
Chris@40 10182 # Only do commands if we really have different PIC objects.
Chris@40 10183 reload_objs="$libobjs $reload_conv_objs"
Chris@40 10184 output=$libobj
Chris@40 10185 func_execute_cmds "$reload_cmds" 'exit $?'
Chris@40 10186 fi
Chris@40 10187
Chris@40 10188 if test -n "$gentop"; then
Chris@40 10189 func_show_eval '${RM}r "$gentop"'
Chris@40 10190 fi
Chris@40 10191
Chris@40 10192 exit $EXIT_SUCCESS
Chris@40 10193 ;;
Chris@40 10194
Chris@40 10195 prog)
Chris@40 10196 case $host in
Chris@40 10197 *cygwin*) func_stripname '' '.exe' "$output"
Chris@40 10198 output=$func_stripname_result.exe;;
Chris@40 10199 esac
Chris@40 10200 test -n "$vinfo" && \
Chris@40 10201 func_warning "'-version-info' is ignored for programs"
Chris@40 10202
Chris@40 10203 test -n "$release" && \
Chris@40 10204 func_warning "'-release' is ignored for programs"
Chris@40 10205
Chris@40 10206 $preload \
Chris@40 10207 && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
Chris@40 10208 && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
Chris@40 10209
Chris@40 10210 case $host in
Chris@40 10211 *-*-rhapsody* | *-*-darwin1.[012])
Chris@40 10212 # On Rhapsody replace the C library is the System framework
Chris@40 10213 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
Chris@40 10214 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
Chris@40 10215 ;;
Chris@40 10216 esac
Chris@40 10217
Chris@40 10218 case $host in
Chris@40 10219 *-*-darwin*)
Chris@40 10220 # Don't allow lazy linking, it breaks C++ global constructors
Chris@40 10221 # But is supposedly fixed on 10.4 or later (yay!).
Chris@40 10222 if test CXX = "$tagname"; then
Chris@40 10223 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
Chris@40 10224 10.[0123])
Chris@40 10225 func_append compile_command " $wl-bind_at_load"
Chris@40 10226 func_append finalize_command " $wl-bind_at_load"
Chris@40 10227 ;;
Chris@40 10228 esac
Chris@40 10229 fi
Chris@40 10230 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
Chris@40 10231 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@40 10232 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@40 10233 ;;
Chris@40 10234 esac
Chris@40 10235
Chris@40 10236
Chris@40 10237 # move library search paths that coincide with paths to not yet
Chris@40 10238 # installed libraries to the beginning of the library search list
Chris@40 10239 new_libs=
Chris@40 10240 for path in $notinst_path; do
Chris@40 10241 case " $new_libs " in
Chris@40 10242 *" -L$path/$objdir "*) ;;
Chris@40 10243 *)
Chris@40 10244 case " $compile_deplibs " in
Chris@40 10245 *" -L$path/$objdir "*)
Chris@40 10246 func_append new_libs " -L$path/$objdir" ;;
Chris@40 10247 esac
Chris@40 10248 ;;
Chris@40 10249 esac
Chris@40 10250 done
Chris@40 10251 for deplib in $compile_deplibs; do
Chris@40 10252 case $deplib in
Chris@40 10253 -L*)
Chris@40 10254 case " $new_libs " in
Chris@40 10255 *" $deplib "*) ;;
Chris@40 10256 *) func_append new_libs " $deplib" ;;
Chris@40 10257 esac
Chris@40 10258 ;;
Chris@40 10259 *) func_append new_libs " $deplib" ;;
Chris@40 10260 esac
Chris@40 10261 done
Chris@40 10262 compile_deplibs=$new_libs
Chris@40 10263
Chris@40 10264
Chris@40 10265 func_append compile_command " $compile_deplibs"
Chris@40 10266 func_append finalize_command " $finalize_deplibs"
Chris@40 10267
Chris@40 10268 if test -n "$rpath$xrpath"; then
Chris@40 10269 # If the user specified any rpath flags, then add them.
Chris@40 10270 for libdir in $rpath $xrpath; do
Chris@40 10271 # This is the magic to use -rpath.
Chris@40 10272 case "$finalize_rpath " in
Chris@40 10273 *" $libdir "*) ;;
Chris@40 10274 *) func_append finalize_rpath " $libdir" ;;
Chris@40 10275 esac
Chris@40 10276 done
Chris@40 10277 fi
Chris@40 10278
Chris@40 10279 # Now hardcode the library paths
Chris@40 10280 rpath=
Chris@40 10281 hardcode_libdirs=
Chris@40 10282 for libdir in $compile_rpath $finalize_rpath; do
Chris@40 10283 if test -n "$hardcode_libdir_flag_spec"; then
Chris@40 10284 if test -n "$hardcode_libdir_separator"; then
Chris@40 10285 if test -z "$hardcode_libdirs"; then
Chris@40 10286 hardcode_libdirs=$libdir
Chris@40 10287 else
Chris@40 10288 # Just accumulate the unique libdirs.
Chris@40 10289 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Chris@40 10290 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
Chris@40 10291 ;;
Chris@40 10292 *)
Chris@40 10293 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
Chris@40 10294 ;;
Chris@40 10295 esac
Chris@40 10296 fi
Chris@40 10297 else
Chris@40 10298 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@40 10299 func_append rpath " $flag"
Chris@40 10300 fi
Chris@40 10301 elif test -n "$runpath_var"; then
Chris@40 10302 case "$perm_rpath " in
Chris@40 10303 *" $libdir "*) ;;
Chris@40 10304 *) func_append perm_rpath " $libdir" ;;
Chris@40 10305 esac
Chris@40 10306 fi
Chris@40 10307 case $host in
Chris@40 10308 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
Chris@40 10309 testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
Chris@40 10310 case :$dllsearchpath: in
Chris@40 10311 *":$libdir:"*) ;;
Chris@40 10312 ::) dllsearchpath=$libdir;;
Chris@40 10313 *) func_append dllsearchpath ":$libdir";;
Chris@40 10314 esac
Chris@40 10315 case :$dllsearchpath: in
Chris@40 10316 *":$testbindir:"*) ;;
Chris@40 10317 ::) dllsearchpath=$testbindir;;
Chris@40 10318 *) func_append dllsearchpath ":$testbindir";;
Chris@40 10319 esac
Chris@40 10320 ;;
Chris@40 10321 esac
Chris@40 10322 done
Chris@40 10323 # Substitute the hardcoded libdirs into the rpath.
Chris@40 10324 if test -n "$hardcode_libdir_separator" &&
Chris@40 10325 test -n "$hardcode_libdirs"; then
Chris@40 10326 libdir=$hardcode_libdirs
Chris@40 10327 eval rpath=\" $hardcode_libdir_flag_spec\"
Chris@40 10328 fi
Chris@40 10329 compile_rpath=$rpath
Chris@40 10330
Chris@40 10331 rpath=
Chris@40 10332 hardcode_libdirs=
Chris@40 10333 for libdir in $finalize_rpath; do
Chris@40 10334 if test -n "$hardcode_libdir_flag_spec"; then
Chris@40 10335 if test -n "$hardcode_libdir_separator"; then
Chris@40 10336 if test -z "$hardcode_libdirs"; then
Chris@40 10337 hardcode_libdirs=$libdir
Chris@40 10338 else
Chris@40 10339 # Just accumulate the unique libdirs.
Chris@40 10340 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Chris@40 10341 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
Chris@40 10342 ;;
Chris@40 10343 *)
Chris@40 10344 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
Chris@40 10345 ;;
Chris@40 10346 esac
Chris@40 10347 fi
Chris@40 10348 else
Chris@40 10349 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@40 10350 func_append rpath " $flag"
Chris@40 10351 fi
Chris@40 10352 elif test -n "$runpath_var"; then
Chris@40 10353 case "$finalize_perm_rpath " in
Chris@40 10354 *" $libdir "*) ;;
Chris@40 10355 *) func_append finalize_perm_rpath " $libdir" ;;
Chris@40 10356 esac
Chris@40 10357 fi
Chris@40 10358 done
Chris@40 10359 # Substitute the hardcoded libdirs into the rpath.
Chris@40 10360 if test -n "$hardcode_libdir_separator" &&
Chris@40 10361 test -n "$hardcode_libdirs"; then
Chris@40 10362 libdir=$hardcode_libdirs
Chris@40 10363 eval rpath=\" $hardcode_libdir_flag_spec\"
Chris@40 10364 fi
Chris@40 10365 finalize_rpath=$rpath
Chris@40 10366
Chris@40 10367 if test -n "$libobjs" && test yes = "$build_old_libs"; then
Chris@40 10368 # Transform all the library objects into standard objects.
Chris@40 10369 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@40 10370 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@40 10371 fi
Chris@40 10372
Chris@40 10373 func_generate_dlsyms "$outputname" "@PROGRAM@" false
Chris@40 10374
Chris@40 10375 # template prelinking step
Chris@40 10376 if test -n "$prelink_cmds"; then
Chris@40 10377 func_execute_cmds "$prelink_cmds" 'exit $?'
Chris@40 10378 fi
Chris@40 10379
Chris@40 10380 wrappers_required=:
Chris@40 10381 case $host in
Chris@40 10382 *cegcc* | *mingw32ce*)
Chris@40 10383 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
Chris@40 10384 wrappers_required=false
Chris@40 10385 ;;
Chris@40 10386 *cygwin* | *mingw* )
Chris@40 10387 test yes = "$build_libtool_libs" || wrappers_required=false
Chris@40 10388 ;;
Chris@40 10389 *)
Chris@40 10390 if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
Chris@40 10391 wrappers_required=false
Chris@40 10392 fi
Chris@40 10393 ;;
Chris@40 10394 esac
Chris@40 10395 $wrappers_required || {
Chris@40 10396 # Replace the output file specification.
Chris@40 10397 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
Chris@40 10398 link_command=$compile_command$compile_rpath
Chris@40 10399
Chris@40 10400 # We have no uninstalled library dependencies, so finalize right now.
Chris@40 10401 exit_status=0
Chris@40 10402 func_show_eval "$link_command" 'exit_status=$?'
Chris@40 10403
Chris@40 10404 if test -n "$postlink_cmds"; then
Chris@40 10405 func_to_tool_file "$output"
Chris@40 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@40 10407 func_execute_cmds "$postlink_cmds" 'exit $?'
Chris@40 10408 fi
Chris@40 10409
Chris@40 10410 # Delete the generated files.
Chris@40 10411 if test -f "$output_objdir/${outputname}S.$objext"; then
Chris@40 10412 func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
Chris@40 10413 fi
Chris@40 10414
Chris@40 10415 exit $exit_status
Chris@40 10416 }
Chris@40 10417
Chris@40 10418 if test -n "$compile_shlibpath$finalize_shlibpath"; then
Chris@40 10419 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
Chris@40 10420 fi
Chris@40 10421 if test -n "$finalize_shlibpath"; then
Chris@40 10422 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
Chris@40 10423 fi
Chris@40 10424
Chris@40 10425 compile_var=
Chris@40 10426 finalize_var=
Chris@40 10427 if test -n "$runpath_var"; then
Chris@40 10428 if test -n "$perm_rpath"; then
Chris@40 10429 # We should set the runpath_var.
Chris@40 10430 rpath=
Chris@40 10431 for dir in $perm_rpath; do
Chris@40 10432 func_append rpath "$dir:"
Chris@40 10433 done
Chris@40 10434 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
Chris@40 10435 fi
Chris@40 10436 if test -n "$finalize_perm_rpath"; then
Chris@40 10437 # We should set the runpath_var.
Chris@40 10438 rpath=
Chris@40 10439 for dir in $finalize_perm_rpath; do
Chris@40 10440 func_append rpath "$dir:"
Chris@40 10441 done
Chris@40 10442 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
Chris@40 10443 fi
Chris@40 10444 fi
Chris@40 10445
Chris@40 10446 if test yes = "$no_install"; then
Chris@40 10447 # We don't need to create a wrapper script.
Chris@40 10448 link_command=$compile_var$compile_command$compile_rpath
Chris@40 10449 # Replace the output file specification.
Chris@40 10450 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
Chris@40 10451 # Delete the old output file.
Chris@40 10452 $opt_dry_run || $RM $output
Chris@40 10453 # Link the executable and exit
Chris@40 10454 func_show_eval "$link_command" 'exit $?'
Chris@40 10455
Chris@40 10456 if test -n "$postlink_cmds"; then
Chris@40 10457 func_to_tool_file "$output"
Chris@40 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@40 10459 func_execute_cmds "$postlink_cmds" 'exit $?'
Chris@40 10460 fi
Chris@40 10461
Chris@40 10462 exit $EXIT_SUCCESS
Chris@40 10463 fi
Chris@40 10464
Chris@40 10465 case $hardcode_action,$fast_install in
Chris@40 10466 relink,*)
Chris@40 10467 # Fast installation is not supported
Chris@40 10468 link_command=$compile_var$compile_command$compile_rpath
Chris@40 10469 relink_command=$finalize_var$finalize_command$finalize_rpath
Chris@40 10470
Chris@40 10471 func_warning "this platform does not like uninstalled shared libraries"
Chris@40 10472 func_warning "'$output' will be relinked during installation"
Chris@40 10473 ;;
Chris@40 10474 *,yes)
Chris@40 10475 link_command=$finalize_var$compile_command$finalize_rpath
Chris@40 10476 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
Chris@40 10477 ;;
Chris@40 10478 *,no)
Chris@40 10479 link_command=$compile_var$compile_command$compile_rpath
Chris@40 10480 relink_command=$finalize_var$finalize_command$finalize_rpath
Chris@40 10481 ;;
Chris@40 10482 *,needless)
Chris@40 10483 link_command=$finalize_var$compile_command$finalize_rpath
Chris@40 10484 relink_command=
Chris@40 10485 ;;
Chris@40 10486 esac
Chris@40 10487
Chris@40 10488 # Replace the output file specification.
Chris@40 10489 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
Chris@40 10490
Chris@40 10491 # Delete the old output files.
Chris@40 10492 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
Chris@40 10493
Chris@40 10494 func_show_eval "$link_command" 'exit $?'
Chris@40 10495
Chris@40 10496 if test -n "$postlink_cmds"; then
Chris@40 10497 func_to_tool_file "$output_objdir/$outputname"
Chris@40 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@40 10499 func_execute_cmds "$postlink_cmds" 'exit $?'
Chris@40 10500 fi
Chris@40 10501
Chris@40 10502 # Now create the wrapper script.
Chris@40 10503 func_verbose "creating $output"
Chris@40 10504
Chris@40 10505 # Quote the relink command for shipping.
Chris@40 10506 if test -n "$relink_command"; then
Chris@40 10507 # Preserve any variables that may affect compiler behavior
Chris@40 10508 for var in $variables_saved_for_relink; do
Chris@40 10509 if eval test -z \"\${$var+set}\"; then
Chris@40 10510 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
Chris@40 10511 elif eval var_value=\$$var; test -z "$var_value"; then
Chris@40 10512 relink_command="$var=; export $var; $relink_command"
Chris@40 10513 else
Chris@40 10514 func_quote_for_eval "$var_value"
Chris@40 10515 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
Chris@40 10516 fi
Chris@40 10517 done
Chris@40 10518 relink_command="(cd `pwd`; $relink_command)"
Chris@40 10519 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
Chris@40 10520 fi
Chris@40 10521
Chris@40 10522 # Only actually do things if not in dry run mode.
Chris@40 10523 $opt_dry_run || {
Chris@40 10524 # win32 will think the script is a binary if it has
Chris@40 10525 # a .exe suffix, so we strip it off here.
Chris@40 10526 case $output in
Chris@40 10527 *.exe) func_stripname '' '.exe' "$output"
Chris@40 10528 output=$func_stripname_result ;;
Chris@40 10529 esac
Chris@40 10530 # test for cygwin because mv fails w/o .exe extensions
Chris@40 10531 case $host in
Chris@40 10532 *cygwin*)
Chris@40 10533 exeext=.exe
Chris@40 10534 func_stripname '' '.exe' "$outputname"
Chris@40 10535 outputname=$func_stripname_result ;;
Chris@40 10536 *) exeext= ;;
Chris@40 10537 esac
Chris@40 10538 case $host in
Chris@40 10539 *cygwin* | *mingw* )
Chris@40 10540 func_dirname_and_basename "$output" "" "."
Chris@40 10541 output_name=$func_basename_result
Chris@40 10542 output_path=$func_dirname_result
Chris@40 10543 cwrappersource=$output_path/$objdir/lt-$output_name.c
Chris@40 10544 cwrapper=$output_path/$output_name.exe
Chris@40 10545 $RM $cwrappersource $cwrapper
Chris@40 10546 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
Chris@40 10547
Chris@40 10548 func_emit_cwrapperexe_src > $cwrappersource
Chris@40 10549
Chris@40 10550 # The wrapper executable is built using the $host compiler,
Chris@40 10551 # because it contains $host paths and files. If cross-
Chris@40 10552 # compiling, it, like the target executable, must be
Chris@40 10553 # executed on the $host or under an emulation environment.
Chris@40 10554 $opt_dry_run || {
Chris@40 10555 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
Chris@40 10556 $STRIP $cwrapper
Chris@40 10557 }
Chris@40 10558
Chris@40 10559 # Now, create the wrapper script for func_source use:
Chris@40 10560 func_ltwrapper_scriptname $cwrapper
Chris@40 10561 $RM $func_ltwrapper_scriptname_result
Chris@40 10562 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
Chris@40 10563 $opt_dry_run || {
Chris@40 10564 # note: this script will not be executed, so do not chmod.
Chris@40 10565 if test "x$build" = "x$host"; then
Chris@40 10566 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
Chris@40 10567 else
Chris@40 10568 func_emit_wrapper no > $func_ltwrapper_scriptname_result
Chris@40 10569 fi
Chris@40 10570 }
Chris@40 10571 ;;
Chris@40 10572 * )
Chris@40 10573 $RM $output
Chris@40 10574 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
Chris@40 10575
Chris@40 10576 func_emit_wrapper no > $output
Chris@40 10577 chmod +x $output
Chris@40 10578 ;;
Chris@40 10579 esac
Chris@40 10580 }
Chris@40 10581 exit $EXIT_SUCCESS
Chris@40 10582 ;;
Chris@40 10583 esac
Chris@40 10584
Chris@40 10585 # See if we need to build an old-fashioned archive.
Chris@40 10586 for oldlib in $oldlibs; do
Chris@40 10587
Chris@40 10588 case $build_libtool_libs in
Chris@40 10589 convenience)
Chris@40 10590 oldobjs="$libobjs_save $symfileobj"
Chris@40 10591 addlibs=$convenience
Chris@40 10592 build_libtool_libs=no
Chris@40 10593 ;;
Chris@40 10594 module)
Chris@40 10595 oldobjs=$libobjs_save
Chris@40 10596 addlibs=$old_convenience
Chris@40 10597 build_libtool_libs=no
Chris@40 10598 ;;
Chris@40 10599 *)
Chris@40 10600 oldobjs="$old_deplibs $non_pic_objects"
Chris@40 10601 $preload && test -f "$symfileobj" \
Chris@40 10602 && func_append oldobjs " $symfileobj"
Chris@40 10603 addlibs=$old_convenience
Chris@40 10604 ;;
Chris@40 10605 esac
Chris@40 10606
Chris@40 10607 if test -n "$addlibs"; then
Chris@40 10608 gentop=$output_objdir/${outputname}x
Chris@40 10609 func_append generated " $gentop"
Chris@40 10610
Chris@40 10611 func_extract_archives $gentop $addlibs
Chris@40 10612 func_append oldobjs " $func_extract_archives_result"
Chris@40 10613 fi
Chris@40 10614
Chris@40 10615 # Do each command in the archive commands.
Chris@40 10616 if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
Chris@40 10617 cmds=$old_archive_from_new_cmds
Chris@40 10618 else
Chris@40 10619
Chris@40 10620 # Add any objects from preloaded convenience libraries
Chris@40 10621 if test -n "$dlprefiles"; then
Chris@40 10622 gentop=$output_objdir/${outputname}x
Chris@40 10623 func_append generated " $gentop"
Chris@40 10624
Chris@40 10625 func_extract_archives $gentop $dlprefiles
Chris@40 10626 func_append oldobjs " $func_extract_archives_result"
Chris@40 10627 fi
Chris@40 10628
Chris@40 10629 # POSIX demands no paths to be encoded in archives. We have
Chris@40 10630 # to avoid creating archives with duplicate basenames if we
Chris@40 10631 # might have to extract them afterwards, e.g., when creating a
Chris@40 10632 # static archive out of a convenience library, or when linking
Chris@40 10633 # the entirety of a libtool archive into another (currently
Chris@40 10634 # not supported by libtool).
Chris@40 10635 if (for obj in $oldobjs
Chris@40 10636 do
Chris@40 10637 func_basename "$obj"
Chris@40 10638 $ECHO "$func_basename_result"
Chris@40 10639 done | sort | sort -uc >/dev/null 2>&1); then
Chris@40 10640 :
Chris@40 10641 else
Chris@40 10642 echo "copying selected object files to avoid basename conflicts..."
Chris@40 10643 gentop=$output_objdir/${outputname}x
Chris@40 10644 func_append generated " $gentop"
Chris@40 10645 func_mkdir_p "$gentop"
Chris@40 10646 save_oldobjs=$oldobjs
Chris@40 10647 oldobjs=
Chris@40 10648 counter=1
Chris@40 10649 for obj in $save_oldobjs
Chris@40 10650 do
Chris@40 10651 func_basename "$obj"
Chris@40 10652 objbase=$func_basename_result
Chris@40 10653 case " $oldobjs " in
Chris@40 10654 " ") oldobjs=$obj ;;
Chris@40 10655 *[\ /]"$objbase "*)
Chris@40 10656 while :; do
Chris@40 10657 # Make sure we don't pick an alternate name that also
Chris@40 10658 # overlaps.
Chris@40 10659 newobj=lt$counter-$objbase
Chris@40 10660 func_arith $counter + 1
Chris@40 10661 counter=$func_arith_result
Chris@40 10662 case " $oldobjs " in
Chris@40 10663 *[\ /]"$newobj "*) ;;
Chris@40 10664 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
Chris@40 10665 esac
Chris@40 10666 done
Chris@40 10667 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
Chris@40 10668 func_append oldobjs " $gentop/$newobj"
Chris@40 10669 ;;
Chris@40 10670 *) func_append oldobjs " $obj" ;;
Chris@40 10671 esac
Chris@40 10672 done
Chris@40 10673 fi
Chris@40 10674 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
Chris@40 10675 tool_oldlib=$func_to_tool_file_result
Chris@40 10676 eval cmds=\"$old_archive_cmds\"
Chris@40 10677
Chris@40 10678 func_len " $cmds"
Chris@40 10679 len=$func_len_result
Chris@40 10680 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
Chris@40 10681 cmds=$old_archive_cmds
Chris@40 10682 elif test -n "$archiver_list_spec"; then
Chris@40 10683 func_verbose "using command file archive linking..."
Chris@40 10684 for obj in $oldobjs
Chris@40 10685 do
Chris@40 10686 func_to_tool_file "$obj"
Chris@40 10687 $ECHO "$func_to_tool_file_result"
Chris@40 10688 done > $output_objdir/$libname.libcmd
Chris@40 10689 func_to_tool_file "$output_objdir/$libname.libcmd"
Chris@40 10690 oldobjs=" $archiver_list_spec$func_to_tool_file_result"
Chris@40 10691 cmds=$old_archive_cmds
Chris@40 10692 else
Chris@40 10693 # the command line is too long to link in one step, link in parts
Chris@40 10694 func_verbose "using piecewise archive linking..."
Chris@40 10695 save_RANLIB=$RANLIB
Chris@40 10696 RANLIB=:
Chris@40 10697 objlist=
Chris@40 10698 concat_cmds=
Chris@40 10699 save_oldobjs=$oldobjs
Chris@40 10700 oldobjs=
Chris@40 10701 # Is there a better way of finding the last object in the list?
Chris@40 10702 for obj in $save_oldobjs
Chris@40 10703 do
Chris@40 10704 last_oldobj=$obj
Chris@40 10705 done
Chris@40 10706 eval test_cmds=\"$old_archive_cmds\"
Chris@40 10707 func_len " $test_cmds"
Chris@40 10708 len0=$func_len_result
Chris@40 10709 len=$len0
Chris@40 10710 for obj in $save_oldobjs
Chris@40 10711 do
Chris@40 10712 func_len " $obj"
Chris@40 10713 func_arith $len + $func_len_result
Chris@40 10714 len=$func_arith_result
Chris@40 10715 func_append objlist " $obj"
Chris@40 10716 if test "$len" -lt "$max_cmd_len"; then
Chris@40 10717 :
Chris@40 10718 else
Chris@40 10719 # the above command should be used before it gets too long
Chris@40 10720 oldobjs=$objlist
Chris@40 10721 if test "$obj" = "$last_oldobj"; then
Chris@40 10722 RANLIB=$save_RANLIB
Chris@40 10723 fi
Chris@40 10724 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Chris@40 10725 eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
Chris@40 10726 objlist=
Chris@40 10727 len=$len0
Chris@40 10728 fi
Chris@40 10729 done
Chris@40 10730 RANLIB=$save_RANLIB
Chris@40 10731 oldobjs=$objlist
Chris@40 10732 if test -z "$oldobjs"; then
Chris@40 10733 eval cmds=\"\$concat_cmds\"
Chris@40 10734 else
Chris@40 10735 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
Chris@40 10736 fi
Chris@40 10737 fi
Chris@40 10738 fi
Chris@40 10739 func_execute_cmds "$cmds" 'exit $?'
Chris@40 10740 done
Chris@40 10741
Chris@40 10742 test -n "$generated" && \
Chris@40 10743 func_show_eval "${RM}r$generated"
Chris@40 10744
Chris@40 10745 # Now create the libtool archive.
Chris@40 10746 case $output in
Chris@40 10747 *.la)
Chris@40 10748 old_library=
Chris@40 10749 test yes = "$build_old_libs" && old_library=$libname.$libext
Chris@40 10750 func_verbose "creating $output"
Chris@40 10751
Chris@40 10752 # Preserve any variables that may affect compiler behavior
Chris@40 10753 for var in $variables_saved_for_relink; do
Chris@40 10754 if eval test -z \"\${$var+set}\"; then
Chris@40 10755 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
Chris@40 10756 elif eval var_value=\$$var; test -z "$var_value"; then
Chris@40 10757 relink_command="$var=; export $var; $relink_command"
Chris@40 10758 else
Chris@40 10759 func_quote_for_eval "$var_value"
Chris@40 10760 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
Chris@40 10761 fi
Chris@40 10762 done
Chris@40 10763 # Quote the link command for shipping.
Chris@40 10764 relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
Chris@40 10765 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
Chris@40 10766 if test yes = "$hardcode_automatic"; then
Chris@40 10767 relink_command=
Chris@40 10768 fi
Chris@40 10769
Chris@40 10770 # Only create the output if not a dry run.
Chris@40 10771 $opt_dry_run || {
Chris@40 10772 for installed in no yes; do
Chris@40 10773 if test yes = "$installed"; then
Chris@40 10774 if test -z "$install_libdir"; then
Chris@40 10775 break
Chris@40 10776 fi
Chris@40 10777 output=$output_objdir/${outputname}i
Chris@40 10778 # Replace all uninstalled libtool libraries with the installed ones
Chris@40 10779 newdependency_libs=
Chris@40 10780 for deplib in $dependency_libs; do
Chris@40 10781 case $deplib in
Chris@40 10782 *.la)
Chris@40 10783 func_basename "$deplib"
Chris@40 10784 name=$func_basename_result
Chris@40 10785 func_resolve_sysroot "$deplib"
Chris@40 10786 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
Chris@40 10787 test -z "$libdir" && \
Chris@40 10788 func_fatal_error "'$deplib' is not a valid libtool archive"
Chris@40 10789 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
Chris@40 10790 ;;
Chris@40 10791 -L*)
Chris@40 10792 func_stripname -L '' "$deplib"
Chris@40 10793 func_replace_sysroot "$func_stripname_result"
Chris@40 10794 func_append newdependency_libs " -L$func_replace_sysroot_result"
Chris@40 10795 ;;
Chris@40 10796 -R*)
Chris@40 10797 func_stripname -R '' "$deplib"
Chris@40 10798 func_replace_sysroot "$func_stripname_result"
Chris@40 10799 func_append newdependency_libs " -R$func_replace_sysroot_result"
Chris@40 10800 ;;
Chris@40 10801 *) func_append newdependency_libs " $deplib" ;;
Chris@40 10802 esac
Chris@40 10803 done
Chris@40 10804 dependency_libs=$newdependency_libs
Chris@40 10805 newdlfiles=
Chris@40 10806
Chris@40 10807 for lib in $dlfiles; do
Chris@40 10808 case $lib in
Chris@40 10809 *.la)
Chris@40 10810 func_basename "$lib"
Chris@40 10811 name=$func_basename_result
Chris@40 10812 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
Chris@40 10813 test -z "$libdir" && \
Chris@40 10814 func_fatal_error "'$lib' is not a valid libtool archive"
Chris@40 10815 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
Chris@40 10816 ;;
Chris@40 10817 *) func_append newdlfiles " $lib" ;;
Chris@40 10818 esac
Chris@40 10819 done
Chris@40 10820 dlfiles=$newdlfiles
Chris@40 10821 newdlprefiles=
Chris@40 10822 for lib in $dlprefiles; do
Chris@40 10823 case $lib in
Chris@40 10824 *.la)
Chris@40 10825 # Only pass preopened files to the pseudo-archive (for
Chris@40 10826 # eventual linking with the app. that links it) if we
Chris@40 10827 # didn't already link the preopened objects directly into
Chris@40 10828 # the library:
Chris@40 10829 func_basename "$lib"
Chris@40 10830 name=$func_basename_result
Chris@40 10831 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
Chris@40 10832 test -z "$libdir" && \
Chris@40 10833 func_fatal_error "'$lib' is not a valid libtool archive"
Chris@40 10834 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
Chris@40 10835 ;;
Chris@40 10836 esac
Chris@40 10837 done
Chris@40 10838 dlprefiles=$newdlprefiles
Chris@40 10839 else
Chris@40 10840 newdlfiles=
Chris@40 10841 for lib in $dlfiles; do
Chris@40 10842 case $lib in
Chris@40 10843 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
Chris@40 10844 *) abs=`pwd`"/$lib" ;;
Chris@40 10845 esac
Chris@40 10846 func_append newdlfiles " $abs"
Chris@40 10847 done
Chris@40 10848 dlfiles=$newdlfiles
Chris@40 10849 newdlprefiles=
Chris@40 10850 for lib in $dlprefiles; do
Chris@40 10851 case $lib in
Chris@40 10852 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
Chris@40 10853 *) abs=`pwd`"/$lib" ;;
Chris@40 10854 esac
Chris@40 10855 func_append newdlprefiles " $abs"
Chris@40 10856 done
Chris@40 10857 dlprefiles=$newdlprefiles
Chris@40 10858 fi
Chris@40 10859 $RM $output
Chris@40 10860 # place dlname in correct position for cygwin
Chris@40 10861 # In fact, it would be nice if we could use this code for all target
Chris@40 10862 # systems that can't hard-code library paths into their executables
Chris@40 10863 # and that have no shared library path variable independent of PATH,
Chris@40 10864 # but it turns out we can't easily determine that from inspecting
Chris@40 10865 # libtool variables, so we have to hard-code the OSs to which it
Chris@40 10866 # applies here; at the moment, that means platforms that use the PE
Chris@40 10867 # object format with DLL files. See the long comment at the top of
Chris@40 10868 # tests/bindir.at for full details.
Chris@40 10869 tdlname=$dlname
Chris@40 10870 case $host,$output,$installed,$module,$dlname in
Chris@40 10871 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
Chris@40 10872 # If a -bindir argument was supplied, place the dll there.
Chris@40 10873 if test -n "$bindir"; then
Chris@40 10874 func_relative_path "$install_libdir" "$bindir"
Chris@40 10875 tdlname=$func_relative_path_result/$dlname
Chris@40 10876 else
Chris@40 10877 # Otherwise fall back on heuristic.
Chris@40 10878 tdlname=../bin/$dlname
Chris@40 10879 fi
Chris@40 10880 ;;
Chris@40 10881 esac
Chris@40 10882 $ECHO > $output "\
Chris@40 10883 # $outputname - a libtool library file
Chris@40 10884 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@40 10885 #
Chris@40 10886 # Please DO NOT delete this file!
Chris@40 10887 # It is necessary for linking the library.
Chris@40 10888
Chris@40 10889 # The name that we can dlopen(3).
Chris@40 10890 dlname='$tdlname'
Chris@40 10891
Chris@40 10892 # Names of this library.
Chris@40 10893 library_names='$library_names'
Chris@40 10894
Chris@40 10895 # The name of the static archive.
Chris@40 10896 old_library='$old_library'
Chris@40 10897
Chris@40 10898 # Linker flags that cannot go in dependency_libs.
Chris@40 10899 inherited_linker_flags='$new_inherited_linker_flags'
Chris@40 10900
Chris@40 10901 # Libraries that this one depends upon.
Chris@40 10902 dependency_libs='$dependency_libs'
Chris@40 10903
Chris@40 10904 # Names of additional weak libraries provided by this library
Chris@40 10905 weak_library_names='$weak_libs'
Chris@40 10906
Chris@40 10907 # Version information for $libname.
Chris@40 10908 current=$current
Chris@40 10909 age=$age
Chris@40 10910 revision=$revision
Chris@40 10911
Chris@40 10912 # Is this an already installed library?
Chris@40 10913 installed=$installed
Chris@40 10914
Chris@40 10915 # Should we warn about portability when linking against -modules?
Chris@40 10916 shouldnotlink=$module
Chris@40 10917
Chris@40 10918 # Files to dlopen/dlpreopen
Chris@40 10919 dlopen='$dlfiles'
Chris@40 10920 dlpreopen='$dlprefiles'
Chris@40 10921
Chris@40 10922 # Directory that this library needs to be installed in:
Chris@40 10923 libdir='$install_libdir'"
Chris@40 10924 if test no,yes = "$installed,$need_relink"; then
Chris@40 10925 $ECHO >> $output "\
Chris@40 10926 relink_command=\"$relink_command\""
Chris@40 10927 fi
Chris@40 10928 done
Chris@40 10929 }
Chris@40 10930
Chris@40 10931 # Do a symbolic link so that the libtool archive can be found in
Chris@40 10932 # LD_LIBRARY_PATH before the program is installed.
Chris@40 10933 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
Chris@40 10934 ;;
Chris@40 10935 esac
Chris@40 10936 exit $EXIT_SUCCESS
Chris@40 10937 }
Chris@40 10938
Chris@40 10939 if test link = "$opt_mode" || test relink = "$opt_mode"; then
Chris@40 10940 func_mode_link ${1+"$@"}
Chris@40 10941 fi
Chris@40 10942
Chris@40 10943
Chris@40 10944 # func_mode_uninstall arg...
Chris@40 10945 func_mode_uninstall ()
Chris@40 10946 {
Chris@40 10947 $debug_cmd
Chris@40 10948
Chris@40 10949 RM=$nonopt
Chris@40 10950 files=
Chris@40 10951 rmforce=false
Chris@40 10952 exit_status=0
Chris@40 10953
Chris@40 10954 # This variable tells wrapper scripts just to set variables rather
Chris@40 10955 # than running their programs.
Chris@40 10956 libtool_install_magic=$magic
Chris@40 10957
Chris@40 10958 for arg
Chris@40 10959 do
Chris@40 10960 case $arg in
Chris@40 10961 -f) func_append RM " $arg"; rmforce=: ;;
Chris@40 10962 -*) func_append RM " $arg" ;;
Chris@40 10963 *) func_append files " $arg" ;;
Chris@40 10964 esac
Chris@40 10965 done
Chris@40 10966
Chris@40 10967 test -z "$RM" && \
Chris@40 10968 func_fatal_help "you must specify an RM program"
Chris@40 10969
Chris@40 10970 rmdirs=
Chris@40 10971
Chris@40 10972 for file in $files; do
Chris@40 10973 func_dirname "$file" "" "."
Chris@40 10974 dir=$func_dirname_result
Chris@40 10975 if test . = "$dir"; then
Chris@40 10976 odir=$objdir
Chris@40 10977 else
Chris@40 10978 odir=$dir/$objdir
Chris@40 10979 fi
Chris@40 10980 func_basename "$file"
Chris@40 10981 name=$func_basename_result
Chris@40 10982 test uninstall = "$opt_mode" && odir=$dir
Chris@40 10983
Chris@40 10984 # Remember odir for removal later, being careful to avoid duplicates
Chris@40 10985 if test clean = "$opt_mode"; then
Chris@40 10986 case " $rmdirs " in
Chris@40 10987 *" $odir "*) ;;
Chris@40 10988 *) func_append rmdirs " $odir" ;;
Chris@40 10989 esac
Chris@40 10990 fi
Chris@40 10991
Chris@40 10992 # Don't error if the file doesn't exist and rm -f was used.
Chris@40 10993 if { test -L "$file"; } >/dev/null 2>&1 ||
Chris@40 10994 { test -h "$file"; } >/dev/null 2>&1 ||
Chris@40 10995 test -f "$file"; then
Chris@40 10996 :
Chris@40 10997 elif test -d "$file"; then
Chris@40 10998 exit_status=1
Chris@40 10999 continue
Chris@40 11000 elif $rmforce; then
Chris@40 11001 continue
Chris@40 11002 fi
Chris@40 11003
Chris@40 11004 rmfiles=$file
Chris@40 11005
Chris@40 11006 case $name in
Chris@40 11007 *.la)
Chris@40 11008 # Possibly a libtool archive, so verify it.
Chris@40 11009 if func_lalib_p "$file"; then
Chris@40 11010 func_source $dir/$name
Chris@40 11011
Chris@40 11012 # Delete the libtool libraries and symlinks.
Chris@40 11013 for n in $library_names; do
Chris@40 11014 func_append rmfiles " $odir/$n"
Chris@40 11015 done
Chris@40 11016 test -n "$old_library" && func_append rmfiles " $odir/$old_library"
Chris@40 11017
Chris@40 11018 case $opt_mode in
Chris@40 11019 clean)
Chris@40 11020 case " $library_names " in
Chris@40 11021 *" $dlname "*) ;;
Chris@40 11022 *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
Chris@40 11023 esac
Chris@40 11024 test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
Chris@40 11025 ;;
Chris@40 11026 uninstall)
Chris@40 11027 if test -n "$library_names"; then
Chris@40 11028 # Do each command in the postuninstall commands.
Chris@40 11029 func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
Chris@40 11030 fi
Chris@40 11031
Chris@40 11032 if test -n "$old_library"; then
Chris@40 11033 # Do each command in the old_postuninstall commands.
Chris@40 11034 func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
Chris@40 11035 fi
Chris@40 11036 # FIXME: should reinstall the best remaining shared library.
Chris@40 11037 ;;
Chris@40 11038 esac
Chris@40 11039 fi
Chris@40 11040 ;;
Chris@40 11041
Chris@40 11042 *.lo)
Chris@40 11043 # Possibly a libtool object, so verify it.
Chris@40 11044 if func_lalib_p "$file"; then
Chris@40 11045
Chris@40 11046 # Read the .lo file
Chris@40 11047 func_source $dir/$name
Chris@40 11048
Chris@40 11049 # Add PIC object to the list of files to remove.
Chris@40 11050 if test -n "$pic_object" && test none != "$pic_object"; then
Chris@40 11051 func_append rmfiles " $dir/$pic_object"
Chris@40 11052 fi
Chris@40 11053
Chris@40 11054 # Add non-PIC object to the list of files to remove.
Chris@40 11055 if test -n "$non_pic_object" && test none != "$non_pic_object"; then
Chris@40 11056 func_append rmfiles " $dir/$non_pic_object"
Chris@40 11057 fi
Chris@40 11058 fi
Chris@40 11059 ;;
Chris@40 11060
Chris@40 11061 *)
Chris@40 11062 if test clean = "$opt_mode"; then
Chris@40 11063 noexename=$name
Chris@40 11064 case $file in
Chris@40 11065 *.exe)
Chris@40 11066 func_stripname '' '.exe' "$file"
Chris@40 11067 file=$func_stripname_result
Chris@40 11068 func_stripname '' '.exe' "$name"
Chris@40 11069 noexename=$func_stripname_result
Chris@40 11070 # $file with .exe has already been added to rmfiles,
Chris@40 11071 # add $file without .exe
Chris@40 11072 func_append rmfiles " $file"
Chris@40 11073 ;;
Chris@40 11074 esac
Chris@40 11075 # Do a test to see if this is a libtool program.
Chris@40 11076 if func_ltwrapper_p "$file"; then
Chris@40 11077 if func_ltwrapper_executable_p "$file"; then
Chris@40 11078 func_ltwrapper_scriptname "$file"
Chris@40 11079 relink_command=
Chris@40 11080 func_source $func_ltwrapper_scriptname_result
Chris@40 11081 func_append rmfiles " $func_ltwrapper_scriptname_result"
Chris@40 11082 else
Chris@40 11083 relink_command=
Chris@40 11084 func_source $dir/$noexename
Chris@40 11085 fi
Chris@40 11086
Chris@40 11087 # note $name still contains .exe if it was in $file originally
Chris@40 11088 # as does the version of $file that was added into $rmfiles
Chris@40 11089 func_append rmfiles " $odir/$name $odir/${name}S.$objext"
Chris@40 11090 if test yes = "$fast_install" && test -n "$relink_command"; then
Chris@40 11091 func_append rmfiles " $odir/lt-$name"
Chris@40 11092 fi
Chris@40 11093 if test "X$noexename" != "X$name"; then
Chris@40 11094 func_append rmfiles " $odir/lt-$noexename.c"
Chris@40 11095 fi
Chris@40 11096 fi
Chris@40 11097 fi
Chris@40 11098 ;;
Chris@40 11099 esac
Chris@40 11100 func_show_eval "$RM $rmfiles" 'exit_status=1'
Chris@40 11101 done
Chris@40 11102
Chris@40 11103 # Try to remove the $objdir's in the directories where we deleted files
Chris@40 11104 for dir in $rmdirs; do
Chris@40 11105 if test -d "$dir"; then
Chris@40 11106 func_show_eval "rmdir $dir >/dev/null 2>&1"
Chris@40 11107 fi
Chris@40 11108 done
Chris@40 11109
Chris@40 11110 exit $exit_status
Chris@40 11111 }
Chris@40 11112
Chris@40 11113 if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
Chris@40 11114 func_mode_uninstall ${1+"$@"}
Chris@40 11115 fi
Chris@40 11116
Chris@40 11117 test -z "$opt_mode" && {
Chris@40 11118 help=$generic_help
Chris@40 11119 func_fatal_help "you must specify a MODE"
Chris@40 11120 }
Chris@40 11121
Chris@40 11122 test -z "$exec_cmd" && \
Chris@40 11123 func_fatal_help "invalid operation mode '$opt_mode'"
Chris@40 11124
Chris@40 11125 if test -n "$exec_cmd"; then
Chris@40 11126 eval exec "$exec_cmd"
Chris@40 11127 exit $EXIT_FAILURE
Chris@40 11128 fi
Chris@40 11129
Chris@40 11130 exit $exit_status
Chris@40 11131
Chris@40 11132
Chris@40 11133 # The TAGs below are defined such that we never get into a situation
Chris@40 11134 # where we disable both kinds of libraries. Given conflicting
Chris@40 11135 # choices, we go for a static library, that is the most portable,
Chris@40 11136 # since we can't tell whether shared libraries were disabled because
Chris@40 11137 # the user asked for that or because the platform doesn't support
Chris@40 11138 # them. This is particularly important on AIX, because we don't
Chris@40 11139 # support having both static and shared libraries enabled at the same
Chris@40 11140 # time on that platform, so we default to a shared-only configuration.
Chris@40 11141 # If a disable-shared tag is given, we'll fallback to a static-only
Chris@40 11142 # configuration. But we'll never go from static-only to shared-only.
Chris@40 11143
Chris@40 11144 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
Chris@40 11145 build_libtool_libs=no
Chris@40 11146 build_old_libs=yes
Chris@40 11147 # ### END LIBTOOL TAG CONFIG: disable-shared
Chris@40 11148
Chris@40 11149 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
Chris@40 11150 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
Chris@40 11151 # ### END LIBTOOL TAG CONFIG: disable-static
Chris@40 11152
Chris@40 11153 # Local Variables:
Chris@40 11154 # mode:shell-script
Chris@40 11155 # sh-indentation:2
Chris@40 11156 # End: