annotate src/fftw-3.3.8/ltmain.sh @ 84:08ae793730bd

Add null config files
author Chris Cannam
date Mon, 02 Mar 2020 14:03:47 +0000
parents d0c2a83c1364
children
rev   line source
Chris@82 1 #! /bin/sh
Chris@82 2 ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
Chris@82 3 ## by inline-source v2014-01-03.01
Chris@82 4
Chris@82 5 # libtool (GNU libtool) 2.4.6
Chris@82 6 # Provide generalized library-building support services.
Chris@82 7 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
Chris@82 8
Chris@82 9 # Copyright (C) 1996-2015 Free Software Foundation, Inc.
Chris@82 10 # This is free software; see the source for copying conditions. There is NO
Chris@82 11 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chris@82 12
Chris@82 13 # GNU Libtool is free software; you can redistribute it and/or modify
Chris@82 14 # it under the terms of the GNU General Public License as published by
Chris@82 15 # the Free Software Foundation; either version 2 of the License, or
Chris@82 16 # (at your option) any later version.
Chris@82 17 #
Chris@82 18 # As a special exception to the GNU General Public License,
Chris@82 19 # if you distribute this file as part of a program or library that
Chris@82 20 # is built using GNU Libtool, you may include this file under the
Chris@82 21 # same distribution terms that you use for the rest of that program.
Chris@82 22 #
Chris@82 23 # GNU Libtool is distributed in the hope that it will be useful, but
Chris@82 24 # WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@82 25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Chris@82 26 # General Public License for more details.
Chris@82 27 #
Chris@82 28 # You should have received a copy of the GNU General Public License
Chris@82 29 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@82 30
Chris@82 31
Chris@82 32 PROGRAM=libtool
Chris@82 33 PACKAGE=libtool
Chris@82 34 VERSION="2.4.6 Debian-2.4.6-2"
Chris@82 35 package_revision=2.4.6
Chris@82 36
Chris@82 37
Chris@82 38 ## ------ ##
Chris@82 39 ## Usage. ##
Chris@82 40 ## ------ ##
Chris@82 41
Chris@82 42 # Run './libtool --help' for help with using this script from the
Chris@82 43 # command line.
Chris@82 44
Chris@82 45
Chris@82 46 ## ------------------------------- ##
Chris@82 47 ## User overridable command paths. ##
Chris@82 48 ## ------------------------------- ##
Chris@82 49
Chris@82 50 # After configure completes, it has a better idea of some of the
Chris@82 51 # shell tools we need than the defaults used by the functions shared
Chris@82 52 # with bootstrap, so set those here where they can still be over-
Chris@82 53 # ridden by the user, but otherwise take precedence.
Chris@82 54
Chris@82 55 : ${AUTOCONF="autoconf"}
Chris@82 56 : ${AUTOMAKE="automake"}
Chris@82 57
Chris@82 58
Chris@82 59 ## -------------------------- ##
Chris@82 60 ## Source external libraries. ##
Chris@82 61 ## -------------------------- ##
Chris@82 62
Chris@82 63 # Much of our low-level functionality needs to be sourced from external
Chris@82 64 # libraries, which are installed to $pkgauxdir.
Chris@82 65
Chris@82 66 # Set a version string for this script.
Chris@82 67 scriptversion=2015-01-20.17; # UTC
Chris@82 68
Chris@82 69 # General shell script boiler plate, and helper functions.
Chris@82 70 # Written by Gary V. Vaughan, 2004
Chris@82 71
Chris@82 72 # Copyright (C) 2004-2015 Free Software Foundation, Inc.
Chris@82 73 # This is free software; see the source for copying conditions. There is NO
Chris@82 74 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chris@82 75
Chris@82 76 # This program is free software; you can redistribute it and/or modify
Chris@82 77 # it under the terms of the GNU General Public License as published by
Chris@82 78 # the Free Software Foundation; either version 3 of the License, or
Chris@82 79 # (at your option) any later version.
Chris@82 80
Chris@82 81 # As a special exception to the GNU General Public License, if you distribute
Chris@82 82 # this file as part of a program or library that is built using GNU Libtool,
Chris@82 83 # you may include this file under the same distribution terms that you use
Chris@82 84 # for the rest of that program.
Chris@82 85
Chris@82 86 # This program is distributed in the hope that it will be useful,
Chris@82 87 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@82 88 # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
Chris@82 89 # General Public License for more details.
Chris@82 90
Chris@82 91 # You should have received a copy of the GNU General Public License
Chris@82 92 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@82 93
Chris@82 94 # Please report bugs or propose patches to gary@gnu.org.
Chris@82 95
Chris@82 96
Chris@82 97 ## ------ ##
Chris@82 98 ## Usage. ##
Chris@82 99 ## ------ ##
Chris@82 100
Chris@82 101 # Evaluate this file near the top of your script to gain access to
Chris@82 102 # the functions and variables defined here:
Chris@82 103 #
Chris@82 104 # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
Chris@82 105 #
Chris@82 106 # If you need to override any of the default environment variable
Chris@82 107 # settings, do that before evaluating this file.
Chris@82 108
Chris@82 109
Chris@82 110 ## -------------------- ##
Chris@82 111 ## Shell normalisation. ##
Chris@82 112 ## -------------------- ##
Chris@82 113
Chris@82 114 # Some shells need a little help to be as Bourne compatible as possible.
Chris@82 115 # Before doing anything else, make sure all that help has been provided!
Chris@82 116
Chris@82 117 DUALCASE=1; export DUALCASE # for MKS sh
Chris@82 118 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
Chris@82 119 emulate sh
Chris@82 120 NULLCMD=:
Chris@82 121 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
Chris@82 122 # is contrary to our usage. Disable this feature.
Chris@82 123 alias -g '${1+"$@"}'='"$@"'
Chris@82 124 setopt NO_GLOB_SUBST
Chris@82 125 else
Chris@82 126 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
Chris@82 127 fi
Chris@82 128
Chris@82 129 # NLS nuisances: We save the old values in case they are required later.
Chris@82 130 _G_user_locale=
Chris@82 131 _G_safe_locale=
Chris@82 132 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
Chris@82 133 do
Chris@82 134 eval "if test set = \"\${$_G_var+set}\"; then
Chris@82 135 save_$_G_var=\$$_G_var
Chris@82 136 $_G_var=C
Chris@82 137 export $_G_var
Chris@82 138 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
Chris@82 139 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
Chris@82 140 fi"
Chris@82 141 done
Chris@82 142
Chris@82 143 # CDPATH.
Chris@82 144 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
Chris@82 145
Chris@82 146 # Make sure IFS has a sensible default
Chris@82 147 sp=' '
Chris@82 148 nl='
Chris@82 149 '
Chris@82 150 IFS="$sp $nl"
Chris@82 151
Chris@82 152 # There are apparently some retarded systems that use ';' as a PATH separator!
Chris@82 153 if test "${PATH_SEPARATOR+set}" != set; then
Chris@82 154 PATH_SEPARATOR=:
Chris@82 155 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
Chris@82 156 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
Chris@82 157 PATH_SEPARATOR=';'
Chris@82 158 }
Chris@82 159 fi
Chris@82 160
Chris@82 161
Chris@82 162
Chris@82 163 ## ------------------------- ##
Chris@82 164 ## Locate command utilities. ##
Chris@82 165 ## ------------------------- ##
Chris@82 166
Chris@82 167
Chris@82 168 # func_executable_p FILE
Chris@82 169 # ----------------------
Chris@82 170 # Check that FILE is an executable regular file.
Chris@82 171 func_executable_p ()
Chris@82 172 {
Chris@82 173 test -f "$1" && test -x "$1"
Chris@82 174 }
Chris@82 175
Chris@82 176
Chris@82 177 # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
Chris@82 178 # --------------------------------------------
Chris@82 179 # Search for either a program that responds to --version with output
Chris@82 180 # containing "GNU", or else returned by CHECK_FUNC otherwise, by
Chris@82 181 # trying all the directories in PATH with each of the elements of
Chris@82 182 # PROGS_LIST.
Chris@82 183 #
Chris@82 184 # CHECK_FUNC should accept the path to a candidate program, and
Chris@82 185 # set $func_check_prog_result if it truncates its output less than
Chris@82 186 # $_G_path_prog_max characters.
Chris@82 187 func_path_progs ()
Chris@82 188 {
Chris@82 189 _G_progs_list=$1
Chris@82 190 _G_check_func=$2
Chris@82 191 _G_PATH=${3-"$PATH"}
Chris@82 192
Chris@82 193 _G_path_prog_max=0
Chris@82 194 _G_path_prog_found=false
Chris@82 195 _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
Chris@82 196 for _G_dir in $_G_PATH; do
Chris@82 197 IFS=$_G_save_IFS
Chris@82 198 test -z "$_G_dir" && _G_dir=.
Chris@82 199 for _G_prog_name in $_G_progs_list; do
Chris@82 200 for _exeext in '' .EXE; do
Chris@82 201 _G_path_prog=$_G_dir/$_G_prog_name$_exeext
Chris@82 202 func_executable_p "$_G_path_prog" || continue
Chris@82 203 case `"$_G_path_prog" --version 2>&1` in
Chris@82 204 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
Chris@82 205 *) $_G_check_func $_G_path_prog
Chris@82 206 func_path_progs_result=$func_check_prog_result
Chris@82 207 ;;
Chris@82 208 esac
Chris@82 209 $_G_path_prog_found && break 3
Chris@82 210 done
Chris@82 211 done
Chris@82 212 done
Chris@82 213 IFS=$_G_save_IFS
Chris@82 214 test -z "$func_path_progs_result" && {
Chris@82 215 echo "no acceptable sed could be found in \$PATH" >&2
Chris@82 216 exit 1
Chris@82 217 }
Chris@82 218 }
Chris@82 219
Chris@82 220
Chris@82 221 # We want to be able to use the functions in this file before configure
Chris@82 222 # has figured out where the best binaries are kept, which means we have
Chris@82 223 # to search for them ourselves - except when the results are already set
Chris@82 224 # where we skip the searches.
Chris@82 225
Chris@82 226 # Unless the user overrides by setting SED, search the path for either GNU
Chris@82 227 # sed, or the sed that truncates its output the least.
Chris@82 228 test -z "$SED" && {
Chris@82 229 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
Chris@82 230 for _G_i in 1 2 3 4 5 6 7; do
Chris@82 231 _G_sed_script=$_G_sed_script$nl$_G_sed_script
Chris@82 232 done
Chris@82 233 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
Chris@82 234 _G_sed_script=
Chris@82 235
Chris@82 236 func_check_prog_sed ()
Chris@82 237 {
Chris@82 238 _G_path_prog=$1
Chris@82 239
Chris@82 240 _G_count=0
Chris@82 241 printf 0123456789 >conftest.in
Chris@82 242 while :
Chris@82 243 do
Chris@82 244 cat conftest.in conftest.in >conftest.tmp
Chris@82 245 mv conftest.tmp conftest.in
Chris@82 246 cp conftest.in conftest.nl
Chris@82 247 echo '' >> conftest.nl
Chris@82 248 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
Chris@82 249 diff conftest.out conftest.nl >/dev/null 2>&1 || break
Chris@82 250 _G_count=`expr $_G_count + 1`
Chris@82 251 if test "$_G_count" -gt "$_G_path_prog_max"; then
Chris@82 252 # Best one so far, save it but keep looking for a better one
Chris@82 253 func_check_prog_result=$_G_path_prog
Chris@82 254 _G_path_prog_max=$_G_count
Chris@82 255 fi
Chris@82 256 # 10*(2^10) chars as input seems more than enough
Chris@82 257 test 10 -lt "$_G_count" && break
Chris@82 258 done
Chris@82 259 rm -f conftest.in conftest.tmp conftest.nl conftest.out
Chris@82 260 }
Chris@82 261
Chris@82 262 func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
Chris@82 263 rm -f conftest.sed
Chris@82 264 SED=$func_path_progs_result
Chris@82 265 }
Chris@82 266
Chris@82 267
Chris@82 268 # Unless the user overrides by setting GREP, search the path for either GNU
Chris@82 269 # grep, or the grep that truncates its output the least.
Chris@82 270 test -z "$GREP" && {
Chris@82 271 func_check_prog_grep ()
Chris@82 272 {
Chris@82 273 _G_path_prog=$1
Chris@82 274
Chris@82 275 _G_count=0
Chris@82 276 _G_path_prog_max=0
Chris@82 277 printf 0123456789 >conftest.in
Chris@82 278 while :
Chris@82 279 do
Chris@82 280 cat conftest.in conftest.in >conftest.tmp
Chris@82 281 mv conftest.tmp conftest.in
Chris@82 282 cp conftest.in conftest.nl
Chris@82 283 echo 'GREP' >> conftest.nl
Chris@82 284 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
Chris@82 285 diff conftest.out conftest.nl >/dev/null 2>&1 || break
Chris@82 286 _G_count=`expr $_G_count + 1`
Chris@82 287 if test "$_G_count" -gt "$_G_path_prog_max"; then
Chris@82 288 # Best one so far, save it but keep looking for a better one
Chris@82 289 func_check_prog_result=$_G_path_prog
Chris@82 290 _G_path_prog_max=$_G_count
Chris@82 291 fi
Chris@82 292 # 10*(2^10) chars as input seems more than enough
Chris@82 293 test 10 -lt "$_G_count" && break
Chris@82 294 done
Chris@82 295 rm -f conftest.in conftest.tmp conftest.nl conftest.out
Chris@82 296 }
Chris@82 297
Chris@82 298 func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
Chris@82 299 GREP=$func_path_progs_result
Chris@82 300 }
Chris@82 301
Chris@82 302
Chris@82 303 ## ------------------------------- ##
Chris@82 304 ## User overridable command paths. ##
Chris@82 305 ## ------------------------------- ##
Chris@82 306
Chris@82 307 # All uppercase variable names are used for environment variables. These
Chris@82 308 # variables can be overridden by the user before calling a script that
Chris@82 309 # uses them if a suitable command of that name is not already available
Chris@82 310 # in the command search PATH.
Chris@82 311
Chris@82 312 : ${CP="cp -f"}
Chris@82 313 : ${ECHO="printf %s\n"}
Chris@82 314 : ${EGREP="$GREP -E"}
Chris@82 315 : ${FGREP="$GREP -F"}
Chris@82 316 : ${LN_S="ln -s"}
Chris@82 317 : ${MAKE="make"}
Chris@82 318 : ${MKDIR="mkdir"}
Chris@82 319 : ${MV="mv -f"}
Chris@82 320 : ${RM="rm -f"}
Chris@82 321 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
Chris@82 322
Chris@82 323
Chris@82 324 ## -------------------- ##
Chris@82 325 ## Useful sed snippets. ##
Chris@82 326 ## -------------------- ##
Chris@82 327
Chris@82 328 sed_dirname='s|/[^/]*$||'
Chris@82 329 sed_basename='s|^.*/||'
Chris@82 330
Chris@82 331 # Sed substitution that helps us do robust quoting. It backslashifies
Chris@82 332 # metacharacters that are still active within double-quoted strings.
Chris@82 333 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
Chris@82 334
Chris@82 335 # Same as above, but do not quote variable references.
Chris@82 336 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
Chris@82 337
Chris@82 338 # Sed substitution that turns a string into a regex matching for the
Chris@82 339 # string literally.
Chris@82 340 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
Chris@82 341
Chris@82 342 # Sed substitution that converts a w32 file name or path
Chris@82 343 # that contains forward slashes, into one that contains
Chris@82 344 # (escaped) backslashes. A very naive implementation.
Chris@82 345 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
Chris@82 346
Chris@82 347 # Re-'\' parameter expansions in output of sed_double_quote_subst that
Chris@82 348 # were '\'-ed in input to the same. If an odd number of '\' preceded a
Chris@82 349 # '$' in input to sed_double_quote_subst, that '$' was protected from
Chris@82 350 # expansion. Since each input '\' is now two '\'s, look for any number
Chris@82 351 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
Chris@82 352 _G_bs='\\'
Chris@82 353 _G_bs2='\\\\'
Chris@82 354 _G_bs4='\\\\\\\\'
Chris@82 355 _G_dollar='\$'
Chris@82 356 sed_double_backslash="\
Chris@82 357 s/$_G_bs4/&\\
Chris@82 358 /g
Chris@82 359 s/^$_G_bs2$_G_dollar/$_G_bs&/
Chris@82 360 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
Chris@82 361 s/\n//g"
Chris@82 362
Chris@82 363
Chris@82 364 ## ----------------- ##
Chris@82 365 ## Global variables. ##
Chris@82 366 ## ----------------- ##
Chris@82 367
Chris@82 368 # Except for the global variables explicitly listed below, the following
Chris@82 369 # functions in the '^func_' namespace, and the '^require_' namespace
Chris@82 370 # variables initialised in the 'Resource management' section, sourcing
Chris@82 371 # this file will not pollute your global namespace with anything
Chris@82 372 # else. There's no portable way to scope variables in Bourne shell
Chris@82 373 # though, so actually running these functions will sometimes place
Chris@82 374 # results into a variable named after the function, and often use
Chris@82 375 # temporary variables in the '^_G_' namespace. If you are careful to
Chris@82 376 # avoid using those namespaces casually in your sourcing script, things
Chris@82 377 # should continue to work as you expect. And, of course, you can freely
Chris@82 378 # overwrite any of the functions or variables defined here before
Chris@82 379 # calling anything to customize them.
Chris@82 380
Chris@82 381 EXIT_SUCCESS=0
Chris@82 382 EXIT_FAILURE=1
Chris@82 383 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
Chris@82 384 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
Chris@82 385
Chris@82 386 # Allow overriding, eg assuming that you follow the convention of
Chris@82 387 # putting '$debug_cmd' at the start of all your functions, you can get
Chris@82 388 # bash to show function call trace with:
Chris@82 389 #
Chris@82 390 # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
Chris@82 391 debug_cmd=${debug_cmd-":"}
Chris@82 392 exit_cmd=:
Chris@82 393
Chris@82 394 # By convention, finish your script with:
Chris@82 395 #
Chris@82 396 # exit $exit_status
Chris@82 397 #
Chris@82 398 # so that you can set exit_status to non-zero if you want to indicate
Chris@82 399 # something went wrong during execution without actually bailing out at
Chris@82 400 # the point of failure.
Chris@82 401 exit_status=$EXIT_SUCCESS
Chris@82 402
Chris@82 403 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
Chris@82 404 # is ksh but when the shell is invoked as "sh" and the current value of
Chris@82 405 # the _XPG environment variable is not equal to 1 (one), the special
Chris@82 406 # positional parameter $0, within a function call, is the name of the
Chris@82 407 # function.
Chris@82 408 progpath=$0
Chris@82 409
Chris@82 410 # The name of this program.
Chris@82 411 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
Chris@82 412
Chris@82 413 # Make sure we have an absolute progpath for reexecution:
Chris@82 414 case $progpath in
Chris@82 415 [\\/]*|[A-Za-z]:\\*) ;;
Chris@82 416 *[\\/]*)
Chris@82 417 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
Chris@82 418 progdir=`cd "$progdir" && pwd`
Chris@82 419 progpath=$progdir/$progname
Chris@82 420 ;;
Chris@82 421 *)
Chris@82 422 _G_IFS=$IFS
Chris@82 423 IFS=${PATH_SEPARATOR-:}
Chris@82 424 for progdir in $PATH; do
Chris@82 425 IFS=$_G_IFS
Chris@82 426 test -x "$progdir/$progname" && break
Chris@82 427 done
Chris@82 428 IFS=$_G_IFS
Chris@82 429 test -n "$progdir" || progdir=`pwd`
Chris@82 430 progpath=$progdir/$progname
Chris@82 431 ;;
Chris@82 432 esac
Chris@82 433
Chris@82 434
Chris@82 435 ## ----------------- ##
Chris@82 436 ## Standard options. ##
Chris@82 437 ## ----------------- ##
Chris@82 438
Chris@82 439 # The following options affect the operation of the functions defined
Chris@82 440 # below, and should be set appropriately depending on run-time para-
Chris@82 441 # meters passed on the command line.
Chris@82 442
Chris@82 443 opt_dry_run=false
Chris@82 444 opt_quiet=false
Chris@82 445 opt_verbose=false
Chris@82 446
Chris@82 447 # Categories 'all' and 'none' are always available. Append any others
Chris@82 448 # you will pass as the first argument to func_warning from your own
Chris@82 449 # code.
Chris@82 450 warning_categories=
Chris@82 451
Chris@82 452 # By default, display warnings according to 'opt_warning_types'. Set
Chris@82 453 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
Chris@82 454 # treat the next displayed warning as a fatal error.
Chris@82 455 warning_func=func_warn_and_continue
Chris@82 456
Chris@82 457 # Set to 'all' to display all warnings, 'none' to suppress all
Chris@82 458 # warnings, or a space delimited list of some subset of
Chris@82 459 # 'warning_categories' to display only the listed warnings.
Chris@82 460 opt_warning_types=all
Chris@82 461
Chris@82 462
Chris@82 463 ## -------------------- ##
Chris@82 464 ## Resource management. ##
Chris@82 465 ## -------------------- ##
Chris@82 466
Chris@82 467 # This section contains definitions for functions that each ensure a
Chris@82 468 # particular resource (a file, or a non-empty configuration variable for
Chris@82 469 # example) is available, and if appropriate to extract default values
Chris@82 470 # from pertinent package files. Call them using their associated
Chris@82 471 # 'require_*' variable to ensure that they are executed, at most, once.
Chris@82 472 #
Chris@82 473 # It's entirely deliberate that calling these functions can set
Chris@82 474 # variables that don't obey the namespace limitations obeyed by the rest
Chris@82 475 # of this file, in order that that they be as useful as possible to
Chris@82 476 # callers.
Chris@82 477
Chris@82 478
Chris@82 479 # require_term_colors
Chris@82 480 # -------------------
Chris@82 481 # Allow display of bold text on terminals that support it.
Chris@82 482 require_term_colors=func_require_term_colors
Chris@82 483 func_require_term_colors ()
Chris@82 484 {
Chris@82 485 $debug_cmd
Chris@82 486
Chris@82 487 test -t 1 && {
Chris@82 488 # COLORTERM and USE_ANSI_COLORS environment variables take
Chris@82 489 # precedence, because most terminfo databases neglect to describe
Chris@82 490 # whether color sequences are supported.
Chris@82 491 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
Chris@82 492
Chris@82 493 if test 1 = "$USE_ANSI_COLORS"; then
Chris@82 494 # Standard ANSI escape sequences
Chris@82 495 tc_reset=''
Chris@82 496 tc_bold=''; tc_standout=''
Chris@82 497 tc_red=''; tc_green=''
Chris@82 498 tc_blue=''; tc_cyan=''
Chris@82 499 else
Chris@82 500 # Otherwise trust the terminfo database after all.
Chris@82 501 test -n "`tput sgr0 2>/dev/null`" && {
Chris@82 502 tc_reset=`tput sgr0`
Chris@82 503 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
Chris@82 504 tc_standout=$tc_bold
Chris@82 505 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
Chris@82 506 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
Chris@82 507 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
Chris@82 508 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
Chris@82 509 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
Chris@82 510 }
Chris@82 511 fi
Chris@82 512 }
Chris@82 513
Chris@82 514 require_term_colors=:
Chris@82 515 }
Chris@82 516
Chris@82 517
Chris@82 518 ## ----------------- ##
Chris@82 519 ## Function library. ##
Chris@82 520 ## ----------------- ##
Chris@82 521
Chris@82 522 # This section contains a variety of useful functions to call in your
Chris@82 523 # scripts. Take note of the portable wrappers for features provided by
Chris@82 524 # some modern shells, which will fall back to slower equivalents on
Chris@82 525 # less featureful shells.
Chris@82 526
Chris@82 527
Chris@82 528 # func_append VAR VALUE
Chris@82 529 # ---------------------
Chris@82 530 # Append VALUE onto the existing contents of VAR.
Chris@82 531
Chris@82 532 # We should try to minimise forks, especially on Windows where they are
Chris@82 533 # unreasonably slow, so skip the feature probes when bash or zsh are
Chris@82 534 # being used:
Chris@82 535 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
Chris@82 536 : ${_G_HAVE_ARITH_OP="yes"}
Chris@82 537 : ${_G_HAVE_XSI_OPS="yes"}
Chris@82 538 # The += operator was introduced in bash 3.1
Chris@82 539 case $BASH_VERSION in
Chris@82 540 [12].* | 3.0 | 3.0*) ;;
Chris@82 541 *)
Chris@82 542 : ${_G_HAVE_PLUSEQ_OP="yes"}
Chris@82 543 ;;
Chris@82 544 esac
Chris@82 545 fi
Chris@82 546
Chris@82 547 # _G_HAVE_PLUSEQ_OP
Chris@82 548 # Can be empty, in which case the shell is probed, "yes" if += is
Chris@82 549 # useable or anything else if it does not work.
Chris@82 550 test -z "$_G_HAVE_PLUSEQ_OP" \
Chris@82 551 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
Chris@82 552 && _G_HAVE_PLUSEQ_OP=yes
Chris@82 553
Chris@82 554 if test yes = "$_G_HAVE_PLUSEQ_OP"
Chris@82 555 then
Chris@82 556 # This is an XSI compatible shell, allowing a faster implementation...
Chris@82 557 eval 'func_append ()
Chris@82 558 {
Chris@82 559 $debug_cmd
Chris@82 560
Chris@82 561 eval "$1+=\$2"
Chris@82 562 }'
Chris@82 563 else
Chris@82 564 # ...otherwise fall back to using expr, which is often a shell builtin.
Chris@82 565 func_append ()
Chris@82 566 {
Chris@82 567 $debug_cmd
Chris@82 568
Chris@82 569 eval "$1=\$$1\$2"
Chris@82 570 }
Chris@82 571 fi
Chris@82 572
Chris@82 573
Chris@82 574 # func_append_quoted VAR VALUE
Chris@82 575 # ----------------------------
Chris@82 576 # Quote VALUE and append to the end of shell variable VAR, separated
Chris@82 577 # by a space.
Chris@82 578 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
Chris@82 579 eval 'func_append_quoted ()
Chris@82 580 {
Chris@82 581 $debug_cmd
Chris@82 582
Chris@82 583 func_quote_for_eval "$2"
Chris@82 584 eval "$1+=\\ \$func_quote_for_eval_result"
Chris@82 585 }'
Chris@82 586 else
Chris@82 587 func_append_quoted ()
Chris@82 588 {
Chris@82 589 $debug_cmd
Chris@82 590
Chris@82 591 func_quote_for_eval "$2"
Chris@82 592 eval "$1=\$$1\\ \$func_quote_for_eval_result"
Chris@82 593 }
Chris@82 594 fi
Chris@82 595
Chris@82 596
Chris@82 597 # func_append_uniq VAR VALUE
Chris@82 598 # --------------------------
Chris@82 599 # Append unique VALUE onto the existing contents of VAR, assuming
Chris@82 600 # entries are delimited by the first character of VALUE. For example:
Chris@82 601 #
Chris@82 602 # func_append_uniq options " --another-option option-argument"
Chris@82 603 #
Chris@82 604 # will only append to $options if " --another-option option-argument "
Chris@82 605 # is not already present somewhere in $options already (note spaces at
Chris@82 606 # each end implied by leading space in second argument).
Chris@82 607 func_append_uniq ()
Chris@82 608 {
Chris@82 609 $debug_cmd
Chris@82 610
Chris@82 611 eval _G_current_value='`$ECHO $'$1'`'
Chris@82 612 _G_delim=`expr "$2" : '\(.\)'`
Chris@82 613
Chris@82 614 case $_G_delim$_G_current_value$_G_delim in
Chris@82 615 *"$2$_G_delim"*) ;;
Chris@82 616 *) func_append "$@" ;;
Chris@82 617 esac
Chris@82 618 }
Chris@82 619
Chris@82 620
Chris@82 621 # func_arith TERM...
Chris@82 622 # ------------------
Chris@82 623 # Set func_arith_result to the result of evaluating TERMs.
Chris@82 624 test -z "$_G_HAVE_ARITH_OP" \
Chris@82 625 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
Chris@82 626 && _G_HAVE_ARITH_OP=yes
Chris@82 627
Chris@82 628 if test yes = "$_G_HAVE_ARITH_OP"; then
Chris@82 629 eval 'func_arith ()
Chris@82 630 {
Chris@82 631 $debug_cmd
Chris@82 632
Chris@82 633 func_arith_result=$(( $* ))
Chris@82 634 }'
Chris@82 635 else
Chris@82 636 func_arith ()
Chris@82 637 {
Chris@82 638 $debug_cmd
Chris@82 639
Chris@82 640 func_arith_result=`expr "$@"`
Chris@82 641 }
Chris@82 642 fi
Chris@82 643
Chris@82 644
Chris@82 645 # func_basename FILE
Chris@82 646 # ------------------
Chris@82 647 # Set func_basename_result to FILE with everything up to and including
Chris@82 648 # the last / stripped.
Chris@82 649 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@82 650 # If this shell supports suffix pattern removal, then use it to avoid
Chris@82 651 # forking. Hide the definitions single quotes in case the shell chokes
Chris@82 652 # on unsupported syntax...
Chris@82 653 _b='func_basename_result=${1##*/}'
Chris@82 654 _d='case $1 in
Chris@82 655 */*) func_dirname_result=${1%/*}$2 ;;
Chris@82 656 * ) func_dirname_result=$3 ;;
Chris@82 657 esac'
Chris@82 658
Chris@82 659 else
Chris@82 660 # ...otherwise fall back to using sed.
Chris@82 661 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
Chris@82 662 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
Chris@82 663 if test "X$func_dirname_result" = "X$1"; then
Chris@82 664 func_dirname_result=$3
Chris@82 665 else
Chris@82 666 func_append func_dirname_result "$2"
Chris@82 667 fi'
Chris@82 668 fi
Chris@82 669
Chris@82 670 eval 'func_basename ()
Chris@82 671 {
Chris@82 672 $debug_cmd
Chris@82 673
Chris@82 674 '"$_b"'
Chris@82 675 }'
Chris@82 676
Chris@82 677
Chris@82 678 # func_dirname FILE APPEND NONDIR_REPLACEMENT
Chris@82 679 # -------------------------------------------
Chris@82 680 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
Chris@82 681 # otherwise set result to NONDIR_REPLACEMENT.
Chris@82 682 eval 'func_dirname ()
Chris@82 683 {
Chris@82 684 $debug_cmd
Chris@82 685
Chris@82 686 '"$_d"'
Chris@82 687 }'
Chris@82 688
Chris@82 689
Chris@82 690 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
Chris@82 691 # --------------------------------------------------------
Chris@82 692 # Perform func_basename and func_dirname in a single function
Chris@82 693 # call:
Chris@82 694 # dirname: Compute the dirname of FILE. If nonempty,
Chris@82 695 # add APPEND to the result, otherwise set result
Chris@82 696 # to NONDIR_REPLACEMENT.
Chris@82 697 # value returned in "$func_dirname_result"
Chris@82 698 # basename: Compute filename of FILE.
Chris@82 699 # value retuned in "$func_basename_result"
Chris@82 700 # For efficiency, we do not delegate to the functions above but instead
Chris@82 701 # duplicate the functionality here.
Chris@82 702 eval 'func_dirname_and_basename ()
Chris@82 703 {
Chris@82 704 $debug_cmd
Chris@82 705
Chris@82 706 '"$_b"'
Chris@82 707 '"$_d"'
Chris@82 708 }'
Chris@82 709
Chris@82 710
Chris@82 711 # func_echo ARG...
Chris@82 712 # ----------------
Chris@82 713 # Echo program name prefixed message.
Chris@82 714 func_echo ()
Chris@82 715 {
Chris@82 716 $debug_cmd
Chris@82 717
Chris@82 718 _G_message=$*
Chris@82 719
Chris@82 720 func_echo_IFS=$IFS
Chris@82 721 IFS=$nl
Chris@82 722 for _G_line in $_G_message; do
Chris@82 723 IFS=$func_echo_IFS
Chris@82 724 $ECHO "$progname: $_G_line"
Chris@82 725 done
Chris@82 726 IFS=$func_echo_IFS
Chris@82 727 }
Chris@82 728
Chris@82 729
Chris@82 730 # func_echo_all ARG...
Chris@82 731 # --------------------
Chris@82 732 # Invoke $ECHO with all args, space-separated.
Chris@82 733 func_echo_all ()
Chris@82 734 {
Chris@82 735 $ECHO "$*"
Chris@82 736 }
Chris@82 737
Chris@82 738
Chris@82 739 # func_echo_infix_1 INFIX ARG...
Chris@82 740 # ------------------------------
Chris@82 741 # Echo program name, followed by INFIX on the first line, with any
Chris@82 742 # additional lines not showing INFIX.
Chris@82 743 func_echo_infix_1 ()
Chris@82 744 {
Chris@82 745 $debug_cmd
Chris@82 746
Chris@82 747 $require_term_colors
Chris@82 748
Chris@82 749 _G_infix=$1; shift
Chris@82 750 _G_indent=$_G_infix
Chris@82 751 _G_prefix="$progname: $_G_infix: "
Chris@82 752 _G_message=$*
Chris@82 753
Chris@82 754 # Strip color escape sequences before counting printable length
Chris@82 755 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
Chris@82 756 do
Chris@82 757 test -n "$_G_tc" && {
Chris@82 758 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
Chris@82 759 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
Chris@82 760 }
Chris@82 761 done
Chris@82 762 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
Chris@82 763
Chris@82 764 func_echo_infix_1_IFS=$IFS
Chris@82 765 IFS=$nl
Chris@82 766 for _G_line in $_G_message; do
Chris@82 767 IFS=$func_echo_infix_1_IFS
Chris@82 768 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
Chris@82 769 _G_prefix=$_G_indent
Chris@82 770 done
Chris@82 771 IFS=$func_echo_infix_1_IFS
Chris@82 772 }
Chris@82 773
Chris@82 774
Chris@82 775 # func_error ARG...
Chris@82 776 # -----------------
Chris@82 777 # Echo program name prefixed message to standard error.
Chris@82 778 func_error ()
Chris@82 779 {
Chris@82 780 $debug_cmd
Chris@82 781
Chris@82 782 $require_term_colors
Chris@82 783
Chris@82 784 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
Chris@82 785 }
Chris@82 786
Chris@82 787
Chris@82 788 # func_fatal_error ARG...
Chris@82 789 # -----------------------
Chris@82 790 # Echo program name prefixed message to standard error, and exit.
Chris@82 791 func_fatal_error ()
Chris@82 792 {
Chris@82 793 $debug_cmd
Chris@82 794
Chris@82 795 func_error "$*"
Chris@82 796 exit $EXIT_FAILURE
Chris@82 797 }
Chris@82 798
Chris@82 799
Chris@82 800 # func_grep EXPRESSION FILENAME
Chris@82 801 # -----------------------------
Chris@82 802 # Check whether EXPRESSION matches any line of FILENAME, without output.
Chris@82 803 func_grep ()
Chris@82 804 {
Chris@82 805 $debug_cmd
Chris@82 806
Chris@82 807 $GREP "$1" "$2" >/dev/null 2>&1
Chris@82 808 }
Chris@82 809
Chris@82 810
Chris@82 811 # func_len STRING
Chris@82 812 # ---------------
Chris@82 813 # Set func_len_result to the length of STRING. STRING may not
Chris@82 814 # start with a hyphen.
Chris@82 815 test -z "$_G_HAVE_XSI_OPS" \
Chris@82 816 && (eval 'x=a/b/c;
Chris@82 817 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
Chris@82 818 && _G_HAVE_XSI_OPS=yes
Chris@82 819
Chris@82 820 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@82 821 eval 'func_len ()
Chris@82 822 {
Chris@82 823 $debug_cmd
Chris@82 824
Chris@82 825 func_len_result=${#1}
Chris@82 826 }'
Chris@82 827 else
Chris@82 828 func_len ()
Chris@82 829 {
Chris@82 830 $debug_cmd
Chris@82 831
Chris@82 832 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
Chris@82 833 }
Chris@82 834 fi
Chris@82 835
Chris@82 836
Chris@82 837 # func_mkdir_p DIRECTORY-PATH
Chris@82 838 # ---------------------------
Chris@82 839 # Make sure the entire path to DIRECTORY-PATH is available.
Chris@82 840 func_mkdir_p ()
Chris@82 841 {
Chris@82 842 $debug_cmd
Chris@82 843
Chris@82 844 _G_directory_path=$1
Chris@82 845 _G_dir_list=
Chris@82 846
Chris@82 847 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
Chris@82 848
Chris@82 849 # Protect directory names starting with '-'
Chris@82 850 case $_G_directory_path in
Chris@82 851 -*) _G_directory_path=./$_G_directory_path ;;
Chris@82 852 esac
Chris@82 853
Chris@82 854 # While some portion of DIR does not yet exist...
Chris@82 855 while test ! -d "$_G_directory_path"; do
Chris@82 856 # ...make a list in topmost first order. Use a colon delimited
Chris@82 857 # list incase some portion of path contains whitespace.
Chris@82 858 _G_dir_list=$_G_directory_path:$_G_dir_list
Chris@82 859
Chris@82 860 # If the last portion added has no slash in it, the list is done
Chris@82 861 case $_G_directory_path in */*) ;; *) break ;; esac
Chris@82 862
Chris@82 863 # ...otherwise throw away the child directory and loop
Chris@82 864 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
Chris@82 865 done
Chris@82 866 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
Chris@82 867
Chris@82 868 func_mkdir_p_IFS=$IFS; IFS=:
Chris@82 869 for _G_dir in $_G_dir_list; do
Chris@82 870 IFS=$func_mkdir_p_IFS
Chris@82 871 # mkdir can fail with a 'File exist' error if two processes
Chris@82 872 # try to create one of the directories concurrently. Don't
Chris@82 873 # stop in that case!
Chris@82 874 $MKDIR "$_G_dir" 2>/dev/null || :
Chris@82 875 done
Chris@82 876 IFS=$func_mkdir_p_IFS
Chris@82 877
Chris@82 878 # Bail out if we (or some other process) failed to create a directory.
Chris@82 879 test -d "$_G_directory_path" || \
Chris@82 880 func_fatal_error "Failed to create '$1'"
Chris@82 881 fi
Chris@82 882 }
Chris@82 883
Chris@82 884
Chris@82 885 # func_mktempdir [BASENAME]
Chris@82 886 # -------------------------
Chris@82 887 # Make a temporary directory that won't clash with other running
Chris@82 888 # libtool processes, and avoids race conditions if possible. If
Chris@82 889 # given, BASENAME is the basename for that directory.
Chris@82 890 func_mktempdir ()
Chris@82 891 {
Chris@82 892 $debug_cmd
Chris@82 893
Chris@82 894 _G_template=${TMPDIR-/tmp}/${1-$progname}
Chris@82 895
Chris@82 896 if test : = "$opt_dry_run"; then
Chris@82 897 # Return a directory name, but don't create it in dry-run mode
Chris@82 898 _G_tmpdir=$_G_template-$$
Chris@82 899 else
Chris@82 900
Chris@82 901 # If mktemp works, use that first and foremost
Chris@82 902 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
Chris@82 903
Chris@82 904 if test ! -d "$_G_tmpdir"; then
Chris@82 905 # Failing that, at least try and use $RANDOM to avoid a race
Chris@82 906 _G_tmpdir=$_G_template-${RANDOM-0}$$
Chris@82 907
Chris@82 908 func_mktempdir_umask=`umask`
Chris@82 909 umask 0077
Chris@82 910 $MKDIR "$_G_tmpdir"
Chris@82 911 umask $func_mktempdir_umask
Chris@82 912 fi
Chris@82 913
Chris@82 914 # If we're not in dry-run mode, bomb out on failure
Chris@82 915 test -d "$_G_tmpdir" || \
Chris@82 916 func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
Chris@82 917 fi
Chris@82 918
Chris@82 919 $ECHO "$_G_tmpdir"
Chris@82 920 }
Chris@82 921
Chris@82 922
Chris@82 923 # func_normal_abspath PATH
Chris@82 924 # ------------------------
Chris@82 925 # Remove doubled-up and trailing slashes, "." path components,
Chris@82 926 # and cancel out any ".." path components in PATH after making
Chris@82 927 # it an absolute path.
Chris@82 928 func_normal_abspath ()
Chris@82 929 {
Chris@82 930 $debug_cmd
Chris@82 931
Chris@82 932 # These SED scripts presuppose an absolute path with a trailing slash.
Chris@82 933 _G_pathcar='s|^/\([^/]*\).*$|\1|'
Chris@82 934 _G_pathcdr='s|^/[^/]*||'
Chris@82 935 _G_removedotparts=':dotsl
Chris@82 936 s|/\./|/|g
Chris@82 937 t dotsl
Chris@82 938 s|/\.$|/|'
Chris@82 939 _G_collapseslashes='s|/\{1,\}|/|g'
Chris@82 940 _G_finalslash='s|/*$|/|'
Chris@82 941
Chris@82 942 # Start from root dir and reassemble the path.
Chris@82 943 func_normal_abspath_result=
Chris@82 944 func_normal_abspath_tpath=$1
Chris@82 945 func_normal_abspath_altnamespace=
Chris@82 946 case $func_normal_abspath_tpath in
Chris@82 947 "")
Chris@82 948 # Empty path, that just means $cwd.
Chris@82 949 func_stripname '' '/' "`pwd`"
Chris@82 950 func_normal_abspath_result=$func_stripname_result
Chris@82 951 return
Chris@82 952 ;;
Chris@82 953 # The next three entries are used to spot a run of precisely
Chris@82 954 # two leading slashes without using negated character classes;
Chris@82 955 # we take advantage of case's first-match behaviour.
Chris@82 956 ///*)
Chris@82 957 # Unusual form of absolute path, do nothing.
Chris@82 958 ;;
Chris@82 959 //*)
Chris@82 960 # Not necessarily an ordinary path; POSIX reserves leading '//'
Chris@82 961 # and for example Cygwin uses it to access remote file shares
Chris@82 962 # over CIFS/SMB, so we conserve a leading double slash if found.
Chris@82 963 func_normal_abspath_altnamespace=/
Chris@82 964 ;;
Chris@82 965 /*)
Chris@82 966 # Absolute path, do nothing.
Chris@82 967 ;;
Chris@82 968 *)
Chris@82 969 # Relative path, prepend $cwd.
Chris@82 970 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
Chris@82 971 ;;
Chris@82 972 esac
Chris@82 973
Chris@82 974 # Cancel out all the simple stuff to save iterations. We also want
Chris@82 975 # the path to end with a slash for ease of parsing, so make sure
Chris@82 976 # there is one (and only one) here.
Chris@82 977 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
Chris@82 978 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
Chris@82 979 while :; do
Chris@82 980 # Processed it all yet?
Chris@82 981 if test / = "$func_normal_abspath_tpath"; then
Chris@82 982 # If we ascended to the root using ".." the result may be empty now.
Chris@82 983 if test -z "$func_normal_abspath_result"; then
Chris@82 984 func_normal_abspath_result=/
Chris@82 985 fi
Chris@82 986 break
Chris@82 987 fi
Chris@82 988 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
Chris@82 989 -e "$_G_pathcar"`
Chris@82 990 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
Chris@82 991 -e "$_G_pathcdr"`
Chris@82 992 # Figure out what to do with it
Chris@82 993 case $func_normal_abspath_tcomponent in
Chris@82 994 "")
Chris@82 995 # Trailing empty path component, ignore it.
Chris@82 996 ;;
Chris@82 997 ..)
Chris@82 998 # Parent dir; strip last assembled component from result.
Chris@82 999 func_dirname "$func_normal_abspath_result"
Chris@82 1000 func_normal_abspath_result=$func_dirname_result
Chris@82 1001 ;;
Chris@82 1002 *)
Chris@82 1003 # Actual path component, append it.
Chris@82 1004 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
Chris@82 1005 ;;
Chris@82 1006 esac
Chris@82 1007 done
Chris@82 1008 # Restore leading double-slash if one was found on entry.
Chris@82 1009 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
Chris@82 1010 }
Chris@82 1011
Chris@82 1012
Chris@82 1013 # func_notquiet ARG...
Chris@82 1014 # --------------------
Chris@82 1015 # Echo program name prefixed message only when not in quiet mode.
Chris@82 1016 func_notquiet ()
Chris@82 1017 {
Chris@82 1018 $debug_cmd
Chris@82 1019
Chris@82 1020 $opt_quiet || func_echo ${1+"$@"}
Chris@82 1021
Chris@82 1022 # A bug in bash halts the script if the last line of a function
Chris@82 1023 # fails when set -e is in force, so we need another command to
Chris@82 1024 # work around that:
Chris@82 1025 :
Chris@82 1026 }
Chris@82 1027
Chris@82 1028
Chris@82 1029 # func_relative_path SRCDIR DSTDIR
Chris@82 1030 # --------------------------------
Chris@82 1031 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
Chris@82 1032 func_relative_path ()
Chris@82 1033 {
Chris@82 1034 $debug_cmd
Chris@82 1035
Chris@82 1036 func_relative_path_result=
Chris@82 1037 func_normal_abspath "$1"
Chris@82 1038 func_relative_path_tlibdir=$func_normal_abspath_result
Chris@82 1039 func_normal_abspath "$2"
Chris@82 1040 func_relative_path_tbindir=$func_normal_abspath_result
Chris@82 1041
Chris@82 1042 # Ascend the tree starting from libdir
Chris@82 1043 while :; do
Chris@82 1044 # check if we have found a prefix of bindir
Chris@82 1045 case $func_relative_path_tbindir in
Chris@82 1046 $func_relative_path_tlibdir)
Chris@82 1047 # found an exact match
Chris@82 1048 func_relative_path_tcancelled=
Chris@82 1049 break
Chris@82 1050 ;;
Chris@82 1051 $func_relative_path_tlibdir*)
Chris@82 1052 # found a matching prefix
Chris@82 1053 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
Chris@82 1054 func_relative_path_tcancelled=$func_stripname_result
Chris@82 1055 if test -z "$func_relative_path_result"; then
Chris@82 1056 func_relative_path_result=.
Chris@82 1057 fi
Chris@82 1058 break
Chris@82 1059 ;;
Chris@82 1060 *)
Chris@82 1061 func_dirname $func_relative_path_tlibdir
Chris@82 1062 func_relative_path_tlibdir=$func_dirname_result
Chris@82 1063 if test -z "$func_relative_path_tlibdir"; then
Chris@82 1064 # Have to descend all the way to the root!
Chris@82 1065 func_relative_path_result=../$func_relative_path_result
Chris@82 1066 func_relative_path_tcancelled=$func_relative_path_tbindir
Chris@82 1067 break
Chris@82 1068 fi
Chris@82 1069 func_relative_path_result=../$func_relative_path_result
Chris@82 1070 ;;
Chris@82 1071 esac
Chris@82 1072 done
Chris@82 1073
Chris@82 1074 # Now calculate path; take care to avoid doubling-up slashes.
Chris@82 1075 func_stripname '' '/' "$func_relative_path_result"
Chris@82 1076 func_relative_path_result=$func_stripname_result
Chris@82 1077 func_stripname '/' '/' "$func_relative_path_tcancelled"
Chris@82 1078 if test -n "$func_stripname_result"; then
Chris@82 1079 func_append func_relative_path_result "/$func_stripname_result"
Chris@82 1080 fi
Chris@82 1081
Chris@82 1082 # Normalisation. If bindir is libdir, return '.' else relative path.
Chris@82 1083 if test -n "$func_relative_path_result"; then
Chris@82 1084 func_stripname './' '' "$func_relative_path_result"
Chris@82 1085 func_relative_path_result=$func_stripname_result
Chris@82 1086 fi
Chris@82 1087
Chris@82 1088 test -n "$func_relative_path_result" || func_relative_path_result=.
Chris@82 1089
Chris@82 1090 :
Chris@82 1091 }
Chris@82 1092
Chris@82 1093
Chris@82 1094 # func_quote_for_eval ARG...
Chris@82 1095 # --------------------------
Chris@82 1096 # Aesthetically quote ARGs to be evaled later.
Chris@82 1097 # This function returns two values:
Chris@82 1098 # i) func_quote_for_eval_result
Chris@82 1099 # double-quoted, suitable for a subsequent eval
Chris@82 1100 # ii) func_quote_for_eval_unquoted_result
Chris@82 1101 # has all characters that are still active within double
Chris@82 1102 # quotes backslashified.
Chris@82 1103 func_quote_for_eval ()
Chris@82 1104 {
Chris@82 1105 $debug_cmd
Chris@82 1106
Chris@82 1107 func_quote_for_eval_unquoted_result=
Chris@82 1108 func_quote_for_eval_result=
Chris@82 1109 while test 0 -lt $#; do
Chris@82 1110 case $1 in
Chris@82 1111 *[\\\`\"\$]*)
Chris@82 1112 _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
Chris@82 1113 *)
Chris@82 1114 _G_unquoted_arg=$1 ;;
Chris@82 1115 esac
Chris@82 1116 if test -n "$func_quote_for_eval_unquoted_result"; then
Chris@82 1117 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
Chris@82 1118 else
Chris@82 1119 func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
Chris@82 1120 fi
Chris@82 1121
Chris@82 1122 case $_G_unquoted_arg in
Chris@82 1123 # Double-quote args containing shell metacharacters to delay
Chris@82 1124 # word splitting, command substitution and variable expansion
Chris@82 1125 # for a subsequent eval.
Chris@82 1126 # Many Bourne shells cannot handle close brackets correctly
Chris@82 1127 # in scan sets, so we specify it separately.
Chris@82 1128 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
Chris@82 1129 _G_quoted_arg=\"$_G_unquoted_arg\"
Chris@82 1130 ;;
Chris@82 1131 *)
Chris@82 1132 _G_quoted_arg=$_G_unquoted_arg
Chris@82 1133 ;;
Chris@82 1134 esac
Chris@82 1135
Chris@82 1136 if test -n "$func_quote_for_eval_result"; then
Chris@82 1137 func_append func_quote_for_eval_result " $_G_quoted_arg"
Chris@82 1138 else
Chris@82 1139 func_append func_quote_for_eval_result "$_G_quoted_arg"
Chris@82 1140 fi
Chris@82 1141 shift
Chris@82 1142 done
Chris@82 1143 }
Chris@82 1144
Chris@82 1145
Chris@82 1146 # func_quote_for_expand ARG
Chris@82 1147 # -------------------------
Chris@82 1148 # Aesthetically quote ARG to be evaled later; same as above,
Chris@82 1149 # but do not quote variable references.
Chris@82 1150 func_quote_for_expand ()
Chris@82 1151 {
Chris@82 1152 $debug_cmd
Chris@82 1153
Chris@82 1154 case $1 in
Chris@82 1155 *[\\\`\"]*)
Chris@82 1156 _G_arg=`$ECHO "$1" | $SED \
Chris@82 1157 -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
Chris@82 1158 *)
Chris@82 1159 _G_arg=$1 ;;
Chris@82 1160 esac
Chris@82 1161
Chris@82 1162 case $_G_arg in
Chris@82 1163 # Double-quote args containing shell metacharacters to delay
Chris@82 1164 # word splitting and command substitution for a subsequent eval.
Chris@82 1165 # Many Bourne shells cannot handle close brackets correctly
Chris@82 1166 # in scan sets, so we specify it separately.
Chris@82 1167 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
Chris@82 1168 _G_arg=\"$_G_arg\"
Chris@82 1169 ;;
Chris@82 1170 esac
Chris@82 1171
Chris@82 1172 func_quote_for_expand_result=$_G_arg
Chris@82 1173 }
Chris@82 1174
Chris@82 1175
Chris@82 1176 # func_stripname PREFIX SUFFIX NAME
Chris@82 1177 # ---------------------------------
Chris@82 1178 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
Chris@82 1179 # PREFIX and SUFFIX must not contain globbing or regex special
Chris@82 1180 # characters, hashes, percent signs, but SUFFIX may contain a leading
Chris@82 1181 # dot (in which case that matches only a dot).
Chris@82 1182 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@82 1183 eval 'func_stripname ()
Chris@82 1184 {
Chris@82 1185 $debug_cmd
Chris@82 1186
Chris@82 1187 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
Chris@82 1188 # positional parameters, so assign one to ordinary variable first.
Chris@82 1189 func_stripname_result=$3
Chris@82 1190 func_stripname_result=${func_stripname_result#"$1"}
Chris@82 1191 func_stripname_result=${func_stripname_result%"$2"}
Chris@82 1192 }'
Chris@82 1193 else
Chris@82 1194 func_stripname ()
Chris@82 1195 {
Chris@82 1196 $debug_cmd
Chris@82 1197
Chris@82 1198 case $2 in
Chris@82 1199 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
Chris@82 1200 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
Chris@82 1201 esac
Chris@82 1202 }
Chris@82 1203 fi
Chris@82 1204
Chris@82 1205
Chris@82 1206 # func_show_eval CMD [FAIL_EXP]
Chris@82 1207 # -----------------------------
Chris@82 1208 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
Chris@82 1209 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
Chris@82 1210 # is given, then evaluate it.
Chris@82 1211 func_show_eval ()
Chris@82 1212 {
Chris@82 1213 $debug_cmd
Chris@82 1214
Chris@82 1215 _G_cmd=$1
Chris@82 1216 _G_fail_exp=${2-':'}
Chris@82 1217
Chris@82 1218 func_quote_for_expand "$_G_cmd"
Chris@82 1219 eval "func_notquiet $func_quote_for_expand_result"
Chris@82 1220
Chris@82 1221 $opt_dry_run || {
Chris@82 1222 eval "$_G_cmd"
Chris@82 1223 _G_status=$?
Chris@82 1224 if test 0 -ne "$_G_status"; then
Chris@82 1225 eval "(exit $_G_status); $_G_fail_exp"
Chris@82 1226 fi
Chris@82 1227 }
Chris@82 1228 }
Chris@82 1229
Chris@82 1230
Chris@82 1231 # func_show_eval_locale CMD [FAIL_EXP]
Chris@82 1232 # ------------------------------------
Chris@82 1233 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
Chris@82 1234 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
Chris@82 1235 # is given, then evaluate it. Use the saved locale for evaluation.
Chris@82 1236 func_show_eval_locale ()
Chris@82 1237 {
Chris@82 1238 $debug_cmd
Chris@82 1239
Chris@82 1240 _G_cmd=$1
Chris@82 1241 _G_fail_exp=${2-':'}
Chris@82 1242
Chris@82 1243 $opt_quiet || {
Chris@82 1244 func_quote_for_expand "$_G_cmd"
Chris@82 1245 eval "func_echo $func_quote_for_expand_result"
Chris@82 1246 }
Chris@82 1247
Chris@82 1248 $opt_dry_run || {
Chris@82 1249 eval "$_G_user_locale
Chris@82 1250 $_G_cmd"
Chris@82 1251 _G_status=$?
Chris@82 1252 eval "$_G_safe_locale"
Chris@82 1253 if test 0 -ne "$_G_status"; then
Chris@82 1254 eval "(exit $_G_status); $_G_fail_exp"
Chris@82 1255 fi
Chris@82 1256 }
Chris@82 1257 }
Chris@82 1258
Chris@82 1259
Chris@82 1260 # func_tr_sh
Chris@82 1261 # ----------
Chris@82 1262 # Turn $1 into a string suitable for a shell variable name.
Chris@82 1263 # Result is stored in $func_tr_sh_result. All characters
Chris@82 1264 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
Chris@82 1265 # if $1 begins with a digit, a '_' is prepended as well.
Chris@82 1266 func_tr_sh ()
Chris@82 1267 {
Chris@82 1268 $debug_cmd
Chris@82 1269
Chris@82 1270 case $1 in
Chris@82 1271 [0-9]* | *[!a-zA-Z0-9_]*)
Chris@82 1272 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
Chris@82 1273 ;;
Chris@82 1274 * )
Chris@82 1275 func_tr_sh_result=$1
Chris@82 1276 ;;
Chris@82 1277 esac
Chris@82 1278 }
Chris@82 1279
Chris@82 1280
Chris@82 1281 # func_verbose ARG...
Chris@82 1282 # -------------------
Chris@82 1283 # Echo program name prefixed message in verbose mode only.
Chris@82 1284 func_verbose ()
Chris@82 1285 {
Chris@82 1286 $debug_cmd
Chris@82 1287
Chris@82 1288 $opt_verbose && func_echo "$*"
Chris@82 1289
Chris@82 1290 :
Chris@82 1291 }
Chris@82 1292
Chris@82 1293
Chris@82 1294 # func_warn_and_continue ARG...
Chris@82 1295 # -----------------------------
Chris@82 1296 # Echo program name prefixed warning message to standard error.
Chris@82 1297 func_warn_and_continue ()
Chris@82 1298 {
Chris@82 1299 $debug_cmd
Chris@82 1300
Chris@82 1301 $require_term_colors
Chris@82 1302
Chris@82 1303 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
Chris@82 1304 }
Chris@82 1305
Chris@82 1306
Chris@82 1307 # func_warning CATEGORY ARG...
Chris@82 1308 # ----------------------------
Chris@82 1309 # Echo program name prefixed warning message to standard error. Warning
Chris@82 1310 # messages can be filtered according to CATEGORY, where this function
Chris@82 1311 # elides messages where CATEGORY is not listed in the global variable
Chris@82 1312 # 'opt_warning_types'.
Chris@82 1313 func_warning ()
Chris@82 1314 {
Chris@82 1315 $debug_cmd
Chris@82 1316
Chris@82 1317 # CATEGORY must be in the warning_categories list!
Chris@82 1318 case " $warning_categories " in
Chris@82 1319 *" $1 "*) ;;
Chris@82 1320 *) func_internal_error "invalid warning category '$1'" ;;
Chris@82 1321 esac
Chris@82 1322
Chris@82 1323 _G_category=$1
Chris@82 1324 shift
Chris@82 1325
Chris@82 1326 case " $opt_warning_types " in
Chris@82 1327 *" $_G_category "*) $warning_func ${1+"$@"} ;;
Chris@82 1328 esac
Chris@82 1329 }
Chris@82 1330
Chris@82 1331
Chris@82 1332 # func_sort_ver VER1 VER2
Chris@82 1333 # -----------------------
Chris@82 1334 # 'sort -V' is not generally available.
Chris@82 1335 # Note this deviates from the version comparison in automake
Chris@82 1336 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
Chris@82 1337 # but this should suffice as we won't be specifying old
Chris@82 1338 # version formats or redundant trailing .0 in bootstrap.conf.
Chris@82 1339 # If we did want full compatibility then we should probably
Chris@82 1340 # use m4_version_compare from autoconf.
Chris@82 1341 func_sort_ver ()
Chris@82 1342 {
Chris@82 1343 $debug_cmd
Chris@82 1344
Chris@82 1345 printf '%s\n%s\n' "$1" "$2" \
Chris@82 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@82 1347 }
Chris@82 1348
Chris@82 1349 # func_lt_ver PREV CURR
Chris@82 1350 # ---------------------
Chris@82 1351 # Return true if PREV and CURR are in the correct order according to
Chris@82 1352 # func_sort_ver, otherwise false. Use it like this:
Chris@82 1353 #
Chris@82 1354 # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
Chris@82 1355 func_lt_ver ()
Chris@82 1356 {
Chris@82 1357 $debug_cmd
Chris@82 1358
Chris@82 1359 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
Chris@82 1360 }
Chris@82 1361
Chris@82 1362
Chris@82 1363 # Local variables:
Chris@82 1364 # mode: shell-script
Chris@82 1365 # sh-indentation: 2
Chris@82 1366 # eval: (add-hook 'before-save-hook 'time-stamp)
Chris@82 1367 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
Chris@82 1368 # time-stamp-time-zone: "UTC"
Chris@82 1369 # End:
Chris@82 1370 #! /bin/sh
Chris@82 1371
Chris@82 1372 # Set a version string for this script.
Chris@82 1373 scriptversion=2014-01-07.03; # UTC
Chris@82 1374
Chris@82 1375 # A portable, pluggable option parser for Bourne shell.
Chris@82 1376 # Written by Gary V. Vaughan, 2010
Chris@82 1377
Chris@82 1378 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
Chris@82 1379 # This is free software; see the source for copying conditions. There is NO
Chris@82 1380 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
Chris@82 1381
Chris@82 1382 # This program is free software: you can redistribute it and/or modify
Chris@82 1383 # it under the terms of the GNU General Public License as published by
Chris@82 1384 # the Free Software Foundation, either version 3 of the License, or
Chris@82 1385 # (at your option) any later version.
Chris@82 1386
Chris@82 1387 # This program is distributed in the hope that it will be useful,
Chris@82 1388 # but WITHOUT ANY WARRANTY; without even the implied warranty of
Chris@82 1389 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
Chris@82 1390 # GNU General Public License for more details.
Chris@82 1391
Chris@82 1392 # You should have received a copy of the GNU General Public License
Chris@82 1393 # along with this program. If not, see <http://www.gnu.org/licenses/>.
Chris@82 1394
Chris@82 1395 # Please report bugs or propose patches to gary@gnu.org.
Chris@82 1396
Chris@82 1397
Chris@82 1398 ## ------ ##
Chris@82 1399 ## Usage. ##
Chris@82 1400 ## ------ ##
Chris@82 1401
Chris@82 1402 # This file is a library for parsing options in your shell scripts along
Chris@82 1403 # with assorted other useful supporting features that you can make use
Chris@82 1404 # of too.
Chris@82 1405 #
Chris@82 1406 # For the simplest scripts you might need only:
Chris@82 1407 #
Chris@82 1408 # #!/bin/sh
Chris@82 1409 # . relative/path/to/funclib.sh
Chris@82 1410 # . relative/path/to/options-parser
Chris@82 1411 # scriptversion=1.0
Chris@82 1412 # func_options ${1+"$@"}
Chris@82 1413 # eval set dummy "$func_options_result"; shift
Chris@82 1414 # ...rest of your script...
Chris@82 1415 #
Chris@82 1416 # In order for the '--version' option to work, you will need to have a
Chris@82 1417 # suitably formatted comment like the one at the top of this file
Chris@82 1418 # starting with '# Written by ' and ending with '# warranty; '.
Chris@82 1419 #
Chris@82 1420 # For '-h' and '--help' to work, you will also need a one line
Chris@82 1421 # description of your script's purpose in a comment directly above the
Chris@82 1422 # '# Written by ' line, like the one at the top of this file.
Chris@82 1423 #
Chris@82 1424 # The default options also support '--debug', which will turn on shell
Chris@82 1425 # execution tracing (see the comment above debug_cmd below for another
Chris@82 1426 # use), and '--verbose' and the func_verbose function to allow your script
Chris@82 1427 # to display verbose messages only when your user has specified
Chris@82 1428 # '--verbose'.
Chris@82 1429 #
Chris@82 1430 # After sourcing this file, you can plug processing for additional
Chris@82 1431 # options by amending the variables from the 'Configuration' section
Chris@82 1432 # below, and following the instructions in the 'Option parsing'
Chris@82 1433 # section further down.
Chris@82 1434
Chris@82 1435 ## -------------- ##
Chris@82 1436 ## Configuration. ##
Chris@82 1437 ## -------------- ##
Chris@82 1438
Chris@82 1439 # You should override these variables in your script after sourcing this
Chris@82 1440 # file so that they reflect the customisations you have added to the
Chris@82 1441 # option parser.
Chris@82 1442
Chris@82 1443 # The usage line for option parsing errors and the start of '-h' and
Chris@82 1444 # '--help' output messages. You can embed shell variables for delayed
Chris@82 1445 # expansion at the time the message is displayed, but you will need to
Chris@82 1446 # quote other shell meta-characters carefully to prevent them being
Chris@82 1447 # expanded when the contents are evaled.
Chris@82 1448 usage='$progpath [OPTION]...'
Chris@82 1449
Chris@82 1450 # Short help message in response to '-h' and '--help'. Add to this or
Chris@82 1451 # override it after sourcing this library to reflect the full set of
Chris@82 1452 # options your script accepts.
Chris@82 1453 usage_message="\
Chris@82 1454 --debug enable verbose shell tracing
Chris@82 1455 -W, --warnings=CATEGORY
Chris@82 1456 report the warnings falling in CATEGORY [all]
Chris@82 1457 -v, --verbose verbosely report processing
Chris@82 1458 --version print version information and exit
Chris@82 1459 -h, --help print short or long help message and exit
Chris@82 1460 "
Chris@82 1461
Chris@82 1462 # Additional text appended to 'usage_message' in response to '--help'.
Chris@82 1463 long_help_message="
Chris@82 1464 Warning categories include:
Chris@82 1465 'all' show all warnings
Chris@82 1466 'none' turn off all the warnings
Chris@82 1467 'error' warnings are treated as fatal errors"
Chris@82 1468
Chris@82 1469 # Help message printed before fatal option parsing errors.
Chris@82 1470 fatal_help="Try '\$progname --help' for more information."
Chris@82 1471
Chris@82 1472
Chris@82 1473
Chris@82 1474 ## ------------------------- ##
Chris@82 1475 ## Hook function management. ##
Chris@82 1476 ## ------------------------- ##
Chris@82 1477
Chris@82 1478 # This section contains functions for adding, removing, and running hooks
Chris@82 1479 # to the main code. A hook is just a named list of of function, that can
Chris@82 1480 # be run in order later on.
Chris@82 1481
Chris@82 1482 # func_hookable FUNC_NAME
Chris@82 1483 # -----------------------
Chris@82 1484 # Declare that FUNC_NAME will run hooks added with
Chris@82 1485 # 'func_add_hook FUNC_NAME ...'.
Chris@82 1486 func_hookable ()
Chris@82 1487 {
Chris@82 1488 $debug_cmd
Chris@82 1489
Chris@82 1490 func_append hookable_fns " $1"
Chris@82 1491 }
Chris@82 1492
Chris@82 1493
Chris@82 1494 # func_add_hook FUNC_NAME HOOK_FUNC
Chris@82 1495 # ---------------------------------
Chris@82 1496 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
Chris@82 1497 # first have been declared "hookable" by a call to 'func_hookable'.
Chris@82 1498 func_add_hook ()
Chris@82 1499 {
Chris@82 1500 $debug_cmd
Chris@82 1501
Chris@82 1502 case " $hookable_fns " in
Chris@82 1503 *" $1 "*) ;;
Chris@82 1504 *) func_fatal_error "'$1' does not accept hook functions." ;;
Chris@82 1505 esac
Chris@82 1506
Chris@82 1507 eval func_append ${1}_hooks '" $2"'
Chris@82 1508 }
Chris@82 1509
Chris@82 1510
Chris@82 1511 # func_remove_hook FUNC_NAME HOOK_FUNC
Chris@82 1512 # ------------------------------------
Chris@82 1513 # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
Chris@82 1514 func_remove_hook ()
Chris@82 1515 {
Chris@82 1516 $debug_cmd
Chris@82 1517
Chris@82 1518 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
Chris@82 1519 }
Chris@82 1520
Chris@82 1521
Chris@82 1522 # func_run_hooks FUNC_NAME [ARG]...
Chris@82 1523 # ---------------------------------
Chris@82 1524 # Run all hook functions registered to FUNC_NAME.
Chris@82 1525 # It is assumed that the list of hook functions contains nothing more
Chris@82 1526 # than a whitespace-delimited list of legal shell function names, and
Chris@82 1527 # no effort is wasted trying to catch shell meta-characters or preserve
Chris@82 1528 # whitespace.
Chris@82 1529 func_run_hooks ()
Chris@82 1530 {
Chris@82 1531 $debug_cmd
Chris@82 1532
Chris@82 1533 case " $hookable_fns " in
Chris@82 1534 *" $1 "*) ;;
Chris@82 1535 *) func_fatal_error "'$1' does not support hook funcions.n" ;;
Chris@82 1536 esac
Chris@82 1537
Chris@82 1538 eval _G_hook_fns=\$$1_hooks; shift
Chris@82 1539
Chris@82 1540 for _G_hook in $_G_hook_fns; do
Chris@82 1541 eval $_G_hook '"$@"'
Chris@82 1542
Chris@82 1543 # store returned options list back into positional
Chris@82 1544 # parameters for next 'cmd' execution.
Chris@82 1545 eval _G_hook_result=\$${_G_hook}_result
Chris@82 1546 eval set dummy "$_G_hook_result"; shift
Chris@82 1547 done
Chris@82 1548
Chris@82 1549 func_quote_for_eval ${1+"$@"}
Chris@82 1550 func_run_hooks_result=$func_quote_for_eval_result
Chris@82 1551 }
Chris@82 1552
Chris@82 1553
Chris@82 1554
Chris@82 1555 ## --------------- ##
Chris@82 1556 ## Option parsing. ##
Chris@82 1557 ## --------------- ##
Chris@82 1558
Chris@82 1559 # In order to add your own option parsing hooks, you must accept the
Chris@82 1560 # full positional parameter list in your hook function, remove any
Chris@82 1561 # options that you action, and then pass back the remaining unprocessed
Chris@82 1562 # options in '<hooked_function_name>_result', escaped suitably for
Chris@82 1563 # 'eval'. Like this:
Chris@82 1564 #
Chris@82 1565 # my_options_prep ()
Chris@82 1566 # {
Chris@82 1567 # $debug_cmd
Chris@82 1568 #
Chris@82 1569 # # Extend the existing usage message.
Chris@82 1570 # usage_message=$usage_message'
Chris@82 1571 # -s, --silent don'\''t print informational messages
Chris@82 1572 # '
Chris@82 1573 #
Chris@82 1574 # func_quote_for_eval ${1+"$@"}
Chris@82 1575 # my_options_prep_result=$func_quote_for_eval_result
Chris@82 1576 # }
Chris@82 1577 # func_add_hook func_options_prep my_options_prep
Chris@82 1578 #
Chris@82 1579 #
Chris@82 1580 # my_silent_option ()
Chris@82 1581 # {
Chris@82 1582 # $debug_cmd
Chris@82 1583 #
Chris@82 1584 # # Note that for efficiency, we parse as many options as we can
Chris@82 1585 # # recognise in a loop before passing the remainder back to the
Chris@82 1586 # # caller on the first unrecognised argument we encounter.
Chris@82 1587 # while test $# -gt 0; do
Chris@82 1588 # opt=$1; shift
Chris@82 1589 # case $opt in
Chris@82 1590 # --silent|-s) opt_silent=: ;;
Chris@82 1591 # # Separate non-argument short options:
Chris@82 1592 # -s*) func_split_short_opt "$_G_opt"
Chris@82 1593 # set dummy "$func_split_short_opt_name" \
Chris@82 1594 # "-$func_split_short_opt_arg" ${1+"$@"}
Chris@82 1595 # shift
Chris@82 1596 # ;;
Chris@82 1597 # *) set dummy "$_G_opt" "$*"; shift; break ;;
Chris@82 1598 # esac
Chris@82 1599 # done
Chris@82 1600 #
Chris@82 1601 # func_quote_for_eval ${1+"$@"}
Chris@82 1602 # my_silent_option_result=$func_quote_for_eval_result
Chris@82 1603 # }
Chris@82 1604 # func_add_hook func_parse_options my_silent_option
Chris@82 1605 #
Chris@82 1606 #
Chris@82 1607 # my_option_validation ()
Chris@82 1608 # {
Chris@82 1609 # $debug_cmd
Chris@82 1610 #
Chris@82 1611 # $opt_silent && $opt_verbose && func_fatal_help "\
Chris@82 1612 # '--silent' and '--verbose' options are mutually exclusive."
Chris@82 1613 #
Chris@82 1614 # func_quote_for_eval ${1+"$@"}
Chris@82 1615 # my_option_validation_result=$func_quote_for_eval_result
Chris@82 1616 # }
Chris@82 1617 # func_add_hook func_validate_options my_option_validation
Chris@82 1618 #
Chris@82 1619 # You'll alse need to manually amend $usage_message to reflect the extra
Chris@82 1620 # options you parse. It's preferable to append if you can, so that
Chris@82 1621 # multiple option parsing hooks can be added safely.
Chris@82 1622
Chris@82 1623
Chris@82 1624 # func_options [ARG]...
Chris@82 1625 # ---------------------
Chris@82 1626 # All the functions called inside func_options are hookable. See the
Chris@82 1627 # individual implementations for details.
Chris@82 1628 func_hookable func_options
Chris@82 1629 func_options ()
Chris@82 1630 {
Chris@82 1631 $debug_cmd
Chris@82 1632
Chris@82 1633 func_options_prep ${1+"$@"}
Chris@82 1634 eval func_parse_options \
Chris@82 1635 ${func_options_prep_result+"$func_options_prep_result"}
Chris@82 1636 eval func_validate_options \
Chris@82 1637 ${func_parse_options_result+"$func_parse_options_result"}
Chris@82 1638
Chris@82 1639 eval func_run_hooks func_options \
Chris@82 1640 ${func_validate_options_result+"$func_validate_options_result"}
Chris@82 1641
Chris@82 1642 # save modified positional parameters for caller
Chris@82 1643 func_options_result=$func_run_hooks_result
Chris@82 1644 }
Chris@82 1645
Chris@82 1646
Chris@82 1647 # func_options_prep [ARG]...
Chris@82 1648 # --------------------------
Chris@82 1649 # All initialisations required before starting the option parse loop.
Chris@82 1650 # Note that when calling hook functions, we pass through the list of
Chris@82 1651 # positional parameters. If a hook function modifies that list, and
Chris@82 1652 # needs to propogate that back to rest of this script, then the complete
Chris@82 1653 # modified list must be put in 'func_run_hooks_result' before
Chris@82 1654 # returning.
Chris@82 1655 func_hookable func_options_prep
Chris@82 1656 func_options_prep ()
Chris@82 1657 {
Chris@82 1658 $debug_cmd
Chris@82 1659
Chris@82 1660 # Option defaults:
Chris@82 1661 opt_verbose=false
Chris@82 1662 opt_warning_types=
Chris@82 1663
Chris@82 1664 func_run_hooks func_options_prep ${1+"$@"}
Chris@82 1665
Chris@82 1666 # save modified positional parameters for caller
Chris@82 1667 func_options_prep_result=$func_run_hooks_result
Chris@82 1668 }
Chris@82 1669
Chris@82 1670
Chris@82 1671 # func_parse_options [ARG]...
Chris@82 1672 # ---------------------------
Chris@82 1673 # The main option parsing loop.
Chris@82 1674 func_hookable func_parse_options
Chris@82 1675 func_parse_options ()
Chris@82 1676 {
Chris@82 1677 $debug_cmd
Chris@82 1678
Chris@82 1679 func_parse_options_result=
Chris@82 1680
Chris@82 1681 # this just eases exit handling
Chris@82 1682 while test $# -gt 0; do
Chris@82 1683 # Defer to hook functions for initial option parsing, so they
Chris@82 1684 # get priority in the event of reusing an option name.
Chris@82 1685 func_run_hooks func_parse_options ${1+"$@"}
Chris@82 1686
Chris@82 1687 # Adjust func_parse_options positional parameters to match
Chris@82 1688 eval set dummy "$func_run_hooks_result"; shift
Chris@82 1689
Chris@82 1690 # Break out of the loop if we already parsed every option.
Chris@82 1691 test $# -gt 0 || break
Chris@82 1692
Chris@82 1693 _G_opt=$1
Chris@82 1694 shift
Chris@82 1695 case $_G_opt in
Chris@82 1696 --debug|-x) debug_cmd='set -x'
Chris@82 1697 func_echo "enabling shell trace mode"
Chris@82 1698 $debug_cmd
Chris@82 1699 ;;
Chris@82 1700
Chris@82 1701 --no-warnings|--no-warning|--no-warn)
Chris@82 1702 set dummy --warnings none ${1+"$@"}
Chris@82 1703 shift
Chris@82 1704 ;;
Chris@82 1705
Chris@82 1706 --warnings|--warning|-W)
Chris@82 1707 test $# = 0 && func_missing_arg $_G_opt && break
Chris@82 1708 case " $warning_categories $1" in
Chris@82 1709 *" $1 "*)
Chris@82 1710 # trailing space prevents matching last $1 above
Chris@82 1711 func_append_uniq opt_warning_types " $1"
Chris@82 1712 ;;
Chris@82 1713 *all)
Chris@82 1714 opt_warning_types=$warning_categories
Chris@82 1715 ;;
Chris@82 1716 *none)
Chris@82 1717 opt_warning_types=none
Chris@82 1718 warning_func=:
Chris@82 1719 ;;
Chris@82 1720 *error)
Chris@82 1721 opt_warning_types=$warning_categories
Chris@82 1722 warning_func=func_fatal_error
Chris@82 1723 ;;
Chris@82 1724 *)
Chris@82 1725 func_fatal_error \
Chris@82 1726 "unsupported warning category: '$1'"
Chris@82 1727 ;;
Chris@82 1728 esac
Chris@82 1729 shift
Chris@82 1730 ;;
Chris@82 1731
Chris@82 1732 --verbose|-v) opt_verbose=: ;;
Chris@82 1733 --version) func_version ;;
Chris@82 1734 -\?|-h) func_usage ;;
Chris@82 1735 --help) func_help ;;
Chris@82 1736
Chris@82 1737 # Separate optargs to long options (plugins may need this):
Chris@82 1738 --*=*) func_split_equals "$_G_opt"
Chris@82 1739 set dummy "$func_split_equals_lhs" \
Chris@82 1740 "$func_split_equals_rhs" ${1+"$@"}
Chris@82 1741 shift
Chris@82 1742 ;;
Chris@82 1743
Chris@82 1744 # Separate optargs to short options:
Chris@82 1745 -W*)
Chris@82 1746 func_split_short_opt "$_G_opt"
Chris@82 1747 set dummy "$func_split_short_opt_name" \
Chris@82 1748 "$func_split_short_opt_arg" ${1+"$@"}
Chris@82 1749 shift
Chris@82 1750 ;;
Chris@82 1751
Chris@82 1752 # Separate non-argument short options:
Chris@82 1753 -\?*|-h*|-v*|-x*)
Chris@82 1754 func_split_short_opt "$_G_opt"
Chris@82 1755 set dummy "$func_split_short_opt_name" \
Chris@82 1756 "-$func_split_short_opt_arg" ${1+"$@"}
Chris@82 1757 shift
Chris@82 1758 ;;
Chris@82 1759
Chris@82 1760 --) break ;;
Chris@82 1761 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
Chris@82 1762 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
Chris@82 1763 esac
Chris@82 1764 done
Chris@82 1765
Chris@82 1766 # save modified positional parameters for caller
Chris@82 1767 func_quote_for_eval ${1+"$@"}
Chris@82 1768 func_parse_options_result=$func_quote_for_eval_result
Chris@82 1769 }
Chris@82 1770
Chris@82 1771
Chris@82 1772 # func_validate_options [ARG]...
Chris@82 1773 # ------------------------------
Chris@82 1774 # Perform any sanity checks on option settings and/or unconsumed
Chris@82 1775 # arguments.
Chris@82 1776 func_hookable func_validate_options
Chris@82 1777 func_validate_options ()
Chris@82 1778 {
Chris@82 1779 $debug_cmd
Chris@82 1780
Chris@82 1781 # Display all warnings if -W was not given.
Chris@82 1782 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
Chris@82 1783
Chris@82 1784 func_run_hooks func_validate_options ${1+"$@"}
Chris@82 1785
Chris@82 1786 # Bail if the options were screwed!
Chris@82 1787 $exit_cmd $EXIT_FAILURE
Chris@82 1788
Chris@82 1789 # save modified positional parameters for caller
Chris@82 1790 func_validate_options_result=$func_run_hooks_result
Chris@82 1791 }
Chris@82 1792
Chris@82 1793
Chris@82 1794
Chris@82 1795 ## ----------------- ##
Chris@82 1796 ## Helper functions. ##
Chris@82 1797 ## ----------------- ##
Chris@82 1798
Chris@82 1799 # This section contains the helper functions used by the rest of the
Chris@82 1800 # hookable option parser framework in ascii-betical order.
Chris@82 1801
Chris@82 1802
Chris@82 1803 # func_fatal_help ARG...
Chris@82 1804 # ----------------------
Chris@82 1805 # Echo program name prefixed message to standard error, followed by
Chris@82 1806 # a help hint, and exit.
Chris@82 1807 func_fatal_help ()
Chris@82 1808 {
Chris@82 1809 $debug_cmd
Chris@82 1810
Chris@82 1811 eval \$ECHO \""Usage: $usage"\"
Chris@82 1812 eval \$ECHO \""$fatal_help"\"
Chris@82 1813 func_error ${1+"$@"}
Chris@82 1814 exit $EXIT_FAILURE
Chris@82 1815 }
Chris@82 1816
Chris@82 1817
Chris@82 1818 # func_help
Chris@82 1819 # ---------
Chris@82 1820 # Echo long help message to standard output and exit.
Chris@82 1821 func_help ()
Chris@82 1822 {
Chris@82 1823 $debug_cmd
Chris@82 1824
Chris@82 1825 func_usage_message
Chris@82 1826 $ECHO "$long_help_message"
Chris@82 1827 exit 0
Chris@82 1828 }
Chris@82 1829
Chris@82 1830
Chris@82 1831 # func_missing_arg ARGNAME
Chris@82 1832 # ------------------------
Chris@82 1833 # Echo program name prefixed message to standard error and set global
Chris@82 1834 # exit_cmd.
Chris@82 1835 func_missing_arg ()
Chris@82 1836 {
Chris@82 1837 $debug_cmd
Chris@82 1838
Chris@82 1839 func_error "Missing argument for '$1'."
Chris@82 1840 exit_cmd=exit
Chris@82 1841 }
Chris@82 1842
Chris@82 1843
Chris@82 1844 # func_split_equals STRING
Chris@82 1845 # ------------------------
Chris@82 1846 # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
Chris@82 1847 # splitting STRING at the '=' sign.
Chris@82 1848 test -z "$_G_HAVE_XSI_OPS" \
Chris@82 1849 && (eval 'x=a/b/c;
Chris@82 1850 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
Chris@82 1851 && _G_HAVE_XSI_OPS=yes
Chris@82 1852
Chris@82 1853 if test yes = "$_G_HAVE_XSI_OPS"
Chris@82 1854 then
Chris@82 1855 # This is an XSI compatible shell, allowing a faster implementation...
Chris@82 1856 eval 'func_split_equals ()
Chris@82 1857 {
Chris@82 1858 $debug_cmd
Chris@82 1859
Chris@82 1860 func_split_equals_lhs=${1%%=*}
Chris@82 1861 func_split_equals_rhs=${1#*=}
Chris@82 1862 test "x$func_split_equals_lhs" = "x$1" \
Chris@82 1863 && func_split_equals_rhs=
Chris@82 1864 }'
Chris@82 1865 else
Chris@82 1866 # ...otherwise fall back to using expr, which is often a shell builtin.
Chris@82 1867 func_split_equals ()
Chris@82 1868 {
Chris@82 1869 $debug_cmd
Chris@82 1870
Chris@82 1871 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
Chris@82 1872 func_split_equals_rhs=
Chris@82 1873 test "x$func_split_equals_lhs" = "x$1" \
Chris@82 1874 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
Chris@82 1875 }
Chris@82 1876 fi #func_split_equals
Chris@82 1877
Chris@82 1878
Chris@82 1879 # func_split_short_opt SHORTOPT
Chris@82 1880 # -----------------------------
Chris@82 1881 # Set func_split_short_opt_name and func_split_short_opt_arg shell
Chris@82 1882 # variables after splitting SHORTOPT after the 2nd character.
Chris@82 1883 if test yes = "$_G_HAVE_XSI_OPS"
Chris@82 1884 then
Chris@82 1885 # This is an XSI compatible shell, allowing a faster implementation...
Chris@82 1886 eval 'func_split_short_opt ()
Chris@82 1887 {
Chris@82 1888 $debug_cmd
Chris@82 1889
Chris@82 1890 func_split_short_opt_arg=${1#??}
Chris@82 1891 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
Chris@82 1892 }'
Chris@82 1893 else
Chris@82 1894 # ...otherwise fall back to using expr, which is often a shell builtin.
Chris@82 1895 func_split_short_opt ()
Chris@82 1896 {
Chris@82 1897 $debug_cmd
Chris@82 1898
Chris@82 1899 func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
Chris@82 1900 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
Chris@82 1901 }
Chris@82 1902 fi #func_split_short_opt
Chris@82 1903
Chris@82 1904
Chris@82 1905 # func_usage
Chris@82 1906 # ----------
Chris@82 1907 # Echo short help message to standard output and exit.
Chris@82 1908 func_usage ()
Chris@82 1909 {
Chris@82 1910 $debug_cmd
Chris@82 1911
Chris@82 1912 func_usage_message
Chris@82 1913 $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
Chris@82 1914 exit 0
Chris@82 1915 }
Chris@82 1916
Chris@82 1917
Chris@82 1918 # func_usage_message
Chris@82 1919 # ------------------
Chris@82 1920 # Echo short help message to standard output.
Chris@82 1921 func_usage_message ()
Chris@82 1922 {
Chris@82 1923 $debug_cmd
Chris@82 1924
Chris@82 1925 eval \$ECHO \""Usage: $usage"\"
Chris@82 1926 echo
Chris@82 1927 $SED -n 's|^# ||
Chris@82 1928 /^Written by/{
Chris@82 1929 x;p;x
Chris@82 1930 }
Chris@82 1931 h
Chris@82 1932 /^Written by/q' < "$progpath"
Chris@82 1933 echo
Chris@82 1934 eval \$ECHO \""$usage_message"\"
Chris@82 1935 }
Chris@82 1936
Chris@82 1937
Chris@82 1938 # func_version
Chris@82 1939 # ------------
Chris@82 1940 # Echo version message to standard output and exit.
Chris@82 1941 func_version ()
Chris@82 1942 {
Chris@82 1943 $debug_cmd
Chris@82 1944
Chris@82 1945 printf '%s\n' "$progname $scriptversion"
Chris@82 1946 $SED -n '
Chris@82 1947 /(C)/!b go
Chris@82 1948 :more
Chris@82 1949 /\./!{
Chris@82 1950 N
Chris@82 1951 s|\n# | |
Chris@82 1952 b more
Chris@82 1953 }
Chris@82 1954 :go
Chris@82 1955 /^# Written by /,/# warranty; / {
Chris@82 1956 s|^# ||
Chris@82 1957 s|^# *$||
Chris@82 1958 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
Chris@82 1959 p
Chris@82 1960 }
Chris@82 1961 /^# Written by / {
Chris@82 1962 s|^# ||
Chris@82 1963 p
Chris@82 1964 }
Chris@82 1965 /^warranty; /q' < "$progpath"
Chris@82 1966
Chris@82 1967 exit $?
Chris@82 1968 }
Chris@82 1969
Chris@82 1970
Chris@82 1971 # Local variables:
Chris@82 1972 # mode: shell-script
Chris@82 1973 # sh-indentation: 2
Chris@82 1974 # eval: (add-hook 'before-save-hook 'time-stamp)
Chris@82 1975 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
Chris@82 1976 # time-stamp-time-zone: "UTC"
Chris@82 1977 # End:
Chris@82 1978
Chris@82 1979 # Set a version string.
Chris@82 1980 scriptversion='(GNU libtool) 2.4.6'
Chris@82 1981
Chris@82 1982
Chris@82 1983 # func_echo ARG...
Chris@82 1984 # ----------------
Chris@82 1985 # Libtool also displays the current mode in messages, so override
Chris@82 1986 # funclib.sh func_echo with this custom definition.
Chris@82 1987 func_echo ()
Chris@82 1988 {
Chris@82 1989 $debug_cmd
Chris@82 1990
Chris@82 1991 _G_message=$*
Chris@82 1992
Chris@82 1993 func_echo_IFS=$IFS
Chris@82 1994 IFS=$nl
Chris@82 1995 for _G_line in $_G_message; do
Chris@82 1996 IFS=$func_echo_IFS
Chris@82 1997 $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
Chris@82 1998 done
Chris@82 1999 IFS=$func_echo_IFS
Chris@82 2000 }
Chris@82 2001
Chris@82 2002
Chris@82 2003 # func_warning ARG...
Chris@82 2004 # -------------------
Chris@82 2005 # Libtool warnings are not categorized, so override funclib.sh
Chris@82 2006 # func_warning with this simpler definition.
Chris@82 2007 func_warning ()
Chris@82 2008 {
Chris@82 2009 $debug_cmd
Chris@82 2010
Chris@82 2011 $warning_func ${1+"$@"}
Chris@82 2012 }
Chris@82 2013
Chris@82 2014
Chris@82 2015 ## ---------------- ##
Chris@82 2016 ## Options parsing. ##
Chris@82 2017 ## ---------------- ##
Chris@82 2018
Chris@82 2019 # Hook in the functions to make sure our own options are parsed during
Chris@82 2020 # the option parsing loop.
Chris@82 2021
Chris@82 2022 usage='$progpath [OPTION]... [MODE-ARG]...'
Chris@82 2023
Chris@82 2024 # Short help message in response to '-h'.
Chris@82 2025 usage_message="Options:
Chris@82 2026 --config show all configuration variables
Chris@82 2027 --debug enable verbose shell tracing
Chris@82 2028 -n, --dry-run display commands without modifying any files
Chris@82 2029 --features display basic configuration information and exit
Chris@82 2030 --mode=MODE use operation mode MODE
Chris@82 2031 --no-warnings equivalent to '-Wnone'
Chris@82 2032 --preserve-dup-deps don't remove duplicate dependency libraries
Chris@82 2033 --quiet, --silent don't print informational messages
Chris@82 2034 --tag=TAG use configuration variables from tag TAG
Chris@82 2035 -v, --verbose print more informational messages than default
Chris@82 2036 --version print version information
Chris@82 2037 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
Chris@82 2038 -h, --help, --help-all print short, long, or detailed help message
Chris@82 2039 "
Chris@82 2040
Chris@82 2041 # Additional text appended to 'usage_message' in response to '--help'.
Chris@82 2042 func_help ()
Chris@82 2043 {
Chris@82 2044 $debug_cmd
Chris@82 2045
Chris@82 2046 func_usage_message
Chris@82 2047 $ECHO "$long_help_message
Chris@82 2048
Chris@82 2049 MODE must be one of the following:
Chris@82 2050
Chris@82 2051 clean remove files from the build directory
Chris@82 2052 compile compile a source file into a libtool object
Chris@82 2053 execute automatically set library path, then run a program
Chris@82 2054 finish complete the installation of libtool libraries
Chris@82 2055 install install libraries or executables
Chris@82 2056 link create a library or an executable
Chris@82 2057 uninstall remove libraries from an installed directory
Chris@82 2058
Chris@82 2059 MODE-ARGS vary depending on the MODE. When passed as first option,
Chris@82 2060 '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
Chris@82 2061 Try '$progname --help --mode=MODE' for a more detailed description of MODE.
Chris@82 2062
Chris@82 2063 When reporting a bug, please describe a test case to reproduce it and
Chris@82 2064 include the following information:
Chris@82 2065
Chris@82 2066 host-triplet: $host
Chris@82 2067 shell: $SHELL
Chris@82 2068 compiler: $LTCC
Chris@82 2069 compiler flags: $LTCFLAGS
Chris@82 2070 linker: $LD (gnu? $with_gnu_ld)
Chris@82 2071 version: $progname $scriptversion Debian-2.4.6-2
Chris@82 2072 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
Chris@82 2073 autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
Chris@82 2074
Chris@82 2075 Report bugs to <bug-libtool@gnu.org>.
Chris@82 2076 GNU libtool home page: <http://www.gnu.org/s/libtool/>.
Chris@82 2077 General help using GNU software: <http://www.gnu.org/gethelp/>."
Chris@82 2078 exit 0
Chris@82 2079 }
Chris@82 2080
Chris@82 2081
Chris@82 2082 # func_lo2o OBJECT-NAME
Chris@82 2083 # ---------------------
Chris@82 2084 # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
Chris@82 2085 # object suffix.
Chris@82 2086
Chris@82 2087 lo2o=s/\\.lo\$/.$objext/
Chris@82 2088 o2lo=s/\\.$objext\$/.lo/
Chris@82 2089
Chris@82 2090 if test yes = "$_G_HAVE_XSI_OPS"; then
Chris@82 2091 eval 'func_lo2o ()
Chris@82 2092 {
Chris@82 2093 case $1 in
Chris@82 2094 *.lo) func_lo2o_result=${1%.lo}.$objext ;;
Chris@82 2095 * ) func_lo2o_result=$1 ;;
Chris@82 2096 esac
Chris@82 2097 }'
Chris@82 2098
Chris@82 2099 # func_xform LIBOBJ-OR-SOURCE
Chris@82 2100 # ---------------------------
Chris@82 2101 # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
Chris@82 2102 # suffix to a '.lo' libtool-object suffix.
Chris@82 2103 eval 'func_xform ()
Chris@82 2104 {
Chris@82 2105 func_xform_result=${1%.*}.lo
Chris@82 2106 }'
Chris@82 2107 else
Chris@82 2108 # ...otherwise fall back to using sed.
Chris@82 2109 func_lo2o ()
Chris@82 2110 {
Chris@82 2111 func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
Chris@82 2112 }
Chris@82 2113
Chris@82 2114 func_xform ()
Chris@82 2115 {
Chris@82 2116 func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
Chris@82 2117 }
Chris@82 2118 fi
Chris@82 2119
Chris@82 2120
Chris@82 2121 # func_fatal_configuration ARG...
Chris@82 2122 # -------------------------------
Chris@82 2123 # Echo program name prefixed message to standard error, followed by
Chris@82 2124 # a configuration failure hint, and exit.
Chris@82 2125 func_fatal_configuration ()
Chris@82 2126 {
Chris@82 2127 func__fatal_error ${1+"$@"} \
Chris@82 2128 "See the $PACKAGE documentation for more information." \
Chris@82 2129 "Fatal configuration error."
Chris@82 2130 }
Chris@82 2131
Chris@82 2132
Chris@82 2133 # func_config
Chris@82 2134 # -----------
Chris@82 2135 # Display the configuration for all the tags in this script.
Chris@82 2136 func_config ()
Chris@82 2137 {
Chris@82 2138 re_begincf='^# ### BEGIN LIBTOOL'
Chris@82 2139 re_endcf='^# ### END LIBTOOL'
Chris@82 2140
Chris@82 2141 # Default configuration.
Chris@82 2142 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
Chris@82 2143
Chris@82 2144 # Now print the configurations for the tags.
Chris@82 2145 for tagname in $taglist; do
Chris@82 2146 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
Chris@82 2147 done
Chris@82 2148
Chris@82 2149 exit $?
Chris@82 2150 }
Chris@82 2151
Chris@82 2152
Chris@82 2153 # func_features
Chris@82 2154 # -------------
Chris@82 2155 # Display the features supported by this script.
Chris@82 2156 func_features ()
Chris@82 2157 {
Chris@82 2158 echo "host: $host"
Chris@82 2159 if test yes = "$build_libtool_libs"; then
Chris@82 2160 echo "enable shared libraries"
Chris@82 2161 else
Chris@82 2162 echo "disable shared libraries"
Chris@82 2163 fi
Chris@82 2164 if test yes = "$build_old_libs"; then
Chris@82 2165 echo "enable static libraries"
Chris@82 2166 else
Chris@82 2167 echo "disable static libraries"
Chris@82 2168 fi
Chris@82 2169
Chris@82 2170 exit $?
Chris@82 2171 }
Chris@82 2172
Chris@82 2173
Chris@82 2174 # func_enable_tag TAGNAME
Chris@82 2175 # -----------------------
Chris@82 2176 # Verify that TAGNAME is valid, and either flag an error and exit, or
Chris@82 2177 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
Chris@82 2178 # variable here.
Chris@82 2179 func_enable_tag ()
Chris@82 2180 {
Chris@82 2181 # Global variable:
Chris@82 2182 tagname=$1
Chris@82 2183
Chris@82 2184 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
Chris@82 2185 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
Chris@82 2186 sed_extractcf=/$re_begincf/,/$re_endcf/p
Chris@82 2187
Chris@82 2188 # Validate tagname.
Chris@82 2189 case $tagname in
Chris@82 2190 *[!-_A-Za-z0-9,/]*)
Chris@82 2191 func_fatal_error "invalid tag name: $tagname"
Chris@82 2192 ;;
Chris@82 2193 esac
Chris@82 2194
Chris@82 2195 # Don't test for the "default" C tag, as we know it's
Chris@82 2196 # there but not specially marked.
Chris@82 2197 case $tagname in
Chris@82 2198 CC) ;;
Chris@82 2199 *)
Chris@82 2200 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
Chris@82 2201 taglist="$taglist $tagname"
Chris@82 2202
Chris@82 2203 # Evaluate the configuration. Be careful to quote the path
Chris@82 2204 # and the sed script, to avoid splitting on whitespace, but
Chris@82 2205 # also don't use non-portable quotes within backquotes within
Chris@82 2206 # quotes we have to do it in 2 steps:
Chris@82 2207 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
Chris@82 2208 eval "$extractedcf"
Chris@82 2209 else
Chris@82 2210 func_error "ignoring unknown tag $tagname"
Chris@82 2211 fi
Chris@82 2212 ;;
Chris@82 2213 esac
Chris@82 2214 }
Chris@82 2215
Chris@82 2216
Chris@82 2217 # func_check_version_match
Chris@82 2218 # ------------------------
Chris@82 2219 # Ensure that we are using m4 macros, and libtool script from the same
Chris@82 2220 # release of libtool.
Chris@82 2221 func_check_version_match ()
Chris@82 2222 {
Chris@82 2223 if test "$package_revision" != "$macro_revision"; then
Chris@82 2224 if test "$VERSION" != "$macro_version"; then
Chris@82 2225 if test -z "$macro_version"; then
Chris@82 2226 cat >&2 <<_LT_EOF
Chris@82 2227 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
Chris@82 2228 $progname: definition of this LT_INIT comes from an older release.
Chris@82 2229 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
Chris@82 2230 $progname: and run autoconf again.
Chris@82 2231 _LT_EOF
Chris@82 2232 else
Chris@82 2233 cat >&2 <<_LT_EOF
Chris@82 2234 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
Chris@82 2235 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
Chris@82 2236 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
Chris@82 2237 $progname: and run autoconf again.
Chris@82 2238 _LT_EOF
Chris@82 2239 fi
Chris@82 2240 else
Chris@82 2241 cat >&2 <<_LT_EOF
Chris@82 2242 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
Chris@82 2243 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
Chris@82 2244 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
Chris@82 2245 $progname: of $PACKAGE $VERSION and run autoconf again.
Chris@82 2246 _LT_EOF
Chris@82 2247 fi
Chris@82 2248
Chris@82 2249 exit $EXIT_MISMATCH
Chris@82 2250 fi
Chris@82 2251 }
Chris@82 2252
Chris@82 2253
Chris@82 2254 # libtool_options_prep [ARG]...
Chris@82 2255 # -----------------------------
Chris@82 2256 # Preparation for options parsed by libtool.
Chris@82 2257 libtool_options_prep ()
Chris@82 2258 {
Chris@82 2259 $debug_mode
Chris@82 2260
Chris@82 2261 # Option defaults:
Chris@82 2262 opt_config=false
Chris@82 2263 opt_dlopen=
Chris@82 2264 opt_dry_run=false
Chris@82 2265 opt_help=false
Chris@82 2266 opt_mode=
Chris@82 2267 opt_preserve_dup_deps=false
Chris@82 2268 opt_quiet=false
Chris@82 2269
Chris@82 2270 nonopt=
Chris@82 2271 preserve_args=
Chris@82 2272
Chris@82 2273 # Shorthand for --mode=foo, only valid as the first argument
Chris@82 2274 case $1 in
Chris@82 2275 clean|clea|cle|cl)
Chris@82 2276 shift; set dummy --mode clean ${1+"$@"}; shift
Chris@82 2277 ;;
Chris@82 2278 compile|compil|compi|comp|com|co|c)
Chris@82 2279 shift; set dummy --mode compile ${1+"$@"}; shift
Chris@82 2280 ;;
Chris@82 2281 execute|execut|execu|exec|exe|ex|e)
Chris@82 2282 shift; set dummy --mode execute ${1+"$@"}; shift
Chris@82 2283 ;;
Chris@82 2284 finish|finis|fini|fin|fi|f)
Chris@82 2285 shift; set dummy --mode finish ${1+"$@"}; shift
Chris@82 2286 ;;
Chris@82 2287 install|instal|insta|inst|ins|in|i)
Chris@82 2288 shift; set dummy --mode install ${1+"$@"}; shift
Chris@82 2289 ;;
Chris@82 2290 link|lin|li|l)
Chris@82 2291 shift; set dummy --mode link ${1+"$@"}; shift
Chris@82 2292 ;;
Chris@82 2293 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
Chris@82 2294 shift; set dummy --mode uninstall ${1+"$@"}; shift
Chris@82 2295 ;;
Chris@82 2296 esac
Chris@82 2297
Chris@82 2298 # Pass back the list of options.
Chris@82 2299 func_quote_for_eval ${1+"$@"}
Chris@82 2300 libtool_options_prep_result=$func_quote_for_eval_result
Chris@82 2301 }
Chris@82 2302 func_add_hook func_options_prep libtool_options_prep
Chris@82 2303
Chris@82 2304
Chris@82 2305 # libtool_parse_options [ARG]...
Chris@82 2306 # ---------------------------------
Chris@82 2307 # Provide handling for libtool specific options.
Chris@82 2308 libtool_parse_options ()
Chris@82 2309 {
Chris@82 2310 $debug_cmd
Chris@82 2311
Chris@82 2312 # Perform our own loop to consume as many options as possible in
Chris@82 2313 # each iteration.
Chris@82 2314 while test $# -gt 0; do
Chris@82 2315 _G_opt=$1
Chris@82 2316 shift
Chris@82 2317 case $_G_opt in
Chris@82 2318 --dry-run|--dryrun|-n)
Chris@82 2319 opt_dry_run=:
Chris@82 2320 ;;
Chris@82 2321
Chris@82 2322 --config) func_config ;;
Chris@82 2323
Chris@82 2324 --dlopen|-dlopen)
Chris@82 2325 opt_dlopen="${opt_dlopen+$opt_dlopen
Chris@82 2326 }$1"
Chris@82 2327 shift
Chris@82 2328 ;;
Chris@82 2329
Chris@82 2330 --preserve-dup-deps)
Chris@82 2331 opt_preserve_dup_deps=: ;;
Chris@82 2332
Chris@82 2333 --features) func_features ;;
Chris@82 2334
Chris@82 2335 --finish) set dummy --mode finish ${1+"$@"}; shift ;;
Chris@82 2336
Chris@82 2337 --help) opt_help=: ;;
Chris@82 2338
Chris@82 2339 --help-all) opt_help=': help-all' ;;
Chris@82 2340
Chris@82 2341 --mode) test $# = 0 && func_missing_arg $_G_opt && break
Chris@82 2342 opt_mode=$1
Chris@82 2343 case $1 in
Chris@82 2344 # Valid mode arguments:
Chris@82 2345 clean|compile|execute|finish|install|link|relink|uninstall) ;;
Chris@82 2346
Chris@82 2347 # Catch anything else as an error
Chris@82 2348 *) func_error "invalid argument for $_G_opt"
Chris@82 2349 exit_cmd=exit
Chris@82 2350 break
Chris@82 2351 ;;
Chris@82 2352 esac
Chris@82 2353 shift
Chris@82 2354 ;;
Chris@82 2355
Chris@82 2356 --no-silent|--no-quiet)
Chris@82 2357 opt_quiet=false
Chris@82 2358 func_append preserve_args " $_G_opt"
Chris@82 2359 ;;
Chris@82 2360
Chris@82 2361 --no-warnings|--no-warning|--no-warn)
Chris@82 2362 opt_warning=false
Chris@82 2363 func_append preserve_args " $_G_opt"
Chris@82 2364 ;;
Chris@82 2365
Chris@82 2366 --no-verbose)
Chris@82 2367 opt_verbose=false
Chris@82 2368 func_append preserve_args " $_G_opt"
Chris@82 2369 ;;
Chris@82 2370
Chris@82 2371 --silent|--quiet)
Chris@82 2372 opt_quiet=:
Chris@82 2373 opt_verbose=false
Chris@82 2374 func_append preserve_args " $_G_opt"
Chris@82 2375 ;;
Chris@82 2376
Chris@82 2377 --tag) test $# = 0 && func_missing_arg $_G_opt && break
Chris@82 2378 opt_tag=$1
Chris@82 2379 func_append preserve_args " $_G_opt $1"
Chris@82 2380 func_enable_tag "$1"
Chris@82 2381 shift
Chris@82 2382 ;;
Chris@82 2383
Chris@82 2384 --verbose|-v) opt_quiet=false
Chris@82 2385 opt_verbose=:
Chris@82 2386 func_append preserve_args " $_G_opt"
Chris@82 2387 ;;
Chris@82 2388
Chris@82 2389 # An option not handled by this hook function:
Chris@82 2390 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
Chris@82 2391 esac
Chris@82 2392 done
Chris@82 2393
Chris@82 2394
Chris@82 2395 # save modified positional parameters for caller
Chris@82 2396 func_quote_for_eval ${1+"$@"}
Chris@82 2397 libtool_parse_options_result=$func_quote_for_eval_result
Chris@82 2398 }
Chris@82 2399 func_add_hook func_parse_options libtool_parse_options
Chris@82 2400
Chris@82 2401
Chris@82 2402
Chris@82 2403 # libtool_validate_options [ARG]...
Chris@82 2404 # ---------------------------------
Chris@82 2405 # Perform any sanity checks on option settings and/or unconsumed
Chris@82 2406 # arguments.
Chris@82 2407 libtool_validate_options ()
Chris@82 2408 {
Chris@82 2409 # save first non-option argument
Chris@82 2410 if test 0 -lt $#; then
Chris@82 2411 nonopt=$1
Chris@82 2412 shift
Chris@82 2413 fi
Chris@82 2414
Chris@82 2415 # preserve --debug
Chris@82 2416 test : = "$debug_cmd" || func_append preserve_args " --debug"
Chris@82 2417
Chris@82 2418 case $host in
Chris@82 2419 # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
Chris@82 2420 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
Chris@82 2421 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
Chris@82 2422 # don't eliminate duplications in $postdeps and $predeps
Chris@82 2423 opt_duplicate_compiler_generated_deps=:
Chris@82 2424 ;;
Chris@82 2425 *)
Chris@82 2426 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
Chris@82 2427 ;;
Chris@82 2428 esac
Chris@82 2429
Chris@82 2430 $opt_help || {
Chris@82 2431 # Sanity checks first:
Chris@82 2432 func_check_version_match
Chris@82 2433
Chris@82 2434 test yes != "$build_libtool_libs" \
Chris@82 2435 && test yes != "$build_old_libs" \
Chris@82 2436 && func_fatal_configuration "not configured to build any kind of library"
Chris@82 2437
Chris@82 2438 # Darwin sucks
Chris@82 2439 eval std_shrext=\"$shrext_cmds\"
Chris@82 2440
Chris@82 2441 # Only execute mode is allowed to have -dlopen flags.
Chris@82 2442 if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
Chris@82 2443 func_error "unrecognized option '-dlopen'"
Chris@82 2444 $ECHO "$help" 1>&2
Chris@82 2445 exit $EXIT_FAILURE
Chris@82 2446 fi
Chris@82 2447
Chris@82 2448 # Change the help message to a mode-specific one.
Chris@82 2449 generic_help=$help
Chris@82 2450 help="Try '$progname --help --mode=$opt_mode' for more information."
Chris@82 2451 }
Chris@82 2452
Chris@82 2453 # Pass back the unparsed argument list
Chris@82 2454 func_quote_for_eval ${1+"$@"}
Chris@82 2455 libtool_validate_options_result=$func_quote_for_eval_result
Chris@82 2456 }
Chris@82 2457 func_add_hook func_validate_options libtool_validate_options
Chris@82 2458
Chris@82 2459
Chris@82 2460 # Process options as early as possible so that --help and --version
Chris@82 2461 # can return quickly.
Chris@82 2462 func_options ${1+"$@"}
Chris@82 2463 eval set dummy "$func_options_result"; shift
Chris@82 2464
Chris@82 2465
Chris@82 2466
Chris@82 2467 ## ----------- ##
Chris@82 2468 ## Main. ##
Chris@82 2469 ## ----------- ##
Chris@82 2470
Chris@82 2471 magic='%%%MAGIC variable%%%'
Chris@82 2472 magic_exe='%%%MAGIC EXE variable%%%'
Chris@82 2473
Chris@82 2474 # Global variables.
Chris@82 2475 extracted_archives=
Chris@82 2476 extracted_serial=0
Chris@82 2477
Chris@82 2478 # If this variable is set in any of the actions, the command in it
Chris@82 2479 # will be execed at the end. This prevents here-documents from being
Chris@82 2480 # left over by shells.
Chris@82 2481 exec_cmd=
Chris@82 2482
Chris@82 2483
Chris@82 2484 # A function that is used when there is no print builtin or printf.
Chris@82 2485 func_fallback_echo ()
Chris@82 2486 {
Chris@82 2487 eval 'cat <<_LTECHO_EOF
Chris@82 2488 $1
Chris@82 2489 _LTECHO_EOF'
Chris@82 2490 }
Chris@82 2491
Chris@82 2492 # func_generated_by_libtool
Chris@82 2493 # True iff stdin has been generated by Libtool. This function is only
Chris@82 2494 # a basic sanity check; it will hardly flush out determined imposters.
Chris@82 2495 func_generated_by_libtool_p ()
Chris@82 2496 {
Chris@82 2497 $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
Chris@82 2498 }
Chris@82 2499
Chris@82 2500 # func_lalib_p file
Chris@82 2501 # True iff FILE is a libtool '.la' library or '.lo' object file.
Chris@82 2502 # This function is only a basic sanity check; it will hardly flush out
Chris@82 2503 # determined imposters.
Chris@82 2504 func_lalib_p ()
Chris@82 2505 {
Chris@82 2506 test -f "$1" &&
Chris@82 2507 $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
Chris@82 2508 }
Chris@82 2509
Chris@82 2510 # func_lalib_unsafe_p file
Chris@82 2511 # True iff FILE is a libtool '.la' library or '.lo' object file.
Chris@82 2512 # This function implements the same check as func_lalib_p without
Chris@82 2513 # resorting to external programs. To this end, it redirects stdin and
Chris@82 2514 # closes it afterwards, without saving the original file descriptor.
Chris@82 2515 # As a safety measure, use it only where a negative result would be
Chris@82 2516 # fatal anyway. Works if 'file' does not exist.
Chris@82 2517 func_lalib_unsafe_p ()
Chris@82 2518 {
Chris@82 2519 lalib_p=no
Chris@82 2520 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
Chris@82 2521 for lalib_p_l in 1 2 3 4
Chris@82 2522 do
Chris@82 2523 read lalib_p_line
Chris@82 2524 case $lalib_p_line in
Chris@82 2525 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
Chris@82 2526 esac
Chris@82 2527 done
Chris@82 2528 exec 0<&5 5<&-
Chris@82 2529 fi
Chris@82 2530 test yes = "$lalib_p"
Chris@82 2531 }
Chris@82 2532
Chris@82 2533 # func_ltwrapper_script_p file
Chris@82 2534 # True iff FILE is a libtool wrapper script
Chris@82 2535 # This function is only a basic sanity check; it will hardly flush out
Chris@82 2536 # determined imposters.
Chris@82 2537 func_ltwrapper_script_p ()
Chris@82 2538 {
Chris@82 2539 test -f "$1" &&
Chris@82 2540 $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
Chris@82 2541 }
Chris@82 2542
Chris@82 2543 # func_ltwrapper_executable_p file
Chris@82 2544 # True iff FILE is a libtool wrapper executable
Chris@82 2545 # This function is only a basic sanity check; it will hardly flush out
Chris@82 2546 # determined imposters.
Chris@82 2547 func_ltwrapper_executable_p ()
Chris@82 2548 {
Chris@82 2549 func_ltwrapper_exec_suffix=
Chris@82 2550 case $1 in
Chris@82 2551 *.exe) ;;
Chris@82 2552 *) func_ltwrapper_exec_suffix=.exe ;;
Chris@82 2553 esac
Chris@82 2554 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
Chris@82 2555 }
Chris@82 2556
Chris@82 2557 # func_ltwrapper_scriptname file
Chris@82 2558 # Assumes file is an ltwrapper_executable
Chris@82 2559 # uses $file to determine the appropriate filename for a
Chris@82 2560 # temporary ltwrapper_script.
Chris@82 2561 func_ltwrapper_scriptname ()
Chris@82 2562 {
Chris@82 2563 func_dirname_and_basename "$1" "" "."
Chris@82 2564 func_stripname '' '.exe' "$func_basename_result"
Chris@82 2565 func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
Chris@82 2566 }
Chris@82 2567
Chris@82 2568 # func_ltwrapper_p file
Chris@82 2569 # True iff FILE is a libtool wrapper script or wrapper executable
Chris@82 2570 # This function is only a basic sanity check; it will hardly flush out
Chris@82 2571 # determined imposters.
Chris@82 2572 func_ltwrapper_p ()
Chris@82 2573 {
Chris@82 2574 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
Chris@82 2575 }
Chris@82 2576
Chris@82 2577
Chris@82 2578 # func_execute_cmds commands fail_cmd
Chris@82 2579 # Execute tilde-delimited COMMANDS.
Chris@82 2580 # If FAIL_CMD is given, eval that upon failure.
Chris@82 2581 # FAIL_CMD may read-access the current command in variable CMD!
Chris@82 2582 func_execute_cmds ()
Chris@82 2583 {
Chris@82 2584 $debug_cmd
Chris@82 2585
Chris@82 2586 save_ifs=$IFS; IFS='~'
Chris@82 2587 for cmd in $1; do
Chris@82 2588 IFS=$sp$nl
Chris@82 2589 eval cmd=\"$cmd\"
Chris@82 2590 IFS=$save_ifs
Chris@82 2591 func_show_eval "$cmd" "${2-:}"
Chris@82 2592 done
Chris@82 2593 IFS=$save_ifs
Chris@82 2594 }
Chris@82 2595
Chris@82 2596
Chris@82 2597 # func_source file
Chris@82 2598 # Source FILE, adding directory component if necessary.
Chris@82 2599 # Note that it is not necessary on cygwin/mingw to append a dot to
Chris@82 2600 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
Chris@82 2601 # behavior happens only for exec(3), not for open(2)! Also, sourcing
Chris@82 2602 # 'FILE.' does not work on cygwin managed mounts.
Chris@82 2603 func_source ()
Chris@82 2604 {
Chris@82 2605 $debug_cmd
Chris@82 2606
Chris@82 2607 case $1 in
Chris@82 2608 */* | *\\*) . "$1" ;;
Chris@82 2609 *) . "./$1" ;;
Chris@82 2610 esac
Chris@82 2611 }
Chris@82 2612
Chris@82 2613
Chris@82 2614 # func_resolve_sysroot PATH
Chris@82 2615 # Replace a leading = in PATH with a sysroot. Store the result into
Chris@82 2616 # func_resolve_sysroot_result
Chris@82 2617 func_resolve_sysroot ()
Chris@82 2618 {
Chris@82 2619 func_resolve_sysroot_result=$1
Chris@82 2620 case $func_resolve_sysroot_result in
Chris@82 2621 =*)
Chris@82 2622 func_stripname '=' '' "$func_resolve_sysroot_result"
Chris@82 2623 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
Chris@82 2624 ;;
Chris@82 2625 esac
Chris@82 2626 }
Chris@82 2627
Chris@82 2628 # func_replace_sysroot PATH
Chris@82 2629 # If PATH begins with the sysroot, replace it with = and
Chris@82 2630 # store the result into func_replace_sysroot_result.
Chris@82 2631 func_replace_sysroot ()
Chris@82 2632 {
Chris@82 2633 case $lt_sysroot:$1 in
Chris@82 2634 ?*:"$lt_sysroot"*)
Chris@82 2635 func_stripname "$lt_sysroot" '' "$1"
Chris@82 2636 func_replace_sysroot_result='='$func_stripname_result
Chris@82 2637 ;;
Chris@82 2638 *)
Chris@82 2639 # Including no sysroot.
Chris@82 2640 func_replace_sysroot_result=$1
Chris@82 2641 ;;
Chris@82 2642 esac
Chris@82 2643 }
Chris@82 2644
Chris@82 2645 # func_infer_tag arg
Chris@82 2646 # Infer tagged configuration to use if any are available and
Chris@82 2647 # if one wasn't chosen via the "--tag" command line option.
Chris@82 2648 # Only attempt this if the compiler in the base compile
Chris@82 2649 # command doesn't match the default compiler.
Chris@82 2650 # arg is usually of the form 'gcc ...'
Chris@82 2651 func_infer_tag ()
Chris@82 2652 {
Chris@82 2653 $debug_cmd
Chris@82 2654
Chris@82 2655 if test -n "$available_tags" && test -z "$tagname"; then
Chris@82 2656 CC_quoted=
Chris@82 2657 for arg in $CC; do
Chris@82 2658 func_append_quoted CC_quoted "$arg"
Chris@82 2659 done
Chris@82 2660 CC_expanded=`func_echo_all $CC`
Chris@82 2661 CC_quoted_expanded=`func_echo_all $CC_quoted`
Chris@82 2662 case $@ in
Chris@82 2663 # Blanks in the command may have been stripped by the calling shell,
Chris@82 2664 # but not from the CC environment variable when configure was run.
Chris@82 2665 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
Chris@82 2666 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
Chris@82 2667 # Blanks at the start of $base_compile will cause this to fail
Chris@82 2668 # if we don't check for them as well.
Chris@82 2669 *)
Chris@82 2670 for z in $available_tags; do
Chris@82 2671 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
Chris@82 2672 # Evaluate the configuration.
Chris@82 2673 eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
Chris@82 2674 CC_quoted=
Chris@82 2675 for arg in $CC; do
Chris@82 2676 # Double-quote args containing other shell metacharacters.
Chris@82 2677 func_append_quoted CC_quoted "$arg"
Chris@82 2678 done
Chris@82 2679 CC_expanded=`func_echo_all $CC`
Chris@82 2680 CC_quoted_expanded=`func_echo_all $CC_quoted`
Chris@82 2681 case "$@ " in
Chris@82 2682 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
Chris@82 2683 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
Chris@82 2684 # The compiler in the base compile command matches
Chris@82 2685 # the one in the tagged configuration.
Chris@82 2686 # Assume this is the tagged configuration we want.
Chris@82 2687 tagname=$z
Chris@82 2688 break
Chris@82 2689 ;;
Chris@82 2690 esac
Chris@82 2691 fi
Chris@82 2692 done
Chris@82 2693 # If $tagname still isn't set, then no tagged configuration
Chris@82 2694 # was found and let the user know that the "--tag" command
Chris@82 2695 # line option must be used.
Chris@82 2696 if test -z "$tagname"; then
Chris@82 2697 func_echo "unable to infer tagged configuration"
Chris@82 2698 func_fatal_error "specify a tag with '--tag'"
Chris@82 2699 # else
Chris@82 2700 # func_verbose "using $tagname tagged configuration"
Chris@82 2701 fi
Chris@82 2702 ;;
Chris@82 2703 esac
Chris@82 2704 fi
Chris@82 2705 }
Chris@82 2706
Chris@82 2707
Chris@82 2708
Chris@82 2709 # func_write_libtool_object output_name pic_name nonpic_name
Chris@82 2710 # Create a libtool object file (analogous to a ".la" file),
Chris@82 2711 # but don't create it if we're doing a dry run.
Chris@82 2712 func_write_libtool_object ()
Chris@82 2713 {
Chris@82 2714 write_libobj=$1
Chris@82 2715 if test yes = "$build_libtool_libs"; then
Chris@82 2716 write_lobj=\'$2\'
Chris@82 2717 else
Chris@82 2718 write_lobj=none
Chris@82 2719 fi
Chris@82 2720
Chris@82 2721 if test yes = "$build_old_libs"; then
Chris@82 2722 write_oldobj=\'$3\'
Chris@82 2723 else
Chris@82 2724 write_oldobj=none
Chris@82 2725 fi
Chris@82 2726
Chris@82 2727 $opt_dry_run || {
Chris@82 2728 cat >${write_libobj}T <<EOF
Chris@82 2729 # $write_libobj - a libtool object file
Chris@82 2730 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@82 2731 #
Chris@82 2732 # Please DO NOT delete this file!
Chris@82 2733 # It is necessary for linking the library.
Chris@82 2734
Chris@82 2735 # Name of the PIC object.
Chris@82 2736 pic_object=$write_lobj
Chris@82 2737
Chris@82 2738 # Name of the non-PIC object
Chris@82 2739 non_pic_object=$write_oldobj
Chris@82 2740
Chris@82 2741 EOF
Chris@82 2742 $MV "${write_libobj}T" "$write_libobj"
Chris@82 2743 }
Chris@82 2744 }
Chris@82 2745
Chris@82 2746
Chris@82 2747 ##################################################
Chris@82 2748 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
Chris@82 2749 ##################################################
Chris@82 2750
Chris@82 2751 # func_convert_core_file_wine_to_w32 ARG
Chris@82 2752 # Helper function used by file name conversion functions when $build is *nix,
Chris@82 2753 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
Chris@82 2754 # correctly configured wine environment available, with the winepath program
Chris@82 2755 # in $build's $PATH.
Chris@82 2756 #
Chris@82 2757 # ARG is the $build file name to be converted to w32 format.
Chris@82 2758 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
Chris@82 2759 # be empty on error (or when ARG is empty)
Chris@82 2760 func_convert_core_file_wine_to_w32 ()
Chris@82 2761 {
Chris@82 2762 $debug_cmd
Chris@82 2763
Chris@82 2764 func_convert_core_file_wine_to_w32_result=$1
Chris@82 2765 if test -n "$1"; then
Chris@82 2766 # Unfortunately, winepath does not exit with a non-zero error code, so we
Chris@82 2767 # are forced to check the contents of stdout. On the other hand, if the
Chris@82 2768 # command is not found, the shell will set an exit code of 127 and print
Chris@82 2769 # *an error message* to stdout. So we must check for both error code of
Chris@82 2770 # zero AND non-empty stdout, which explains the odd construction:
Chris@82 2771 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
Chris@82 2772 if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
Chris@82 2773 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
Chris@82 2774 $SED -e "$sed_naive_backslashify"`
Chris@82 2775 else
Chris@82 2776 func_convert_core_file_wine_to_w32_result=
Chris@82 2777 fi
Chris@82 2778 fi
Chris@82 2779 }
Chris@82 2780 # end: func_convert_core_file_wine_to_w32
Chris@82 2781
Chris@82 2782
Chris@82 2783 # func_convert_core_path_wine_to_w32 ARG
Chris@82 2784 # Helper function used by path conversion functions when $build is *nix, and
Chris@82 2785 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
Chris@82 2786 # configured wine environment available, with the winepath program in $build's
Chris@82 2787 # $PATH. Assumes ARG has no leading or trailing path separator characters.
Chris@82 2788 #
Chris@82 2789 # ARG is path to be converted from $build format to win32.
Chris@82 2790 # Result is available in $func_convert_core_path_wine_to_w32_result.
Chris@82 2791 # Unconvertible file (directory) names in ARG are skipped; if no directory names
Chris@82 2792 # are convertible, then the result may be empty.
Chris@82 2793 func_convert_core_path_wine_to_w32 ()
Chris@82 2794 {
Chris@82 2795 $debug_cmd
Chris@82 2796
Chris@82 2797 # unfortunately, winepath doesn't convert paths, only file names
Chris@82 2798 func_convert_core_path_wine_to_w32_result=
Chris@82 2799 if test -n "$1"; then
Chris@82 2800 oldIFS=$IFS
Chris@82 2801 IFS=:
Chris@82 2802 for func_convert_core_path_wine_to_w32_f in $1; do
Chris@82 2803 IFS=$oldIFS
Chris@82 2804 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
Chris@82 2805 if test -n "$func_convert_core_file_wine_to_w32_result"; then
Chris@82 2806 if test -z "$func_convert_core_path_wine_to_w32_result"; then
Chris@82 2807 func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
Chris@82 2808 else
Chris@82 2809 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
Chris@82 2810 fi
Chris@82 2811 fi
Chris@82 2812 done
Chris@82 2813 IFS=$oldIFS
Chris@82 2814 fi
Chris@82 2815 }
Chris@82 2816 # end: func_convert_core_path_wine_to_w32
Chris@82 2817
Chris@82 2818
Chris@82 2819 # func_cygpath ARGS...
Chris@82 2820 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
Chris@82 2821 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
Chris@82 2822 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
Chris@82 2823 # (2), returns the Cygwin file name or path in func_cygpath_result (input
Chris@82 2824 # file name or path is assumed to be in w32 format, as previously converted
Chris@82 2825 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
Chris@82 2826 # or path in func_cygpath_result (input file name or path is assumed to be in
Chris@82 2827 # Cygwin format). Returns an empty string on error.
Chris@82 2828 #
Chris@82 2829 # ARGS are passed to cygpath, with the last one being the file name or path to
Chris@82 2830 # be converted.
Chris@82 2831 #
Chris@82 2832 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
Chris@82 2833 # environment variable; do not put it in $PATH.
Chris@82 2834 func_cygpath ()
Chris@82 2835 {
Chris@82 2836 $debug_cmd
Chris@82 2837
Chris@82 2838 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
Chris@82 2839 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
Chris@82 2840 if test "$?" -ne 0; then
Chris@82 2841 # on failure, ensure result is empty
Chris@82 2842 func_cygpath_result=
Chris@82 2843 fi
Chris@82 2844 else
Chris@82 2845 func_cygpath_result=
Chris@82 2846 func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
Chris@82 2847 fi
Chris@82 2848 }
Chris@82 2849 #end: func_cygpath
Chris@82 2850
Chris@82 2851
Chris@82 2852 # func_convert_core_msys_to_w32 ARG
Chris@82 2853 # Convert file name or path ARG from MSYS format to w32 format. Return
Chris@82 2854 # result in func_convert_core_msys_to_w32_result.
Chris@82 2855 func_convert_core_msys_to_w32 ()
Chris@82 2856 {
Chris@82 2857 $debug_cmd
Chris@82 2858
Chris@82 2859 # awkward: cmd appends spaces to result
Chris@82 2860 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
Chris@82 2861 $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
Chris@82 2862 }
Chris@82 2863 #end: func_convert_core_msys_to_w32
Chris@82 2864
Chris@82 2865
Chris@82 2866 # func_convert_file_check ARG1 ARG2
Chris@82 2867 # Verify that ARG1 (a file name in $build format) was converted to $host
Chris@82 2868 # format in ARG2. Otherwise, emit an error message, but continue (resetting
Chris@82 2869 # func_to_host_file_result to ARG1).
Chris@82 2870 func_convert_file_check ()
Chris@82 2871 {
Chris@82 2872 $debug_cmd
Chris@82 2873
Chris@82 2874 if test -z "$2" && test -n "$1"; then
Chris@82 2875 func_error "Could not determine host file name corresponding to"
Chris@82 2876 func_error " '$1'"
Chris@82 2877 func_error "Continuing, but uninstalled executables may not work."
Chris@82 2878 # Fallback:
Chris@82 2879 func_to_host_file_result=$1
Chris@82 2880 fi
Chris@82 2881 }
Chris@82 2882 # end func_convert_file_check
Chris@82 2883
Chris@82 2884
Chris@82 2885 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
Chris@82 2886 # Verify that FROM_PATH (a path in $build format) was converted to $host
Chris@82 2887 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
Chris@82 2888 # func_to_host_file_result to a simplistic fallback value (see below).
Chris@82 2889 func_convert_path_check ()
Chris@82 2890 {
Chris@82 2891 $debug_cmd
Chris@82 2892
Chris@82 2893 if test -z "$4" && test -n "$3"; then
Chris@82 2894 func_error "Could not determine the host path corresponding to"
Chris@82 2895 func_error " '$3'"
Chris@82 2896 func_error "Continuing, but uninstalled executables may not work."
Chris@82 2897 # Fallback. This is a deliberately simplistic "conversion" and
Chris@82 2898 # should not be "improved". See libtool.info.
Chris@82 2899 if test "x$1" != "x$2"; then
Chris@82 2900 lt_replace_pathsep_chars="s|$1|$2|g"
Chris@82 2901 func_to_host_path_result=`echo "$3" |
Chris@82 2902 $SED -e "$lt_replace_pathsep_chars"`
Chris@82 2903 else
Chris@82 2904 func_to_host_path_result=$3
Chris@82 2905 fi
Chris@82 2906 fi
Chris@82 2907 }
Chris@82 2908 # end func_convert_path_check
Chris@82 2909
Chris@82 2910
Chris@82 2911 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
Chris@82 2912 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
Chris@82 2913 # and appending REPL if ORIG matches BACKPAT.
Chris@82 2914 func_convert_path_front_back_pathsep ()
Chris@82 2915 {
Chris@82 2916 $debug_cmd
Chris@82 2917
Chris@82 2918 case $4 in
Chris@82 2919 $1 ) func_to_host_path_result=$3$func_to_host_path_result
Chris@82 2920 ;;
Chris@82 2921 esac
Chris@82 2922 case $4 in
Chris@82 2923 $2 ) func_append func_to_host_path_result "$3"
Chris@82 2924 ;;
Chris@82 2925 esac
Chris@82 2926 }
Chris@82 2927 # end func_convert_path_front_back_pathsep
Chris@82 2928
Chris@82 2929
Chris@82 2930 ##################################################
Chris@82 2931 # $build to $host FILE NAME CONVERSION FUNCTIONS #
Chris@82 2932 ##################################################
Chris@82 2933 # invoked via '$to_host_file_cmd ARG'
Chris@82 2934 #
Chris@82 2935 # In each case, ARG is the path to be converted from $build to $host format.
Chris@82 2936 # Result will be available in $func_to_host_file_result.
Chris@82 2937
Chris@82 2938
Chris@82 2939 # func_to_host_file ARG
Chris@82 2940 # Converts the file name ARG from $build format to $host format. Return result
Chris@82 2941 # in func_to_host_file_result.
Chris@82 2942 func_to_host_file ()
Chris@82 2943 {
Chris@82 2944 $debug_cmd
Chris@82 2945
Chris@82 2946 $to_host_file_cmd "$1"
Chris@82 2947 }
Chris@82 2948 # end func_to_host_file
Chris@82 2949
Chris@82 2950
Chris@82 2951 # func_to_tool_file ARG LAZY
Chris@82 2952 # converts the file name ARG from $build format to toolchain format. Return
Chris@82 2953 # result in func_to_tool_file_result. If the conversion in use is listed
Chris@82 2954 # in (the comma separated) LAZY, no conversion takes place.
Chris@82 2955 func_to_tool_file ()
Chris@82 2956 {
Chris@82 2957 $debug_cmd
Chris@82 2958
Chris@82 2959 case ,$2, in
Chris@82 2960 *,"$to_tool_file_cmd",*)
Chris@82 2961 func_to_tool_file_result=$1
Chris@82 2962 ;;
Chris@82 2963 *)
Chris@82 2964 $to_tool_file_cmd "$1"
Chris@82 2965 func_to_tool_file_result=$func_to_host_file_result
Chris@82 2966 ;;
Chris@82 2967 esac
Chris@82 2968 }
Chris@82 2969 # end func_to_tool_file
Chris@82 2970
Chris@82 2971
Chris@82 2972 # func_convert_file_noop ARG
Chris@82 2973 # Copy ARG to func_to_host_file_result.
Chris@82 2974 func_convert_file_noop ()
Chris@82 2975 {
Chris@82 2976 func_to_host_file_result=$1
Chris@82 2977 }
Chris@82 2978 # end func_convert_file_noop
Chris@82 2979
Chris@82 2980
Chris@82 2981 # func_convert_file_msys_to_w32 ARG
Chris@82 2982 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
Chris@82 2983 # conversion to w32 is not available inside the cwrapper. Returns result in
Chris@82 2984 # func_to_host_file_result.
Chris@82 2985 func_convert_file_msys_to_w32 ()
Chris@82 2986 {
Chris@82 2987 $debug_cmd
Chris@82 2988
Chris@82 2989 func_to_host_file_result=$1
Chris@82 2990 if test -n "$1"; then
Chris@82 2991 func_convert_core_msys_to_w32 "$1"
Chris@82 2992 func_to_host_file_result=$func_convert_core_msys_to_w32_result
Chris@82 2993 fi
Chris@82 2994 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@82 2995 }
Chris@82 2996 # end func_convert_file_msys_to_w32
Chris@82 2997
Chris@82 2998
Chris@82 2999 # func_convert_file_cygwin_to_w32 ARG
Chris@82 3000 # Convert file name ARG from Cygwin to w32 format. Returns result in
Chris@82 3001 # func_to_host_file_result.
Chris@82 3002 func_convert_file_cygwin_to_w32 ()
Chris@82 3003 {
Chris@82 3004 $debug_cmd
Chris@82 3005
Chris@82 3006 func_to_host_file_result=$1
Chris@82 3007 if test -n "$1"; then
Chris@82 3008 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
Chris@82 3009 # LT_CYGPATH in this case.
Chris@82 3010 func_to_host_file_result=`cygpath -m "$1"`
Chris@82 3011 fi
Chris@82 3012 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@82 3013 }
Chris@82 3014 # end func_convert_file_cygwin_to_w32
Chris@82 3015
Chris@82 3016
Chris@82 3017 # func_convert_file_nix_to_w32 ARG
Chris@82 3018 # Convert file name ARG from *nix to w32 format. Requires a wine environment
Chris@82 3019 # and a working winepath. Returns result in func_to_host_file_result.
Chris@82 3020 func_convert_file_nix_to_w32 ()
Chris@82 3021 {
Chris@82 3022 $debug_cmd
Chris@82 3023
Chris@82 3024 func_to_host_file_result=$1
Chris@82 3025 if test -n "$1"; then
Chris@82 3026 func_convert_core_file_wine_to_w32 "$1"
Chris@82 3027 func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
Chris@82 3028 fi
Chris@82 3029 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@82 3030 }
Chris@82 3031 # end func_convert_file_nix_to_w32
Chris@82 3032
Chris@82 3033
Chris@82 3034 # func_convert_file_msys_to_cygwin ARG
Chris@82 3035 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
Chris@82 3036 # Returns result in func_to_host_file_result.
Chris@82 3037 func_convert_file_msys_to_cygwin ()
Chris@82 3038 {
Chris@82 3039 $debug_cmd
Chris@82 3040
Chris@82 3041 func_to_host_file_result=$1
Chris@82 3042 if test -n "$1"; then
Chris@82 3043 func_convert_core_msys_to_w32 "$1"
Chris@82 3044 func_cygpath -u "$func_convert_core_msys_to_w32_result"
Chris@82 3045 func_to_host_file_result=$func_cygpath_result
Chris@82 3046 fi
Chris@82 3047 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@82 3048 }
Chris@82 3049 # end func_convert_file_msys_to_cygwin
Chris@82 3050
Chris@82 3051
Chris@82 3052 # func_convert_file_nix_to_cygwin ARG
Chris@82 3053 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
Chris@82 3054 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
Chris@82 3055 # in func_to_host_file_result.
Chris@82 3056 func_convert_file_nix_to_cygwin ()
Chris@82 3057 {
Chris@82 3058 $debug_cmd
Chris@82 3059
Chris@82 3060 func_to_host_file_result=$1
Chris@82 3061 if test -n "$1"; then
Chris@82 3062 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
Chris@82 3063 func_convert_core_file_wine_to_w32 "$1"
Chris@82 3064 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
Chris@82 3065 func_to_host_file_result=$func_cygpath_result
Chris@82 3066 fi
Chris@82 3067 func_convert_file_check "$1" "$func_to_host_file_result"
Chris@82 3068 }
Chris@82 3069 # end func_convert_file_nix_to_cygwin
Chris@82 3070
Chris@82 3071
Chris@82 3072 #############################################
Chris@82 3073 # $build to $host PATH CONVERSION FUNCTIONS #
Chris@82 3074 #############################################
Chris@82 3075 # invoked via '$to_host_path_cmd ARG'
Chris@82 3076 #
Chris@82 3077 # In each case, ARG is the path to be converted from $build to $host format.
Chris@82 3078 # The result will be available in $func_to_host_path_result.
Chris@82 3079 #
Chris@82 3080 # Path separators are also converted from $build format to $host format. If
Chris@82 3081 # ARG begins or ends with a path separator character, it is preserved (but
Chris@82 3082 # converted to $host format) on output.
Chris@82 3083 #
Chris@82 3084 # All path conversion functions are named using the following convention:
Chris@82 3085 # file name conversion function : func_convert_file_X_to_Y ()
Chris@82 3086 # path conversion function : func_convert_path_X_to_Y ()
Chris@82 3087 # where, for any given $build/$host combination the 'X_to_Y' value is the
Chris@82 3088 # same. If conversion functions are added for new $build/$host combinations,
Chris@82 3089 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
Chris@82 3090 # will break.
Chris@82 3091
Chris@82 3092
Chris@82 3093 # func_init_to_host_path_cmd
Chris@82 3094 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
Chris@82 3095 # appropriate value, based on the value of $to_host_file_cmd.
Chris@82 3096 to_host_path_cmd=
Chris@82 3097 func_init_to_host_path_cmd ()
Chris@82 3098 {
Chris@82 3099 $debug_cmd
Chris@82 3100
Chris@82 3101 if test -z "$to_host_path_cmd"; then
Chris@82 3102 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
Chris@82 3103 to_host_path_cmd=func_convert_path_$func_stripname_result
Chris@82 3104 fi
Chris@82 3105 }
Chris@82 3106
Chris@82 3107
Chris@82 3108 # func_to_host_path ARG
Chris@82 3109 # Converts the path ARG from $build format to $host format. Return result
Chris@82 3110 # in func_to_host_path_result.
Chris@82 3111 func_to_host_path ()
Chris@82 3112 {
Chris@82 3113 $debug_cmd
Chris@82 3114
Chris@82 3115 func_init_to_host_path_cmd
Chris@82 3116 $to_host_path_cmd "$1"
Chris@82 3117 }
Chris@82 3118 # end func_to_host_path
Chris@82 3119
Chris@82 3120
Chris@82 3121 # func_convert_path_noop ARG
Chris@82 3122 # Copy ARG to func_to_host_path_result.
Chris@82 3123 func_convert_path_noop ()
Chris@82 3124 {
Chris@82 3125 func_to_host_path_result=$1
Chris@82 3126 }
Chris@82 3127 # end func_convert_path_noop
Chris@82 3128
Chris@82 3129
Chris@82 3130 # func_convert_path_msys_to_w32 ARG
Chris@82 3131 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
Chris@82 3132 # conversion to w32 is not available inside the cwrapper. Returns result in
Chris@82 3133 # func_to_host_path_result.
Chris@82 3134 func_convert_path_msys_to_w32 ()
Chris@82 3135 {
Chris@82 3136 $debug_cmd
Chris@82 3137
Chris@82 3138 func_to_host_path_result=$1
Chris@82 3139 if test -n "$1"; then
Chris@82 3140 # Remove leading and trailing path separator characters from ARG. MSYS
Chris@82 3141 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
Chris@82 3142 # and winepath ignores them completely.
Chris@82 3143 func_stripname : : "$1"
Chris@82 3144 func_to_host_path_tmp1=$func_stripname_result
Chris@82 3145 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
Chris@82 3146 func_to_host_path_result=$func_convert_core_msys_to_w32_result
Chris@82 3147 func_convert_path_check : ";" \
Chris@82 3148 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@82 3149 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Chris@82 3150 fi
Chris@82 3151 }
Chris@82 3152 # end func_convert_path_msys_to_w32
Chris@82 3153
Chris@82 3154
Chris@82 3155 # func_convert_path_cygwin_to_w32 ARG
Chris@82 3156 # Convert path ARG from Cygwin to w32 format. Returns result in
Chris@82 3157 # func_to_host_file_result.
Chris@82 3158 func_convert_path_cygwin_to_w32 ()
Chris@82 3159 {
Chris@82 3160 $debug_cmd
Chris@82 3161
Chris@82 3162 func_to_host_path_result=$1
Chris@82 3163 if test -n "$1"; then
Chris@82 3164 # See func_convert_path_msys_to_w32:
Chris@82 3165 func_stripname : : "$1"
Chris@82 3166 func_to_host_path_tmp1=$func_stripname_result
Chris@82 3167 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
Chris@82 3168 func_convert_path_check : ";" \
Chris@82 3169 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@82 3170 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Chris@82 3171 fi
Chris@82 3172 }
Chris@82 3173 # end func_convert_path_cygwin_to_w32
Chris@82 3174
Chris@82 3175
Chris@82 3176 # func_convert_path_nix_to_w32 ARG
Chris@82 3177 # Convert path ARG from *nix to w32 format. Requires a wine environment and
Chris@82 3178 # a working winepath. Returns result in func_to_host_file_result.
Chris@82 3179 func_convert_path_nix_to_w32 ()
Chris@82 3180 {
Chris@82 3181 $debug_cmd
Chris@82 3182
Chris@82 3183 func_to_host_path_result=$1
Chris@82 3184 if test -n "$1"; then
Chris@82 3185 # See func_convert_path_msys_to_w32:
Chris@82 3186 func_stripname : : "$1"
Chris@82 3187 func_to_host_path_tmp1=$func_stripname_result
Chris@82 3188 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
Chris@82 3189 func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
Chris@82 3190 func_convert_path_check : ";" \
Chris@82 3191 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@82 3192 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
Chris@82 3193 fi
Chris@82 3194 }
Chris@82 3195 # end func_convert_path_nix_to_w32
Chris@82 3196
Chris@82 3197
Chris@82 3198 # func_convert_path_msys_to_cygwin ARG
Chris@82 3199 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
Chris@82 3200 # Returns result in func_to_host_file_result.
Chris@82 3201 func_convert_path_msys_to_cygwin ()
Chris@82 3202 {
Chris@82 3203 $debug_cmd
Chris@82 3204
Chris@82 3205 func_to_host_path_result=$1
Chris@82 3206 if test -n "$1"; then
Chris@82 3207 # See func_convert_path_msys_to_w32:
Chris@82 3208 func_stripname : : "$1"
Chris@82 3209 func_to_host_path_tmp1=$func_stripname_result
Chris@82 3210 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
Chris@82 3211 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
Chris@82 3212 func_to_host_path_result=$func_cygpath_result
Chris@82 3213 func_convert_path_check : : \
Chris@82 3214 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@82 3215 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
Chris@82 3216 fi
Chris@82 3217 }
Chris@82 3218 # end func_convert_path_msys_to_cygwin
Chris@82 3219
Chris@82 3220
Chris@82 3221 # func_convert_path_nix_to_cygwin ARG
Chris@82 3222 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
Chris@82 3223 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
Chris@82 3224 # func_to_host_file_result.
Chris@82 3225 func_convert_path_nix_to_cygwin ()
Chris@82 3226 {
Chris@82 3227 $debug_cmd
Chris@82 3228
Chris@82 3229 func_to_host_path_result=$1
Chris@82 3230 if test -n "$1"; then
Chris@82 3231 # Remove leading and trailing path separator characters from
Chris@82 3232 # ARG. msys behavior is inconsistent here, cygpath turns them
Chris@82 3233 # into '.;' and ';.', and winepath ignores them completely.
Chris@82 3234 func_stripname : : "$1"
Chris@82 3235 func_to_host_path_tmp1=$func_stripname_result
Chris@82 3236 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
Chris@82 3237 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
Chris@82 3238 func_to_host_path_result=$func_cygpath_result
Chris@82 3239 func_convert_path_check : : \
Chris@82 3240 "$func_to_host_path_tmp1" "$func_to_host_path_result"
Chris@82 3241 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
Chris@82 3242 fi
Chris@82 3243 }
Chris@82 3244 # end func_convert_path_nix_to_cygwin
Chris@82 3245
Chris@82 3246
Chris@82 3247 # func_dll_def_p FILE
Chris@82 3248 # True iff FILE is a Windows DLL '.def' file.
Chris@82 3249 # Keep in sync with _LT_DLL_DEF_P in libtool.m4
Chris@82 3250 func_dll_def_p ()
Chris@82 3251 {
Chris@82 3252 $debug_cmd
Chris@82 3253
Chris@82 3254 func_dll_def_p_tmp=`$SED -n \
Chris@82 3255 -e 's/^[ ]*//' \
Chris@82 3256 -e '/^\(;.*\)*$/d' \
Chris@82 3257 -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
Chris@82 3258 -e q \
Chris@82 3259 "$1"`
Chris@82 3260 test DEF = "$func_dll_def_p_tmp"
Chris@82 3261 }
Chris@82 3262
Chris@82 3263
Chris@82 3264 # func_mode_compile arg...
Chris@82 3265 func_mode_compile ()
Chris@82 3266 {
Chris@82 3267 $debug_cmd
Chris@82 3268
Chris@82 3269 # Get the compilation command and the source file.
Chris@82 3270 base_compile=
Chris@82 3271 srcfile=$nonopt # always keep a non-empty value in "srcfile"
Chris@82 3272 suppress_opt=yes
Chris@82 3273 suppress_output=
Chris@82 3274 arg_mode=normal
Chris@82 3275 libobj=
Chris@82 3276 later=
Chris@82 3277 pie_flag=
Chris@82 3278
Chris@82 3279 for arg
Chris@82 3280 do
Chris@82 3281 case $arg_mode in
Chris@82 3282 arg )
Chris@82 3283 # do not "continue". Instead, add this to base_compile
Chris@82 3284 lastarg=$arg
Chris@82 3285 arg_mode=normal
Chris@82 3286 ;;
Chris@82 3287
Chris@82 3288 target )
Chris@82 3289 libobj=$arg
Chris@82 3290 arg_mode=normal
Chris@82 3291 continue
Chris@82 3292 ;;
Chris@82 3293
Chris@82 3294 normal )
Chris@82 3295 # Accept any command-line options.
Chris@82 3296 case $arg in
Chris@82 3297 -o)
Chris@82 3298 test -n "$libobj" && \
Chris@82 3299 func_fatal_error "you cannot specify '-o' more than once"
Chris@82 3300 arg_mode=target
Chris@82 3301 continue
Chris@82 3302 ;;
Chris@82 3303
Chris@82 3304 -pie | -fpie | -fPIE)
Chris@82 3305 func_append pie_flag " $arg"
Chris@82 3306 continue
Chris@82 3307 ;;
Chris@82 3308
Chris@82 3309 -shared | -static | -prefer-pic | -prefer-non-pic)
Chris@82 3310 func_append later " $arg"
Chris@82 3311 continue
Chris@82 3312 ;;
Chris@82 3313
Chris@82 3314 -no-suppress)
Chris@82 3315 suppress_opt=no
Chris@82 3316 continue
Chris@82 3317 ;;
Chris@82 3318
Chris@82 3319 -Xcompiler)
Chris@82 3320 arg_mode=arg # the next one goes into the "base_compile" arg list
Chris@82 3321 continue # The current "srcfile" will either be retained or
Chris@82 3322 ;; # replaced later. I would guess that would be a bug.
Chris@82 3323
Chris@82 3324 -Wc,*)
Chris@82 3325 func_stripname '-Wc,' '' "$arg"
Chris@82 3326 args=$func_stripname_result
Chris@82 3327 lastarg=
Chris@82 3328 save_ifs=$IFS; IFS=,
Chris@82 3329 for arg in $args; do
Chris@82 3330 IFS=$save_ifs
Chris@82 3331 func_append_quoted lastarg "$arg"
Chris@82 3332 done
Chris@82 3333 IFS=$save_ifs
Chris@82 3334 func_stripname ' ' '' "$lastarg"
Chris@82 3335 lastarg=$func_stripname_result
Chris@82 3336
Chris@82 3337 # Add the arguments to base_compile.
Chris@82 3338 func_append base_compile " $lastarg"
Chris@82 3339 continue
Chris@82 3340 ;;
Chris@82 3341
Chris@82 3342 *)
Chris@82 3343 # Accept the current argument as the source file.
Chris@82 3344 # The previous "srcfile" becomes the current argument.
Chris@82 3345 #
Chris@82 3346 lastarg=$srcfile
Chris@82 3347 srcfile=$arg
Chris@82 3348 ;;
Chris@82 3349 esac # case $arg
Chris@82 3350 ;;
Chris@82 3351 esac # case $arg_mode
Chris@82 3352
Chris@82 3353 # Aesthetically quote the previous argument.
Chris@82 3354 func_append_quoted base_compile "$lastarg"
Chris@82 3355 done # for arg
Chris@82 3356
Chris@82 3357 case $arg_mode in
Chris@82 3358 arg)
Chris@82 3359 func_fatal_error "you must specify an argument for -Xcompile"
Chris@82 3360 ;;
Chris@82 3361 target)
Chris@82 3362 func_fatal_error "you must specify a target with '-o'"
Chris@82 3363 ;;
Chris@82 3364 *)
Chris@82 3365 # Get the name of the library object.
Chris@82 3366 test -z "$libobj" && {
Chris@82 3367 func_basename "$srcfile"
Chris@82 3368 libobj=$func_basename_result
Chris@82 3369 }
Chris@82 3370 ;;
Chris@82 3371 esac
Chris@82 3372
Chris@82 3373 # Recognize several different file suffixes.
Chris@82 3374 # If the user specifies -o file.o, it is replaced with file.lo
Chris@82 3375 case $libobj in
Chris@82 3376 *.[cCFSifmso] | \
Chris@82 3377 *.ada | *.adb | *.ads | *.asm | \
Chris@82 3378 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
Chris@82 3379 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
Chris@82 3380 func_xform "$libobj"
Chris@82 3381 libobj=$func_xform_result
Chris@82 3382 ;;
Chris@82 3383 esac
Chris@82 3384
Chris@82 3385 case $libobj in
Chris@82 3386 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
Chris@82 3387 *)
Chris@82 3388 func_fatal_error "cannot determine name of library object from '$libobj'"
Chris@82 3389 ;;
Chris@82 3390 esac
Chris@82 3391
Chris@82 3392 func_infer_tag $base_compile
Chris@82 3393
Chris@82 3394 for arg in $later; do
Chris@82 3395 case $arg in
Chris@82 3396 -shared)
Chris@82 3397 test yes = "$build_libtool_libs" \
Chris@82 3398 || func_fatal_configuration "cannot build a shared library"
Chris@82 3399 build_old_libs=no
Chris@82 3400 continue
Chris@82 3401 ;;
Chris@82 3402
Chris@82 3403 -static)
Chris@82 3404 build_libtool_libs=no
Chris@82 3405 build_old_libs=yes
Chris@82 3406 continue
Chris@82 3407 ;;
Chris@82 3408
Chris@82 3409 -prefer-pic)
Chris@82 3410 pic_mode=yes
Chris@82 3411 continue
Chris@82 3412 ;;
Chris@82 3413
Chris@82 3414 -prefer-non-pic)
Chris@82 3415 pic_mode=no
Chris@82 3416 continue
Chris@82 3417 ;;
Chris@82 3418 esac
Chris@82 3419 done
Chris@82 3420
Chris@82 3421 func_quote_for_eval "$libobj"
Chris@82 3422 test "X$libobj" != "X$func_quote_for_eval_result" \
Chris@82 3423 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
Chris@82 3424 && func_warning "libobj name '$libobj' may not contain shell special characters."
Chris@82 3425 func_dirname_and_basename "$obj" "/" ""
Chris@82 3426 objname=$func_basename_result
Chris@82 3427 xdir=$func_dirname_result
Chris@82 3428 lobj=$xdir$objdir/$objname
Chris@82 3429
Chris@82 3430 test -z "$base_compile" && \
Chris@82 3431 func_fatal_help "you must specify a compilation command"
Chris@82 3432
Chris@82 3433 # Delete any leftover library objects.
Chris@82 3434 if test yes = "$build_old_libs"; then
Chris@82 3435 removelist="$obj $lobj $libobj ${libobj}T"
Chris@82 3436 else
Chris@82 3437 removelist="$lobj $libobj ${libobj}T"
Chris@82 3438 fi
Chris@82 3439
Chris@82 3440 # On Cygwin there's no "real" PIC flag so we must build both object types
Chris@82 3441 case $host_os in
Chris@82 3442 cygwin* | mingw* | pw32* | os2* | cegcc*)
Chris@82 3443 pic_mode=default
Chris@82 3444 ;;
Chris@82 3445 esac
Chris@82 3446 if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
Chris@82 3447 # non-PIC code in shared libraries is not supported
Chris@82 3448 pic_mode=default
Chris@82 3449 fi
Chris@82 3450
Chris@82 3451 # Calculate the filename of the output object if compiler does
Chris@82 3452 # not support -o with -c
Chris@82 3453 if test no = "$compiler_c_o"; then
Chris@82 3454 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
Chris@82 3455 lockfile=$output_obj.lock
Chris@82 3456 else
Chris@82 3457 output_obj=
Chris@82 3458 need_locks=no
Chris@82 3459 lockfile=
Chris@82 3460 fi
Chris@82 3461
Chris@82 3462 # Lock this critical section if it is needed
Chris@82 3463 # We use this script file to make the link, it avoids creating a new file
Chris@82 3464 if test yes = "$need_locks"; then
Chris@82 3465 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
Chris@82 3466 func_echo "Waiting for $lockfile to be removed"
Chris@82 3467 sleep 2
Chris@82 3468 done
Chris@82 3469 elif test warn = "$need_locks"; then
Chris@82 3470 if test -f "$lockfile"; then
Chris@82 3471 $ECHO "\
Chris@82 3472 *** ERROR, $lockfile exists and contains:
Chris@82 3473 `cat $lockfile 2>/dev/null`
Chris@82 3474
Chris@82 3475 This indicates that another process is trying to use the same
Chris@82 3476 temporary object file, and libtool could not work around it because
Chris@82 3477 your compiler does not support '-c' and '-o' together. If you
Chris@82 3478 repeat this compilation, it may succeed, by chance, but you had better
Chris@82 3479 avoid parallel builds (make -j) in this platform, or get a better
Chris@82 3480 compiler."
Chris@82 3481
Chris@82 3482 $opt_dry_run || $RM $removelist
Chris@82 3483 exit $EXIT_FAILURE
Chris@82 3484 fi
Chris@82 3485 func_append removelist " $output_obj"
Chris@82 3486 $ECHO "$srcfile" > "$lockfile"
Chris@82 3487 fi
Chris@82 3488
Chris@82 3489 $opt_dry_run || $RM $removelist
Chris@82 3490 func_append removelist " $lockfile"
Chris@82 3491 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
Chris@82 3492
Chris@82 3493 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
Chris@82 3494 srcfile=$func_to_tool_file_result
Chris@82 3495 func_quote_for_eval "$srcfile"
Chris@82 3496 qsrcfile=$func_quote_for_eval_result
Chris@82 3497
Chris@82 3498 # Only build a PIC object if we are building libtool libraries.
Chris@82 3499 if test yes = "$build_libtool_libs"; then
Chris@82 3500 # Without this assignment, base_compile gets emptied.
Chris@82 3501 fbsd_hideous_sh_bug=$base_compile
Chris@82 3502
Chris@82 3503 if test no != "$pic_mode"; then
Chris@82 3504 command="$base_compile $qsrcfile $pic_flag"
Chris@82 3505 else
Chris@82 3506 # Don't build PIC code
Chris@82 3507 command="$base_compile $qsrcfile"
Chris@82 3508 fi
Chris@82 3509
Chris@82 3510 func_mkdir_p "$xdir$objdir"
Chris@82 3511
Chris@82 3512 if test -z "$output_obj"; then
Chris@82 3513 # Place PIC objects in $objdir
Chris@82 3514 func_append command " -o $lobj"
Chris@82 3515 fi
Chris@82 3516
Chris@82 3517 func_show_eval_locale "$command" \
Chris@82 3518 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
Chris@82 3519
Chris@82 3520 if test warn = "$need_locks" &&
Chris@82 3521 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
Chris@82 3522 $ECHO "\
Chris@82 3523 *** ERROR, $lockfile contains:
Chris@82 3524 `cat $lockfile 2>/dev/null`
Chris@82 3525
Chris@82 3526 but it should contain:
Chris@82 3527 $srcfile
Chris@82 3528
Chris@82 3529 This indicates that another process is trying to use the same
Chris@82 3530 temporary object file, and libtool could not work around it because
Chris@82 3531 your compiler does not support '-c' and '-o' together. If you
Chris@82 3532 repeat this compilation, it may succeed, by chance, but you had better
Chris@82 3533 avoid parallel builds (make -j) in this platform, or get a better
Chris@82 3534 compiler."
Chris@82 3535
Chris@82 3536 $opt_dry_run || $RM $removelist
Chris@82 3537 exit $EXIT_FAILURE
Chris@82 3538 fi
Chris@82 3539
Chris@82 3540 # Just move the object if needed, then go on to compile the next one
Chris@82 3541 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
Chris@82 3542 func_show_eval '$MV "$output_obj" "$lobj"' \
Chris@82 3543 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
Chris@82 3544 fi
Chris@82 3545
Chris@82 3546 # Allow error messages only from the first compilation.
Chris@82 3547 if test yes = "$suppress_opt"; then
Chris@82 3548 suppress_output=' >/dev/null 2>&1'
Chris@82 3549 fi
Chris@82 3550 fi
Chris@82 3551
Chris@82 3552 # Only build a position-dependent object if we build old libraries.
Chris@82 3553 if test yes = "$build_old_libs"; then
Chris@82 3554 if test yes != "$pic_mode"; then
Chris@82 3555 # Don't build PIC code
Chris@82 3556 command="$base_compile $qsrcfile$pie_flag"
Chris@82 3557 else
Chris@82 3558 command="$base_compile $qsrcfile $pic_flag"
Chris@82 3559 fi
Chris@82 3560 if test yes = "$compiler_c_o"; then
Chris@82 3561 func_append command " -o $obj"
Chris@82 3562 fi
Chris@82 3563
Chris@82 3564 # Suppress compiler output if we already did a PIC compilation.
Chris@82 3565 func_append command "$suppress_output"
Chris@82 3566 func_show_eval_locale "$command" \
Chris@82 3567 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
Chris@82 3568
Chris@82 3569 if test warn = "$need_locks" &&
Chris@82 3570 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
Chris@82 3571 $ECHO "\
Chris@82 3572 *** ERROR, $lockfile contains:
Chris@82 3573 `cat $lockfile 2>/dev/null`
Chris@82 3574
Chris@82 3575 but it should contain:
Chris@82 3576 $srcfile
Chris@82 3577
Chris@82 3578 This indicates that another process is trying to use the same
Chris@82 3579 temporary object file, and libtool could not work around it because
Chris@82 3580 your compiler does not support '-c' and '-o' together. If you
Chris@82 3581 repeat this compilation, it may succeed, by chance, but you had better
Chris@82 3582 avoid parallel builds (make -j) in this platform, or get a better
Chris@82 3583 compiler."
Chris@82 3584
Chris@82 3585 $opt_dry_run || $RM $removelist
Chris@82 3586 exit $EXIT_FAILURE
Chris@82 3587 fi
Chris@82 3588
Chris@82 3589 # Just move the object if needed
Chris@82 3590 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
Chris@82 3591 func_show_eval '$MV "$output_obj" "$obj"' \
Chris@82 3592 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
Chris@82 3593 fi
Chris@82 3594 fi
Chris@82 3595
Chris@82 3596 $opt_dry_run || {
Chris@82 3597 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
Chris@82 3598
Chris@82 3599 # Unlock the critical section if it was locked
Chris@82 3600 if test no != "$need_locks"; then
Chris@82 3601 removelist=$lockfile
Chris@82 3602 $RM "$lockfile"
Chris@82 3603 fi
Chris@82 3604 }
Chris@82 3605
Chris@82 3606 exit $EXIT_SUCCESS
Chris@82 3607 }
Chris@82 3608
Chris@82 3609 $opt_help || {
Chris@82 3610 test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
Chris@82 3611 }
Chris@82 3612
Chris@82 3613 func_mode_help ()
Chris@82 3614 {
Chris@82 3615 # We need to display help for each of the modes.
Chris@82 3616 case $opt_mode in
Chris@82 3617 "")
Chris@82 3618 # Generic help is extracted from the usage comments
Chris@82 3619 # at the start of this file.
Chris@82 3620 func_help
Chris@82 3621 ;;
Chris@82 3622
Chris@82 3623 clean)
Chris@82 3624 $ECHO \
Chris@82 3625 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
Chris@82 3626
Chris@82 3627 Remove files from the build directory.
Chris@82 3628
Chris@82 3629 RM is the name of the program to use to delete files associated with each FILE
Chris@82 3630 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
Chris@82 3631 to RM.
Chris@82 3632
Chris@82 3633 If FILE is a libtool library, object or program, all the files associated
Chris@82 3634 with it are deleted. Otherwise, only FILE itself is deleted using RM."
Chris@82 3635 ;;
Chris@82 3636
Chris@82 3637 compile)
Chris@82 3638 $ECHO \
Chris@82 3639 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
Chris@82 3640
Chris@82 3641 Compile a source file into a libtool library object.
Chris@82 3642
Chris@82 3643 This mode accepts the following additional options:
Chris@82 3644
Chris@82 3645 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
Chris@82 3646 -no-suppress do not suppress compiler output for multiple passes
Chris@82 3647 -prefer-pic try to build PIC objects only
Chris@82 3648 -prefer-non-pic try to build non-PIC objects only
Chris@82 3649 -shared do not build a '.o' file suitable for static linking
Chris@82 3650 -static only build a '.o' file suitable for static linking
Chris@82 3651 -Wc,FLAG pass FLAG directly to the compiler
Chris@82 3652
Chris@82 3653 COMPILE-COMMAND is a command to be used in creating a 'standard' object file
Chris@82 3654 from the given SOURCEFILE.
Chris@82 3655
Chris@82 3656 The output file name is determined by removing the directory component from
Chris@82 3657 SOURCEFILE, then substituting the C source code suffix '.c' with the
Chris@82 3658 library object suffix, '.lo'."
Chris@82 3659 ;;
Chris@82 3660
Chris@82 3661 execute)
Chris@82 3662 $ECHO \
Chris@82 3663 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
Chris@82 3664
Chris@82 3665 Automatically set library path, then run a program.
Chris@82 3666
Chris@82 3667 This mode accepts the following additional options:
Chris@82 3668
Chris@82 3669 -dlopen FILE add the directory containing FILE to the library path
Chris@82 3670
Chris@82 3671 This mode sets the library path environment variable according to '-dlopen'
Chris@82 3672 flags.
Chris@82 3673
Chris@82 3674 If any of the ARGS are libtool executable wrappers, then they are translated
Chris@82 3675 into their corresponding uninstalled binary, and any of their required library
Chris@82 3676 directories are added to the library path.
Chris@82 3677
Chris@82 3678 Then, COMMAND is executed, with ARGS as arguments."
Chris@82 3679 ;;
Chris@82 3680
Chris@82 3681 finish)
Chris@82 3682 $ECHO \
Chris@82 3683 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
Chris@82 3684
Chris@82 3685 Complete the installation of libtool libraries.
Chris@82 3686
Chris@82 3687 Each LIBDIR is a directory that contains libtool libraries.
Chris@82 3688
Chris@82 3689 The commands that this mode executes may require superuser privileges. Use
Chris@82 3690 the '--dry-run' option if you just want to see what would be executed."
Chris@82 3691 ;;
Chris@82 3692
Chris@82 3693 install)
Chris@82 3694 $ECHO \
Chris@82 3695 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
Chris@82 3696
Chris@82 3697 Install executables or libraries.
Chris@82 3698
Chris@82 3699 INSTALL-COMMAND is the installation command. The first component should be
Chris@82 3700 either the 'install' or 'cp' program.
Chris@82 3701
Chris@82 3702 The following components of INSTALL-COMMAND are treated specially:
Chris@82 3703
Chris@82 3704 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
Chris@82 3705
Chris@82 3706 The rest of the components are interpreted as arguments to that command (only
Chris@82 3707 BSD-compatible install options are recognized)."
Chris@82 3708 ;;
Chris@82 3709
Chris@82 3710 link)
Chris@82 3711 $ECHO \
Chris@82 3712 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
Chris@82 3713
Chris@82 3714 Link object files or libraries together to form another library, or to
Chris@82 3715 create an executable program.
Chris@82 3716
Chris@82 3717 LINK-COMMAND is a command using the C compiler that you would use to create
Chris@82 3718 a program from several object files.
Chris@82 3719
Chris@82 3720 The following components of LINK-COMMAND are treated specially:
Chris@82 3721
Chris@82 3722 -all-static do not do any dynamic linking at all
Chris@82 3723 -avoid-version do not add a version suffix if possible
Chris@82 3724 -bindir BINDIR specify path to binaries directory (for systems where
Chris@82 3725 libraries must be found in the PATH setting at runtime)
Chris@82 3726 -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
Chris@82 3727 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
Chris@82 3728 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
Chris@82 3729 -export-symbols SYMFILE
Chris@82 3730 try to export only the symbols listed in SYMFILE
Chris@82 3731 -export-symbols-regex REGEX
Chris@82 3732 try to export only the symbols matching REGEX
Chris@82 3733 -LLIBDIR search LIBDIR for required installed libraries
Chris@82 3734 -lNAME OUTPUT-FILE requires the installed library libNAME
Chris@82 3735 -module build a library that can dlopened
Chris@82 3736 -no-fast-install disable the fast-install mode
Chris@82 3737 -no-install link a not-installable executable
Chris@82 3738 -no-undefined declare that a library does not refer to external symbols
Chris@82 3739 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
Chris@82 3740 -objectlist FILE use a list of object files found in FILE to specify objects
Chris@82 3741 -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
Chris@82 3742 -precious-files-regex REGEX
Chris@82 3743 don't remove output files matching REGEX
Chris@82 3744 -release RELEASE specify package release information
Chris@82 3745 -rpath LIBDIR the created library will eventually be installed in LIBDIR
Chris@82 3746 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
Chris@82 3747 -shared only do dynamic linking of libtool libraries
Chris@82 3748 -shrext SUFFIX override the standard shared library file extension
Chris@82 3749 -static do not do any dynamic linking of uninstalled libtool libraries
Chris@82 3750 -static-libtool-libs
Chris@82 3751 do not do any dynamic linking of libtool libraries
Chris@82 3752 -version-info CURRENT[:REVISION[:AGE]]
Chris@82 3753 specify library version info [each variable defaults to 0]
Chris@82 3754 -weak LIBNAME declare that the target provides the LIBNAME interface
Chris@82 3755 -Wc,FLAG
Chris@82 3756 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
Chris@82 3757 -Wl,FLAG
Chris@82 3758 -Xlinker FLAG pass linker-specific FLAG directly to the linker
Chris@82 3759 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
Chris@82 3760
Chris@82 3761 All other options (arguments beginning with '-') are ignored.
Chris@82 3762
Chris@82 3763 Every other argument is treated as a filename. Files ending in '.la' are
Chris@82 3764 treated as uninstalled libtool libraries, other files are standard or library
Chris@82 3765 object files.
Chris@82 3766
Chris@82 3767 If the OUTPUT-FILE ends in '.la', then a libtool library is created,
Chris@82 3768 only library objects ('.lo' files) may be specified, and '-rpath' is
Chris@82 3769 required, except when creating a convenience library.
Chris@82 3770
Chris@82 3771 If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
Chris@82 3772 using 'ar' and 'ranlib', or on Windows using 'lib'.
Chris@82 3773
Chris@82 3774 If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
Chris@82 3775 is created, otherwise an executable program is created."
Chris@82 3776 ;;
Chris@82 3777
Chris@82 3778 uninstall)
Chris@82 3779 $ECHO \
Chris@82 3780 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
Chris@82 3781
Chris@82 3782 Remove libraries from an installation directory.
Chris@82 3783
Chris@82 3784 RM is the name of the program to use to delete files associated with each FILE
Chris@82 3785 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
Chris@82 3786 to RM.
Chris@82 3787
Chris@82 3788 If FILE is a libtool library, all the files associated with it are deleted.
Chris@82 3789 Otherwise, only FILE itself is deleted using RM."
Chris@82 3790 ;;
Chris@82 3791
Chris@82 3792 *)
Chris@82 3793 func_fatal_help "invalid operation mode '$opt_mode'"
Chris@82 3794 ;;
Chris@82 3795 esac
Chris@82 3796
Chris@82 3797 echo
Chris@82 3798 $ECHO "Try '$progname --help' for more information about other modes."
Chris@82 3799 }
Chris@82 3800
Chris@82 3801 # Now that we've collected a possible --mode arg, show help if necessary
Chris@82 3802 if $opt_help; then
Chris@82 3803 if test : = "$opt_help"; then
Chris@82 3804 func_mode_help
Chris@82 3805 else
Chris@82 3806 {
Chris@82 3807 func_help noexit
Chris@82 3808 for opt_mode in compile link execute install finish uninstall clean; do
Chris@82 3809 func_mode_help
Chris@82 3810 done
Chris@82 3811 } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
Chris@82 3812 {
Chris@82 3813 func_help noexit
Chris@82 3814 for opt_mode in compile link execute install finish uninstall clean; do
Chris@82 3815 echo
Chris@82 3816 func_mode_help
Chris@82 3817 done
Chris@82 3818 } |
Chris@82 3819 $SED '1d
Chris@82 3820 /^When reporting/,/^Report/{
Chris@82 3821 H
Chris@82 3822 d
Chris@82 3823 }
Chris@82 3824 $x
Chris@82 3825 /information about other modes/d
Chris@82 3826 /more detailed .*MODE/d
Chris@82 3827 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
Chris@82 3828 fi
Chris@82 3829 exit $?
Chris@82 3830 fi
Chris@82 3831
Chris@82 3832
Chris@82 3833 # func_mode_execute arg...
Chris@82 3834 func_mode_execute ()
Chris@82 3835 {
Chris@82 3836 $debug_cmd
Chris@82 3837
Chris@82 3838 # The first argument is the command name.
Chris@82 3839 cmd=$nonopt
Chris@82 3840 test -z "$cmd" && \
Chris@82 3841 func_fatal_help "you must specify a COMMAND"
Chris@82 3842
Chris@82 3843 # Handle -dlopen flags immediately.
Chris@82 3844 for file in $opt_dlopen; do
Chris@82 3845 test -f "$file" \
Chris@82 3846 || func_fatal_help "'$file' is not a file"
Chris@82 3847
Chris@82 3848 dir=
Chris@82 3849 case $file in
Chris@82 3850 *.la)
Chris@82 3851 func_resolve_sysroot "$file"
Chris@82 3852 file=$func_resolve_sysroot_result
Chris@82 3853
Chris@82 3854 # Check to see that this really is a libtool archive.
Chris@82 3855 func_lalib_unsafe_p "$file" \
Chris@82 3856 || func_fatal_help "'$lib' is not a valid libtool archive"
Chris@82 3857
Chris@82 3858 # Read the libtool library.
Chris@82 3859 dlname=
Chris@82 3860 library_names=
Chris@82 3861 func_source "$file"
Chris@82 3862
Chris@82 3863 # Skip this library if it cannot be dlopened.
Chris@82 3864 if test -z "$dlname"; then
Chris@82 3865 # Warn if it was a shared library.
Chris@82 3866 test -n "$library_names" && \
Chris@82 3867 func_warning "'$file' was not linked with '-export-dynamic'"
Chris@82 3868 continue
Chris@82 3869 fi
Chris@82 3870
Chris@82 3871 func_dirname "$file" "" "."
Chris@82 3872 dir=$func_dirname_result
Chris@82 3873
Chris@82 3874 if test -f "$dir/$objdir/$dlname"; then
Chris@82 3875 func_append dir "/$objdir"
Chris@82 3876 else
Chris@82 3877 if test ! -f "$dir/$dlname"; then
Chris@82 3878 func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
Chris@82 3879 fi
Chris@82 3880 fi
Chris@82 3881 ;;
Chris@82 3882
Chris@82 3883 *.lo)
Chris@82 3884 # Just add the directory containing the .lo file.
Chris@82 3885 func_dirname "$file" "" "."
Chris@82 3886 dir=$func_dirname_result
Chris@82 3887 ;;
Chris@82 3888
Chris@82 3889 *)
Chris@82 3890 func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
Chris@82 3891 continue
Chris@82 3892 ;;
Chris@82 3893 esac
Chris@82 3894
Chris@82 3895 # Get the absolute pathname.
Chris@82 3896 absdir=`cd "$dir" && pwd`
Chris@82 3897 test -n "$absdir" && dir=$absdir
Chris@82 3898
Chris@82 3899 # Now add the directory to shlibpath_var.
Chris@82 3900 if eval "test -z \"\$$shlibpath_var\""; then
Chris@82 3901 eval "$shlibpath_var=\"\$dir\""
Chris@82 3902 else
Chris@82 3903 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
Chris@82 3904 fi
Chris@82 3905 done
Chris@82 3906
Chris@82 3907 # This variable tells wrapper scripts just to set shlibpath_var
Chris@82 3908 # rather than running their programs.
Chris@82 3909 libtool_execute_magic=$magic
Chris@82 3910
Chris@82 3911 # Check if any of the arguments is a wrapper script.
Chris@82 3912 args=
Chris@82 3913 for file
Chris@82 3914 do
Chris@82 3915 case $file in
Chris@82 3916 -* | *.la | *.lo ) ;;
Chris@82 3917 *)
Chris@82 3918 # Do a test to see if this is really a libtool program.
Chris@82 3919 if func_ltwrapper_script_p "$file"; then
Chris@82 3920 func_source "$file"
Chris@82 3921 # Transform arg to wrapped name.
Chris@82 3922 file=$progdir/$program
Chris@82 3923 elif func_ltwrapper_executable_p "$file"; then
Chris@82 3924 func_ltwrapper_scriptname "$file"
Chris@82 3925 func_source "$func_ltwrapper_scriptname_result"
Chris@82 3926 # Transform arg to wrapped name.
Chris@82 3927 file=$progdir/$program
Chris@82 3928 fi
Chris@82 3929 ;;
Chris@82 3930 esac
Chris@82 3931 # Quote arguments (to preserve shell metacharacters).
Chris@82 3932 func_append_quoted args "$file"
Chris@82 3933 done
Chris@82 3934
Chris@82 3935 if $opt_dry_run; then
Chris@82 3936 # Display what would be done.
Chris@82 3937 if test -n "$shlibpath_var"; then
Chris@82 3938 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
Chris@82 3939 echo "export $shlibpath_var"
Chris@82 3940 fi
Chris@82 3941 $ECHO "$cmd$args"
Chris@82 3942 exit $EXIT_SUCCESS
Chris@82 3943 else
Chris@82 3944 if test -n "$shlibpath_var"; then
Chris@82 3945 # Export the shlibpath_var.
Chris@82 3946 eval "export $shlibpath_var"
Chris@82 3947 fi
Chris@82 3948
Chris@82 3949 # Restore saved environment variables
Chris@82 3950 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
Chris@82 3951 do
Chris@82 3952 eval "if test \"\${save_$lt_var+set}\" = set; then
Chris@82 3953 $lt_var=\$save_$lt_var; export $lt_var
Chris@82 3954 else
Chris@82 3955 $lt_unset $lt_var
Chris@82 3956 fi"
Chris@82 3957 done
Chris@82 3958
Chris@82 3959 # Now prepare to actually exec the command.
Chris@82 3960 exec_cmd=\$cmd$args
Chris@82 3961 fi
Chris@82 3962 }
Chris@82 3963
Chris@82 3964 test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
Chris@82 3965
Chris@82 3966
Chris@82 3967 # func_mode_finish arg...
Chris@82 3968 func_mode_finish ()
Chris@82 3969 {
Chris@82 3970 $debug_cmd
Chris@82 3971
Chris@82 3972 libs=
Chris@82 3973 libdirs=
Chris@82 3974 admincmds=
Chris@82 3975
Chris@82 3976 for opt in "$nonopt" ${1+"$@"}
Chris@82 3977 do
Chris@82 3978 if test -d "$opt"; then
Chris@82 3979 func_append libdirs " $opt"
Chris@82 3980
Chris@82 3981 elif test -f "$opt"; then
Chris@82 3982 if func_lalib_unsafe_p "$opt"; then
Chris@82 3983 func_append libs " $opt"
Chris@82 3984 else
Chris@82 3985 func_warning "'$opt' is not a valid libtool archive"
Chris@82 3986 fi
Chris@82 3987
Chris@82 3988 else
Chris@82 3989 func_fatal_error "invalid argument '$opt'"
Chris@82 3990 fi
Chris@82 3991 done
Chris@82 3992
Chris@82 3993 if test -n "$libs"; then
Chris@82 3994 if test -n "$lt_sysroot"; then
Chris@82 3995 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
Chris@82 3996 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
Chris@82 3997 else
Chris@82 3998 sysroot_cmd=
Chris@82 3999 fi
Chris@82 4000
Chris@82 4001 # Remove sysroot references
Chris@82 4002 if $opt_dry_run; then
Chris@82 4003 for lib in $libs; do
Chris@82 4004 echo "removing references to $lt_sysroot and '=' prefixes from $lib"
Chris@82 4005 done
Chris@82 4006 else
Chris@82 4007 tmpdir=`func_mktempdir`
Chris@82 4008 for lib in $libs; do
Chris@82 4009 $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
Chris@82 4010 > $tmpdir/tmp-la
Chris@82 4011 mv -f $tmpdir/tmp-la $lib
Chris@82 4012 done
Chris@82 4013 ${RM}r "$tmpdir"
Chris@82 4014 fi
Chris@82 4015 fi
Chris@82 4016
Chris@82 4017 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
Chris@82 4018 for libdir in $libdirs; do
Chris@82 4019 if test -n "$finish_cmds"; then
Chris@82 4020 # Do each command in the finish commands.
Chris@82 4021 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
Chris@82 4022 '"$cmd"'"'
Chris@82 4023 fi
Chris@82 4024 if test -n "$finish_eval"; then
Chris@82 4025 # Do the single finish_eval.
Chris@82 4026 eval cmds=\"$finish_eval\"
Chris@82 4027 $opt_dry_run || eval "$cmds" || func_append admincmds "
Chris@82 4028 $cmds"
Chris@82 4029 fi
Chris@82 4030 done
Chris@82 4031 fi
Chris@82 4032
Chris@82 4033 # Exit here if they wanted silent mode.
Chris@82 4034 $opt_quiet && exit $EXIT_SUCCESS
Chris@82 4035
Chris@82 4036 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
Chris@82 4037 echo "----------------------------------------------------------------------"
Chris@82 4038 echo "Libraries have been installed in:"
Chris@82 4039 for libdir in $libdirs; do
Chris@82 4040 $ECHO " $libdir"
Chris@82 4041 done
Chris@82 4042 echo
Chris@82 4043 echo "If you ever happen to want to link against installed libraries"
Chris@82 4044 echo "in a given directory, LIBDIR, you must either use libtool, and"
Chris@82 4045 echo "specify the full pathname of the library, or use the '-LLIBDIR'"
Chris@82 4046 echo "flag during linking and do at least one of the following:"
Chris@82 4047 if test -n "$shlibpath_var"; then
Chris@82 4048 echo " - add LIBDIR to the '$shlibpath_var' environment variable"
Chris@82 4049 echo " during execution"
Chris@82 4050 fi
Chris@82 4051 if test -n "$runpath_var"; then
Chris@82 4052 echo " - add LIBDIR to the '$runpath_var' environment variable"
Chris@82 4053 echo " during linking"
Chris@82 4054 fi
Chris@82 4055 if test -n "$hardcode_libdir_flag_spec"; then
Chris@82 4056 libdir=LIBDIR
Chris@82 4057 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@82 4058
Chris@82 4059 $ECHO " - use the '$flag' linker flag"
Chris@82 4060 fi
Chris@82 4061 if test -n "$admincmds"; then
Chris@82 4062 $ECHO " - have your system administrator run these commands:$admincmds"
Chris@82 4063 fi
Chris@82 4064 if test -f /etc/ld.so.conf; then
Chris@82 4065 echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
Chris@82 4066 fi
Chris@82 4067 echo
Chris@82 4068
Chris@82 4069 echo "See any operating system documentation about shared libraries for"
Chris@82 4070 case $host in
Chris@82 4071 solaris2.[6789]|solaris2.1[0-9])
Chris@82 4072 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
Chris@82 4073 echo "pages."
Chris@82 4074 ;;
Chris@82 4075 *)
Chris@82 4076 echo "more information, such as the ld(1) and ld.so(8) manual pages."
Chris@82 4077 ;;
Chris@82 4078 esac
Chris@82 4079 echo "----------------------------------------------------------------------"
Chris@82 4080 fi
Chris@82 4081 exit $EXIT_SUCCESS
Chris@82 4082 }
Chris@82 4083
Chris@82 4084 test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
Chris@82 4085
Chris@82 4086
Chris@82 4087 # func_mode_install arg...
Chris@82 4088 func_mode_install ()
Chris@82 4089 {
Chris@82 4090 $debug_cmd
Chris@82 4091
Chris@82 4092 # There may be an optional sh(1) argument at the beginning of
Chris@82 4093 # install_prog (especially on Windows NT).
Chris@82 4094 if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
Chris@82 4095 # Allow the use of GNU shtool's install command.
Chris@82 4096 case $nonopt in *shtool*) :;; *) false;; esac
Chris@82 4097 then
Chris@82 4098 # Aesthetically quote it.
Chris@82 4099 func_quote_for_eval "$nonopt"
Chris@82 4100 install_prog="$func_quote_for_eval_result "
Chris@82 4101 arg=$1
Chris@82 4102 shift
Chris@82 4103 else
Chris@82 4104 install_prog=
Chris@82 4105 arg=$nonopt
Chris@82 4106 fi
Chris@82 4107
Chris@82 4108 # The real first argument should be the name of the installation program.
Chris@82 4109 # Aesthetically quote it.
Chris@82 4110 func_quote_for_eval "$arg"
Chris@82 4111 func_append install_prog "$func_quote_for_eval_result"
Chris@82 4112 install_shared_prog=$install_prog
Chris@82 4113 case " $install_prog " in
Chris@82 4114 *[\\\ /]cp\ *) install_cp=: ;;
Chris@82 4115 *) install_cp=false ;;
Chris@82 4116 esac
Chris@82 4117
Chris@82 4118 # We need to accept at least all the BSD install flags.
Chris@82 4119 dest=
Chris@82 4120 files=
Chris@82 4121 opts=
Chris@82 4122 prev=
Chris@82 4123 install_type=
Chris@82 4124 isdir=false
Chris@82 4125 stripme=
Chris@82 4126 no_mode=:
Chris@82 4127 for arg
Chris@82 4128 do
Chris@82 4129 arg2=
Chris@82 4130 if test -n "$dest"; then
Chris@82 4131 func_append files " $dest"
Chris@82 4132 dest=$arg
Chris@82 4133 continue
Chris@82 4134 fi
Chris@82 4135
Chris@82 4136 case $arg in
Chris@82 4137 -d) isdir=: ;;
Chris@82 4138 -f)
Chris@82 4139 if $install_cp; then :; else
Chris@82 4140 prev=$arg
Chris@82 4141 fi
Chris@82 4142 ;;
Chris@82 4143 -g | -m | -o)
Chris@82 4144 prev=$arg
Chris@82 4145 ;;
Chris@82 4146 -s)
Chris@82 4147 stripme=" -s"
Chris@82 4148 continue
Chris@82 4149 ;;
Chris@82 4150 -*)
Chris@82 4151 ;;
Chris@82 4152 *)
Chris@82 4153 # If the previous option needed an argument, then skip it.
Chris@82 4154 if test -n "$prev"; then
Chris@82 4155 if test X-m = "X$prev" && test -n "$install_override_mode"; then
Chris@82 4156 arg2=$install_override_mode
Chris@82 4157 no_mode=false
Chris@82 4158 fi
Chris@82 4159 prev=
Chris@82 4160 else
Chris@82 4161 dest=$arg
Chris@82 4162 continue
Chris@82 4163 fi
Chris@82 4164 ;;
Chris@82 4165 esac
Chris@82 4166
Chris@82 4167 # Aesthetically quote the argument.
Chris@82 4168 func_quote_for_eval "$arg"
Chris@82 4169 func_append install_prog " $func_quote_for_eval_result"
Chris@82 4170 if test -n "$arg2"; then
Chris@82 4171 func_quote_for_eval "$arg2"
Chris@82 4172 fi
Chris@82 4173 func_append install_shared_prog " $func_quote_for_eval_result"
Chris@82 4174 done
Chris@82 4175
Chris@82 4176 test -z "$install_prog" && \
Chris@82 4177 func_fatal_help "you must specify an install program"
Chris@82 4178
Chris@82 4179 test -n "$prev" && \
Chris@82 4180 func_fatal_help "the '$prev' option requires an argument"
Chris@82 4181
Chris@82 4182 if test -n "$install_override_mode" && $no_mode; then
Chris@82 4183 if $install_cp; then :; else
Chris@82 4184 func_quote_for_eval "$install_override_mode"
Chris@82 4185 func_append install_shared_prog " -m $func_quote_for_eval_result"
Chris@82 4186 fi
Chris@82 4187 fi
Chris@82 4188
Chris@82 4189 if test -z "$files"; then
Chris@82 4190 if test -z "$dest"; then
Chris@82 4191 func_fatal_help "no file or destination specified"
Chris@82 4192 else
Chris@82 4193 func_fatal_help "you must specify a destination"
Chris@82 4194 fi
Chris@82 4195 fi
Chris@82 4196
Chris@82 4197 # Strip any trailing slash from the destination.
Chris@82 4198 func_stripname '' '/' "$dest"
Chris@82 4199 dest=$func_stripname_result
Chris@82 4200
Chris@82 4201 # Check to see that the destination is a directory.
Chris@82 4202 test -d "$dest" && isdir=:
Chris@82 4203 if $isdir; then
Chris@82 4204 destdir=$dest
Chris@82 4205 destname=
Chris@82 4206 else
Chris@82 4207 func_dirname_and_basename "$dest" "" "."
Chris@82 4208 destdir=$func_dirname_result
Chris@82 4209 destname=$func_basename_result
Chris@82 4210
Chris@82 4211 # Not a directory, so check to see that there is only one file specified.
Chris@82 4212 set dummy $files; shift
Chris@82 4213 test "$#" -gt 1 && \
Chris@82 4214 func_fatal_help "'$dest' is not a directory"
Chris@82 4215 fi
Chris@82 4216 case $destdir in
Chris@82 4217 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@82 4218 *)
Chris@82 4219 for file in $files; do
Chris@82 4220 case $file in
Chris@82 4221 *.lo) ;;
Chris@82 4222 *)
Chris@82 4223 func_fatal_help "'$destdir' must be an absolute directory name"
Chris@82 4224 ;;
Chris@82 4225 esac
Chris@82 4226 done
Chris@82 4227 ;;
Chris@82 4228 esac
Chris@82 4229
Chris@82 4230 # This variable tells wrapper scripts just to set variables rather
Chris@82 4231 # than running their programs.
Chris@82 4232 libtool_install_magic=$magic
Chris@82 4233
Chris@82 4234 staticlibs=
Chris@82 4235 future_libdirs=
Chris@82 4236 current_libdirs=
Chris@82 4237 for file in $files; do
Chris@82 4238
Chris@82 4239 # Do each installation.
Chris@82 4240 case $file in
Chris@82 4241 *.$libext)
Chris@82 4242 # Do the static libraries later.
Chris@82 4243 func_append staticlibs " $file"
Chris@82 4244 ;;
Chris@82 4245
Chris@82 4246 *.la)
Chris@82 4247 func_resolve_sysroot "$file"
Chris@82 4248 file=$func_resolve_sysroot_result
Chris@82 4249
Chris@82 4250 # Check to see that this really is a libtool archive.
Chris@82 4251 func_lalib_unsafe_p "$file" \
Chris@82 4252 || func_fatal_help "'$file' is not a valid libtool archive"
Chris@82 4253
Chris@82 4254 library_names=
Chris@82 4255 old_library=
Chris@82 4256 relink_command=
Chris@82 4257 func_source "$file"
Chris@82 4258
Chris@82 4259 # Add the libdir to current_libdirs if it is the destination.
Chris@82 4260 if test "X$destdir" = "X$libdir"; then
Chris@82 4261 case "$current_libdirs " in
Chris@82 4262 *" $libdir "*) ;;
Chris@82 4263 *) func_append current_libdirs " $libdir" ;;
Chris@82 4264 esac
Chris@82 4265 else
Chris@82 4266 # Note the libdir as a future libdir.
Chris@82 4267 case "$future_libdirs " in
Chris@82 4268 *" $libdir "*) ;;
Chris@82 4269 *) func_append future_libdirs " $libdir" ;;
Chris@82 4270 esac
Chris@82 4271 fi
Chris@82 4272
Chris@82 4273 func_dirname "$file" "/" ""
Chris@82 4274 dir=$func_dirname_result
Chris@82 4275 func_append dir "$objdir"
Chris@82 4276
Chris@82 4277 if test -n "$relink_command"; then
Chris@82 4278 # Determine the prefix the user has applied to our future dir.
Chris@82 4279 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
Chris@82 4280
Chris@82 4281 # Don't allow the user to place us outside of our expected
Chris@82 4282 # location b/c this prevents finding dependent libraries that
Chris@82 4283 # are installed to the same prefix.
Chris@82 4284 # At present, this check doesn't affect windows .dll's that
Chris@82 4285 # are installed into $libdir/../bin (currently, that works fine)
Chris@82 4286 # but it's something to keep an eye on.
Chris@82 4287 test "$inst_prefix_dir" = "$destdir" && \
Chris@82 4288 func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
Chris@82 4289
Chris@82 4290 if test -n "$inst_prefix_dir"; then
Chris@82 4291 # Stick the inst_prefix_dir data into the link command.
Chris@82 4292 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
Chris@82 4293 else
Chris@82 4294 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
Chris@82 4295 fi
Chris@82 4296
Chris@82 4297 func_warning "relinking '$file'"
Chris@82 4298 func_show_eval "$relink_command" \
Chris@82 4299 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
Chris@82 4300 fi
Chris@82 4301
Chris@82 4302 # See the names of the shared library.
Chris@82 4303 set dummy $library_names; shift
Chris@82 4304 if test -n "$1"; then
Chris@82 4305 realname=$1
Chris@82 4306 shift
Chris@82 4307
Chris@82 4308 srcname=$realname
Chris@82 4309 test -n "$relink_command" && srcname=${realname}T
Chris@82 4310
Chris@82 4311 # Install the shared library and build the symlinks.
Chris@82 4312 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
Chris@82 4313 'exit $?'
Chris@82 4314 tstripme=$stripme
Chris@82 4315 case $host_os in
Chris@82 4316 cygwin* | mingw* | pw32* | cegcc*)
Chris@82 4317 case $realname in
Chris@82 4318 *.dll.a)
Chris@82 4319 tstripme=
Chris@82 4320 ;;
Chris@82 4321 esac
Chris@82 4322 ;;
Chris@82 4323 os2*)
Chris@82 4324 case $realname in
Chris@82 4325 *_dll.a)
Chris@82 4326 tstripme=
Chris@82 4327 ;;
Chris@82 4328 esac
Chris@82 4329 ;;
Chris@82 4330 esac
Chris@82 4331 if test -n "$tstripme" && test -n "$striplib"; then
Chris@82 4332 func_show_eval "$striplib $destdir/$realname" 'exit $?'
Chris@82 4333 fi
Chris@82 4334
Chris@82 4335 if test "$#" -gt 0; then
Chris@82 4336 # Delete the old symlinks, and create new ones.
Chris@82 4337 # Try 'ln -sf' first, because the 'ln' binary might depend on
Chris@82 4338 # the symlink we replace! Solaris /bin/ln does not understand -f,
Chris@82 4339 # so we also need to try rm && ln -s.
Chris@82 4340 for linkname
Chris@82 4341 do
Chris@82 4342 test "$linkname" != "$realname" \
Chris@82 4343 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
Chris@82 4344 done
Chris@82 4345 fi
Chris@82 4346
Chris@82 4347 # Do each command in the postinstall commands.
Chris@82 4348 lib=$destdir/$realname
Chris@82 4349 func_execute_cmds "$postinstall_cmds" 'exit $?'
Chris@82 4350 fi
Chris@82 4351
Chris@82 4352 # Install the pseudo-library for information purposes.
Chris@82 4353 func_basename "$file"
Chris@82 4354 name=$func_basename_result
Chris@82 4355 instname=$dir/${name}i
Chris@82 4356 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
Chris@82 4357
Chris@82 4358 # Maybe install the static library, too.
Chris@82 4359 test -n "$old_library" && func_append staticlibs " $dir/$old_library"
Chris@82 4360 ;;
Chris@82 4361
Chris@82 4362 *.lo)
Chris@82 4363 # Install (i.e. copy) a libtool object.
Chris@82 4364
Chris@82 4365 # Figure out destination file name, if it wasn't already specified.
Chris@82 4366 if test -n "$destname"; then
Chris@82 4367 destfile=$destdir/$destname
Chris@82 4368 else
Chris@82 4369 func_basename "$file"
Chris@82 4370 destfile=$func_basename_result
Chris@82 4371 destfile=$destdir/$destfile
Chris@82 4372 fi
Chris@82 4373
Chris@82 4374 # Deduce the name of the destination old-style object file.
Chris@82 4375 case $destfile in
Chris@82 4376 *.lo)
Chris@82 4377 func_lo2o "$destfile"
Chris@82 4378 staticdest=$func_lo2o_result
Chris@82 4379 ;;
Chris@82 4380 *.$objext)
Chris@82 4381 staticdest=$destfile
Chris@82 4382 destfile=
Chris@82 4383 ;;
Chris@82 4384 *)
Chris@82 4385 func_fatal_help "cannot copy a libtool object to '$destfile'"
Chris@82 4386 ;;
Chris@82 4387 esac
Chris@82 4388
Chris@82 4389 # Install the libtool object if requested.
Chris@82 4390 test -n "$destfile" && \
Chris@82 4391 func_show_eval "$install_prog $file $destfile" 'exit $?'
Chris@82 4392
Chris@82 4393 # Install the old object if enabled.
Chris@82 4394 if test yes = "$build_old_libs"; then
Chris@82 4395 # Deduce the name of the old-style object file.
Chris@82 4396 func_lo2o "$file"
Chris@82 4397 staticobj=$func_lo2o_result
Chris@82 4398 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
Chris@82 4399 fi
Chris@82 4400 exit $EXIT_SUCCESS
Chris@82 4401 ;;
Chris@82 4402
Chris@82 4403 *)
Chris@82 4404 # Figure out destination file name, if it wasn't already specified.
Chris@82 4405 if test -n "$destname"; then
Chris@82 4406 destfile=$destdir/$destname
Chris@82 4407 else
Chris@82 4408 func_basename "$file"
Chris@82 4409 destfile=$func_basename_result
Chris@82 4410 destfile=$destdir/$destfile
Chris@82 4411 fi
Chris@82 4412
Chris@82 4413 # If the file is missing, and there is a .exe on the end, strip it
Chris@82 4414 # because it is most likely a libtool script we actually want to
Chris@82 4415 # install
Chris@82 4416 stripped_ext=
Chris@82 4417 case $file in
Chris@82 4418 *.exe)
Chris@82 4419 if test ! -f "$file"; then
Chris@82 4420 func_stripname '' '.exe' "$file"
Chris@82 4421 file=$func_stripname_result
Chris@82 4422 stripped_ext=.exe
Chris@82 4423 fi
Chris@82 4424 ;;
Chris@82 4425 esac
Chris@82 4426
Chris@82 4427 # Do a test to see if this is really a libtool program.
Chris@82 4428 case $host in
Chris@82 4429 *cygwin* | *mingw*)
Chris@82 4430 if func_ltwrapper_executable_p "$file"; then
Chris@82 4431 func_ltwrapper_scriptname "$file"
Chris@82 4432 wrapper=$func_ltwrapper_scriptname_result
Chris@82 4433 else
Chris@82 4434 func_stripname '' '.exe' "$file"
Chris@82 4435 wrapper=$func_stripname_result
Chris@82 4436 fi
Chris@82 4437 ;;
Chris@82 4438 *)
Chris@82 4439 wrapper=$file
Chris@82 4440 ;;
Chris@82 4441 esac
Chris@82 4442 if func_ltwrapper_script_p "$wrapper"; then
Chris@82 4443 notinst_deplibs=
Chris@82 4444 relink_command=
Chris@82 4445
Chris@82 4446 func_source "$wrapper"
Chris@82 4447
Chris@82 4448 # Check the variables that should have been set.
Chris@82 4449 test -z "$generated_by_libtool_version" && \
Chris@82 4450 func_fatal_error "invalid libtool wrapper script '$wrapper'"
Chris@82 4451
Chris@82 4452 finalize=:
Chris@82 4453 for lib in $notinst_deplibs; do
Chris@82 4454 # Check to see that each library is installed.
Chris@82 4455 libdir=
Chris@82 4456 if test -f "$lib"; then
Chris@82 4457 func_source "$lib"
Chris@82 4458 fi
Chris@82 4459 libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
Chris@82 4460 if test -n "$libdir" && test ! -f "$libfile"; then
Chris@82 4461 func_warning "'$lib' has not been installed in '$libdir'"
Chris@82 4462 finalize=false
Chris@82 4463 fi
Chris@82 4464 done
Chris@82 4465
Chris@82 4466 relink_command=
Chris@82 4467 func_source "$wrapper"
Chris@82 4468
Chris@82 4469 outputname=
Chris@82 4470 if test no = "$fast_install" && test -n "$relink_command"; then
Chris@82 4471 $opt_dry_run || {
Chris@82 4472 if $finalize; then
Chris@82 4473 tmpdir=`func_mktempdir`
Chris@82 4474 func_basename "$file$stripped_ext"
Chris@82 4475 file=$func_basename_result
Chris@82 4476 outputname=$tmpdir/$file
Chris@82 4477 # Replace the output file specification.
Chris@82 4478 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
Chris@82 4479
Chris@82 4480 $opt_quiet || {
Chris@82 4481 func_quote_for_expand "$relink_command"
Chris@82 4482 eval "func_echo $func_quote_for_expand_result"
Chris@82 4483 }
Chris@82 4484 if eval "$relink_command"; then :
Chris@82 4485 else
Chris@82 4486 func_error "error: relink '$file' with the above command before installing it"
Chris@82 4487 $opt_dry_run || ${RM}r "$tmpdir"
Chris@82 4488 continue
Chris@82 4489 fi
Chris@82 4490 file=$outputname
Chris@82 4491 else
Chris@82 4492 func_warning "cannot relink '$file'"
Chris@82 4493 fi
Chris@82 4494 }
Chris@82 4495 else
Chris@82 4496 # Install the binary that we compiled earlier.
Chris@82 4497 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
Chris@82 4498 fi
Chris@82 4499 fi
Chris@82 4500
Chris@82 4501 # remove .exe since cygwin /usr/bin/install will append another
Chris@82 4502 # one anyway
Chris@82 4503 case $install_prog,$host in
Chris@82 4504 */usr/bin/install*,*cygwin*)
Chris@82 4505 case $file:$destfile in
Chris@82 4506 *.exe:*.exe)
Chris@82 4507 # this is ok
Chris@82 4508 ;;
Chris@82 4509 *.exe:*)
Chris@82 4510 destfile=$destfile.exe
Chris@82 4511 ;;
Chris@82 4512 *:*.exe)
Chris@82 4513 func_stripname '' '.exe' "$destfile"
Chris@82 4514 destfile=$func_stripname_result
Chris@82 4515 ;;
Chris@82 4516 esac
Chris@82 4517 ;;
Chris@82 4518 esac
Chris@82 4519 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
Chris@82 4520 $opt_dry_run || if test -n "$outputname"; then
Chris@82 4521 ${RM}r "$tmpdir"
Chris@82 4522 fi
Chris@82 4523 ;;
Chris@82 4524 esac
Chris@82 4525 done
Chris@82 4526
Chris@82 4527 for file in $staticlibs; do
Chris@82 4528 func_basename "$file"
Chris@82 4529 name=$func_basename_result
Chris@82 4530
Chris@82 4531 # Set up the ranlib parameters.
Chris@82 4532 oldlib=$destdir/$name
Chris@82 4533 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
Chris@82 4534 tool_oldlib=$func_to_tool_file_result
Chris@82 4535
Chris@82 4536 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
Chris@82 4537
Chris@82 4538 if test -n "$stripme" && test -n "$old_striplib"; then
Chris@82 4539 func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
Chris@82 4540 fi
Chris@82 4541
Chris@82 4542 # Do each command in the postinstall commands.
Chris@82 4543 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
Chris@82 4544 done
Chris@82 4545
Chris@82 4546 test -n "$future_libdirs" && \
Chris@82 4547 func_warning "remember to run '$progname --finish$future_libdirs'"
Chris@82 4548
Chris@82 4549 if test -n "$current_libdirs"; then
Chris@82 4550 # Maybe just do a dry run.
Chris@82 4551 $opt_dry_run && current_libdirs=" -n$current_libdirs"
Chris@82 4552 exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
Chris@82 4553 else
Chris@82 4554 exit $EXIT_SUCCESS
Chris@82 4555 fi
Chris@82 4556 }
Chris@82 4557
Chris@82 4558 test install = "$opt_mode" && func_mode_install ${1+"$@"}
Chris@82 4559
Chris@82 4560
Chris@82 4561 # func_generate_dlsyms outputname originator pic_p
Chris@82 4562 # Extract symbols from dlprefiles and create ${outputname}S.o with
Chris@82 4563 # a dlpreopen symbol table.
Chris@82 4564 func_generate_dlsyms ()
Chris@82 4565 {
Chris@82 4566 $debug_cmd
Chris@82 4567
Chris@82 4568 my_outputname=$1
Chris@82 4569 my_originator=$2
Chris@82 4570 my_pic_p=${3-false}
Chris@82 4571 my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
Chris@82 4572 my_dlsyms=
Chris@82 4573
Chris@82 4574 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
Chris@82 4575 if test -n "$NM" && test -n "$global_symbol_pipe"; then
Chris@82 4576 my_dlsyms=${my_outputname}S.c
Chris@82 4577 else
Chris@82 4578 func_error "not configured to extract global symbols from dlpreopened files"
Chris@82 4579 fi
Chris@82 4580 fi
Chris@82 4581
Chris@82 4582 if test -n "$my_dlsyms"; then
Chris@82 4583 case $my_dlsyms in
Chris@82 4584 "") ;;
Chris@82 4585 *.c)
Chris@82 4586 # Discover the nlist of each of the dlfiles.
Chris@82 4587 nlist=$output_objdir/$my_outputname.nm
Chris@82 4588
Chris@82 4589 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
Chris@82 4590
Chris@82 4591 # Parse the name list into a source file.
Chris@82 4592 func_verbose "creating $output_objdir/$my_dlsyms"
Chris@82 4593
Chris@82 4594 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
Chris@82 4595 /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
Chris@82 4596 /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
Chris@82 4597
Chris@82 4598 #ifdef __cplusplus
Chris@82 4599 extern \"C\" {
Chris@82 4600 #endif
Chris@82 4601
Chris@82 4602 #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
Chris@82 4603 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
Chris@82 4604 #endif
Chris@82 4605
Chris@82 4606 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
Chris@82 4607 #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
Chris@82 4608 /* DATA imports from DLLs on WIN32 can't be const, because runtime
Chris@82 4609 relocations are performed -- see ld's documentation on pseudo-relocs. */
Chris@82 4610 # define LT_DLSYM_CONST
Chris@82 4611 #elif defined __osf__
Chris@82 4612 /* This system does not cope well with relocations in const data. */
Chris@82 4613 # define LT_DLSYM_CONST
Chris@82 4614 #else
Chris@82 4615 # define LT_DLSYM_CONST const
Chris@82 4616 #endif
Chris@82 4617
Chris@82 4618 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
Chris@82 4619
Chris@82 4620 /* External symbol declarations for the compiler. */\
Chris@82 4621 "
Chris@82 4622
Chris@82 4623 if test yes = "$dlself"; then
Chris@82 4624 func_verbose "generating symbol list for '$output'"
Chris@82 4625
Chris@82 4626 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
Chris@82 4627
Chris@82 4628 # Add our own program objects to the symbol list.
Chris@82 4629 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@82 4630 for progfile in $progfiles; do
Chris@82 4631 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
Chris@82 4632 func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
Chris@82 4633 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
Chris@82 4634 done
Chris@82 4635
Chris@82 4636 if test -n "$exclude_expsyms"; then
Chris@82 4637 $opt_dry_run || {
Chris@82 4638 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
Chris@82 4639 eval '$MV "$nlist"T "$nlist"'
Chris@82 4640 }
Chris@82 4641 fi
Chris@82 4642
Chris@82 4643 if test -n "$export_symbols_regex"; then
Chris@82 4644 $opt_dry_run || {
Chris@82 4645 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
Chris@82 4646 eval '$MV "$nlist"T "$nlist"'
Chris@82 4647 }
Chris@82 4648 fi
Chris@82 4649
Chris@82 4650 # Prepare the list of exported symbols
Chris@82 4651 if test -z "$export_symbols"; then
Chris@82 4652 export_symbols=$output_objdir/$outputname.exp
Chris@82 4653 $opt_dry_run || {
Chris@82 4654 $RM $export_symbols
Chris@82 4655 eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
Chris@82 4656 case $host in
Chris@82 4657 *cygwin* | *mingw* | *cegcc* )
Chris@82 4658 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
Chris@82 4659 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
Chris@82 4660 ;;
Chris@82 4661 esac
Chris@82 4662 }
Chris@82 4663 else
Chris@82 4664 $opt_dry_run || {
Chris@82 4665 eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
Chris@82 4666 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
Chris@82 4667 eval '$MV "$nlist"T "$nlist"'
Chris@82 4668 case $host in
Chris@82 4669 *cygwin* | *mingw* | *cegcc* )
Chris@82 4670 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
Chris@82 4671 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
Chris@82 4672 ;;
Chris@82 4673 esac
Chris@82 4674 }
Chris@82 4675 fi
Chris@82 4676 fi
Chris@82 4677
Chris@82 4678 for dlprefile in $dlprefiles; do
Chris@82 4679 func_verbose "extracting global C symbols from '$dlprefile'"
Chris@82 4680 func_basename "$dlprefile"
Chris@82 4681 name=$func_basename_result
Chris@82 4682 case $host in
Chris@82 4683 *cygwin* | *mingw* | *cegcc* )
Chris@82 4684 # if an import library, we need to obtain dlname
Chris@82 4685 if func_win32_import_lib_p "$dlprefile"; then
Chris@82 4686 func_tr_sh "$dlprefile"
Chris@82 4687 eval "curr_lafile=\$libfile_$func_tr_sh_result"
Chris@82 4688 dlprefile_dlbasename=
Chris@82 4689 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
Chris@82 4690 # Use subshell, to avoid clobbering current variable values
Chris@82 4691 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
Chris@82 4692 if test -n "$dlprefile_dlname"; then
Chris@82 4693 func_basename "$dlprefile_dlname"
Chris@82 4694 dlprefile_dlbasename=$func_basename_result
Chris@82 4695 else
Chris@82 4696 # no lafile. user explicitly requested -dlpreopen <import library>.
Chris@82 4697 $sharedlib_from_linklib_cmd "$dlprefile"
Chris@82 4698 dlprefile_dlbasename=$sharedlib_from_linklib_result
Chris@82 4699 fi
Chris@82 4700 fi
Chris@82 4701 $opt_dry_run || {
Chris@82 4702 if test -n "$dlprefile_dlbasename"; then
Chris@82 4703 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
Chris@82 4704 else
Chris@82 4705 func_warning "Could not compute DLL name from $name"
Chris@82 4706 eval '$ECHO ": $name " >> "$nlist"'
Chris@82 4707 fi
Chris@82 4708 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
Chris@82 4709 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
Chris@82 4710 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
Chris@82 4711 }
Chris@82 4712 else # not an import lib
Chris@82 4713 $opt_dry_run || {
Chris@82 4714 eval '$ECHO ": $name " >> "$nlist"'
Chris@82 4715 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
Chris@82 4716 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
Chris@82 4717 }
Chris@82 4718 fi
Chris@82 4719 ;;
Chris@82 4720 *)
Chris@82 4721 $opt_dry_run || {
Chris@82 4722 eval '$ECHO ": $name " >> "$nlist"'
Chris@82 4723 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
Chris@82 4724 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
Chris@82 4725 }
Chris@82 4726 ;;
Chris@82 4727 esac
Chris@82 4728 done
Chris@82 4729
Chris@82 4730 $opt_dry_run || {
Chris@82 4731 # Make sure we have at least an empty file.
Chris@82 4732 test -f "$nlist" || : > "$nlist"
Chris@82 4733
Chris@82 4734 if test -n "$exclude_expsyms"; then
Chris@82 4735 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
Chris@82 4736 $MV "$nlist"T "$nlist"
Chris@82 4737 fi
Chris@82 4738
Chris@82 4739 # Try sorting and uniquifying the output.
Chris@82 4740 if $GREP -v "^: " < "$nlist" |
Chris@82 4741 if sort -k 3 </dev/null >/dev/null 2>&1; then
Chris@82 4742 sort -k 3
Chris@82 4743 else
Chris@82 4744 sort +2
Chris@82 4745 fi |
Chris@82 4746 uniq > "$nlist"S; then
Chris@82 4747 :
Chris@82 4748 else
Chris@82 4749 $GREP -v "^: " < "$nlist" > "$nlist"S
Chris@82 4750 fi
Chris@82 4751
Chris@82 4752 if test -f "$nlist"S; then
Chris@82 4753 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
Chris@82 4754 else
Chris@82 4755 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
Chris@82 4756 fi
Chris@82 4757
Chris@82 4758 func_show_eval '$RM "${nlist}I"'
Chris@82 4759 if test -n "$global_symbol_to_import"; then
Chris@82 4760 eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
Chris@82 4761 fi
Chris@82 4762
Chris@82 4763 echo >> "$output_objdir/$my_dlsyms" "\
Chris@82 4764
Chris@82 4765 /* The mapping between symbol names and symbols. */
Chris@82 4766 typedef struct {
Chris@82 4767 const char *name;
Chris@82 4768 void *address;
Chris@82 4769 } lt_dlsymlist;
Chris@82 4770 extern LT_DLSYM_CONST lt_dlsymlist
Chris@82 4771 lt_${my_prefix}_LTX_preloaded_symbols[];\
Chris@82 4772 "
Chris@82 4773
Chris@82 4774 if test -s "$nlist"I; then
Chris@82 4775 echo >> "$output_objdir/$my_dlsyms" "\
Chris@82 4776 static void lt_syminit(void)
Chris@82 4777 {
Chris@82 4778 LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
Chris@82 4779 for (; symbol->name; ++symbol)
Chris@82 4780 {"
Chris@82 4781 $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
Chris@82 4782 echo >> "$output_objdir/$my_dlsyms" "\
Chris@82 4783 }
Chris@82 4784 }"
Chris@82 4785 fi
Chris@82 4786 echo >> "$output_objdir/$my_dlsyms" "\
Chris@82 4787 LT_DLSYM_CONST lt_dlsymlist
Chris@82 4788 lt_${my_prefix}_LTX_preloaded_symbols[] =
Chris@82 4789 { {\"$my_originator\", (void *) 0},"
Chris@82 4790
Chris@82 4791 if test -s "$nlist"I; then
Chris@82 4792 echo >> "$output_objdir/$my_dlsyms" "\
Chris@82 4793 {\"@INIT@\", (void *) &lt_syminit},"
Chris@82 4794 fi
Chris@82 4795
Chris@82 4796 case $need_lib_prefix in
Chris@82 4797 no)
Chris@82 4798 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
Chris@82 4799 ;;
Chris@82 4800 *)
Chris@82 4801 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
Chris@82 4802 ;;
Chris@82 4803 esac
Chris@82 4804 echo >> "$output_objdir/$my_dlsyms" "\
Chris@82 4805 {0, (void *) 0}
Chris@82 4806 };
Chris@82 4807
Chris@82 4808 /* This works around a problem in FreeBSD linker */
Chris@82 4809 #ifdef FREEBSD_WORKAROUND
Chris@82 4810 static const void *lt_preloaded_setup() {
Chris@82 4811 return lt_${my_prefix}_LTX_preloaded_symbols;
Chris@82 4812 }
Chris@82 4813 #endif
Chris@82 4814
Chris@82 4815 #ifdef __cplusplus
Chris@82 4816 }
Chris@82 4817 #endif\
Chris@82 4818 "
Chris@82 4819 } # !$opt_dry_run
Chris@82 4820
Chris@82 4821 pic_flag_for_symtable=
Chris@82 4822 case "$compile_command " in
Chris@82 4823 *" -static "*) ;;
Chris@82 4824 *)
Chris@82 4825 case $host in
Chris@82 4826 # compiling the symbol table file with pic_flag works around
Chris@82 4827 # a FreeBSD bug that causes programs to crash when -lm is
Chris@82 4828 # linked before any other PIC object. But we must not use
Chris@82 4829 # pic_flag when linking with -static. The problem exists in
Chris@82 4830 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
Chris@82 4831 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
Chris@82 4832 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
Chris@82 4833 *-*-hpux*)
Chris@82 4834 pic_flag_for_symtable=" $pic_flag" ;;
Chris@82 4835 *)
Chris@82 4836 $my_pic_p && pic_flag_for_symtable=" $pic_flag"
Chris@82 4837 ;;
Chris@82 4838 esac
Chris@82 4839 ;;
Chris@82 4840 esac
Chris@82 4841 symtab_cflags=
Chris@82 4842 for arg in $LTCFLAGS; do
Chris@82 4843 case $arg in
Chris@82 4844 -pie | -fpie | -fPIE) ;;
Chris@82 4845 *) func_append symtab_cflags " $arg" ;;
Chris@82 4846 esac
Chris@82 4847 done
Chris@82 4848
Chris@82 4849 # Now compile the dynamic symbol file.
Chris@82 4850 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
Chris@82 4851
Chris@82 4852 # Clean up the generated files.
Chris@82 4853 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
Chris@82 4854
Chris@82 4855 # Transform the symbol file into the correct name.
Chris@82 4856 symfileobj=$output_objdir/${my_outputname}S.$objext
Chris@82 4857 case $host in
Chris@82 4858 *cygwin* | *mingw* | *cegcc* )
Chris@82 4859 if test -f "$output_objdir/$my_outputname.def"; then
Chris@82 4860 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
Chris@82 4861 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
Chris@82 4862 else
Chris@82 4863 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@82 4864 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@82 4865 fi
Chris@82 4866 ;;
Chris@82 4867 *)
Chris@82 4868 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@82 4869 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
Chris@82 4870 ;;
Chris@82 4871 esac
Chris@82 4872 ;;
Chris@82 4873 *)
Chris@82 4874 func_fatal_error "unknown suffix for '$my_dlsyms'"
Chris@82 4875 ;;
Chris@82 4876 esac
Chris@82 4877 else
Chris@82 4878 # We keep going just in case the user didn't refer to
Chris@82 4879 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
Chris@82 4880 # really was required.
Chris@82 4881
Chris@82 4882 # Nullify the symbol file.
Chris@82 4883 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
Chris@82 4884 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
Chris@82 4885 fi
Chris@82 4886 }
Chris@82 4887
Chris@82 4888 # func_cygming_gnu_implib_p ARG
Chris@82 4889 # This predicate returns with zero status (TRUE) if
Chris@82 4890 # ARG is a GNU/binutils-style import library. Returns
Chris@82 4891 # with nonzero status (FALSE) otherwise.
Chris@82 4892 func_cygming_gnu_implib_p ()
Chris@82 4893 {
Chris@82 4894 $debug_cmd
Chris@82 4895
Chris@82 4896 func_to_tool_file "$1" func_convert_file_msys_to_w32
Chris@82 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@82 4898 test -n "$func_cygming_gnu_implib_tmp"
Chris@82 4899 }
Chris@82 4900
Chris@82 4901 # func_cygming_ms_implib_p ARG
Chris@82 4902 # This predicate returns with zero status (TRUE) if
Chris@82 4903 # ARG is an MS-style import library. Returns
Chris@82 4904 # with nonzero status (FALSE) otherwise.
Chris@82 4905 func_cygming_ms_implib_p ()
Chris@82 4906 {
Chris@82 4907 $debug_cmd
Chris@82 4908
Chris@82 4909 func_to_tool_file "$1" func_convert_file_msys_to_w32
Chris@82 4910 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
Chris@82 4911 test -n "$func_cygming_ms_implib_tmp"
Chris@82 4912 }
Chris@82 4913
Chris@82 4914 # func_win32_libid arg
Chris@82 4915 # return the library type of file 'arg'
Chris@82 4916 #
Chris@82 4917 # Need a lot of goo to handle *both* DLLs and import libs
Chris@82 4918 # Has to be a shell function in order to 'eat' the argument
Chris@82 4919 # that is supplied when $file_magic_command is called.
Chris@82 4920 # Despite the name, also deal with 64 bit binaries.
Chris@82 4921 func_win32_libid ()
Chris@82 4922 {
Chris@82 4923 $debug_cmd
Chris@82 4924
Chris@82 4925 win32_libid_type=unknown
Chris@82 4926 win32_fileres=`file -L $1 2>/dev/null`
Chris@82 4927 case $win32_fileres in
Chris@82 4928 *ar\ archive\ import\ library*) # definitely import
Chris@82 4929 win32_libid_type="x86 archive import"
Chris@82 4930 ;;
Chris@82 4931 *ar\ archive*) # could be an import, or static
Chris@82 4932 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
Chris@82 4933 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
Chris@82 4934 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
Chris@82 4935 case $nm_interface in
Chris@82 4936 "MS dumpbin")
Chris@82 4937 if func_cygming_ms_implib_p "$1" ||
Chris@82 4938 func_cygming_gnu_implib_p "$1"
Chris@82 4939 then
Chris@82 4940 win32_nmres=import
Chris@82 4941 else
Chris@82 4942 win32_nmres=
Chris@82 4943 fi
Chris@82 4944 ;;
Chris@82 4945 *)
Chris@82 4946 func_to_tool_file "$1" func_convert_file_msys_to_w32
Chris@82 4947 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
Chris@82 4948 $SED -n -e '
Chris@82 4949 1,100{
Chris@82 4950 / I /{
Chris@82 4951 s|.*|import|
Chris@82 4952 p
Chris@82 4953 q
Chris@82 4954 }
Chris@82 4955 }'`
Chris@82 4956 ;;
Chris@82 4957 esac
Chris@82 4958 case $win32_nmres in
Chris@82 4959 import*) win32_libid_type="x86 archive import";;
Chris@82 4960 *) win32_libid_type="x86 archive static";;
Chris@82 4961 esac
Chris@82 4962 fi
Chris@82 4963 ;;
Chris@82 4964 *DLL*)
Chris@82 4965 win32_libid_type="x86 DLL"
Chris@82 4966 ;;
Chris@82 4967 *executable*) # but shell scripts are "executable" too...
Chris@82 4968 case $win32_fileres in
Chris@82 4969 *MS\ Windows\ PE\ Intel*)
Chris@82 4970 win32_libid_type="x86 DLL"
Chris@82 4971 ;;
Chris@82 4972 esac
Chris@82 4973 ;;
Chris@82 4974 esac
Chris@82 4975 $ECHO "$win32_libid_type"
Chris@82 4976 }
Chris@82 4977
Chris@82 4978 # func_cygming_dll_for_implib ARG
Chris@82 4979 #
Chris@82 4980 # Platform-specific function to extract the
Chris@82 4981 # name of the DLL associated with the specified
Chris@82 4982 # import library ARG.
Chris@82 4983 # Invoked by eval'ing the libtool variable
Chris@82 4984 # $sharedlib_from_linklib_cmd
Chris@82 4985 # Result is available in the variable
Chris@82 4986 # $sharedlib_from_linklib_result
Chris@82 4987 func_cygming_dll_for_implib ()
Chris@82 4988 {
Chris@82 4989 $debug_cmd
Chris@82 4990
Chris@82 4991 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
Chris@82 4992 }
Chris@82 4993
Chris@82 4994 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
Chris@82 4995 #
Chris@82 4996 # The is the core of a fallback implementation of a
Chris@82 4997 # platform-specific function to extract the name of the
Chris@82 4998 # DLL associated with the specified import library LIBNAME.
Chris@82 4999 #
Chris@82 5000 # SECTION_NAME is either .idata$6 or .idata$7, depending
Chris@82 5001 # on the platform and compiler that created the implib.
Chris@82 5002 #
Chris@82 5003 # Echos the name of the DLL associated with the
Chris@82 5004 # specified import library.
Chris@82 5005 func_cygming_dll_for_implib_fallback_core ()
Chris@82 5006 {
Chris@82 5007 $debug_cmd
Chris@82 5008
Chris@82 5009 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
Chris@82 5010 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
Chris@82 5011 $SED '/^Contents of section '"$match_literal"':/{
Chris@82 5012 # Place marker at beginning of archive member dllname section
Chris@82 5013 s/.*/====MARK====/
Chris@82 5014 p
Chris@82 5015 d
Chris@82 5016 }
Chris@82 5017 # These lines can sometimes be longer than 43 characters, but
Chris@82 5018 # are always uninteresting
Chris@82 5019 /:[ ]*file format pe[i]\{,1\}-/d
Chris@82 5020 /^In archive [^:]*:/d
Chris@82 5021 # Ensure marker is printed
Chris@82 5022 /^====MARK====/p
Chris@82 5023 # Remove all lines with less than 43 characters
Chris@82 5024 /^.\{43\}/!d
Chris@82 5025 # From remaining lines, remove first 43 characters
Chris@82 5026 s/^.\{43\}//' |
Chris@82 5027 $SED -n '
Chris@82 5028 # Join marker and all lines until next marker into a single line
Chris@82 5029 /^====MARK====/ b para
Chris@82 5030 H
Chris@82 5031 $ b para
Chris@82 5032 b
Chris@82 5033 :para
Chris@82 5034 x
Chris@82 5035 s/\n//g
Chris@82 5036 # Remove the marker
Chris@82 5037 s/^====MARK====//
Chris@82 5038 # Remove trailing dots and whitespace
Chris@82 5039 s/[\. \t]*$//
Chris@82 5040 # Print
Chris@82 5041 /./p' |
Chris@82 5042 # we now have a list, one entry per line, of the stringified
Chris@82 5043 # contents of the appropriate section of all members of the
Chris@82 5044 # archive that possess that section. Heuristic: eliminate
Chris@82 5045 # all those that have a first or second character that is
Chris@82 5046 # a '.' (that is, objdump's representation of an unprintable
Chris@82 5047 # character.) This should work for all archives with less than
Chris@82 5048 # 0x302f exports -- but will fail for DLLs whose name actually
Chris@82 5049 # begins with a literal '.' or a single character followed by
Chris@82 5050 # a '.'.
Chris@82 5051 #
Chris@82 5052 # Of those that remain, print the first one.
Chris@82 5053 $SED -e '/^\./d;/^.\./d;q'
Chris@82 5054 }
Chris@82 5055
Chris@82 5056 # func_cygming_dll_for_implib_fallback ARG
Chris@82 5057 # Platform-specific function to extract the
Chris@82 5058 # name of the DLL associated with the specified
Chris@82 5059 # import library ARG.
Chris@82 5060 #
Chris@82 5061 # This fallback implementation is for use when $DLLTOOL
Chris@82 5062 # does not support the --identify-strict option.
Chris@82 5063 # Invoked by eval'ing the libtool variable
Chris@82 5064 # $sharedlib_from_linklib_cmd
Chris@82 5065 # Result is available in the variable
Chris@82 5066 # $sharedlib_from_linklib_result
Chris@82 5067 func_cygming_dll_for_implib_fallback ()
Chris@82 5068 {
Chris@82 5069 $debug_cmd
Chris@82 5070
Chris@82 5071 if func_cygming_gnu_implib_p "$1"; then
Chris@82 5072 # binutils import library
Chris@82 5073 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
Chris@82 5074 elif func_cygming_ms_implib_p "$1"; then
Chris@82 5075 # ms-generated import library
Chris@82 5076 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
Chris@82 5077 else
Chris@82 5078 # unknown
Chris@82 5079 sharedlib_from_linklib_result=
Chris@82 5080 fi
Chris@82 5081 }
Chris@82 5082
Chris@82 5083
Chris@82 5084 # func_extract_an_archive dir oldlib
Chris@82 5085 func_extract_an_archive ()
Chris@82 5086 {
Chris@82 5087 $debug_cmd
Chris@82 5088
Chris@82 5089 f_ex_an_ar_dir=$1; shift
Chris@82 5090 f_ex_an_ar_oldlib=$1
Chris@82 5091 if test yes = "$lock_old_archive_extraction"; then
Chris@82 5092 lockfile=$f_ex_an_ar_oldlib.lock
Chris@82 5093 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
Chris@82 5094 func_echo "Waiting for $lockfile to be removed"
Chris@82 5095 sleep 2
Chris@82 5096 done
Chris@82 5097 fi
Chris@82 5098 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
Chris@82 5099 'stat=$?; rm -f "$lockfile"; exit $stat'
Chris@82 5100 if test yes = "$lock_old_archive_extraction"; then
Chris@82 5101 $opt_dry_run || rm -f "$lockfile"
Chris@82 5102 fi
Chris@82 5103 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
Chris@82 5104 :
Chris@82 5105 else
Chris@82 5106 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
Chris@82 5107 fi
Chris@82 5108 }
Chris@82 5109
Chris@82 5110
Chris@82 5111 # func_extract_archives gentop oldlib ...
Chris@82 5112 func_extract_archives ()
Chris@82 5113 {
Chris@82 5114 $debug_cmd
Chris@82 5115
Chris@82 5116 my_gentop=$1; shift
Chris@82 5117 my_oldlibs=${1+"$@"}
Chris@82 5118 my_oldobjs=
Chris@82 5119 my_xlib=
Chris@82 5120 my_xabs=
Chris@82 5121 my_xdir=
Chris@82 5122
Chris@82 5123 for my_xlib in $my_oldlibs; do
Chris@82 5124 # Extract the objects.
Chris@82 5125 case $my_xlib in
Chris@82 5126 [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
Chris@82 5127 *) my_xabs=`pwd`"/$my_xlib" ;;
Chris@82 5128 esac
Chris@82 5129 func_basename "$my_xlib"
Chris@82 5130 my_xlib=$func_basename_result
Chris@82 5131 my_xlib_u=$my_xlib
Chris@82 5132 while :; do
Chris@82 5133 case " $extracted_archives " in
Chris@82 5134 *" $my_xlib_u "*)
Chris@82 5135 func_arith $extracted_serial + 1
Chris@82 5136 extracted_serial=$func_arith_result
Chris@82 5137 my_xlib_u=lt$extracted_serial-$my_xlib ;;
Chris@82 5138 *) break ;;
Chris@82 5139 esac
Chris@82 5140 done
Chris@82 5141 extracted_archives="$extracted_archives $my_xlib_u"
Chris@82 5142 my_xdir=$my_gentop/$my_xlib_u
Chris@82 5143
Chris@82 5144 func_mkdir_p "$my_xdir"
Chris@82 5145
Chris@82 5146 case $host in
Chris@82 5147 *-darwin*)
Chris@82 5148 func_verbose "Extracting $my_xabs"
Chris@82 5149 # Do not bother doing anything if just a dry run
Chris@82 5150 $opt_dry_run || {
Chris@82 5151 darwin_orig_dir=`pwd`
Chris@82 5152 cd $my_xdir || exit $?
Chris@82 5153 darwin_archive=$my_xabs
Chris@82 5154 darwin_curdir=`pwd`
Chris@82 5155 func_basename "$darwin_archive"
Chris@82 5156 darwin_base_archive=$func_basename_result
Chris@82 5157 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
Chris@82 5158 if test -n "$darwin_arches"; then
Chris@82 5159 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
Chris@82 5160 darwin_arch=
Chris@82 5161 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
Chris@82 5162 for darwin_arch in $darwin_arches; do
Chris@82 5163 func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
Chris@82 5164 $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
Chris@82 5165 cd "unfat-$$/$darwin_base_archive-$darwin_arch"
Chris@82 5166 func_extract_an_archive "`pwd`" "$darwin_base_archive"
Chris@82 5167 cd "$darwin_curdir"
Chris@82 5168 $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
Chris@82 5169 done # $darwin_arches
Chris@82 5170 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
Chris@82 5171 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
Chris@82 5172 darwin_file=
Chris@82 5173 darwin_files=
Chris@82 5174 for darwin_file in $darwin_filelist; do
Chris@82 5175 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
Chris@82 5176 $LIPO -create -output "$darwin_file" $darwin_files
Chris@82 5177 done # $darwin_filelist
Chris@82 5178 $RM -rf unfat-$$
Chris@82 5179 cd "$darwin_orig_dir"
Chris@82 5180 else
Chris@82 5181 cd $darwin_orig_dir
Chris@82 5182 func_extract_an_archive "$my_xdir" "$my_xabs"
Chris@82 5183 fi # $darwin_arches
Chris@82 5184 } # !$opt_dry_run
Chris@82 5185 ;;
Chris@82 5186 *)
Chris@82 5187 func_extract_an_archive "$my_xdir" "$my_xabs"
Chris@82 5188 ;;
Chris@82 5189 esac
Chris@82 5190 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
Chris@82 5191 done
Chris@82 5192
Chris@82 5193 func_extract_archives_result=$my_oldobjs
Chris@82 5194 }
Chris@82 5195
Chris@82 5196
Chris@82 5197 # func_emit_wrapper [arg=no]
Chris@82 5198 #
Chris@82 5199 # Emit a libtool wrapper script on stdout.
Chris@82 5200 # Don't directly open a file because we may want to
Chris@82 5201 # incorporate the script contents within a cygwin/mingw
Chris@82 5202 # wrapper executable. Must ONLY be called from within
Chris@82 5203 # func_mode_link because it depends on a number of variables
Chris@82 5204 # set therein.
Chris@82 5205 #
Chris@82 5206 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
Chris@82 5207 # variable will take. If 'yes', then the emitted script
Chris@82 5208 # will assume that the directory where it is stored is
Chris@82 5209 # the $objdir directory. This is a cygwin/mingw-specific
Chris@82 5210 # behavior.
Chris@82 5211 func_emit_wrapper ()
Chris@82 5212 {
Chris@82 5213 func_emit_wrapper_arg1=${1-no}
Chris@82 5214
Chris@82 5215 $ECHO "\
Chris@82 5216 #! $SHELL
Chris@82 5217
Chris@82 5218 # $output - temporary wrapper script for $objdir/$outputname
Chris@82 5219 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@82 5220 #
Chris@82 5221 # The $output program cannot be directly executed until all the libtool
Chris@82 5222 # libraries that it depends on are installed.
Chris@82 5223 #
Chris@82 5224 # This wrapper script should never be moved out of the build directory.
Chris@82 5225 # If it is, it will not operate correctly.
Chris@82 5226
Chris@82 5227 # Sed substitution that helps us do robust quoting. It backslashifies
Chris@82 5228 # metacharacters that are still active within double-quoted strings.
Chris@82 5229 sed_quote_subst='$sed_quote_subst'
Chris@82 5230
Chris@82 5231 # Be Bourne compatible
Chris@82 5232 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
Chris@82 5233 emulate sh
Chris@82 5234 NULLCMD=:
Chris@82 5235 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
Chris@82 5236 # is contrary to our usage. Disable this feature.
Chris@82 5237 alias -g '\${1+\"\$@\"}'='\"\$@\"'
Chris@82 5238 setopt NO_GLOB_SUBST
Chris@82 5239 else
Chris@82 5240 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
Chris@82 5241 fi
Chris@82 5242 BIN_SH=xpg4; export BIN_SH # for Tru64
Chris@82 5243 DUALCASE=1; export DUALCASE # for MKS sh
Chris@82 5244
Chris@82 5245 # The HP-UX ksh and POSIX shell print the target directory to stdout
Chris@82 5246 # if CDPATH is set.
Chris@82 5247 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
Chris@82 5248
Chris@82 5249 relink_command=\"$relink_command\"
Chris@82 5250
Chris@82 5251 # This environment variable determines our operation mode.
Chris@82 5252 if test \"\$libtool_install_magic\" = \"$magic\"; then
Chris@82 5253 # install mode needs the following variables:
Chris@82 5254 generated_by_libtool_version='$macro_version'
Chris@82 5255 notinst_deplibs='$notinst_deplibs'
Chris@82 5256 else
Chris@82 5257 # When we are sourced in execute mode, \$file and \$ECHO are already set.
Chris@82 5258 if test \"\$libtool_execute_magic\" != \"$magic\"; then
Chris@82 5259 file=\"\$0\""
Chris@82 5260
Chris@82 5261 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
Chris@82 5262 $ECHO "\
Chris@82 5263
Chris@82 5264 # A function that is used when there is no print builtin or printf.
Chris@82 5265 func_fallback_echo ()
Chris@82 5266 {
Chris@82 5267 eval 'cat <<_LTECHO_EOF
Chris@82 5268 \$1
Chris@82 5269 _LTECHO_EOF'
Chris@82 5270 }
Chris@82 5271 ECHO=\"$qECHO\"
Chris@82 5272 fi
Chris@82 5273
Chris@82 5274 # Very basic option parsing. These options are (a) specific to
Chris@82 5275 # the libtool wrapper, (b) are identical between the wrapper
Chris@82 5276 # /script/ and the wrapper /executable/ that is used only on
Chris@82 5277 # windows platforms, and (c) all begin with the string "--lt-"
Chris@82 5278 # (application programs are unlikely to have options that match
Chris@82 5279 # this pattern).
Chris@82 5280 #
Chris@82 5281 # There are only two supported options: --lt-debug and
Chris@82 5282 # --lt-dump-script. There is, deliberately, no --lt-help.
Chris@82 5283 #
Chris@82 5284 # The first argument to this parsing function should be the
Chris@82 5285 # script's $0 value, followed by "$@".
Chris@82 5286 lt_option_debug=
Chris@82 5287 func_parse_lt_options ()
Chris@82 5288 {
Chris@82 5289 lt_script_arg0=\$0
Chris@82 5290 shift
Chris@82 5291 for lt_opt
Chris@82 5292 do
Chris@82 5293 case \"\$lt_opt\" in
Chris@82 5294 --lt-debug) lt_option_debug=1 ;;
Chris@82 5295 --lt-dump-script)
Chris@82 5296 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
Chris@82 5297 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
Chris@82 5298 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
Chris@82 5299 cat \"\$lt_dump_D/\$lt_dump_F\"
Chris@82 5300 exit 0
Chris@82 5301 ;;
Chris@82 5302 --lt-*)
Chris@82 5303 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
Chris@82 5304 exit 1
Chris@82 5305 ;;
Chris@82 5306 esac
Chris@82 5307 done
Chris@82 5308
Chris@82 5309 # Print the debug banner immediately:
Chris@82 5310 if test -n \"\$lt_option_debug\"; then
Chris@82 5311 echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
Chris@82 5312 fi
Chris@82 5313 }
Chris@82 5314
Chris@82 5315 # Used when --lt-debug. Prints its arguments to stdout
Chris@82 5316 # (redirection is the responsibility of the caller)
Chris@82 5317 func_lt_dump_args ()
Chris@82 5318 {
Chris@82 5319 lt_dump_args_N=1;
Chris@82 5320 for lt_arg
Chris@82 5321 do
Chris@82 5322 \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
Chris@82 5323 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
Chris@82 5324 done
Chris@82 5325 }
Chris@82 5326
Chris@82 5327 # Core function for launching the target application
Chris@82 5328 func_exec_program_core ()
Chris@82 5329 {
Chris@82 5330 "
Chris@82 5331 case $host in
Chris@82 5332 # Backslashes separate directories on plain windows
Chris@82 5333 *-*-mingw | *-*-os2* | *-cegcc*)
Chris@82 5334 $ECHO "\
Chris@82 5335 if test -n \"\$lt_option_debug\"; then
Chris@82 5336 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
Chris@82 5337 func_lt_dump_args \${1+\"\$@\"} 1>&2
Chris@82 5338 fi
Chris@82 5339 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
Chris@82 5340 "
Chris@82 5341 ;;
Chris@82 5342
Chris@82 5343 *)
Chris@82 5344 $ECHO "\
Chris@82 5345 if test -n \"\$lt_option_debug\"; then
Chris@82 5346 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
Chris@82 5347 func_lt_dump_args \${1+\"\$@\"} 1>&2
Chris@82 5348 fi
Chris@82 5349 exec \"\$progdir/\$program\" \${1+\"\$@\"}
Chris@82 5350 "
Chris@82 5351 ;;
Chris@82 5352 esac
Chris@82 5353 $ECHO "\
Chris@82 5354 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
Chris@82 5355 exit 1
Chris@82 5356 }
Chris@82 5357
Chris@82 5358 # A function to encapsulate launching the target application
Chris@82 5359 # Strips options in the --lt-* namespace from \$@ and
Chris@82 5360 # launches target application with the remaining arguments.
Chris@82 5361 func_exec_program ()
Chris@82 5362 {
Chris@82 5363 case \" \$* \" in
Chris@82 5364 *\\ --lt-*)
Chris@82 5365 for lt_wr_arg
Chris@82 5366 do
Chris@82 5367 case \$lt_wr_arg in
Chris@82 5368 --lt-*) ;;
Chris@82 5369 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
Chris@82 5370 esac
Chris@82 5371 shift
Chris@82 5372 done ;;
Chris@82 5373 esac
Chris@82 5374 func_exec_program_core \${1+\"\$@\"}
Chris@82 5375 }
Chris@82 5376
Chris@82 5377 # Parse options
Chris@82 5378 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
Chris@82 5379
Chris@82 5380 # Find the directory that this script lives in.
Chris@82 5381 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
Chris@82 5382 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
Chris@82 5383
Chris@82 5384 # Follow symbolic links until we get to the real thisdir.
Chris@82 5385 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
Chris@82 5386 while test -n \"\$file\"; do
Chris@82 5387 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
Chris@82 5388
Chris@82 5389 # If there was a directory component, then change thisdir.
Chris@82 5390 if test \"x\$destdir\" != \"x\$file\"; then
Chris@82 5391 case \"\$destdir\" in
Chris@82 5392 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
Chris@82 5393 *) thisdir=\"\$thisdir/\$destdir\" ;;
Chris@82 5394 esac
Chris@82 5395 fi
Chris@82 5396
Chris@82 5397 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
Chris@82 5398 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
Chris@82 5399 done
Chris@82 5400
Chris@82 5401 # Usually 'no', except on cygwin/mingw when embedded into
Chris@82 5402 # the cwrapper.
Chris@82 5403 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
Chris@82 5404 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
Chris@82 5405 # special case for '.'
Chris@82 5406 if test \"\$thisdir\" = \".\"; then
Chris@82 5407 thisdir=\`pwd\`
Chris@82 5408 fi
Chris@82 5409 # remove .libs from thisdir
Chris@82 5410 case \"\$thisdir\" in
Chris@82 5411 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
Chris@82 5412 $objdir ) thisdir=. ;;
Chris@82 5413 esac
Chris@82 5414 fi
Chris@82 5415
Chris@82 5416 # Try to get the absolute directory name.
Chris@82 5417 absdir=\`cd \"\$thisdir\" && pwd\`
Chris@82 5418 test -n \"\$absdir\" && thisdir=\"\$absdir\"
Chris@82 5419 "
Chris@82 5420
Chris@82 5421 if test yes = "$fast_install"; then
Chris@82 5422 $ECHO "\
Chris@82 5423 program=lt-'$outputname'$exeext
Chris@82 5424 progdir=\"\$thisdir/$objdir\"
Chris@82 5425
Chris@82 5426 if test ! -f \"\$progdir/\$program\" ||
Chris@82 5427 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
Chris@82 5428 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
Chris@82 5429
Chris@82 5430 file=\"\$\$-\$program\"
Chris@82 5431
Chris@82 5432 if test ! -d \"\$progdir\"; then
Chris@82 5433 $MKDIR \"\$progdir\"
Chris@82 5434 else
Chris@82 5435 $RM \"\$progdir/\$file\"
Chris@82 5436 fi"
Chris@82 5437
Chris@82 5438 $ECHO "\
Chris@82 5439
Chris@82 5440 # relink executable if necessary
Chris@82 5441 if test -n \"\$relink_command\"; then
Chris@82 5442 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
Chris@82 5443 else
Chris@82 5444 \$ECHO \"\$relink_command_output\" >&2
Chris@82 5445 $RM \"\$progdir/\$file\"
Chris@82 5446 exit 1
Chris@82 5447 fi
Chris@82 5448 fi
Chris@82 5449
Chris@82 5450 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
Chris@82 5451 { $RM \"\$progdir/\$program\";
Chris@82 5452 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
Chris@82 5453 $RM \"\$progdir/\$file\"
Chris@82 5454 fi"
Chris@82 5455 else
Chris@82 5456 $ECHO "\
Chris@82 5457 program='$outputname'
Chris@82 5458 progdir=\"\$thisdir/$objdir\"
Chris@82 5459 "
Chris@82 5460 fi
Chris@82 5461
Chris@82 5462 $ECHO "\
Chris@82 5463
Chris@82 5464 if test -f \"\$progdir/\$program\"; then"
Chris@82 5465
Chris@82 5466 # fixup the dll searchpath if we need to.
Chris@82 5467 #
Chris@82 5468 # Fix the DLL searchpath if we need to. Do this before prepending
Chris@82 5469 # to shlibpath, because on Windows, both are PATH and uninstalled
Chris@82 5470 # libraries must come first.
Chris@82 5471 if test -n "$dllsearchpath"; then
Chris@82 5472 $ECHO "\
Chris@82 5473 # Add the dll search path components to the executable PATH
Chris@82 5474 PATH=$dllsearchpath:\$PATH
Chris@82 5475 "
Chris@82 5476 fi
Chris@82 5477
Chris@82 5478 # Export our shlibpath_var if we have one.
Chris@82 5479 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
Chris@82 5480 $ECHO "\
Chris@82 5481 # Add our own library path to $shlibpath_var
Chris@82 5482 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
Chris@82 5483
Chris@82 5484 # Some systems cannot cope with colon-terminated $shlibpath_var
Chris@82 5485 # The second colon is a workaround for a bug in BeOS R4 sed
Chris@82 5486 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
Chris@82 5487
Chris@82 5488 export $shlibpath_var
Chris@82 5489 "
Chris@82 5490 fi
Chris@82 5491
Chris@82 5492 $ECHO "\
Chris@82 5493 if test \"\$libtool_execute_magic\" != \"$magic\"; then
Chris@82 5494 # Run the actual program with our arguments.
Chris@82 5495 func_exec_program \${1+\"\$@\"}
Chris@82 5496 fi
Chris@82 5497 else
Chris@82 5498 # The program doesn't exist.
Chris@82 5499 \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
Chris@82 5500 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
Chris@82 5501 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
Chris@82 5502 exit 1
Chris@82 5503 fi
Chris@82 5504 fi\
Chris@82 5505 "
Chris@82 5506 }
Chris@82 5507
Chris@82 5508
Chris@82 5509 # func_emit_cwrapperexe_src
Chris@82 5510 # emit the source code for a wrapper executable on stdout
Chris@82 5511 # Must ONLY be called from within func_mode_link because
Chris@82 5512 # it depends on a number of variable set therein.
Chris@82 5513 func_emit_cwrapperexe_src ()
Chris@82 5514 {
Chris@82 5515 cat <<EOF
Chris@82 5516
Chris@82 5517 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
Chris@82 5518 Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@82 5519
Chris@82 5520 The $output program cannot be directly executed until all the libtool
Chris@82 5521 libraries that it depends on are installed.
Chris@82 5522
Chris@82 5523 This wrapper executable should never be moved out of the build directory.
Chris@82 5524 If it is, it will not operate correctly.
Chris@82 5525 */
Chris@82 5526 EOF
Chris@82 5527 cat <<"EOF"
Chris@82 5528 #ifdef _MSC_VER
Chris@82 5529 # define _CRT_SECURE_NO_DEPRECATE 1
Chris@82 5530 #endif
Chris@82 5531 #include <stdio.h>
Chris@82 5532 #include <stdlib.h>
Chris@82 5533 #ifdef _MSC_VER
Chris@82 5534 # include <direct.h>
Chris@82 5535 # include <process.h>
Chris@82 5536 # include <io.h>
Chris@82 5537 #else
Chris@82 5538 # include <unistd.h>
Chris@82 5539 # include <stdint.h>
Chris@82 5540 # ifdef __CYGWIN__
Chris@82 5541 # include <io.h>
Chris@82 5542 # endif
Chris@82 5543 #endif
Chris@82 5544 #include <malloc.h>
Chris@82 5545 #include <stdarg.h>
Chris@82 5546 #include <assert.h>
Chris@82 5547 #include <string.h>
Chris@82 5548 #include <ctype.h>
Chris@82 5549 #include <errno.h>
Chris@82 5550 #include <fcntl.h>
Chris@82 5551 #include <sys/stat.h>
Chris@82 5552
Chris@82 5553 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
Chris@82 5554
Chris@82 5555 /* declarations of non-ANSI functions */
Chris@82 5556 #if defined __MINGW32__
Chris@82 5557 # ifdef __STRICT_ANSI__
Chris@82 5558 int _putenv (const char *);
Chris@82 5559 # endif
Chris@82 5560 #elif defined __CYGWIN__
Chris@82 5561 # ifdef __STRICT_ANSI__
Chris@82 5562 char *realpath (const char *, char *);
Chris@82 5563 int putenv (char *);
Chris@82 5564 int setenv (const char *, const char *, int);
Chris@82 5565 # endif
Chris@82 5566 /* #elif defined other_platform || defined ... */
Chris@82 5567 #endif
Chris@82 5568
Chris@82 5569 /* portability defines, excluding path handling macros */
Chris@82 5570 #if defined _MSC_VER
Chris@82 5571 # define setmode _setmode
Chris@82 5572 # define stat _stat
Chris@82 5573 # define chmod _chmod
Chris@82 5574 # define getcwd _getcwd
Chris@82 5575 # define putenv _putenv
Chris@82 5576 # define S_IXUSR _S_IEXEC
Chris@82 5577 #elif defined __MINGW32__
Chris@82 5578 # define setmode _setmode
Chris@82 5579 # define stat _stat
Chris@82 5580 # define chmod _chmod
Chris@82 5581 # define getcwd _getcwd
Chris@82 5582 # define putenv _putenv
Chris@82 5583 #elif defined __CYGWIN__
Chris@82 5584 # define HAVE_SETENV
Chris@82 5585 # define FOPEN_WB "wb"
Chris@82 5586 /* #elif defined other platforms ... */
Chris@82 5587 #endif
Chris@82 5588
Chris@82 5589 #if defined PATH_MAX
Chris@82 5590 # define LT_PATHMAX PATH_MAX
Chris@82 5591 #elif defined MAXPATHLEN
Chris@82 5592 # define LT_PATHMAX MAXPATHLEN
Chris@82 5593 #else
Chris@82 5594 # define LT_PATHMAX 1024
Chris@82 5595 #endif
Chris@82 5596
Chris@82 5597 #ifndef S_IXOTH
Chris@82 5598 # define S_IXOTH 0
Chris@82 5599 #endif
Chris@82 5600 #ifndef S_IXGRP
Chris@82 5601 # define S_IXGRP 0
Chris@82 5602 #endif
Chris@82 5603
Chris@82 5604 /* path handling portability macros */
Chris@82 5605 #ifndef DIR_SEPARATOR
Chris@82 5606 # define DIR_SEPARATOR '/'
Chris@82 5607 # define PATH_SEPARATOR ':'
Chris@82 5608 #endif
Chris@82 5609
Chris@82 5610 #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
Chris@82 5611 defined __OS2__
Chris@82 5612 # define HAVE_DOS_BASED_FILE_SYSTEM
Chris@82 5613 # define FOPEN_WB "wb"
Chris@82 5614 # ifndef DIR_SEPARATOR_2
Chris@82 5615 # define DIR_SEPARATOR_2 '\\'
Chris@82 5616 # endif
Chris@82 5617 # ifndef PATH_SEPARATOR_2
Chris@82 5618 # define PATH_SEPARATOR_2 ';'
Chris@82 5619 # endif
Chris@82 5620 #endif
Chris@82 5621
Chris@82 5622 #ifndef DIR_SEPARATOR_2
Chris@82 5623 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
Chris@82 5624 #else /* DIR_SEPARATOR_2 */
Chris@82 5625 # define IS_DIR_SEPARATOR(ch) \
Chris@82 5626 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
Chris@82 5627 #endif /* DIR_SEPARATOR_2 */
Chris@82 5628
Chris@82 5629 #ifndef PATH_SEPARATOR_2
Chris@82 5630 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
Chris@82 5631 #else /* PATH_SEPARATOR_2 */
Chris@82 5632 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
Chris@82 5633 #endif /* PATH_SEPARATOR_2 */
Chris@82 5634
Chris@82 5635 #ifndef FOPEN_WB
Chris@82 5636 # define FOPEN_WB "w"
Chris@82 5637 #endif
Chris@82 5638 #ifndef _O_BINARY
Chris@82 5639 # define _O_BINARY 0
Chris@82 5640 #endif
Chris@82 5641
Chris@82 5642 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
Chris@82 5643 #define XFREE(stale) do { \
Chris@82 5644 if (stale) { free (stale); stale = 0; } \
Chris@82 5645 } while (0)
Chris@82 5646
Chris@82 5647 #if defined LT_DEBUGWRAPPER
Chris@82 5648 static int lt_debug = 1;
Chris@82 5649 #else
Chris@82 5650 static int lt_debug = 0;
Chris@82 5651 #endif
Chris@82 5652
Chris@82 5653 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
Chris@82 5654
Chris@82 5655 void *xmalloc (size_t num);
Chris@82 5656 char *xstrdup (const char *string);
Chris@82 5657 const char *base_name (const char *name);
Chris@82 5658 char *find_executable (const char *wrapper);
Chris@82 5659 char *chase_symlinks (const char *pathspec);
Chris@82 5660 int make_executable (const char *path);
Chris@82 5661 int check_executable (const char *path);
Chris@82 5662 char *strendzap (char *str, const char *pat);
Chris@82 5663 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
Chris@82 5664 void lt_fatal (const char *file, int line, const char *message, ...);
Chris@82 5665 static const char *nonnull (const char *s);
Chris@82 5666 static const char *nonempty (const char *s);
Chris@82 5667 void lt_setenv (const char *name, const char *value);
Chris@82 5668 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
Chris@82 5669 void lt_update_exe_path (const char *name, const char *value);
Chris@82 5670 void lt_update_lib_path (const char *name, const char *value);
Chris@82 5671 char **prepare_spawn (char **argv);
Chris@82 5672 void lt_dump_script (FILE *f);
Chris@82 5673 EOF
Chris@82 5674
Chris@82 5675 cat <<EOF
Chris@82 5676 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
Chris@82 5677 # define externally_visible volatile
Chris@82 5678 #else
Chris@82 5679 # define externally_visible __attribute__((externally_visible)) volatile
Chris@82 5680 #endif
Chris@82 5681 externally_visible const char * MAGIC_EXE = "$magic_exe";
Chris@82 5682 const char * LIB_PATH_VARNAME = "$shlibpath_var";
Chris@82 5683 EOF
Chris@82 5684
Chris@82 5685 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
Chris@82 5686 func_to_host_path "$temp_rpath"
Chris@82 5687 cat <<EOF
Chris@82 5688 const char * LIB_PATH_VALUE = "$func_to_host_path_result";
Chris@82 5689 EOF
Chris@82 5690 else
Chris@82 5691 cat <<"EOF"
Chris@82 5692 const char * LIB_PATH_VALUE = "";
Chris@82 5693 EOF
Chris@82 5694 fi
Chris@82 5695
Chris@82 5696 if test -n "$dllsearchpath"; then
Chris@82 5697 func_to_host_path "$dllsearchpath:"
Chris@82 5698 cat <<EOF
Chris@82 5699 const char * EXE_PATH_VARNAME = "PATH";
Chris@82 5700 const char * EXE_PATH_VALUE = "$func_to_host_path_result";
Chris@82 5701 EOF
Chris@82 5702 else
Chris@82 5703 cat <<"EOF"
Chris@82 5704 const char * EXE_PATH_VARNAME = "";
Chris@82 5705 const char * EXE_PATH_VALUE = "";
Chris@82 5706 EOF
Chris@82 5707 fi
Chris@82 5708
Chris@82 5709 if test yes = "$fast_install"; then
Chris@82 5710 cat <<EOF
Chris@82 5711 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
Chris@82 5712 EOF
Chris@82 5713 else
Chris@82 5714 cat <<EOF
Chris@82 5715 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
Chris@82 5716 EOF
Chris@82 5717 fi
Chris@82 5718
Chris@82 5719
Chris@82 5720 cat <<"EOF"
Chris@82 5721
Chris@82 5722 #define LTWRAPPER_OPTION_PREFIX "--lt-"
Chris@82 5723
Chris@82 5724 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
Chris@82 5725 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
Chris@82 5726 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
Chris@82 5727
Chris@82 5728 int
Chris@82 5729 main (int argc, char *argv[])
Chris@82 5730 {
Chris@82 5731 char **newargz;
Chris@82 5732 int newargc;
Chris@82 5733 char *tmp_pathspec;
Chris@82 5734 char *actual_cwrapper_path;
Chris@82 5735 char *actual_cwrapper_name;
Chris@82 5736 char *target_name;
Chris@82 5737 char *lt_argv_zero;
Chris@82 5738 int rval = 127;
Chris@82 5739
Chris@82 5740 int i;
Chris@82 5741
Chris@82 5742 program_name = (char *) xstrdup (base_name (argv[0]));
Chris@82 5743 newargz = XMALLOC (char *, (size_t) argc + 1);
Chris@82 5744
Chris@82 5745 /* very simple arg parsing; don't want to rely on getopt
Chris@82 5746 * also, copy all non cwrapper options to newargz, except
Chris@82 5747 * argz[0], which is handled differently
Chris@82 5748 */
Chris@82 5749 newargc=0;
Chris@82 5750 for (i = 1; i < argc; i++)
Chris@82 5751 {
Chris@82 5752 if (STREQ (argv[i], dumpscript_opt))
Chris@82 5753 {
Chris@82 5754 EOF
Chris@82 5755 case $host in
Chris@82 5756 *mingw* | *cygwin* )
Chris@82 5757 # make stdout use "unix" line endings
Chris@82 5758 echo " setmode(1,_O_BINARY);"
Chris@82 5759 ;;
Chris@82 5760 esac
Chris@82 5761
Chris@82 5762 cat <<"EOF"
Chris@82 5763 lt_dump_script (stdout);
Chris@82 5764 return 0;
Chris@82 5765 }
Chris@82 5766 if (STREQ (argv[i], debug_opt))
Chris@82 5767 {
Chris@82 5768 lt_debug = 1;
Chris@82 5769 continue;
Chris@82 5770 }
Chris@82 5771 if (STREQ (argv[i], ltwrapper_option_prefix))
Chris@82 5772 {
Chris@82 5773 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
Chris@82 5774 namespace, but it is not one of the ones we know about and
Chris@82 5775 have already dealt with, above (inluding dump-script), then
Chris@82 5776 report an error. Otherwise, targets might begin to believe
Chris@82 5777 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
Chris@82 5778 namespace. The first time any user complains about this, we'll
Chris@82 5779 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
Chris@82 5780 or a configure.ac-settable value.
Chris@82 5781 */
Chris@82 5782 lt_fatal (__FILE__, __LINE__,
Chris@82 5783 "unrecognized %s option: '%s'",
Chris@82 5784 ltwrapper_option_prefix, argv[i]);
Chris@82 5785 }
Chris@82 5786 /* otherwise ... */
Chris@82 5787 newargz[++newargc] = xstrdup (argv[i]);
Chris@82 5788 }
Chris@82 5789 newargz[++newargc] = NULL;
Chris@82 5790
Chris@82 5791 EOF
Chris@82 5792 cat <<EOF
Chris@82 5793 /* The GNU banner must be the first non-error debug message */
Chris@82 5794 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
Chris@82 5795 EOF
Chris@82 5796 cat <<"EOF"
Chris@82 5797 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
Chris@82 5798 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
Chris@82 5799
Chris@82 5800 tmp_pathspec = find_executable (argv[0]);
Chris@82 5801 if (tmp_pathspec == NULL)
Chris@82 5802 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
Chris@82 5803 lt_debugprintf (__FILE__, __LINE__,
Chris@82 5804 "(main) found exe (before symlink chase) at: %s\n",
Chris@82 5805 tmp_pathspec);
Chris@82 5806
Chris@82 5807 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
Chris@82 5808 lt_debugprintf (__FILE__, __LINE__,
Chris@82 5809 "(main) found exe (after symlink chase) at: %s\n",
Chris@82 5810 actual_cwrapper_path);
Chris@82 5811 XFREE (tmp_pathspec);
Chris@82 5812
Chris@82 5813 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
Chris@82 5814 strendzap (actual_cwrapper_path, actual_cwrapper_name);
Chris@82 5815
Chris@82 5816 /* wrapper name transforms */
Chris@82 5817 strendzap (actual_cwrapper_name, ".exe");
Chris@82 5818 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
Chris@82 5819 XFREE (actual_cwrapper_name);
Chris@82 5820 actual_cwrapper_name = tmp_pathspec;
Chris@82 5821 tmp_pathspec = 0;
Chris@82 5822
Chris@82 5823 /* target_name transforms -- use actual target program name; might have lt- prefix */
Chris@82 5824 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
Chris@82 5825 strendzap (target_name, ".exe");
Chris@82 5826 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
Chris@82 5827 XFREE (target_name);
Chris@82 5828 target_name = tmp_pathspec;
Chris@82 5829 tmp_pathspec = 0;
Chris@82 5830
Chris@82 5831 lt_debugprintf (__FILE__, __LINE__,
Chris@82 5832 "(main) libtool target name: %s\n",
Chris@82 5833 target_name);
Chris@82 5834 EOF
Chris@82 5835
Chris@82 5836 cat <<EOF
Chris@82 5837 newargz[0] =
Chris@82 5838 XMALLOC (char, (strlen (actual_cwrapper_path) +
Chris@82 5839 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
Chris@82 5840 strcpy (newargz[0], actual_cwrapper_path);
Chris@82 5841 strcat (newargz[0], "$objdir");
Chris@82 5842 strcat (newargz[0], "/");
Chris@82 5843 EOF
Chris@82 5844
Chris@82 5845 cat <<"EOF"
Chris@82 5846 /* stop here, and copy so we don't have to do this twice */
Chris@82 5847 tmp_pathspec = xstrdup (newargz[0]);
Chris@82 5848
Chris@82 5849 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
Chris@82 5850 strcat (newargz[0], actual_cwrapper_name);
Chris@82 5851
Chris@82 5852 /* DO want the lt- prefix here if it exists, so use target_name */
Chris@82 5853 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
Chris@82 5854 XFREE (tmp_pathspec);
Chris@82 5855 tmp_pathspec = NULL;
Chris@82 5856 EOF
Chris@82 5857
Chris@82 5858 case $host_os in
Chris@82 5859 mingw*)
Chris@82 5860 cat <<"EOF"
Chris@82 5861 {
Chris@82 5862 char* p;
Chris@82 5863 while ((p = strchr (newargz[0], '\\')) != NULL)
Chris@82 5864 {
Chris@82 5865 *p = '/';
Chris@82 5866 }
Chris@82 5867 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
Chris@82 5868 {
Chris@82 5869 *p = '/';
Chris@82 5870 }
Chris@82 5871 }
Chris@82 5872 EOF
Chris@82 5873 ;;
Chris@82 5874 esac
Chris@82 5875
Chris@82 5876 cat <<"EOF"
Chris@82 5877 XFREE (target_name);
Chris@82 5878 XFREE (actual_cwrapper_path);
Chris@82 5879 XFREE (actual_cwrapper_name);
Chris@82 5880
Chris@82 5881 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
Chris@82 5882 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
Chris@82 5883 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
Chris@82 5884 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
Chris@82 5885 because on Windows, both *_VARNAMEs are PATH but uninstalled
Chris@82 5886 libraries must come first. */
Chris@82 5887 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
Chris@82 5888 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
Chris@82 5889
Chris@82 5890 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
Chris@82 5891 nonnull (lt_argv_zero));
Chris@82 5892 for (i = 0; i < newargc; i++)
Chris@82 5893 {
Chris@82 5894 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
Chris@82 5895 i, nonnull (newargz[i]));
Chris@82 5896 }
Chris@82 5897
Chris@82 5898 EOF
Chris@82 5899
Chris@82 5900 case $host_os in
Chris@82 5901 mingw*)
Chris@82 5902 cat <<"EOF"
Chris@82 5903 /* execv doesn't actually work on mingw as expected on unix */
Chris@82 5904 newargz = prepare_spawn (newargz);
Chris@82 5905 rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
Chris@82 5906 if (rval == -1)
Chris@82 5907 {
Chris@82 5908 /* failed to start process */
Chris@82 5909 lt_debugprintf (__FILE__, __LINE__,
Chris@82 5910 "(main) failed to launch target \"%s\": %s\n",
Chris@82 5911 lt_argv_zero, nonnull (strerror (errno)));
Chris@82 5912 return 127;
Chris@82 5913 }
Chris@82 5914 return rval;
Chris@82 5915 EOF
Chris@82 5916 ;;
Chris@82 5917 *)
Chris@82 5918 cat <<"EOF"
Chris@82 5919 execv (lt_argv_zero, newargz);
Chris@82 5920 return rval; /* =127, but avoids unused variable warning */
Chris@82 5921 EOF
Chris@82 5922 ;;
Chris@82 5923 esac
Chris@82 5924
Chris@82 5925 cat <<"EOF"
Chris@82 5926 }
Chris@82 5927
Chris@82 5928 void *
Chris@82 5929 xmalloc (size_t num)
Chris@82 5930 {
Chris@82 5931 void *p = (void *) malloc (num);
Chris@82 5932 if (!p)
Chris@82 5933 lt_fatal (__FILE__, __LINE__, "memory exhausted");
Chris@82 5934
Chris@82 5935 return p;
Chris@82 5936 }
Chris@82 5937
Chris@82 5938 char *
Chris@82 5939 xstrdup (const char *string)
Chris@82 5940 {
Chris@82 5941 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
Chris@82 5942 string) : NULL;
Chris@82 5943 }
Chris@82 5944
Chris@82 5945 const char *
Chris@82 5946 base_name (const char *name)
Chris@82 5947 {
Chris@82 5948 const char *base;
Chris@82 5949
Chris@82 5950 #if defined HAVE_DOS_BASED_FILE_SYSTEM
Chris@82 5951 /* Skip over the disk name in MSDOS pathnames. */
Chris@82 5952 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
Chris@82 5953 name += 2;
Chris@82 5954 #endif
Chris@82 5955
Chris@82 5956 for (base = name; *name; name++)
Chris@82 5957 if (IS_DIR_SEPARATOR (*name))
Chris@82 5958 base = name + 1;
Chris@82 5959 return base;
Chris@82 5960 }
Chris@82 5961
Chris@82 5962 int
Chris@82 5963 check_executable (const char *path)
Chris@82 5964 {
Chris@82 5965 struct stat st;
Chris@82 5966
Chris@82 5967 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
Chris@82 5968 nonempty (path));
Chris@82 5969 if ((!path) || (!*path))
Chris@82 5970 return 0;
Chris@82 5971
Chris@82 5972 if ((stat (path, &st) >= 0)
Chris@82 5973 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
Chris@82 5974 return 1;
Chris@82 5975 else
Chris@82 5976 return 0;
Chris@82 5977 }
Chris@82 5978
Chris@82 5979 int
Chris@82 5980 make_executable (const char *path)
Chris@82 5981 {
Chris@82 5982 int rval = 0;
Chris@82 5983 struct stat st;
Chris@82 5984
Chris@82 5985 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
Chris@82 5986 nonempty (path));
Chris@82 5987 if ((!path) || (!*path))
Chris@82 5988 return 0;
Chris@82 5989
Chris@82 5990 if (stat (path, &st) >= 0)
Chris@82 5991 {
Chris@82 5992 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
Chris@82 5993 }
Chris@82 5994 return rval;
Chris@82 5995 }
Chris@82 5996
Chris@82 5997 /* Searches for the full path of the wrapper. Returns
Chris@82 5998 newly allocated full path name if found, NULL otherwise
Chris@82 5999 Does not chase symlinks, even on platforms that support them.
Chris@82 6000 */
Chris@82 6001 char *
Chris@82 6002 find_executable (const char *wrapper)
Chris@82 6003 {
Chris@82 6004 int has_slash = 0;
Chris@82 6005 const char *p;
Chris@82 6006 const char *p_next;
Chris@82 6007 /* static buffer for getcwd */
Chris@82 6008 char tmp[LT_PATHMAX + 1];
Chris@82 6009 size_t tmp_len;
Chris@82 6010 char *concat_name;
Chris@82 6011
Chris@82 6012 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
Chris@82 6013 nonempty (wrapper));
Chris@82 6014
Chris@82 6015 if ((wrapper == NULL) || (*wrapper == '\0'))
Chris@82 6016 return NULL;
Chris@82 6017
Chris@82 6018 /* Absolute path? */
Chris@82 6019 #if defined HAVE_DOS_BASED_FILE_SYSTEM
Chris@82 6020 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
Chris@82 6021 {
Chris@82 6022 concat_name = xstrdup (wrapper);
Chris@82 6023 if (check_executable (concat_name))
Chris@82 6024 return concat_name;
Chris@82 6025 XFREE (concat_name);
Chris@82 6026 }
Chris@82 6027 else
Chris@82 6028 {
Chris@82 6029 #endif
Chris@82 6030 if (IS_DIR_SEPARATOR (wrapper[0]))
Chris@82 6031 {
Chris@82 6032 concat_name = xstrdup (wrapper);
Chris@82 6033 if (check_executable (concat_name))
Chris@82 6034 return concat_name;
Chris@82 6035 XFREE (concat_name);
Chris@82 6036 }
Chris@82 6037 #if defined HAVE_DOS_BASED_FILE_SYSTEM
Chris@82 6038 }
Chris@82 6039 #endif
Chris@82 6040
Chris@82 6041 for (p = wrapper; *p; p++)
Chris@82 6042 if (*p == '/')
Chris@82 6043 {
Chris@82 6044 has_slash = 1;
Chris@82 6045 break;
Chris@82 6046 }
Chris@82 6047 if (!has_slash)
Chris@82 6048 {
Chris@82 6049 /* no slashes; search PATH */
Chris@82 6050 const char *path = getenv ("PATH");
Chris@82 6051 if (path != NULL)
Chris@82 6052 {
Chris@82 6053 for (p = path; *p; p = p_next)
Chris@82 6054 {
Chris@82 6055 const char *q;
Chris@82 6056 size_t p_len;
Chris@82 6057 for (q = p; *q; q++)
Chris@82 6058 if (IS_PATH_SEPARATOR (*q))
Chris@82 6059 break;
Chris@82 6060 p_len = (size_t) (q - p);
Chris@82 6061 p_next = (*q == '\0' ? q : q + 1);
Chris@82 6062 if (p_len == 0)
Chris@82 6063 {
Chris@82 6064 /* empty path: current directory */
Chris@82 6065 if (getcwd (tmp, LT_PATHMAX) == NULL)
Chris@82 6066 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
Chris@82 6067 nonnull (strerror (errno)));
Chris@82 6068 tmp_len = strlen (tmp);
Chris@82 6069 concat_name =
Chris@82 6070 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
Chris@82 6071 memcpy (concat_name, tmp, tmp_len);
Chris@82 6072 concat_name[tmp_len] = '/';
Chris@82 6073 strcpy (concat_name + tmp_len + 1, wrapper);
Chris@82 6074 }
Chris@82 6075 else
Chris@82 6076 {
Chris@82 6077 concat_name =
Chris@82 6078 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
Chris@82 6079 memcpy (concat_name, p, p_len);
Chris@82 6080 concat_name[p_len] = '/';
Chris@82 6081 strcpy (concat_name + p_len + 1, wrapper);
Chris@82 6082 }
Chris@82 6083 if (check_executable (concat_name))
Chris@82 6084 return concat_name;
Chris@82 6085 XFREE (concat_name);
Chris@82 6086 }
Chris@82 6087 }
Chris@82 6088 /* not found in PATH; assume curdir */
Chris@82 6089 }
Chris@82 6090 /* Relative path | not found in path: prepend cwd */
Chris@82 6091 if (getcwd (tmp, LT_PATHMAX) == NULL)
Chris@82 6092 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
Chris@82 6093 nonnull (strerror (errno)));
Chris@82 6094 tmp_len = strlen (tmp);
Chris@82 6095 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
Chris@82 6096 memcpy (concat_name, tmp, tmp_len);
Chris@82 6097 concat_name[tmp_len] = '/';
Chris@82 6098 strcpy (concat_name + tmp_len + 1, wrapper);
Chris@82 6099
Chris@82 6100 if (check_executable (concat_name))
Chris@82 6101 return concat_name;
Chris@82 6102 XFREE (concat_name);
Chris@82 6103 return NULL;
Chris@82 6104 }
Chris@82 6105
Chris@82 6106 char *
Chris@82 6107 chase_symlinks (const char *pathspec)
Chris@82 6108 {
Chris@82 6109 #ifndef S_ISLNK
Chris@82 6110 return xstrdup (pathspec);
Chris@82 6111 #else
Chris@82 6112 char buf[LT_PATHMAX];
Chris@82 6113 struct stat s;
Chris@82 6114 char *tmp_pathspec = xstrdup (pathspec);
Chris@82 6115 char *p;
Chris@82 6116 int has_symlinks = 0;
Chris@82 6117 while (strlen (tmp_pathspec) && !has_symlinks)
Chris@82 6118 {
Chris@82 6119 lt_debugprintf (__FILE__, __LINE__,
Chris@82 6120 "checking path component for symlinks: %s\n",
Chris@82 6121 tmp_pathspec);
Chris@82 6122 if (lstat (tmp_pathspec, &s) == 0)
Chris@82 6123 {
Chris@82 6124 if (S_ISLNK (s.st_mode) != 0)
Chris@82 6125 {
Chris@82 6126 has_symlinks = 1;
Chris@82 6127 break;
Chris@82 6128 }
Chris@82 6129
Chris@82 6130 /* search backwards for last DIR_SEPARATOR */
Chris@82 6131 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
Chris@82 6132 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
Chris@82 6133 p--;
Chris@82 6134 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
Chris@82 6135 {
Chris@82 6136 /* no more DIR_SEPARATORS left */
Chris@82 6137 break;
Chris@82 6138 }
Chris@82 6139 *p = '\0';
Chris@82 6140 }
Chris@82 6141 else
Chris@82 6142 {
Chris@82 6143 lt_fatal (__FILE__, __LINE__,
Chris@82 6144 "error accessing file \"%s\": %s",
Chris@82 6145 tmp_pathspec, nonnull (strerror (errno)));
Chris@82 6146 }
Chris@82 6147 }
Chris@82 6148 XFREE (tmp_pathspec);
Chris@82 6149
Chris@82 6150 if (!has_symlinks)
Chris@82 6151 {
Chris@82 6152 return xstrdup (pathspec);
Chris@82 6153 }
Chris@82 6154
Chris@82 6155 tmp_pathspec = realpath (pathspec, buf);
Chris@82 6156 if (tmp_pathspec == 0)
Chris@82 6157 {
Chris@82 6158 lt_fatal (__FILE__, __LINE__,
Chris@82 6159 "could not follow symlinks for %s", pathspec);
Chris@82 6160 }
Chris@82 6161 return xstrdup (tmp_pathspec);
Chris@82 6162 #endif
Chris@82 6163 }
Chris@82 6164
Chris@82 6165 char *
Chris@82 6166 strendzap (char *str, const char *pat)
Chris@82 6167 {
Chris@82 6168 size_t len, patlen;
Chris@82 6169
Chris@82 6170 assert (str != NULL);
Chris@82 6171 assert (pat != NULL);
Chris@82 6172
Chris@82 6173 len = strlen (str);
Chris@82 6174 patlen = strlen (pat);
Chris@82 6175
Chris@82 6176 if (patlen <= len)
Chris@82 6177 {
Chris@82 6178 str += len - patlen;
Chris@82 6179 if (STREQ (str, pat))
Chris@82 6180 *str = '\0';
Chris@82 6181 }
Chris@82 6182 return str;
Chris@82 6183 }
Chris@82 6184
Chris@82 6185 void
Chris@82 6186 lt_debugprintf (const char *file, int line, const char *fmt, ...)
Chris@82 6187 {
Chris@82 6188 va_list args;
Chris@82 6189 if (lt_debug)
Chris@82 6190 {
Chris@82 6191 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
Chris@82 6192 va_start (args, fmt);
Chris@82 6193 (void) vfprintf (stderr, fmt, args);
Chris@82 6194 va_end (args);
Chris@82 6195 }
Chris@82 6196 }
Chris@82 6197
Chris@82 6198 static void
Chris@82 6199 lt_error_core (int exit_status, const char *file,
Chris@82 6200 int line, const char *mode,
Chris@82 6201 const char *message, va_list ap)
Chris@82 6202 {
Chris@82 6203 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
Chris@82 6204 vfprintf (stderr, message, ap);
Chris@82 6205 fprintf (stderr, ".\n");
Chris@82 6206
Chris@82 6207 if (exit_status >= 0)
Chris@82 6208 exit (exit_status);
Chris@82 6209 }
Chris@82 6210
Chris@82 6211 void
Chris@82 6212 lt_fatal (const char *file, int line, const char *message, ...)
Chris@82 6213 {
Chris@82 6214 va_list ap;
Chris@82 6215 va_start (ap, message);
Chris@82 6216 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
Chris@82 6217 va_end (ap);
Chris@82 6218 }
Chris@82 6219
Chris@82 6220 static const char *
Chris@82 6221 nonnull (const char *s)
Chris@82 6222 {
Chris@82 6223 return s ? s : "(null)";
Chris@82 6224 }
Chris@82 6225
Chris@82 6226 static const char *
Chris@82 6227 nonempty (const char *s)
Chris@82 6228 {
Chris@82 6229 return (s && !*s) ? "(empty)" : nonnull (s);
Chris@82 6230 }
Chris@82 6231
Chris@82 6232 void
Chris@82 6233 lt_setenv (const char *name, const char *value)
Chris@82 6234 {
Chris@82 6235 lt_debugprintf (__FILE__, __LINE__,
Chris@82 6236 "(lt_setenv) setting '%s' to '%s'\n",
Chris@82 6237 nonnull (name), nonnull (value));
Chris@82 6238 {
Chris@82 6239 #ifdef HAVE_SETENV
Chris@82 6240 /* always make a copy, for consistency with !HAVE_SETENV */
Chris@82 6241 char *str = xstrdup (value);
Chris@82 6242 setenv (name, str, 1);
Chris@82 6243 #else
Chris@82 6244 size_t len = strlen (name) + 1 + strlen (value) + 1;
Chris@82 6245 char *str = XMALLOC (char, len);
Chris@82 6246 sprintf (str, "%s=%s", name, value);
Chris@82 6247 if (putenv (str) != EXIT_SUCCESS)
Chris@82 6248 {
Chris@82 6249 XFREE (str);
Chris@82 6250 }
Chris@82 6251 #endif
Chris@82 6252 }
Chris@82 6253 }
Chris@82 6254
Chris@82 6255 char *
Chris@82 6256 lt_extend_str (const char *orig_value, const char *add, int to_end)
Chris@82 6257 {
Chris@82 6258 char *new_value;
Chris@82 6259 if (orig_value && *orig_value)
Chris@82 6260 {
Chris@82 6261 size_t orig_value_len = strlen (orig_value);
Chris@82 6262 size_t add_len = strlen (add);
Chris@82 6263 new_value = XMALLOC (char, add_len + orig_value_len + 1);
Chris@82 6264 if (to_end)
Chris@82 6265 {
Chris@82 6266 strcpy (new_value, orig_value);
Chris@82 6267 strcpy (new_value + orig_value_len, add);
Chris@82 6268 }
Chris@82 6269 else
Chris@82 6270 {
Chris@82 6271 strcpy (new_value, add);
Chris@82 6272 strcpy (new_value + add_len, orig_value);
Chris@82 6273 }
Chris@82 6274 }
Chris@82 6275 else
Chris@82 6276 {
Chris@82 6277 new_value = xstrdup (add);
Chris@82 6278 }
Chris@82 6279 return new_value;
Chris@82 6280 }
Chris@82 6281
Chris@82 6282 void
Chris@82 6283 lt_update_exe_path (const char *name, const char *value)
Chris@82 6284 {
Chris@82 6285 lt_debugprintf (__FILE__, __LINE__,
Chris@82 6286 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
Chris@82 6287 nonnull (name), nonnull (value));
Chris@82 6288
Chris@82 6289 if (name && *name && value && *value)
Chris@82 6290 {
Chris@82 6291 char *new_value = lt_extend_str (getenv (name), value, 0);
Chris@82 6292 /* some systems can't cope with a ':'-terminated path #' */
Chris@82 6293 size_t len = strlen (new_value);
Chris@82 6294 while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
Chris@82 6295 {
Chris@82 6296 new_value[--len] = '\0';
Chris@82 6297 }
Chris@82 6298 lt_setenv (name, new_value);
Chris@82 6299 XFREE (new_value);
Chris@82 6300 }
Chris@82 6301 }
Chris@82 6302
Chris@82 6303 void
Chris@82 6304 lt_update_lib_path (const char *name, const char *value)
Chris@82 6305 {
Chris@82 6306 lt_debugprintf (__FILE__, __LINE__,
Chris@82 6307 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
Chris@82 6308 nonnull (name), nonnull (value));
Chris@82 6309
Chris@82 6310 if (name && *name && value && *value)
Chris@82 6311 {
Chris@82 6312 char *new_value = lt_extend_str (getenv (name), value, 0);
Chris@82 6313 lt_setenv (name, new_value);
Chris@82 6314 XFREE (new_value);
Chris@82 6315 }
Chris@82 6316 }
Chris@82 6317
Chris@82 6318 EOF
Chris@82 6319 case $host_os in
Chris@82 6320 mingw*)
Chris@82 6321 cat <<"EOF"
Chris@82 6322
Chris@82 6323 /* Prepares an argument vector before calling spawn().
Chris@82 6324 Note that spawn() does not by itself call the command interpreter
Chris@82 6325 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
Chris@82 6326 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
Chris@82 6327 GetVersionEx(&v);
Chris@82 6328 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
Chris@82 6329 }) ? "cmd.exe" : "command.com").
Chris@82 6330 Instead it simply concatenates the arguments, separated by ' ', and calls
Chris@82 6331 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
Chris@82 6332 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
Chris@82 6333 special way:
Chris@82 6334 - Space and tab are interpreted as delimiters. They are not treated as
Chris@82 6335 delimiters if they are surrounded by double quotes: "...".
Chris@82 6336 - Unescaped double quotes are removed from the input. Their only effect is
Chris@82 6337 that within double quotes, space and tab are treated like normal
Chris@82 6338 characters.
Chris@82 6339 - Backslashes not followed by double quotes are not special.
Chris@82 6340 - But 2*n+1 backslashes followed by a double quote become
Chris@82 6341 n backslashes followed by a double quote (n >= 0):
Chris@82 6342 \" -> "
Chris@82 6343 \\\" -> \"
Chris@82 6344 \\\\\" -> \\"
Chris@82 6345 */
Chris@82 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@82 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@82 6348 char **
Chris@82 6349 prepare_spawn (char **argv)
Chris@82 6350 {
Chris@82 6351 size_t argc;
Chris@82 6352 char **new_argv;
Chris@82 6353 size_t i;
Chris@82 6354
Chris@82 6355 /* Count number of arguments. */
Chris@82 6356 for (argc = 0; argv[argc] != NULL; argc++)
Chris@82 6357 ;
Chris@82 6358
Chris@82 6359 /* Allocate new argument vector. */
Chris@82 6360 new_argv = XMALLOC (char *, argc + 1);
Chris@82 6361
Chris@82 6362 /* Put quoted arguments into the new argument vector. */
Chris@82 6363 for (i = 0; i < argc; i++)
Chris@82 6364 {
Chris@82 6365 const char *string = argv[i];
Chris@82 6366
Chris@82 6367 if (string[0] == '\0')
Chris@82 6368 new_argv[i] = xstrdup ("\"\"");
Chris@82 6369 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
Chris@82 6370 {
Chris@82 6371 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
Chris@82 6372 size_t length;
Chris@82 6373 unsigned int backslashes;
Chris@82 6374 const char *s;
Chris@82 6375 char *quoted_string;
Chris@82 6376 char *p;
Chris@82 6377
Chris@82 6378 length = 0;
Chris@82 6379 backslashes = 0;
Chris@82 6380 if (quote_around)
Chris@82 6381 length++;
Chris@82 6382 for (s = string; *s != '\0'; s++)
Chris@82 6383 {
Chris@82 6384 char c = *s;
Chris@82 6385 if (c == '"')
Chris@82 6386 length += backslashes + 1;
Chris@82 6387 length++;
Chris@82 6388 if (c == '\\')
Chris@82 6389 backslashes++;
Chris@82 6390 else
Chris@82 6391 backslashes = 0;
Chris@82 6392 }
Chris@82 6393 if (quote_around)
Chris@82 6394 length += backslashes + 1;
Chris@82 6395
Chris@82 6396 quoted_string = XMALLOC (char, length + 1);
Chris@82 6397
Chris@82 6398 p = quoted_string;
Chris@82 6399 backslashes = 0;
Chris@82 6400 if (quote_around)
Chris@82 6401 *p++ = '"';
Chris@82 6402 for (s = string; *s != '\0'; s++)
Chris@82 6403 {
Chris@82 6404 char c = *s;
Chris@82 6405 if (c == '"')
Chris@82 6406 {
Chris@82 6407 unsigned int j;
Chris@82 6408 for (j = backslashes + 1; j > 0; j--)
Chris@82 6409 *p++ = '\\';
Chris@82 6410 }
Chris@82 6411 *p++ = c;
Chris@82 6412 if (c == '\\')
Chris@82 6413 backslashes++;
Chris@82 6414 else
Chris@82 6415 backslashes = 0;
Chris@82 6416 }
Chris@82 6417 if (quote_around)
Chris@82 6418 {
Chris@82 6419 unsigned int j;
Chris@82 6420 for (j = backslashes; j > 0; j--)
Chris@82 6421 *p++ = '\\';
Chris@82 6422 *p++ = '"';
Chris@82 6423 }
Chris@82 6424 *p = '\0';
Chris@82 6425
Chris@82 6426 new_argv[i] = quoted_string;
Chris@82 6427 }
Chris@82 6428 else
Chris@82 6429 new_argv[i] = (char *) string;
Chris@82 6430 }
Chris@82 6431 new_argv[argc] = NULL;
Chris@82 6432
Chris@82 6433 return new_argv;
Chris@82 6434 }
Chris@82 6435 EOF
Chris@82 6436 ;;
Chris@82 6437 esac
Chris@82 6438
Chris@82 6439 cat <<"EOF"
Chris@82 6440 void lt_dump_script (FILE* f)
Chris@82 6441 {
Chris@82 6442 EOF
Chris@82 6443 func_emit_wrapper yes |
Chris@82 6444 $SED -n -e '
Chris@82 6445 s/^\(.\{79\}\)\(..*\)/\1\
Chris@82 6446 \2/
Chris@82 6447 h
Chris@82 6448 s/\([\\"]\)/\\\1/g
Chris@82 6449 s/$/\\n/
Chris@82 6450 s/\([^\n]*\).*/ fputs ("\1", f);/p
Chris@82 6451 g
Chris@82 6452 D'
Chris@82 6453 cat <<"EOF"
Chris@82 6454 }
Chris@82 6455 EOF
Chris@82 6456 }
Chris@82 6457 # end: func_emit_cwrapperexe_src
Chris@82 6458
Chris@82 6459 # func_win32_import_lib_p ARG
Chris@82 6460 # True if ARG is an import lib, as indicated by $file_magic_cmd
Chris@82 6461 func_win32_import_lib_p ()
Chris@82 6462 {
Chris@82 6463 $debug_cmd
Chris@82 6464
Chris@82 6465 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
Chris@82 6466 *import*) : ;;
Chris@82 6467 *) false ;;
Chris@82 6468 esac
Chris@82 6469 }
Chris@82 6470
Chris@82 6471 # func_suncc_cstd_abi
Chris@82 6472 # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
Chris@82 6473 # Several compiler flags select an ABI that is incompatible with the
Chris@82 6474 # Cstd library. Avoid specifying it if any are in CXXFLAGS.
Chris@82 6475 func_suncc_cstd_abi ()
Chris@82 6476 {
Chris@82 6477 $debug_cmd
Chris@82 6478
Chris@82 6479 case " $compile_command " in
Chris@82 6480 *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
Chris@82 6481 suncc_use_cstd_abi=no
Chris@82 6482 ;;
Chris@82 6483 *)
Chris@82 6484 suncc_use_cstd_abi=yes
Chris@82 6485 ;;
Chris@82 6486 esac
Chris@82 6487 }
Chris@82 6488
Chris@82 6489 # func_mode_link arg...
Chris@82 6490 func_mode_link ()
Chris@82 6491 {
Chris@82 6492 $debug_cmd
Chris@82 6493
Chris@82 6494 case $host in
Chris@82 6495 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
Chris@82 6496 # It is impossible to link a dll without this setting, and
Chris@82 6497 # we shouldn't force the makefile maintainer to figure out
Chris@82 6498 # what system we are compiling for in order to pass an extra
Chris@82 6499 # flag for every libtool invocation.
Chris@82 6500 # allow_undefined=no
Chris@82 6501
Chris@82 6502 # FIXME: Unfortunately, there are problems with the above when trying
Chris@82 6503 # to make a dll that has undefined symbols, in which case not
Chris@82 6504 # even a static library is built. For now, we need to specify
Chris@82 6505 # -no-undefined on the libtool link line when we can be certain
Chris@82 6506 # that all symbols are satisfied, otherwise we get a static library.
Chris@82 6507 allow_undefined=yes
Chris@82 6508 ;;
Chris@82 6509 *)
Chris@82 6510 allow_undefined=yes
Chris@82 6511 ;;
Chris@82 6512 esac
Chris@82 6513 libtool_args=$nonopt
Chris@82 6514 base_compile="$nonopt $@"
Chris@82 6515 compile_command=$nonopt
Chris@82 6516 finalize_command=$nonopt
Chris@82 6517
Chris@82 6518 compile_rpath=
Chris@82 6519 finalize_rpath=
Chris@82 6520 compile_shlibpath=
Chris@82 6521 finalize_shlibpath=
Chris@82 6522 convenience=
Chris@82 6523 old_convenience=
Chris@82 6524 deplibs=
Chris@82 6525 old_deplibs=
Chris@82 6526 compiler_flags=
Chris@82 6527 linker_flags=
Chris@82 6528 dllsearchpath=
Chris@82 6529 lib_search_path=`pwd`
Chris@82 6530 inst_prefix_dir=
Chris@82 6531 new_inherited_linker_flags=
Chris@82 6532
Chris@82 6533 avoid_version=no
Chris@82 6534 bindir=
Chris@82 6535 dlfiles=
Chris@82 6536 dlprefiles=
Chris@82 6537 dlself=no
Chris@82 6538 export_dynamic=no
Chris@82 6539 export_symbols=
Chris@82 6540 export_symbols_regex=
Chris@82 6541 generated=
Chris@82 6542 libobjs=
Chris@82 6543 ltlibs=
Chris@82 6544 module=no
Chris@82 6545 no_install=no
Chris@82 6546 objs=
Chris@82 6547 os2dllname=
Chris@82 6548 non_pic_objects=
Chris@82 6549 precious_files_regex=
Chris@82 6550 prefer_static_libs=no
Chris@82 6551 preload=false
Chris@82 6552 prev=
Chris@82 6553 prevarg=
Chris@82 6554 release=
Chris@82 6555 rpath=
Chris@82 6556 xrpath=
Chris@82 6557 perm_rpath=
Chris@82 6558 temp_rpath=
Chris@82 6559 thread_safe=no
Chris@82 6560 vinfo=
Chris@82 6561 vinfo_number=no
Chris@82 6562 weak_libs=
Chris@82 6563 single_module=$wl-single_module
Chris@82 6564 func_infer_tag $base_compile
Chris@82 6565
Chris@82 6566 # We need to know -static, to get the right output filenames.
Chris@82 6567 for arg
Chris@82 6568 do
Chris@82 6569 case $arg in
Chris@82 6570 -shared)
Chris@82 6571 test yes != "$build_libtool_libs" \
Chris@82 6572 && func_fatal_configuration "cannot build a shared library"
Chris@82 6573 build_old_libs=no
Chris@82 6574 break
Chris@82 6575 ;;
Chris@82 6576 -all-static | -static | -static-libtool-libs)
Chris@82 6577 case $arg in
Chris@82 6578 -all-static)
Chris@82 6579 if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
Chris@82 6580 func_warning "complete static linking is impossible in this configuration"
Chris@82 6581 fi
Chris@82 6582 if test -n "$link_static_flag"; then
Chris@82 6583 dlopen_self=$dlopen_self_static
Chris@82 6584 fi
Chris@82 6585 prefer_static_libs=yes
Chris@82 6586 ;;
Chris@82 6587 -static)
Chris@82 6588 if test -z "$pic_flag" && test -n "$link_static_flag"; then
Chris@82 6589 dlopen_self=$dlopen_self_static
Chris@82 6590 fi
Chris@82 6591 prefer_static_libs=built
Chris@82 6592 ;;
Chris@82 6593 -static-libtool-libs)
Chris@82 6594 if test -z "$pic_flag" && test -n "$link_static_flag"; then
Chris@82 6595 dlopen_self=$dlopen_self_static
Chris@82 6596 fi
Chris@82 6597 prefer_static_libs=yes
Chris@82 6598 ;;
Chris@82 6599 esac
Chris@82 6600 build_libtool_libs=no
Chris@82 6601 build_old_libs=yes
Chris@82 6602 break
Chris@82 6603 ;;
Chris@82 6604 esac
Chris@82 6605 done
Chris@82 6606
Chris@82 6607 # See if our shared archives depend on static archives.
Chris@82 6608 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
Chris@82 6609
Chris@82 6610 # Go through the arguments, transforming them on the way.
Chris@82 6611 while test "$#" -gt 0; do
Chris@82 6612 arg=$1
Chris@82 6613 shift
Chris@82 6614 func_quote_for_eval "$arg"
Chris@82 6615 qarg=$func_quote_for_eval_unquoted_result
Chris@82 6616 func_append libtool_args " $func_quote_for_eval_result"
Chris@82 6617
Chris@82 6618 # If the previous option needs an argument, assign it.
Chris@82 6619 if test -n "$prev"; then
Chris@82 6620 case $prev in
Chris@82 6621 output)
Chris@82 6622 func_append compile_command " @OUTPUT@"
Chris@82 6623 func_append finalize_command " @OUTPUT@"
Chris@82 6624 ;;
Chris@82 6625 esac
Chris@82 6626
Chris@82 6627 case $prev in
Chris@82 6628 bindir)
Chris@82 6629 bindir=$arg
Chris@82 6630 prev=
Chris@82 6631 continue
Chris@82 6632 ;;
Chris@82 6633 dlfiles|dlprefiles)
Chris@82 6634 $preload || {
Chris@82 6635 # Add the symbol object into the linking commands.
Chris@82 6636 func_append compile_command " @SYMFILE@"
Chris@82 6637 func_append finalize_command " @SYMFILE@"
Chris@82 6638 preload=:
Chris@82 6639 }
Chris@82 6640 case $arg in
Chris@82 6641 *.la | *.lo) ;; # We handle these cases below.
Chris@82 6642 force)
Chris@82 6643 if test no = "$dlself"; then
Chris@82 6644 dlself=needless
Chris@82 6645 export_dynamic=yes
Chris@82 6646 fi
Chris@82 6647 prev=
Chris@82 6648 continue
Chris@82 6649 ;;
Chris@82 6650 self)
Chris@82 6651 if test dlprefiles = "$prev"; then
Chris@82 6652 dlself=yes
Chris@82 6653 elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
Chris@82 6654 dlself=yes
Chris@82 6655 else
Chris@82 6656 dlself=needless
Chris@82 6657 export_dynamic=yes
Chris@82 6658 fi
Chris@82 6659 prev=
Chris@82 6660 continue
Chris@82 6661 ;;
Chris@82 6662 *)
Chris@82 6663 if test dlfiles = "$prev"; then
Chris@82 6664 func_append dlfiles " $arg"
Chris@82 6665 else
Chris@82 6666 func_append dlprefiles " $arg"
Chris@82 6667 fi
Chris@82 6668 prev=
Chris@82 6669 continue
Chris@82 6670 ;;
Chris@82 6671 esac
Chris@82 6672 ;;
Chris@82 6673 expsyms)
Chris@82 6674 export_symbols=$arg
Chris@82 6675 test -f "$arg" \
Chris@82 6676 || func_fatal_error "symbol file '$arg' does not exist"
Chris@82 6677 prev=
Chris@82 6678 continue
Chris@82 6679 ;;
Chris@82 6680 expsyms_regex)
Chris@82 6681 export_symbols_regex=$arg
Chris@82 6682 prev=
Chris@82 6683 continue
Chris@82 6684 ;;
Chris@82 6685 framework)
Chris@82 6686 case $host in
Chris@82 6687 *-*-darwin*)
Chris@82 6688 case "$deplibs " in
Chris@82 6689 *" $qarg.ltframework "*) ;;
Chris@82 6690 *) func_append deplibs " $qarg.ltframework" # this is fixed later
Chris@82 6691 ;;
Chris@82 6692 esac
Chris@82 6693 ;;
Chris@82 6694 esac
Chris@82 6695 prev=
Chris@82 6696 continue
Chris@82 6697 ;;
Chris@82 6698 inst_prefix)
Chris@82 6699 inst_prefix_dir=$arg
Chris@82 6700 prev=
Chris@82 6701 continue
Chris@82 6702 ;;
Chris@82 6703 mllvm)
Chris@82 6704 # Clang does not use LLVM to link, so we can simply discard any
Chris@82 6705 # '-mllvm $arg' options when doing the link step.
Chris@82 6706 prev=
Chris@82 6707 continue
Chris@82 6708 ;;
Chris@82 6709 objectlist)
Chris@82 6710 if test -f "$arg"; then
Chris@82 6711 save_arg=$arg
Chris@82 6712 moreargs=
Chris@82 6713 for fil in `cat "$save_arg"`
Chris@82 6714 do
Chris@82 6715 # func_append moreargs " $fil"
Chris@82 6716 arg=$fil
Chris@82 6717 # A libtool-controlled object.
Chris@82 6718
Chris@82 6719 # Check to see that this really is a libtool object.
Chris@82 6720 if func_lalib_unsafe_p "$arg"; then
Chris@82 6721 pic_object=
Chris@82 6722 non_pic_object=
Chris@82 6723
Chris@82 6724 # Read the .lo file
Chris@82 6725 func_source "$arg"
Chris@82 6726
Chris@82 6727 if test -z "$pic_object" ||
Chris@82 6728 test -z "$non_pic_object" ||
Chris@82 6729 test none = "$pic_object" &&
Chris@82 6730 test none = "$non_pic_object"; then
Chris@82 6731 func_fatal_error "cannot find name of object for '$arg'"
Chris@82 6732 fi
Chris@82 6733
Chris@82 6734 # Extract subdirectory from the argument.
Chris@82 6735 func_dirname "$arg" "/" ""
Chris@82 6736 xdir=$func_dirname_result
Chris@82 6737
Chris@82 6738 if test none != "$pic_object"; then
Chris@82 6739 # Prepend the subdirectory the object is found in.
Chris@82 6740 pic_object=$xdir$pic_object
Chris@82 6741
Chris@82 6742 if test dlfiles = "$prev"; then
Chris@82 6743 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
Chris@82 6744 func_append dlfiles " $pic_object"
Chris@82 6745 prev=
Chris@82 6746 continue
Chris@82 6747 else
Chris@82 6748 # If libtool objects are unsupported, then we need to preload.
Chris@82 6749 prev=dlprefiles
Chris@82 6750 fi
Chris@82 6751 fi
Chris@82 6752
Chris@82 6753 # CHECK ME: I think I busted this. -Ossama
Chris@82 6754 if test dlprefiles = "$prev"; then
Chris@82 6755 # Preload the old-style object.
Chris@82 6756 func_append dlprefiles " $pic_object"
Chris@82 6757 prev=
Chris@82 6758 fi
Chris@82 6759
Chris@82 6760 # A PIC object.
Chris@82 6761 func_append libobjs " $pic_object"
Chris@82 6762 arg=$pic_object
Chris@82 6763 fi
Chris@82 6764
Chris@82 6765 # Non-PIC object.
Chris@82 6766 if test none != "$non_pic_object"; then
Chris@82 6767 # Prepend the subdirectory the object is found in.
Chris@82 6768 non_pic_object=$xdir$non_pic_object
Chris@82 6769
Chris@82 6770 # A standard non-PIC object
Chris@82 6771 func_append non_pic_objects " $non_pic_object"
Chris@82 6772 if test -z "$pic_object" || test none = "$pic_object"; then
Chris@82 6773 arg=$non_pic_object
Chris@82 6774 fi
Chris@82 6775 else
Chris@82 6776 # If the PIC object exists, use it instead.
Chris@82 6777 # $xdir was prepended to $pic_object above.
Chris@82 6778 non_pic_object=$pic_object
Chris@82 6779 func_append non_pic_objects " $non_pic_object"
Chris@82 6780 fi
Chris@82 6781 else
Chris@82 6782 # Only an error if not doing a dry-run.
Chris@82 6783 if $opt_dry_run; then
Chris@82 6784 # Extract subdirectory from the argument.
Chris@82 6785 func_dirname "$arg" "/" ""
Chris@82 6786 xdir=$func_dirname_result
Chris@82 6787
Chris@82 6788 func_lo2o "$arg"
Chris@82 6789 pic_object=$xdir$objdir/$func_lo2o_result
Chris@82 6790 non_pic_object=$xdir$func_lo2o_result
Chris@82 6791 func_append libobjs " $pic_object"
Chris@82 6792 func_append non_pic_objects " $non_pic_object"
Chris@82 6793 else
Chris@82 6794 func_fatal_error "'$arg' is not a valid libtool object"
Chris@82 6795 fi
Chris@82 6796 fi
Chris@82 6797 done
Chris@82 6798 else
Chris@82 6799 func_fatal_error "link input file '$arg' does not exist"
Chris@82 6800 fi
Chris@82 6801 arg=$save_arg
Chris@82 6802 prev=
Chris@82 6803 continue
Chris@82 6804 ;;
Chris@82 6805 os2dllname)
Chris@82 6806 os2dllname=$arg
Chris@82 6807 prev=
Chris@82 6808 continue
Chris@82 6809 ;;
Chris@82 6810 precious_regex)
Chris@82 6811 precious_files_regex=$arg
Chris@82 6812 prev=
Chris@82 6813 continue
Chris@82 6814 ;;
Chris@82 6815 release)
Chris@82 6816 release=-$arg
Chris@82 6817 prev=
Chris@82 6818 continue
Chris@82 6819 ;;
Chris@82 6820 rpath | xrpath)
Chris@82 6821 # We need an absolute path.
Chris@82 6822 case $arg in
Chris@82 6823 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@82 6824 *)
Chris@82 6825 func_fatal_error "only absolute run-paths are allowed"
Chris@82 6826 ;;
Chris@82 6827 esac
Chris@82 6828 if test rpath = "$prev"; then
Chris@82 6829 case "$rpath " in
Chris@82 6830 *" $arg "*) ;;
Chris@82 6831 *) func_append rpath " $arg" ;;
Chris@82 6832 esac
Chris@82 6833 else
Chris@82 6834 case "$xrpath " in
Chris@82 6835 *" $arg "*) ;;
Chris@82 6836 *) func_append xrpath " $arg" ;;
Chris@82 6837 esac
Chris@82 6838 fi
Chris@82 6839 prev=
Chris@82 6840 continue
Chris@82 6841 ;;
Chris@82 6842 shrext)
Chris@82 6843 shrext_cmds=$arg
Chris@82 6844 prev=
Chris@82 6845 continue
Chris@82 6846 ;;
Chris@82 6847 weak)
Chris@82 6848 func_append weak_libs " $arg"
Chris@82 6849 prev=
Chris@82 6850 continue
Chris@82 6851 ;;
Chris@82 6852 xcclinker)
Chris@82 6853 func_append linker_flags " $qarg"
Chris@82 6854 func_append compiler_flags " $qarg"
Chris@82 6855 prev=
Chris@82 6856 func_append compile_command " $qarg"
Chris@82 6857 func_append finalize_command " $qarg"
Chris@82 6858 continue
Chris@82 6859 ;;
Chris@82 6860 xcompiler)
Chris@82 6861 func_append compiler_flags " $qarg"
Chris@82 6862 prev=
Chris@82 6863 func_append compile_command " $qarg"
Chris@82 6864 func_append finalize_command " $qarg"
Chris@82 6865 continue
Chris@82 6866 ;;
Chris@82 6867 xlinker)
Chris@82 6868 func_append linker_flags " $qarg"
Chris@82 6869 func_append compiler_flags " $wl$qarg"
Chris@82 6870 prev=
Chris@82 6871 func_append compile_command " $wl$qarg"
Chris@82 6872 func_append finalize_command " $wl$qarg"
Chris@82 6873 continue
Chris@82 6874 ;;
Chris@82 6875 *)
Chris@82 6876 eval "$prev=\"\$arg\""
Chris@82 6877 prev=
Chris@82 6878 continue
Chris@82 6879 ;;
Chris@82 6880 esac
Chris@82 6881 fi # test -n "$prev"
Chris@82 6882
Chris@82 6883 prevarg=$arg
Chris@82 6884
Chris@82 6885 case $arg in
Chris@82 6886 -all-static)
Chris@82 6887 if test -n "$link_static_flag"; then
Chris@82 6888 # See comment for -static flag below, for more details.
Chris@82 6889 func_append compile_command " $link_static_flag"
Chris@82 6890 func_append finalize_command " $link_static_flag"
Chris@82 6891 fi
Chris@82 6892 continue
Chris@82 6893 ;;
Chris@82 6894
Chris@82 6895 -allow-undefined)
Chris@82 6896 # FIXME: remove this flag sometime in the future.
Chris@82 6897 func_fatal_error "'-allow-undefined' must not be used because it is the default"
Chris@82 6898 ;;
Chris@82 6899
Chris@82 6900 -avoid-version)
Chris@82 6901 avoid_version=yes
Chris@82 6902 continue
Chris@82 6903 ;;
Chris@82 6904
Chris@82 6905 -bindir)
Chris@82 6906 prev=bindir
Chris@82 6907 continue
Chris@82 6908 ;;
Chris@82 6909
Chris@82 6910 -dlopen)
Chris@82 6911 prev=dlfiles
Chris@82 6912 continue
Chris@82 6913 ;;
Chris@82 6914
Chris@82 6915 -dlpreopen)
Chris@82 6916 prev=dlprefiles
Chris@82 6917 continue
Chris@82 6918 ;;
Chris@82 6919
Chris@82 6920 -export-dynamic)
Chris@82 6921 export_dynamic=yes
Chris@82 6922 continue
Chris@82 6923 ;;
Chris@82 6924
Chris@82 6925 -export-symbols | -export-symbols-regex)
Chris@82 6926 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
Chris@82 6927 func_fatal_error "more than one -exported-symbols argument is not allowed"
Chris@82 6928 fi
Chris@82 6929 if test X-export-symbols = "X$arg"; then
Chris@82 6930 prev=expsyms
Chris@82 6931 else
Chris@82 6932 prev=expsyms_regex
Chris@82 6933 fi
Chris@82 6934 continue
Chris@82 6935 ;;
Chris@82 6936
Chris@82 6937 -framework)
Chris@82 6938 prev=framework
Chris@82 6939 continue
Chris@82 6940 ;;
Chris@82 6941
Chris@82 6942 -inst-prefix-dir)
Chris@82 6943 prev=inst_prefix
Chris@82 6944 continue
Chris@82 6945 ;;
Chris@82 6946
Chris@82 6947 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
Chris@82 6948 # so, if we see these flags be careful not to treat them like -L
Chris@82 6949 -L[A-Z][A-Z]*:*)
Chris@82 6950 case $with_gcc/$host in
Chris@82 6951 no/*-*-irix* | /*-*-irix*)
Chris@82 6952 func_append compile_command " $arg"
Chris@82 6953 func_append finalize_command " $arg"
Chris@82 6954 ;;
Chris@82 6955 esac
Chris@82 6956 continue
Chris@82 6957 ;;
Chris@82 6958
Chris@82 6959 -L*)
Chris@82 6960 func_stripname "-L" '' "$arg"
Chris@82 6961 if test -z "$func_stripname_result"; then
Chris@82 6962 if test "$#" -gt 0; then
Chris@82 6963 func_fatal_error "require no space between '-L' and '$1'"
Chris@82 6964 else
Chris@82 6965 func_fatal_error "need path for '-L' option"
Chris@82 6966 fi
Chris@82 6967 fi
Chris@82 6968 func_resolve_sysroot "$func_stripname_result"
Chris@82 6969 dir=$func_resolve_sysroot_result
Chris@82 6970 # We need an absolute path.
Chris@82 6971 case $dir in
Chris@82 6972 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@82 6973 *)
Chris@82 6974 absdir=`cd "$dir" && pwd`
Chris@82 6975 test -z "$absdir" && \
Chris@82 6976 func_fatal_error "cannot determine absolute directory name of '$dir'"
Chris@82 6977 dir=$absdir
Chris@82 6978 ;;
Chris@82 6979 esac
Chris@82 6980 case "$deplibs " in
Chris@82 6981 *" -L$dir "* | *" $arg "*)
Chris@82 6982 # Will only happen for absolute or sysroot arguments
Chris@82 6983 ;;
Chris@82 6984 *)
Chris@82 6985 # Preserve sysroot, but never include relative directories
Chris@82 6986 case $dir in
Chris@82 6987 [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
Chris@82 6988 *) func_append deplibs " -L$dir" ;;
Chris@82 6989 esac
Chris@82 6990 func_append lib_search_path " $dir"
Chris@82 6991 ;;
Chris@82 6992 esac
Chris@82 6993 case $host in
Chris@82 6994 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
Chris@82 6995 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
Chris@82 6996 case :$dllsearchpath: in
Chris@82 6997 *":$dir:"*) ;;
Chris@82 6998 ::) dllsearchpath=$dir;;
Chris@82 6999 *) func_append dllsearchpath ":$dir";;
Chris@82 7000 esac
Chris@82 7001 case :$dllsearchpath: in
Chris@82 7002 *":$testbindir:"*) ;;
Chris@82 7003 ::) dllsearchpath=$testbindir;;
Chris@82 7004 *) func_append dllsearchpath ":$testbindir";;
Chris@82 7005 esac
Chris@82 7006 ;;
Chris@82 7007 esac
Chris@82 7008 continue
Chris@82 7009 ;;
Chris@82 7010
Chris@82 7011 -l*)
Chris@82 7012 if test X-lc = "X$arg" || test X-lm = "X$arg"; then
Chris@82 7013 case $host in
Chris@82 7014 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
Chris@82 7015 # These systems don't actually have a C or math library (as such)
Chris@82 7016 continue
Chris@82 7017 ;;
Chris@82 7018 *-*-os2*)
Chris@82 7019 # These systems don't actually have a C library (as such)
Chris@82 7020 test X-lc = "X$arg" && continue
Chris@82 7021 ;;
Chris@82 7022 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
Chris@82 7023 # Do not include libc due to us having libc/libc_r.
Chris@82 7024 test X-lc = "X$arg" && continue
Chris@82 7025 ;;
Chris@82 7026 *-*-rhapsody* | *-*-darwin1.[012])
Chris@82 7027 # Rhapsody C and math libraries are in the System framework
Chris@82 7028 func_append deplibs " System.ltframework"
Chris@82 7029 continue
Chris@82 7030 ;;
Chris@82 7031 *-*-sco3.2v5* | *-*-sco5v6*)
Chris@82 7032 # Causes problems with __ctype
Chris@82 7033 test X-lc = "X$arg" && continue
Chris@82 7034 ;;
Chris@82 7035 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
Chris@82 7036 # Compiler inserts libc in the correct place for threads to work
Chris@82 7037 test X-lc = "X$arg" && continue
Chris@82 7038 ;;
Chris@82 7039 esac
Chris@82 7040 elif test X-lc_r = "X$arg"; then
Chris@82 7041 case $host in
Chris@82 7042 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
Chris@82 7043 # Do not include libc_r directly, use -pthread flag.
Chris@82 7044 continue
Chris@82 7045 ;;
Chris@82 7046 esac
Chris@82 7047 fi
Chris@82 7048 func_append deplibs " $arg"
Chris@82 7049 continue
Chris@82 7050 ;;
Chris@82 7051
Chris@82 7052 -mllvm)
Chris@82 7053 prev=mllvm
Chris@82 7054 continue
Chris@82 7055 ;;
Chris@82 7056
Chris@82 7057 -module)
Chris@82 7058 module=yes
Chris@82 7059 continue
Chris@82 7060 ;;
Chris@82 7061
Chris@82 7062 # Tru64 UNIX uses -model [arg] to determine the layout of C++
Chris@82 7063 # classes, name mangling, and exception handling.
Chris@82 7064 # Darwin uses the -arch flag to determine output architecture.
Chris@82 7065 -model|-arch|-isysroot|--sysroot)
Chris@82 7066 func_append compiler_flags " $arg"
Chris@82 7067 func_append compile_command " $arg"
Chris@82 7068 func_append finalize_command " $arg"
Chris@82 7069 prev=xcompiler
Chris@82 7070 continue
Chris@82 7071 ;;
Chris@82 7072
Chris@82 7073 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
Chris@82 7074 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
Chris@82 7075 func_append compiler_flags " $arg"
Chris@82 7076 func_append compile_command " $arg"
Chris@82 7077 func_append finalize_command " $arg"
Chris@82 7078 case "$new_inherited_linker_flags " in
Chris@82 7079 *" $arg "*) ;;
Chris@82 7080 * ) func_append new_inherited_linker_flags " $arg" ;;
Chris@82 7081 esac
Chris@82 7082 continue
Chris@82 7083 ;;
Chris@82 7084
Chris@82 7085 -multi_module)
Chris@82 7086 single_module=$wl-multi_module
Chris@82 7087 continue
Chris@82 7088 ;;
Chris@82 7089
Chris@82 7090 -no-fast-install)
Chris@82 7091 fast_install=no
Chris@82 7092 continue
Chris@82 7093 ;;
Chris@82 7094
Chris@82 7095 -no-install)
Chris@82 7096 case $host in
Chris@82 7097 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
Chris@82 7098 # The PATH hackery in wrapper scripts is required on Windows
Chris@82 7099 # and Darwin in order for the loader to find any dlls it needs.
Chris@82 7100 func_warning "'-no-install' is ignored for $host"
Chris@82 7101 func_warning "assuming '-no-fast-install' instead"
Chris@82 7102 fast_install=no
Chris@82 7103 ;;
Chris@82 7104 *) no_install=yes ;;
Chris@82 7105 esac
Chris@82 7106 continue
Chris@82 7107 ;;
Chris@82 7108
Chris@82 7109 -no-undefined)
Chris@82 7110 allow_undefined=no
Chris@82 7111 continue
Chris@82 7112 ;;
Chris@82 7113
Chris@82 7114 -objectlist)
Chris@82 7115 prev=objectlist
Chris@82 7116 continue
Chris@82 7117 ;;
Chris@82 7118
Chris@82 7119 -os2dllname)
Chris@82 7120 prev=os2dllname
Chris@82 7121 continue
Chris@82 7122 ;;
Chris@82 7123
Chris@82 7124 -o) prev=output ;;
Chris@82 7125
Chris@82 7126 -precious-files-regex)
Chris@82 7127 prev=precious_regex
Chris@82 7128 continue
Chris@82 7129 ;;
Chris@82 7130
Chris@82 7131 -release)
Chris@82 7132 prev=release
Chris@82 7133 continue
Chris@82 7134 ;;
Chris@82 7135
Chris@82 7136 -rpath)
Chris@82 7137 prev=rpath
Chris@82 7138 continue
Chris@82 7139 ;;
Chris@82 7140
Chris@82 7141 -R)
Chris@82 7142 prev=xrpath
Chris@82 7143 continue
Chris@82 7144 ;;
Chris@82 7145
Chris@82 7146 -R*)
Chris@82 7147 func_stripname '-R' '' "$arg"
Chris@82 7148 dir=$func_stripname_result
Chris@82 7149 # We need an absolute path.
Chris@82 7150 case $dir in
Chris@82 7151 [\\/]* | [A-Za-z]:[\\/]*) ;;
Chris@82 7152 =*)
Chris@82 7153 func_stripname '=' '' "$dir"
Chris@82 7154 dir=$lt_sysroot$func_stripname_result
Chris@82 7155 ;;
Chris@82 7156 *)
Chris@82 7157 func_fatal_error "only absolute run-paths are allowed"
Chris@82 7158 ;;
Chris@82 7159 esac
Chris@82 7160 case "$xrpath " in
Chris@82 7161 *" $dir "*) ;;
Chris@82 7162 *) func_append xrpath " $dir" ;;
Chris@82 7163 esac
Chris@82 7164 continue
Chris@82 7165 ;;
Chris@82 7166
Chris@82 7167 -shared)
Chris@82 7168 # The effects of -shared are defined in a previous loop.
Chris@82 7169 continue
Chris@82 7170 ;;
Chris@82 7171
Chris@82 7172 -shrext)
Chris@82 7173 prev=shrext
Chris@82 7174 continue
Chris@82 7175 ;;
Chris@82 7176
Chris@82 7177 -static | -static-libtool-libs)
Chris@82 7178 # The effects of -static are defined in a previous loop.
Chris@82 7179 # We used to do the same as -all-static on platforms that
Chris@82 7180 # didn't have a PIC flag, but the assumption that the effects
Chris@82 7181 # would be equivalent was wrong. It would break on at least
Chris@82 7182 # Digital Unix and AIX.
Chris@82 7183 continue
Chris@82 7184 ;;
Chris@82 7185
Chris@82 7186 -thread-safe)
Chris@82 7187 thread_safe=yes
Chris@82 7188 continue
Chris@82 7189 ;;
Chris@82 7190
Chris@82 7191 -version-info)
Chris@82 7192 prev=vinfo
Chris@82 7193 continue
Chris@82 7194 ;;
Chris@82 7195
Chris@82 7196 -version-number)
Chris@82 7197 prev=vinfo
Chris@82 7198 vinfo_number=yes
Chris@82 7199 continue
Chris@82 7200 ;;
Chris@82 7201
Chris@82 7202 -weak)
Chris@82 7203 prev=weak
Chris@82 7204 continue
Chris@82 7205 ;;
Chris@82 7206
Chris@82 7207 -Wc,*)
Chris@82 7208 func_stripname '-Wc,' '' "$arg"
Chris@82 7209 args=$func_stripname_result
Chris@82 7210 arg=
Chris@82 7211 save_ifs=$IFS; IFS=,
Chris@82 7212 for flag in $args; do
Chris@82 7213 IFS=$save_ifs
Chris@82 7214 func_quote_for_eval "$flag"
Chris@82 7215 func_append arg " $func_quote_for_eval_result"
Chris@82 7216 func_append compiler_flags " $func_quote_for_eval_result"
Chris@82 7217 done
Chris@82 7218 IFS=$save_ifs
Chris@82 7219 func_stripname ' ' '' "$arg"
Chris@82 7220 arg=$func_stripname_result
Chris@82 7221 ;;
Chris@82 7222
Chris@82 7223 -Wl,*)
Chris@82 7224 func_stripname '-Wl,' '' "$arg"
Chris@82 7225 args=$func_stripname_result
Chris@82 7226 arg=
Chris@82 7227 save_ifs=$IFS; IFS=,
Chris@82 7228 for flag in $args; do
Chris@82 7229 IFS=$save_ifs
Chris@82 7230 func_quote_for_eval "$flag"
Chris@82 7231 func_append arg " $wl$func_quote_for_eval_result"
Chris@82 7232 func_append compiler_flags " $wl$func_quote_for_eval_result"
Chris@82 7233 func_append linker_flags " $func_quote_for_eval_result"
Chris@82 7234 done
Chris@82 7235 IFS=$save_ifs
Chris@82 7236 func_stripname ' ' '' "$arg"
Chris@82 7237 arg=$func_stripname_result
Chris@82 7238 ;;
Chris@82 7239
Chris@82 7240 -Xcompiler)
Chris@82 7241 prev=xcompiler
Chris@82 7242 continue
Chris@82 7243 ;;
Chris@82 7244
Chris@82 7245 -Xlinker)
Chris@82 7246 prev=xlinker
Chris@82 7247 continue
Chris@82 7248 ;;
Chris@82 7249
Chris@82 7250 -XCClinker)
Chris@82 7251 prev=xcclinker
Chris@82 7252 continue
Chris@82 7253 ;;
Chris@82 7254
Chris@82 7255 # -msg_* for osf cc
Chris@82 7256 -msg_*)
Chris@82 7257 func_quote_for_eval "$arg"
Chris@82 7258 arg=$func_quote_for_eval_result
Chris@82 7259 ;;
Chris@82 7260
Chris@82 7261 # Flags to be passed through unchanged, with rationale:
Chris@82 7262 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
Chris@82 7263 # -r[0-9][0-9]* specify processor for the SGI compiler
Chris@82 7264 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
Chris@82 7265 # +DA*, +DD* enable 64-bit mode for the HP compiler
Chris@82 7266 # -q* compiler args for the IBM compiler
Chris@82 7267 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
Chris@82 7268 # -F/path path to uninstalled frameworks, gcc on darwin
Chris@82 7269 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
Chris@82 7270 # -fstack-protector* stack protector flags for GCC
Chris@82 7271 # @file GCC response files
Chris@82 7272 # -tp=* Portland pgcc target processor selection
Chris@82 7273 # --sysroot=* for sysroot support
Chris@82 7274 # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
Chris@82 7275 # -specs=* GCC specs files
Chris@82 7276 # -stdlib=* select c++ std lib with clang
Chris@82 7277 # -fsanitize=* Clang/GCC memory and address sanitizer
Chris@82 7278 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
Chris@82 7279 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
Chris@82 7280 -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
Chris@82 7281 -specs=*|-fsanitize=*)
Chris@82 7282 func_quote_for_eval "$arg"
Chris@82 7283 arg=$func_quote_for_eval_result
Chris@82 7284 func_append compile_command " $arg"
Chris@82 7285 func_append finalize_command " $arg"
Chris@82 7286 func_append compiler_flags " $arg"
Chris@82 7287 continue
Chris@82 7288 ;;
Chris@82 7289
Chris@82 7290 -Z*)
Chris@82 7291 if test os2 = "`expr $host : '.*\(os2\)'`"; then
Chris@82 7292 # OS/2 uses -Zxxx to specify OS/2-specific options
Chris@82 7293 compiler_flags="$compiler_flags $arg"
Chris@82 7294 func_append compile_command " $arg"
Chris@82 7295 func_append finalize_command " $arg"
Chris@82 7296 case $arg in
Chris@82 7297 -Zlinker | -Zstack)
Chris@82 7298 prev=xcompiler
Chris@82 7299 ;;
Chris@82 7300 esac
Chris@82 7301 continue
Chris@82 7302 else
Chris@82 7303 # Otherwise treat like 'Some other compiler flag' below
Chris@82 7304 func_quote_for_eval "$arg"
Chris@82 7305 arg=$func_quote_for_eval_result
Chris@82 7306 fi
Chris@82 7307 ;;
Chris@82 7308
Chris@82 7309 # Some other compiler flag.
Chris@82 7310 -* | +*)
Chris@82 7311 func_quote_for_eval "$arg"
Chris@82 7312 arg=$func_quote_for_eval_result
Chris@82 7313 ;;
Chris@82 7314
Chris@82 7315 *.$objext)
Chris@82 7316 # A standard object.
Chris@82 7317 func_append objs " $arg"
Chris@82 7318 ;;
Chris@82 7319
Chris@82 7320 *.lo)
Chris@82 7321 # A libtool-controlled object.
Chris@82 7322
Chris@82 7323 # Check to see that this really is a libtool object.
Chris@82 7324 if func_lalib_unsafe_p "$arg"; then
Chris@82 7325 pic_object=
Chris@82 7326 non_pic_object=
Chris@82 7327
Chris@82 7328 # Read the .lo file
Chris@82 7329 func_source "$arg"
Chris@82 7330
Chris@82 7331 if test -z "$pic_object" ||
Chris@82 7332 test -z "$non_pic_object" ||
Chris@82 7333 test none = "$pic_object" &&
Chris@82 7334 test none = "$non_pic_object"; then
Chris@82 7335 func_fatal_error "cannot find name of object for '$arg'"
Chris@82 7336 fi
Chris@82 7337
Chris@82 7338 # Extract subdirectory from the argument.
Chris@82 7339 func_dirname "$arg" "/" ""
Chris@82 7340 xdir=$func_dirname_result
Chris@82 7341
Chris@82 7342 test none = "$pic_object" || {
Chris@82 7343 # Prepend the subdirectory the object is found in.
Chris@82 7344 pic_object=$xdir$pic_object
Chris@82 7345
Chris@82 7346 if test dlfiles = "$prev"; then
Chris@82 7347 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
Chris@82 7348 func_append dlfiles " $pic_object"
Chris@82 7349 prev=
Chris@82 7350 continue
Chris@82 7351 else
Chris@82 7352 # If libtool objects are unsupported, then we need to preload.
Chris@82 7353 prev=dlprefiles
Chris@82 7354 fi
Chris@82 7355 fi
Chris@82 7356
Chris@82 7357 # CHECK ME: I think I busted this. -Ossama
Chris@82 7358 if test dlprefiles = "$prev"; then
Chris@82 7359 # Preload the old-style object.
Chris@82 7360 func_append dlprefiles " $pic_object"
Chris@82 7361 prev=
Chris@82 7362 fi
Chris@82 7363
Chris@82 7364 # A PIC object.
Chris@82 7365 func_append libobjs " $pic_object"
Chris@82 7366 arg=$pic_object
Chris@82 7367 }
Chris@82 7368
Chris@82 7369 # Non-PIC object.
Chris@82 7370 if test none != "$non_pic_object"; then
Chris@82 7371 # Prepend the subdirectory the object is found in.
Chris@82 7372 non_pic_object=$xdir$non_pic_object
Chris@82 7373
Chris@82 7374 # A standard non-PIC object
Chris@82 7375 func_append non_pic_objects " $non_pic_object"
Chris@82 7376 if test -z "$pic_object" || test none = "$pic_object"; then
Chris@82 7377 arg=$non_pic_object
Chris@82 7378 fi
Chris@82 7379 else
Chris@82 7380 # If the PIC object exists, use it instead.
Chris@82 7381 # $xdir was prepended to $pic_object above.
Chris@82 7382 non_pic_object=$pic_object
Chris@82 7383 func_append non_pic_objects " $non_pic_object"
Chris@82 7384 fi
Chris@82 7385 else
Chris@82 7386 # Only an error if not doing a dry-run.
Chris@82 7387 if $opt_dry_run; then
Chris@82 7388 # Extract subdirectory from the argument.
Chris@82 7389 func_dirname "$arg" "/" ""
Chris@82 7390 xdir=$func_dirname_result
Chris@82 7391
Chris@82 7392 func_lo2o "$arg"
Chris@82 7393 pic_object=$xdir$objdir/$func_lo2o_result
Chris@82 7394 non_pic_object=$xdir$func_lo2o_result
Chris@82 7395 func_append libobjs " $pic_object"
Chris@82 7396 func_append non_pic_objects " $non_pic_object"
Chris@82 7397 else
Chris@82 7398 func_fatal_error "'$arg' is not a valid libtool object"
Chris@82 7399 fi
Chris@82 7400 fi
Chris@82 7401 ;;
Chris@82 7402
Chris@82 7403 *.$libext)
Chris@82 7404 # An archive.
Chris@82 7405 func_append deplibs " $arg"
Chris@82 7406 func_append old_deplibs " $arg"
Chris@82 7407 continue
Chris@82 7408 ;;
Chris@82 7409
Chris@82 7410 *.la)
Chris@82 7411 # A libtool-controlled library.
Chris@82 7412
Chris@82 7413 func_resolve_sysroot "$arg"
Chris@82 7414 if test dlfiles = "$prev"; then
Chris@82 7415 # This library was specified with -dlopen.
Chris@82 7416 func_append dlfiles " $func_resolve_sysroot_result"
Chris@82 7417 prev=
Chris@82 7418 elif test dlprefiles = "$prev"; then
Chris@82 7419 # The library was specified with -dlpreopen.
Chris@82 7420 func_append dlprefiles " $func_resolve_sysroot_result"
Chris@82 7421 prev=
Chris@82 7422 else
Chris@82 7423 func_append deplibs " $func_resolve_sysroot_result"
Chris@82 7424 fi
Chris@82 7425 continue
Chris@82 7426 ;;
Chris@82 7427
Chris@82 7428 # Some other compiler argument.
Chris@82 7429 *)
Chris@82 7430 # Unknown arguments in both finalize_command and compile_command need
Chris@82 7431 # to be aesthetically quoted because they are evaled later.
Chris@82 7432 func_quote_for_eval "$arg"
Chris@82 7433 arg=$func_quote_for_eval_result
Chris@82 7434 ;;
Chris@82 7435 esac # arg
Chris@82 7436
Chris@82 7437 # Now actually substitute the argument into the commands.
Chris@82 7438 if test -n "$arg"; then
Chris@82 7439 func_append compile_command " $arg"
Chris@82 7440 func_append finalize_command " $arg"
Chris@82 7441 fi
Chris@82 7442 done # argument parsing loop
Chris@82 7443
Chris@82 7444 test -n "$prev" && \
Chris@82 7445 func_fatal_help "the '$prevarg' option requires an argument"
Chris@82 7446
Chris@82 7447 if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
Chris@82 7448 eval arg=\"$export_dynamic_flag_spec\"
Chris@82 7449 func_append compile_command " $arg"
Chris@82 7450 func_append finalize_command " $arg"
Chris@82 7451 fi
Chris@82 7452
Chris@82 7453 oldlibs=
Chris@82 7454 # calculate the name of the file, without its directory
Chris@82 7455 func_basename "$output"
Chris@82 7456 outputname=$func_basename_result
Chris@82 7457 libobjs_save=$libobjs
Chris@82 7458
Chris@82 7459 if test -n "$shlibpath_var"; then
Chris@82 7460 # get the directories listed in $shlibpath_var
Chris@82 7461 eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
Chris@82 7462 else
Chris@82 7463 shlib_search_path=
Chris@82 7464 fi
Chris@82 7465 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
Chris@82 7466 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
Chris@82 7467
Chris@82 7468 # Definition is injected by LT_CONFIG during libtool generation.
Chris@82 7469 func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
Chris@82 7470
Chris@82 7471 func_dirname "$output" "/" ""
Chris@82 7472 output_objdir=$func_dirname_result$objdir
Chris@82 7473 func_to_tool_file "$output_objdir/"
Chris@82 7474 tool_output_objdir=$func_to_tool_file_result
Chris@82 7475 # Create the object directory.
Chris@82 7476 func_mkdir_p "$output_objdir"
Chris@82 7477
Chris@82 7478 # Determine the type of output
Chris@82 7479 case $output in
Chris@82 7480 "")
Chris@82 7481 func_fatal_help "you must specify an output file"
Chris@82 7482 ;;
Chris@82 7483 *.$libext) linkmode=oldlib ;;
Chris@82 7484 *.lo | *.$objext) linkmode=obj ;;
Chris@82 7485 *.la) linkmode=lib ;;
Chris@82 7486 *) linkmode=prog ;; # Anything else should be a program.
Chris@82 7487 esac
Chris@82 7488
Chris@82 7489 specialdeplibs=
Chris@82 7490
Chris@82 7491 libs=
Chris@82 7492 # Find all interdependent deplibs by searching for libraries
Chris@82 7493 # that are linked more than once (e.g. -la -lb -la)
Chris@82 7494 for deplib in $deplibs; do
Chris@82 7495 if $opt_preserve_dup_deps; then
Chris@82 7496 case "$libs " in
Chris@82 7497 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
Chris@82 7498 esac
Chris@82 7499 fi
Chris@82 7500 func_append libs " $deplib"
Chris@82 7501 done
Chris@82 7502
Chris@82 7503 if test lib = "$linkmode"; then
Chris@82 7504 libs="$predeps $libs $compiler_lib_search_path $postdeps"
Chris@82 7505
Chris@82 7506 # Compute libraries that are listed more than once in $predeps
Chris@82 7507 # $postdeps and mark them as special (i.e., whose duplicates are
Chris@82 7508 # not to be eliminated).
Chris@82 7509 pre_post_deps=
Chris@82 7510 if $opt_duplicate_compiler_generated_deps; then
Chris@82 7511 for pre_post_dep in $predeps $postdeps; do
Chris@82 7512 case "$pre_post_deps " in
Chris@82 7513 *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
Chris@82 7514 esac
Chris@82 7515 func_append pre_post_deps " $pre_post_dep"
Chris@82 7516 done
Chris@82 7517 fi
Chris@82 7518 pre_post_deps=
Chris@82 7519 fi
Chris@82 7520
Chris@82 7521 deplibs=
Chris@82 7522 newdependency_libs=
Chris@82 7523 newlib_search_path=
Chris@82 7524 need_relink=no # whether we're linking any uninstalled libtool libraries
Chris@82 7525 notinst_deplibs= # not-installed libtool libraries
Chris@82 7526 notinst_path= # paths that contain not-installed libtool libraries
Chris@82 7527
Chris@82 7528 case $linkmode in
Chris@82 7529 lib)
Chris@82 7530 passes="conv dlpreopen link"
Chris@82 7531 for file in $dlfiles $dlprefiles; do
Chris@82 7532 case $file in
Chris@82 7533 *.la) ;;
Chris@82 7534 *)
Chris@82 7535 func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
Chris@82 7536 ;;
Chris@82 7537 esac
Chris@82 7538 done
Chris@82 7539 ;;
Chris@82 7540 prog)
Chris@82 7541 compile_deplibs=
Chris@82 7542 finalize_deplibs=
Chris@82 7543 alldeplibs=false
Chris@82 7544 newdlfiles=
Chris@82 7545 newdlprefiles=
Chris@82 7546 passes="conv scan dlopen dlpreopen link"
Chris@82 7547 ;;
Chris@82 7548 *) passes="conv"
Chris@82 7549 ;;
Chris@82 7550 esac
Chris@82 7551
Chris@82 7552 for pass in $passes; do
Chris@82 7553 # The preopen pass in lib mode reverses $deplibs; put it back here
Chris@82 7554 # so that -L comes before libs that need it for instance...
Chris@82 7555 if test lib,link = "$linkmode,$pass"; then
Chris@82 7556 ## FIXME: Find the place where the list is rebuilt in the wrong
Chris@82 7557 ## order, and fix it there properly
Chris@82 7558 tmp_deplibs=
Chris@82 7559 for deplib in $deplibs; do
Chris@82 7560 tmp_deplibs="$deplib $tmp_deplibs"
Chris@82 7561 done
Chris@82 7562 deplibs=$tmp_deplibs
Chris@82 7563 fi
Chris@82 7564
Chris@82 7565 if test lib,link = "$linkmode,$pass" ||
Chris@82 7566 test prog,scan = "$linkmode,$pass"; then
Chris@82 7567 libs=$deplibs
Chris@82 7568 deplibs=
Chris@82 7569 fi
Chris@82 7570 if test prog = "$linkmode"; then
Chris@82 7571 case $pass in
Chris@82 7572 dlopen) libs=$dlfiles ;;
Chris@82 7573 dlpreopen) libs=$dlprefiles ;;
Chris@82 7574 link)
Chris@82 7575 libs="$deplibs %DEPLIBS%"
Chris@82 7576 test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
Chris@82 7577 ;;
Chris@82 7578 esac
Chris@82 7579 fi
Chris@82 7580 if test lib,dlpreopen = "$linkmode,$pass"; then
Chris@82 7581 # Collect and forward deplibs of preopened libtool libs
Chris@82 7582 for lib in $dlprefiles; do
Chris@82 7583 # Ignore non-libtool-libs
Chris@82 7584 dependency_libs=
Chris@82 7585 func_resolve_sysroot "$lib"
Chris@82 7586 case $lib in
Chris@82 7587 *.la) func_source "$func_resolve_sysroot_result" ;;
Chris@82 7588 esac
Chris@82 7589
Chris@82 7590 # Collect preopened libtool deplibs, except any this library
Chris@82 7591 # has declared as weak libs
Chris@82 7592 for deplib in $dependency_libs; do
Chris@82 7593 func_basename "$deplib"
Chris@82 7594 deplib_base=$func_basename_result
Chris@82 7595 case " $weak_libs " in
Chris@82 7596 *" $deplib_base "*) ;;
Chris@82 7597 *) func_append deplibs " $deplib" ;;
Chris@82 7598 esac
Chris@82 7599 done
Chris@82 7600 done
Chris@82 7601 libs=$dlprefiles
Chris@82 7602 fi
Chris@82 7603 if test dlopen = "$pass"; then
Chris@82 7604 # Collect dlpreopened libraries
Chris@82 7605 save_deplibs=$deplibs
Chris@82 7606 deplibs=
Chris@82 7607 fi
Chris@82 7608
Chris@82 7609 for deplib in $libs; do
Chris@82 7610 lib=
Chris@82 7611 found=false
Chris@82 7612 case $deplib in
Chris@82 7613 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
Chris@82 7614 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
Chris@82 7615 if test prog,link = "$linkmode,$pass"; then
Chris@82 7616 compile_deplibs="$deplib $compile_deplibs"
Chris@82 7617 finalize_deplibs="$deplib $finalize_deplibs"
Chris@82 7618 else
Chris@82 7619 func_append compiler_flags " $deplib"
Chris@82 7620 if test lib = "$linkmode"; then
Chris@82 7621 case "$new_inherited_linker_flags " in
Chris@82 7622 *" $deplib "*) ;;
Chris@82 7623 * ) func_append new_inherited_linker_flags " $deplib" ;;
Chris@82 7624 esac
Chris@82 7625 fi
Chris@82 7626 fi
Chris@82 7627 continue
Chris@82 7628 ;;
Chris@82 7629 -l*)
Chris@82 7630 if test lib != "$linkmode" && test prog != "$linkmode"; then
Chris@82 7631 func_warning "'-l' is ignored for archives/objects"
Chris@82 7632 continue
Chris@82 7633 fi
Chris@82 7634 func_stripname '-l' '' "$deplib"
Chris@82 7635 name=$func_stripname_result
Chris@82 7636 if test lib = "$linkmode"; then
Chris@82 7637 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
Chris@82 7638 else
Chris@82 7639 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
Chris@82 7640 fi
Chris@82 7641 for searchdir in $searchdirs; do
Chris@82 7642 for search_ext in .la $std_shrext .so .a; do
Chris@82 7643 # Search the libtool library
Chris@82 7644 lib=$searchdir/lib$name$search_ext
Chris@82 7645 if test -f "$lib"; then
Chris@82 7646 if test .la = "$search_ext"; then
Chris@82 7647 found=:
Chris@82 7648 else
Chris@82 7649 found=false
Chris@82 7650 fi
Chris@82 7651 break 2
Chris@82 7652 fi
Chris@82 7653 done
Chris@82 7654 done
Chris@82 7655 if $found; then
Chris@82 7656 # deplib is a libtool library
Chris@82 7657 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
Chris@82 7658 # We need to do some special things here, and not later.
Chris@82 7659 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@82 7660 case " $predeps $postdeps " in
Chris@82 7661 *" $deplib "*)
Chris@82 7662 if func_lalib_p "$lib"; then
Chris@82 7663 library_names=
Chris@82 7664 old_library=
Chris@82 7665 func_source "$lib"
Chris@82 7666 for l in $old_library $library_names; do
Chris@82 7667 ll=$l
Chris@82 7668 done
Chris@82 7669 if test "X$ll" = "X$old_library"; then # only static version available
Chris@82 7670 found=false
Chris@82 7671 func_dirname "$lib" "" "."
Chris@82 7672 ladir=$func_dirname_result
Chris@82 7673 lib=$ladir/$old_library
Chris@82 7674 if test prog,link = "$linkmode,$pass"; then
Chris@82 7675 compile_deplibs="$deplib $compile_deplibs"
Chris@82 7676 finalize_deplibs="$deplib $finalize_deplibs"
Chris@82 7677 else
Chris@82 7678 deplibs="$deplib $deplibs"
Chris@82 7679 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
Chris@82 7680 fi
Chris@82 7681 continue
Chris@82 7682 fi
Chris@82 7683 fi
Chris@82 7684 ;;
Chris@82 7685 *) ;;
Chris@82 7686 esac
Chris@82 7687 fi
Chris@82 7688 else
Chris@82 7689 # deplib doesn't seem to be a libtool library
Chris@82 7690 if test prog,link = "$linkmode,$pass"; then
Chris@82 7691 compile_deplibs="$deplib $compile_deplibs"
Chris@82 7692 finalize_deplibs="$deplib $finalize_deplibs"
Chris@82 7693 else
Chris@82 7694 deplibs="$deplib $deplibs"
Chris@82 7695 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
Chris@82 7696 fi
Chris@82 7697 continue
Chris@82 7698 fi
Chris@82 7699 ;; # -l
Chris@82 7700 *.ltframework)
Chris@82 7701 if test prog,link = "$linkmode,$pass"; then
Chris@82 7702 compile_deplibs="$deplib $compile_deplibs"
Chris@82 7703 finalize_deplibs="$deplib $finalize_deplibs"
Chris@82 7704 else
Chris@82 7705 deplibs="$deplib $deplibs"
Chris@82 7706 if test lib = "$linkmode"; then
Chris@82 7707 case "$new_inherited_linker_flags " in
Chris@82 7708 *" $deplib "*) ;;
Chris@82 7709 * ) func_append new_inherited_linker_flags " $deplib" ;;
Chris@82 7710 esac
Chris@82 7711 fi
Chris@82 7712 fi
Chris@82 7713 continue
Chris@82 7714 ;;
Chris@82 7715 -L*)
Chris@82 7716 case $linkmode in
Chris@82 7717 lib)
Chris@82 7718 deplibs="$deplib $deplibs"
Chris@82 7719 test conv = "$pass" && continue
Chris@82 7720 newdependency_libs="$deplib $newdependency_libs"
Chris@82 7721 func_stripname '-L' '' "$deplib"
Chris@82 7722 func_resolve_sysroot "$func_stripname_result"
Chris@82 7723 func_append newlib_search_path " $func_resolve_sysroot_result"
Chris@82 7724 ;;
Chris@82 7725 prog)
Chris@82 7726 if test conv = "$pass"; then
Chris@82 7727 deplibs="$deplib $deplibs"
Chris@82 7728 continue
Chris@82 7729 fi
Chris@82 7730 if test scan = "$pass"; then
Chris@82 7731 deplibs="$deplib $deplibs"
Chris@82 7732 else
Chris@82 7733 compile_deplibs="$deplib $compile_deplibs"
Chris@82 7734 finalize_deplibs="$deplib $finalize_deplibs"
Chris@82 7735 fi
Chris@82 7736 func_stripname '-L' '' "$deplib"
Chris@82 7737 func_resolve_sysroot "$func_stripname_result"
Chris@82 7738 func_append newlib_search_path " $func_resolve_sysroot_result"
Chris@82 7739 ;;
Chris@82 7740 *)
Chris@82 7741 func_warning "'-L' is ignored for archives/objects"
Chris@82 7742 ;;
Chris@82 7743 esac # linkmode
Chris@82 7744 continue
Chris@82 7745 ;; # -L
Chris@82 7746 -R*)
Chris@82 7747 if test link = "$pass"; then
Chris@82 7748 func_stripname '-R' '' "$deplib"
Chris@82 7749 func_resolve_sysroot "$func_stripname_result"
Chris@82 7750 dir=$func_resolve_sysroot_result
Chris@82 7751 # Make sure the xrpath contains only unique directories.
Chris@82 7752 case "$xrpath " in
Chris@82 7753 *" $dir "*) ;;
Chris@82 7754 *) func_append xrpath " $dir" ;;
Chris@82 7755 esac
Chris@82 7756 fi
Chris@82 7757 deplibs="$deplib $deplibs"
Chris@82 7758 continue
Chris@82 7759 ;;
Chris@82 7760 *.la)
Chris@82 7761 func_resolve_sysroot "$deplib"
Chris@82 7762 lib=$func_resolve_sysroot_result
Chris@82 7763 ;;
Chris@82 7764 *.$libext)
Chris@82 7765 if test conv = "$pass"; then
Chris@82 7766 deplibs="$deplib $deplibs"
Chris@82 7767 continue
Chris@82 7768 fi
Chris@82 7769 case $linkmode in
Chris@82 7770 lib)
Chris@82 7771 # Linking convenience modules into shared libraries is allowed,
Chris@82 7772 # but linking other static libraries is non-portable.
Chris@82 7773 case " $dlpreconveniencelibs " in
Chris@82 7774 *" $deplib "*) ;;
Chris@82 7775 *)
Chris@82 7776 valid_a_lib=false
Chris@82 7777 case $deplibs_check_method in
Chris@82 7778 match_pattern*)
Chris@82 7779 set dummy $deplibs_check_method; shift
Chris@82 7780 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Chris@82 7781 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
Chris@82 7782 | $EGREP "$match_pattern_regex" > /dev/null; then
Chris@82 7783 valid_a_lib=:
Chris@82 7784 fi
Chris@82 7785 ;;
Chris@82 7786 pass_all)
Chris@82 7787 valid_a_lib=:
Chris@82 7788 ;;
Chris@82 7789 esac
Chris@82 7790 if $valid_a_lib; then
Chris@82 7791 echo
Chris@82 7792 $ECHO "*** Warning: Linking the shared library $output against the"
Chris@82 7793 $ECHO "*** static library $deplib is not portable!"
Chris@82 7794 deplibs="$deplib $deplibs"
Chris@82 7795 else
Chris@82 7796 echo
Chris@82 7797 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
Chris@82 7798 echo "*** I have the capability to make that library automatically link in when"
Chris@82 7799 echo "*** you link to this library. But I can only do this if you have a"
Chris@82 7800 echo "*** shared version of the library, which you do not appear to have"
Chris@82 7801 echo "*** because the file extensions .$libext of this argument makes me believe"
Chris@82 7802 echo "*** that it is just a static archive that I should not use here."
Chris@82 7803 fi
Chris@82 7804 ;;
Chris@82 7805 esac
Chris@82 7806 continue
Chris@82 7807 ;;
Chris@82 7808 prog)
Chris@82 7809 if test link != "$pass"; then
Chris@82 7810 deplibs="$deplib $deplibs"
Chris@82 7811 else
Chris@82 7812 compile_deplibs="$deplib $compile_deplibs"
Chris@82 7813 finalize_deplibs="$deplib $finalize_deplibs"
Chris@82 7814 fi
Chris@82 7815 continue
Chris@82 7816 ;;
Chris@82 7817 esac # linkmode
Chris@82 7818 ;; # *.$libext
Chris@82 7819 *.lo | *.$objext)
Chris@82 7820 if test conv = "$pass"; then
Chris@82 7821 deplibs="$deplib $deplibs"
Chris@82 7822 elif test prog = "$linkmode"; then
Chris@82 7823 if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
Chris@82 7824 # If there is no dlopen support or we're linking statically,
Chris@82 7825 # we need to preload.
Chris@82 7826 func_append newdlprefiles " $deplib"
Chris@82 7827 compile_deplibs="$deplib $compile_deplibs"
Chris@82 7828 finalize_deplibs="$deplib $finalize_deplibs"
Chris@82 7829 else
Chris@82 7830 func_append newdlfiles " $deplib"
Chris@82 7831 fi
Chris@82 7832 fi
Chris@82 7833 continue
Chris@82 7834 ;;
Chris@82 7835 %DEPLIBS%)
Chris@82 7836 alldeplibs=:
Chris@82 7837 continue
Chris@82 7838 ;;
Chris@82 7839 esac # case $deplib
Chris@82 7840
Chris@82 7841 $found || test -f "$lib" \
Chris@82 7842 || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
Chris@82 7843
Chris@82 7844 # Check to see that this really is a libtool archive.
Chris@82 7845 func_lalib_unsafe_p "$lib" \
Chris@82 7846 || func_fatal_error "'$lib' is not a valid libtool archive"
Chris@82 7847
Chris@82 7848 func_dirname "$lib" "" "."
Chris@82 7849 ladir=$func_dirname_result
Chris@82 7850
Chris@82 7851 dlname=
Chris@82 7852 dlopen=
Chris@82 7853 dlpreopen=
Chris@82 7854 libdir=
Chris@82 7855 library_names=
Chris@82 7856 old_library=
Chris@82 7857 inherited_linker_flags=
Chris@82 7858 # If the library was installed with an old release of libtool,
Chris@82 7859 # it will not redefine variables installed, or shouldnotlink
Chris@82 7860 installed=yes
Chris@82 7861 shouldnotlink=no
Chris@82 7862 avoidtemprpath=
Chris@82 7863
Chris@82 7864
Chris@82 7865 # Read the .la file
Chris@82 7866 func_source "$lib"
Chris@82 7867
Chris@82 7868 # Convert "-framework foo" to "foo.ltframework"
Chris@82 7869 if test -n "$inherited_linker_flags"; then
Chris@82 7870 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
Chris@82 7871 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
Chris@82 7872 case " $new_inherited_linker_flags " in
Chris@82 7873 *" $tmp_inherited_linker_flag "*) ;;
Chris@82 7874 *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
Chris@82 7875 esac
Chris@82 7876 done
Chris@82 7877 fi
Chris@82 7878 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@82 7879 if test lib,link = "$linkmode,$pass" ||
Chris@82 7880 test prog,scan = "$linkmode,$pass" ||
Chris@82 7881 { test prog != "$linkmode" && test lib != "$linkmode"; }; then
Chris@82 7882 test -n "$dlopen" && func_append dlfiles " $dlopen"
Chris@82 7883 test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
Chris@82 7884 fi
Chris@82 7885
Chris@82 7886 if test conv = "$pass"; then
Chris@82 7887 # Only check for convenience libraries
Chris@82 7888 deplibs="$lib $deplibs"
Chris@82 7889 if test -z "$libdir"; then
Chris@82 7890 if test -z "$old_library"; then
Chris@82 7891 func_fatal_error "cannot find name of link library for '$lib'"
Chris@82 7892 fi
Chris@82 7893 # It is a libtool convenience library, so add in its objects.
Chris@82 7894 func_append convenience " $ladir/$objdir/$old_library"
Chris@82 7895 func_append old_convenience " $ladir/$objdir/$old_library"
Chris@82 7896 tmp_libs=
Chris@82 7897 for deplib in $dependency_libs; do
Chris@82 7898 deplibs="$deplib $deplibs"
Chris@82 7899 if $opt_preserve_dup_deps; then
Chris@82 7900 case "$tmp_libs " in
Chris@82 7901 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
Chris@82 7902 esac
Chris@82 7903 fi
Chris@82 7904 func_append tmp_libs " $deplib"
Chris@82 7905 done
Chris@82 7906 elif test prog != "$linkmode" && test lib != "$linkmode"; then
Chris@82 7907 func_fatal_error "'$lib' is not a convenience library"
Chris@82 7908 fi
Chris@82 7909 continue
Chris@82 7910 fi # $pass = conv
Chris@82 7911
Chris@82 7912
Chris@82 7913 # Get the name of the library we link against.
Chris@82 7914 linklib=
Chris@82 7915 if test -n "$old_library" &&
Chris@82 7916 { test yes = "$prefer_static_libs" ||
Chris@82 7917 test built,no = "$prefer_static_libs,$installed"; }; then
Chris@82 7918 linklib=$old_library
Chris@82 7919 else
Chris@82 7920 for l in $old_library $library_names; do
Chris@82 7921 linklib=$l
Chris@82 7922 done
Chris@82 7923 fi
Chris@82 7924 if test -z "$linklib"; then
Chris@82 7925 func_fatal_error "cannot find name of link library for '$lib'"
Chris@82 7926 fi
Chris@82 7927
Chris@82 7928 # This library was specified with -dlopen.
Chris@82 7929 if test dlopen = "$pass"; then
Chris@82 7930 test -z "$libdir" \
Chris@82 7931 && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
Chris@82 7932 if test -z "$dlname" ||
Chris@82 7933 test yes != "$dlopen_support" ||
Chris@82 7934 test no = "$build_libtool_libs"
Chris@82 7935 then
Chris@82 7936 # If there is no dlname, no dlopen support or we're linking
Chris@82 7937 # statically, we need to preload. We also need to preload any
Chris@82 7938 # dependent libraries so libltdl's deplib preloader doesn't
Chris@82 7939 # bomb out in the load deplibs phase.
Chris@82 7940 func_append dlprefiles " $lib $dependency_libs"
Chris@82 7941 else
Chris@82 7942 func_append newdlfiles " $lib"
Chris@82 7943 fi
Chris@82 7944 continue
Chris@82 7945 fi # $pass = dlopen
Chris@82 7946
Chris@82 7947 # We need an absolute path.
Chris@82 7948 case $ladir in
Chris@82 7949 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
Chris@82 7950 *)
Chris@82 7951 abs_ladir=`cd "$ladir" && pwd`
Chris@82 7952 if test -z "$abs_ladir"; then
Chris@82 7953 func_warning "cannot determine absolute directory name of '$ladir'"
Chris@82 7954 func_warning "passing it literally to the linker, although it might fail"
Chris@82 7955 abs_ladir=$ladir
Chris@82 7956 fi
Chris@82 7957 ;;
Chris@82 7958 esac
Chris@82 7959 func_basename "$lib"
Chris@82 7960 laname=$func_basename_result
Chris@82 7961
Chris@82 7962 # Find the relevant object directory and library name.
Chris@82 7963 if test yes = "$installed"; then
Chris@82 7964 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
Chris@82 7965 func_warning "library '$lib' was moved."
Chris@82 7966 dir=$ladir
Chris@82 7967 absdir=$abs_ladir
Chris@82 7968 libdir=$abs_ladir
Chris@82 7969 else
Chris@82 7970 dir=$lt_sysroot$libdir
Chris@82 7971 absdir=$lt_sysroot$libdir
Chris@82 7972 fi
Chris@82 7973 test yes = "$hardcode_automatic" && avoidtemprpath=yes
Chris@82 7974 else
Chris@82 7975 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
Chris@82 7976 dir=$ladir
Chris@82 7977 absdir=$abs_ladir
Chris@82 7978 # Remove this search path later
Chris@82 7979 func_append notinst_path " $abs_ladir"
Chris@82 7980 else
Chris@82 7981 dir=$ladir/$objdir
Chris@82 7982 absdir=$abs_ladir/$objdir
Chris@82 7983 # Remove this search path later
Chris@82 7984 func_append notinst_path " $abs_ladir"
Chris@82 7985 fi
Chris@82 7986 fi # $installed = yes
Chris@82 7987 func_stripname 'lib' '.la' "$laname"
Chris@82 7988 name=$func_stripname_result
Chris@82 7989
Chris@82 7990 # This library was specified with -dlpreopen.
Chris@82 7991 if test dlpreopen = "$pass"; then
Chris@82 7992 if test -z "$libdir" && test prog = "$linkmode"; then
Chris@82 7993 func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
Chris@82 7994 fi
Chris@82 7995 case $host in
Chris@82 7996 # special handling for platforms with PE-DLLs.
Chris@82 7997 *cygwin* | *mingw* | *cegcc* )
Chris@82 7998 # Linker will automatically link against shared library if both
Chris@82 7999 # static and shared are present. Therefore, ensure we extract
Chris@82 8000 # symbols from the import library if a shared library is present
Chris@82 8001 # (otherwise, the dlopen module name will be incorrect). We do
Chris@82 8002 # this by putting the import library name into $newdlprefiles.
Chris@82 8003 # We recover the dlopen module name by 'saving' the la file
Chris@82 8004 # name in a special purpose variable, and (later) extracting the
Chris@82 8005 # dlname from the la file.
Chris@82 8006 if test -n "$dlname"; then
Chris@82 8007 func_tr_sh "$dir/$linklib"
Chris@82 8008 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
Chris@82 8009 func_append newdlprefiles " $dir/$linklib"
Chris@82 8010 else
Chris@82 8011 func_append newdlprefiles " $dir/$old_library"
Chris@82 8012 # Keep a list of preopened convenience libraries to check
Chris@82 8013 # that they are being used correctly in the link pass.
Chris@82 8014 test -z "$libdir" && \
Chris@82 8015 func_append dlpreconveniencelibs " $dir/$old_library"
Chris@82 8016 fi
Chris@82 8017 ;;
Chris@82 8018 * )
Chris@82 8019 # Prefer using a static library (so that no silly _DYNAMIC symbols
Chris@82 8020 # are required to link).
Chris@82 8021 if test -n "$old_library"; then
Chris@82 8022 func_append newdlprefiles " $dir/$old_library"
Chris@82 8023 # Keep a list of preopened convenience libraries to check
Chris@82 8024 # that they are being used correctly in the link pass.
Chris@82 8025 test -z "$libdir" && \
Chris@82 8026 func_append dlpreconveniencelibs " $dir/$old_library"
Chris@82 8027 # Otherwise, use the dlname, so that lt_dlopen finds it.
Chris@82 8028 elif test -n "$dlname"; then
Chris@82 8029 func_append newdlprefiles " $dir/$dlname"
Chris@82 8030 else
Chris@82 8031 func_append newdlprefiles " $dir/$linklib"
Chris@82 8032 fi
Chris@82 8033 ;;
Chris@82 8034 esac
Chris@82 8035 fi # $pass = dlpreopen
Chris@82 8036
Chris@82 8037 if test -z "$libdir"; then
Chris@82 8038 # Link the convenience library
Chris@82 8039 if test lib = "$linkmode"; then
Chris@82 8040 deplibs="$dir/$old_library $deplibs"
Chris@82 8041 elif test prog,link = "$linkmode,$pass"; then
Chris@82 8042 compile_deplibs="$dir/$old_library $compile_deplibs"
Chris@82 8043 finalize_deplibs="$dir/$old_library $finalize_deplibs"
Chris@82 8044 else
Chris@82 8045 deplibs="$lib $deplibs" # used for prog,scan pass
Chris@82 8046 fi
Chris@82 8047 continue
Chris@82 8048 fi
Chris@82 8049
Chris@82 8050
Chris@82 8051 if test prog = "$linkmode" && test link != "$pass"; then
Chris@82 8052 func_append newlib_search_path " $ladir"
Chris@82 8053 deplibs="$lib $deplibs"
Chris@82 8054
Chris@82 8055 linkalldeplibs=false
Chris@82 8056 if test no != "$link_all_deplibs" || test -z "$library_names" ||
Chris@82 8057 test no = "$build_libtool_libs"; then
Chris@82 8058 linkalldeplibs=:
Chris@82 8059 fi
Chris@82 8060
Chris@82 8061 tmp_libs=
Chris@82 8062 for deplib in $dependency_libs; do
Chris@82 8063 case $deplib in
Chris@82 8064 -L*) func_stripname '-L' '' "$deplib"
Chris@82 8065 func_resolve_sysroot "$func_stripname_result"
Chris@82 8066 func_append newlib_search_path " $func_resolve_sysroot_result"
Chris@82 8067 ;;
Chris@82 8068 esac
Chris@82 8069 # Need to link against all dependency_libs?
Chris@82 8070 if $linkalldeplibs; then
Chris@82 8071 deplibs="$deplib $deplibs"
Chris@82 8072 else
Chris@82 8073 # Need to hardcode shared library paths
Chris@82 8074 # or/and link against static libraries
Chris@82 8075 newdependency_libs="$deplib $newdependency_libs"
Chris@82 8076 fi
Chris@82 8077 if $opt_preserve_dup_deps; then
Chris@82 8078 case "$tmp_libs " in
Chris@82 8079 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
Chris@82 8080 esac
Chris@82 8081 fi
Chris@82 8082 func_append tmp_libs " $deplib"
Chris@82 8083 done # for deplib
Chris@82 8084 continue
Chris@82 8085 fi # $linkmode = prog...
Chris@82 8086
Chris@82 8087 if test prog,link = "$linkmode,$pass"; then
Chris@82 8088 if test -n "$library_names" &&
Chris@82 8089 { { test no = "$prefer_static_libs" ||
Chris@82 8090 test built,yes = "$prefer_static_libs,$installed"; } ||
Chris@82 8091 test -z "$old_library"; }; then
Chris@82 8092 # We need to hardcode the library path
Chris@82 8093 if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
Chris@82 8094 # Make sure the rpath contains only unique directories.
Chris@82 8095 case $temp_rpath: in
Chris@82 8096 *"$absdir:"*) ;;
Chris@82 8097 *) func_append temp_rpath "$absdir:" ;;
Chris@82 8098 esac
Chris@82 8099 fi
Chris@82 8100
Chris@82 8101 # Hardcode the library path.
Chris@82 8102 # Skip directories that are in the system default run-time
Chris@82 8103 # search path.
Chris@82 8104 case " $sys_lib_dlsearch_path " in
Chris@82 8105 *" $absdir "*) ;;
Chris@82 8106 *)
Chris@82 8107 case "$compile_rpath " in
Chris@82 8108 *" $absdir "*) ;;
Chris@82 8109 *) func_append compile_rpath " $absdir" ;;
Chris@82 8110 esac
Chris@82 8111 ;;
Chris@82 8112 esac
Chris@82 8113 case " $sys_lib_dlsearch_path " in
Chris@82 8114 *" $libdir "*) ;;
Chris@82 8115 *)
Chris@82 8116 case "$finalize_rpath " in
Chris@82 8117 *" $libdir "*) ;;
Chris@82 8118 *) func_append finalize_rpath " $libdir" ;;
Chris@82 8119 esac
Chris@82 8120 ;;
Chris@82 8121 esac
Chris@82 8122 fi # $linkmode,$pass = prog,link...
Chris@82 8123
Chris@82 8124 if $alldeplibs &&
Chris@82 8125 { test pass_all = "$deplibs_check_method" ||
Chris@82 8126 { test yes = "$build_libtool_libs" &&
Chris@82 8127 test -n "$library_names"; }; }; then
Chris@82 8128 # We only need to search for static libraries
Chris@82 8129 continue
Chris@82 8130 fi
Chris@82 8131 fi
Chris@82 8132
Chris@82 8133 link_static=no # Whether the deplib will be linked statically
Chris@82 8134 use_static_libs=$prefer_static_libs
Chris@82 8135 if test built = "$use_static_libs" && test yes = "$installed"; then
Chris@82 8136 use_static_libs=no
Chris@82 8137 fi
Chris@82 8138 if test -n "$library_names" &&
Chris@82 8139 { test no = "$use_static_libs" || test -z "$old_library"; }; then
Chris@82 8140 case $host in
Chris@82 8141 *cygwin* | *mingw* | *cegcc* | *os2*)
Chris@82 8142 # No point in relinking DLLs because paths are not encoded
Chris@82 8143 func_append notinst_deplibs " $lib"
Chris@82 8144 need_relink=no
Chris@82 8145 ;;
Chris@82 8146 *)
Chris@82 8147 if test no = "$installed"; then
Chris@82 8148 func_append notinst_deplibs " $lib"
Chris@82 8149 need_relink=yes
Chris@82 8150 fi
Chris@82 8151 ;;
Chris@82 8152 esac
Chris@82 8153 # This is a shared library
Chris@82 8154
Chris@82 8155 # Warn about portability, can't link against -module's on some
Chris@82 8156 # systems (darwin). Don't bleat about dlopened modules though!
Chris@82 8157 dlopenmodule=
Chris@82 8158 for dlpremoduletest in $dlprefiles; do
Chris@82 8159 if test "X$dlpremoduletest" = "X$lib"; then
Chris@82 8160 dlopenmodule=$dlpremoduletest
Chris@82 8161 break
Chris@82 8162 fi
Chris@82 8163 done
Chris@82 8164 if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
Chris@82 8165 echo
Chris@82 8166 if test prog = "$linkmode"; then
Chris@82 8167 $ECHO "*** Warning: Linking the executable $output against the loadable module"
Chris@82 8168 else
Chris@82 8169 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
Chris@82 8170 fi
Chris@82 8171 $ECHO "*** $linklib is not portable!"
Chris@82 8172 fi
Chris@82 8173 if test lib = "$linkmode" &&
Chris@82 8174 test yes = "$hardcode_into_libs"; then
Chris@82 8175 # Hardcode the library path.
Chris@82 8176 # Skip directories that are in the system default run-time
Chris@82 8177 # search path.
Chris@82 8178 case " $sys_lib_dlsearch_path " in
Chris@82 8179 *" $absdir "*) ;;
Chris@82 8180 *)
Chris@82 8181 case "$compile_rpath " in
Chris@82 8182 *" $absdir "*) ;;
Chris@82 8183 *) func_append compile_rpath " $absdir" ;;
Chris@82 8184 esac
Chris@82 8185 ;;
Chris@82 8186 esac
Chris@82 8187 case " $sys_lib_dlsearch_path " in
Chris@82 8188 *" $libdir "*) ;;
Chris@82 8189 *)
Chris@82 8190 case "$finalize_rpath " in
Chris@82 8191 *" $libdir "*) ;;
Chris@82 8192 *) func_append finalize_rpath " $libdir" ;;
Chris@82 8193 esac
Chris@82 8194 ;;
Chris@82 8195 esac
Chris@82 8196 fi
Chris@82 8197
Chris@82 8198 if test -n "$old_archive_from_expsyms_cmds"; then
Chris@82 8199 # figure out the soname
Chris@82 8200 set dummy $library_names
Chris@82 8201 shift
Chris@82 8202 realname=$1
Chris@82 8203 shift
Chris@82 8204 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@82 8205 # use dlname if we got it. it's perfectly good, no?
Chris@82 8206 if test -n "$dlname"; then
Chris@82 8207 soname=$dlname
Chris@82 8208 elif test -n "$soname_spec"; then
Chris@82 8209 # bleh windows
Chris@82 8210 case $host in
Chris@82 8211 *cygwin* | mingw* | *cegcc* | *os2*)
Chris@82 8212 func_arith $current - $age
Chris@82 8213 major=$func_arith_result
Chris@82 8214 versuffix=-$major
Chris@82 8215 ;;
Chris@82 8216 esac
Chris@82 8217 eval soname=\"$soname_spec\"
Chris@82 8218 else
Chris@82 8219 soname=$realname
Chris@82 8220 fi
Chris@82 8221
Chris@82 8222 # Make a new name for the extract_expsyms_cmds to use
Chris@82 8223 soroot=$soname
Chris@82 8224 func_basename "$soroot"
Chris@82 8225 soname=$func_basename_result
Chris@82 8226 func_stripname 'lib' '.dll' "$soname"
Chris@82 8227 newlib=libimp-$func_stripname_result.a
Chris@82 8228
Chris@82 8229 # If the library has no export list, then create one now
Chris@82 8230 if test -f "$output_objdir/$soname-def"; then :
Chris@82 8231 else
Chris@82 8232 func_verbose "extracting exported symbol list from '$soname'"
Chris@82 8233 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
Chris@82 8234 fi
Chris@82 8235
Chris@82 8236 # Create $newlib
Chris@82 8237 if test -f "$output_objdir/$newlib"; then :; else
Chris@82 8238 func_verbose "generating import library for '$soname'"
Chris@82 8239 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
Chris@82 8240 fi
Chris@82 8241 # make sure the library variables are pointing to the new library
Chris@82 8242 dir=$output_objdir
Chris@82 8243 linklib=$newlib
Chris@82 8244 fi # test -n "$old_archive_from_expsyms_cmds"
Chris@82 8245
Chris@82 8246 if test prog = "$linkmode" || test relink != "$opt_mode"; then
Chris@82 8247 add_shlibpath=
Chris@82 8248 add_dir=
Chris@82 8249 add=
Chris@82 8250 lib_linked=yes
Chris@82 8251 case $hardcode_action in
Chris@82 8252 immediate | unsupported)
Chris@82 8253 if test no = "$hardcode_direct"; then
Chris@82 8254 add=$dir/$linklib
Chris@82 8255 case $host in
Chris@82 8256 *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
Chris@82 8257 *-*-sysv4*uw2*) add_dir=-L$dir ;;
Chris@82 8258 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
Chris@82 8259 *-*-unixware7*) add_dir=-L$dir ;;
Chris@82 8260 *-*-darwin* )
Chris@82 8261 # if the lib is a (non-dlopened) module then we cannot
Chris@82 8262 # link against it, someone is ignoring the earlier warnings
Chris@82 8263 if /usr/bin/file -L $add 2> /dev/null |
Chris@82 8264 $GREP ": [^:]* bundle" >/dev/null; then
Chris@82 8265 if test "X$dlopenmodule" != "X$lib"; then
Chris@82 8266 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
Chris@82 8267 if test -z "$old_library"; then
Chris@82 8268 echo
Chris@82 8269 echo "*** And there doesn't seem to be a static archive available"
Chris@82 8270 echo "*** The link will probably fail, sorry"
Chris@82 8271 else
Chris@82 8272 add=$dir/$old_library
Chris@82 8273 fi
Chris@82 8274 elif test -n "$old_library"; then
Chris@82 8275 add=$dir/$old_library
Chris@82 8276 fi
Chris@82 8277 fi
Chris@82 8278 esac
Chris@82 8279 elif test no = "$hardcode_minus_L"; then
Chris@82 8280 case $host in
Chris@82 8281 *-*-sunos*) add_shlibpath=$dir ;;
Chris@82 8282 esac
Chris@82 8283 add_dir=-L$dir
Chris@82 8284 add=-l$name
Chris@82 8285 elif test no = "$hardcode_shlibpath_var"; then
Chris@82 8286 add_shlibpath=$dir
Chris@82 8287 add=-l$name
Chris@82 8288 else
Chris@82 8289 lib_linked=no
Chris@82 8290 fi
Chris@82 8291 ;;
Chris@82 8292 relink)
Chris@82 8293 if test yes = "$hardcode_direct" &&
Chris@82 8294 test no = "$hardcode_direct_absolute"; then
Chris@82 8295 add=$dir/$linklib
Chris@82 8296 elif test yes = "$hardcode_minus_L"; then
Chris@82 8297 add_dir=-L$absdir
Chris@82 8298 # Try looking first in the location we're being installed to.
Chris@82 8299 if test -n "$inst_prefix_dir"; then
Chris@82 8300 case $libdir in
Chris@82 8301 [\\/]*)
Chris@82 8302 func_append add_dir " -L$inst_prefix_dir$libdir"
Chris@82 8303 ;;
Chris@82 8304 esac
Chris@82 8305 fi
Chris@82 8306 add=-l$name
Chris@82 8307 elif test yes = "$hardcode_shlibpath_var"; then
Chris@82 8308 add_shlibpath=$dir
Chris@82 8309 add=-l$name
Chris@82 8310 else
Chris@82 8311 lib_linked=no
Chris@82 8312 fi
Chris@82 8313 ;;
Chris@82 8314 *) lib_linked=no ;;
Chris@82 8315 esac
Chris@82 8316
Chris@82 8317 if test yes != "$lib_linked"; then
Chris@82 8318 func_fatal_configuration "unsupported hardcode properties"
Chris@82 8319 fi
Chris@82 8320
Chris@82 8321 if test -n "$add_shlibpath"; then
Chris@82 8322 case :$compile_shlibpath: in
Chris@82 8323 *":$add_shlibpath:"*) ;;
Chris@82 8324 *) func_append compile_shlibpath "$add_shlibpath:" ;;
Chris@82 8325 esac
Chris@82 8326 fi
Chris@82 8327 if test prog = "$linkmode"; then
Chris@82 8328 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
Chris@82 8329 test -n "$add" && compile_deplibs="$add $compile_deplibs"
Chris@82 8330 else
Chris@82 8331 test -n "$add_dir" && deplibs="$add_dir $deplibs"
Chris@82 8332 test -n "$add" && deplibs="$add $deplibs"
Chris@82 8333 if test yes != "$hardcode_direct" &&
Chris@82 8334 test yes != "$hardcode_minus_L" &&
Chris@82 8335 test yes = "$hardcode_shlibpath_var"; then
Chris@82 8336 case :$finalize_shlibpath: in
Chris@82 8337 *":$libdir:"*) ;;
Chris@82 8338 *) func_append finalize_shlibpath "$libdir:" ;;
Chris@82 8339 esac
Chris@82 8340 fi
Chris@82 8341 fi
Chris@82 8342 fi
Chris@82 8343
Chris@82 8344 if test prog = "$linkmode" || test relink = "$opt_mode"; then
Chris@82 8345 add_shlibpath=
Chris@82 8346 add_dir=
Chris@82 8347 add=
Chris@82 8348 # Finalize command for both is simple: just hardcode it.
Chris@82 8349 if test yes = "$hardcode_direct" &&
Chris@82 8350 test no = "$hardcode_direct_absolute"; then
Chris@82 8351 add=$libdir/$linklib
Chris@82 8352 elif test yes = "$hardcode_minus_L"; then
Chris@82 8353 add_dir=-L$libdir
Chris@82 8354 add=-l$name
Chris@82 8355 elif test yes = "$hardcode_shlibpath_var"; then
Chris@82 8356 case :$finalize_shlibpath: in
Chris@82 8357 *":$libdir:"*) ;;
Chris@82 8358 *) func_append finalize_shlibpath "$libdir:" ;;
Chris@82 8359 esac
Chris@82 8360 add=-l$name
Chris@82 8361 elif test yes = "$hardcode_automatic"; then
Chris@82 8362 if test -n "$inst_prefix_dir" &&
Chris@82 8363 test -f "$inst_prefix_dir$libdir/$linklib"; then
Chris@82 8364 add=$inst_prefix_dir$libdir/$linklib
Chris@82 8365 else
Chris@82 8366 add=$libdir/$linklib
Chris@82 8367 fi
Chris@82 8368 else
Chris@82 8369 # We cannot seem to hardcode it, guess we'll fake it.
Chris@82 8370 add_dir=-L$libdir
Chris@82 8371 # Try looking first in the location we're being installed to.
Chris@82 8372 if test -n "$inst_prefix_dir"; then
Chris@82 8373 case $libdir in
Chris@82 8374 [\\/]*)
Chris@82 8375 func_append add_dir " -L$inst_prefix_dir$libdir"
Chris@82 8376 ;;
Chris@82 8377 esac
Chris@82 8378 fi
Chris@82 8379 add=-l$name
Chris@82 8380 fi
Chris@82 8381
Chris@82 8382 if test prog = "$linkmode"; then
Chris@82 8383 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
Chris@82 8384 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
Chris@82 8385 else
Chris@82 8386 test -n "$add_dir" && deplibs="$add_dir $deplibs"
Chris@82 8387 test -n "$add" && deplibs="$add $deplibs"
Chris@82 8388 fi
Chris@82 8389 fi
Chris@82 8390 elif test prog = "$linkmode"; then
Chris@82 8391 # Here we assume that one of hardcode_direct or hardcode_minus_L
Chris@82 8392 # is not unsupported. This is valid on all known static and
Chris@82 8393 # shared platforms.
Chris@82 8394 if test unsupported != "$hardcode_direct"; then
Chris@82 8395 test -n "$old_library" && linklib=$old_library
Chris@82 8396 compile_deplibs="$dir/$linklib $compile_deplibs"
Chris@82 8397 finalize_deplibs="$dir/$linklib $finalize_deplibs"
Chris@82 8398 else
Chris@82 8399 compile_deplibs="-l$name -L$dir $compile_deplibs"
Chris@82 8400 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
Chris@82 8401 fi
Chris@82 8402 elif test yes = "$build_libtool_libs"; then
Chris@82 8403 # Not a shared library
Chris@82 8404 if test pass_all != "$deplibs_check_method"; then
Chris@82 8405 # We're trying link a shared library against a static one
Chris@82 8406 # but the system doesn't support it.
Chris@82 8407
Chris@82 8408 # Just print a warning and add the library to dependency_libs so
Chris@82 8409 # that the program can be linked against the static library.
Chris@82 8410 echo
Chris@82 8411 $ECHO "*** Warning: This system cannot link to static lib archive $lib."
Chris@82 8412 echo "*** I have the capability to make that library automatically link in when"
Chris@82 8413 echo "*** you link to this library. But I can only do this if you have a"
Chris@82 8414 echo "*** shared version of the library, which you do not appear to have."
Chris@82 8415 if test yes = "$module"; then
Chris@82 8416 echo "*** But as you try to build a module library, libtool will still create "
Chris@82 8417 echo "*** a static module, that should work as long as the dlopening application"
Chris@82 8418 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
Chris@82 8419 if test -z "$global_symbol_pipe"; then
Chris@82 8420 echo
Chris@82 8421 echo "*** However, this would only work if libtool was able to extract symbol"
Chris@82 8422 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
Chris@82 8423 echo "*** not find such a program. So, this module is probably useless."
Chris@82 8424 echo "*** 'nm' from GNU binutils and a full rebuild may help."
Chris@82 8425 fi
Chris@82 8426 if test no = "$build_old_libs"; then
Chris@82 8427 build_libtool_libs=module
Chris@82 8428 build_old_libs=yes
Chris@82 8429 else
Chris@82 8430 build_libtool_libs=no
Chris@82 8431 fi
Chris@82 8432 fi
Chris@82 8433 else
Chris@82 8434 deplibs="$dir/$old_library $deplibs"
Chris@82 8435 link_static=yes
Chris@82 8436 fi
Chris@82 8437 fi # link shared/static library?
Chris@82 8438
Chris@82 8439 if test lib = "$linkmode"; then
Chris@82 8440 if test -n "$dependency_libs" &&
Chris@82 8441 { test yes != "$hardcode_into_libs" ||
Chris@82 8442 test yes = "$build_old_libs" ||
Chris@82 8443 test yes = "$link_static"; }; then
Chris@82 8444 # Extract -R from dependency_libs
Chris@82 8445 temp_deplibs=
Chris@82 8446 for libdir in $dependency_libs; do
Chris@82 8447 case $libdir in
Chris@82 8448 -R*) func_stripname '-R' '' "$libdir"
Chris@82 8449 temp_xrpath=$func_stripname_result
Chris@82 8450 case " $xrpath " in
Chris@82 8451 *" $temp_xrpath "*) ;;
Chris@82 8452 *) func_append xrpath " $temp_xrpath";;
Chris@82 8453 esac;;
Chris@82 8454 *) func_append temp_deplibs " $libdir";;
Chris@82 8455 esac
Chris@82 8456 done
Chris@82 8457 dependency_libs=$temp_deplibs
Chris@82 8458 fi
Chris@82 8459
Chris@82 8460 func_append newlib_search_path " $absdir"
Chris@82 8461 # Link against this library
Chris@82 8462 test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
Chris@82 8463 # ... and its dependency_libs
Chris@82 8464 tmp_libs=
Chris@82 8465 for deplib in $dependency_libs; do
Chris@82 8466 newdependency_libs="$deplib $newdependency_libs"
Chris@82 8467 case $deplib in
Chris@82 8468 -L*) func_stripname '-L' '' "$deplib"
Chris@82 8469 func_resolve_sysroot "$func_stripname_result";;
Chris@82 8470 *) func_resolve_sysroot "$deplib" ;;
Chris@82 8471 esac
Chris@82 8472 if $opt_preserve_dup_deps; then
Chris@82 8473 case "$tmp_libs " in
Chris@82 8474 *" $func_resolve_sysroot_result "*)
Chris@82 8475 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
Chris@82 8476 esac
Chris@82 8477 fi
Chris@82 8478 func_append tmp_libs " $func_resolve_sysroot_result"
Chris@82 8479 done
Chris@82 8480
Chris@82 8481 if test no != "$link_all_deplibs"; then
Chris@82 8482 # Add the search paths of all dependency libraries
Chris@82 8483 for deplib in $dependency_libs; do
Chris@82 8484 path=
Chris@82 8485 case $deplib in
Chris@82 8486 -L*) path=$deplib ;;
Chris@82 8487 *.la)
Chris@82 8488 func_resolve_sysroot "$deplib"
Chris@82 8489 deplib=$func_resolve_sysroot_result
Chris@82 8490 func_dirname "$deplib" "" "."
Chris@82 8491 dir=$func_dirname_result
Chris@82 8492 # We need an absolute path.
Chris@82 8493 case $dir in
Chris@82 8494 [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
Chris@82 8495 *)
Chris@82 8496 absdir=`cd "$dir" && pwd`
Chris@82 8497 if test -z "$absdir"; then
Chris@82 8498 func_warning "cannot determine absolute directory name of '$dir'"
Chris@82 8499 absdir=$dir
Chris@82 8500 fi
Chris@82 8501 ;;
Chris@82 8502 esac
Chris@82 8503 if $GREP "^installed=no" $deplib > /dev/null; then
Chris@82 8504 case $host in
Chris@82 8505 *-*-darwin*)
Chris@82 8506 depdepl=
Chris@82 8507 eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
Chris@82 8508 if test -n "$deplibrary_names"; then
Chris@82 8509 for tmp in $deplibrary_names; do
Chris@82 8510 depdepl=$tmp
Chris@82 8511 done
Chris@82 8512 if test -f "$absdir/$objdir/$depdepl"; then
Chris@82 8513 depdepl=$absdir/$objdir/$depdepl
Chris@82 8514 darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
Chris@82 8515 if test -z "$darwin_install_name"; then
Chris@82 8516 darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
Chris@82 8517 fi
Chris@82 8518 func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
Chris@82 8519 func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
Chris@82 8520 path=
Chris@82 8521 fi
Chris@82 8522 fi
Chris@82 8523 ;;
Chris@82 8524 *)
Chris@82 8525 path=-L$absdir/$objdir
Chris@82 8526 ;;
Chris@82 8527 esac
Chris@82 8528 else
Chris@82 8529 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
Chris@82 8530 test -z "$libdir" && \
Chris@82 8531 func_fatal_error "'$deplib' is not a valid libtool archive"
Chris@82 8532 test "$absdir" != "$libdir" && \
Chris@82 8533 func_warning "'$deplib' seems to be moved"
Chris@82 8534
Chris@82 8535 path=-L$absdir
Chris@82 8536 fi
Chris@82 8537 ;;
Chris@82 8538 esac
Chris@82 8539 case " $deplibs " in
Chris@82 8540 *" $path "*) ;;
Chris@82 8541 *) deplibs="$path $deplibs" ;;
Chris@82 8542 esac
Chris@82 8543 done
Chris@82 8544 fi # link_all_deplibs != no
Chris@82 8545 fi # linkmode = lib
Chris@82 8546 done # for deplib in $libs
Chris@82 8547 if test link = "$pass"; then
Chris@82 8548 if test prog = "$linkmode"; then
Chris@82 8549 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
Chris@82 8550 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
Chris@82 8551 else
Chris@82 8552 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@82 8553 fi
Chris@82 8554 fi
Chris@82 8555 dependency_libs=$newdependency_libs
Chris@82 8556 if test dlpreopen = "$pass"; then
Chris@82 8557 # Link the dlpreopened libraries before other libraries
Chris@82 8558 for deplib in $save_deplibs; do
Chris@82 8559 deplibs="$deplib $deplibs"
Chris@82 8560 done
Chris@82 8561 fi
Chris@82 8562 if test dlopen != "$pass"; then
Chris@82 8563 test conv = "$pass" || {
Chris@82 8564 # Make sure lib_search_path contains only unique directories.
Chris@82 8565 lib_search_path=
Chris@82 8566 for dir in $newlib_search_path; do
Chris@82 8567 case "$lib_search_path " in
Chris@82 8568 *" $dir "*) ;;
Chris@82 8569 *) func_append lib_search_path " $dir" ;;
Chris@82 8570 esac
Chris@82 8571 done
Chris@82 8572 newlib_search_path=
Chris@82 8573 }
Chris@82 8574
Chris@82 8575 if test prog,link = "$linkmode,$pass"; then
Chris@82 8576 vars="compile_deplibs finalize_deplibs"
Chris@82 8577 else
Chris@82 8578 vars=deplibs
Chris@82 8579 fi
Chris@82 8580 for var in $vars dependency_libs; do
Chris@82 8581 # Add libraries to $var in reverse order
Chris@82 8582 eval tmp_libs=\"\$$var\"
Chris@82 8583 new_libs=
Chris@82 8584 for deplib in $tmp_libs; do
Chris@82 8585 # FIXME: Pedantically, this is the right thing to do, so
Chris@82 8586 # that some nasty dependency loop isn't accidentally
Chris@82 8587 # broken:
Chris@82 8588 #new_libs="$deplib $new_libs"
Chris@82 8589 # Pragmatically, this seems to cause very few problems in
Chris@82 8590 # practice:
Chris@82 8591 case $deplib in
Chris@82 8592 -L*) new_libs="$deplib $new_libs" ;;
Chris@82 8593 -R*) ;;
Chris@82 8594 *)
Chris@82 8595 # And here is the reason: when a library appears more
Chris@82 8596 # than once as an explicit dependence of a library, or
Chris@82 8597 # is implicitly linked in more than once by the
Chris@82 8598 # compiler, it is considered special, and multiple
Chris@82 8599 # occurrences thereof are not removed. Compare this
Chris@82 8600 # with having the same library being listed as a
Chris@82 8601 # dependency of multiple other libraries: in this case,
Chris@82 8602 # we know (pedantically, we assume) the library does not
Chris@82 8603 # need to be listed more than once, so we keep only the
Chris@82 8604 # last copy. This is not always right, but it is rare
Chris@82 8605 # enough that we require users that really mean to play
Chris@82 8606 # such unportable linking tricks to link the library
Chris@82 8607 # using -Wl,-lname, so that libtool does not consider it
Chris@82 8608 # for duplicate removal.
Chris@82 8609 case " $specialdeplibs " in
Chris@82 8610 *" $deplib "*) new_libs="$deplib $new_libs" ;;
Chris@82 8611 *)
Chris@82 8612 case " $new_libs " in
Chris@82 8613 *" $deplib "*) ;;
Chris@82 8614 *) new_libs="$deplib $new_libs" ;;
Chris@82 8615 esac
Chris@82 8616 ;;
Chris@82 8617 esac
Chris@82 8618 ;;
Chris@82 8619 esac
Chris@82 8620 done
Chris@82 8621 tmp_libs=
Chris@82 8622 for deplib in $new_libs; do
Chris@82 8623 case $deplib in
Chris@82 8624 -L*)
Chris@82 8625 case " $tmp_libs " in
Chris@82 8626 *" $deplib "*) ;;
Chris@82 8627 *) func_append tmp_libs " $deplib" ;;
Chris@82 8628 esac
Chris@82 8629 ;;
Chris@82 8630 *) func_append tmp_libs " $deplib" ;;
Chris@82 8631 esac
Chris@82 8632 done
Chris@82 8633 eval $var=\"$tmp_libs\"
Chris@82 8634 done # for var
Chris@82 8635 fi
Chris@82 8636
Chris@82 8637 # Add Sun CC postdeps if required:
Chris@82 8638 test CXX = "$tagname" && {
Chris@82 8639 case $host_os in
Chris@82 8640 linux*)
Chris@82 8641 case `$CC -V 2>&1 | sed 5q` in
Chris@82 8642 *Sun\ C*) # Sun C++ 5.9
Chris@82 8643 func_suncc_cstd_abi
Chris@82 8644
Chris@82 8645 if test no != "$suncc_use_cstd_abi"; then
Chris@82 8646 func_append postdeps ' -library=Cstd -library=Crun'
Chris@82 8647 fi
Chris@82 8648 ;;
Chris@82 8649 esac
Chris@82 8650 ;;
Chris@82 8651
Chris@82 8652 solaris*)
Chris@82 8653 func_cc_basename "$CC"
Chris@82 8654 case $func_cc_basename_result in
Chris@82 8655 CC* | sunCC*)
Chris@82 8656 func_suncc_cstd_abi
Chris@82 8657
Chris@82 8658 if test no != "$suncc_use_cstd_abi"; then
Chris@82 8659 func_append postdeps ' -library=Cstd -library=Crun'
Chris@82 8660 fi
Chris@82 8661 ;;
Chris@82 8662 esac
Chris@82 8663 ;;
Chris@82 8664 esac
Chris@82 8665 }
Chris@82 8666
Chris@82 8667 # Last step: remove runtime libs from dependency_libs
Chris@82 8668 # (they stay in deplibs)
Chris@82 8669 tmp_libs=
Chris@82 8670 for i in $dependency_libs; do
Chris@82 8671 case " $predeps $postdeps $compiler_lib_search_path " in
Chris@82 8672 *" $i "*)
Chris@82 8673 i=
Chris@82 8674 ;;
Chris@82 8675 esac
Chris@82 8676 if test -n "$i"; then
Chris@82 8677 func_append tmp_libs " $i"
Chris@82 8678 fi
Chris@82 8679 done
Chris@82 8680 dependency_libs=$tmp_libs
Chris@82 8681 done # for pass
Chris@82 8682 if test prog = "$linkmode"; then
Chris@82 8683 dlfiles=$newdlfiles
Chris@82 8684 fi
Chris@82 8685 if test prog = "$linkmode" || test lib = "$linkmode"; then
Chris@82 8686 dlprefiles=$newdlprefiles
Chris@82 8687 fi
Chris@82 8688
Chris@82 8689 case $linkmode in
Chris@82 8690 oldlib)
Chris@82 8691 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
Chris@82 8692 func_warning "'-dlopen' is ignored for archives"
Chris@82 8693 fi
Chris@82 8694
Chris@82 8695 case " $deplibs" in
Chris@82 8696 *\ -l* | *\ -L*)
Chris@82 8697 func_warning "'-l' and '-L' are ignored for archives" ;;
Chris@82 8698 esac
Chris@82 8699
Chris@82 8700 test -n "$rpath" && \
Chris@82 8701 func_warning "'-rpath' is ignored for archives"
Chris@82 8702
Chris@82 8703 test -n "$xrpath" && \
Chris@82 8704 func_warning "'-R' is ignored for archives"
Chris@82 8705
Chris@82 8706 test -n "$vinfo" && \
Chris@82 8707 func_warning "'-version-info/-version-number' is ignored for archives"
Chris@82 8708
Chris@82 8709 test -n "$release" && \
Chris@82 8710 func_warning "'-release' is ignored for archives"
Chris@82 8711
Chris@82 8712 test -n "$export_symbols$export_symbols_regex" && \
Chris@82 8713 func_warning "'-export-symbols' is ignored for archives"
Chris@82 8714
Chris@82 8715 # Now set the variables for building old libraries.
Chris@82 8716 build_libtool_libs=no
Chris@82 8717 oldlibs=$output
Chris@82 8718 func_append objs "$old_deplibs"
Chris@82 8719 ;;
Chris@82 8720
Chris@82 8721 lib)
Chris@82 8722 # Make sure we only generate libraries of the form 'libNAME.la'.
Chris@82 8723 case $outputname in
Chris@82 8724 lib*)
Chris@82 8725 func_stripname 'lib' '.la' "$outputname"
Chris@82 8726 name=$func_stripname_result
Chris@82 8727 eval shared_ext=\"$shrext_cmds\"
Chris@82 8728 eval libname=\"$libname_spec\"
Chris@82 8729 ;;
Chris@82 8730 *)
Chris@82 8731 test no = "$module" \
Chris@82 8732 && func_fatal_help "libtool library '$output' must begin with 'lib'"
Chris@82 8733
Chris@82 8734 if test no != "$need_lib_prefix"; then
Chris@82 8735 # Add the "lib" prefix for modules if required
Chris@82 8736 func_stripname '' '.la' "$outputname"
Chris@82 8737 name=$func_stripname_result
Chris@82 8738 eval shared_ext=\"$shrext_cmds\"
Chris@82 8739 eval libname=\"$libname_spec\"
Chris@82 8740 else
Chris@82 8741 func_stripname '' '.la' "$outputname"
Chris@82 8742 libname=$func_stripname_result
Chris@82 8743 fi
Chris@82 8744 ;;
Chris@82 8745 esac
Chris@82 8746
Chris@82 8747 if test -n "$objs"; then
Chris@82 8748 if test pass_all != "$deplibs_check_method"; then
Chris@82 8749 func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
Chris@82 8750 else
Chris@82 8751 echo
Chris@82 8752 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
Chris@82 8753 $ECHO "*** objects $objs is not portable!"
Chris@82 8754 func_append libobjs " $objs"
Chris@82 8755 fi
Chris@82 8756 fi
Chris@82 8757
Chris@82 8758 test no = "$dlself" \
Chris@82 8759 || func_warning "'-dlopen self' is ignored for libtool libraries"
Chris@82 8760
Chris@82 8761 set dummy $rpath
Chris@82 8762 shift
Chris@82 8763 test 1 -lt "$#" \
Chris@82 8764 && func_warning "ignoring multiple '-rpath's for a libtool library"
Chris@82 8765
Chris@82 8766 install_libdir=$1
Chris@82 8767
Chris@82 8768 oldlibs=
Chris@82 8769 if test -z "$rpath"; then
Chris@82 8770 if test yes = "$build_libtool_libs"; then
Chris@82 8771 # Building a libtool convenience library.
Chris@82 8772 # Some compilers have problems with a '.al' extension so
Chris@82 8773 # convenience libraries should have the same extension an
Chris@82 8774 # archive normally would.
Chris@82 8775 oldlibs="$output_objdir/$libname.$libext $oldlibs"
Chris@82 8776 build_libtool_libs=convenience
Chris@82 8777 build_old_libs=yes
Chris@82 8778 fi
Chris@82 8779
Chris@82 8780 test -n "$vinfo" && \
Chris@82 8781 func_warning "'-version-info/-version-number' is ignored for convenience libraries"
Chris@82 8782
Chris@82 8783 test -n "$release" && \
Chris@82 8784 func_warning "'-release' is ignored for convenience libraries"
Chris@82 8785 else
Chris@82 8786
Chris@82 8787 # Parse the version information argument.
Chris@82 8788 save_ifs=$IFS; IFS=:
Chris@82 8789 set dummy $vinfo 0 0 0
Chris@82 8790 shift
Chris@82 8791 IFS=$save_ifs
Chris@82 8792
Chris@82 8793 test -n "$7" && \
Chris@82 8794 func_fatal_help "too many parameters to '-version-info'"
Chris@82 8795
Chris@82 8796 # convert absolute version numbers to libtool ages
Chris@82 8797 # this retains compatibility with .la files and attempts
Chris@82 8798 # to make the code below a bit more comprehensible
Chris@82 8799
Chris@82 8800 case $vinfo_number in
Chris@82 8801 yes)
Chris@82 8802 number_major=$1
Chris@82 8803 number_minor=$2
Chris@82 8804 number_revision=$3
Chris@82 8805 #
Chris@82 8806 # There are really only two kinds -- those that
Chris@82 8807 # use the current revision as the major version
Chris@82 8808 # and those that subtract age and use age as
Chris@82 8809 # a minor version. But, then there is irix
Chris@82 8810 # that has an extra 1 added just for fun
Chris@82 8811 #
Chris@82 8812 case $version_type in
Chris@82 8813 # correct linux to gnu/linux during the next big refactor
Chris@82 8814 darwin|freebsd-elf|linux|osf|windows|none)
Chris@82 8815 func_arith $number_major + $number_minor
Chris@82 8816 current=$func_arith_result
Chris@82 8817 age=$number_minor
Chris@82 8818 revision=$number_revision
Chris@82 8819 ;;
Chris@82 8820 freebsd-aout|qnx|sunos)
Chris@82 8821 current=$number_major
Chris@82 8822 revision=$number_minor
Chris@82 8823 age=0
Chris@82 8824 ;;
Chris@82 8825 irix|nonstopux)
Chris@82 8826 func_arith $number_major + $number_minor
Chris@82 8827 current=$func_arith_result
Chris@82 8828 age=$number_minor
Chris@82 8829 revision=$number_minor
Chris@82 8830 lt_irix_increment=no
Chris@82 8831 ;;
Chris@82 8832 *)
Chris@82 8833 func_fatal_configuration "$modename: unknown library version type '$version_type'"
Chris@82 8834 ;;
Chris@82 8835 esac
Chris@82 8836 ;;
Chris@82 8837 no)
Chris@82 8838 current=$1
Chris@82 8839 revision=$2
Chris@82 8840 age=$3
Chris@82 8841 ;;
Chris@82 8842 esac
Chris@82 8843
Chris@82 8844 # Check that each of the things are valid numbers.
Chris@82 8845 case $current in
Chris@82 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@82 8847 *)
Chris@82 8848 func_error "CURRENT '$current' must be a nonnegative integer"
Chris@82 8849 func_fatal_error "'$vinfo' is not valid version information"
Chris@82 8850 ;;
Chris@82 8851 esac
Chris@82 8852
Chris@82 8853 case $revision in
Chris@82 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@82 8855 *)
Chris@82 8856 func_error "REVISION '$revision' must be a nonnegative integer"
Chris@82 8857 func_fatal_error "'$vinfo' is not valid version information"
Chris@82 8858 ;;
Chris@82 8859 esac
Chris@82 8860
Chris@82 8861 case $age in
Chris@82 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@82 8863 *)
Chris@82 8864 func_error "AGE '$age' must be a nonnegative integer"
Chris@82 8865 func_fatal_error "'$vinfo' is not valid version information"
Chris@82 8866 ;;
Chris@82 8867 esac
Chris@82 8868
Chris@82 8869 if test "$age" -gt "$current"; then
Chris@82 8870 func_error "AGE '$age' is greater than the current interface number '$current'"
Chris@82 8871 func_fatal_error "'$vinfo' is not valid version information"
Chris@82 8872 fi
Chris@82 8873
Chris@82 8874 # Calculate the version variables.
Chris@82 8875 major=
Chris@82 8876 versuffix=
Chris@82 8877 verstring=
Chris@82 8878 case $version_type in
Chris@82 8879 none) ;;
Chris@82 8880
Chris@82 8881 darwin)
Chris@82 8882 # Like Linux, but with the current version available in
Chris@82 8883 # verstring for coding it into the library header
Chris@82 8884 func_arith $current - $age
Chris@82 8885 major=.$func_arith_result
Chris@82 8886 versuffix=$major.$age.$revision
Chris@82 8887 # Darwin ld doesn't like 0 for these options...
Chris@82 8888 func_arith $current + 1
Chris@82 8889 minor_current=$func_arith_result
Chris@82 8890 xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
Chris@82 8891 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
Chris@82 8892 # On Darwin other compilers
Chris@82 8893 case $CC in
Chris@82 8894 nagfor*)
Chris@82 8895 verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
Chris@82 8896 ;;
Chris@82 8897 *)
Chris@82 8898 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
Chris@82 8899 ;;
Chris@82 8900 esac
Chris@82 8901 ;;
Chris@82 8902
Chris@82 8903 freebsd-aout)
Chris@82 8904 major=.$current
Chris@82 8905 versuffix=.$current.$revision
Chris@82 8906 ;;
Chris@82 8907
Chris@82 8908 freebsd-elf)
Chris@82 8909 func_arith $current - $age
Chris@82 8910 major=.$func_arith_result
Chris@82 8911 versuffix=$major.$age.$revision
Chris@82 8912 ;;
Chris@82 8913
Chris@82 8914 irix | nonstopux)
Chris@82 8915 if test no = "$lt_irix_increment"; then
Chris@82 8916 func_arith $current - $age
Chris@82 8917 else
Chris@82 8918 func_arith $current - $age + 1
Chris@82 8919 fi
Chris@82 8920 major=$func_arith_result
Chris@82 8921
Chris@82 8922 case $version_type in
Chris@82 8923 nonstopux) verstring_prefix=nonstopux ;;
Chris@82 8924 *) verstring_prefix=sgi ;;
Chris@82 8925 esac
Chris@82 8926 verstring=$verstring_prefix$major.$revision
Chris@82 8927
Chris@82 8928 # Add in all the interfaces that we are compatible with.
Chris@82 8929 loop=$revision
Chris@82 8930 while test 0 -ne "$loop"; do
Chris@82 8931 func_arith $revision - $loop
Chris@82 8932 iface=$func_arith_result
Chris@82 8933 func_arith $loop - 1
Chris@82 8934 loop=$func_arith_result
Chris@82 8935 verstring=$verstring_prefix$major.$iface:$verstring
Chris@82 8936 done
Chris@82 8937
Chris@82 8938 # Before this point, $major must not contain '.'.
Chris@82 8939 major=.$major
Chris@82 8940 versuffix=$major.$revision
Chris@82 8941 ;;
Chris@82 8942
Chris@82 8943 linux) # correct to gnu/linux during the next big refactor
Chris@82 8944 func_arith $current - $age
Chris@82 8945 major=.$func_arith_result
Chris@82 8946 versuffix=$major.$age.$revision
Chris@82 8947 ;;
Chris@82 8948
Chris@82 8949 osf)
Chris@82 8950 func_arith $current - $age
Chris@82 8951 major=.$func_arith_result
Chris@82 8952 versuffix=.$current.$age.$revision
Chris@82 8953 verstring=$current.$age.$revision
Chris@82 8954
Chris@82 8955 # Add in all the interfaces that we are compatible with.
Chris@82 8956 loop=$age
Chris@82 8957 while test 0 -ne "$loop"; do
Chris@82 8958 func_arith $current - $loop
Chris@82 8959 iface=$func_arith_result
Chris@82 8960 func_arith $loop - 1
Chris@82 8961 loop=$func_arith_result
Chris@82 8962 verstring=$verstring:$iface.0
Chris@82 8963 done
Chris@82 8964
Chris@82 8965 # Make executables depend on our current version.
Chris@82 8966 func_append verstring ":$current.0"
Chris@82 8967 ;;
Chris@82 8968
Chris@82 8969 qnx)
Chris@82 8970 major=.$current
Chris@82 8971 versuffix=.$current
Chris@82 8972 ;;
Chris@82 8973
Chris@82 8974 sco)
Chris@82 8975 major=.$current
Chris@82 8976 versuffix=.$current
Chris@82 8977 ;;
Chris@82 8978
Chris@82 8979 sunos)
Chris@82 8980 major=.$current
Chris@82 8981 versuffix=.$current.$revision
Chris@82 8982 ;;
Chris@82 8983
Chris@82 8984 windows)
Chris@82 8985 # Use '-' rather than '.', since we only want one
Chris@82 8986 # extension on DOS 8.3 file systems.
Chris@82 8987 func_arith $current - $age
Chris@82 8988 major=$func_arith_result
Chris@82 8989 versuffix=-$major
Chris@82 8990 ;;
Chris@82 8991
Chris@82 8992 *)
Chris@82 8993 func_fatal_configuration "unknown library version type '$version_type'"
Chris@82 8994 ;;
Chris@82 8995 esac
Chris@82 8996
Chris@82 8997 # Clear the version info if we defaulted, and they specified a release.
Chris@82 8998 if test -z "$vinfo" && test -n "$release"; then
Chris@82 8999 major=
Chris@82 9000 case $version_type in
Chris@82 9001 darwin)
Chris@82 9002 # we can't check for "0.0" in archive_cmds due to quoting
Chris@82 9003 # problems, so we reset it completely
Chris@82 9004 verstring=
Chris@82 9005 ;;
Chris@82 9006 *)
Chris@82 9007 verstring=0.0
Chris@82 9008 ;;
Chris@82 9009 esac
Chris@82 9010 if test no = "$need_version"; then
Chris@82 9011 versuffix=
Chris@82 9012 else
Chris@82 9013 versuffix=.0.0
Chris@82 9014 fi
Chris@82 9015 fi
Chris@82 9016
Chris@82 9017 # Remove version info from name if versioning should be avoided
Chris@82 9018 if test yes,no = "$avoid_version,$need_version"; then
Chris@82 9019 major=
Chris@82 9020 versuffix=
Chris@82 9021 verstring=
Chris@82 9022 fi
Chris@82 9023
Chris@82 9024 # Check to see if the archive will have undefined symbols.
Chris@82 9025 if test yes = "$allow_undefined"; then
Chris@82 9026 if test unsupported = "$allow_undefined_flag"; then
Chris@82 9027 if test yes = "$build_old_libs"; then
Chris@82 9028 func_warning "undefined symbols not allowed in $host shared libraries; building static only"
Chris@82 9029 build_libtool_libs=no
Chris@82 9030 else
Chris@82 9031 func_fatal_error "can't build $host shared library unless -no-undefined is specified"
Chris@82 9032 fi
Chris@82 9033 fi
Chris@82 9034 else
Chris@82 9035 # Don't allow undefined symbols.
Chris@82 9036 allow_undefined_flag=$no_undefined_flag
Chris@82 9037 fi
Chris@82 9038
Chris@82 9039 fi
Chris@82 9040
Chris@82 9041 func_generate_dlsyms "$libname" "$libname" :
Chris@82 9042 func_append libobjs " $symfileobj"
Chris@82 9043 test " " = "$libobjs" && libobjs=
Chris@82 9044
Chris@82 9045 if test relink != "$opt_mode"; then
Chris@82 9046 # Remove our outputs, but don't remove object files since they
Chris@82 9047 # may have been created when compiling PIC objects.
Chris@82 9048 removelist=
Chris@82 9049 tempremovelist=`$ECHO "$output_objdir/*"`
Chris@82 9050 for p in $tempremovelist; do
Chris@82 9051 case $p in
Chris@82 9052 *.$objext | *.gcno)
Chris@82 9053 ;;
Chris@82 9054 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
Chris@82 9055 if test -n "$precious_files_regex"; then
Chris@82 9056 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
Chris@82 9057 then
Chris@82 9058 continue
Chris@82 9059 fi
Chris@82 9060 fi
Chris@82 9061 func_append removelist " $p"
Chris@82 9062 ;;
Chris@82 9063 *) ;;
Chris@82 9064 esac
Chris@82 9065 done
Chris@82 9066 test -n "$removelist" && \
Chris@82 9067 func_show_eval "${RM}r \$removelist"
Chris@82 9068 fi
Chris@82 9069
Chris@82 9070 # Now set the variables for building old libraries.
Chris@82 9071 if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
Chris@82 9072 func_append oldlibs " $output_objdir/$libname.$libext"
Chris@82 9073
Chris@82 9074 # Transform .lo files to .o files.
Chris@82 9075 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
Chris@82 9076 fi
Chris@82 9077
Chris@82 9078 # Eliminate all temporary directories.
Chris@82 9079 #for path in $notinst_path; do
Chris@82 9080 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
Chris@82 9081 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
Chris@82 9082 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
Chris@82 9083 #done
Chris@82 9084
Chris@82 9085 if test -n "$xrpath"; then
Chris@82 9086 # If the user specified any rpath flags, then add them.
Chris@82 9087 temp_xrpath=
Chris@82 9088 for libdir in $xrpath; do
Chris@82 9089 func_replace_sysroot "$libdir"
Chris@82 9090 func_append temp_xrpath " -R$func_replace_sysroot_result"
Chris@82 9091 case "$finalize_rpath " in
Chris@82 9092 *" $libdir "*) ;;
Chris@82 9093 *) func_append finalize_rpath " $libdir" ;;
Chris@82 9094 esac
Chris@82 9095 done
Chris@82 9096 if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
Chris@82 9097 dependency_libs="$temp_xrpath $dependency_libs"
Chris@82 9098 fi
Chris@82 9099 fi
Chris@82 9100
Chris@82 9101 # Make sure dlfiles contains only unique files that won't be dlpreopened
Chris@82 9102 old_dlfiles=$dlfiles
Chris@82 9103 dlfiles=
Chris@82 9104 for lib in $old_dlfiles; do
Chris@82 9105 case " $dlprefiles $dlfiles " in
Chris@82 9106 *" $lib "*) ;;
Chris@82 9107 *) func_append dlfiles " $lib" ;;
Chris@82 9108 esac
Chris@82 9109 done
Chris@82 9110
Chris@82 9111 # Make sure dlprefiles contains only unique files
Chris@82 9112 old_dlprefiles=$dlprefiles
Chris@82 9113 dlprefiles=
Chris@82 9114 for lib in $old_dlprefiles; do
Chris@82 9115 case "$dlprefiles " in
Chris@82 9116 *" $lib "*) ;;
Chris@82 9117 *) func_append dlprefiles " $lib" ;;
Chris@82 9118 esac
Chris@82 9119 done
Chris@82 9120
Chris@82 9121 if test yes = "$build_libtool_libs"; then
Chris@82 9122 if test -n "$rpath"; then
Chris@82 9123 case $host in
Chris@82 9124 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
Chris@82 9125 # these systems don't actually have a c library (as such)!
Chris@82 9126 ;;
Chris@82 9127 *-*-rhapsody* | *-*-darwin1.[012])
Chris@82 9128 # Rhapsody C library is in the System framework
Chris@82 9129 func_append deplibs " System.ltframework"
Chris@82 9130 ;;
Chris@82 9131 *-*-netbsd*)
Chris@82 9132 # Don't link with libc until the a.out ld.so is fixed.
Chris@82 9133 ;;
Chris@82 9134 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
Chris@82 9135 # Do not include libc due to us having libc/libc_r.
Chris@82 9136 ;;
Chris@82 9137 *-*-sco3.2v5* | *-*-sco5v6*)
Chris@82 9138 # Causes problems with __ctype
Chris@82 9139 ;;
Chris@82 9140 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
Chris@82 9141 # Compiler inserts libc in the correct place for threads to work
Chris@82 9142 ;;
Chris@82 9143 *)
Chris@82 9144 # Add libc to deplibs on all other systems if necessary.
Chris@82 9145 if test yes = "$build_libtool_need_lc"; then
Chris@82 9146 func_append deplibs " -lc"
Chris@82 9147 fi
Chris@82 9148 ;;
Chris@82 9149 esac
Chris@82 9150 fi
Chris@82 9151
Chris@82 9152 # Transform deplibs into only deplibs that can be linked in shared.
Chris@82 9153 name_save=$name
Chris@82 9154 libname_save=$libname
Chris@82 9155 release_save=$release
Chris@82 9156 versuffix_save=$versuffix
Chris@82 9157 major_save=$major
Chris@82 9158 # I'm not sure if I'm treating the release correctly. I think
Chris@82 9159 # release should show up in the -l (ie -lgmp5) so we don't want to
Chris@82 9160 # add it in twice. Is that correct?
Chris@82 9161 release=
Chris@82 9162 versuffix=
Chris@82 9163 major=
Chris@82 9164 newdeplibs=
Chris@82 9165 droppeddeps=no
Chris@82 9166 case $deplibs_check_method in
Chris@82 9167 pass_all)
Chris@82 9168 # Don't check for shared/static. Everything works.
Chris@82 9169 # This might be a little naive. We might want to check
Chris@82 9170 # whether the library exists or not. But this is on
Chris@82 9171 # osf3 & osf4 and I'm not really sure... Just
Chris@82 9172 # implementing what was already the behavior.
Chris@82 9173 newdeplibs=$deplibs
Chris@82 9174 ;;
Chris@82 9175 test_compile)
Chris@82 9176 # This code stresses the "libraries are programs" paradigm to its
Chris@82 9177 # limits. Maybe even breaks it. We compile a program, linking it
Chris@82 9178 # against the deplibs as a proxy for the library. Then we can check
Chris@82 9179 # whether they linked in statically or dynamically with ldd.
Chris@82 9180 $opt_dry_run || $RM conftest.c
Chris@82 9181 cat > conftest.c <<EOF
Chris@82 9182 int main() { return 0; }
Chris@82 9183 EOF
Chris@82 9184 $opt_dry_run || $RM conftest
Chris@82 9185 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
Chris@82 9186 ldd_output=`ldd conftest`
Chris@82 9187 for i in $deplibs; do
Chris@82 9188 case $i in
Chris@82 9189 -l*)
Chris@82 9190 func_stripname -l '' "$i"
Chris@82 9191 name=$func_stripname_result
Chris@82 9192 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@82 9193 case " $predeps $postdeps " in
Chris@82 9194 *" $i "*)
Chris@82 9195 func_append newdeplibs " $i"
Chris@82 9196 i=
Chris@82 9197 ;;
Chris@82 9198 esac
Chris@82 9199 fi
Chris@82 9200 if test -n "$i"; then
Chris@82 9201 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@82 9202 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
Chris@82 9203 set dummy $deplib_matches; shift
Chris@82 9204 deplib_match=$1
Chris@82 9205 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
Chris@82 9206 func_append newdeplibs " $i"
Chris@82 9207 else
Chris@82 9208 droppeddeps=yes
Chris@82 9209 echo
Chris@82 9210 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
Chris@82 9211 echo "*** I have the capability to make that library automatically link in when"
Chris@82 9212 echo "*** you link to this library. But I can only do this if you have a"
Chris@82 9213 echo "*** shared version of the library, which I believe you do not have"
Chris@82 9214 echo "*** because a test_compile did reveal that the linker did not use it for"
Chris@82 9215 echo "*** its dynamic dependency list that programs get resolved with at runtime."
Chris@82 9216 fi
Chris@82 9217 fi
Chris@82 9218 ;;
Chris@82 9219 *)
Chris@82 9220 func_append newdeplibs " $i"
Chris@82 9221 ;;
Chris@82 9222 esac
Chris@82 9223 done
Chris@82 9224 else
Chris@82 9225 # Error occurred in the first compile. Let's try to salvage
Chris@82 9226 # the situation: Compile a separate program for each library.
Chris@82 9227 for i in $deplibs; do
Chris@82 9228 case $i in
Chris@82 9229 -l*)
Chris@82 9230 func_stripname -l '' "$i"
Chris@82 9231 name=$func_stripname_result
Chris@82 9232 $opt_dry_run || $RM conftest
Chris@82 9233 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
Chris@82 9234 ldd_output=`ldd conftest`
Chris@82 9235 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@82 9236 case " $predeps $postdeps " in
Chris@82 9237 *" $i "*)
Chris@82 9238 func_append newdeplibs " $i"
Chris@82 9239 i=
Chris@82 9240 ;;
Chris@82 9241 esac
Chris@82 9242 fi
Chris@82 9243 if test -n "$i"; then
Chris@82 9244 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@82 9245 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
Chris@82 9246 set dummy $deplib_matches; shift
Chris@82 9247 deplib_match=$1
Chris@82 9248 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
Chris@82 9249 func_append newdeplibs " $i"
Chris@82 9250 else
Chris@82 9251 droppeddeps=yes
Chris@82 9252 echo
Chris@82 9253 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
Chris@82 9254 echo "*** I have the capability to make that library automatically link in when"
Chris@82 9255 echo "*** you link to this library. But I can only do this if you have a"
Chris@82 9256 echo "*** shared version of the library, which you do not appear to have"
Chris@82 9257 echo "*** because a test_compile did reveal that the linker did not use this one"
Chris@82 9258 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
Chris@82 9259 fi
Chris@82 9260 fi
Chris@82 9261 else
Chris@82 9262 droppeddeps=yes
Chris@82 9263 echo
Chris@82 9264 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
Chris@82 9265 echo "*** make it link in! You will probably need to install it or some"
Chris@82 9266 echo "*** library that it depends on before this library will be fully"
Chris@82 9267 echo "*** functional. Installing it before continuing would be even better."
Chris@82 9268 fi
Chris@82 9269 ;;
Chris@82 9270 *)
Chris@82 9271 func_append newdeplibs " $i"
Chris@82 9272 ;;
Chris@82 9273 esac
Chris@82 9274 done
Chris@82 9275 fi
Chris@82 9276 ;;
Chris@82 9277 file_magic*)
Chris@82 9278 set dummy $deplibs_check_method; shift
Chris@82 9279 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Chris@82 9280 for a_deplib in $deplibs; do
Chris@82 9281 case $a_deplib in
Chris@82 9282 -l*)
Chris@82 9283 func_stripname -l '' "$a_deplib"
Chris@82 9284 name=$func_stripname_result
Chris@82 9285 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@82 9286 case " $predeps $postdeps " in
Chris@82 9287 *" $a_deplib "*)
Chris@82 9288 func_append newdeplibs " $a_deplib"
Chris@82 9289 a_deplib=
Chris@82 9290 ;;
Chris@82 9291 esac
Chris@82 9292 fi
Chris@82 9293 if test -n "$a_deplib"; then
Chris@82 9294 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@82 9295 if test -n "$file_magic_glob"; then
Chris@82 9296 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
Chris@82 9297 else
Chris@82 9298 libnameglob=$libname
Chris@82 9299 fi
Chris@82 9300 test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
Chris@82 9301 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
Chris@82 9302 if test yes = "$want_nocaseglob"; then
Chris@82 9303 shopt -s nocaseglob
Chris@82 9304 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
Chris@82 9305 $nocaseglob
Chris@82 9306 else
Chris@82 9307 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
Chris@82 9308 fi
Chris@82 9309 for potent_lib in $potential_libs; do
Chris@82 9310 # Follow soft links.
Chris@82 9311 if ls -lLd "$potent_lib" 2>/dev/null |
Chris@82 9312 $GREP " -> " >/dev/null; then
Chris@82 9313 continue
Chris@82 9314 fi
Chris@82 9315 # The statement above tries to avoid entering an
Chris@82 9316 # endless loop below, in case of cyclic links.
Chris@82 9317 # We might still enter an endless loop, since a link
Chris@82 9318 # loop can be closed while we follow links,
Chris@82 9319 # but so what?
Chris@82 9320 potlib=$potent_lib
Chris@82 9321 while test -h "$potlib" 2>/dev/null; do
Chris@82 9322 potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
Chris@82 9323 case $potliblink in
Chris@82 9324 [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
Chris@82 9325 *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
Chris@82 9326 esac
Chris@82 9327 done
Chris@82 9328 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
Chris@82 9329 $SED -e 10q |
Chris@82 9330 $EGREP "$file_magic_regex" > /dev/null; then
Chris@82 9331 func_append newdeplibs " $a_deplib"
Chris@82 9332 a_deplib=
Chris@82 9333 break 2
Chris@82 9334 fi
Chris@82 9335 done
Chris@82 9336 done
Chris@82 9337 fi
Chris@82 9338 if test -n "$a_deplib"; then
Chris@82 9339 droppeddeps=yes
Chris@82 9340 echo
Chris@82 9341 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
Chris@82 9342 echo "*** I have the capability to make that library automatically link in when"
Chris@82 9343 echo "*** you link to this library. But I can only do this if you have a"
Chris@82 9344 echo "*** shared version of the library, which you do not appear to have"
Chris@82 9345 echo "*** because I did check the linker path looking for a file starting"
Chris@82 9346 if test -z "$potlib"; then
Chris@82 9347 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
Chris@82 9348 else
Chris@82 9349 $ECHO "*** with $libname and none of the candidates passed a file format test"
Chris@82 9350 $ECHO "*** using a file magic. Last file checked: $potlib"
Chris@82 9351 fi
Chris@82 9352 fi
Chris@82 9353 ;;
Chris@82 9354 *)
Chris@82 9355 # Add a -L argument.
Chris@82 9356 func_append newdeplibs " $a_deplib"
Chris@82 9357 ;;
Chris@82 9358 esac
Chris@82 9359 done # Gone through all deplibs.
Chris@82 9360 ;;
Chris@82 9361 match_pattern*)
Chris@82 9362 set dummy $deplibs_check_method; shift
Chris@82 9363 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
Chris@82 9364 for a_deplib in $deplibs; do
Chris@82 9365 case $a_deplib in
Chris@82 9366 -l*)
Chris@82 9367 func_stripname -l '' "$a_deplib"
Chris@82 9368 name=$func_stripname_result
Chris@82 9369 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@82 9370 case " $predeps $postdeps " in
Chris@82 9371 *" $a_deplib "*)
Chris@82 9372 func_append newdeplibs " $a_deplib"
Chris@82 9373 a_deplib=
Chris@82 9374 ;;
Chris@82 9375 esac
Chris@82 9376 fi
Chris@82 9377 if test -n "$a_deplib"; then
Chris@82 9378 libname=`eval "\\$ECHO \"$libname_spec\""`
Chris@82 9379 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
Chris@82 9380 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
Chris@82 9381 for potent_lib in $potential_libs; do
Chris@82 9382 potlib=$potent_lib # see symlink-check above in file_magic test
Chris@82 9383 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
Chris@82 9384 $EGREP "$match_pattern_regex" > /dev/null; then
Chris@82 9385 func_append newdeplibs " $a_deplib"
Chris@82 9386 a_deplib=
Chris@82 9387 break 2
Chris@82 9388 fi
Chris@82 9389 done
Chris@82 9390 done
Chris@82 9391 fi
Chris@82 9392 if test -n "$a_deplib"; then
Chris@82 9393 droppeddeps=yes
Chris@82 9394 echo
Chris@82 9395 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
Chris@82 9396 echo "*** I have the capability to make that library automatically link in when"
Chris@82 9397 echo "*** you link to this library. But I can only do this if you have a"
Chris@82 9398 echo "*** shared version of the library, which you do not appear to have"
Chris@82 9399 echo "*** because I did check the linker path looking for a file starting"
Chris@82 9400 if test -z "$potlib"; then
Chris@82 9401 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
Chris@82 9402 else
Chris@82 9403 $ECHO "*** with $libname and none of the candidates passed a file format test"
Chris@82 9404 $ECHO "*** using a regex pattern. Last file checked: $potlib"
Chris@82 9405 fi
Chris@82 9406 fi
Chris@82 9407 ;;
Chris@82 9408 *)
Chris@82 9409 # Add a -L argument.
Chris@82 9410 func_append newdeplibs " $a_deplib"
Chris@82 9411 ;;
Chris@82 9412 esac
Chris@82 9413 done # Gone through all deplibs.
Chris@82 9414 ;;
Chris@82 9415 none | unknown | *)
Chris@82 9416 newdeplibs=
Chris@82 9417 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
Chris@82 9418 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
Chris@82 9419 for i in $predeps $postdeps; do
Chris@82 9420 # can't use Xsed below, because $i might contain '/'
Chris@82 9421 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
Chris@82 9422 done
Chris@82 9423 fi
Chris@82 9424 case $tmp_deplibs in
Chris@82 9425 *[!\ \ ]*)
Chris@82 9426 echo
Chris@82 9427 if test none = "$deplibs_check_method"; then
Chris@82 9428 echo "*** Warning: inter-library dependencies are not supported in this platform."
Chris@82 9429 else
Chris@82 9430 echo "*** Warning: inter-library dependencies are not known to be supported."
Chris@82 9431 fi
Chris@82 9432 echo "*** All declared inter-library dependencies are being dropped."
Chris@82 9433 droppeddeps=yes
Chris@82 9434 ;;
Chris@82 9435 esac
Chris@82 9436 ;;
Chris@82 9437 esac
Chris@82 9438 versuffix=$versuffix_save
Chris@82 9439 major=$major_save
Chris@82 9440 release=$release_save
Chris@82 9441 libname=$libname_save
Chris@82 9442 name=$name_save
Chris@82 9443
Chris@82 9444 case $host in
Chris@82 9445 *-*-rhapsody* | *-*-darwin1.[012])
Chris@82 9446 # On Rhapsody replace the C library with the System framework
Chris@82 9447 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
Chris@82 9448 ;;
Chris@82 9449 esac
Chris@82 9450
Chris@82 9451 if test yes = "$droppeddeps"; then
Chris@82 9452 if test yes = "$module"; then
Chris@82 9453 echo
Chris@82 9454 echo "*** Warning: libtool could not satisfy all declared inter-library"
Chris@82 9455 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
Chris@82 9456 echo "*** a static module, that should work as long as the dlopening"
Chris@82 9457 echo "*** application is linked with the -dlopen flag."
Chris@82 9458 if test -z "$global_symbol_pipe"; then
Chris@82 9459 echo
Chris@82 9460 echo "*** However, this would only work if libtool was able to extract symbol"
Chris@82 9461 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
Chris@82 9462 echo "*** not find such a program. So, this module is probably useless."
Chris@82 9463 echo "*** 'nm' from GNU binutils and a full rebuild may help."
Chris@82 9464 fi
Chris@82 9465 if test no = "$build_old_libs"; then
Chris@82 9466 oldlibs=$output_objdir/$libname.$libext
Chris@82 9467 build_libtool_libs=module
Chris@82 9468 build_old_libs=yes
Chris@82 9469 else
Chris@82 9470 build_libtool_libs=no
Chris@82 9471 fi
Chris@82 9472 else
Chris@82 9473 echo "*** The inter-library dependencies that have been dropped here will be"
Chris@82 9474 echo "*** automatically added whenever a program is linked with this library"
Chris@82 9475 echo "*** or is declared to -dlopen it."
Chris@82 9476
Chris@82 9477 if test no = "$allow_undefined"; then
Chris@82 9478 echo
Chris@82 9479 echo "*** Since this library must not contain undefined symbols,"
Chris@82 9480 echo "*** because either the platform does not support them or"
Chris@82 9481 echo "*** it was explicitly requested with -no-undefined,"
Chris@82 9482 echo "*** libtool will only create a static version of it."
Chris@82 9483 if test no = "$build_old_libs"; then
Chris@82 9484 oldlibs=$output_objdir/$libname.$libext
Chris@82 9485 build_libtool_libs=module
Chris@82 9486 build_old_libs=yes
Chris@82 9487 else
Chris@82 9488 build_libtool_libs=no
Chris@82 9489 fi
Chris@82 9490 fi
Chris@82 9491 fi
Chris@82 9492 fi
Chris@82 9493 # Done checking deplibs!
Chris@82 9494 deplibs=$newdeplibs
Chris@82 9495 fi
Chris@82 9496 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
Chris@82 9497 case $host in
Chris@82 9498 *-*-darwin*)
Chris@82 9499 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@82 9500 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@82 9501 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@82 9502 ;;
Chris@82 9503 esac
Chris@82 9504
Chris@82 9505 # move library search paths that coincide with paths to not yet
Chris@82 9506 # installed libraries to the beginning of the library search list
Chris@82 9507 new_libs=
Chris@82 9508 for path in $notinst_path; do
Chris@82 9509 case " $new_libs " in
Chris@82 9510 *" -L$path/$objdir "*) ;;
Chris@82 9511 *)
Chris@82 9512 case " $deplibs " in
Chris@82 9513 *" -L$path/$objdir "*)
Chris@82 9514 func_append new_libs " -L$path/$objdir" ;;
Chris@82 9515 esac
Chris@82 9516 ;;
Chris@82 9517 esac
Chris@82 9518 done
Chris@82 9519 for deplib in $deplibs; do
Chris@82 9520 case $deplib in
Chris@82 9521 -L*)
Chris@82 9522 case " $new_libs " in
Chris@82 9523 *" $deplib "*) ;;
Chris@82 9524 *) func_append new_libs " $deplib" ;;
Chris@82 9525 esac
Chris@82 9526 ;;
Chris@82 9527 *) func_append new_libs " $deplib" ;;
Chris@82 9528 esac
Chris@82 9529 done
Chris@82 9530 deplibs=$new_libs
Chris@82 9531
Chris@82 9532 # All the library-specific variables (install_libdir is set above).
Chris@82 9533 library_names=
Chris@82 9534 old_library=
Chris@82 9535 dlname=
Chris@82 9536
Chris@82 9537 # Test again, we may have decided not to build it any more
Chris@82 9538 if test yes = "$build_libtool_libs"; then
Chris@82 9539 # Remove $wl instances when linking with ld.
Chris@82 9540 # FIXME: should test the right _cmds variable.
Chris@82 9541 case $archive_cmds in
Chris@82 9542 *\$LD\ *) wl= ;;
Chris@82 9543 esac
Chris@82 9544 if test yes = "$hardcode_into_libs"; then
Chris@82 9545 # Hardcode the library paths
Chris@82 9546 hardcode_libdirs=
Chris@82 9547 dep_rpath=
Chris@82 9548 rpath=$finalize_rpath
Chris@82 9549 test relink = "$opt_mode" || rpath=$compile_rpath$rpath
Chris@82 9550 for libdir in $rpath; do
Chris@82 9551 if test -n "$hardcode_libdir_flag_spec"; then
Chris@82 9552 if test -n "$hardcode_libdir_separator"; then
Chris@82 9553 func_replace_sysroot "$libdir"
Chris@82 9554 libdir=$func_replace_sysroot_result
Chris@82 9555 if test -z "$hardcode_libdirs"; then
Chris@82 9556 hardcode_libdirs=$libdir
Chris@82 9557 else
Chris@82 9558 # Just accumulate the unique libdirs.
Chris@82 9559 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Chris@82 9560 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
Chris@82 9561 ;;
Chris@82 9562 *)
Chris@82 9563 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
Chris@82 9564 ;;
Chris@82 9565 esac
Chris@82 9566 fi
Chris@82 9567 else
Chris@82 9568 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@82 9569 func_append dep_rpath " $flag"
Chris@82 9570 fi
Chris@82 9571 elif test -n "$runpath_var"; then
Chris@82 9572 case "$perm_rpath " in
Chris@82 9573 *" $libdir "*) ;;
Chris@82 9574 *) func_append perm_rpath " $libdir" ;;
Chris@82 9575 esac
Chris@82 9576 fi
Chris@82 9577 done
Chris@82 9578 # Substitute the hardcoded libdirs into the rpath.
Chris@82 9579 if test -n "$hardcode_libdir_separator" &&
Chris@82 9580 test -n "$hardcode_libdirs"; then
Chris@82 9581 libdir=$hardcode_libdirs
Chris@82 9582 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
Chris@82 9583 fi
Chris@82 9584 if test -n "$runpath_var" && test -n "$perm_rpath"; then
Chris@82 9585 # We should set the runpath_var.
Chris@82 9586 rpath=
Chris@82 9587 for dir in $perm_rpath; do
Chris@82 9588 func_append rpath "$dir:"
Chris@82 9589 done
Chris@82 9590 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
Chris@82 9591 fi
Chris@82 9592 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
Chris@82 9593 fi
Chris@82 9594
Chris@82 9595 shlibpath=$finalize_shlibpath
Chris@82 9596 test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
Chris@82 9597 if test -n "$shlibpath"; then
Chris@82 9598 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
Chris@82 9599 fi
Chris@82 9600
Chris@82 9601 # Get the real and link names of the library.
Chris@82 9602 eval shared_ext=\"$shrext_cmds\"
Chris@82 9603 eval library_names=\"$library_names_spec\"
Chris@82 9604 set dummy $library_names
Chris@82 9605 shift
Chris@82 9606 realname=$1
Chris@82 9607 shift
Chris@82 9608
Chris@82 9609 if test -n "$soname_spec"; then
Chris@82 9610 eval soname=\"$soname_spec\"
Chris@82 9611 else
Chris@82 9612 soname=$realname
Chris@82 9613 fi
Chris@82 9614 if test -z "$dlname"; then
Chris@82 9615 dlname=$soname
Chris@82 9616 fi
Chris@82 9617
Chris@82 9618 lib=$output_objdir/$realname
Chris@82 9619 linknames=
Chris@82 9620 for link
Chris@82 9621 do
Chris@82 9622 func_append linknames " $link"
Chris@82 9623 done
Chris@82 9624
Chris@82 9625 # Use standard objects if they are pic
Chris@82 9626 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@82 9627 test "X$libobjs" = "X " && libobjs=
Chris@82 9628
Chris@82 9629 delfiles=
Chris@82 9630 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Chris@82 9631 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
Chris@82 9632 export_symbols=$output_objdir/$libname.uexp
Chris@82 9633 func_append delfiles " $export_symbols"
Chris@82 9634 fi
Chris@82 9635
Chris@82 9636 orig_export_symbols=
Chris@82 9637 case $host_os in
Chris@82 9638 cygwin* | mingw* | cegcc*)
Chris@82 9639 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
Chris@82 9640 # exporting using user supplied symfile
Chris@82 9641 func_dll_def_p "$export_symbols" || {
Chris@82 9642 # and it's NOT already a .def file. Must figure out
Chris@82 9643 # which of the given symbols are data symbols and tag
Chris@82 9644 # them as such. So, trigger use of export_symbols_cmds.
Chris@82 9645 # export_symbols gets reassigned inside the "prepare
Chris@82 9646 # the list of exported symbols" if statement, so the
Chris@82 9647 # include_expsyms logic still works.
Chris@82 9648 orig_export_symbols=$export_symbols
Chris@82 9649 export_symbols=
Chris@82 9650 always_export_symbols=yes
Chris@82 9651 }
Chris@82 9652 fi
Chris@82 9653 ;;
Chris@82 9654 esac
Chris@82 9655
Chris@82 9656 # Prepare the list of exported symbols
Chris@82 9657 if test -z "$export_symbols"; then
Chris@82 9658 if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
Chris@82 9659 func_verbose "generating symbol list for '$libname.la'"
Chris@82 9660 export_symbols=$output_objdir/$libname.exp
Chris@82 9661 $opt_dry_run || $RM $export_symbols
Chris@82 9662 cmds=$export_symbols_cmds
Chris@82 9663 save_ifs=$IFS; IFS='~'
Chris@82 9664 for cmd1 in $cmds; do
Chris@82 9665 IFS=$save_ifs
Chris@82 9666 # Take the normal branch if the nm_file_list_spec branch
Chris@82 9667 # doesn't work or if tool conversion is not needed.
Chris@82 9668 case $nm_file_list_spec~$to_tool_file_cmd in
Chris@82 9669 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
Chris@82 9670 try_normal_branch=yes
Chris@82 9671 eval cmd=\"$cmd1\"
Chris@82 9672 func_len " $cmd"
Chris@82 9673 len=$func_len_result
Chris@82 9674 ;;
Chris@82 9675 *)
Chris@82 9676 try_normal_branch=no
Chris@82 9677 ;;
Chris@82 9678 esac
Chris@82 9679 if test yes = "$try_normal_branch" \
Chris@82 9680 && { test "$len" -lt "$max_cmd_len" \
Chris@82 9681 || test "$max_cmd_len" -le -1; }
Chris@82 9682 then
Chris@82 9683 func_show_eval "$cmd" 'exit $?'
Chris@82 9684 skipped_export=false
Chris@82 9685 elif test -n "$nm_file_list_spec"; then
Chris@82 9686 func_basename "$output"
Chris@82 9687 output_la=$func_basename_result
Chris@82 9688 save_libobjs=$libobjs
Chris@82 9689 save_output=$output
Chris@82 9690 output=$output_objdir/$output_la.nm
Chris@82 9691 func_to_tool_file "$output"
Chris@82 9692 libobjs=$nm_file_list_spec$func_to_tool_file_result
Chris@82 9693 func_append delfiles " $output"
Chris@82 9694 func_verbose "creating $NM input file list: $output"
Chris@82 9695 for obj in $save_libobjs; do
Chris@82 9696 func_to_tool_file "$obj"
Chris@82 9697 $ECHO "$func_to_tool_file_result"
Chris@82 9698 done > "$output"
Chris@82 9699 eval cmd=\"$cmd1\"
Chris@82 9700 func_show_eval "$cmd" 'exit $?'
Chris@82 9701 output=$save_output
Chris@82 9702 libobjs=$save_libobjs
Chris@82 9703 skipped_export=false
Chris@82 9704 else
Chris@82 9705 # The command line is too long to execute in one step.
Chris@82 9706 func_verbose "using reloadable object file for export list..."
Chris@82 9707 skipped_export=:
Chris@82 9708 # Break out early, otherwise skipped_export may be
Chris@82 9709 # set to false by a later but shorter cmd.
Chris@82 9710 break
Chris@82 9711 fi
Chris@82 9712 done
Chris@82 9713 IFS=$save_ifs
Chris@82 9714 if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
Chris@82 9715 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
Chris@82 9716 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
Chris@82 9717 fi
Chris@82 9718 fi
Chris@82 9719 fi
Chris@82 9720
Chris@82 9721 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Chris@82 9722 tmp_export_symbols=$export_symbols
Chris@82 9723 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
Chris@82 9724 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
Chris@82 9725 fi
Chris@82 9726
Chris@82 9727 if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
Chris@82 9728 # The given exports_symbols file has to be filtered, so filter it.
Chris@82 9729 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
Chris@82 9730 # FIXME: $output_objdir/$libname.filter potentially contains lots of
Chris@82 9731 # 's' commands, which not all seds can handle. GNU sed should be fine
Chris@82 9732 # though. Also, the filter scales superlinearly with the number of
Chris@82 9733 # global variables. join(1) would be nice here, but unfortunately
Chris@82 9734 # isn't a blessed tool.
Chris@82 9735 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
Chris@82 9736 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
Chris@82 9737 export_symbols=$output_objdir/$libname.def
Chris@82 9738 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
Chris@82 9739 fi
Chris@82 9740
Chris@82 9741 tmp_deplibs=
Chris@82 9742 for test_deplib in $deplibs; do
Chris@82 9743 case " $convenience " in
Chris@82 9744 *" $test_deplib "*) ;;
Chris@82 9745 *)
Chris@82 9746 func_append tmp_deplibs " $test_deplib"
Chris@82 9747 ;;
Chris@82 9748 esac
Chris@82 9749 done
Chris@82 9750 deplibs=$tmp_deplibs
Chris@82 9751
Chris@82 9752 if test -n "$convenience"; then
Chris@82 9753 if test -n "$whole_archive_flag_spec" &&
Chris@82 9754 test yes = "$compiler_needs_object" &&
Chris@82 9755 test -z "$libobjs"; then
Chris@82 9756 # extract the archives, so we have objects to list.
Chris@82 9757 # TODO: could optimize this to just extract one archive.
Chris@82 9758 whole_archive_flag_spec=
Chris@82 9759 fi
Chris@82 9760 if test -n "$whole_archive_flag_spec"; then
Chris@82 9761 save_libobjs=$libobjs
Chris@82 9762 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
Chris@82 9763 test "X$libobjs" = "X " && libobjs=
Chris@82 9764 else
Chris@82 9765 gentop=$output_objdir/${outputname}x
Chris@82 9766 func_append generated " $gentop"
Chris@82 9767
Chris@82 9768 func_extract_archives $gentop $convenience
Chris@82 9769 func_append libobjs " $func_extract_archives_result"
Chris@82 9770 test "X$libobjs" = "X " && libobjs=
Chris@82 9771 fi
Chris@82 9772 fi
Chris@82 9773
Chris@82 9774 if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
Chris@82 9775 eval flag=\"$thread_safe_flag_spec\"
Chris@82 9776 func_append linker_flags " $flag"
Chris@82 9777 fi
Chris@82 9778
Chris@82 9779 # Make a backup of the uninstalled library when relinking
Chris@82 9780 if test relink = "$opt_mode"; then
Chris@82 9781 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
Chris@82 9782 fi
Chris@82 9783
Chris@82 9784 # Do each of the archive commands.
Chris@82 9785 if test yes = "$module" && test -n "$module_cmds"; then
Chris@82 9786 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
Chris@82 9787 eval test_cmds=\"$module_expsym_cmds\"
Chris@82 9788 cmds=$module_expsym_cmds
Chris@82 9789 else
Chris@82 9790 eval test_cmds=\"$module_cmds\"
Chris@82 9791 cmds=$module_cmds
Chris@82 9792 fi
Chris@82 9793 else
Chris@82 9794 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
Chris@82 9795 eval test_cmds=\"$archive_expsym_cmds\"
Chris@82 9796 cmds=$archive_expsym_cmds
Chris@82 9797 else
Chris@82 9798 eval test_cmds=\"$archive_cmds\"
Chris@82 9799 cmds=$archive_cmds
Chris@82 9800 fi
Chris@82 9801 fi
Chris@82 9802
Chris@82 9803 if test : != "$skipped_export" &&
Chris@82 9804 func_len " $test_cmds" &&
Chris@82 9805 len=$func_len_result &&
Chris@82 9806 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
Chris@82 9807 :
Chris@82 9808 else
Chris@82 9809 # The command line is too long to link in one step, link piecewise
Chris@82 9810 # or, if using GNU ld and skipped_export is not :, use a linker
Chris@82 9811 # script.
Chris@82 9812
Chris@82 9813 # Save the value of $output and $libobjs because we want to
Chris@82 9814 # use them later. If we have whole_archive_flag_spec, we
Chris@82 9815 # want to use save_libobjs as it was before
Chris@82 9816 # whole_archive_flag_spec was expanded, because we can't
Chris@82 9817 # assume the linker understands whole_archive_flag_spec.
Chris@82 9818 # This may have to be revisited, in case too many
Chris@82 9819 # convenience libraries get linked in and end up exceeding
Chris@82 9820 # the spec.
Chris@82 9821 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
Chris@82 9822 save_libobjs=$libobjs
Chris@82 9823 fi
Chris@82 9824 save_output=$output
Chris@82 9825 func_basename "$output"
Chris@82 9826 output_la=$func_basename_result
Chris@82 9827
Chris@82 9828 # Clear the reloadable object creation command queue and
Chris@82 9829 # initialize k to one.
Chris@82 9830 test_cmds=
Chris@82 9831 concat_cmds=
Chris@82 9832 objlist=
Chris@82 9833 last_robj=
Chris@82 9834 k=1
Chris@82 9835
Chris@82 9836 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
Chris@82 9837 output=$output_objdir/$output_la.lnkscript
Chris@82 9838 func_verbose "creating GNU ld script: $output"
Chris@82 9839 echo 'INPUT (' > $output
Chris@82 9840 for obj in $save_libobjs
Chris@82 9841 do
Chris@82 9842 func_to_tool_file "$obj"
Chris@82 9843 $ECHO "$func_to_tool_file_result" >> $output
Chris@82 9844 done
Chris@82 9845 echo ')' >> $output
Chris@82 9846 func_append delfiles " $output"
Chris@82 9847 func_to_tool_file "$output"
Chris@82 9848 output=$func_to_tool_file_result
Chris@82 9849 elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
Chris@82 9850 output=$output_objdir/$output_la.lnk
Chris@82 9851 func_verbose "creating linker input file list: $output"
Chris@82 9852 : > $output
Chris@82 9853 set x $save_libobjs
Chris@82 9854 shift
Chris@82 9855 firstobj=
Chris@82 9856 if test yes = "$compiler_needs_object"; then
Chris@82 9857 firstobj="$1 "
Chris@82 9858 shift
Chris@82 9859 fi
Chris@82 9860 for obj
Chris@82 9861 do
Chris@82 9862 func_to_tool_file "$obj"
Chris@82 9863 $ECHO "$func_to_tool_file_result" >> $output
Chris@82 9864 done
Chris@82 9865 func_append delfiles " $output"
Chris@82 9866 func_to_tool_file "$output"
Chris@82 9867 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
Chris@82 9868 else
Chris@82 9869 if test -n "$save_libobjs"; then
Chris@82 9870 func_verbose "creating reloadable object files..."
Chris@82 9871 output=$output_objdir/$output_la-$k.$objext
Chris@82 9872 eval test_cmds=\"$reload_cmds\"
Chris@82 9873 func_len " $test_cmds"
Chris@82 9874 len0=$func_len_result
Chris@82 9875 len=$len0
Chris@82 9876
Chris@82 9877 # Loop over the list of objects to be linked.
Chris@82 9878 for obj in $save_libobjs
Chris@82 9879 do
Chris@82 9880 func_len " $obj"
Chris@82 9881 func_arith $len + $func_len_result
Chris@82 9882 len=$func_arith_result
Chris@82 9883 if test -z "$objlist" ||
Chris@82 9884 test "$len" -lt "$max_cmd_len"; then
Chris@82 9885 func_append objlist " $obj"
Chris@82 9886 else
Chris@82 9887 # The command $test_cmds is almost too long, add a
Chris@82 9888 # command to the queue.
Chris@82 9889 if test 1 -eq "$k"; then
Chris@82 9890 # The first file doesn't have a previous command to add.
Chris@82 9891 reload_objs=$objlist
Chris@82 9892 eval concat_cmds=\"$reload_cmds\"
Chris@82 9893 else
Chris@82 9894 # All subsequent reloadable object files will link in
Chris@82 9895 # the last one created.
Chris@82 9896 reload_objs="$objlist $last_robj"
Chris@82 9897 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
Chris@82 9898 fi
Chris@82 9899 last_robj=$output_objdir/$output_la-$k.$objext
Chris@82 9900 func_arith $k + 1
Chris@82 9901 k=$func_arith_result
Chris@82 9902 output=$output_objdir/$output_la-$k.$objext
Chris@82 9903 objlist=" $obj"
Chris@82 9904 func_len " $last_robj"
Chris@82 9905 func_arith $len0 + $func_len_result
Chris@82 9906 len=$func_arith_result
Chris@82 9907 fi
Chris@82 9908 done
Chris@82 9909 # Handle the remaining objects by creating one last
Chris@82 9910 # reloadable object file. All subsequent reloadable object
Chris@82 9911 # files will link in the last one created.
Chris@82 9912 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Chris@82 9913 reload_objs="$objlist $last_robj"
Chris@82 9914 eval concat_cmds=\"\$concat_cmds$reload_cmds\"
Chris@82 9915 if test -n "$last_robj"; then
Chris@82 9916 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
Chris@82 9917 fi
Chris@82 9918 func_append delfiles " $output"
Chris@82 9919
Chris@82 9920 else
Chris@82 9921 output=
Chris@82 9922 fi
Chris@82 9923
Chris@82 9924 ${skipped_export-false} && {
Chris@82 9925 func_verbose "generating symbol list for '$libname.la'"
Chris@82 9926 export_symbols=$output_objdir/$libname.exp
Chris@82 9927 $opt_dry_run || $RM $export_symbols
Chris@82 9928 libobjs=$output
Chris@82 9929 # Append the command to create the export file.
Chris@82 9930 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Chris@82 9931 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
Chris@82 9932 if test -n "$last_robj"; then
Chris@82 9933 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
Chris@82 9934 fi
Chris@82 9935 }
Chris@82 9936
Chris@82 9937 test -n "$save_libobjs" &&
Chris@82 9938 func_verbose "creating a temporary reloadable object file: $output"
Chris@82 9939
Chris@82 9940 # Loop through the commands generated above and execute them.
Chris@82 9941 save_ifs=$IFS; IFS='~'
Chris@82 9942 for cmd in $concat_cmds; do
Chris@82 9943 IFS=$save_ifs
Chris@82 9944 $opt_quiet || {
Chris@82 9945 func_quote_for_expand "$cmd"
Chris@82 9946 eval "func_echo $func_quote_for_expand_result"
Chris@82 9947 }
Chris@82 9948 $opt_dry_run || eval "$cmd" || {
Chris@82 9949 lt_exit=$?
Chris@82 9950
Chris@82 9951 # Restore the uninstalled library and exit
Chris@82 9952 if test relink = "$opt_mode"; then
Chris@82 9953 ( cd "$output_objdir" && \
Chris@82 9954 $RM "${realname}T" && \
Chris@82 9955 $MV "${realname}U" "$realname" )
Chris@82 9956 fi
Chris@82 9957
Chris@82 9958 exit $lt_exit
Chris@82 9959 }
Chris@82 9960 done
Chris@82 9961 IFS=$save_ifs
Chris@82 9962
Chris@82 9963 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
Chris@82 9964 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
Chris@82 9965 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
Chris@82 9966 fi
Chris@82 9967 fi
Chris@82 9968
Chris@82 9969 ${skipped_export-false} && {
Chris@82 9970 if test -n "$export_symbols" && test -n "$include_expsyms"; then
Chris@82 9971 tmp_export_symbols=$export_symbols
Chris@82 9972 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
Chris@82 9973 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
Chris@82 9974 fi
Chris@82 9975
Chris@82 9976 if test -n "$orig_export_symbols"; then
Chris@82 9977 # The given exports_symbols file has to be filtered, so filter it.
Chris@82 9978 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
Chris@82 9979 # FIXME: $output_objdir/$libname.filter potentially contains lots of
Chris@82 9980 # 's' commands, which not all seds can handle. GNU sed should be fine
Chris@82 9981 # though. Also, the filter scales superlinearly with the number of
Chris@82 9982 # global variables. join(1) would be nice here, but unfortunately
Chris@82 9983 # isn't a blessed tool.
Chris@82 9984 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
Chris@82 9985 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
Chris@82 9986 export_symbols=$output_objdir/$libname.def
Chris@82 9987 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
Chris@82 9988 fi
Chris@82 9989 }
Chris@82 9990
Chris@82 9991 libobjs=$output
Chris@82 9992 # Restore the value of output.
Chris@82 9993 output=$save_output
Chris@82 9994
Chris@82 9995 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
Chris@82 9996 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
Chris@82 9997 test "X$libobjs" = "X " && libobjs=
Chris@82 9998 fi
Chris@82 9999 # Expand the library linking commands again to reset the
Chris@82 10000 # value of $libobjs for piecewise linking.
Chris@82 10001
Chris@82 10002 # Do each of the archive commands.
Chris@82 10003 if test yes = "$module" && test -n "$module_cmds"; then
Chris@82 10004 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
Chris@82 10005 cmds=$module_expsym_cmds
Chris@82 10006 else
Chris@82 10007 cmds=$module_cmds
Chris@82 10008 fi
Chris@82 10009 else
Chris@82 10010 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
Chris@82 10011 cmds=$archive_expsym_cmds
Chris@82 10012 else
Chris@82 10013 cmds=$archive_cmds
Chris@82 10014 fi
Chris@82 10015 fi
Chris@82 10016 fi
Chris@82 10017
Chris@82 10018 if test -n "$delfiles"; then
Chris@82 10019 # Append the command to remove temporary files to $cmds.
Chris@82 10020 eval cmds=\"\$cmds~\$RM $delfiles\"
Chris@82 10021 fi
Chris@82 10022
Chris@82 10023 # Add any objects from preloaded convenience libraries
Chris@82 10024 if test -n "$dlprefiles"; then
Chris@82 10025 gentop=$output_objdir/${outputname}x
Chris@82 10026 func_append generated " $gentop"
Chris@82 10027
Chris@82 10028 func_extract_archives $gentop $dlprefiles
Chris@82 10029 func_append libobjs " $func_extract_archives_result"
Chris@82 10030 test "X$libobjs" = "X " && libobjs=
Chris@82 10031 fi
Chris@82 10032
Chris@82 10033 save_ifs=$IFS; IFS='~'
Chris@82 10034 for cmd in $cmds; do
Chris@82 10035 IFS=$sp$nl
Chris@82 10036 eval cmd=\"$cmd\"
Chris@82 10037 IFS=$save_ifs
Chris@82 10038 $opt_quiet || {
Chris@82 10039 func_quote_for_expand "$cmd"
Chris@82 10040 eval "func_echo $func_quote_for_expand_result"
Chris@82 10041 }
Chris@82 10042 $opt_dry_run || eval "$cmd" || {
Chris@82 10043 lt_exit=$?
Chris@82 10044
Chris@82 10045 # Restore the uninstalled library and exit
Chris@82 10046 if test relink = "$opt_mode"; then
Chris@82 10047 ( cd "$output_objdir" && \
Chris@82 10048 $RM "${realname}T" && \
Chris@82 10049 $MV "${realname}U" "$realname" )
Chris@82 10050 fi
Chris@82 10051
Chris@82 10052 exit $lt_exit
Chris@82 10053 }
Chris@82 10054 done
Chris@82 10055 IFS=$save_ifs
Chris@82 10056
Chris@82 10057 # Restore the uninstalled library and exit
Chris@82 10058 if test relink = "$opt_mode"; then
Chris@82 10059 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
Chris@82 10060
Chris@82 10061 if test -n "$convenience"; then
Chris@82 10062 if test -z "$whole_archive_flag_spec"; then
Chris@82 10063 func_show_eval '${RM}r "$gentop"'
Chris@82 10064 fi
Chris@82 10065 fi
Chris@82 10066
Chris@82 10067 exit $EXIT_SUCCESS
Chris@82 10068 fi
Chris@82 10069
Chris@82 10070 # Create links to the real library.
Chris@82 10071 for linkname in $linknames; do
Chris@82 10072 if test "$realname" != "$linkname"; then
Chris@82 10073 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
Chris@82 10074 fi
Chris@82 10075 done
Chris@82 10076
Chris@82 10077 # If -module or -export-dynamic was specified, set the dlname.
Chris@82 10078 if test yes = "$module" || test yes = "$export_dynamic"; then
Chris@82 10079 # On all known operating systems, these are identical.
Chris@82 10080 dlname=$soname
Chris@82 10081 fi
Chris@82 10082 fi
Chris@82 10083 ;;
Chris@82 10084
Chris@82 10085 obj)
Chris@82 10086 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
Chris@82 10087 func_warning "'-dlopen' is ignored for objects"
Chris@82 10088 fi
Chris@82 10089
Chris@82 10090 case " $deplibs" in
Chris@82 10091 *\ -l* | *\ -L*)
Chris@82 10092 func_warning "'-l' and '-L' are ignored for objects" ;;
Chris@82 10093 esac
Chris@82 10094
Chris@82 10095 test -n "$rpath" && \
Chris@82 10096 func_warning "'-rpath' is ignored for objects"
Chris@82 10097
Chris@82 10098 test -n "$xrpath" && \
Chris@82 10099 func_warning "'-R' is ignored for objects"
Chris@82 10100
Chris@82 10101 test -n "$vinfo" && \
Chris@82 10102 func_warning "'-version-info' is ignored for objects"
Chris@82 10103
Chris@82 10104 test -n "$release" && \
Chris@82 10105 func_warning "'-release' is ignored for objects"
Chris@82 10106
Chris@82 10107 case $output in
Chris@82 10108 *.lo)
Chris@82 10109 test -n "$objs$old_deplibs" && \
Chris@82 10110 func_fatal_error "cannot build library object '$output' from non-libtool objects"
Chris@82 10111
Chris@82 10112 libobj=$output
Chris@82 10113 func_lo2o "$libobj"
Chris@82 10114 obj=$func_lo2o_result
Chris@82 10115 ;;
Chris@82 10116 *)
Chris@82 10117 libobj=
Chris@82 10118 obj=$output
Chris@82 10119 ;;
Chris@82 10120 esac
Chris@82 10121
Chris@82 10122 # Delete the old objects.
Chris@82 10123 $opt_dry_run || $RM $obj $libobj
Chris@82 10124
Chris@82 10125 # Objects from convenience libraries. This assumes
Chris@82 10126 # single-version convenience libraries. Whenever we create
Chris@82 10127 # different ones for PIC/non-PIC, this we'll have to duplicate
Chris@82 10128 # the extraction.
Chris@82 10129 reload_conv_objs=
Chris@82 10130 gentop=
Chris@82 10131 # if reload_cmds runs $LD directly, get rid of -Wl from
Chris@82 10132 # whole_archive_flag_spec and hope we can get by with turning comma
Chris@82 10133 # into space.
Chris@82 10134 case $reload_cmds in
Chris@82 10135 *\$LD[\ \$]*) wl= ;;
Chris@82 10136 esac
Chris@82 10137 if test -n "$convenience"; then
Chris@82 10138 if test -n "$whole_archive_flag_spec"; then
Chris@82 10139 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
Chris@82 10140 test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
Chris@82 10141 reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
Chris@82 10142 else
Chris@82 10143 gentop=$output_objdir/${obj}x
Chris@82 10144 func_append generated " $gentop"
Chris@82 10145
Chris@82 10146 func_extract_archives $gentop $convenience
Chris@82 10147 reload_conv_objs="$reload_objs $func_extract_archives_result"
Chris@82 10148 fi
Chris@82 10149 fi
Chris@82 10150
Chris@82 10151 # If we're not building shared, we need to use non_pic_objs
Chris@82 10152 test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
Chris@82 10153
Chris@82 10154 # Create the old-style object.
Chris@82 10155 reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
Chris@82 10156
Chris@82 10157 output=$obj
Chris@82 10158 func_execute_cmds "$reload_cmds" 'exit $?'
Chris@82 10159
Chris@82 10160 # Exit if we aren't doing a library object file.
Chris@82 10161 if test -z "$libobj"; then
Chris@82 10162 if test -n "$gentop"; then
Chris@82 10163 func_show_eval '${RM}r "$gentop"'
Chris@82 10164 fi
Chris@82 10165
Chris@82 10166 exit $EXIT_SUCCESS
Chris@82 10167 fi
Chris@82 10168
Chris@82 10169 test yes = "$build_libtool_libs" || {
Chris@82 10170 if test -n "$gentop"; then
Chris@82 10171 func_show_eval '${RM}r "$gentop"'
Chris@82 10172 fi
Chris@82 10173
Chris@82 10174 # Create an invalid libtool object if no PIC, so that we don't
Chris@82 10175 # accidentally link it into a program.
Chris@82 10176 # $show "echo timestamp > $libobj"
Chris@82 10177 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
Chris@82 10178 exit $EXIT_SUCCESS
Chris@82 10179 }
Chris@82 10180
Chris@82 10181 if test -n "$pic_flag" || test default != "$pic_mode"; then
Chris@82 10182 # Only do commands if we really have different PIC objects.
Chris@82 10183 reload_objs="$libobjs $reload_conv_objs"
Chris@82 10184 output=$libobj
Chris@82 10185 func_execute_cmds "$reload_cmds" 'exit $?'
Chris@82 10186 fi
Chris@82 10187
Chris@82 10188 if test -n "$gentop"; then
Chris@82 10189 func_show_eval '${RM}r "$gentop"'
Chris@82 10190 fi
Chris@82 10191
Chris@82 10192 exit $EXIT_SUCCESS
Chris@82 10193 ;;
Chris@82 10194
Chris@82 10195 prog)
Chris@82 10196 case $host in
Chris@82 10197 *cygwin*) func_stripname '' '.exe' "$output"
Chris@82 10198 output=$func_stripname_result.exe;;
Chris@82 10199 esac
Chris@82 10200 test -n "$vinfo" && \
Chris@82 10201 func_warning "'-version-info' is ignored for programs"
Chris@82 10202
Chris@82 10203 test -n "$release" && \
Chris@82 10204 func_warning "'-release' is ignored for programs"
Chris@82 10205
Chris@82 10206 $preload \
Chris@82 10207 && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
Chris@82 10208 && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
Chris@82 10209
Chris@82 10210 case $host in
Chris@82 10211 *-*-rhapsody* | *-*-darwin1.[012])
Chris@82 10212 # On Rhapsody replace the C library is the System framework
Chris@82 10213 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
Chris@82 10214 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
Chris@82 10215 ;;
Chris@82 10216 esac
Chris@82 10217
Chris@82 10218 case $host in
Chris@82 10219 *-*-darwin*)
Chris@82 10220 # Don't allow lazy linking, it breaks C++ global constructors
Chris@82 10221 # But is supposedly fixed on 10.4 or later (yay!).
Chris@82 10222 if test CXX = "$tagname"; then
Chris@82 10223 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
Chris@82 10224 10.[0123])
Chris@82 10225 func_append compile_command " $wl-bind_at_load"
Chris@82 10226 func_append finalize_command " $wl-bind_at_load"
Chris@82 10227 ;;
Chris@82 10228 esac
Chris@82 10229 fi
Chris@82 10230 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
Chris@82 10231 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@82 10232 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
Chris@82 10233 ;;
Chris@82 10234 esac
Chris@82 10235
Chris@82 10236
Chris@82 10237 # move library search paths that coincide with paths to not yet
Chris@82 10238 # installed libraries to the beginning of the library search list
Chris@82 10239 new_libs=
Chris@82 10240 for path in $notinst_path; do
Chris@82 10241 case " $new_libs " in
Chris@82 10242 *" -L$path/$objdir "*) ;;
Chris@82 10243 *)
Chris@82 10244 case " $compile_deplibs " in
Chris@82 10245 *" -L$path/$objdir "*)
Chris@82 10246 func_append new_libs " -L$path/$objdir" ;;
Chris@82 10247 esac
Chris@82 10248 ;;
Chris@82 10249 esac
Chris@82 10250 done
Chris@82 10251 for deplib in $compile_deplibs; do
Chris@82 10252 case $deplib in
Chris@82 10253 -L*)
Chris@82 10254 case " $new_libs " in
Chris@82 10255 *" $deplib "*) ;;
Chris@82 10256 *) func_append new_libs " $deplib" ;;
Chris@82 10257 esac
Chris@82 10258 ;;
Chris@82 10259 *) func_append new_libs " $deplib" ;;
Chris@82 10260 esac
Chris@82 10261 done
Chris@82 10262 compile_deplibs=$new_libs
Chris@82 10263
Chris@82 10264
Chris@82 10265 func_append compile_command " $compile_deplibs"
Chris@82 10266 func_append finalize_command " $finalize_deplibs"
Chris@82 10267
Chris@82 10268 if test -n "$rpath$xrpath"; then
Chris@82 10269 # If the user specified any rpath flags, then add them.
Chris@82 10270 for libdir in $rpath $xrpath; do
Chris@82 10271 # This is the magic to use -rpath.
Chris@82 10272 case "$finalize_rpath " in
Chris@82 10273 *" $libdir "*) ;;
Chris@82 10274 *) func_append finalize_rpath " $libdir" ;;
Chris@82 10275 esac
Chris@82 10276 done
Chris@82 10277 fi
Chris@82 10278
Chris@82 10279 # Now hardcode the library paths
Chris@82 10280 rpath=
Chris@82 10281 hardcode_libdirs=
Chris@82 10282 for libdir in $compile_rpath $finalize_rpath; do
Chris@82 10283 if test -n "$hardcode_libdir_flag_spec"; then
Chris@82 10284 if test -n "$hardcode_libdir_separator"; then
Chris@82 10285 if test -z "$hardcode_libdirs"; then
Chris@82 10286 hardcode_libdirs=$libdir
Chris@82 10287 else
Chris@82 10288 # Just accumulate the unique libdirs.
Chris@82 10289 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Chris@82 10290 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
Chris@82 10291 ;;
Chris@82 10292 *)
Chris@82 10293 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
Chris@82 10294 ;;
Chris@82 10295 esac
Chris@82 10296 fi
Chris@82 10297 else
Chris@82 10298 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@82 10299 func_append rpath " $flag"
Chris@82 10300 fi
Chris@82 10301 elif test -n "$runpath_var"; then
Chris@82 10302 case "$perm_rpath " in
Chris@82 10303 *" $libdir "*) ;;
Chris@82 10304 *) func_append perm_rpath " $libdir" ;;
Chris@82 10305 esac
Chris@82 10306 fi
Chris@82 10307 case $host in
Chris@82 10308 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
Chris@82 10309 testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
Chris@82 10310 case :$dllsearchpath: in
Chris@82 10311 *":$libdir:"*) ;;
Chris@82 10312 ::) dllsearchpath=$libdir;;
Chris@82 10313 *) func_append dllsearchpath ":$libdir";;
Chris@82 10314 esac
Chris@82 10315 case :$dllsearchpath: in
Chris@82 10316 *":$testbindir:"*) ;;
Chris@82 10317 ::) dllsearchpath=$testbindir;;
Chris@82 10318 *) func_append dllsearchpath ":$testbindir";;
Chris@82 10319 esac
Chris@82 10320 ;;
Chris@82 10321 esac
Chris@82 10322 done
Chris@82 10323 # Substitute the hardcoded libdirs into the rpath.
Chris@82 10324 if test -n "$hardcode_libdir_separator" &&
Chris@82 10325 test -n "$hardcode_libdirs"; then
Chris@82 10326 libdir=$hardcode_libdirs
Chris@82 10327 eval rpath=\" $hardcode_libdir_flag_spec\"
Chris@82 10328 fi
Chris@82 10329 compile_rpath=$rpath
Chris@82 10330
Chris@82 10331 rpath=
Chris@82 10332 hardcode_libdirs=
Chris@82 10333 for libdir in $finalize_rpath; do
Chris@82 10334 if test -n "$hardcode_libdir_flag_spec"; then
Chris@82 10335 if test -n "$hardcode_libdir_separator"; then
Chris@82 10336 if test -z "$hardcode_libdirs"; then
Chris@82 10337 hardcode_libdirs=$libdir
Chris@82 10338 else
Chris@82 10339 # Just accumulate the unique libdirs.
Chris@82 10340 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
Chris@82 10341 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
Chris@82 10342 ;;
Chris@82 10343 *)
Chris@82 10344 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
Chris@82 10345 ;;
Chris@82 10346 esac
Chris@82 10347 fi
Chris@82 10348 else
Chris@82 10349 eval flag=\"$hardcode_libdir_flag_spec\"
Chris@82 10350 func_append rpath " $flag"
Chris@82 10351 fi
Chris@82 10352 elif test -n "$runpath_var"; then
Chris@82 10353 case "$finalize_perm_rpath " in
Chris@82 10354 *" $libdir "*) ;;
Chris@82 10355 *) func_append finalize_perm_rpath " $libdir" ;;
Chris@82 10356 esac
Chris@82 10357 fi
Chris@82 10358 done
Chris@82 10359 # Substitute the hardcoded libdirs into the rpath.
Chris@82 10360 if test -n "$hardcode_libdir_separator" &&
Chris@82 10361 test -n "$hardcode_libdirs"; then
Chris@82 10362 libdir=$hardcode_libdirs
Chris@82 10363 eval rpath=\" $hardcode_libdir_flag_spec\"
Chris@82 10364 fi
Chris@82 10365 finalize_rpath=$rpath
Chris@82 10366
Chris@82 10367 if test -n "$libobjs" && test yes = "$build_old_libs"; then
Chris@82 10368 # Transform all the library objects into standard objects.
Chris@82 10369 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@82 10370 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
Chris@82 10371 fi
Chris@82 10372
Chris@82 10373 func_generate_dlsyms "$outputname" "@PROGRAM@" false
Chris@82 10374
Chris@82 10375 # template prelinking step
Chris@82 10376 if test -n "$prelink_cmds"; then
Chris@82 10377 func_execute_cmds "$prelink_cmds" 'exit $?'
Chris@82 10378 fi
Chris@82 10379
Chris@82 10380 wrappers_required=:
Chris@82 10381 case $host in
Chris@82 10382 *cegcc* | *mingw32ce*)
Chris@82 10383 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
Chris@82 10384 wrappers_required=false
Chris@82 10385 ;;
Chris@82 10386 *cygwin* | *mingw* )
Chris@82 10387 test yes = "$build_libtool_libs" || wrappers_required=false
Chris@82 10388 ;;
Chris@82 10389 *)
Chris@82 10390 if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
Chris@82 10391 wrappers_required=false
Chris@82 10392 fi
Chris@82 10393 ;;
Chris@82 10394 esac
Chris@82 10395 $wrappers_required || {
Chris@82 10396 # Replace the output file specification.
Chris@82 10397 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
Chris@82 10398 link_command=$compile_command$compile_rpath
Chris@82 10399
Chris@82 10400 # We have no uninstalled library dependencies, so finalize right now.
Chris@82 10401 exit_status=0
Chris@82 10402 func_show_eval "$link_command" 'exit_status=$?'
Chris@82 10403
Chris@82 10404 if test -n "$postlink_cmds"; then
Chris@82 10405 func_to_tool_file "$output"
Chris@82 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@82 10407 func_execute_cmds "$postlink_cmds" 'exit $?'
Chris@82 10408 fi
Chris@82 10409
Chris@82 10410 # Delete the generated files.
Chris@82 10411 if test -f "$output_objdir/${outputname}S.$objext"; then
Chris@82 10412 func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
Chris@82 10413 fi
Chris@82 10414
Chris@82 10415 exit $exit_status
Chris@82 10416 }
Chris@82 10417
Chris@82 10418 if test -n "$compile_shlibpath$finalize_shlibpath"; then
Chris@82 10419 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
Chris@82 10420 fi
Chris@82 10421 if test -n "$finalize_shlibpath"; then
Chris@82 10422 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
Chris@82 10423 fi
Chris@82 10424
Chris@82 10425 compile_var=
Chris@82 10426 finalize_var=
Chris@82 10427 if test -n "$runpath_var"; then
Chris@82 10428 if test -n "$perm_rpath"; then
Chris@82 10429 # We should set the runpath_var.
Chris@82 10430 rpath=
Chris@82 10431 for dir in $perm_rpath; do
Chris@82 10432 func_append rpath "$dir:"
Chris@82 10433 done
Chris@82 10434 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
Chris@82 10435 fi
Chris@82 10436 if test -n "$finalize_perm_rpath"; then
Chris@82 10437 # We should set the runpath_var.
Chris@82 10438 rpath=
Chris@82 10439 for dir in $finalize_perm_rpath; do
Chris@82 10440 func_append rpath "$dir:"
Chris@82 10441 done
Chris@82 10442 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
Chris@82 10443 fi
Chris@82 10444 fi
Chris@82 10445
Chris@82 10446 if test yes = "$no_install"; then
Chris@82 10447 # We don't need to create a wrapper script.
Chris@82 10448 link_command=$compile_var$compile_command$compile_rpath
Chris@82 10449 # Replace the output file specification.
Chris@82 10450 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
Chris@82 10451 # Delete the old output file.
Chris@82 10452 $opt_dry_run || $RM $output
Chris@82 10453 # Link the executable and exit
Chris@82 10454 func_show_eval "$link_command" 'exit $?'
Chris@82 10455
Chris@82 10456 if test -n "$postlink_cmds"; then
Chris@82 10457 func_to_tool_file "$output"
Chris@82 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@82 10459 func_execute_cmds "$postlink_cmds" 'exit $?'
Chris@82 10460 fi
Chris@82 10461
Chris@82 10462 exit $EXIT_SUCCESS
Chris@82 10463 fi
Chris@82 10464
Chris@82 10465 case $hardcode_action,$fast_install in
Chris@82 10466 relink,*)
Chris@82 10467 # Fast installation is not supported
Chris@82 10468 link_command=$compile_var$compile_command$compile_rpath
Chris@82 10469 relink_command=$finalize_var$finalize_command$finalize_rpath
Chris@82 10470
Chris@82 10471 func_warning "this platform does not like uninstalled shared libraries"
Chris@82 10472 func_warning "'$output' will be relinked during installation"
Chris@82 10473 ;;
Chris@82 10474 *,yes)
Chris@82 10475 link_command=$finalize_var$compile_command$finalize_rpath
Chris@82 10476 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
Chris@82 10477 ;;
Chris@82 10478 *,no)
Chris@82 10479 link_command=$compile_var$compile_command$compile_rpath
Chris@82 10480 relink_command=$finalize_var$finalize_command$finalize_rpath
Chris@82 10481 ;;
Chris@82 10482 *,needless)
Chris@82 10483 link_command=$finalize_var$compile_command$finalize_rpath
Chris@82 10484 relink_command=
Chris@82 10485 ;;
Chris@82 10486 esac
Chris@82 10487
Chris@82 10488 # Replace the output file specification.
Chris@82 10489 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
Chris@82 10490
Chris@82 10491 # Delete the old output files.
Chris@82 10492 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
Chris@82 10493
Chris@82 10494 func_show_eval "$link_command" 'exit $?'
Chris@82 10495
Chris@82 10496 if test -n "$postlink_cmds"; then
Chris@82 10497 func_to_tool_file "$output_objdir/$outputname"
Chris@82 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@82 10499 func_execute_cmds "$postlink_cmds" 'exit $?'
Chris@82 10500 fi
Chris@82 10501
Chris@82 10502 # Now create the wrapper script.
Chris@82 10503 func_verbose "creating $output"
Chris@82 10504
Chris@82 10505 # Quote the relink command for shipping.
Chris@82 10506 if test -n "$relink_command"; then
Chris@82 10507 # Preserve any variables that may affect compiler behavior
Chris@82 10508 for var in $variables_saved_for_relink; do
Chris@82 10509 if eval test -z \"\${$var+set}\"; then
Chris@82 10510 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
Chris@82 10511 elif eval var_value=\$$var; test -z "$var_value"; then
Chris@82 10512 relink_command="$var=; export $var; $relink_command"
Chris@82 10513 else
Chris@82 10514 func_quote_for_eval "$var_value"
Chris@82 10515 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
Chris@82 10516 fi
Chris@82 10517 done
Chris@82 10518 relink_command="(cd `pwd`; $relink_command)"
Chris@82 10519 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
Chris@82 10520 fi
Chris@82 10521
Chris@82 10522 # Only actually do things if not in dry run mode.
Chris@82 10523 $opt_dry_run || {
Chris@82 10524 # win32 will think the script is a binary if it has
Chris@82 10525 # a .exe suffix, so we strip it off here.
Chris@82 10526 case $output in
Chris@82 10527 *.exe) func_stripname '' '.exe' "$output"
Chris@82 10528 output=$func_stripname_result ;;
Chris@82 10529 esac
Chris@82 10530 # test for cygwin because mv fails w/o .exe extensions
Chris@82 10531 case $host in
Chris@82 10532 *cygwin*)
Chris@82 10533 exeext=.exe
Chris@82 10534 func_stripname '' '.exe' "$outputname"
Chris@82 10535 outputname=$func_stripname_result ;;
Chris@82 10536 *) exeext= ;;
Chris@82 10537 esac
Chris@82 10538 case $host in
Chris@82 10539 *cygwin* | *mingw* )
Chris@82 10540 func_dirname_and_basename "$output" "" "."
Chris@82 10541 output_name=$func_basename_result
Chris@82 10542 output_path=$func_dirname_result
Chris@82 10543 cwrappersource=$output_path/$objdir/lt-$output_name.c
Chris@82 10544 cwrapper=$output_path/$output_name.exe
Chris@82 10545 $RM $cwrappersource $cwrapper
Chris@82 10546 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
Chris@82 10547
Chris@82 10548 func_emit_cwrapperexe_src > $cwrappersource
Chris@82 10549
Chris@82 10550 # The wrapper executable is built using the $host compiler,
Chris@82 10551 # because it contains $host paths and files. If cross-
Chris@82 10552 # compiling, it, like the target executable, must be
Chris@82 10553 # executed on the $host or under an emulation environment.
Chris@82 10554 $opt_dry_run || {
Chris@82 10555 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
Chris@82 10556 $STRIP $cwrapper
Chris@82 10557 }
Chris@82 10558
Chris@82 10559 # Now, create the wrapper script for func_source use:
Chris@82 10560 func_ltwrapper_scriptname $cwrapper
Chris@82 10561 $RM $func_ltwrapper_scriptname_result
Chris@82 10562 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
Chris@82 10563 $opt_dry_run || {
Chris@82 10564 # note: this script will not be executed, so do not chmod.
Chris@82 10565 if test "x$build" = "x$host"; then
Chris@82 10566 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
Chris@82 10567 else
Chris@82 10568 func_emit_wrapper no > $func_ltwrapper_scriptname_result
Chris@82 10569 fi
Chris@82 10570 }
Chris@82 10571 ;;
Chris@82 10572 * )
Chris@82 10573 $RM $output
Chris@82 10574 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
Chris@82 10575
Chris@82 10576 func_emit_wrapper no > $output
Chris@82 10577 chmod +x $output
Chris@82 10578 ;;
Chris@82 10579 esac
Chris@82 10580 }
Chris@82 10581 exit $EXIT_SUCCESS
Chris@82 10582 ;;
Chris@82 10583 esac
Chris@82 10584
Chris@82 10585 # See if we need to build an old-fashioned archive.
Chris@82 10586 for oldlib in $oldlibs; do
Chris@82 10587
Chris@82 10588 case $build_libtool_libs in
Chris@82 10589 convenience)
Chris@82 10590 oldobjs="$libobjs_save $symfileobj"
Chris@82 10591 addlibs=$convenience
Chris@82 10592 build_libtool_libs=no
Chris@82 10593 ;;
Chris@82 10594 module)
Chris@82 10595 oldobjs=$libobjs_save
Chris@82 10596 addlibs=$old_convenience
Chris@82 10597 build_libtool_libs=no
Chris@82 10598 ;;
Chris@82 10599 *)
Chris@82 10600 oldobjs="$old_deplibs $non_pic_objects"
Chris@82 10601 $preload && test -f "$symfileobj" \
Chris@82 10602 && func_append oldobjs " $symfileobj"
Chris@82 10603 addlibs=$old_convenience
Chris@82 10604 ;;
Chris@82 10605 esac
Chris@82 10606
Chris@82 10607 if test -n "$addlibs"; then
Chris@82 10608 gentop=$output_objdir/${outputname}x
Chris@82 10609 func_append generated " $gentop"
Chris@82 10610
Chris@82 10611 func_extract_archives $gentop $addlibs
Chris@82 10612 func_append oldobjs " $func_extract_archives_result"
Chris@82 10613 fi
Chris@82 10614
Chris@82 10615 # Do each command in the archive commands.
Chris@82 10616 if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
Chris@82 10617 cmds=$old_archive_from_new_cmds
Chris@82 10618 else
Chris@82 10619
Chris@82 10620 # Add any objects from preloaded convenience libraries
Chris@82 10621 if test -n "$dlprefiles"; then
Chris@82 10622 gentop=$output_objdir/${outputname}x
Chris@82 10623 func_append generated " $gentop"
Chris@82 10624
Chris@82 10625 func_extract_archives $gentop $dlprefiles
Chris@82 10626 func_append oldobjs " $func_extract_archives_result"
Chris@82 10627 fi
Chris@82 10628
Chris@82 10629 # POSIX demands no paths to be encoded in archives. We have
Chris@82 10630 # to avoid creating archives with duplicate basenames if we
Chris@82 10631 # might have to extract them afterwards, e.g., when creating a
Chris@82 10632 # static archive out of a convenience library, or when linking
Chris@82 10633 # the entirety of a libtool archive into another (currently
Chris@82 10634 # not supported by libtool).
Chris@82 10635 if (for obj in $oldobjs
Chris@82 10636 do
Chris@82 10637 func_basename "$obj"
Chris@82 10638 $ECHO "$func_basename_result"
Chris@82 10639 done | sort | sort -uc >/dev/null 2>&1); then
Chris@82 10640 :
Chris@82 10641 else
Chris@82 10642 echo "copying selected object files to avoid basename conflicts..."
Chris@82 10643 gentop=$output_objdir/${outputname}x
Chris@82 10644 func_append generated " $gentop"
Chris@82 10645 func_mkdir_p "$gentop"
Chris@82 10646 save_oldobjs=$oldobjs
Chris@82 10647 oldobjs=
Chris@82 10648 counter=1
Chris@82 10649 for obj in $save_oldobjs
Chris@82 10650 do
Chris@82 10651 func_basename "$obj"
Chris@82 10652 objbase=$func_basename_result
Chris@82 10653 case " $oldobjs " in
Chris@82 10654 " ") oldobjs=$obj ;;
Chris@82 10655 *[\ /]"$objbase "*)
Chris@82 10656 while :; do
Chris@82 10657 # Make sure we don't pick an alternate name that also
Chris@82 10658 # overlaps.
Chris@82 10659 newobj=lt$counter-$objbase
Chris@82 10660 func_arith $counter + 1
Chris@82 10661 counter=$func_arith_result
Chris@82 10662 case " $oldobjs " in
Chris@82 10663 *[\ /]"$newobj "*) ;;
Chris@82 10664 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
Chris@82 10665 esac
Chris@82 10666 done
Chris@82 10667 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
Chris@82 10668 func_append oldobjs " $gentop/$newobj"
Chris@82 10669 ;;
Chris@82 10670 *) func_append oldobjs " $obj" ;;
Chris@82 10671 esac
Chris@82 10672 done
Chris@82 10673 fi
Chris@82 10674 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
Chris@82 10675 tool_oldlib=$func_to_tool_file_result
Chris@82 10676 eval cmds=\"$old_archive_cmds\"
Chris@82 10677
Chris@82 10678 func_len " $cmds"
Chris@82 10679 len=$func_len_result
Chris@82 10680 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
Chris@82 10681 cmds=$old_archive_cmds
Chris@82 10682 elif test -n "$archiver_list_spec"; then
Chris@82 10683 func_verbose "using command file archive linking..."
Chris@82 10684 for obj in $oldobjs
Chris@82 10685 do
Chris@82 10686 func_to_tool_file "$obj"
Chris@82 10687 $ECHO "$func_to_tool_file_result"
Chris@82 10688 done > $output_objdir/$libname.libcmd
Chris@82 10689 func_to_tool_file "$output_objdir/$libname.libcmd"
Chris@82 10690 oldobjs=" $archiver_list_spec$func_to_tool_file_result"
Chris@82 10691 cmds=$old_archive_cmds
Chris@82 10692 else
Chris@82 10693 # the command line is too long to link in one step, link in parts
Chris@82 10694 func_verbose "using piecewise archive linking..."
Chris@82 10695 save_RANLIB=$RANLIB
Chris@82 10696 RANLIB=:
Chris@82 10697 objlist=
Chris@82 10698 concat_cmds=
Chris@82 10699 save_oldobjs=$oldobjs
Chris@82 10700 oldobjs=
Chris@82 10701 # Is there a better way of finding the last object in the list?
Chris@82 10702 for obj in $save_oldobjs
Chris@82 10703 do
Chris@82 10704 last_oldobj=$obj
Chris@82 10705 done
Chris@82 10706 eval test_cmds=\"$old_archive_cmds\"
Chris@82 10707 func_len " $test_cmds"
Chris@82 10708 len0=$func_len_result
Chris@82 10709 len=$len0
Chris@82 10710 for obj in $save_oldobjs
Chris@82 10711 do
Chris@82 10712 func_len " $obj"
Chris@82 10713 func_arith $len + $func_len_result
Chris@82 10714 len=$func_arith_result
Chris@82 10715 func_append objlist " $obj"
Chris@82 10716 if test "$len" -lt "$max_cmd_len"; then
Chris@82 10717 :
Chris@82 10718 else
Chris@82 10719 # the above command should be used before it gets too long
Chris@82 10720 oldobjs=$objlist
Chris@82 10721 if test "$obj" = "$last_oldobj"; then
Chris@82 10722 RANLIB=$save_RANLIB
Chris@82 10723 fi
Chris@82 10724 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
Chris@82 10725 eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
Chris@82 10726 objlist=
Chris@82 10727 len=$len0
Chris@82 10728 fi
Chris@82 10729 done
Chris@82 10730 RANLIB=$save_RANLIB
Chris@82 10731 oldobjs=$objlist
Chris@82 10732 if test -z "$oldobjs"; then
Chris@82 10733 eval cmds=\"\$concat_cmds\"
Chris@82 10734 else
Chris@82 10735 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
Chris@82 10736 fi
Chris@82 10737 fi
Chris@82 10738 fi
Chris@82 10739 func_execute_cmds "$cmds" 'exit $?'
Chris@82 10740 done
Chris@82 10741
Chris@82 10742 test -n "$generated" && \
Chris@82 10743 func_show_eval "${RM}r$generated"
Chris@82 10744
Chris@82 10745 # Now create the libtool archive.
Chris@82 10746 case $output in
Chris@82 10747 *.la)
Chris@82 10748 old_library=
Chris@82 10749 test yes = "$build_old_libs" && old_library=$libname.$libext
Chris@82 10750 func_verbose "creating $output"
Chris@82 10751
Chris@82 10752 # Preserve any variables that may affect compiler behavior
Chris@82 10753 for var in $variables_saved_for_relink; do
Chris@82 10754 if eval test -z \"\${$var+set}\"; then
Chris@82 10755 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
Chris@82 10756 elif eval var_value=\$$var; test -z "$var_value"; then
Chris@82 10757 relink_command="$var=; export $var; $relink_command"
Chris@82 10758 else
Chris@82 10759 func_quote_for_eval "$var_value"
Chris@82 10760 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
Chris@82 10761 fi
Chris@82 10762 done
Chris@82 10763 # Quote the link command for shipping.
Chris@82 10764 relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
Chris@82 10765 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
Chris@82 10766 if test yes = "$hardcode_automatic"; then
Chris@82 10767 relink_command=
Chris@82 10768 fi
Chris@82 10769
Chris@82 10770 # Only create the output if not a dry run.
Chris@82 10771 $opt_dry_run || {
Chris@82 10772 for installed in no yes; do
Chris@82 10773 if test yes = "$installed"; then
Chris@82 10774 if test -z "$install_libdir"; then
Chris@82 10775 break
Chris@82 10776 fi
Chris@82 10777 output=$output_objdir/${outputname}i
Chris@82 10778 # Replace all uninstalled libtool libraries with the installed ones
Chris@82 10779 newdependency_libs=
Chris@82 10780 for deplib in $dependency_libs; do
Chris@82 10781 case $deplib in
Chris@82 10782 *.la)
Chris@82 10783 func_basename "$deplib"
Chris@82 10784 name=$func_basename_result
Chris@82 10785 func_resolve_sysroot "$deplib"
Chris@82 10786 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
Chris@82 10787 test -z "$libdir" && \
Chris@82 10788 func_fatal_error "'$deplib' is not a valid libtool archive"
Chris@82 10789 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
Chris@82 10790 ;;
Chris@82 10791 -L*)
Chris@82 10792 func_stripname -L '' "$deplib"
Chris@82 10793 func_replace_sysroot "$func_stripname_result"
Chris@82 10794 func_append newdependency_libs " -L$func_replace_sysroot_result"
Chris@82 10795 ;;
Chris@82 10796 -R*)
Chris@82 10797 func_stripname -R '' "$deplib"
Chris@82 10798 func_replace_sysroot "$func_stripname_result"
Chris@82 10799 func_append newdependency_libs " -R$func_replace_sysroot_result"
Chris@82 10800 ;;
Chris@82 10801 *) func_append newdependency_libs " $deplib" ;;
Chris@82 10802 esac
Chris@82 10803 done
Chris@82 10804 dependency_libs=$newdependency_libs
Chris@82 10805 newdlfiles=
Chris@82 10806
Chris@82 10807 for lib in $dlfiles; do
Chris@82 10808 case $lib in
Chris@82 10809 *.la)
Chris@82 10810 func_basename "$lib"
Chris@82 10811 name=$func_basename_result
Chris@82 10812 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
Chris@82 10813 test -z "$libdir" && \
Chris@82 10814 func_fatal_error "'$lib' is not a valid libtool archive"
Chris@82 10815 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
Chris@82 10816 ;;
Chris@82 10817 *) func_append newdlfiles " $lib" ;;
Chris@82 10818 esac
Chris@82 10819 done
Chris@82 10820 dlfiles=$newdlfiles
Chris@82 10821 newdlprefiles=
Chris@82 10822 for lib in $dlprefiles; do
Chris@82 10823 case $lib in
Chris@82 10824 *.la)
Chris@82 10825 # Only pass preopened files to the pseudo-archive (for
Chris@82 10826 # eventual linking with the app. that links it) if we
Chris@82 10827 # didn't already link the preopened objects directly into
Chris@82 10828 # the library:
Chris@82 10829 func_basename "$lib"
Chris@82 10830 name=$func_basename_result
Chris@82 10831 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
Chris@82 10832 test -z "$libdir" && \
Chris@82 10833 func_fatal_error "'$lib' is not a valid libtool archive"
Chris@82 10834 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
Chris@82 10835 ;;
Chris@82 10836 esac
Chris@82 10837 done
Chris@82 10838 dlprefiles=$newdlprefiles
Chris@82 10839 else
Chris@82 10840 newdlfiles=
Chris@82 10841 for lib in $dlfiles; do
Chris@82 10842 case $lib in
Chris@82 10843 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
Chris@82 10844 *) abs=`pwd`"/$lib" ;;
Chris@82 10845 esac
Chris@82 10846 func_append newdlfiles " $abs"
Chris@82 10847 done
Chris@82 10848 dlfiles=$newdlfiles
Chris@82 10849 newdlprefiles=
Chris@82 10850 for lib in $dlprefiles; do
Chris@82 10851 case $lib in
Chris@82 10852 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
Chris@82 10853 *) abs=`pwd`"/$lib" ;;
Chris@82 10854 esac
Chris@82 10855 func_append newdlprefiles " $abs"
Chris@82 10856 done
Chris@82 10857 dlprefiles=$newdlprefiles
Chris@82 10858 fi
Chris@82 10859 $RM $output
Chris@82 10860 # place dlname in correct position for cygwin
Chris@82 10861 # In fact, it would be nice if we could use this code for all target
Chris@82 10862 # systems that can't hard-code library paths into their executables
Chris@82 10863 # and that have no shared library path variable independent of PATH,
Chris@82 10864 # but it turns out we can't easily determine that from inspecting
Chris@82 10865 # libtool variables, so we have to hard-code the OSs to which it
Chris@82 10866 # applies here; at the moment, that means platforms that use the PE
Chris@82 10867 # object format with DLL files. See the long comment at the top of
Chris@82 10868 # tests/bindir.at for full details.
Chris@82 10869 tdlname=$dlname
Chris@82 10870 case $host,$output,$installed,$module,$dlname in
Chris@82 10871 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
Chris@82 10872 # If a -bindir argument was supplied, place the dll there.
Chris@82 10873 if test -n "$bindir"; then
Chris@82 10874 func_relative_path "$install_libdir" "$bindir"
Chris@82 10875 tdlname=$func_relative_path_result/$dlname
Chris@82 10876 else
Chris@82 10877 # Otherwise fall back on heuristic.
Chris@82 10878 tdlname=../bin/$dlname
Chris@82 10879 fi
Chris@82 10880 ;;
Chris@82 10881 esac
Chris@82 10882 $ECHO > $output "\
Chris@82 10883 # $outputname - a libtool library file
Chris@82 10884 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
Chris@82 10885 #
Chris@82 10886 # Please DO NOT delete this file!
Chris@82 10887 # It is necessary for linking the library.
Chris@82 10888
Chris@82 10889 # The name that we can dlopen(3).
Chris@82 10890 dlname='$tdlname'
Chris@82 10891
Chris@82 10892 # Names of this library.
Chris@82 10893 library_names='$library_names'
Chris@82 10894
Chris@82 10895 # The name of the static archive.
Chris@82 10896 old_library='$old_library'
Chris@82 10897
Chris@82 10898 # Linker flags that cannot go in dependency_libs.
Chris@82 10899 inherited_linker_flags='$new_inherited_linker_flags'
Chris@82 10900
Chris@82 10901 # Libraries that this one depends upon.
Chris@82 10902 dependency_libs='$dependency_libs'
Chris@82 10903
Chris@82 10904 # Names of additional weak libraries provided by this library
Chris@82 10905 weak_library_names='$weak_libs'
Chris@82 10906
Chris@82 10907 # Version information for $libname.
Chris@82 10908 current=$current
Chris@82 10909 age=$age
Chris@82 10910 revision=$revision
Chris@82 10911
Chris@82 10912 # Is this an already installed library?
Chris@82 10913 installed=$installed
Chris@82 10914
Chris@82 10915 # Should we warn about portability when linking against -modules?
Chris@82 10916 shouldnotlink=$module
Chris@82 10917
Chris@82 10918 # Files to dlopen/dlpreopen
Chris@82 10919 dlopen='$dlfiles'
Chris@82 10920 dlpreopen='$dlprefiles'
Chris@82 10921
Chris@82 10922 # Directory that this library needs to be installed in:
Chris@82 10923 libdir='$install_libdir'"
Chris@82 10924 if test no,yes = "$installed,$need_relink"; then
Chris@82 10925 $ECHO >> $output "\
Chris@82 10926 relink_command=\"$relink_command\""
Chris@82 10927 fi
Chris@82 10928 done
Chris@82 10929 }
Chris@82 10930
Chris@82 10931 # Do a symbolic link so that the libtool archive can be found in
Chris@82 10932 # LD_LIBRARY_PATH before the program is installed.
Chris@82 10933 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
Chris@82 10934 ;;
Chris@82 10935 esac
Chris@82 10936 exit $EXIT_SUCCESS
Chris@82 10937 }
Chris@82 10938
Chris@82 10939 if test link = "$opt_mode" || test relink = "$opt_mode"; then
Chris@82 10940 func_mode_link ${1+"$@"}
Chris@82 10941 fi
Chris@82 10942
Chris@82 10943
Chris@82 10944 # func_mode_uninstall arg...
Chris@82 10945 func_mode_uninstall ()
Chris@82 10946 {
Chris@82 10947 $debug_cmd
Chris@82 10948
Chris@82 10949 RM=$nonopt
Chris@82 10950 files=
Chris@82 10951 rmforce=false
Chris@82 10952 exit_status=0
Chris@82 10953
Chris@82 10954 # This variable tells wrapper scripts just to set variables rather
Chris@82 10955 # than running their programs.
Chris@82 10956 libtool_install_magic=$magic
Chris@82 10957
Chris@82 10958 for arg
Chris@82 10959 do
Chris@82 10960 case $arg in
Chris@82 10961 -f) func_append RM " $arg"; rmforce=: ;;
Chris@82 10962 -*) func_append RM " $arg" ;;
Chris@82 10963 *) func_append files " $arg" ;;
Chris@82 10964 esac
Chris@82 10965 done
Chris@82 10966
Chris@82 10967 test -z "$RM" && \
Chris@82 10968 func_fatal_help "you must specify an RM program"
Chris@82 10969
Chris@82 10970 rmdirs=
Chris@82 10971
Chris@82 10972 for file in $files; do
Chris@82 10973 func_dirname "$file" "" "."
Chris@82 10974 dir=$func_dirname_result
Chris@82 10975 if test . = "$dir"; then
Chris@82 10976 odir=$objdir
Chris@82 10977 else
Chris@82 10978 odir=$dir/$objdir
Chris@82 10979 fi
Chris@82 10980 func_basename "$file"
Chris@82 10981 name=$func_basename_result
Chris@82 10982 test uninstall = "$opt_mode" && odir=$dir
Chris@82 10983
Chris@82 10984 # Remember odir for removal later, being careful to avoid duplicates
Chris@82 10985 if test clean = "$opt_mode"; then
Chris@82 10986 case " $rmdirs " in
Chris@82 10987 *" $odir "*) ;;
Chris@82 10988 *) func_append rmdirs " $odir" ;;
Chris@82 10989 esac
Chris@82 10990 fi
Chris@82 10991
Chris@82 10992 # Don't error if the file doesn't exist and rm -f was used.
Chris@82 10993 if { test -L "$file"; } >/dev/null 2>&1 ||
Chris@82 10994 { test -h "$file"; } >/dev/null 2>&1 ||
Chris@82 10995 test -f "$file"; then
Chris@82 10996 :
Chris@82 10997 elif test -d "$file"; then
Chris@82 10998 exit_status=1
Chris@82 10999 continue
Chris@82 11000 elif $rmforce; then
Chris@82 11001 continue
Chris@82 11002 fi
Chris@82 11003
Chris@82 11004 rmfiles=$file
Chris@82 11005
Chris@82 11006 case $name in
Chris@82 11007 *.la)
Chris@82 11008 # Possibly a libtool archive, so verify it.
Chris@82 11009 if func_lalib_p "$file"; then
Chris@82 11010 func_source $dir/$name
Chris@82 11011
Chris@82 11012 # Delete the libtool libraries and symlinks.
Chris@82 11013 for n in $library_names; do
Chris@82 11014 func_append rmfiles " $odir/$n"
Chris@82 11015 done
Chris@82 11016 test -n "$old_library" && func_append rmfiles " $odir/$old_library"
Chris@82 11017
Chris@82 11018 case $opt_mode in
Chris@82 11019 clean)
Chris@82 11020 case " $library_names " in
Chris@82 11021 *" $dlname "*) ;;
Chris@82 11022 *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
Chris@82 11023 esac
Chris@82 11024 test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
Chris@82 11025 ;;
Chris@82 11026 uninstall)
Chris@82 11027 if test -n "$library_names"; then
Chris@82 11028 # Do each command in the postuninstall commands.
Chris@82 11029 func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
Chris@82 11030 fi
Chris@82 11031
Chris@82 11032 if test -n "$old_library"; then
Chris@82 11033 # Do each command in the old_postuninstall commands.
Chris@82 11034 func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
Chris@82 11035 fi
Chris@82 11036 # FIXME: should reinstall the best remaining shared library.
Chris@82 11037 ;;
Chris@82 11038 esac
Chris@82 11039 fi
Chris@82 11040 ;;
Chris@82 11041
Chris@82 11042 *.lo)
Chris@82 11043 # Possibly a libtool object, so verify it.
Chris@82 11044 if func_lalib_p "$file"; then
Chris@82 11045
Chris@82 11046 # Read the .lo file
Chris@82 11047 func_source $dir/$name
Chris@82 11048
Chris@82 11049 # Add PIC object to the list of files to remove.
Chris@82 11050 if test -n "$pic_object" && test none != "$pic_object"; then
Chris@82 11051 func_append rmfiles " $dir/$pic_object"
Chris@82 11052 fi
Chris@82 11053
Chris@82 11054 # Add non-PIC object to the list of files to remove.
Chris@82 11055 if test -n "$non_pic_object" && test none != "$non_pic_object"; then
Chris@82 11056 func_append rmfiles " $dir/$non_pic_object"
Chris@82 11057 fi
Chris@82 11058 fi
Chris@82 11059 ;;
Chris@82 11060
Chris@82 11061 *)
Chris@82 11062 if test clean = "$opt_mode"; then
Chris@82 11063 noexename=$name
Chris@82 11064 case $file in
Chris@82 11065 *.exe)
Chris@82 11066 func_stripname '' '.exe' "$file"
Chris@82 11067 file=$func_stripname_result
Chris@82 11068 func_stripname '' '.exe' "$name"
Chris@82 11069 noexename=$func_stripname_result
Chris@82 11070 # $file with .exe has already been added to rmfiles,
Chris@82 11071 # add $file without .exe
Chris@82 11072 func_append rmfiles " $file"
Chris@82 11073 ;;
Chris@82 11074 esac
Chris@82 11075 # Do a test to see if this is a libtool program.
Chris@82 11076 if func_ltwrapper_p "$file"; then
Chris@82 11077 if func_ltwrapper_executable_p "$file"; then
Chris@82 11078 func_ltwrapper_scriptname "$file"
Chris@82 11079 relink_command=
Chris@82 11080 func_source $func_ltwrapper_scriptname_result
Chris@82 11081 func_append rmfiles " $func_ltwrapper_scriptname_result"
Chris@82 11082 else
Chris@82 11083 relink_command=
Chris@82 11084 func_source $dir/$noexename
Chris@82 11085 fi
Chris@82 11086
Chris@82 11087 # note $name still contains .exe if it was in $file originally
Chris@82 11088 # as does the version of $file that was added into $rmfiles
Chris@82 11089 func_append rmfiles " $odir/$name $odir/${name}S.$objext"
Chris@82 11090 if test yes = "$fast_install" && test -n "$relink_command"; then
Chris@82 11091 func_append rmfiles " $odir/lt-$name"
Chris@82 11092 fi
Chris@82 11093 if test "X$noexename" != "X$name"; then
Chris@82 11094 func_append rmfiles " $odir/lt-$noexename.c"
Chris@82 11095 fi
Chris@82 11096 fi
Chris@82 11097 fi
Chris@82 11098 ;;
Chris@82 11099 esac
Chris@82 11100 func_show_eval "$RM $rmfiles" 'exit_status=1'
Chris@82 11101 done
Chris@82 11102
Chris@82 11103 # Try to remove the $objdir's in the directories where we deleted files
Chris@82 11104 for dir in $rmdirs; do
Chris@82 11105 if test -d "$dir"; then
Chris@82 11106 func_show_eval "rmdir $dir >/dev/null 2>&1"
Chris@82 11107 fi
Chris@82 11108 done
Chris@82 11109
Chris@82 11110 exit $exit_status
Chris@82 11111 }
Chris@82 11112
Chris@82 11113 if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
Chris@82 11114 func_mode_uninstall ${1+"$@"}
Chris@82 11115 fi
Chris@82 11116
Chris@82 11117 test -z "$opt_mode" && {
Chris@82 11118 help=$generic_help
Chris@82 11119 func_fatal_help "you must specify a MODE"
Chris@82 11120 }
Chris@82 11121
Chris@82 11122 test -z "$exec_cmd" && \
Chris@82 11123 func_fatal_help "invalid operation mode '$opt_mode'"
Chris@82 11124
Chris@82 11125 if test -n "$exec_cmd"; then
Chris@82 11126 eval exec "$exec_cmd"
Chris@82 11127 exit $EXIT_FAILURE
Chris@82 11128 fi
Chris@82 11129
Chris@82 11130 exit $exit_status
Chris@82 11131
Chris@82 11132
Chris@82 11133 # The TAGs below are defined such that we never get into a situation
Chris@82 11134 # where we disable both kinds of libraries. Given conflicting
Chris@82 11135 # choices, we go for a static library, that is the most portable,
Chris@82 11136 # since we can't tell whether shared libraries were disabled because
Chris@82 11137 # the user asked for that or because the platform doesn't support
Chris@82 11138 # them. This is particularly important on AIX, because we don't
Chris@82 11139 # support having both static and shared libraries enabled at the same
Chris@82 11140 # time on that platform, so we default to a shared-only configuration.
Chris@82 11141 # If a disable-shared tag is given, we'll fallback to a static-only
Chris@82 11142 # configuration. But we'll never go from static-only to shared-only.
Chris@82 11143
Chris@82 11144 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
Chris@82 11145 build_libtool_libs=no
Chris@82 11146 build_old_libs=yes
Chris@82 11147 # ### END LIBTOOL TAG CONFIG: disable-shared
Chris@82 11148
Chris@82 11149 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
Chris@82 11150 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
Chris@82 11151 # ### END LIBTOOL TAG CONFIG: disable-static
Chris@82 11152
Chris@82 11153 # Local Variables:
Chris@82 11154 # mode:shell-script
Chris@82 11155 # sh-indentation:2
Chris@82 11156 # End: