annotate src/libsndfile-1.0.27/Cfg/ltmain.sh @ 169:223a55898ab9 tip default

Add null config files
author Chris Cannam <cannam@all-day-breakfast.com>
date Mon, 02 Mar 2020 14:03:47 +0000
parents cd6cdf86811e
children
rev   line source
cannam@125 1 #! /bin/sh
cannam@125 2 ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
cannam@125 3 ## by inline-source v2014-01-03.01
cannam@125 4
cannam@125 5 # libtool (GNU libtool) 2.4.6
cannam@125 6 # Provide generalized library-building support services.
cannam@125 7 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
cannam@125 8
cannam@125 9 # Copyright (C) 1996-2015 Free Software Foundation, Inc.
cannam@125 10 # This is free software; see the source for copying conditions. There is NO
cannam@125 11 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cannam@125 12
cannam@125 13 # GNU Libtool is free software; you can redistribute it and/or modify
cannam@125 14 # it under the terms of the GNU General Public License as published by
cannam@125 15 # the Free Software Foundation; either version 2 of the License, or
cannam@125 16 # (at your option) any later version.
cannam@125 17 #
cannam@125 18 # As a special exception to the GNU General Public License,
cannam@125 19 # if you distribute this file as part of a program or library that
cannam@125 20 # is built using GNU Libtool, you may include this file under the
cannam@125 21 # same distribution terms that you use for the rest of that program.
cannam@125 22 #
cannam@125 23 # GNU Libtool is distributed in the hope that it will be useful, but
cannam@125 24 # WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@125 25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cannam@125 26 # General Public License for more details.
cannam@125 27 #
cannam@125 28 # You should have received a copy of the GNU General Public License
cannam@125 29 # along with this program. If not, see <http://www.gnu.org/licenses/>.
cannam@125 30
cannam@125 31
cannam@125 32 PROGRAM=libtool
cannam@125 33 PACKAGE=libtool
cannam@125 34 VERSION="2.4.6 Debian-2.4.6-0.1"
cannam@125 35 package_revision=2.4.6
cannam@125 36
cannam@125 37
cannam@125 38 ## ------ ##
cannam@125 39 ## Usage. ##
cannam@125 40 ## ------ ##
cannam@125 41
cannam@125 42 # Run './libtool --help' for help with using this script from the
cannam@125 43 # command line.
cannam@125 44
cannam@125 45
cannam@125 46 ## ------------------------------- ##
cannam@125 47 ## User overridable command paths. ##
cannam@125 48 ## ------------------------------- ##
cannam@125 49
cannam@125 50 # After configure completes, it has a better idea of some of the
cannam@125 51 # shell tools we need than the defaults used by the functions shared
cannam@125 52 # with bootstrap, so set those here where they can still be over-
cannam@125 53 # ridden by the user, but otherwise take precedence.
cannam@125 54
cannam@125 55 : ${AUTOCONF="autoconf"}
cannam@125 56 : ${AUTOMAKE="automake"}
cannam@125 57
cannam@125 58
cannam@125 59 ## -------------------------- ##
cannam@125 60 ## Source external libraries. ##
cannam@125 61 ## -------------------------- ##
cannam@125 62
cannam@125 63 # Much of our low-level functionality needs to be sourced from external
cannam@125 64 # libraries, which are installed to $pkgauxdir.
cannam@125 65
cannam@125 66 # Set a version string for this script.
cannam@125 67 scriptversion=2015-01-20.17; # UTC
cannam@125 68
cannam@125 69 # General shell script boiler plate, and helper functions.
cannam@125 70 # Written by Gary V. Vaughan, 2004
cannam@125 71
cannam@125 72 # Copyright (C) 2004-2015 Free Software Foundation, Inc.
cannam@125 73 # This is free software; see the source for copying conditions. There is NO
cannam@125 74 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cannam@125 75
cannam@125 76 # This program is free software; you can redistribute it and/or modify
cannam@125 77 # it under the terms of the GNU General Public License as published by
cannam@125 78 # the Free Software Foundation; either version 3 of the License, or
cannam@125 79 # (at your option) any later version.
cannam@125 80
cannam@125 81 # As a special exception to the GNU General Public License, if you distribute
cannam@125 82 # this file as part of a program or library that is built using GNU Libtool,
cannam@125 83 # you may include this file under the same distribution terms that you use
cannam@125 84 # for the rest of that program.
cannam@125 85
cannam@125 86 # This program is distributed in the hope that it will be useful,
cannam@125 87 # but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@125 88 # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
cannam@125 89 # General Public License for more details.
cannam@125 90
cannam@125 91 # You should have received a copy of the GNU General Public License
cannam@125 92 # along with this program. If not, see <http://www.gnu.org/licenses/>.
cannam@125 93
cannam@125 94 # Please report bugs or propose patches to gary@gnu.org.
cannam@125 95
cannam@125 96
cannam@125 97 ## ------ ##
cannam@125 98 ## Usage. ##
cannam@125 99 ## ------ ##
cannam@125 100
cannam@125 101 # Evaluate this file near the top of your script to gain access to
cannam@125 102 # the functions and variables defined here:
cannam@125 103 #
cannam@125 104 # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
cannam@125 105 #
cannam@125 106 # If you need to override any of the default environment variable
cannam@125 107 # settings, do that before evaluating this file.
cannam@125 108
cannam@125 109
cannam@125 110 ## -------------------- ##
cannam@125 111 ## Shell normalisation. ##
cannam@125 112 ## -------------------- ##
cannam@125 113
cannam@125 114 # Some shells need a little help to be as Bourne compatible as possible.
cannam@125 115 # Before doing anything else, make sure all that help has been provided!
cannam@125 116
cannam@125 117 DUALCASE=1; export DUALCASE # for MKS sh
cannam@125 118 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
cannam@125 119 emulate sh
cannam@125 120 NULLCMD=:
cannam@125 121 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
cannam@125 122 # is contrary to our usage. Disable this feature.
cannam@125 123 alias -g '${1+"$@"}'='"$@"'
cannam@125 124 setopt NO_GLOB_SUBST
cannam@125 125 else
cannam@125 126 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
cannam@125 127 fi
cannam@125 128
cannam@125 129 # NLS nuisances: We save the old values in case they are required later.
cannam@125 130 _G_user_locale=
cannam@125 131 _G_safe_locale=
cannam@125 132 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
cannam@125 133 do
cannam@125 134 eval "if test set = \"\${$_G_var+set}\"; then
cannam@125 135 save_$_G_var=\$$_G_var
cannam@125 136 $_G_var=C
cannam@125 137 export $_G_var
cannam@125 138 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
cannam@125 139 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
cannam@125 140 fi"
cannam@125 141 done
cannam@125 142
cannam@125 143 # CDPATH.
cannam@125 144 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
cannam@125 145
cannam@125 146 # Make sure IFS has a sensible default
cannam@125 147 sp=' '
cannam@125 148 nl='
cannam@125 149 '
cannam@125 150 IFS="$sp $nl"
cannam@125 151
cannam@125 152 # There are apparently some retarded systems that use ';' as a PATH separator!
cannam@125 153 if test "${PATH_SEPARATOR+set}" != set; then
cannam@125 154 PATH_SEPARATOR=:
cannam@125 155 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
cannam@125 156 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
cannam@125 157 PATH_SEPARATOR=';'
cannam@125 158 }
cannam@125 159 fi
cannam@125 160
cannam@125 161
cannam@125 162
cannam@125 163 ## ------------------------- ##
cannam@125 164 ## Locate command utilities. ##
cannam@125 165 ## ------------------------- ##
cannam@125 166
cannam@125 167
cannam@125 168 # func_executable_p FILE
cannam@125 169 # ----------------------
cannam@125 170 # Check that FILE is an executable regular file.
cannam@125 171 func_executable_p ()
cannam@125 172 {
cannam@125 173 test -f "$1" && test -x "$1"
cannam@125 174 }
cannam@125 175
cannam@125 176
cannam@125 177 # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
cannam@125 178 # --------------------------------------------
cannam@125 179 # Search for either a program that responds to --version with output
cannam@125 180 # containing "GNU", or else returned by CHECK_FUNC otherwise, by
cannam@125 181 # trying all the directories in PATH with each of the elements of
cannam@125 182 # PROGS_LIST.
cannam@125 183 #
cannam@125 184 # CHECK_FUNC should accept the path to a candidate program, and
cannam@125 185 # set $func_check_prog_result if it truncates its output less than
cannam@125 186 # $_G_path_prog_max characters.
cannam@125 187 func_path_progs ()
cannam@125 188 {
cannam@125 189 _G_progs_list=$1
cannam@125 190 _G_check_func=$2
cannam@125 191 _G_PATH=${3-"$PATH"}
cannam@125 192
cannam@125 193 _G_path_prog_max=0
cannam@125 194 _G_path_prog_found=false
cannam@125 195 _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
cannam@125 196 for _G_dir in $_G_PATH; do
cannam@125 197 IFS=$_G_save_IFS
cannam@125 198 test -z "$_G_dir" && _G_dir=.
cannam@125 199 for _G_prog_name in $_G_progs_list; do
cannam@125 200 for _exeext in '' .EXE; do
cannam@125 201 _G_path_prog=$_G_dir/$_G_prog_name$_exeext
cannam@125 202 func_executable_p "$_G_path_prog" || continue
cannam@125 203 case `"$_G_path_prog" --version 2>&1` in
cannam@125 204 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
cannam@125 205 *) $_G_check_func $_G_path_prog
cannam@125 206 func_path_progs_result=$func_check_prog_result
cannam@125 207 ;;
cannam@125 208 esac
cannam@125 209 $_G_path_prog_found && break 3
cannam@125 210 done
cannam@125 211 done
cannam@125 212 done
cannam@125 213 IFS=$_G_save_IFS
cannam@125 214 test -z "$func_path_progs_result" && {
cannam@125 215 echo "no acceptable sed could be found in \$PATH" >&2
cannam@125 216 exit 1
cannam@125 217 }
cannam@125 218 }
cannam@125 219
cannam@125 220
cannam@125 221 # We want to be able to use the functions in this file before configure
cannam@125 222 # has figured out where the best binaries are kept, which means we have
cannam@125 223 # to search for them ourselves - except when the results are already set
cannam@125 224 # where we skip the searches.
cannam@125 225
cannam@125 226 # Unless the user overrides by setting SED, search the path for either GNU
cannam@125 227 # sed, or the sed that truncates its output the least.
cannam@125 228 test -z "$SED" && {
cannam@125 229 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
cannam@125 230 for _G_i in 1 2 3 4 5 6 7; do
cannam@125 231 _G_sed_script=$_G_sed_script$nl$_G_sed_script
cannam@125 232 done
cannam@125 233 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
cannam@125 234 _G_sed_script=
cannam@125 235
cannam@125 236 func_check_prog_sed ()
cannam@125 237 {
cannam@125 238 _G_path_prog=$1
cannam@125 239
cannam@125 240 _G_count=0
cannam@125 241 printf 0123456789 >conftest.in
cannam@125 242 while :
cannam@125 243 do
cannam@125 244 cat conftest.in conftest.in >conftest.tmp
cannam@125 245 mv conftest.tmp conftest.in
cannam@125 246 cp conftest.in conftest.nl
cannam@125 247 echo '' >> conftest.nl
cannam@125 248 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
cannam@125 249 diff conftest.out conftest.nl >/dev/null 2>&1 || break
cannam@125 250 _G_count=`expr $_G_count + 1`
cannam@125 251 if test "$_G_count" -gt "$_G_path_prog_max"; then
cannam@125 252 # Best one so far, save it but keep looking for a better one
cannam@125 253 func_check_prog_result=$_G_path_prog
cannam@125 254 _G_path_prog_max=$_G_count
cannam@125 255 fi
cannam@125 256 # 10*(2^10) chars as input seems more than enough
cannam@125 257 test 10 -lt "$_G_count" && break
cannam@125 258 done
cannam@125 259 rm -f conftest.in conftest.tmp conftest.nl conftest.out
cannam@125 260 }
cannam@125 261
cannam@125 262 func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
cannam@125 263 rm -f conftest.sed
cannam@125 264 SED=$func_path_progs_result
cannam@125 265 }
cannam@125 266
cannam@125 267
cannam@125 268 # Unless the user overrides by setting GREP, search the path for either GNU
cannam@125 269 # grep, or the grep that truncates its output the least.
cannam@125 270 test -z "$GREP" && {
cannam@125 271 func_check_prog_grep ()
cannam@125 272 {
cannam@125 273 _G_path_prog=$1
cannam@125 274
cannam@125 275 _G_count=0
cannam@125 276 _G_path_prog_max=0
cannam@125 277 printf 0123456789 >conftest.in
cannam@125 278 while :
cannam@125 279 do
cannam@125 280 cat conftest.in conftest.in >conftest.tmp
cannam@125 281 mv conftest.tmp conftest.in
cannam@125 282 cp conftest.in conftest.nl
cannam@125 283 echo 'GREP' >> conftest.nl
cannam@125 284 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
cannam@125 285 diff conftest.out conftest.nl >/dev/null 2>&1 || break
cannam@125 286 _G_count=`expr $_G_count + 1`
cannam@125 287 if test "$_G_count" -gt "$_G_path_prog_max"; then
cannam@125 288 # Best one so far, save it but keep looking for a better one
cannam@125 289 func_check_prog_result=$_G_path_prog
cannam@125 290 _G_path_prog_max=$_G_count
cannam@125 291 fi
cannam@125 292 # 10*(2^10) chars as input seems more than enough
cannam@125 293 test 10 -lt "$_G_count" && break
cannam@125 294 done
cannam@125 295 rm -f conftest.in conftest.tmp conftest.nl conftest.out
cannam@125 296 }
cannam@125 297
cannam@125 298 func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
cannam@125 299 GREP=$func_path_progs_result
cannam@125 300 }
cannam@125 301
cannam@125 302
cannam@125 303 ## ------------------------------- ##
cannam@125 304 ## User overridable command paths. ##
cannam@125 305 ## ------------------------------- ##
cannam@125 306
cannam@125 307 # All uppercase variable names are used for environment variables. These
cannam@125 308 # variables can be overridden by the user before calling a script that
cannam@125 309 # uses them if a suitable command of that name is not already available
cannam@125 310 # in the command search PATH.
cannam@125 311
cannam@125 312 : ${CP="cp -f"}
cannam@125 313 : ${ECHO="printf %s\n"}
cannam@125 314 : ${EGREP="$GREP -E"}
cannam@125 315 : ${FGREP="$GREP -F"}
cannam@125 316 : ${LN_S="ln -s"}
cannam@125 317 : ${MAKE="make"}
cannam@125 318 : ${MKDIR="mkdir"}
cannam@125 319 : ${MV="mv -f"}
cannam@125 320 : ${RM="rm -f"}
cannam@125 321 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
cannam@125 322
cannam@125 323
cannam@125 324 ## -------------------- ##
cannam@125 325 ## Useful sed snippets. ##
cannam@125 326 ## -------------------- ##
cannam@125 327
cannam@125 328 sed_dirname='s|/[^/]*$||'
cannam@125 329 sed_basename='s|^.*/||'
cannam@125 330
cannam@125 331 # Sed substitution that helps us do robust quoting. It backslashifies
cannam@125 332 # metacharacters that are still active within double-quoted strings.
cannam@125 333 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
cannam@125 334
cannam@125 335 # Same as above, but do not quote variable references.
cannam@125 336 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
cannam@125 337
cannam@125 338 # Sed substitution that turns a string into a regex matching for the
cannam@125 339 # string literally.
cannam@125 340 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
cannam@125 341
cannam@125 342 # Sed substitution that converts a w32 file name or path
cannam@125 343 # that contains forward slashes, into one that contains
cannam@125 344 # (escaped) backslashes. A very naive implementation.
cannam@125 345 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
cannam@125 346
cannam@125 347 # Re-'\' parameter expansions in output of sed_double_quote_subst that
cannam@125 348 # were '\'-ed in input to the same. If an odd number of '\' preceded a
cannam@125 349 # '$' in input to sed_double_quote_subst, that '$' was protected from
cannam@125 350 # expansion. Since each input '\' is now two '\'s, look for any number
cannam@125 351 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
cannam@125 352 _G_bs='\\'
cannam@125 353 _G_bs2='\\\\'
cannam@125 354 _G_bs4='\\\\\\\\'
cannam@125 355 _G_dollar='\$'
cannam@125 356 sed_double_backslash="\
cannam@125 357 s/$_G_bs4/&\\
cannam@125 358 /g
cannam@125 359 s/^$_G_bs2$_G_dollar/$_G_bs&/
cannam@125 360 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
cannam@125 361 s/\n//g"
cannam@125 362
cannam@125 363
cannam@125 364 ## ----------------- ##
cannam@125 365 ## Global variables. ##
cannam@125 366 ## ----------------- ##
cannam@125 367
cannam@125 368 # Except for the global variables explicitly listed below, the following
cannam@125 369 # functions in the '^func_' namespace, and the '^require_' namespace
cannam@125 370 # variables initialised in the 'Resource management' section, sourcing
cannam@125 371 # this file will not pollute your global namespace with anything
cannam@125 372 # else. There's no portable way to scope variables in Bourne shell
cannam@125 373 # though, so actually running these functions will sometimes place
cannam@125 374 # results into a variable named after the function, and often use
cannam@125 375 # temporary variables in the '^_G_' namespace. If you are careful to
cannam@125 376 # avoid using those namespaces casually in your sourcing script, things
cannam@125 377 # should continue to work as you expect. And, of course, you can freely
cannam@125 378 # overwrite any of the functions or variables defined here before
cannam@125 379 # calling anything to customize them.
cannam@125 380
cannam@125 381 EXIT_SUCCESS=0
cannam@125 382 EXIT_FAILURE=1
cannam@125 383 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
cannam@125 384 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
cannam@125 385
cannam@125 386 # Allow overriding, eg assuming that you follow the convention of
cannam@125 387 # putting '$debug_cmd' at the start of all your functions, you can get
cannam@125 388 # bash to show function call trace with:
cannam@125 389 #
cannam@125 390 # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
cannam@125 391 debug_cmd=${debug_cmd-":"}
cannam@125 392 exit_cmd=:
cannam@125 393
cannam@125 394 # By convention, finish your script with:
cannam@125 395 #
cannam@125 396 # exit $exit_status
cannam@125 397 #
cannam@125 398 # so that you can set exit_status to non-zero if you want to indicate
cannam@125 399 # something went wrong during execution without actually bailing out at
cannam@125 400 # the point of failure.
cannam@125 401 exit_status=$EXIT_SUCCESS
cannam@125 402
cannam@125 403 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
cannam@125 404 # is ksh but when the shell is invoked as "sh" and the current value of
cannam@125 405 # the _XPG environment variable is not equal to 1 (one), the special
cannam@125 406 # positional parameter $0, within a function call, is the name of the
cannam@125 407 # function.
cannam@125 408 progpath=$0
cannam@125 409
cannam@125 410 # The name of this program.
cannam@125 411 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
cannam@125 412
cannam@125 413 # Make sure we have an absolute progpath for reexecution:
cannam@125 414 case $progpath in
cannam@125 415 [\\/]*|[A-Za-z]:\\*) ;;
cannam@125 416 *[\\/]*)
cannam@125 417 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
cannam@125 418 progdir=`cd "$progdir" && pwd`
cannam@125 419 progpath=$progdir/$progname
cannam@125 420 ;;
cannam@125 421 *)
cannam@125 422 _G_IFS=$IFS
cannam@125 423 IFS=${PATH_SEPARATOR-:}
cannam@125 424 for progdir in $PATH; do
cannam@125 425 IFS=$_G_IFS
cannam@125 426 test -x "$progdir/$progname" && break
cannam@125 427 done
cannam@125 428 IFS=$_G_IFS
cannam@125 429 test -n "$progdir" || progdir=`pwd`
cannam@125 430 progpath=$progdir/$progname
cannam@125 431 ;;
cannam@125 432 esac
cannam@125 433
cannam@125 434
cannam@125 435 ## ----------------- ##
cannam@125 436 ## Standard options. ##
cannam@125 437 ## ----------------- ##
cannam@125 438
cannam@125 439 # The following options affect the operation of the functions defined
cannam@125 440 # below, and should be set appropriately depending on run-time para-
cannam@125 441 # meters passed on the command line.
cannam@125 442
cannam@125 443 opt_dry_run=false
cannam@125 444 opt_quiet=false
cannam@125 445 opt_verbose=false
cannam@125 446
cannam@125 447 # Categories 'all' and 'none' are always available. Append any others
cannam@125 448 # you will pass as the first argument to func_warning from your own
cannam@125 449 # code.
cannam@125 450 warning_categories=
cannam@125 451
cannam@125 452 # By default, display warnings according to 'opt_warning_types'. Set
cannam@125 453 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
cannam@125 454 # treat the next displayed warning as a fatal error.
cannam@125 455 warning_func=func_warn_and_continue
cannam@125 456
cannam@125 457 # Set to 'all' to display all warnings, 'none' to suppress all
cannam@125 458 # warnings, or a space delimited list of some subset of
cannam@125 459 # 'warning_categories' to display only the listed warnings.
cannam@125 460 opt_warning_types=all
cannam@125 461
cannam@125 462
cannam@125 463 ## -------------------- ##
cannam@125 464 ## Resource management. ##
cannam@125 465 ## -------------------- ##
cannam@125 466
cannam@125 467 # This section contains definitions for functions that each ensure a
cannam@125 468 # particular resource (a file, or a non-empty configuration variable for
cannam@125 469 # example) is available, and if appropriate to extract default values
cannam@125 470 # from pertinent package files. Call them using their associated
cannam@125 471 # 'require_*' variable to ensure that they are executed, at most, once.
cannam@125 472 #
cannam@125 473 # It's entirely deliberate that calling these functions can set
cannam@125 474 # variables that don't obey the namespace limitations obeyed by the rest
cannam@125 475 # of this file, in order that that they be as useful as possible to
cannam@125 476 # callers.
cannam@125 477
cannam@125 478
cannam@125 479 # require_term_colors
cannam@125 480 # -------------------
cannam@125 481 # Allow display of bold text on terminals that support it.
cannam@125 482 require_term_colors=func_require_term_colors
cannam@125 483 func_require_term_colors ()
cannam@125 484 {
cannam@125 485 $debug_cmd
cannam@125 486
cannam@125 487 test -t 1 && {
cannam@125 488 # COLORTERM and USE_ANSI_COLORS environment variables take
cannam@125 489 # precedence, because most terminfo databases neglect to describe
cannam@125 490 # whether color sequences are supported.
cannam@125 491 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
cannam@125 492
cannam@125 493 if test 1 = "$USE_ANSI_COLORS"; then
cannam@125 494 # Standard ANSI escape sequences
cannam@125 495 tc_reset=''
cannam@125 496 tc_bold=''; tc_standout=''
cannam@125 497 tc_red=''; tc_green=''
cannam@125 498 tc_blue=''; tc_cyan=''
cannam@125 499 else
cannam@125 500 # Otherwise trust the terminfo database after all.
cannam@125 501 test -n "`tput sgr0 2>/dev/null`" && {
cannam@125 502 tc_reset=`tput sgr0`
cannam@125 503 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
cannam@125 504 tc_standout=$tc_bold
cannam@125 505 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
cannam@125 506 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
cannam@125 507 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
cannam@125 508 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
cannam@125 509 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
cannam@125 510 }
cannam@125 511 fi
cannam@125 512 }
cannam@125 513
cannam@125 514 require_term_colors=:
cannam@125 515 }
cannam@125 516
cannam@125 517
cannam@125 518 ## ----------------- ##
cannam@125 519 ## Function library. ##
cannam@125 520 ## ----------------- ##
cannam@125 521
cannam@125 522 # This section contains a variety of useful functions to call in your
cannam@125 523 # scripts. Take note of the portable wrappers for features provided by
cannam@125 524 # some modern shells, which will fall back to slower equivalents on
cannam@125 525 # less featureful shells.
cannam@125 526
cannam@125 527
cannam@125 528 # func_append VAR VALUE
cannam@125 529 # ---------------------
cannam@125 530 # Append VALUE onto the existing contents of VAR.
cannam@125 531
cannam@125 532 # We should try to minimise forks, especially on Windows where they are
cannam@125 533 # unreasonably slow, so skip the feature probes when bash or zsh are
cannam@125 534 # being used:
cannam@125 535 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
cannam@125 536 : ${_G_HAVE_ARITH_OP="yes"}
cannam@125 537 : ${_G_HAVE_XSI_OPS="yes"}
cannam@125 538 # The += operator was introduced in bash 3.1
cannam@125 539 case $BASH_VERSION in
cannam@125 540 [12].* | 3.0 | 3.0*) ;;
cannam@125 541 *)
cannam@125 542 : ${_G_HAVE_PLUSEQ_OP="yes"}
cannam@125 543 ;;
cannam@125 544 esac
cannam@125 545 fi
cannam@125 546
cannam@125 547 # _G_HAVE_PLUSEQ_OP
cannam@125 548 # Can be empty, in which case the shell is probed, "yes" if += is
cannam@125 549 # useable or anything else if it does not work.
cannam@125 550 test -z "$_G_HAVE_PLUSEQ_OP" \
cannam@125 551 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
cannam@125 552 && _G_HAVE_PLUSEQ_OP=yes
cannam@125 553
cannam@125 554 if test yes = "$_G_HAVE_PLUSEQ_OP"
cannam@125 555 then
cannam@125 556 # This is an XSI compatible shell, allowing a faster implementation...
cannam@125 557 eval 'func_append ()
cannam@125 558 {
cannam@125 559 $debug_cmd
cannam@125 560
cannam@125 561 eval "$1+=\$2"
cannam@125 562 }'
cannam@125 563 else
cannam@125 564 # ...otherwise fall back to using expr, which is often a shell builtin.
cannam@125 565 func_append ()
cannam@125 566 {
cannam@125 567 $debug_cmd
cannam@125 568
cannam@125 569 eval "$1=\$$1\$2"
cannam@125 570 }
cannam@125 571 fi
cannam@125 572
cannam@125 573
cannam@125 574 # func_append_quoted VAR VALUE
cannam@125 575 # ----------------------------
cannam@125 576 # Quote VALUE and append to the end of shell variable VAR, separated
cannam@125 577 # by a space.
cannam@125 578 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
cannam@125 579 eval 'func_append_quoted ()
cannam@125 580 {
cannam@125 581 $debug_cmd
cannam@125 582
cannam@125 583 func_quote_for_eval "$2"
cannam@125 584 eval "$1+=\\ \$func_quote_for_eval_result"
cannam@125 585 }'
cannam@125 586 else
cannam@125 587 func_append_quoted ()
cannam@125 588 {
cannam@125 589 $debug_cmd
cannam@125 590
cannam@125 591 func_quote_for_eval "$2"
cannam@125 592 eval "$1=\$$1\\ \$func_quote_for_eval_result"
cannam@125 593 }
cannam@125 594 fi
cannam@125 595
cannam@125 596
cannam@125 597 # func_append_uniq VAR VALUE
cannam@125 598 # --------------------------
cannam@125 599 # Append unique VALUE onto the existing contents of VAR, assuming
cannam@125 600 # entries are delimited by the first character of VALUE. For example:
cannam@125 601 #
cannam@125 602 # func_append_uniq options " --another-option option-argument"
cannam@125 603 #
cannam@125 604 # will only append to $options if " --another-option option-argument "
cannam@125 605 # is not already present somewhere in $options already (note spaces at
cannam@125 606 # each end implied by leading space in second argument).
cannam@125 607 func_append_uniq ()
cannam@125 608 {
cannam@125 609 $debug_cmd
cannam@125 610
cannam@125 611 eval _G_current_value='`$ECHO $'$1'`'
cannam@125 612 _G_delim=`expr "$2" : '\(.\)'`
cannam@125 613
cannam@125 614 case $_G_delim$_G_current_value$_G_delim in
cannam@125 615 *"$2$_G_delim"*) ;;
cannam@125 616 *) func_append "$@" ;;
cannam@125 617 esac
cannam@125 618 }
cannam@125 619
cannam@125 620
cannam@125 621 # func_arith TERM...
cannam@125 622 # ------------------
cannam@125 623 # Set func_arith_result to the result of evaluating TERMs.
cannam@125 624 test -z "$_G_HAVE_ARITH_OP" \
cannam@125 625 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
cannam@125 626 && _G_HAVE_ARITH_OP=yes
cannam@125 627
cannam@125 628 if test yes = "$_G_HAVE_ARITH_OP"; then
cannam@125 629 eval 'func_arith ()
cannam@125 630 {
cannam@125 631 $debug_cmd
cannam@125 632
cannam@125 633 func_arith_result=$(( $* ))
cannam@125 634 }'
cannam@125 635 else
cannam@125 636 func_arith ()
cannam@125 637 {
cannam@125 638 $debug_cmd
cannam@125 639
cannam@125 640 func_arith_result=`expr "$@"`
cannam@125 641 }
cannam@125 642 fi
cannam@125 643
cannam@125 644
cannam@125 645 # func_basename FILE
cannam@125 646 # ------------------
cannam@125 647 # Set func_basename_result to FILE with everything up to and including
cannam@125 648 # the last / stripped.
cannam@125 649 if test yes = "$_G_HAVE_XSI_OPS"; then
cannam@125 650 # If this shell supports suffix pattern removal, then use it to avoid
cannam@125 651 # forking. Hide the definitions single quotes in case the shell chokes
cannam@125 652 # on unsupported syntax...
cannam@125 653 _b='func_basename_result=${1##*/}'
cannam@125 654 _d='case $1 in
cannam@125 655 */*) func_dirname_result=${1%/*}$2 ;;
cannam@125 656 * ) func_dirname_result=$3 ;;
cannam@125 657 esac'
cannam@125 658
cannam@125 659 else
cannam@125 660 # ...otherwise fall back to using sed.
cannam@125 661 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
cannam@125 662 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
cannam@125 663 if test "X$func_dirname_result" = "X$1"; then
cannam@125 664 func_dirname_result=$3
cannam@125 665 else
cannam@125 666 func_append func_dirname_result "$2"
cannam@125 667 fi'
cannam@125 668 fi
cannam@125 669
cannam@125 670 eval 'func_basename ()
cannam@125 671 {
cannam@125 672 $debug_cmd
cannam@125 673
cannam@125 674 '"$_b"'
cannam@125 675 }'
cannam@125 676
cannam@125 677
cannam@125 678 # func_dirname FILE APPEND NONDIR_REPLACEMENT
cannam@125 679 # -------------------------------------------
cannam@125 680 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
cannam@125 681 # otherwise set result to NONDIR_REPLACEMENT.
cannam@125 682 eval 'func_dirname ()
cannam@125 683 {
cannam@125 684 $debug_cmd
cannam@125 685
cannam@125 686 '"$_d"'
cannam@125 687 }'
cannam@125 688
cannam@125 689
cannam@125 690 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
cannam@125 691 # --------------------------------------------------------
cannam@125 692 # Perform func_basename and func_dirname in a single function
cannam@125 693 # call:
cannam@125 694 # dirname: Compute the dirname of FILE. If nonempty,
cannam@125 695 # add APPEND to the result, otherwise set result
cannam@125 696 # to NONDIR_REPLACEMENT.
cannam@125 697 # value returned in "$func_dirname_result"
cannam@125 698 # basename: Compute filename of FILE.
cannam@125 699 # value retuned in "$func_basename_result"
cannam@125 700 # For efficiency, we do not delegate to the functions above but instead
cannam@125 701 # duplicate the functionality here.
cannam@125 702 eval 'func_dirname_and_basename ()
cannam@125 703 {
cannam@125 704 $debug_cmd
cannam@125 705
cannam@125 706 '"$_b"'
cannam@125 707 '"$_d"'
cannam@125 708 }'
cannam@125 709
cannam@125 710
cannam@125 711 # func_echo ARG...
cannam@125 712 # ----------------
cannam@125 713 # Echo program name prefixed message.
cannam@125 714 func_echo ()
cannam@125 715 {
cannam@125 716 $debug_cmd
cannam@125 717
cannam@125 718 _G_message=$*
cannam@125 719
cannam@125 720 func_echo_IFS=$IFS
cannam@125 721 IFS=$nl
cannam@125 722 for _G_line in $_G_message; do
cannam@125 723 IFS=$func_echo_IFS
cannam@125 724 $ECHO "$progname: $_G_line"
cannam@125 725 done
cannam@125 726 IFS=$func_echo_IFS
cannam@125 727 }
cannam@125 728
cannam@125 729
cannam@125 730 # func_echo_all ARG...
cannam@125 731 # --------------------
cannam@125 732 # Invoke $ECHO with all args, space-separated.
cannam@125 733 func_echo_all ()
cannam@125 734 {
cannam@125 735 $ECHO "$*"
cannam@125 736 }
cannam@125 737
cannam@125 738
cannam@125 739 # func_echo_infix_1 INFIX ARG...
cannam@125 740 # ------------------------------
cannam@125 741 # Echo program name, followed by INFIX on the first line, with any
cannam@125 742 # additional lines not showing INFIX.
cannam@125 743 func_echo_infix_1 ()
cannam@125 744 {
cannam@125 745 $debug_cmd
cannam@125 746
cannam@125 747 $require_term_colors
cannam@125 748
cannam@125 749 _G_infix=$1; shift
cannam@125 750 _G_indent=$_G_infix
cannam@125 751 _G_prefix="$progname: $_G_infix: "
cannam@125 752 _G_message=$*
cannam@125 753
cannam@125 754 # Strip color escape sequences before counting printable length
cannam@125 755 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
cannam@125 756 do
cannam@125 757 test -n "$_G_tc" && {
cannam@125 758 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
cannam@125 759 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
cannam@125 760 }
cannam@125 761 done
cannam@125 762 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
cannam@125 763
cannam@125 764 func_echo_infix_1_IFS=$IFS
cannam@125 765 IFS=$nl
cannam@125 766 for _G_line in $_G_message; do
cannam@125 767 IFS=$func_echo_infix_1_IFS
cannam@125 768 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
cannam@125 769 _G_prefix=$_G_indent
cannam@125 770 done
cannam@125 771 IFS=$func_echo_infix_1_IFS
cannam@125 772 }
cannam@125 773
cannam@125 774
cannam@125 775 # func_error ARG...
cannam@125 776 # -----------------
cannam@125 777 # Echo program name prefixed message to standard error.
cannam@125 778 func_error ()
cannam@125 779 {
cannam@125 780 $debug_cmd
cannam@125 781
cannam@125 782 $require_term_colors
cannam@125 783
cannam@125 784 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
cannam@125 785 }
cannam@125 786
cannam@125 787
cannam@125 788 # func_fatal_error ARG...
cannam@125 789 # -----------------------
cannam@125 790 # Echo program name prefixed message to standard error, and exit.
cannam@125 791 func_fatal_error ()
cannam@125 792 {
cannam@125 793 $debug_cmd
cannam@125 794
cannam@125 795 func_error "$*"
cannam@125 796 exit $EXIT_FAILURE
cannam@125 797 }
cannam@125 798
cannam@125 799
cannam@125 800 # func_grep EXPRESSION FILENAME
cannam@125 801 # -----------------------------
cannam@125 802 # Check whether EXPRESSION matches any line of FILENAME, without output.
cannam@125 803 func_grep ()
cannam@125 804 {
cannam@125 805 $debug_cmd
cannam@125 806
cannam@125 807 $GREP "$1" "$2" >/dev/null 2>&1
cannam@125 808 }
cannam@125 809
cannam@125 810
cannam@125 811 # func_len STRING
cannam@125 812 # ---------------
cannam@125 813 # Set func_len_result to the length of STRING. STRING may not
cannam@125 814 # start with a hyphen.
cannam@125 815 test -z "$_G_HAVE_XSI_OPS" \
cannam@125 816 && (eval 'x=a/b/c;
cannam@125 817 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
cannam@125 818 && _G_HAVE_XSI_OPS=yes
cannam@125 819
cannam@125 820 if test yes = "$_G_HAVE_XSI_OPS"; then
cannam@125 821 eval 'func_len ()
cannam@125 822 {
cannam@125 823 $debug_cmd
cannam@125 824
cannam@125 825 func_len_result=${#1}
cannam@125 826 }'
cannam@125 827 else
cannam@125 828 func_len ()
cannam@125 829 {
cannam@125 830 $debug_cmd
cannam@125 831
cannam@125 832 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
cannam@125 833 }
cannam@125 834 fi
cannam@125 835
cannam@125 836
cannam@125 837 # func_mkdir_p DIRECTORY-PATH
cannam@125 838 # ---------------------------
cannam@125 839 # Make sure the entire path to DIRECTORY-PATH is available.
cannam@125 840 func_mkdir_p ()
cannam@125 841 {
cannam@125 842 $debug_cmd
cannam@125 843
cannam@125 844 _G_directory_path=$1
cannam@125 845 _G_dir_list=
cannam@125 846
cannam@125 847 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
cannam@125 848
cannam@125 849 # Protect directory names starting with '-'
cannam@125 850 case $_G_directory_path in
cannam@125 851 -*) _G_directory_path=./$_G_directory_path ;;
cannam@125 852 esac
cannam@125 853
cannam@125 854 # While some portion of DIR does not yet exist...
cannam@125 855 while test ! -d "$_G_directory_path"; do
cannam@125 856 # ...make a list in topmost first order. Use a colon delimited
cannam@125 857 # list incase some portion of path contains whitespace.
cannam@125 858 _G_dir_list=$_G_directory_path:$_G_dir_list
cannam@125 859
cannam@125 860 # If the last portion added has no slash in it, the list is done
cannam@125 861 case $_G_directory_path in */*) ;; *) break ;; esac
cannam@125 862
cannam@125 863 # ...otherwise throw away the child directory and loop
cannam@125 864 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
cannam@125 865 done
cannam@125 866 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
cannam@125 867
cannam@125 868 func_mkdir_p_IFS=$IFS; IFS=:
cannam@125 869 for _G_dir in $_G_dir_list; do
cannam@125 870 IFS=$func_mkdir_p_IFS
cannam@125 871 # mkdir can fail with a 'File exist' error if two processes
cannam@125 872 # try to create one of the directories concurrently. Don't
cannam@125 873 # stop in that case!
cannam@125 874 $MKDIR "$_G_dir" 2>/dev/null || :
cannam@125 875 done
cannam@125 876 IFS=$func_mkdir_p_IFS
cannam@125 877
cannam@125 878 # Bail out if we (or some other process) failed to create a directory.
cannam@125 879 test -d "$_G_directory_path" || \
cannam@125 880 func_fatal_error "Failed to create '$1'"
cannam@125 881 fi
cannam@125 882 }
cannam@125 883
cannam@125 884
cannam@125 885 # func_mktempdir [BASENAME]
cannam@125 886 # -------------------------
cannam@125 887 # Make a temporary directory that won't clash with other running
cannam@125 888 # libtool processes, and avoids race conditions if possible. If
cannam@125 889 # given, BASENAME is the basename for that directory.
cannam@125 890 func_mktempdir ()
cannam@125 891 {
cannam@125 892 $debug_cmd
cannam@125 893
cannam@125 894 _G_template=${TMPDIR-/tmp}/${1-$progname}
cannam@125 895
cannam@125 896 if test : = "$opt_dry_run"; then
cannam@125 897 # Return a directory name, but don't create it in dry-run mode
cannam@125 898 _G_tmpdir=$_G_template-$$
cannam@125 899 else
cannam@125 900
cannam@125 901 # If mktemp works, use that first and foremost
cannam@125 902 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
cannam@125 903
cannam@125 904 if test ! -d "$_G_tmpdir"; then
cannam@125 905 # Failing that, at least try and use $RANDOM to avoid a race
cannam@125 906 _G_tmpdir=$_G_template-${RANDOM-0}$$
cannam@125 907
cannam@125 908 func_mktempdir_umask=`umask`
cannam@125 909 umask 0077
cannam@125 910 $MKDIR "$_G_tmpdir"
cannam@125 911 umask $func_mktempdir_umask
cannam@125 912 fi
cannam@125 913
cannam@125 914 # If we're not in dry-run mode, bomb out on failure
cannam@125 915 test -d "$_G_tmpdir" || \
cannam@125 916 func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
cannam@125 917 fi
cannam@125 918
cannam@125 919 $ECHO "$_G_tmpdir"
cannam@125 920 }
cannam@125 921
cannam@125 922
cannam@125 923 # func_normal_abspath PATH
cannam@125 924 # ------------------------
cannam@125 925 # Remove doubled-up and trailing slashes, "." path components,
cannam@125 926 # and cancel out any ".." path components in PATH after making
cannam@125 927 # it an absolute path.
cannam@125 928 func_normal_abspath ()
cannam@125 929 {
cannam@125 930 $debug_cmd
cannam@125 931
cannam@125 932 # These SED scripts presuppose an absolute path with a trailing slash.
cannam@125 933 _G_pathcar='s|^/\([^/]*\).*$|\1|'
cannam@125 934 _G_pathcdr='s|^/[^/]*||'
cannam@125 935 _G_removedotparts=':dotsl
cannam@125 936 s|/\./|/|g
cannam@125 937 t dotsl
cannam@125 938 s|/\.$|/|'
cannam@125 939 _G_collapseslashes='s|/\{1,\}|/|g'
cannam@125 940 _G_finalslash='s|/*$|/|'
cannam@125 941
cannam@125 942 # Start from root dir and reassemble the path.
cannam@125 943 func_normal_abspath_result=
cannam@125 944 func_normal_abspath_tpath=$1
cannam@125 945 func_normal_abspath_altnamespace=
cannam@125 946 case $func_normal_abspath_tpath in
cannam@125 947 "")
cannam@125 948 # Empty path, that just means $cwd.
cannam@125 949 func_stripname '' '/' "`pwd`"
cannam@125 950 func_normal_abspath_result=$func_stripname_result
cannam@125 951 return
cannam@125 952 ;;
cannam@125 953 # The next three entries are used to spot a run of precisely
cannam@125 954 # two leading slashes without using negated character classes;
cannam@125 955 # we take advantage of case's first-match behaviour.
cannam@125 956 ///*)
cannam@125 957 # Unusual form of absolute path, do nothing.
cannam@125 958 ;;
cannam@125 959 //*)
cannam@125 960 # Not necessarily an ordinary path; POSIX reserves leading '//'
cannam@125 961 # and for example Cygwin uses it to access remote file shares
cannam@125 962 # over CIFS/SMB, so we conserve a leading double slash if found.
cannam@125 963 func_normal_abspath_altnamespace=/
cannam@125 964 ;;
cannam@125 965 /*)
cannam@125 966 # Absolute path, do nothing.
cannam@125 967 ;;
cannam@125 968 *)
cannam@125 969 # Relative path, prepend $cwd.
cannam@125 970 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
cannam@125 971 ;;
cannam@125 972 esac
cannam@125 973
cannam@125 974 # Cancel out all the simple stuff to save iterations. We also want
cannam@125 975 # the path to end with a slash for ease of parsing, so make sure
cannam@125 976 # there is one (and only one) here.
cannam@125 977 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
cannam@125 978 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
cannam@125 979 while :; do
cannam@125 980 # Processed it all yet?
cannam@125 981 if test / = "$func_normal_abspath_tpath"; then
cannam@125 982 # If we ascended to the root using ".." the result may be empty now.
cannam@125 983 if test -z "$func_normal_abspath_result"; then
cannam@125 984 func_normal_abspath_result=/
cannam@125 985 fi
cannam@125 986 break
cannam@125 987 fi
cannam@125 988 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
cannam@125 989 -e "$_G_pathcar"`
cannam@125 990 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
cannam@125 991 -e "$_G_pathcdr"`
cannam@125 992 # Figure out what to do with it
cannam@125 993 case $func_normal_abspath_tcomponent in
cannam@125 994 "")
cannam@125 995 # Trailing empty path component, ignore it.
cannam@125 996 ;;
cannam@125 997 ..)
cannam@125 998 # Parent dir; strip last assembled component from result.
cannam@125 999 func_dirname "$func_normal_abspath_result"
cannam@125 1000 func_normal_abspath_result=$func_dirname_result
cannam@125 1001 ;;
cannam@125 1002 *)
cannam@125 1003 # Actual path component, append it.
cannam@125 1004 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
cannam@125 1005 ;;
cannam@125 1006 esac
cannam@125 1007 done
cannam@125 1008 # Restore leading double-slash if one was found on entry.
cannam@125 1009 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
cannam@125 1010 }
cannam@125 1011
cannam@125 1012
cannam@125 1013 # func_notquiet ARG...
cannam@125 1014 # --------------------
cannam@125 1015 # Echo program name prefixed message only when not in quiet mode.
cannam@125 1016 func_notquiet ()
cannam@125 1017 {
cannam@125 1018 $debug_cmd
cannam@125 1019
cannam@125 1020 $opt_quiet || func_echo ${1+"$@"}
cannam@125 1021
cannam@125 1022 # A bug in bash halts the script if the last line of a function
cannam@125 1023 # fails when set -e is in force, so we need another command to
cannam@125 1024 # work around that:
cannam@125 1025 :
cannam@125 1026 }
cannam@125 1027
cannam@125 1028
cannam@125 1029 # func_relative_path SRCDIR DSTDIR
cannam@125 1030 # --------------------------------
cannam@125 1031 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
cannam@125 1032 func_relative_path ()
cannam@125 1033 {
cannam@125 1034 $debug_cmd
cannam@125 1035
cannam@125 1036 func_relative_path_result=
cannam@125 1037 func_normal_abspath "$1"
cannam@125 1038 func_relative_path_tlibdir=$func_normal_abspath_result
cannam@125 1039 func_normal_abspath "$2"
cannam@125 1040 func_relative_path_tbindir=$func_normal_abspath_result
cannam@125 1041
cannam@125 1042 # Ascend the tree starting from libdir
cannam@125 1043 while :; do
cannam@125 1044 # check if we have found a prefix of bindir
cannam@125 1045 case $func_relative_path_tbindir in
cannam@125 1046 $func_relative_path_tlibdir)
cannam@125 1047 # found an exact match
cannam@125 1048 func_relative_path_tcancelled=
cannam@125 1049 break
cannam@125 1050 ;;
cannam@125 1051 $func_relative_path_tlibdir*)
cannam@125 1052 # found a matching prefix
cannam@125 1053 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
cannam@125 1054 func_relative_path_tcancelled=$func_stripname_result
cannam@125 1055 if test -z "$func_relative_path_result"; then
cannam@125 1056 func_relative_path_result=.
cannam@125 1057 fi
cannam@125 1058 break
cannam@125 1059 ;;
cannam@125 1060 *)
cannam@125 1061 func_dirname $func_relative_path_tlibdir
cannam@125 1062 func_relative_path_tlibdir=$func_dirname_result
cannam@125 1063 if test -z "$func_relative_path_tlibdir"; then
cannam@125 1064 # Have to descend all the way to the root!
cannam@125 1065 func_relative_path_result=../$func_relative_path_result
cannam@125 1066 func_relative_path_tcancelled=$func_relative_path_tbindir
cannam@125 1067 break
cannam@125 1068 fi
cannam@125 1069 func_relative_path_result=../$func_relative_path_result
cannam@125 1070 ;;
cannam@125 1071 esac
cannam@125 1072 done
cannam@125 1073
cannam@125 1074 # Now calculate path; take care to avoid doubling-up slashes.
cannam@125 1075 func_stripname '' '/' "$func_relative_path_result"
cannam@125 1076 func_relative_path_result=$func_stripname_result
cannam@125 1077 func_stripname '/' '/' "$func_relative_path_tcancelled"
cannam@125 1078 if test -n "$func_stripname_result"; then
cannam@125 1079 func_append func_relative_path_result "/$func_stripname_result"
cannam@125 1080 fi
cannam@125 1081
cannam@125 1082 # Normalisation. If bindir is libdir, return '.' else relative path.
cannam@125 1083 if test -n "$func_relative_path_result"; then
cannam@125 1084 func_stripname './' '' "$func_relative_path_result"
cannam@125 1085 func_relative_path_result=$func_stripname_result
cannam@125 1086 fi
cannam@125 1087
cannam@125 1088 test -n "$func_relative_path_result" || func_relative_path_result=.
cannam@125 1089
cannam@125 1090 :
cannam@125 1091 }
cannam@125 1092
cannam@125 1093
cannam@125 1094 # func_quote_for_eval ARG...
cannam@125 1095 # --------------------------
cannam@125 1096 # Aesthetically quote ARGs to be evaled later.
cannam@125 1097 # This function returns two values:
cannam@125 1098 # i) func_quote_for_eval_result
cannam@125 1099 # double-quoted, suitable for a subsequent eval
cannam@125 1100 # ii) func_quote_for_eval_unquoted_result
cannam@125 1101 # has all characters that are still active within double
cannam@125 1102 # quotes backslashified.
cannam@125 1103 func_quote_for_eval ()
cannam@125 1104 {
cannam@125 1105 $debug_cmd
cannam@125 1106
cannam@125 1107 func_quote_for_eval_unquoted_result=
cannam@125 1108 func_quote_for_eval_result=
cannam@125 1109 while test 0 -lt $#; do
cannam@125 1110 case $1 in
cannam@125 1111 *[\\\`\"\$]*)
cannam@125 1112 _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
cannam@125 1113 *)
cannam@125 1114 _G_unquoted_arg=$1 ;;
cannam@125 1115 esac
cannam@125 1116 if test -n "$func_quote_for_eval_unquoted_result"; then
cannam@125 1117 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
cannam@125 1118 else
cannam@125 1119 func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
cannam@125 1120 fi
cannam@125 1121
cannam@125 1122 case $_G_unquoted_arg in
cannam@125 1123 # Double-quote args containing shell metacharacters to delay
cannam@125 1124 # word splitting, command substitution and variable expansion
cannam@125 1125 # for a subsequent eval.
cannam@125 1126 # Many Bourne shells cannot handle close brackets correctly
cannam@125 1127 # in scan sets, so we specify it separately.
cannam@125 1128 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
cannam@125 1129 _G_quoted_arg=\"$_G_unquoted_arg\"
cannam@125 1130 ;;
cannam@125 1131 *)
cannam@125 1132 _G_quoted_arg=$_G_unquoted_arg
cannam@125 1133 ;;
cannam@125 1134 esac
cannam@125 1135
cannam@125 1136 if test -n "$func_quote_for_eval_result"; then
cannam@125 1137 func_append func_quote_for_eval_result " $_G_quoted_arg"
cannam@125 1138 else
cannam@125 1139 func_append func_quote_for_eval_result "$_G_quoted_arg"
cannam@125 1140 fi
cannam@125 1141 shift
cannam@125 1142 done
cannam@125 1143 }
cannam@125 1144
cannam@125 1145
cannam@125 1146 # func_quote_for_expand ARG
cannam@125 1147 # -------------------------
cannam@125 1148 # Aesthetically quote ARG to be evaled later; same as above,
cannam@125 1149 # but do not quote variable references.
cannam@125 1150 func_quote_for_expand ()
cannam@125 1151 {
cannam@125 1152 $debug_cmd
cannam@125 1153
cannam@125 1154 case $1 in
cannam@125 1155 *[\\\`\"]*)
cannam@125 1156 _G_arg=`$ECHO "$1" | $SED \
cannam@125 1157 -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
cannam@125 1158 *)
cannam@125 1159 _G_arg=$1 ;;
cannam@125 1160 esac
cannam@125 1161
cannam@125 1162 case $_G_arg in
cannam@125 1163 # Double-quote args containing shell metacharacters to delay
cannam@125 1164 # word splitting and command substitution for a subsequent eval.
cannam@125 1165 # Many Bourne shells cannot handle close brackets correctly
cannam@125 1166 # in scan sets, so we specify it separately.
cannam@125 1167 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
cannam@125 1168 _G_arg=\"$_G_arg\"
cannam@125 1169 ;;
cannam@125 1170 esac
cannam@125 1171
cannam@125 1172 func_quote_for_expand_result=$_G_arg
cannam@125 1173 }
cannam@125 1174
cannam@125 1175
cannam@125 1176 # func_stripname PREFIX SUFFIX NAME
cannam@125 1177 # ---------------------------------
cannam@125 1178 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
cannam@125 1179 # PREFIX and SUFFIX must not contain globbing or regex special
cannam@125 1180 # characters, hashes, percent signs, but SUFFIX may contain a leading
cannam@125 1181 # dot (in which case that matches only a dot).
cannam@125 1182 if test yes = "$_G_HAVE_XSI_OPS"; then
cannam@125 1183 eval 'func_stripname ()
cannam@125 1184 {
cannam@125 1185 $debug_cmd
cannam@125 1186
cannam@125 1187 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
cannam@125 1188 # positional parameters, so assign one to ordinary variable first.
cannam@125 1189 func_stripname_result=$3
cannam@125 1190 func_stripname_result=${func_stripname_result#"$1"}
cannam@125 1191 func_stripname_result=${func_stripname_result%"$2"}
cannam@125 1192 }'
cannam@125 1193 else
cannam@125 1194 func_stripname ()
cannam@125 1195 {
cannam@125 1196 $debug_cmd
cannam@125 1197
cannam@125 1198 case $2 in
cannam@125 1199 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
cannam@125 1200 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
cannam@125 1201 esac
cannam@125 1202 }
cannam@125 1203 fi
cannam@125 1204
cannam@125 1205
cannam@125 1206 # func_show_eval CMD [FAIL_EXP]
cannam@125 1207 # -----------------------------
cannam@125 1208 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
cannam@125 1209 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
cannam@125 1210 # is given, then evaluate it.
cannam@125 1211 func_show_eval ()
cannam@125 1212 {
cannam@125 1213 $debug_cmd
cannam@125 1214
cannam@125 1215 _G_cmd=$1
cannam@125 1216 _G_fail_exp=${2-':'}
cannam@125 1217
cannam@125 1218 func_quote_for_expand "$_G_cmd"
cannam@125 1219 eval "func_notquiet $func_quote_for_expand_result"
cannam@125 1220
cannam@125 1221 $opt_dry_run || {
cannam@125 1222 eval "$_G_cmd"
cannam@125 1223 _G_status=$?
cannam@125 1224 if test 0 -ne "$_G_status"; then
cannam@125 1225 eval "(exit $_G_status); $_G_fail_exp"
cannam@125 1226 fi
cannam@125 1227 }
cannam@125 1228 }
cannam@125 1229
cannam@125 1230
cannam@125 1231 # func_show_eval_locale CMD [FAIL_EXP]
cannam@125 1232 # ------------------------------------
cannam@125 1233 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
cannam@125 1234 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
cannam@125 1235 # is given, then evaluate it. Use the saved locale for evaluation.
cannam@125 1236 func_show_eval_locale ()
cannam@125 1237 {
cannam@125 1238 $debug_cmd
cannam@125 1239
cannam@125 1240 _G_cmd=$1
cannam@125 1241 _G_fail_exp=${2-':'}
cannam@125 1242
cannam@125 1243 $opt_quiet || {
cannam@125 1244 func_quote_for_expand "$_G_cmd"
cannam@125 1245 eval "func_echo $func_quote_for_expand_result"
cannam@125 1246 }
cannam@125 1247
cannam@125 1248 $opt_dry_run || {
cannam@125 1249 eval "$_G_user_locale
cannam@125 1250 $_G_cmd"
cannam@125 1251 _G_status=$?
cannam@125 1252 eval "$_G_safe_locale"
cannam@125 1253 if test 0 -ne "$_G_status"; then
cannam@125 1254 eval "(exit $_G_status); $_G_fail_exp"
cannam@125 1255 fi
cannam@125 1256 }
cannam@125 1257 }
cannam@125 1258
cannam@125 1259
cannam@125 1260 # func_tr_sh
cannam@125 1261 # ----------
cannam@125 1262 # Turn $1 into a string suitable for a shell variable name.
cannam@125 1263 # Result is stored in $func_tr_sh_result. All characters
cannam@125 1264 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
cannam@125 1265 # if $1 begins with a digit, a '_' is prepended as well.
cannam@125 1266 func_tr_sh ()
cannam@125 1267 {
cannam@125 1268 $debug_cmd
cannam@125 1269
cannam@125 1270 case $1 in
cannam@125 1271 [0-9]* | *[!a-zA-Z0-9_]*)
cannam@125 1272 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
cannam@125 1273 ;;
cannam@125 1274 * )
cannam@125 1275 func_tr_sh_result=$1
cannam@125 1276 ;;
cannam@125 1277 esac
cannam@125 1278 }
cannam@125 1279
cannam@125 1280
cannam@125 1281 # func_verbose ARG...
cannam@125 1282 # -------------------
cannam@125 1283 # Echo program name prefixed message in verbose mode only.
cannam@125 1284 func_verbose ()
cannam@125 1285 {
cannam@125 1286 $debug_cmd
cannam@125 1287
cannam@125 1288 $opt_verbose && func_echo "$*"
cannam@125 1289
cannam@125 1290 :
cannam@125 1291 }
cannam@125 1292
cannam@125 1293
cannam@125 1294 # func_warn_and_continue ARG...
cannam@125 1295 # -----------------------------
cannam@125 1296 # Echo program name prefixed warning message to standard error.
cannam@125 1297 func_warn_and_continue ()
cannam@125 1298 {
cannam@125 1299 $debug_cmd
cannam@125 1300
cannam@125 1301 $require_term_colors
cannam@125 1302
cannam@125 1303 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
cannam@125 1304 }
cannam@125 1305
cannam@125 1306
cannam@125 1307 # func_warning CATEGORY ARG...
cannam@125 1308 # ----------------------------
cannam@125 1309 # Echo program name prefixed warning message to standard error. Warning
cannam@125 1310 # messages can be filtered according to CATEGORY, where this function
cannam@125 1311 # elides messages where CATEGORY is not listed in the global variable
cannam@125 1312 # 'opt_warning_types'.
cannam@125 1313 func_warning ()
cannam@125 1314 {
cannam@125 1315 $debug_cmd
cannam@125 1316
cannam@125 1317 # CATEGORY must be in the warning_categories list!
cannam@125 1318 case " $warning_categories " in
cannam@125 1319 *" $1 "*) ;;
cannam@125 1320 *) func_internal_error "invalid warning category '$1'" ;;
cannam@125 1321 esac
cannam@125 1322
cannam@125 1323 _G_category=$1
cannam@125 1324 shift
cannam@125 1325
cannam@125 1326 case " $opt_warning_types " in
cannam@125 1327 *" $_G_category "*) $warning_func ${1+"$@"} ;;
cannam@125 1328 esac
cannam@125 1329 }
cannam@125 1330
cannam@125 1331
cannam@125 1332 # func_sort_ver VER1 VER2
cannam@125 1333 # -----------------------
cannam@125 1334 # 'sort -V' is not generally available.
cannam@125 1335 # Note this deviates from the version comparison in automake
cannam@125 1336 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
cannam@125 1337 # but this should suffice as we won't be specifying old
cannam@125 1338 # version formats or redundant trailing .0 in bootstrap.conf.
cannam@125 1339 # If we did want full compatibility then we should probably
cannam@125 1340 # use m4_version_compare from autoconf.
cannam@125 1341 func_sort_ver ()
cannam@125 1342 {
cannam@125 1343 $debug_cmd
cannam@125 1344
cannam@125 1345 printf '%s\n%s\n' "$1" "$2" \
cannam@125 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
cannam@125 1347 }
cannam@125 1348
cannam@125 1349 # func_lt_ver PREV CURR
cannam@125 1350 # ---------------------
cannam@125 1351 # Return true if PREV and CURR are in the correct order according to
cannam@125 1352 # func_sort_ver, otherwise false. Use it like this:
cannam@125 1353 #
cannam@125 1354 # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
cannam@125 1355 func_lt_ver ()
cannam@125 1356 {
cannam@125 1357 $debug_cmd
cannam@125 1358
cannam@125 1359 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
cannam@125 1360 }
cannam@125 1361
cannam@125 1362
cannam@125 1363 # Local variables:
cannam@125 1364 # mode: shell-script
cannam@125 1365 # sh-indentation: 2
cannam@125 1366 # eval: (add-hook 'before-save-hook 'time-stamp)
cannam@125 1367 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
cannam@125 1368 # time-stamp-time-zone: "UTC"
cannam@125 1369 # End:
cannam@125 1370 #! /bin/sh
cannam@125 1371
cannam@125 1372 # Set a version string for this script.
cannam@125 1373 scriptversion=2014-01-07.03; # UTC
cannam@125 1374
cannam@125 1375 # A portable, pluggable option parser for Bourne shell.
cannam@125 1376 # Written by Gary V. Vaughan, 2010
cannam@125 1377
cannam@125 1378 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
cannam@125 1379 # This is free software; see the source for copying conditions. There is NO
cannam@125 1380 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cannam@125 1381
cannam@125 1382 # This program is free software: you can redistribute it and/or modify
cannam@125 1383 # it under the terms of the GNU General Public License as published by
cannam@125 1384 # the Free Software Foundation, either version 3 of the License, or
cannam@125 1385 # (at your option) any later version.
cannam@125 1386
cannam@125 1387 # This program is distributed in the hope that it will be useful,
cannam@125 1388 # but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@125 1389 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@125 1390 # GNU General Public License for more details.
cannam@125 1391
cannam@125 1392 # You should have received a copy of the GNU General Public License
cannam@125 1393 # along with this program. If not, see <http://www.gnu.org/licenses/>.
cannam@125 1394
cannam@125 1395 # Please report bugs or propose patches to gary@gnu.org.
cannam@125 1396
cannam@125 1397
cannam@125 1398 ## ------ ##
cannam@125 1399 ## Usage. ##
cannam@125 1400 ## ------ ##
cannam@125 1401
cannam@125 1402 # This file is a library for parsing options in your shell scripts along
cannam@125 1403 # with assorted other useful supporting features that you can make use
cannam@125 1404 # of too.
cannam@125 1405 #
cannam@125 1406 # For the simplest scripts you might need only:
cannam@125 1407 #
cannam@125 1408 # #!/bin/sh
cannam@125 1409 # . relative/path/to/funclib.sh
cannam@125 1410 # . relative/path/to/options-parser
cannam@125 1411 # scriptversion=1.0
cannam@125 1412 # func_options ${1+"$@"}
cannam@125 1413 # eval set dummy "$func_options_result"; shift
cannam@125 1414 # ...rest of your script...
cannam@125 1415 #
cannam@125 1416 # In order for the '--version' option to work, you will need to have a
cannam@125 1417 # suitably formatted comment like the one at the top of this file
cannam@125 1418 # starting with '# Written by ' and ending with '# warranty; '.
cannam@125 1419 #
cannam@125 1420 # For '-h' and '--help' to work, you will also need a one line
cannam@125 1421 # description of your script's purpose in a comment directly above the
cannam@125 1422 # '# Written by ' line, like the one at the top of this file.
cannam@125 1423 #
cannam@125 1424 # The default options also support '--debug', which will turn on shell
cannam@125 1425 # execution tracing (see the comment above debug_cmd below for another
cannam@125 1426 # use), and '--verbose' and the func_verbose function to allow your script
cannam@125 1427 # to display verbose messages only when your user has specified
cannam@125 1428 # '--verbose'.
cannam@125 1429 #
cannam@125 1430 # After sourcing this file, you can plug processing for additional
cannam@125 1431 # options by amending the variables from the 'Configuration' section
cannam@125 1432 # below, and following the instructions in the 'Option parsing'
cannam@125 1433 # section further down.
cannam@125 1434
cannam@125 1435 ## -------------- ##
cannam@125 1436 ## Configuration. ##
cannam@125 1437 ## -------------- ##
cannam@125 1438
cannam@125 1439 # You should override these variables in your script after sourcing this
cannam@125 1440 # file so that they reflect the customisations you have added to the
cannam@125 1441 # option parser.
cannam@125 1442
cannam@125 1443 # The usage line for option parsing errors and the start of '-h' and
cannam@125 1444 # '--help' output messages. You can embed shell variables for delayed
cannam@125 1445 # expansion at the time the message is displayed, but you will need to
cannam@125 1446 # quote other shell meta-characters carefully to prevent them being
cannam@125 1447 # expanded when the contents are evaled.
cannam@125 1448 usage='$progpath [OPTION]...'
cannam@125 1449
cannam@125 1450 # Short help message in response to '-h' and '--help'. Add to this or
cannam@125 1451 # override it after sourcing this library to reflect the full set of
cannam@125 1452 # options your script accepts.
cannam@125 1453 usage_message="\
cannam@125 1454 --debug enable verbose shell tracing
cannam@125 1455 -W, --warnings=CATEGORY
cannam@125 1456 report the warnings falling in CATEGORY [all]
cannam@125 1457 -v, --verbose verbosely report processing
cannam@125 1458 --version print version information and exit
cannam@125 1459 -h, --help print short or long help message and exit
cannam@125 1460 "
cannam@125 1461
cannam@125 1462 # Additional text appended to 'usage_message' in response to '--help'.
cannam@125 1463 long_help_message="
cannam@125 1464 Warning categories include:
cannam@125 1465 'all' show all warnings
cannam@125 1466 'none' turn off all the warnings
cannam@125 1467 'error' warnings are treated as fatal errors"
cannam@125 1468
cannam@125 1469 # Help message printed before fatal option parsing errors.
cannam@125 1470 fatal_help="Try '\$progname --help' for more information."
cannam@125 1471
cannam@125 1472
cannam@125 1473
cannam@125 1474 ## ------------------------- ##
cannam@125 1475 ## Hook function management. ##
cannam@125 1476 ## ------------------------- ##
cannam@125 1477
cannam@125 1478 # This section contains functions for adding, removing, and running hooks
cannam@125 1479 # to the main code. A hook is just a named list of of function, that can
cannam@125 1480 # be run in order later on.
cannam@125 1481
cannam@125 1482 # func_hookable FUNC_NAME
cannam@125 1483 # -----------------------
cannam@125 1484 # Declare that FUNC_NAME will run hooks added with
cannam@125 1485 # 'func_add_hook FUNC_NAME ...'.
cannam@125 1486 func_hookable ()
cannam@125 1487 {
cannam@125 1488 $debug_cmd
cannam@125 1489
cannam@125 1490 func_append hookable_fns " $1"
cannam@125 1491 }
cannam@125 1492
cannam@125 1493
cannam@125 1494 # func_add_hook FUNC_NAME HOOK_FUNC
cannam@125 1495 # ---------------------------------
cannam@125 1496 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
cannam@125 1497 # first have been declared "hookable" by a call to 'func_hookable'.
cannam@125 1498 func_add_hook ()
cannam@125 1499 {
cannam@125 1500 $debug_cmd
cannam@125 1501
cannam@125 1502 case " $hookable_fns " in
cannam@125 1503 *" $1 "*) ;;
cannam@125 1504 *) func_fatal_error "'$1' does not accept hook functions." ;;
cannam@125 1505 esac
cannam@125 1506
cannam@125 1507 eval func_append ${1}_hooks '" $2"'
cannam@125 1508 }
cannam@125 1509
cannam@125 1510
cannam@125 1511 # func_remove_hook FUNC_NAME HOOK_FUNC
cannam@125 1512 # ------------------------------------
cannam@125 1513 # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
cannam@125 1514 func_remove_hook ()
cannam@125 1515 {
cannam@125 1516 $debug_cmd
cannam@125 1517
cannam@125 1518 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
cannam@125 1519 }
cannam@125 1520
cannam@125 1521
cannam@125 1522 # func_run_hooks FUNC_NAME [ARG]...
cannam@125 1523 # ---------------------------------
cannam@125 1524 # Run all hook functions registered to FUNC_NAME.
cannam@125 1525 # It is assumed that the list of hook functions contains nothing more
cannam@125 1526 # than a whitespace-delimited list of legal shell function names, and
cannam@125 1527 # no effort is wasted trying to catch shell meta-characters or preserve
cannam@125 1528 # whitespace.
cannam@125 1529 func_run_hooks ()
cannam@125 1530 {
cannam@125 1531 $debug_cmd
cannam@125 1532
cannam@125 1533 case " $hookable_fns " in
cannam@125 1534 *" $1 "*) ;;
cannam@125 1535 *) func_fatal_error "'$1' does not support hook funcions.n" ;;
cannam@125 1536 esac
cannam@125 1537
cannam@125 1538 eval _G_hook_fns=\$$1_hooks; shift
cannam@125 1539
cannam@125 1540 for _G_hook in $_G_hook_fns; do
cannam@125 1541 eval $_G_hook '"$@"'
cannam@125 1542
cannam@125 1543 # store returned options list back into positional
cannam@125 1544 # parameters for next 'cmd' execution.
cannam@125 1545 eval _G_hook_result=\$${_G_hook}_result
cannam@125 1546 eval set dummy "$_G_hook_result"; shift
cannam@125 1547 done
cannam@125 1548
cannam@125 1549 func_quote_for_eval ${1+"$@"}
cannam@125 1550 func_run_hooks_result=$func_quote_for_eval_result
cannam@125 1551 }
cannam@125 1552
cannam@125 1553
cannam@125 1554
cannam@125 1555 ## --------------- ##
cannam@125 1556 ## Option parsing. ##
cannam@125 1557 ## --------------- ##
cannam@125 1558
cannam@125 1559 # In order to add your own option parsing hooks, you must accept the
cannam@125 1560 # full positional parameter list in your hook function, remove any
cannam@125 1561 # options that you action, and then pass back the remaining unprocessed
cannam@125 1562 # options in '<hooked_function_name>_result', escaped suitably for
cannam@125 1563 # 'eval'. Like this:
cannam@125 1564 #
cannam@125 1565 # my_options_prep ()
cannam@125 1566 # {
cannam@125 1567 # $debug_cmd
cannam@125 1568 #
cannam@125 1569 # # Extend the existing usage message.
cannam@125 1570 # usage_message=$usage_message'
cannam@125 1571 # -s, --silent don'\''t print informational messages
cannam@125 1572 # '
cannam@125 1573 #
cannam@125 1574 # func_quote_for_eval ${1+"$@"}
cannam@125 1575 # my_options_prep_result=$func_quote_for_eval_result
cannam@125 1576 # }
cannam@125 1577 # func_add_hook func_options_prep my_options_prep
cannam@125 1578 #
cannam@125 1579 #
cannam@125 1580 # my_silent_option ()
cannam@125 1581 # {
cannam@125 1582 # $debug_cmd
cannam@125 1583 #
cannam@125 1584 # # Note that for efficiency, we parse as many options as we can
cannam@125 1585 # # recognise in a loop before passing the remainder back to the
cannam@125 1586 # # caller on the first unrecognised argument we encounter.
cannam@125 1587 # while test $# -gt 0; do
cannam@125 1588 # opt=$1; shift
cannam@125 1589 # case $opt in
cannam@125 1590 # --silent|-s) opt_silent=: ;;
cannam@125 1591 # # Separate non-argument short options:
cannam@125 1592 # -s*) func_split_short_opt "$_G_opt"
cannam@125 1593 # set dummy "$func_split_short_opt_name" \
cannam@125 1594 # "-$func_split_short_opt_arg" ${1+"$@"}
cannam@125 1595 # shift
cannam@125 1596 # ;;
cannam@125 1597 # *) set dummy "$_G_opt" "$*"; shift; break ;;
cannam@125 1598 # esac
cannam@125 1599 # done
cannam@125 1600 #
cannam@125 1601 # func_quote_for_eval ${1+"$@"}
cannam@125 1602 # my_silent_option_result=$func_quote_for_eval_result
cannam@125 1603 # }
cannam@125 1604 # func_add_hook func_parse_options my_silent_option
cannam@125 1605 #
cannam@125 1606 #
cannam@125 1607 # my_option_validation ()
cannam@125 1608 # {
cannam@125 1609 # $debug_cmd
cannam@125 1610 #
cannam@125 1611 # $opt_silent && $opt_verbose && func_fatal_help "\
cannam@125 1612 # '--silent' and '--verbose' options are mutually exclusive."
cannam@125 1613 #
cannam@125 1614 # func_quote_for_eval ${1+"$@"}
cannam@125 1615 # my_option_validation_result=$func_quote_for_eval_result
cannam@125 1616 # }
cannam@125 1617 # func_add_hook func_validate_options my_option_validation
cannam@125 1618 #
cannam@125 1619 # You'll alse need to manually amend $usage_message to reflect the extra
cannam@125 1620 # options you parse. It's preferable to append if you can, so that
cannam@125 1621 # multiple option parsing hooks can be added safely.
cannam@125 1622
cannam@125 1623
cannam@125 1624 # func_options [ARG]...
cannam@125 1625 # ---------------------
cannam@125 1626 # All the functions called inside func_options are hookable. See the
cannam@125 1627 # individual implementations for details.
cannam@125 1628 func_hookable func_options
cannam@125 1629 func_options ()
cannam@125 1630 {
cannam@125 1631 $debug_cmd
cannam@125 1632
cannam@125 1633 func_options_prep ${1+"$@"}
cannam@125 1634 eval func_parse_options \
cannam@125 1635 ${func_options_prep_result+"$func_options_prep_result"}
cannam@125 1636 eval func_validate_options \
cannam@125 1637 ${func_parse_options_result+"$func_parse_options_result"}
cannam@125 1638
cannam@125 1639 eval func_run_hooks func_options \
cannam@125 1640 ${func_validate_options_result+"$func_validate_options_result"}
cannam@125 1641
cannam@125 1642 # save modified positional parameters for caller
cannam@125 1643 func_options_result=$func_run_hooks_result
cannam@125 1644 }
cannam@125 1645
cannam@125 1646
cannam@125 1647 # func_options_prep [ARG]...
cannam@125 1648 # --------------------------
cannam@125 1649 # All initialisations required before starting the option parse loop.
cannam@125 1650 # Note that when calling hook functions, we pass through the list of
cannam@125 1651 # positional parameters. If a hook function modifies that list, and
cannam@125 1652 # needs to propogate that back to rest of this script, then the complete
cannam@125 1653 # modified list must be put in 'func_run_hooks_result' before
cannam@125 1654 # returning.
cannam@125 1655 func_hookable func_options_prep
cannam@125 1656 func_options_prep ()
cannam@125 1657 {
cannam@125 1658 $debug_cmd
cannam@125 1659
cannam@125 1660 # Option defaults:
cannam@125 1661 opt_verbose=false
cannam@125 1662 opt_warning_types=
cannam@125 1663
cannam@125 1664 func_run_hooks func_options_prep ${1+"$@"}
cannam@125 1665
cannam@125 1666 # save modified positional parameters for caller
cannam@125 1667 func_options_prep_result=$func_run_hooks_result
cannam@125 1668 }
cannam@125 1669
cannam@125 1670
cannam@125 1671 # func_parse_options [ARG]...
cannam@125 1672 # ---------------------------
cannam@125 1673 # The main option parsing loop.
cannam@125 1674 func_hookable func_parse_options
cannam@125 1675 func_parse_options ()
cannam@125 1676 {
cannam@125 1677 $debug_cmd
cannam@125 1678
cannam@125 1679 func_parse_options_result=
cannam@125 1680
cannam@125 1681 # this just eases exit handling
cannam@125 1682 while test $# -gt 0; do
cannam@125 1683 # Defer to hook functions for initial option parsing, so they
cannam@125 1684 # get priority in the event of reusing an option name.
cannam@125 1685 func_run_hooks func_parse_options ${1+"$@"}
cannam@125 1686
cannam@125 1687 # Adjust func_parse_options positional parameters to match
cannam@125 1688 eval set dummy "$func_run_hooks_result"; shift
cannam@125 1689
cannam@125 1690 # Break out of the loop if we already parsed every option.
cannam@125 1691 test $# -gt 0 || break
cannam@125 1692
cannam@125 1693 _G_opt=$1
cannam@125 1694 shift
cannam@125 1695 case $_G_opt in
cannam@125 1696 --debug|-x) debug_cmd='set -x'
cannam@125 1697 func_echo "enabling shell trace mode"
cannam@125 1698 $debug_cmd
cannam@125 1699 ;;
cannam@125 1700
cannam@125 1701 --no-warnings|--no-warning|--no-warn)
cannam@125 1702 set dummy --warnings none ${1+"$@"}
cannam@125 1703 shift
cannam@125 1704 ;;
cannam@125 1705
cannam@125 1706 --warnings|--warning|-W)
cannam@125 1707 test $# = 0 && func_missing_arg $_G_opt && break
cannam@125 1708 case " $warning_categories $1" in
cannam@125 1709 *" $1 "*)
cannam@125 1710 # trailing space prevents matching last $1 above
cannam@125 1711 func_append_uniq opt_warning_types " $1"
cannam@125 1712 ;;
cannam@125 1713 *all)
cannam@125 1714 opt_warning_types=$warning_categories
cannam@125 1715 ;;
cannam@125 1716 *none)
cannam@125 1717 opt_warning_types=none
cannam@125 1718 warning_func=:
cannam@125 1719 ;;
cannam@125 1720 *error)
cannam@125 1721 opt_warning_types=$warning_categories
cannam@125 1722 warning_func=func_fatal_error
cannam@125 1723 ;;
cannam@125 1724 *)
cannam@125 1725 func_fatal_error \
cannam@125 1726 "unsupported warning category: '$1'"
cannam@125 1727 ;;
cannam@125 1728 esac
cannam@125 1729 shift
cannam@125 1730 ;;
cannam@125 1731
cannam@125 1732 --verbose|-v) opt_verbose=: ;;
cannam@125 1733 --version) func_version ;;
cannam@125 1734 -\?|-h) func_usage ;;
cannam@125 1735 --help) func_help ;;
cannam@125 1736
cannam@125 1737 # Separate optargs to long options (plugins may need this):
cannam@125 1738 --*=*) func_split_equals "$_G_opt"
cannam@125 1739 set dummy "$func_split_equals_lhs" \
cannam@125 1740 "$func_split_equals_rhs" ${1+"$@"}
cannam@125 1741 shift
cannam@125 1742 ;;
cannam@125 1743
cannam@125 1744 # Separate optargs to short options:
cannam@125 1745 -W*)
cannam@125 1746 func_split_short_opt "$_G_opt"
cannam@125 1747 set dummy "$func_split_short_opt_name" \
cannam@125 1748 "$func_split_short_opt_arg" ${1+"$@"}
cannam@125 1749 shift
cannam@125 1750 ;;
cannam@125 1751
cannam@125 1752 # Separate non-argument short options:
cannam@125 1753 -\?*|-h*|-v*|-x*)
cannam@125 1754 func_split_short_opt "$_G_opt"
cannam@125 1755 set dummy "$func_split_short_opt_name" \
cannam@125 1756 "-$func_split_short_opt_arg" ${1+"$@"}
cannam@125 1757 shift
cannam@125 1758 ;;
cannam@125 1759
cannam@125 1760 --) break ;;
cannam@125 1761 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
cannam@125 1762 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
cannam@125 1763 esac
cannam@125 1764 done
cannam@125 1765
cannam@125 1766 # save modified positional parameters for caller
cannam@125 1767 func_quote_for_eval ${1+"$@"}
cannam@125 1768 func_parse_options_result=$func_quote_for_eval_result
cannam@125 1769 }
cannam@125 1770
cannam@125 1771
cannam@125 1772 # func_validate_options [ARG]...
cannam@125 1773 # ------------------------------
cannam@125 1774 # Perform any sanity checks on option settings and/or unconsumed
cannam@125 1775 # arguments.
cannam@125 1776 func_hookable func_validate_options
cannam@125 1777 func_validate_options ()
cannam@125 1778 {
cannam@125 1779 $debug_cmd
cannam@125 1780
cannam@125 1781 # Display all warnings if -W was not given.
cannam@125 1782 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
cannam@125 1783
cannam@125 1784 func_run_hooks func_validate_options ${1+"$@"}
cannam@125 1785
cannam@125 1786 # Bail if the options were screwed!
cannam@125 1787 $exit_cmd $EXIT_FAILURE
cannam@125 1788
cannam@125 1789 # save modified positional parameters for caller
cannam@125 1790 func_validate_options_result=$func_run_hooks_result
cannam@125 1791 }
cannam@125 1792
cannam@125 1793
cannam@125 1794
cannam@125 1795 ## ----------------- ##
cannam@125 1796 ## Helper functions. ##
cannam@125 1797 ## ----------------- ##
cannam@125 1798
cannam@125 1799 # This section contains the helper functions used by the rest of the
cannam@125 1800 # hookable option parser framework in ascii-betical order.
cannam@125 1801
cannam@125 1802
cannam@125 1803 # func_fatal_help ARG...
cannam@125 1804 # ----------------------
cannam@125 1805 # Echo program name prefixed message to standard error, followed by
cannam@125 1806 # a help hint, and exit.
cannam@125 1807 func_fatal_help ()
cannam@125 1808 {
cannam@125 1809 $debug_cmd
cannam@125 1810
cannam@125 1811 eval \$ECHO \""Usage: $usage"\"
cannam@125 1812 eval \$ECHO \""$fatal_help"\"
cannam@125 1813 func_error ${1+"$@"}
cannam@125 1814 exit $EXIT_FAILURE
cannam@125 1815 }
cannam@125 1816
cannam@125 1817
cannam@125 1818 # func_help
cannam@125 1819 # ---------
cannam@125 1820 # Echo long help message to standard output and exit.
cannam@125 1821 func_help ()
cannam@125 1822 {
cannam@125 1823 $debug_cmd
cannam@125 1824
cannam@125 1825 func_usage_message
cannam@125 1826 $ECHO "$long_help_message"
cannam@125 1827 exit 0
cannam@125 1828 }
cannam@125 1829
cannam@125 1830
cannam@125 1831 # func_missing_arg ARGNAME
cannam@125 1832 # ------------------------
cannam@125 1833 # Echo program name prefixed message to standard error and set global
cannam@125 1834 # exit_cmd.
cannam@125 1835 func_missing_arg ()
cannam@125 1836 {
cannam@125 1837 $debug_cmd
cannam@125 1838
cannam@125 1839 func_error "Missing argument for '$1'."
cannam@125 1840 exit_cmd=exit
cannam@125 1841 }
cannam@125 1842
cannam@125 1843
cannam@125 1844 # func_split_equals STRING
cannam@125 1845 # ------------------------
cannam@125 1846 # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
cannam@125 1847 # splitting STRING at the '=' sign.
cannam@125 1848 test -z "$_G_HAVE_XSI_OPS" \
cannam@125 1849 && (eval 'x=a/b/c;
cannam@125 1850 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
cannam@125 1851 && _G_HAVE_XSI_OPS=yes
cannam@125 1852
cannam@125 1853 if test yes = "$_G_HAVE_XSI_OPS"
cannam@125 1854 then
cannam@125 1855 # This is an XSI compatible shell, allowing a faster implementation...
cannam@125 1856 eval 'func_split_equals ()
cannam@125 1857 {
cannam@125 1858 $debug_cmd
cannam@125 1859
cannam@125 1860 func_split_equals_lhs=${1%%=*}
cannam@125 1861 func_split_equals_rhs=${1#*=}
cannam@125 1862 test "x$func_split_equals_lhs" = "x$1" \
cannam@125 1863 && func_split_equals_rhs=
cannam@125 1864 }'
cannam@125 1865 else
cannam@125 1866 # ...otherwise fall back to using expr, which is often a shell builtin.
cannam@125 1867 func_split_equals ()
cannam@125 1868 {
cannam@125 1869 $debug_cmd
cannam@125 1870
cannam@125 1871 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
cannam@125 1872 func_split_equals_rhs=
cannam@125 1873 test "x$func_split_equals_lhs" = "x$1" \
cannam@125 1874 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
cannam@125 1875 }
cannam@125 1876 fi #func_split_equals
cannam@125 1877
cannam@125 1878
cannam@125 1879 # func_split_short_opt SHORTOPT
cannam@125 1880 # -----------------------------
cannam@125 1881 # Set func_split_short_opt_name and func_split_short_opt_arg shell
cannam@125 1882 # variables after splitting SHORTOPT after the 2nd character.
cannam@125 1883 if test yes = "$_G_HAVE_XSI_OPS"
cannam@125 1884 then
cannam@125 1885 # This is an XSI compatible shell, allowing a faster implementation...
cannam@125 1886 eval 'func_split_short_opt ()
cannam@125 1887 {
cannam@125 1888 $debug_cmd
cannam@125 1889
cannam@125 1890 func_split_short_opt_arg=${1#??}
cannam@125 1891 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
cannam@125 1892 }'
cannam@125 1893 else
cannam@125 1894 # ...otherwise fall back to using expr, which is often a shell builtin.
cannam@125 1895 func_split_short_opt ()
cannam@125 1896 {
cannam@125 1897 $debug_cmd
cannam@125 1898
cannam@125 1899 func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
cannam@125 1900 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
cannam@125 1901 }
cannam@125 1902 fi #func_split_short_opt
cannam@125 1903
cannam@125 1904
cannam@125 1905 # func_usage
cannam@125 1906 # ----------
cannam@125 1907 # Echo short help message to standard output and exit.
cannam@125 1908 func_usage ()
cannam@125 1909 {
cannam@125 1910 $debug_cmd
cannam@125 1911
cannam@125 1912 func_usage_message
cannam@125 1913 $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
cannam@125 1914 exit 0
cannam@125 1915 }
cannam@125 1916
cannam@125 1917
cannam@125 1918 # func_usage_message
cannam@125 1919 # ------------------
cannam@125 1920 # Echo short help message to standard output.
cannam@125 1921 func_usage_message ()
cannam@125 1922 {
cannam@125 1923 $debug_cmd
cannam@125 1924
cannam@125 1925 eval \$ECHO \""Usage: $usage"\"
cannam@125 1926 echo
cannam@125 1927 $SED -n 's|^# ||
cannam@125 1928 /^Written by/{
cannam@125 1929 x;p;x
cannam@125 1930 }
cannam@125 1931 h
cannam@125 1932 /^Written by/q' < "$progpath"
cannam@125 1933 echo
cannam@125 1934 eval \$ECHO \""$usage_message"\"
cannam@125 1935 }
cannam@125 1936
cannam@125 1937
cannam@125 1938 # func_version
cannam@125 1939 # ------------
cannam@125 1940 # Echo version message to standard output and exit.
cannam@125 1941 func_version ()
cannam@125 1942 {
cannam@125 1943 $debug_cmd
cannam@125 1944
cannam@125 1945 printf '%s\n' "$progname $scriptversion"
cannam@125 1946 $SED -n '
cannam@125 1947 /(C)/!b go
cannam@125 1948 :more
cannam@125 1949 /\./!{
cannam@125 1950 N
cannam@125 1951 s|\n# | |
cannam@125 1952 b more
cannam@125 1953 }
cannam@125 1954 :go
cannam@125 1955 /^# Written by /,/# warranty; / {
cannam@125 1956 s|^# ||
cannam@125 1957 s|^# *$||
cannam@125 1958 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
cannam@125 1959 p
cannam@125 1960 }
cannam@125 1961 /^# Written by / {
cannam@125 1962 s|^# ||
cannam@125 1963 p
cannam@125 1964 }
cannam@125 1965 /^warranty; /q' < "$progpath"
cannam@125 1966
cannam@125 1967 exit $?
cannam@125 1968 }
cannam@125 1969
cannam@125 1970
cannam@125 1971 # Local variables:
cannam@125 1972 # mode: shell-script
cannam@125 1973 # sh-indentation: 2
cannam@125 1974 # eval: (add-hook 'before-save-hook 'time-stamp)
cannam@125 1975 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
cannam@125 1976 # time-stamp-time-zone: "UTC"
cannam@125 1977 # End:
cannam@125 1978
cannam@125 1979 # Set a version string.
cannam@125 1980 scriptversion='(GNU libtool) 2.4.6'
cannam@125 1981
cannam@125 1982
cannam@125 1983 # func_echo ARG...
cannam@125 1984 # ----------------
cannam@125 1985 # Libtool also displays the current mode in messages, so override
cannam@125 1986 # funclib.sh func_echo with this custom definition.
cannam@125 1987 func_echo ()
cannam@125 1988 {
cannam@125 1989 $debug_cmd
cannam@125 1990
cannam@125 1991 _G_message=$*
cannam@125 1992
cannam@125 1993 func_echo_IFS=$IFS
cannam@125 1994 IFS=$nl
cannam@125 1995 for _G_line in $_G_message; do
cannam@125 1996 IFS=$func_echo_IFS
cannam@125 1997 $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
cannam@125 1998 done
cannam@125 1999 IFS=$func_echo_IFS
cannam@125 2000 }
cannam@125 2001
cannam@125 2002
cannam@125 2003 # func_warning ARG...
cannam@125 2004 # -------------------
cannam@125 2005 # Libtool warnings are not categorized, so override funclib.sh
cannam@125 2006 # func_warning with this simpler definition.
cannam@125 2007 func_warning ()
cannam@125 2008 {
cannam@125 2009 $debug_cmd
cannam@125 2010
cannam@125 2011 $warning_func ${1+"$@"}
cannam@125 2012 }
cannam@125 2013
cannam@125 2014
cannam@125 2015 ## ---------------- ##
cannam@125 2016 ## Options parsing. ##
cannam@125 2017 ## ---------------- ##
cannam@125 2018
cannam@125 2019 # Hook in the functions to make sure our own options are parsed during
cannam@125 2020 # the option parsing loop.
cannam@125 2021
cannam@125 2022 usage='$progpath [OPTION]... [MODE-ARG]...'
cannam@125 2023
cannam@125 2024 # Short help message in response to '-h'.
cannam@125 2025 usage_message="Options:
cannam@125 2026 --config show all configuration variables
cannam@125 2027 --debug enable verbose shell tracing
cannam@125 2028 -n, --dry-run display commands without modifying any files
cannam@125 2029 --features display basic configuration information and exit
cannam@125 2030 --mode=MODE use operation mode MODE
cannam@125 2031 --no-warnings equivalent to '-Wnone'
cannam@125 2032 --preserve-dup-deps don't remove duplicate dependency libraries
cannam@125 2033 --quiet, --silent don't print informational messages
cannam@125 2034 --tag=TAG use configuration variables from tag TAG
cannam@125 2035 -v, --verbose print more informational messages than default
cannam@125 2036 --version print version information
cannam@125 2037 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
cannam@125 2038 -h, --help, --help-all print short, long, or detailed help message
cannam@125 2039 "
cannam@125 2040
cannam@125 2041 # Additional text appended to 'usage_message' in response to '--help'.
cannam@125 2042 func_help ()
cannam@125 2043 {
cannam@125 2044 $debug_cmd
cannam@125 2045
cannam@125 2046 func_usage_message
cannam@125 2047 $ECHO "$long_help_message
cannam@125 2048
cannam@125 2049 MODE must be one of the following:
cannam@125 2050
cannam@125 2051 clean remove files from the build directory
cannam@125 2052 compile compile a source file into a libtool object
cannam@125 2053 execute automatically set library path, then run a program
cannam@125 2054 finish complete the installation of libtool libraries
cannam@125 2055 install install libraries or executables
cannam@125 2056 link create a library or an executable
cannam@125 2057 uninstall remove libraries from an installed directory
cannam@125 2058
cannam@125 2059 MODE-ARGS vary depending on the MODE. When passed as first option,
cannam@125 2060 '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
cannam@125 2061 Try '$progname --help --mode=MODE' for a more detailed description of MODE.
cannam@125 2062
cannam@125 2063 When reporting a bug, please describe a test case to reproduce it and
cannam@125 2064 include the following information:
cannam@125 2065
cannam@125 2066 host-triplet: $host
cannam@125 2067 shell: $SHELL
cannam@125 2068 compiler: $LTCC
cannam@125 2069 compiler flags: $LTCFLAGS
cannam@125 2070 linker: $LD (gnu? $with_gnu_ld)
cannam@125 2071 version: $progname (GNU libtool) 2.4.6
cannam@125 2072 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
cannam@125 2073 autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
cannam@125 2074
cannam@125 2075 Report bugs to <bug-libtool@gnu.org>.
cannam@125 2076 GNU libtool home page: <http://www.gnu.org/s/libtool/>.
cannam@125 2077 General help using GNU software: <http://www.gnu.org/gethelp/>."
cannam@125 2078 exit 0
cannam@125 2079 }
cannam@125 2080
cannam@125 2081
cannam@125 2082 # func_lo2o OBJECT-NAME
cannam@125 2083 # ---------------------
cannam@125 2084 # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
cannam@125 2085 # object suffix.
cannam@125 2086
cannam@125 2087 lo2o=s/\\.lo\$/.$objext/
cannam@125 2088 o2lo=s/\\.$objext\$/.lo/
cannam@125 2089
cannam@125 2090 if test yes = "$_G_HAVE_XSI_OPS"; then
cannam@125 2091 eval 'func_lo2o ()
cannam@125 2092 {
cannam@125 2093 case $1 in
cannam@125 2094 *.lo) func_lo2o_result=${1%.lo}.$objext ;;
cannam@125 2095 * ) func_lo2o_result=$1 ;;
cannam@125 2096 esac
cannam@125 2097 }'
cannam@125 2098
cannam@125 2099 # func_xform LIBOBJ-OR-SOURCE
cannam@125 2100 # ---------------------------
cannam@125 2101 # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
cannam@125 2102 # suffix to a '.lo' libtool-object suffix.
cannam@125 2103 eval 'func_xform ()
cannam@125 2104 {
cannam@125 2105 func_xform_result=${1%.*}.lo
cannam@125 2106 }'
cannam@125 2107 else
cannam@125 2108 # ...otherwise fall back to using sed.
cannam@125 2109 func_lo2o ()
cannam@125 2110 {
cannam@125 2111 func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
cannam@125 2112 }
cannam@125 2113
cannam@125 2114 func_xform ()
cannam@125 2115 {
cannam@125 2116 func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
cannam@125 2117 }
cannam@125 2118 fi
cannam@125 2119
cannam@125 2120
cannam@125 2121 # func_fatal_configuration ARG...
cannam@125 2122 # -------------------------------
cannam@125 2123 # Echo program name prefixed message to standard error, followed by
cannam@125 2124 # a configuration failure hint, and exit.
cannam@125 2125 func_fatal_configuration ()
cannam@125 2126 {
cannam@125 2127 func__fatal_error ${1+"$@"} \
cannam@125 2128 "See the $PACKAGE documentation for more information." \
cannam@125 2129 "Fatal configuration error."
cannam@125 2130 }
cannam@125 2131
cannam@125 2132
cannam@125 2133 # func_config
cannam@125 2134 # -----------
cannam@125 2135 # Display the configuration for all the tags in this script.
cannam@125 2136 func_config ()
cannam@125 2137 {
cannam@125 2138 re_begincf='^# ### BEGIN LIBTOOL'
cannam@125 2139 re_endcf='^# ### END LIBTOOL'
cannam@125 2140
cannam@125 2141 # Default configuration.
cannam@125 2142 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
cannam@125 2143
cannam@125 2144 # Now print the configurations for the tags.
cannam@125 2145 for tagname in $taglist; do
cannam@125 2146 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
cannam@125 2147 done
cannam@125 2148
cannam@125 2149 exit $?
cannam@125 2150 }
cannam@125 2151
cannam@125 2152
cannam@125 2153 # func_features
cannam@125 2154 # -------------
cannam@125 2155 # Display the features supported by this script.
cannam@125 2156 func_features ()
cannam@125 2157 {
cannam@125 2158 echo "host: $host"
cannam@125 2159 if test yes = "$build_libtool_libs"; then
cannam@125 2160 echo "enable shared libraries"
cannam@125 2161 else
cannam@125 2162 echo "disable shared libraries"
cannam@125 2163 fi
cannam@125 2164 if test yes = "$build_old_libs"; then
cannam@125 2165 echo "enable static libraries"
cannam@125 2166 else
cannam@125 2167 echo "disable static libraries"
cannam@125 2168 fi
cannam@125 2169
cannam@125 2170 exit $?
cannam@125 2171 }
cannam@125 2172
cannam@125 2173
cannam@125 2174 # func_enable_tag TAGNAME
cannam@125 2175 # -----------------------
cannam@125 2176 # Verify that TAGNAME is valid, and either flag an error and exit, or
cannam@125 2177 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
cannam@125 2178 # variable here.
cannam@125 2179 func_enable_tag ()
cannam@125 2180 {
cannam@125 2181 # Global variable:
cannam@125 2182 tagname=$1
cannam@125 2183
cannam@125 2184 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
cannam@125 2185 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
cannam@125 2186 sed_extractcf=/$re_begincf/,/$re_endcf/p
cannam@125 2187
cannam@125 2188 # Validate tagname.
cannam@125 2189 case $tagname in
cannam@125 2190 *[!-_A-Za-z0-9,/]*)
cannam@125 2191 func_fatal_error "invalid tag name: $tagname"
cannam@125 2192 ;;
cannam@125 2193 esac
cannam@125 2194
cannam@125 2195 # Don't test for the "default" C tag, as we know it's
cannam@125 2196 # there but not specially marked.
cannam@125 2197 case $tagname in
cannam@125 2198 CC) ;;
cannam@125 2199 *)
cannam@125 2200 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
cannam@125 2201 taglist="$taglist $tagname"
cannam@125 2202
cannam@125 2203 # Evaluate the configuration. Be careful to quote the path
cannam@125 2204 # and the sed script, to avoid splitting on whitespace, but
cannam@125 2205 # also don't use non-portable quotes within backquotes within
cannam@125 2206 # quotes we have to do it in 2 steps:
cannam@125 2207 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
cannam@125 2208 eval "$extractedcf"
cannam@125 2209 else
cannam@125 2210 func_error "ignoring unknown tag $tagname"
cannam@125 2211 fi
cannam@125 2212 ;;
cannam@125 2213 esac
cannam@125 2214 }
cannam@125 2215
cannam@125 2216
cannam@125 2217 # func_check_version_match
cannam@125 2218 # ------------------------
cannam@125 2219 # Ensure that we are using m4 macros, and libtool script from the same
cannam@125 2220 # release of libtool.
cannam@125 2221 func_check_version_match ()
cannam@125 2222 {
cannam@125 2223 if test "$package_revision" != "$macro_revision"; then
cannam@125 2224 if test "$VERSION" != "$macro_version"; then
cannam@125 2225 if test -z "$macro_version"; then
cannam@125 2226 cat >&2 <<_LT_EOF
cannam@125 2227 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
cannam@125 2228 $progname: definition of this LT_INIT comes from an older release.
cannam@125 2229 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
cannam@125 2230 $progname: and run autoconf again.
cannam@125 2231 _LT_EOF
cannam@125 2232 else
cannam@125 2233 cat >&2 <<_LT_EOF
cannam@125 2234 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
cannam@125 2235 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
cannam@125 2236 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
cannam@125 2237 $progname: and run autoconf again.
cannam@125 2238 _LT_EOF
cannam@125 2239 fi
cannam@125 2240 else
cannam@125 2241 cat >&2 <<_LT_EOF
cannam@125 2242 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
cannam@125 2243 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
cannam@125 2244 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
cannam@125 2245 $progname: of $PACKAGE $VERSION and run autoconf again.
cannam@125 2246 _LT_EOF
cannam@125 2247 fi
cannam@125 2248
cannam@125 2249 exit $EXIT_MISMATCH
cannam@125 2250 fi
cannam@125 2251 }
cannam@125 2252
cannam@125 2253
cannam@125 2254 # libtool_options_prep [ARG]...
cannam@125 2255 # -----------------------------
cannam@125 2256 # Preparation for options parsed by libtool.
cannam@125 2257 libtool_options_prep ()
cannam@125 2258 {
cannam@125 2259 $debug_mode
cannam@125 2260
cannam@125 2261 # Option defaults:
cannam@125 2262 opt_config=false
cannam@125 2263 opt_dlopen=
cannam@125 2264 opt_dry_run=false
cannam@125 2265 opt_help=false
cannam@125 2266 opt_mode=
cannam@125 2267 opt_preserve_dup_deps=false
cannam@125 2268 opt_quiet=false
cannam@125 2269
cannam@125 2270 nonopt=
cannam@125 2271 preserve_args=
cannam@125 2272
cannam@125 2273 # Shorthand for --mode=foo, only valid as the first argument
cannam@125 2274 case $1 in
cannam@125 2275 clean|clea|cle|cl)
cannam@125 2276 shift; set dummy --mode clean ${1+"$@"}; shift
cannam@125 2277 ;;
cannam@125 2278 compile|compil|compi|comp|com|co|c)
cannam@125 2279 shift; set dummy --mode compile ${1+"$@"}; shift
cannam@125 2280 ;;
cannam@125 2281 execute|execut|execu|exec|exe|ex|e)
cannam@125 2282 shift; set dummy --mode execute ${1+"$@"}; shift
cannam@125 2283 ;;
cannam@125 2284 finish|finis|fini|fin|fi|f)
cannam@125 2285 shift; set dummy --mode finish ${1+"$@"}; shift
cannam@125 2286 ;;
cannam@125 2287 install|instal|insta|inst|ins|in|i)
cannam@125 2288 shift; set dummy --mode install ${1+"$@"}; shift
cannam@125 2289 ;;
cannam@125 2290 link|lin|li|l)
cannam@125 2291 shift; set dummy --mode link ${1+"$@"}; shift
cannam@125 2292 ;;
cannam@125 2293 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
cannam@125 2294 shift; set dummy --mode uninstall ${1+"$@"}; shift
cannam@125 2295 ;;
cannam@125 2296 esac
cannam@125 2297
cannam@125 2298 # Pass back the list of options.
cannam@125 2299 func_quote_for_eval ${1+"$@"}
cannam@125 2300 libtool_options_prep_result=$func_quote_for_eval_result
cannam@125 2301 }
cannam@125 2302 func_add_hook func_options_prep libtool_options_prep
cannam@125 2303
cannam@125 2304
cannam@125 2305 # libtool_parse_options [ARG]...
cannam@125 2306 # ---------------------------------
cannam@125 2307 # Provide handling for libtool specific options.
cannam@125 2308 libtool_parse_options ()
cannam@125 2309 {
cannam@125 2310 $debug_cmd
cannam@125 2311
cannam@125 2312 # Perform our own loop to consume as many options as possible in
cannam@125 2313 # each iteration.
cannam@125 2314 while test $# -gt 0; do
cannam@125 2315 _G_opt=$1
cannam@125 2316 shift
cannam@125 2317 case $_G_opt in
cannam@125 2318 --dry-run|--dryrun|-n)
cannam@125 2319 opt_dry_run=:
cannam@125 2320 ;;
cannam@125 2321
cannam@125 2322 --config) func_config ;;
cannam@125 2323
cannam@125 2324 --dlopen|-dlopen)
cannam@125 2325 opt_dlopen="${opt_dlopen+$opt_dlopen
cannam@125 2326 }$1"
cannam@125 2327 shift
cannam@125 2328 ;;
cannam@125 2329
cannam@125 2330 --preserve-dup-deps)
cannam@125 2331 opt_preserve_dup_deps=: ;;
cannam@125 2332
cannam@125 2333 --features) func_features ;;
cannam@125 2334
cannam@125 2335 --finish) set dummy --mode finish ${1+"$@"}; shift ;;
cannam@125 2336
cannam@125 2337 --help) opt_help=: ;;
cannam@125 2338
cannam@125 2339 --help-all) opt_help=': help-all' ;;
cannam@125 2340
cannam@125 2341 --mode) test $# = 0 && func_missing_arg $_G_opt && break
cannam@125 2342 opt_mode=$1
cannam@125 2343 case $1 in
cannam@125 2344 # Valid mode arguments:
cannam@125 2345 clean|compile|execute|finish|install|link|relink|uninstall) ;;
cannam@125 2346
cannam@125 2347 # Catch anything else as an error
cannam@125 2348 *) func_error "invalid argument for $_G_opt"
cannam@125 2349 exit_cmd=exit
cannam@125 2350 break
cannam@125 2351 ;;
cannam@125 2352 esac
cannam@125 2353 shift
cannam@125 2354 ;;
cannam@125 2355
cannam@125 2356 --no-silent|--no-quiet)
cannam@125 2357 opt_quiet=false
cannam@125 2358 func_append preserve_args " $_G_opt"
cannam@125 2359 ;;
cannam@125 2360
cannam@125 2361 --no-warnings|--no-warning|--no-warn)
cannam@125 2362 opt_warning=false
cannam@125 2363 func_append preserve_args " $_G_opt"
cannam@125 2364 ;;
cannam@125 2365
cannam@125 2366 --no-verbose)
cannam@125 2367 opt_verbose=false
cannam@125 2368 func_append preserve_args " $_G_opt"
cannam@125 2369 ;;
cannam@125 2370
cannam@125 2371 --silent|--quiet)
cannam@125 2372 opt_quiet=:
cannam@125 2373 opt_verbose=false
cannam@125 2374 func_append preserve_args " $_G_opt"
cannam@125 2375 ;;
cannam@125 2376
cannam@125 2377 --tag) test $# = 0 && func_missing_arg $_G_opt && break
cannam@125 2378 opt_tag=$1
cannam@125 2379 func_append preserve_args " $_G_opt $1"
cannam@125 2380 func_enable_tag "$1"
cannam@125 2381 shift
cannam@125 2382 ;;
cannam@125 2383
cannam@125 2384 --verbose|-v) opt_quiet=false
cannam@125 2385 opt_verbose=:
cannam@125 2386 func_append preserve_args " $_G_opt"
cannam@125 2387 ;;
cannam@125 2388
cannam@125 2389 # An option not handled by this hook function:
cannam@125 2390 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
cannam@125 2391 esac
cannam@125 2392 done
cannam@125 2393
cannam@125 2394
cannam@125 2395 # save modified positional parameters for caller
cannam@125 2396 func_quote_for_eval ${1+"$@"}
cannam@125 2397 libtool_parse_options_result=$func_quote_for_eval_result
cannam@125 2398 }
cannam@125 2399 func_add_hook func_parse_options libtool_parse_options
cannam@125 2400
cannam@125 2401
cannam@125 2402
cannam@125 2403 # libtool_validate_options [ARG]...
cannam@125 2404 # ---------------------------------
cannam@125 2405 # Perform any sanity checks on option settings and/or unconsumed
cannam@125 2406 # arguments.
cannam@125 2407 libtool_validate_options ()
cannam@125 2408 {
cannam@125 2409 # save first non-option argument
cannam@125 2410 if test 0 -lt $#; then
cannam@125 2411 nonopt=$1
cannam@125 2412 shift
cannam@125 2413 fi
cannam@125 2414
cannam@125 2415 # preserve --debug
cannam@125 2416 test : = "$debug_cmd" || func_append preserve_args " --debug"
cannam@125 2417
cannam@125 2418 case $host in
cannam@125 2419 # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
cannam@125 2420 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
cannam@125 2421 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
cannam@125 2422 # don't eliminate duplications in $postdeps and $predeps
cannam@125 2423 opt_duplicate_compiler_generated_deps=:
cannam@125 2424 ;;
cannam@125 2425 *)
cannam@125 2426 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
cannam@125 2427 ;;
cannam@125 2428 esac
cannam@125 2429
cannam@125 2430 $opt_help || {
cannam@125 2431 # Sanity checks first:
cannam@125 2432 func_check_version_match
cannam@125 2433
cannam@125 2434 test yes != "$build_libtool_libs" \
cannam@125 2435 && test yes != "$build_old_libs" \
cannam@125 2436 && func_fatal_configuration "not configured to build any kind of library"
cannam@125 2437
cannam@125 2438 # Darwin sucks
cannam@125 2439 eval std_shrext=\"$shrext_cmds\"
cannam@125 2440
cannam@125 2441 # Only execute mode is allowed to have -dlopen flags.
cannam@125 2442 if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
cannam@125 2443 func_error "unrecognized option '-dlopen'"
cannam@125 2444 $ECHO "$help" 1>&2
cannam@125 2445 exit $EXIT_FAILURE
cannam@125 2446 fi
cannam@125 2447
cannam@125 2448 # Change the help message to a mode-specific one.
cannam@125 2449 generic_help=$help
cannam@125 2450 help="Try '$progname --help --mode=$opt_mode' for more information."
cannam@125 2451 }
cannam@125 2452
cannam@125 2453 # Pass back the unparsed argument list
cannam@125 2454 func_quote_for_eval ${1+"$@"}
cannam@125 2455 libtool_validate_options_result=$func_quote_for_eval_result
cannam@125 2456 }
cannam@125 2457 func_add_hook func_validate_options libtool_validate_options
cannam@125 2458
cannam@125 2459
cannam@125 2460 # Process options as early as possible so that --help and --version
cannam@125 2461 # can return quickly.
cannam@125 2462 func_options ${1+"$@"}
cannam@125 2463 eval set dummy "$func_options_result"; shift
cannam@125 2464
cannam@125 2465
cannam@125 2466
cannam@125 2467 ## ----------- ##
cannam@125 2468 ## Main. ##
cannam@125 2469 ## ----------- ##
cannam@125 2470
cannam@125 2471 magic='%%%MAGIC variable%%%'
cannam@125 2472 magic_exe='%%%MAGIC EXE variable%%%'
cannam@125 2473
cannam@125 2474 # Global variables.
cannam@125 2475 extracted_archives=
cannam@125 2476 extracted_serial=0
cannam@125 2477
cannam@125 2478 # If this variable is set in any of the actions, the command in it
cannam@125 2479 # will be execed at the end. This prevents here-documents from being
cannam@125 2480 # left over by shells.
cannam@125 2481 exec_cmd=
cannam@125 2482
cannam@125 2483
cannam@125 2484 # A function that is used when there is no print builtin or printf.
cannam@125 2485 func_fallback_echo ()
cannam@125 2486 {
cannam@125 2487 eval 'cat <<_LTECHO_EOF
cannam@125 2488 $1
cannam@125 2489 _LTECHO_EOF'
cannam@125 2490 }
cannam@125 2491
cannam@125 2492 # func_generated_by_libtool
cannam@125 2493 # True iff stdin has been generated by Libtool. This function is only
cannam@125 2494 # a basic sanity check; it will hardly flush out determined imposters.
cannam@125 2495 func_generated_by_libtool_p ()
cannam@125 2496 {
cannam@125 2497 $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
cannam@125 2498 }
cannam@125 2499
cannam@125 2500 # func_lalib_p file
cannam@125 2501 # True iff FILE is a libtool '.la' library or '.lo' object file.
cannam@125 2502 # This function is only a basic sanity check; it will hardly flush out
cannam@125 2503 # determined imposters.
cannam@125 2504 func_lalib_p ()
cannam@125 2505 {
cannam@125 2506 test -f "$1" &&
cannam@125 2507 $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
cannam@125 2508 }
cannam@125 2509
cannam@125 2510 # func_lalib_unsafe_p file
cannam@125 2511 # True iff FILE is a libtool '.la' library or '.lo' object file.
cannam@125 2512 # This function implements the same check as func_lalib_p without
cannam@125 2513 # resorting to external programs. To this end, it redirects stdin and
cannam@125 2514 # closes it afterwards, without saving the original file descriptor.
cannam@125 2515 # As a safety measure, use it only where a negative result would be
cannam@125 2516 # fatal anyway. Works if 'file' does not exist.
cannam@125 2517 func_lalib_unsafe_p ()
cannam@125 2518 {
cannam@125 2519 lalib_p=no
cannam@125 2520 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
cannam@125 2521 for lalib_p_l in 1 2 3 4
cannam@125 2522 do
cannam@125 2523 read lalib_p_line
cannam@125 2524 case $lalib_p_line in
cannam@125 2525 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
cannam@125 2526 esac
cannam@125 2527 done
cannam@125 2528 exec 0<&5 5<&-
cannam@125 2529 fi
cannam@125 2530 test yes = "$lalib_p"
cannam@125 2531 }
cannam@125 2532
cannam@125 2533 # func_ltwrapper_script_p file
cannam@125 2534 # True iff FILE is a libtool wrapper script
cannam@125 2535 # This function is only a basic sanity check; it will hardly flush out
cannam@125 2536 # determined imposters.
cannam@125 2537 func_ltwrapper_script_p ()
cannam@125 2538 {
cannam@125 2539 test -f "$1" &&
cannam@125 2540 $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
cannam@125 2541 }
cannam@125 2542
cannam@125 2543 # func_ltwrapper_executable_p file
cannam@125 2544 # True iff FILE is a libtool wrapper executable
cannam@125 2545 # This function is only a basic sanity check; it will hardly flush out
cannam@125 2546 # determined imposters.
cannam@125 2547 func_ltwrapper_executable_p ()
cannam@125 2548 {
cannam@125 2549 func_ltwrapper_exec_suffix=
cannam@125 2550 case $1 in
cannam@125 2551 *.exe) ;;
cannam@125 2552 *) func_ltwrapper_exec_suffix=.exe ;;
cannam@125 2553 esac
cannam@125 2554 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
cannam@125 2555 }
cannam@125 2556
cannam@125 2557 # func_ltwrapper_scriptname file
cannam@125 2558 # Assumes file is an ltwrapper_executable
cannam@125 2559 # uses $file to determine the appropriate filename for a
cannam@125 2560 # temporary ltwrapper_script.
cannam@125 2561 func_ltwrapper_scriptname ()
cannam@125 2562 {
cannam@125 2563 func_dirname_and_basename "$1" "" "."
cannam@125 2564 func_stripname '' '.exe' "$func_basename_result"
cannam@125 2565 func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
cannam@125 2566 }
cannam@125 2567
cannam@125 2568 # func_ltwrapper_p file
cannam@125 2569 # True iff FILE is a libtool wrapper script or wrapper executable
cannam@125 2570 # This function is only a basic sanity check; it will hardly flush out
cannam@125 2571 # determined imposters.
cannam@125 2572 func_ltwrapper_p ()
cannam@125 2573 {
cannam@125 2574 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
cannam@125 2575 }
cannam@125 2576
cannam@125 2577
cannam@125 2578 # func_execute_cmds commands fail_cmd
cannam@125 2579 # Execute tilde-delimited COMMANDS.
cannam@125 2580 # If FAIL_CMD is given, eval that upon failure.
cannam@125 2581 # FAIL_CMD may read-access the current command in variable CMD!
cannam@125 2582 func_execute_cmds ()
cannam@125 2583 {
cannam@125 2584 $debug_cmd
cannam@125 2585
cannam@125 2586 save_ifs=$IFS; IFS='~'
cannam@125 2587 for cmd in $1; do
cannam@125 2588 IFS=$sp$nl
cannam@125 2589 eval cmd=\"$cmd\"
cannam@125 2590 IFS=$save_ifs
cannam@125 2591 func_show_eval "$cmd" "${2-:}"
cannam@125 2592 done
cannam@125 2593 IFS=$save_ifs
cannam@125 2594 }
cannam@125 2595
cannam@125 2596
cannam@125 2597 # func_source file
cannam@125 2598 # Source FILE, adding directory component if necessary.
cannam@125 2599 # Note that it is not necessary on cygwin/mingw to append a dot to
cannam@125 2600 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
cannam@125 2601 # behavior happens only for exec(3), not for open(2)! Also, sourcing
cannam@125 2602 # 'FILE.' does not work on cygwin managed mounts.
cannam@125 2603 func_source ()
cannam@125 2604 {
cannam@125 2605 $debug_cmd
cannam@125 2606
cannam@125 2607 case $1 in
cannam@125 2608 */* | *\\*) . "$1" ;;
cannam@125 2609 *) . "./$1" ;;
cannam@125 2610 esac
cannam@125 2611 }
cannam@125 2612
cannam@125 2613
cannam@125 2614 # func_resolve_sysroot PATH
cannam@125 2615 # Replace a leading = in PATH with a sysroot. Store the result into
cannam@125 2616 # func_resolve_sysroot_result
cannam@125 2617 func_resolve_sysroot ()
cannam@125 2618 {
cannam@125 2619 func_resolve_sysroot_result=$1
cannam@125 2620 case $func_resolve_sysroot_result in
cannam@125 2621 =*)
cannam@125 2622 func_stripname '=' '' "$func_resolve_sysroot_result"
cannam@125 2623 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
cannam@125 2624 ;;
cannam@125 2625 esac
cannam@125 2626 }
cannam@125 2627
cannam@125 2628 # func_replace_sysroot PATH
cannam@125 2629 # If PATH begins with the sysroot, replace it with = and
cannam@125 2630 # store the result into func_replace_sysroot_result.
cannam@125 2631 func_replace_sysroot ()
cannam@125 2632 {
cannam@125 2633 case $lt_sysroot:$1 in
cannam@125 2634 ?*:"$lt_sysroot"*)
cannam@125 2635 func_stripname "$lt_sysroot" '' "$1"
cannam@125 2636 func_replace_sysroot_result='='$func_stripname_result
cannam@125 2637 ;;
cannam@125 2638 *)
cannam@125 2639 # Including no sysroot.
cannam@125 2640 func_replace_sysroot_result=$1
cannam@125 2641 ;;
cannam@125 2642 esac
cannam@125 2643 }
cannam@125 2644
cannam@125 2645 # func_infer_tag arg
cannam@125 2646 # Infer tagged configuration to use if any are available and
cannam@125 2647 # if one wasn't chosen via the "--tag" command line option.
cannam@125 2648 # Only attempt this if the compiler in the base compile
cannam@125 2649 # command doesn't match the default compiler.
cannam@125 2650 # arg is usually of the form 'gcc ...'
cannam@125 2651 func_infer_tag ()
cannam@125 2652 {
cannam@125 2653 $debug_cmd
cannam@125 2654
cannam@125 2655 if test -n "$available_tags" && test -z "$tagname"; then
cannam@125 2656 CC_quoted=
cannam@125 2657 for arg in $CC; do
cannam@125 2658 func_append_quoted CC_quoted "$arg"
cannam@125 2659 done
cannam@125 2660 CC_expanded=`func_echo_all $CC`
cannam@125 2661 CC_quoted_expanded=`func_echo_all $CC_quoted`
cannam@125 2662 case $@ in
cannam@125 2663 # Blanks in the command may have been stripped by the calling shell,
cannam@125 2664 # but not from the CC environment variable when configure was run.
cannam@125 2665 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
cannam@125 2666 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
cannam@125 2667 # Blanks at the start of $base_compile will cause this to fail
cannam@125 2668 # if we don't check for them as well.
cannam@125 2669 *)
cannam@125 2670 for z in $available_tags; do
cannam@125 2671 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
cannam@125 2672 # Evaluate the configuration.
cannam@125 2673 eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
cannam@125 2674 CC_quoted=
cannam@125 2675 for arg in $CC; do
cannam@125 2676 # Double-quote args containing other shell metacharacters.
cannam@125 2677 func_append_quoted CC_quoted "$arg"
cannam@125 2678 done
cannam@125 2679 CC_expanded=`func_echo_all $CC`
cannam@125 2680 CC_quoted_expanded=`func_echo_all $CC_quoted`
cannam@125 2681 case "$@ " in
cannam@125 2682 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
cannam@125 2683 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
cannam@125 2684 # The compiler in the base compile command matches
cannam@125 2685 # the one in the tagged configuration.
cannam@125 2686 # Assume this is the tagged configuration we want.
cannam@125 2687 tagname=$z
cannam@125 2688 break
cannam@125 2689 ;;
cannam@125 2690 esac
cannam@125 2691 fi
cannam@125 2692 done
cannam@125 2693 # If $tagname still isn't set, then no tagged configuration
cannam@125 2694 # was found and let the user know that the "--tag" command
cannam@125 2695 # line option must be used.
cannam@125 2696 if test -z "$tagname"; then
cannam@125 2697 func_echo "unable to infer tagged configuration"
cannam@125 2698 func_fatal_error "specify a tag with '--tag'"
cannam@125 2699 # else
cannam@125 2700 # func_verbose "using $tagname tagged configuration"
cannam@125 2701 fi
cannam@125 2702 ;;
cannam@125 2703 esac
cannam@125 2704 fi
cannam@125 2705 }
cannam@125 2706
cannam@125 2707
cannam@125 2708
cannam@125 2709 # func_write_libtool_object output_name pic_name nonpic_name
cannam@125 2710 # Create a libtool object file (analogous to a ".la" file),
cannam@125 2711 # but don't create it if we're doing a dry run.
cannam@125 2712 func_write_libtool_object ()
cannam@125 2713 {
cannam@125 2714 write_libobj=$1
cannam@125 2715 if test yes = "$build_libtool_libs"; then
cannam@125 2716 write_lobj=\'$2\'
cannam@125 2717 else
cannam@125 2718 write_lobj=none
cannam@125 2719 fi
cannam@125 2720
cannam@125 2721 if test yes = "$build_old_libs"; then
cannam@125 2722 write_oldobj=\'$3\'
cannam@125 2723 else
cannam@125 2724 write_oldobj=none
cannam@125 2725 fi
cannam@125 2726
cannam@125 2727 $opt_dry_run || {
cannam@125 2728 cat >${write_libobj}T <<EOF
cannam@125 2729 # $write_libobj - a libtool object file
cannam@125 2730 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
cannam@125 2731 #
cannam@125 2732 # Please DO NOT delete this file!
cannam@125 2733 # It is necessary for linking the library.
cannam@125 2734
cannam@125 2735 # Name of the PIC object.
cannam@125 2736 pic_object=$write_lobj
cannam@125 2737
cannam@125 2738 # Name of the non-PIC object
cannam@125 2739 non_pic_object=$write_oldobj
cannam@125 2740
cannam@125 2741 EOF
cannam@125 2742 $MV "${write_libobj}T" "$write_libobj"
cannam@125 2743 }
cannam@125 2744 }
cannam@125 2745
cannam@125 2746
cannam@125 2747 ##################################################
cannam@125 2748 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
cannam@125 2749 ##################################################
cannam@125 2750
cannam@125 2751 # func_convert_core_file_wine_to_w32 ARG
cannam@125 2752 # Helper function used by file name conversion functions when $build is *nix,
cannam@125 2753 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
cannam@125 2754 # correctly configured wine environment available, with the winepath program
cannam@125 2755 # in $build's $PATH.
cannam@125 2756 #
cannam@125 2757 # ARG is the $build file name to be converted to w32 format.
cannam@125 2758 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
cannam@125 2759 # be empty on error (or when ARG is empty)
cannam@125 2760 func_convert_core_file_wine_to_w32 ()
cannam@125 2761 {
cannam@125 2762 $debug_cmd
cannam@125 2763
cannam@125 2764 func_convert_core_file_wine_to_w32_result=$1
cannam@125 2765 if test -n "$1"; then
cannam@125 2766 # Unfortunately, winepath does not exit with a non-zero error code, so we
cannam@125 2767 # are forced to check the contents of stdout. On the other hand, if the
cannam@125 2768 # command is not found, the shell will set an exit code of 127 and print
cannam@125 2769 # *an error message* to stdout. So we must check for both error code of
cannam@125 2770 # zero AND non-empty stdout, which explains the odd construction:
cannam@125 2771 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
cannam@125 2772 if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
cannam@125 2773 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
cannam@125 2774 $SED -e "$sed_naive_backslashify"`
cannam@125 2775 else
cannam@125 2776 func_convert_core_file_wine_to_w32_result=
cannam@125 2777 fi
cannam@125 2778 fi
cannam@125 2779 }
cannam@125 2780 # end: func_convert_core_file_wine_to_w32
cannam@125 2781
cannam@125 2782
cannam@125 2783 # func_convert_core_path_wine_to_w32 ARG
cannam@125 2784 # Helper function used by path conversion functions when $build is *nix, and
cannam@125 2785 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
cannam@125 2786 # configured wine environment available, with the winepath program in $build's
cannam@125 2787 # $PATH. Assumes ARG has no leading or trailing path separator characters.
cannam@125 2788 #
cannam@125 2789 # ARG is path to be converted from $build format to win32.
cannam@125 2790 # Result is available in $func_convert_core_path_wine_to_w32_result.
cannam@125 2791 # Unconvertible file (directory) names in ARG are skipped; if no directory names
cannam@125 2792 # are convertible, then the result may be empty.
cannam@125 2793 func_convert_core_path_wine_to_w32 ()
cannam@125 2794 {
cannam@125 2795 $debug_cmd
cannam@125 2796
cannam@125 2797 # unfortunately, winepath doesn't convert paths, only file names
cannam@125 2798 func_convert_core_path_wine_to_w32_result=
cannam@125 2799 if test -n "$1"; then
cannam@125 2800 oldIFS=$IFS
cannam@125 2801 IFS=:
cannam@125 2802 for func_convert_core_path_wine_to_w32_f in $1; do
cannam@125 2803 IFS=$oldIFS
cannam@125 2804 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
cannam@125 2805 if test -n "$func_convert_core_file_wine_to_w32_result"; then
cannam@125 2806 if test -z "$func_convert_core_path_wine_to_w32_result"; then
cannam@125 2807 func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
cannam@125 2808 else
cannam@125 2809 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
cannam@125 2810 fi
cannam@125 2811 fi
cannam@125 2812 done
cannam@125 2813 IFS=$oldIFS
cannam@125 2814 fi
cannam@125 2815 }
cannam@125 2816 # end: func_convert_core_path_wine_to_w32
cannam@125 2817
cannam@125 2818
cannam@125 2819 # func_cygpath ARGS...
cannam@125 2820 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
cannam@125 2821 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
cannam@125 2822 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
cannam@125 2823 # (2), returns the Cygwin file name or path in func_cygpath_result (input
cannam@125 2824 # file name or path is assumed to be in w32 format, as previously converted
cannam@125 2825 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
cannam@125 2826 # or path in func_cygpath_result (input file name or path is assumed to be in
cannam@125 2827 # Cygwin format). Returns an empty string on error.
cannam@125 2828 #
cannam@125 2829 # ARGS are passed to cygpath, with the last one being the file name or path to
cannam@125 2830 # be converted.
cannam@125 2831 #
cannam@125 2832 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
cannam@125 2833 # environment variable; do not put it in $PATH.
cannam@125 2834 func_cygpath ()
cannam@125 2835 {
cannam@125 2836 $debug_cmd
cannam@125 2837
cannam@125 2838 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
cannam@125 2839 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
cannam@125 2840 if test "$?" -ne 0; then
cannam@125 2841 # on failure, ensure result is empty
cannam@125 2842 func_cygpath_result=
cannam@125 2843 fi
cannam@125 2844 else
cannam@125 2845 func_cygpath_result=
cannam@125 2846 func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
cannam@125 2847 fi
cannam@125 2848 }
cannam@125 2849 #end: func_cygpath
cannam@125 2850
cannam@125 2851
cannam@125 2852 # func_convert_core_msys_to_w32 ARG
cannam@125 2853 # Convert file name or path ARG from MSYS format to w32 format. Return
cannam@125 2854 # result in func_convert_core_msys_to_w32_result.
cannam@125 2855 func_convert_core_msys_to_w32 ()
cannam@125 2856 {
cannam@125 2857 $debug_cmd
cannam@125 2858
cannam@125 2859 # awkward: cmd appends spaces to result
cannam@125 2860 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
cannam@125 2861 $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
cannam@125 2862 }
cannam@125 2863 #end: func_convert_core_msys_to_w32
cannam@125 2864
cannam@125 2865
cannam@125 2866 # func_convert_file_check ARG1 ARG2
cannam@125 2867 # Verify that ARG1 (a file name in $build format) was converted to $host
cannam@125 2868 # format in ARG2. Otherwise, emit an error message, but continue (resetting
cannam@125 2869 # func_to_host_file_result to ARG1).
cannam@125 2870 func_convert_file_check ()
cannam@125 2871 {
cannam@125 2872 $debug_cmd
cannam@125 2873
cannam@125 2874 if test -z "$2" && test -n "$1"; then
cannam@125 2875 func_error "Could not determine host file name corresponding to"
cannam@125 2876 func_error " '$1'"
cannam@125 2877 func_error "Continuing, but uninstalled executables may not work."
cannam@125 2878 # Fallback:
cannam@125 2879 func_to_host_file_result=$1
cannam@125 2880 fi
cannam@125 2881 }
cannam@125 2882 # end func_convert_file_check
cannam@125 2883
cannam@125 2884
cannam@125 2885 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
cannam@125 2886 # Verify that FROM_PATH (a path in $build format) was converted to $host
cannam@125 2887 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
cannam@125 2888 # func_to_host_file_result to a simplistic fallback value (see below).
cannam@125 2889 func_convert_path_check ()
cannam@125 2890 {
cannam@125 2891 $debug_cmd
cannam@125 2892
cannam@125 2893 if test -z "$4" && test -n "$3"; then
cannam@125 2894 func_error "Could not determine the host path corresponding to"
cannam@125 2895 func_error " '$3'"
cannam@125 2896 func_error "Continuing, but uninstalled executables may not work."
cannam@125 2897 # Fallback. This is a deliberately simplistic "conversion" and
cannam@125 2898 # should not be "improved". See libtool.info.
cannam@125 2899 if test "x$1" != "x$2"; then
cannam@125 2900 lt_replace_pathsep_chars="s|$1|$2|g"
cannam@125 2901 func_to_host_path_result=`echo "$3" |
cannam@125 2902 $SED -e "$lt_replace_pathsep_chars"`
cannam@125 2903 else
cannam@125 2904 func_to_host_path_result=$3
cannam@125 2905 fi
cannam@125 2906 fi
cannam@125 2907 }
cannam@125 2908 # end func_convert_path_check
cannam@125 2909
cannam@125 2910
cannam@125 2911 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
cannam@125 2912 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
cannam@125 2913 # and appending REPL if ORIG matches BACKPAT.
cannam@125 2914 func_convert_path_front_back_pathsep ()
cannam@125 2915 {
cannam@125 2916 $debug_cmd
cannam@125 2917
cannam@125 2918 case $4 in
cannam@125 2919 $1 ) func_to_host_path_result=$3$func_to_host_path_result
cannam@125 2920 ;;
cannam@125 2921 esac
cannam@125 2922 case $4 in
cannam@125 2923 $2 ) func_append func_to_host_path_result "$3"
cannam@125 2924 ;;
cannam@125 2925 esac
cannam@125 2926 }
cannam@125 2927 # end func_convert_path_front_back_pathsep
cannam@125 2928
cannam@125 2929
cannam@125 2930 ##################################################
cannam@125 2931 # $build to $host FILE NAME CONVERSION FUNCTIONS #
cannam@125 2932 ##################################################
cannam@125 2933 # invoked via '$to_host_file_cmd ARG'
cannam@125 2934 #
cannam@125 2935 # In each case, ARG is the path to be converted from $build to $host format.
cannam@125 2936 # Result will be available in $func_to_host_file_result.
cannam@125 2937
cannam@125 2938
cannam@125 2939 # func_to_host_file ARG
cannam@125 2940 # Converts the file name ARG from $build format to $host format. Return result
cannam@125 2941 # in func_to_host_file_result.
cannam@125 2942 func_to_host_file ()
cannam@125 2943 {
cannam@125 2944 $debug_cmd
cannam@125 2945
cannam@125 2946 $to_host_file_cmd "$1"
cannam@125 2947 }
cannam@125 2948 # end func_to_host_file
cannam@125 2949
cannam@125 2950
cannam@125 2951 # func_to_tool_file ARG LAZY
cannam@125 2952 # converts the file name ARG from $build format to toolchain format. Return
cannam@125 2953 # result in func_to_tool_file_result. If the conversion in use is listed
cannam@125 2954 # in (the comma separated) LAZY, no conversion takes place.
cannam@125 2955 func_to_tool_file ()
cannam@125 2956 {
cannam@125 2957 $debug_cmd
cannam@125 2958
cannam@125 2959 case ,$2, in
cannam@125 2960 *,"$to_tool_file_cmd",*)
cannam@125 2961 func_to_tool_file_result=$1
cannam@125 2962 ;;
cannam@125 2963 *)
cannam@125 2964 $to_tool_file_cmd "$1"
cannam@125 2965 func_to_tool_file_result=$func_to_host_file_result
cannam@125 2966 ;;
cannam@125 2967 esac
cannam@125 2968 }
cannam@125 2969 # end func_to_tool_file
cannam@125 2970
cannam@125 2971
cannam@125 2972 # func_convert_file_noop ARG
cannam@125 2973 # Copy ARG to func_to_host_file_result.
cannam@125 2974 func_convert_file_noop ()
cannam@125 2975 {
cannam@125 2976 func_to_host_file_result=$1
cannam@125 2977 }
cannam@125 2978 # end func_convert_file_noop
cannam@125 2979
cannam@125 2980
cannam@125 2981 # func_convert_file_msys_to_w32 ARG
cannam@125 2982 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
cannam@125 2983 # conversion to w32 is not available inside the cwrapper. Returns result in
cannam@125 2984 # func_to_host_file_result.
cannam@125 2985 func_convert_file_msys_to_w32 ()
cannam@125 2986 {
cannam@125 2987 $debug_cmd
cannam@125 2988
cannam@125 2989 func_to_host_file_result=$1
cannam@125 2990 if test -n "$1"; then
cannam@125 2991 func_convert_core_msys_to_w32 "$1"
cannam@125 2992 func_to_host_file_result=$func_convert_core_msys_to_w32_result
cannam@125 2993 fi
cannam@125 2994 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@125 2995 }
cannam@125 2996 # end func_convert_file_msys_to_w32
cannam@125 2997
cannam@125 2998
cannam@125 2999 # func_convert_file_cygwin_to_w32 ARG
cannam@125 3000 # Convert file name ARG from Cygwin to w32 format. Returns result in
cannam@125 3001 # func_to_host_file_result.
cannam@125 3002 func_convert_file_cygwin_to_w32 ()
cannam@125 3003 {
cannam@125 3004 $debug_cmd
cannam@125 3005
cannam@125 3006 func_to_host_file_result=$1
cannam@125 3007 if test -n "$1"; then
cannam@125 3008 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
cannam@125 3009 # LT_CYGPATH in this case.
cannam@125 3010 func_to_host_file_result=`cygpath -m "$1"`
cannam@125 3011 fi
cannam@125 3012 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@125 3013 }
cannam@125 3014 # end func_convert_file_cygwin_to_w32
cannam@125 3015
cannam@125 3016
cannam@125 3017 # func_convert_file_nix_to_w32 ARG
cannam@125 3018 # Convert file name ARG from *nix to w32 format. Requires a wine environment
cannam@125 3019 # and a working winepath. Returns result in func_to_host_file_result.
cannam@125 3020 func_convert_file_nix_to_w32 ()
cannam@125 3021 {
cannam@125 3022 $debug_cmd
cannam@125 3023
cannam@125 3024 func_to_host_file_result=$1
cannam@125 3025 if test -n "$1"; then
cannam@125 3026 func_convert_core_file_wine_to_w32 "$1"
cannam@125 3027 func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
cannam@125 3028 fi
cannam@125 3029 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@125 3030 }
cannam@125 3031 # end func_convert_file_nix_to_w32
cannam@125 3032
cannam@125 3033
cannam@125 3034 # func_convert_file_msys_to_cygwin ARG
cannam@125 3035 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
cannam@125 3036 # Returns result in func_to_host_file_result.
cannam@125 3037 func_convert_file_msys_to_cygwin ()
cannam@125 3038 {
cannam@125 3039 $debug_cmd
cannam@125 3040
cannam@125 3041 func_to_host_file_result=$1
cannam@125 3042 if test -n "$1"; then
cannam@125 3043 func_convert_core_msys_to_w32 "$1"
cannam@125 3044 func_cygpath -u "$func_convert_core_msys_to_w32_result"
cannam@125 3045 func_to_host_file_result=$func_cygpath_result
cannam@125 3046 fi
cannam@125 3047 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@125 3048 }
cannam@125 3049 # end func_convert_file_msys_to_cygwin
cannam@125 3050
cannam@125 3051
cannam@125 3052 # func_convert_file_nix_to_cygwin ARG
cannam@125 3053 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
cannam@125 3054 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
cannam@125 3055 # in func_to_host_file_result.
cannam@125 3056 func_convert_file_nix_to_cygwin ()
cannam@125 3057 {
cannam@125 3058 $debug_cmd
cannam@125 3059
cannam@125 3060 func_to_host_file_result=$1
cannam@125 3061 if test -n "$1"; then
cannam@125 3062 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
cannam@125 3063 func_convert_core_file_wine_to_w32 "$1"
cannam@125 3064 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
cannam@125 3065 func_to_host_file_result=$func_cygpath_result
cannam@125 3066 fi
cannam@125 3067 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@125 3068 }
cannam@125 3069 # end func_convert_file_nix_to_cygwin
cannam@125 3070
cannam@125 3071
cannam@125 3072 #############################################
cannam@125 3073 # $build to $host PATH CONVERSION FUNCTIONS #
cannam@125 3074 #############################################
cannam@125 3075 # invoked via '$to_host_path_cmd ARG'
cannam@125 3076 #
cannam@125 3077 # In each case, ARG is the path to be converted from $build to $host format.
cannam@125 3078 # The result will be available in $func_to_host_path_result.
cannam@125 3079 #
cannam@125 3080 # Path separators are also converted from $build format to $host format. If
cannam@125 3081 # ARG begins or ends with a path separator character, it is preserved (but
cannam@125 3082 # converted to $host format) on output.
cannam@125 3083 #
cannam@125 3084 # All path conversion functions are named using the following convention:
cannam@125 3085 # file name conversion function : func_convert_file_X_to_Y ()
cannam@125 3086 # path conversion function : func_convert_path_X_to_Y ()
cannam@125 3087 # where, for any given $build/$host combination the 'X_to_Y' value is the
cannam@125 3088 # same. If conversion functions are added for new $build/$host combinations,
cannam@125 3089 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
cannam@125 3090 # will break.
cannam@125 3091
cannam@125 3092
cannam@125 3093 # func_init_to_host_path_cmd
cannam@125 3094 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
cannam@125 3095 # appropriate value, based on the value of $to_host_file_cmd.
cannam@125 3096 to_host_path_cmd=
cannam@125 3097 func_init_to_host_path_cmd ()
cannam@125 3098 {
cannam@125 3099 $debug_cmd
cannam@125 3100
cannam@125 3101 if test -z "$to_host_path_cmd"; then
cannam@125 3102 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
cannam@125 3103 to_host_path_cmd=func_convert_path_$func_stripname_result
cannam@125 3104 fi
cannam@125 3105 }
cannam@125 3106
cannam@125 3107
cannam@125 3108 # func_to_host_path ARG
cannam@125 3109 # Converts the path ARG from $build format to $host format. Return result
cannam@125 3110 # in func_to_host_path_result.
cannam@125 3111 func_to_host_path ()
cannam@125 3112 {
cannam@125 3113 $debug_cmd
cannam@125 3114
cannam@125 3115 func_init_to_host_path_cmd
cannam@125 3116 $to_host_path_cmd "$1"
cannam@125 3117 }
cannam@125 3118 # end func_to_host_path
cannam@125 3119
cannam@125 3120
cannam@125 3121 # func_convert_path_noop ARG
cannam@125 3122 # Copy ARG to func_to_host_path_result.
cannam@125 3123 func_convert_path_noop ()
cannam@125 3124 {
cannam@125 3125 func_to_host_path_result=$1
cannam@125 3126 }
cannam@125 3127 # end func_convert_path_noop
cannam@125 3128
cannam@125 3129
cannam@125 3130 # func_convert_path_msys_to_w32 ARG
cannam@125 3131 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
cannam@125 3132 # conversion to w32 is not available inside the cwrapper. Returns result in
cannam@125 3133 # func_to_host_path_result.
cannam@125 3134 func_convert_path_msys_to_w32 ()
cannam@125 3135 {
cannam@125 3136 $debug_cmd
cannam@125 3137
cannam@125 3138 func_to_host_path_result=$1
cannam@125 3139 if test -n "$1"; then
cannam@125 3140 # Remove leading and trailing path separator characters from ARG. MSYS
cannam@125 3141 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
cannam@125 3142 # and winepath ignores them completely.
cannam@125 3143 func_stripname : : "$1"
cannam@125 3144 func_to_host_path_tmp1=$func_stripname_result
cannam@125 3145 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
cannam@125 3146 func_to_host_path_result=$func_convert_core_msys_to_w32_result
cannam@125 3147 func_convert_path_check : ";" \
cannam@125 3148 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@125 3149 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
cannam@125 3150 fi
cannam@125 3151 }
cannam@125 3152 # end func_convert_path_msys_to_w32
cannam@125 3153
cannam@125 3154
cannam@125 3155 # func_convert_path_cygwin_to_w32 ARG
cannam@125 3156 # Convert path ARG from Cygwin to w32 format. Returns result in
cannam@125 3157 # func_to_host_file_result.
cannam@125 3158 func_convert_path_cygwin_to_w32 ()
cannam@125 3159 {
cannam@125 3160 $debug_cmd
cannam@125 3161
cannam@125 3162 func_to_host_path_result=$1
cannam@125 3163 if test -n "$1"; then
cannam@125 3164 # See func_convert_path_msys_to_w32:
cannam@125 3165 func_stripname : : "$1"
cannam@125 3166 func_to_host_path_tmp1=$func_stripname_result
cannam@125 3167 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
cannam@125 3168 func_convert_path_check : ";" \
cannam@125 3169 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@125 3170 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
cannam@125 3171 fi
cannam@125 3172 }
cannam@125 3173 # end func_convert_path_cygwin_to_w32
cannam@125 3174
cannam@125 3175
cannam@125 3176 # func_convert_path_nix_to_w32 ARG
cannam@125 3177 # Convert path ARG from *nix to w32 format. Requires a wine environment and
cannam@125 3178 # a working winepath. Returns result in func_to_host_file_result.
cannam@125 3179 func_convert_path_nix_to_w32 ()
cannam@125 3180 {
cannam@125 3181 $debug_cmd
cannam@125 3182
cannam@125 3183 func_to_host_path_result=$1
cannam@125 3184 if test -n "$1"; then
cannam@125 3185 # See func_convert_path_msys_to_w32:
cannam@125 3186 func_stripname : : "$1"
cannam@125 3187 func_to_host_path_tmp1=$func_stripname_result
cannam@125 3188 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
cannam@125 3189 func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
cannam@125 3190 func_convert_path_check : ";" \
cannam@125 3191 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@125 3192 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
cannam@125 3193 fi
cannam@125 3194 }
cannam@125 3195 # end func_convert_path_nix_to_w32
cannam@125 3196
cannam@125 3197
cannam@125 3198 # func_convert_path_msys_to_cygwin ARG
cannam@125 3199 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
cannam@125 3200 # Returns result in func_to_host_file_result.
cannam@125 3201 func_convert_path_msys_to_cygwin ()
cannam@125 3202 {
cannam@125 3203 $debug_cmd
cannam@125 3204
cannam@125 3205 func_to_host_path_result=$1
cannam@125 3206 if test -n "$1"; then
cannam@125 3207 # See func_convert_path_msys_to_w32:
cannam@125 3208 func_stripname : : "$1"
cannam@125 3209 func_to_host_path_tmp1=$func_stripname_result
cannam@125 3210 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
cannam@125 3211 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
cannam@125 3212 func_to_host_path_result=$func_cygpath_result
cannam@125 3213 func_convert_path_check : : \
cannam@125 3214 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@125 3215 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
cannam@125 3216 fi
cannam@125 3217 }
cannam@125 3218 # end func_convert_path_msys_to_cygwin
cannam@125 3219
cannam@125 3220
cannam@125 3221 # func_convert_path_nix_to_cygwin ARG
cannam@125 3222 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
cannam@125 3223 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
cannam@125 3224 # func_to_host_file_result.
cannam@125 3225 func_convert_path_nix_to_cygwin ()
cannam@125 3226 {
cannam@125 3227 $debug_cmd
cannam@125 3228
cannam@125 3229 func_to_host_path_result=$1
cannam@125 3230 if test -n "$1"; then
cannam@125 3231 # Remove leading and trailing path separator characters from
cannam@125 3232 # ARG. msys behavior is inconsistent here, cygpath turns them
cannam@125 3233 # into '.;' and ';.', and winepath ignores them completely.
cannam@125 3234 func_stripname : : "$1"
cannam@125 3235 func_to_host_path_tmp1=$func_stripname_result
cannam@125 3236 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
cannam@125 3237 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
cannam@125 3238 func_to_host_path_result=$func_cygpath_result
cannam@125 3239 func_convert_path_check : : \
cannam@125 3240 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@125 3241 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
cannam@125 3242 fi
cannam@125 3243 }
cannam@125 3244 # end func_convert_path_nix_to_cygwin
cannam@125 3245
cannam@125 3246
cannam@125 3247 # func_dll_def_p FILE
cannam@125 3248 # True iff FILE is a Windows DLL '.def' file.
cannam@125 3249 # Keep in sync with _LT_DLL_DEF_P in libtool.m4
cannam@125 3250 func_dll_def_p ()
cannam@125 3251 {
cannam@125 3252 $debug_cmd
cannam@125 3253
cannam@125 3254 func_dll_def_p_tmp=`$SED -n \
cannam@125 3255 -e 's/^[ ]*//' \
cannam@125 3256 -e '/^\(;.*\)*$/d' \
cannam@125 3257 -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
cannam@125 3258 -e q \
cannam@125 3259 "$1"`
cannam@125 3260 test DEF = "$func_dll_def_p_tmp"
cannam@125 3261 }
cannam@125 3262
cannam@125 3263
cannam@125 3264 # func_mode_compile arg...
cannam@125 3265 func_mode_compile ()
cannam@125 3266 {
cannam@125 3267 $debug_cmd
cannam@125 3268
cannam@125 3269 # Get the compilation command and the source file.
cannam@125 3270 base_compile=
cannam@125 3271 srcfile=$nonopt # always keep a non-empty value in "srcfile"
cannam@125 3272 suppress_opt=yes
cannam@125 3273 suppress_output=
cannam@125 3274 arg_mode=normal
cannam@125 3275 libobj=
cannam@125 3276 later=
cannam@125 3277 pie_flag=
cannam@125 3278
cannam@125 3279 for arg
cannam@125 3280 do
cannam@125 3281 case $arg_mode in
cannam@125 3282 arg )
cannam@125 3283 # do not "continue". Instead, add this to base_compile
cannam@125 3284 lastarg=$arg
cannam@125 3285 arg_mode=normal
cannam@125 3286 ;;
cannam@125 3287
cannam@125 3288 target )
cannam@125 3289 libobj=$arg
cannam@125 3290 arg_mode=normal
cannam@125 3291 continue
cannam@125 3292 ;;
cannam@125 3293
cannam@125 3294 normal )
cannam@125 3295 # Accept any command-line options.
cannam@125 3296 case $arg in
cannam@125 3297 -o)
cannam@125 3298 test -n "$libobj" && \
cannam@125 3299 func_fatal_error "you cannot specify '-o' more than once"
cannam@125 3300 arg_mode=target
cannam@125 3301 continue
cannam@125 3302 ;;
cannam@125 3303
cannam@125 3304 -pie | -fpie | -fPIE)
cannam@125 3305 func_append pie_flag " $arg"
cannam@125 3306 continue
cannam@125 3307 ;;
cannam@125 3308
cannam@125 3309 -shared | -static | -prefer-pic | -prefer-non-pic)
cannam@125 3310 func_append later " $arg"
cannam@125 3311 continue
cannam@125 3312 ;;
cannam@125 3313
cannam@125 3314 -no-suppress)
cannam@125 3315 suppress_opt=no
cannam@125 3316 continue
cannam@125 3317 ;;
cannam@125 3318
cannam@125 3319 -Xcompiler)
cannam@125 3320 arg_mode=arg # the next one goes into the "base_compile" arg list
cannam@125 3321 continue # The current "srcfile" will either be retained or
cannam@125 3322 ;; # replaced later. I would guess that would be a bug.
cannam@125 3323
cannam@125 3324 -Wc,*)
cannam@125 3325 func_stripname '-Wc,' '' "$arg"
cannam@125 3326 args=$func_stripname_result
cannam@125 3327 lastarg=
cannam@125 3328 save_ifs=$IFS; IFS=,
cannam@125 3329 for arg in $args; do
cannam@125 3330 IFS=$save_ifs
cannam@125 3331 func_append_quoted lastarg "$arg"
cannam@125 3332 done
cannam@125 3333 IFS=$save_ifs
cannam@125 3334 func_stripname ' ' '' "$lastarg"
cannam@125 3335 lastarg=$func_stripname_result
cannam@125 3336
cannam@125 3337 # Add the arguments to base_compile.
cannam@125 3338 func_append base_compile " $lastarg"
cannam@125 3339 continue
cannam@125 3340 ;;
cannam@125 3341
cannam@125 3342 *)
cannam@125 3343 # Accept the current argument as the source file.
cannam@125 3344 # The previous "srcfile" becomes the current argument.
cannam@125 3345 #
cannam@125 3346 lastarg=$srcfile
cannam@125 3347 srcfile=$arg
cannam@125 3348 ;;
cannam@125 3349 esac # case $arg
cannam@125 3350 ;;
cannam@125 3351 esac # case $arg_mode
cannam@125 3352
cannam@125 3353 # Aesthetically quote the previous argument.
cannam@125 3354 func_append_quoted base_compile "$lastarg"
cannam@125 3355 done # for arg
cannam@125 3356
cannam@125 3357 case $arg_mode in
cannam@125 3358 arg)
cannam@125 3359 func_fatal_error "you must specify an argument for -Xcompile"
cannam@125 3360 ;;
cannam@125 3361 target)
cannam@125 3362 func_fatal_error "you must specify a target with '-o'"
cannam@125 3363 ;;
cannam@125 3364 *)
cannam@125 3365 # Get the name of the library object.
cannam@125 3366 test -z "$libobj" && {
cannam@125 3367 func_basename "$srcfile"
cannam@125 3368 libobj=$func_basename_result
cannam@125 3369 }
cannam@125 3370 ;;
cannam@125 3371 esac
cannam@125 3372
cannam@125 3373 # Recognize several different file suffixes.
cannam@125 3374 # If the user specifies -o file.o, it is replaced with file.lo
cannam@125 3375 case $libobj in
cannam@125 3376 *.[cCFSifmso] | \
cannam@125 3377 *.ada | *.adb | *.ads | *.asm | \
cannam@125 3378 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
cannam@125 3379 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
cannam@125 3380 func_xform "$libobj"
cannam@125 3381 libobj=$func_xform_result
cannam@125 3382 ;;
cannam@125 3383 esac
cannam@125 3384
cannam@125 3385 case $libobj in
cannam@125 3386 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
cannam@125 3387 *)
cannam@125 3388 func_fatal_error "cannot determine name of library object from '$libobj'"
cannam@125 3389 ;;
cannam@125 3390 esac
cannam@125 3391
cannam@125 3392 func_infer_tag $base_compile
cannam@125 3393
cannam@125 3394 for arg in $later; do
cannam@125 3395 case $arg in
cannam@125 3396 -shared)
cannam@125 3397 test yes = "$build_libtool_libs" \
cannam@125 3398 || func_fatal_configuration "cannot build a shared library"
cannam@125 3399 build_old_libs=no
cannam@125 3400 continue
cannam@125 3401 ;;
cannam@125 3402
cannam@125 3403 -static)
cannam@125 3404 build_libtool_libs=no
cannam@125 3405 build_old_libs=yes
cannam@125 3406 continue
cannam@125 3407 ;;
cannam@125 3408
cannam@125 3409 -prefer-pic)
cannam@125 3410 pic_mode=yes
cannam@125 3411 continue
cannam@125 3412 ;;
cannam@125 3413
cannam@125 3414 -prefer-non-pic)
cannam@125 3415 pic_mode=no
cannam@125 3416 continue
cannam@125 3417 ;;
cannam@125 3418 esac
cannam@125 3419 done
cannam@125 3420
cannam@125 3421 func_quote_for_eval "$libobj"
cannam@125 3422 test "X$libobj" != "X$func_quote_for_eval_result" \
cannam@125 3423 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
cannam@125 3424 && func_warning "libobj name '$libobj' may not contain shell special characters."
cannam@125 3425 func_dirname_and_basename "$obj" "/" ""
cannam@125 3426 objname=$func_basename_result
cannam@125 3427 xdir=$func_dirname_result
cannam@125 3428 lobj=$xdir$objdir/$objname
cannam@125 3429
cannam@125 3430 test -z "$base_compile" && \
cannam@125 3431 func_fatal_help "you must specify a compilation command"
cannam@125 3432
cannam@125 3433 # Delete any leftover library objects.
cannam@125 3434 if test yes = "$build_old_libs"; then
cannam@125 3435 removelist="$obj $lobj $libobj ${libobj}T"
cannam@125 3436 else
cannam@125 3437 removelist="$lobj $libobj ${libobj}T"
cannam@125 3438 fi
cannam@125 3439
cannam@125 3440 # On Cygwin there's no "real" PIC flag so we must build both object types
cannam@125 3441 case $host_os in
cannam@125 3442 cygwin* | mingw* | pw32* | os2* | cegcc*)
cannam@125 3443 pic_mode=default
cannam@125 3444 ;;
cannam@125 3445 esac
cannam@125 3446 if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
cannam@125 3447 # non-PIC code in shared libraries is not supported
cannam@125 3448 pic_mode=default
cannam@125 3449 fi
cannam@125 3450
cannam@125 3451 # Calculate the filename of the output object if compiler does
cannam@125 3452 # not support -o with -c
cannam@125 3453 if test no = "$compiler_c_o"; then
cannam@125 3454 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
cannam@125 3455 lockfile=$output_obj.lock
cannam@125 3456 else
cannam@125 3457 output_obj=
cannam@125 3458 need_locks=no
cannam@125 3459 lockfile=
cannam@125 3460 fi
cannam@125 3461
cannam@125 3462 # Lock this critical section if it is needed
cannam@125 3463 # We use this script file to make the link, it avoids creating a new file
cannam@125 3464 if test yes = "$need_locks"; then
cannam@125 3465 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
cannam@125 3466 func_echo "Waiting for $lockfile to be removed"
cannam@125 3467 sleep 2
cannam@125 3468 done
cannam@125 3469 elif test warn = "$need_locks"; then
cannam@125 3470 if test -f "$lockfile"; then
cannam@125 3471 $ECHO "\
cannam@125 3472 *** ERROR, $lockfile exists and contains:
cannam@125 3473 `cat $lockfile 2>/dev/null`
cannam@125 3474
cannam@125 3475 This indicates that another process is trying to use the same
cannam@125 3476 temporary object file, and libtool could not work around it because
cannam@125 3477 your compiler does not support '-c' and '-o' together. If you
cannam@125 3478 repeat this compilation, it may succeed, by chance, but you had better
cannam@125 3479 avoid parallel builds (make -j) in this platform, or get a better
cannam@125 3480 compiler."
cannam@125 3481
cannam@125 3482 $opt_dry_run || $RM $removelist
cannam@125 3483 exit $EXIT_FAILURE
cannam@125 3484 fi
cannam@125 3485 func_append removelist " $output_obj"
cannam@125 3486 $ECHO "$srcfile" > "$lockfile"
cannam@125 3487 fi
cannam@125 3488
cannam@125 3489 $opt_dry_run || $RM $removelist
cannam@125 3490 func_append removelist " $lockfile"
cannam@125 3491 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
cannam@125 3492
cannam@125 3493 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
cannam@125 3494 srcfile=$func_to_tool_file_result
cannam@125 3495 func_quote_for_eval "$srcfile"
cannam@125 3496 qsrcfile=$func_quote_for_eval_result
cannam@125 3497
cannam@125 3498 # Only build a PIC object if we are building libtool libraries.
cannam@125 3499 if test yes = "$build_libtool_libs"; then
cannam@125 3500 # Without this assignment, base_compile gets emptied.
cannam@125 3501 fbsd_hideous_sh_bug=$base_compile
cannam@125 3502
cannam@125 3503 if test no != "$pic_mode"; then
cannam@125 3504 command="$base_compile $qsrcfile $pic_flag"
cannam@125 3505 else
cannam@125 3506 # Don't build PIC code
cannam@125 3507 command="$base_compile $qsrcfile"
cannam@125 3508 fi
cannam@125 3509
cannam@125 3510 func_mkdir_p "$xdir$objdir"
cannam@125 3511
cannam@125 3512 if test -z "$output_obj"; then
cannam@125 3513 # Place PIC objects in $objdir
cannam@125 3514 func_append command " -o $lobj"
cannam@125 3515 fi
cannam@125 3516
cannam@125 3517 func_show_eval_locale "$command" \
cannam@125 3518 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
cannam@125 3519
cannam@125 3520 if test warn = "$need_locks" &&
cannam@125 3521 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
cannam@125 3522 $ECHO "\
cannam@125 3523 *** ERROR, $lockfile contains:
cannam@125 3524 `cat $lockfile 2>/dev/null`
cannam@125 3525
cannam@125 3526 but it should contain:
cannam@125 3527 $srcfile
cannam@125 3528
cannam@125 3529 This indicates that another process is trying to use the same
cannam@125 3530 temporary object file, and libtool could not work around it because
cannam@125 3531 your compiler does not support '-c' and '-o' together. If you
cannam@125 3532 repeat this compilation, it may succeed, by chance, but you had better
cannam@125 3533 avoid parallel builds (make -j) in this platform, or get a better
cannam@125 3534 compiler."
cannam@125 3535
cannam@125 3536 $opt_dry_run || $RM $removelist
cannam@125 3537 exit $EXIT_FAILURE
cannam@125 3538 fi
cannam@125 3539
cannam@125 3540 # Just move the object if needed, then go on to compile the next one
cannam@125 3541 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
cannam@125 3542 func_show_eval '$MV "$output_obj" "$lobj"' \
cannam@125 3543 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
cannam@125 3544 fi
cannam@125 3545
cannam@125 3546 # Allow error messages only from the first compilation.
cannam@125 3547 if test yes = "$suppress_opt"; then
cannam@125 3548 suppress_output=' >/dev/null 2>&1'
cannam@125 3549 fi
cannam@125 3550 fi
cannam@125 3551
cannam@125 3552 # Only build a position-dependent object if we build old libraries.
cannam@125 3553 if test yes = "$build_old_libs"; then
cannam@125 3554 if test yes != "$pic_mode"; then
cannam@125 3555 # Don't build PIC code
cannam@125 3556 command="$base_compile $qsrcfile$pie_flag"
cannam@125 3557 else
cannam@125 3558 command="$base_compile $qsrcfile $pic_flag"
cannam@125 3559 fi
cannam@125 3560 if test yes = "$compiler_c_o"; then
cannam@125 3561 func_append command " -o $obj"
cannam@125 3562 fi
cannam@125 3563
cannam@125 3564 # Suppress compiler output if we already did a PIC compilation.
cannam@125 3565 func_append command "$suppress_output"
cannam@125 3566 func_show_eval_locale "$command" \
cannam@125 3567 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
cannam@125 3568
cannam@125 3569 if test warn = "$need_locks" &&
cannam@125 3570 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
cannam@125 3571 $ECHO "\
cannam@125 3572 *** ERROR, $lockfile contains:
cannam@125 3573 `cat $lockfile 2>/dev/null`
cannam@125 3574
cannam@125 3575 but it should contain:
cannam@125 3576 $srcfile
cannam@125 3577
cannam@125 3578 This indicates that another process is trying to use the same
cannam@125 3579 temporary object file, and libtool could not work around it because
cannam@125 3580 your compiler does not support '-c' and '-o' together. If you
cannam@125 3581 repeat this compilation, it may succeed, by chance, but you had better
cannam@125 3582 avoid parallel builds (make -j) in this platform, or get a better
cannam@125 3583 compiler."
cannam@125 3584
cannam@125 3585 $opt_dry_run || $RM $removelist
cannam@125 3586 exit $EXIT_FAILURE
cannam@125 3587 fi
cannam@125 3588
cannam@125 3589 # Just move the object if needed
cannam@125 3590 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
cannam@125 3591 func_show_eval '$MV "$output_obj" "$obj"' \
cannam@125 3592 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
cannam@125 3593 fi
cannam@125 3594 fi
cannam@125 3595
cannam@125 3596 $opt_dry_run || {
cannam@125 3597 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
cannam@125 3598
cannam@125 3599 # Unlock the critical section if it was locked
cannam@125 3600 if test no != "$need_locks"; then
cannam@125 3601 removelist=$lockfile
cannam@125 3602 $RM "$lockfile"
cannam@125 3603 fi
cannam@125 3604 }
cannam@125 3605
cannam@125 3606 exit $EXIT_SUCCESS
cannam@125 3607 }
cannam@125 3608
cannam@125 3609 $opt_help || {
cannam@125 3610 test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
cannam@125 3611 }
cannam@125 3612
cannam@125 3613 func_mode_help ()
cannam@125 3614 {
cannam@125 3615 # We need to display help for each of the modes.
cannam@125 3616 case $opt_mode in
cannam@125 3617 "")
cannam@125 3618 # Generic help is extracted from the usage comments
cannam@125 3619 # at the start of this file.
cannam@125 3620 func_help
cannam@125 3621 ;;
cannam@125 3622
cannam@125 3623 clean)
cannam@125 3624 $ECHO \
cannam@125 3625 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
cannam@125 3626
cannam@125 3627 Remove files from the build directory.
cannam@125 3628
cannam@125 3629 RM is the name of the program to use to delete files associated with each FILE
cannam@125 3630 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
cannam@125 3631 to RM.
cannam@125 3632
cannam@125 3633 If FILE is a libtool library, object or program, all the files associated
cannam@125 3634 with it are deleted. Otherwise, only FILE itself is deleted using RM."
cannam@125 3635 ;;
cannam@125 3636
cannam@125 3637 compile)
cannam@125 3638 $ECHO \
cannam@125 3639 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
cannam@125 3640
cannam@125 3641 Compile a source file into a libtool library object.
cannam@125 3642
cannam@125 3643 This mode accepts the following additional options:
cannam@125 3644
cannam@125 3645 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
cannam@125 3646 -no-suppress do not suppress compiler output for multiple passes
cannam@125 3647 -prefer-pic try to build PIC objects only
cannam@125 3648 -prefer-non-pic try to build non-PIC objects only
cannam@125 3649 -shared do not build a '.o' file suitable for static linking
cannam@125 3650 -static only build a '.o' file suitable for static linking
cannam@125 3651 -Wc,FLAG pass FLAG directly to the compiler
cannam@125 3652
cannam@125 3653 COMPILE-COMMAND is a command to be used in creating a 'standard' object file
cannam@125 3654 from the given SOURCEFILE.
cannam@125 3655
cannam@125 3656 The output file name is determined by removing the directory component from
cannam@125 3657 SOURCEFILE, then substituting the C source code suffix '.c' with the
cannam@125 3658 library object suffix, '.lo'."
cannam@125 3659 ;;
cannam@125 3660
cannam@125 3661 execute)
cannam@125 3662 $ECHO \
cannam@125 3663 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
cannam@125 3664
cannam@125 3665 Automatically set library path, then run a program.
cannam@125 3666
cannam@125 3667 This mode accepts the following additional options:
cannam@125 3668
cannam@125 3669 -dlopen FILE add the directory containing FILE to the library path
cannam@125 3670
cannam@125 3671 This mode sets the library path environment variable according to '-dlopen'
cannam@125 3672 flags.
cannam@125 3673
cannam@125 3674 If any of the ARGS are libtool executable wrappers, then they are translated
cannam@125 3675 into their corresponding uninstalled binary, and any of their required library
cannam@125 3676 directories are added to the library path.
cannam@125 3677
cannam@125 3678 Then, COMMAND is executed, with ARGS as arguments."
cannam@125 3679 ;;
cannam@125 3680
cannam@125 3681 finish)
cannam@125 3682 $ECHO \
cannam@125 3683 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
cannam@125 3684
cannam@125 3685 Complete the installation of libtool libraries.
cannam@125 3686
cannam@125 3687 Each LIBDIR is a directory that contains libtool libraries.
cannam@125 3688
cannam@125 3689 The commands that this mode executes may require superuser privileges. Use
cannam@125 3690 the '--dry-run' option if you just want to see what would be executed."
cannam@125 3691 ;;
cannam@125 3692
cannam@125 3693 install)
cannam@125 3694 $ECHO \
cannam@125 3695 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
cannam@125 3696
cannam@125 3697 Install executables or libraries.
cannam@125 3698
cannam@125 3699 INSTALL-COMMAND is the installation command. The first component should be
cannam@125 3700 either the 'install' or 'cp' program.
cannam@125 3701
cannam@125 3702 The following components of INSTALL-COMMAND are treated specially:
cannam@125 3703
cannam@125 3704 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
cannam@125 3705
cannam@125 3706 The rest of the components are interpreted as arguments to that command (only
cannam@125 3707 BSD-compatible install options are recognized)."
cannam@125 3708 ;;
cannam@125 3709
cannam@125 3710 link)
cannam@125 3711 $ECHO \
cannam@125 3712 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
cannam@125 3713
cannam@125 3714 Link object files or libraries together to form another library, or to
cannam@125 3715 create an executable program.
cannam@125 3716
cannam@125 3717 LINK-COMMAND is a command using the C compiler that you would use to create
cannam@125 3718 a program from several object files.
cannam@125 3719
cannam@125 3720 The following components of LINK-COMMAND are treated specially:
cannam@125 3721
cannam@125 3722 -all-static do not do any dynamic linking at all
cannam@125 3723 -avoid-version do not add a version suffix if possible
cannam@125 3724 -bindir BINDIR specify path to binaries directory (for systems where
cannam@125 3725 libraries must be found in the PATH setting at runtime)
cannam@125 3726 -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
cannam@125 3727 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
cannam@125 3728 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
cannam@125 3729 -export-symbols SYMFILE
cannam@125 3730 try to export only the symbols listed in SYMFILE
cannam@125 3731 -export-symbols-regex REGEX
cannam@125 3732 try to export only the symbols matching REGEX
cannam@125 3733 -LLIBDIR search LIBDIR for required installed libraries
cannam@125 3734 -lNAME OUTPUT-FILE requires the installed library libNAME
cannam@125 3735 -module build a library that can dlopened
cannam@125 3736 -no-fast-install disable the fast-install mode
cannam@125 3737 -no-install link a not-installable executable
cannam@125 3738 -no-undefined declare that a library does not refer to external symbols
cannam@125 3739 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
cannam@125 3740 -objectlist FILE use a list of object files found in FILE to specify objects
cannam@125 3741 -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
cannam@125 3742 -precious-files-regex REGEX
cannam@125 3743 don't remove output files matching REGEX
cannam@125 3744 -release RELEASE specify package release information
cannam@125 3745 -rpath LIBDIR the created library will eventually be installed in LIBDIR
cannam@125 3746 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
cannam@125 3747 -shared only do dynamic linking of libtool libraries
cannam@125 3748 -shrext SUFFIX override the standard shared library file extension
cannam@125 3749 -static do not do any dynamic linking of uninstalled libtool libraries
cannam@125 3750 -static-libtool-libs
cannam@125 3751 do not do any dynamic linking of libtool libraries
cannam@125 3752 -version-info CURRENT[:REVISION[:AGE]]
cannam@125 3753 specify library version info [each variable defaults to 0]
cannam@125 3754 -weak LIBNAME declare that the target provides the LIBNAME interface
cannam@125 3755 -Wc,FLAG
cannam@125 3756 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
cannam@125 3757 -Wl,FLAG
cannam@125 3758 -Xlinker FLAG pass linker-specific FLAG directly to the linker
cannam@125 3759 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
cannam@125 3760
cannam@125 3761 All other options (arguments beginning with '-') are ignored.
cannam@125 3762
cannam@125 3763 Every other argument is treated as a filename. Files ending in '.la' are
cannam@125 3764 treated as uninstalled libtool libraries, other files are standard or library
cannam@125 3765 object files.
cannam@125 3766
cannam@125 3767 If the OUTPUT-FILE ends in '.la', then a libtool library is created,
cannam@125 3768 only library objects ('.lo' files) may be specified, and '-rpath' is
cannam@125 3769 required, except when creating a convenience library.
cannam@125 3770
cannam@125 3771 If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
cannam@125 3772 using 'ar' and 'ranlib', or on Windows using 'lib'.
cannam@125 3773
cannam@125 3774 If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
cannam@125 3775 is created, otherwise an executable program is created."
cannam@125 3776 ;;
cannam@125 3777
cannam@125 3778 uninstall)
cannam@125 3779 $ECHO \
cannam@125 3780 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
cannam@125 3781
cannam@125 3782 Remove libraries from an installation directory.
cannam@125 3783
cannam@125 3784 RM is the name of the program to use to delete files associated with each FILE
cannam@125 3785 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
cannam@125 3786 to RM.
cannam@125 3787
cannam@125 3788 If FILE is a libtool library, all the files associated with it are deleted.
cannam@125 3789 Otherwise, only FILE itself is deleted using RM."
cannam@125 3790 ;;
cannam@125 3791
cannam@125 3792 *)
cannam@125 3793 func_fatal_help "invalid operation mode '$opt_mode'"
cannam@125 3794 ;;
cannam@125 3795 esac
cannam@125 3796
cannam@125 3797 echo
cannam@125 3798 $ECHO "Try '$progname --help' for more information about other modes."
cannam@125 3799 }
cannam@125 3800
cannam@125 3801 # Now that we've collected a possible --mode arg, show help if necessary
cannam@125 3802 if $opt_help; then
cannam@125 3803 if test : = "$opt_help"; then
cannam@125 3804 func_mode_help
cannam@125 3805 else
cannam@125 3806 {
cannam@125 3807 func_help noexit
cannam@125 3808 for opt_mode in compile link execute install finish uninstall clean; do
cannam@125 3809 func_mode_help
cannam@125 3810 done
cannam@125 3811 } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
cannam@125 3812 {
cannam@125 3813 func_help noexit
cannam@125 3814 for opt_mode in compile link execute install finish uninstall clean; do
cannam@125 3815 echo
cannam@125 3816 func_mode_help
cannam@125 3817 done
cannam@125 3818 } |
cannam@125 3819 $SED '1d
cannam@125 3820 /^When reporting/,/^Report/{
cannam@125 3821 H
cannam@125 3822 d
cannam@125 3823 }
cannam@125 3824 $x
cannam@125 3825 /information about other modes/d
cannam@125 3826 /more detailed .*MODE/d
cannam@125 3827 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
cannam@125 3828 fi
cannam@125 3829 exit $?
cannam@125 3830 fi
cannam@125 3831
cannam@125 3832
cannam@125 3833 # func_mode_execute arg...
cannam@125 3834 func_mode_execute ()
cannam@125 3835 {
cannam@125 3836 $debug_cmd
cannam@125 3837
cannam@125 3838 # The first argument is the command name.
cannam@125 3839 cmd=$nonopt
cannam@125 3840 test -z "$cmd" && \
cannam@125 3841 func_fatal_help "you must specify a COMMAND"
cannam@125 3842
cannam@125 3843 # Handle -dlopen flags immediately.
cannam@125 3844 for file in $opt_dlopen; do
cannam@125 3845 test -f "$file" \
cannam@125 3846 || func_fatal_help "'$file' is not a file"
cannam@125 3847
cannam@125 3848 dir=
cannam@125 3849 case $file in
cannam@125 3850 *.la)
cannam@125 3851 func_resolve_sysroot "$file"
cannam@125 3852 file=$func_resolve_sysroot_result
cannam@125 3853
cannam@125 3854 # Check to see that this really is a libtool archive.
cannam@125 3855 func_lalib_unsafe_p "$file" \
cannam@125 3856 || func_fatal_help "'$lib' is not a valid libtool archive"
cannam@125 3857
cannam@125 3858 # Read the libtool library.
cannam@125 3859 dlname=
cannam@125 3860 library_names=
cannam@125 3861 func_source "$file"
cannam@125 3862
cannam@125 3863 # Skip this library if it cannot be dlopened.
cannam@125 3864 if test -z "$dlname"; then
cannam@125 3865 # Warn if it was a shared library.
cannam@125 3866 test -n "$library_names" && \
cannam@125 3867 func_warning "'$file' was not linked with '-export-dynamic'"
cannam@125 3868 continue
cannam@125 3869 fi
cannam@125 3870
cannam@125 3871 func_dirname "$file" "" "."
cannam@125 3872 dir=$func_dirname_result
cannam@125 3873
cannam@125 3874 if test -f "$dir/$objdir/$dlname"; then
cannam@125 3875 func_append dir "/$objdir"
cannam@125 3876 else
cannam@125 3877 if test ! -f "$dir/$dlname"; then
cannam@125 3878 func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
cannam@125 3879 fi
cannam@125 3880 fi
cannam@125 3881 ;;
cannam@125 3882
cannam@125 3883 *.lo)
cannam@125 3884 # Just add the directory containing the .lo file.
cannam@125 3885 func_dirname "$file" "" "."
cannam@125 3886 dir=$func_dirname_result
cannam@125 3887 ;;
cannam@125 3888
cannam@125 3889 *)
cannam@125 3890 func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
cannam@125 3891 continue
cannam@125 3892 ;;
cannam@125 3893 esac
cannam@125 3894
cannam@125 3895 # Get the absolute pathname.
cannam@125 3896 absdir=`cd "$dir" && pwd`
cannam@125 3897 test -n "$absdir" && dir=$absdir
cannam@125 3898
cannam@125 3899 # Now add the directory to shlibpath_var.
cannam@125 3900 if eval "test -z \"\$$shlibpath_var\""; then
cannam@125 3901 eval "$shlibpath_var=\"\$dir\""
cannam@125 3902 else
cannam@125 3903 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
cannam@125 3904 fi
cannam@125 3905 done
cannam@125 3906
cannam@125 3907 # This variable tells wrapper scripts just to set shlibpath_var
cannam@125 3908 # rather than running their programs.
cannam@125 3909 libtool_execute_magic=$magic
cannam@125 3910
cannam@125 3911 # Check if any of the arguments is a wrapper script.
cannam@125 3912 args=
cannam@125 3913 for file
cannam@125 3914 do
cannam@125 3915 case $file in
cannam@125 3916 -* | *.la | *.lo ) ;;
cannam@125 3917 *)
cannam@125 3918 # Do a test to see if this is really a libtool program.
cannam@125 3919 if func_ltwrapper_script_p "$file"; then
cannam@125 3920 func_source "$file"
cannam@125 3921 # Transform arg to wrapped name.
cannam@125 3922 file=$progdir/$program
cannam@125 3923 elif func_ltwrapper_executable_p "$file"; then
cannam@125 3924 func_ltwrapper_scriptname "$file"
cannam@125 3925 func_source "$func_ltwrapper_scriptname_result"
cannam@125 3926 # Transform arg to wrapped name.
cannam@125 3927 file=$progdir/$program
cannam@125 3928 fi
cannam@125 3929 ;;
cannam@125 3930 esac
cannam@125 3931 # Quote arguments (to preserve shell metacharacters).
cannam@125 3932 func_append_quoted args "$file"
cannam@125 3933 done
cannam@125 3934
cannam@125 3935 if $opt_dry_run; then
cannam@125 3936 # Display what would be done.
cannam@125 3937 if test -n "$shlibpath_var"; then
cannam@125 3938 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
cannam@125 3939 echo "export $shlibpath_var"
cannam@125 3940 fi
cannam@125 3941 $ECHO "$cmd$args"
cannam@125 3942 exit $EXIT_SUCCESS
cannam@125 3943 else
cannam@125 3944 if test -n "$shlibpath_var"; then
cannam@125 3945 # Export the shlibpath_var.
cannam@125 3946 eval "export $shlibpath_var"
cannam@125 3947 fi
cannam@125 3948
cannam@125 3949 # Restore saved environment variables
cannam@125 3950 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
cannam@125 3951 do
cannam@125 3952 eval "if test \"\${save_$lt_var+set}\" = set; then
cannam@125 3953 $lt_var=\$save_$lt_var; export $lt_var
cannam@125 3954 else
cannam@125 3955 $lt_unset $lt_var
cannam@125 3956 fi"
cannam@125 3957 done
cannam@125 3958
cannam@125 3959 # Now prepare to actually exec the command.
cannam@125 3960 exec_cmd=\$cmd$args
cannam@125 3961 fi
cannam@125 3962 }
cannam@125 3963
cannam@125 3964 test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
cannam@125 3965
cannam@125 3966
cannam@125 3967 # func_mode_finish arg...
cannam@125 3968 func_mode_finish ()
cannam@125 3969 {
cannam@125 3970 $debug_cmd
cannam@125 3971
cannam@125 3972 libs=
cannam@125 3973 libdirs=
cannam@125 3974 admincmds=
cannam@125 3975
cannam@125 3976 for opt in "$nonopt" ${1+"$@"}
cannam@125 3977 do
cannam@125 3978 if test -d "$opt"; then
cannam@125 3979 func_append libdirs " $opt"
cannam@125 3980
cannam@125 3981 elif test -f "$opt"; then
cannam@125 3982 if func_lalib_unsafe_p "$opt"; then
cannam@125 3983 func_append libs " $opt"
cannam@125 3984 else
cannam@125 3985 func_warning "'$opt' is not a valid libtool archive"
cannam@125 3986 fi
cannam@125 3987
cannam@125 3988 else
cannam@125 3989 func_fatal_error "invalid argument '$opt'"
cannam@125 3990 fi
cannam@125 3991 done
cannam@125 3992
cannam@125 3993 if test -n "$libs"; then
cannam@125 3994 if test -n "$lt_sysroot"; then
cannam@125 3995 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
cannam@125 3996 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
cannam@125 3997 else
cannam@125 3998 sysroot_cmd=
cannam@125 3999 fi
cannam@125 4000
cannam@125 4001 # Remove sysroot references
cannam@125 4002 if $opt_dry_run; then
cannam@125 4003 for lib in $libs; do
cannam@125 4004 echo "removing references to $lt_sysroot and '=' prefixes from $lib"
cannam@125 4005 done
cannam@125 4006 else
cannam@125 4007 tmpdir=`func_mktempdir`
cannam@125 4008 for lib in $libs; do
cannam@125 4009 $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
cannam@125 4010 > $tmpdir/tmp-la
cannam@125 4011 mv -f $tmpdir/tmp-la $lib
cannam@125 4012 done
cannam@125 4013 ${RM}r "$tmpdir"
cannam@125 4014 fi
cannam@125 4015 fi
cannam@125 4016
cannam@125 4017 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
cannam@125 4018 for libdir in $libdirs; do
cannam@125 4019 if test -n "$finish_cmds"; then
cannam@125 4020 # Do each command in the finish commands.
cannam@125 4021 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
cannam@125 4022 '"$cmd"'"'
cannam@125 4023 fi
cannam@125 4024 if test -n "$finish_eval"; then
cannam@125 4025 # Do the single finish_eval.
cannam@125 4026 eval cmds=\"$finish_eval\"
cannam@125 4027 $opt_dry_run || eval "$cmds" || func_append admincmds "
cannam@125 4028 $cmds"
cannam@125 4029 fi
cannam@125 4030 done
cannam@125 4031 fi
cannam@125 4032
cannam@125 4033 # Exit here if they wanted silent mode.
cannam@125 4034 $opt_quiet && exit $EXIT_SUCCESS
cannam@125 4035
cannam@125 4036 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
cannam@125 4037 echo "----------------------------------------------------------------------"
cannam@125 4038 echo "Libraries have been installed in:"
cannam@125 4039 for libdir in $libdirs; do
cannam@125 4040 $ECHO " $libdir"
cannam@125 4041 done
cannam@125 4042 echo
cannam@125 4043 echo "If you ever happen to want to link against installed libraries"
cannam@125 4044 echo "in a given directory, LIBDIR, you must either use libtool, and"
cannam@125 4045 echo "specify the full pathname of the library, or use the '-LLIBDIR'"
cannam@125 4046 echo "flag during linking and do at least one of the following:"
cannam@125 4047 if test -n "$shlibpath_var"; then
cannam@125 4048 echo " - add LIBDIR to the '$shlibpath_var' environment variable"
cannam@125 4049 echo " during execution"
cannam@125 4050 fi
cannam@125 4051 if test -n "$runpath_var"; then
cannam@125 4052 echo " - add LIBDIR to the '$runpath_var' environment variable"
cannam@125 4053 echo " during linking"
cannam@125 4054 fi
cannam@125 4055 if test -n "$hardcode_libdir_flag_spec"; then
cannam@125 4056 libdir=LIBDIR
cannam@125 4057 eval flag=\"$hardcode_libdir_flag_spec\"
cannam@125 4058
cannam@125 4059 $ECHO " - use the '$flag' linker flag"
cannam@125 4060 fi
cannam@125 4061 if test -n "$admincmds"; then
cannam@125 4062 $ECHO " - have your system administrator run these commands:$admincmds"
cannam@125 4063 fi
cannam@125 4064 if test -f /etc/ld.so.conf; then
cannam@125 4065 echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
cannam@125 4066 fi
cannam@125 4067 echo
cannam@125 4068
cannam@125 4069 echo "See any operating system documentation about shared libraries for"
cannam@125 4070 case $host in
cannam@125 4071 solaris2.[6789]|solaris2.1[0-9])
cannam@125 4072 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
cannam@125 4073 echo "pages."
cannam@125 4074 ;;
cannam@125 4075 *)
cannam@125 4076 echo "more information, such as the ld(1) and ld.so(8) manual pages."
cannam@125 4077 ;;
cannam@125 4078 esac
cannam@125 4079 echo "----------------------------------------------------------------------"
cannam@125 4080 fi
cannam@125 4081 exit $EXIT_SUCCESS
cannam@125 4082 }
cannam@125 4083
cannam@125 4084 test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
cannam@125 4085
cannam@125 4086
cannam@125 4087 # func_mode_install arg...
cannam@125 4088 func_mode_install ()
cannam@125 4089 {
cannam@125 4090 $debug_cmd
cannam@125 4091
cannam@125 4092 # There may be an optional sh(1) argument at the beginning of
cannam@125 4093 # install_prog (especially on Windows NT).
cannam@125 4094 if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
cannam@125 4095 # Allow the use of GNU shtool's install command.
cannam@125 4096 case $nonopt in *shtool*) :;; *) false;; esac
cannam@125 4097 then
cannam@125 4098 # Aesthetically quote it.
cannam@125 4099 func_quote_for_eval "$nonopt"
cannam@125 4100 install_prog="$func_quote_for_eval_result "
cannam@125 4101 arg=$1
cannam@125 4102 shift
cannam@125 4103 else
cannam@125 4104 install_prog=
cannam@125 4105 arg=$nonopt
cannam@125 4106 fi
cannam@125 4107
cannam@125 4108 # The real first argument should be the name of the installation program.
cannam@125 4109 # Aesthetically quote it.
cannam@125 4110 func_quote_for_eval "$arg"
cannam@125 4111 func_append install_prog "$func_quote_for_eval_result"
cannam@125 4112 install_shared_prog=$install_prog
cannam@125 4113 case " $install_prog " in
cannam@125 4114 *[\\\ /]cp\ *) install_cp=: ;;
cannam@125 4115 *) install_cp=false ;;
cannam@125 4116 esac
cannam@125 4117
cannam@125 4118 # We need to accept at least all the BSD install flags.
cannam@125 4119 dest=
cannam@125 4120 files=
cannam@125 4121 opts=
cannam@125 4122 prev=
cannam@125 4123 install_type=
cannam@125 4124 isdir=false
cannam@125 4125 stripme=
cannam@125 4126 no_mode=:
cannam@125 4127 for arg
cannam@125 4128 do
cannam@125 4129 arg2=
cannam@125 4130 if test -n "$dest"; then
cannam@125 4131 func_append files " $dest"
cannam@125 4132 dest=$arg
cannam@125 4133 continue
cannam@125 4134 fi
cannam@125 4135
cannam@125 4136 case $arg in
cannam@125 4137 -d) isdir=: ;;
cannam@125 4138 -f)
cannam@125 4139 if $install_cp; then :; else
cannam@125 4140 prev=$arg
cannam@125 4141 fi
cannam@125 4142 ;;
cannam@125 4143 -g | -m | -o)
cannam@125 4144 prev=$arg
cannam@125 4145 ;;
cannam@125 4146 -s)
cannam@125 4147 stripme=" -s"
cannam@125 4148 continue
cannam@125 4149 ;;
cannam@125 4150 -*)
cannam@125 4151 ;;
cannam@125 4152 *)
cannam@125 4153 # If the previous option needed an argument, then skip it.
cannam@125 4154 if test -n "$prev"; then
cannam@125 4155 if test X-m = "X$prev" && test -n "$install_override_mode"; then
cannam@125 4156 arg2=$install_override_mode
cannam@125 4157 no_mode=false
cannam@125 4158 fi
cannam@125 4159 prev=
cannam@125 4160 else
cannam@125 4161 dest=$arg
cannam@125 4162 continue
cannam@125 4163 fi
cannam@125 4164 ;;
cannam@125 4165 esac
cannam@125 4166
cannam@125 4167 # Aesthetically quote the argument.
cannam@125 4168 func_quote_for_eval "$arg"
cannam@125 4169 func_append install_prog " $func_quote_for_eval_result"
cannam@125 4170 if test -n "$arg2"; then
cannam@125 4171 func_quote_for_eval "$arg2"
cannam@125 4172 fi
cannam@125 4173 func_append install_shared_prog " $func_quote_for_eval_result"
cannam@125 4174 done
cannam@125 4175
cannam@125 4176 test -z "$install_prog" && \
cannam@125 4177 func_fatal_help "you must specify an install program"
cannam@125 4178
cannam@125 4179 test -n "$prev" && \
cannam@125 4180 func_fatal_help "the '$prev' option requires an argument"
cannam@125 4181
cannam@125 4182 if test -n "$install_override_mode" && $no_mode; then
cannam@125 4183 if $install_cp; then :; else
cannam@125 4184 func_quote_for_eval "$install_override_mode"
cannam@125 4185 func_append install_shared_prog " -m $func_quote_for_eval_result"
cannam@125 4186 fi
cannam@125 4187 fi
cannam@125 4188
cannam@125 4189 if test -z "$files"; then
cannam@125 4190 if test -z "$dest"; then
cannam@125 4191 func_fatal_help "no file or destination specified"
cannam@125 4192 else
cannam@125 4193 func_fatal_help "you must specify a destination"
cannam@125 4194 fi
cannam@125 4195 fi
cannam@125 4196
cannam@125 4197 # Strip any trailing slash from the destination.
cannam@125 4198 func_stripname '' '/' "$dest"
cannam@125 4199 dest=$func_stripname_result
cannam@125 4200
cannam@125 4201 # Check to see that the destination is a directory.
cannam@125 4202 test -d "$dest" && isdir=:
cannam@125 4203 if $isdir; then
cannam@125 4204 destdir=$dest
cannam@125 4205 destname=
cannam@125 4206 else
cannam@125 4207 func_dirname_and_basename "$dest" "" "."
cannam@125 4208 destdir=$func_dirname_result
cannam@125 4209 destname=$func_basename_result
cannam@125 4210
cannam@125 4211 # Not a directory, so check to see that there is only one file specified.
cannam@125 4212 set dummy $files; shift
cannam@125 4213 test "$#" -gt 1 && \
cannam@125 4214 func_fatal_help "'$dest' is not a directory"
cannam@125 4215 fi
cannam@125 4216 case $destdir in
cannam@125 4217 [\\/]* | [A-Za-z]:[\\/]*) ;;
cannam@125 4218 *)
cannam@125 4219 for file in $files; do
cannam@125 4220 case $file in
cannam@125 4221 *.lo) ;;
cannam@125 4222 *)
cannam@125 4223 func_fatal_help "'$destdir' must be an absolute directory name"
cannam@125 4224 ;;
cannam@125 4225 esac
cannam@125 4226 done
cannam@125 4227 ;;
cannam@125 4228 esac
cannam@125 4229
cannam@125 4230 # This variable tells wrapper scripts just to set variables rather
cannam@125 4231 # than running their programs.
cannam@125 4232 libtool_install_magic=$magic
cannam@125 4233
cannam@125 4234 staticlibs=
cannam@125 4235 future_libdirs=
cannam@125 4236 current_libdirs=
cannam@125 4237 for file in $files; do
cannam@125 4238
cannam@125 4239 # Do each installation.
cannam@125 4240 case $file in
cannam@125 4241 *.$libext)
cannam@125 4242 # Do the static libraries later.
cannam@125 4243 func_append staticlibs " $file"
cannam@125 4244 ;;
cannam@125 4245
cannam@125 4246 *.la)
cannam@125 4247 func_resolve_sysroot "$file"
cannam@125 4248 file=$func_resolve_sysroot_result
cannam@125 4249
cannam@125 4250 # Check to see that this really is a libtool archive.
cannam@125 4251 func_lalib_unsafe_p "$file" \
cannam@125 4252 || func_fatal_help "'$file' is not a valid libtool archive"
cannam@125 4253
cannam@125 4254 library_names=
cannam@125 4255 old_library=
cannam@125 4256 relink_command=
cannam@125 4257 func_source "$file"
cannam@125 4258
cannam@125 4259 # Add the libdir to current_libdirs if it is the destination.
cannam@125 4260 if test "X$destdir" = "X$libdir"; then
cannam@125 4261 case "$current_libdirs " in
cannam@125 4262 *" $libdir "*) ;;
cannam@125 4263 *) func_append current_libdirs " $libdir" ;;
cannam@125 4264 esac
cannam@125 4265 else
cannam@125 4266 # Note the libdir as a future libdir.
cannam@125 4267 case "$future_libdirs " in
cannam@125 4268 *" $libdir "*) ;;
cannam@125 4269 *) func_append future_libdirs " $libdir" ;;
cannam@125 4270 esac
cannam@125 4271 fi
cannam@125 4272
cannam@125 4273 func_dirname "$file" "/" ""
cannam@125 4274 dir=$func_dirname_result
cannam@125 4275 func_append dir "$objdir"
cannam@125 4276
cannam@125 4277 if test -n "$relink_command"; then
cannam@125 4278 # Determine the prefix the user has applied to our future dir.
cannam@125 4279 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
cannam@125 4280
cannam@125 4281 # Don't allow the user to place us outside of our expected
cannam@125 4282 # location b/c this prevents finding dependent libraries that
cannam@125 4283 # are installed to the same prefix.
cannam@125 4284 # At present, this check doesn't affect windows .dll's that
cannam@125 4285 # are installed into $libdir/../bin (currently, that works fine)
cannam@125 4286 # but it's something to keep an eye on.
cannam@125 4287 test "$inst_prefix_dir" = "$destdir" && \
cannam@125 4288 func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
cannam@125 4289
cannam@125 4290 if test -n "$inst_prefix_dir"; then
cannam@125 4291 # Stick the inst_prefix_dir data into the link command.
cannam@125 4292 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
cannam@125 4293 else
cannam@125 4294 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
cannam@125 4295 fi
cannam@125 4296
cannam@125 4297 func_warning "relinking '$file'"
cannam@125 4298 func_show_eval "$relink_command" \
cannam@125 4299 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
cannam@125 4300 fi
cannam@125 4301
cannam@125 4302 # See the names of the shared library.
cannam@125 4303 set dummy $library_names; shift
cannam@125 4304 if test -n "$1"; then
cannam@125 4305 realname=$1
cannam@125 4306 shift
cannam@125 4307
cannam@125 4308 srcname=$realname
cannam@125 4309 test -n "$relink_command" && srcname=${realname}T
cannam@125 4310
cannam@125 4311 # Install the shared library and build the symlinks.
cannam@125 4312 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
cannam@125 4313 'exit $?'
cannam@125 4314 tstripme=$stripme
cannam@125 4315 case $host_os in
cannam@125 4316 cygwin* | mingw* | pw32* | cegcc*)
cannam@125 4317 case $realname in
cannam@125 4318 *.dll.a)
cannam@125 4319 tstripme=
cannam@125 4320 ;;
cannam@125 4321 esac
cannam@125 4322 ;;
cannam@125 4323 os2*)
cannam@125 4324 case $realname in
cannam@125 4325 *_dll.a)
cannam@125 4326 tstripme=
cannam@125 4327 ;;
cannam@125 4328 esac
cannam@125 4329 ;;
cannam@125 4330 esac
cannam@125 4331 if test -n "$tstripme" && test -n "$striplib"; then
cannam@125 4332 func_show_eval "$striplib $destdir/$realname" 'exit $?'
cannam@125 4333 fi
cannam@125 4334
cannam@125 4335 if test "$#" -gt 0; then
cannam@125 4336 # Delete the old symlinks, and create new ones.
cannam@125 4337 # Try 'ln -sf' first, because the 'ln' binary might depend on
cannam@125 4338 # the symlink we replace! Solaris /bin/ln does not understand -f,
cannam@125 4339 # so we also need to try rm && ln -s.
cannam@125 4340 for linkname
cannam@125 4341 do
cannam@125 4342 test "$linkname" != "$realname" \
cannam@125 4343 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
cannam@125 4344 done
cannam@125 4345 fi
cannam@125 4346
cannam@125 4347 # Do each command in the postinstall commands.
cannam@125 4348 lib=$destdir/$realname
cannam@125 4349 func_execute_cmds "$postinstall_cmds" 'exit $?'
cannam@125 4350 fi
cannam@125 4351
cannam@125 4352 # Install the pseudo-library for information purposes.
cannam@125 4353 func_basename "$file"
cannam@125 4354 name=$func_basename_result
cannam@125 4355 instname=$dir/${name}i
cannam@125 4356 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
cannam@125 4357
cannam@125 4358 # Maybe install the static library, too.
cannam@125 4359 test -n "$old_library" && func_append staticlibs " $dir/$old_library"
cannam@125 4360 ;;
cannam@125 4361
cannam@125 4362 *.lo)
cannam@125 4363 # Install (i.e. copy) a libtool object.
cannam@125 4364
cannam@125 4365 # Figure out destination file name, if it wasn't already specified.
cannam@125 4366 if test -n "$destname"; then
cannam@125 4367 destfile=$destdir/$destname
cannam@125 4368 else
cannam@125 4369 func_basename "$file"
cannam@125 4370 destfile=$func_basename_result
cannam@125 4371 destfile=$destdir/$destfile
cannam@125 4372 fi
cannam@125 4373
cannam@125 4374 # Deduce the name of the destination old-style object file.
cannam@125 4375 case $destfile in
cannam@125 4376 *.lo)
cannam@125 4377 func_lo2o "$destfile"
cannam@125 4378 staticdest=$func_lo2o_result
cannam@125 4379 ;;
cannam@125 4380 *.$objext)
cannam@125 4381 staticdest=$destfile
cannam@125 4382 destfile=
cannam@125 4383 ;;
cannam@125 4384 *)
cannam@125 4385 func_fatal_help "cannot copy a libtool object to '$destfile'"
cannam@125 4386 ;;
cannam@125 4387 esac
cannam@125 4388
cannam@125 4389 # Install the libtool object if requested.
cannam@125 4390 test -n "$destfile" && \
cannam@125 4391 func_show_eval "$install_prog $file $destfile" 'exit $?'
cannam@125 4392
cannam@125 4393 # Install the old object if enabled.
cannam@125 4394 if test yes = "$build_old_libs"; then
cannam@125 4395 # Deduce the name of the old-style object file.
cannam@125 4396 func_lo2o "$file"
cannam@125 4397 staticobj=$func_lo2o_result
cannam@125 4398 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
cannam@125 4399 fi
cannam@125 4400 exit $EXIT_SUCCESS
cannam@125 4401 ;;
cannam@125 4402
cannam@125 4403 *)
cannam@125 4404 # Figure out destination file name, if it wasn't already specified.
cannam@125 4405 if test -n "$destname"; then
cannam@125 4406 destfile=$destdir/$destname
cannam@125 4407 else
cannam@125 4408 func_basename "$file"
cannam@125 4409 destfile=$func_basename_result
cannam@125 4410 destfile=$destdir/$destfile
cannam@125 4411 fi
cannam@125 4412
cannam@125 4413 # If the file is missing, and there is a .exe on the end, strip it
cannam@125 4414 # because it is most likely a libtool script we actually want to
cannam@125 4415 # install
cannam@125 4416 stripped_ext=
cannam@125 4417 case $file in
cannam@125 4418 *.exe)
cannam@125 4419 if test ! -f "$file"; then
cannam@125 4420 func_stripname '' '.exe' "$file"
cannam@125 4421 file=$func_stripname_result
cannam@125 4422 stripped_ext=.exe
cannam@125 4423 fi
cannam@125 4424 ;;
cannam@125 4425 esac
cannam@125 4426
cannam@125 4427 # Do a test to see if this is really a libtool program.
cannam@125 4428 case $host in
cannam@125 4429 *cygwin* | *mingw*)
cannam@125 4430 if func_ltwrapper_executable_p "$file"; then
cannam@125 4431 func_ltwrapper_scriptname "$file"
cannam@125 4432 wrapper=$func_ltwrapper_scriptname_result
cannam@125 4433 else
cannam@125 4434 func_stripname '' '.exe' "$file"
cannam@125 4435 wrapper=$func_stripname_result
cannam@125 4436 fi
cannam@125 4437 ;;
cannam@125 4438 *)
cannam@125 4439 wrapper=$file
cannam@125 4440 ;;
cannam@125 4441 esac
cannam@125 4442 if func_ltwrapper_script_p "$wrapper"; then
cannam@125 4443 notinst_deplibs=
cannam@125 4444 relink_command=
cannam@125 4445
cannam@125 4446 func_source "$wrapper"
cannam@125 4447
cannam@125 4448 # Check the variables that should have been set.
cannam@125 4449 test -z "$generated_by_libtool_version" && \
cannam@125 4450 func_fatal_error "invalid libtool wrapper script '$wrapper'"
cannam@125 4451
cannam@125 4452 finalize=:
cannam@125 4453 for lib in $notinst_deplibs; do
cannam@125 4454 # Check to see that each library is installed.
cannam@125 4455 libdir=
cannam@125 4456 if test -f "$lib"; then
cannam@125 4457 func_source "$lib"
cannam@125 4458 fi
cannam@125 4459 libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
cannam@125 4460 if test -n "$libdir" && test ! -f "$libfile"; then
cannam@125 4461 func_warning "'$lib' has not been installed in '$libdir'"
cannam@125 4462 finalize=false
cannam@125 4463 fi
cannam@125 4464 done
cannam@125 4465
cannam@125 4466 relink_command=
cannam@125 4467 func_source "$wrapper"
cannam@125 4468
cannam@125 4469 outputname=
cannam@125 4470 if test no = "$fast_install" && test -n "$relink_command"; then
cannam@125 4471 $opt_dry_run || {
cannam@125 4472 if $finalize; then
cannam@125 4473 tmpdir=`func_mktempdir`
cannam@125 4474 func_basename "$file$stripped_ext"
cannam@125 4475 file=$func_basename_result
cannam@125 4476 outputname=$tmpdir/$file
cannam@125 4477 # Replace the output file specification.
cannam@125 4478 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
cannam@125 4479
cannam@125 4480 $opt_quiet || {
cannam@125 4481 func_quote_for_expand "$relink_command"
cannam@125 4482 eval "func_echo $func_quote_for_expand_result"
cannam@125 4483 }
cannam@125 4484 if eval "$relink_command"; then :
cannam@125 4485 else
cannam@125 4486 func_error "error: relink '$file' with the above command before installing it"
cannam@125 4487 $opt_dry_run || ${RM}r "$tmpdir"
cannam@125 4488 continue
cannam@125 4489 fi
cannam@125 4490 file=$outputname
cannam@125 4491 else
cannam@125 4492 func_warning "cannot relink '$file'"
cannam@125 4493 fi
cannam@125 4494 }
cannam@125 4495 else
cannam@125 4496 # Install the binary that we compiled earlier.
cannam@125 4497 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
cannam@125 4498 fi
cannam@125 4499 fi
cannam@125 4500
cannam@125 4501 # remove .exe since cygwin /usr/bin/install will append another
cannam@125 4502 # one anyway
cannam@125 4503 case $install_prog,$host in
cannam@125 4504 */usr/bin/install*,*cygwin*)
cannam@125 4505 case $file:$destfile in
cannam@125 4506 *.exe:*.exe)
cannam@125 4507 # this is ok
cannam@125 4508 ;;
cannam@125 4509 *.exe:*)
cannam@125 4510 destfile=$destfile.exe
cannam@125 4511 ;;
cannam@125 4512 *:*.exe)
cannam@125 4513 func_stripname '' '.exe' "$destfile"
cannam@125 4514 destfile=$func_stripname_result
cannam@125 4515 ;;
cannam@125 4516 esac
cannam@125 4517 ;;
cannam@125 4518 esac
cannam@125 4519 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
cannam@125 4520 $opt_dry_run || if test -n "$outputname"; then
cannam@125 4521 ${RM}r "$tmpdir"
cannam@125 4522 fi
cannam@125 4523 ;;
cannam@125 4524 esac
cannam@125 4525 done
cannam@125 4526
cannam@125 4527 for file in $staticlibs; do
cannam@125 4528 func_basename "$file"
cannam@125 4529 name=$func_basename_result
cannam@125 4530
cannam@125 4531 # Set up the ranlib parameters.
cannam@125 4532 oldlib=$destdir/$name
cannam@125 4533 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
cannam@125 4534 tool_oldlib=$func_to_tool_file_result
cannam@125 4535
cannam@125 4536 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
cannam@125 4537
cannam@125 4538 if test -n "$stripme" && test -n "$old_striplib"; then
cannam@125 4539 func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
cannam@125 4540 fi
cannam@125 4541
cannam@125 4542 # Do each command in the postinstall commands.
cannam@125 4543 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
cannam@125 4544 done
cannam@125 4545
cannam@125 4546 test -n "$future_libdirs" && \
cannam@125 4547 func_warning "remember to run '$progname --finish$future_libdirs'"
cannam@125 4548
cannam@125 4549 if test -n "$current_libdirs"; then
cannam@125 4550 # Maybe just do a dry run.
cannam@125 4551 $opt_dry_run && current_libdirs=" -n$current_libdirs"
cannam@125 4552 exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
cannam@125 4553 else
cannam@125 4554 exit $EXIT_SUCCESS
cannam@125 4555 fi
cannam@125 4556 }
cannam@125 4557
cannam@125 4558 test install = "$opt_mode" && func_mode_install ${1+"$@"}
cannam@125 4559
cannam@125 4560
cannam@125 4561 # func_generate_dlsyms outputname originator pic_p
cannam@125 4562 # Extract symbols from dlprefiles and create ${outputname}S.o with
cannam@125 4563 # a dlpreopen symbol table.
cannam@125 4564 func_generate_dlsyms ()
cannam@125 4565 {
cannam@125 4566 $debug_cmd
cannam@125 4567
cannam@125 4568 my_outputname=$1
cannam@125 4569 my_originator=$2
cannam@125 4570 my_pic_p=${3-false}
cannam@125 4571 my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
cannam@125 4572 my_dlsyms=
cannam@125 4573
cannam@125 4574 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
cannam@125 4575 if test -n "$NM" && test -n "$global_symbol_pipe"; then
cannam@125 4576 my_dlsyms=${my_outputname}S.c
cannam@125 4577 else
cannam@125 4578 func_error "not configured to extract global symbols from dlpreopened files"
cannam@125 4579 fi
cannam@125 4580 fi
cannam@125 4581
cannam@125 4582 if test -n "$my_dlsyms"; then
cannam@125 4583 case $my_dlsyms in
cannam@125 4584 "") ;;
cannam@125 4585 *.c)
cannam@125 4586 # Discover the nlist of each of the dlfiles.
cannam@125 4587 nlist=$output_objdir/$my_outputname.nm
cannam@125 4588
cannam@125 4589 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
cannam@125 4590
cannam@125 4591 # Parse the name list into a source file.
cannam@125 4592 func_verbose "creating $output_objdir/$my_dlsyms"
cannam@125 4593
cannam@125 4594 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
cannam@125 4595 /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
cannam@125 4596 /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
cannam@125 4597
cannam@125 4598 #ifdef __cplusplus
cannam@125 4599 extern \"C\" {
cannam@125 4600 #endif
cannam@125 4601
cannam@125 4602 #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
cannam@125 4603 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
cannam@125 4604 #endif
cannam@125 4605
cannam@125 4606 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
cannam@125 4607 #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
cannam@125 4608 /* DATA imports from DLLs on WIN32 can't be const, because runtime
cannam@125 4609 relocations are performed -- see ld's documentation on pseudo-relocs. */
cannam@125 4610 # define LT_DLSYM_CONST
cannam@125 4611 #elif defined __osf__
cannam@125 4612 /* This system does not cope well with relocations in const data. */
cannam@125 4613 # define LT_DLSYM_CONST
cannam@125 4614 #else
cannam@125 4615 # define LT_DLSYM_CONST const
cannam@125 4616 #endif
cannam@125 4617
cannam@125 4618 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
cannam@125 4619
cannam@125 4620 /* External symbol declarations for the compiler. */\
cannam@125 4621 "
cannam@125 4622
cannam@125 4623 if test yes = "$dlself"; then
cannam@125 4624 func_verbose "generating symbol list for '$output'"
cannam@125 4625
cannam@125 4626 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
cannam@125 4627
cannam@125 4628 # Add our own program objects to the symbol list.
cannam@125 4629 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
cannam@125 4630 for progfile in $progfiles; do
cannam@125 4631 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
cannam@125 4632 func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
cannam@125 4633 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
cannam@125 4634 done
cannam@125 4635
cannam@125 4636 if test -n "$exclude_expsyms"; then
cannam@125 4637 $opt_dry_run || {
cannam@125 4638 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
cannam@125 4639 eval '$MV "$nlist"T "$nlist"'
cannam@125 4640 }
cannam@125 4641 fi
cannam@125 4642
cannam@125 4643 if test -n "$export_symbols_regex"; then
cannam@125 4644 $opt_dry_run || {
cannam@125 4645 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
cannam@125 4646 eval '$MV "$nlist"T "$nlist"'
cannam@125 4647 }
cannam@125 4648 fi
cannam@125 4649
cannam@125 4650 # Prepare the list of exported symbols
cannam@125 4651 if test -z "$export_symbols"; then
cannam@125 4652 export_symbols=$output_objdir/$outputname.exp
cannam@125 4653 $opt_dry_run || {
cannam@125 4654 $RM $export_symbols
cannam@125 4655 eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
cannam@125 4656 case $host in
cannam@125 4657 *cygwin* | *mingw* | *cegcc* )
cannam@125 4658 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
cannam@125 4659 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
cannam@125 4660 ;;
cannam@125 4661 esac
cannam@125 4662 }
cannam@125 4663 else
cannam@125 4664 $opt_dry_run || {
cannam@125 4665 eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
cannam@125 4666 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
cannam@125 4667 eval '$MV "$nlist"T "$nlist"'
cannam@125 4668 case $host in
cannam@125 4669 *cygwin* | *mingw* | *cegcc* )
cannam@125 4670 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
cannam@125 4671 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
cannam@125 4672 ;;
cannam@125 4673 esac
cannam@125 4674 }
cannam@125 4675 fi
cannam@125 4676 fi
cannam@125 4677
cannam@125 4678 for dlprefile in $dlprefiles; do
cannam@125 4679 func_verbose "extracting global C symbols from '$dlprefile'"
cannam@125 4680 func_basename "$dlprefile"
cannam@125 4681 name=$func_basename_result
cannam@125 4682 case $host in
cannam@125 4683 *cygwin* | *mingw* | *cegcc* )
cannam@125 4684 # if an import library, we need to obtain dlname
cannam@125 4685 if func_win32_import_lib_p "$dlprefile"; then
cannam@125 4686 func_tr_sh "$dlprefile"
cannam@125 4687 eval "curr_lafile=\$libfile_$func_tr_sh_result"
cannam@125 4688 dlprefile_dlbasename=
cannam@125 4689 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
cannam@125 4690 # Use subshell, to avoid clobbering current variable values
cannam@125 4691 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
cannam@125 4692 if test -n "$dlprefile_dlname"; then
cannam@125 4693 func_basename "$dlprefile_dlname"
cannam@125 4694 dlprefile_dlbasename=$func_basename_result
cannam@125 4695 else
cannam@125 4696 # no lafile. user explicitly requested -dlpreopen <import library>.
cannam@125 4697 $sharedlib_from_linklib_cmd "$dlprefile"
cannam@125 4698 dlprefile_dlbasename=$sharedlib_from_linklib_result
cannam@125 4699 fi
cannam@125 4700 fi
cannam@125 4701 $opt_dry_run || {
cannam@125 4702 if test -n "$dlprefile_dlbasename"; then
cannam@125 4703 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
cannam@125 4704 else
cannam@125 4705 func_warning "Could not compute DLL name from $name"
cannam@125 4706 eval '$ECHO ": $name " >> "$nlist"'
cannam@125 4707 fi
cannam@125 4708 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
cannam@125 4709 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
cannam@125 4710 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
cannam@125 4711 }
cannam@125 4712 else # not an import lib
cannam@125 4713 $opt_dry_run || {
cannam@125 4714 eval '$ECHO ": $name " >> "$nlist"'
cannam@125 4715 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
cannam@125 4716 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
cannam@125 4717 }
cannam@125 4718 fi
cannam@125 4719 ;;
cannam@125 4720 *)
cannam@125 4721 $opt_dry_run || {
cannam@125 4722 eval '$ECHO ": $name " >> "$nlist"'
cannam@125 4723 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
cannam@125 4724 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
cannam@125 4725 }
cannam@125 4726 ;;
cannam@125 4727 esac
cannam@125 4728 done
cannam@125 4729
cannam@125 4730 $opt_dry_run || {
cannam@125 4731 # Make sure we have at least an empty file.
cannam@125 4732 test -f "$nlist" || : > "$nlist"
cannam@125 4733
cannam@125 4734 if test -n "$exclude_expsyms"; then
cannam@125 4735 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
cannam@125 4736 $MV "$nlist"T "$nlist"
cannam@125 4737 fi
cannam@125 4738
cannam@125 4739 # Try sorting and uniquifying the output.
cannam@125 4740 if $GREP -v "^: " < "$nlist" |
cannam@125 4741 if sort -k 3 </dev/null >/dev/null 2>&1; then
cannam@125 4742 sort -k 3
cannam@125 4743 else
cannam@125 4744 sort +2
cannam@125 4745 fi |
cannam@125 4746 uniq > "$nlist"S; then
cannam@125 4747 :
cannam@125 4748 else
cannam@125 4749 $GREP -v "^: " < "$nlist" > "$nlist"S
cannam@125 4750 fi
cannam@125 4751
cannam@125 4752 if test -f "$nlist"S; then
cannam@125 4753 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
cannam@125 4754 else
cannam@125 4755 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
cannam@125 4756 fi
cannam@125 4757
cannam@125 4758 func_show_eval '$RM "${nlist}I"'
cannam@125 4759 if test -n "$global_symbol_to_import"; then
cannam@125 4760 eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
cannam@125 4761 fi
cannam@125 4762
cannam@125 4763 echo >> "$output_objdir/$my_dlsyms" "\
cannam@125 4764
cannam@125 4765 /* The mapping between symbol names and symbols. */
cannam@125 4766 typedef struct {
cannam@125 4767 const char *name;
cannam@125 4768 void *address;
cannam@125 4769 } lt_dlsymlist;
cannam@125 4770 extern LT_DLSYM_CONST lt_dlsymlist
cannam@125 4771 lt_${my_prefix}_LTX_preloaded_symbols[];\
cannam@125 4772 "
cannam@125 4773
cannam@125 4774 if test -s "$nlist"I; then
cannam@125 4775 echo >> "$output_objdir/$my_dlsyms" "\
cannam@125 4776 static void lt_syminit(void)
cannam@125 4777 {
cannam@125 4778 LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
cannam@125 4779 for (; symbol->name; ++symbol)
cannam@125 4780 {"
cannam@125 4781 $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
cannam@125 4782 echo >> "$output_objdir/$my_dlsyms" "\
cannam@125 4783 }
cannam@125 4784 }"
cannam@125 4785 fi
cannam@125 4786 echo >> "$output_objdir/$my_dlsyms" "\
cannam@125 4787 LT_DLSYM_CONST lt_dlsymlist
cannam@125 4788 lt_${my_prefix}_LTX_preloaded_symbols[] =
cannam@125 4789 { {\"$my_originator\", (void *) 0},"
cannam@125 4790
cannam@125 4791 if test -s "$nlist"I; then
cannam@125 4792 echo >> "$output_objdir/$my_dlsyms" "\
cannam@125 4793 {\"@INIT@\", (void *) &lt_syminit},"
cannam@125 4794 fi
cannam@125 4795
cannam@125 4796 case $need_lib_prefix in
cannam@125 4797 no)
cannam@125 4798 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
cannam@125 4799 ;;
cannam@125 4800 *)
cannam@125 4801 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
cannam@125 4802 ;;
cannam@125 4803 esac
cannam@125 4804 echo >> "$output_objdir/$my_dlsyms" "\
cannam@125 4805 {0, (void *) 0}
cannam@125 4806 };
cannam@125 4807
cannam@125 4808 /* This works around a problem in FreeBSD linker */
cannam@125 4809 #ifdef FREEBSD_WORKAROUND
cannam@125 4810 static const void *lt_preloaded_setup() {
cannam@125 4811 return lt_${my_prefix}_LTX_preloaded_symbols;
cannam@125 4812 }
cannam@125 4813 #endif
cannam@125 4814
cannam@125 4815 #ifdef __cplusplus
cannam@125 4816 }
cannam@125 4817 #endif\
cannam@125 4818 "
cannam@125 4819 } # !$opt_dry_run
cannam@125 4820
cannam@125 4821 pic_flag_for_symtable=
cannam@125 4822 case "$compile_command " in
cannam@125 4823 *" -static "*) ;;
cannam@125 4824 *)
cannam@125 4825 case $host in
cannam@125 4826 # compiling the symbol table file with pic_flag works around
cannam@125 4827 # a FreeBSD bug that causes programs to crash when -lm is
cannam@125 4828 # linked before any other PIC object. But we must not use
cannam@125 4829 # pic_flag when linking with -static. The problem exists in
cannam@125 4830 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
cannam@125 4831 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
cannam@125 4832 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
cannam@125 4833 *-*-hpux*)
cannam@125 4834 pic_flag_for_symtable=" $pic_flag" ;;
cannam@125 4835 *)
cannam@125 4836 $my_pic_p && pic_flag_for_symtable=" $pic_flag"
cannam@125 4837 ;;
cannam@125 4838 esac
cannam@125 4839 ;;
cannam@125 4840 esac
cannam@125 4841 symtab_cflags=
cannam@125 4842 for arg in $LTCFLAGS; do
cannam@125 4843 case $arg in
cannam@125 4844 -pie | -fpie | -fPIE) ;;
cannam@125 4845 *) func_append symtab_cflags " $arg" ;;
cannam@125 4846 esac
cannam@125 4847 done
cannam@125 4848
cannam@125 4849 # Now compile the dynamic symbol file.
cannam@125 4850 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
cannam@125 4851
cannam@125 4852 # Clean up the generated files.
cannam@125 4853 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
cannam@125 4854
cannam@125 4855 # Transform the symbol file into the correct name.
cannam@125 4856 symfileobj=$output_objdir/${my_outputname}S.$objext
cannam@125 4857 case $host in
cannam@125 4858 *cygwin* | *mingw* | *cegcc* )
cannam@125 4859 if test -f "$output_objdir/$my_outputname.def"; then
cannam@125 4860 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
cannam@125 4861 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
cannam@125 4862 else
cannam@125 4863 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
cannam@125 4864 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
cannam@125 4865 fi
cannam@125 4866 ;;
cannam@125 4867 *)
cannam@125 4868 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
cannam@125 4869 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
cannam@125 4870 ;;
cannam@125 4871 esac
cannam@125 4872 ;;
cannam@125 4873 *)
cannam@125 4874 func_fatal_error "unknown suffix for '$my_dlsyms'"
cannam@125 4875 ;;
cannam@125 4876 esac
cannam@125 4877 else
cannam@125 4878 # We keep going just in case the user didn't refer to
cannam@125 4879 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
cannam@125 4880 # really was required.
cannam@125 4881
cannam@125 4882 # Nullify the symbol file.
cannam@125 4883 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
cannam@125 4884 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
cannam@125 4885 fi
cannam@125 4886 }
cannam@125 4887
cannam@125 4888 # func_cygming_gnu_implib_p ARG
cannam@125 4889 # This predicate returns with zero status (TRUE) if
cannam@125 4890 # ARG is a GNU/binutils-style import library. Returns
cannam@125 4891 # with nonzero status (FALSE) otherwise.
cannam@125 4892 func_cygming_gnu_implib_p ()
cannam@125 4893 {
cannam@125 4894 $debug_cmd
cannam@125 4895
cannam@125 4896 func_to_tool_file "$1" func_convert_file_msys_to_w32
cannam@125 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)$'`
cannam@125 4898 test -n "$func_cygming_gnu_implib_tmp"
cannam@125 4899 }
cannam@125 4900
cannam@125 4901 # func_cygming_ms_implib_p ARG
cannam@125 4902 # This predicate returns with zero status (TRUE) if
cannam@125 4903 # ARG is an MS-style import library. Returns
cannam@125 4904 # with nonzero status (FALSE) otherwise.
cannam@125 4905 func_cygming_ms_implib_p ()
cannam@125 4906 {
cannam@125 4907 $debug_cmd
cannam@125 4908
cannam@125 4909 func_to_tool_file "$1" func_convert_file_msys_to_w32
cannam@125 4910 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
cannam@125 4911 test -n "$func_cygming_ms_implib_tmp"
cannam@125 4912 }
cannam@125 4913
cannam@125 4914 # func_win32_libid arg
cannam@125 4915 # return the library type of file 'arg'
cannam@125 4916 #
cannam@125 4917 # Need a lot of goo to handle *both* DLLs and import libs
cannam@125 4918 # Has to be a shell function in order to 'eat' the argument
cannam@125 4919 # that is supplied when $file_magic_command is called.
cannam@125 4920 # Despite the name, also deal with 64 bit binaries.
cannam@125 4921 func_win32_libid ()
cannam@125 4922 {
cannam@125 4923 $debug_cmd
cannam@125 4924
cannam@125 4925 win32_libid_type=unknown
cannam@125 4926 win32_fileres=`file -L $1 2>/dev/null`
cannam@125 4927 case $win32_fileres in
cannam@125 4928 *ar\ archive\ import\ library*) # definitely import
cannam@125 4929 win32_libid_type="x86 archive import"
cannam@125 4930 ;;
cannam@125 4931 *ar\ archive*) # could be an import, or static
cannam@125 4932 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
cannam@125 4933 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
cannam@125 4934 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
cannam@125 4935 case $nm_interface in
cannam@125 4936 "MS dumpbin")
cannam@125 4937 if func_cygming_ms_implib_p "$1" ||
cannam@125 4938 func_cygming_gnu_implib_p "$1"
cannam@125 4939 then
cannam@125 4940 win32_nmres=import
cannam@125 4941 else
cannam@125 4942 win32_nmres=
cannam@125 4943 fi
cannam@125 4944 ;;
cannam@125 4945 *)
cannam@125 4946 func_to_tool_file "$1" func_convert_file_msys_to_w32
cannam@125 4947 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
cannam@125 4948 $SED -n -e '
cannam@125 4949 1,100{
cannam@125 4950 / I /{
cannam@125 4951 s|.*|import|
cannam@125 4952 p
cannam@125 4953 q
cannam@125 4954 }
cannam@125 4955 }'`
cannam@125 4956 ;;
cannam@125 4957 esac
cannam@125 4958 case $win32_nmres in
cannam@125 4959 import*) win32_libid_type="x86 archive import";;
cannam@125 4960 *) win32_libid_type="x86 archive static";;
cannam@125 4961 esac
cannam@125 4962 fi
cannam@125 4963 ;;
cannam@125 4964 *DLL*)
cannam@125 4965 win32_libid_type="x86 DLL"
cannam@125 4966 ;;
cannam@125 4967 *executable*) # but shell scripts are "executable" too...
cannam@125 4968 case $win32_fileres in
cannam@125 4969 *MS\ Windows\ PE\ Intel*)
cannam@125 4970 win32_libid_type="x86 DLL"
cannam@125 4971 ;;
cannam@125 4972 esac
cannam@125 4973 ;;
cannam@125 4974 esac
cannam@125 4975 $ECHO "$win32_libid_type"
cannam@125 4976 }
cannam@125 4977
cannam@125 4978 # func_cygming_dll_for_implib ARG
cannam@125 4979 #
cannam@125 4980 # Platform-specific function to extract the
cannam@125 4981 # name of the DLL associated with the specified
cannam@125 4982 # import library ARG.
cannam@125 4983 # Invoked by eval'ing the libtool variable
cannam@125 4984 # $sharedlib_from_linklib_cmd
cannam@125 4985 # Result is available in the variable
cannam@125 4986 # $sharedlib_from_linklib_result
cannam@125 4987 func_cygming_dll_for_implib ()
cannam@125 4988 {
cannam@125 4989 $debug_cmd
cannam@125 4990
cannam@125 4991 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
cannam@125 4992 }
cannam@125 4993
cannam@125 4994 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
cannam@125 4995 #
cannam@125 4996 # The is the core of a fallback implementation of a
cannam@125 4997 # platform-specific function to extract the name of the
cannam@125 4998 # DLL associated with the specified import library LIBNAME.
cannam@125 4999 #
cannam@125 5000 # SECTION_NAME is either .idata$6 or .idata$7, depending
cannam@125 5001 # on the platform and compiler that created the implib.
cannam@125 5002 #
cannam@125 5003 # Echos the name of the DLL associated with the
cannam@125 5004 # specified import library.
cannam@125 5005 func_cygming_dll_for_implib_fallback_core ()
cannam@125 5006 {
cannam@125 5007 $debug_cmd
cannam@125 5008
cannam@125 5009 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
cannam@125 5010 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
cannam@125 5011 $SED '/^Contents of section '"$match_literal"':/{
cannam@125 5012 # Place marker at beginning of archive member dllname section
cannam@125 5013 s/.*/====MARK====/
cannam@125 5014 p
cannam@125 5015 d
cannam@125 5016 }
cannam@125 5017 # These lines can sometimes be longer than 43 characters, but
cannam@125 5018 # are always uninteresting
cannam@125 5019 /:[ ]*file format pe[i]\{,1\}-/d
cannam@125 5020 /^In archive [^:]*:/d
cannam@125 5021 # Ensure marker is printed
cannam@125 5022 /^====MARK====/p
cannam@125 5023 # Remove all lines with less than 43 characters
cannam@125 5024 /^.\{43\}/!d
cannam@125 5025 # From remaining lines, remove first 43 characters
cannam@125 5026 s/^.\{43\}//' |
cannam@125 5027 $SED -n '
cannam@125 5028 # Join marker and all lines until next marker into a single line
cannam@125 5029 /^====MARK====/ b para
cannam@125 5030 H
cannam@125 5031 $ b para
cannam@125 5032 b
cannam@125 5033 :para
cannam@125 5034 x
cannam@125 5035 s/\n//g
cannam@125 5036 # Remove the marker
cannam@125 5037 s/^====MARK====//
cannam@125 5038 # Remove trailing dots and whitespace
cannam@125 5039 s/[\. \t]*$//
cannam@125 5040 # Print
cannam@125 5041 /./p' |
cannam@125 5042 # we now have a list, one entry per line, of the stringified
cannam@125 5043 # contents of the appropriate section of all members of the
cannam@125 5044 # archive that possess that section. Heuristic: eliminate
cannam@125 5045 # all those that have a first or second character that is
cannam@125 5046 # a '.' (that is, objdump's representation of an unprintable
cannam@125 5047 # character.) This should work for all archives with less than
cannam@125 5048 # 0x302f exports -- but will fail for DLLs whose name actually
cannam@125 5049 # begins with a literal '.' or a single character followed by
cannam@125 5050 # a '.'.
cannam@125 5051 #
cannam@125 5052 # Of those that remain, print the first one.
cannam@125 5053 $SED -e '/^\./d;/^.\./d;q'
cannam@125 5054 }
cannam@125 5055
cannam@125 5056 # func_cygming_dll_for_implib_fallback ARG
cannam@125 5057 # Platform-specific function to extract the
cannam@125 5058 # name of the DLL associated with the specified
cannam@125 5059 # import library ARG.
cannam@125 5060 #
cannam@125 5061 # This fallback implementation is for use when $DLLTOOL
cannam@125 5062 # does not support the --identify-strict option.
cannam@125 5063 # Invoked by eval'ing the libtool variable
cannam@125 5064 # $sharedlib_from_linklib_cmd
cannam@125 5065 # Result is available in the variable
cannam@125 5066 # $sharedlib_from_linklib_result
cannam@125 5067 func_cygming_dll_for_implib_fallback ()
cannam@125 5068 {
cannam@125 5069 $debug_cmd
cannam@125 5070
cannam@125 5071 if func_cygming_gnu_implib_p "$1"; then
cannam@125 5072 # binutils import library
cannam@125 5073 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
cannam@125 5074 elif func_cygming_ms_implib_p "$1"; then
cannam@125 5075 # ms-generated import library
cannam@125 5076 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
cannam@125 5077 else
cannam@125 5078 # unknown
cannam@125 5079 sharedlib_from_linklib_result=
cannam@125 5080 fi
cannam@125 5081 }
cannam@125 5082
cannam@125 5083
cannam@125 5084 # func_extract_an_archive dir oldlib
cannam@125 5085 func_extract_an_archive ()
cannam@125 5086 {
cannam@125 5087 $debug_cmd
cannam@125 5088
cannam@125 5089 f_ex_an_ar_dir=$1; shift
cannam@125 5090 f_ex_an_ar_oldlib=$1
cannam@125 5091 if test yes = "$lock_old_archive_extraction"; then
cannam@125 5092 lockfile=$f_ex_an_ar_oldlib.lock
cannam@125 5093 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
cannam@125 5094 func_echo "Waiting for $lockfile to be removed"
cannam@125 5095 sleep 2
cannam@125 5096 done
cannam@125 5097 fi
cannam@125 5098 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
cannam@125 5099 'stat=$?; rm -f "$lockfile"; exit $stat'
cannam@125 5100 if test yes = "$lock_old_archive_extraction"; then
cannam@125 5101 $opt_dry_run || rm -f "$lockfile"
cannam@125 5102 fi
cannam@125 5103 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
cannam@125 5104 :
cannam@125 5105 else
cannam@125 5106 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
cannam@125 5107 fi
cannam@125 5108 }
cannam@125 5109
cannam@125 5110
cannam@125 5111 # func_extract_archives gentop oldlib ...
cannam@125 5112 func_extract_archives ()
cannam@125 5113 {
cannam@125 5114 $debug_cmd
cannam@125 5115
cannam@125 5116 my_gentop=$1; shift
cannam@125 5117 my_oldlibs=${1+"$@"}
cannam@125 5118 my_oldobjs=
cannam@125 5119 my_xlib=
cannam@125 5120 my_xabs=
cannam@125 5121 my_xdir=
cannam@125 5122
cannam@125 5123 for my_xlib in $my_oldlibs; do
cannam@125 5124 # Extract the objects.
cannam@125 5125 case $my_xlib in
cannam@125 5126 [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
cannam@125 5127 *) my_xabs=`pwd`"/$my_xlib" ;;
cannam@125 5128 esac
cannam@125 5129 func_basename "$my_xlib"
cannam@125 5130 my_xlib=$func_basename_result
cannam@125 5131 my_xlib_u=$my_xlib
cannam@125 5132 while :; do
cannam@125 5133 case " $extracted_archives " in
cannam@125 5134 *" $my_xlib_u "*)
cannam@125 5135 func_arith $extracted_serial + 1
cannam@125 5136 extracted_serial=$func_arith_result
cannam@125 5137 my_xlib_u=lt$extracted_serial-$my_xlib ;;
cannam@125 5138 *) break ;;
cannam@125 5139 esac
cannam@125 5140 done
cannam@125 5141 extracted_archives="$extracted_archives $my_xlib_u"
cannam@125 5142 my_xdir=$my_gentop/$my_xlib_u
cannam@125 5143
cannam@125 5144 func_mkdir_p "$my_xdir"
cannam@125 5145
cannam@125 5146 case $host in
cannam@125 5147 *-darwin*)
cannam@125 5148 func_verbose "Extracting $my_xabs"
cannam@125 5149 # Do not bother doing anything if just a dry run
cannam@125 5150 $opt_dry_run || {
cannam@125 5151 darwin_orig_dir=`pwd`
cannam@125 5152 cd $my_xdir || exit $?
cannam@125 5153 darwin_archive=$my_xabs
cannam@125 5154 darwin_curdir=`pwd`
cannam@125 5155 func_basename "$darwin_archive"
cannam@125 5156 darwin_base_archive=$func_basename_result
cannam@125 5157 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
cannam@125 5158 if test -n "$darwin_arches"; then
cannam@125 5159 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
cannam@125 5160 darwin_arch=
cannam@125 5161 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
cannam@125 5162 for darwin_arch in $darwin_arches; do
cannam@125 5163 func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
cannam@125 5164 $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
cannam@125 5165 cd "unfat-$$/$darwin_base_archive-$darwin_arch"
cannam@125 5166 func_extract_an_archive "`pwd`" "$darwin_base_archive"
cannam@125 5167 cd "$darwin_curdir"
cannam@125 5168 $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
cannam@125 5169 done # $darwin_arches
cannam@125 5170 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
cannam@125 5171 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
cannam@125 5172 darwin_file=
cannam@125 5173 darwin_files=
cannam@125 5174 for darwin_file in $darwin_filelist; do
cannam@125 5175 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
cannam@125 5176 $LIPO -create -output "$darwin_file" $darwin_files
cannam@125 5177 done # $darwin_filelist
cannam@125 5178 $RM -rf unfat-$$
cannam@125 5179 cd "$darwin_orig_dir"
cannam@125 5180 else
cannam@125 5181 cd $darwin_orig_dir
cannam@125 5182 func_extract_an_archive "$my_xdir" "$my_xabs"
cannam@125 5183 fi # $darwin_arches
cannam@125 5184 } # !$opt_dry_run
cannam@125 5185 ;;
cannam@125 5186 *)
cannam@125 5187 func_extract_an_archive "$my_xdir" "$my_xabs"
cannam@125 5188 ;;
cannam@125 5189 esac
cannam@125 5190 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
cannam@125 5191 done
cannam@125 5192
cannam@125 5193 func_extract_archives_result=$my_oldobjs
cannam@125 5194 }
cannam@125 5195
cannam@125 5196
cannam@125 5197 # func_emit_wrapper [arg=no]
cannam@125 5198 #
cannam@125 5199 # Emit a libtool wrapper script on stdout.
cannam@125 5200 # Don't directly open a file because we may want to
cannam@125 5201 # incorporate the script contents within a cygwin/mingw
cannam@125 5202 # wrapper executable. Must ONLY be called from within
cannam@125 5203 # func_mode_link because it depends on a number of variables
cannam@125 5204 # set therein.
cannam@125 5205 #
cannam@125 5206 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
cannam@125 5207 # variable will take. If 'yes', then the emitted script
cannam@125 5208 # will assume that the directory where it is stored is
cannam@125 5209 # the $objdir directory. This is a cygwin/mingw-specific
cannam@125 5210 # behavior.
cannam@125 5211 func_emit_wrapper ()
cannam@125 5212 {
cannam@125 5213 func_emit_wrapper_arg1=${1-no}
cannam@125 5214
cannam@125 5215 $ECHO "\
cannam@125 5216 #! $SHELL
cannam@125 5217
cannam@125 5218 # $output - temporary wrapper script for $objdir/$outputname
cannam@125 5219 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
cannam@125 5220 #
cannam@125 5221 # The $output program cannot be directly executed until all the libtool
cannam@125 5222 # libraries that it depends on are installed.
cannam@125 5223 #
cannam@125 5224 # This wrapper script should never be moved out of the build directory.
cannam@125 5225 # If it is, it will not operate correctly.
cannam@125 5226
cannam@125 5227 # Sed substitution that helps us do robust quoting. It backslashifies
cannam@125 5228 # metacharacters that are still active within double-quoted strings.
cannam@125 5229 sed_quote_subst='$sed_quote_subst'
cannam@125 5230
cannam@125 5231 # Be Bourne compatible
cannam@125 5232 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
cannam@125 5233 emulate sh
cannam@125 5234 NULLCMD=:
cannam@125 5235 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
cannam@125 5236 # is contrary to our usage. Disable this feature.
cannam@125 5237 alias -g '\${1+\"\$@\"}'='\"\$@\"'
cannam@125 5238 setopt NO_GLOB_SUBST
cannam@125 5239 else
cannam@125 5240 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
cannam@125 5241 fi
cannam@125 5242 BIN_SH=xpg4; export BIN_SH # for Tru64
cannam@125 5243 DUALCASE=1; export DUALCASE # for MKS sh
cannam@125 5244
cannam@125 5245 # The HP-UX ksh and POSIX shell print the target directory to stdout
cannam@125 5246 # if CDPATH is set.
cannam@125 5247 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
cannam@125 5248
cannam@125 5249 relink_command=\"$relink_command\"
cannam@125 5250
cannam@125 5251 # This environment variable determines our operation mode.
cannam@125 5252 if test \"\$libtool_install_magic\" = \"$magic\"; then
cannam@125 5253 # install mode needs the following variables:
cannam@125 5254 generated_by_libtool_version='$macro_version'
cannam@125 5255 notinst_deplibs='$notinst_deplibs'
cannam@125 5256 else
cannam@125 5257 # When we are sourced in execute mode, \$file and \$ECHO are already set.
cannam@125 5258 if test \"\$libtool_execute_magic\" != \"$magic\"; then
cannam@125 5259 file=\"\$0\""
cannam@125 5260
cannam@125 5261 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
cannam@125 5262 $ECHO "\
cannam@125 5263
cannam@125 5264 # A function that is used when there is no print builtin or printf.
cannam@125 5265 func_fallback_echo ()
cannam@125 5266 {
cannam@125 5267 eval 'cat <<_LTECHO_EOF
cannam@125 5268 \$1
cannam@125 5269 _LTECHO_EOF'
cannam@125 5270 }
cannam@125 5271 ECHO=\"$qECHO\"
cannam@125 5272 fi
cannam@125 5273
cannam@125 5274 # Very basic option parsing. These options are (a) specific to
cannam@125 5275 # the libtool wrapper, (b) are identical between the wrapper
cannam@125 5276 # /script/ and the wrapper /executable/ that is used only on
cannam@125 5277 # windows platforms, and (c) all begin with the string "--lt-"
cannam@125 5278 # (application programs are unlikely to have options that match
cannam@125 5279 # this pattern).
cannam@125 5280 #
cannam@125 5281 # There are only two supported options: --lt-debug and
cannam@125 5282 # --lt-dump-script. There is, deliberately, no --lt-help.
cannam@125 5283 #
cannam@125 5284 # The first argument to this parsing function should be the
cannam@125 5285 # script's $0 value, followed by "$@".
cannam@125 5286 lt_option_debug=
cannam@125 5287 func_parse_lt_options ()
cannam@125 5288 {
cannam@125 5289 lt_script_arg0=\$0
cannam@125 5290 shift
cannam@125 5291 for lt_opt
cannam@125 5292 do
cannam@125 5293 case \"\$lt_opt\" in
cannam@125 5294 --lt-debug) lt_option_debug=1 ;;
cannam@125 5295 --lt-dump-script)
cannam@125 5296 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
cannam@125 5297 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
cannam@125 5298 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
cannam@125 5299 cat \"\$lt_dump_D/\$lt_dump_F\"
cannam@125 5300 exit 0
cannam@125 5301 ;;
cannam@125 5302 --lt-*)
cannam@125 5303 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
cannam@125 5304 exit 1
cannam@125 5305 ;;
cannam@125 5306 esac
cannam@125 5307 done
cannam@125 5308
cannam@125 5309 # Print the debug banner immediately:
cannam@125 5310 if test -n \"\$lt_option_debug\"; then
cannam@125 5311 echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
cannam@125 5312 fi
cannam@125 5313 }
cannam@125 5314
cannam@125 5315 # Used when --lt-debug. Prints its arguments to stdout
cannam@125 5316 # (redirection is the responsibility of the caller)
cannam@125 5317 func_lt_dump_args ()
cannam@125 5318 {
cannam@125 5319 lt_dump_args_N=1;
cannam@125 5320 for lt_arg
cannam@125 5321 do
cannam@125 5322 \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
cannam@125 5323 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
cannam@125 5324 done
cannam@125 5325 }
cannam@125 5326
cannam@125 5327 # Core function for launching the target application
cannam@125 5328 func_exec_program_core ()
cannam@125 5329 {
cannam@125 5330 "
cannam@125 5331 case $host in
cannam@125 5332 # Backslashes separate directories on plain windows
cannam@125 5333 *-*-mingw | *-*-os2* | *-cegcc*)
cannam@125 5334 $ECHO "\
cannam@125 5335 if test -n \"\$lt_option_debug\"; then
cannam@125 5336 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
cannam@125 5337 func_lt_dump_args \${1+\"\$@\"} 1>&2
cannam@125 5338 fi
cannam@125 5339 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
cannam@125 5340 "
cannam@125 5341 ;;
cannam@125 5342
cannam@125 5343 *)
cannam@125 5344 $ECHO "\
cannam@125 5345 if test -n \"\$lt_option_debug\"; then
cannam@125 5346 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
cannam@125 5347 func_lt_dump_args \${1+\"\$@\"} 1>&2
cannam@125 5348 fi
cannam@125 5349 exec \"\$progdir/\$program\" \${1+\"\$@\"}
cannam@125 5350 "
cannam@125 5351 ;;
cannam@125 5352 esac
cannam@125 5353 $ECHO "\
cannam@125 5354 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
cannam@125 5355 exit 1
cannam@125 5356 }
cannam@125 5357
cannam@125 5358 # A function to encapsulate launching the target application
cannam@125 5359 # Strips options in the --lt-* namespace from \$@ and
cannam@125 5360 # launches target application with the remaining arguments.
cannam@125 5361 func_exec_program ()
cannam@125 5362 {
cannam@125 5363 case \" \$* \" in
cannam@125 5364 *\\ --lt-*)
cannam@125 5365 for lt_wr_arg
cannam@125 5366 do
cannam@125 5367 case \$lt_wr_arg in
cannam@125 5368 --lt-*) ;;
cannam@125 5369 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
cannam@125 5370 esac
cannam@125 5371 shift
cannam@125 5372 done ;;
cannam@125 5373 esac
cannam@125 5374 func_exec_program_core \${1+\"\$@\"}
cannam@125 5375 }
cannam@125 5376
cannam@125 5377 # Parse options
cannam@125 5378 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
cannam@125 5379
cannam@125 5380 # Find the directory that this script lives in.
cannam@125 5381 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
cannam@125 5382 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
cannam@125 5383
cannam@125 5384 # Follow symbolic links until we get to the real thisdir.
cannam@125 5385 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
cannam@125 5386 while test -n \"\$file\"; do
cannam@125 5387 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
cannam@125 5388
cannam@125 5389 # If there was a directory component, then change thisdir.
cannam@125 5390 if test \"x\$destdir\" != \"x\$file\"; then
cannam@125 5391 case \"\$destdir\" in
cannam@125 5392 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
cannam@125 5393 *) thisdir=\"\$thisdir/\$destdir\" ;;
cannam@125 5394 esac
cannam@125 5395 fi
cannam@125 5396
cannam@125 5397 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
cannam@125 5398 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
cannam@125 5399 done
cannam@125 5400
cannam@125 5401 # Usually 'no', except on cygwin/mingw when embedded into
cannam@125 5402 # the cwrapper.
cannam@125 5403 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
cannam@125 5404 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
cannam@125 5405 # special case for '.'
cannam@125 5406 if test \"\$thisdir\" = \".\"; then
cannam@125 5407 thisdir=\`pwd\`
cannam@125 5408 fi
cannam@125 5409 # remove .libs from thisdir
cannam@125 5410 case \"\$thisdir\" in
cannam@125 5411 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
cannam@125 5412 $objdir ) thisdir=. ;;
cannam@125 5413 esac
cannam@125 5414 fi
cannam@125 5415
cannam@125 5416 # Try to get the absolute directory name.
cannam@125 5417 absdir=\`cd \"\$thisdir\" && pwd\`
cannam@125 5418 test -n \"\$absdir\" && thisdir=\"\$absdir\"
cannam@125 5419 "
cannam@125 5420
cannam@125 5421 if test yes = "$fast_install"; then
cannam@125 5422 $ECHO "\
cannam@125 5423 program=lt-'$outputname'$exeext
cannam@125 5424 progdir=\"\$thisdir/$objdir\"
cannam@125 5425
cannam@125 5426 if test ! -f \"\$progdir/\$program\" ||
cannam@125 5427 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
cannam@125 5428 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
cannam@125 5429
cannam@125 5430 file=\"\$\$-\$program\"
cannam@125 5431
cannam@125 5432 if test ! -d \"\$progdir\"; then
cannam@125 5433 $MKDIR \"\$progdir\"
cannam@125 5434 else
cannam@125 5435 $RM \"\$progdir/\$file\"
cannam@125 5436 fi"
cannam@125 5437
cannam@125 5438 $ECHO "\
cannam@125 5439
cannam@125 5440 # relink executable if necessary
cannam@125 5441 if test -n \"\$relink_command\"; then
cannam@125 5442 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
cannam@125 5443 else
cannam@125 5444 \$ECHO \"\$relink_command_output\" >&2
cannam@125 5445 $RM \"\$progdir/\$file\"
cannam@125 5446 exit 1
cannam@125 5447 fi
cannam@125 5448 fi
cannam@125 5449
cannam@125 5450 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
cannam@125 5451 { $RM \"\$progdir/\$program\";
cannam@125 5452 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
cannam@125 5453 $RM \"\$progdir/\$file\"
cannam@125 5454 fi"
cannam@125 5455 else
cannam@125 5456 $ECHO "\
cannam@125 5457 program='$outputname'
cannam@125 5458 progdir=\"\$thisdir/$objdir\"
cannam@125 5459 "
cannam@125 5460 fi
cannam@125 5461
cannam@125 5462 $ECHO "\
cannam@125 5463
cannam@125 5464 if test -f \"\$progdir/\$program\"; then"
cannam@125 5465
cannam@125 5466 # fixup the dll searchpath if we need to.
cannam@125 5467 #
cannam@125 5468 # Fix the DLL searchpath if we need to. Do this before prepending
cannam@125 5469 # to shlibpath, because on Windows, both are PATH and uninstalled
cannam@125 5470 # libraries must come first.
cannam@125 5471 if test -n "$dllsearchpath"; then
cannam@125 5472 $ECHO "\
cannam@125 5473 # Add the dll search path components to the executable PATH
cannam@125 5474 PATH=$dllsearchpath:\$PATH
cannam@125 5475 "
cannam@125 5476 fi
cannam@125 5477
cannam@125 5478 # Export our shlibpath_var if we have one.
cannam@125 5479 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
cannam@125 5480 $ECHO "\
cannam@125 5481 # Add our own library path to $shlibpath_var
cannam@125 5482 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
cannam@125 5483
cannam@125 5484 # Some systems cannot cope with colon-terminated $shlibpath_var
cannam@125 5485 # The second colon is a workaround for a bug in BeOS R4 sed
cannam@125 5486 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
cannam@125 5487
cannam@125 5488 export $shlibpath_var
cannam@125 5489 "
cannam@125 5490 fi
cannam@125 5491
cannam@125 5492 $ECHO "\
cannam@125 5493 if test \"\$libtool_execute_magic\" != \"$magic\"; then
cannam@125 5494 # Run the actual program with our arguments.
cannam@125 5495 func_exec_program \${1+\"\$@\"}
cannam@125 5496 fi
cannam@125 5497 else
cannam@125 5498 # The program doesn't exist.
cannam@125 5499 \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
cannam@125 5500 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
cannam@125 5501 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
cannam@125 5502 exit 1
cannam@125 5503 fi
cannam@125 5504 fi\
cannam@125 5505 "
cannam@125 5506 }
cannam@125 5507
cannam@125 5508
cannam@125 5509 # func_emit_cwrapperexe_src
cannam@125 5510 # emit the source code for a wrapper executable on stdout
cannam@125 5511 # Must ONLY be called from within func_mode_link because
cannam@125 5512 # it depends on a number of variable set therein.
cannam@125 5513 func_emit_cwrapperexe_src ()
cannam@125 5514 {
cannam@125 5515 cat <<EOF
cannam@125 5516
cannam@125 5517 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
cannam@125 5518 Generated by $PROGRAM (GNU $PACKAGE) $VERSION
cannam@125 5519
cannam@125 5520 The $output program cannot be directly executed until all the libtool
cannam@125 5521 libraries that it depends on are installed.
cannam@125 5522
cannam@125 5523 This wrapper executable should never be moved out of the build directory.
cannam@125 5524 If it is, it will not operate correctly.
cannam@125 5525 */
cannam@125 5526 EOF
cannam@125 5527 cat <<"EOF"
cannam@125 5528 #ifdef _MSC_VER
cannam@125 5529 # define _CRT_SECURE_NO_DEPRECATE 1
cannam@125 5530 #endif
cannam@125 5531 #include <stdio.h>
cannam@125 5532 #include <stdlib.h>
cannam@125 5533 #ifdef _MSC_VER
cannam@125 5534 # include <direct.h>
cannam@125 5535 # include <process.h>
cannam@125 5536 # include <io.h>
cannam@125 5537 #else
cannam@125 5538 # include <unistd.h>
cannam@125 5539 # include <stdint.h>
cannam@125 5540 # ifdef __CYGWIN__
cannam@125 5541 # include <io.h>
cannam@125 5542 # endif
cannam@125 5543 #endif
cannam@125 5544 #include <malloc.h>
cannam@125 5545 #include <stdarg.h>
cannam@125 5546 #include <assert.h>
cannam@125 5547 #include <string.h>
cannam@125 5548 #include <ctype.h>
cannam@125 5549 #include <errno.h>
cannam@125 5550 #include <fcntl.h>
cannam@125 5551 #include <sys/stat.h>
cannam@125 5552
cannam@125 5553 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
cannam@125 5554
cannam@125 5555 /* declarations of non-ANSI functions */
cannam@125 5556 #if defined __MINGW32__
cannam@125 5557 # ifdef __STRICT_ANSI__
cannam@125 5558 int _putenv (const char *);
cannam@125 5559 # endif
cannam@125 5560 #elif defined __CYGWIN__
cannam@125 5561 # ifdef __STRICT_ANSI__
cannam@125 5562 char *realpath (const char *, char *);
cannam@125 5563 int putenv (char *);
cannam@125 5564 int setenv (const char *, const char *, int);
cannam@125 5565 # endif
cannam@125 5566 /* #elif defined other_platform || defined ... */
cannam@125 5567 #endif
cannam@125 5568
cannam@125 5569 /* portability defines, excluding path handling macros */
cannam@125 5570 #if defined _MSC_VER
cannam@125 5571 # define setmode _setmode
cannam@125 5572 # define stat _stat
cannam@125 5573 # define chmod _chmod
cannam@125 5574 # define getcwd _getcwd
cannam@125 5575 # define putenv _putenv
cannam@125 5576 # define S_IXUSR _S_IEXEC
cannam@125 5577 #elif defined __MINGW32__
cannam@125 5578 # define setmode _setmode
cannam@125 5579 # define stat _stat
cannam@125 5580 # define chmod _chmod
cannam@125 5581 # define getcwd _getcwd
cannam@125 5582 # define putenv _putenv
cannam@125 5583 #elif defined __CYGWIN__
cannam@125 5584 # define HAVE_SETENV
cannam@125 5585 # define FOPEN_WB "wb"
cannam@125 5586 /* #elif defined other platforms ... */
cannam@125 5587 #endif
cannam@125 5588
cannam@125 5589 #if defined PATH_MAX
cannam@125 5590 # define LT_PATHMAX PATH_MAX
cannam@125 5591 #elif defined MAXPATHLEN
cannam@125 5592 # define LT_PATHMAX MAXPATHLEN
cannam@125 5593 #else
cannam@125 5594 # define LT_PATHMAX 1024
cannam@125 5595 #endif
cannam@125 5596
cannam@125 5597 #ifndef S_IXOTH
cannam@125 5598 # define S_IXOTH 0
cannam@125 5599 #endif
cannam@125 5600 #ifndef S_IXGRP
cannam@125 5601 # define S_IXGRP 0
cannam@125 5602 #endif
cannam@125 5603
cannam@125 5604 /* path handling portability macros */
cannam@125 5605 #ifndef DIR_SEPARATOR
cannam@125 5606 # define DIR_SEPARATOR '/'
cannam@125 5607 # define PATH_SEPARATOR ':'
cannam@125 5608 #endif
cannam@125 5609
cannam@125 5610 #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
cannam@125 5611 defined __OS2__
cannam@125 5612 # define HAVE_DOS_BASED_FILE_SYSTEM
cannam@125 5613 # define FOPEN_WB "wb"
cannam@125 5614 # ifndef DIR_SEPARATOR_2
cannam@125 5615 # define DIR_SEPARATOR_2 '\\'
cannam@125 5616 # endif
cannam@125 5617 # ifndef PATH_SEPARATOR_2
cannam@125 5618 # define PATH_SEPARATOR_2 ';'
cannam@125 5619 # endif
cannam@125 5620 #endif
cannam@125 5621
cannam@125 5622 #ifndef DIR_SEPARATOR_2
cannam@125 5623 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
cannam@125 5624 #else /* DIR_SEPARATOR_2 */
cannam@125 5625 # define IS_DIR_SEPARATOR(ch) \
cannam@125 5626 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
cannam@125 5627 #endif /* DIR_SEPARATOR_2 */
cannam@125 5628
cannam@125 5629 #ifndef PATH_SEPARATOR_2
cannam@125 5630 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
cannam@125 5631 #else /* PATH_SEPARATOR_2 */
cannam@125 5632 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
cannam@125 5633 #endif /* PATH_SEPARATOR_2 */
cannam@125 5634
cannam@125 5635 #ifndef FOPEN_WB
cannam@125 5636 # define FOPEN_WB "w"
cannam@125 5637 #endif
cannam@125 5638 #ifndef _O_BINARY
cannam@125 5639 # define _O_BINARY 0
cannam@125 5640 #endif
cannam@125 5641
cannam@125 5642 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
cannam@125 5643 #define XFREE(stale) do { \
cannam@125 5644 if (stale) { free (stale); stale = 0; } \
cannam@125 5645 } while (0)
cannam@125 5646
cannam@125 5647 #if defined LT_DEBUGWRAPPER
cannam@125 5648 static int lt_debug = 1;
cannam@125 5649 #else
cannam@125 5650 static int lt_debug = 0;
cannam@125 5651 #endif
cannam@125 5652
cannam@125 5653 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
cannam@125 5654
cannam@125 5655 void *xmalloc (size_t num);
cannam@125 5656 char *xstrdup (const char *string);
cannam@125 5657 const char *base_name (const char *name);
cannam@125 5658 char *find_executable (const char *wrapper);
cannam@125 5659 char *chase_symlinks (const char *pathspec);
cannam@125 5660 int make_executable (const char *path);
cannam@125 5661 int check_executable (const char *path);
cannam@125 5662 char *strendzap (char *str, const char *pat);
cannam@125 5663 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
cannam@125 5664 void lt_fatal (const char *file, int line, const char *message, ...);
cannam@125 5665 static const char *nonnull (const char *s);
cannam@125 5666 static const char *nonempty (const char *s);
cannam@125 5667 void lt_setenv (const char *name, const char *value);
cannam@125 5668 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
cannam@125 5669 void lt_update_exe_path (const char *name, const char *value);
cannam@125 5670 void lt_update_lib_path (const char *name, const char *value);
cannam@125 5671 char **prepare_spawn (char **argv);
cannam@125 5672 void lt_dump_script (FILE *f);
cannam@125 5673 EOF
cannam@125 5674
cannam@125 5675 cat <<EOF
cannam@125 5676 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
cannam@125 5677 # define externally_visible volatile
cannam@125 5678 #else
cannam@125 5679 # define externally_visible __attribute__((externally_visible)) volatile
cannam@125 5680 #endif
cannam@125 5681 externally_visible const char * MAGIC_EXE = "$magic_exe";
cannam@125 5682 const char * LIB_PATH_VARNAME = "$shlibpath_var";
cannam@125 5683 EOF
cannam@125 5684
cannam@125 5685 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
cannam@125 5686 func_to_host_path "$temp_rpath"
cannam@125 5687 cat <<EOF
cannam@125 5688 const char * LIB_PATH_VALUE = "$func_to_host_path_result";
cannam@125 5689 EOF
cannam@125 5690 else
cannam@125 5691 cat <<"EOF"
cannam@125 5692 const char * LIB_PATH_VALUE = "";
cannam@125 5693 EOF
cannam@125 5694 fi
cannam@125 5695
cannam@125 5696 if test -n "$dllsearchpath"; then
cannam@125 5697 func_to_host_path "$dllsearchpath:"
cannam@125 5698 cat <<EOF
cannam@125 5699 const char * EXE_PATH_VARNAME = "PATH";
cannam@125 5700 const char * EXE_PATH_VALUE = "$func_to_host_path_result";
cannam@125 5701 EOF
cannam@125 5702 else
cannam@125 5703 cat <<"EOF"
cannam@125 5704 const char * EXE_PATH_VARNAME = "";
cannam@125 5705 const char * EXE_PATH_VALUE = "";
cannam@125 5706 EOF
cannam@125 5707 fi
cannam@125 5708
cannam@125 5709 if test yes = "$fast_install"; then
cannam@125 5710 cat <<EOF
cannam@125 5711 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
cannam@125 5712 EOF
cannam@125 5713 else
cannam@125 5714 cat <<EOF
cannam@125 5715 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
cannam@125 5716 EOF
cannam@125 5717 fi
cannam@125 5718
cannam@125 5719
cannam@125 5720 cat <<"EOF"
cannam@125 5721
cannam@125 5722 #define LTWRAPPER_OPTION_PREFIX "--lt-"
cannam@125 5723
cannam@125 5724 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
cannam@125 5725 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
cannam@125 5726 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
cannam@125 5727
cannam@125 5728 int
cannam@125 5729 main (int argc, char *argv[])
cannam@125 5730 {
cannam@125 5731 char **newargz;
cannam@125 5732 int newargc;
cannam@125 5733 char *tmp_pathspec;
cannam@125 5734 char *actual_cwrapper_path;
cannam@125 5735 char *actual_cwrapper_name;
cannam@125 5736 char *target_name;
cannam@125 5737 char *lt_argv_zero;
cannam@125 5738 int rval = 127;
cannam@125 5739
cannam@125 5740 int i;
cannam@125 5741
cannam@125 5742 program_name = (char *) xstrdup (base_name (argv[0]));
cannam@125 5743 newargz = XMALLOC (char *, (size_t) argc + 1);
cannam@125 5744
cannam@125 5745 /* very simple arg parsing; don't want to rely on getopt
cannam@125 5746 * also, copy all non cwrapper options to newargz, except
cannam@125 5747 * argz[0], which is handled differently
cannam@125 5748 */
cannam@125 5749 newargc=0;
cannam@125 5750 for (i = 1; i < argc; i++)
cannam@125 5751 {
cannam@125 5752 if (STREQ (argv[i], dumpscript_opt))
cannam@125 5753 {
cannam@125 5754 EOF
cannam@125 5755 case $host in
cannam@125 5756 *mingw* | *cygwin* )
cannam@125 5757 # make stdout use "unix" line endings
cannam@125 5758 echo " setmode(1,_O_BINARY);"
cannam@125 5759 ;;
cannam@125 5760 esac
cannam@125 5761
cannam@125 5762 cat <<"EOF"
cannam@125 5763 lt_dump_script (stdout);
cannam@125 5764 return 0;
cannam@125 5765 }
cannam@125 5766 if (STREQ (argv[i], debug_opt))
cannam@125 5767 {
cannam@125 5768 lt_debug = 1;
cannam@125 5769 continue;
cannam@125 5770 }
cannam@125 5771 if (STREQ (argv[i], ltwrapper_option_prefix))
cannam@125 5772 {
cannam@125 5773 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
cannam@125 5774 namespace, but it is not one of the ones we know about and
cannam@125 5775 have already dealt with, above (inluding dump-script), then
cannam@125 5776 report an error. Otherwise, targets might begin to believe
cannam@125 5777 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
cannam@125 5778 namespace. The first time any user complains about this, we'll
cannam@125 5779 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
cannam@125 5780 or a configure.ac-settable value.
cannam@125 5781 */
cannam@125 5782 lt_fatal (__FILE__, __LINE__,
cannam@125 5783 "unrecognized %s option: '%s'",
cannam@125 5784 ltwrapper_option_prefix, argv[i]);
cannam@125 5785 }
cannam@125 5786 /* otherwise ... */
cannam@125 5787 newargz[++newargc] = xstrdup (argv[i]);
cannam@125 5788 }
cannam@125 5789 newargz[++newargc] = NULL;
cannam@125 5790
cannam@125 5791 EOF
cannam@125 5792 cat <<EOF
cannam@125 5793 /* The GNU banner must be the first non-error debug message */
cannam@125 5794 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
cannam@125 5795 EOF
cannam@125 5796 cat <<"EOF"
cannam@125 5797 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
cannam@125 5798 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
cannam@125 5799
cannam@125 5800 tmp_pathspec = find_executable (argv[0]);
cannam@125 5801 if (tmp_pathspec == NULL)
cannam@125 5802 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
cannam@125 5803 lt_debugprintf (__FILE__, __LINE__,
cannam@125 5804 "(main) found exe (before symlink chase) at: %s\n",
cannam@125 5805 tmp_pathspec);
cannam@125 5806
cannam@125 5807 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
cannam@125 5808 lt_debugprintf (__FILE__, __LINE__,
cannam@125 5809 "(main) found exe (after symlink chase) at: %s\n",
cannam@125 5810 actual_cwrapper_path);
cannam@125 5811 XFREE (tmp_pathspec);
cannam@125 5812
cannam@125 5813 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
cannam@125 5814 strendzap (actual_cwrapper_path, actual_cwrapper_name);
cannam@125 5815
cannam@125 5816 /* wrapper name transforms */
cannam@125 5817 strendzap (actual_cwrapper_name, ".exe");
cannam@125 5818 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
cannam@125 5819 XFREE (actual_cwrapper_name);
cannam@125 5820 actual_cwrapper_name = tmp_pathspec;
cannam@125 5821 tmp_pathspec = 0;
cannam@125 5822
cannam@125 5823 /* target_name transforms -- use actual target program name; might have lt- prefix */
cannam@125 5824 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
cannam@125 5825 strendzap (target_name, ".exe");
cannam@125 5826 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
cannam@125 5827 XFREE (target_name);
cannam@125 5828 target_name = tmp_pathspec;
cannam@125 5829 tmp_pathspec = 0;
cannam@125 5830
cannam@125 5831 lt_debugprintf (__FILE__, __LINE__,
cannam@125 5832 "(main) libtool target name: %s\n",
cannam@125 5833 target_name);
cannam@125 5834 EOF
cannam@125 5835
cannam@125 5836 cat <<EOF
cannam@125 5837 newargz[0] =
cannam@125 5838 XMALLOC (char, (strlen (actual_cwrapper_path) +
cannam@125 5839 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
cannam@125 5840 strcpy (newargz[0], actual_cwrapper_path);
cannam@125 5841 strcat (newargz[0], "$objdir");
cannam@125 5842 strcat (newargz[0], "/");
cannam@125 5843 EOF
cannam@125 5844
cannam@125 5845 cat <<"EOF"
cannam@125 5846 /* stop here, and copy so we don't have to do this twice */
cannam@125 5847 tmp_pathspec = xstrdup (newargz[0]);
cannam@125 5848
cannam@125 5849 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
cannam@125 5850 strcat (newargz[0], actual_cwrapper_name);
cannam@125 5851
cannam@125 5852 /* DO want the lt- prefix here if it exists, so use target_name */
cannam@125 5853 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
cannam@125 5854 XFREE (tmp_pathspec);
cannam@125 5855 tmp_pathspec = NULL;
cannam@125 5856 EOF
cannam@125 5857
cannam@125 5858 case $host_os in
cannam@125 5859 mingw*)
cannam@125 5860 cat <<"EOF"
cannam@125 5861 {
cannam@125 5862 char* p;
cannam@125 5863 while ((p = strchr (newargz[0], '\\')) != NULL)
cannam@125 5864 {
cannam@125 5865 *p = '/';
cannam@125 5866 }
cannam@125 5867 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
cannam@125 5868 {
cannam@125 5869 *p = '/';
cannam@125 5870 }
cannam@125 5871 }
cannam@125 5872 EOF
cannam@125 5873 ;;
cannam@125 5874 esac
cannam@125 5875
cannam@125 5876 cat <<"EOF"
cannam@125 5877 XFREE (target_name);
cannam@125 5878 XFREE (actual_cwrapper_path);
cannam@125 5879 XFREE (actual_cwrapper_name);
cannam@125 5880
cannam@125 5881 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
cannam@125 5882 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
cannam@125 5883 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
cannam@125 5884 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
cannam@125 5885 because on Windows, both *_VARNAMEs are PATH but uninstalled
cannam@125 5886 libraries must come first. */
cannam@125 5887 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
cannam@125 5888 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
cannam@125 5889
cannam@125 5890 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
cannam@125 5891 nonnull (lt_argv_zero));
cannam@125 5892 for (i = 0; i < newargc; i++)
cannam@125 5893 {
cannam@125 5894 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
cannam@125 5895 i, nonnull (newargz[i]));
cannam@125 5896 }
cannam@125 5897
cannam@125 5898 EOF
cannam@125 5899
cannam@125 5900 case $host_os in
cannam@125 5901 mingw*)
cannam@125 5902 cat <<"EOF"
cannam@125 5903 /* execv doesn't actually work on mingw as expected on unix */
cannam@125 5904 newargz = prepare_spawn (newargz);
cannam@125 5905 rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
cannam@125 5906 if (rval == -1)
cannam@125 5907 {
cannam@125 5908 /* failed to start process */
cannam@125 5909 lt_debugprintf (__FILE__, __LINE__,
cannam@125 5910 "(main) failed to launch target \"%s\": %s\n",
cannam@125 5911 lt_argv_zero, nonnull (strerror (errno)));
cannam@125 5912 return 127;
cannam@125 5913 }
cannam@125 5914 return rval;
cannam@125 5915 EOF
cannam@125 5916 ;;
cannam@125 5917 *)
cannam@125 5918 cat <<"EOF"
cannam@125 5919 execv (lt_argv_zero, newargz);
cannam@125 5920 return rval; /* =127, but avoids unused variable warning */
cannam@125 5921 EOF
cannam@125 5922 ;;
cannam@125 5923 esac
cannam@125 5924
cannam@125 5925 cat <<"EOF"
cannam@125 5926 }
cannam@125 5927
cannam@125 5928 void *
cannam@125 5929 xmalloc (size_t num)
cannam@125 5930 {
cannam@125 5931 void *p = (void *) malloc (num);
cannam@125 5932 if (!p)
cannam@125 5933 lt_fatal (__FILE__, __LINE__, "memory exhausted");
cannam@125 5934
cannam@125 5935 return p;
cannam@125 5936 }
cannam@125 5937
cannam@125 5938 char *
cannam@125 5939 xstrdup (const char *string)
cannam@125 5940 {
cannam@125 5941 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
cannam@125 5942 string) : NULL;
cannam@125 5943 }
cannam@125 5944
cannam@125 5945 const char *
cannam@125 5946 base_name (const char *name)
cannam@125 5947 {
cannam@125 5948 const char *base;
cannam@125 5949
cannam@125 5950 #if defined HAVE_DOS_BASED_FILE_SYSTEM
cannam@125 5951 /* Skip over the disk name in MSDOS pathnames. */
cannam@125 5952 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
cannam@125 5953 name += 2;
cannam@125 5954 #endif
cannam@125 5955
cannam@125 5956 for (base = name; *name; name++)
cannam@125 5957 if (IS_DIR_SEPARATOR (*name))
cannam@125 5958 base = name + 1;
cannam@125 5959 return base;
cannam@125 5960 }
cannam@125 5961
cannam@125 5962 int
cannam@125 5963 check_executable (const char *path)
cannam@125 5964 {
cannam@125 5965 struct stat st;
cannam@125 5966
cannam@125 5967 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
cannam@125 5968 nonempty (path));
cannam@125 5969 if ((!path) || (!*path))
cannam@125 5970 return 0;
cannam@125 5971
cannam@125 5972 if ((stat (path, &st) >= 0)
cannam@125 5973 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
cannam@125 5974 return 1;
cannam@125 5975 else
cannam@125 5976 return 0;
cannam@125 5977 }
cannam@125 5978
cannam@125 5979 int
cannam@125 5980 make_executable (const char *path)
cannam@125 5981 {
cannam@125 5982 int rval = 0;
cannam@125 5983 struct stat st;
cannam@125 5984
cannam@125 5985 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
cannam@125 5986 nonempty (path));
cannam@125 5987 if ((!path) || (!*path))
cannam@125 5988 return 0;
cannam@125 5989
cannam@125 5990 if (stat (path, &st) >= 0)
cannam@125 5991 {
cannam@125 5992 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
cannam@125 5993 }
cannam@125 5994 return rval;
cannam@125 5995 }
cannam@125 5996
cannam@125 5997 /* Searches for the full path of the wrapper. Returns
cannam@125 5998 newly allocated full path name if found, NULL otherwise
cannam@125 5999 Does not chase symlinks, even on platforms that support them.
cannam@125 6000 */
cannam@125 6001 char *
cannam@125 6002 find_executable (const char *wrapper)
cannam@125 6003 {
cannam@125 6004 int has_slash = 0;
cannam@125 6005 const char *p;
cannam@125 6006 const char *p_next;
cannam@125 6007 /* static buffer for getcwd */
cannam@125 6008 char tmp[LT_PATHMAX + 1];
cannam@125 6009 size_t tmp_len;
cannam@125 6010 char *concat_name;
cannam@125 6011
cannam@125 6012 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
cannam@125 6013 nonempty (wrapper));
cannam@125 6014
cannam@125 6015 if ((wrapper == NULL) || (*wrapper == '\0'))
cannam@125 6016 return NULL;
cannam@125 6017
cannam@125 6018 /* Absolute path? */
cannam@125 6019 #if defined HAVE_DOS_BASED_FILE_SYSTEM
cannam@125 6020 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
cannam@125 6021 {
cannam@125 6022 concat_name = xstrdup (wrapper);
cannam@125 6023 if (check_executable (concat_name))
cannam@125 6024 return concat_name;
cannam@125 6025 XFREE (concat_name);
cannam@125 6026 }
cannam@125 6027 else
cannam@125 6028 {
cannam@125 6029 #endif
cannam@125 6030 if (IS_DIR_SEPARATOR (wrapper[0]))
cannam@125 6031 {
cannam@125 6032 concat_name = xstrdup (wrapper);
cannam@125 6033 if (check_executable (concat_name))
cannam@125 6034 return concat_name;
cannam@125 6035 XFREE (concat_name);
cannam@125 6036 }
cannam@125 6037 #if defined HAVE_DOS_BASED_FILE_SYSTEM
cannam@125 6038 }
cannam@125 6039 #endif
cannam@125 6040
cannam@125 6041 for (p = wrapper; *p; p++)
cannam@125 6042 if (*p == '/')
cannam@125 6043 {
cannam@125 6044 has_slash = 1;
cannam@125 6045 break;
cannam@125 6046 }
cannam@125 6047 if (!has_slash)
cannam@125 6048 {
cannam@125 6049 /* no slashes; search PATH */
cannam@125 6050 const char *path = getenv ("PATH");
cannam@125 6051 if (path != NULL)
cannam@125 6052 {
cannam@125 6053 for (p = path; *p; p = p_next)
cannam@125 6054 {
cannam@125 6055 const char *q;
cannam@125 6056 size_t p_len;
cannam@125 6057 for (q = p; *q; q++)
cannam@125 6058 if (IS_PATH_SEPARATOR (*q))
cannam@125 6059 break;
cannam@125 6060 p_len = (size_t) (q - p);
cannam@125 6061 p_next = (*q == '\0' ? q : q + 1);
cannam@125 6062 if (p_len == 0)
cannam@125 6063 {
cannam@125 6064 /* empty path: current directory */
cannam@125 6065 if (getcwd (tmp, LT_PATHMAX) == NULL)
cannam@125 6066 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
cannam@125 6067 nonnull (strerror (errno)));
cannam@125 6068 tmp_len = strlen (tmp);
cannam@125 6069 concat_name =
cannam@125 6070 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
cannam@125 6071 memcpy (concat_name, tmp, tmp_len);
cannam@125 6072 concat_name[tmp_len] = '/';
cannam@125 6073 strcpy (concat_name + tmp_len + 1, wrapper);
cannam@125 6074 }
cannam@125 6075 else
cannam@125 6076 {
cannam@125 6077 concat_name =
cannam@125 6078 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
cannam@125 6079 memcpy (concat_name, p, p_len);
cannam@125 6080 concat_name[p_len] = '/';
cannam@125 6081 strcpy (concat_name + p_len + 1, wrapper);
cannam@125 6082 }
cannam@125 6083 if (check_executable (concat_name))
cannam@125 6084 return concat_name;
cannam@125 6085 XFREE (concat_name);
cannam@125 6086 }
cannam@125 6087 }
cannam@125 6088 /* not found in PATH; assume curdir */
cannam@125 6089 }
cannam@125 6090 /* Relative path | not found in path: prepend cwd */
cannam@125 6091 if (getcwd (tmp, LT_PATHMAX) == NULL)
cannam@125 6092 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
cannam@125 6093 nonnull (strerror (errno)));
cannam@125 6094 tmp_len = strlen (tmp);
cannam@125 6095 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
cannam@125 6096 memcpy (concat_name, tmp, tmp_len);
cannam@125 6097 concat_name[tmp_len] = '/';
cannam@125 6098 strcpy (concat_name + tmp_len + 1, wrapper);
cannam@125 6099
cannam@125 6100 if (check_executable (concat_name))
cannam@125 6101 return concat_name;
cannam@125 6102 XFREE (concat_name);
cannam@125 6103 return NULL;
cannam@125 6104 }
cannam@125 6105
cannam@125 6106 char *
cannam@125 6107 chase_symlinks (const char *pathspec)
cannam@125 6108 {
cannam@125 6109 #ifndef S_ISLNK
cannam@125 6110 return xstrdup (pathspec);
cannam@125 6111 #else
cannam@125 6112 char buf[LT_PATHMAX];
cannam@125 6113 struct stat s;
cannam@125 6114 char *tmp_pathspec = xstrdup (pathspec);
cannam@125 6115 char *p;
cannam@125 6116 int has_symlinks = 0;
cannam@125 6117 while (strlen (tmp_pathspec) && !has_symlinks)
cannam@125 6118 {
cannam@125 6119 lt_debugprintf (__FILE__, __LINE__,
cannam@125 6120 "checking path component for symlinks: %s\n",
cannam@125 6121 tmp_pathspec);
cannam@125 6122 if (lstat (tmp_pathspec, &s) == 0)
cannam@125 6123 {
cannam@125 6124 if (S_ISLNK (s.st_mode) != 0)
cannam@125 6125 {
cannam@125 6126 has_symlinks = 1;
cannam@125 6127 break;
cannam@125 6128 }
cannam@125 6129
cannam@125 6130 /* search backwards for last DIR_SEPARATOR */
cannam@125 6131 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
cannam@125 6132 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
cannam@125 6133 p--;
cannam@125 6134 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
cannam@125 6135 {
cannam@125 6136 /* no more DIR_SEPARATORS left */
cannam@125 6137 break;
cannam@125 6138 }
cannam@125 6139 *p = '\0';
cannam@125 6140 }
cannam@125 6141 else
cannam@125 6142 {
cannam@125 6143 lt_fatal (__FILE__, __LINE__,
cannam@125 6144 "error accessing file \"%s\": %s",
cannam@125 6145 tmp_pathspec, nonnull (strerror (errno)));
cannam@125 6146 }
cannam@125 6147 }
cannam@125 6148 XFREE (tmp_pathspec);
cannam@125 6149
cannam@125 6150 if (!has_symlinks)
cannam@125 6151 {
cannam@125 6152 return xstrdup (pathspec);
cannam@125 6153 }
cannam@125 6154
cannam@125 6155 tmp_pathspec = realpath (pathspec, buf);
cannam@125 6156 if (tmp_pathspec == 0)
cannam@125 6157 {
cannam@125 6158 lt_fatal (__FILE__, __LINE__,
cannam@125 6159 "could not follow symlinks for %s", pathspec);
cannam@125 6160 }
cannam@125 6161 return xstrdup (tmp_pathspec);
cannam@125 6162 #endif
cannam@125 6163 }
cannam@125 6164
cannam@125 6165 char *
cannam@125 6166 strendzap (char *str, const char *pat)
cannam@125 6167 {
cannam@125 6168 size_t len, patlen;
cannam@125 6169
cannam@125 6170 assert (str != NULL);
cannam@125 6171 assert (pat != NULL);
cannam@125 6172
cannam@125 6173 len = strlen (str);
cannam@125 6174 patlen = strlen (pat);
cannam@125 6175
cannam@125 6176 if (patlen <= len)
cannam@125 6177 {
cannam@125 6178 str += len - patlen;
cannam@125 6179 if (STREQ (str, pat))
cannam@125 6180 *str = '\0';
cannam@125 6181 }
cannam@125 6182 return str;
cannam@125 6183 }
cannam@125 6184
cannam@125 6185 void
cannam@125 6186 lt_debugprintf (const char *file, int line, const char *fmt, ...)
cannam@125 6187 {
cannam@125 6188 va_list args;
cannam@125 6189 if (lt_debug)
cannam@125 6190 {
cannam@125 6191 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
cannam@125 6192 va_start (args, fmt);
cannam@125 6193 (void) vfprintf (stderr, fmt, args);
cannam@125 6194 va_end (args);
cannam@125 6195 }
cannam@125 6196 }
cannam@125 6197
cannam@125 6198 static void
cannam@125 6199 lt_error_core (int exit_status, const char *file,
cannam@125 6200 int line, const char *mode,
cannam@125 6201 const char *message, va_list ap)
cannam@125 6202 {
cannam@125 6203 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
cannam@125 6204 vfprintf (stderr, message, ap);
cannam@125 6205 fprintf (stderr, ".\n");
cannam@125 6206
cannam@125 6207 if (exit_status >= 0)
cannam@125 6208 exit (exit_status);
cannam@125 6209 }
cannam@125 6210
cannam@125 6211 void
cannam@125 6212 lt_fatal (const char *file, int line, const char *message, ...)
cannam@125 6213 {
cannam@125 6214 va_list ap;
cannam@125 6215 va_start (ap, message);
cannam@125 6216 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
cannam@125 6217 va_end (ap);
cannam@125 6218 }
cannam@125 6219
cannam@125 6220 static const char *
cannam@125 6221 nonnull (const char *s)
cannam@125 6222 {
cannam@125 6223 return s ? s : "(null)";
cannam@125 6224 }
cannam@125 6225
cannam@125 6226 static const char *
cannam@125 6227 nonempty (const char *s)
cannam@125 6228 {
cannam@125 6229 return (s && !*s) ? "(empty)" : nonnull (s);
cannam@125 6230 }
cannam@125 6231
cannam@125 6232 void
cannam@125 6233 lt_setenv (const char *name, const char *value)
cannam@125 6234 {
cannam@125 6235 lt_debugprintf (__FILE__, __LINE__,
cannam@125 6236 "(lt_setenv) setting '%s' to '%s'\n",
cannam@125 6237 nonnull (name), nonnull (value));
cannam@125 6238 {
cannam@125 6239 #ifdef HAVE_SETENV
cannam@125 6240 /* always make a copy, for consistency with !HAVE_SETENV */
cannam@125 6241 char *str = xstrdup (value);
cannam@125 6242 setenv (name, str, 1);
cannam@125 6243 #else
cannam@125 6244 size_t len = strlen (name) + 1 + strlen (value) + 1;
cannam@125 6245 char *str = XMALLOC (char, len);
cannam@125 6246 sprintf (str, "%s=%s", name, value);
cannam@125 6247 if (putenv (str) != EXIT_SUCCESS)
cannam@125 6248 {
cannam@125 6249 XFREE (str);
cannam@125 6250 }
cannam@125 6251 #endif
cannam@125 6252 }
cannam@125 6253 }
cannam@125 6254
cannam@125 6255 char *
cannam@125 6256 lt_extend_str (const char *orig_value, const char *add, int to_end)
cannam@125 6257 {
cannam@125 6258 char *new_value;
cannam@125 6259 if (orig_value && *orig_value)
cannam@125 6260 {
cannam@125 6261 size_t orig_value_len = strlen (orig_value);
cannam@125 6262 size_t add_len = strlen (add);
cannam@125 6263 new_value = XMALLOC (char, add_len + orig_value_len + 1);
cannam@125 6264 if (to_end)
cannam@125 6265 {
cannam@125 6266 strcpy (new_value, orig_value);
cannam@125 6267 strcpy (new_value + orig_value_len, add);
cannam@125 6268 }
cannam@125 6269 else
cannam@125 6270 {
cannam@125 6271 strcpy (new_value, add);
cannam@125 6272 strcpy (new_value + add_len, orig_value);
cannam@125 6273 }
cannam@125 6274 }
cannam@125 6275 else
cannam@125 6276 {
cannam@125 6277 new_value = xstrdup (add);
cannam@125 6278 }
cannam@125 6279 return new_value;
cannam@125 6280 }
cannam@125 6281
cannam@125 6282 void
cannam@125 6283 lt_update_exe_path (const char *name, const char *value)
cannam@125 6284 {
cannam@125 6285 lt_debugprintf (__FILE__, __LINE__,
cannam@125 6286 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
cannam@125 6287 nonnull (name), nonnull (value));
cannam@125 6288
cannam@125 6289 if (name && *name && value && *value)
cannam@125 6290 {
cannam@125 6291 char *new_value = lt_extend_str (getenv (name), value, 0);
cannam@125 6292 /* some systems can't cope with a ':'-terminated path #' */
cannam@125 6293 size_t len = strlen (new_value);
cannam@125 6294 while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
cannam@125 6295 {
cannam@125 6296 new_value[--len] = '\0';
cannam@125 6297 }
cannam@125 6298 lt_setenv (name, new_value);
cannam@125 6299 XFREE (new_value);
cannam@125 6300 }
cannam@125 6301 }
cannam@125 6302
cannam@125 6303 void
cannam@125 6304 lt_update_lib_path (const char *name, const char *value)
cannam@125 6305 {
cannam@125 6306 lt_debugprintf (__FILE__, __LINE__,
cannam@125 6307 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
cannam@125 6308 nonnull (name), nonnull (value));
cannam@125 6309
cannam@125 6310 if (name && *name && value && *value)
cannam@125 6311 {
cannam@125 6312 char *new_value = lt_extend_str (getenv (name), value, 0);
cannam@125 6313 lt_setenv (name, new_value);
cannam@125 6314 XFREE (new_value);
cannam@125 6315 }
cannam@125 6316 }
cannam@125 6317
cannam@125 6318 EOF
cannam@125 6319 case $host_os in
cannam@125 6320 mingw*)
cannam@125 6321 cat <<"EOF"
cannam@125 6322
cannam@125 6323 /* Prepares an argument vector before calling spawn().
cannam@125 6324 Note that spawn() does not by itself call the command interpreter
cannam@125 6325 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
cannam@125 6326 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
cannam@125 6327 GetVersionEx(&v);
cannam@125 6328 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
cannam@125 6329 }) ? "cmd.exe" : "command.com").
cannam@125 6330 Instead it simply concatenates the arguments, separated by ' ', and calls
cannam@125 6331 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
cannam@125 6332 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
cannam@125 6333 special way:
cannam@125 6334 - Space and tab are interpreted as delimiters. They are not treated as
cannam@125 6335 delimiters if they are surrounded by double quotes: "...".
cannam@125 6336 - Unescaped double quotes are removed from the input. Their only effect is
cannam@125 6337 that within double quotes, space and tab are treated like normal
cannam@125 6338 characters.
cannam@125 6339 - Backslashes not followed by double quotes are not special.
cannam@125 6340 - But 2*n+1 backslashes followed by a double quote become
cannam@125 6341 n backslashes followed by a double quote (n >= 0):
cannam@125 6342 \" -> "
cannam@125 6343 \\\" -> \"
cannam@125 6344 \\\\\" -> \\"
cannam@125 6345 */
cannam@125 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"
cannam@125 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"
cannam@125 6348 char **
cannam@125 6349 prepare_spawn (char **argv)
cannam@125 6350 {
cannam@125 6351 size_t argc;
cannam@125 6352 char **new_argv;
cannam@125 6353 size_t i;
cannam@125 6354
cannam@125 6355 /* Count number of arguments. */
cannam@125 6356 for (argc = 0; argv[argc] != NULL; argc++)
cannam@125 6357 ;
cannam@125 6358
cannam@125 6359 /* Allocate new argument vector. */
cannam@125 6360 new_argv = XMALLOC (char *, argc + 1);
cannam@125 6361
cannam@125 6362 /* Put quoted arguments into the new argument vector. */
cannam@125 6363 for (i = 0; i < argc; i++)
cannam@125 6364 {
cannam@125 6365 const char *string = argv[i];
cannam@125 6366
cannam@125 6367 if (string[0] == '\0')
cannam@125 6368 new_argv[i] = xstrdup ("\"\"");
cannam@125 6369 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
cannam@125 6370 {
cannam@125 6371 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
cannam@125 6372 size_t length;
cannam@125 6373 unsigned int backslashes;
cannam@125 6374 const char *s;
cannam@125 6375 char *quoted_string;
cannam@125 6376 char *p;
cannam@125 6377
cannam@125 6378 length = 0;
cannam@125 6379 backslashes = 0;
cannam@125 6380 if (quote_around)
cannam@125 6381 length++;
cannam@125 6382 for (s = string; *s != '\0'; s++)
cannam@125 6383 {
cannam@125 6384 char c = *s;
cannam@125 6385 if (c == '"')
cannam@125 6386 length += backslashes + 1;
cannam@125 6387 length++;
cannam@125 6388 if (c == '\\')
cannam@125 6389 backslashes++;
cannam@125 6390 else
cannam@125 6391 backslashes = 0;
cannam@125 6392 }
cannam@125 6393 if (quote_around)
cannam@125 6394 length += backslashes + 1;
cannam@125 6395
cannam@125 6396 quoted_string = XMALLOC (char, length + 1);
cannam@125 6397
cannam@125 6398 p = quoted_string;
cannam@125 6399 backslashes = 0;
cannam@125 6400 if (quote_around)
cannam@125 6401 *p++ = '"';
cannam@125 6402 for (s = string; *s != '\0'; s++)
cannam@125 6403 {
cannam@125 6404 char c = *s;
cannam@125 6405 if (c == '"')
cannam@125 6406 {
cannam@125 6407 unsigned int j;
cannam@125 6408 for (j = backslashes + 1; j > 0; j--)
cannam@125 6409 *p++ = '\\';
cannam@125 6410 }
cannam@125 6411 *p++ = c;
cannam@125 6412 if (c == '\\')
cannam@125 6413 backslashes++;
cannam@125 6414 else
cannam@125 6415 backslashes = 0;
cannam@125 6416 }
cannam@125 6417 if (quote_around)
cannam@125 6418 {
cannam@125 6419 unsigned int j;
cannam@125 6420 for (j = backslashes; j > 0; j--)
cannam@125 6421 *p++ = '\\';
cannam@125 6422 *p++ = '"';
cannam@125 6423 }
cannam@125 6424 *p = '\0';
cannam@125 6425
cannam@125 6426 new_argv[i] = quoted_string;
cannam@125 6427 }
cannam@125 6428 else
cannam@125 6429 new_argv[i] = (char *) string;
cannam@125 6430 }
cannam@125 6431 new_argv[argc] = NULL;
cannam@125 6432
cannam@125 6433 return new_argv;
cannam@125 6434 }
cannam@125 6435 EOF
cannam@125 6436 ;;
cannam@125 6437 esac
cannam@125 6438
cannam@125 6439 cat <<"EOF"
cannam@125 6440 void lt_dump_script (FILE* f)
cannam@125 6441 {
cannam@125 6442 EOF
cannam@125 6443 func_emit_wrapper yes |
cannam@125 6444 $SED -n -e '
cannam@125 6445 s/^\(.\{79\}\)\(..*\)/\1\
cannam@125 6446 \2/
cannam@125 6447 h
cannam@125 6448 s/\([\\"]\)/\\\1/g
cannam@125 6449 s/$/\\n/
cannam@125 6450 s/\([^\n]*\).*/ fputs ("\1", f);/p
cannam@125 6451 g
cannam@125 6452 D'
cannam@125 6453 cat <<"EOF"
cannam@125 6454 }
cannam@125 6455 EOF
cannam@125 6456 }
cannam@125 6457 # end: func_emit_cwrapperexe_src
cannam@125 6458
cannam@125 6459 # func_win32_import_lib_p ARG
cannam@125 6460 # True if ARG is an import lib, as indicated by $file_magic_cmd
cannam@125 6461 func_win32_import_lib_p ()
cannam@125 6462 {
cannam@125 6463 $debug_cmd
cannam@125 6464
cannam@125 6465 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
cannam@125 6466 *import*) : ;;
cannam@125 6467 *) false ;;
cannam@125 6468 esac
cannam@125 6469 }
cannam@125 6470
cannam@125 6471 # func_suncc_cstd_abi
cannam@125 6472 # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
cannam@125 6473 # Several compiler flags select an ABI that is incompatible with the
cannam@125 6474 # Cstd library. Avoid specifying it if any are in CXXFLAGS.
cannam@125 6475 func_suncc_cstd_abi ()
cannam@125 6476 {
cannam@125 6477 $debug_cmd
cannam@125 6478
cannam@125 6479 case " $compile_command " in
cannam@125 6480 *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
cannam@125 6481 suncc_use_cstd_abi=no
cannam@125 6482 ;;
cannam@125 6483 *)
cannam@125 6484 suncc_use_cstd_abi=yes
cannam@125 6485 ;;
cannam@125 6486 esac
cannam@125 6487 }
cannam@125 6488
cannam@125 6489 # func_mode_link arg...
cannam@125 6490 func_mode_link ()
cannam@125 6491 {
cannam@125 6492 $debug_cmd
cannam@125 6493
cannam@125 6494 case $host in
cannam@125 6495 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
cannam@125 6496 # It is impossible to link a dll without this setting, and
cannam@125 6497 # we shouldn't force the makefile maintainer to figure out
cannam@125 6498 # what system we are compiling for in order to pass an extra
cannam@125 6499 # flag for every libtool invocation.
cannam@125 6500 # allow_undefined=no
cannam@125 6501
cannam@125 6502 # FIXME: Unfortunately, there are problems with the above when trying
cannam@125 6503 # to make a dll that has undefined symbols, in which case not
cannam@125 6504 # even a static library is built. For now, we need to specify
cannam@125 6505 # -no-undefined on the libtool link line when we can be certain
cannam@125 6506 # that all symbols are satisfied, otherwise we get a static library.
cannam@125 6507 allow_undefined=yes
cannam@125 6508 ;;
cannam@125 6509 *)
cannam@125 6510 allow_undefined=yes
cannam@125 6511 ;;
cannam@125 6512 esac
cannam@125 6513 libtool_args=$nonopt
cannam@125 6514 base_compile="$nonopt $@"
cannam@125 6515 compile_command=$nonopt
cannam@125 6516 finalize_command=$nonopt
cannam@125 6517
cannam@125 6518 compile_rpath=
cannam@125 6519 finalize_rpath=
cannam@125 6520 compile_shlibpath=
cannam@125 6521 finalize_shlibpath=
cannam@125 6522 convenience=
cannam@125 6523 old_convenience=
cannam@125 6524 deplibs=
cannam@125 6525 old_deplibs=
cannam@125 6526 compiler_flags=
cannam@125 6527 linker_flags=
cannam@125 6528 dllsearchpath=
cannam@125 6529 lib_search_path=`pwd`
cannam@125 6530 inst_prefix_dir=
cannam@125 6531 new_inherited_linker_flags=
cannam@125 6532
cannam@125 6533 avoid_version=no
cannam@125 6534 bindir=
cannam@125 6535 dlfiles=
cannam@125 6536 dlprefiles=
cannam@125 6537 dlself=no
cannam@125 6538 export_dynamic=no
cannam@125 6539 export_symbols=
cannam@125 6540 export_symbols_regex=
cannam@125 6541 generated=
cannam@125 6542 libobjs=
cannam@125 6543 ltlibs=
cannam@125 6544 module=no
cannam@125 6545 no_install=no
cannam@125 6546 objs=
cannam@125 6547 os2dllname=
cannam@125 6548 non_pic_objects=
cannam@125 6549 precious_files_regex=
cannam@125 6550 prefer_static_libs=no
cannam@125 6551 preload=false
cannam@125 6552 prev=
cannam@125 6553 prevarg=
cannam@125 6554 release=
cannam@125 6555 rpath=
cannam@125 6556 xrpath=
cannam@125 6557 perm_rpath=
cannam@125 6558 temp_rpath=
cannam@125 6559 thread_safe=no
cannam@125 6560 vinfo=
cannam@125 6561 vinfo_number=no
cannam@125 6562 weak_libs=
cannam@125 6563 single_module=$wl-single_module
cannam@125 6564 func_infer_tag $base_compile
cannam@125 6565
cannam@125 6566 # We need to know -static, to get the right output filenames.
cannam@125 6567 for arg
cannam@125 6568 do
cannam@125 6569 case $arg in
cannam@125 6570 -shared)
cannam@125 6571 test yes != "$build_libtool_libs" \
cannam@125 6572 && func_fatal_configuration "cannot build a shared library"
cannam@125 6573 build_old_libs=no
cannam@125 6574 break
cannam@125 6575 ;;
cannam@125 6576 -all-static | -static | -static-libtool-libs)
cannam@125 6577 case $arg in
cannam@125 6578 -all-static)
cannam@125 6579 if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
cannam@125 6580 func_warning "complete static linking is impossible in this configuration"
cannam@125 6581 fi
cannam@125 6582 if test -n "$link_static_flag"; then
cannam@125 6583 dlopen_self=$dlopen_self_static
cannam@125 6584 fi
cannam@125 6585 prefer_static_libs=yes
cannam@125 6586 ;;
cannam@125 6587 -static)
cannam@125 6588 if test -z "$pic_flag" && test -n "$link_static_flag"; then
cannam@125 6589 dlopen_self=$dlopen_self_static
cannam@125 6590 fi
cannam@125 6591 prefer_static_libs=built
cannam@125 6592 ;;
cannam@125 6593 -static-libtool-libs)
cannam@125 6594 if test -z "$pic_flag" && test -n "$link_static_flag"; then
cannam@125 6595 dlopen_self=$dlopen_self_static
cannam@125 6596 fi
cannam@125 6597 prefer_static_libs=yes
cannam@125 6598 ;;
cannam@125 6599 esac
cannam@125 6600 build_libtool_libs=no
cannam@125 6601 build_old_libs=yes
cannam@125 6602 break
cannam@125 6603 ;;
cannam@125 6604 esac
cannam@125 6605 done
cannam@125 6606
cannam@125 6607 # See if our shared archives depend on static archives.
cannam@125 6608 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
cannam@125 6609
cannam@125 6610 # Go through the arguments, transforming them on the way.
cannam@125 6611 while test "$#" -gt 0; do
cannam@125 6612 arg=$1
cannam@125 6613 shift
cannam@125 6614 func_quote_for_eval "$arg"
cannam@125 6615 qarg=$func_quote_for_eval_unquoted_result
cannam@125 6616 func_append libtool_args " $func_quote_for_eval_result"
cannam@125 6617
cannam@125 6618 # If the previous option needs an argument, assign it.
cannam@125 6619 if test -n "$prev"; then
cannam@125 6620 case $prev in
cannam@125 6621 output)
cannam@125 6622 func_append compile_command " @OUTPUT@"
cannam@125 6623 func_append finalize_command " @OUTPUT@"
cannam@125 6624 ;;
cannam@125 6625 esac
cannam@125 6626
cannam@125 6627 case $prev in
cannam@125 6628 bindir)
cannam@125 6629 bindir=$arg
cannam@125 6630 prev=
cannam@125 6631 continue
cannam@125 6632 ;;
cannam@125 6633 dlfiles|dlprefiles)
cannam@125 6634 $preload || {
cannam@125 6635 # Add the symbol object into the linking commands.
cannam@125 6636 func_append compile_command " @SYMFILE@"
cannam@125 6637 func_append finalize_command " @SYMFILE@"
cannam@125 6638 preload=:
cannam@125 6639 }
cannam@125 6640 case $arg in
cannam@125 6641 *.la | *.lo) ;; # We handle these cases below.
cannam@125 6642 force)
cannam@125 6643 if test no = "$dlself"; then
cannam@125 6644 dlself=needless
cannam@125 6645 export_dynamic=yes
cannam@125 6646 fi
cannam@125 6647 prev=
cannam@125 6648 continue
cannam@125 6649 ;;
cannam@125 6650 self)
cannam@125 6651 if test dlprefiles = "$prev"; then
cannam@125 6652 dlself=yes
cannam@125 6653 elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
cannam@125 6654 dlself=yes
cannam@125 6655 else
cannam@125 6656 dlself=needless
cannam@125 6657 export_dynamic=yes
cannam@125 6658 fi
cannam@125 6659 prev=
cannam@125 6660 continue
cannam@125 6661 ;;
cannam@125 6662 *)
cannam@125 6663 if test dlfiles = "$prev"; then
cannam@125 6664 func_append dlfiles " $arg"
cannam@125 6665 else
cannam@125 6666 func_append dlprefiles " $arg"
cannam@125 6667 fi
cannam@125 6668 prev=
cannam@125 6669 continue
cannam@125 6670 ;;
cannam@125 6671 esac
cannam@125 6672 ;;
cannam@125 6673 expsyms)
cannam@125 6674 export_symbols=$arg
cannam@125 6675 test -f "$arg" \
cannam@125 6676 || func_fatal_error "symbol file '$arg' does not exist"
cannam@125 6677 prev=
cannam@125 6678 continue
cannam@125 6679 ;;
cannam@125 6680 expsyms_regex)
cannam@125 6681 export_symbols_regex=$arg
cannam@125 6682 prev=
cannam@125 6683 continue
cannam@125 6684 ;;
cannam@125 6685 framework)
cannam@125 6686 case $host in
cannam@125 6687 *-*-darwin*)
cannam@125 6688 case "$deplibs " in
cannam@125 6689 *" $qarg.ltframework "*) ;;
cannam@125 6690 *) func_append deplibs " $qarg.ltframework" # this is fixed later
cannam@125 6691 ;;
cannam@125 6692 esac
cannam@125 6693 ;;
cannam@125 6694 esac
cannam@125 6695 prev=
cannam@125 6696 continue
cannam@125 6697 ;;
cannam@125 6698 inst_prefix)
cannam@125 6699 inst_prefix_dir=$arg
cannam@125 6700 prev=
cannam@125 6701 continue
cannam@125 6702 ;;
cannam@125 6703 mllvm)
cannam@125 6704 # Clang does not use LLVM to link, so we can simply discard any
cannam@125 6705 # '-mllvm $arg' options when doing the link step.
cannam@125 6706 prev=
cannam@125 6707 continue
cannam@125 6708 ;;
cannam@125 6709 objectlist)
cannam@125 6710 if test -f "$arg"; then
cannam@125 6711 save_arg=$arg
cannam@125 6712 moreargs=
cannam@125 6713 for fil in `cat "$save_arg"`
cannam@125 6714 do
cannam@125 6715 # func_append moreargs " $fil"
cannam@125 6716 arg=$fil
cannam@125 6717 # A libtool-controlled object.
cannam@125 6718
cannam@125 6719 # Check to see that this really is a libtool object.
cannam@125 6720 if func_lalib_unsafe_p "$arg"; then
cannam@125 6721 pic_object=
cannam@125 6722 non_pic_object=
cannam@125 6723
cannam@125 6724 # Read the .lo file
cannam@125 6725 func_source "$arg"
cannam@125 6726
cannam@125 6727 if test -z "$pic_object" ||
cannam@125 6728 test -z "$non_pic_object" ||
cannam@125 6729 test none = "$pic_object" &&
cannam@125 6730 test none = "$non_pic_object"; then
cannam@125 6731 func_fatal_error "cannot find name of object for '$arg'"
cannam@125 6732 fi
cannam@125 6733
cannam@125 6734 # Extract subdirectory from the argument.
cannam@125 6735 func_dirname "$arg" "/" ""
cannam@125 6736 xdir=$func_dirname_result
cannam@125 6737
cannam@125 6738 if test none != "$pic_object"; then
cannam@125 6739 # Prepend the subdirectory the object is found in.
cannam@125 6740 pic_object=$xdir$pic_object
cannam@125 6741
cannam@125 6742 if test dlfiles = "$prev"; then
cannam@125 6743 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
cannam@125 6744 func_append dlfiles " $pic_object"
cannam@125 6745 prev=
cannam@125 6746 continue
cannam@125 6747 else
cannam@125 6748 # If libtool objects are unsupported, then we need to preload.
cannam@125 6749 prev=dlprefiles
cannam@125 6750 fi
cannam@125 6751 fi
cannam@125 6752
cannam@125 6753 # CHECK ME: I think I busted this. -Ossama
cannam@125 6754 if test dlprefiles = "$prev"; then
cannam@125 6755 # Preload the old-style object.
cannam@125 6756 func_append dlprefiles " $pic_object"
cannam@125 6757 prev=
cannam@125 6758 fi
cannam@125 6759
cannam@125 6760 # A PIC object.
cannam@125 6761 func_append libobjs " $pic_object"
cannam@125 6762 arg=$pic_object
cannam@125 6763 fi
cannam@125 6764
cannam@125 6765 # Non-PIC object.
cannam@125 6766 if test none != "$non_pic_object"; then
cannam@125 6767 # Prepend the subdirectory the object is found in.
cannam@125 6768 non_pic_object=$xdir$non_pic_object
cannam@125 6769
cannam@125 6770 # A standard non-PIC object
cannam@125 6771 func_append non_pic_objects " $non_pic_object"
cannam@125 6772 if test -z "$pic_object" || test none = "$pic_object"; then
cannam@125 6773 arg=$non_pic_object
cannam@125 6774 fi
cannam@125 6775 else
cannam@125 6776 # If the PIC object exists, use it instead.
cannam@125 6777 # $xdir was prepended to $pic_object above.
cannam@125 6778 non_pic_object=$pic_object
cannam@125 6779 func_append non_pic_objects " $non_pic_object"
cannam@125 6780 fi
cannam@125 6781 else
cannam@125 6782 # Only an error if not doing a dry-run.
cannam@125 6783 if $opt_dry_run; then
cannam@125 6784 # Extract subdirectory from the argument.
cannam@125 6785 func_dirname "$arg" "/" ""
cannam@125 6786 xdir=$func_dirname_result
cannam@125 6787
cannam@125 6788 func_lo2o "$arg"
cannam@125 6789 pic_object=$xdir$objdir/$func_lo2o_result
cannam@125 6790 non_pic_object=$xdir$func_lo2o_result
cannam@125 6791 func_append libobjs " $pic_object"
cannam@125 6792 func_append non_pic_objects " $non_pic_object"
cannam@125 6793 else
cannam@125 6794 func_fatal_error "'$arg' is not a valid libtool object"
cannam@125 6795 fi
cannam@125 6796 fi
cannam@125 6797 done
cannam@125 6798 else
cannam@125 6799 func_fatal_error "link input file '$arg' does not exist"
cannam@125 6800 fi
cannam@125 6801 arg=$save_arg
cannam@125 6802 prev=
cannam@125 6803 continue
cannam@125 6804 ;;
cannam@125 6805 os2dllname)
cannam@125 6806 os2dllname=$arg
cannam@125 6807 prev=
cannam@125 6808 continue
cannam@125 6809 ;;
cannam@125 6810 precious_regex)
cannam@125 6811 precious_files_regex=$arg
cannam@125 6812 prev=
cannam@125 6813 continue
cannam@125 6814 ;;
cannam@125 6815 release)
cannam@125 6816 release=-$arg
cannam@125 6817 prev=
cannam@125 6818 continue
cannam@125 6819 ;;
cannam@125 6820 rpath | xrpath)
cannam@125 6821 # We need an absolute path.
cannam@125 6822 case $arg in
cannam@125 6823 [\\/]* | [A-Za-z]:[\\/]*) ;;
cannam@125 6824 *)
cannam@125 6825 func_fatal_error "only absolute run-paths are allowed"
cannam@125 6826 ;;
cannam@125 6827 esac
cannam@125 6828 if test rpath = "$prev"; then
cannam@125 6829 case "$rpath " in
cannam@125 6830 *" $arg "*) ;;
cannam@125 6831 *) func_append rpath " $arg" ;;
cannam@125 6832 esac
cannam@125 6833 else
cannam@125 6834 case "$xrpath " in
cannam@125 6835 *" $arg "*) ;;
cannam@125 6836 *) func_append xrpath " $arg" ;;
cannam@125 6837 esac
cannam@125 6838 fi
cannam@125 6839 prev=
cannam@125 6840 continue
cannam@125 6841 ;;
cannam@125 6842 shrext)
cannam@125 6843 shrext_cmds=$arg
cannam@125 6844 prev=
cannam@125 6845 continue
cannam@125 6846 ;;
cannam@125 6847 weak)
cannam@125 6848 func_append weak_libs " $arg"
cannam@125 6849 prev=
cannam@125 6850 continue
cannam@125 6851 ;;
cannam@125 6852 xcclinker)
cannam@125 6853 func_append linker_flags " $qarg"
cannam@125 6854 func_append compiler_flags " $qarg"
cannam@125 6855 prev=
cannam@125 6856 func_append compile_command " $qarg"
cannam@125 6857 func_append finalize_command " $qarg"
cannam@125 6858 continue
cannam@125 6859 ;;
cannam@125 6860 xcompiler)
cannam@125 6861 func_append compiler_flags " $qarg"
cannam@125 6862 prev=
cannam@125 6863 func_append compile_command " $qarg"
cannam@125 6864 func_append finalize_command " $qarg"
cannam@125 6865 continue
cannam@125 6866 ;;
cannam@125 6867 xlinker)
cannam@125 6868 func_append linker_flags " $qarg"
cannam@125 6869 func_append compiler_flags " $wl$qarg"
cannam@125 6870 prev=
cannam@125 6871 func_append compile_command " $wl$qarg"
cannam@125 6872 func_append finalize_command " $wl$qarg"
cannam@125 6873 continue
cannam@125 6874 ;;
cannam@125 6875 *)
cannam@125 6876 eval "$prev=\"\$arg\""
cannam@125 6877 prev=
cannam@125 6878 continue
cannam@125 6879 ;;
cannam@125 6880 esac
cannam@125 6881 fi # test -n "$prev"
cannam@125 6882
cannam@125 6883 prevarg=$arg
cannam@125 6884
cannam@125 6885 case $arg in
cannam@125 6886 -all-static)
cannam@125 6887 if test -n "$link_static_flag"; then
cannam@125 6888 # See comment for -static flag below, for more details.
cannam@125 6889 func_append compile_command " $link_static_flag"
cannam@125 6890 func_append finalize_command " $link_static_flag"
cannam@125 6891 fi
cannam@125 6892 continue
cannam@125 6893 ;;
cannam@125 6894
cannam@125 6895 -allow-undefined)
cannam@125 6896 # FIXME: remove this flag sometime in the future.
cannam@125 6897 func_fatal_error "'-allow-undefined' must not be used because it is the default"
cannam@125 6898 ;;
cannam@125 6899
cannam@125 6900 -avoid-version)
cannam@125 6901 avoid_version=yes
cannam@125 6902 continue
cannam@125 6903 ;;
cannam@125 6904
cannam@125 6905 -bindir)
cannam@125 6906 prev=bindir
cannam@125 6907 continue
cannam@125 6908 ;;
cannam@125 6909
cannam@125 6910 -dlopen)
cannam@125 6911 prev=dlfiles
cannam@125 6912 continue
cannam@125 6913 ;;
cannam@125 6914
cannam@125 6915 -dlpreopen)
cannam@125 6916 prev=dlprefiles
cannam@125 6917 continue
cannam@125 6918 ;;
cannam@125 6919
cannam@125 6920 -export-dynamic)
cannam@125 6921 export_dynamic=yes
cannam@125 6922 continue
cannam@125 6923 ;;
cannam@125 6924
cannam@125 6925 -export-symbols | -export-symbols-regex)
cannam@125 6926 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
cannam@125 6927 func_fatal_error "more than one -exported-symbols argument is not allowed"
cannam@125 6928 fi
cannam@125 6929 if test X-export-symbols = "X$arg"; then
cannam@125 6930 prev=expsyms
cannam@125 6931 else
cannam@125 6932 prev=expsyms_regex
cannam@125 6933 fi
cannam@125 6934 continue
cannam@125 6935 ;;
cannam@125 6936
cannam@125 6937 -framework)
cannam@125 6938 prev=framework
cannam@125 6939 continue
cannam@125 6940 ;;
cannam@125 6941
cannam@125 6942 -inst-prefix-dir)
cannam@125 6943 prev=inst_prefix
cannam@125 6944 continue
cannam@125 6945 ;;
cannam@125 6946
cannam@125 6947 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
cannam@125 6948 # so, if we see these flags be careful not to treat them like -L
cannam@125 6949 -L[A-Z][A-Z]*:*)
cannam@125 6950 case $with_gcc/$host in
cannam@125 6951 no/*-*-irix* | /*-*-irix*)
cannam@125 6952 func_append compile_command " $arg"
cannam@125 6953 func_append finalize_command " $arg"
cannam@125 6954 ;;
cannam@125 6955 esac
cannam@125 6956 continue
cannam@125 6957 ;;
cannam@125 6958
cannam@125 6959 -L*)
cannam@125 6960 func_stripname "-L" '' "$arg"
cannam@125 6961 if test -z "$func_stripname_result"; then
cannam@125 6962 if test "$#" -gt 0; then
cannam@125 6963 func_fatal_error "require no space between '-L' and '$1'"
cannam@125 6964 else
cannam@125 6965 func_fatal_error "need path for '-L' option"
cannam@125 6966 fi
cannam@125 6967 fi
cannam@125 6968 func_resolve_sysroot "$func_stripname_result"
cannam@125 6969 dir=$func_resolve_sysroot_result
cannam@125 6970 # We need an absolute path.
cannam@125 6971 case $dir in
cannam@125 6972 [\\/]* | [A-Za-z]:[\\/]*) ;;
cannam@125 6973 *)
cannam@125 6974 absdir=`cd "$dir" && pwd`
cannam@125 6975 test -z "$absdir" && \
cannam@125 6976 func_fatal_error "cannot determine absolute directory name of '$dir'"
cannam@125 6977 dir=$absdir
cannam@125 6978 ;;
cannam@125 6979 esac
cannam@125 6980 case "$deplibs " in
cannam@125 6981 *" -L$dir "* | *" $arg "*)
cannam@125 6982 # Will only happen for absolute or sysroot arguments
cannam@125 6983 ;;
cannam@125 6984 *)
cannam@125 6985 # Preserve sysroot, but never include relative directories
cannam@125 6986 case $dir in
cannam@125 6987 [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
cannam@125 6988 *) func_append deplibs " -L$dir" ;;
cannam@125 6989 esac
cannam@125 6990 func_append lib_search_path " $dir"
cannam@125 6991 ;;
cannam@125 6992 esac
cannam@125 6993 case $host in
cannam@125 6994 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
cannam@125 6995 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
cannam@125 6996 case :$dllsearchpath: in
cannam@125 6997 *":$dir:"*) ;;
cannam@125 6998 ::) dllsearchpath=$dir;;
cannam@125 6999 *) func_append dllsearchpath ":$dir";;
cannam@125 7000 esac
cannam@125 7001 case :$dllsearchpath: in
cannam@125 7002 *":$testbindir:"*) ;;
cannam@125 7003 ::) dllsearchpath=$testbindir;;
cannam@125 7004 *) func_append dllsearchpath ":$testbindir";;
cannam@125 7005 esac
cannam@125 7006 ;;
cannam@125 7007 esac
cannam@125 7008 continue
cannam@125 7009 ;;
cannam@125 7010
cannam@125 7011 -l*)
cannam@125 7012 if test X-lc = "X$arg" || test X-lm = "X$arg"; then
cannam@125 7013 case $host in
cannam@125 7014 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
cannam@125 7015 # These systems don't actually have a C or math library (as such)
cannam@125 7016 continue
cannam@125 7017 ;;
cannam@125 7018 *-*-os2*)
cannam@125 7019 # These systems don't actually have a C library (as such)
cannam@125 7020 test X-lc = "X$arg" && continue
cannam@125 7021 ;;
cannam@125 7022 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
cannam@125 7023 # Do not include libc due to us having libc/libc_r.
cannam@125 7024 test X-lc = "X$arg" && continue
cannam@125 7025 ;;
cannam@125 7026 *-*-rhapsody* | *-*-darwin1.[012])
cannam@125 7027 # Rhapsody C and math libraries are in the System framework
cannam@125 7028 func_append deplibs " System.ltframework"
cannam@125 7029 continue
cannam@125 7030 ;;
cannam@125 7031 *-*-sco3.2v5* | *-*-sco5v6*)
cannam@125 7032 # Causes problems with __ctype
cannam@125 7033 test X-lc = "X$arg" && continue
cannam@125 7034 ;;
cannam@125 7035 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
cannam@125 7036 # Compiler inserts libc in the correct place for threads to work
cannam@125 7037 test X-lc = "X$arg" && continue
cannam@125 7038 ;;
cannam@125 7039 esac
cannam@125 7040 elif test X-lc_r = "X$arg"; then
cannam@125 7041 case $host in
cannam@125 7042 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
cannam@125 7043 # Do not include libc_r directly, use -pthread flag.
cannam@125 7044 continue
cannam@125 7045 ;;
cannam@125 7046 esac
cannam@125 7047 fi
cannam@125 7048 func_append deplibs " $arg"
cannam@125 7049 continue
cannam@125 7050 ;;
cannam@125 7051
cannam@125 7052 -mllvm)
cannam@125 7053 prev=mllvm
cannam@125 7054 continue
cannam@125 7055 ;;
cannam@125 7056
cannam@125 7057 -module)
cannam@125 7058 module=yes
cannam@125 7059 continue
cannam@125 7060 ;;
cannam@125 7061
cannam@125 7062 # Tru64 UNIX uses -model [arg] to determine the layout of C++
cannam@125 7063 # classes, name mangling, and exception handling.
cannam@125 7064 # Darwin uses the -arch flag to determine output architecture.
cannam@125 7065 -model|-arch|-isysroot|--sysroot)
cannam@125 7066 func_append compiler_flags " $arg"
cannam@125 7067 func_append compile_command " $arg"
cannam@125 7068 func_append finalize_command " $arg"
cannam@125 7069 prev=xcompiler
cannam@125 7070 continue
cannam@125 7071 ;;
cannam@125 7072
cannam@125 7073 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
cannam@125 7074 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
cannam@125 7075 func_append compiler_flags " $arg"
cannam@125 7076 func_append compile_command " $arg"
cannam@125 7077 func_append finalize_command " $arg"
cannam@125 7078 case "$new_inherited_linker_flags " in
cannam@125 7079 *" $arg "*) ;;
cannam@125 7080 * ) func_append new_inherited_linker_flags " $arg" ;;
cannam@125 7081 esac
cannam@125 7082 continue
cannam@125 7083 ;;
cannam@125 7084
cannam@125 7085 -multi_module)
cannam@125 7086 single_module=$wl-multi_module
cannam@125 7087 continue
cannam@125 7088 ;;
cannam@125 7089
cannam@125 7090 -no-fast-install)
cannam@125 7091 fast_install=no
cannam@125 7092 continue
cannam@125 7093 ;;
cannam@125 7094
cannam@125 7095 -no-install)
cannam@125 7096 case $host in
cannam@125 7097 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
cannam@125 7098 # The PATH hackery in wrapper scripts is required on Windows
cannam@125 7099 # and Darwin in order for the loader to find any dlls it needs.
cannam@125 7100 func_warning "'-no-install' is ignored for $host"
cannam@125 7101 func_warning "assuming '-no-fast-install' instead"
cannam@125 7102 fast_install=no
cannam@125 7103 ;;
cannam@125 7104 *) no_install=yes ;;
cannam@125 7105 esac
cannam@125 7106 continue
cannam@125 7107 ;;
cannam@125 7108
cannam@125 7109 -no-undefined)
cannam@125 7110 allow_undefined=no
cannam@125 7111 continue
cannam@125 7112 ;;
cannam@125 7113
cannam@125 7114 -objectlist)
cannam@125 7115 prev=objectlist
cannam@125 7116 continue
cannam@125 7117 ;;
cannam@125 7118
cannam@125 7119 -os2dllname)
cannam@125 7120 prev=os2dllname
cannam@125 7121 continue
cannam@125 7122 ;;
cannam@125 7123
cannam@125 7124 -o) prev=output ;;
cannam@125 7125
cannam@125 7126 -precious-files-regex)
cannam@125 7127 prev=precious_regex
cannam@125 7128 continue
cannam@125 7129 ;;
cannam@125 7130
cannam@125 7131 -release)
cannam@125 7132 prev=release
cannam@125 7133 continue
cannam@125 7134 ;;
cannam@125 7135
cannam@125 7136 -rpath)
cannam@125 7137 prev=rpath
cannam@125 7138 continue
cannam@125 7139 ;;
cannam@125 7140
cannam@125 7141 -R)
cannam@125 7142 prev=xrpath
cannam@125 7143 continue
cannam@125 7144 ;;
cannam@125 7145
cannam@125 7146 -R*)
cannam@125 7147 func_stripname '-R' '' "$arg"
cannam@125 7148 dir=$func_stripname_result
cannam@125 7149 # We need an absolute path.
cannam@125 7150 case $dir in
cannam@125 7151 [\\/]* | [A-Za-z]:[\\/]*) ;;
cannam@125 7152 =*)
cannam@125 7153 func_stripname '=' '' "$dir"
cannam@125 7154 dir=$lt_sysroot$func_stripname_result
cannam@125 7155 ;;
cannam@125 7156 *)
cannam@125 7157 func_fatal_error "only absolute run-paths are allowed"
cannam@125 7158 ;;
cannam@125 7159 esac
cannam@125 7160 case "$xrpath " in
cannam@125 7161 *" $dir "*) ;;
cannam@125 7162 *) func_append xrpath " $dir" ;;
cannam@125 7163 esac
cannam@125 7164 continue
cannam@125 7165 ;;
cannam@125 7166
cannam@125 7167 -shared)
cannam@125 7168 # The effects of -shared are defined in a previous loop.
cannam@125 7169 continue
cannam@125 7170 ;;
cannam@125 7171
cannam@125 7172 -shrext)
cannam@125 7173 prev=shrext
cannam@125 7174 continue
cannam@125 7175 ;;
cannam@125 7176
cannam@125 7177 -static | -static-libtool-libs)
cannam@125 7178 # The effects of -static are defined in a previous loop.
cannam@125 7179 # We used to do the same as -all-static on platforms that
cannam@125 7180 # didn't have a PIC flag, but the assumption that the effects
cannam@125 7181 # would be equivalent was wrong. It would break on at least
cannam@125 7182 # Digital Unix and AIX.
cannam@125 7183 continue
cannam@125 7184 ;;
cannam@125 7185
cannam@125 7186 -thread-safe)
cannam@125 7187 thread_safe=yes
cannam@125 7188 continue
cannam@125 7189 ;;
cannam@125 7190
cannam@125 7191 -version-info)
cannam@125 7192 prev=vinfo
cannam@125 7193 continue
cannam@125 7194 ;;
cannam@125 7195
cannam@125 7196 -version-number)
cannam@125 7197 prev=vinfo
cannam@125 7198 vinfo_number=yes
cannam@125 7199 continue
cannam@125 7200 ;;
cannam@125 7201
cannam@125 7202 -weak)
cannam@125 7203 prev=weak
cannam@125 7204 continue
cannam@125 7205 ;;
cannam@125 7206
cannam@125 7207 -Wc,*)
cannam@125 7208 func_stripname '-Wc,' '' "$arg"
cannam@125 7209 args=$func_stripname_result
cannam@125 7210 arg=
cannam@125 7211 save_ifs=$IFS; IFS=,
cannam@125 7212 for flag in $args; do
cannam@125 7213 IFS=$save_ifs
cannam@125 7214 func_quote_for_eval "$flag"
cannam@125 7215 func_append arg " $func_quote_for_eval_result"
cannam@125 7216 func_append compiler_flags " $func_quote_for_eval_result"
cannam@125 7217 done
cannam@125 7218 IFS=$save_ifs
cannam@125 7219 func_stripname ' ' '' "$arg"
cannam@125 7220 arg=$func_stripname_result
cannam@125 7221 ;;
cannam@125 7222
cannam@125 7223 -Wl,*)
cannam@125 7224 func_stripname '-Wl,' '' "$arg"
cannam@125 7225 args=$func_stripname_result
cannam@125 7226 arg=
cannam@125 7227 save_ifs=$IFS; IFS=,
cannam@125 7228 for flag in $args; do
cannam@125 7229 IFS=$save_ifs
cannam@125 7230 func_quote_for_eval "$flag"
cannam@125 7231 func_append arg " $wl$func_quote_for_eval_result"
cannam@125 7232 func_append compiler_flags " $wl$func_quote_for_eval_result"
cannam@125 7233 func_append linker_flags " $func_quote_for_eval_result"
cannam@125 7234 done
cannam@125 7235 IFS=$save_ifs
cannam@125 7236 func_stripname ' ' '' "$arg"
cannam@125 7237 arg=$func_stripname_result
cannam@125 7238 ;;
cannam@125 7239
cannam@125 7240 -Xcompiler)
cannam@125 7241 prev=xcompiler
cannam@125 7242 continue
cannam@125 7243 ;;
cannam@125 7244
cannam@125 7245 -Xlinker)
cannam@125 7246 prev=xlinker
cannam@125 7247 continue
cannam@125 7248 ;;
cannam@125 7249
cannam@125 7250 -XCClinker)
cannam@125 7251 prev=xcclinker
cannam@125 7252 continue
cannam@125 7253 ;;
cannam@125 7254
cannam@125 7255 # -msg_* for osf cc
cannam@125 7256 -msg_*)
cannam@125 7257 func_quote_for_eval "$arg"
cannam@125 7258 arg=$func_quote_for_eval_result
cannam@125 7259 ;;
cannam@125 7260
cannam@125 7261 # Flags to be passed through unchanged, with rationale:
cannam@125 7262 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
cannam@125 7263 # -r[0-9][0-9]* specify processor for the SGI compiler
cannam@125 7264 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
cannam@125 7265 # +DA*, +DD* enable 64-bit mode for the HP compiler
cannam@125 7266 # -q* compiler args for the IBM compiler
cannam@125 7267 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
cannam@125 7268 # -F/path path to uninstalled frameworks, gcc on darwin
cannam@125 7269 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
cannam@125 7270 # -fstack-protector* stack protector flags for GCC
cannam@125 7271 # @file GCC response files
cannam@125 7272 # -tp=* Portland pgcc target processor selection
cannam@125 7273 # --sysroot=* for sysroot support
cannam@125 7274 # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
cannam@125 7275 # -specs=* GCC specs files
cannam@125 7276 # -stdlib=* select c++ std lib with clang
cannam@125 7277 # -fsanitize=* Clang/GCC memory and address sanitizer
cannam@125 7278 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
cannam@125 7279 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
cannam@125 7280 -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
cannam@125 7281 -specs=*|-fsanitize=*)
cannam@125 7282 func_quote_for_eval "$arg"
cannam@125 7283 arg=$func_quote_for_eval_result
cannam@125 7284 func_append compile_command " $arg"
cannam@125 7285 func_append finalize_command " $arg"
cannam@125 7286 func_append compiler_flags " $arg"
cannam@125 7287 continue
cannam@125 7288 ;;
cannam@125 7289
cannam@125 7290 -Z*)
cannam@125 7291 if test os2 = "`expr $host : '.*\(os2\)'`"; then
cannam@125 7292 # OS/2 uses -Zxxx to specify OS/2-specific options
cannam@125 7293 compiler_flags="$compiler_flags $arg"
cannam@125 7294 func_append compile_command " $arg"
cannam@125 7295 func_append finalize_command " $arg"
cannam@125 7296 case $arg in
cannam@125 7297 -Zlinker | -Zstack)
cannam@125 7298 prev=xcompiler
cannam@125 7299 ;;
cannam@125 7300 esac
cannam@125 7301 continue
cannam@125 7302 else
cannam@125 7303 # Otherwise treat like 'Some other compiler flag' below
cannam@125 7304 func_quote_for_eval "$arg"
cannam@125 7305 arg=$func_quote_for_eval_result
cannam@125 7306 fi
cannam@125 7307 ;;
cannam@125 7308
cannam@125 7309 # Some other compiler flag.
cannam@125 7310 -* | +*)
cannam@125 7311 func_quote_for_eval "$arg"
cannam@125 7312 arg=$func_quote_for_eval_result
cannam@125 7313 ;;
cannam@125 7314
cannam@125 7315 *.$objext)
cannam@125 7316 # A standard object.
cannam@125 7317 func_append objs " $arg"
cannam@125 7318 ;;
cannam@125 7319
cannam@125 7320 *.lo)
cannam@125 7321 # A libtool-controlled object.
cannam@125 7322
cannam@125 7323 # Check to see that this really is a libtool object.
cannam@125 7324 if func_lalib_unsafe_p "$arg"; then
cannam@125 7325 pic_object=
cannam@125 7326 non_pic_object=
cannam@125 7327
cannam@125 7328 # Read the .lo file
cannam@125 7329 func_source "$arg"
cannam@125 7330
cannam@125 7331 if test -z "$pic_object" ||
cannam@125 7332 test -z "$non_pic_object" ||
cannam@125 7333 test none = "$pic_object" &&
cannam@125 7334 test none = "$non_pic_object"; then
cannam@125 7335 func_fatal_error "cannot find name of object for '$arg'"
cannam@125 7336 fi
cannam@125 7337
cannam@125 7338 # Extract subdirectory from the argument.
cannam@125 7339 func_dirname "$arg" "/" ""
cannam@125 7340 xdir=$func_dirname_result
cannam@125 7341
cannam@125 7342 test none = "$pic_object" || {
cannam@125 7343 # Prepend the subdirectory the object is found in.
cannam@125 7344 pic_object=$xdir$pic_object
cannam@125 7345
cannam@125 7346 if test dlfiles = "$prev"; then
cannam@125 7347 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
cannam@125 7348 func_append dlfiles " $pic_object"
cannam@125 7349 prev=
cannam@125 7350 continue
cannam@125 7351 else
cannam@125 7352 # If libtool objects are unsupported, then we need to preload.
cannam@125 7353 prev=dlprefiles
cannam@125 7354 fi
cannam@125 7355 fi
cannam@125 7356
cannam@125 7357 # CHECK ME: I think I busted this. -Ossama
cannam@125 7358 if test dlprefiles = "$prev"; then
cannam@125 7359 # Preload the old-style object.
cannam@125 7360 func_append dlprefiles " $pic_object"
cannam@125 7361 prev=
cannam@125 7362 fi
cannam@125 7363
cannam@125 7364 # A PIC object.
cannam@125 7365 func_append libobjs " $pic_object"
cannam@125 7366 arg=$pic_object
cannam@125 7367 }
cannam@125 7368
cannam@125 7369 # Non-PIC object.
cannam@125 7370 if test none != "$non_pic_object"; then
cannam@125 7371 # Prepend the subdirectory the object is found in.
cannam@125 7372 non_pic_object=$xdir$non_pic_object
cannam@125 7373
cannam@125 7374 # A standard non-PIC object
cannam@125 7375 func_append non_pic_objects " $non_pic_object"
cannam@125 7376 if test -z "$pic_object" || test none = "$pic_object"; then
cannam@125 7377 arg=$non_pic_object
cannam@125 7378 fi
cannam@125 7379 else
cannam@125 7380 # If the PIC object exists, use it instead.
cannam@125 7381 # $xdir was prepended to $pic_object above.
cannam@125 7382 non_pic_object=$pic_object
cannam@125 7383 func_append non_pic_objects " $non_pic_object"
cannam@125 7384 fi
cannam@125 7385 else
cannam@125 7386 # Only an error if not doing a dry-run.
cannam@125 7387 if $opt_dry_run; then
cannam@125 7388 # Extract subdirectory from the argument.
cannam@125 7389 func_dirname "$arg" "/" ""
cannam@125 7390 xdir=$func_dirname_result
cannam@125 7391
cannam@125 7392 func_lo2o "$arg"
cannam@125 7393 pic_object=$xdir$objdir/$func_lo2o_result
cannam@125 7394 non_pic_object=$xdir$func_lo2o_result
cannam@125 7395 func_append libobjs " $pic_object"
cannam@125 7396 func_append non_pic_objects " $non_pic_object"
cannam@125 7397 else
cannam@125 7398 func_fatal_error "'$arg' is not a valid libtool object"
cannam@125 7399 fi
cannam@125 7400 fi
cannam@125 7401 ;;
cannam@125 7402
cannam@125 7403 *.$libext)
cannam@125 7404 # An archive.
cannam@125 7405 func_append deplibs " $arg"
cannam@125 7406 func_append old_deplibs " $arg"
cannam@125 7407 continue
cannam@125 7408 ;;
cannam@125 7409
cannam@125 7410 *.la)
cannam@125 7411 # A libtool-controlled library.
cannam@125 7412
cannam@125 7413 func_resolve_sysroot "$arg"
cannam@125 7414 if test dlfiles = "$prev"; then
cannam@125 7415 # This library was specified with -dlopen.
cannam@125 7416 func_append dlfiles " $func_resolve_sysroot_result"
cannam@125 7417 prev=
cannam@125 7418 elif test dlprefiles = "$prev"; then
cannam@125 7419 # The library was specified with -dlpreopen.
cannam@125 7420 func_append dlprefiles " $func_resolve_sysroot_result"
cannam@125 7421 prev=
cannam@125 7422 else
cannam@125 7423 func_append deplibs " $func_resolve_sysroot_result"
cannam@125 7424 fi
cannam@125 7425 continue
cannam@125 7426 ;;
cannam@125 7427
cannam@125 7428 # Some other compiler argument.
cannam@125 7429 *)
cannam@125 7430 # Unknown arguments in both finalize_command and compile_command need
cannam@125 7431 # to be aesthetically quoted because they are evaled later.
cannam@125 7432 func_quote_for_eval "$arg"
cannam@125 7433 arg=$func_quote_for_eval_result
cannam@125 7434 ;;
cannam@125 7435 esac # arg
cannam@125 7436
cannam@125 7437 # Now actually substitute the argument into the commands.
cannam@125 7438 if test -n "$arg"; then
cannam@125 7439 func_append compile_command " $arg"
cannam@125 7440 func_append finalize_command " $arg"
cannam@125 7441 fi
cannam@125 7442 done # argument parsing loop
cannam@125 7443
cannam@125 7444 test -n "$prev" && \
cannam@125 7445 func_fatal_help "the '$prevarg' option requires an argument"
cannam@125 7446
cannam@125 7447 if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
cannam@125 7448 eval arg=\"$export_dynamic_flag_spec\"
cannam@125 7449 func_append compile_command " $arg"
cannam@125 7450 func_append finalize_command " $arg"
cannam@125 7451 fi
cannam@125 7452
cannam@125 7453 oldlibs=
cannam@125 7454 # calculate the name of the file, without its directory
cannam@125 7455 func_basename "$output"
cannam@125 7456 outputname=$func_basename_result
cannam@125 7457 libobjs_save=$libobjs
cannam@125 7458
cannam@125 7459 if test -n "$shlibpath_var"; then
cannam@125 7460 # get the directories listed in $shlibpath_var
cannam@125 7461 eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
cannam@125 7462 else
cannam@125 7463 shlib_search_path=
cannam@125 7464 fi
cannam@125 7465 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
cannam@125 7466 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
cannam@125 7467
cannam@125 7468 # Definition is injected by LT_CONFIG during libtool generation.
cannam@125 7469 func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
cannam@125 7470
cannam@125 7471 func_dirname "$output" "/" ""
cannam@125 7472 output_objdir=$func_dirname_result$objdir
cannam@125 7473 func_to_tool_file "$output_objdir/"
cannam@125 7474 tool_output_objdir=$func_to_tool_file_result
cannam@125 7475 # Create the object directory.
cannam@125 7476 func_mkdir_p "$output_objdir"
cannam@125 7477
cannam@125 7478 # Determine the type of output
cannam@125 7479 case $output in
cannam@125 7480 "")
cannam@125 7481 func_fatal_help "you must specify an output file"
cannam@125 7482 ;;
cannam@125 7483 *.$libext) linkmode=oldlib ;;
cannam@125 7484 *.lo | *.$objext) linkmode=obj ;;
cannam@125 7485 *.la) linkmode=lib ;;
cannam@125 7486 *) linkmode=prog ;; # Anything else should be a program.
cannam@125 7487 esac
cannam@125 7488
cannam@125 7489 specialdeplibs=
cannam@125 7490
cannam@125 7491 libs=
cannam@125 7492 # Find all interdependent deplibs by searching for libraries
cannam@125 7493 # that are linked more than once (e.g. -la -lb -la)
cannam@125 7494 for deplib in $deplibs; do
cannam@125 7495 if $opt_preserve_dup_deps; then
cannam@125 7496 case "$libs " in
cannam@125 7497 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
cannam@125 7498 esac
cannam@125 7499 fi
cannam@125 7500 func_append libs " $deplib"
cannam@125 7501 done
cannam@125 7502
cannam@125 7503 if test lib = "$linkmode"; then
cannam@125 7504 libs="$predeps $libs $compiler_lib_search_path $postdeps"
cannam@125 7505
cannam@125 7506 # Compute libraries that are listed more than once in $predeps
cannam@125 7507 # $postdeps and mark them as special (i.e., whose duplicates are
cannam@125 7508 # not to be eliminated).
cannam@125 7509 pre_post_deps=
cannam@125 7510 if $opt_duplicate_compiler_generated_deps; then
cannam@125 7511 for pre_post_dep in $predeps $postdeps; do
cannam@125 7512 case "$pre_post_deps " in
cannam@125 7513 *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
cannam@125 7514 esac
cannam@125 7515 func_append pre_post_deps " $pre_post_dep"
cannam@125 7516 done
cannam@125 7517 fi
cannam@125 7518 pre_post_deps=
cannam@125 7519 fi
cannam@125 7520
cannam@125 7521 deplibs=
cannam@125 7522 newdependency_libs=
cannam@125 7523 newlib_search_path=
cannam@125 7524 need_relink=no # whether we're linking any uninstalled libtool libraries
cannam@125 7525 notinst_deplibs= # not-installed libtool libraries
cannam@125 7526 notinst_path= # paths that contain not-installed libtool libraries
cannam@125 7527
cannam@125 7528 case $linkmode in
cannam@125 7529 lib)
cannam@125 7530 passes="conv dlpreopen link"
cannam@125 7531 for file in $dlfiles $dlprefiles; do
cannam@125 7532 case $file in
cannam@125 7533 *.la) ;;
cannam@125 7534 *)
cannam@125 7535 func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
cannam@125 7536 ;;
cannam@125 7537 esac
cannam@125 7538 done
cannam@125 7539 ;;
cannam@125 7540 prog)
cannam@125 7541 compile_deplibs=
cannam@125 7542 finalize_deplibs=
cannam@125 7543 alldeplibs=false
cannam@125 7544 newdlfiles=
cannam@125 7545 newdlprefiles=
cannam@125 7546 passes="conv scan dlopen dlpreopen link"
cannam@125 7547 ;;
cannam@125 7548 *) passes="conv"
cannam@125 7549 ;;
cannam@125 7550 esac
cannam@125 7551
cannam@125 7552 for pass in $passes; do
cannam@125 7553 # The preopen pass in lib mode reverses $deplibs; put it back here
cannam@125 7554 # so that -L comes before libs that need it for instance...
cannam@125 7555 if test lib,link = "$linkmode,$pass"; then
cannam@125 7556 ## FIXME: Find the place where the list is rebuilt in the wrong
cannam@125 7557 ## order, and fix it there properly
cannam@125 7558 tmp_deplibs=
cannam@125 7559 for deplib in $deplibs; do
cannam@125 7560 tmp_deplibs="$deplib $tmp_deplibs"
cannam@125 7561 done
cannam@125 7562 deplibs=$tmp_deplibs
cannam@125 7563 fi
cannam@125 7564
cannam@125 7565 if test lib,link = "$linkmode,$pass" ||
cannam@125 7566 test prog,scan = "$linkmode,$pass"; then
cannam@125 7567 libs=$deplibs
cannam@125 7568 deplibs=
cannam@125 7569 fi
cannam@125 7570 if test prog = "$linkmode"; then
cannam@125 7571 case $pass in
cannam@125 7572 dlopen) libs=$dlfiles ;;
cannam@125 7573 dlpreopen) libs=$dlprefiles ;;
cannam@125 7574 link)
cannam@125 7575 libs="$deplibs %DEPLIBS%"
cannam@125 7576 test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
cannam@125 7577 ;;
cannam@125 7578 esac
cannam@125 7579 fi
cannam@125 7580 if test lib,dlpreopen = "$linkmode,$pass"; then
cannam@125 7581 # Collect and forward deplibs of preopened libtool libs
cannam@125 7582 for lib in $dlprefiles; do
cannam@125 7583 # Ignore non-libtool-libs
cannam@125 7584 dependency_libs=
cannam@125 7585 func_resolve_sysroot "$lib"
cannam@125 7586 case $lib in
cannam@125 7587 *.la) func_source "$func_resolve_sysroot_result" ;;
cannam@125 7588 esac
cannam@125 7589
cannam@125 7590 # Collect preopened libtool deplibs, except any this library
cannam@125 7591 # has declared as weak libs
cannam@125 7592 for deplib in $dependency_libs; do
cannam@125 7593 func_basename "$deplib"
cannam@125 7594 deplib_base=$func_basename_result
cannam@125 7595 case " $weak_libs " in
cannam@125 7596 *" $deplib_base "*) ;;
cannam@125 7597 *) func_append deplibs " $deplib" ;;
cannam@125 7598 esac
cannam@125 7599 done
cannam@125 7600 done
cannam@125 7601 libs=$dlprefiles
cannam@125 7602 fi
cannam@125 7603 if test dlopen = "$pass"; then
cannam@125 7604 # Collect dlpreopened libraries
cannam@125 7605 save_deplibs=$deplibs
cannam@125 7606 deplibs=
cannam@125 7607 fi
cannam@125 7608
cannam@125 7609 for deplib in $libs; do
cannam@125 7610 lib=
cannam@125 7611 found=false
cannam@125 7612 case $deplib in
cannam@125 7613 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
cannam@125 7614 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
cannam@125 7615 if test prog,link = "$linkmode,$pass"; then
cannam@125 7616 compile_deplibs="$deplib $compile_deplibs"
cannam@125 7617 finalize_deplibs="$deplib $finalize_deplibs"
cannam@125 7618 else
cannam@125 7619 func_append compiler_flags " $deplib"
cannam@125 7620 if test lib = "$linkmode"; then
cannam@125 7621 case "$new_inherited_linker_flags " in
cannam@125 7622 *" $deplib "*) ;;
cannam@125 7623 * ) func_append new_inherited_linker_flags " $deplib" ;;
cannam@125 7624 esac
cannam@125 7625 fi
cannam@125 7626 fi
cannam@125 7627 continue
cannam@125 7628 ;;
cannam@125 7629 -l*)
cannam@125 7630 if test lib != "$linkmode" && test prog != "$linkmode"; then
cannam@125 7631 func_warning "'-l' is ignored for archives/objects"
cannam@125 7632 continue
cannam@125 7633 fi
cannam@125 7634 func_stripname '-l' '' "$deplib"
cannam@125 7635 name=$func_stripname_result
cannam@125 7636 if test lib = "$linkmode"; then
cannam@125 7637 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
cannam@125 7638 else
cannam@125 7639 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
cannam@125 7640 fi
cannam@125 7641 for searchdir in $searchdirs; do
cannam@125 7642 for search_ext in .la $std_shrext .so .a; do
cannam@125 7643 # Search the libtool library
cannam@125 7644 lib=$searchdir/lib$name$search_ext
cannam@125 7645 if test -f "$lib"; then
cannam@125 7646 if test .la = "$search_ext"; then
cannam@125 7647 found=:
cannam@125 7648 else
cannam@125 7649 found=false
cannam@125 7650 fi
cannam@125 7651 break 2
cannam@125 7652 fi
cannam@125 7653 done
cannam@125 7654 done
cannam@125 7655 if $found; then
cannam@125 7656 # deplib is a libtool library
cannam@125 7657 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
cannam@125 7658 # We need to do some special things here, and not later.
cannam@125 7659 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@125 7660 case " $predeps $postdeps " in
cannam@125 7661 *" $deplib "*)
cannam@125 7662 if func_lalib_p "$lib"; then
cannam@125 7663 library_names=
cannam@125 7664 old_library=
cannam@125 7665 func_source "$lib"
cannam@125 7666 for l in $old_library $library_names; do
cannam@125 7667 ll=$l
cannam@125 7668 done
cannam@125 7669 if test "X$ll" = "X$old_library"; then # only static version available
cannam@125 7670 found=false
cannam@125 7671 func_dirname "$lib" "" "."
cannam@125 7672 ladir=$func_dirname_result
cannam@125 7673 lib=$ladir/$old_library
cannam@125 7674 if test prog,link = "$linkmode,$pass"; then
cannam@125 7675 compile_deplibs="$deplib $compile_deplibs"
cannam@125 7676 finalize_deplibs="$deplib $finalize_deplibs"
cannam@125 7677 else
cannam@125 7678 deplibs="$deplib $deplibs"
cannam@125 7679 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
cannam@125 7680 fi
cannam@125 7681 continue
cannam@125 7682 fi
cannam@125 7683 fi
cannam@125 7684 ;;
cannam@125 7685 *) ;;
cannam@125 7686 esac
cannam@125 7687 fi
cannam@125 7688 else
cannam@125 7689 # deplib doesn't seem to be a libtool library
cannam@125 7690 if test prog,link = "$linkmode,$pass"; then
cannam@125 7691 compile_deplibs="$deplib $compile_deplibs"
cannam@125 7692 finalize_deplibs="$deplib $finalize_deplibs"
cannam@125 7693 else
cannam@125 7694 deplibs="$deplib $deplibs"
cannam@125 7695 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
cannam@125 7696 fi
cannam@125 7697 continue
cannam@125 7698 fi
cannam@125 7699 ;; # -l
cannam@125 7700 *.ltframework)
cannam@125 7701 if test prog,link = "$linkmode,$pass"; then
cannam@125 7702 compile_deplibs="$deplib $compile_deplibs"
cannam@125 7703 finalize_deplibs="$deplib $finalize_deplibs"
cannam@125 7704 else
cannam@125 7705 deplibs="$deplib $deplibs"
cannam@125 7706 if test lib = "$linkmode"; then
cannam@125 7707 case "$new_inherited_linker_flags " in
cannam@125 7708 *" $deplib "*) ;;
cannam@125 7709 * ) func_append new_inherited_linker_flags " $deplib" ;;
cannam@125 7710 esac
cannam@125 7711 fi
cannam@125 7712 fi
cannam@125 7713 continue
cannam@125 7714 ;;
cannam@125 7715 -L*)
cannam@125 7716 case $linkmode in
cannam@125 7717 lib)
cannam@125 7718 deplibs="$deplib $deplibs"
cannam@125 7719 test conv = "$pass" && continue
cannam@125 7720 newdependency_libs="$deplib $newdependency_libs"
cannam@125 7721 func_stripname '-L' '' "$deplib"
cannam@125 7722 func_resolve_sysroot "$func_stripname_result"
cannam@125 7723 func_append newlib_search_path " $func_resolve_sysroot_result"
cannam@125 7724 ;;
cannam@125 7725 prog)
cannam@125 7726 if test conv = "$pass"; then
cannam@125 7727 deplibs="$deplib $deplibs"
cannam@125 7728 continue
cannam@125 7729 fi
cannam@125 7730 if test scan = "$pass"; then
cannam@125 7731 deplibs="$deplib $deplibs"
cannam@125 7732 else
cannam@125 7733 compile_deplibs="$deplib $compile_deplibs"
cannam@125 7734 finalize_deplibs="$deplib $finalize_deplibs"
cannam@125 7735 fi
cannam@125 7736 func_stripname '-L' '' "$deplib"
cannam@125 7737 func_resolve_sysroot "$func_stripname_result"
cannam@125 7738 func_append newlib_search_path " $func_resolve_sysroot_result"
cannam@125 7739 ;;
cannam@125 7740 *)
cannam@125 7741 func_warning "'-L' is ignored for archives/objects"
cannam@125 7742 ;;
cannam@125 7743 esac # linkmode
cannam@125 7744 continue
cannam@125 7745 ;; # -L
cannam@125 7746 -R*)
cannam@125 7747 if test link = "$pass"; then
cannam@125 7748 func_stripname '-R' '' "$deplib"
cannam@125 7749 func_resolve_sysroot "$func_stripname_result"
cannam@125 7750 dir=$func_resolve_sysroot_result
cannam@125 7751 # Make sure the xrpath contains only unique directories.
cannam@125 7752 case "$xrpath " in
cannam@125 7753 *" $dir "*) ;;
cannam@125 7754 *) func_append xrpath " $dir" ;;
cannam@125 7755 esac
cannam@125 7756 fi
cannam@125 7757 deplibs="$deplib $deplibs"
cannam@125 7758 continue
cannam@125 7759 ;;
cannam@125 7760 *.la)
cannam@125 7761 func_resolve_sysroot "$deplib"
cannam@125 7762 lib=$func_resolve_sysroot_result
cannam@125 7763 ;;
cannam@125 7764 *.$libext)
cannam@125 7765 if test conv = "$pass"; then
cannam@125 7766 deplibs="$deplib $deplibs"
cannam@125 7767 continue
cannam@125 7768 fi
cannam@125 7769 case $linkmode in
cannam@125 7770 lib)
cannam@125 7771 # Linking convenience modules into shared libraries is allowed,
cannam@125 7772 # but linking other static libraries is non-portable.
cannam@125 7773 case " $dlpreconveniencelibs " in
cannam@125 7774 *" $deplib "*) ;;
cannam@125 7775 *)
cannam@125 7776 valid_a_lib=false
cannam@125 7777 case $deplibs_check_method in
cannam@125 7778 match_pattern*)
cannam@125 7779 set dummy $deplibs_check_method; shift
cannam@125 7780 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
cannam@125 7781 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
cannam@125 7782 | $EGREP "$match_pattern_regex" > /dev/null; then
cannam@125 7783 valid_a_lib=:
cannam@125 7784 fi
cannam@125 7785 ;;
cannam@125 7786 pass_all)
cannam@125 7787 valid_a_lib=:
cannam@125 7788 ;;
cannam@125 7789 esac
cannam@125 7790 if $valid_a_lib; then
cannam@125 7791 echo
cannam@125 7792 $ECHO "*** Warning: Linking the shared library $output against the"
cannam@125 7793 $ECHO "*** static library $deplib is not portable!"
cannam@125 7794 deplibs="$deplib $deplibs"
cannam@125 7795 else
cannam@125 7796 echo
cannam@125 7797 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
cannam@125 7798 echo "*** I have the capability to make that library automatically link in when"
cannam@125 7799 echo "*** you link to this library. But I can only do this if you have a"
cannam@125 7800 echo "*** shared version of the library, which you do not appear to have"
cannam@125 7801 echo "*** because the file extensions .$libext of this argument makes me believe"
cannam@125 7802 echo "*** that it is just a static archive that I should not use here."
cannam@125 7803 fi
cannam@125 7804 ;;
cannam@125 7805 esac
cannam@125 7806 continue
cannam@125 7807 ;;
cannam@125 7808 prog)
cannam@125 7809 if test link != "$pass"; then
cannam@125 7810 deplibs="$deplib $deplibs"
cannam@125 7811 else
cannam@125 7812 compile_deplibs="$deplib $compile_deplibs"
cannam@125 7813 finalize_deplibs="$deplib $finalize_deplibs"
cannam@125 7814 fi
cannam@125 7815 continue
cannam@125 7816 ;;
cannam@125 7817 esac # linkmode
cannam@125 7818 ;; # *.$libext
cannam@125 7819 *.lo | *.$objext)
cannam@125 7820 if test conv = "$pass"; then
cannam@125 7821 deplibs="$deplib $deplibs"
cannam@125 7822 elif test prog = "$linkmode"; then
cannam@125 7823 if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
cannam@125 7824 # If there is no dlopen support or we're linking statically,
cannam@125 7825 # we need to preload.
cannam@125 7826 func_append newdlprefiles " $deplib"
cannam@125 7827 compile_deplibs="$deplib $compile_deplibs"
cannam@125 7828 finalize_deplibs="$deplib $finalize_deplibs"
cannam@125 7829 else
cannam@125 7830 func_append newdlfiles " $deplib"
cannam@125 7831 fi
cannam@125 7832 fi
cannam@125 7833 continue
cannam@125 7834 ;;
cannam@125 7835 %DEPLIBS%)
cannam@125 7836 alldeplibs=:
cannam@125 7837 continue
cannam@125 7838 ;;
cannam@125 7839 esac # case $deplib
cannam@125 7840
cannam@125 7841 $found || test -f "$lib" \
cannam@125 7842 || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
cannam@125 7843
cannam@125 7844 # Check to see that this really is a libtool archive.
cannam@125 7845 func_lalib_unsafe_p "$lib" \
cannam@125 7846 || func_fatal_error "'$lib' is not a valid libtool archive"
cannam@125 7847
cannam@125 7848 func_dirname "$lib" "" "."
cannam@125 7849 ladir=$func_dirname_result
cannam@125 7850
cannam@125 7851 dlname=
cannam@125 7852 dlopen=
cannam@125 7853 dlpreopen=
cannam@125 7854 libdir=
cannam@125 7855 library_names=
cannam@125 7856 old_library=
cannam@125 7857 inherited_linker_flags=
cannam@125 7858 # If the library was installed with an old release of libtool,
cannam@125 7859 # it will not redefine variables installed, or shouldnotlink
cannam@125 7860 installed=yes
cannam@125 7861 shouldnotlink=no
cannam@125 7862 avoidtemprpath=
cannam@125 7863
cannam@125 7864
cannam@125 7865 # Read the .la file
cannam@125 7866 func_source "$lib"
cannam@125 7867
cannam@125 7868 # Convert "-framework foo" to "foo.ltframework"
cannam@125 7869 if test -n "$inherited_linker_flags"; then
cannam@125 7870 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
cannam@125 7871 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
cannam@125 7872 case " $new_inherited_linker_flags " in
cannam@125 7873 *" $tmp_inherited_linker_flag "*) ;;
cannam@125 7874 *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
cannam@125 7875 esac
cannam@125 7876 done
cannam@125 7877 fi
cannam@125 7878 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@125 7879 if test lib,link = "$linkmode,$pass" ||
cannam@125 7880 test prog,scan = "$linkmode,$pass" ||
cannam@125 7881 { test prog != "$linkmode" && test lib != "$linkmode"; }; then
cannam@125 7882 test -n "$dlopen" && func_append dlfiles " $dlopen"
cannam@125 7883 test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
cannam@125 7884 fi
cannam@125 7885
cannam@125 7886 if test conv = "$pass"; then
cannam@125 7887 # Only check for convenience libraries
cannam@125 7888 deplibs="$lib $deplibs"
cannam@125 7889 if test -z "$libdir"; then
cannam@125 7890 if test -z "$old_library"; then
cannam@125 7891 func_fatal_error "cannot find name of link library for '$lib'"
cannam@125 7892 fi
cannam@125 7893 # It is a libtool convenience library, so add in its objects.
cannam@125 7894 func_append convenience " $ladir/$objdir/$old_library"
cannam@125 7895 func_append old_convenience " $ladir/$objdir/$old_library"
cannam@125 7896 tmp_libs=
cannam@125 7897 for deplib in $dependency_libs; do
cannam@125 7898 deplibs="$deplib $deplibs"
cannam@125 7899 if $opt_preserve_dup_deps; then
cannam@125 7900 case "$tmp_libs " in
cannam@125 7901 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
cannam@125 7902 esac
cannam@125 7903 fi
cannam@125 7904 func_append tmp_libs " $deplib"
cannam@125 7905 done
cannam@125 7906 elif test prog != "$linkmode" && test lib != "$linkmode"; then
cannam@125 7907 func_fatal_error "'$lib' is not a convenience library"
cannam@125 7908 fi
cannam@125 7909 continue
cannam@125 7910 fi # $pass = conv
cannam@125 7911
cannam@125 7912
cannam@125 7913 # Get the name of the library we link against.
cannam@125 7914 linklib=
cannam@125 7915 if test -n "$old_library" &&
cannam@125 7916 { test yes = "$prefer_static_libs" ||
cannam@125 7917 test built,no = "$prefer_static_libs,$installed"; }; then
cannam@125 7918 linklib=$old_library
cannam@125 7919 else
cannam@125 7920 for l in $old_library $library_names; do
cannam@125 7921 linklib=$l
cannam@125 7922 done
cannam@125 7923 fi
cannam@125 7924 if test -z "$linklib"; then
cannam@125 7925 func_fatal_error "cannot find name of link library for '$lib'"
cannam@125 7926 fi
cannam@125 7927
cannam@125 7928 # This library was specified with -dlopen.
cannam@125 7929 if test dlopen = "$pass"; then
cannam@125 7930 test -z "$libdir" \
cannam@125 7931 && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
cannam@125 7932 if test -z "$dlname" ||
cannam@125 7933 test yes != "$dlopen_support" ||
cannam@125 7934 test no = "$build_libtool_libs"
cannam@125 7935 then
cannam@125 7936 # If there is no dlname, no dlopen support or we're linking
cannam@125 7937 # statically, we need to preload. We also need to preload any
cannam@125 7938 # dependent libraries so libltdl's deplib preloader doesn't
cannam@125 7939 # bomb out in the load deplibs phase.
cannam@125 7940 func_append dlprefiles " $lib $dependency_libs"
cannam@125 7941 else
cannam@125 7942 func_append newdlfiles " $lib"
cannam@125 7943 fi
cannam@125 7944 continue
cannam@125 7945 fi # $pass = dlopen
cannam@125 7946
cannam@125 7947 # We need an absolute path.
cannam@125 7948 case $ladir in
cannam@125 7949 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
cannam@125 7950 *)
cannam@125 7951 abs_ladir=`cd "$ladir" && pwd`
cannam@125 7952 if test -z "$abs_ladir"; then
cannam@125 7953 func_warning "cannot determine absolute directory name of '$ladir'"
cannam@125 7954 func_warning "passing it literally to the linker, although it might fail"
cannam@125 7955 abs_ladir=$ladir
cannam@125 7956 fi
cannam@125 7957 ;;
cannam@125 7958 esac
cannam@125 7959 func_basename "$lib"
cannam@125 7960 laname=$func_basename_result
cannam@125 7961
cannam@125 7962 # Find the relevant object directory and library name.
cannam@125 7963 if test yes = "$installed"; then
cannam@125 7964 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
cannam@125 7965 func_warning "library '$lib' was moved."
cannam@125 7966 dir=$ladir
cannam@125 7967 absdir=$abs_ladir
cannam@125 7968 libdir=$abs_ladir
cannam@125 7969 else
cannam@125 7970 dir=$lt_sysroot$libdir
cannam@125 7971 absdir=$lt_sysroot$libdir
cannam@125 7972 fi
cannam@125 7973 test yes = "$hardcode_automatic" && avoidtemprpath=yes
cannam@125 7974 else
cannam@125 7975 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
cannam@125 7976 dir=$ladir
cannam@125 7977 absdir=$abs_ladir
cannam@125 7978 # Remove this search path later
cannam@125 7979 func_append notinst_path " $abs_ladir"
cannam@125 7980 else
cannam@125 7981 dir=$ladir/$objdir
cannam@125 7982 absdir=$abs_ladir/$objdir
cannam@125 7983 # Remove this search path later
cannam@125 7984 func_append notinst_path " $abs_ladir"
cannam@125 7985 fi
cannam@125 7986 fi # $installed = yes
cannam@125 7987 func_stripname 'lib' '.la' "$laname"
cannam@125 7988 name=$func_stripname_result
cannam@125 7989
cannam@125 7990 # This library was specified with -dlpreopen.
cannam@125 7991 if test dlpreopen = "$pass"; then
cannam@125 7992 if test -z "$libdir" && test prog = "$linkmode"; then
cannam@125 7993 func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
cannam@125 7994 fi
cannam@125 7995 case $host in
cannam@125 7996 # special handling for platforms with PE-DLLs.
cannam@125 7997 *cygwin* | *mingw* | *cegcc* )
cannam@125 7998 # Linker will automatically link against shared library if both
cannam@125 7999 # static and shared are present. Therefore, ensure we extract
cannam@125 8000 # symbols from the import library if a shared library is present
cannam@125 8001 # (otherwise, the dlopen module name will be incorrect). We do
cannam@125 8002 # this by putting the import library name into $newdlprefiles.
cannam@125 8003 # We recover the dlopen module name by 'saving' the la file
cannam@125 8004 # name in a special purpose variable, and (later) extracting the
cannam@125 8005 # dlname from the la file.
cannam@125 8006 if test -n "$dlname"; then
cannam@125 8007 func_tr_sh "$dir/$linklib"
cannam@125 8008 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
cannam@125 8009 func_append newdlprefiles " $dir/$linklib"
cannam@125 8010 else
cannam@125 8011 func_append newdlprefiles " $dir/$old_library"
cannam@125 8012 # Keep a list of preopened convenience libraries to check
cannam@125 8013 # that they are being used correctly in the link pass.
cannam@125 8014 test -z "$libdir" && \
cannam@125 8015 func_append dlpreconveniencelibs " $dir/$old_library"
cannam@125 8016 fi
cannam@125 8017 ;;
cannam@125 8018 * )
cannam@125 8019 # Prefer using a static library (so that no silly _DYNAMIC symbols
cannam@125 8020 # are required to link).
cannam@125 8021 if test -n "$old_library"; then
cannam@125 8022 func_append newdlprefiles " $dir/$old_library"
cannam@125 8023 # Keep a list of preopened convenience libraries to check
cannam@125 8024 # that they are being used correctly in the link pass.
cannam@125 8025 test -z "$libdir" && \
cannam@125 8026 func_append dlpreconveniencelibs " $dir/$old_library"
cannam@125 8027 # Otherwise, use the dlname, so that lt_dlopen finds it.
cannam@125 8028 elif test -n "$dlname"; then
cannam@125 8029 func_append newdlprefiles " $dir/$dlname"
cannam@125 8030 else
cannam@125 8031 func_append newdlprefiles " $dir/$linklib"
cannam@125 8032 fi
cannam@125 8033 ;;
cannam@125 8034 esac
cannam@125 8035 fi # $pass = dlpreopen
cannam@125 8036
cannam@125 8037 if test -z "$libdir"; then
cannam@125 8038 # Link the convenience library
cannam@125 8039 if test lib = "$linkmode"; then
cannam@125 8040 deplibs="$dir/$old_library $deplibs"
cannam@125 8041 elif test prog,link = "$linkmode,$pass"; then
cannam@125 8042 compile_deplibs="$dir/$old_library $compile_deplibs"
cannam@125 8043 finalize_deplibs="$dir/$old_library $finalize_deplibs"
cannam@125 8044 else
cannam@125 8045 deplibs="$lib $deplibs" # used for prog,scan pass
cannam@125 8046 fi
cannam@125 8047 continue
cannam@125 8048 fi
cannam@125 8049
cannam@125 8050
cannam@125 8051 if test prog = "$linkmode" && test link != "$pass"; then
cannam@125 8052 func_append newlib_search_path " $ladir"
cannam@125 8053 deplibs="$lib $deplibs"
cannam@125 8054
cannam@125 8055 linkalldeplibs=false
cannam@125 8056 if test no != "$link_all_deplibs" || test -z "$library_names" ||
cannam@125 8057 test no = "$build_libtool_libs"; then
cannam@125 8058 linkalldeplibs=:
cannam@125 8059 fi
cannam@125 8060
cannam@125 8061 tmp_libs=
cannam@125 8062 for deplib in $dependency_libs; do
cannam@125 8063 case $deplib in
cannam@125 8064 -L*) func_stripname '-L' '' "$deplib"
cannam@125 8065 func_resolve_sysroot "$func_stripname_result"
cannam@125 8066 func_append newlib_search_path " $func_resolve_sysroot_result"
cannam@125 8067 ;;
cannam@125 8068 esac
cannam@125 8069 # Need to link against all dependency_libs?
cannam@125 8070 if $linkalldeplibs; then
cannam@125 8071 deplibs="$deplib $deplibs"
cannam@125 8072 else
cannam@125 8073 # Need to hardcode shared library paths
cannam@125 8074 # or/and link against static libraries
cannam@125 8075 newdependency_libs="$deplib $newdependency_libs"
cannam@125 8076 fi
cannam@125 8077 if $opt_preserve_dup_deps; then
cannam@125 8078 case "$tmp_libs " in
cannam@125 8079 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
cannam@125 8080 esac
cannam@125 8081 fi
cannam@125 8082 func_append tmp_libs " $deplib"
cannam@125 8083 done # for deplib
cannam@125 8084 continue
cannam@125 8085 fi # $linkmode = prog...
cannam@125 8086
cannam@125 8087 if test prog,link = "$linkmode,$pass"; then
cannam@125 8088 if test -n "$library_names" &&
cannam@125 8089 { { test no = "$prefer_static_libs" ||
cannam@125 8090 test built,yes = "$prefer_static_libs,$installed"; } ||
cannam@125 8091 test -z "$old_library"; }; then
cannam@125 8092 # We need to hardcode the library path
cannam@125 8093 if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
cannam@125 8094 # Make sure the rpath contains only unique directories.
cannam@125 8095 case $temp_rpath: in
cannam@125 8096 *"$absdir:"*) ;;
cannam@125 8097 *) func_append temp_rpath "$absdir:" ;;
cannam@125 8098 esac
cannam@125 8099 fi
cannam@125 8100
cannam@125 8101 # Hardcode the library path.
cannam@125 8102 # Skip directories that are in the system default run-time
cannam@125 8103 # search path.
cannam@125 8104 case " $sys_lib_dlsearch_path " in
cannam@125 8105 *" $absdir "*) ;;
cannam@125 8106 *)
cannam@125 8107 case "$compile_rpath " in
cannam@125 8108 *" $absdir "*) ;;
cannam@125 8109 *) func_append compile_rpath " $absdir" ;;
cannam@125 8110 esac
cannam@125 8111 ;;
cannam@125 8112 esac
cannam@125 8113 case " $sys_lib_dlsearch_path " in
cannam@125 8114 *" $libdir "*) ;;
cannam@125 8115 *)
cannam@125 8116 case "$finalize_rpath " in
cannam@125 8117 *" $libdir "*) ;;
cannam@125 8118 *) func_append finalize_rpath " $libdir" ;;
cannam@125 8119 esac
cannam@125 8120 ;;
cannam@125 8121 esac
cannam@125 8122 fi # $linkmode,$pass = prog,link...
cannam@125 8123
cannam@125 8124 if $alldeplibs &&
cannam@125 8125 { test pass_all = "$deplibs_check_method" ||
cannam@125 8126 { test yes = "$build_libtool_libs" &&
cannam@125 8127 test -n "$library_names"; }; }; then
cannam@125 8128 # We only need to search for static libraries
cannam@125 8129 continue
cannam@125 8130 fi
cannam@125 8131 fi
cannam@125 8132
cannam@125 8133 link_static=no # Whether the deplib will be linked statically
cannam@125 8134 use_static_libs=$prefer_static_libs
cannam@125 8135 if test built = "$use_static_libs" && test yes = "$installed"; then
cannam@125 8136 use_static_libs=no
cannam@125 8137 fi
cannam@125 8138 if test -n "$library_names" &&
cannam@125 8139 { test no = "$use_static_libs" || test -z "$old_library"; }; then
cannam@125 8140 case $host in
cannam@125 8141 *cygwin* | *mingw* | *cegcc* | *os2*)
cannam@125 8142 # No point in relinking DLLs because paths are not encoded
cannam@125 8143 func_append notinst_deplibs " $lib"
cannam@125 8144 need_relink=no
cannam@125 8145 ;;
cannam@125 8146 *)
cannam@125 8147 if test no = "$installed"; then
cannam@125 8148 func_append notinst_deplibs " $lib"
cannam@125 8149 need_relink=yes
cannam@125 8150 fi
cannam@125 8151 ;;
cannam@125 8152 esac
cannam@125 8153 # This is a shared library
cannam@125 8154
cannam@125 8155 # Warn about portability, can't link against -module's on some
cannam@125 8156 # systems (darwin). Don't bleat about dlopened modules though!
cannam@125 8157 dlopenmodule=
cannam@125 8158 for dlpremoduletest in $dlprefiles; do
cannam@125 8159 if test "X$dlpremoduletest" = "X$lib"; then
cannam@125 8160 dlopenmodule=$dlpremoduletest
cannam@125 8161 break
cannam@125 8162 fi
cannam@125 8163 done
cannam@125 8164 if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
cannam@125 8165 echo
cannam@125 8166 if test prog = "$linkmode"; then
cannam@125 8167 $ECHO "*** Warning: Linking the executable $output against the loadable module"
cannam@125 8168 else
cannam@125 8169 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
cannam@125 8170 fi
cannam@125 8171 $ECHO "*** $linklib is not portable!"
cannam@125 8172 fi
cannam@125 8173 if test lib = "$linkmode" &&
cannam@125 8174 test yes = "$hardcode_into_libs"; then
cannam@125 8175 # Hardcode the library path.
cannam@125 8176 # Skip directories that are in the system default run-time
cannam@125 8177 # search path.
cannam@125 8178 case " $sys_lib_dlsearch_path " in
cannam@125 8179 *" $absdir "*) ;;
cannam@125 8180 *)
cannam@125 8181 case "$compile_rpath " in
cannam@125 8182 *" $absdir "*) ;;
cannam@125 8183 *) func_append compile_rpath " $absdir" ;;
cannam@125 8184 esac
cannam@125 8185 ;;
cannam@125 8186 esac
cannam@125 8187 case " $sys_lib_dlsearch_path " in
cannam@125 8188 *" $libdir "*) ;;
cannam@125 8189 *)
cannam@125 8190 case "$finalize_rpath " in
cannam@125 8191 *" $libdir "*) ;;
cannam@125 8192 *) func_append finalize_rpath " $libdir" ;;
cannam@125 8193 esac
cannam@125 8194 ;;
cannam@125 8195 esac
cannam@125 8196 fi
cannam@125 8197
cannam@125 8198 if test -n "$old_archive_from_expsyms_cmds"; then
cannam@125 8199 # figure out the soname
cannam@125 8200 set dummy $library_names
cannam@125 8201 shift
cannam@125 8202 realname=$1
cannam@125 8203 shift
cannam@125 8204 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@125 8205 # use dlname if we got it. it's perfectly good, no?
cannam@125 8206 if test -n "$dlname"; then
cannam@125 8207 soname=$dlname
cannam@125 8208 elif test -n "$soname_spec"; then
cannam@125 8209 # bleh windows
cannam@125 8210 case $host in
cannam@125 8211 *cygwin* | mingw* | *cegcc* | *os2*)
cannam@125 8212 func_arith $current - $age
cannam@125 8213 major=$func_arith_result
cannam@125 8214 versuffix=-$major
cannam@125 8215 ;;
cannam@125 8216 esac
cannam@125 8217 eval soname=\"$soname_spec\"
cannam@125 8218 else
cannam@125 8219 soname=$realname
cannam@125 8220 fi
cannam@125 8221
cannam@125 8222 # Make a new name for the extract_expsyms_cmds to use
cannam@125 8223 soroot=$soname
cannam@125 8224 func_basename "$soroot"
cannam@125 8225 soname=$func_basename_result
cannam@125 8226 func_stripname 'lib' '.dll' "$soname"
cannam@125 8227 newlib=libimp-$func_stripname_result.a
cannam@125 8228
cannam@125 8229 # If the library has no export list, then create one now
cannam@125 8230 if test -f "$output_objdir/$soname-def"; then :
cannam@125 8231 else
cannam@125 8232 func_verbose "extracting exported symbol list from '$soname'"
cannam@125 8233 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
cannam@125 8234 fi
cannam@125 8235
cannam@125 8236 # Create $newlib
cannam@125 8237 if test -f "$output_objdir/$newlib"; then :; else
cannam@125 8238 func_verbose "generating import library for '$soname'"
cannam@125 8239 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
cannam@125 8240 fi
cannam@125 8241 # make sure the library variables are pointing to the new library
cannam@125 8242 dir=$output_objdir
cannam@125 8243 linklib=$newlib
cannam@125 8244 fi # test -n "$old_archive_from_expsyms_cmds"
cannam@125 8245
cannam@125 8246 if test prog = "$linkmode" || test relink != "$opt_mode"; then
cannam@125 8247 add_shlibpath=
cannam@125 8248 add_dir=
cannam@125 8249 add=
cannam@125 8250 lib_linked=yes
cannam@125 8251 case $hardcode_action in
cannam@125 8252 immediate | unsupported)
cannam@125 8253 if test no = "$hardcode_direct"; then
cannam@125 8254 add=$dir/$linklib
cannam@125 8255 case $host in
cannam@125 8256 *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
cannam@125 8257 *-*-sysv4*uw2*) add_dir=-L$dir ;;
cannam@125 8258 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
cannam@125 8259 *-*-unixware7*) add_dir=-L$dir ;;
cannam@125 8260 *-*-darwin* )
cannam@125 8261 # if the lib is a (non-dlopened) module then we cannot
cannam@125 8262 # link against it, someone is ignoring the earlier warnings
cannam@125 8263 if /usr/bin/file -L $add 2> /dev/null |
cannam@125 8264 $GREP ": [^:]* bundle" >/dev/null; then
cannam@125 8265 if test "X$dlopenmodule" != "X$lib"; then
cannam@125 8266 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
cannam@125 8267 if test -z "$old_library"; then
cannam@125 8268 echo
cannam@125 8269 echo "*** And there doesn't seem to be a static archive available"
cannam@125 8270 echo "*** The link will probably fail, sorry"
cannam@125 8271 else
cannam@125 8272 add=$dir/$old_library
cannam@125 8273 fi
cannam@125 8274 elif test -n "$old_library"; then
cannam@125 8275 add=$dir/$old_library
cannam@125 8276 fi
cannam@125 8277 fi
cannam@125 8278 esac
cannam@125 8279 elif test no = "$hardcode_minus_L"; then
cannam@125 8280 case $host in
cannam@125 8281 *-*-sunos*) add_shlibpath=$dir ;;
cannam@125 8282 esac
cannam@125 8283 add_dir=-L$dir
cannam@125 8284 add=-l$name
cannam@125 8285 elif test no = "$hardcode_shlibpath_var"; then
cannam@125 8286 add_shlibpath=$dir
cannam@125 8287 add=-l$name
cannam@125 8288 else
cannam@125 8289 lib_linked=no
cannam@125 8290 fi
cannam@125 8291 ;;
cannam@125 8292 relink)
cannam@125 8293 if test yes = "$hardcode_direct" &&
cannam@125 8294 test no = "$hardcode_direct_absolute"; then
cannam@125 8295 add=$dir/$linklib
cannam@125 8296 elif test yes = "$hardcode_minus_L"; then
cannam@125 8297 add_dir=-L$absdir
cannam@125 8298 # Try looking first in the location we're being installed to.
cannam@125 8299 if test -n "$inst_prefix_dir"; then
cannam@125 8300 case $libdir in
cannam@125 8301 [\\/]*)
cannam@125 8302 func_append add_dir " -L$inst_prefix_dir$libdir"
cannam@125 8303 ;;
cannam@125 8304 esac
cannam@125 8305 fi
cannam@125 8306 add=-l$name
cannam@125 8307 elif test yes = "$hardcode_shlibpath_var"; then
cannam@125 8308 add_shlibpath=$dir
cannam@125 8309 add=-l$name
cannam@125 8310 else
cannam@125 8311 lib_linked=no
cannam@125 8312 fi
cannam@125 8313 ;;
cannam@125 8314 *) lib_linked=no ;;
cannam@125 8315 esac
cannam@125 8316
cannam@125 8317 if test yes != "$lib_linked"; then
cannam@125 8318 func_fatal_configuration "unsupported hardcode properties"
cannam@125 8319 fi
cannam@125 8320
cannam@125 8321 if test -n "$add_shlibpath"; then
cannam@125 8322 case :$compile_shlibpath: in
cannam@125 8323 *":$add_shlibpath:"*) ;;
cannam@125 8324 *) func_append compile_shlibpath "$add_shlibpath:" ;;
cannam@125 8325 esac
cannam@125 8326 fi
cannam@125 8327 if test prog = "$linkmode"; then
cannam@125 8328 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
cannam@125 8329 test -n "$add" && compile_deplibs="$add $compile_deplibs"
cannam@125 8330 else
cannam@125 8331 test -n "$add_dir" && deplibs="$add_dir $deplibs"
cannam@125 8332 test -n "$add" && deplibs="$add $deplibs"
cannam@125 8333 if test yes != "$hardcode_direct" &&
cannam@125 8334 test yes != "$hardcode_minus_L" &&
cannam@125 8335 test yes = "$hardcode_shlibpath_var"; then
cannam@125 8336 case :$finalize_shlibpath: in
cannam@125 8337 *":$libdir:"*) ;;
cannam@125 8338 *) func_append finalize_shlibpath "$libdir:" ;;
cannam@125 8339 esac
cannam@125 8340 fi
cannam@125 8341 fi
cannam@125 8342 fi
cannam@125 8343
cannam@125 8344 if test prog = "$linkmode" || test relink = "$opt_mode"; then
cannam@125 8345 add_shlibpath=
cannam@125 8346 add_dir=
cannam@125 8347 add=
cannam@125 8348 # Finalize command for both is simple: just hardcode it.
cannam@125 8349 if test yes = "$hardcode_direct" &&
cannam@125 8350 test no = "$hardcode_direct_absolute"; then
cannam@125 8351 add=$libdir/$linklib
cannam@125 8352 elif test yes = "$hardcode_minus_L"; then
cannam@125 8353 add_dir=-L$libdir
cannam@125 8354 add=-l$name
cannam@125 8355 elif test yes = "$hardcode_shlibpath_var"; then
cannam@125 8356 case :$finalize_shlibpath: in
cannam@125 8357 *":$libdir:"*) ;;
cannam@125 8358 *) func_append finalize_shlibpath "$libdir:" ;;
cannam@125 8359 esac
cannam@125 8360 add=-l$name
cannam@125 8361 elif test yes = "$hardcode_automatic"; then
cannam@125 8362 if test -n "$inst_prefix_dir" &&
cannam@125 8363 test -f "$inst_prefix_dir$libdir/$linklib"; then
cannam@125 8364 add=$inst_prefix_dir$libdir/$linklib
cannam@125 8365 else
cannam@125 8366 add=$libdir/$linklib
cannam@125 8367 fi
cannam@125 8368 else
cannam@125 8369 # We cannot seem to hardcode it, guess we'll fake it.
cannam@125 8370 add_dir=-L$libdir
cannam@125 8371 # Try looking first in the location we're being installed to.
cannam@125 8372 if test -n "$inst_prefix_dir"; then
cannam@125 8373 case $libdir in
cannam@125 8374 [\\/]*)
cannam@125 8375 func_append add_dir " -L$inst_prefix_dir$libdir"
cannam@125 8376 ;;
cannam@125 8377 esac
cannam@125 8378 fi
cannam@125 8379 add=-l$name
cannam@125 8380 fi
cannam@125 8381
cannam@125 8382 if test prog = "$linkmode"; then
cannam@125 8383 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
cannam@125 8384 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
cannam@125 8385 else
cannam@125 8386 test -n "$add_dir" && deplibs="$add_dir $deplibs"
cannam@125 8387 test -n "$add" && deplibs="$add $deplibs"
cannam@125 8388 fi
cannam@125 8389 fi
cannam@125 8390 elif test prog = "$linkmode"; then
cannam@125 8391 # Here we assume that one of hardcode_direct or hardcode_minus_L
cannam@125 8392 # is not unsupported. This is valid on all known static and
cannam@125 8393 # shared platforms.
cannam@125 8394 if test unsupported != "$hardcode_direct"; then
cannam@125 8395 test -n "$old_library" && linklib=$old_library
cannam@125 8396 compile_deplibs="$dir/$linklib $compile_deplibs"
cannam@125 8397 finalize_deplibs="$dir/$linklib $finalize_deplibs"
cannam@125 8398 else
cannam@125 8399 compile_deplibs="-l$name -L$dir $compile_deplibs"
cannam@125 8400 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
cannam@125 8401 fi
cannam@125 8402 elif test yes = "$build_libtool_libs"; then
cannam@125 8403 # Not a shared library
cannam@125 8404 if test pass_all != "$deplibs_check_method"; then
cannam@125 8405 # We're trying link a shared library against a static one
cannam@125 8406 # but the system doesn't support it.
cannam@125 8407
cannam@125 8408 # Just print a warning and add the library to dependency_libs so
cannam@125 8409 # that the program can be linked against the static library.
cannam@125 8410 echo
cannam@125 8411 $ECHO "*** Warning: This system cannot link to static lib archive $lib."
cannam@125 8412 echo "*** I have the capability to make that library automatically link in when"
cannam@125 8413 echo "*** you link to this library. But I can only do this if you have a"
cannam@125 8414 echo "*** shared version of the library, which you do not appear to have."
cannam@125 8415 if test yes = "$module"; then
cannam@125 8416 echo "*** But as you try to build a module library, libtool will still create "
cannam@125 8417 echo "*** a static module, that should work as long as the dlopening application"
cannam@125 8418 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
cannam@125 8419 if test -z "$global_symbol_pipe"; then
cannam@125 8420 echo
cannam@125 8421 echo "*** However, this would only work if libtool was able to extract symbol"
cannam@125 8422 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
cannam@125 8423 echo "*** not find such a program. So, this module is probably useless."
cannam@125 8424 echo "*** 'nm' from GNU binutils and a full rebuild may help."
cannam@125 8425 fi
cannam@125 8426 if test no = "$build_old_libs"; then
cannam@125 8427 build_libtool_libs=module
cannam@125 8428 build_old_libs=yes
cannam@125 8429 else
cannam@125 8430 build_libtool_libs=no
cannam@125 8431 fi
cannam@125 8432 fi
cannam@125 8433 else
cannam@125 8434 deplibs="$dir/$old_library $deplibs"
cannam@125 8435 link_static=yes
cannam@125 8436 fi
cannam@125 8437 fi # link shared/static library?
cannam@125 8438
cannam@125 8439 if test lib = "$linkmode"; then
cannam@125 8440 if test -n "$dependency_libs" &&
cannam@125 8441 { test yes != "$hardcode_into_libs" ||
cannam@125 8442 test yes = "$build_old_libs" ||
cannam@125 8443 test yes = "$link_static"; }; then
cannam@125 8444 # Extract -R from dependency_libs
cannam@125 8445 temp_deplibs=
cannam@125 8446 for libdir in $dependency_libs; do
cannam@125 8447 case $libdir in
cannam@125 8448 -R*) func_stripname '-R' '' "$libdir"
cannam@125 8449 temp_xrpath=$func_stripname_result
cannam@125 8450 case " $xrpath " in
cannam@125 8451 *" $temp_xrpath "*) ;;
cannam@125 8452 *) func_append xrpath " $temp_xrpath";;
cannam@125 8453 esac;;
cannam@125 8454 *) func_append temp_deplibs " $libdir";;
cannam@125 8455 esac
cannam@125 8456 done
cannam@125 8457 dependency_libs=$temp_deplibs
cannam@125 8458 fi
cannam@125 8459
cannam@125 8460 func_append newlib_search_path " $absdir"
cannam@125 8461 # Link against this library
cannam@125 8462 test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
cannam@125 8463 # ... and its dependency_libs
cannam@125 8464 tmp_libs=
cannam@125 8465 for deplib in $dependency_libs; do
cannam@125 8466 newdependency_libs="$deplib $newdependency_libs"
cannam@125 8467 case $deplib in
cannam@125 8468 -L*) func_stripname '-L' '' "$deplib"
cannam@125 8469 func_resolve_sysroot "$func_stripname_result";;
cannam@125 8470 *) func_resolve_sysroot "$deplib" ;;
cannam@125 8471 esac
cannam@125 8472 if $opt_preserve_dup_deps; then
cannam@125 8473 case "$tmp_libs " in
cannam@125 8474 *" $func_resolve_sysroot_result "*)
cannam@125 8475 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
cannam@125 8476 esac
cannam@125 8477 fi
cannam@125 8478 func_append tmp_libs " $func_resolve_sysroot_result"
cannam@125 8479 done
cannam@125 8480
cannam@125 8481 if test no != "$link_all_deplibs"; then
cannam@125 8482 # Add the search paths of all dependency libraries
cannam@125 8483 for deplib in $dependency_libs; do
cannam@125 8484 path=
cannam@125 8485 case $deplib in
cannam@125 8486 -L*) path=$deplib ;;
cannam@125 8487 *.la)
cannam@125 8488 func_resolve_sysroot "$deplib"
cannam@125 8489 deplib=$func_resolve_sysroot_result
cannam@125 8490 func_dirname "$deplib" "" "."
cannam@125 8491 dir=$func_dirname_result
cannam@125 8492 # We need an absolute path.
cannam@125 8493 case $dir in
cannam@125 8494 [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
cannam@125 8495 *)
cannam@125 8496 absdir=`cd "$dir" && pwd`
cannam@125 8497 if test -z "$absdir"; then
cannam@125 8498 func_warning "cannot determine absolute directory name of '$dir'"
cannam@125 8499 absdir=$dir
cannam@125 8500 fi
cannam@125 8501 ;;
cannam@125 8502 esac
cannam@125 8503 if $GREP "^installed=no" $deplib > /dev/null; then
cannam@125 8504 case $host in
cannam@125 8505 *-*-darwin*)
cannam@125 8506 depdepl=
cannam@125 8507 eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
cannam@125 8508 if test -n "$deplibrary_names"; then
cannam@125 8509 for tmp in $deplibrary_names; do
cannam@125 8510 depdepl=$tmp
cannam@125 8511 done
cannam@125 8512 if test -f "$absdir/$objdir/$depdepl"; then
cannam@125 8513 depdepl=$absdir/$objdir/$depdepl
cannam@125 8514 darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
cannam@125 8515 if test -z "$darwin_install_name"; then
cannam@125 8516 darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
cannam@125 8517 fi
cannam@125 8518 func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
cannam@125 8519 func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
cannam@125 8520 path=
cannam@125 8521 fi
cannam@125 8522 fi
cannam@125 8523 ;;
cannam@125 8524 *)
cannam@125 8525 path=-L$absdir/$objdir
cannam@125 8526 ;;
cannam@125 8527 esac
cannam@125 8528 else
cannam@125 8529 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
cannam@125 8530 test -z "$libdir" && \
cannam@125 8531 func_fatal_error "'$deplib' is not a valid libtool archive"
cannam@125 8532 test "$absdir" != "$libdir" && \
cannam@125 8533 func_warning "'$deplib' seems to be moved"
cannam@125 8534
cannam@125 8535 path=-L$absdir
cannam@125 8536 fi
cannam@125 8537 ;;
cannam@125 8538 esac
cannam@125 8539 case " $deplibs " in
cannam@125 8540 *" $path "*) ;;
cannam@125 8541 *) deplibs="$path $deplibs" ;;
cannam@125 8542 esac
cannam@125 8543 done
cannam@125 8544 fi # link_all_deplibs != no
cannam@125 8545 fi # linkmode = lib
cannam@125 8546 done # for deplib in $libs
cannam@125 8547 if test link = "$pass"; then
cannam@125 8548 if test prog = "$linkmode"; then
cannam@125 8549 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
cannam@125 8550 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
cannam@125 8551 else
cannam@125 8552 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@125 8553 fi
cannam@125 8554 fi
cannam@125 8555 dependency_libs=$newdependency_libs
cannam@125 8556 if test dlpreopen = "$pass"; then
cannam@125 8557 # Link the dlpreopened libraries before other libraries
cannam@125 8558 for deplib in $save_deplibs; do
cannam@125 8559 deplibs="$deplib $deplibs"
cannam@125 8560 done
cannam@125 8561 fi
cannam@125 8562 if test dlopen != "$pass"; then
cannam@125 8563 test conv = "$pass" || {
cannam@125 8564 # Make sure lib_search_path contains only unique directories.
cannam@125 8565 lib_search_path=
cannam@125 8566 for dir in $newlib_search_path; do
cannam@125 8567 case "$lib_search_path " in
cannam@125 8568 *" $dir "*) ;;
cannam@125 8569 *) func_append lib_search_path " $dir" ;;
cannam@125 8570 esac
cannam@125 8571 done
cannam@125 8572 newlib_search_path=
cannam@125 8573 }
cannam@125 8574
cannam@125 8575 if test prog,link = "$linkmode,$pass"; then
cannam@125 8576 vars="compile_deplibs finalize_deplibs"
cannam@125 8577 else
cannam@125 8578 vars=deplibs
cannam@125 8579 fi
cannam@125 8580 for var in $vars dependency_libs; do
cannam@125 8581 # Add libraries to $var in reverse order
cannam@125 8582 eval tmp_libs=\"\$$var\"
cannam@125 8583 new_libs=
cannam@125 8584 for deplib in $tmp_libs; do
cannam@125 8585 # FIXME: Pedantically, this is the right thing to do, so
cannam@125 8586 # that some nasty dependency loop isn't accidentally
cannam@125 8587 # broken:
cannam@125 8588 #new_libs="$deplib $new_libs"
cannam@125 8589 # Pragmatically, this seems to cause very few problems in
cannam@125 8590 # practice:
cannam@125 8591 case $deplib in
cannam@125 8592 -L*) new_libs="$deplib $new_libs" ;;
cannam@125 8593 -R*) ;;
cannam@125 8594 *)
cannam@125 8595 # And here is the reason: when a library appears more
cannam@125 8596 # than once as an explicit dependence of a library, or
cannam@125 8597 # is implicitly linked in more than once by the
cannam@125 8598 # compiler, it is considered special, and multiple
cannam@125 8599 # occurrences thereof are not removed. Compare this
cannam@125 8600 # with having the same library being listed as a
cannam@125 8601 # dependency of multiple other libraries: in this case,
cannam@125 8602 # we know (pedantically, we assume) the library does not
cannam@125 8603 # need to be listed more than once, so we keep only the
cannam@125 8604 # last copy. This is not always right, but it is rare
cannam@125 8605 # enough that we require users that really mean to play
cannam@125 8606 # such unportable linking tricks to link the library
cannam@125 8607 # using -Wl,-lname, so that libtool does not consider it
cannam@125 8608 # for duplicate removal.
cannam@125 8609 case " $specialdeplibs " in
cannam@125 8610 *" $deplib "*) new_libs="$deplib $new_libs" ;;
cannam@125 8611 *)
cannam@125 8612 case " $new_libs " in
cannam@125 8613 *" $deplib "*) ;;
cannam@125 8614 *) new_libs="$deplib $new_libs" ;;
cannam@125 8615 esac
cannam@125 8616 ;;
cannam@125 8617 esac
cannam@125 8618 ;;
cannam@125 8619 esac
cannam@125 8620 done
cannam@125 8621 tmp_libs=
cannam@125 8622 for deplib in $new_libs; do
cannam@125 8623 case $deplib in
cannam@125 8624 -L*)
cannam@125 8625 case " $tmp_libs " in
cannam@125 8626 *" $deplib "*) ;;
cannam@125 8627 *) func_append tmp_libs " $deplib" ;;
cannam@125 8628 esac
cannam@125 8629 ;;
cannam@125 8630 *) func_append tmp_libs " $deplib" ;;
cannam@125 8631 esac
cannam@125 8632 done
cannam@125 8633 eval $var=\"$tmp_libs\"
cannam@125 8634 done # for var
cannam@125 8635 fi
cannam@125 8636
cannam@125 8637 # Add Sun CC postdeps if required:
cannam@125 8638 test CXX = "$tagname" && {
cannam@125 8639 case $host_os in
cannam@125 8640 linux*)
cannam@125 8641 case `$CC -V 2>&1 | sed 5q` in
cannam@125 8642 *Sun\ C*) # Sun C++ 5.9
cannam@125 8643 func_suncc_cstd_abi
cannam@125 8644
cannam@125 8645 if test no != "$suncc_use_cstd_abi"; then
cannam@125 8646 func_append postdeps ' -library=Cstd -library=Crun'
cannam@125 8647 fi
cannam@125 8648 ;;
cannam@125 8649 esac
cannam@125 8650 ;;
cannam@125 8651
cannam@125 8652 solaris*)
cannam@125 8653 func_cc_basename "$CC"
cannam@125 8654 case $func_cc_basename_result in
cannam@125 8655 CC* | sunCC*)
cannam@125 8656 func_suncc_cstd_abi
cannam@125 8657
cannam@125 8658 if test no != "$suncc_use_cstd_abi"; then
cannam@125 8659 func_append postdeps ' -library=Cstd -library=Crun'
cannam@125 8660 fi
cannam@125 8661 ;;
cannam@125 8662 esac
cannam@125 8663 ;;
cannam@125 8664 esac
cannam@125 8665 }
cannam@125 8666
cannam@125 8667 # Last step: remove runtime libs from dependency_libs
cannam@125 8668 # (they stay in deplibs)
cannam@125 8669 tmp_libs=
cannam@125 8670 for i in $dependency_libs; do
cannam@125 8671 case " $predeps $postdeps $compiler_lib_search_path " in
cannam@125 8672 *" $i "*)
cannam@125 8673 i=
cannam@125 8674 ;;
cannam@125 8675 esac
cannam@125 8676 if test -n "$i"; then
cannam@125 8677 func_append tmp_libs " $i"
cannam@125 8678 fi
cannam@125 8679 done
cannam@125 8680 dependency_libs=$tmp_libs
cannam@125 8681 done # for pass
cannam@125 8682 if test prog = "$linkmode"; then
cannam@125 8683 dlfiles=$newdlfiles
cannam@125 8684 fi
cannam@125 8685 if test prog = "$linkmode" || test lib = "$linkmode"; then
cannam@125 8686 dlprefiles=$newdlprefiles
cannam@125 8687 fi
cannam@125 8688
cannam@125 8689 case $linkmode in
cannam@125 8690 oldlib)
cannam@125 8691 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
cannam@125 8692 func_warning "'-dlopen' is ignored for archives"
cannam@125 8693 fi
cannam@125 8694
cannam@125 8695 case " $deplibs" in
cannam@125 8696 *\ -l* | *\ -L*)
cannam@125 8697 func_warning "'-l' and '-L' are ignored for archives" ;;
cannam@125 8698 esac
cannam@125 8699
cannam@125 8700 test -n "$rpath" && \
cannam@125 8701 func_warning "'-rpath' is ignored for archives"
cannam@125 8702
cannam@125 8703 test -n "$xrpath" && \
cannam@125 8704 func_warning "'-R' is ignored for archives"
cannam@125 8705
cannam@125 8706 test -n "$vinfo" && \
cannam@125 8707 func_warning "'-version-info/-version-number' is ignored for archives"
cannam@125 8708
cannam@125 8709 test -n "$release" && \
cannam@125 8710 func_warning "'-release' is ignored for archives"
cannam@125 8711
cannam@125 8712 test -n "$export_symbols$export_symbols_regex" && \
cannam@125 8713 func_warning "'-export-symbols' is ignored for archives"
cannam@125 8714
cannam@125 8715 # Now set the variables for building old libraries.
cannam@125 8716 build_libtool_libs=no
cannam@125 8717 oldlibs=$output
cannam@125 8718 func_append objs "$old_deplibs"
cannam@125 8719 ;;
cannam@125 8720
cannam@125 8721 lib)
cannam@125 8722 # Make sure we only generate libraries of the form 'libNAME.la'.
cannam@125 8723 case $outputname in
cannam@125 8724 lib*)
cannam@125 8725 func_stripname 'lib' '.la' "$outputname"
cannam@125 8726 name=$func_stripname_result
cannam@125 8727 eval shared_ext=\"$shrext_cmds\"
cannam@125 8728 eval libname=\"$libname_spec\"
cannam@125 8729 ;;
cannam@125 8730 *)
cannam@125 8731 test no = "$module" \
cannam@125 8732 && func_fatal_help "libtool library '$output' must begin with 'lib'"
cannam@125 8733
cannam@125 8734 if test no != "$need_lib_prefix"; then
cannam@125 8735 # Add the "lib" prefix for modules if required
cannam@125 8736 func_stripname '' '.la' "$outputname"
cannam@125 8737 name=$func_stripname_result
cannam@125 8738 eval shared_ext=\"$shrext_cmds\"
cannam@125 8739 eval libname=\"$libname_spec\"
cannam@125 8740 else
cannam@125 8741 func_stripname '' '.la' "$outputname"
cannam@125 8742 libname=$func_stripname_result
cannam@125 8743 fi
cannam@125 8744 ;;
cannam@125 8745 esac
cannam@125 8746
cannam@125 8747 if test -n "$objs"; then
cannam@125 8748 if test pass_all != "$deplibs_check_method"; then
cannam@125 8749 func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
cannam@125 8750 else
cannam@125 8751 echo
cannam@125 8752 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
cannam@125 8753 $ECHO "*** objects $objs is not portable!"
cannam@125 8754 func_append libobjs " $objs"
cannam@125 8755 fi
cannam@125 8756 fi
cannam@125 8757
cannam@125 8758 test no = "$dlself" \
cannam@125 8759 || func_warning "'-dlopen self' is ignored for libtool libraries"
cannam@125 8760
cannam@125 8761 set dummy $rpath
cannam@125 8762 shift
cannam@125 8763 test 1 -lt "$#" \
cannam@125 8764 && func_warning "ignoring multiple '-rpath's for a libtool library"
cannam@125 8765
cannam@125 8766 install_libdir=$1
cannam@125 8767
cannam@125 8768 oldlibs=
cannam@125 8769 if test -z "$rpath"; then
cannam@125 8770 if test yes = "$build_libtool_libs"; then
cannam@125 8771 # Building a libtool convenience library.
cannam@125 8772 # Some compilers have problems with a '.al' extension so
cannam@125 8773 # convenience libraries should have the same extension an
cannam@125 8774 # archive normally would.
cannam@125 8775 oldlibs="$output_objdir/$libname.$libext $oldlibs"
cannam@125 8776 build_libtool_libs=convenience
cannam@125 8777 build_old_libs=yes
cannam@125 8778 fi
cannam@125 8779
cannam@125 8780 test -n "$vinfo" && \
cannam@125 8781 func_warning "'-version-info/-version-number' is ignored for convenience libraries"
cannam@125 8782
cannam@125 8783 test -n "$release" && \
cannam@125 8784 func_warning "'-release' is ignored for convenience libraries"
cannam@125 8785 else
cannam@125 8786
cannam@125 8787 # Parse the version information argument.
cannam@125 8788 save_ifs=$IFS; IFS=:
cannam@125 8789 set dummy $vinfo 0 0 0
cannam@125 8790 shift
cannam@125 8791 IFS=$save_ifs
cannam@125 8792
cannam@125 8793 test -n "$7" && \
cannam@125 8794 func_fatal_help "too many parameters to '-version-info'"
cannam@125 8795
cannam@125 8796 # convert absolute version numbers to libtool ages
cannam@125 8797 # this retains compatibility with .la files and attempts
cannam@125 8798 # to make the code below a bit more comprehensible
cannam@125 8799
cannam@125 8800 case $vinfo_number in
cannam@125 8801 yes)
cannam@125 8802 number_major=$1
cannam@125 8803 number_minor=$2
cannam@125 8804 number_revision=$3
cannam@125 8805 #
cannam@125 8806 # There are really only two kinds -- those that
cannam@125 8807 # use the current revision as the major version
cannam@125 8808 # and those that subtract age and use age as
cannam@125 8809 # a minor version. But, then there is irix
cannam@125 8810 # that has an extra 1 added just for fun
cannam@125 8811 #
cannam@125 8812 case $version_type in
cannam@125 8813 # correct linux to gnu/linux during the next big refactor
cannam@125 8814 darwin|freebsd-elf|linux|osf|windows|none)
cannam@125 8815 func_arith $number_major + $number_minor
cannam@125 8816 current=$func_arith_result
cannam@125 8817 age=$number_minor
cannam@125 8818 revision=$number_revision
cannam@125 8819 ;;
cannam@125 8820 freebsd-aout|qnx|sunos)
cannam@125 8821 current=$number_major
cannam@125 8822 revision=$number_minor
cannam@125 8823 age=0
cannam@125 8824 ;;
cannam@125 8825 irix|nonstopux)
cannam@125 8826 func_arith $number_major + $number_minor
cannam@125 8827 current=$func_arith_result
cannam@125 8828 age=$number_minor
cannam@125 8829 revision=$number_minor
cannam@125 8830 lt_irix_increment=no
cannam@125 8831 ;;
cannam@125 8832 *)
cannam@125 8833 func_fatal_configuration "$modename: unknown library version type '$version_type'"
cannam@125 8834 ;;
cannam@125 8835 esac
cannam@125 8836 ;;
cannam@125 8837 no)
cannam@125 8838 current=$1
cannam@125 8839 revision=$2
cannam@125 8840 age=$3
cannam@125 8841 ;;
cannam@125 8842 esac
cannam@125 8843
cannam@125 8844 # Check that each of the things are valid numbers.
cannam@125 8845 case $current in
cannam@125 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]) ;;
cannam@125 8847 *)
cannam@125 8848 func_error "CURRENT '$current' must be a nonnegative integer"
cannam@125 8849 func_fatal_error "'$vinfo' is not valid version information"
cannam@125 8850 ;;
cannam@125 8851 esac
cannam@125 8852
cannam@125 8853 case $revision in
cannam@125 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]) ;;
cannam@125 8855 *)
cannam@125 8856 func_error "REVISION '$revision' must be a nonnegative integer"
cannam@125 8857 func_fatal_error "'$vinfo' is not valid version information"
cannam@125 8858 ;;
cannam@125 8859 esac
cannam@125 8860
cannam@125 8861 case $age in
cannam@125 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]) ;;
cannam@125 8863 *)
cannam@125 8864 func_error "AGE '$age' must be a nonnegative integer"
cannam@125 8865 func_fatal_error "'$vinfo' is not valid version information"
cannam@125 8866 ;;
cannam@125 8867 esac
cannam@125 8868
cannam@125 8869 if test "$age" -gt "$current"; then
cannam@125 8870 func_error "AGE '$age' is greater than the current interface number '$current'"
cannam@125 8871 func_fatal_error "'$vinfo' is not valid version information"
cannam@125 8872 fi
cannam@125 8873
cannam@125 8874 # Calculate the version variables.
cannam@125 8875 major=
cannam@125 8876 versuffix=
cannam@125 8877 verstring=
cannam@125 8878 case $version_type in
cannam@125 8879 none) ;;
cannam@125 8880
cannam@125 8881 darwin)
cannam@125 8882 # Like Linux, but with the current version available in
cannam@125 8883 # verstring for coding it into the library header
cannam@125 8884 func_arith $current - $age
cannam@125 8885 major=.$func_arith_result
cannam@125 8886 versuffix=$major.$age.$revision
cannam@125 8887 # Darwin ld doesn't like 0 for these options...
cannam@125 8888 func_arith $current + 1
cannam@125 8889 minor_current=$func_arith_result
cannam@125 8890 xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
cannam@125 8891 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
cannam@125 8892 # On Darwin other compilers
cannam@125 8893 case $CC in
cannam@125 8894 nagfor*)
cannam@125 8895 verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
cannam@125 8896 ;;
cannam@125 8897 *)
cannam@125 8898 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
cannam@125 8899 ;;
cannam@125 8900 esac
cannam@125 8901 ;;
cannam@125 8902
cannam@125 8903 freebsd-aout)
cannam@125 8904 major=.$current
cannam@125 8905 versuffix=.$current.$revision
cannam@125 8906 ;;
cannam@125 8907
cannam@125 8908 freebsd-elf)
cannam@125 8909 func_arith $current - $age
cannam@125 8910 major=.$func_arith_result
cannam@125 8911 versuffix=$major.$age.$revision
cannam@125 8912 ;;
cannam@125 8913
cannam@125 8914 irix | nonstopux)
cannam@125 8915 if test no = "$lt_irix_increment"; then
cannam@125 8916 func_arith $current - $age
cannam@125 8917 else
cannam@125 8918 func_arith $current - $age + 1
cannam@125 8919 fi
cannam@125 8920 major=$func_arith_result
cannam@125 8921
cannam@125 8922 case $version_type in
cannam@125 8923 nonstopux) verstring_prefix=nonstopux ;;
cannam@125 8924 *) verstring_prefix=sgi ;;
cannam@125 8925 esac
cannam@125 8926 verstring=$verstring_prefix$major.$revision
cannam@125 8927
cannam@125 8928 # Add in all the interfaces that we are compatible with.
cannam@125 8929 loop=$revision
cannam@125 8930 while test 0 -ne "$loop"; do
cannam@125 8931 func_arith $revision - $loop
cannam@125 8932 iface=$func_arith_result
cannam@125 8933 func_arith $loop - 1
cannam@125 8934 loop=$func_arith_result
cannam@125 8935 verstring=$verstring_prefix$major.$iface:$verstring
cannam@125 8936 done
cannam@125 8937
cannam@125 8938 # Before this point, $major must not contain '.'.
cannam@125 8939 major=.$major
cannam@125 8940 versuffix=$major.$revision
cannam@125 8941 ;;
cannam@125 8942
cannam@125 8943 linux) # correct to gnu/linux during the next big refactor
cannam@125 8944 func_arith $current - $age
cannam@125 8945 major=.$func_arith_result
cannam@125 8946 versuffix=$major.$age.$revision
cannam@125 8947 ;;
cannam@125 8948
cannam@125 8949 osf)
cannam@125 8950 func_arith $current - $age
cannam@125 8951 major=.$func_arith_result
cannam@125 8952 versuffix=.$current.$age.$revision
cannam@125 8953 verstring=$current.$age.$revision
cannam@125 8954
cannam@125 8955 # Add in all the interfaces that we are compatible with.
cannam@125 8956 loop=$age
cannam@125 8957 while test 0 -ne "$loop"; do
cannam@125 8958 func_arith $current - $loop
cannam@125 8959 iface=$func_arith_result
cannam@125 8960 func_arith $loop - 1
cannam@125 8961 loop=$func_arith_result
cannam@125 8962 verstring=$verstring:$iface.0
cannam@125 8963 done
cannam@125 8964
cannam@125 8965 # Make executables depend on our current version.
cannam@125 8966 func_append verstring ":$current.0"
cannam@125 8967 ;;
cannam@125 8968
cannam@125 8969 qnx)
cannam@125 8970 major=.$current
cannam@125 8971 versuffix=.$current
cannam@125 8972 ;;
cannam@125 8973
cannam@125 8974 sco)
cannam@125 8975 major=.$current
cannam@125 8976 versuffix=.$current
cannam@125 8977 ;;
cannam@125 8978
cannam@125 8979 sunos)
cannam@125 8980 major=.$current
cannam@125 8981 versuffix=.$current.$revision
cannam@125 8982 ;;
cannam@125 8983
cannam@125 8984 windows)
cannam@125 8985 # Use '-' rather than '.', since we only want one
cannam@125 8986 # extension on DOS 8.3 file systems.
cannam@125 8987 func_arith $current - $age
cannam@125 8988 major=$func_arith_result
cannam@125 8989 versuffix=-$major
cannam@125 8990 ;;
cannam@125 8991
cannam@125 8992 *)
cannam@125 8993 func_fatal_configuration "unknown library version type '$version_type'"
cannam@125 8994 ;;
cannam@125 8995 esac
cannam@125 8996
cannam@125 8997 # Clear the version info if we defaulted, and they specified a release.
cannam@125 8998 if test -z "$vinfo" && test -n "$release"; then
cannam@125 8999 major=
cannam@125 9000 case $version_type in
cannam@125 9001 darwin)
cannam@125 9002 # we can't check for "0.0" in archive_cmds due to quoting
cannam@125 9003 # problems, so we reset it completely
cannam@125 9004 verstring=
cannam@125 9005 ;;
cannam@125 9006 *)
cannam@125 9007 verstring=0.0
cannam@125 9008 ;;
cannam@125 9009 esac
cannam@125 9010 if test no = "$need_version"; then
cannam@125 9011 versuffix=
cannam@125 9012 else
cannam@125 9013 versuffix=.0.0
cannam@125 9014 fi
cannam@125 9015 fi
cannam@125 9016
cannam@125 9017 # Remove version info from name if versioning should be avoided
cannam@125 9018 if test yes,no = "$avoid_version,$need_version"; then
cannam@125 9019 major=
cannam@125 9020 versuffix=
cannam@125 9021 verstring=
cannam@125 9022 fi
cannam@125 9023
cannam@125 9024 # Check to see if the archive will have undefined symbols.
cannam@125 9025 if test yes = "$allow_undefined"; then
cannam@125 9026 if test unsupported = "$allow_undefined_flag"; then
cannam@125 9027 if test yes = "$build_old_libs"; then
cannam@125 9028 func_warning "undefined symbols not allowed in $host shared libraries; building static only"
cannam@125 9029 build_libtool_libs=no
cannam@125 9030 else
cannam@125 9031 func_fatal_error "can't build $host shared library unless -no-undefined is specified"
cannam@125 9032 fi
cannam@125 9033 fi
cannam@125 9034 else
cannam@125 9035 # Don't allow undefined symbols.
cannam@125 9036 allow_undefined_flag=$no_undefined_flag
cannam@125 9037 fi
cannam@125 9038
cannam@125 9039 fi
cannam@125 9040
cannam@125 9041 func_generate_dlsyms "$libname" "$libname" :
cannam@125 9042 func_append libobjs " $symfileobj"
cannam@125 9043 test " " = "$libobjs" && libobjs=
cannam@125 9044
cannam@125 9045 if test relink != "$opt_mode"; then
cannam@125 9046 # Remove our outputs, but don't remove object files since they
cannam@125 9047 # may have been created when compiling PIC objects.
cannam@125 9048 removelist=
cannam@125 9049 tempremovelist=`$ECHO "$output_objdir/*"`
cannam@125 9050 for p in $tempremovelist; do
cannam@125 9051 case $p in
cannam@125 9052 *.$objext | *.gcno)
cannam@125 9053 ;;
cannam@125 9054 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
cannam@125 9055 if test -n "$precious_files_regex"; then
cannam@125 9056 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
cannam@125 9057 then
cannam@125 9058 continue
cannam@125 9059 fi
cannam@125 9060 fi
cannam@125 9061 func_append removelist " $p"
cannam@125 9062 ;;
cannam@125 9063 *) ;;
cannam@125 9064 esac
cannam@125 9065 done
cannam@125 9066 test -n "$removelist" && \
cannam@125 9067 func_show_eval "${RM}r \$removelist"
cannam@125 9068 fi
cannam@125 9069
cannam@125 9070 # Now set the variables for building old libraries.
cannam@125 9071 if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
cannam@125 9072 func_append oldlibs " $output_objdir/$libname.$libext"
cannam@125 9073
cannam@125 9074 # Transform .lo files to .o files.
cannam@125 9075 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
cannam@125 9076 fi
cannam@125 9077
cannam@125 9078 # Eliminate all temporary directories.
cannam@125 9079 #for path in $notinst_path; do
cannam@125 9080 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
cannam@125 9081 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
cannam@125 9082 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
cannam@125 9083 #done
cannam@125 9084
cannam@125 9085 if test -n "$xrpath"; then
cannam@125 9086 # If the user specified any rpath flags, then add them.
cannam@125 9087 temp_xrpath=
cannam@125 9088 for libdir in $xrpath; do
cannam@125 9089 func_replace_sysroot "$libdir"
cannam@125 9090 func_append temp_xrpath " -R$func_replace_sysroot_result"
cannam@125 9091 case "$finalize_rpath " in
cannam@125 9092 *" $libdir "*) ;;
cannam@125 9093 *) func_append finalize_rpath " $libdir" ;;
cannam@125 9094 esac
cannam@125 9095 done
cannam@125 9096 if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
cannam@125 9097 dependency_libs="$temp_xrpath $dependency_libs"
cannam@125 9098 fi
cannam@125 9099 fi
cannam@125 9100
cannam@125 9101 # Make sure dlfiles contains only unique files that won't be dlpreopened
cannam@125 9102 old_dlfiles=$dlfiles
cannam@125 9103 dlfiles=
cannam@125 9104 for lib in $old_dlfiles; do
cannam@125 9105 case " $dlprefiles $dlfiles " in
cannam@125 9106 *" $lib "*) ;;
cannam@125 9107 *) func_append dlfiles " $lib" ;;
cannam@125 9108 esac
cannam@125 9109 done
cannam@125 9110
cannam@125 9111 # Make sure dlprefiles contains only unique files
cannam@125 9112 old_dlprefiles=$dlprefiles
cannam@125 9113 dlprefiles=
cannam@125 9114 for lib in $old_dlprefiles; do
cannam@125 9115 case "$dlprefiles " in
cannam@125 9116 *" $lib "*) ;;
cannam@125 9117 *) func_append dlprefiles " $lib" ;;
cannam@125 9118 esac
cannam@125 9119 done
cannam@125 9120
cannam@125 9121 if test yes = "$build_libtool_libs"; then
cannam@125 9122 if test -n "$rpath"; then
cannam@125 9123 case $host in
cannam@125 9124 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
cannam@125 9125 # these systems don't actually have a c library (as such)!
cannam@125 9126 ;;
cannam@125 9127 *-*-rhapsody* | *-*-darwin1.[012])
cannam@125 9128 # Rhapsody C library is in the System framework
cannam@125 9129 func_append deplibs " System.ltframework"
cannam@125 9130 ;;
cannam@125 9131 *-*-netbsd*)
cannam@125 9132 # Don't link with libc until the a.out ld.so is fixed.
cannam@125 9133 ;;
cannam@125 9134 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
cannam@125 9135 # Do not include libc due to us having libc/libc_r.
cannam@125 9136 ;;
cannam@125 9137 *-*-sco3.2v5* | *-*-sco5v6*)
cannam@125 9138 # Causes problems with __ctype
cannam@125 9139 ;;
cannam@125 9140 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
cannam@125 9141 # Compiler inserts libc in the correct place for threads to work
cannam@125 9142 ;;
cannam@125 9143 *)
cannam@125 9144 # Add libc to deplibs on all other systems if necessary.
cannam@125 9145 if test yes = "$build_libtool_need_lc"; then
cannam@125 9146 func_append deplibs " -lc"
cannam@125 9147 fi
cannam@125 9148 ;;
cannam@125 9149 esac
cannam@125 9150 fi
cannam@125 9151
cannam@125 9152 # Transform deplibs into only deplibs that can be linked in shared.
cannam@125 9153 name_save=$name
cannam@125 9154 libname_save=$libname
cannam@125 9155 release_save=$release
cannam@125 9156 versuffix_save=$versuffix
cannam@125 9157 major_save=$major
cannam@125 9158 # I'm not sure if I'm treating the release correctly. I think
cannam@125 9159 # release should show up in the -l (ie -lgmp5) so we don't want to
cannam@125 9160 # add it in twice. Is that correct?
cannam@125 9161 release=
cannam@125 9162 versuffix=
cannam@125 9163 major=
cannam@125 9164 newdeplibs=
cannam@125 9165 droppeddeps=no
cannam@125 9166 case $deplibs_check_method in
cannam@125 9167 pass_all)
cannam@125 9168 # Don't check for shared/static. Everything works.
cannam@125 9169 # This might be a little naive. We might want to check
cannam@125 9170 # whether the library exists or not. But this is on
cannam@125 9171 # osf3 & osf4 and I'm not really sure... Just
cannam@125 9172 # implementing what was already the behavior.
cannam@125 9173 newdeplibs=$deplibs
cannam@125 9174 ;;
cannam@125 9175 test_compile)
cannam@125 9176 # This code stresses the "libraries are programs" paradigm to its
cannam@125 9177 # limits. Maybe even breaks it. We compile a program, linking it
cannam@125 9178 # against the deplibs as a proxy for the library. Then we can check
cannam@125 9179 # whether they linked in statically or dynamically with ldd.
cannam@125 9180 $opt_dry_run || $RM conftest.c
cannam@125 9181 cat > conftest.c <<EOF
cannam@125 9182 int main() { return 0; }
cannam@125 9183 EOF
cannam@125 9184 $opt_dry_run || $RM conftest
cannam@125 9185 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
cannam@125 9186 ldd_output=`ldd conftest`
cannam@125 9187 for i in $deplibs; do
cannam@125 9188 case $i in
cannam@125 9189 -l*)
cannam@125 9190 func_stripname -l '' "$i"
cannam@125 9191 name=$func_stripname_result
cannam@125 9192 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@125 9193 case " $predeps $postdeps " in
cannam@125 9194 *" $i "*)
cannam@125 9195 func_append newdeplibs " $i"
cannam@125 9196 i=
cannam@125 9197 ;;
cannam@125 9198 esac
cannam@125 9199 fi
cannam@125 9200 if test -n "$i"; then
cannam@125 9201 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@125 9202 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
cannam@125 9203 set dummy $deplib_matches; shift
cannam@125 9204 deplib_match=$1
cannam@125 9205 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
cannam@125 9206 func_append newdeplibs " $i"
cannam@125 9207 else
cannam@125 9208 droppeddeps=yes
cannam@125 9209 echo
cannam@125 9210 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
cannam@125 9211 echo "*** I have the capability to make that library automatically link in when"
cannam@125 9212 echo "*** you link to this library. But I can only do this if you have a"
cannam@125 9213 echo "*** shared version of the library, which I believe you do not have"
cannam@125 9214 echo "*** because a test_compile did reveal that the linker did not use it for"
cannam@125 9215 echo "*** its dynamic dependency list that programs get resolved with at runtime."
cannam@125 9216 fi
cannam@125 9217 fi
cannam@125 9218 ;;
cannam@125 9219 *)
cannam@125 9220 func_append newdeplibs " $i"
cannam@125 9221 ;;
cannam@125 9222 esac
cannam@125 9223 done
cannam@125 9224 else
cannam@125 9225 # Error occurred in the first compile. Let's try to salvage
cannam@125 9226 # the situation: Compile a separate program for each library.
cannam@125 9227 for i in $deplibs; do
cannam@125 9228 case $i in
cannam@125 9229 -l*)
cannam@125 9230 func_stripname -l '' "$i"
cannam@125 9231 name=$func_stripname_result
cannam@125 9232 $opt_dry_run || $RM conftest
cannam@125 9233 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
cannam@125 9234 ldd_output=`ldd conftest`
cannam@125 9235 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@125 9236 case " $predeps $postdeps " in
cannam@125 9237 *" $i "*)
cannam@125 9238 func_append newdeplibs " $i"
cannam@125 9239 i=
cannam@125 9240 ;;
cannam@125 9241 esac
cannam@125 9242 fi
cannam@125 9243 if test -n "$i"; then
cannam@125 9244 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@125 9245 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
cannam@125 9246 set dummy $deplib_matches; shift
cannam@125 9247 deplib_match=$1
cannam@125 9248 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
cannam@125 9249 func_append newdeplibs " $i"
cannam@125 9250 else
cannam@125 9251 droppeddeps=yes
cannam@125 9252 echo
cannam@125 9253 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
cannam@125 9254 echo "*** I have the capability to make that library automatically link in when"
cannam@125 9255 echo "*** you link to this library. But I can only do this if you have a"
cannam@125 9256 echo "*** shared version of the library, which you do not appear to have"
cannam@125 9257 echo "*** because a test_compile did reveal that the linker did not use this one"
cannam@125 9258 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
cannam@125 9259 fi
cannam@125 9260 fi
cannam@125 9261 else
cannam@125 9262 droppeddeps=yes
cannam@125 9263 echo
cannam@125 9264 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
cannam@125 9265 echo "*** make it link in! You will probably need to install it or some"
cannam@125 9266 echo "*** library that it depends on before this library will be fully"
cannam@125 9267 echo "*** functional. Installing it before continuing would be even better."
cannam@125 9268 fi
cannam@125 9269 ;;
cannam@125 9270 *)
cannam@125 9271 func_append newdeplibs " $i"
cannam@125 9272 ;;
cannam@125 9273 esac
cannam@125 9274 done
cannam@125 9275 fi
cannam@125 9276 ;;
cannam@125 9277 file_magic*)
cannam@125 9278 set dummy $deplibs_check_method; shift
cannam@125 9279 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
cannam@125 9280 for a_deplib in $deplibs; do
cannam@125 9281 case $a_deplib in
cannam@125 9282 -l*)
cannam@125 9283 func_stripname -l '' "$a_deplib"
cannam@125 9284 name=$func_stripname_result
cannam@125 9285 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@125 9286 case " $predeps $postdeps " in
cannam@125 9287 *" $a_deplib "*)
cannam@125 9288 func_append newdeplibs " $a_deplib"
cannam@125 9289 a_deplib=
cannam@125 9290 ;;
cannam@125 9291 esac
cannam@125 9292 fi
cannam@125 9293 if test -n "$a_deplib"; then
cannam@125 9294 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@125 9295 if test -n "$file_magic_glob"; then
cannam@125 9296 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
cannam@125 9297 else
cannam@125 9298 libnameglob=$libname
cannam@125 9299 fi
cannam@125 9300 test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
cannam@125 9301 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
cannam@125 9302 if test yes = "$want_nocaseglob"; then
cannam@125 9303 shopt -s nocaseglob
cannam@125 9304 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
cannam@125 9305 $nocaseglob
cannam@125 9306 else
cannam@125 9307 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
cannam@125 9308 fi
cannam@125 9309 for potent_lib in $potential_libs; do
cannam@125 9310 # Follow soft links.
cannam@125 9311 if ls -lLd "$potent_lib" 2>/dev/null |
cannam@125 9312 $GREP " -> " >/dev/null; then
cannam@125 9313 continue
cannam@125 9314 fi
cannam@125 9315 # The statement above tries to avoid entering an
cannam@125 9316 # endless loop below, in case of cyclic links.
cannam@125 9317 # We might still enter an endless loop, since a link
cannam@125 9318 # loop can be closed while we follow links,
cannam@125 9319 # but so what?
cannam@125 9320 potlib=$potent_lib
cannam@125 9321 while test -h "$potlib" 2>/dev/null; do
cannam@125 9322 potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
cannam@125 9323 case $potliblink in
cannam@125 9324 [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
cannam@125 9325 *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
cannam@125 9326 esac
cannam@125 9327 done
cannam@125 9328 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
cannam@125 9329 $SED -e 10q |
cannam@125 9330 $EGREP "$file_magic_regex" > /dev/null; then
cannam@125 9331 func_append newdeplibs " $a_deplib"
cannam@125 9332 a_deplib=
cannam@125 9333 break 2
cannam@125 9334 fi
cannam@125 9335 done
cannam@125 9336 done
cannam@125 9337 fi
cannam@125 9338 if test -n "$a_deplib"; then
cannam@125 9339 droppeddeps=yes
cannam@125 9340 echo
cannam@125 9341 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
cannam@125 9342 echo "*** I have the capability to make that library automatically link in when"
cannam@125 9343 echo "*** you link to this library. But I can only do this if you have a"
cannam@125 9344 echo "*** shared version of the library, which you do not appear to have"
cannam@125 9345 echo "*** because I did check the linker path looking for a file starting"
cannam@125 9346 if test -z "$potlib"; then
cannam@125 9347 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
cannam@125 9348 else
cannam@125 9349 $ECHO "*** with $libname and none of the candidates passed a file format test"
cannam@125 9350 $ECHO "*** using a file magic. Last file checked: $potlib"
cannam@125 9351 fi
cannam@125 9352 fi
cannam@125 9353 ;;
cannam@125 9354 *)
cannam@125 9355 # Add a -L argument.
cannam@125 9356 func_append newdeplibs " $a_deplib"
cannam@125 9357 ;;
cannam@125 9358 esac
cannam@125 9359 done # Gone through all deplibs.
cannam@125 9360 ;;
cannam@125 9361 match_pattern*)
cannam@125 9362 set dummy $deplibs_check_method; shift
cannam@125 9363 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
cannam@125 9364 for a_deplib in $deplibs; do
cannam@125 9365 case $a_deplib in
cannam@125 9366 -l*)
cannam@125 9367 func_stripname -l '' "$a_deplib"
cannam@125 9368 name=$func_stripname_result
cannam@125 9369 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@125 9370 case " $predeps $postdeps " in
cannam@125 9371 *" $a_deplib "*)
cannam@125 9372 func_append newdeplibs " $a_deplib"
cannam@125 9373 a_deplib=
cannam@125 9374 ;;
cannam@125 9375 esac
cannam@125 9376 fi
cannam@125 9377 if test -n "$a_deplib"; then
cannam@125 9378 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@125 9379 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
cannam@125 9380 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
cannam@125 9381 for potent_lib in $potential_libs; do
cannam@125 9382 potlib=$potent_lib # see symlink-check above in file_magic test
cannam@125 9383 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
cannam@125 9384 $EGREP "$match_pattern_regex" > /dev/null; then
cannam@125 9385 func_append newdeplibs " $a_deplib"
cannam@125 9386 a_deplib=
cannam@125 9387 break 2
cannam@125 9388 fi
cannam@125 9389 done
cannam@125 9390 done
cannam@125 9391 fi
cannam@125 9392 if test -n "$a_deplib"; then
cannam@125 9393 droppeddeps=yes
cannam@125 9394 echo
cannam@125 9395 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
cannam@125 9396 echo "*** I have the capability to make that library automatically link in when"
cannam@125 9397 echo "*** you link to this library. But I can only do this if you have a"
cannam@125 9398 echo "*** shared version of the library, which you do not appear to have"
cannam@125 9399 echo "*** because I did check the linker path looking for a file starting"
cannam@125 9400 if test -z "$potlib"; then
cannam@125 9401 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
cannam@125 9402 else
cannam@125 9403 $ECHO "*** with $libname and none of the candidates passed a file format test"
cannam@125 9404 $ECHO "*** using a regex pattern. Last file checked: $potlib"
cannam@125 9405 fi
cannam@125 9406 fi
cannam@125 9407 ;;
cannam@125 9408 *)
cannam@125 9409 # Add a -L argument.
cannam@125 9410 func_append newdeplibs " $a_deplib"
cannam@125 9411 ;;
cannam@125 9412 esac
cannam@125 9413 done # Gone through all deplibs.
cannam@125 9414 ;;
cannam@125 9415 none | unknown | *)
cannam@125 9416 newdeplibs=
cannam@125 9417 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
cannam@125 9418 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@125 9419 for i in $predeps $postdeps; do
cannam@125 9420 # can't use Xsed below, because $i might contain '/'
cannam@125 9421 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
cannam@125 9422 done
cannam@125 9423 fi
cannam@125 9424 case $tmp_deplibs in
cannam@125 9425 *[!\ \ ]*)
cannam@125 9426 echo
cannam@125 9427 if test none = "$deplibs_check_method"; then
cannam@125 9428 echo "*** Warning: inter-library dependencies are not supported in this platform."
cannam@125 9429 else
cannam@125 9430 echo "*** Warning: inter-library dependencies are not known to be supported."
cannam@125 9431 fi
cannam@125 9432 echo "*** All declared inter-library dependencies are being dropped."
cannam@125 9433 droppeddeps=yes
cannam@125 9434 ;;
cannam@125 9435 esac
cannam@125 9436 ;;
cannam@125 9437 esac
cannam@125 9438 versuffix=$versuffix_save
cannam@125 9439 major=$major_save
cannam@125 9440 release=$release_save
cannam@125 9441 libname=$libname_save
cannam@125 9442 name=$name_save
cannam@125 9443
cannam@125 9444 case $host in
cannam@125 9445 *-*-rhapsody* | *-*-darwin1.[012])
cannam@125 9446 # On Rhapsody replace the C library with the System framework
cannam@125 9447 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
cannam@125 9448 ;;
cannam@125 9449 esac
cannam@125 9450
cannam@125 9451 if test yes = "$droppeddeps"; then
cannam@125 9452 if test yes = "$module"; then
cannam@125 9453 echo
cannam@125 9454 echo "*** Warning: libtool could not satisfy all declared inter-library"
cannam@125 9455 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
cannam@125 9456 echo "*** a static module, that should work as long as the dlopening"
cannam@125 9457 echo "*** application is linked with the -dlopen flag."
cannam@125 9458 if test -z "$global_symbol_pipe"; then
cannam@125 9459 echo
cannam@125 9460 echo "*** However, this would only work if libtool was able to extract symbol"
cannam@125 9461 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
cannam@125 9462 echo "*** not find such a program. So, this module is probably useless."
cannam@125 9463 echo "*** 'nm' from GNU binutils and a full rebuild may help."
cannam@125 9464 fi
cannam@125 9465 if test no = "$build_old_libs"; then
cannam@125 9466 oldlibs=$output_objdir/$libname.$libext
cannam@125 9467 build_libtool_libs=module
cannam@125 9468 build_old_libs=yes
cannam@125 9469 else
cannam@125 9470 build_libtool_libs=no
cannam@125 9471 fi
cannam@125 9472 else
cannam@125 9473 echo "*** The inter-library dependencies that have been dropped here will be"
cannam@125 9474 echo "*** automatically added whenever a program is linked with this library"
cannam@125 9475 echo "*** or is declared to -dlopen it."
cannam@125 9476
cannam@125 9477 if test no = "$allow_undefined"; then
cannam@125 9478 echo
cannam@125 9479 echo "*** Since this library must not contain undefined symbols,"
cannam@125 9480 echo "*** because either the platform does not support them or"
cannam@125 9481 echo "*** it was explicitly requested with -no-undefined,"
cannam@125 9482 echo "*** libtool will only create a static version of it."
cannam@125 9483 if test no = "$build_old_libs"; then
cannam@125 9484 oldlibs=$output_objdir/$libname.$libext
cannam@125 9485 build_libtool_libs=module
cannam@125 9486 build_old_libs=yes
cannam@125 9487 else
cannam@125 9488 build_libtool_libs=no
cannam@125 9489 fi
cannam@125 9490 fi
cannam@125 9491 fi
cannam@125 9492 fi
cannam@125 9493 # Done checking deplibs!
cannam@125 9494 deplibs=$newdeplibs
cannam@125 9495 fi
cannam@125 9496 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
cannam@125 9497 case $host in
cannam@125 9498 *-*-darwin*)
cannam@125 9499 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@125 9500 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@125 9501 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@125 9502 ;;
cannam@125 9503 esac
cannam@125 9504
cannam@125 9505 # move library search paths that coincide with paths to not yet
cannam@125 9506 # installed libraries to the beginning of the library search list
cannam@125 9507 new_libs=
cannam@125 9508 for path in $notinst_path; do
cannam@125 9509 case " $new_libs " in
cannam@125 9510 *" -L$path/$objdir "*) ;;
cannam@125 9511 *)
cannam@125 9512 case " $deplibs " in
cannam@125 9513 *" -L$path/$objdir "*)
cannam@125 9514 func_append new_libs " -L$path/$objdir" ;;
cannam@125 9515 esac
cannam@125 9516 ;;
cannam@125 9517 esac
cannam@125 9518 done
cannam@125 9519 for deplib in $deplibs; do
cannam@125 9520 case $deplib in
cannam@125 9521 -L*)
cannam@125 9522 case " $new_libs " in
cannam@125 9523 *" $deplib "*) ;;
cannam@125 9524 *) func_append new_libs " $deplib" ;;
cannam@125 9525 esac
cannam@125 9526 ;;
cannam@125 9527 *) func_append new_libs " $deplib" ;;
cannam@125 9528 esac
cannam@125 9529 done
cannam@125 9530 deplibs=$new_libs
cannam@125 9531
cannam@125 9532 # All the library-specific variables (install_libdir is set above).
cannam@125 9533 library_names=
cannam@125 9534 old_library=
cannam@125 9535 dlname=
cannam@125 9536
cannam@125 9537 # Test again, we may have decided not to build it any more
cannam@125 9538 if test yes = "$build_libtool_libs"; then
cannam@125 9539 # Remove $wl instances when linking with ld.
cannam@125 9540 # FIXME: should test the right _cmds variable.
cannam@125 9541 case $archive_cmds in
cannam@125 9542 *\$LD\ *) wl= ;;
cannam@125 9543 esac
cannam@125 9544 if test yes = "$hardcode_into_libs"; then
cannam@125 9545 # Hardcode the library paths
cannam@125 9546 hardcode_libdirs=
cannam@125 9547 dep_rpath=
cannam@125 9548 rpath=$finalize_rpath
cannam@125 9549 test relink = "$opt_mode" || rpath=$compile_rpath$rpath
cannam@125 9550 for libdir in $rpath; do
cannam@125 9551 if test -n "$hardcode_libdir_flag_spec"; then
cannam@125 9552 if test -n "$hardcode_libdir_separator"; then
cannam@125 9553 func_replace_sysroot "$libdir"
cannam@125 9554 libdir=$func_replace_sysroot_result
cannam@125 9555 if test -z "$hardcode_libdirs"; then
cannam@125 9556 hardcode_libdirs=$libdir
cannam@125 9557 else
cannam@125 9558 # Just accumulate the unique libdirs.
cannam@125 9559 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
cannam@125 9560 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
cannam@125 9561 ;;
cannam@125 9562 *)
cannam@125 9563 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
cannam@125 9564 ;;
cannam@125 9565 esac
cannam@125 9566 fi
cannam@125 9567 else
cannam@125 9568 eval flag=\"$hardcode_libdir_flag_spec\"
cannam@125 9569 func_append dep_rpath " $flag"
cannam@125 9570 fi
cannam@125 9571 elif test -n "$runpath_var"; then
cannam@125 9572 case "$perm_rpath " in
cannam@125 9573 *" $libdir "*) ;;
cannam@125 9574 *) func_append perm_rpath " $libdir" ;;
cannam@125 9575 esac
cannam@125 9576 fi
cannam@125 9577 done
cannam@125 9578 # Substitute the hardcoded libdirs into the rpath.
cannam@125 9579 if test -n "$hardcode_libdir_separator" &&
cannam@125 9580 test -n "$hardcode_libdirs"; then
cannam@125 9581 libdir=$hardcode_libdirs
cannam@125 9582 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
cannam@125 9583 fi
cannam@125 9584 if test -n "$runpath_var" && test -n "$perm_rpath"; then
cannam@125 9585 # We should set the runpath_var.
cannam@125 9586 rpath=
cannam@125 9587 for dir in $perm_rpath; do
cannam@125 9588 func_append rpath "$dir:"
cannam@125 9589 done
cannam@125 9590 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
cannam@125 9591 fi
cannam@125 9592 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
cannam@125 9593 fi
cannam@125 9594
cannam@125 9595 shlibpath=$finalize_shlibpath
cannam@125 9596 test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
cannam@125 9597 if test -n "$shlibpath"; then
cannam@125 9598 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
cannam@125 9599 fi
cannam@125 9600
cannam@125 9601 # Get the real and link names of the library.
cannam@125 9602 eval shared_ext=\"$shrext_cmds\"
cannam@125 9603 eval library_names=\"$library_names_spec\"
cannam@125 9604 set dummy $library_names
cannam@125 9605 shift
cannam@125 9606 realname=$1
cannam@125 9607 shift
cannam@125 9608
cannam@125 9609 if test -n "$soname_spec"; then
cannam@125 9610 eval soname=\"$soname_spec\"
cannam@125 9611 else
cannam@125 9612 soname=$realname
cannam@125 9613 fi
cannam@125 9614 if test -z "$dlname"; then
cannam@125 9615 dlname=$soname
cannam@125 9616 fi
cannam@125 9617
cannam@125 9618 lib=$output_objdir/$realname
cannam@125 9619 linknames=
cannam@125 9620 for link
cannam@125 9621 do
cannam@125 9622 func_append linknames " $link"
cannam@125 9623 done
cannam@125 9624
cannam@125 9625 # Use standard objects if they are pic
cannam@125 9626 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
cannam@125 9627 test "X$libobjs" = "X " && libobjs=
cannam@125 9628
cannam@125 9629 delfiles=
cannam@125 9630 if test -n "$export_symbols" && test -n "$include_expsyms"; then
cannam@125 9631 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
cannam@125 9632 export_symbols=$output_objdir/$libname.uexp
cannam@125 9633 func_append delfiles " $export_symbols"
cannam@125 9634 fi
cannam@125 9635
cannam@125 9636 orig_export_symbols=
cannam@125 9637 case $host_os in
cannam@125 9638 cygwin* | mingw* | cegcc*)
cannam@125 9639 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
cannam@125 9640 # exporting using user supplied symfile
cannam@125 9641 func_dll_def_p "$export_symbols" || {
cannam@125 9642 # and it's NOT already a .def file. Must figure out
cannam@125 9643 # which of the given symbols are data symbols and tag
cannam@125 9644 # them as such. So, trigger use of export_symbols_cmds.
cannam@125 9645 # export_symbols gets reassigned inside the "prepare
cannam@125 9646 # the list of exported symbols" if statement, so the
cannam@125 9647 # include_expsyms logic still works.
cannam@125 9648 orig_export_symbols=$export_symbols
cannam@125 9649 export_symbols=
cannam@125 9650 always_export_symbols=yes
cannam@125 9651 }
cannam@125 9652 fi
cannam@125 9653 ;;
cannam@125 9654 esac
cannam@125 9655
cannam@125 9656 # Prepare the list of exported symbols
cannam@125 9657 if test -z "$export_symbols"; then
cannam@125 9658 if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
cannam@125 9659 func_verbose "generating symbol list for '$libname.la'"
cannam@125 9660 export_symbols=$output_objdir/$libname.exp
cannam@125 9661 $opt_dry_run || $RM $export_symbols
cannam@125 9662 cmds=$export_symbols_cmds
cannam@125 9663 save_ifs=$IFS; IFS='~'
cannam@125 9664 for cmd1 in $cmds; do
cannam@125 9665 IFS=$save_ifs
cannam@125 9666 # Take the normal branch if the nm_file_list_spec branch
cannam@125 9667 # doesn't work or if tool conversion is not needed.
cannam@125 9668 case $nm_file_list_spec~$to_tool_file_cmd in
cannam@125 9669 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
cannam@125 9670 try_normal_branch=yes
cannam@125 9671 eval cmd=\"$cmd1\"
cannam@125 9672 func_len " $cmd"
cannam@125 9673 len=$func_len_result
cannam@125 9674 ;;
cannam@125 9675 *)
cannam@125 9676 try_normal_branch=no
cannam@125 9677 ;;
cannam@125 9678 esac
cannam@125 9679 if test yes = "$try_normal_branch" \
cannam@125 9680 && { test "$len" -lt "$max_cmd_len" \
cannam@125 9681 || test "$max_cmd_len" -le -1; }
cannam@125 9682 then
cannam@125 9683 func_show_eval "$cmd" 'exit $?'
cannam@125 9684 skipped_export=false
cannam@125 9685 elif test -n "$nm_file_list_spec"; then
cannam@125 9686 func_basename "$output"
cannam@125 9687 output_la=$func_basename_result
cannam@125 9688 save_libobjs=$libobjs
cannam@125 9689 save_output=$output
cannam@125 9690 output=$output_objdir/$output_la.nm
cannam@125 9691 func_to_tool_file "$output"
cannam@125 9692 libobjs=$nm_file_list_spec$func_to_tool_file_result
cannam@125 9693 func_append delfiles " $output"
cannam@125 9694 func_verbose "creating $NM input file list: $output"
cannam@125 9695 for obj in $save_libobjs; do
cannam@125 9696 func_to_tool_file "$obj"
cannam@125 9697 $ECHO "$func_to_tool_file_result"
cannam@125 9698 done > "$output"
cannam@125 9699 eval cmd=\"$cmd1\"
cannam@125 9700 func_show_eval "$cmd" 'exit $?'
cannam@125 9701 output=$save_output
cannam@125 9702 libobjs=$save_libobjs
cannam@125 9703 skipped_export=false
cannam@125 9704 else
cannam@125 9705 # The command line is too long to execute in one step.
cannam@125 9706 func_verbose "using reloadable object file for export list..."
cannam@125 9707 skipped_export=:
cannam@125 9708 # Break out early, otherwise skipped_export may be
cannam@125 9709 # set to false by a later but shorter cmd.
cannam@125 9710 break
cannam@125 9711 fi
cannam@125 9712 done
cannam@125 9713 IFS=$save_ifs
cannam@125 9714 if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
cannam@125 9715 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
cannam@125 9716 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
cannam@125 9717 fi
cannam@125 9718 fi
cannam@125 9719 fi
cannam@125 9720
cannam@125 9721 if test -n "$export_symbols" && test -n "$include_expsyms"; then
cannam@125 9722 tmp_export_symbols=$export_symbols
cannam@125 9723 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
cannam@125 9724 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
cannam@125 9725 fi
cannam@125 9726
cannam@125 9727 if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
cannam@125 9728 # The given exports_symbols file has to be filtered, so filter it.
cannam@125 9729 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
cannam@125 9730 # FIXME: $output_objdir/$libname.filter potentially contains lots of
cannam@125 9731 # 's' commands, which not all seds can handle. GNU sed should be fine
cannam@125 9732 # though. Also, the filter scales superlinearly with the number of
cannam@125 9733 # global variables. join(1) would be nice here, but unfortunately
cannam@125 9734 # isn't a blessed tool.
cannam@125 9735 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
cannam@125 9736 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
cannam@125 9737 export_symbols=$output_objdir/$libname.def
cannam@125 9738 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
cannam@125 9739 fi
cannam@125 9740
cannam@125 9741 tmp_deplibs=
cannam@125 9742 for test_deplib in $deplibs; do
cannam@125 9743 case " $convenience " in
cannam@125 9744 *" $test_deplib "*) ;;
cannam@125 9745 *)
cannam@125 9746 func_append tmp_deplibs " $test_deplib"
cannam@125 9747 ;;
cannam@125 9748 esac
cannam@125 9749 done
cannam@125 9750 deplibs=$tmp_deplibs
cannam@125 9751
cannam@125 9752 if test -n "$convenience"; then
cannam@125 9753 if test -n "$whole_archive_flag_spec" &&
cannam@125 9754 test yes = "$compiler_needs_object" &&
cannam@125 9755 test -z "$libobjs"; then
cannam@125 9756 # extract the archives, so we have objects to list.
cannam@125 9757 # TODO: could optimize this to just extract one archive.
cannam@125 9758 whole_archive_flag_spec=
cannam@125 9759 fi
cannam@125 9760 if test -n "$whole_archive_flag_spec"; then
cannam@125 9761 save_libobjs=$libobjs
cannam@125 9762 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
cannam@125 9763 test "X$libobjs" = "X " && libobjs=
cannam@125 9764 else
cannam@125 9765 gentop=$output_objdir/${outputname}x
cannam@125 9766 func_append generated " $gentop"
cannam@125 9767
cannam@125 9768 func_extract_archives $gentop $convenience
cannam@125 9769 func_append libobjs " $func_extract_archives_result"
cannam@125 9770 test "X$libobjs" = "X " && libobjs=
cannam@125 9771 fi
cannam@125 9772 fi
cannam@125 9773
cannam@125 9774 if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
cannam@125 9775 eval flag=\"$thread_safe_flag_spec\"
cannam@125 9776 func_append linker_flags " $flag"
cannam@125 9777 fi
cannam@125 9778
cannam@125 9779 # Make a backup of the uninstalled library when relinking
cannam@125 9780 if test relink = "$opt_mode"; then
cannam@125 9781 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
cannam@125 9782 fi
cannam@125 9783
cannam@125 9784 # Do each of the archive commands.
cannam@125 9785 if test yes = "$module" && test -n "$module_cmds"; then
cannam@125 9786 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
cannam@125 9787 eval test_cmds=\"$module_expsym_cmds\"
cannam@125 9788 cmds=$module_expsym_cmds
cannam@125 9789 else
cannam@125 9790 eval test_cmds=\"$module_cmds\"
cannam@125 9791 cmds=$module_cmds
cannam@125 9792 fi
cannam@125 9793 else
cannam@125 9794 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
cannam@125 9795 eval test_cmds=\"$archive_expsym_cmds\"
cannam@125 9796 cmds=$archive_expsym_cmds
cannam@125 9797 else
cannam@125 9798 eval test_cmds=\"$archive_cmds\"
cannam@125 9799 cmds=$archive_cmds
cannam@125 9800 fi
cannam@125 9801 fi
cannam@125 9802
cannam@125 9803 if test : != "$skipped_export" &&
cannam@125 9804 func_len " $test_cmds" &&
cannam@125 9805 len=$func_len_result &&
cannam@125 9806 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
cannam@125 9807 :
cannam@125 9808 else
cannam@125 9809 # The command line is too long to link in one step, link piecewise
cannam@125 9810 # or, if using GNU ld and skipped_export is not :, use a linker
cannam@125 9811 # script.
cannam@125 9812
cannam@125 9813 # Save the value of $output and $libobjs because we want to
cannam@125 9814 # use them later. If we have whole_archive_flag_spec, we
cannam@125 9815 # want to use save_libobjs as it was before
cannam@125 9816 # whole_archive_flag_spec was expanded, because we can't
cannam@125 9817 # assume the linker understands whole_archive_flag_spec.
cannam@125 9818 # This may have to be revisited, in case too many
cannam@125 9819 # convenience libraries get linked in and end up exceeding
cannam@125 9820 # the spec.
cannam@125 9821 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
cannam@125 9822 save_libobjs=$libobjs
cannam@125 9823 fi
cannam@125 9824 save_output=$output
cannam@125 9825 func_basename "$output"
cannam@125 9826 output_la=$func_basename_result
cannam@125 9827
cannam@125 9828 # Clear the reloadable object creation command queue and
cannam@125 9829 # initialize k to one.
cannam@125 9830 test_cmds=
cannam@125 9831 concat_cmds=
cannam@125 9832 objlist=
cannam@125 9833 last_robj=
cannam@125 9834 k=1
cannam@125 9835
cannam@125 9836 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
cannam@125 9837 output=$output_objdir/$output_la.lnkscript
cannam@125 9838 func_verbose "creating GNU ld script: $output"
cannam@125 9839 echo 'INPUT (' > $output
cannam@125 9840 for obj in $save_libobjs
cannam@125 9841 do
cannam@125 9842 func_to_tool_file "$obj"
cannam@125 9843 $ECHO "$func_to_tool_file_result" >> $output
cannam@125 9844 done
cannam@125 9845 echo ')' >> $output
cannam@125 9846 func_append delfiles " $output"
cannam@125 9847 func_to_tool_file "$output"
cannam@125 9848 output=$func_to_tool_file_result
cannam@125 9849 elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
cannam@125 9850 output=$output_objdir/$output_la.lnk
cannam@125 9851 func_verbose "creating linker input file list: $output"
cannam@125 9852 : > $output
cannam@125 9853 set x $save_libobjs
cannam@125 9854 shift
cannam@125 9855 firstobj=
cannam@125 9856 if test yes = "$compiler_needs_object"; then
cannam@125 9857 firstobj="$1 "
cannam@125 9858 shift
cannam@125 9859 fi
cannam@125 9860 for obj
cannam@125 9861 do
cannam@125 9862 func_to_tool_file "$obj"
cannam@125 9863 $ECHO "$func_to_tool_file_result" >> $output
cannam@125 9864 done
cannam@125 9865 func_append delfiles " $output"
cannam@125 9866 func_to_tool_file "$output"
cannam@125 9867 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
cannam@125 9868 else
cannam@125 9869 if test -n "$save_libobjs"; then
cannam@125 9870 func_verbose "creating reloadable object files..."
cannam@125 9871 output=$output_objdir/$output_la-$k.$objext
cannam@125 9872 eval test_cmds=\"$reload_cmds\"
cannam@125 9873 func_len " $test_cmds"
cannam@125 9874 len0=$func_len_result
cannam@125 9875 len=$len0
cannam@125 9876
cannam@125 9877 # Loop over the list of objects to be linked.
cannam@125 9878 for obj in $save_libobjs
cannam@125 9879 do
cannam@125 9880 func_len " $obj"
cannam@125 9881 func_arith $len + $func_len_result
cannam@125 9882 len=$func_arith_result
cannam@125 9883 if test -z "$objlist" ||
cannam@125 9884 test "$len" -lt "$max_cmd_len"; then
cannam@125 9885 func_append objlist " $obj"
cannam@125 9886 else
cannam@125 9887 # The command $test_cmds is almost too long, add a
cannam@125 9888 # command to the queue.
cannam@125 9889 if test 1 -eq "$k"; then
cannam@125 9890 # The first file doesn't have a previous command to add.
cannam@125 9891 reload_objs=$objlist
cannam@125 9892 eval concat_cmds=\"$reload_cmds\"
cannam@125 9893 else
cannam@125 9894 # All subsequent reloadable object files will link in
cannam@125 9895 # the last one created.
cannam@125 9896 reload_objs="$objlist $last_robj"
cannam@125 9897 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
cannam@125 9898 fi
cannam@125 9899 last_robj=$output_objdir/$output_la-$k.$objext
cannam@125 9900 func_arith $k + 1
cannam@125 9901 k=$func_arith_result
cannam@125 9902 output=$output_objdir/$output_la-$k.$objext
cannam@125 9903 objlist=" $obj"
cannam@125 9904 func_len " $last_robj"
cannam@125 9905 func_arith $len0 + $func_len_result
cannam@125 9906 len=$func_arith_result
cannam@125 9907 fi
cannam@125 9908 done
cannam@125 9909 # Handle the remaining objects by creating one last
cannam@125 9910 # reloadable object file. All subsequent reloadable object
cannam@125 9911 # files will link in the last one created.
cannam@125 9912 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
cannam@125 9913 reload_objs="$objlist $last_robj"
cannam@125 9914 eval concat_cmds=\"\$concat_cmds$reload_cmds\"
cannam@125 9915 if test -n "$last_robj"; then
cannam@125 9916 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
cannam@125 9917 fi
cannam@125 9918 func_append delfiles " $output"
cannam@125 9919
cannam@125 9920 else
cannam@125 9921 output=
cannam@125 9922 fi
cannam@125 9923
cannam@125 9924 ${skipped_export-false} && {
cannam@125 9925 func_verbose "generating symbol list for '$libname.la'"
cannam@125 9926 export_symbols=$output_objdir/$libname.exp
cannam@125 9927 $opt_dry_run || $RM $export_symbols
cannam@125 9928 libobjs=$output
cannam@125 9929 # Append the command to create the export file.
cannam@125 9930 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
cannam@125 9931 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
cannam@125 9932 if test -n "$last_robj"; then
cannam@125 9933 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
cannam@125 9934 fi
cannam@125 9935 }
cannam@125 9936
cannam@125 9937 test -n "$save_libobjs" &&
cannam@125 9938 func_verbose "creating a temporary reloadable object file: $output"
cannam@125 9939
cannam@125 9940 # Loop through the commands generated above and execute them.
cannam@125 9941 save_ifs=$IFS; IFS='~'
cannam@125 9942 for cmd in $concat_cmds; do
cannam@125 9943 IFS=$save_ifs
cannam@125 9944 $opt_quiet || {
cannam@125 9945 func_quote_for_expand "$cmd"
cannam@125 9946 eval "func_echo $func_quote_for_expand_result"
cannam@125 9947 }
cannam@125 9948 $opt_dry_run || eval "$cmd" || {
cannam@125 9949 lt_exit=$?
cannam@125 9950
cannam@125 9951 # Restore the uninstalled library and exit
cannam@125 9952 if test relink = "$opt_mode"; then
cannam@125 9953 ( cd "$output_objdir" && \
cannam@125 9954 $RM "${realname}T" && \
cannam@125 9955 $MV "${realname}U" "$realname" )
cannam@125 9956 fi
cannam@125 9957
cannam@125 9958 exit $lt_exit
cannam@125 9959 }
cannam@125 9960 done
cannam@125 9961 IFS=$save_ifs
cannam@125 9962
cannam@125 9963 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
cannam@125 9964 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
cannam@125 9965 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
cannam@125 9966 fi
cannam@125 9967 fi
cannam@125 9968
cannam@125 9969 ${skipped_export-false} && {
cannam@125 9970 if test -n "$export_symbols" && test -n "$include_expsyms"; then
cannam@125 9971 tmp_export_symbols=$export_symbols
cannam@125 9972 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
cannam@125 9973 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
cannam@125 9974 fi
cannam@125 9975
cannam@125 9976 if test -n "$orig_export_symbols"; then
cannam@125 9977 # The given exports_symbols file has to be filtered, so filter it.
cannam@125 9978 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
cannam@125 9979 # FIXME: $output_objdir/$libname.filter potentially contains lots of
cannam@125 9980 # 's' commands, which not all seds can handle. GNU sed should be fine
cannam@125 9981 # though. Also, the filter scales superlinearly with the number of
cannam@125 9982 # global variables. join(1) would be nice here, but unfortunately
cannam@125 9983 # isn't a blessed tool.
cannam@125 9984 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
cannam@125 9985 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
cannam@125 9986 export_symbols=$output_objdir/$libname.def
cannam@125 9987 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
cannam@125 9988 fi
cannam@125 9989 }
cannam@125 9990
cannam@125 9991 libobjs=$output
cannam@125 9992 # Restore the value of output.
cannam@125 9993 output=$save_output
cannam@125 9994
cannam@125 9995 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
cannam@125 9996 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
cannam@125 9997 test "X$libobjs" = "X " && libobjs=
cannam@125 9998 fi
cannam@125 9999 # Expand the library linking commands again to reset the
cannam@125 10000 # value of $libobjs for piecewise linking.
cannam@125 10001
cannam@125 10002 # Do each of the archive commands.
cannam@125 10003 if test yes = "$module" && test -n "$module_cmds"; then
cannam@125 10004 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
cannam@125 10005 cmds=$module_expsym_cmds
cannam@125 10006 else
cannam@125 10007 cmds=$module_cmds
cannam@125 10008 fi
cannam@125 10009 else
cannam@125 10010 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
cannam@125 10011 cmds=$archive_expsym_cmds
cannam@125 10012 else
cannam@125 10013 cmds=$archive_cmds
cannam@125 10014 fi
cannam@125 10015 fi
cannam@125 10016 fi
cannam@125 10017
cannam@125 10018 if test -n "$delfiles"; then
cannam@125 10019 # Append the command to remove temporary files to $cmds.
cannam@125 10020 eval cmds=\"\$cmds~\$RM $delfiles\"
cannam@125 10021 fi
cannam@125 10022
cannam@125 10023 # Add any objects from preloaded convenience libraries
cannam@125 10024 if test -n "$dlprefiles"; then
cannam@125 10025 gentop=$output_objdir/${outputname}x
cannam@125 10026 func_append generated " $gentop"
cannam@125 10027
cannam@125 10028 func_extract_archives $gentop $dlprefiles
cannam@125 10029 func_append libobjs " $func_extract_archives_result"
cannam@125 10030 test "X$libobjs" = "X " && libobjs=
cannam@125 10031 fi
cannam@125 10032
cannam@125 10033 save_ifs=$IFS; IFS='~'
cannam@125 10034 for cmd in $cmds; do
cannam@125 10035 IFS=$sp$nl
cannam@125 10036 eval cmd=\"$cmd\"
cannam@125 10037 IFS=$save_ifs
cannam@125 10038 $opt_quiet || {
cannam@125 10039 func_quote_for_expand "$cmd"
cannam@125 10040 eval "func_echo $func_quote_for_expand_result"
cannam@125 10041 }
cannam@125 10042 $opt_dry_run || eval "$cmd" || {
cannam@125 10043 lt_exit=$?
cannam@125 10044
cannam@125 10045 # Restore the uninstalled library and exit
cannam@125 10046 if test relink = "$opt_mode"; then
cannam@125 10047 ( cd "$output_objdir" && \
cannam@125 10048 $RM "${realname}T" && \
cannam@125 10049 $MV "${realname}U" "$realname" )
cannam@125 10050 fi
cannam@125 10051
cannam@125 10052 exit $lt_exit
cannam@125 10053 }
cannam@125 10054 done
cannam@125 10055 IFS=$save_ifs
cannam@125 10056
cannam@125 10057 # Restore the uninstalled library and exit
cannam@125 10058 if test relink = "$opt_mode"; then
cannam@125 10059 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
cannam@125 10060
cannam@125 10061 if test -n "$convenience"; then
cannam@125 10062 if test -z "$whole_archive_flag_spec"; then
cannam@125 10063 func_show_eval '${RM}r "$gentop"'
cannam@125 10064 fi
cannam@125 10065 fi
cannam@125 10066
cannam@125 10067 exit $EXIT_SUCCESS
cannam@125 10068 fi
cannam@125 10069
cannam@125 10070 # Create links to the real library.
cannam@125 10071 for linkname in $linknames; do
cannam@125 10072 if test "$realname" != "$linkname"; then
cannam@125 10073 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
cannam@125 10074 fi
cannam@125 10075 done
cannam@125 10076
cannam@125 10077 # If -module or -export-dynamic was specified, set the dlname.
cannam@125 10078 if test yes = "$module" || test yes = "$export_dynamic"; then
cannam@125 10079 # On all known operating systems, these are identical.
cannam@125 10080 dlname=$soname
cannam@125 10081 fi
cannam@125 10082 fi
cannam@125 10083 ;;
cannam@125 10084
cannam@125 10085 obj)
cannam@125 10086 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
cannam@125 10087 func_warning "'-dlopen' is ignored for objects"
cannam@125 10088 fi
cannam@125 10089
cannam@125 10090 case " $deplibs" in
cannam@125 10091 *\ -l* | *\ -L*)
cannam@125 10092 func_warning "'-l' and '-L' are ignored for objects" ;;
cannam@125 10093 esac
cannam@125 10094
cannam@125 10095 test -n "$rpath" && \
cannam@125 10096 func_warning "'-rpath' is ignored for objects"
cannam@125 10097
cannam@125 10098 test -n "$xrpath" && \
cannam@125 10099 func_warning "'-R' is ignored for objects"
cannam@125 10100
cannam@125 10101 test -n "$vinfo" && \
cannam@125 10102 func_warning "'-version-info' is ignored for objects"
cannam@125 10103
cannam@125 10104 test -n "$release" && \
cannam@125 10105 func_warning "'-release' is ignored for objects"
cannam@125 10106
cannam@125 10107 case $output in
cannam@125 10108 *.lo)
cannam@125 10109 test -n "$objs$old_deplibs" && \
cannam@125 10110 func_fatal_error "cannot build library object '$output' from non-libtool objects"
cannam@125 10111
cannam@125 10112 libobj=$output
cannam@125 10113 func_lo2o "$libobj"
cannam@125 10114 obj=$func_lo2o_result
cannam@125 10115 ;;
cannam@125 10116 *)
cannam@125 10117 libobj=
cannam@125 10118 obj=$output
cannam@125 10119 ;;
cannam@125 10120 esac
cannam@125 10121
cannam@125 10122 # Delete the old objects.
cannam@125 10123 $opt_dry_run || $RM $obj $libobj
cannam@125 10124
cannam@125 10125 # Objects from convenience libraries. This assumes
cannam@125 10126 # single-version convenience libraries. Whenever we create
cannam@125 10127 # different ones for PIC/non-PIC, this we'll have to duplicate
cannam@125 10128 # the extraction.
cannam@125 10129 reload_conv_objs=
cannam@125 10130 gentop=
cannam@125 10131 # if reload_cmds runs $LD directly, get rid of -Wl from
cannam@125 10132 # whole_archive_flag_spec and hope we can get by with turning comma
cannam@125 10133 # into space.
cannam@125 10134 case $reload_cmds in
cannam@125 10135 *\$LD[\ \$]*) wl= ;;
cannam@125 10136 esac
cannam@125 10137 if test -n "$convenience"; then
cannam@125 10138 if test -n "$whole_archive_flag_spec"; then
cannam@125 10139 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
cannam@125 10140 test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
cannam@125 10141 reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
cannam@125 10142 else
cannam@125 10143 gentop=$output_objdir/${obj}x
cannam@125 10144 func_append generated " $gentop"
cannam@125 10145
cannam@125 10146 func_extract_archives $gentop $convenience
cannam@125 10147 reload_conv_objs="$reload_objs $func_extract_archives_result"
cannam@125 10148 fi
cannam@125 10149 fi
cannam@125 10150
cannam@125 10151 # If we're not building shared, we need to use non_pic_objs
cannam@125 10152 test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
cannam@125 10153
cannam@125 10154 # Create the old-style object.
cannam@125 10155 reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
cannam@125 10156
cannam@125 10157 output=$obj
cannam@125 10158 func_execute_cmds "$reload_cmds" 'exit $?'
cannam@125 10159
cannam@125 10160 # Exit if we aren't doing a library object file.
cannam@125 10161 if test -z "$libobj"; then
cannam@125 10162 if test -n "$gentop"; then
cannam@125 10163 func_show_eval '${RM}r "$gentop"'
cannam@125 10164 fi
cannam@125 10165
cannam@125 10166 exit $EXIT_SUCCESS
cannam@125 10167 fi
cannam@125 10168
cannam@125 10169 test yes = "$build_libtool_libs" || {
cannam@125 10170 if test -n "$gentop"; then
cannam@125 10171 func_show_eval '${RM}r "$gentop"'
cannam@125 10172 fi
cannam@125 10173
cannam@125 10174 # Create an invalid libtool object if no PIC, so that we don't
cannam@125 10175 # accidentally link it into a program.
cannam@125 10176 # $show "echo timestamp > $libobj"
cannam@125 10177 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
cannam@125 10178 exit $EXIT_SUCCESS
cannam@125 10179 }
cannam@125 10180
cannam@125 10181 if test -n "$pic_flag" || test default != "$pic_mode"; then
cannam@125 10182 # Only do commands if we really have different PIC objects.
cannam@125 10183 reload_objs="$libobjs $reload_conv_objs"
cannam@125 10184 output=$libobj
cannam@125 10185 func_execute_cmds "$reload_cmds" 'exit $?'
cannam@125 10186 fi
cannam@125 10187
cannam@125 10188 if test -n "$gentop"; then
cannam@125 10189 func_show_eval '${RM}r "$gentop"'
cannam@125 10190 fi
cannam@125 10191
cannam@125 10192 exit $EXIT_SUCCESS
cannam@125 10193 ;;
cannam@125 10194
cannam@125 10195 prog)
cannam@125 10196 case $host in
cannam@125 10197 *cygwin*) func_stripname '' '.exe' "$output"
cannam@125 10198 output=$func_stripname_result.exe;;
cannam@125 10199 esac
cannam@125 10200 test -n "$vinfo" && \
cannam@125 10201 func_warning "'-version-info' is ignored for programs"
cannam@125 10202
cannam@125 10203 test -n "$release" && \
cannam@125 10204 func_warning "'-release' is ignored for programs"
cannam@125 10205
cannam@125 10206 $preload \
cannam@125 10207 && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
cannam@125 10208 && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
cannam@125 10209
cannam@125 10210 case $host in
cannam@125 10211 *-*-rhapsody* | *-*-darwin1.[012])
cannam@125 10212 # On Rhapsody replace the C library is the System framework
cannam@125 10213 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
cannam@125 10214 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
cannam@125 10215 ;;
cannam@125 10216 esac
cannam@125 10217
cannam@125 10218 case $host in
cannam@125 10219 *-*-darwin*)
cannam@125 10220 # Don't allow lazy linking, it breaks C++ global constructors
cannam@125 10221 # But is supposedly fixed on 10.4 or later (yay!).
cannam@125 10222 if test CXX = "$tagname"; then
cannam@125 10223 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
cannam@125 10224 10.[0123])
cannam@125 10225 func_append compile_command " $wl-bind_at_load"
cannam@125 10226 func_append finalize_command " $wl-bind_at_load"
cannam@125 10227 ;;
cannam@125 10228 esac
cannam@125 10229 fi
cannam@125 10230 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
cannam@125 10231 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@125 10232 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@125 10233 ;;
cannam@125 10234 esac
cannam@125 10235
cannam@125 10236
cannam@125 10237 # move library search paths that coincide with paths to not yet
cannam@125 10238 # installed libraries to the beginning of the library search list
cannam@125 10239 new_libs=
cannam@125 10240 for path in $notinst_path; do
cannam@125 10241 case " $new_libs " in
cannam@125 10242 *" -L$path/$objdir "*) ;;
cannam@125 10243 *)
cannam@125 10244 case " $compile_deplibs " in
cannam@125 10245 *" -L$path/$objdir "*)
cannam@125 10246 func_append new_libs " -L$path/$objdir" ;;
cannam@125 10247 esac
cannam@125 10248 ;;
cannam@125 10249 esac
cannam@125 10250 done
cannam@125 10251 for deplib in $compile_deplibs; do
cannam@125 10252 case $deplib in
cannam@125 10253 -L*)
cannam@125 10254 case " $new_libs " in
cannam@125 10255 *" $deplib "*) ;;
cannam@125 10256 *) func_append new_libs " $deplib" ;;
cannam@125 10257 esac
cannam@125 10258 ;;
cannam@125 10259 *) func_append new_libs " $deplib" ;;
cannam@125 10260 esac
cannam@125 10261 done
cannam@125 10262 compile_deplibs=$new_libs
cannam@125 10263
cannam@125 10264
cannam@125 10265 func_append compile_command " $compile_deplibs"
cannam@125 10266 func_append finalize_command " $finalize_deplibs"
cannam@125 10267
cannam@125 10268 if test -n "$rpath$xrpath"; then
cannam@125 10269 # If the user specified any rpath flags, then add them.
cannam@125 10270 for libdir in $rpath $xrpath; do
cannam@125 10271 # This is the magic to use -rpath.
cannam@125 10272 case "$finalize_rpath " in
cannam@125 10273 *" $libdir "*) ;;
cannam@125 10274 *) func_append finalize_rpath " $libdir" ;;
cannam@125 10275 esac
cannam@125 10276 done
cannam@125 10277 fi
cannam@125 10278
cannam@125 10279 # Now hardcode the library paths
cannam@125 10280 rpath=
cannam@125 10281 hardcode_libdirs=
cannam@125 10282 for libdir in $compile_rpath $finalize_rpath; do
cannam@125 10283 if test -n "$hardcode_libdir_flag_spec"; then
cannam@125 10284 if test -n "$hardcode_libdir_separator"; then
cannam@125 10285 if test -z "$hardcode_libdirs"; then
cannam@125 10286 hardcode_libdirs=$libdir
cannam@125 10287 else
cannam@125 10288 # Just accumulate the unique libdirs.
cannam@125 10289 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
cannam@125 10290 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
cannam@125 10291 ;;
cannam@125 10292 *)
cannam@125 10293 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
cannam@125 10294 ;;
cannam@125 10295 esac
cannam@125 10296 fi
cannam@125 10297 else
cannam@125 10298 eval flag=\"$hardcode_libdir_flag_spec\"
cannam@125 10299 func_append rpath " $flag"
cannam@125 10300 fi
cannam@125 10301 elif test -n "$runpath_var"; then
cannam@125 10302 case "$perm_rpath " in
cannam@125 10303 *" $libdir "*) ;;
cannam@125 10304 *) func_append perm_rpath " $libdir" ;;
cannam@125 10305 esac
cannam@125 10306 fi
cannam@125 10307 case $host in
cannam@125 10308 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
cannam@125 10309 testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
cannam@125 10310 case :$dllsearchpath: in
cannam@125 10311 *":$libdir:"*) ;;
cannam@125 10312 ::) dllsearchpath=$libdir;;
cannam@125 10313 *) func_append dllsearchpath ":$libdir";;
cannam@125 10314 esac
cannam@125 10315 case :$dllsearchpath: in
cannam@125 10316 *":$testbindir:"*) ;;
cannam@125 10317 ::) dllsearchpath=$testbindir;;
cannam@125 10318 *) func_append dllsearchpath ":$testbindir";;
cannam@125 10319 esac
cannam@125 10320 ;;
cannam@125 10321 esac
cannam@125 10322 done
cannam@125 10323 # Substitute the hardcoded libdirs into the rpath.
cannam@125 10324 if test -n "$hardcode_libdir_separator" &&
cannam@125 10325 test -n "$hardcode_libdirs"; then
cannam@125 10326 libdir=$hardcode_libdirs
cannam@125 10327 eval rpath=\" $hardcode_libdir_flag_spec\"
cannam@125 10328 fi
cannam@125 10329 compile_rpath=$rpath
cannam@125 10330
cannam@125 10331 rpath=
cannam@125 10332 hardcode_libdirs=
cannam@125 10333 for libdir in $finalize_rpath; do
cannam@125 10334 if test -n "$hardcode_libdir_flag_spec"; then
cannam@125 10335 if test -n "$hardcode_libdir_separator"; then
cannam@125 10336 if test -z "$hardcode_libdirs"; then
cannam@125 10337 hardcode_libdirs=$libdir
cannam@125 10338 else
cannam@125 10339 # Just accumulate the unique libdirs.
cannam@125 10340 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
cannam@125 10341 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
cannam@125 10342 ;;
cannam@125 10343 *)
cannam@125 10344 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
cannam@125 10345 ;;
cannam@125 10346 esac
cannam@125 10347 fi
cannam@125 10348 else
cannam@125 10349 eval flag=\"$hardcode_libdir_flag_spec\"
cannam@125 10350 func_append rpath " $flag"
cannam@125 10351 fi
cannam@125 10352 elif test -n "$runpath_var"; then
cannam@125 10353 case "$finalize_perm_rpath " in
cannam@125 10354 *" $libdir "*) ;;
cannam@125 10355 *) func_append finalize_perm_rpath " $libdir" ;;
cannam@125 10356 esac
cannam@125 10357 fi
cannam@125 10358 done
cannam@125 10359 # Substitute the hardcoded libdirs into the rpath.
cannam@125 10360 if test -n "$hardcode_libdir_separator" &&
cannam@125 10361 test -n "$hardcode_libdirs"; then
cannam@125 10362 libdir=$hardcode_libdirs
cannam@125 10363 eval rpath=\" $hardcode_libdir_flag_spec\"
cannam@125 10364 fi
cannam@125 10365 finalize_rpath=$rpath
cannam@125 10366
cannam@125 10367 if test -n "$libobjs" && test yes = "$build_old_libs"; then
cannam@125 10368 # Transform all the library objects into standard objects.
cannam@125 10369 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
cannam@125 10370 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
cannam@125 10371 fi
cannam@125 10372
cannam@125 10373 func_generate_dlsyms "$outputname" "@PROGRAM@" false
cannam@125 10374
cannam@125 10375 # template prelinking step
cannam@125 10376 if test -n "$prelink_cmds"; then
cannam@125 10377 func_execute_cmds "$prelink_cmds" 'exit $?'
cannam@125 10378 fi
cannam@125 10379
cannam@125 10380 wrappers_required=:
cannam@125 10381 case $host in
cannam@125 10382 *cegcc* | *mingw32ce*)
cannam@125 10383 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
cannam@125 10384 wrappers_required=false
cannam@125 10385 ;;
cannam@125 10386 *cygwin* | *mingw* )
cannam@125 10387 test yes = "$build_libtool_libs" || wrappers_required=false
cannam@125 10388 ;;
cannam@125 10389 *)
cannam@125 10390 if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
cannam@125 10391 wrappers_required=false
cannam@125 10392 fi
cannam@125 10393 ;;
cannam@125 10394 esac
cannam@125 10395 $wrappers_required || {
cannam@125 10396 # Replace the output file specification.
cannam@125 10397 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
cannam@125 10398 link_command=$compile_command$compile_rpath
cannam@125 10399
cannam@125 10400 # We have no uninstalled library dependencies, so finalize right now.
cannam@125 10401 exit_status=0
cannam@125 10402 func_show_eval "$link_command" 'exit_status=$?'
cannam@125 10403
cannam@125 10404 if test -n "$postlink_cmds"; then
cannam@125 10405 func_to_tool_file "$output"
cannam@125 10406 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
cannam@125 10407 func_execute_cmds "$postlink_cmds" 'exit $?'
cannam@125 10408 fi
cannam@125 10409
cannam@125 10410 # Delete the generated files.
cannam@125 10411 if test -f "$output_objdir/${outputname}S.$objext"; then
cannam@125 10412 func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
cannam@125 10413 fi
cannam@125 10414
cannam@125 10415 exit $exit_status
cannam@125 10416 }
cannam@125 10417
cannam@125 10418 if test -n "$compile_shlibpath$finalize_shlibpath"; then
cannam@125 10419 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
cannam@125 10420 fi
cannam@125 10421 if test -n "$finalize_shlibpath"; then
cannam@125 10422 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
cannam@125 10423 fi
cannam@125 10424
cannam@125 10425 compile_var=
cannam@125 10426 finalize_var=
cannam@125 10427 if test -n "$runpath_var"; then
cannam@125 10428 if test -n "$perm_rpath"; then
cannam@125 10429 # We should set the runpath_var.
cannam@125 10430 rpath=
cannam@125 10431 for dir in $perm_rpath; do
cannam@125 10432 func_append rpath "$dir:"
cannam@125 10433 done
cannam@125 10434 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
cannam@125 10435 fi
cannam@125 10436 if test -n "$finalize_perm_rpath"; then
cannam@125 10437 # We should set the runpath_var.
cannam@125 10438 rpath=
cannam@125 10439 for dir in $finalize_perm_rpath; do
cannam@125 10440 func_append rpath "$dir:"
cannam@125 10441 done
cannam@125 10442 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
cannam@125 10443 fi
cannam@125 10444 fi
cannam@125 10445
cannam@125 10446 if test yes = "$no_install"; then
cannam@125 10447 # We don't need to create a wrapper script.
cannam@125 10448 link_command=$compile_var$compile_command$compile_rpath
cannam@125 10449 # Replace the output file specification.
cannam@125 10450 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
cannam@125 10451 # Delete the old output file.
cannam@125 10452 $opt_dry_run || $RM $output
cannam@125 10453 # Link the executable and exit
cannam@125 10454 func_show_eval "$link_command" 'exit $?'
cannam@125 10455
cannam@125 10456 if test -n "$postlink_cmds"; then
cannam@125 10457 func_to_tool_file "$output"
cannam@125 10458 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
cannam@125 10459 func_execute_cmds "$postlink_cmds" 'exit $?'
cannam@125 10460 fi
cannam@125 10461
cannam@125 10462 exit $EXIT_SUCCESS
cannam@125 10463 fi
cannam@125 10464
cannam@125 10465 case $hardcode_action,$fast_install in
cannam@125 10466 relink,*)
cannam@125 10467 # Fast installation is not supported
cannam@125 10468 link_command=$compile_var$compile_command$compile_rpath
cannam@125 10469 relink_command=$finalize_var$finalize_command$finalize_rpath
cannam@125 10470
cannam@125 10471 func_warning "this platform does not like uninstalled shared libraries"
cannam@125 10472 func_warning "'$output' will be relinked during installation"
cannam@125 10473 ;;
cannam@125 10474 *,yes)
cannam@125 10475 link_command=$finalize_var$compile_command$finalize_rpath
cannam@125 10476 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
cannam@125 10477 ;;
cannam@125 10478 *,no)
cannam@125 10479 link_command=$compile_var$compile_command$compile_rpath
cannam@125 10480 relink_command=$finalize_var$finalize_command$finalize_rpath
cannam@125 10481 ;;
cannam@125 10482 *,needless)
cannam@125 10483 link_command=$finalize_var$compile_command$finalize_rpath
cannam@125 10484 relink_command=
cannam@125 10485 ;;
cannam@125 10486 esac
cannam@125 10487
cannam@125 10488 # Replace the output file specification.
cannam@125 10489 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
cannam@125 10490
cannam@125 10491 # Delete the old output files.
cannam@125 10492 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
cannam@125 10493
cannam@125 10494 func_show_eval "$link_command" 'exit $?'
cannam@125 10495
cannam@125 10496 if test -n "$postlink_cmds"; then
cannam@125 10497 func_to_tool_file "$output_objdir/$outputname"
cannam@125 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'`
cannam@125 10499 func_execute_cmds "$postlink_cmds" 'exit $?'
cannam@125 10500 fi
cannam@125 10501
cannam@125 10502 # Now create the wrapper script.
cannam@125 10503 func_verbose "creating $output"
cannam@125 10504
cannam@125 10505 # Quote the relink command for shipping.
cannam@125 10506 if test -n "$relink_command"; then
cannam@125 10507 # Preserve any variables that may affect compiler behavior
cannam@125 10508 for var in $variables_saved_for_relink; do
cannam@125 10509 if eval test -z \"\${$var+set}\"; then
cannam@125 10510 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
cannam@125 10511 elif eval var_value=\$$var; test -z "$var_value"; then
cannam@125 10512 relink_command="$var=; export $var; $relink_command"
cannam@125 10513 else
cannam@125 10514 func_quote_for_eval "$var_value"
cannam@125 10515 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
cannam@125 10516 fi
cannam@125 10517 done
cannam@125 10518 relink_command="(cd `pwd`; $relink_command)"
cannam@125 10519 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
cannam@125 10520 fi
cannam@125 10521
cannam@125 10522 # Only actually do things if not in dry run mode.
cannam@125 10523 $opt_dry_run || {
cannam@125 10524 # win32 will think the script is a binary if it has
cannam@125 10525 # a .exe suffix, so we strip it off here.
cannam@125 10526 case $output in
cannam@125 10527 *.exe) func_stripname '' '.exe' "$output"
cannam@125 10528 output=$func_stripname_result ;;
cannam@125 10529 esac
cannam@125 10530 # test for cygwin because mv fails w/o .exe extensions
cannam@125 10531 case $host in
cannam@125 10532 *cygwin*)
cannam@125 10533 exeext=.exe
cannam@125 10534 func_stripname '' '.exe' "$outputname"
cannam@125 10535 outputname=$func_stripname_result ;;
cannam@125 10536 *) exeext= ;;
cannam@125 10537 esac
cannam@125 10538 case $host in
cannam@125 10539 *cygwin* | *mingw* )
cannam@125 10540 func_dirname_and_basename "$output" "" "."
cannam@125 10541 output_name=$func_basename_result
cannam@125 10542 output_path=$func_dirname_result
cannam@125 10543 cwrappersource=$output_path/$objdir/lt-$output_name.c
cannam@125 10544 cwrapper=$output_path/$output_name.exe
cannam@125 10545 $RM $cwrappersource $cwrapper
cannam@125 10546 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
cannam@125 10547
cannam@125 10548 func_emit_cwrapperexe_src > $cwrappersource
cannam@125 10549
cannam@125 10550 # The wrapper executable is built using the $host compiler,
cannam@125 10551 # because it contains $host paths and files. If cross-
cannam@125 10552 # compiling, it, like the target executable, must be
cannam@125 10553 # executed on the $host or under an emulation environment.
cannam@125 10554 $opt_dry_run || {
cannam@125 10555 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
cannam@125 10556 $STRIP $cwrapper
cannam@125 10557 }
cannam@125 10558
cannam@125 10559 # Now, create the wrapper script for func_source use:
cannam@125 10560 func_ltwrapper_scriptname $cwrapper
cannam@125 10561 $RM $func_ltwrapper_scriptname_result
cannam@125 10562 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
cannam@125 10563 $opt_dry_run || {
cannam@125 10564 # note: this script will not be executed, so do not chmod.
cannam@125 10565 if test "x$build" = "x$host"; then
cannam@125 10566 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
cannam@125 10567 else
cannam@125 10568 func_emit_wrapper no > $func_ltwrapper_scriptname_result
cannam@125 10569 fi
cannam@125 10570 }
cannam@125 10571 ;;
cannam@125 10572 * )
cannam@125 10573 $RM $output
cannam@125 10574 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
cannam@125 10575
cannam@125 10576 func_emit_wrapper no > $output
cannam@125 10577 chmod +x $output
cannam@125 10578 ;;
cannam@125 10579 esac
cannam@125 10580 }
cannam@125 10581 exit $EXIT_SUCCESS
cannam@125 10582 ;;
cannam@125 10583 esac
cannam@125 10584
cannam@125 10585 # See if we need to build an old-fashioned archive.
cannam@125 10586 for oldlib in $oldlibs; do
cannam@125 10587
cannam@125 10588 case $build_libtool_libs in
cannam@125 10589 convenience)
cannam@125 10590 oldobjs="$libobjs_save $symfileobj"
cannam@125 10591 addlibs=$convenience
cannam@125 10592 build_libtool_libs=no
cannam@125 10593 ;;
cannam@125 10594 module)
cannam@125 10595 oldobjs=$libobjs_save
cannam@125 10596 addlibs=$old_convenience
cannam@125 10597 build_libtool_libs=no
cannam@125 10598 ;;
cannam@125 10599 *)
cannam@125 10600 oldobjs="$old_deplibs $non_pic_objects"
cannam@125 10601 $preload && test -f "$symfileobj" \
cannam@125 10602 && func_append oldobjs " $symfileobj"
cannam@125 10603 addlibs=$old_convenience
cannam@125 10604 ;;
cannam@125 10605 esac
cannam@125 10606
cannam@125 10607 if test -n "$addlibs"; then
cannam@125 10608 gentop=$output_objdir/${outputname}x
cannam@125 10609 func_append generated " $gentop"
cannam@125 10610
cannam@125 10611 func_extract_archives $gentop $addlibs
cannam@125 10612 func_append oldobjs " $func_extract_archives_result"
cannam@125 10613 fi
cannam@125 10614
cannam@125 10615 # Do each command in the archive commands.
cannam@125 10616 if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
cannam@125 10617 cmds=$old_archive_from_new_cmds
cannam@125 10618 else
cannam@125 10619
cannam@125 10620 # Add any objects from preloaded convenience libraries
cannam@125 10621 if test -n "$dlprefiles"; then
cannam@125 10622 gentop=$output_objdir/${outputname}x
cannam@125 10623 func_append generated " $gentop"
cannam@125 10624
cannam@125 10625 func_extract_archives $gentop $dlprefiles
cannam@125 10626 func_append oldobjs " $func_extract_archives_result"
cannam@125 10627 fi
cannam@125 10628
cannam@125 10629 # POSIX demands no paths to be encoded in archives. We have
cannam@125 10630 # to avoid creating archives with duplicate basenames if we
cannam@125 10631 # might have to extract them afterwards, e.g., when creating a
cannam@125 10632 # static archive out of a convenience library, or when linking
cannam@125 10633 # the entirety of a libtool archive into another (currently
cannam@125 10634 # not supported by libtool).
cannam@125 10635 if (for obj in $oldobjs
cannam@125 10636 do
cannam@125 10637 func_basename "$obj"
cannam@125 10638 $ECHO "$func_basename_result"
cannam@125 10639 done | sort | sort -uc >/dev/null 2>&1); then
cannam@125 10640 :
cannam@125 10641 else
cannam@125 10642 echo "copying selected object files to avoid basename conflicts..."
cannam@125 10643 gentop=$output_objdir/${outputname}x
cannam@125 10644 func_append generated " $gentop"
cannam@125 10645 func_mkdir_p "$gentop"
cannam@125 10646 save_oldobjs=$oldobjs
cannam@125 10647 oldobjs=
cannam@125 10648 counter=1
cannam@125 10649 for obj in $save_oldobjs
cannam@125 10650 do
cannam@125 10651 func_basename "$obj"
cannam@125 10652 objbase=$func_basename_result
cannam@125 10653 case " $oldobjs " in
cannam@125 10654 " ") oldobjs=$obj ;;
cannam@125 10655 *[\ /]"$objbase "*)
cannam@125 10656 while :; do
cannam@125 10657 # Make sure we don't pick an alternate name that also
cannam@125 10658 # overlaps.
cannam@125 10659 newobj=lt$counter-$objbase
cannam@125 10660 func_arith $counter + 1
cannam@125 10661 counter=$func_arith_result
cannam@125 10662 case " $oldobjs " in
cannam@125 10663 *[\ /]"$newobj "*) ;;
cannam@125 10664 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
cannam@125 10665 esac
cannam@125 10666 done
cannam@125 10667 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
cannam@125 10668 func_append oldobjs " $gentop/$newobj"
cannam@125 10669 ;;
cannam@125 10670 *) func_append oldobjs " $obj" ;;
cannam@125 10671 esac
cannam@125 10672 done
cannam@125 10673 fi
cannam@125 10674 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
cannam@125 10675 tool_oldlib=$func_to_tool_file_result
cannam@125 10676 eval cmds=\"$old_archive_cmds\"
cannam@125 10677
cannam@125 10678 func_len " $cmds"
cannam@125 10679 len=$func_len_result
cannam@125 10680 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
cannam@125 10681 cmds=$old_archive_cmds
cannam@125 10682 elif test -n "$archiver_list_spec"; then
cannam@125 10683 func_verbose "using command file archive linking..."
cannam@125 10684 for obj in $oldobjs
cannam@125 10685 do
cannam@125 10686 func_to_tool_file "$obj"
cannam@125 10687 $ECHO "$func_to_tool_file_result"
cannam@125 10688 done > $output_objdir/$libname.libcmd
cannam@125 10689 func_to_tool_file "$output_objdir/$libname.libcmd"
cannam@125 10690 oldobjs=" $archiver_list_spec$func_to_tool_file_result"
cannam@125 10691 cmds=$old_archive_cmds
cannam@125 10692 else
cannam@125 10693 # the command line is too long to link in one step, link in parts
cannam@125 10694 func_verbose "using piecewise archive linking..."
cannam@125 10695 save_RANLIB=$RANLIB
cannam@125 10696 RANLIB=:
cannam@125 10697 objlist=
cannam@125 10698 concat_cmds=
cannam@125 10699 save_oldobjs=$oldobjs
cannam@125 10700 oldobjs=
cannam@125 10701 # Is there a better way of finding the last object in the list?
cannam@125 10702 for obj in $save_oldobjs
cannam@125 10703 do
cannam@125 10704 last_oldobj=$obj
cannam@125 10705 done
cannam@125 10706 eval test_cmds=\"$old_archive_cmds\"
cannam@125 10707 func_len " $test_cmds"
cannam@125 10708 len0=$func_len_result
cannam@125 10709 len=$len0
cannam@125 10710 for obj in $save_oldobjs
cannam@125 10711 do
cannam@125 10712 func_len " $obj"
cannam@125 10713 func_arith $len + $func_len_result
cannam@125 10714 len=$func_arith_result
cannam@125 10715 func_append objlist " $obj"
cannam@125 10716 if test "$len" -lt "$max_cmd_len"; then
cannam@125 10717 :
cannam@125 10718 else
cannam@125 10719 # the above command should be used before it gets too long
cannam@125 10720 oldobjs=$objlist
cannam@125 10721 if test "$obj" = "$last_oldobj"; then
cannam@125 10722 RANLIB=$save_RANLIB
cannam@125 10723 fi
cannam@125 10724 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
cannam@125 10725 eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
cannam@125 10726 objlist=
cannam@125 10727 len=$len0
cannam@125 10728 fi
cannam@125 10729 done
cannam@125 10730 RANLIB=$save_RANLIB
cannam@125 10731 oldobjs=$objlist
cannam@125 10732 if test -z "$oldobjs"; then
cannam@125 10733 eval cmds=\"\$concat_cmds\"
cannam@125 10734 else
cannam@125 10735 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
cannam@125 10736 fi
cannam@125 10737 fi
cannam@125 10738 fi
cannam@125 10739 func_execute_cmds "$cmds" 'exit $?'
cannam@125 10740 done
cannam@125 10741
cannam@125 10742 test -n "$generated" && \
cannam@125 10743 func_show_eval "${RM}r$generated"
cannam@125 10744
cannam@125 10745 # Now create the libtool archive.
cannam@125 10746 case $output in
cannam@125 10747 *.la)
cannam@125 10748 old_library=
cannam@125 10749 test yes = "$build_old_libs" && old_library=$libname.$libext
cannam@125 10750 func_verbose "creating $output"
cannam@125 10751
cannam@125 10752 # Preserve any variables that may affect compiler behavior
cannam@125 10753 for var in $variables_saved_for_relink; do
cannam@125 10754 if eval test -z \"\${$var+set}\"; then
cannam@125 10755 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
cannam@125 10756 elif eval var_value=\$$var; test -z "$var_value"; then
cannam@125 10757 relink_command="$var=; export $var; $relink_command"
cannam@125 10758 else
cannam@125 10759 func_quote_for_eval "$var_value"
cannam@125 10760 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
cannam@125 10761 fi
cannam@125 10762 done
cannam@125 10763 # Quote the link command for shipping.
cannam@125 10764 relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
cannam@125 10765 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
cannam@125 10766 if test yes = "$hardcode_automatic"; then
cannam@125 10767 relink_command=
cannam@125 10768 fi
cannam@125 10769
cannam@125 10770 # Only create the output if not a dry run.
cannam@125 10771 $opt_dry_run || {
cannam@125 10772 for installed in no yes; do
cannam@125 10773 if test yes = "$installed"; then
cannam@125 10774 if test -z "$install_libdir"; then
cannam@125 10775 break
cannam@125 10776 fi
cannam@125 10777 output=$output_objdir/${outputname}i
cannam@125 10778 # Replace all uninstalled libtool libraries with the installed ones
cannam@125 10779 newdependency_libs=
cannam@125 10780 for deplib in $dependency_libs; do
cannam@125 10781 case $deplib in
cannam@125 10782 *.la)
cannam@125 10783 func_basename "$deplib"
cannam@125 10784 name=$func_basename_result
cannam@125 10785 func_resolve_sysroot "$deplib"
cannam@125 10786 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
cannam@125 10787 test -z "$libdir" && \
cannam@125 10788 func_fatal_error "'$deplib' is not a valid libtool archive"
cannam@125 10789 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
cannam@125 10790 ;;
cannam@125 10791 -L*)
cannam@125 10792 func_stripname -L '' "$deplib"
cannam@125 10793 func_replace_sysroot "$func_stripname_result"
cannam@125 10794 func_append newdependency_libs " -L$func_replace_sysroot_result"
cannam@125 10795 ;;
cannam@125 10796 -R*)
cannam@125 10797 func_stripname -R '' "$deplib"
cannam@125 10798 func_replace_sysroot "$func_stripname_result"
cannam@125 10799 func_append newdependency_libs " -R$func_replace_sysroot_result"
cannam@125 10800 ;;
cannam@125 10801 *) func_append newdependency_libs " $deplib" ;;
cannam@125 10802 esac
cannam@125 10803 done
cannam@125 10804 dependency_libs=$newdependency_libs
cannam@125 10805 newdlfiles=
cannam@125 10806
cannam@125 10807 for lib in $dlfiles; do
cannam@125 10808 case $lib in
cannam@125 10809 *.la)
cannam@125 10810 func_basename "$lib"
cannam@125 10811 name=$func_basename_result
cannam@125 10812 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
cannam@125 10813 test -z "$libdir" && \
cannam@125 10814 func_fatal_error "'$lib' is not a valid libtool archive"
cannam@125 10815 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
cannam@125 10816 ;;
cannam@125 10817 *) func_append newdlfiles " $lib" ;;
cannam@125 10818 esac
cannam@125 10819 done
cannam@125 10820 dlfiles=$newdlfiles
cannam@125 10821 newdlprefiles=
cannam@125 10822 for lib in $dlprefiles; do
cannam@125 10823 case $lib in
cannam@125 10824 *.la)
cannam@125 10825 # Only pass preopened files to the pseudo-archive (for
cannam@125 10826 # eventual linking with the app. that links it) if we
cannam@125 10827 # didn't already link the preopened objects directly into
cannam@125 10828 # the library:
cannam@125 10829 func_basename "$lib"
cannam@125 10830 name=$func_basename_result
cannam@125 10831 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
cannam@125 10832 test -z "$libdir" && \
cannam@125 10833 func_fatal_error "'$lib' is not a valid libtool archive"
cannam@125 10834 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
cannam@125 10835 ;;
cannam@125 10836 esac
cannam@125 10837 done
cannam@125 10838 dlprefiles=$newdlprefiles
cannam@125 10839 else
cannam@125 10840 newdlfiles=
cannam@125 10841 for lib in $dlfiles; do
cannam@125 10842 case $lib in
cannam@125 10843 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
cannam@125 10844 *) abs=`pwd`"/$lib" ;;
cannam@125 10845 esac
cannam@125 10846 func_append newdlfiles " $abs"
cannam@125 10847 done
cannam@125 10848 dlfiles=$newdlfiles
cannam@125 10849 newdlprefiles=
cannam@125 10850 for lib in $dlprefiles; do
cannam@125 10851 case $lib in
cannam@125 10852 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
cannam@125 10853 *) abs=`pwd`"/$lib" ;;
cannam@125 10854 esac
cannam@125 10855 func_append newdlprefiles " $abs"
cannam@125 10856 done
cannam@125 10857 dlprefiles=$newdlprefiles
cannam@125 10858 fi
cannam@125 10859 $RM $output
cannam@125 10860 # place dlname in correct position for cygwin
cannam@125 10861 # In fact, it would be nice if we could use this code for all target
cannam@125 10862 # systems that can't hard-code library paths into their executables
cannam@125 10863 # and that have no shared library path variable independent of PATH,
cannam@125 10864 # but it turns out we can't easily determine that from inspecting
cannam@125 10865 # libtool variables, so we have to hard-code the OSs to which it
cannam@125 10866 # applies here; at the moment, that means platforms that use the PE
cannam@125 10867 # object format with DLL files. See the long comment at the top of
cannam@125 10868 # tests/bindir.at for full details.
cannam@125 10869 tdlname=$dlname
cannam@125 10870 case $host,$output,$installed,$module,$dlname in
cannam@125 10871 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
cannam@125 10872 # If a -bindir argument was supplied, place the dll there.
cannam@125 10873 if test -n "$bindir"; then
cannam@125 10874 func_relative_path "$install_libdir" "$bindir"
cannam@125 10875 tdlname=$func_relative_path_result/$dlname
cannam@125 10876 else
cannam@125 10877 # Otherwise fall back on heuristic.
cannam@125 10878 tdlname=../bin/$dlname
cannam@125 10879 fi
cannam@125 10880 ;;
cannam@125 10881 esac
cannam@125 10882 $ECHO > $output "\
cannam@125 10883 # $outputname - a libtool library file
cannam@125 10884 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
cannam@125 10885 #
cannam@125 10886 # Please DO NOT delete this file!
cannam@125 10887 # It is necessary for linking the library.
cannam@125 10888
cannam@125 10889 # The name that we can dlopen(3).
cannam@125 10890 dlname='$tdlname'
cannam@125 10891
cannam@125 10892 # Names of this library.
cannam@125 10893 library_names='$library_names'
cannam@125 10894
cannam@125 10895 # The name of the static archive.
cannam@125 10896 old_library='$old_library'
cannam@125 10897
cannam@125 10898 # Linker flags that cannot go in dependency_libs.
cannam@125 10899 inherited_linker_flags='$new_inherited_linker_flags'
cannam@125 10900
cannam@125 10901 # Libraries that this one depends upon.
cannam@125 10902 dependency_libs='$dependency_libs'
cannam@125 10903
cannam@125 10904 # Names of additional weak libraries provided by this library
cannam@125 10905 weak_library_names='$weak_libs'
cannam@125 10906
cannam@125 10907 # Version information for $libname.
cannam@125 10908 current=$current
cannam@125 10909 age=$age
cannam@125 10910 revision=$revision
cannam@125 10911
cannam@125 10912 # Is this an already installed library?
cannam@125 10913 installed=$installed
cannam@125 10914
cannam@125 10915 # Should we warn about portability when linking against -modules?
cannam@125 10916 shouldnotlink=$module
cannam@125 10917
cannam@125 10918 # Files to dlopen/dlpreopen
cannam@125 10919 dlopen='$dlfiles'
cannam@125 10920 dlpreopen='$dlprefiles'
cannam@125 10921
cannam@125 10922 # Directory that this library needs to be installed in:
cannam@125 10923 libdir='$install_libdir'"
cannam@125 10924 if test no,yes = "$installed,$need_relink"; then
cannam@125 10925 $ECHO >> $output "\
cannam@125 10926 relink_command=\"$relink_command\""
cannam@125 10927 fi
cannam@125 10928 done
cannam@125 10929 }
cannam@125 10930
cannam@125 10931 # Do a symbolic link so that the libtool archive can be found in
cannam@125 10932 # LD_LIBRARY_PATH before the program is installed.
cannam@125 10933 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
cannam@125 10934 ;;
cannam@125 10935 esac
cannam@125 10936 exit $EXIT_SUCCESS
cannam@125 10937 }
cannam@125 10938
cannam@125 10939 if test link = "$opt_mode" || test relink = "$opt_mode"; then
cannam@125 10940 func_mode_link ${1+"$@"}
cannam@125 10941 fi
cannam@125 10942
cannam@125 10943
cannam@125 10944 # func_mode_uninstall arg...
cannam@125 10945 func_mode_uninstall ()
cannam@125 10946 {
cannam@125 10947 $debug_cmd
cannam@125 10948
cannam@125 10949 RM=$nonopt
cannam@125 10950 files=
cannam@125 10951 rmforce=false
cannam@125 10952 exit_status=0
cannam@125 10953
cannam@125 10954 # This variable tells wrapper scripts just to set variables rather
cannam@125 10955 # than running their programs.
cannam@125 10956 libtool_install_magic=$magic
cannam@125 10957
cannam@125 10958 for arg
cannam@125 10959 do
cannam@125 10960 case $arg in
cannam@125 10961 -f) func_append RM " $arg"; rmforce=: ;;
cannam@125 10962 -*) func_append RM " $arg" ;;
cannam@125 10963 *) func_append files " $arg" ;;
cannam@125 10964 esac
cannam@125 10965 done
cannam@125 10966
cannam@125 10967 test -z "$RM" && \
cannam@125 10968 func_fatal_help "you must specify an RM program"
cannam@125 10969
cannam@125 10970 rmdirs=
cannam@125 10971
cannam@125 10972 for file in $files; do
cannam@125 10973 func_dirname "$file" "" "."
cannam@125 10974 dir=$func_dirname_result
cannam@125 10975 if test . = "$dir"; then
cannam@125 10976 odir=$objdir
cannam@125 10977 else
cannam@125 10978 odir=$dir/$objdir
cannam@125 10979 fi
cannam@125 10980 func_basename "$file"
cannam@125 10981 name=$func_basename_result
cannam@125 10982 test uninstall = "$opt_mode" && odir=$dir
cannam@125 10983
cannam@125 10984 # Remember odir for removal later, being careful to avoid duplicates
cannam@125 10985 if test clean = "$opt_mode"; then
cannam@125 10986 case " $rmdirs " in
cannam@125 10987 *" $odir "*) ;;
cannam@125 10988 *) func_append rmdirs " $odir" ;;
cannam@125 10989 esac
cannam@125 10990 fi
cannam@125 10991
cannam@125 10992 # Don't error if the file doesn't exist and rm -f was used.
cannam@125 10993 if { test -L "$file"; } >/dev/null 2>&1 ||
cannam@125 10994 { test -h "$file"; } >/dev/null 2>&1 ||
cannam@125 10995 test -f "$file"; then
cannam@125 10996 :
cannam@125 10997 elif test -d "$file"; then
cannam@125 10998 exit_status=1
cannam@125 10999 continue
cannam@125 11000 elif $rmforce; then
cannam@125 11001 continue
cannam@125 11002 fi
cannam@125 11003
cannam@125 11004 rmfiles=$file
cannam@125 11005
cannam@125 11006 case $name in
cannam@125 11007 *.la)
cannam@125 11008 # Possibly a libtool archive, so verify it.
cannam@125 11009 if func_lalib_p "$file"; then
cannam@125 11010 func_source $dir/$name
cannam@125 11011
cannam@125 11012 # Delete the libtool libraries and symlinks.
cannam@125 11013 for n in $library_names; do
cannam@125 11014 func_append rmfiles " $odir/$n"
cannam@125 11015 done
cannam@125 11016 test -n "$old_library" && func_append rmfiles " $odir/$old_library"
cannam@125 11017
cannam@125 11018 case $opt_mode in
cannam@125 11019 clean)
cannam@125 11020 case " $library_names " in
cannam@125 11021 *" $dlname "*) ;;
cannam@125 11022 *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
cannam@125 11023 esac
cannam@125 11024 test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
cannam@125 11025 ;;
cannam@125 11026 uninstall)
cannam@125 11027 if test -n "$library_names"; then
cannam@125 11028 # Do each command in the postuninstall commands.
cannam@125 11029 func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
cannam@125 11030 fi
cannam@125 11031
cannam@125 11032 if test -n "$old_library"; then
cannam@125 11033 # Do each command in the old_postuninstall commands.
cannam@125 11034 func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
cannam@125 11035 fi
cannam@125 11036 # FIXME: should reinstall the best remaining shared library.
cannam@125 11037 ;;
cannam@125 11038 esac
cannam@125 11039 fi
cannam@125 11040 ;;
cannam@125 11041
cannam@125 11042 *.lo)
cannam@125 11043 # Possibly a libtool object, so verify it.
cannam@125 11044 if func_lalib_p "$file"; then
cannam@125 11045
cannam@125 11046 # Read the .lo file
cannam@125 11047 func_source $dir/$name
cannam@125 11048
cannam@125 11049 # Add PIC object to the list of files to remove.
cannam@125 11050 if test -n "$pic_object" && test none != "$pic_object"; then
cannam@125 11051 func_append rmfiles " $dir/$pic_object"
cannam@125 11052 fi
cannam@125 11053
cannam@125 11054 # Add non-PIC object to the list of files to remove.
cannam@125 11055 if test -n "$non_pic_object" && test none != "$non_pic_object"; then
cannam@125 11056 func_append rmfiles " $dir/$non_pic_object"
cannam@125 11057 fi
cannam@125 11058 fi
cannam@125 11059 ;;
cannam@125 11060
cannam@125 11061 *)
cannam@125 11062 if test clean = "$opt_mode"; then
cannam@125 11063 noexename=$name
cannam@125 11064 case $file in
cannam@125 11065 *.exe)
cannam@125 11066 func_stripname '' '.exe' "$file"
cannam@125 11067 file=$func_stripname_result
cannam@125 11068 func_stripname '' '.exe' "$name"
cannam@125 11069 noexename=$func_stripname_result
cannam@125 11070 # $file with .exe has already been added to rmfiles,
cannam@125 11071 # add $file without .exe
cannam@125 11072 func_append rmfiles " $file"
cannam@125 11073 ;;
cannam@125 11074 esac
cannam@125 11075 # Do a test to see if this is a libtool program.
cannam@125 11076 if func_ltwrapper_p "$file"; then
cannam@125 11077 if func_ltwrapper_executable_p "$file"; then
cannam@125 11078 func_ltwrapper_scriptname "$file"
cannam@125 11079 relink_command=
cannam@125 11080 func_source $func_ltwrapper_scriptname_result
cannam@125 11081 func_append rmfiles " $func_ltwrapper_scriptname_result"
cannam@125 11082 else
cannam@125 11083 relink_command=
cannam@125 11084 func_source $dir/$noexename
cannam@125 11085 fi
cannam@125 11086
cannam@125 11087 # note $name still contains .exe if it was in $file originally
cannam@125 11088 # as does the version of $file that was added into $rmfiles
cannam@125 11089 func_append rmfiles " $odir/$name $odir/${name}S.$objext"
cannam@125 11090 if test yes = "$fast_install" && test -n "$relink_command"; then
cannam@125 11091 func_append rmfiles " $odir/lt-$name"
cannam@125 11092 fi
cannam@125 11093 if test "X$noexename" != "X$name"; then
cannam@125 11094 func_append rmfiles " $odir/lt-$noexename.c"
cannam@125 11095 fi
cannam@125 11096 fi
cannam@125 11097 fi
cannam@125 11098 ;;
cannam@125 11099 esac
cannam@125 11100 func_show_eval "$RM $rmfiles" 'exit_status=1'
cannam@125 11101 done
cannam@125 11102
cannam@125 11103 # Try to remove the $objdir's in the directories where we deleted files
cannam@125 11104 for dir in $rmdirs; do
cannam@125 11105 if test -d "$dir"; then
cannam@125 11106 func_show_eval "rmdir $dir >/dev/null 2>&1"
cannam@125 11107 fi
cannam@125 11108 done
cannam@125 11109
cannam@125 11110 exit $exit_status
cannam@125 11111 }
cannam@125 11112
cannam@125 11113 if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
cannam@125 11114 func_mode_uninstall ${1+"$@"}
cannam@125 11115 fi
cannam@125 11116
cannam@125 11117 test -z "$opt_mode" && {
cannam@125 11118 help=$generic_help
cannam@125 11119 func_fatal_help "you must specify a MODE"
cannam@125 11120 }
cannam@125 11121
cannam@125 11122 test -z "$exec_cmd" && \
cannam@125 11123 func_fatal_help "invalid operation mode '$opt_mode'"
cannam@125 11124
cannam@125 11125 if test -n "$exec_cmd"; then
cannam@125 11126 eval exec "$exec_cmd"
cannam@125 11127 exit $EXIT_FAILURE
cannam@125 11128 fi
cannam@125 11129
cannam@125 11130 exit $exit_status
cannam@125 11131
cannam@125 11132
cannam@125 11133 # The TAGs below are defined such that we never get into a situation
cannam@125 11134 # where we disable both kinds of libraries. Given conflicting
cannam@125 11135 # choices, we go for a static library, that is the most portable,
cannam@125 11136 # since we can't tell whether shared libraries were disabled because
cannam@125 11137 # the user asked for that or because the platform doesn't support
cannam@125 11138 # them. This is particularly important on AIX, because we don't
cannam@125 11139 # support having both static and shared libraries enabled at the same
cannam@125 11140 # time on that platform, so we default to a shared-only configuration.
cannam@125 11141 # If a disable-shared tag is given, we'll fallback to a static-only
cannam@125 11142 # configuration. But we'll never go from static-only to shared-only.
cannam@125 11143
cannam@125 11144 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
cannam@125 11145 build_libtool_libs=no
cannam@125 11146 build_old_libs=yes
cannam@125 11147 # ### END LIBTOOL TAG CONFIG: disable-shared
cannam@125 11148
cannam@125 11149 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
cannam@125 11150 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
cannam@125 11151 # ### END LIBTOOL TAG CONFIG: disable-static
cannam@125 11152
cannam@125 11153 # Local Variables:
cannam@125 11154 # mode:shell-script
cannam@125 11155 # sh-indentation:2
cannam@125 11156 # End: