annotate src/libsamplerate-0.1.9/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 4a7071416412
children
rev   line source
cannam@126 1 #! /bin/sh
cannam@126 2 ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
cannam@126 3 ## by inline-source v2014-01-03.01
cannam@126 4
cannam@126 5 # libtool (GNU libtool) 2.4.6
cannam@126 6 # Provide generalized library-building support services.
cannam@126 7 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
cannam@126 8
cannam@126 9 # Copyright (C) 1996-2015 Free Software Foundation, Inc.
cannam@126 10 # This is free software; see the source for copying conditions. There is NO
cannam@126 11 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cannam@126 12
cannam@126 13 # GNU Libtool is free software; you can redistribute it and/or modify
cannam@126 14 # it under the terms of the GNU General Public License as published by
cannam@126 15 # the Free Software Foundation; either version 2 of the License, or
cannam@126 16 # (at your option) any later version.
cannam@126 17 #
cannam@126 18 # As a special exception to the GNU General Public License,
cannam@126 19 # if you distribute this file as part of a program or library that
cannam@126 20 # is built using GNU Libtool, you may include this file under the
cannam@126 21 # same distribution terms that you use for the rest of that program.
cannam@126 22 #
cannam@126 23 # GNU Libtool is distributed in the hope that it will be useful, but
cannam@126 24 # WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@126 25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cannam@126 26 # General Public License for more details.
cannam@126 27 #
cannam@126 28 # You should have received a copy of the GNU General Public License
cannam@126 29 # along with this program. If not, see <http://www.gnu.org/licenses/>.
cannam@126 30
cannam@126 31
cannam@126 32 PROGRAM=libtool
cannam@126 33 PACKAGE=libtool
cannam@126 34 VERSION="2.4.6 Debian-2.4.6-2"
cannam@126 35 package_revision=2.4.6
cannam@126 36
cannam@126 37
cannam@126 38 ## ------ ##
cannam@126 39 ## Usage. ##
cannam@126 40 ## ------ ##
cannam@126 41
cannam@126 42 # Run './libtool --help' for help with using this script from the
cannam@126 43 # command line.
cannam@126 44
cannam@126 45
cannam@126 46 ## ------------------------------- ##
cannam@126 47 ## User overridable command paths. ##
cannam@126 48 ## ------------------------------- ##
cannam@126 49
cannam@126 50 # After configure completes, it has a better idea of some of the
cannam@126 51 # shell tools we need than the defaults used by the functions shared
cannam@126 52 # with bootstrap, so set those here where they can still be over-
cannam@126 53 # ridden by the user, but otherwise take precedence.
cannam@126 54
cannam@126 55 : ${AUTOCONF="autoconf"}
cannam@126 56 : ${AUTOMAKE="automake"}
cannam@126 57
cannam@126 58
cannam@126 59 ## -------------------------- ##
cannam@126 60 ## Source external libraries. ##
cannam@126 61 ## -------------------------- ##
cannam@126 62
cannam@126 63 # Much of our low-level functionality needs to be sourced from external
cannam@126 64 # libraries, which are installed to $pkgauxdir.
cannam@126 65
cannam@126 66 # Set a version string for this script.
cannam@126 67 scriptversion=2015-01-20.17; # UTC
cannam@126 68
cannam@126 69 # General shell script boiler plate, and helper functions.
cannam@126 70 # Written by Gary V. Vaughan, 2004
cannam@126 71
cannam@126 72 # Copyright (C) 2004-2015 Free Software Foundation, Inc.
cannam@126 73 # This is free software; see the source for copying conditions. There is NO
cannam@126 74 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cannam@126 75
cannam@126 76 # This program is free software; you can redistribute it and/or modify
cannam@126 77 # it under the terms of the GNU General Public License as published by
cannam@126 78 # the Free Software Foundation; either version 3 of the License, or
cannam@126 79 # (at your option) any later version.
cannam@126 80
cannam@126 81 # As a special exception to the GNU General Public License, if you distribute
cannam@126 82 # this file as part of a program or library that is built using GNU Libtool,
cannam@126 83 # you may include this file under the same distribution terms that you use
cannam@126 84 # for the rest of that program.
cannam@126 85
cannam@126 86 # This program is distributed in the hope that it will be useful,
cannam@126 87 # but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@126 88 # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
cannam@126 89 # General Public License for more details.
cannam@126 90
cannam@126 91 # You should have received a copy of the GNU General Public License
cannam@126 92 # along with this program. If not, see <http://www.gnu.org/licenses/>.
cannam@126 93
cannam@126 94 # Please report bugs or propose patches to gary@gnu.org.
cannam@126 95
cannam@126 96
cannam@126 97 ## ------ ##
cannam@126 98 ## Usage. ##
cannam@126 99 ## ------ ##
cannam@126 100
cannam@126 101 # Evaluate this file near the top of your script to gain access to
cannam@126 102 # the functions and variables defined here:
cannam@126 103 #
cannam@126 104 # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
cannam@126 105 #
cannam@126 106 # If you need to override any of the default environment variable
cannam@126 107 # settings, do that before evaluating this file.
cannam@126 108
cannam@126 109
cannam@126 110 ## -------------------- ##
cannam@126 111 ## Shell normalisation. ##
cannam@126 112 ## -------------------- ##
cannam@126 113
cannam@126 114 # Some shells need a little help to be as Bourne compatible as possible.
cannam@126 115 # Before doing anything else, make sure all that help has been provided!
cannam@126 116
cannam@126 117 DUALCASE=1; export DUALCASE # for MKS sh
cannam@126 118 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
cannam@126 119 emulate sh
cannam@126 120 NULLCMD=:
cannam@126 121 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
cannam@126 122 # is contrary to our usage. Disable this feature.
cannam@126 123 alias -g '${1+"$@"}'='"$@"'
cannam@126 124 setopt NO_GLOB_SUBST
cannam@126 125 else
cannam@126 126 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
cannam@126 127 fi
cannam@126 128
cannam@126 129 # NLS nuisances: We save the old values in case they are required later.
cannam@126 130 _G_user_locale=
cannam@126 131 _G_safe_locale=
cannam@126 132 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
cannam@126 133 do
cannam@126 134 eval "if test set = \"\${$_G_var+set}\"; then
cannam@126 135 save_$_G_var=\$$_G_var
cannam@126 136 $_G_var=C
cannam@126 137 export $_G_var
cannam@126 138 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
cannam@126 139 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
cannam@126 140 fi"
cannam@126 141 done
cannam@126 142
cannam@126 143 # CDPATH.
cannam@126 144 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
cannam@126 145
cannam@126 146 # Make sure IFS has a sensible default
cannam@126 147 sp=' '
cannam@126 148 nl='
cannam@126 149 '
cannam@126 150 IFS="$sp $nl"
cannam@126 151
cannam@126 152 # There are apparently some retarded systems that use ';' as a PATH separator!
cannam@126 153 if test "${PATH_SEPARATOR+set}" != set; then
cannam@126 154 PATH_SEPARATOR=:
cannam@126 155 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
cannam@126 156 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
cannam@126 157 PATH_SEPARATOR=';'
cannam@126 158 }
cannam@126 159 fi
cannam@126 160
cannam@126 161
cannam@126 162
cannam@126 163 ## ------------------------- ##
cannam@126 164 ## Locate command utilities. ##
cannam@126 165 ## ------------------------- ##
cannam@126 166
cannam@126 167
cannam@126 168 # func_executable_p FILE
cannam@126 169 # ----------------------
cannam@126 170 # Check that FILE is an executable regular file.
cannam@126 171 func_executable_p ()
cannam@126 172 {
cannam@126 173 test -f "$1" && test -x "$1"
cannam@126 174 }
cannam@126 175
cannam@126 176
cannam@126 177 # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
cannam@126 178 # --------------------------------------------
cannam@126 179 # Search for either a program that responds to --version with output
cannam@126 180 # containing "GNU", or else returned by CHECK_FUNC otherwise, by
cannam@126 181 # trying all the directories in PATH with each of the elements of
cannam@126 182 # PROGS_LIST.
cannam@126 183 #
cannam@126 184 # CHECK_FUNC should accept the path to a candidate program, and
cannam@126 185 # set $func_check_prog_result if it truncates its output less than
cannam@126 186 # $_G_path_prog_max characters.
cannam@126 187 func_path_progs ()
cannam@126 188 {
cannam@126 189 _G_progs_list=$1
cannam@126 190 _G_check_func=$2
cannam@126 191 _G_PATH=${3-"$PATH"}
cannam@126 192
cannam@126 193 _G_path_prog_max=0
cannam@126 194 _G_path_prog_found=false
cannam@126 195 _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
cannam@126 196 for _G_dir in $_G_PATH; do
cannam@126 197 IFS=$_G_save_IFS
cannam@126 198 test -z "$_G_dir" && _G_dir=.
cannam@126 199 for _G_prog_name in $_G_progs_list; do
cannam@126 200 for _exeext in '' .EXE; do
cannam@126 201 _G_path_prog=$_G_dir/$_G_prog_name$_exeext
cannam@126 202 func_executable_p "$_G_path_prog" || continue
cannam@126 203 case `"$_G_path_prog" --version 2>&1` in
cannam@126 204 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
cannam@126 205 *) $_G_check_func $_G_path_prog
cannam@126 206 func_path_progs_result=$func_check_prog_result
cannam@126 207 ;;
cannam@126 208 esac
cannam@126 209 $_G_path_prog_found && break 3
cannam@126 210 done
cannam@126 211 done
cannam@126 212 done
cannam@126 213 IFS=$_G_save_IFS
cannam@126 214 test -z "$func_path_progs_result" && {
cannam@126 215 echo "no acceptable sed could be found in \$PATH" >&2
cannam@126 216 exit 1
cannam@126 217 }
cannam@126 218 }
cannam@126 219
cannam@126 220
cannam@126 221 # We want to be able to use the functions in this file before configure
cannam@126 222 # has figured out where the best binaries are kept, which means we have
cannam@126 223 # to search for them ourselves - except when the results are already set
cannam@126 224 # where we skip the searches.
cannam@126 225
cannam@126 226 # Unless the user overrides by setting SED, search the path for either GNU
cannam@126 227 # sed, or the sed that truncates its output the least.
cannam@126 228 test -z "$SED" && {
cannam@126 229 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
cannam@126 230 for _G_i in 1 2 3 4 5 6 7; do
cannam@126 231 _G_sed_script=$_G_sed_script$nl$_G_sed_script
cannam@126 232 done
cannam@126 233 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
cannam@126 234 _G_sed_script=
cannam@126 235
cannam@126 236 func_check_prog_sed ()
cannam@126 237 {
cannam@126 238 _G_path_prog=$1
cannam@126 239
cannam@126 240 _G_count=0
cannam@126 241 printf 0123456789 >conftest.in
cannam@126 242 while :
cannam@126 243 do
cannam@126 244 cat conftest.in conftest.in >conftest.tmp
cannam@126 245 mv conftest.tmp conftest.in
cannam@126 246 cp conftest.in conftest.nl
cannam@126 247 echo '' >> conftest.nl
cannam@126 248 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
cannam@126 249 diff conftest.out conftest.nl >/dev/null 2>&1 || break
cannam@126 250 _G_count=`expr $_G_count + 1`
cannam@126 251 if test "$_G_count" -gt "$_G_path_prog_max"; then
cannam@126 252 # Best one so far, save it but keep looking for a better one
cannam@126 253 func_check_prog_result=$_G_path_prog
cannam@126 254 _G_path_prog_max=$_G_count
cannam@126 255 fi
cannam@126 256 # 10*(2^10) chars as input seems more than enough
cannam@126 257 test 10 -lt "$_G_count" && break
cannam@126 258 done
cannam@126 259 rm -f conftest.in conftest.tmp conftest.nl conftest.out
cannam@126 260 }
cannam@126 261
cannam@126 262 func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
cannam@126 263 rm -f conftest.sed
cannam@126 264 SED=$func_path_progs_result
cannam@126 265 }
cannam@126 266
cannam@126 267
cannam@126 268 # Unless the user overrides by setting GREP, search the path for either GNU
cannam@126 269 # grep, or the grep that truncates its output the least.
cannam@126 270 test -z "$GREP" && {
cannam@126 271 func_check_prog_grep ()
cannam@126 272 {
cannam@126 273 _G_path_prog=$1
cannam@126 274
cannam@126 275 _G_count=0
cannam@126 276 _G_path_prog_max=0
cannam@126 277 printf 0123456789 >conftest.in
cannam@126 278 while :
cannam@126 279 do
cannam@126 280 cat conftest.in conftest.in >conftest.tmp
cannam@126 281 mv conftest.tmp conftest.in
cannam@126 282 cp conftest.in conftest.nl
cannam@126 283 echo 'GREP' >> conftest.nl
cannam@126 284 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
cannam@126 285 diff conftest.out conftest.nl >/dev/null 2>&1 || break
cannam@126 286 _G_count=`expr $_G_count + 1`
cannam@126 287 if test "$_G_count" -gt "$_G_path_prog_max"; then
cannam@126 288 # Best one so far, save it but keep looking for a better one
cannam@126 289 func_check_prog_result=$_G_path_prog
cannam@126 290 _G_path_prog_max=$_G_count
cannam@126 291 fi
cannam@126 292 # 10*(2^10) chars as input seems more than enough
cannam@126 293 test 10 -lt "$_G_count" && break
cannam@126 294 done
cannam@126 295 rm -f conftest.in conftest.tmp conftest.nl conftest.out
cannam@126 296 }
cannam@126 297
cannam@126 298 func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
cannam@126 299 GREP=$func_path_progs_result
cannam@126 300 }
cannam@126 301
cannam@126 302
cannam@126 303 ## ------------------------------- ##
cannam@126 304 ## User overridable command paths. ##
cannam@126 305 ## ------------------------------- ##
cannam@126 306
cannam@126 307 # All uppercase variable names are used for environment variables. These
cannam@126 308 # variables can be overridden by the user before calling a script that
cannam@126 309 # uses them if a suitable command of that name is not already available
cannam@126 310 # in the command search PATH.
cannam@126 311
cannam@126 312 : ${CP="cp -f"}
cannam@126 313 : ${ECHO="printf %s\n"}
cannam@126 314 : ${EGREP="$GREP -E"}
cannam@126 315 : ${FGREP="$GREP -F"}
cannam@126 316 : ${LN_S="ln -s"}
cannam@126 317 : ${MAKE="make"}
cannam@126 318 : ${MKDIR="mkdir"}
cannam@126 319 : ${MV="mv -f"}
cannam@126 320 : ${RM="rm -f"}
cannam@126 321 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
cannam@126 322
cannam@126 323
cannam@126 324 ## -------------------- ##
cannam@126 325 ## Useful sed snippets. ##
cannam@126 326 ## -------------------- ##
cannam@126 327
cannam@126 328 sed_dirname='s|/[^/]*$||'
cannam@126 329 sed_basename='s|^.*/||'
cannam@126 330
cannam@126 331 # Sed substitution that helps us do robust quoting. It backslashifies
cannam@126 332 # metacharacters that are still active within double-quoted strings.
cannam@126 333 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
cannam@126 334
cannam@126 335 # Same as above, but do not quote variable references.
cannam@126 336 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
cannam@126 337
cannam@126 338 # Sed substitution that turns a string into a regex matching for the
cannam@126 339 # string literally.
cannam@126 340 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
cannam@126 341
cannam@126 342 # Sed substitution that converts a w32 file name or path
cannam@126 343 # that contains forward slashes, into one that contains
cannam@126 344 # (escaped) backslashes. A very naive implementation.
cannam@126 345 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
cannam@126 346
cannam@126 347 # Re-'\' parameter expansions in output of sed_double_quote_subst that
cannam@126 348 # were '\'-ed in input to the same. If an odd number of '\' preceded a
cannam@126 349 # '$' in input to sed_double_quote_subst, that '$' was protected from
cannam@126 350 # expansion. Since each input '\' is now two '\'s, look for any number
cannam@126 351 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
cannam@126 352 _G_bs='\\'
cannam@126 353 _G_bs2='\\\\'
cannam@126 354 _G_bs4='\\\\\\\\'
cannam@126 355 _G_dollar='\$'
cannam@126 356 sed_double_backslash="\
cannam@126 357 s/$_G_bs4/&\\
cannam@126 358 /g
cannam@126 359 s/^$_G_bs2$_G_dollar/$_G_bs&/
cannam@126 360 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
cannam@126 361 s/\n//g"
cannam@126 362
cannam@126 363
cannam@126 364 ## ----------------- ##
cannam@126 365 ## Global variables. ##
cannam@126 366 ## ----------------- ##
cannam@126 367
cannam@126 368 # Except for the global variables explicitly listed below, the following
cannam@126 369 # functions in the '^func_' namespace, and the '^require_' namespace
cannam@126 370 # variables initialised in the 'Resource management' section, sourcing
cannam@126 371 # this file will not pollute your global namespace with anything
cannam@126 372 # else. There's no portable way to scope variables in Bourne shell
cannam@126 373 # though, so actually running these functions will sometimes place
cannam@126 374 # results into a variable named after the function, and often use
cannam@126 375 # temporary variables in the '^_G_' namespace. If you are careful to
cannam@126 376 # avoid using those namespaces casually in your sourcing script, things
cannam@126 377 # should continue to work as you expect. And, of course, you can freely
cannam@126 378 # overwrite any of the functions or variables defined here before
cannam@126 379 # calling anything to customize them.
cannam@126 380
cannam@126 381 EXIT_SUCCESS=0
cannam@126 382 EXIT_FAILURE=1
cannam@126 383 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
cannam@126 384 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
cannam@126 385
cannam@126 386 # Allow overriding, eg assuming that you follow the convention of
cannam@126 387 # putting '$debug_cmd' at the start of all your functions, you can get
cannam@126 388 # bash to show function call trace with:
cannam@126 389 #
cannam@126 390 # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
cannam@126 391 debug_cmd=${debug_cmd-":"}
cannam@126 392 exit_cmd=:
cannam@126 393
cannam@126 394 # By convention, finish your script with:
cannam@126 395 #
cannam@126 396 # exit $exit_status
cannam@126 397 #
cannam@126 398 # so that you can set exit_status to non-zero if you want to indicate
cannam@126 399 # something went wrong during execution without actually bailing out at
cannam@126 400 # the point of failure.
cannam@126 401 exit_status=$EXIT_SUCCESS
cannam@126 402
cannam@126 403 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
cannam@126 404 # is ksh but when the shell is invoked as "sh" and the current value of
cannam@126 405 # the _XPG environment variable is not equal to 1 (one), the special
cannam@126 406 # positional parameter $0, within a function call, is the name of the
cannam@126 407 # function.
cannam@126 408 progpath=$0
cannam@126 409
cannam@126 410 # The name of this program.
cannam@126 411 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
cannam@126 412
cannam@126 413 # Make sure we have an absolute progpath for reexecution:
cannam@126 414 case $progpath in
cannam@126 415 [\\/]*|[A-Za-z]:\\*) ;;
cannam@126 416 *[\\/]*)
cannam@126 417 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
cannam@126 418 progdir=`cd "$progdir" && pwd`
cannam@126 419 progpath=$progdir/$progname
cannam@126 420 ;;
cannam@126 421 *)
cannam@126 422 _G_IFS=$IFS
cannam@126 423 IFS=${PATH_SEPARATOR-:}
cannam@126 424 for progdir in $PATH; do
cannam@126 425 IFS=$_G_IFS
cannam@126 426 test -x "$progdir/$progname" && break
cannam@126 427 done
cannam@126 428 IFS=$_G_IFS
cannam@126 429 test -n "$progdir" || progdir=`pwd`
cannam@126 430 progpath=$progdir/$progname
cannam@126 431 ;;
cannam@126 432 esac
cannam@126 433
cannam@126 434
cannam@126 435 ## ----------------- ##
cannam@126 436 ## Standard options. ##
cannam@126 437 ## ----------------- ##
cannam@126 438
cannam@126 439 # The following options affect the operation of the functions defined
cannam@126 440 # below, and should be set appropriately depending on run-time para-
cannam@126 441 # meters passed on the command line.
cannam@126 442
cannam@126 443 opt_dry_run=false
cannam@126 444 opt_quiet=false
cannam@126 445 opt_verbose=false
cannam@126 446
cannam@126 447 # Categories 'all' and 'none' are always available. Append any others
cannam@126 448 # you will pass as the first argument to func_warning from your own
cannam@126 449 # code.
cannam@126 450 warning_categories=
cannam@126 451
cannam@126 452 # By default, display warnings according to 'opt_warning_types'. Set
cannam@126 453 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
cannam@126 454 # treat the next displayed warning as a fatal error.
cannam@126 455 warning_func=func_warn_and_continue
cannam@126 456
cannam@126 457 # Set to 'all' to display all warnings, 'none' to suppress all
cannam@126 458 # warnings, or a space delimited list of some subset of
cannam@126 459 # 'warning_categories' to display only the listed warnings.
cannam@126 460 opt_warning_types=all
cannam@126 461
cannam@126 462
cannam@126 463 ## -------------------- ##
cannam@126 464 ## Resource management. ##
cannam@126 465 ## -------------------- ##
cannam@126 466
cannam@126 467 # This section contains definitions for functions that each ensure a
cannam@126 468 # particular resource (a file, or a non-empty configuration variable for
cannam@126 469 # example) is available, and if appropriate to extract default values
cannam@126 470 # from pertinent package files. Call them using their associated
cannam@126 471 # 'require_*' variable to ensure that they are executed, at most, once.
cannam@126 472 #
cannam@126 473 # It's entirely deliberate that calling these functions can set
cannam@126 474 # variables that don't obey the namespace limitations obeyed by the rest
cannam@126 475 # of this file, in order that that they be as useful as possible to
cannam@126 476 # callers.
cannam@126 477
cannam@126 478
cannam@126 479 # require_term_colors
cannam@126 480 # -------------------
cannam@126 481 # Allow display of bold text on terminals that support it.
cannam@126 482 require_term_colors=func_require_term_colors
cannam@126 483 func_require_term_colors ()
cannam@126 484 {
cannam@126 485 $debug_cmd
cannam@126 486
cannam@126 487 test -t 1 && {
cannam@126 488 # COLORTERM and USE_ANSI_COLORS environment variables take
cannam@126 489 # precedence, because most terminfo databases neglect to describe
cannam@126 490 # whether color sequences are supported.
cannam@126 491 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
cannam@126 492
cannam@126 493 if test 1 = "$USE_ANSI_COLORS"; then
cannam@126 494 # Standard ANSI escape sequences
cannam@126 495 tc_reset=''
cannam@126 496 tc_bold=''; tc_standout=''
cannam@126 497 tc_red=''; tc_green=''
cannam@126 498 tc_blue=''; tc_cyan=''
cannam@126 499 else
cannam@126 500 # Otherwise trust the terminfo database after all.
cannam@126 501 test -n "`tput sgr0 2>/dev/null`" && {
cannam@126 502 tc_reset=`tput sgr0`
cannam@126 503 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
cannam@126 504 tc_standout=$tc_bold
cannam@126 505 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
cannam@126 506 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
cannam@126 507 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
cannam@126 508 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
cannam@126 509 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
cannam@126 510 }
cannam@126 511 fi
cannam@126 512 }
cannam@126 513
cannam@126 514 require_term_colors=:
cannam@126 515 }
cannam@126 516
cannam@126 517
cannam@126 518 ## ----------------- ##
cannam@126 519 ## Function library. ##
cannam@126 520 ## ----------------- ##
cannam@126 521
cannam@126 522 # This section contains a variety of useful functions to call in your
cannam@126 523 # scripts. Take note of the portable wrappers for features provided by
cannam@126 524 # some modern shells, which will fall back to slower equivalents on
cannam@126 525 # less featureful shells.
cannam@126 526
cannam@126 527
cannam@126 528 # func_append VAR VALUE
cannam@126 529 # ---------------------
cannam@126 530 # Append VALUE onto the existing contents of VAR.
cannam@126 531
cannam@126 532 # We should try to minimise forks, especially on Windows where they are
cannam@126 533 # unreasonably slow, so skip the feature probes when bash or zsh are
cannam@126 534 # being used:
cannam@126 535 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
cannam@126 536 : ${_G_HAVE_ARITH_OP="yes"}
cannam@126 537 : ${_G_HAVE_XSI_OPS="yes"}
cannam@126 538 # The += operator was introduced in bash 3.1
cannam@126 539 case $BASH_VERSION in
cannam@126 540 [12].* | 3.0 | 3.0*) ;;
cannam@126 541 *)
cannam@126 542 : ${_G_HAVE_PLUSEQ_OP="yes"}
cannam@126 543 ;;
cannam@126 544 esac
cannam@126 545 fi
cannam@126 546
cannam@126 547 # _G_HAVE_PLUSEQ_OP
cannam@126 548 # Can be empty, in which case the shell is probed, "yes" if += is
cannam@126 549 # useable or anything else if it does not work.
cannam@126 550 test -z "$_G_HAVE_PLUSEQ_OP" \
cannam@126 551 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
cannam@126 552 && _G_HAVE_PLUSEQ_OP=yes
cannam@126 553
cannam@126 554 if test yes = "$_G_HAVE_PLUSEQ_OP"
cannam@126 555 then
cannam@126 556 # This is an XSI compatible shell, allowing a faster implementation...
cannam@126 557 eval 'func_append ()
cannam@126 558 {
cannam@126 559 $debug_cmd
cannam@126 560
cannam@126 561 eval "$1+=\$2"
cannam@126 562 }'
cannam@126 563 else
cannam@126 564 # ...otherwise fall back to using expr, which is often a shell builtin.
cannam@126 565 func_append ()
cannam@126 566 {
cannam@126 567 $debug_cmd
cannam@126 568
cannam@126 569 eval "$1=\$$1\$2"
cannam@126 570 }
cannam@126 571 fi
cannam@126 572
cannam@126 573
cannam@126 574 # func_append_quoted VAR VALUE
cannam@126 575 # ----------------------------
cannam@126 576 # Quote VALUE and append to the end of shell variable VAR, separated
cannam@126 577 # by a space.
cannam@126 578 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
cannam@126 579 eval 'func_append_quoted ()
cannam@126 580 {
cannam@126 581 $debug_cmd
cannam@126 582
cannam@126 583 func_quote_for_eval "$2"
cannam@126 584 eval "$1+=\\ \$func_quote_for_eval_result"
cannam@126 585 }'
cannam@126 586 else
cannam@126 587 func_append_quoted ()
cannam@126 588 {
cannam@126 589 $debug_cmd
cannam@126 590
cannam@126 591 func_quote_for_eval "$2"
cannam@126 592 eval "$1=\$$1\\ \$func_quote_for_eval_result"
cannam@126 593 }
cannam@126 594 fi
cannam@126 595
cannam@126 596
cannam@126 597 # func_append_uniq VAR VALUE
cannam@126 598 # --------------------------
cannam@126 599 # Append unique VALUE onto the existing contents of VAR, assuming
cannam@126 600 # entries are delimited by the first character of VALUE. For example:
cannam@126 601 #
cannam@126 602 # func_append_uniq options " --another-option option-argument"
cannam@126 603 #
cannam@126 604 # will only append to $options if " --another-option option-argument "
cannam@126 605 # is not already present somewhere in $options already (note spaces at
cannam@126 606 # each end implied by leading space in second argument).
cannam@126 607 func_append_uniq ()
cannam@126 608 {
cannam@126 609 $debug_cmd
cannam@126 610
cannam@126 611 eval _G_current_value='`$ECHO $'$1'`'
cannam@126 612 _G_delim=`expr "$2" : '\(.\)'`
cannam@126 613
cannam@126 614 case $_G_delim$_G_current_value$_G_delim in
cannam@126 615 *"$2$_G_delim"*) ;;
cannam@126 616 *) func_append "$@" ;;
cannam@126 617 esac
cannam@126 618 }
cannam@126 619
cannam@126 620
cannam@126 621 # func_arith TERM...
cannam@126 622 # ------------------
cannam@126 623 # Set func_arith_result to the result of evaluating TERMs.
cannam@126 624 test -z "$_G_HAVE_ARITH_OP" \
cannam@126 625 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
cannam@126 626 && _G_HAVE_ARITH_OP=yes
cannam@126 627
cannam@126 628 if test yes = "$_G_HAVE_ARITH_OP"; then
cannam@126 629 eval 'func_arith ()
cannam@126 630 {
cannam@126 631 $debug_cmd
cannam@126 632
cannam@126 633 func_arith_result=$(( $* ))
cannam@126 634 }'
cannam@126 635 else
cannam@126 636 func_arith ()
cannam@126 637 {
cannam@126 638 $debug_cmd
cannam@126 639
cannam@126 640 func_arith_result=`expr "$@"`
cannam@126 641 }
cannam@126 642 fi
cannam@126 643
cannam@126 644
cannam@126 645 # func_basename FILE
cannam@126 646 # ------------------
cannam@126 647 # Set func_basename_result to FILE with everything up to and including
cannam@126 648 # the last / stripped.
cannam@126 649 if test yes = "$_G_HAVE_XSI_OPS"; then
cannam@126 650 # If this shell supports suffix pattern removal, then use it to avoid
cannam@126 651 # forking. Hide the definitions single quotes in case the shell chokes
cannam@126 652 # on unsupported syntax...
cannam@126 653 _b='func_basename_result=${1##*/}'
cannam@126 654 _d='case $1 in
cannam@126 655 */*) func_dirname_result=${1%/*}$2 ;;
cannam@126 656 * ) func_dirname_result=$3 ;;
cannam@126 657 esac'
cannam@126 658
cannam@126 659 else
cannam@126 660 # ...otherwise fall back to using sed.
cannam@126 661 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
cannam@126 662 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
cannam@126 663 if test "X$func_dirname_result" = "X$1"; then
cannam@126 664 func_dirname_result=$3
cannam@126 665 else
cannam@126 666 func_append func_dirname_result "$2"
cannam@126 667 fi'
cannam@126 668 fi
cannam@126 669
cannam@126 670 eval 'func_basename ()
cannam@126 671 {
cannam@126 672 $debug_cmd
cannam@126 673
cannam@126 674 '"$_b"'
cannam@126 675 }'
cannam@126 676
cannam@126 677
cannam@126 678 # func_dirname FILE APPEND NONDIR_REPLACEMENT
cannam@126 679 # -------------------------------------------
cannam@126 680 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
cannam@126 681 # otherwise set result to NONDIR_REPLACEMENT.
cannam@126 682 eval 'func_dirname ()
cannam@126 683 {
cannam@126 684 $debug_cmd
cannam@126 685
cannam@126 686 '"$_d"'
cannam@126 687 }'
cannam@126 688
cannam@126 689
cannam@126 690 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
cannam@126 691 # --------------------------------------------------------
cannam@126 692 # Perform func_basename and func_dirname in a single function
cannam@126 693 # call:
cannam@126 694 # dirname: Compute the dirname of FILE. If nonempty,
cannam@126 695 # add APPEND to the result, otherwise set result
cannam@126 696 # to NONDIR_REPLACEMENT.
cannam@126 697 # value returned in "$func_dirname_result"
cannam@126 698 # basename: Compute filename of FILE.
cannam@126 699 # value retuned in "$func_basename_result"
cannam@126 700 # For efficiency, we do not delegate to the functions above but instead
cannam@126 701 # duplicate the functionality here.
cannam@126 702 eval 'func_dirname_and_basename ()
cannam@126 703 {
cannam@126 704 $debug_cmd
cannam@126 705
cannam@126 706 '"$_b"'
cannam@126 707 '"$_d"'
cannam@126 708 }'
cannam@126 709
cannam@126 710
cannam@126 711 # func_echo ARG...
cannam@126 712 # ----------------
cannam@126 713 # Echo program name prefixed message.
cannam@126 714 func_echo ()
cannam@126 715 {
cannam@126 716 $debug_cmd
cannam@126 717
cannam@126 718 _G_message=$*
cannam@126 719
cannam@126 720 func_echo_IFS=$IFS
cannam@126 721 IFS=$nl
cannam@126 722 for _G_line in $_G_message; do
cannam@126 723 IFS=$func_echo_IFS
cannam@126 724 $ECHO "$progname: $_G_line"
cannam@126 725 done
cannam@126 726 IFS=$func_echo_IFS
cannam@126 727 }
cannam@126 728
cannam@126 729
cannam@126 730 # func_echo_all ARG...
cannam@126 731 # --------------------
cannam@126 732 # Invoke $ECHO with all args, space-separated.
cannam@126 733 func_echo_all ()
cannam@126 734 {
cannam@126 735 $ECHO "$*"
cannam@126 736 }
cannam@126 737
cannam@126 738
cannam@126 739 # func_echo_infix_1 INFIX ARG...
cannam@126 740 # ------------------------------
cannam@126 741 # Echo program name, followed by INFIX on the first line, with any
cannam@126 742 # additional lines not showing INFIX.
cannam@126 743 func_echo_infix_1 ()
cannam@126 744 {
cannam@126 745 $debug_cmd
cannam@126 746
cannam@126 747 $require_term_colors
cannam@126 748
cannam@126 749 _G_infix=$1; shift
cannam@126 750 _G_indent=$_G_infix
cannam@126 751 _G_prefix="$progname: $_G_infix: "
cannam@126 752 _G_message=$*
cannam@126 753
cannam@126 754 # Strip color escape sequences before counting printable length
cannam@126 755 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
cannam@126 756 do
cannam@126 757 test -n "$_G_tc" && {
cannam@126 758 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
cannam@126 759 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
cannam@126 760 }
cannam@126 761 done
cannam@126 762 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
cannam@126 763
cannam@126 764 func_echo_infix_1_IFS=$IFS
cannam@126 765 IFS=$nl
cannam@126 766 for _G_line in $_G_message; do
cannam@126 767 IFS=$func_echo_infix_1_IFS
cannam@126 768 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
cannam@126 769 _G_prefix=$_G_indent
cannam@126 770 done
cannam@126 771 IFS=$func_echo_infix_1_IFS
cannam@126 772 }
cannam@126 773
cannam@126 774
cannam@126 775 # func_error ARG...
cannam@126 776 # -----------------
cannam@126 777 # Echo program name prefixed message to standard error.
cannam@126 778 func_error ()
cannam@126 779 {
cannam@126 780 $debug_cmd
cannam@126 781
cannam@126 782 $require_term_colors
cannam@126 783
cannam@126 784 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
cannam@126 785 }
cannam@126 786
cannam@126 787
cannam@126 788 # func_fatal_error ARG...
cannam@126 789 # -----------------------
cannam@126 790 # Echo program name prefixed message to standard error, and exit.
cannam@126 791 func_fatal_error ()
cannam@126 792 {
cannam@126 793 $debug_cmd
cannam@126 794
cannam@126 795 func_error "$*"
cannam@126 796 exit $EXIT_FAILURE
cannam@126 797 }
cannam@126 798
cannam@126 799
cannam@126 800 # func_grep EXPRESSION FILENAME
cannam@126 801 # -----------------------------
cannam@126 802 # Check whether EXPRESSION matches any line of FILENAME, without output.
cannam@126 803 func_grep ()
cannam@126 804 {
cannam@126 805 $debug_cmd
cannam@126 806
cannam@126 807 $GREP "$1" "$2" >/dev/null 2>&1
cannam@126 808 }
cannam@126 809
cannam@126 810
cannam@126 811 # func_len STRING
cannam@126 812 # ---------------
cannam@126 813 # Set func_len_result to the length of STRING. STRING may not
cannam@126 814 # start with a hyphen.
cannam@126 815 test -z "$_G_HAVE_XSI_OPS" \
cannam@126 816 && (eval 'x=a/b/c;
cannam@126 817 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
cannam@126 818 && _G_HAVE_XSI_OPS=yes
cannam@126 819
cannam@126 820 if test yes = "$_G_HAVE_XSI_OPS"; then
cannam@126 821 eval 'func_len ()
cannam@126 822 {
cannam@126 823 $debug_cmd
cannam@126 824
cannam@126 825 func_len_result=${#1}
cannam@126 826 }'
cannam@126 827 else
cannam@126 828 func_len ()
cannam@126 829 {
cannam@126 830 $debug_cmd
cannam@126 831
cannam@126 832 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
cannam@126 833 }
cannam@126 834 fi
cannam@126 835
cannam@126 836
cannam@126 837 # func_mkdir_p DIRECTORY-PATH
cannam@126 838 # ---------------------------
cannam@126 839 # Make sure the entire path to DIRECTORY-PATH is available.
cannam@126 840 func_mkdir_p ()
cannam@126 841 {
cannam@126 842 $debug_cmd
cannam@126 843
cannam@126 844 _G_directory_path=$1
cannam@126 845 _G_dir_list=
cannam@126 846
cannam@126 847 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
cannam@126 848
cannam@126 849 # Protect directory names starting with '-'
cannam@126 850 case $_G_directory_path in
cannam@126 851 -*) _G_directory_path=./$_G_directory_path ;;
cannam@126 852 esac
cannam@126 853
cannam@126 854 # While some portion of DIR does not yet exist...
cannam@126 855 while test ! -d "$_G_directory_path"; do
cannam@126 856 # ...make a list in topmost first order. Use a colon delimited
cannam@126 857 # list incase some portion of path contains whitespace.
cannam@126 858 _G_dir_list=$_G_directory_path:$_G_dir_list
cannam@126 859
cannam@126 860 # If the last portion added has no slash in it, the list is done
cannam@126 861 case $_G_directory_path in */*) ;; *) break ;; esac
cannam@126 862
cannam@126 863 # ...otherwise throw away the child directory and loop
cannam@126 864 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
cannam@126 865 done
cannam@126 866 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
cannam@126 867
cannam@126 868 func_mkdir_p_IFS=$IFS; IFS=:
cannam@126 869 for _G_dir in $_G_dir_list; do
cannam@126 870 IFS=$func_mkdir_p_IFS
cannam@126 871 # mkdir can fail with a 'File exist' error if two processes
cannam@126 872 # try to create one of the directories concurrently. Don't
cannam@126 873 # stop in that case!
cannam@126 874 $MKDIR "$_G_dir" 2>/dev/null || :
cannam@126 875 done
cannam@126 876 IFS=$func_mkdir_p_IFS
cannam@126 877
cannam@126 878 # Bail out if we (or some other process) failed to create a directory.
cannam@126 879 test -d "$_G_directory_path" || \
cannam@126 880 func_fatal_error "Failed to create '$1'"
cannam@126 881 fi
cannam@126 882 }
cannam@126 883
cannam@126 884
cannam@126 885 # func_mktempdir [BASENAME]
cannam@126 886 # -------------------------
cannam@126 887 # Make a temporary directory that won't clash with other running
cannam@126 888 # libtool processes, and avoids race conditions if possible. If
cannam@126 889 # given, BASENAME is the basename for that directory.
cannam@126 890 func_mktempdir ()
cannam@126 891 {
cannam@126 892 $debug_cmd
cannam@126 893
cannam@126 894 _G_template=${TMPDIR-/tmp}/${1-$progname}
cannam@126 895
cannam@126 896 if test : = "$opt_dry_run"; then
cannam@126 897 # Return a directory name, but don't create it in dry-run mode
cannam@126 898 _G_tmpdir=$_G_template-$$
cannam@126 899 else
cannam@126 900
cannam@126 901 # If mktemp works, use that first and foremost
cannam@126 902 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
cannam@126 903
cannam@126 904 if test ! -d "$_G_tmpdir"; then
cannam@126 905 # Failing that, at least try and use $RANDOM to avoid a race
cannam@126 906 _G_tmpdir=$_G_template-${RANDOM-0}$$
cannam@126 907
cannam@126 908 func_mktempdir_umask=`umask`
cannam@126 909 umask 0077
cannam@126 910 $MKDIR "$_G_tmpdir"
cannam@126 911 umask $func_mktempdir_umask
cannam@126 912 fi
cannam@126 913
cannam@126 914 # If we're not in dry-run mode, bomb out on failure
cannam@126 915 test -d "$_G_tmpdir" || \
cannam@126 916 func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
cannam@126 917 fi
cannam@126 918
cannam@126 919 $ECHO "$_G_tmpdir"
cannam@126 920 }
cannam@126 921
cannam@126 922
cannam@126 923 # func_normal_abspath PATH
cannam@126 924 # ------------------------
cannam@126 925 # Remove doubled-up and trailing slashes, "." path components,
cannam@126 926 # and cancel out any ".." path components in PATH after making
cannam@126 927 # it an absolute path.
cannam@126 928 func_normal_abspath ()
cannam@126 929 {
cannam@126 930 $debug_cmd
cannam@126 931
cannam@126 932 # These SED scripts presuppose an absolute path with a trailing slash.
cannam@126 933 _G_pathcar='s|^/\([^/]*\).*$|\1|'
cannam@126 934 _G_pathcdr='s|^/[^/]*||'
cannam@126 935 _G_removedotparts=':dotsl
cannam@126 936 s|/\./|/|g
cannam@126 937 t dotsl
cannam@126 938 s|/\.$|/|'
cannam@126 939 _G_collapseslashes='s|/\{1,\}|/|g'
cannam@126 940 _G_finalslash='s|/*$|/|'
cannam@126 941
cannam@126 942 # Start from root dir and reassemble the path.
cannam@126 943 func_normal_abspath_result=
cannam@126 944 func_normal_abspath_tpath=$1
cannam@126 945 func_normal_abspath_altnamespace=
cannam@126 946 case $func_normal_abspath_tpath in
cannam@126 947 "")
cannam@126 948 # Empty path, that just means $cwd.
cannam@126 949 func_stripname '' '/' "`pwd`"
cannam@126 950 func_normal_abspath_result=$func_stripname_result
cannam@126 951 return
cannam@126 952 ;;
cannam@126 953 # The next three entries are used to spot a run of precisely
cannam@126 954 # two leading slashes without using negated character classes;
cannam@126 955 # we take advantage of case's first-match behaviour.
cannam@126 956 ///*)
cannam@126 957 # Unusual form of absolute path, do nothing.
cannam@126 958 ;;
cannam@126 959 //*)
cannam@126 960 # Not necessarily an ordinary path; POSIX reserves leading '//'
cannam@126 961 # and for example Cygwin uses it to access remote file shares
cannam@126 962 # over CIFS/SMB, so we conserve a leading double slash if found.
cannam@126 963 func_normal_abspath_altnamespace=/
cannam@126 964 ;;
cannam@126 965 /*)
cannam@126 966 # Absolute path, do nothing.
cannam@126 967 ;;
cannam@126 968 *)
cannam@126 969 # Relative path, prepend $cwd.
cannam@126 970 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
cannam@126 971 ;;
cannam@126 972 esac
cannam@126 973
cannam@126 974 # Cancel out all the simple stuff to save iterations. We also want
cannam@126 975 # the path to end with a slash for ease of parsing, so make sure
cannam@126 976 # there is one (and only one) here.
cannam@126 977 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
cannam@126 978 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
cannam@126 979 while :; do
cannam@126 980 # Processed it all yet?
cannam@126 981 if test / = "$func_normal_abspath_tpath"; then
cannam@126 982 # If we ascended to the root using ".." the result may be empty now.
cannam@126 983 if test -z "$func_normal_abspath_result"; then
cannam@126 984 func_normal_abspath_result=/
cannam@126 985 fi
cannam@126 986 break
cannam@126 987 fi
cannam@126 988 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
cannam@126 989 -e "$_G_pathcar"`
cannam@126 990 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
cannam@126 991 -e "$_G_pathcdr"`
cannam@126 992 # Figure out what to do with it
cannam@126 993 case $func_normal_abspath_tcomponent in
cannam@126 994 "")
cannam@126 995 # Trailing empty path component, ignore it.
cannam@126 996 ;;
cannam@126 997 ..)
cannam@126 998 # Parent dir; strip last assembled component from result.
cannam@126 999 func_dirname "$func_normal_abspath_result"
cannam@126 1000 func_normal_abspath_result=$func_dirname_result
cannam@126 1001 ;;
cannam@126 1002 *)
cannam@126 1003 # Actual path component, append it.
cannam@126 1004 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
cannam@126 1005 ;;
cannam@126 1006 esac
cannam@126 1007 done
cannam@126 1008 # Restore leading double-slash if one was found on entry.
cannam@126 1009 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
cannam@126 1010 }
cannam@126 1011
cannam@126 1012
cannam@126 1013 # func_notquiet ARG...
cannam@126 1014 # --------------------
cannam@126 1015 # Echo program name prefixed message only when not in quiet mode.
cannam@126 1016 func_notquiet ()
cannam@126 1017 {
cannam@126 1018 $debug_cmd
cannam@126 1019
cannam@126 1020 $opt_quiet || func_echo ${1+"$@"}
cannam@126 1021
cannam@126 1022 # A bug in bash halts the script if the last line of a function
cannam@126 1023 # fails when set -e is in force, so we need another command to
cannam@126 1024 # work around that:
cannam@126 1025 :
cannam@126 1026 }
cannam@126 1027
cannam@126 1028
cannam@126 1029 # func_relative_path SRCDIR DSTDIR
cannam@126 1030 # --------------------------------
cannam@126 1031 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
cannam@126 1032 func_relative_path ()
cannam@126 1033 {
cannam@126 1034 $debug_cmd
cannam@126 1035
cannam@126 1036 func_relative_path_result=
cannam@126 1037 func_normal_abspath "$1"
cannam@126 1038 func_relative_path_tlibdir=$func_normal_abspath_result
cannam@126 1039 func_normal_abspath "$2"
cannam@126 1040 func_relative_path_tbindir=$func_normal_abspath_result
cannam@126 1041
cannam@126 1042 # Ascend the tree starting from libdir
cannam@126 1043 while :; do
cannam@126 1044 # check if we have found a prefix of bindir
cannam@126 1045 case $func_relative_path_tbindir in
cannam@126 1046 $func_relative_path_tlibdir)
cannam@126 1047 # found an exact match
cannam@126 1048 func_relative_path_tcancelled=
cannam@126 1049 break
cannam@126 1050 ;;
cannam@126 1051 $func_relative_path_tlibdir*)
cannam@126 1052 # found a matching prefix
cannam@126 1053 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
cannam@126 1054 func_relative_path_tcancelled=$func_stripname_result
cannam@126 1055 if test -z "$func_relative_path_result"; then
cannam@126 1056 func_relative_path_result=.
cannam@126 1057 fi
cannam@126 1058 break
cannam@126 1059 ;;
cannam@126 1060 *)
cannam@126 1061 func_dirname $func_relative_path_tlibdir
cannam@126 1062 func_relative_path_tlibdir=$func_dirname_result
cannam@126 1063 if test -z "$func_relative_path_tlibdir"; then
cannam@126 1064 # Have to descend all the way to the root!
cannam@126 1065 func_relative_path_result=../$func_relative_path_result
cannam@126 1066 func_relative_path_tcancelled=$func_relative_path_tbindir
cannam@126 1067 break
cannam@126 1068 fi
cannam@126 1069 func_relative_path_result=../$func_relative_path_result
cannam@126 1070 ;;
cannam@126 1071 esac
cannam@126 1072 done
cannam@126 1073
cannam@126 1074 # Now calculate path; take care to avoid doubling-up slashes.
cannam@126 1075 func_stripname '' '/' "$func_relative_path_result"
cannam@126 1076 func_relative_path_result=$func_stripname_result
cannam@126 1077 func_stripname '/' '/' "$func_relative_path_tcancelled"
cannam@126 1078 if test -n "$func_stripname_result"; then
cannam@126 1079 func_append func_relative_path_result "/$func_stripname_result"
cannam@126 1080 fi
cannam@126 1081
cannam@126 1082 # Normalisation. If bindir is libdir, return '.' else relative path.
cannam@126 1083 if test -n "$func_relative_path_result"; then
cannam@126 1084 func_stripname './' '' "$func_relative_path_result"
cannam@126 1085 func_relative_path_result=$func_stripname_result
cannam@126 1086 fi
cannam@126 1087
cannam@126 1088 test -n "$func_relative_path_result" || func_relative_path_result=.
cannam@126 1089
cannam@126 1090 :
cannam@126 1091 }
cannam@126 1092
cannam@126 1093
cannam@126 1094 # func_quote_for_eval ARG...
cannam@126 1095 # --------------------------
cannam@126 1096 # Aesthetically quote ARGs to be evaled later.
cannam@126 1097 # This function returns two values:
cannam@126 1098 # i) func_quote_for_eval_result
cannam@126 1099 # double-quoted, suitable for a subsequent eval
cannam@126 1100 # ii) func_quote_for_eval_unquoted_result
cannam@126 1101 # has all characters that are still active within double
cannam@126 1102 # quotes backslashified.
cannam@126 1103 func_quote_for_eval ()
cannam@126 1104 {
cannam@126 1105 $debug_cmd
cannam@126 1106
cannam@126 1107 func_quote_for_eval_unquoted_result=
cannam@126 1108 func_quote_for_eval_result=
cannam@126 1109 while test 0 -lt $#; do
cannam@126 1110 case $1 in
cannam@126 1111 *[\\\`\"\$]*)
cannam@126 1112 _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
cannam@126 1113 *)
cannam@126 1114 _G_unquoted_arg=$1 ;;
cannam@126 1115 esac
cannam@126 1116 if test -n "$func_quote_for_eval_unquoted_result"; then
cannam@126 1117 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
cannam@126 1118 else
cannam@126 1119 func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
cannam@126 1120 fi
cannam@126 1121
cannam@126 1122 case $_G_unquoted_arg in
cannam@126 1123 # Double-quote args containing shell metacharacters to delay
cannam@126 1124 # word splitting, command substitution and variable expansion
cannam@126 1125 # for a subsequent eval.
cannam@126 1126 # Many Bourne shells cannot handle close brackets correctly
cannam@126 1127 # in scan sets, so we specify it separately.
cannam@126 1128 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
cannam@126 1129 _G_quoted_arg=\"$_G_unquoted_arg\"
cannam@126 1130 ;;
cannam@126 1131 *)
cannam@126 1132 _G_quoted_arg=$_G_unquoted_arg
cannam@126 1133 ;;
cannam@126 1134 esac
cannam@126 1135
cannam@126 1136 if test -n "$func_quote_for_eval_result"; then
cannam@126 1137 func_append func_quote_for_eval_result " $_G_quoted_arg"
cannam@126 1138 else
cannam@126 1139 func_append func_quote_for_eval_result "$_G_quoted_arg"
cannam@126 1140 fi
cannam@126 1141 shift
cannam@126 1142 done
cannam@126 1143 }
cannam@126 1144
cannam@126 1145
cannam@126 1146 # func_quote_for_expand ARG
cannam@126 1147 # -------------------------
cannam@126 1148 # Aesthetically quote ARG to be evaled later; same as above,
cannam@126 1149 # but do not quote variable references.
cannam@126 1150 func_quote_for_expand ()
cannam@126 1151 {
cannam@126 1152 $debug_cmd
cannam@126 1153
cannam@126 1154 case $1 in
cannam@126 1155 *[\\\`\"]*)
cannam@126 1156 _G_arg=`$ECHO "$1" | $SED \
cannam@126 1157 -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
cannam@126 1158 *)
cannam@126 1159 _G_arg=$1 ;;
cannam@126 1160 esac
cannam@126 1161
cannam@126 1162 case $_G_arg in
cannam@126 1163 # Double-quote args containing shell metacharacters to delay
cannam@126 1164 # word splitting and command substitution for a subsequent eval.
cannam@126 1165 # Many Bourne shells cannot handle close brackets correctly
cannam@126 1166 # in scan sets, so we specify it separately.
cannam@126 1167 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
cannam@126 1168 _G_arg=\"$_G_arg\"
cannam@126 1169 ;;
cannam@126 1170 esac
cannam@126 1171
cannam@126 1172 func_quote_for_expand_result=$_G_arg
cannam@126 1173 }
cannam@126 1174
cannam@126 1175
cannam@126 1176 # func_stripname PREFIX SUFFIX NAME
cannam@126 1177 # ---------------------------------
cannam@126 1178 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
cannam@126 1179 # PREFIX and SUFFIX must not contain globbing or regex special
cannam@126 1180 # characters, hashes, percent signs, but SUFFIX may contain a leading
cannam@126 1181 # dot (in which case that matches only a dot).
cannam@126 1182 if test yes = "$_G_HAVE_XSI_OPS"; then
cannam@126 1183 eval 'func_stripname ()
cannam@126 1184 {
cannam@126 1185 $debug_cmd
cannam@126 1186
cannam@126 1187 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
cannam@126 1188 # positional parameters, so assign one to ordinary variable first.
cannam@126 1189 func_stripname_result=$3
cannam@126 1190 func_stripname_result=${func_stripname_result#"$1"}
cannam@126 1191 func_stripname_result=${func_stripname_result%"$2"}
cannam@126 1192 }'
cannam@126 1193 else
cannam@126 1194 func_stripname ()
cannam@126 1195 {
cannam@126 1196 $debug_cmd
cannam@126 1197
cannam@126 1198 case $2 in
cannam@126 1199 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
cannam@126 1200 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
cannam@126 1201 esac
cannam@126 1202 }
cannam@126 1203 fi
cannam@126 1204
cannam@126 1205
cannam@126 1206 # func_show_eval CMD [FAIL_EXP]
cannam@126 1207 # -----------------------------
cannam@126 1208 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
cannam@126 1209 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
cannam@126 1210 # is given, then evaluate it.
cannam@126 1211 func_show_eval ()
cannam@126 1212 {
cannam@126 1213 $debug_cmd
cannam@126 1214
cannam@126 1215 _G_cmd=$1
cannam@126 1216 _G_fail_exp=${2-':'}
cannam@126 1217
cannam@126 1218 func_quote_for_expand "$_G_cmd"
cannam@126 1219 eval "func_notquiet $func_quote_for_expand_result"
cannam@126 1220
cannam@126 1221 $opt_dry_run || {
cannam@126 1222 eval "$_G_cmd"
cannam@126 1223 _G_status=$?
cannam@126 1224 if test 0 -ne "$_G_status"; then
cannam@126 1225 eval "(exit $_G_status); $_G_fail_exp"
cannam@126 1226 fi
cannam@126 1227 }
cannam@126 1228 }
cannam@126 1229
cannam@126 1230
cannam@126 1231 # func_show_eval_locale CMD [FAIL_EXP]
cannam@126 1232 # ------------------------------------
cannam@126 1233 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
cannam@126 1234 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
cannam@126 1235 # is given, then evaluate it. Use the saved locale for evaluation.
cannam@126 1236 func_show_eval_locale ()
cannam@126 1237 {
cannam@126 1238 $debug_cmd
cannam@126 1239
cannam@126 1240 _G_cmd=$1
cannam@126 1241 _G_fail_exp=${2-':'}
cannam@126 1242
cannam@126 1243 $opt_quiet || {
cannam@126 1244 func_quote_for_expand "$_G_cmd"
cannam@126 1245 eval "func_echo $func_quote_for_expand_result"
cannam@126 1246 }
cannam@126 1247
cannam@126 1248 $opt_dry_run || {
cannam@126 1249 eval "$_G_user_locale
cannam@126 1250 $_G_cmd"
cannam@126 1251 _G_status=$?
cannam@126 1252 eval "$_G_safe_locale"
cannam@126 1253 if test 0 -ne "$_G_status"; then
cannam@126 1254 eval "(exit $_G_status); $_G_fail_exp"
cannam@126 1255 fi
cannam@126 1256 }
cannam@126 1257 }
cannam@126 1258
cannam@126 1259
cannam@126 1260 # func_tr_sh
cannam@126 1261 # ----------
cannam@126 1262 # Turn $1 into a string suitable for a shell variable name.
cannam@126 1263 # Result is stored in $func_tr_sh_result. All characters
cannam@126 1264 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
cannam@126 1265 # if $1 begins with a digit, a '_' is prepended as well.
cannam@126 1266 func_tr_sh ()
cannam@126 1267 {
cannam@126 1268 $debug_cmd
cannam@126 1269
cannam@126 1270 case $1 in
cannam@126 1271 [0-9]* | *[!a-zA-Z0-9_]*)
cannam@126 1272 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
cannam@126 1273 ;;
cannam@126 1274 * )
cannam@126 1275 func_tr_sh_result=$1
cannam@126 1276 ;;
cannam@126 1277 esac
cannam@126 1278 }
cannam@126 1279
cannam@126 1280
cannam@126 1281 # func_verbose ARG...
cannam@126 1282 # -------------------
cannam@126 1283 # Echo program name prefixed message in verbose mode only.
cannam@126 1284 func_verbose ()
cannam@126 1285 {
cannam@126 1286 $debug_cmd
cannam@126 1287
cannam@126 1288 $opt_verbose && func_echo "$*"
cannam@126 1289
cannam@126 1290 :
cannam@126 1291 }
cannam@126 1292
cannam@126 1293
cannam@126 1294 # func_warn_and_continue ARG...
cannam@126 1295 # -----------------------------
cannam@126 1296 # Echo program name prefixed warning message to standard error.
cannam@126 1297 func_warn_and_continue ()
cannam@126 1298 {
cannam@126 1299 $debug_cmd
cannam@126 1300
cannam@126 1301 $require_term_colors
cannam@126 1302
cannam@126 1303 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
cannam@126 1304 }
cannam@126 1305
cannam@126 1306
cannam@126 1307 # func_warning CATEGORY ARG...
cannam@126 1308 # ----------------------------
cannam@126 1309 # Echo program name prefixed warning message to standard error. Warning
cannam@126 1310 # messages can be filtered according to CATEGORY, where this function
cannam@126 1311 # elides messages where CATEGORY is not listed in the global variable
cannam@126 1312 # 'opt_warning_types'.
cannam@126 1313 func_warning ()
cannam@126 1314 {
cannam@126 1315 $debug_cmd
cannam@126 1316
cannam@126 1317 # CATEGORY must be in the warning_categories list!
cannam@126 1318 case " $warning_categories " in
cannam@126 1319 *" $1 "*) ;;
cannam@126 1320 *) func_internal_error "invalid warning category '$1'" ;;
cannam@126 1321 esac
cannam@126 1322
cannam@126 1323 _G_category=$1
cannam@126 1324 shift
cannam@126 1325
cannam@126 1326 case " $opt_warning_types " in
cannam@126 1327 *" $_G_category "*) $warning_func ${1+"$@"} ;;
cannam@126 1328 esac
cannam@126 1329 }
cannam@126 1330
cannam@126 1331
cannam@126 1332 # func_sort_ver VER1 VER2
cannam@126 1333 # -----------------------
cannam@126 1334 # 'sort -V' is not generally available.
cannam@126 1335 # Note this deviates from the version comparison in automake
cannam@126 1336 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
cannam@126 1337 # but this should suffice as we won't be specifying old
cannam@126 1338 # version formats or redundant trailing .0 in bootstrap.conf.
cannam@126 1339 # If we did want full compatibility then we should probably
cannam@126 1340 # use m4_version_compare from autoconf.
cannam@126 1341 func_sort_ver ()
cannam@126 1342 {
cannam@126 1343 $debug_cmd
cannam@126 1344
cannam@126 1345 printf '%s\n%s\n' "$1" "$2" \
cannam@126 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@126 1347 }
cannam@126 1348
cannam@126 1349 # func_lt_ver PREV CURR
cannam@126 1350 # ---------------------
cannam@126 1351 # Return true if PREV and CURR are in the correct order according to
cannam@126 1352 # func_sort_ver, otherwise false. Use it like this:
cannam@126 1353 #
cannam@126 1354 # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
cannam@126 1355 func_lt_ver ()
cannam@126 1356 {
cannam@126 1357 $debug_cmd
cannam@126 1358
cannam@126 1359 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
cannam@126 1360 }
cannam@126 1361
cannam@126 1362
cannam@126 1363 # Local variables:
cannam@126 1364 # mode: shell-script
cannam@126 1365 # sh-indentation: 2
cannam@126 1366 # eval: (add-hook 'before-save-hook 'time-stamp)
cannam@126 1367 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
cannam@126 1368 # time-stamp-time-zone: "UTC"
cannam@126 1369 # End:
cannam@126 1370 #! /bin/sh
cannam@126 1371
cannam@126 1372 # Set a version string for this script.
cannam@126 1373 scriptversion=2014-01-07.03; # UTC
cannam@126 1374
cannam@126 1375 # A portable, pluggable option parser for Bourne shell.
cannam@126 1376 # Written by Gary V. Vaughan, 2010
cannam@126 1377
cannam@126 1378 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
cannam@126 1379 # This is free software; see the source for copying conditions. There is NO
cannam@126 1380 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cannam@126 1381
cannam@126 1382 # This program is free software: you can redistribute it and/or modify
cannam@126 1383 # it under the terms of the GNU General Public License as published by
cannam@126 1384 # the Free Software Foundation, either version 3 of the License, or
cannam@126 1385 # (at your option) any later version.
cannam@126 1386
cannam@126 1387 # This program is distributed in the hope that it will be useful,
cannam@126 1388 # but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@126 1389 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@126 1390 # GNU General Public License for more details.
cannam@126 1391
cannam@126 1392 # You should have received a copy of the GNU General Public License
cannam@126 1393 # along with this program. If not, see <http://www.gnu.org/licenses/>.
cannam@126 1394
cannam@126 1395 # Please report bugs or propose patches to gary@gnu.org.
cannam@126 1396
cannam@126 1397
cannam@126 1398 ## ------ ##
cannam@126 1399 ## Usage. ##
cannam@126 1400 ## ------ ##
cannam@126 1401
cannam@126 1402 # This file is a library for parsing options in your shell scripts along
cannam@126 1403 # with assorted other useful supporting features that you can make use
cannam@126 1404 # of too.
cannam@126 1405 #
cannam@126 1406 # For the simplest scripts you might need only:
cannam@126 1407 #
cannam@126 1408 # #!/bin/sh
cannam@126 1409 # . relative/path/to/funclib.sh
cannam@126 1410 # . relative/path/to/options-parser
cannam@126 1411 # scriptversion=1.0
cannam@126 1412 # func_options ${1+"$@"}
cannam@126 1413 # eval set dummy "$func_options_result"; shift
cannam@126 1414 # ...rest of your script...
cannam@126 1415 #
cannam@126 1416 # In order for the '--version' option to work, you will need to have a
cannam@126 1417 # suitably formatted comment like the one at the top of this file
cannam@126 1418 # starting with '# Written by ' and ending with '# warranty; '.
cannam@126 1419 #
cannam@126 1420 # For '-h' and '--help' to work, you will also need a one line
cannam@126 1421 # description of your script's purpose in a comment directly above the
cannam@126 1422 # '# Written by ' line, like the one at the top of this file.
cannam@126 1423 #
cannam@126 1424 # The default options also support '--debug', which will turn on shell
cannam@126 1425 # execution tracing (see the comment above debug_cmd below for another
cannam@126 1426 # use), and '--verbose' and the func_verbose function to allow your script
cannam@126 1427 # to display verbose messages only when your user has specified
cannam@126 1428 # '--verbose'.
cannam@126 1429 #
cannam@126 1430 # After sourcing this file, you can plug processing for additional
cannam@126 1431 # options by amending the variables from the 'Configuration' section
cannam@126 1432 # below, and following the instructions in the 'Option parsing'
cannam@126 1433 # section further down.
cannam@126 1434
cannam@126 1435 ## -------------- ##
cannam@126 1436 ## Configuration. ##
cannam@126 1437 ## -------------- ##
cannam@126 1438
cannam@126 1439 # You should override these variables in your script after sourcing this
cannam@126 1440 # file so that they reflect the customisations you have added to the
cannam@126 1441 # option parser.
cannam@126 1442
cannam@126 1443 # The usage line for option parsing errors and the start of '-h' and
cannam@126 1444 # '--help' output messages. You can embed shell variables for delayed
cannam@126 1445 # expansion at the time the message is displayed, but you will need to
cannam@126 1446 # quote other shell meta-characters carefully to prevent them being
cannam@126 1447 # expanded when the contents are evaled.
cannam@126 1448 usage='$progpath [OPTION]...'
cannam@126 1449
cannam@126 1450 # Short help message in response to '-h' and '--help'. Add to this or
cannam@126 1451 # override it after sourcing this library to reflect the full set of
cannam@126 1452 # options your script accepts.
cannam@126 1453 usage_message="\
cannam@126 1454 --debug enable verbose shell tracing
cannam@126 1455 -W, --warnings=CATEGORY
cannam@126 1456 report the warnings falling in CATEGORY [all]
cannam@126 1457 -v, --verbose verbosely report processing
cannam@126 1458 --version print version information and exit
cannam@126 1459 -h, --help print short or long help message and exit
cannam@126 1460 "
cannam@126 1461
cannam@126 1462 # Additional text appended to 'usage_message' in response to '--help'.
cannam@126 1463 long_help_message="
cannam@126 1464 Warning categories include:
cannam@126 1465 'all' show all warnings
cannam@126 1466 'none' turn off all the warnings
cannam@126 1467 'error' warnings are treated as fatal errors"
cannam@126 1468
cannam@126 1469 # Help message printed before fatal option parsing errors.
cannam@126 1470 fatal_help="Try '\$progname --help' for more information."
cannam@126 1471
cannam@126 1472
cannam@126 1473
cannam@126 1474 ## ------------------------- ##
cannam@126 1475 ## Hook function management. ##
cannam@126 1476 ## ------------------------- ##
cannam@126 1477
cannam@126 1478 # This section contains functions for adding, removing, and running hooks
cannam@126 1479 # to the main code. A hook is just a named list of of function, that can
cannam@126 1480 # be run in order later on.
cannam@126 1481
cannam@126 1482 # func_hookable FUNC_NAME
cannam@126 1483 # -----------------------
cannam@126 1484 # Declare that FUNC_NAME will run hooks added with
cannam@126 1485 # 'func_add_hook FUNC_NAME ...'.
cannam@126 1486 func_hookable ()
cannam@126 1487 {
cannam@126 1488 $debug_cmd
cannam@126 1489
cannam@126 1490 func_append hookable_fns " $1"
cannam@126 1491 }
cannam@126 1492
cannam@126 1493
cannam@126 1494 # func_add_hook FUNC_NAME HOOK_FUNC
cannam@126 1495 # ---------------------------------
cannam@126 1496 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
cannam@126 1497 # first have been declared "hookable" by a call to 'func_hookable'.
cannam@126 1498 func_add_hook ()
cannam@126 1499 {
cannam@126 1500 $debug_cmd
cannam@126 1501
cannam@126 1502 case " $hookable_fns " in
cannam@126 1503 *" $1 "*) ;;
cannam@126 1504 *) func_fatal_error "'$1' does not accept hook functions." ;;
cannam@126 1505 esac
cannam@126 1506
cannam@126 1507 eval func_append ${1}_hooks '" $2"'
cannam@126 1508 }
cannam@126 1509
cannam@126 1510
cannam@126 1511 # func_remove_hook FUNC_NAME HOOK_FUNC
cannam@126 1512 # ------------------------------------
cannam@126 1513 # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
cannam@126 1514 func_remove_hook ()
cannam@126 1515 {
cannam@126 1516 $debug_cmd
cannam@126 1517
cannam@126 1518 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
cannam@126 1519 }
cannam@126 1520
cannam@126 1521
cannam@126 1522 # func_run_hooks FUNC_NAME [ARG]...
cannam@126 1523 # ---------------------------------
cannam@126 1524 # Run all hook functions registered to FUNC_NAME.
cannam@126 1525 # It is assumed that the list of hook functions contains nothing more
cannam@126 1526 # than a whitespace-delimited list of legal shell function names, and
cannam@126 1527 # no effort is wasted trying to catch shell meta-characters or preserve
cannam@126 1528 # whitespace.
cannam@126 1529 func_run_hooks ()
cannam@126 1530 {
cannam@126 1531 $debug_cmd
cannam@126 1532
cannam@126 1533 case " $hookable_fns " in
cannam@126 1534 *" $1 "*) ;;
cannam@126 1535 *) func_fatal_error "'$1' does not support hook funcions.n" ;;
cannam@126 1536 esac
cannam@126 1537
cannam@126 1538 eval _G_hook_fns=\$$1_hooks; shift
cannam@126 1539
cannam@126 1540 for _G_hook in $_G_hook_fns; do
cannam@126 1541 eval $_G_hook '"$@"'
cannam@126 1542
cannam@126 1543 # store returned options list back into positional
cannam@126 1544 # parameters for next 'cmd' execution.
cannam@126 1545 eval _G_hook_result=\$${_G_hook}_result
cannam@126 1546 eval set dummy "$_G_hook_result"; shift
cannam@126 1547 done
cannam@126 1548
cannam@126 1549 func_quote_for_eval ${1+"$@"}
cannam@126 1550 func_run_hooks_result=$func_quote_for_eval_result
cannam@126 1551 }
cannam@126 1552
cannam@126 1553
cannam@126 1554
cannam@126 1555 ## --------------- ##
cannam@126 1556 ## Option parsing. ##
cannam@126 1557 ## --------------- ##
cannam@126 1558
cannam@126 1559 # In order to add your own option parsing hooks, you must accept the
cannam@126 1560 # full positional parameter list in your hook function, remove any
cannam@126 1561 # options that you action, and then pass back the remaining unprocessed
cannam@126 1562 # options in '<hooked_function_name>_result', escaped suitably for
cannam@126 1563 # 'eval'. Like this:
cannam@126 1564 #
cannam@126 1565 # my_options_prep ()
cannam@126 1566 # {
cannam@126 1567 # $debug_cmd
cannam@126 1568 #
cannam@126 1569 # # Extend the existing usage message.
cannam@126 1570 # usage_message=$usage_message'
cannam@126 1571 # -s, --silent don'\''t print informational messages
cannam@126 1572 # '
cannam@126 1573 #
cannam@126 1574 # func_quote_for_eval ${1+"$@"}
cannam@126 1575 # my_options_prep_result=$func_quote_for_eval_result
cannam@126 1576 # }
cannam@126 1577 # func_add_hook func_options_prep my_options_prep
cannam@126 1578 #
cannam@126 1579 #
cannam@126 1580 # my_silent_option ()
cannam@126 1581 # {
cannam@126 1582 # $debug_cmd
cannam@126 1583 #
cannam@126 1584 # # Note that for efficiency, we parse as many options as we can
cannam@126 1585 # # recognise in a loop before passing the remainder back to the
cannam@126 1586 # # caller on the first unrecognised argument we encounter.
cannam@126 1587 # while test $# -gt 0; do
cannam@126 1588 # opt=$1; shift
cannam@126 1589 # case $opt in
cannam@126 1590 # --silent|-s) opt_silent=: ;;
cannam@126 1591 # # Separate non-argument short options:
cannam@126 1592 # -s*) func_split_short_opt "$_G_opt"
cannam@126 1593 # set dummy "$func_split_short_opt_name" \
cannam@126 1594 # "-$func_split_short_opt_arg" ${1+"$@"}
cannam@126 1595 # shift
cannam@126 1596 # ;;
cannam@126 1597 # *) set dummy "$_G_opt" "$*"; shift; break ;;
cannam@126 1598 # esac
cannam@126 1599 # done
cannam@126 1600 #
cannam@126 1601 # func_quote_for_eval ${1+"$@"}
cannam@126 1602 # my_silent_option_result=$func_quote_for_eval_result
cannam@126 1603 # }
cannam@126 1604 # func_add_hook func_parse_options my_silent_option
cannam@126 1605 #
cannam@126 1606 #
cannam@126 1607 # my_option_validation ()
cannam@126 1608 # {
cannam@126 1609 # $debug_cmd
cannam@126 1610 #
cannam@126 1611 # $opt_silent && $opt_verbose && func_fatal_help "\
cannam@126 1612 # '--silent' and '--verbose' options are mutually exclusive."
cannam@126 1613 #
cannam@126 1614 # func_quote_for_eval ${1+"$@"}
cannam@126 1615 # my_option_validation_result=$func_quote_for_eval_result
cannam@126 1616 # }
cannam@126 1617 # func_add_hook func_validate_options my_option_validation
cannam@126 1618 #
cannam@126 1619 # You'll alse need to manually amend $usage_message to reflect the extra
cannam@126 1620 # options you parse. It's preferable to append if you can, so that
cannam@126 1621 # multiple option parsing hooks can be added safely.
cannam@126 1622
cannam@126 1623
cannam@126 1624 # func_options [ARG]...
cannam@126 1625 # ---------------------
cannam@126 1626 # All the functions called inside func_options are hookable. See the
cannam@126 1627 # individual implementations for details.
cannam@126 1628 func_hookable func_options
cannam@126 1629 func_options ()
cannam@126 1630 {
cannam@126 1631 $debug_cmd
cannam@126 1632
cannam@126 1633 func_options_prep ${1+"$@"}
cannam@126 1634 eval func_parse_options \
cannam@126 1635 ${func_options_prep_result+"$func_options_prep_result"}
cannam@126 1636 eval func_validate_options \
cannam@126 1637 ${func_parse_options_result+"$func_parse_options_result"}
cannam@126 1638
cannam@126 1639 eval func_run_hooks func_options \
cannam@126 1640 ${func_validate_options_result+"$func_validate_options_result"}
cannam@126 1641
cannam@126 1642 # save modified positional parameters for caller
cannam@126 1643 func_options_result=$func_run_hooks_result
cannam@126 1644 }
cannam@126 1645
cannam@126 1646
cannam@126 1647 # func_options_prep [ARG]...
cannam@126 1648 # --------------------------
cannam@126 1649 # All initialisations required before starting the option parse loop.
cannam@126 1650 # Note that when calling hook functions, we pass through the list of
cannam@126 1651 # positional parameters. If a hook function modifies that list, and
cannam@126 1652 # needs to propogate that back to rest of this script, then the complete
cannam@126 1653 # modified list must be put in 'func_run_hooks_result' before
cannam@126 1654 # returning.
cannam@126 1655 func_hookable func_options_prep
cannam@126 1656 func_options_prep ()
cannam@126 1657 {
cannam@126 1658 $debug_cmd
cannam@126 1659
cannam@126 1660 # Option defaults:
cannam@126 1661 opt_verbose=false
cannam@126 1662 opt_warning_types=
cannam@126 1663
cannam@126 1664 func_run_hooks func_options_prep ${1+"$@"}
cannam@126 1665
cannam@126 1666 # save modified positional parameters for caller
cannam@126 1667 func_options_prep_result=$func_run_hooks_result
cannam@126 1668 }
cannam@126 1669
cannam@126 1670
cannam@126 1671 # func_parse_options [ARG]...
cannam@126 1672 # ---------------------------
cannam@126 1673 # The main option parsing loop.
cannam@126 1674 func_hookable func_parse_options
cannam@126 1675 func_parse_options ()
cannam@126 1676 {
cannam@126 1677 $debug_cmd
cannam@126 1678
cannam@126 1679 func_parse_options_result=
cannam@126 1680
cannam@126 1681 # this just eases exit handling
cannam@126 1682 while test $# -gt 0; do
cannam@126 1683 # Defer to hook functions for initial option parsing, so they
cannam@126 1684 # get priority in the event of reusing an option name.
cannam@126 1685 func_run_hooks func_parse_options ${1+"$@"}
cannam@126 1686
cannam@126 1687 # Adjust func_parse_options positional parameters to match
cannam@126 1688 eval set dummy "$func_run_hooks_result"; shift
cannam@126 1689
cannam@126 1690 # Break out of the loop if we already parsed every option.
cannam@126 1691 test $# -gt 0 || break
cannam@126 1692
cannam@126 1693 _G_opt=$1
cannam@126 1694 shift
cannam@126 1695 case $_G_opt in
cannam@126 1696 --debug|-x) debug_cmd='set -x'
cannam@126 1697 func_echo "enabling shell trace mode"
cannam@126 1698 $debug_cmd
cannam@126 1699 ;;
cannam@126 1700
cannam@126 1701 --no-warnings|--no-warning|--no-warn)
cannam@126 1702 set dummy --warnings none ${1+"$@"}
cannam@126 1703 shift
cannam@126 1704 ;;
cannam@126 1705
cannam@126 1706 --warnings|--warning|-W)
cannam@126 1707 test $# = 0 && func_missing_arg $_G_opt && break
cannam@126 1708 case " $warning_categories $1" in
cannam@126 1709 *" $1 "*)
cannam@126 1710 # trailing space prevents matching last $1 above
cannam@126 1711 func_append_uniq opt_warning_types " $1"
cannam@126 1712 ;;
cannam@126 1713 *all)
cannam@126 1714 opt_warning_types=$warning_categories
cannam@126 1715 ;;
cannam@126 1716 *none)
cannam@126 1717 opt_warning_types=none
cannam@126 1718 warning_func=:
cannam@126 1719 ;;
cannam@126 1720 *error)
cannam@126 1721 opt_warning_types=$warning_categories
cannam@126 1722 warning_func=func_fatal_error
cannam@126 1723 ;;
cannam@126 1724 *)
cannam@126 1725 func_fatal_error \
cannam@126 1726 "unsupported warning category: '$1'"
cannam@126 1727 ;;
cannam@126 1728 esac
cannam@126 1729 shift
cannam@126 1730 ;;
cannam@126 1731
cannam@126 1732 --verbose|-v) opt_verbose=: ;;
cannam@126 1733 --version) func_version ;;
cannam@126 1734 -\?|-h) func_usage ;;
cannam@126 1735 --help) func_help ;;
cannam@126 1736
cannam@126 1737 # Separate optargs to long options (plugins may need this):
cannam@126 1738 --*=*) func_split_equals "$_G_opt"
cannam@126 1739 set dummy "$func_split_equals_lhs" \
cannam@126 1740 "$func_split_equals_rhs" ${1+"$@"}
cannam@126 1741 shift
cannam@126 1742 ;;
cannam@126 1743
cannam@126 1744 # Separate optargs to short options:
cannam@126 1745 -W*)
cannam@126 1746 func_split_short_opt "$_G_opt"
cannam@126 1747 set dummy "$func_split_short_opt_name" \
cannam@126 1748 "$func_split_short_opt_arg" ${1+"$@"}
cannam@126 1749 shift
cannam@126 1750 ;;
cannam@126 1751
cannam@126 1752 # Separate non-argument short options:
cannam@126 1753 -\?*|-h*|-v*|-x*)
cannam@126 1754 func_split_short_opt "$_G_opt"
cannam@126 1755 set dummy "$func_split_short_opt_name" \
cannam@126 1756 "-$func_split_short_opt_arg" ${1+"$@"}
cannam@126 1757 shift
cannam@126 1758 ;;
cannam@126 1759
cannam@126 1760 --) break ;;
cannam@126 1761 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
cannam@126 1762 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
cannam@126 1763 esac
cannam@126 1764 done
cannam@126 1765
cannam@126 1766 # save modified positional parameters for caller
cannam@126 1767 func_quote_for_eval ${1+"$@"}
cannam@126 1768 func_parse_options_result=$func_quote_for_eval_result
cannam@126 1769 }
cannam@126 1770
cannam@126 1771
cannam@126 1772 # func_validate_options [ARG]...
cannam@126 1773 # ------------------------------
cannam@126 1774 # Perform any sanity checks on option settings and/or unconsumed
cannam@126 1775 # arguments.
cannam@126 1776 func_hookable func_validate_options
cannam@126 1777 func_validate_options ()
cannam@126 1778 {
cannam@126 1779 $debug_cmd
cannam@126 1780
cannam@126 1781 # Display all warnings if -W was not given.
cannam@126 1782 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
cannam@126 1783
cannam@126 1784 func_run_hooks func_validate_options ${1+"$@"}
cannam@126 1785
cannam@126 1786 # Bail if the options were screwed!
cannam@126 1787 $exit_cmd $EXIT_FAILURE
cannam@126 1788
cannam@126 1789 # save modified positional parameters for caller
cannam@126 1790 func_validate_options_result=$func_run_hooks_result
cannam@126 1791 }
cannam@126 1792
cannam@126 1793
cannam@126 1794
cannam@126 1795 ## ----------------- ##
cannam@126 1796 ## Helper functions. ##
cannam@126 1797 ## ----------------- ##
cannam@126 1798
cannam@126 1799 # This section contains the helper functions used by the rest of the
cannam@126 1800 # hookable option parser framework in ascii-betical order.
cannam@126 1801
cannam@126 1802
cannam@126 1803 # func_fatal_help ARG...
cannam@126 1804 # ----------------------
cannam@126 1805 # Echo program name prefixed message to standard error, followed by
cannam@126 1806 # a help hint, and exit.
cannam@126 1807 func_fatal_help ()
cannam@126 1808 {
cannam@126 1809 $debug_cmd
cannam@126 1810
cannam@126 1811 eval \$ECHO \""Usage: $usage"\"
cannam@126 1812 eval \$ECHO \""$fatal_help"\"
cannam@126 1813 func_error ${1+"$@"}
cannam@126 1814 exit $EXIT_FAILURE
cannam@126 1815 }
cannam@126 1816
cannam@126 1817
cannam@126 1818 # func_help
cannam@126 1819 # ---------
cannam@126 1820 # Echo long help message to standard output and exit.
cannam@126 1821 func_help ()
cannam@126 1822 {
cannam@126 1823 $debug_cmd
cannam@126 1824
cannam@126 1825 func_usage_message
cannam@126 1826 $ECHO "$long_help_message"
cannam@126 1827 exit 0
cannam@126 1828 }
cannam@126 1829
cannam@126 1830
cannam@126 1831 # func_missing_arg ARGNAME
cannam@126 1832 # ------------------------
cannam@126 1833 # Echo program name prefixed message to standard error and set global
cannam@126 1834 # exit_cmd.
cannam@126 1835 func_missing_arg ()
cannam@126 1836 {
cannam@126 1837 $debug_cmd
cannam@126 1838
cannam@126 1839 func_error "Missing argument for '$1'."
cannam@126 1840 exit_cmd=exit
cannam@126 1841 }
cannam@126 1842
cannam@126 1843
cannam@126 1844 # func_split_equals STRING
cannam@126 1845 # ------------------------
cannam@126 1846 # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
cannam@126 1847 # splitting STRING at the '=' sign.
cannam@126 1848 test -z "$_G_HAVE_XSI_OPS" \
cannam@126 1849 && (eval 'x=a/b/c;
cannam@126 1850 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
cannam@126 1851 && _G_HAVE_XSI_OPS=yes
cannam@126 1852
cannam@126 1853 if test yes = "$_G_HAVE_XSI_OPS"
cannam@126 1854 then
cannam@126 1855 # This is an XSI compatible shell, allowing a faster implementation...
cannam@126 1856 eval 'func_split_equals ()
cannam@126 1857 {
cannam@126 1858 $debug_cmd
cannam@126 1859
cannam@126 1860 func_split_equals_lhs=${1%%=*}
cannam@126 1861 func_split_equals_rhs=${1#*=}
cannam@126 1862 test "x$func_split_equals_lhs" = "x$1" \
cannam@126 1863 && func_split_equals_rhs=
cannam@126 1864 }'
cannam@126 1865 else
cannam@126 1866 # ...otherwise fall back to using expr, which is often a shell builtin.
cannam@126 1867 func_split_equals ()
cannam@126 1868 {
cannam@126 1869 $debug_cmd
cannam@126 1870
cannam@126 1871 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
cannam@126 1872 func_split_equals_rhs=
cannam@126 1873 test "x$func_split_equals_lhs" = "x$1" \
cannam@126 1874 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
cannam@126 1875 }
cannam@126 1876 fi #func_split_equals
cannam@126 1877
cannam@126 1878
cannam@126 1879 # func_split_short_opt SHORTOPT
cannam@126 1880 # -----------------------------
cannam@126 1881 # Set func_split_short_opt_name and func_split_short_opt_arg shell
cannam@126 1882 # variables after splitting SHORTOPT after the 2nd character.
cannam@126 1883 if test yes = "$_G_HAVE_XSI_OPS"
cannam@126 1884 then
cannam@126 1885 # This is an XSI compatible shell, allowing a faster implementation...
cannam@126 1886 eval 'func_split_short_opt ()
cannam@126 1887 {
cannam@126 1888 $debug_cmd
cannam@126 1889
cannam@126 1890 func_split_short_opt_arg=${1#??}
cannam@126 1891 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
cannam@126 1892 }'
cannam@126 1893 else
cannam@126 1894 # ...otherwise fall back to using expr, which is often a shell builtin.
cannam@126 1895 func_split_short_opt ()
cannam@126 1896 {
cannam@126 1897 $debug_cmd
cannam@126 1898
cannam@126 1899 func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
cannam@126 1900 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
cannam@126 1901 }
cannam@126 1902 fi #func_split_short_opt
cannam@126 1903
cannam@126 1904
cannam@126 1905 # func_usage
cannam@126 1906 # ----------
cannam@126 1907 # Echo short help message to standard output and exit.
cannam@126 1908 func_usage ()
cannam@126 1909 {
cannam@126 1910 $debug_cmd
cannam@126 1911
cannam@126 1912 func_usage_message
cannam@126 1913 $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
cannam@126 1914 exit 0
cannam@126 1915 }
cannam@126 1916
cannam@126 1917
cannam@126 1918 # func_usage_message
cannam@126 1919 # ------------------
cannam@126 1920 # Echo short help message to standard output.
cannam@126 1921 func_usage_message ()
cannam@126 1922 {
cannam@126 1923 $debug_cmd
cannam@126 1924
cannam@126 1925 eval \$ECHO \""Usage: $usage"\"
cannam@126 1926 echo
cannam@126 1927 $SED -n 's|^# ||
cannam@126 1928 /^Written by/{
cannam@126 1929 x;p;x
cannam@126 1930 }
cannam@126 1931 h
cannam@126 1932 /^Written by/q' < "$progpath"
cannam@126 1933 echo
cannam@126 1934 eval \$ECHO \""$usage_message"\"
cannam@126 1935 }
cannam@126 1936
cannam@126 1937
cannam@126 1938 # func_version
cannam@126 1939 # ------------
cannam@126 1940 # Echo version message to standard output and exit.
cannam@126 1941 func_version ()
cannam@126 1942 {
cannam@126 1943 $debug_cmd
cannam@126 1944
cannam@126 1945 printf '%s\n' "$progname $scriptversion"
cannam@126 1946 $SED -n '
cannam@126 1947 /(C)/!b go
cannam@126 1948 :more
cannam@126 1949 /\./!{
cannam@126 1950 N
cannam@126 1951 s|\n# | |
cannam@126 1952 b more
cannam@126 1953 }
cannam@126 1954 :go
cannam@126 1955 /^# Written by /,/# warranty; / {
cannam@126 1956 s|^# ||
cannam@126 1957 s|^# *$||
cannam@126 1958 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
cannam@126 1959 p
cannam@126 1960 }
cannam@126 1961 /^# Written by / {
cannam@126 1962 s|^# ||
cannam@126 1963 p
cannam@126 1964 }
cannam@126 1965 /^warranty; /q' < "$progpath"
cannam@126 1966
cannam@126 1967 exit $?
cannam@126 1968 }
cannam@126 1969
cannam@126 1970
cannam@126 1971 # Local variables:
cannam@126 1972 # mode: shell-script
cannam@126 1973 # sh-indentation: 2
cannam@126 1974 # eval: (add-hook 'before-save-hook 'time-stamp)
cannam@126 1975 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
cannam@126 1976 # time-stamp-time-zone: "UTC"
cannam@126 1977 # End:
cannam@126 1978
cannam@126 1979 # Set a version string.
cannam@126 1980 scriptversion='(GNU libtool) 2.4.6'
cannam@126 1981
cannam@126 1982
cannam@126 1983 # func_echo ARG...
cannam@126 1984 # ----------------
cannam@126 1985 # Libtool also displays the current mode in messages, so override
cannam@126 1986 # funclib.sh func_echo with this custom definition.
cannam@126 1987 func_echo ()
cannam@126 1988 {
cannam@126 1989 $debug_cmd
cannam@126 1990
cannam@126 1991 _G_message=$*
cannam@126 1992
cannam@126 1993 func_echo_IFS=$IFS
cannam@126 1994 IFS=$nl
cannam@126 1995 for _G_line in $_G_message; do
cannam@126 1996 IFS=$func_echo_IFS
cannam@126 1997 $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
cannam@126 1998 done
cannam@126 1999 IFS=$func_echo_IFS
cannam@126 2000 }
cannam@126 2001
cannam@126 2002
cannam@126 2003 # func_warning ARG...
cannam@126 2004 # -------------------
cannam@126 2005 # Libtool warnings are not categorized, so override funclib.sh
cannam@126 2006 # func_warning with this simpler definition.
cannam@126 2007 func_warning ()
cannam@126 2008 {
cannam@126 2009 $debug_cmd
cannam@126 2010
cannam@126 2011 $warning_func ${1+"$@"}
cannam@126 2012 }
cannam@126 2013
cannam@126 2014
cannam@126 2015 ## ---------------- ##
cannam@126 2016 ## Options parsing. ##
cannam@126 2017 ## ---------------- ##
cannam@126 2018
cannam@126 2019 # Hook in the functions to make sure our own options are parsed during
cannam@126 2020 # the option parsing loop.
cannam@126 2021
cannam@126 2022 usage='$progpath [OPTION]... [MODE-ARG]...'
cannam@126 2023
cannam@126 2024 # Short help message in response to '-h'.
cannam@126 2025 usage_message="Options:
cannam@126 2026 --config show all configuration variables
cannam@126 2027 --debug enable verbose shell tracing
cannam@126 2028 -n, --dry-run display commands without modifying any files
cannam@126 2029 --features display basic configuration information and exit
cannam@126 2030 --mode=MODE use operation mode MODE
cannam@126 2031 --no-warnings equivalent to '-Wnone'
cannam@126 2032 --preserve-dup-deps don't remove duplicate dependency libraries
cannam@126 2033 --quiet, --silent don't print informational messages
cannam@126 2034 --tag=TAG use configuration variables from tag TAG
cannam@126 2035 -v, --verbose print more informational messages than default
cannam@126 2036 --version print version information
cannam@126 2037 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
cannam@126 2038 -h, --help, --help-all print short, long, or detailed help message
cannam@126 2039 "
cannam@126 2040
cannam@126 2041 # Additional text appended to 'usage_message' in response to '--help'.
cannam@126 2042 func_help ()
cannam@126 2043 {
cannam@126 2044 $debug_cmd
cannam@126 2045
cannam@126 2046 func_usage_message
cannam@126 2047 $ECHO "$long_help_message
cannam@126 2048
cannam@126 2049 MODE must be one of the following:
cannam@126 2050
cannam@126 2051 clean remove files from the build directory
cannam@126 2052 compile compile a source file into a libtool object
cannam@126 2053 execute automatically set library path, then run a program
cannam@126 2054 finish complete the installation of libtool libraries
cannam@126 2055 install install libraries or executables
cannam@126 2056 link create a library or an executable
cannam@126 2057 uninstall remove libraries from an installed directory
cannam@126 2058
cannam@126 2059 MODE-ARGS vary depending on the MODE. When passed as first option,
cannam@126 2060 '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
cannam@126 2061 Try '$progname --help --mode=MODE' for a more detailed description of MODE.
cannam@126 2062
cannam@126 2063 When reporting a bug, please describe a test case to reproduce it and
cannam@126 2064 include the following information:
cannam@126 2065
cannam@126 2066 host-triplet: $host
cannam@126 2067 shell: $SHELL
cannam@126 2068 compiler: $LTCC
cannam@126 2069 compiler flags: $LTCFLAGS
cannam@126 2070 linker: $LD (gnu? $with_gnu_ld)
cannam@126 2071 version: $progname $scriptversion Debian-2.4.6-2
cannam@126 2072 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
cannam@126 2073 autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
cannam@126 2074
cannam@126 2075 Report bugs to <bug-libtool@gnu.org>.
cannam@126 2076 GNU libtool home page: <http://www.gnu.org/s/libtool/>.
cannam@126 2077 General help using GNU software: <http://www.gnu.org/gethelp/>."
cannam@126 2078 exit 0
cannam@126 2079 }
cannam@126 2080
cannam@126 2081
cannam@126 2082 # func_lo2o OBJECT-NAME
cannam@126 2083 # ---------------------
cannam@126 2084 # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
cannam@126 2085 # object suffix.
cannam@126 2086
cannam@126 2087 lo2o=s/\\.lo\$/.$objext/
cannam@126 2088 o2lo=s/\\.$objext\$/.lo/
cannam@126 2089
cannam@126 2090 if test yes = "$_G_HAVE_XSI_OPS"; then
cannam@126 2091 eval 'func_lo2o ()
cannam@126 2092 {
cannam@126 2093 case $1 in
cannam@126 2094 *.lo) func_lo2o_result=${1%.lo}.$objext ;;
cannam@126 2095 * ) func_lo2o_result=$1 ;;
cannam@126 2096 esac
cannam@126 2097 }'
cannam@126 2098
cannam@126 2099 # func_xform LIBOBJ-OR-SOURCE
cannam@126 2100 # ---------------------------
cannam@126 2101 # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
cannam@126 2102 # suffix to a '.lo' libtool-object suffix.
cannam@126 2103 eval 'func_xform ()
cannam@126 2104 {
cannam@126 2105 func_xform_result=${1%.*}.lo
cannam@126 2106 }'
cannam@126 2107 else
cannam@126 2108 # ...otherwise fall back to using sed.
cannam@126 2109 func_lo2o ()
cannam@126 2110 {
cannam@126 2111 func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
cannam@126 2112 }
cannam@126 2113
cannam@126 2114 func_xform ()
cannam@126 2115 {
cannam@126 2116 func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
cannam@126 2117 }
cannam@126 2118 fi
cannam@126 2119
cannam@126 2120
cannam@126 2121 # func_fatal_configuration ARG...
cannam@126 2122 # -------------------------------
cannam@126 2123 # Echo program name prefixed message to standard error, followed by
cannam@126 2124 # a configuration failure hint, and exit.
cannam@126 2125 func_fatal_configuration ()
cannam@126 2126 {
cannam@126 2127 func__fatal_error ${1+"$@"} \
cannam@126 2128 "See the $PACKAGE documentation for more information." \
cannam@126 2129 "Fatal configuration error."
cannam@126 2130 }
cannam@126 2131
cannam@126 2132
cannam@126 2133 # func_config
cannam@126 2134 # -----------
cannam@126 2135 # Display the configuration for all the tags in this script.
cannam@126 2136 func_config ()
cannam@126 2137 {
cannam@126 2138 re_begincf='^# ### BEGIN LIBTOOL'
cannam@126 2139 re_endcf='^# ### END LIBTOOL'
cannam@126 2140
cannam@126 2141 # Default configuration.
cannam@126 2142 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
cannam@126 2143
cannam@126 2144 # Now print the configurations for the tags.
cannam@126 2145 for tagname in $taglist; do
cannam@126 2146 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
cannam@126 2147 done
cannam@126 2148
cannam@126 2149 exit $?
cannam@126 2150 }
cannam@126 2151
cannam@126 2152
cannam@126 2153 # func_features
cannam@126 2154 # -------------
cannam@126 2155 # Display the features supported by this script.
cannam@126 2156 func_features ()
cannam@126 2157 {
cannam@126 2158 echo "host: $host"
cannam@126 2159 if test yes = "$build_libtool_libs"; then
cannam@126 2160 echo "enable shared libraries"
cannam@126 2161 else
cannam@126 2162 echo "disable shared libraries"
cannam@126 2163 fi
cannam@126 2164 if test yes = "$build_old_libs"; then
cannam@126 2165 echo "enable static libraries"
cannam@126 2166 else
cannam@126 2167 echo "disable static libraries"
cannam@126 2168 fi
cannam@126 2169
cannam@126 2170 exit $?
cannam@126 2171 }
cannam@126 2172
cannam@126 2173
cannam@126 2174 # func_enable_tag TAGNAME
cannam@126 2175 # -----------------------
cannam@126 2176 # Verify that TAGNAME is valid, and either flag an error and exit, or
cannam@126 2177 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
cannam@126 2178 # variable here.
cannam@126 2179 func_enable_tag ()
cannam@126 2180 {
cannam@126 2181 # Global variable:
cannam@126 2182 tagname=$1
cannam@126 2183
cannam@126 2184 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
cannam@126 2185 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
cannam@126 2186 sed_extractcf=/$re_begincf/,/$re_endcf/p
cannam@126 2187
cannam@126 2188 # Validate tagname.
cannam@126 2189 case $tagname in
cannam@126 2190 *[!-_A-Za-z0-9,/]*)
cannam@126 2191 func_fatal_error "invalid tag name: $tagname"
cannam@126 2192 ;;
cannam@126 2193 esac
cannam@126 2194
cannam@126 2195 # Don't test for the "default" C tag, as we know it's
cannam@126 2196 # there but not specially marked.
cannam@126 2197 case $tagname in
cannam@126 2198 CC) ;;
cannam@126 2199 *)
cannam@126 2200 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
cannam@126 2201 taglist="$taglist $tagname"
cannam@126 2202
cannam@126 2203 # Evaluate the configuration. Be careful to quote the path
cannam@126 2204 # and the sed script, to avoid splitting on whitespace, but
cannam@126 2205 # also don't use non-portable quotes within backquotes within
cannam@126 2206 # quotes we have to do it in 2 steps:
cannam@126 2207 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
cannam@126 2208 eval "$extractedcf"
cannam@126 2209 else
cannam@126 2210 func_error "ignoring unknown tag $tagname"
cannam@126 2211 fi
cannam@126 2212 ;;
cannam@126 2213 esac
cannam@126 2214 }
cannam@126 2215
cannam@126 2216
cannam@126 2217 # func_check_version_match
cannam@126 2218 # ------------------------
cannam@126 2219 # Ensure that we are using m4 macros, and libtool script from the same
cannam@126 2220 # release of libtool.
cannam@126 2221 func_check_version_match ()
cannam@126 2222 {
cannam@126 2223 if test "$package_revision" != "$macro_revision"; then
cannam@126 2224 if test "$VERSION" != "$macro_version"; then
cannam@126 2225 if test -z "$macro_version"; then
cannam@126 2226 cat >&2 <<_LT_EOF
cannam@126 2227 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
cannam@126 2228 $progname: definition of this LT_INIT comes from an older release.
cannam@126 2229 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
cannam@126 2230 $progname: and run autoconf again.
cannam@126 2231 _LT_EOF
cannam@126 2232 else
cannam@126 2233 cat >&2 <<_LT_EOF
cannam@126 2234 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
cannam@126 2235 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
cannam@126 2236 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
cannam@126 2237 $progname: and run autoconf again.
cannam@126 2238 _LT_EOF
cannam@126 2239 fi
cannam@126 2240 else
cannam@126 2241 cat >&2 <<_LT_EOF
cannam@126 2242 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
cannam@126 2243 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
cannam@126 2244 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
cannam@126 2245 $progname: of $PACKAGE $VERSION and run autoconf again.
cannam@126 2246 _LT_EOF
cannam@126 2247 fi
cannam@126 2248
cannam@126 2249 exit $EXIT_MISMATCH
cannam@126 2250 fi
cannam@126 2251 }
cannam@126 2252
cannam@126 2253
cannam@126 2254 # libtool_options_prep [ARG]...
cannam@126 2255 # -----------------------------
cannam@126 2256 # Preparation for options parsed by libtool.
cannam@126 2257 libtool_options_prep ()
cannam@126 2258 {
cannam@126 2259 $debug_mode
cannam@126 2260
cannam@126 2261 # Option defaults:
cannam@126 2262 opt_config=false
cannam@126 2263 opt_dlopen=
cannam@126 2264 opt_dry_run=false
cannam@126 2265 opt_help=false
cannam@126 2266 opt_mode=
cannam@126 2267 opt_preserve_dup_deps=false
cannam@126 2268 opt_quiet=false
cannam@126 2269
cannam@126 2270 nonopt=
cannam@126 2271 preserve_args=
cannam@126 2272
cannam@126 2273 # Shorthand for --mode=foo, only valid as the first argument
cannam@126 2274 case $1 in
cannam@126 2275 clean|clea|cle|cl)
cannam@126 2276 shift; set dummy --mode clean ${1+"$@"}; shift
cannam@126 2277 ;;
cannam@126 2278 compile|compil|compi|comp|com|co|c)
cannam@126 2279 shift; set dummy --mode compile ${1+"$@"}; shift
cannam@126 2280 ;;
cannam@126 2281 execute|execut|execu|exec|exe|ex|e)
cannam@126 2282 shift; set dummy --mode execute ${1+"$@"}; shift
cannam@126 2283 ;;
cannam@126 2284 finish|finis|fini|fin|fi|f)
cannam@126 2285 shift; set dummy --mode finish ${1+"$@"}; shift
cannam@126 2286 ;;
cannam@126 2287 install|instal|insta|inst|ins|in|i)
cannam@126 2288 shift; set dummy --mode install ${1+"$@"}; shift
cannam@126 2289 ;;
cannam@126 2290 link|lin|li|l)
cannam@126 2291 shift; set dummy --mode link ${1+"$@"}; shift
cannam@126 2292 ;;
cannam@126 2293 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
cannam@126 2294 shift; set dummy --mode uninstall ${1+"$@"}; shift
cannam@126 2295 ;;
cannam@126 2296 esac
cannam@126 2297
cannam@126 2298 # Pass back the list of options.
cannam@126 2299 func_quote_for_eval ${1+"$@"}
cannam@126 2300 libtool_options_prep_result=$func_quote_for_eval_result
cannam@126 2301 }
cannam@126 2302 func_add_hook func_options_prep libtool_options_prep
cannam@126 2303
cannam@126 2304
cannam@126 2305 # libtool_parse_options [ARG]...
cannam@126 2306 # ---------------------------------
cannam@126 2307 # Provide handling for libtool specific options.
cannam@126 2308 libtool_parse_options ()
cannam@126 2309 {
cannam@126 2310 $debug_cmd
cannam@126 2311
cannam@126 2312 # Perform our own loop to consume as many options as possible in
cannam@126 2313 # each iteration.
cannam@126 2314 while test $# -gt 0; do
cannam@126 2315 _G_opt=$1
cannam@126 2316 shift
cannam@126 2317 case $_G_opt in
cannam@126 2318 --dry-run|--dryrun|-n)
cannam@126 2319 opt_dry_run=:
cannam@126 2320 ;;
cannam@126 2321
cannam@126 2322 --config) func_config ;;
cannam@126 2323
cannam@126 2324 --dlopen|-dlopen)
cannam@126 2325 opt_dlopen="${opt_dlopen+$opt_dlopen
cannam@126 2326 }$1"
cannam@126 2327 shift
cannam@126 2328 ;;
cannam@126 2329
cannam@126 2330 --preserve-dup-deps)
cannam@126 2331 opt_preserve_dup_deps=: ;;
cannam@126 2332
cannam@126 2333 --features) func_features ;;
cannam@126 2334
cannam@126 2335 --finish) set dummy --mode finish ${1+"$@"}; shift ;;
cannam@126 2336
cannam@126 2337 --help) opt_help=: ;;
cannam@126 2338
cannam@126 2339 --help-all) opt_help=': help-all' ;;
cannam@126 2340
cannam@126 2341 --mode) test $# = 0 && func_missing_arg $_G_opt && break
cannam@126 2342 opt_mode=$1
cannam@126 2343 case $1 in
cannam@126 2344 # Valid mode arguments:
cannam@126 2345 clean|compile|execute|finish|install|link|relink|uninstall) ;;
cannam@126 2346
cannam@126 2347 # Catch anything else as an error
cannam@126 2348 *) func_error "invalid argument for $_G_opt"
cannam@126 2349 exit_cmd=exit
cannam@126 2350 break
cannam@126 2351 ;;
cannam@126 2352 esac
cannam@126 2353 shift
cannam@126 2354 ;;
cannam@126 2355
cannam@126 2356 --no-silent|--no-quiet)
cannam@126 2357 opt_quiet=false
cannam@126 2358 func_append preserve_args " $_G_opt"
cannam@126 2359 ;;
cannam@126 2360
cannam@126 2361 --no-warnings|--no-warning|--no-warn)
cannam@126 2362 opt_warning=false
cannam@126 2363 func_append preserve_args " $_G_opt"
cannam@126 2364 ;;
cannam@126 2365
cannam@126 2366 --no-verbose)
cannam@126 2367 opt_verbose=false
cannam@126 2368 func_append preserve_args " $_G_opt"
cannam@126 2369 ;;
cannam@126 2370
cannam@126 2371 --silent|--quiet)
cannam@126 2372 opt_quiet=:
cannam@126 2373 opt_verbose=false
cannam@126 2374 func_append preserve_args " $_G_opt"
cannam@126 2375 ;;
cannam@126 2376
cannam@126 2377 --tag) test $# = 0 && func_missing_arg $_G_opt && break
cannam@126 2378 opt_tag=$1
cannam@126 2379 func_append preserve_args " $_G_opt $1"
cannam@126 2380 func_enable_tag "$1"
cannam@126 2381 shift
cannam@126 2382 ;;
cannam@126 2383
cannam@126 2384 --verbose|-v) opt_quiet=false
cannam@126 2385 opt_verbose=:
cannam@126 2386 func_append preserve_args " $_G_opt"
cannam@126 2387 ;;
cannam@126 2388
cannam@126 2389 # An option not handled by this hook function:
cannam@126 2390 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
cannam@126 2391 esac
cannam@126 2392 done
cannam@126 2393
cannam@126 2394
cannam@126 2395 # save modified positional parameters for caller
cannam@126 2396 func_quote_for_eval ${1+"$@"}
cannam@126 2397 libtool_parse_options_result=$func_quote_for_eval_result
cannam@126 2398 }
cannam@126 2399 func_add_hook func_parse_options libtool_parse_options
cannam@126 2400
cannam@126 2401
cannam@126 2402
cannam@126 2403 # libtool_validate_options [ARG]...
cannam@126 2404 # ---------------------------------
cannam@126 2405 # Perform any sanity checks on option settings and/or unconsumed
cannam@126 2406 # arguments.
cannam@126 2407 libtool_validate_options ()
cannam@126 2408 {
cannam@126 2409 # save first non-option argument
cannam@126 2410 if test 0 -lt $#; then
cannam@126 2411 nonopt=$1
cannam@126 2412 shift
cannam@126 2413 fi
cannam@126 2414
cannam@126 2415 # preserve --debug
cannam@126 2416 test : = "$debug_cmd" || func_append preserve_args " --debug"
cannam@126 2417
cannam@126 2418 case $host in
cannam@126 2419 # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
cannam@126 2420 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
cannam@126 2421 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
cannam@126 2422 # don't eliminate duplications in $postdeps and $predeps
cannam@126 2423 opt_duplicate_compiler_generated_deps=:
cannam@126 2424 ;;
cannam@126 2425 *)
cannam@126 2426 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
cannam@126 2427 ;;
cannam@126 2428 esac
cannam@126 2429
cannam@126 2430 $opt_help || {
cannam@126 2431 # Sanity checks first:
cannam@126 2432 func_check_version_match
cannam@126 2433
cannam@126 2434 test yes != "$build_libtool_libs" \
cannam@126 2435 && test yes != "$build_old_libs" \
cannam@126 2436 && func_fatal_configuration "not configured to build any kind of library"
cannam@126 2437
cannam@126 2438 # Darwin sucks
cannam@126 2439 eval std_shrext=\"$shrext_cmds\"
cannam@126 2440
cannam@126 2441 # Only execute mode is allowed to have -dlopen flags.
cannam@126 2442 if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
cannam@126 2443 func_error "unrecognized option '-dlopen'"
cannam@126 2444 $ECHO "$help" 1>&2
cannam@126 2445 exit $EXIT_FAILURE
cannam@126 2446 fi
cannam@126 2447
cannam@126 2448 # Change the help message to a mode-specific one.
cannam@126 2449 generic_help=$help
cannam@126 2450 help="Try '$progname --help --mode=$opt_mode' for more information."
cannam@126 2451 }
cannam@126 2452
cannam@126 2453 # Pass back the unparsed argument list
cannam@126 2454 func_quote_for_eval ${1+"$@"}
cannam@126 2455 libtool_validate_options_result=$func_quote_for_eval_result
cannam@126 2456 }
cannam@126 2457 func_add_hook func_validate_options libtool_validate_options
cannam@126 2458
cannam@126 2459
cannam@126 2460 # Process options as early as possible so that --help and --version
cannam@126 2461 # can return quickly.
cannam@126 2462 func_options ${1+"$@"}
cannam@126 2463 eval set dummy "$func_options_result"; shift
cannam@126 2464
cannam@126 2465
cannam@126 2466
cannam@126 2467 ## ----------- ##
cannam@126 2468 ## Main. ##
cannam@126 2469 ## ----------- ##
cannam@126 2470
cannam@126 2471 magic='%%%MAGIC variable%%%'
cannam@126 2472 magic_exe='%%%MAGIC EXE variable%%%'
cannam@126 2473
cannam@126 2474 # Global variables.
cannam@126 2475 extracted_archives=
cannam@126 2476 extracted_serial=0
cannam@126 2477
cannam@126 2478 # If this variable is set in any of the actions, the command in it
cannam@126 2479 # will be execed at the end. This prevents here-documents from being
cannam@126 2480 # left over by shells.
cannam@126 2481 exec_cmd=
cannam@126 2482
cannam@126 2483
cannam@126 2484 # A function that is used when there is no print builtin or printf.
cannam@126 2485 func_fallback_echo ()
cannam@126 2486 {
cannam@126 2487 eval 'cat <<_LTECHO_EOF
cannam@126 2488 $1
cannam@126 2489 _LTECHO_EOF'
cannam@126 2490 }
cannam@126 2491
cannam@126 2492 # func_generated_by_libtool
cannam@126 2493 # True iff stdin has been generated by Libtool. This function is only
cannam@126 2494 # a basic sanity check; it will hardly flush out determined imposters.
cannam@126 2495 func_generated_by_libtool_p ()
cannam@126 2496 {
cannam@126 2497 $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
cannam@126 2498 }
cannam@126 2499
cannam@126 2500 # func_lalib_p file
cannam@126 2501 # True iff FILE is a libtool '.la' library or '.lo' object file.
cannam@126 2502 # This function is only a basic sanity check; it will hardly flush out
cannam@126 2503 # determined imposters.
cannam@126 2504 func_lalib_p ()
cannam@126 2505 {
cannam@126 2506 test -f "$1" &&
cannam@126 2507 $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
cannam@126 2508 }
cannam@126 2509
cannam@126 2510 # func_lalib_unsafe_p file
cannam@126 2511 # True iff FILE is a libtool '.la' library or '.lo' object file.
cannam@126 2512 # This function implements the same check as func_lalib_p without
cannam@126 2513 # resorting to external programs. To this end, it redirects stdin and
cannam@126 2514 # closes it afterwards, without saving the original file descriptor.
cannam@126 2515 # As a safety measure, use it only where a negative result would be
cannam@126 2516 # fatal anyway. Works if 'file' does not exist.
cannam@126 2517 func_lalib_unsafe_p ()
cannam@126 2518 {
cannam@126 2519 lalib_p=no
cannam@126 2520 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
cannam@126 2521 for lalib_p_l in 1 2 3 4
cannam@126 2522 do
cannam@126 2523 read lalib_p_line
cannam@126 2524 case $lalib_p_line in
cannam@126 2525 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
cannam@126 2526 esac
cannam@126 2527 done
cannam@126 2528 exec 0<&5 5<&-
cannam@126 2529 fi
cannam@126 2530 test yes = "$lalib_p"
cannam@126 2531 }
cannam@126 2532
cannam@126 2533 # func_ltwrapper_script_p file
cannam@126 2534 # True iff FILE is a libtool wrapper script
cannam@126 2535 # This function is only a basic sanity check; it will hardly flush out
cannam@126 2536 # determined imposters.
cannam@126 2537 func_ltwrapper_script_p ()
cannam@126 2538 {
cannam@126 2539 test -f "$1" &&
cannam@126 2540 $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
cannam@126 2541 }
cannam@126 2542
cannam@126 2543 # func_ltwrapper_executable_p file
cannam@126 2544 # True iff FILE is a libtool wrapper executable
cannam@126 2545 # This function is only a basic sanity check; it will hardly flush out
cannam@126 2546 # determined imposters.
cannam@126 2547 func_ltwrapper_executable_p ()
cannam@126 2548 {
cannam@126 2549 func_ltwrapper_exec_suffix=
cannam@126 2550 case $1 in
cannam@126 2551 *.exe) ;;
cannam@126 2552 *) func_ltwrapper_exec_suffix=.exe ;;
cannam@126 2553 esac
cannam@126 2554 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
cannam@126 2555 }
cannam@126 2556
cannam@126 2557 # func_ltwrapper_scriptname file
cannam@126 2558 # Assumes file is an ltwrapper_executable
cannam@126 2559 # uses $file to determine the appropriate filename for a
cannam@126 2560 # temporary ltwrapper_script.
cannam@126 2561 func_ltwrapper_scriptname ()
cannam@126 2562 {
cannam@126 2563 func_dirname_and_basename "$1" "" "."
cannam@126 2564 func_stripname '' '.exe' "$func_basename_result"
cannam@126 2565 func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
cannam@126 2566 }
cannam@126 2567
cannam@126 2568 # func_ltwrapper_p file
cannam@126 2569 # True iff FILE is a libtool wrapper script or wrapper executable
cannam@126 2570 # This function is only a basic sanity check; it will hardly flush out
cannam@126 2571 # determined imposters.
cannam@126 2572 func_ltwrapper_p ()
cannam@126 2573 {
cannam@126 2574 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
cannam@126 2575 }
cannam@126 2576
cannam@126 2577
cannam@126 2578 # func_execute_cmds commands fail_cmd
cannam@126 2579 # Execute tilde-delimited COMMANDS.
cannam@126 2580 # If FAIL_CMD is given, eval that upon failure.
cannam@126 2581 # FAIL_CMD may read-access the current command in variable CMD!
cannam@126 2582 func_execute_cmds ()
cannam@126 2583 {
cannam@126 2584 $debug_cmd
cannam@126 2585
cannam@126 2586 save_ifs=$IFS; IFS='~'
cannam@126 2587 for cmd in $1; do
cannam@126 2588 IFS=$sp$nl
cannam@126 2589 eval cmd=\"$cmd\"
cannam@126 2590 IFS=$save_ifs
cannam@126 2591 func_show_eval "$cmd" "${2-:}"
cannam@126 2592 done
cannam@126 2593 IFS=$save_ifs
cannam@126 2594 }
cannam@126 2595
cannam@126 2596
cannam@126 2597 # func_source file
cannam@126 2598 # Source FILE, adding directory component if necessary.
cannam@126 2599 # Note that it is not necessary on cygwin/mingw to append a dot to
cannam@126 2600 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
cannam@126 2601 # behavior happens only for exec(3), not for open(2)! Also, sourcing
cannam@126 2602 # 'FILE.' does not work on cygwin managed mounts.
cannam@126 2603 func_source ()
cannam@126 2604 {
cannam@126 2605 $debug_cmd
cannam@126 2606
cannam@126 2607 case $1 in
cannam@126 2608 */* | *\\*) . "$1" ;;
cannam@126 2609 *) . "./$1" ;;
cannam@126 2610 esac
cannam@126 2611 }
cannam@126 2612
cannam@126 2613
cannam@126 2614 # func_resolve_sysroot PATH
cannam@126 2615 # Replace a leading = in PATH with a sysroot. Store the result into
cannam@126 2616 # func_resolve_sysroot_result
cannam@126 2617 func_resolve_sysroot ()
cannam@126 2618 {
cannam@126 2619 func_resolve_sysroot_result=$1
cannam@126 2620 case $func_resolve_sysroot_result in
cannam@126 2621 =*)
cannam@126 2622 func_stripname '=' '' "$func_resolve_sysroot_result"
cannam@126 2623 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
cannam@126 2624 ;;
cannam@126 2625 esac
cannam@126 2626 }
cannam@126 2627
cannam@126 2628 # func_replace_sysroot PATH
cannam@126 2629 # If PATH begins with the sysroot, replace it with = and
cannam@126 2630 # store the result into func_replace_sysroot_result.
cannam@126 2631 func_replace_sysroot ()
cannam@126 2632 {
cannam@126 2633 case $lt_sysroot:$1 in
cannam@126 2634 ?*:"$lt_sysroot"*)
cannam@126 2635 func_stripname "$lt_sysroot" '' "$1"
cannam@126 2636 func_replace_sysroot_result='='$func_stripname_result
cannam@126 2637 ;;
cannam@126 2638 *)
cannam@126 2639 # Including no sysroot.
cannam@126 2640 func_replace_sysroot_result=$1
cannam@126 2641 ;;
cannam@126 2642 esac
cannam@126 2643 }
cannam@126 2644
cannam@126 2645 # func_infer_tag arg
cannam@126 2646 # Infer tagged configuration to use if any are available and
cannam@126 2647 # if one wasn't chosen via the "--tag" command line option.
cannam@126 2648 # Only attempt this if the compiler in the base compile
cannam@126 2649 # command doesn't match the default compiler.
cannam@126 2650 # arg is usually of the form 'gcc ...'
cannam@126 2651 func_infer_tag ()
cannam@126 2652 {
cannam@126 2653 $debug_cmd
cannam@126 2654
cannam@126 2655 if test -n "$available_tags" && test -z "$tagname"; then
cannam@126 2656 CC_quoted=
cannam@126 2657 for arg in $CC; do
cannam@126 2658 func_append_quoted CC_quoted "$arg"
cannam@126 2659 done
cannam@126 2660 CC_expanded=`func_echo_all $CC`
cannam@126 2661 CC_quoted_expanded=`func_echo_all $CC_quoted`
cannam@126 2662 case $@ in
cannam@126 2663 # Blanks in the command may have been stripped by the calling shell,
cannam@126 2664 # but not from the CC environment variable when configure was run.
cannam@126 2665 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
cannam@126 2666 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
cannam@126 2667 # Blanks at the start of $base_compile will cause this to fail
cannam@126 2668 # if we don't check for them as well.
cannam@126 2669 *)
cannam@126 2670 for z in $available_tags; do
cannam@126 2671 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
cannam@126 2672 # Evaluate the configuration.
cannam@126 2673 eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
cannam@126 2674 CC_quoted=
cannam@126 2675 for arg in $CC; do
cannam@126 2676 # Double-quote args containing other shell metacharacters.
cannam@126 2677 func_append_quoted CC_quoted "$arg"
cannam@126 2678 done
cannam@126 2679 CC_expanded=`func_echo_all $CC`
cannam@126 2680 CC_quoted_expanded=`func_echo_all $CC_quoted`
cannam@126 2681 case "$@ " in
cannam@126 2682 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
cannam@126 2683 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
cannam@126 2684 # The compiler in the base compile command matches
cannam@126 2685 # the one in the tagged configuration.
cannam@126 2686 # Assume this is the tagged configuration we want.
cannam@126 2687 tagname=$z
cannam@126 2688 break
cannam@126 2689 ;;
cannam@126 2690 esac
cannam@126 2691 fi
cannam@126 2692 done
cannam@126 2693 # If $tagname still isn't set, then no tagged configuration
cannam@126 2694 # was found and let the user know that the "--tag" command
cannam@126 2695 # line option must be used.
cannam@126 2696 if test -z "$tagname"; then
cannam@126 2697 func_echo "unable to infer tagged configuration"
cannam@126 2698 func_fatal_error "specify a tag with '--tag'"
cannam@126 2699 # else
cannam@126 2700 # func_verbose "using $tagname tagged configuration"
cannam@126 2701 fi
cannam@126 2702 ;;
cannam@126 2703 esac
cannam@126 2704 fi
cannam@126 2705 }
cannam@126 2706
cannam@126 2707
cannam@126 2708
cannam@126 2709 # func_write_libtool_object output_name pic_name nonpic_name
cannam@126 2710 # Create a libtool object file (analogous to a ".la" file),
cannam@126 2711 # but don't create it if we're doing a dry run.
cannam@126 2712 func_write_libtool_object ()
cannam@126 2713 {
cannam@126 2714 write_libobj=$1
cannam@126 2715 if test yes = "$build_libtool_libs"; then
cannam@126 2716 write_lobj=\'$2\'
cannam@126 2717 else
cannam@126 2718 write_lobj=none
cannam@126 2719 fi
cannam@126 2720
cannam@126 2721 if test yes = "$build_old_libs"; then
cannam@126 2722 write_oldobj=\'$3\'
cannam@126 2723 else
cannam@126 2724 write_oldobj=none
cannam@126 2725 fi
cannam@126 2726
cannam@126 2727 $opt_dry_run || {
cannam@126 2728 cat >${write_libobj}T <<EOF
cannam@126 2729 # $write_libobj - a libtool object file
cannam@126 2730 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
cannam@126 2731 #
cannam@126 2732 # Please DO NOT delete this file!
cannam@126 2733 # It is necessary for linking the library.
cannam@126 2734
cannam@126 2735 # Name of the PIC object.
cannam@126 2736 pic_object=$write_lobj
cannam@126 2737
cannam@126 2738 # Name of the non-PIC object
cannam@126 2739 non_pic_object=$write_oldobj
cannam@126 2740
cannam@126 2741 EOF
cannam@126 2742 $MV "${write_libobj}T" "$write_libobj"
cannam@126 2743 }
cannam@126 2744 }
cannam@126 2745
cannam@126 2746
cannam@126 2747 ##################################################
cannam@126 2748 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
cannam@126 2749 ##################################################
cannam@126 2750
cannam@126 2751 # func_convert_core_file_wine_to_w32 ARG
cannam@126 2752 # Helper function used by file name conversion functions when $build is *nix,
cannam@126 2753 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
cannam@126 2754 # correctly configured wine environment available, with the winepath program
cannam@126 2755 # in $build's $PATH.
cannam@126 2756 #
cannam@126 2757 # ARG is the $build file name to be converted to w32 format.
cannam@126 2758 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
cannam@126 2759 # be empty on error (or when ARG is empty)
cannam@126 2760 func_convert_core_file_wine_to_w32 ()
cannam@126 2761 {
cannam@126 2762 $debug_cmd
cannam@126 2763
cannam@126 2764 func_convert_core_file_wine_to_w32_result=$1
cannam@126 2765 if test -n "$1"; then
cannam@126 2766 # Unfortunately, winepath does not exit with a non-zero error code, so we
cannam@126 2767 # are forced to check the contents of stdout. On the other hand, if the
cannam@126 2768 # command is not found, the shell will set an exit code of 127 and print
cannam@126 2769 # *an error message* to stdout. So we must check for both error code of
cannam@126 2770 # zero AND non-empty stdout, which explains the odd construction:
cannam@126 2771 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
cannam@126 2772 if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
cannam@126 2773 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
cannam@126 2774 $SED -e "$sed_naive_backslashify"`
cannam@126 2775 else
cannam@126 2776 func_convert_core_file_wine_to_w32_result=
cannam@126 2777 fi
cannam@126 2778 fi
cannam@126 2779 }
cannam@126 2780 # end: func_convert_core_file_wine_to_w32
cannam@126 2781
cannam@126 2782
cannam@126 2783 # func_convert_core_path_wine_to_w32 ARG
cannam@126 2784 # Helper function used by path conversion functions when $build is *nix, and
cannam@126 2785 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
cannam@126 2786 # configured wine environment available, with the winepath program in $build's
cannam@126 2787 # $PATH. Assumes ARG has no leading or trailing path separator characters.
cannam@126 2788 #
cannam@126 2789 # ARG is path to be converted from $build format to win32.
cannam@126 2790 # Result is available in $func_convert_core_path_wine_to_w32_result.
cannam@126 2791 # Unconvertible file (directory) names in ARG are skipped; if no directory names
cannam@126 2792 # are convertible, then the result may be empty.
cannam@126 2793 func_convert_core_path_wine_to_w32 ()
cannam@126 2794 {
cannam@126 2795 $debug_cmd
cannam@126 2796
cannam@126 2797 # unfortunately, winepath doesn't convert paths, only file names
cannam@126 2798 func_convert_core_path_wine_to_w32_result=
cannam@126 2799 if test -n "$1"; then
cannam@126 2800 oldIFS=$IFS
cannam@126 2801 IFS=:
cannam@126 2802 for func_convert_core_path_wine_to_w32_f in $1; do
cannam@126 2803 IFS=$oldIFS
cannam@126 2804 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
cannam@126 2805 if test -n "$func_convert_core_file_wine_to_w32_result"; then
cannam@126 2806 if test -z "$func_convert_core_path_wine_to_w32_result"; then
cannam@126 2807 func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
cannam@126 2808 else
cannam@126 2809 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
cannam@126 2810 fi
cannam@126 2811 fi
cannam@126 2812 done
cannam@126 2813 IFS=$oldIFS
cannam@126 2814 fi
cannam@126 2815 }
cannam@126 2816 # end: func_convert_core_path_wine_to_w32
cannam@126 2817
cannam@126 2818
cannam@126 2819 # func_cygpath ARGS...
cannam@126 2820 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
cannam@126 2821 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
cannam@126 2822 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
cannam@126 2823 # (2), returns the Cygwin file name or path in func_cygpath_result (input
cannam@126 2824 # file name or path is assumed to be in w32 format, as previously converted
cannam@126 2825 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
cannam@126 2826 # or path in func_cygpath_result (input file name or path is assumed to be in
cannam@126 2827 # Cygwin format). Returns an empty string on error.
cannam@126 2828 #
cannam@126 2829 # ARGS are passed to cygpath, with the last one being the file name or path to
cannam@126 2830 # be converted.
cannam@126 2831 #
cannam@126 2832 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
cannam@126 2833 # environment variable; do not put it in $PATH.
cannam@126 2834 func_cygpath ()
cannam@126 2835 {
cannam@126 2836 $debug_cmd
cannam@126 2837
cannam@126 2838 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
cannam@126 2839 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
cannam@126 2840 if test "$?" -ne 0; then
cannam@126 2841 # on failure, ensure result is empty
cannam@126 2842 func_cygpath_result=
cannam@126 2843 fi
cannam@126 2844 else
cannam@126 2845 func_cygpath_result=
cannam@126 2846 func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
cannam@126 2847 fi
cannam@126 2848 }
cannam@126 2849 #end: func_cygpath
cannam@126 2850
cannam@126 2851
cannam@126 2852 # func_convert_core_msys_to_w32 ARG
cannam@126 2853 # Convert file name or path ARG from MSYS format to w32 format. Return
cannam@126 2854 # result in func_convert_core_msys_to_w32_result.
cannam@126 2855 func_convert_core_msys_to_w32 ()
cannam@126 2856 {
cannam@126 2857 $debug_cmd
cannam@126 2858
cannam@126 2859 # awkward: cmd appends spaces to result
cannam@126 2860 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
cannam@126 2861 $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
cannam@126 2862 }
cannam@126 2863 #end: func_convert_core_msys_to_w32
cannam@126 2864
cannam@126 2865
cannam@126 2866 # func_convert_file_check ARG1 ARG2
cannam@126 2867 # Verify that ARG1 (a file name in $build format) was converted to $host
cannam@126 2868 # format in ARG2. Otherwise, emit an error message, but continue (resetting
cannam@126 2869 # func_to_host_file_result to ARG1).
cannam@126 2870 func_convert_file_check ()
cannam@126 2871 {
cannam@126 2872 $debug_cmd
cannam@126 2873
cannam@126 2874 if test -z "$2" && test -n "$1"; then
cannam@126 2875 func_error "Could not determine host file name corresponding to"
cannam@126 2876 func_error " '$1'"
cannam@126 2877 func_error "Continuing, but uninstalled executables may not work."
cannam@126 2878 # Fallback:
cannam@126 2879 func_to_host_file_result=$1
cannam@126 2880 fi
cannam@126 2881 }
cannam@126 2882 # end func_convert_file_check
cannam@126 2883
cannam@126 2884
cannam@126 2885 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
cannam@126 2886 # Verify that FROM_PATH (a path in $build format) was converted to $host
cannam@126 2887 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
cannam@126 2888 # func_to_host_file_result to a simplistic fallback value (see below).
cannam@126 2889 func_convert_path_check ()
cannam@126 2890 {
cannam@126 2891 $debug_cmd
cannam@126 2892
cannam@126 2893 if test -z "$4" && test -n "$3"; then
cannam@126 2894 func_error "Could not determine the host path corresponding to"
cannam@126 2895 func_error " '$3'"
cannam@126 2896 func_error "Continuing, but uninstalled executables may not work."
cannam@126 2897 # Fallback. This is a deliberately simplistic "conversion" and
cannam@126 2898 # should not be "improved". See libtool.info.
cannam@126 2899 if test "x$1" != "x$2"; then
cannam@126 2900 lt_replace_pathsep_chars="s|$1|$2|g"
cannam@126 2901 func_to_host_path_result=`echo "$3" |
cannam@126 2902 $SED -e "$lt_replace_pathsep_chars"`
cannam@126 2903 else
cannam@126 2904 func_to_host_path_result=$3
cannam@126 2905 fi
cannam@126 2906 fi
cannam@126 2907 }
cannam@126 2908 # end func_convert_path_check
cannam@126 2909
cannam@126 2910
cannam@126 2911 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
cannam@126 2912 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
cannam@126 2913 # and appending REPL if ORIG matches BACKPAT.
cannam@126 2914 func_convert_path_front_back_pathsep ()
cannam@126 2915 {
cannam@126 2916 $debug_cmd
cannam@126 2917
cannam@126 2918 case $4 in
cannam@126 2919 $1 ) func_to_host_path_result=$3$func_to_host_path_result
cannam@126 2920 ;;
cannam@126 2921 esac
cannam@126 2922 case $4 in
cannam@126 2923 $2 ) func_append func_to_host_path_result "$3"
cannam@126 2924 ;;
cannam@126 2925 esac
cannam@126 2926 }
cannam@126 2927 # end func_convert_path_front_back_pathsep
cannam@126 2928
cannam@126 2929
cannam@126 2930 ##################################################
cannam@126 2931 # $build to $host FILE NAME CONVERSION FUNCTIONS #
cannam@126 2932 ##################################################
cannam@126 2933 # invoked via '$to_host_file_cmd ARG'
cannam@126 2934 #
cannam@126 2935 # In each case, ARG is the path to be converted from $build to $host format.
cannam@126 2936 # Result will be available in $func_to_host_file_result.
cannam@126 2937
cannam@126 2938
cannam@126 2939 # func_to_host_file ARG
cannam@126 2940 # Converts the file name ARG from $build format to $host format. Return result
cannam@126 2941 # in func_to_host_file_result.
cannam@126 2942 func_to_host_file ()
cannam@126 2943 {
cannam@126 2944 $debug_cmd
cannam@126 2945
cannam@126 2946 $to_host_file_cmd "$1"
cannam@126 2947 }
cannam@126 2948 # end func_to_host_file
cannam@126 2949
cannam@126 2950
cannam@126 2951 # func_to_tool_file ARG LAZY
cannam@126 2952 # converts the file name ARG from $build format to toolchain format. Return
cannam@126 2953 # result in func_to_tool_file_result. If the conversion in use is listed
cannam@126 2954 # in (the comma separated) LAZY, no conversion takes place.
cannam@126 2955 func_to_tool_file ()
cannam@126 2956 {
cannam@126 2957 $debug_cmd
cannam@126 2958
cannam@126 2959 case ,$2, in
cannam@126 2960 *,"$to_tool_file_cmd",*)
cannam@126 2961 func_to_tool_file_result=$1
cannam@126 2962 ;;
cannam@126 2963 *)
cannam@126 2964 $to_tool_file_cmd "$1"
cannam@126 2965 func_to_tool_file_result=$func_to_host_file_result
cannam@126 2966 ;;
cannam@126 2967 esac
cannam@126 2968 }
cannam@126 2969 # end func_to_tool_file
cannam@126 2970
cannam@126 2971
cannam@126 2972 # func_convert_file_noop ARG
cannam@126 2973 # Copy ARG to func_to_host_file_result.
cannam@126 2974 func_convert_file_noop ()
cannam@126 2975 {
cannam@126 2976 func_to_host_file_result=$1
cannam@126 2977 }
cannam@126 2978 # end func_convert_file_noop
cannam@126 2979
cannam@126 2980
cannam@126 2981 # func_convert_file_msys_to_w32 ARG
cannam@126 2982 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
cannam@126 2983 # conversion to w32 is not available inside the cwrapper. Returns result in
cannam@126 2984 # func_to_host_file_result.
cannam@126 2985 func_convert_file_msys_to_w32 ()
cannam@126 2986 {
cannam@126 2987 $debug_cmd
cannam@126 2988
cannam@126 2989 func_to_host_file_result=$1
cannam@126 2990 if test -n "$1"; then
cannam@126 2991 func_convert_core_msys_to_w32 "$1"
cannam@126 2992 func_to_host_file_result=$func_convert_core_msys_to_w32_result
cannam@126 2993 fi
cannam@126 2994 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@126 2995 }
cannam@126 2996 # end func_convert_file_msys_to_w32
cannam@126 2997
cannam@126 2998
cannam@126 2999 # func_convert_file_cygwin_to_w32 ARG
cannam@126 3000 # Convert file name ARG from Cygwin to w32 format. Returns result in
cannam@126 3001 # func_to_host_file_result.
cannam@126 3002 func_convert_file_cygwin_to_w32 ()
cannam@126 3003 {
cannam@126 3004 $debug_cmd
cannam@126 3005
cannam@126 3006 func_to_host_file_result=$1
cannam@126 3007 if test -n "$1"; then
cannam@126 3008 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
cannam@126 3009 # LT_CYGPATH in this case.
cannam@126 3010 func_to_host_file_result=`cygpath -m "$1"`
cannam@126 3011 fi
cannam@126 3012 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@126 3013 }
cannam@126 3014 # end func_convert_file_cygwin_to_w32
cannam@126 3015
cannam@126 3016
cannam@126 3017 # func_convert_file_nix_to_w32 ARG
cannam@126 3018 # Convert file name ARG from *nix to w32 format. Requires a wine environment
cannam@126 3019 # and a working winepath. Returns result in func_to_host_file_result.
cannam@126 3020 func_convert_file_nix_to_w32 ()
cannam@126 3021 {
cannam@126 3022 $debug_cmd
cannam@126 3023
cannam@126 3024 func_to_host_file_result=$1
cannam@126 3025 if test -n "$1"; then
cannam@126 3026 func_convert_core_file_wine_to_w32 "$1"
cannam@126 3027 func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
cannam@126 3028 fi
cannam@126 3029 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@126 3030 }
cannam@126 3031 # end func_convert_file_nix_to_w32
cannam@126 3032
cannam@126 3033
cannam@126 3034 # func_convert_file_msys_to_cygwin ARG
cannam@126 3035 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
cannam@126 3036 # Returns result in func_to_host_file_result.
cannam@126 3037 func_convert_file_msys_to_cygwin ()
cannam@126 3038 {
cannam@126 3039 $debug_cmd
cannam@126 3040
cannam@126 3041 func_to_host_file_result=$1
cannam@126 3042 if test -n "$1"; then
cannam@126 3043 func_convert_core_msys_to_w32 "$1"
cannam@126 3044 func_cygpath -u "$func_convert_core_msys_to_w32_result"
cannam@126 3045 func_to_host_file_result=$func_cygpath_result
cannam@126 3046 fi
cannam@126 3047 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@126 3048 }
cannam@126 3049 # end func_convert_file_msys_to_cygwin
cannam@126 3050
cannam@126 3051
cannam@126 3052 # func_convert_file_nix_to_cygwin ARG
cannam@126 3053 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
cannam@126 3054 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
cannam@126 3055 # in func_to_host_file_result.
cannam@126 3056 func_convert_file_nix_to_cygwin ()
cannam@126 3057 {
cannam@126 3058 $debug_cmd
cannam@126 3059
cannam@126 3060 func_to_host_file_result=$1
cannam@126 3061 if test -n "$1"; then
cannam@126 3062 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
cannam@126 3063 func_convert_core_file_wine_to_w32 "$1"
cannam@126 3064 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
cannam@126 3065 func_to_host_file_result=$func_cygpath_result
cannam@126 3066 fi
cannam@126 3067 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@126 3068 }
cannam@126 3069 # end func_convert_file_nix_to_cygwin
cannam@126 3070
cannam@126 3071
cannam@126 3072 #############################################
cannam@126 3073 # $build to $host PATH CONVERSION FUNCTIONS #
cannam@126 3074 #############################################
cannam@126 3075 # invoked via '$to_host_path_cmd ARG'
cannam@126 3076 #
cannam@126 3077 # In each case, ARG is the path to be converted from $build to $host format.
cannam@126 3078 # The result will be available in $func_to_host_path_result.
cannam@126 3079 #
cannam@126 3080 # Path separators are also converted from $build format to $host format. If
cannam@126 3081 # ARG begins or ends with a path separator character, it is preserved (but
cannam@126 3082 # converted to $host format) on output.
cannam@126 3083 #
cannam@126 3084 # All path conversion functions are named using the following convention:
cannam@126 3085 # file name conversion function : func_convert_file_X_to_Y ()
cannam@126 3086 # path conversion function : func_convert_path_X_to_Y ()
cannam@126 3087 # where, for any given $build/$host combination the 'X_to_Y' value is the
cannam@126 3088 # same. If conversion functions are added for new $build/$host combinations,
cannam@126 3089 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
cannam@126 3090 # will break.
cannam@126 3091
cannam@126 3092
cannam@126 3093 # func_init_to_host_path_cmd
cannam@126 3094 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
cannam@126 3095 # appropriate value, based on the value of $to_host_file_cmd.
cannam@126 3096 to_host_path_cmd=
cannam@126 3097 func_init_to_host_path_cmd ()
cannam@126 3098 {
cannam@126 3099 $debug_cmd
cannam@126 3100
cannam@126 3101 if test -z "$to_host_path_cmd"; then
cannam@126 3102 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
cannam@126 3103 to_host_path_cmd=func_convert_path_$func_stripname_result
cannam@126 3104 fi
cannam@126 3105 }
cannam@126 3106
cannam@126 3107
cannam@126 3108 # func_to_host_path ARG
cannam@126 3109 # Converts the path ARG from $build format to $host format. Return result
cannam@126 3110 # in func_to_host_path_result.
cannam@126 3111 func_to_host_path ()
cannam@126 3112 {
cannam@126 3113 $debug_cmd
cannam@126 3114
cannam@126 3115 func_init_to_host_path_cmd
cannam@126 3116 $to_host_path_cmd "$1"
cannam@126 3117 }
cannam@126 3118 # end func_to_host_path
cannam@126 3119
cannam@126 3120
cannam@126 3121 # func_convert_path_noop ARG
cannam@126 3122 # Copy ARG to func_to_host_path_result.
cannam@126 3123 func_convert_path_noop ()
cannam@126 3124 {
cannam@126 3125 func_to_host_path_result=$1
cannam@126 3126 }
cannam@126 3127 # end func_convert_path_noop
cannam@126 3128
cannam@126 3129
cannam@126 3130 # func_convert_path_msys_to_w32 ARG
cannam@126 3131 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
cannam@126 3132 # conversion to w32 is not available inside the cwrapper. Returns result in
cannam@126 3133 # func_to_host_path_result.
cannam@126 3134 func_convert_path_msys_to_w32 ()
cannam@126 3135 {
cannam@126 3136 $debug_cmd
cannam@126 3137
cannam@126 3138 func_to_host_path_result=$1
cannam@126 3139 if test -n "$1"; then
cannam@126 3140 # Remove leading and trailing path separator characters from ARG. MSYS
cannam@126 3141 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
cannam@126 3142 # and winepath ignores them completely.
cannam@126 3143 func_stripname : : "$1"
cannam@126 3144 func_to_host_path_tmp1=$func_stripname_result
cannam@126 3145 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
cannam@126 3146 func_to_host_path_result=$func_convert_core_msys_to_w32_result
cannam@126 3147 func_convert_path_check : ";" \
cannam@126 3148 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@126 3149 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
cannam@126 3150 fi
cannam@126 3151 }
cannam@126 3152 # end func_convert_path_msys_to_w32
cannam@126 3153
cannam@126 3154
cannam@126 3155 # func_convert_path_cygwin_to_w32 ARG
cannam@126 3156 # Convert path ARG from Cygwin to w32 format. Returns result in
cannam@126 3157 # func_to_host_file_result.
cannam@126 3158 func_convert_path_cygwin_to_w32 ()
cannam@126 3159 {
cannam@126 3160 $debug_cmd
cannam@126 3161
cannam@126 3162 func_to_host_path_result=$1
cannam@126 3163 if test -n "$1"; then
cannam@126 3164 # See func_convert_path_msys_to_w32:
cannam@126 3165 func_stripname : : "$1"
cannam@126 3166 func_to_host_path_tmp1=$func_stripname_result
cannam@126 3167 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
cannam@126 3168 func_convert_path_check : ";" \
cannam@126 3169 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@126 3170 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
cannam@126 3171 fi
cannam@126 3172 }
cannam@126 3173 # end func_convert_path_cygwin_to_w32
cannam@126 3174
cannam@126 3175
cannam@126 3176 # func_convert_path_nix_to_w32 ARG
cannam@126 3177 # Convert path ARG from *nix to w32 format. Requires a wine environment and
cannam@126 3178 # a working winepath. Returns result in func_to_host_file_result.
cannam@126 3179 func_convert_path_nix_to_w32 ()
cannam@126 3180 {
cannam@126 3181 $debug_cmd
cannam@126 3182
cannam@126 3183 func_to_host_path_result=$1
cannam@126 3184 if test -n "$1"; then
cannam@126 3185 # See func_convert_path_msys_to_w32:
cannam@126 3186 func_stripname : : "$1"
cannam@126 3187 func_to_host_path_tmp1=$func_stripname_result
cannam@126 3188 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
cannam@126 3189 func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
cannam@126 3190 func_convert_path_check : ";" \
cannam@126 3191 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@126 3192 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
cannam@126 3193 fi
cannam@126 3194 }
cannam@126 3195 # end func_convert_path_nix_to_w32
cannam@126 3196
cannam@126 3197
cannam@126 3198 # func_convert_path_msys_to_cygwin ARG
cannam@126 3199 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
cannam@126 3200 # Returns result in func_to_host_file_result.
cannam@126 3201 func_convert_path_msys_to_cygwin ()
cannam@126 3202 {
cannam@126 3203 $debug_cmd
cannam@126 3204
cannam@126 3205 func_to_host_path_result=$1
cannam@126 3206 if test -n "$1"; then
cannam@126 3207 # See func_convert_path_msys_to_w32:
cannam@126 3208 func_stripname : : "$1"
cannam@126 3209 func_to_host_path_tmp1=$func_stripname_result
cannam@126 3210 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
cannam@126 3211 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
cannam@126 3212 func_to_host_path_result=$func_cygpath_result
cannam@126 3213 func_convert_path_check : : \
cannam@126 3214 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@126 3215 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
cannam@126 3216 fi
cannam@126 3217 }
cannam@126 3218 # end func_convert_path_msys_to_cygwin
cannam@126 3219
cannam@126 3220
cannam@126 3221 # func_convert_path_nix_to_cygwin ARG
cannam@126 3222 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
cannam@126 3223 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
cannam@126 3224 # func_to_host_file_result.
cannam@126 3225 func_convert_path_nix_to_cygwin ()
cannam@126 3226 {
cannam@126 3227 $debug_cmd
cannam@126 3228
cannam@126 3229 func_to_host_path_result=$1
cannam@126 3230 if test -n "$1"; then
cannam@126 3231 # Remove leading and trailing path separator characters from
cannam@126 3232 # ARG. msys behavior is inconsistent here, cygpath turns them
cannam@126 3233 # into '.;' and ';.', and winepath ignores them completely.
cannam@126 3234 func_stripname : : "$1"
cannam@126 3235 func_to_host_path_tmp1=$func_stripname_result
cannam@126 3236 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
cannam@126 3237 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
cannam@126 3238 func_to_host_path_result=$func_cygpath_result
cannam@126 3239 func_convert_path_check : : \
cannam@126 3240 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@126 3241 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
cannam@126 3242 fi
cannam@126 3243 }
cannam@126 3244 # end func_convert_path_nix_to_cygwin
cannam@126 3245
cannam@126 3246
cannam@126 3247 # func_dll_def_p FILE
cannam@126 3248 # True iff FILE is a Windows DLL '.def' file.
cannam@126 3249 # Keep in sync with _LT_DLL_DEF_P in libtool.m4
cannam@126 3250 func_dll_def_p ()
cannam@126 3251 {
cannam@126 3252 $debug_cmd
cannam@126 3253
cannam@126 3254 func_dll_def_p_tmp=`$SED -n \
cannam@126 3255 -e 's/^[ ]*//' \
cannam@126 3256 -e '/^\(;.*\)*$/d' \
cannam@126 3257 -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
cannam@126 3258 -e q \
cannam@126 3259 "$1"`
cannam@126 3260 test DEF = "$func_dll_def_p_tmp"
cannam@126 3261 }
cannam@126 3262
cannam@126 3263
cannam@126 3264 # func_mode_compile arg...
cannam@126 3265 func_mode_compile ()
cannam@126 3266 {
cannam@126 3267 $debug_cmd
cannam@126 3268
cannam@126 3269 # Get the compilation command and the source file.
cannam@126 3270 base_compile=
cannam@126 3271 srcfile=$nonopt # always keep a non-empty value in "srcfile"
cannam@126 3272 suppress_opt=yes
cannam@126 3273 suppress_output=
cannam@126 3274 arg_mode=normal
cannam@126 3275 libobj=
cannam@126 3276 later=
cannam@126 3277 pie_flag=
cannam@126 3278
cannam@126 3279 for arg
cannam@126 3280 do
cannam@126 3281 case $arg_mode in
cannam@126 3282 arg )
cannam@126 3283 # do not "continue". Instead, add this to base_compile
cannam@126 3284 lastarg=$arg
cannam@126 3285 arg_mode=normal
cannam@126 3286 ;;
cannam@126 3287
cannam@126 3288 target )
cannam@126 3289 libobj=$arg
cannam@126 3290 arg_mode=normal
cannam@126 3291 continue
cannam@126 3292 ;;
cannam@126 3293
cannam@126 3294 normal )
cannam@126 3295 # Accept any command-line options.
cannam@126 3296 case $arg in
cannam@126 3297 -o)
cannam@126 3298 test -n "$libobj" && \
cannam@126 3299 func_fatal_error "you cannot specify '-o' more than once"
cannam@126 3300 arg_mode=target
cannam@126 3301 continue
cannam@126 3302 ;;
cannam@126 3303
cannam@126 3304 -pie | -fpie | -fPIE)
cannam@126 3305 func_append pie_flag " $arg"
cannam@126 3306 continue
cannam@126 3307 ;;
cannam@126 3308
cannam@126 3309 -shared | -static | -prefer-pic | -prefer-non-pic)
cannam@126 3310 func_append later " $arg"
cannam@126 3311 continue
cannam@126 3312 ;;
cannam@126 3313
cannam@126 3314 -no-suppress)
cannam@126 3315 suppress_opt=no
cannam@126 3316 continue
cannam@126 3317 ;;
cannam@126 3318
cannam@126 3319 -Xcompiler)
cannam@126 3320 arg_mode=arg # the next one goes into the "base_compile" arg list
cannam@126 3321 continue # The current "srcfile" will either be retained or
cannam@126 3322 ;; # replaced later. I would guess that would be a bug.
cannam@126 3323
cannam@126 3324 -Wc,*)
cannam@126 3325 func_stripname '-Wc,' '' "$arg"
cannam@126 3326 args=$func_stripname_result
cannam@126 3327 lastarg=
cannam@126 3328 save_ifs=$IFS; IFS=,
cannam@126 3329 for arg in $args; do
cannam@126 3330 IFS=$save_ifs
cannam@126 3331 func_append_quoted lastarg "$arg"
cannam@126 3332 done
cannam@126 3333 IFS=$save_ifs
cannam@126 3334 func_stripname ' ' '' "$lastarg"
cannam@126 3335 lastarg=$func_stripname_result
cannam@126 3336
cannam@126 3337 # Add the arguments to base_compile.
cannam@126 3338 func_append base_compile " $lastarg"
cannam@126 3339 continue
cannam@126 3340 ;;
cannam@126 3341
cannam@126 3342 *)
cannam@126 3343 # Accept the current argument as the source file.
cannam@126 3344 # The previous "srcfile" becomes the current argument.
cannam@126 3345 #
cannam@126 3346 lastarg=$srcfile
cannam@126 3347 srcfile=$arg
cannam@126 3348 ;;
cannam@126 3349 esac # case $arg
cannam@126 3350 ;;
cannam@126 3351 esac # case $arg_mode
cannam@126 3352
cannam@126 3353 # Aesthetically quote the previous argument.
cannam@126 3354 func_append_quoted base_compile "$lastarg"
cannam@126 3355 done # for arg
cannam@126 3356
cannam@126 3357 case $arg_mode in
cannam@126 3358 arg)
cannam@126 3359 func_fatal_error "you must specify an argument for -Xcompile"
cannam@126 3360 ;;
cannam@126 3361 target)
cannam@126 3362 func_fatal_error "you must specify a target with '-o'"
cannam@126 3363 ;;
cannam@126 3364 *)
cannam@126 3365 # Get the name of the library object.
cannam@126 3366 test -z "$libobj" && {
cannam@126 3367 func_basename "$srcfile"
cannam@126 3368 libobj=$func_basename_result
cannam@126 3369 }
cannam@126 3370 ;;
cannam@126 3371 esac
cannam@126 3372
cannam@126 3373 # Recognize several different file suffixes.
cannam@126 3374 # If the user specifies -o file.o, it is replaced with file.lo
cannam@126 3375 case $libobj in
cannam@126 3376 *.[cCFSifmso] | \
cannam@126 3377 *.ada | *.adb | *.ads | *.asm | \
cannam@126 3378 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
cannam@126 3379 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
cannam@126 3380 func_xform "$libobj"
cannam@126 3381 libobj=$func_xform_result
cannam@126 3382 ;;
cannam@126 3383 esac
cannam@126 3384
cannam@126 3385 case $libobj in
cannam@126 3386 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
cannam@126 3387 *)
cannam@126 3388 func_fatal_error "cannot determine name of library object from '$libobj'"
cannam@126 3389 ;;
cannam@126 3390 esac
cannam@126 3391
cannam@126 3392 func_infer_tag $base_compile
cannam@126 3393
cannam@126 3394 for arg in $later; do
cannam@126 3395 case $arg in
cannam@126 3396 -shared)
cannam@126 3397 test yes = "$build_libtool_libs" \
cannam@126 3398 || func_fatal_configuration "cannot build a shared library"
cannam@126 3399 build_old_libs=no
cannam@126 3400 continue
cannam@126 3401 ;;
cannam@126 3402
cannam@126 3403 -static)
cannam@126 3404 build_libtool_libs=no
cannam@126 3405 build_old_libs=yes
cannam@126 3406 continue
cannam@126 3407 ;;
cannam@126 3408
cannam@126 3409 -prefer-pic)
cannam@126 3410 pic_mode=yes
cannam@126 3411 continue
cannam@126 3412 ;;
cannam@126 3413
cannam@126 3414 -prefer-non-pic)
cannam@126 3415 pic_mode=no
cannam@126 3416 continue
cannam@126 3417 ;;
cannam@126 3418 esac
cannam@126 3419 done
cannam@126 3420
cannam@126 3421 func_quote_for_eval "$libobj"
cannam@126 3422 test "X$libobj" != "X$func_quote_for_eval_result" \
cannam@126 3423 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
cannam@126 3424 && func_warning "libobj name '$libobj' may not contain shell special characters."
cannam@126 3425 func_dirname_and_basename "$obj" "/" ""
cannam@126 3426 objname=$func_basename_result
cannam@126 3427 xdir=$func_dirname_result
cannam@126 3428 lobj=$xdir$objdir/$objname
cannam@126 3429
cannam@126 3430 test -z "$base_compile" && \
cannam@126 3431 func_fatal_help "you must specify a compilation command"
cannam@126 3432
cannam@126 3433 # Delete any leftover library objects.
cannam@126 3434 if test yes = "$build_old_libs"; then
cannam@126 3435 removelist="$obj $lobj $libobj ${libobj}T"
cannam@126 3436 else
cannam@126 3437 removelist="$lobj $libobj ${libobj}T"
cannam@126 3438 fi
cannam@126 3439
cannam@126 3440 # On Cygwin there's no "real" PIC flag so we must build both object types
cannam@126 3441 case $host_os in
cannam@126 3442 cygwin* | mingw* | pw32* | os2* | cegcc*)
cannam@126 3443 pic_mode=default
cannam@126 3444 ;;
cannam@126 3445 esac
cannam@126 3446 if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
cannam@126 3447 # non-PIC code in shared libraries is not supported
cannam@126 3448 pic_mode=default
cannam@126 3449 fi
cannam@126 3450
cannam@126 3451 # Calculate the filename of the output object if compiler does
cannam@126 3452 # not support -o with -c
cannam@126 3453 if test no = "$compiler_c_o"; then
cannam@126 3454 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
cannam@126 3455 lockfile=$output_obj.lock
cannam@126 3456 else
cannam@126 3457 output_obj=
cannam@126 3458 need_locks=no
cannam@126 3459 lockfile=
cannam@126 3460 fi
cannam@126 3461
cannam@126 3462 # Lock this critical section if it is needed
cannam@126 3463 # We use this script file to make the link, it avoids creating a new file
cannam@126 3464 if test yes = "$need_locks"; then
cannam@126 3465 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
cannam@126 3466 func_echo "Waiting for $lockfile to be removed"
cannam@126 3467 sleep 2
cannam@126 3468 done
cannam@126 3469 elif test warn = "$need_locks"; then
cannam@126 3470 if test -f "$lockfile"; then
cannam@126 3471 $ECHO "\
cannam@126 3472 *** ERROR, $lockfile exists and contains:
cannam@126 3473 `cat $lockfile 2>/dev/null`
cannam@126 3474
cannam@126 3475 This indicates that another process is trying to use the same
cannam@126 3476 temporary object file, and libtool could not work around it because
cannam@126 3477 your compiler does not support '-c' and '-o' together. If you
cannam@126 3478 repeat this compilation, it may succeed, by chance, but you had better
cannam@126 3479 avoid parallel builds (make -j) in this platform, or get a better
cannam@126 3480 compiler."
cannam@126 3481
cannam@126 3482 $opt_dry_run || $RM $removelist
cannam@126 3483 exit $EXIT_FAILURE
cannam@126 3484 fi
cannam@126 3485 func_append removelist " $output_obj"
cannam@126 3486 $ECHO "$srcfile" > "$lockfile"
cannam@126 3487 fi
cannam@126 3488
cannam@126 3489 $opt_dry_run || $RM $removelist
cannam@126 3490 func_append removelist " $lockfile"
cannam@126 3491 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
cannam@126 3492
cannam@126 3493 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
cannam@126 3494 srcfile=$func_to_tool_file_result
cannam@126 3495 func_quote_for_eval "$srcfile"
cannam@126 3496 qsrcfile=$func_quote_for_eval_result
cannam@126 3497
cannam@126 3498 # Only build a PIC object if we are building libtool libraries.
cannam@126 3499 if test yes = "$build_libtool_libs"; then
cannam@126 3500 # Without this assignment, base_compile gets emptied.
cannam@126 3501 fbsd_hideous_sh_bug=$base_compile
cannam@126 3502
cannam@126 3503 if test no != "$pic_mode"; then
cannam@126 3504 command="$base_compile $qsrcfile $pic_flag"
cannam@126 3505 else
cannam@126 3506 # Don't build PIC code
cannam@126 3507 command="$base_compile $qsrcfile"
cannam@126 3508 fi
cannam@126 3509
cannam@126 3510 func_mkdir_p "$xdir$objdir"
cannam@126 3511
cannam@126 3512 if test -z "$output_obj"; then
cannam@126 3513 # Place PIC objects in $objdir
cannam@126 3514 func_append command " -o $lobj"
cannam@126 3515 fi
cannam@126 3516
cannam@126 3517 func_show_eval_locale "$command" \
cannam@126 3518 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
cannam@126 3519
cannam@126 3520 if test warn = "$need_locks" &&
cannam@126 3521 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
cannam@126 3522 $ECHO "\
cannam@126 3523 *** ERROR, $lockfile contains:
cannam@126 3524 `cat $lockfile 2>/dev/null`
cannam@126 3525
cannam@126 3526 but it should contain:
cannam@126 3527 $srcfile
cannam@126 3528
cannam@126 3529 This indicates that another process is trying to use the same
cannam@126 3530 temporary object file, and libtool could not work around it because
cannam@126 3531 your compiler does not support '-c' and '-o' together. If you
cannam@126 3532 repeat this compilation, it may succeed, by chance, but you had better
cannam@126 3533 avoid parallel builds (make -j) in this platform, or get a better
cannam@126 3534 compiler."
cannam@126 3535
cannam@126 3536 $opt_dry_run || $RM $removelist
cannam@126 3537 exit $EXIT_FAILURE
cannam@126 3538 fi
cannam@126 3539
cannam@126 3540 # Just move the object if needed, then go on to compile the next one
cannam@126 3541 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
cannam@126 3542 func_show_eval '$MV "$output_obj" "$lobj"' \
cannam@126 3543 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
cannam@126 3544 fi
cannam@126 3545
cannam@126 3546 # Allow error messages only from the first compilation.
cannam@126 3547 if test yes = "$suppress_opt"; then
cannam@126 3548 suppress_output=' >/dev/null 2>&1'
cannam@126 3549 fi
cannam@126 3550 fi
cannam@126 3551
cannam@126 3552 # Only build a position-dependent object if we build old libraries.
cannam@126 3553 if test yes = "$build_old_libs"; then
cannam@126 3554 if test yes != "$pic_mode"; then
cannam@126 3555 # Don't build PIC code
cannam@126 3556 command="$base_compile $qsrcfile$pie_flag"
cannam@126 3557 else
cannam@126 3558 command="$base_compile $qsrcfile $pic_flag"
cannam@126 3559 fi
cannam@126 3560 if test yes = "$compiler_c_o"; then
cannam@126 3561 func_append command " -o $obj"
cannam@126 3562 fi
cannam@126 3563
cannam@126 3564 # Suppress compiler output if we already did a PIC compilation.
cannam@126 3565 func_append command "$suppress_output"
cannam@126 3566 func_show_eval_locale "$command" \
cannam@126 3567 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
cannam@126 3568
cannam@126 3569 if test warn = "$need_locks" &&
cannam@126 3570 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
cannam@126 3571 $ECHO "\
cannam@126 3572 *** ERROR, $lockfile contains:
cannam@126 3573 `cat $lockfile 2>/dev/null`
cannam@126 3574
cannam@126 3575 but it should contain:
cannam@126 3576 $srcfile
cannam@126 3577
cannam@126 3578 This indicates that another process is trying to use the same
cannam@126 3579 temporary object file, and libtool could not work around it because
cannam@126 3580 your compiler does not support '-c' and '-o' together. If you
cannam@126 3581 repeat this compilation, it may succeed, by chance, but you had better
cannam@126 3582 avoid parallel builds (make -j) in this platform, or get a better
cannam@126 3583 compiler."
cannam@126 3584
cannam@126 3585 $opt_dry_run || $RM $removelist
cannam@126 3586 exit $EXIT_FAILURE
cannam@126 3587 fi
cannam@126 3588
cannam@126 3589 # Just move the object if needed
cannam@126 3590 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
cannam@126 3591 func_show_eval '$MV "$output_obj" "$obj"' \
cannam@126 3592 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
cannam@126 3593 fi
cannam@126 3594 fi
cannam@126 3595
cannam@126 3596 $opt_dry_run || {
cannam@126 3597 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
cannam@126 3598
cannam@126 3599 # Unlock the critical section if it was locked
cannam@126 3600 if test no != "$need_locks"; then
cannam@126 3601 removelist=$lockfile
cannam@126 3602 $RM "$lockfile"
cannam@126 3603 fi
cannam@126 3604 }
cannam@126 3605
cannam@126 3606 exit $EXIT_SUCCESS
cannam@126 3607 }
cannam@126 3608
cannam@126 3609 $opt_help || {
cannam@126 3610 test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
cannam@126 3611 }
cannam@126 3612
cannam@126 3613 func_mode_help ()
cannam@126 3614 {
cannam@126 3615 # We need to display help for each of the modes.
cannam@126 3616 case $opt_mode in
cannam@126 3617 "")
cannam@126 3618 # Generic help is extracted from the usage comments
cannam@126 3619 # at the start of this file.
cannam@126 3620 func_help
cannam@126 3621 ;;
cannam@126 3622
cannam@126 3623 clean)
cannam@126 3624 $ECHO \
cannam@126 3625 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
cannam@126 3626
cannam@126 3627 Remove files from the build directory.
cannam@126 3628
cannam@126 3629 RM is the name of the program to use to delete files associated with each FILE
cannam@126 3630 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
cannam@126 3631 to RM.
cannam@126 3632
cannam@126 3633 If FILE is a libtool library, object or program, all the files associated
cannam@126 3634 with it are deleted. Otherwise, only FILE itself is deleted using RM."
cannam@126 3635 ;;
cannam@126 3636
cannam@126 3637 compile)
cannam@126 3638 $ECHO \
cannam@126 3639 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
cannam@126 3640
cannam@126 3641 Compile a source file into a libtool library object.
cannam@126 3642
cannam@126 3643 This mode accepts the following additional options:
cannam@126 3644
cannam@126 3645 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
cannam@126 3646 -no-suppress do not suppress compiler output for multiple passes
cannam@126 3647 -prefer-pic try to build PIC objects only
cannam@126 3648 -prefer-non-pic try to build non-PIC objects only
cannam@126 3649 -shared do not build a '.o' file suitable for static linking
cannam@126 3650 -static only build a '.o' file suitable for static linking
cannam@126 3651 -Wc,FLAG pass FLAG directly to the compiler
cannam@126 3652
cannam@126 3653 COMPILE-COMMAND is a command to be used in creating a 'standard' object file
cannam@126 3654 from the given SOURCEFILE.
cannam@126 3655
cannam@126 3656 The output file name is determined by removing the directory component from
cannam@126 3657 SOURCEFILE, then substituting the C source code suffix '.c' with the
cannam@126 3658 library object suffix, '.lo'."
cannam@126 3659 ;;
cannam@126 3660
cannam@126 3661 execute)
cannam@126 3662 $ECHO \
cannam@126 3663 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
cannam@126 3664
cannam@126 3665 Automatically set library path, then run a program.
cannam@126 3666
cannam@126 3667 This mode accepts the following additional options:
cannam@126 3668
cannam@126 3669 -dlopen FILE add the directory containing FILE to the library path
cannam@126 3670
cannam@126 3671 This mode sets the library path environment variable according to '-dlopen'
cannam@126 3672 flags.
cannam@126 3673
cannam@126 3674 If any of the ARGS are libtool executable wrappers, then they are translated
cannam@126 3675 into their corresponding uninstalled binary, and any of their required library
cannam@126 3676 directories are added to the library path.
cannam@126 3677
cannam@126 3678 Then, COMMAND is executed, with ARGS as arguments."
cannam@126 3679 ;;
cannam@126 3680
cannam@126 3681 finish)
cannam@126 3682 $ECHO \
cannam@126 3683 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
cannam@126 3684
cannam@126 3685 Complete the installation of libtool libraries.
cannam@126 3686
cannam@126 3687 Each LIBDIR is a directory that contains libtool libraries.
cannam@126 3688
cannam@126 3689 The commands that this mode executes may require superuser privileges. Use
cannam@126 3690 the '--dry-run' option if you just want to see what would be executed."
cannam@126 3691 ;;
cannam@126 3692
cannam@126 3693 install)
cannam@126 3694 $ECHO \
cannam@126 3695 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
cannam@126 3696
cannam@126 3697 Install executables or libraries.
cannam@126 3698
cannam@126 3699 INSTALL-COMMAND is the installation command. The first component should be
cannam@126 3700 either the 'install' or 'cp' program.
cannam@126 3701
cannam@126 3702 The following components of INSTALL-COMMAND are treated specially:
cannam@126 3703
cannam@126 3704 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
cannam@126 3705
cannam@126 3706 The rest of the components are interpreted as arguments to that command (only
cannam@126 3707 BSD-compatible install options are recognized)."
cannam@126 3708 ;;
cannam@126 3709
cannam@126 3710 link)
cannam@126 3711 $ECHO \
cannam@126 3712 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
cannam@126 3713
cannam@126 3714 Link object files or libraries together to form another library, or to
cannam@126 3715 create an executable program.
cannam@126 3716
cannam@126 3717 LINK-COMMAND is a command using the C compiler that you would use to create
cannam@126 3718 a program from several object files.
cannam@126 3719
cannam@126 3720 The following components of LINK-COMMAND are treated specially:
cannam@126 3721
cannam@126 3722 -all-static do not do any dynamic linking at all
cannam@126 3723 -avoid-version do not add a version suffix if possible
cannam@126 3724 -bindir BINDIR specify path to binaries directory (for systems where
cannam@126 3725 libraries must be found in the PATH setting at runtime)
cannam@126 3726 -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
cannam@126 3727 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
cannam@126 3728 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
cannam@126 3729 -export-symbols SYMFILE
cannam@126 3730 try to export only the symbols listed in SYMFILE
cannam@126 3731 -export-symbols-regex REGEX
cannam@126 3732 try to export only the symbols matching REGEX
cannam@126 3733 -LLIBDIR search LIBDIR for required installed libraries
cannam@126 3734 -lNAME OUTPUT-FILE requires the installed library libNAME
cannam@126 3735 -module build a library that can dlopened
cannam@126 3736 -no-fast-install disable the fast-install mode
cannam@126 3737 -no-install link a not-installable executable
cannam@126 3738 -no-undefined declare that a library does not refer to external symbols
cannam@126 3739 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
cannam@126 3740 -objectlist FILE use a list of object files found in FILE to specify objects
cannam@126 3741 -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
cannam@126 3742 -precious-files-regex REGEX
cannam@126 3743 don't remove output files matching REGEX
cannam@126 3744 -release RELEASE specify package release information
cannam@126 3745 -rpath LIBDIR the created library will eventually be installed in LIBDIR
cannam@126 3746 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
cannam@126 3747 -shared only do dynamic linking of libtool libraries
cannam@126 3748 -shrext SUFFIX override the standard shared library file extension
cannam@126 3749 -static do not do any dynamic linking of uninstalled libtool libraries
cannam@126 3750 -static-libtool-libs
cannam@126 3751 do not do any dynamic linking of libtool libraries
cannam@126 3752 -version-info CURRENT[:REVISION[:AGE]]
cannam@126 3753 specify library version info [each variable defaults to 0]
cannam@126 3754 -weak LIBNAME declare that the target provides the LIBNAME interface
cannam@126 3755 -Wc,FLAG
cannam@126 3756 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
cannam@126 3757 -Wl,FLAG
cannam@126 3758 -Xlinker FLAG pass linker-specific FLAG directly to the linker
cannam@126 3759 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
cannam@126 3760
cannam@126 3761 All other options (arguments beginning with '-') are ignored.
cannam@126 3762
cannam@126 3763 Every other argument is treated as a filename. Files ending in '.la' are
cannam@126 3764 treated as uninstalled libtool libraries, other files are standard or library
cannam@126 3765 object files.
cannam@126 3766
cannam@126 3767 If the OUTPUT-FILE ends in '.la', then a libtool library is created,
cannam@126 3768 only library objects ('.lo' files) may be specified, and '-rpath' is
cannam@126 3769 required, except when creating a convenience library.
cannam@126 3770
cannam@126 3771 If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
cannam@126 3772 using 'ar' and 'ranlib', or on Windows using 'lib'.
cannam@126 3773
cannam@126 3774 If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
cannam@126 3775 is created, otherwise an executable program is created."
cannam@126 3776 ;;
cannam@126 3777
cannam@126 3778 uninstall)
cannam@126 3779 $ECHO \
cannam@126 3780 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
cannam@126 3781
cannam@126 3782 Remove libraries from an installation directory.
cannam@126 3783
cannam@126 3784 RM is the name of the program to use to delete files associated with each FILE
cannam@126 3785 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
cannam@126 3786 to RM.
cannam@126 3787
cannam@126 3788 If FILE is a libtool library, all the files associated with it are deleted.
cannam@126 3789 Otherwise, only FILE itself is deleted using RM."
cannam@126 3790 ;;
cannam@126 3791
cannam@126 3792 *)
cannam@126 3793 func_fatal_help "invalid operation mode '$opt_mode'"
cannam@126 3794 ;;
cannam@126 3795 esac
cannam@126 3796
cannam@126 3797 echo
cannam@126 3798 $ECHO "Try '$progname --help' for more information about other modes."
cannam@126 3799 }
cannam@126 3800
cannam@126 3801 # Now that we've collected a possible --mode arg, show help if necessary
cannam@126 3802 if $opt_help; then
cannam@126 3803 if test : = "$opt_help"; then
cannam@126 3804 func_mode_help
cannam@126 3805 else
cannam@126 3806 {
cannam@126 3807 func_help noexit
cannam@126 3808 for opt_mode in compile link execute install finish uninstall clean; do
cannam@126 3809 func_mode_help
cannam@126 3810 done
cannam@126 3811 } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
cannam@126 3812 {
cannam@126 3813 func_help noexit
cannam@126 3814 for opt_mode in compile link execute install finish uninstall clean; do
cannam@126 3815 echo
cannam@126 3816 func_mode_help
cannam@126 3817 done
cannam@126 3818 } |
cannam@126 3819 $SED '1d
cannam@126 3820 /^When reporting/,/^Report/{
cannam@126 3821 H
cannam@126 3822 d
cannam@126 3823 }
cannam@126 3824 $x
cannam@126 3825 /information about other modes/d
cannam@126 3826 /more detailed .*MODE/d
cannam@126 3827 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
cannam@126 3828 fi
cannam@126 3829 exit $?
cannam@126 3830 fi
cannam@126 3831
cannam@126 3832
cannam@126 3833 # func_mode_execute arg...
cannam@126 3834 func_mode_execute ()
cannam@126 3835 {
cannam@126 3836 $debug_cmd
cannam@126 3837
cannam@126 3838 # The first argument is the command name.
cannam@126 3839 cmd=$nonopt
cannam@126 3840 test -z "$cmd" && \
cannam@126 3841 func_fatal_help "you must specify a COMMAND"
cannam@126 3842
cannam@126 3843 # Handle -dlopen flags immediately.
cannam@126 3844 for file in $opt_dlopen; do
cannam@126 3845 test -f "$file" \
cannam@126 3846 || func_fatal_help "'$file' is not a file"
cannam@126 3847
cannam@126 3848 dir=
cannam@126 3849 case $file in
cannam@126 3850 *.la)
cannam@126 3851 func_resolve_sysroot "$file"
cannam@126 3852 file=$func_resolve_sysroot_result
cannam@126 3853
cannam@126 3854 # Check to see that this really is a libtool archive.
cannam@126 3855 func_lalib_unsafe_p "$file" \
cannam@126 3856 || func_fatal_help "'$lib' is not a valid libtool archive"
cannam@126 3857
cannam@126 3858 # Read the libtool library.
cannam@126 3859 dlname=
cannam@126 3860 library_names=
cannam@126 3861 func_source "$file"
cannam@126 3862
cannam@126 3863 # Skip this library if it cannot be dlopened.
cannam@126 3864 if test -z "$dlname"; then
cannam@126 3865 # Warn if it was a shared library.
cannam@126 3866 test -n "$library_names" && \
cannam@126 3867 func_warning "'$file' was not linked with '-export-dynamic'"
cannam@126 3868 continue
cannam@126 3869 fi
cannam@126 3870
cannam@126 3871 func_dirname "$file" "" "."
cannam@126 3872 dir=$func_dirname_result
cannam@126 3873
cannam@126 3874 if test -f "$dir/$objdir/$dlname"; then
cannam@126 3875 func_append dir "/$objdir"
cannam@126 3876 else
cannam@126 3877 if test ! -f "$dir/$dlname"; then
cannam@126 3878 func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
cannam@126 3879 fi
cannam@126 3880 fi
cannam@126 3881 ;;
cannam@126 3882
cannam@126 3883 *.lo)
cannam@126 3884 # Just add the directory containing the .lo file.
cannam@126 3885 func_dirname "$file" "" "."
cannam@126 3886 dir=$func_dirname_result
cannam@126 3887 ;;
cannam@126 3888
cannam@126 3889 *)
cannam@126 3890 func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
cannam@126 3891 continue
cannam@126 3892 ;;
cannam@126 3893 esac
cannam@126 3894
cannam@126 3895 # Get the absolute pathname.
cannam@126 3896 absdir=`cd "$dir" && pwd`
cannam@126 3897 test -n "$absdir" && dir=$absdir
cannam@126 3898
cannam@126 3899 # Now add the directory to shlibpath_var.
cannam@126 3900 if eval "test -z \"\$$shlibpath_var\""; then
cannam@126 3901 eval "$shlibpath_var=\"\$dir\""
cannam@126 3902 else
cannam@126 3903 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
cannam@126 3904 fi
cannam@126 3905 done
cannam@126 3906
cannam@126 3907 # This variable tells wrapper scripts just to set shlibpath_var
cannam@126 3908 # rather than running their programs.
cannam@126 3909 libtool_execute_magic=$magic
cannam@126 3910
cannam@126 3911 # Check if any of the arguments is a wrapper script.
cannam@126 3912 args=
cannam@126 3913 for file
cannam@126 3914 do
cannam@126 3915 case $file in
cannam@126 3916 -* | *.la | *.lo ) ;;
cannam@126 3917 *)
cannam@126 3918 # Do a test to see if this is really a libtool program.
cannam@126 3919 if func_ltwrapper_script_p "$file"; then
cannam@126 3920 func_source "$file"
cannam@126 3921 # Transform arg to wrapped name.
cannam@126 3922 file=$progdir/$program
cannam@126 3923 elif func_ltwrapper_executable_p "$file"; then
cannam@126 3924 func_ltwrapper_scriptname "$file"
cannam@126 3925 func_source "$func_ltwrapper_scriptname_result"
cannam@126 3926 # Transform arg to wrapped name.
cannam@126 3927 file=$progdir/$program
cannam@126 3928 fi
cannam@126 3929 ;;
cannam@126 3930 esac
cannam@126 3931 # Quote arguments (to preserve shell metacharacters).
cannam@126 3932 func_append_quoted args "$file"
cannam@126 3933 done
cannam@126 3934
cannam@126 3935 if $opt_dry_run; then
cannam@126 3936 # Display what would be done.
cannam@126 3937 if test -n "$shlibpath_var"; then
cannam@126 3938 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
cannam@126 3939 echo "export $shlibpath_var"
cannam@126 3940 fi
cannam@126 3941 $ECHO "$cmd$args"
cannam@126 3942 exit $EXIT_SUCCESS
cannam@126 3943 else
cannam@126 3944 if test -n "$shlibpath_var"; then
cannam@126 3945 # Export the shlibpath_var.
cannam@126 3946 eval "export $shlibpath_var"
cannam@126 3947 fi
cannam@126 3948
cannam@126 3949 # Restore saved environment variables
cannam@126 3950 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
cannam@126 3951 do
cannam@126 3952 eval "if test \"\${save_$lt_var+set}\" = set; then
cannam@126 3953 $lt_var=\$save_$lt_var; export $lt_var
cannam@126 3954 else
cannam@126 3955 $lt_unset $lt_var
cannam@126 3956 fi"
cannam@126 3957 done
cannam@126 3958
cannam@126 3959 # Now prepare to actually exec the command.
cannam@126 3960 exec_cmd=\$cmd$args
cannam@126 3961 fi
cannam@126 3962 }
cannam@126 3963
cannam@126 3964 test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
cannam@126 3965
cannam@126 3966
cannam@126 3967 # func_mode_finish arg...
cannam@126 3968 func_mode_finish ()
cannam@126 3969 {
cannam@126 3970 $debug_cmd
cannam@126 3971
cannam@126 3972 libs=
cannam@126 3973 libdirs=
cannam@126 3974 admincmds=
cannam@126 3975
cannam@126 3976 for opt in "$nonopt" ${1+"$@"}
cannam@126 3977 do
cannam@126 3978 if test -d "$opt"; then
cannam@126 3979 func_append libdirs " $opt"
cannam@126 3980
cannam@126 3981 elif test -f "$opt"; then
cannam@126 3982 if func_lalib_unsafe_p "$opt"; then
cannam@126 3983 func_append libs " $opt"
cannam@126 3984 else
cannam@126 3985 func_warning "'$opt' is not a valid libtool archive"
cannam@126 3986 fi
cannam@126 3987
cannam@126 3988 else
cannam@126 3989 func_fatal_error "invalid argument '$opt'"
cannam@126 3990 fi
cannam@126 3991 done
cannam@126 3992
cannam@126 3993 if test -n "$libs"; then
cannam@126 3994 if test -n "$lt_sysroot"; then
cannam@126 3995 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
cannam@126 3996 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
cannam@126 3997 else
cannam@126 3998 sysroot_cmd=
cannam@126 3999 fi
cannam@126 4000
cannam@126 4001 # Remove sysroot references
cannam@126 4002 if $opt_dry_run; then
cannam@126 4003 for lib in $libs; do
cannam@126 4004 echo "removing references to $lt_sysroot and '=' prefixes from $lib"
cannam@126 4005 done
cannam@126 4006 else
cannam@126 4007 tmpdir=`func_mktempdir`
cannam@126 4008 for lib in $libs; do
cannam@126 4009 $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
cannam@126 4010 > $tmpdir/tmp-la
cannam@126 4011 mv -f $tmpdir/tmp-la $lib
cannam@126 4012 done
cannam@126 4013 ${RM}r "$tmpdir"
cannam@126 4014 fi
cannam@126 4015 fi
cannam@126 4016
cannam@126 4017 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
cannam@126 4018 for libdir in $libdirs; do
cannam@126 4019 if test -n "$finish_cmds"; then
cannam@126 4020 # Do each command in the finish commands.
cannam@126 4021 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
cannam@126 4022 '"$cmd"'"'
cannam@126 4023 fi
cannam@126 4024 if test -n "$finish_eval"; then
cannam@126 4025 # Do the single finish_eval.
cannam@126 4026 eval cmds=\"$finish_eval\"
cannam@126 4027 $opt_dry_run || eval "$cmds" || func_append admincmds "
cannam@126 4028 $cmds"
cannam@126 4029 fi
cannam@126 4030 done
cannam@126 4031 fi
cannam@126 4032
cannam@126 4033 # Exit here if they wanted silent mode.
cannam@126 4034 $opt_quiet && exit $EXIT_SUCCESS
cannam@126 4035
cannam@126 4036 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
cannam@126 4037 echo "----------------------------------------------------------------------"
cannam@126 4038 echo "Libraries have been installed in:"
cannam@126 4039 for libdir in $libdirs; do
cannam@126 4040 $ECHO " $libdir"
cannam@126 4041 done
cannam@126 4042 echo
cannam@126 4043 echo "If you ever happen to want to link against installed libraries"
cannam@126 4044 echo "in a given directory, LIBDIR, you must either use libtool, and"
cannam@126 4045 echo "specify the full pathname of the library, or use the '-LLIBDIR'"
cannam@126 4046 echo "flag during linking and do at least one of the following:"
cannam@126 4047 if test -n "$shlibpath_var"; then
cannam@126 4048 echo " - add LIBDIR to the '$shlibpath_var' environment variable"
cannam@126 4049 echo " during execution"
cannam@126 4050 fi
cannam@126 4051 if test -n "$runpath_var"; then
cannam@126 4052 echo " - add LIBDIR to the '$runpath_var' environment variable"
cannam@126 4053 echo " during linking"
cannam@126 4054 fi
cannam@126 4055 if test -n "$hardcode_libdir_flag_spec"; then
cannam@126 4056 libdir=LIBDIR
cannam@126 4057 eval flag=\"$hardcode_libdir_flag_spec\"
cannam@126 4058
cannam@126 4059 $ECHO " - use the '$flag' linker flag"
cannam@126 4060 fi
cannam@126 4061 if test -n "$admincmds"; then
cannam@126 4062 $ECHO " - have your system administrator run these commands:$admincmds"
cannam@126 4063 fi
cannam@126 4064 if test -f /etc/ld.so.conf; then
cannam@126 4065 echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
cannam@126 4066 fi
cannam@126 4067 echo
cannam@126 4068
cannam@126 4069 echo "See any operating system documentation about shared libraries for"
cannam@126 4070 case $host in
cannam@126 4071 solaris2.[6789]|solaris2.1[0-9])
cannam@126 4072 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
cannam@126 4073 echo "pages."
cannam@126 4074 ;;
cannam@126 4075 *)
cannam@126 4076 echo "more information, such as the ld(1) and ld.so(8) manual pages."
cannam@126 4077 ;;
cannam@126 4078 esac
cannam@126 4079 echo "----------------------------------------------------------------------"
cannam@126 4080 fi
cannam@126 4081 exit $EXIT_SUCCESS
cannam@126 4082 }
cannam@126 4083
cannam@126 4084 test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
cannam@126 4085
cannam@126 4086
cannam@126 4087 # func_mode_install arg...
cannam@126 4088 func_mode_install ()
cannam@126 4089 {
cannam@126 4090 $debug_cmd
cannam@126 4091
cannam@126 4092 # There may be an optional sh(1) argument at the beginning of
cannam@126 4093 # install_prog (especially on Windows NT).
cannam@126 4094 if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
cannam@126 4095 # Allow the use of GNU shtool's install command.
cannam@126 4096 case $nonopt in *shtool*) :;; *) false;; esac
cannam@126 4097 then
cannam@126 4098 # Aesthetically quote it.
cannam@126 4099 func_quote_for_eval "$nonopt"
cannam@126 4100 install_prog="$func_quote_for_eval_result "
cannam@126 4101 arg=$1
cannam@126 4102 shift
cannam@126 4103 else
cannam@126 4104 install_prog=
cannam@126 4105 arg=$nonopt
cannam@126 4106 fi
cannam@126 4107
cannam@126 4108 # The real first argument should be the name of the installation program.
cannam@126 4109 # Aesthetically quote it.
cannam@126 4110 func_quote_for_eval "$arg"
cannam@126 4111 func_append install_prog "$func_quote_for_eval_result"
cannam@126 4112 install_shared_prog=$install_prog
cannam@126 4113 case " $install_prog " in
cannam@126 4114 *[\\\ /]cp\ *) install_cp=: ;;
cannam@126 4115 *) install_cp=false ;;
cannam@126 4116 esac
cannam@126 4117
cannam@126 4118 # We need to accept at least all the BSD install flags.
cannam@126 4119 dest=
cannam@126 4120 files=
cannam@126 4121 opts=
cannam@126 4122 prev=
cannam@126 4123 install_type=
cannam@126 4124 isdir=false
cannam@126 4125 stripme=
cannam@126 4126 no_mode=:
cannam@126 4127 for arg
cannam@126 4128 do
cannam@126 4129 arg2=
cannam@126 4130 if test -n "$dest"; then
cannam@126 4131 func_append files " $dest"
cannam@126 4132 dest=$arg
cannam@126 4133 continue
cannam@126 4134 fi
cannam@126 4135
cannam@126 4136 case $arg in
cannam@126 4137 -d) isdir=: ;;
cannam@126 4138 -f)
cannam@126 4139 if $install_cp; then :; else
cannam@126 4140 prev=$arg
cannam@126 4141 fi
cannam@126 4142 ;;
cannam@126 4143 -g | -m | -o)
cannam@126 4144 prev=$arg
cannam@126 4145 ;;
cannam@126 4146 -s)
cannam@126 4147 stripme=" -s"
cannam@126 4148 continue
cannam@126 4149 ;;
cannam@126 4150 -*)
cannam@126 4151 ;;
cannam@126 4152 *)
cannam@126 4153 # If the previous option needed an argument, then skip it.
cannam@126 4154 if test -n "$prev"; then
cannam@126 4155 if test X-m = "X$prev" && test -n "$install_override_mode"; then
cannam@126 4156 arg2=$install_override_mode
cannam@126 4157 no_mode=false
cannam@126 4158 fi
cannam@126 4159 prev=
cannam@126 4160 else
cannam@126 4161 dest=$arg
cannam@126 4162 continue
cannam@126 4163 fi
cannam@126 4164 ;;
cannam@126 4165 esac
cannam@126 4166
cannam@126 4167 # Aesthetically quote the argument.
cannam@126 4168 func_quote_for_eval "$arg"
cannam@126 4169 func_append install_prog " $func_quote_for_eval_result"
cannam@126 4170 if test -n "$arg2"; then
cannam@126 4171 func_quote_for_eval "$arg2"
cannam@126 4172 fi
cannam@126 4173 func_append install_shared_prog " $func_quote_for_eval_result"
cannam@126 4174 done
cannam@126 4175
cannam@126 4176 test -z "$install_prog" && \
cannam@126 4177 func_fatal_help "you must specify an install program"
cannam@126 4178
cannam@126 4179 test -n "$prev" && \
cannam@126 4180 func_fatal_help "the '$prev' option requires an argument"
cannam@126 4181
cannam@126 4182 if test -n "$install_override_mode" && $no_mode; then
cannam@126 4183 if $install_cp; then :; else
cannam@126 4184 func_quote_for_eval "$install_override_mode"
cannam@126 4185 func_append install_shared_prog " -m $func_quote_for_eval_result"
cannam@126 4186 fi
cannam@126 4187 fi
cannam@126 4188
cannam@126 4189 if test -z "$files"; then
cannam@126 4190 if test -z "$dest"; then
cannam@126 4191 func_fatal_help "no file or destination specified"
cannam@126 4192 else
cannam@126 4193 func_fatal_help "you must specify a destination"
cannam@126 4194 fi
cannam@126 4195 fi
cannam@126 4196
cannam@126 4197 # Strip any trailing slash from the destination.
cannam@126 4198 func_stripname '' '/' "$dest"
cannam@126 4199 dest=$func_stripname_result
cannam@126 4200
cannam@126 4201 # Check to see that the destination is a directory.
cannam@126 4202 test -d "$dest" && isdir=:
cannam@126 4203 if $isdir; then
cannam@126 4204 destdir=$dest
cannam@126 4205 destname=
cannam@126 4206 else
cannam@126 4207 func_dirname_and_basename "$dest" "" "."
cannam@126 4208 destdir=$func_dirname_result
cannam@126 4209 destname=$func_basename_result
cannam@126 4210
cannam@126 4211 # Not a directory, so check to see that there is only one file specified.
cannam@126 4212 set dummy $files; shift
cannam@126 4213 test "$#" -gt 1 && \
cannam@126 4214 func_fatal_help "'$dest' is not a directory"
cannam@126 4215 fi
cannam@126 4216 case $destdir in
cannam@126 4217 [\\/]* | [A-Za-z]:[\\/]*) ;;
cannam@126 4218 *)
cannam@126 4219 for file in $files; do
cannam@126 4220 case $file in
cannam@126 4221 *.lo) ;;
cannam@126 4222 *)
cannam@126 4223 func_fatal_help "'$destdir' must be an absolute directory name"
cannam@126 4224 ;;
cannam@126 4225 esac
cannam@126 4226 done
cannam@126 4227 ;;
cannam@126 4228 esac
cannam@126 4229
cannam@126 4230 # This variable tells wrapper scripts just to set variables rather
cannam@126 4231 # than running their programs.
cannam@126 4232 libtool_install_magic=$magic
cannam@126 4233
cannam@126 4234 staticlibs=
cannam@126 4235 future_libdirs=
cannam@126 4236 current_libdirs=
cannam@126 4237 for file in $files; do
cannam@126 4238
cannam@126 4239 # Do each installation.
cannam@126 4240 case $file in
cannam@126 4241 *.$libext)
cannam@126 4242 # Do the static libraries later.
cannam@126 4243 func_append staticlibs " $file"
cannam@126 4244 ;;
cannam@126 4245
cannam@126 4246 *.la)
cannam@126 4247 func_resolve_sysroot "$file"
cannam@126 4248 file=$func_resolve_sysroot_result
cannam@126 4249
cannam@126 4250 # Check to see that this really is a libtool archive.
cannam@126 4251 func_lalib_unsafe_p "$file" \
cannam@126 4252 || func_fatal_help "'$file' is not a valid libtool archive"
cannam@126 4253
cannam@126 4254 library_names=
cannam@126 4255 old_library=
cannam@126 4256 relink_command=
cannam@126 4257 func_source "$file"
cannam@126 4258
cannam@126 4259 # Add the libdir to current_libdirs if it is the destination.
cannam@126 4260 if test "X$destdir" = "X$libdir"; then
cannam@126 4261 case "$current_libdirs " in
cannam@126 4262 *" $libdir "*) ;;
cannam@126 4263 *) func_append current_libdirs " $libdir" ;;
cannam@126 4264 esac
cannam@126 4265 else
cannam@126 4266 # Note the libdir as a future libdir.
cannam@126 4267 case "$future_libdirs " in
cannam@126 4268 *" $libdir "*) ;;
cannam@126 4269 *) func_append future_libdirs " $libdir" ;;
cannam@126 4270 esac
cannam@126 4271 fi
cannam@126 4272
cannam@126 4273 func_dirname "$file" "/" ""
cannam@126 4274 dir=$func_dirname_result
cannam@126 4275 func_append dir "$objdir"
cannam@126 4276
cannam@126 4277 if test -n "$relink_command"; then
cannam@126 4278 # Determine the prefix the user has applied to our future dir.
cannam@126 4279 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
cannam@126 4280
cannam@126 4281 # Don't allow the user to place us outside of our expected
cannam@126 4282 # location b/c this prevents finding dependent libraries that
cannam@126 4283 # are installed to the same prefix.
cannam@126 4284 # At present, this check doesn't affect windows .dll's that
cannam@126 4285 # are installed into $libdir/../bin (currently, that works fine)
cannam@126 4286 # but it's something to keep an eye on.
cannam@126 4287 test "$inst_prefix_dir" = "$destdir" && \
cannam@126 4288 func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
cannam@126 4289
cannam@126 4290 if test -n "$inst_prefix_dir"; then
cannam@126 4291 # Stick the inst_prefix_dir data into the link command.
cannam@126 4292 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
cannam@126 4293 else
cannam@126 4294 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
cannam@126 4295 fi
cannam@126 4296
cannam@126 4297 func_warning "relinking '$file'"
cannam@126 4298 func_show_eval "$relink_command" \
cannam@126 4299 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
cannam@126 4300 fi
cannam@126 4301
cannam@126 4302 # See the names of the shared library.
cannam@126 4303 set dummy $library_names; shift
cannam@126 4304 if test -n "$1"; then
cannam@126 4305 realname=$1
cannam@126 4306 shift
cannam@126 4307
cannam@126 4308 srcname=$realname
cannam@126 4309 test -n "$relink_command" && srcname=${realname}T
cannam@126 4310
cannam@126 4311 # Install the shared library and build the symlinks.
cannam@126 4312 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
cannam@126 4313 'exit $?'
cannam@126 4314 tstripme=$stripme
cannam@126 4315 case $host_os in
cannam@126 4316 cygwin* | mingw* | pw32* | cegcc*)
cannam@126 4317 case $realname in
cannam@126 4318 *.dll.a)
cannam@126 4319 tstripme=
cannam@126 4320 ;;
cannam@126 4321 esac
cannam@126 4322 ;;
cannam@126 4323 os2*)
cannam@126 4324 case $realname in
cannam@126 4325 *_dll.a)
cannam@126 4326 tstripme=
cannam@126 4327 ;;
cannam@126 4328 esac
cannam@126 4329 ;;
cannam@126 4330 esac
cannam@126 4331 if test -n "$tstripme" && test -n "$striplib"; then
cannam@126 4332 func_show_eval "$striplib $destdir/$realname" 'exit $?'
cannam@126 4333 fi
cannam@126 4334
cannam@126 4335 if test "$#" -gt 0; then
cannam@126 4336 # Delete the old symlinks, and create new ones.
cannam@126 4337 # Try 'ln -sf' first, because the 'ln' binary might depend on
cannam@126 4338 # the symlink we replace! Solaris /bin/ln does not understand -f,
cannam@126 4339 # so we also need to try rm && ln -s.
cannam@126 4340 for linkname
cannam@126 4341 do
cannam@126 4342 test "$linkname" != "$realname" \
cannam@126 4343 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
cannam@126 4344 done
cannam@126 4345 fi
cannam@126 4346
cannam@126 4347 # Do each command in the postinstall commands.
cannam@126 4348 lib=$destdir/$realname
cannam@126 4349 func_execute_cmds "$postinstall_cmds" 'exit $?'
cannam@126 4350 fi
cannam@126 4351
cannam@126 4352 # Install the pseudo-library for information purposes.
cannam@126 4353 func_basename "$file"
cannam@126 4354 name=$func_basename_result
cannam@126 4355 instname=$dir/${name}i
cannam@126 4356 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
cannam@126 4357
cannam@126 4358 # Maybe install the static library, too.
cannam@126 4359 test -n "$old_library" && func_append staticlibs " $dir/$old_library"
cannam@126 4360 ;;
cannam@126 4361
cannam@126 4362 *.lo)
cannam@126 4363 # Install (i.e. copy) a libtool object.
cannam@126 4364
cannam@126 4365 # Figure out destination file name, if it wasn't already specified.
cannam@126 4366 if test -n "$destname"; then
cannam@126 4367 destfile=$destdir/$destname
cannam@126 4368 else
cannam@126 4369 func_basename "$file"
cannam@126 4370 destfile=$func_basename_result
cannam@126 4371 destfile=$destdir/$destfile
cannam@126 4372 fi
cannam@126 4373
cannam@126 4374 # Deduce the name of the destination old-style object file.
cannam@126 4375 case $destfile in
cannam@126 4376 *.lo)
cannam@126 4377 func_lo2o "$destfile"
cannam@126 4378 staticdest=$func_lo2o_result
cannam@126 4379 ;;
cannam@126 4380 *.$objext)
cannam@126 4381 staticdest=$destfile
cannam@126 4382 destfile=
cannam@126 4383 ;;
cannam@126 4384 *)
cannam@126 4385 func_fatal_help "cannot copy a libtool object to '$destfile'"
cannam@126 4386 ;;
cannam@126 4387 esac
cannam@126 4388
cannam@126 4389 # Install the libtool object if requested.
cannam@126 4390 test -n "$destfile" && \
cannam@126 4391 func_show_eval "$install_prog $file $destfile" 'exit $?'
cannam@126 4392
cannam@126 4393 # Install the old object if enabled.
cannam@126 4394 if test yes = "$build_old_libs"; then
cannam@126 4395 # Deduce the name of the old-style object file.
cannam@126 4396 func_lo2o "$file"
cannam@126 4397 staticobj=$func_lo2o_result
cannam@126 4398 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
cannam@126 4399 fi
cannam@126 4400 exit $EXIT_SUCCESS
cannam@126 4401 ;;
cannam@126 4402
cannam@126 4403 *)
cannam@126 4404 # Figure out destination file name, if it wasn't already specified.
cannam@126 4405 if test -n "$destname"; then
cannam@126 4406 destfile=$destdir/$destname
cannam@126 4407 else
cannam@126 4408 func_basename "$file"
cannam@126 4409 destfile=$func_basename_result
cannam@126 4410 destfile=$destdir/$destfile
cannam@126 4411 fi
cannam@126 4412
cannam@126 4413 # If the file is missing, and there is a .exe on the end, strip it
cannam@126 4414 # because it is most likely a libtool script we actually want to
cannam@126 4415 # install
cannam@126 4416 stripped_ext=
cannam@126 4417 case $file in
cannam@126 4418 *.exe)
cannam@126 4419 if test ! -f "$file"; then
cannam@126 4420 func_stripname '' '.exe' "$file"
cannam@126 4421 file=$func_stripname_result
cannam@126 4422 stripped_ext=.exe
cannam@126 4423 fi
cannam@126 4424 ;;
cannam@126 4425 esac
cannam@126 4426
cannam@126 4427 # Do a test to see if this is really a libtool program.
cannam@126 4428 case $host in
cannam@126 4429 *cygwin* | *mingw*)
cannam@126 4430 if func_ltwrapper_executable_p "$file"; then
cannam@126 4431 func_ltwrapper_scriptname "$file"
cannam@126 4432 wrapper=$func_ltwrapper_scriptname_result
cannam@126 4433 else
cannam@126 4434 func_stripname '' '.exe' "$file"
cannam@126 4435 wrapper=$func_stripname_result
cannam@126 4436 fi
cannam@126 4437 ;;
cannam@126 4438 *)
cannam@126 4439 wrapper=$file
cannam@126 4440 ;;
cannam@126 4441 esac
cannam@126 4442 if func_ltwrapper_script_p "$wrapper"; then
cannam@126 4443 notinst_deplibs=
cannam@126 4444 relink_command=
cannam@126 4445
cannam@126 4446 func_source "$wrapper"
cannam@126 4447
cannam@126 4448 # Check the variables that should have been set.
cannam@126 4449 test -z "$generated_by_libtool_version" && \
cannam@126 4450 func_fatal_error "invalid libtool wrapper script '$wrapper'"
cannam@126 4451
cannam@126 4452 finalize=:
cannam@126 4453 for lib in $notinst_deplibs; do
cannam@126 4454 # Check to see that each library is installed.
cannam@126 4455 libdir=
cannam@126 4456 if test -f "$lib"; then
cannam@126 4457 func_source "$lib"
cannam@126 4458 fi
cannam@126 4459 libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
cannam@126 4460 if test -n "$libdir" && test ! -f "$libfile"; then
cannam@126 4461 func_warning "'$lib' has not been installed in '$libdir'"
cannam@126 4462 finalize=false
cannam@126 4463 fi
cannam@126 4464 done
cannam@126 4465
cannam@126 4466 relink_command=
cannam@126 4467 func_source "$wrapper"
cannam@126 4468
cannam@126 4469 outputname=
cannam@126 4470 if test no = "$fast_install" && test -n "$relink_command"; then
cannam@126 4471 $opt_dry_run || {
cannam@126 4472 if $finalize; then
cannam@126 4473 tmpdir=`func_mktempdir`
cannam@126 4474 func_basename "$file$stripped_ext"
cannam@126 4475 file=$func_basename_result
cannam@126 4476 outputname=$tmpdir/$file
cannam@126 4477 # Replace the output file specification.
cannam@126 4478 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
cannam@126 4479
cannam@126 4480 $opt_quiet || {
cannam@126 4481 func_quote_for_expand "$relink_command"
cannam@126 4482 eval "func_echo $func_quote_for_expand_result"
cannam@126 4483 }
cannam@126 4484 if eval "$relink_command"; then :
cannam@126 4485 else
cannam@126 4486 func_error "error: relink '$file' with the above command before installing it"
cannam@126 4487 $opt_dry_run || ${RM}r "$tmpdir"
cannam@126 4488 continue
cannam@126 4489 fi
cannam@126 4490 file=$outputname
cannam@126 4491 else
cannam@126 4492 func_warning "cannot relink '$file'"
cannam@126 4493 fi
cannam@126 4494 }
cannam@126 4495 else
cannam@126 4496 # Install the binary that we compiled earlier.
cannam@126 4497 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
cannam@126 4498 fi
cannam@126 4499 fi
cannam@126 4500
cannam@126 4501 # remove .exe since cygwin /usr/bin/install will append another
cannam@126 4502 # one anyway
cannam@126 4503 case $install_prog,$host in
cannam@126 4504 */usr/bin/install*,*cygwin*)
cannam@126 4505 case $file:$destfile in
cannam@126 4506 *.exe:*.exe)
cannam@126 4507 # this is ok
cannam@126 4508 ;;
cannam@126 4509 *.exe:*)
cannam@126 4510 destfile=$destfile.exe
cannam@126 4511 ;;
cannam@126 4512 *:*.exe)
cannam@126 4513 func_stripname '' '.exe' "$destfile"
cannam@126 4514 destfile=$func_stripname_result
cannam@126 4515 ;;
cannam@126 4516 esac
cannam@126 4517 ;;
cannam@126 4518 esac
cannam@126 4519 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
cannam@126 4520 $opt_dry_run || if test -n "$outputname"; then
cannam@126 4521 ${RM}r "$tmpdir"
cannam@126 4522 fi
cannam@126 4523 ;;
cannam@126 4524 esac
cannam@126 4525 done
cannam@126 4526
cannam@126 4527 for file in $staticlibs; do
cannam@126 4528 func_basename "$file"
cannam@126 4529 name=$func_basename_result
cannam@126 4530
cannam@126 4531 # Set up the ranlib parameters.
cannam@126 4532 oldlib=$destdir/$name
cannam@126 4533 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
cannam@126 4534 tool_oldlib=$func_to_tool_file_result
cannam@126 4535
cannam@126 4536 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
cannam@126 4537
cannam@126 4538 if test -n "$stripme" && test -n "$old_striplib"; then
cannam@126 4539 func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
cannam@126 4540 fi
cannam@126 4541
cannam@126 4542 # Do each command in the postinstall commands.
cannam@126 4543 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
cannam@126 4544 done
cannam@126 4545
cannam@126 4546 test -n "$future_libdirs" && \
cannam@126 4547 func_warning "remember to run '$progname --finish$future_libdirs'"
cannam@126 4548
cannam@126 4549 if test -n "$current_libdirs"; then
cannam@126 4550 # Maybe just do a dry run.
cannam@126 4551 $opt_dry_run && current_libdirs=" -n$current_libdirs"
cannam@126 4552 exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
cannam@126 4553 else
cannam@126 4554 exit $EXIT_SUCCESS
cannam@126 4555 fi
cannam@126 4556 }
cannam@126 4557
cannam@126 4558 test install = "$opt_mode" && func_mode_install ${1+"$@"}
cannam@126 4559
cannam@126 4560
cannam@126 4561 # func_generate_dlsyms outputname originator pic_p
cannam@126 4562 # Extract symbols from dlprefiles and create ${outputname}S.o with
cannam@126 4563 # a dlpreopen symbol table.
cannam@126 4564 func_generate_dlsyms ()
cannam@126 4565 {
cannam@126 4566 $debug_cmd
cannam@126 4567
cannam@126 4568 my_outputname=$1
cannam@126 4569 my_originator=$2
cannam@126 4570 my_pic_p=${3-false}
cannam@126 4571 my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
cannam@126 4572 my_dlsyms=
cannam@126 4573
cannam@126 4574 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
cannam@126 4575 if test -n "$NM" && test -n "$global_symbol_pipe"; then
cannam@126 4576 my_dlsyms=${my_outputname}S.c
cannam@126 4577 else
cannam@126 4578 func_error "not configured to extract global symbols from dlpreopened files"
cannam@126 4579 fi
cannam@126 4580 fi
cannam@126 4581
cannam@126 4582 if test -n "$my_dlsyms"; then
cannam@126 4583 case $my_dlsyms in
cannam@126 4584 "") ;;
cannam@126 4585 *.c)
cannam@126 4586 # Discover the nlist of each of the dlfiles.
cannam@126 4587 nlist=$output_objdir/$my_outputname.nm
cannam@126 4588
cannam@126 4589 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
cannam@126 4590
cannam@126 4591 # Parse the name list into a source file.
cannam@126 4592 func_verbose "creating $output_objdir/$my_dlsyms"
cannam@126 4593
cannam@126 4594 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
cannam@126 4595 /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
cannam@126 4596 /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
cannam@126 4597
cannam@126 4598 #ifdef __cplusplus
cannam@126 4599 extern \"C\" {
cannam@126 4600 #endif
cannam@126 4601
cannam@126 4602 #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
cannam@126 4603 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
cannam@126 4604 #endif
cannam@126 4605
cannam@126 4606 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
cannam@126 4607 #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
cannam@126 4608 /* DATA imports from DLLs on WIN32 can't be const, because runtime
cannam@126 4609 relocations are performed -- see ld's documentation on pseudo-relocs. */
cannam@126 4610 # define LT_DLSYM_CONST
cannam@126 4611 #elif defined __osf__
cannam@126 4612 /* This system does not cope well with relocations in const data. */
cannam@126 4613 # define LT_DLSYM_CONST
cannam@126 4614 #else
cannam@126 4615 # define LT_DLSYM_CONST const
cannam@126 4616 #endif
cannam@126 4617
cannam@126 4618 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
cannam@126 4619
cannam@126 4620 /* External symbol declarations for the compiler. */\
cannam@126 4621 "
cannam@126 4622
cannam@126 4623 if test yes = "$dlself"; then
cannam@126 4624 func_verbose "generating symbol list for '$output'"
cannam@126 4625
cannam@126 4626 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
cannam@126 4627
cannam@126 4628 # Add our own program objects to the symbol list.
cannam@126 4629 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
cannam@126 4630 for progfile in $progfiles; do
cannam@126 4631 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
cannam@126 4632 func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
cannam@126 4633 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
cannam@126 4634 done
cannam@126 4635
cannam@126 4636 if test -n "$exclude_expsyms"; then
cannam@126 4637 $opt_dry_run || {
cannam@126 4638 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
cannam@126 4639 eval '$MV "$nlist"T "$nlist"'
cannam@126 4640 }
cannam@126 4641 fi
cannam@126 4642
cannam@126 4643 if test -n "$export_symbols_regex"; then
cannam@126 4644 $opt_dry_run || {
cannam@126 4645 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
cannam@126 4646 eval '$MV "$nlist"T "$nlist"'
cannam@126 4647 }
cannam@126 4648 fi
cannam@126 4649
cannam@126 4650 # Prepare the list of exported symbols
cannam@126 4651 if test -z "$export_symbols"; then
cannam@126 4652 export_symbols=$output_objdir/$outputname.exp
cannam@126 4653 $opt_dry_run || {
cannam@126 4654 $RM $export_symbols
cannam@126 4655 eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
cannam@126 4656 case $host in
cannam@126 4657 *cygwin* | *mingw* | *cegcc* )
cannam@126 4658 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
cannam@126 4659 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
cannam@126 4660 ;;
cannam@126 4661 esac
cannam@126 4662 }
cannam@126 4663 else
cannam@126 4664 $opt_dry_run || {
cannam@126 4665 eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
cannam@126 4666 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
cannam@126 4667 eval '$MV "$nlist"T "$nlist"'
cannam@126 4668 case $host in
cannam@126 4669 *cygwin* | *mingw* | *cegcc* )
cannam@126 4670 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
cannam@126 4671 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
cannam@126 4672 ;;
cannam@126 4673 esac
cannam@126 4674 }
cannam@126 4675 fi
cannam@126 4676 fi
cannam@126 4677
cannam@126 4678 for dlprefile in $dlprefiles; do
cannam@126 4679 func_verbose "extracting global C symbols from '$dlprefile'"
cannam@126 4680 func_basename "$dlprefile"
cannam@126 4681 name=$func_basename_result
cannam@126 4682 case $host in
cannam@126 4683 *cygwin* | *mingw* | *cegcc* )
cannam@126 4684 # if an import library, we need to obtain dlname
cannam@126 4685 if func_win32_import_lib_p "$dlprefile"; then
cannam@126 4686 func_tr_sh "$dlprefile"
cannam@126 4687 eval "curr_lafile=\$libfile_$func_tr_sh_result"
cannam@126 4688 dlprefile_dlbasename=
cannam@126 4689 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
cannam@126 4690 # Use subshell, to avoid clobbering current variable values
cannam@126 4691 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
cannam@126 4692 if test -n "$dlprefile_dlname"; then
cannam@126 4693 func_basename "$dlprefile_dlname"
cannam@126 4694 dlprefile_dlbasename=$func_basename_result
cannam@126 4695 else
cannam@126 4696 # no lafile. user explicitly requested -dlpreopen <import library>.
cannam@126 4697 $sharedlib_from_linklib_cmd "$dlprefile"
cannam@126 4698 dlprefile_dlbasename=$sharedlib_from_linklib_result
cannam@126 4699 fi
cannam@126 4700 fi
cannam@126 4701 $opt_dry_run || {
cannam@126 4702 if test -n "$dlprefile_dlbasename"; then
cannam@126 4703 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
cannam@126 4704 else
cannam@126 4705 func_warning "Could not compute DLL name from $name"
cannam@126 4706 eval '$ECHO ": $name " >> "$nlist"'
cannam@126 4707 fi
cannam@126 4708 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
cannam@126 4709 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
cannam@126 4710 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
cannam@126 4711 }
cannam@126 4712 else # not an import lib
cannam@126 4713 $opt_dry_run || {
cannam@126 4714 eval '$ECHO ": $name " >> "$nlist"'
cannam@126 4715 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
cannam@126 4716 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
cannam@126 4717 }
cannam@126 4718 fi
cannam@126 4719 ;;
cannam@126 4720 *)
cannam@126 4721 $opt_dry_run || {
cannam@126 4722 eval '$ECHO ": $name " >> "$nlist"'
cannam@126 4723 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
cannam@126 4724 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
cannam@126 4725 }
cannam@126 4726 ;;
cannam@126 4727 esac
cannam@126 4728 done
cannam@126 4729
cannam@126 4730 $opt_dry_run || {
cannam@126 4731 # Make sure we have at least an empty file.
cannam@126 4732 test -f "$nlist" || : > "$nlist"
cannam@126 4733
cannam@126 4734 if test -n "$exclude_expsyms"; then
cannam@126 4735 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
cannam@126 4736 $MV "$nlist"T "$nlist"
cannam@126 4737 fi
cannam@126 4738
cannam@126 4739 # Try sorting and uniquifying the output.
cannam@126 4740 if $GREP -v "^: " < "$nlist" |
cannam@126 4741 if sort -k 3 </dev/null >/dev/null 2>&1; then
cannam@126 4742 sort -k 3
cannam@126 4743 else
cannam@126 4744 sort +2
cannam@126 4745 fi |
cannam@126 4746 uniq > "$nlist"S; then
cannam@126 4747 :
cannam@126 4748 else
cannam@126 4749 $GREP -v "^: " < "$nlist" > "$nlist"S
cannam@126 4750 fi
cannam@126 4751
cannam@126 4752 if test -f "$nlist"S; then
cannam@126 4753 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
cannam@126 4754 else
cannam@126 4755 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
cannam@126 4756 fi
cannam@126 4757
cannam@126 4758 func_show_eval '$RM "${nlist}I"'
cannam@126 4759 if test -n "$global_symbol_to_import"; then
cannam@126 4760 eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
cannam@126 4761 fi
cannam@126 4762
cannam@126 4763 echo >> "$output_objdir/$my_dlsyms" "\
cannam@126 4764
cannam@126 4765 /* The mapping between symbol names and symbols. */
cannam@126 4766 typedef struct {
cannam@126 4767 const char *name;
cannam@126 4768 void *address;
cannam@126 4769 } lt_dlsymlist;
cannam@126 4770 extern LT_DLSYM_CONST lt_dlsymlist
cannam@126 4771 lt_${my_prefix}_LTX_preloaded_symbols[];\
cannam@126 4772 "
cannam@126 4773
cannam@126 4774 if test -s "$nlist"I; then
cannam@126 4775 echo >> "$output_objdir/$my_dlsyms" "\
cannam@126 4776 static void lt_syminit(void)
cannam@126 4777 {
cannam@126 4778 LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
cannam@126 4779 for (; symbol->name; ++symbol)
cannam@126 4780 {"
cannam@126 4781 $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
cannam@126 4782 echo >> "$output_objdir/$my_dlsyms" "\
cannam@126 4783 }
cannam@126 4784 }"
cannam@126 4785 fi
cannam@126 4786 echo >> "$output_objdir/$my_dlsyms" "\
cannam@126 4787 LT_DLSYM_CONST lt_dlsymlist
cannam@126 4788 lt_${my_prefix}_LTX_preloaded_symbols[] =
cannam@126 4789 { {\"$my_originator\", (void *) 0},"
cannam@126 4790
cannam@126 4791 if test -s "$nlist"I; then
cannam@126 4792 echo >> "$output_objdir/$my_dlsyms" "\
cannam@126 4793 {\"@INIT@\", (void *) &lt_syminit},"
cannam@126 4794 fi
cannam@126 4795
cannam@126 4796 case $need_lib_prefix in
cannam@126 4797 no)
cannam@126 4798 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
cannam@126 4799 ;;
cannam@126 4800 *)
cannam@126 4801 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
cannam@126 4802 ;;
cannam@126 4803 esac
cannam@126 4804 echo >> "$output_objdir/$my_dlsyms" "\
cannam@126 4805 {0, (void *) 0}
cannam@126 4806 };
cannam@126 4807
cannam@126 4808 /* This works around a problem in FreeBSD linker */
cannam@126 4809 #ifdef FREEBSD_WORKAROUND
cannam@126 4810 static const void *lt_preloaded_setup() {
cannam@126 4811 return lt_${my_prefix}_LTX_preloaded_symbols;
cannam@126 4812 }
cannam@126 4813 #endif
cannam@126 4814
cannam@126 4815 #ifdef __cplusplus
cannam@126 4816 }
cannam@126 4817 #endif\
cannam@126 4818 "
cannam@126 4819 } # !$opt_dry_run
cannam@126 4820
cannam@126 4821 pic_flag_for_symtable=
cannam@126 4822 case "$compile_command " in
cannam@126 4823 *" -static "*) ;;
cannam@126 4824 *)
cannam@126 4825 case $host in
cannam@126 4826 # compiling the symbol table file with pic_flag works around
cannam@126 4827 # a FreeBSD bug that causes programs to crash when -lm is
cannam@126 4828 # linked before any other PIC object. But we must not use
cannam@126 4829 # pic_flag when linking with -static. The problem exists in
cannam@126 4830 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
cannam@126 4831 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
cannam@126 4832 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
cannam@126 4833 *-*-hpux*)
cannam@126 4834 pic_flag_for_symtable=" $pic_flag" ;;
cannam@126 4835 *)
cannam@126 4836 $my_pic_p && pic_flag_for_symtable=" $pic_flag"
cannam@126 4837 ;;
cannam@126 4838 esac
cannam@126 4839 ;;
cannam@126 4840 esac
cannam@126 4841 symtab_cflags=
cannam@126 4842 for arg in $LTCFLAGS; do
cannam@126 4843 case $arg in
cannam@126 4844 -pie | -fpie | -fPIE) ;;
cannam@126 4845 *) func_append symtab_cflags " $arg" ;;
cannam@126 4846 esac
cannam@126 4847 done
cannam@126 4848
cannam@126 4849 # Now compile the dynamic symbol file.
cannam@126 4850 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
cannam@126 4851
cannam@126 4852 # Clean up the generated files.
cannam@126 4853 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
cannam@126 4854
cannam@126 4855 # Transform the symbol file into the correct name.
cannam@126 4856 symfileobj=$output_objdir/${my_outputname}S.$objext
cannam@126 4857 case $host in
cannam@126 4858 *cygwin* | *mingw* | *cegcc* )
cannam@126 4859 if test -f "$output_objdir/$my_outputname.def"; then
cannam@126 4860 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
cannam@126 4861 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
cannam@126 4862 else
cannam@126 4863 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
cannam@126 4864 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
cannam@126 4865 fi
cannam@126 4866 ;;
cannam@126 4867 *)
cannam@126 4868 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
cannam@126 4869 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
cannam@126 4870 ;;
cannam@126 4871 esac
cannam@126 4872 ;;
cannam@126 4873 *)
cannam@126 4874 func_fatal_error "unknown suffix for '$my_dlsyms'"
cannam@126 4875 ;;
cannam@126 4876 esac
cannam@126 4877 else
cannam@126 4878 # We keep going just in case the user didn't refer to
cannam@126 4879 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
cannam@126 4880 # really was required.
cannam@126 4881
cannam@126 4882 # Nullify the symbol file.
cannam@126 4883 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
cannam@126 4884 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
cannam@126 4885 fi
cannam@126 4886 }
cannam@126 4887
cannam@126 4888 # func_cygming_gnu_implib_p ARG
cannam@126 4889 # This predicate returns with zero status (TRUE) if
cannam@126 4890 # ARG is a GNU/binutils-style import library. Returns
cannam@126 4891 # with nonzero status (FALSE) otherwise.
cannam@126 4892 func_cygming_gnu_implib_p ()
cannam@126 4893 {
cannam@126 4894 $debug_cmd
cannam@126 4895
cannam@126 4896 func_to_tool_file "$1" func_convert_file_msys_to_w32
cannam@126 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@126 4898 test -n "$func_cygming_gnu_implib_tmp"
cannam@126 4899 }
cannam@126 4900
cannam@126 4901 # func_cygming_ms_implib_p ARG
cannam@126 4902 # This predicate returns with zero status (TRUE) if
cannam@126 4903 # ARG is an MS-style import library. Returns
cannam@126 4904 # with nonzero status (FALSE) otherwise.
cannam@126 4905 func_cygming_ms_implib_p ()
cannam@126 4906 {
cannam@126 4907 $debug_cmd
cannam@126 4908
cannam@126 4909 func_to_tool_file "$1" func_convert_file_msys_to_w32
cannam@126 4910 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
cannam@126 4911 test -n "$func_cygming_ms_implib_tmp"
cannam@126 4912 }
cannam@126 4913
cannam@126 4914 # func_win32_libid arg
cannam@126 4915 # return the library type of file 'arg'
cannam@126 4916 #
cannam@126 4917 # Need a lot of goo to handle *both* DLLs and import libs
cannam@126 4918 # Has to be a shell function in order to 'eat' the argument
cannam@126 4919 # that is supplied when $file_magic_command is called.
cannam@126 4920 # Despite the name, also deal with 64 bit binaries.
cannam@126 4921 func_win32_libid ()
cannam@126 4922 {
cannam@126 4923 $debug_cmd
cannam@126 4924
cannam@126 4925 win32_libid_type=unknown
cannam@126 4926 win32_fileres=`file -L $1 2>/dev/null`
cannam@126 4927 case $win32_fileres in
cannam@126 4928 *ar\ archive\ import\ library*) # definitely import
cannam@126 4929 win32_libid_type="x86 archive import"
cannam@126 4930 ;;
cannam@126 4931 *ar\ archive*) # could be an import, or static
cannam@126 4932 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
cannam@126 4933 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
cannam@126 4934 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
cannam@126 4935 case $nm_interface in
cannam@126 4936 "MS dumpbin")
cannam@126 4937 if func_cygming_ms_implib_p "$1" ||
cannam@126 4938 func_cygming_gnu_implib_p "$1"
cannam@126 4939 then
cannam@126 4940 win32_nmres=import
cannam@126 4941 else
cannam@126 4942 win32_nmres=
cannam@126 4943 fi
cannam@126 4944 ;;
cannam@126 4945 *)
cannam@126 4946 func_to_tool_file "$1" func_convert_file_msys_to_w32
cannam@126 4947 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
cannam@126 4948 $SED -n -e '
cannam@126 4949 1,100{
cannam@126 4950 / I /{
cannam@126 4951 s|.*|import|
cannam@126 4952 p
cannam@126 4953 q
cannam@126 4954 }
cannam@126 4955 }'`
cannam@126 4956 ;;
cannam@126 4957 esac
cannam@126 4958 case $win32_nmres in
cannam@126 4959 import*) win32_libid_type="x86 archive import";;
cannam@126 4960 *) win32_libid_type="x86 archive static";;
cannam@126 4961 esac
cannam@126 4962 fi
cannam@126 4963 ;;
cannam@126 4964 *DLL*)
cannam@126 4965 win32_libid_type="x86 DLL"
cannam@126 4966 ;;
cannam@126 4967 *executable*) # but shell scripts are "executable" too...
cannam@126 4968 case $win32_fileres in
cannam@126 4969 *MS\ Windows\ PE\ Intel*)
cannam@126 4970 win32_libid_type="x86 DLL"
cannam@126 4971 ;;
cannam@126 4972 esac
cannam@126 4973 ;;
cannam@126 4974 esac
cannam@126 4975 $ECHO "$win32_libid_type"
cannam@126 4976 }
cannam@126 4977
cannam@126 4978 # func_cygming_dll_for_implib ARG
cannam@126 4979 #
cannam@126 4980 # Platform-specific function to extract the
cannam@126 4981 # name of the DLL associated with the specified
cannam@126 4982 # import library ARG.
cannam@126 4983 # Invoked by eval'ing the libtool variable
cannam@126 4984 # $sharedlib_from_linklib_cmd
cannam@126 4985 # Result is available in the variable
cannam@126 4986 # $sharedlib_from_linklib_result
cannam@126 4987 func_cygming_dll_for_implib ()
cannam@126 4988 {
cannam@126 4989 $debug_cmd
cannam@126 4990
cannam@126 4991 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
cannam@126 4992 }
cannam@126 4993
cannam@126 4994 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
cannam@126 4995 #
cannam@126 4996 # The is the core of a fallback implementation of a
cannam@126 4997 # platform-specific function to extract the name of the
cannam@126 4998 # DLL associated with the specified import library LIBNAME.
cannam@126 4999 #
cannam@126 5000 # SECTION_NAME is either .idata$6 or .idata$7, depending
cannam@126 5001 # on the platform and compiler that created the implib.
cannam@126 5002 #
cannam@126 5003 # Echos the name of the DLL associated with the
cannam@126 5004 # specified import library.
cannam@126 5005 func_cygming_dll_for_implib_fallback_core ()
cannam@126 5006 {
cannam@126 5007 $debug_cmd
cannam@126 5008
cannam@126 5009 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
cannam@126 5010 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
cannam@126 5011 $SED '/^Contents of section '"$match_literal"':/{
cannam@126 5012 # Place marker at beginning of archive member dllname section
cannam@126 5013 s/.*/====MARK====/
cannam@126 5014 p
cannam@126 5015 d
cannam@126 5016 }
cannam@126 5017 # These lines can sometimes be longer than 43 characters, but
cannam@126 5018 # are always uninteresting
cannam@126 5019 /:[ ]*file format pe[i]\{,1\}-/d
cannam@126 5020 /^In archive [^:]*:/d
cannam@126 5021 # Ensure marker is printed
cannam@126 5022 /^====MARK====/p
cannam@126 5023 # Remove all lines with less than 43 characters
cannam@126 5024 /^.\{43\}/!d
cannam@126 5025 # From remaining lines, remove first 43 characters
cannam@126 5026 s/^.\{43\}//' |
cannam@126 5027 $SED -n '
cannam@126 5028 # Join marker and all lines until next marker into a single line
cannam@126 5029 /^====MARK====/ b para
cannam@126 5030 H
cannam@126 5031 $ b para
cannam@126 5032 b
cannam@126 5033 :para
cannam@126 5034 x
cannam@126 5035 s/\n//g
cannam@126 5036 # Remove the marker
cannam@126 5037 s/^====MARK====//
cannam@126 5038 # Remove trailing dots and whitespace
cannam@126 5039 s/[\. \t]*$//
cannam@126 5040 # Print
cannam@126 5041 /./p' |
cannam@126 5042 # we now have a list, one entry per line, of the stringified
cannam@126 5043 # contents of the appropriate section of all members of the
cannam@126 5044 # archive that possess that section. Heuristic: eliminate
cannam@126 5045 # all those that have a first or second character that is
cannam@126 5046 # a '.' (that is, objdump's representation of an unprintable
cannam@126 5047 # character.) This should work for all archives with less than
cannam@126 5048 # 0x302f exports -- but will fail for DLLs whose name actually
cannam@126 5049 # begins with a literal '.' or a single character followed by
cannam@126 5050 # a '.'.
cannam@126 5051 #
cannam@126 5052 # Of those that remain, print the first one.
cannam@126 5053 $SED -e '/^\./d;/^.\./d;q'
cannam@126 5054 }
cannam@126 5055
cannam@126 5056 # func_cygming_dll_for_implib_fallback ARG
cannam@126 5057 # Platform-specific function to extract the
cannam@126 5058 # name of the DLL associated with the specified
cannam@126 5059 # import library ARG.
cannam@126 5060 #
cannam@126 5061 # This fallback implementation is for use when $DLLTOOL
cannam@126 5062 # does not support the --identify-strict option.
cannam@126 5063 # Invoked by eval'ing the libtool variable
cannam@126 5064 # $sharedlib_from_linklib_cmd
cannam@126 5065 # Result is available in the variable
cannam@126 5066 # $sharedlib_from_linklib_result
cannam@126 5067 func_cygming_dll_for_implib_fallback ()
cannam@126 5068 {
cannam@126 5069 $debug_cmd
cannam@126 5070
cannam@126 5071 if func_cygming_gnu_implib_p "$1"; then
cannam@126 5072 # binutils import library
cannam@126 5073 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
cannam@126 5074 elif func_cygming_ms_implib_p "$1"; then
cannam@126 5075 # ms-generated import library
cannam@126 5076 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
cannam@126 5077 else
cannam@126 5078 # unknown
cannam@126 5079 sharedlib_from_linklib_result=
cannam@126 5080 fi
cannam@126 5081 }
cannam@126 5082
cannam@126 5083
cannam@126 5084 # func_extract_an_archive dir oldlib
cannam@126 5085 func_extract_an_archive ()
cannam@126 5086 {
cannam@126 5087 $debug_cmd
cannam@126 5088
cannam@126 5089 f_ex_an_ar_dir=$1; shift
cannam@126 5090 f_ex_an_ar_oldlib=$1
cannam@126 5091 if test yes = "$lock_old_archive_extraction"; then
cannam@126 5092 lockfile=$f_ex_an_ar_oldlib.lock
cannam@126 5093 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
cannam@126 5094 func_echo "Waiting for $lockfile to be removed"
cannam@126 5095 sleep 2
cannam@126 5096 done
cannam@126 5097 fi
cannam@126 5098 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
cannam@126 5099 'stat=$?; rm -f "$lockfile"; exit $stat'
cannam@126 5100 if test yes = "$lock_old_archive_extraction"; then
cannam@126 5101 $opt_dry_run || rm -f "$lockfile"
cannam@126 5102 fi
cannam@126 5103 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
cannam@126 5104 :
cannam@126 5105 else
cannam@126 5106 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
cannam@126 5107 fi
cannam@126 5108 }
cannam@126 5109
cannam@126 5110
cannam@126 5111 # func_extract_archives gentop oldlib ...
cannam@126 5112 func_extract_archives ()
cannam@126 5113 {
cannam@126 5114 $debug_cmd
cannam@126 5115
cannam@126 5116 my_gentop=$1; shift
cannam@126 5117 my_oldlibs=${1+"$@"}
cannam@126 5118 my_oldobjs=
cannam@126 5119 my_xlib=
cannam@126 5120 my_xabs=
cannam@126 5121 my_xdir=
cannam@126 5122
cannam@126 5123 for my_xlib in $my_oldlibs; do
cannam@126 5124 # Extract the objects.
cannam@126 5125 case $my_xlib in
cannam@126 5126 [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
cannam@126 5127 *) my_xabs=`pwd`"/$my_xlib" ;;
cannam@126 5128 esac
cannam@126 5129 func_basename "$my_xlib"
cannam@126 5130 my_xlib=$func_basename_result
cannam@126 5131 my_xlib_u=$my_xlib
cannam@126 5132 while :; do
cannam@126 5133 case " $extracted_archives " in
cannam@126 5134 *" $my_xlib_u "*)
cannam@126 5135 func_arith $extracted_serial + 1
cannam@126 5136 extracted_serial=$func_arith_result
cannam@126 5137 my_xlib_u=lt$extracted_serial-$my_xlib ;;
cannam@126 5138 *) break ;;
cannam@126 5139 esac
cannam@126 5140 done
cannam@126 5141 extracted_archives="$extracted_archives $my_xlib_u"
cannam@126 5142 my_xdir=$my_gentop/$my_xlib_u
cannam@126 5143
cannam@126 5144 func_mkdir_p "$my_xdir"
cannam@126 5145
cannam@126 5146 case $host in
cannam@126 5147 *-darwin*)
cannam@126 5148 func_verbose "Extracting $my_xabs"
cannam@126 5149 # Do not bother doing anything if just a dry run
cannam@126 5150 $opt_dry_run || {
cannam@126 5151 darwin_orig_dir=`pwd`
cannam@126 5152 cd $my_xdir || exit $?
cannam@126 5153 darwin_archive=$my_xabs
cannam@126 5154 darwin_curdir=`pwd`
cannam@126 5155 func_basename "$darwin_archive"
cannam@126 5156 darwin_base_archive=$func_basename_result
cannam@126 5157 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
cannam@126 5158 if test -n "$darwin_arches"; then
cannam@126 5159 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
cannam@126 5160 darwin_arch=
cannam@126 5161 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
cannam@126 5162 for darwin_arch in $darwin_arches; do
cannam@126 5163 func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
cannam@126 5164 $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
cannam@126 5165 cd "unfat-$$/$darwin_base_archive-$darwin_arch"
cannam@126 5166 func_extract_an_archive "`pwd`" "$darwin_base_archive"
cannam@126 5167 cd "$darwin_curdir"
cannam@126 5168 $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
cannam@126 5169 done # $darwin_arches
cannam@126 5170 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
cannam@126 5171 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
cannam@126 5172 darwin_file=
cannam@126 5173 darwin_files=
cannam@126 5174 for darwin_file in $darwin_filelist; do
cannam@126 5175 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
cannam@126 5176 $LIPO -create -output "$darwin_file" $darwin_files
cannam@126 5177 done # $darwin_filelist
cannam@126 5178 $RM -rf unfat-$$
cannam@126 5179 cd "$darwin_orig_dir"
cannam@126 5180 else
cannam@126 5181 cd $darwin_orig_dir
cannam@126 5182 func_extract_an_archive "$my_xdir" "$my_xabs"
cannam@126 5183 fi # $darwin_arches
cannam@126 5184 } # !$opt_dry_run
cannam@126 5185 ;;
cannam@126 5186 *)
cannam@126 5187 func_extract_an_archive "$my_xdir" "$my_xabs"
cannam@126 5188 ;;
cannam@126 5189 esac
cannam@126 5190 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
cannam@126 5191 done
cannam@126 5192
cannam@126 5193 func_extract_archives_result=$my_oldobjs
cannam@126 5194 }
cannam@126 5195
cannam@126 5196
cannam@126 5197 # func_emit_wrapper [arg=no]
cannam@126 5198 #
cannam@126 5199 # Emit a libtool wrapper script on stdout.
cannam@126 5200 # Don't directly open a file because we may want to
cannam@126 5201 # incorporate the script contents within a cygwin/mingw
cannam@126 5202 # wrapper executable. Must ONLY be called from within
cannam@126 5203 # func_mode_link because it depends on a number of variables
cannam@126 5204 # set therein.
cannam@126 5205 #
cannam@126 5206 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
cannam@126 5207 # variable will take. If 'yes', then the emitted script
cannam@126 5208 # will assume that the directory where it is stored is
cannam@126 5209 # the $objdir directory. This is a cygwin/mingw-specific
cannam@126 5210 # behavior.
cannam@126 5211 func_emit_wrapper ()
cannam@126 5212 {
cannam@126 5213 func_emit_wrapper_arg1=${1-no}
cannam@126 5214
cannam@126 5215 $ECHO "\
cannam@126 5216 #! $SHELL
cannam@126 5217
cannam@126 5218 # $output - temporary wrapper script for $objdir/$outputname
cannam@126 5219 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
cannam@126 5220 #
cannam@126 5221 # The $output program cannot be directly executed until all the libtool
cannam@126 5222 # libraries that it depends on are installed.
cannam@126 5223 #
cannam@126 5224 # This wrapper script should never be moved out of the build directory.
cannam@126 5225 # If it is, it will not operate correctly.
cannam@126 5226
cannam@126 5227 # Sed substitution that helps us do robust quoting. It backslashifies
cannam@126 5228 # metacharacters that are still active within double-quoted strings.
cannam@126 5229 sed_quote_subst='$sed_quote_subst'
cannam@126 5230
cannam@126 5231 # Be Bourne compatible
cannam@126 5232 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
cannam@126 5233 emulate sh
cannam@126 5234 NULLCMD=:
cannam@126 5235 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
cannam@126 5236 # is contrary to our usage. Disable this feature.
cannam@126 5237 alias -g '\${1+\"\$@\"}'='\"\$@\"'
cannam@126 5238 setopt NO_GLOB_SUBST
cannam@126 5239 else
cannam@126 5240 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
cannam@126 5241 fi
cannam@126 5242 BIN_SH=xpg4; export BIN_SH # for Tru64
cannam@126 5243 DUALCASE=1; export DUALCASE # for MKS sh
cannam@126 5244
cannam@126 5245 # The HP-UX ksh and POSIX shell print the target directory to stdout
cannam@126 5246 # if CDPATH is set.
cannam@126 5247 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
cannam@126 5248
cannam@126 5249 relink_command=\"$relink_command\"
cannam@126 5250
cannam@126 5251 # This environment variable determines our operation mode.
cannam@126 5252 if test \"\$libtool_install_magic\" = \"$magic\"; then
cannam@126 5253 # install mode needs the following variables:
cannam@126 5254 generated_by_libtool_version='$macro_version'
cannam@126 5255 notinst_deplibs='$notinst_deplibs'
cannam@126 5256 else
cannam@126 5257 # When we are sourced in execute mode, \$file and \$ECHO are already set.
cannam@126 5258 if test \"\$libtool_execute_magic\" != \"$magic\"; then
cannam@126 5259 file=\"\$0\""
cannam@126 5260
cannam@126 5261 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
cannam@126 5262 $ECHO "\
cannam@126 5263
cannam@126 5264 # A function that is used when there is no print builtin or printf.
cannam@126 5265 func_fallback_echo ()
cannam@126 5266 {
cannam@126 5267 eval 'cat <<_LTECHO_EOF
cannam@126 5268 \$1
cannam@126 5269 _LTECHO_EOF'
cannam@126 5270 }
cannam@126 5271 ECHO=\"$qECHO\"
cannam@126 5272 fi
cannam@126 5273
cannam@126 5274 # Very basic option parsing. These options are (a) specific to
cannam@126 5275 # the libtool wrapper, (b) are identical between the wrapper
cannam@126 5276 # /script/ and the wrapper /executable/ that is used only on
cannam@126 5277 # windows platforms, and (c) all begin with the string "--lt-"
cannam@126 5278 # (application programs are unlikely to have options that match
cannam@126 5279 # this pattern).
cannam@126 5280 #
cannam@126 5281 # There are only two supported options: --lt-debug and
cannam@126 5282 # --lt-dump-script. There is, deliberately, no --lt-help.
cannam@126 5283 #
cannam@126 5284 # The first argument to this parsing function should be the
cannam@126 5285 # script's $0 value, followed by "$@".
cannam@126 5286 lt_option_debug=
cannam@126 5287 func_parse_lt_options ()
cannam@126 5288 {
cannam@126 5289 lt_script_arg0=\$0
cannam@126 5290 shift
cannam@126 5291 for lt_opt
cannam@126 5292 do
cannam@126 5293 case \"\$lt_opt\" in
cannam@126 5294 --lt-debug) lt_option_debug=1 ;;
cannam@126 5295 --lt-dump-script)
cannam@126 5296 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
cannam@126 5297 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
cannam@126 5298 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
cannam@126 5299 cat \"\$lt_dump_D/\$lt_dump_F\"
cannam@126 5300 exit 0
cannam@126 5301 ;;
cannam@126 5302 --lt-*)
cannam@126 5303 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
cannam@126 5304 exit 1
cannam@126 5305 ;;
cannam@126 5306 esac
cannam@126 5307 done
cannam@126 5308
cannam@126 5309 # Print the debug banner immediately:
cannam@126 5310 if test -n \"\$lt_option_debug\"; then
cannam@126 5311 echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
cannam@126 5312 fi
cannam@126 5313 }
cannam@126 5314
cannam@126 5315 # Used when --lt-debug. Prints its arguments to stdout
cannam@126 5316 # (redirection is the responsibility of the caller)
cannam@126 5317 func_lt_dump_args ()
cannam@126 5318 {
cannam@126 5319 lt_dump_args_N=1;
cannam@126 5320 for lt_arg
cannam@126 5321 do
cannam@126 5322 \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
cannam@126 5323 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
cannam@126 5324 done
cannam@126 5325 }
cannam@126 5326
cannam@126 5327 # Core function for launching the target application
cannam@126 5328 func_exec_program_core ()
cannam@126 5329 {
cannam@126 5330 "
cannam@126 5331 case $host in
cannam@126 5332 # Backslashes separate directories on plain windows
cannam@126 5333 *-*-mingw | *-*-os2* | *-cegcc*)
cannam@126 5334 $ECHO "\
cannam@126 5335 if test -n \"\$lt_option_debug\"; then
cannam@126 5336 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
cannam@126 5337 func_lt_dump_args \${1+\"\$@\"} 1>&2
cannam@126 5338 fi
cannam@126 5339 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
cannam@126 5340 "
cannam@126 5341 ;;
cannam@126 5342
cannam@126 5343 *)
cannam@126 5344 $ECHO "\
cannam@126 5345 if test -n \"\$lt_option_debug\"; then
cannam@126 5346 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
cannam@126 5347 func_lt_dump_args \${1+\"\$@\"} 1>&2
cannam@126 5348 fi
cannam@126 5349 exec \"\$progdir/\$program\" \${1+\"\$@\"}
cannam@126 5350 "
cannam@126 5351 ;;
cannam@126 5352 esac
cannam@126 5353 $ECHO "\
cannam@126 5354 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
cannam@126 5355 exit 1
cannam@126 5356 }
cannam@126 5357
cannam@126 5358 # A function to encapsulate launching the target application
cannam@126 5359 # Strips options in the --lt-* namespace from \$@ and
cannam@126 5360 # launches target application with the remaining arguments.
cannam@126 5361 func_exec_program ()
cannam@126 5362 {
cannam@126 5363 case \" \$* \" in
cannam@126 5364 *\\ --lt-*)
cannam@126 5365 for lt_wr_arg
cannam@126 5366 do
cannam@126 5367 case \$lt_wr_arg in
cannam@126 5368 --lt-*) ;;
cannam@126 5369 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
cannam@126 5370 esac
cannam@126 5371 shift
cannam@126 5372 done ;;
cannam@126 5373 esac
cannam@126 5374 func_exec_program_core \${1+\"\$@\"}
cannam@126 5375 }
cannam@126 5376
cannam@126 5377 # Parse options
cannam@126 5378 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
cannam@126 5379
cannam@126 5380 # Find the directory that this script lives in.
cannam@126 5381 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
cannam@126 5382 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
cannam@126 5383
cannam@126 5384 # Follow symbolic links until we get to the real thisdir.
cannam@126 5385 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
cannam@126 5386 while test -n \"\$file\"; do
cannam@126 5387 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
cannam@126 5388
cannam@126 5389 # If there was a directory component, then change thisdir.
cannam@126 5390 if test \"x\$destdir\" != \"x\$file\"; then
cannam@126 5391 case \"\$destdir\" in
cannam@126 5392 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
cannam@126 5393 *) thisdir=\"\$thisdir/\$destdir\" ;;
cannam@126 5394 esac
cannam@126 5395 fi
cannam@126 5396
cannam@126 5397 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
cannam@126 5398 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
cannam@126 5399 done
cannam@126 5400
cannam@126 5401 # Usually 'no', except on cygwin/mingw when embedded into
cannam@126 5402 # the cwrapper.
cannam@126 5403 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
cannam@126 5404 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
cannam@126 5405 # special case for '.'
cannam@126 5406 if test \"\$thisdir\" = \".\"; then
cannam@126 5407 thisdir=\`pwd\`
cannam@126 5408 fi
cannam@126 5409 # remove .libs from thisdir
cannam@126 5410 case \"\$thisdir\" in
cannam@126 5411 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
cannam@126 5412 $objdir ) thisdir=. ;;
cannam@126 5413 esac
cannam@126 5414 fi
cannam@126 5415
cannam@126 5416 # Try to get the absolute directory name.
cannam@126 5417 absdir=\`cd \"\$thisdir\" && pwd\`
cannam@126 5418 test -n \"\$absdir\" && thisdir=\"\$absdir\"
cannam@126 5419 "
cannam@126 5420
cannam@126 5421 if test yes = "$fast_install"; then
cannam@126 5422 $ECHO "\
cannam@126 5423 program=lt-'$outputname'$exeext
cannam@126 5424 progdir=\"\$thisdir/$objdir\"
cannam@126 5425
cannam@126 5426 if test ! -f \"\$progdir/\$program\" ||
cannam@126 5427 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
cannam@126 5428 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
cannam@126 5429
cannam@126 5430 file=\"\$\$-\$program\"
cannam@126 5431
cannam@126 5432 if test ! -d \"\$progdir\"; then
cannam@126 5433 $MKDIR \"\$progdir\"
cannam@126 5434 else
cannam@126 5435 $RM \"\$progdir/\$file\"
cannam@126 5436 fi"
cannam@126 5437
cannam@126 5438 $ECHO "\
cannam@126 5439
cannam@126 5440 # relink executable if necessary
cannam@126 5441 if test -n \"\$relink_command\"; then
cannam@126 5442 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
cannam@126 5443 else
cannam@126 5444 \$ECHO \"\$relink_command_output\" >&2
cannam@126 5445 $RM \"\$progdir/\$file\"
cannam@126 5446 exit 1
cannam@126 5447 fi
cannam@126 5448 fi
cannam@126 5449
cannam@126 5450 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
cannam@126 5451 { $RM \"\$progdir/\$program\";
cannam@126 5452 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
cannam@126 5453 $RM \"\$progdir/\$file\"
cannam@126 5454 fi"
cannam@126 5455 else
cannam@126 5456 $ECHO "\
cannam@126 5457 program='$outputname'
cannam@126 5458 progdir=\"\$thisdir/$objdir\"
cannam@126 5459 "
cannam@126 5460 fi
cannam@126 5461
cannam@126 5462 $ECHO "\
cannam@126 5463
cannam@126 5464 if test -f \"\$progdir/\$program\"; then"
cannam@126 5465
cannam@126 5466 # fixup the dll searchpath if we need to.
cannam@126 5467 #
cannam@126 5468 # Fix the DLL searchpath if we need to. Do this before prepending
cannam@126 5469 # to shlibpath, because on Windows, both are PATH and uninstalled
cannam@126 5470 # libraries must come first.
cannam@126 5471 if test -n "$dllsearchpath"; then
cannam@126 5472 $ECHO "\
cannam@126 5473 # Add the dll search path components to the executable PATH
cannam@126 5474 PATH=$dllsearchpath:\$PATH
cannam@126 5475 "
cannam@126 5476 fi
cannam@126 5477
cannam@126 5478 # Export our shlibpath_var if we have one.
cannam@126 5479 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
cannam@126 5480 $ECHO "\
cannam@126 5481 # Add our own library path to $shlibpath_var
cannam@126 5482 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
cannam@126 5483
cannam@126 5484 # Some systems cannot cope with colon-terminated $shlibpath_var
cannam@126 5485 # The second colon is a workaround for a bug in BeOS R4 sed
cannam@126 5486 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
cannam@126 5487
cannam@126 5488 export $shlibpath_var
cannam@126 5489 "
cannam@126 5490 fi
cannam@126 5491
cannam@126 5492 $ECHO "\
cannam@126 5493 if test \"\$libtool_execute_magic\" != \"$magic\"; then
cannam@126 5494 # Run the actual program with our arguments.
cannam@126 5495 func_exec_program \${1+\"\$@\"}
cannam@126 5496 fi
cannam@126 5497 else
cannam@126 5498 # The program doesn't exist.
cannam@126 5499 \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
cannam@126 5500 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
cannam@126 5501 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
cannam@126 5502 exit 1
cannam@126 5503 fi
cannam@126 5504 fi\
cannam@126 5505 "
cannam@126 5506 }
cannam@126 5507
cannam@126 5508
cannam@126 5509 # func_emit_cwrapperexe_src
cannam@126 5510 # emit the source code for a wrapper executable on stdout
cannam@126 5511 # Must ONLY be called from within func_mode_link because
cannam@126 5512 # it depends on a number of variable set therein.
cannam@126 5513 func_emit_cwrapperexe_src ()
cannam@126 5514 {
cannam@126 5515 cat <<EOF
cannam@126 5516
cannam@126 5517 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
cannam@126 5518 Generated by $PROGRAM (GNU $PACKAGE) $VERSION
cannam@126 5519
cannam@126 5520 The $output program cannot be directly executed until all the libtool
cannam@126 5521 libraries that it depends on are installed.
cannam@126 5522
cannam@126 5523 This wrapper executable should never be moved out of the build directory.
cannam@126 5524 If it is, it will not operate correctly.
cannam@126 5525 */
cannam@126 5526 EOF
cannam@126 5527 cat <<"EOF"
cannam@126 5528 #ifdef _MSC_VER
cannam@126 5529 # define _CRT_SECURE_NO_DEPRECATE 1
cannam@126 5530 #endif
cannam@126 5531 #include <stdio.h>
cannam@126 5532 #include <stdlib.h>
cannam@126 5533 #ifdef _MSC_VER
cannam@126 5534 # include <direct.h>
cannam@126 5535 # include <process.h>
cannam@126 5536 # include <io.h>
cannam@126 5537 #else
cannam@126 5538 # include <unistd.h>
cannam@126 5539 # include <stdint.h>
cannam@126 5540 # ifdef __CYGWIN__
cannam@126 5541 # include <io.h>
cannam@126 5542 # endif
cannam@126 5543 #endif
cannam@126 5544 #include <malloc.h>
cannam@126 5545 #include <stdarg.h>
cannam@126 5546 #include <assert.h>
cannam@126 5547 #include <string.h>
cannam@126 5548 #include <ctype.h>
cannam@126 5549 #include <errno.h>
cannam@126 5550 #include <fcntl.h>
cannam@126 5551 #include <sys/stat.h>
cannam@126 5552
cannam@126 5553 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
cannam@126 5554
cannam@126 5555 /* declarations of non-ANSI functions */
cannam@126 5556 #if defined __MINGW32__
cannam@126 5557 # ifdef __STRICT_ANSI__
cannam@126 5558 int _putenv (const char *);
cannam@126 5559 # endif
cannam@126 5560 #elif defined __CYGWIN__
cannam@126 5561 # ifdef __STRICT_ANSI__
cannam@126 5562 char *realpath (const char *, char *);
cannam@126 5563 int putenv (char *);
cannam@126 5564 int setenv (const char *, const char *, int);
cannam@126 5565 # endif
cannam@126 5566 /* #elif defined other_platform || defined ... */
cannam@126 5567 #endif
cannam@126 5568
cannam@126 5569 /* portability defines, excluding path handling macros */
cannam@126 5570 #if defined _MSC_VER
cannam@126 5571 # define setmode _setmode
cannam@126 5572 # define stat _stat
cannam@126 5573 # define chmod _chmod
cannam@126 5574 # define getcwd _getcwd
cannam@126 5575 # define putenv _putenv
cannam@126 5576 # define S_IXUSR _S_IEXEC
cannam@126 5577 #elif defined __MINGW32__
cannam@126 5578 # define setmode _setmode
cannam@126 5579 # define stat _stat
cannam@126 5580 # define chmod _chmod
cannam@126 5581 # define getcwd _getcwd
cannam@126 5582 # define putenv _putenv
cannam@126 5583 #elif defined __CYGWIN__
cannam@126 5584 # define HAVE_SETENV
cannam@126 5585 # define FOPEN_WB "wb"
cannam@126 5586 /* #elif defined other platforms ... */
cannam@126 5587 #endif
cannam@126 5588
cannam@126 5589 #if defined PATH_MAX
cannam@126 5590 # define LT_PATHMAX PATH_MAX
cannam@126 5591 #elif defined MAXPATHLEN
cannam@126 5592 # define LT_PATHMAX MAXPATHLEN
cannam@126 5593 #else
cannam@126 5594 # define LT_PATHMAX 1024
cannam@126 5595 #endif
cannam@126 5596
cannam@126 5597 #ifndef S_IXOTH
cannam@126 5598 # define S_IXOTH 0
cannam@126 5599 #endif
cannam@126 5600 #ifndef S_IXGRP
cannam@126 5601 # define S_IXGRP 0
cannam@126 5602 #endif
cannam@126 5603
cannam@126 5604 /* path handling portability macros */
cannam@126 5605 #ifndef DIR_SEPARATOR
cannam@126 5606 # define DIR_SEPARATOR '/'
cannam@126 5607 # define PATH_SEPARATOR ':'
cannam@126 5608 #endif
cannam@126 5609
cannam@126 5610 #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
cannam@126 5611 defined __OS2__
cannam@126 5612 # define HAVE_DOS_BASED_FILE_SYSTEM
cannam@126 5613 # define FOPEN_WB "wb"
cannam@126 5614 # ifndef DIR_SEPARATOR_2
cannam@126 5615 # define DIR_SEPARATOR_2 '\\'
cannam@126 5616 # endif
cannam@126 5617 # ifndef PATH_SEPARATOR_2
cannam@126 5618 # define PATH_SEPARATOR_2 ';'
cannam@126 5619 # endif
cannam@126 5620 #endif
cannam@126 5621
cannam@126 5622 #ifndef DIR_SEPARATOR_2
cannam@126 5623 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
cannam@126 5624 #else /* DIR_SEPARATOR_2 */
cannam@126 5625 # define IS_DIR_SEPARATOR(ch) \
cannam@126 5626 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
cannam@126 5627 #endif /* DIR_SEPARATOR_2 */
cannam@126 5628
cannam@126 5629 #ifndef PATH_SEPARATOR_2
cannam@126 5630 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
cannam@126 5631 #else /* PATH_SEPARATOR_2 */
cannam@126 5632 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
cannam@126 5633 #endif /* PATH_SEPARATOR_2 */
cannam@126 5634
cannam@126 5635 #ifndef FOPEN_WB
cannam@126 5636 # define FOPEN_WB "w"
cannam@126 5637 #endif
cannam@126 5638 #ifndef _O_BINARY
cannam@126 5639 # define _O_BINARY 0
cannam@126 5640 #endif
cannam@126 5641
cannam@126 5642 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
cannam@126 5643 #define XFREE(stale) do { \
cannam@126 5644 if (stale) { free (stale); stale = 0; } \
cannam@126 5645 } while (0)
cannam@126 5646
cannam@126 5647 #if defined LT_DEBUGWRAPPER
cannam@126 5648 static int lt_debug = 1;
cannam@126 5649 #else
cannam@126 5650 static int lt_debug = 0;
cannam@126 5651 #endif
cannam@126 5652
cannam@126 5653 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
cannam@126 5654
cannam@126 5655 void *xmalloc (size_t num);
cannam@126 5656 char *xstrdup (const char *string);
cannam@126 5657 const char *base_name (const char *name);
cannam@126 5658 char *find_executable (const char *wrapper);
cannam@126 5659 char *chase_symlinks (const char *pathspec);
cannam@126 5660 int make_executable (const char *path);
cannam@126 5661 int check_executable (const char *path);
cannam@126 5662 char *strendzap (char *str, const char *pat);
cannam@126 5663 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
cannam@126 5664 void lt_fatal (const char *file, int line, const char *message, ...);
cannam@126 5665 static const char *nonnull (const char *s);
cannam@126 5666 static const char *nonempty (const char *s);
cannam@126 5667 void lt_setenv (const char *name, const char *value);
cannam@126 5668 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
cannam@126 5669 void lt_update_exe_path (const char *name, const char *value);
cannam@126 5670 void lt_update_lib_path (const char *name, const char *value);
cannam@126 5671 char **prepare_spawn (char **argv);
cannam@126 5672 void lt_dump_script (FILE *f);
cannam@126 5673 EOF
cannam@126 5674
cannam@126 5675 cat <<EOF
cannam@126 5676 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
cannam@126 5677 # define externally_visible volatile
cannam@126 5678 #else
cannam@126 5679 # define externally_visible __attribute__((externally_visible)) volatile
cannam@126 5680 #endif
cannam@126 5681 externally_visible const char * MAGIC_EXE = "$magic_exe";
cannam@126 5682 const char * LIB_PATH_VARNAME = "$shlibpath_var";
cannam@126 5683 EOF
cannam@126 5684
cannam@126 5685 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
cannam@126 5686 func_to_host_path "$temp_rpath"
cannam@126 5687 cat <<EOF
cannam@126 5688 const char * LIB_PATH_VALUE = "$func_to_host_path_result";
cannam@126 5689 EOF
cannam@126 5690 else
cannam@126 5691 cat <<"EOF"
cannam@126 5692 const char * LIB_PATH_VALUE = "";
cannam@126 5693 EOF
cannam@126 5694 fi
cannam@126 5695
cannam@126 5696 if test -n "$dllsearchpath"; then
cannam@126 5697 func_to_host_path "$dllsearchpath:"
cannam@126 5698 cat <<EOF
cannam@126 5699 const char * EXE_PATH_VARNAME = "PATH";
cannam@126 5700 const char * EXE_PATH_VALUE = "$func_to_host_path_result";
cannam@126 5701 EOF
cannam@126 5702 else
cannam@126 5703 cat <<"EOF"
cannam@126 5704 const char * EXE_PATH_VARNAME = "";
cannam@126 5705 const char * EXE_PATH_VALUE = "";
cannam@126 5706 EOF
cannam@126 5707 fi
cannam@126 5708
cannam@126 5709 if test yes = "$fast_install"; then
cannam@126 5710 cat <<EOF
cannam@126 5711 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
cannam@126 5712 EOF
cannam@126 5713 else
cannam@126 5714 cat <<EOF
cannam@126 5715 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
cannam@126 5716 EOF
cannam@126 5717 fi
cannam@126 5718
cannam@126 5719
cannam@126 5720 cat <<"EOF"
cannam@126 5721
cannam@126 5722 #define LTWRAPPER_OPTION_PREFIX "--lt-"
cannam@126 5723
cannam@126 5724 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
cannam@126 5725 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
cannam@126 5726 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
cannam@126 5727
cannam@126 5728 int
cannam@126 5729 main (int argc, char *argv[])
cannam@126 5730 {
cannam@126 5731 char **newargz;
cannam@126 5732 int newargc;
cannam@126 5733 char *tmp_pathspec;
cannam@126 5734 char *actual_cwrapper_path;
cannam@126 5735 char *actual_cwrapper_name;
cannam@126 5736 char *target_name;
cannam@126 5737 char *lt_argv_zero;
cannam@126 5738 int rval = 127;
cannam@126 5739
cannam@126 5740 int i;
cannam@126 5741
cannam@126 5742 program_name = (char *) xstrdup (base_name (argv[0]));
cannam@126 5743 newargz = XMALLOC (char *, (size_t) argc + 1);
cannam@126 5744
cannam@126 5745 /* very simple arg parsing; don't want to rely on getopt
cannam@126 5746 * also, copy all non cwrapper options to newargz, except
cannam@126 5747 * argz[0], which is handled differently
cannam@126 5748 */
cannam@126 5749 newargc=0;
cannam@126 5750 for (i = 1; i < argc; i++)
cannam@126 5751 {
cannam@126 5752 if (STREQ (argv[i], dumpscript_opt))
cannam@126 5753 {
cannam@126 5754 EOF
cannam@126 5755 case $host in
cannam@126 5756 *mingw* | *cygwin* )
cannam@126 5757 # make stdout use "unix" line endings
cannam@126 5758 echo " setmode(1,_O_BINARY);"
cannam@126 5759 ;;
cannam@126 5760 esac
cannam@126 5761
cannam@126 5762 cat <<"EOF"
cannam@126 5763 lt_dump_script (stdout);
cannam@126 5764 return 0;
cannam@126 5765 }
cannam@126 5766 if (STREQ (argv[i], debug_opt))
cannam@126 5767 {
cannam@126 5768 lt_debug = 1;
cannam@126 5769 continue;
cannam@126 5770 }
cannam@126 5771 if (STREQ (argv[i], ltwrapper_option_prefix))
cannam@126 5772 {
cannam@126 5773 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
cannam@126 5774 namespace, but it is not one of the ones we know about and
cannam@126 5775 have already dealt with, above (inluding dump-script), then
cannam@126 5776 report an error. Otherwise, targets might begin to believe
cannam@126 5777 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
cannam@126 5778 namespace. The first time any user complains about this, we'll
cannam@126 5779 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
cannam@126 5780 or a configure.ac-settable value.
cannam@126 5781 */
cannam@126 5782 lt_fatal (__FILE__, __LINE__,
cannam@126 5783 "unrecognized %s option: '%s'",
cannam@126 5784 ltwrapper_option_prefix, argv[i]);
cannam@126 5785 }
cannam@126 5786 /* otherwise ... */
cannam@126 5787 newargz[++newargc] = xstrdup (argv[i]);
cannam@126 5788 }
cannam@126 5789 newargz[++newargc] = NULL;
cannam@126 5790
cannam@126 5791 EOF
cannam@126 5792 cat <<EOF
cannam@126 5793 /* The GNU banner must be the first non-error debug message */
cannam@126 5794 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
cannam@126 5795 EOF
cannam@126 5796 cat <<"EOF"
cannam@126 5797 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
cannam@126 5798 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
cannam@126 5799
cannam@126 5800 tmp_pathspec = find_executable (argv[0]);
cannam@126 5801 if (tmp_pathspec == NULL)
cannam@126 5802 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
cannam@126 5803 lt_debugprintf (__FILE__, __LINE__,
cannam@126 5804 "(main) found exe (before symlink chase) at: %s\n",
cannam@126 5805 tmp_pathspec);
cannam@126 5806
cannam@126 5807 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
cannam@126 5808 lt_debugprintf (__FILE__, __LINE__,
cannam@126 5809 "(main) found exe (after symlink chase) at: %s\n",
cannam@126 5810 actual_cwrapper_path);
cannam@126 5811 XFREE (tmp_pathspec);
cannam@126 5812
cannam@126 5813 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
cannam@126 5814 strendzap (actual_cwrapper_path, actual_cwrapper_name);
cannam@126 5815
cannam@126 5816 /* wrapper name transforms */
cannam@126 5817 strendzap (actual_cwrapper_name, ".exe");
cannam@126 5818 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
cannam@126 5819 XFREE (actual_cwrapper_name);
cannam@126 5820 actual_cwrapper_name = tmp_pathspec;
cannam@126 5821 tmp_pathspec = 0;
cannam@126 5822
cannam@126 5823 /* target_name transforms -- use actual target program name; might have lt- prefix */
cannam@126 5824 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
cannam@126 5825 strendzap (target_name, ".exe");
cannam@126 5826 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
cannam@126 5827 XFREE (target_name);
cannam@126 5828 target_name = tmp_pathspec;
cannam@126 5829 tmp_pathspec = 0;
cannam@126 5830
cannam@126 5831 lt_debugprintf (__FILE__, __LINE__,
cannam@126 5832 "(main) libtool target name: %s\n",
cannam@126 5833 target_name);
cannam@126 5834 EOF
cannam@126 5835
cannam@126 5836 cat <<EOF
cannam@126 5837 newargz[0] =
cannam@126 5838 XMALLOC (char, (strlen (actual_cwrapper_path) +
cannam@126 5839 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
cannam@126 5840 strcpy (newargz[0], actual_cwrapper_path);
cannam@126 5841 strcat (newargz[0], "$objdir");
cannam@126 5842 strcat (newargz[0], "/");
cannam@126 5843 EOF
cannam@126 5844
cannam@126 5845 cat <<"EOF"
cannam@126 5846 /* stop here, and copy so we don't have to do this twice */
cannam@126 5847 tmp_pathspec = xstrdup (newargz[0]);
cannam@126 5848
cannam@126 5849 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
cannam@126 5850 strcat (newargz[0], actual_cwrapper_name);
cannam@126 5851
cannam@126 5852 /* DO want the lt- prefix here if it exists, so use target_name */
cannam@126 5853 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
cannam@126 5854 XFREE (tmp_pathspec);
cannam@126 5855 tmp_pathspec = NULL;
cannam@126 5856 EOF
cannam@126 5857
cannam@126 5858 case $host_os in
cannam@126 5859 mingw*)
cannam@126 5860 cat <<"EOF"
cannam@126 5861 {
cannam@126 5862 char* p;
cannam@126 5863 while ((p = strchr (newargz[0], '\\')) != NULL)
cannam@126 5864 {
cannam@126 5865 *p = '/';
cannam@126 5866 }
cannam@126 5867 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
cannam@126 5868 {
cannam@126 5869 *p = '/';
cannam@126 5870 }
cannam@126 5871 }
cannam@126 5872 EOF
cannam@126 5873 ;;
cannam@126 5874 esac
cannam@126 5875
cannam@126 5876 cat <<"EOF"
cannam@126 5877 XFREE (target_name);
cannam@126 5878 XFREE (actual_cwrapper_path);
cannam@126 5879 XFREE (actual_cwrapper_name);
cannam@126 5880
cannam@126 5881 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
cannam@126 5882 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
cannam@126 5883 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
cannam@126 5884 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
cannam@126 5885 because on Windows, both *_VARNAMEs are PATH but uninstalled
cannam@126 5886 libraries must come first. */
cannam@126 5887 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
cannam@126 5888 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
cannam@126 5889
cannam@126 5890 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
cannam@126 5891 nonnull (lt_argv_zero));
cannam@126 5892 for (i = 0; i < newargc; i++)
cannam@126 5893 {
cannam@126 5894 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
cannam@126 5895 i, nonnull (newargz[i]));
cannam@126 5896 }
cannam@126 5897
cannam@126 5898 EOF
cannam@126 5899
cannam@126 5900 case $host_os in
cannam@126 5901 mingw*)
cannam@126 5902 cat <<"EOF"
cannam@126 5903 /* execv doesn't actually work on mingw as expected on unix */
cannam@126 5904 newargz = prepare_spawn (newargz);
cannam@126 5905 rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
cannam@126 5906 if (rval == -1)
cannam@126 5907 {
cannam@126 5908 /* failed to start process */
cannam@126 5909 lt_debugprintf (__FILE__, __LINE__,
cannam@126 5910 "(main) failed to launch target \"%s\": %s\n",
cannam@126 5911 lt_argv_zero, nonnull (strerror (errno)));
cannam@126 5912 return 127;
cannam@126 5913 }
cannam@126 5914 return rval;
cannam@126 5915 EOF
cannam@126 5916 ;;
cannam@126 5917 *)
cannam@126 5918 cat <<"EOF"
cannam@126 5919 execv (lt_argv_zero, newargz);
cannam@126 5920 return rval; /* =127, but avoids unused variable warning */
cannam@126 5921 EOF
cannam@126 5922 ;;
cannam@126 5923 esac
cannam@126 5924
cannam@126 5925 cat <<"EOF"
cannam@126 5926 }
cannam@126 5927
cannam@126 5928 void *
cannam@126 5929 xmalloc (size_t num)
cannam@126 5930 {
cannam@126 5931 void *p = (void *) malloc (num);
cannam@126 5932 if (!p)
cannam@126 5933 lt_fatal (__FILE__, __LINE__, "memory exhausted");
cannam@126 5934
cannam@126 5935 return p;
cannam@126 5936 }
cannam@126 5937
cannam@126 5938 char *
cannam@126 5939 xstrdup (const char *string)
cannam@126 5940 {
cannam@126 5941 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
cannam@126 5942 string) : NULL;
cannam@126 5943 }
cannam@126 5944
cannam@126 5945 const char *
cannam@126 5946 base_name (const char *name)
cannam@126 5947 {
cannam@126 5948 const char *base;
cannam@126 5949
cannam@126 5950 #if defined HAVE_DOS_BASED_FILE_SYSTEM
cannam@126 5951 /* Skip over the disk name in MSDOS pathnames. */
cannam@126 5952 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
cannam@126 5953 name += 2;
cannam@126 5954 #endif
cannam@126 5955
cannam@126 5956 for (base = name; *name; name++)
cannam@126 5957 if (IS_DIR_SEPARATOR (*name))
cannam@126 5958 base = name + 1;
cannam@126 5959 return base;
cannam@126 5960 }
cannam@126 5961
cannam@126 5962 int
cannam@126 5963 check_executable (const char *path)
cannam@126 5964 {
cannam@126 5965 struct stat st;
cannam@126 5966
cannam@126 5967 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
cannam@126 5968 nonempty (path));
cannam@126 5969 if ((!path) || (!*path))
cannam@126 5970 return 0;
cannam@126 5971
cannam@126 5972 if ((stat (path, &st) >= 0)
cannam@126 5973 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
cannam@126 5974 return 1;
cannam@126 5975 else
cannam@126 5976 return 0;
cannam@126 5977 }
cannam@126 5978
cannam@126 5979 int
cannam@126 5980 make_executable (const char *path)
cannam@126 5981 {
cannam@126 5982 int rval = 0;
cannam@126 5983 struct stat st;
cannam@126 5984
cannam@126 5985 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
cannam@126 5986 nonempty (path));
cannam@126 5987 if ((!path) || (!*path))
cannam@126 5988 return 0;
cannam@126 5989
cannam@126 5990 if (stat (path, &st) >= 0)
cannam@126 5991 {
cannam@126 5992 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
cannam@126 5993 }
cannam@126 5994 return rval;
cannam@126 5995 }
cannam@126 5996
cannam@126 5997 /* Searches for the full path of the wrapper. Returns
cannam@126 5998 newly allocated full path name if found, NULL otherwise
cannam@126 5999 Does not chase symlinks, even on platforms that support them.
cannam@126 6000 */
cannam@126 6001 char *
cannam@126 6002 find_executable (const char *wrapper)
cannam@126 6003 {
cannam@126 6004 int has_slash = 0;
cannam@126 6005 const char *p;
cannam@126 6006 const char *p_next;
cannam@126 6007 /* static buffer for getcwd */
cannam@126 6008 char tmp[LT_PATHMAX + 1];
cannam@126 6009 size_t tmp_len;
cannam@126 6010 char *concat_name;
cannam@126 6011
cannam@126 6012 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
cannam@126 6013 nonempty (wrapper));
cannam@126 6014
cannam@126 6015 if ((wrapper == NULL) || (*wrapper == '\0'))
cannam@126 6016 return NULL;
cannam@126 6017
cannam@126 6018 /* Absolute path? */
cannam@126 6019 #if defined HAVE_DOS_BASED_FILE_SYSTEM
cannam@126 6020 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
cannam@126 6021 {
cannam@126 6022 concat_name = xstrdup (wrapper);
cannam@126 6023 if (check_executable (concat_name))
cannam@126 6024 return concat_name;
cannam@126 6025 XFREE (concat_name);
cannam@126 6026 }
cannam@126 6027 else
cannam@126 6028 {
cannam@126 6029 #endif
cannam@126 6030 if (IS_DIR_SEPARATOR (wrapper[0]))
cannam@126 6031 {
cannam@126 6032 concat_name = xstrdup (wrapper);
cannam@126 6033 if (check_executable (concat_name))
cannam@126 6034 return concat_name;
cannam@126 6035 XFREE (concat_name);
cannam@126 6036 }
cannam@126 6037 #if defined HAVE_DOS_BASED_FILE_SYSTEM
cannam@126 6038 }
cannam@126 6039 #endif
cannam@126 6040
cannam@126 6041 for (p = wrapper; *p; p++)
cannam@126 6042 if (*p == '/')
cannam@126 6043 {
cannam@126 6044 has_slash = 1;
cannam@126 6045 break;
cannam@126 6046 }
cannam@126 6047 if (!has_slash)
cannam@126 6048 {
cannam@126 6049 /* no slashes; search PATH */
cannam@126 6050 const char *path = getenv ("PATH");
cannam@126 6051 if (path != NULL)
cannam@126 6052 {
cannam@126 6053 for (p = path; *p; p = p_next)
cannam@126 6054 {
cannam@126 6055 const char *q;
cannam@126 6056 size_t p_len;
cannam@126 6057 for (q = p; *q; q++)
cannam@126 6058 if (IS_PATH_SEPARATOR (*q))
cannam@126 6059 break;
cannam@126 6060 p_len = (size_t) (q - p);
cannam@126 6061 p_next = (*q == '\0' ? q : q + 1);
cannam@126 6062 if (p_len == 0)
cannam@126 6063 {
cannam@126 6064 /* empty path: current directory */
cannam@126 6065 if (getcwd (tmp, LT_PATHMAX) == NULL)
cannam@126 6066 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
cannam@126 6067 nonnull (strerror (errno)));
cannam@126 6068 tmp_len = strlen (tmp);
cannam@126 6069 concat_name =
cannam@126 6070 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
cannam@126 6071 memcpy (concat_name, tmp, tmp_len);
cannam@126 6072 concat_name[tmp_len] = '/';
cannam@126 6073 strcpy (concat_name + tmp_len + 1, wrapper);
cannam@126 6074 }
cannam@126 6075 else
cannam@126 6076 {
cannam@126 6077 concat_name =
cannam@126 6078 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
cannam@126 6079 memcpy (concat_name, p, p_len);
cannam@126 6080 concat_name[p_len] = '/';
cannam@126 6081 strcpy (concat_name + p_len + 1, wrapper);
cannam@126 6082 }
cannam@126 6083 if (check_executable (concat_name))
cannam@126 6084 return concat_name;
cannam@126 6085 XFREE (concat_name);
cannam@126 6086 }
cannam@126 6087 }
cannam@126 6088 /* not found in PATH; assume curdir */
cannam@126 6089 }
cannam@126 6090 /* Relative path | not found in path: prepend cwd */
cannam@126 6091 if (getcwd (tmp, LT_PATHMAX) == NULL)
cannam@126 6092 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
cannam@126 6093 nonnull (strerror (errno)));
cannam@126 6094 tmp_len = strlen (tmp);
cannam@126 6095 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
cannam@126 6096 memcpy (concat_name, tmp, tmp_len);
cannam@126 6097 concat_name[tmp_len] = '/';
cannam@126 6098 strcpy (concat_name + tmp_len + 1, wrapper);
cannam@126 6099
cannam@126 6100 if (check_executable (concat_name))
cannam@126 6101 return concat_name;
cannam@126 6102 XFREE (concat_name);
cannam@126 6103 return NULL;
cannam@126 6104 }
cannam@126 6105
cannam@126 6106 char *
cannam@126 6107 chase_symlinks (const char *pathspec)
cannam@126 6108 {
cannam@126 6109 #ifndef S_ISLNK
cannam@126 6110 return xstrdup (pathspec);
cannam@126 6111 #else
cannam@126 6112 char buf[LT_PATHMAX];
cannam@126 6113 struct stat s;
cannam@126 6114 char *tmp_pathspec = xstrdup (pathspec);
cannam@126 6115 char *p;
cannam@126 6116 int has_symlinks = 0;
cannam@126 6117 while (strlen (tmp_pathspec) && !has_symlinks)
cannam@126 6118 {
cannam@126 6119 lt_debugprintf (__FILE__, __LINE__,
cannam@126 6120 "checking path component for symlinks: %s\n",
cannam@126 6121 tmp_pathspec);
cannam@126 6122 if (lstat (tmp_pathspec, &s) == 0)
cannam@126 6123 {
cannam@126 6124 if (S_ISLNK (s.st_mode) != 0)
cannam@126 6125 {
cannam@126 6126 has_symlinks = 1;
cannam@126 6127 break;
cannam@126 6128 }
cannam@126 6129
cannam@126 6130 /* search backwards for last DIR_SEPARATOR */
cannam@126 6131 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
cannam@126 6132 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
cannam@126 6133 p--;
cannam@126 6134 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
cannam@126 6135 {
cannam@126 6136 /* no more DIR_SEPARATORS left */
cannam@126 6137 break;
cannam@126 6138 }
cannam@126 6139 *p = '\0';
cannam@126 6140 }
cannam@126 6141 else
cannam@126 6142 {
cannam@126 6143 lt_fatal (__FILE__, __LINE__,
cannam@126 6144 "error accessing file \"%s\": %s",
cannam@126 6145 tmp_pathspec, nonnull (strerror (errno)));
cannam@126 6146 }
cannam@126 6147 }
cannam@126 6148 XFREE (tmp_pathspec);
cannam@126 6149
cannam@126 6150 if (!has_symlinks)
cannam@126 6151 {
cannam@126 6152 return xstrdup (pathspec);
cannam@126 6153 }
cannam@126 6154
cannam@126 6155 tmp_pathspec = realpath (pathspec, buf);
cannam@126 6156 if (tmp_pathspec == 0)
cannam@126 6157 {
cannam@126 6158 lt_fatal (__FILE__, __LINE__,
cannam@126 6159 "could not follow symlinks for %s", pathspec);
cannam@126 6160 }
cannam@126 6161 return xstrdup (tmp_pathspec);
cannam@126 6162 #endif
cannam@126 6163 }
cannam@126 6164
cannam@126 6165 char *
cannam@126 6166 strendzap (char *str, const char *pat)
cannam@126 6167 {
cannam@126 6168 size_t len, patlen;
cannam@126 6169
cannam@126 6170 assert (str != NULL);
cannam@126 6171 assert (pat != NULL);
cannam@126 6172
cannam@126 6173 len = strlen (str);
cannam@126 6174 patlen = strlen (pat);
cannam@126 6175
cannam@126 6176 if (patlen <= len)
cannam@126 6177 {
cannam@126 6178 str += len - patlen;
cannam@126 6179 if (STREQ (str, pat))
cannam@126 6180 *str = '\0';
cannam@126 6181 }
cannam@126 6182 return str;
cannam@126 6183 }
cannam@126 6184
cannam@126 6185 void
cannam@126 6186 lt_debugprintf (const char *file, int line, const char *fmt, ...)
cannam@126 6187 {
cannam@126 6188 va_list args;
cannam@126 6189 if (lt_debug)
cannam@126 6190 {
cannam@126 6191 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
cannam@126 6192 va_start (args, fmt);
cannam@126 6193 (void) vfprintf (stderr, fmt, args);
cannam@126 6194 va_end (args);
cannam@126 6195 }
cannam@126 6196 }
cannam@126 6197
cannam@126 6198 static void
cannam@126 6199 lt_error_core (int exit_status, const char *file,
cannam@126 6200 int line, const char *mode,
cannam@126 6201 const char *message, va_list ap)
cannam@126 6202 {
cannam@126 6203 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
cannam@126 6204 vfprintf (stderr, message, ap);
cannam@126 6205 fprintf (stderr, ".\n");
cannam@126 6206
cannam@126 6207 if (exit_status >= 0)
cannam@126 6208 exit (exit_status);
cannam@126 6209 }
cannam@126 6210
cannam@126 6211 void
cannam@126 6212 lt_fatal (const char *file, int line, const char *message, ...)
cannam@126 6213 {
cannam@126 6214 va_list ap;
cannam@126 6215 va_start (ap, message);
cannam@126 6216 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
cannam@126 6217 va_end (ap);
cannam@126 6218 }
cannam@126 6219
cannam@126 6220 static const char *
cannam@126 6221 nonnull (const char *s)
cannam@126 6222 {
cannam@126 6223 return s ? s : "(null)";
cannam@126 6224 }
cannam@126 6225
cannam@126 6226 static const char *
cannam@126 6227 nonempty (const char *s)
cannam@126 6228 {
cannam@126 6229 return (s && !*s) ? "(empty)" : nonnull (s);
cannam@126 6230 }
cannam@126 6231
cannam@126 6232 void
cannam@126 6233 lt_setenv (const char *name, const char *value)
cannam@126 6234 {
cannam@126 6235 lt_debugprintf (__FILE__, __LINE__,
cannam@126 6236 "(lt_setenv) setting '%s' to '%s'\n",
cannam@126 6237 nonnull (name), nonnull (value));
cannam@126 6238 {
cannam@126 6239 #ifdef HAVE_SETENV
cannam@126 6240 /* always make a copy, for consistency with !HAVE_SETENV */
cannam@126 6241 char *str = xstrdup (value);
cannam@126 6242 setenv (name, str, 1);
cannam@126 6243 #else
cannam@126 6244 size_t len = strlen (name) + 1 + strlen (value) + 1;
cannam@126 6245 char *str = XMALLOC (char, len);
cannam@126 6246 sprintf (str, "%s=%s", name, value);
cannam@126 6247 if (putenv (str) != EXIT_SUCCESS)
cannam@126 6248 {
cannam@126 6249 XFREE (str);
cannam@126 6250 }
cannam@126 6251 #endif
cannam@126 6252 }
cannam@126 6253 }
cannam@126 6254
cannam@126 6255 char *
cannam@126 6256 lt_extend_str (const char *orig_value, const char *add, int to_end)
cannam@126 6257 {
cannam@126 6258 char *new_value;
cannam@126 6259 if (orig_value && *orig_value)
cannam@126 6260 {
cannam@126 6261 size_t orig_value_len = strlen (orig_value);
cannam@126 6262 size_t add_len = strlen (add);
cannam@126 6263 new_value = XMALLOC (char, add_len + orig_value_len + 1);
cannam@126 6264 if (to_end)
cannam@126 6265 {
cannam@126 6266 strcpy (new_value, orig_value);
cannam@126 6267 strcpy (new_value + orig_value_len, add);
cannam@126 6268 }
cannam@126 6269 else
cannam@126 6270 {
cannam@126 6271 strcpy (new_value, add);
cannam@126 6272 strcpy (new_value + add_len, orig_value);
cannam@126 6273 }
cannam@126 6274 }
cannam@126 6275 else
cannam@126 6276 {
cannam@126 6277 new_value = xstrdup (add);
cannam@126 6278 }
cannam@126 6279 return new_value;
cannam@126 6280 }
cannam@126 6281
cannam@126 6282 void
cannam@126 6283 lt_update_exe_path (const char *name, const char *value)
cannam@126 6284 {
cannam@126 6285 lt_debugprintf (__FILE__, __LINE__,
cannam@126 6286 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
cannam@126 6287 nonnull (name), nonnull (value));
cannam@126 6288
cannam@126 6289 if (name && *name && value && *value)
cannam@126 6290 {
cannam@126 6291 char *new_value = lt_extend_str (getenv (name), value, 0);
cannam@126 6292 /* some systems can't cope with a ':'-terminated path #' */
cannam@126 6293 size_t len = strlen (new_value);
cannam@126 6294 while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
cannam@126 6295 {
cannam@126 6296 new_value[--len] = '\0';
cannam@126 6297 }
cannam@126 6298 lt_setenv (name, new_value);
cannam@126 6299 XFREE (new_value);
cannam@126 6300 }
cannam@126 6301 }
cannam@126 6302
cannam@126 6303 void
cannam@126 6304 lt_update_lib_path (const char *name, const char *value)
cannam@126 6305 {
cannam@126 6306 lt_debugprintf (__FILE__, __LINE__,
cannam@126 6307 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
cannam@126 6308 nonnull (name), nonnull (value));
cannam@126 6309
cannam@126 6310 if (name && *name && value && *value)
cannam@126 6311 {
cannam@126 6312 char *new_value = lt_extend_str (getenv (name), value, 0);
cannam@126 6313 lt_setenv (name, new_value);
cannam@126 6314 XFREE (new_value);
cannam@126 6315 }
cannam@126 6316 }
cannam@126 6317
cannam@126 6318 EOF
cannam@126 6319 case $host_os in
cannam@126 6320 mingw*)
cannam@126 6321 cat <<"EOF"
cannam@126 6322
cannam@126 6323 /* Prepares an argument vector before calling spawn().
cannam@126 6324 Note that spawn() does not by itself call the command interpreter
cannam@126 6325 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
cannam@126 6326 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
cannam@126 6327 GetVersionEx(&v);
cannam@126 6328 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
cannam@126 6329 }) ? "cmd.exe" : "command.com").
cannam@126 6330 Instead it simply concatenates the arguments, separated by ' ', and calls
cannam@126 6331 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
cannam@126 6332 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
cannam@126 6333 special way:
cannam@126 6334 - Space and tab are interpreted as delimiters. They are not treated as
cannam@126 6335 delimiters if they are surrounded by double quotes: "...".
cannam@126 6336 - Unescaped double quotes are removed from the input. Their only effect is
cannam@126 6337 that within double quotes, space and tab are treated like normal
cannam@126 6338 characters.
cannam@126 6339 - Backslashes not followed by double quotes are not special.
cannam@126 6340 - But 2*n+1 backslashes followed by a double quote become
cannam@126 6341 n backslashes followed by a double quote (n >= 0):
cannam@126 6342 \" -> "
cannam@126 6343 \\\" -> \"
cannam@126 6344 \\\\\" -> \\"
cannam@126 6345 */
cannam@126 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@126 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@126 6348 char **
cannam@126 6349 prepare_spawn (char **argv)
cannam@126 6350 {
cannam@126 6351 size_t argc;
cannam@126 6352 char **new_argv;
cannam@126 6353 size_t i;
cannam@126 6354
cannam@126 6355 /* Count number of arguments. */
cannam@126 6356 for (argc = 0; argv[argc] != NULL; argc++)
cannam@126 6357 ;
cannam@126 6358
cannam@126 6359 /* Allocate new argument vector. */
cannam@126 6360 new_argv = XMALLOC (char *, argc + 1);
cannam@126 6361
cannam@126 6362 /* Put quoted arguments into the new argument vector. */
cannam@126 6363 for (i = 0; i < argc; i++)
cannam@126 6364 {
cannam@126 6365 const char *string = argv[i];
cannam@126 6366
cannam@126 6367 if (string[0] == '\0')
cannam@126 6368 new_argv[i] = xstrdup ("\"\"");
cannam@126 6369 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
cannam@126 6370 {
cannam@126 6371 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
cannam@126 6372 size_t length;
cannam@126 6373 unsigned int backslashes;
cannam@126 6374 const char *s;
cannam@126 6375 char *quoted_string;
cannam@126 6376 char *p;
cannam@126 6377
cannam@126 6378 length = 0;
cannam@126 6379 backslashes = 0;
cannam@126 6380 if (quote_around)
cannam@126 6381 length++;
cannam@126 6382 for (s = string; *s != '\0'; s++)
cannam@126 6383 {
cannam@126 6384 char c = *s;
cannam@126 6385 if (c == '"')
cannam@126 6386 length += backslashes + 1;
cannam@126 6387 length++;
cannam@126 6388 if (c == '\\')
cannam@126 6389 backslashes++;
cannam@126 6390 else
cannam@126 6391 backslashes = 0;
cannam@126 6392 }
cannam@126 6393 if (quote_around)
cannam@126 6394 length += backslashes + 1;
cannam@126 6395
cannam@126 6396 quoted_string = XMALLOC (char, length + 1);
cannam@126 6397
cannam@126 6398 p = quoted_string;
cannam@126 6399 backslashes = 0;
cannam@126 6400 if (quote_around)
cannam@126 6401 *p++ = '"';
cannam@126 6402 for (s = string; *s != '\0'; s++)
cannam@126 6403 {
cannam@126 6404 char c = *s;
cannam@126 6405 if (c == '"')
cannam@126 6406 {
cannam@126 6407 unsigned int j;
cannam@126 6408 for (j = backslashes + 1; j > 0; j--)
cannam@126 6409 *p++ = '\\';
cannam@126 6410 }
cannam@126 6411 *p++ = c;
cannam@126 6412 if (c == '\\')
cannam@126 6413 backslashes++;
cannam@126 6414 else
cannam@126 6415 backslashes = 0;
cannam@126 6416 }
cannam@126 6417 if (quote_around)
cannam@126 6418 {
cannam@126 6419 unsigned int j;
cannam@126 6420 for (j = backslashes; j > 0; j--)
cannam@126 6421 *p++ = '\\';
cannam@126 6422 *p++ = '"';
cannam@126 6423 }
cannam@126 6424 *p = '\0';
cannam@126 6425
cannam@126 6426 new_argv[i] = quoted_string;
cannam@126 6427 }
cannam@126 6428 else
cannam@126 6429 new_argv[i] = (char *) string;
cannam@126 6430 }
cannam@126 6431 new_argv[argc] = NULL;
cannam@126 6432
cannam@126 6433 return new_argv;
cannam@126 6434 }
cannam@126 6435 EOF
cannam@126 6436 ;;
cannam@126 6437 esac
cannam@126 6438
cannam@126 6439 cat <<"EOF"
cannam@126 6440 void lt_dump_script (FILE* f)
cannam@126 6441 {
cannam@126 6442 EOF
cannam@126 6443 func_emit_wrapper yes |
cannam@126 6444 $SED -n -e '
cannam@126 6445 s/^\(.\{79\}\)\(..*\)/\1\
cannam@126 6446 \2/
cannam@126 6447 h
cannam@126 6448 s/\([\\"]\)/\\\1/g
cannam@126 6449 s/$/\\n/
cannam@126 6450 s/\([^\n]*\).*/ fputs ("\1", f);/p
cannam@126 6451 g
cannam@126 6452 D'
cannam@126 6453 cat <<"EOF"
cannam@126 6454 }
cannam@126 6455 EOF
cannam@126 6456 }
cannam@126 6457 # end: func_emit_cwrapperexe_src
cannam@126 6458
cannam@126 6459 # func_win32_import_lib_p ARG
cannam@126 6460 # True if ARG is an import lib, as indicated by $file_magic_cmd
cannam@126 6461 func_win32_import_lib_p ()
cannam@126 6462 {
cannam@126 6463 $debug_cmd
cannam@126 6464
cannam@126 6465 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
cannam@126 6466 *import*) : ;;
cannam@126 6467 *) false ;;
cannam@126 6468 esac
cannam@126 6469 }
cannam@126 6470
cannam@126 6471 # func_suncc_cstd_abi
cannam@126 6472 # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
cannam@126 6473 # Several compiler flags select an ABI that is incompatible with the
cannam@126 6474 # Cstd library. Avoid specifying it if any are in CXXFLAGS.
cannam@126 6475 func_suncc_cstd_abi ()
cannam@126 6476 {
cannam@126 6477 $debug_cmd
cannam@126 6478
cannam@126 6479 case " $compile_command " in
cannam@126 6480 *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
cannam@126 6481 suncc_use_cstd_abi=no
cannam@126 6482 ;;
cannam@126 6483 *)
cannam@126 6484 suncc_use_cstd_abi=yes
cannam@126 6485 ;;
cannam@126 6486 esac
cannam@126 6487 }
cannam@126 6488
cannam@126 6489 # func_mode_link arg...
cannam@126 6490 func_mode_link ()
cannam@126 6491 {
cannam@126 6492 $debug_cmd
cannam@126 6493
cannam@126 6494 case $host in
cannam@126 6495 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
cannam@126 6496 # It is impossible to link a dll without this setting, and
cannam@126 6497 # we shouldn't force the makefile maintainer to figure out
cannam@126 6498 # what system we are compiling for in order to pass an extra
cannam@126 6499 # flag for every libtool invocation.
cannam@126 6500 # allow_undefined=no
cannam@126 6501
cannam@126 6502 # FIXME: Unfortunately, there are problems with the above when trying
cannam@126 6503 # to make a dll that has undefined symbols, in which case not
cannam@126 6504 # even a static library is built. For now, we need to specify
cannam@126 6505 # -no-undefined on the libtool link line when we can be certain
cannam@126 6506 # that all symbols are satisfied, otherwise we get a static library.
cannam@126 6507 allow_undefined=yes
cannam@126 6508 ;;
cannam@126 6509 *)
cannam@126 6510 allow_undefined=yes
cannam@126 6511 ;;
cannam@126 6512 esac
cannam@126 6513 libtool_args=$nonopt
cannam@126 6514 base_compile="$nonopt $@"
cannam@126 6515 compile_command=$nonopt
cannam@126 6516 finalize_command=$nonopt
cannam@126 6517
cannam@126 6518 compile_rpath=
cannam@126 6519 finalize_rpath=
cannam@126 6520 compile_shlibpath=
cannam@126 6521 finalize_shlibpath=
cannam@126 6522 convenience=
cannam@126 6523 old_convenience=
cannam@126 6524 deplibs=
cannam@126 6525 old_deplibs=
cannam@126 6526 compiler_flags=
cannam@126 6527 linker_flags=
cannam@126 6528 dllsearchpath=
cannam@126 6529 lib_search_path=`pwd`
cannam@126 6530 inst_prefix_dir=
cannam@126 6531 new_inherited_linker_flags=
cannam@126 6532
cannam@126 6533 avoid_version=no
cannam@126 6534 bindir=
cannam@126 6535 dlfiles=
cannam@126 6536 dlprefiles=
cannam@126 6537 dlself=no
cannam@126 6538 export_dynamic=no
cannam@126 6539 export_symbols=
cannam@126 6540 export_symbols_regex=
cannam@126 6541 generated=
cannam@126 6542 libobjs=
cannam@126 6543 ltlibs=
cannam@126 6544 module=no
cannam@126 6545 no_install=no
cannam@126 6546 objs=
cannam@126 6547 os2dllname=
cannam@126 6548 non_pic_objects=
cannam@126 6549 precious_files_regex=
cannam@126 6550 prefer_static_libs=no
cannam@126 6551 preload=false
cannam@126 6552 prev=
cannam@126 6553 prevarg=
cannam@126 6554 release=
cannam@126 6555 rpath=
cannam@126 6556 xrpath=
cannam@126 6557 perm_rpath=
cannam@126 6558 temp_rpath=
cannam@126 6559 thread_safe=no
cannam@126 6560 vinfo=
cannam@126 6561 vinfo_number=no
cannam@126 6562 weak_libs=
cannam@126 6563 single_module=$wl-single_module
cannam@126 6564 func_infer_tag $base_compile
cannam@126 6565
cannam@126 6566 # We need to know -static, to get the right output filenames.
cannam@126 6567 for arg
cannam@126 6568 do
cannam@126 6569 case $arg in
cannam@126 6570 -shared)
cannam@126 6571 test yes != "$build_libtool_libs" \
cannam@126 6572 && func_fatal_configuration "cannot build a shared library"
cannam@126 6573 build_old_libs=no
cannam@126 6574 break
cannam@126 6575 ;;
cannam@126 6576 -all-static | -static | -static-libtool-libs)
cannam@126 6577 case $arg in
cannam@126 6578 -all-static)
cannam@126 6579 if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
cannam@126 6580 func_warning "complete static linking is impossible in this configuration"
cannam@126 6581 fi
cannam@126 6582 if test -n "$link_static_flag"; then
cannam@126 6583 dlopen_self=$dlopen_self_static
cannam@126 6584 fi
cannam@126 6585 prefer_static_libs=yes
cannam@126 6586 ;;
cannam@126 6587 -static)
cannam@126 6588 if test -z "$pic_flag" && test -n "$link_static_flag"; then
cannam@126 6589 dlopen_self=$dlopen_self_static
cannam@126 6590 fi
cannam@126 6591 prefer_static_libs=built
cannam@126 6592 ;;
cannam@126 6593 -static-libtool-libs)
cannam@126 6594 if test -z "$pic_flag" && test -n "$link_static_flag"; then
cannam@126 6595 dlopen_self=$dlopen_self_static
cannam@126 6596 fi
cannam@126 6597 prefer_static_libs=yes
cannam@126 6598 ;;
cannam@126 6599 esac
cannam@126 6600 build_libtool_libs=no
cannam@126 6601 build_old_libs=yes
cannam@126 6602 break
cannam@126 6603 ;;
cannam@126 6604 esac
cannam@126 6605 done
cannam@126 6606
cannam@126 6607 # See if our shared archives depend on static archives.
cannam@126 6608 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
cannam@126 6609
cannam@126 6610 # Go through the arguments, transforming them on the way.
cannam@126 6611 while test "$#" -gt 0; do
cannam@126 6612 arg=$1
cannam@126 6613 shift
cannam@126 6614 func_quote_for_eval "$arg"
cannam@126 6615 qarg=$func_quote_for_eval_unquoted_result
cannam@126 6616 func_append libtool_args " $func_quote_for_eval_result"
cannam@126 6617
cannam@126 6618 # If the previous option needs an argument, assign it.
cannam@126 6619 if test -n "$prev"; then
cannam@126 6620 case $prev in
cannam@126 6621 output)
cannam@126 6622 func_append compile_command " @OUTPUT@"
cannam@126 6623 func_append finalize_command " @OUTPUT@"
cannam@126 6624 ;;
cannam@126 6625 esac
cannam@126 6626
cannam@126 6627 case $prev in
cannam@126 6628 bindir)
cannam@126 6629 bindir=$arg
cannam@126 6630 prev=
cannam@126 6631 continue
cannam@126 6632 ;;
cannam@126 6633 dlfiles|dlprefiles)
cannam@126 6634 $preload || {
cannam@126 6635 # Add the symbol object into the linking commands.
cannam@126 6636 func_append compile_command " @SYMFILE@"
cannam@126 6637 func_append finalize_command " @SYMFILE@"
cannam@126 6638 preload=:
cannam@126 6639 }
cannam@126 6640 case $arg in
cannam@126 6641 *.la | *.lo) ;; # We handle these cases below.
cannam@126 6642 force)
cannam@126 6643 if test no = "$dlself"; then
cannam@126 6644 dlself=needless
cannam@126 6645 export_dynamic=yes
cannam@126 6646 fi
cannam@126 6647 prev=
cannam@126 6648 continue
cannam@126 6649 ;;
cannam@126 6650 self)
cannam@126 6651 if test dlprefiles = "$prev"; then
cannam@126 6652 dlself=yes
cannam@126 6653 elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
cannam@126 6654 dlself=yes
cannam@126 6655 else
cannam@126 6656 dlself=needless
cannam@126 6657 export_dynamic=yes
cannam@126 6658 fi
cannam@126 6659 prev=
cannam@126 6660 continue
cannam@126 6661 ;;
cannam@126 6662 *)
cannam@126 6663 if test dlfiles = "$prev"; then
cannam@126 6664 func_append dlfiles " $arg"
cannam@126 6665 else
cannam@126 6666 func_append dlprefiles " $arg"
cannam@126 6667 fi
cannam@126 6668 prev=
cannam@126 6669 continue
cannam@126 6670 ;;
cannam@126 6671 esac
cannam@126 6672 ;;
cannam@126 6673 expsyms)
cannam@126 6674 export_symbols=$arg
cannam@126 6675 test -f "$arg" \
cannam@126 6676 || func_fatal_error "symbol file '$arg' does not exist"
cannam@126 6677 prev=
cannam@126 6678 continue
cannam@126 6679 ;;
cannam@126 6680 expsyms_regex)
cannam@126 6681 export_symbols_regex=$arg
cannam@126 6682 prev=
cannam@126 6683 continue
cannam@126 6684 ;;
cannam@126 6685 framework)
cannam@126 6686 case $host in
cannam@126 6687 *-*-darwin*)
cannam@126 6688 case "$deplibs " in
cannam@126 6689 *" $qarg.ltframework "*) ;;
cannam@126 6690 *) func_append deplibs " $qarg.ltframework" # this is fixed later
cannam@126 6691 ;;
cannam@126 6692 esac
cannam@126 6693 ;;
cannam@126 6694 esac
cannam@126 6695 prev=
cannam@126 6696 continue
cannam@126 6697 ;;
cannam@126 6698 inst_prefix)
cannam@126 6699 inst_prefix_dir=$arg
cannam@126 6700 prev=
cannam@126 6701 continue
cannam@126 6702 ;;
cannam@126 6703 mllvm)
cannam@126 6704 # Clang does not use LLVM to link, so we can simply discard any
cannam@126 6705 # '-mllvm $arg' options when doing the link step.
cannam@126 6706 prev=
cannam@126 6707 continue
cannam@126 6708 ;;
cannam@126 6709 objectlist)
cannam@126 6710 if test -f "$arg"; then
cannam@126 6711 save_arg=$arg
cannam@126 6712 moreargs=
cannam@126 6713 for fil in `cat "$save_arg"`
cannam@126 6714 do
cannam@126 6715 # func_append moreargs " $fil"
cannam@126 6716 arg=$fil
cannam@126 6717 # A libtool-controlled object.
cannam@126 6718
cannam@126 6719 # Check to see that this really is a libtool object.
cannam@126 6720 if func_lalib_unsafe_p "$arg"; then
cannam@126 6721 pic_object=
cannam@126 6722 non_pic_object=
cannam@126 6723
cannam@126 6724 # Read the .lo file
cannam@126 6725 func_source "$arg"
cannam@126 6726
cannam@126 6727 if test -z "$pic_object" ||
cannam@126 6728 test -z "$non_pic_object" ||
cannam@126 6729 test none = "$pic_object" &&
cannam@126 6730 test none = "$non_pic_object"; then
cannam@126 6731 func_fatal_error "cannot find name of object for '$arg'"
cannam@126 6732 fi
cannam@126 6733
cannam@126 6734 # Extract subdirectory from the argument.
cannam@126 6735 func_dirname "$arg" "/" ""
cannam@126 6736 xdir=$func_dirname_result
cannam@126 6737
cannam@126 6738 if test none != "$pic_object"; then
cannam@126 6739 # Prepend the subdirectory the object is found in.
cannam@126 6740 pic_object=$xdir$pic_object
cannam@126 6741
cannam@126 6742 if test dlfiles = "$prev"; then
cannam@126 6743 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
cannam@126 6744 func_append dlfiles " $pic_object"
cannam@126 6745 prev=
cannam@126 6746 continue
cannam@126 6747 else
cannam@126 6748 # If libtool objects are unsupported, then we need to preload.
cannam@126 6749 prev=dlprefiles
cannam@126 6750 fi
cannam@126 6751 fi
cannam@126 6752
cannam@126 6753 # CHECK ME: I think I busted this. -Ossama
cannam@126 6754 if test dlprefiles = "$prev"; then
cannam@126 6755 # Preload the old-style object.
cannam@126 6756 func_append dlprefiles " $pic_object"
cannam@126 6757 prev=
cannam@126 6758 fi
cannam@126 6759
cannam@126 6760 # A PIC object.
cannam@126 6761 func_append libobjs " $pic_object"
cannam@126 6762 arg=$pic_object
cannam@126 6763 fi
cannam@126 6764
cannam@126 6765 # Non-PIC object.
cannam@126 6766 if test none != "$non_pic_object"; then
cannam@126 6767 # Prepend the subdirectory the object is found in.
cannam@126 6768 non_pic_object=$xdir$non_pic_object
cannam@126 6769
cannam@126 6770 # A standard non-PIC object
cannam@126 6771 func_append non_pic_objects " $non_pic_object"
cannam@126 6772 if test -z "$pic_object" || test none = "$pic_object"; then
cannam@126 6773 arg=$non_pic_object
cannam@126 6774 fi
cannam@126 6775 else
cannam@126 6776 # If the PIC object exists, use it instead.
cannam@126 6777 # $xdir was prepended to $pic_object above.
cannam@126 6778 non_pic_object=$pic_object
cannam@126 6779 func_append non_pic_objects " $non_pic_object"
cannam@126 6780 fi
cannam@126 6781 else
cannam@126 6782 # Only an error if not doing a dry-run.
cannam@126 6783 if $opt_dry_run; then
cannam@126 6784 # Extract subdirectory from the argument.
cannam@126 6785 func_dirname "$arg" "/" ""
cannam@126 6786 xdir=$func_dirname_result
cannam@126 6787
cannam@126 6788 func_lo2o "$arg"
cannam@126 6789 pic_object=$xdir$objdir/$func_lo2o_result
cannam@126 6790 non_pic_object=$xdir$func_lo2o_result
cannam@126 6791 func_append libobjs " $pic_object"
cannam@126 6792 func_append non_pic_objects " $non_pic_object"
cannam@126 6793 else
cannam@126 6794 func_fatal_error "'$arg' is not a valid libtool object"
cannam@126 6795 fi
cannam@126 6796 fi
cannam@126 6797 done
cannam@126 6798 else
cannam@126 6799 func_fatal_error "link input file '$arg' does not exist"
cannam@126 6800 fi
cannam@126 6801 arg=$save_arg
cannam@126 6802 prev=
cannam@126 6803 continue
cannam@126 6804 ;;
cannam@126 6805 os2dllname)
cannam@126 6806 os2dllname=$arg
cannam@126 6807 prev=
cannam@126 6808 continue
cannam@126 6809 ;;
cannam@126 6810 precious_regex)
cannam@126 6811 precious_files_regex=$arg
cannam@126 6812 prev=
cannam@126 6813 continue
cannam@126 6814 ;;
cannam@126 6815 release)
cannam@126 6816 release=-$arg
cannam@126 6817 prev=
cannam@126 6818 continue
cannam@126 6819 ;;
cannam@126 6820 rpath | xrpath)
cannam@126 6821 # We need an absolute path.
cannam@126 6822 case $arg in
cannam@126 6823 [\\/]* | [A-Za-z]:[\\/]*) ;;
cannam@126 6824 *)
cannam@126 6825 func_fatal_error "only absolute run-paths are allowed"
cannam@126 6826 ;;
cannam@126 6827 esac
cannam@126 6828 if test rpath = "$prev"; then
cannam@126 6829 case "$rpath " in
cannam@126 6830 *" $arg "*) ;;
cannam@126 6831 *) func_append rpath " $arg" ;;
cannam@126 6832 esac
cannam@126 6833 else
cannam@126 6834 case "$xrpath " in
cannam@126 6835 *" $arg "*) ;;
cannam@126 6836 *) func_append xrpath " $arg" ;;
cannam@126 6837 esac
cannam@126 6838 fi
cannam@126 6839 prev=
cannam@126 6840 continue
cannam@126 6841 ;;
cannam@126 6842 shrext)
cannam@126 6843 shrext_cmds=$arg
cannam@126 6844 prev=
cannam@126 6845 continue
cannam@126 6846 ;;
cannam@126 6847 weak)
cannam@126 6848 func_append weak_libs " $arg"
cannam@126 6849 prev=
cannam@126 6850 continue
cannam@126 6851 ;;
cannam@126 6852 xcclinker)
cannam@126 6853 func_append linker_flags " $qarg"
cannam@126 6854 func_append compiler_flags " $qarg"
cannam@126 6855 prev=
cannam@126 6856 func_append compile_command " $qarg"
cannam@126 6857 func_append finalize_command " $qarg"
cannam@126 6858 continue
cannam@126 6859 ;;
cannam@126 6860 xcompiler)
cannam@126 6861 func_append compiler_flags " $qarg"
cannam@126 6862 prev=
cannam@126 6863 func_append compile_command " $qarg"
cannam@126 6864 func_append finalize_command " $qarg"
cannam@126 6865 continue
cannam@126 6866 ;;
cannam@126 6867 xlinker)
cannam@126 6868 func_append linker_flags " $qarg"
cannam@126 6869 func_append compiler_flags " $wl$qarg"
cannam@126 6870 prev=
cannam@126 6871 func_append compile_command " $wl$qarg"
cannam@126 6872 func_append finalize_command " $wl$qarg"
cannam@126 6873 continue
cannam@126 6874 ;;
cannam@126 6875 *)
cannam@126 6876 eval "$prev=\"\$arg\""
cannam@126 6877 prev=
cannam@126 6878 continue
cannam@126 6879 ;;
cannam@126 6880 esac
cannam@126 6881 fi # test -n "$prev"
cannam@126 6882
cannam@126 6883 prevarg=$arg
cannam@126 6884
cannam@126 6885 case $arg in
cannam@126 6886 -all-static)
cannam@126 6887 if test -n "$link_static_flag"; then
cannam@126 6888 # See comment for -static flag below, for more details.
cannam@126 6889 func_append compile_command " $link_static_flag"
cannam@126 6890 func_append finalize_command " $link_static_flag"
cannam@126 6891 fi
cannam@126 6892 continue
cannam@126 6893 ;;
cannam@126 6894
cannam@126 6895 -allow-undefined)
cannam@126 6896 # FIXME: remove this flag sometime in the future.
cannam@126 6897 func_fatal_error "'-allow-undefined' must not be used because it is the default"
cannam@126 6898 ;;
cannam@126 6899
cannam@126 6900 -avoid-version)
cannam@126 6901 avoid_version=yes
cannam@126 6902 continue
cannam@126 6903 ;;
cannam@126 6904
cannam@126 6905 -bindir)
cannam@126 6906 prev=bindir
cannam@126 6907 continue
cannam@126 6908 ;;
cannam@126 6909
cannam@126 6910 -dlopen)
cannam@126 6911 prev=dlfiles
cannam@126 6912 continue
cannam@126 6913 ;;
cannam@126 6914
cannam@126 6915 -dlpreopen)
cannam@126 6916 prev=dlprefiles
cannam@126 6917 continue
cannam@126 6918 ;;
cannam@126 6919
cannam@126 6920 -export-dynamic)
cannam@126 6921 export_dynamic=yes
cannam@126 6922 continue
cannam@126 6923 ;;
cannam@126 6924
cannam@126 6925 -export-symbols | -export-symbols-regex)
cannam@126 6926 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
cannam@126 6927 func_fatal_error "more than one -exported-symbols argument is not allowed"
cannam@126 6928 fi
cannam@126 6929 if test X-export-symbols = "X$arg"; then
cannam@126 6930 prev=expsyms
cannam@126 6931 else
cannam@126 6932 prev=expsyms_regex
cannam@126 6933 fi
cannam@126 6934 continue
cannam@126 6935 ;;
cannam@126 6936
cannam@126 6937 -framework)
cannam@126 6938 prev=framework
cannam@126 6939 continue
cannam@126 6940 ;;
cannam@126 6941
cannam@126 6942 -inst-prefix-dir)
cannam@126 6943 prev=inst_prefix
cannam@126 6944 continue
cannam@126 6945 ;;
cannam@126 6946
cannam@126 6947 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
cannam@126 6948 # so, if we see these flags be careful not to treat them like -L
cannam@126 6949 -L[A-Z][A-Z]*:*)
cannam@126 6950 case $with_gcc/$host in
cannam@126 6951 no/*-*-irix* | /*-*-irix*)
cannam@126 6952 func_append compile_command " $arg"
cannam@126 6953 func_append finalize_command " $arg"
cannam@126 6954 ;;
cannam@126 6955 esac
cannam@126 6956 continue
cannam@126 6957 ;;
cannam@126 6958
cannam@126 6959 -L*)
cannam@126 6960 func_stripname "-L" '' "$arg"
cannam@126 6961 if test -z "$func_stripname_result"; then
cannam@126 6962 if test "$#" -gt 0; then
cannam@126 6963 func_fatal_error "require no space between '-L' and '$1'"
cannam@126 6964 else
cannam@126 6965 func_fatal_error "need path for '-L' option"
cannam@126 6966 fi
cannam@126 6967 fi
cannam@126 6968 func_resolve_sysroot "$func_stripname_result"
cannam@126 6969 dir=$func_resolve_sysroot_result
cannam@126 6970 # We need an absolute path.
cannam@126 6971 case $dir in
cannam@126 6972 [\\/]* | [A-Za-z]:[\\/]*) ;;
cannam@126 6973 *)
cannam@126 6974 absdir=`cd "$dir" && pwd`
cannam@126 6975 test -z "$absdir" && \
cannam@126 6976 func_fatal_error "cannot determine absolute directory name of '$dir'"
cannam@126 6977 dir=$absdir
cannam@126 6978 ;;
cannam@126 6979 esac
cannam@126 6980 case "$deplibs " in
cannam@126 6981 *" -L$dir "* | *" $arg "*)
cannam@126 6982 # Will only happen for absolute or sysroot arguments
cannam@126 6983 ;;
cannam@126 6984 *)
cannam@126 6985 # Preserve sysroot, but never include relative directories
cannam@126 6986 case $dir in
cannam@126 6987 [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
cannam@126 6988 *) func_append deplibs " -L$dir" ;;
cannam@126 6989 esac
cannam@126 6990 func_append lib_search_path " $dir"
cannam@126 6991 ;;
cannam@126 6992 esac
cannam@126 6993 case $host in
cannam@126 6994 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
cannam@126 6995 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
cannam@126 6996 case :$dllsearchpath: in
cannam@126 6997 *":$dir:"*) ;;
cannam@126 6998 ::) dllsearchpath=$dir;;
cannam@126 6999 *) func_append dllsearchpath ":$dir";;
cannam@126 7000 esac
cannam@126 7001 case :$dllsearchpath: in
cannam@126 7002 *":$testbindir:"*) ;;
cannam@126 7003 ::) dllsearchpath=$testbindir;;
cannam@126 7004 *) func_append dllsearchpath ":$testbindir";;
cannam@126 7005 esac
cannam@126 7006 ;;
cannam@126 7007 esac
cannam@126 7008 continue
cannam@126 7009 ;;
cannam@126 7010
cannam@126 7011 -l*)
cannam@126 7012 if test X-lc = "X$arg" || test X-lm = "X$arg"; then
cannam@126 7013 case $host in
cannam@126 7014 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
cannam@126 7015 # These systems don't actually have a C or math library (as such)
cannam@126 7016 continue
cannam@126 7017 ;;
cannam@126 7018 *-*-os2*)
cannam@126 7019 # These systems don't actually have a C library (as such)
cannam@126 7020 test X-lc = "X$arg" && continue
cannam@126 7021 ;;
cannam@126 7022 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
cannam@126 7023 # Do not include libc due to us having libc/libc_r.
cannam@126 7024 test X-lc = "X$arg" && continue
cannam@126 7025 ;;
cannam@126 7026 *-*-rhapsody* | *-*-darwin1.[012])
cannam@126 7027 # Rhapsody C and math libraries are in the System framework
cannam@126 7028 func_append deplibs " System.ltframework"
cannam@126 7029 continue
cannam@126 7030 ;;
cannam@126 7031 *-*-sco3.2v5* | *-*-sco5v6*)
cannam@126 7032 # Causes problems with __ctype
cannam@126 7033 test X-lc = "X$arg" && continue
cannam@126 7034 ;;
cannam@126 7035 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
cannam@126 7036 # Compiler inserts libc in the correct place for threads to work
cannam@126 7037 test X-lc = "X$arg" && continue
cannam@126 7038 ;;
cannam@126 7039 esac
cannam@126 7040 elif test X-lc_r = "X$arg"; then
cannam@126 7041 case $host in
cannam@126 7042 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
cannam@126 7043 # Do not include libc_r directly, use -pthread flag.
cannam@126 7044 continue
cannam@126 7045 ;;
cannam@126 7046 esac
cannam@126 7047 fi
cannam@126 7048 func_append deplibs " $arg"
cannam@126 7049 continue
cannam@126 7050 ;;
cannam@126 7051
cannam@126 7052 -mllvm)
cannam@126 7053 prev=mllvm
cannam@126 7054 continue
cannam@126 7055 ;;
cannam@126 7056
cannam@126 7057 -module)
cannam@126 7058 module=yes
cannam@126 7059 continue
cannam@126 7060 ;;
cannam@126 7061
cannam@126 7062 # Tru64 UNIX uses -model [arg] to determine the layout of C++
cannam@126 7063 # classes, name mangling, and exception handling.
cannam@126 7064 # Darwin uses the -arch flag to determine output architecture.
cannam@126 7065 -model|-arch|-isysroot|--sysroot)
cannam@126 7066 func_append compiler_flags " $arg"
cannam@126 7067 func_append compile_command " $arg"
cannam@126 7068 func_append finalize_command " $arg"
cannam@126 7069 prev=xcompiler
cannam@126 7070 continue
cannam@126 7071 ;;
cannam@126 7072
cannam@126 7073 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
cannam@126 7074 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
cannam@126 7075 func_append compiler_flags " $arg"
cannam@126 7076 func_append compile_command " $arg"
cannam@126 7077 func_append finalize_command " $arg"
cannam@126 7078 case "$new_inherited_linker_flags " in
cannam@126 7079 *" $arg "*) ;;
cannam@126 7080 * ) func_append new_inherited_linker_flags " $arg" ;;
cannam@126 7081 esac
cannam@126 7082 continue
cannam@126 7083 ;;
cannam@126 7084
cannam@126 7085 -multi_module)
cannam@126 7086 single_module=$wl-multi_module
cannam@126 7087 continue
cannam@126 7088 ;;
cannam@126 7089
cannam@126 7090 -no-fast-install)
cannam@126 7091 fast_install=no
cannam@126 7092 continue
cannam@126 7093 ;;
cannam@126 7094
cannam@126 7095 -no-install)
cannam@126 7096 case $host in
cannam@126 7097 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
cannam@126 7098 # The PATH hackery in wrapper scripts is required on Windows
cannam@126 7099 # and Darwin in order for the loader to find any dlls it needs.
cannam@126 7100 func_warning "'-no-install' is ignored for $host"
cannam@126 7101 func_warning "assuming '-no-fast-install' instead"
cannam@126 7102 fast_install=no
cannam@126 7103 ;;
cannam@126 7104 *) no_install=yes ;;
cannam@126 7105 esac
cannam@126 7106 continue
cannam@126 7107 ;;
cannam@126 7108
cannam@126 7109 -no-undefined)
cannam@126 7110 allow_undefined=no
cannam@126 7111 continue
cannam@126 7112 ;;
cannam@126 7113
cannam@126 7114 -objectlist)
cannam@126 7115 prev=objectlist
cannam@126 7116 continue
cannam@126 7117 ;;
cannam@126 7118
cannam@126 7119 -os2dllname)
cannam@126 7120 prev=os2dllname
cannam@126 7121 continue
cannam@126 7122 ;;
cannam@126 7123
cannam@126 7124 -o) prev=output ;;
cannam@126 7125
cannam@126 7126 -precious-files-regex)
cannam@126 7127 prev=precious_regex
cannam@126 7128 continue
cannam@126 7129 ;;
cannam@126 7130
cannam@126 7131 -release)
cannam@126 7132 prev=release
cannam@126 7133 continue
cannam@126 7134 ;;
cannam@126 7135
cannam@126 7136 -rpath)
cannam@126 7137 prev=rpath
cannam@126 7138 continue
cannam@126 7139 ;;
cannam@126 7140
cannam@126 7141 -R)
cannam@126 7142 prev=xrpath
cannam@126 7143 continue
cannam@126 7144 ;;
cannam@126 7145
cannam@126 7146 -R*)
cannam@126 7147 func_stripname '-R' '' "$arg"
cannam@126 7148 dir=$func_stripname_result
cannam@126 7149 # We need an absolute path.
cannam@126 7150 case $dir in
cannam@126 7151 [\\/]* | [A-Za-z]:[\\/]*) ;;
cannam@126 7152 =*)
cannam@126 7153 func_stripname '=' '' "$dir"
cannam@126 7154 dir=$lt_sysroot$func_stripname_result
cannam@126 7155 ;;
cannam@126 7156 *)
cannam@126 7157 func_fatal_error "only absolute run-paths are allowed"
cannam@126 7158 ;;
cannam@126 7159 esac
cannam@126 7160 case "$xrpath " in
cannam@126 7161 *" $dir "*) ;;
cannam@126 7162 *) func_append xrpath " $dir" ;;
cannam@126 7163 esac
cannam@126 7164 continue
cannam@126 7165 ;;
cannam@126 7166
cannam@126 7167 -shared)
cannam@126 7168 # The effects of -shared are defined in a previous loop.
cannam@126 7169 continue
cannam@126 7170 ;;
cannam@126 7171
cannam@126 7172 -shrext)
cannam@126 7173 prev=shrext
cannam@126 7174 continue
cannam@126 7175 ;;
cannam@126 7176
cannam@126 7177 -static | -static-libtool-libs)
cannam@126 7178 # The effects of -static are defined in a previous loop.
cannam@126 7179 # We used to do the same as -all-static on platforms that
cannam@126 7180 # didn't have a PIC flag, but the assumption that the effects
cannam@126 7181 # would be equivalent was wrong. It would break on at least
cannam@126 7182 # Digital Unix and AIX.
cannam@126 7183 continue
cannam@126 7184 ;;
cannam@126 7185
cannam@126 7186 -thread-safe)
cannam@126 7187 thread_safe=yes
cannam@126 7188 continue
cannam@126 7189 ;;
cannam@126 7190
cannam@126 7191 -version-info)
cannam@126 7192 prev=vinfo
cannam@126 7193 continue
cannam@126 7194 ;;
cannam@126 7195
cannam@126 7196 -version-number)
cannam@126 7197 prev=vinfo
cannam@126 7198 vinfo_number=yes
cannam@126 7199 continue
cannam@126 7200 ;;
cannam@126 7201
cannam@126 7202 -weak)
cannam@126 7203 prev=weak
cannam@126 7204 continue
cannam@126 7205 ;;
cannam@126 7206
cannam@126 7207 -Wc,*)
cannam@126 7208 func_stripname '-Wc,' '' "$arg"
cannam@126 7209 args=$func_stripname_result
cannam@126 7210 arg=
cannam@126 7211 save_ifs=$IFS; IFS=,
cannam@126 7212 for flag in $args; do
cannam@126 7213 IFS=$save_ifs
cannam@126 7214 func_quote_for_eval "$flag"
cannam@126 7215 func_append arg " $func_quote_for_eval_result"
cannam@126 7216 func_append compiler_flags " $func_quote_for_eval_result"
cannam@126 7217 done
cannam@126 7218 IFS=$save_ifs
cannam@126 7219 func_stripname ' ' '' "$arg"
cannam@126 7220 arg=$func_stripname_result
cannam@126 7221 ;;
cannam@126 7222
cannam@126 7223 -Wl,*)
cannam@126 7224 func_stripname '-Wl,' '' "$arg"
cannam@126 7225 args=$func_stripname_result
cannam@126 7226 arg=
cannam@126 7227 save_ifs=$IFS; IFS=,
cannam@126 7228 for flag in $args; do
cannam@126 7229 IFS=$save_ifs
cannam@126 7230 func_quote_for_eval "$flag"
cannam@126 7231 func_append arg " $wl$func_quote_for_eval_result"
cannam@126 7232 func_append compiler_flags " $wl$func_quote_for_eval_result"
cannam@126 7233 func_append linker_flags " $func_quote_for_eval_result"
cannam@126 7234 done
cannam@126 7235 IFS=$save_ifs
cannam@126 7236 func_stripname ' ' '' "$arg"
cannam@126 7237 arg=$func_stripname_result
cannam@126 7238 ;;
cannam@126 7239
cannam@126 7240 -Xcompiler)
cannam@126 7241 prev=xcompiler
cannam@126 7242 continue
cannam@126 7243 ;;
cannam@126 7244
cannam@126 7245 -Xlinker)
cannam@126 7246 prev=xlinker
cannam@126 7247 continue
cannam@126 7248 ;;
cannam@126 7249
cannam@126 7250 -XCClinker)
cannam@126 7251 prev=xcclinker
cannam@126 7252 continue
cannam@126 7253 ;;
cannam@126 7254
cannam@126 7255 # -msg_* for osf cc
cannam@126 7256 -msg_*)
cannam@126 7257 func_quote_for_eval "$arg"
cannam@126 7258 arg=$func_quote_for_eval_result
cannam@126 7259 ;;
cannam@126 7260
cannam@126 7261 # Flags to be passed through unchanged, with rationale:
cannam@126 7262 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
cannam@126 7263 # -r[0-9][0-9]* specify processor for the SGI compiler
cannam@126 7264 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
cannam@126 7265 # +DA*, +DD* enable 64-bit mode for the HP compiler
cannam@126 7266 # -q* compiler args for the IBM compiler
cannam@126 7267 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
cannam@126 7268 # -F/path path to uninstalled frameworks, gcc on darwin
cannam@126 7269 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
cannam@126 7270 # -fstack-protector* stack protector flags for GCC
cannam@126 7271 # @file GCC response files
cannam@126 7272 # -tp=* Portland pgcc target processor selection
cannam@126 7273 # --sysroot=* for sysroot support
cannam@126 7274 # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
cannam@126 7275 # -specs=* GCC specs files
cannam@126 7276 # -stdlib=* select c++ std lib with clang
cannam@126 7277 # -fsanitize=* Clang/GCC memory and address sanitizer
cannam@126 7278 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
cannam@126 7279 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
cannam@126 7280 -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
cannam@126 7281 -specs=*|-fsanitize=*)
cannam@126 7282 func_quote_for_eval "$arg"
cannam@126 7283 arg=$func_quote_for_eval_result
cannam@126 7284 func_append compile_command " $arg"
cannam@126 7285 func_append finalize_command " $arg"
cannam@126 7286 func_append compiler_flags " $arg"
cannam@126 7287 continue
cannam@126 7288 ;;
cannam@126 7289
cannam@126 7290 -Z*)
cannam@126 7291 if test os2 = "`expr $host : '.*\(os2\)'`"; then
cannam@126 7292 # OS/2 uses -Zxxx to specify OS/2-specific options
cannam@126 7293 compiler_flags="$compiler_flags $arg"
cannam@126 7294 func_append compile_command " $arg"
cannam@126 7295 func_append finalize_command " $arg"
cannam@126 7296 case $arg in
cannam@126 7297 -Zlinker | -Zstack)
cannam@126 7298 prev=xcompiler
cannam@126 7299 ;;
cannam@126 7300 esac
cannam@126 7301 continue
cannam@126 7302 else
cannam@126 7303 # Otherwise treat like 'Some other compiler flag' below
cannam@126 7304 func_quote_for_eval "$arg"
cannam@126 7305 arg=$func_quote_for_eval_result
cannam@126 7306 fi
cannam@126 7307 ;;
cannam@126 7308
cannam@126 7309 # Some other compiler flag.
cannam@126 7310 -* | +*)
cannam@126 7311 func_quote_for_eval "$arg"
cannam@126 7312 arg=$func_quote_for_eval_result
cannam@126 7313 ;;
cannam@126 7314
cannam@126 7315 *.$objext)
cannam@126 7316 # A standard object.
cannam@126 7317 func_append objs " $arg"
cannam@126 7318 ;;
cannam@126 7319
cannam@126 7320 *.lo)
cannam@126 7321 # A libtool-controlled object.
cannam@126 7322
cannam@126 7323 # Check to see that this really is a libtool object.
cannam@126 7324 if func_lalib_unsafe_p "$arg"; then
cannam@126 7325 pic_object=
cannam@126 7326 non_pic_object=
cannam@126 7327
cannam@126 7328 # Read the .lo file
cannam@126 7329 func_source "$arg"
cannam@126 7330
cannam@126 7331 if test -z "$pic_object" ||
cannam@126 7332 test -z "$non_pic_object" ||
cannam@126 7333 test none = "$pic_object" &&
cannam@126 7334 test none = "$non_pic_object"; then
cannam@126 7335 func_fatal_error "cannot find name of object for '$arg'"
cannam@126 7336 fi
cannam@126 7337
cannam@126 7338 # Extract subdirectory from the argument.
cannam@126 7339 func_dirname "$arg" "/" ""
cannam@126 7340 xdir=$func_dirname_result
cannam@126 7341
cannam@126 7342 test none = "$pic_object" || {
cannam@126 7343 # Prepend the subdirectory the object is found in.
cannam@126 7344 pic_object=$xdir$pic_object
cannam@126 7345
cannam@126 7346 if test dlfiles = "$prev"; then
cannam@126 7347 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
cannam@126 7348 func_append dlfiles " $pic_object"
cannam@126 7349 prev=
cannam@126 7350 continue
cannam@126 7351 else
cannam@126 7352 # If libtool objects are unsupported, then we need to preload.
cannam@126 7353 prev=dlprefiles
cannam@126 7354 fi
cannam@126 7355 fi
cannam@126 7356
cannam@126 7357 # CHECK ME: I think I busted this. -Ossama
cannam@126 7358 if test dlprefiles = "$prev"; then
cannam@126 7359 # Preload the old-style object.
cannam@126 7360 func_append dlprefiles " $pic_object"
cannam@126 7361 prev=
cannam@126 7362 fi
cannam@126 7363
cannam@126 7364 # A PIC object.
cannam@126 7365 func_append libobjs " $pic_object"
cannam@126 7366 arg=$pic_object
cannam@126 7367 }
cannam@126 7368
cannam@126 7369 # Non-PIC object.
cannam@126 7370 if test none != "$non_pic_object"; then
cannam@126 7371 # Prepend the subdirectory the object is found in.
cannam@126 7372 non_pic_object=$xdir$non_pic_object
cannam@126 7373
cannam@126 7374 # A standard non-PIC object
cannam@126 7375 func_append non_pic_objects " $non_pic_object"
cannam@126 7376 if test -z "$pic_object" || test none = "$pic_object"; then
cannam@126 7377 arg=$non_pic_object
cannam@126 7378 fi
cannam@126 7379 else
cannam@126 7380 # If the PIC object exists, use it instead.
cannam@126 7381 # $xdir was prepended to $pic_object above.
cannam@126 7382 non_pic_object=$pic_object
cannam@126 7383 func_append non_pic_objects " $non_pic_object"
cannam@126 7384 fi
cannam@126 7385 else
cannam@126 7386 # Only an error if not doing a dry-run.
cannam@126 7387 if $opt_dry_run; then
cannam@126 7388 # Extract subdirectory from the argument.
cannam@126 7389 func_dirname "$arg" "/" ""
cannam@126 7390 xdir=$func_dirname_result
cannam@126 7391
cannam@126 7392 func_lo2o "$arg"
cannam@126 7393 pic_object=$xdir$objdir/$func_lo2o_result
cannam@126 7394 non_pic_object=$xdir$func_lo2o_result
cannam@126 7395 func_append libobjs " $pic_object"
cannam@126 7396 func_append non_pic_objects " $non_pic_object"
cannam@126 7397 else
cannam@126 7398 func_fatal_error "'$arg' is not a valid libtool object"
cannam@126 7399 fi
cannam@126 7400 fi
cannam@126 7401 ;;
cannam@126 7402
cannam@126 7403 *.$libext)
cannam@126 7404 # An archive.
cannam@126 7405 func_append deplibs " $arg"
cannam@126 7406 func_append old_deplibs " $arg"
cannam@126 7407 continue
cannam@126 7408 ;;
cannam@126 7409
cannam@126 7410 *.la)
cannam@126 7411 # A libtool-controlled library.
cannam@126 7412
cannam@126 7413 func_resolve_sysroot "$arg"
cannam@126 7414 if test dlfiles = "$prev"; then
cannam@126 7415 # This library was specified with -dlopen.
cannam@126 7416 func_append dlfiles " $func_resolve_sysroot_result"
cannam@126 7417 prev=
cannam@126 7418 elif test dlprefiles = "$prev"; then
cannam@126 7419 # The library was specified with -dlpreopen.
cannam@126 7420 func_append dlprefiles " $func_resolve_sysroot_result"
cannam@126 7421 prev=
cannam@126 7422 else
cannam@126 7423 func_append deplibs " $func_resolve_sysroot_result"
cannam@126 7424 fi
cannam@126 7425 continue
cannam@126 7426 ;;
cannam@126 7427
cannam@126 7428 # Some other compiler argument.
cannam@126 7429 *)
cannam@126 7430 # Unknown arguments in both finalize_command and compile_command need
cannam@126 7431 # to be aesthetically quoted because they are evaled later.
cannam@126 7432 func_quote_for_eval "$arg"
cannam@126 7433 arg=$func_quote_for_eval_result
cannam@126 7434 ;;
cannam@126 7435 esac # arg
cannam@126 7436
cannam@126 7437 # Now actually substitute the argument into the commands.
cannam@126 7438 if test -n "$arg"; then
cannam@126 7439 func_append compile_command " $arg"
cannam@126 7440 func_append finalize_command " $arg"
cannam@126 7441 fi
cannam@126 7442 done # argument parsing loop
cannam@126 7443
cannam@126 7444 test -n "$prev" && \
cannam@126 7445 func_fatal_help "the '$prevarg' option requires an argument"
cannam@126 7446
cannam@126 7447 if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
cannam@126 7448 eval arg=\"$export_dynamic_flag_spec\"
cannam@126 7449 func_append compile_command " $arg"
cannam@126 7450 func_append finalize_command " $arg"
cannam@126 7451 fi
cannam@126 7452
cannam@126 7453 oldlibs=
cannam@126 7454 # calculate the name of the file, without its directory
cannam@126 7455 func_basename "$output"
cannam@126 7456 outputname=$func_basename_result
cannam@126 7457 libobjs_save=$libobjs
cannam@126 7458
cannam@126 7459 if test -n "$shlibpath_var"; then
cannam@126 7460 # get the directories listed in $shlibpath_var
cannam@126 7461 eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
cannam@126 7462 else
cannam@126 7463 shlib_search_path=
cannam@126 7464 fi
cannam@126 7465 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
cannam@126 7466 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
cannam@126 7467
cannam@126 7468 # Definition is injected by LT_CONFIG during libtool generation.
cannam@126 7469 func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
cannam@126 7470
cannam@126 7471 func_dirname "$output" "/" ""
cannam@126 7472 output_objdir=$func_dirname_result$objdir
cannam@126 7473 func_to_tool_file "$output_objdir/"
cannam@126 7474 tool_output_objdir=$func_to_tool_file_result
cannam@126 7475 # Create the object directory.
cannam@126 7476 func_mkdir_p "$output_objdir"
cannam@126 7477
cannam@126 7478 # Determine the type of output
cannam@126 7479 case $output in
cannam@126 7480 "")
cannam@126 7481 func_fatal_help "you must specify an output file"
cannam@126 7482 ;;
cannam@126 7483 *.$libext) linkmode=oldlib ;;
cannam@126 7484 *.lo | *.$objext) linkmode=obj ;;
cannam@126 7485 *.la) linkmode=lib ;;
cannam@126 7486 *) linkmode=prog ;; # Anything else should be a program.
cannam@126 7487 esac
cannam@126 7488
cannam@126 7489 specialdeplibs=
cannam@126 7490
cannam@126 7491 libs=
cannam@126 7492 # Find all interdependent deplibs by searching for libraries
cannam@126 7493 # that are linked more than once (e.g. -la -lb -la)
cannam@126 7494 for deplib in $deplibs; do
cannam@126 7495 if $opt_preserve_dup_deps; then
cannam@126 7496 case "$libs " in
cannam@126 7497 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
cannam@126 7498 esac
cannam@126 7499 fi
cannam@126 7500 func_append libs " $deplib"
cannam@126 7501 done
cannam@126 7502
cannam@126 7503 if test lib = "$linkmode"; then
cannam@126 7504 libs="$predeps $libs $compiler_lib_search_path $postdeps"
cannam@126 7505
cannam@126 7506 # Compute libraries that are listed more than once in $predeps
cannam@126 7507 # $postdeps and mark them as special (i.e., whose duplicates are
cannam@126 7508 # not to be eliminated).
cannam@126 7509 pre_post_deps=
cannam@126 7510 if $opt_duplicate_compiler_generated_deps; then
cannam@126 7511 for pre_post_dep in $predeps $postdeps; do
cannam@126 7512 case "$pre_post_deps " in
cannam@126 7513 *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
cannam@126 7514 esac
cannam@126 7515 func_append pre_post_deps " $pre_post_dep"
cannam@126 7516 done
cannam@126 7517 fi
cannam@126 7518 pre_post_deps=
cannam@126 7519 fi
cannam@126 7520
cannam@126 7521 deplibs=
cannam@126 7522 newdependency_libs=
cannam@126 7523 newlib_search_path=
cannam@126 7524 need_relink=no # whether we're linking any uninstalled libtool libraries
cannam@126 7525 notinst_deplibs= # not-installed libtool libraries
cannam@126 7526 notinst_path= # paths that contain not-installed libtool libraries
cannam@126 7527
cannam@126 7528 case $linkmode in
cannam@126 7529 lib)
cannam@126 7530 passes="conv dlpreopen link"
cannam@126 7531 for file in $dlfiles $dlprefiles; do
cannam@126 7532 case $file in
cannam@126 7533 *.la) ;;
cannam@126 7534 *)
cannam@126 7535 func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
cannam@126 7536 ;;
cannam@126 7537 esac
cannam@126 7538 done
cannam@126 7539 ;;
cannam@126 7540 prog)
cannam@126 7541 compile_deplibs=
cannam@126 7542 finalize_deplibs=
cannam@126 7543 alldeplibs=false
cannam@126 7544 newdlfiles=
cannam@126 7545 newdlprefiles=
cannam@126 7546 passes="conv scan dlopen dlpreopen link"
cannam@126 7547 ;;
cannam@126 7548 *) passes="conv"
cannam@126 7549 ;;
cannam@126 7550 esac
cannam@126 7551
cannam@126 7552 for pass in $passes; do
cannam@126 7553 # The preopen pass in lib mode reverses $deplibs; put it back here
cannam@126 7554 # so that -L comes before libs that need it for instance...
cannam@126 7555 if test lib,link = "$linkmode,$pass"; then
cannam@126 7556 ## FIXME: Find the place where the list is rebuilt in the wrong
cannam@126 7557 ## order, and fix it there properly
cannam@126 7558 tmp_deplibs=
cannam@126 7559 for deplib in $deplibs; do
cannam@126 7560 tmp_deplibs="$deplib $tmp_deplibs"
cannam@126 7561 done
cannam@126 7562 deplibs=$tmp_deplibs
cannam@126 7563 fi
cannam@126 7564
cannam@126 7565 if test lib,link = "$linkmode,$pass" ||
cannam@126 7566 test prog,scan = "$linkmode,$pass"; then
cannam@126 7567 libs=$deplibs
cannam@126 7568 deplibs=
cannam@126 7569 fi
cannam@126 7570 if test prog = "$linkmode"; then
cannam@126 7571 case $pass in
cannam@126 7572 dlopen) libs=$dlfiles ;;
cannam@126 7573 dlpreopen) libs=$dlprefiles ;;
cannam@126 7574 link)
cannam@126 7575 libs="$deplibs %DEPLIBS%"
cannam@126 7576 test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
cannam@126 7577 ;;
cannam@126 7578 esac
cannam@126 7579 fi
cannam@126 7580 if test lib,dlpreopen = "$linkmode,$pass"; then
cannam@126 7581 # Collect and forward deplibs of preopened libtool libs
cannam@126 7582 for lib in $dlprefiles; do
cannam@126 7583 # Ignore non-libtool-libs
cannam@126 7584 dependency_libs=
cannam@126 7585 func_resolve_sysroot "$lib"
cannam@126 7586 case $lib in
cannam@126 7587 *.la) func_source "$func_resolve_sysroot_result" ;;
cannam@126 7588 esac
cannam@126 7589
cannam@126 7590 # Collect preopened libtool deplibs, except any this library
cannam@126 7591 # has declared as weak libs
cannam@126 7592 for deplib in $dependency_libs; do
cannam@126 7593 func_basename "$deplib"
cannam@126 7594 deplib_base=$func_basename_result
cannam@126 7595 case " $weak_libs " in
cannam@126 7596 *" $deplib_base "*) ;;
cannam@126 7597 *) func_append deplibs " $deplib" ;;
cannam@126 7598 esac
cannam@126 7599 done
cannam@126 7600 done
cannam@126 7601 libs=$dlprefiles
cannam@126 7602 fi
cannam@126 7603 if test dlopen = "$pass"; then
cannam@126 7604 # Collect dlpreopened libraries
cannam@126 7605 save_deplibs=$deplibs
cannam@126 7606 deplibs=
cannam@126 7607 fi
cannam@126 7608
cannam@126 7609 for deplib in $libs; do
cannam@126 7610 lib=
cannam@126 7611 found=false
cannam@126 7612 case $deplib in
cannam@126 7613 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
cannam@126 7614 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
cannam@126 7615 if test prog,link = "$linkmode,$pass"; then
cannam@126 7616 compile_deplibs="$deplib $compile_deplibs"
cannam@126 7617 finalize_deplibs="$deplib $finalize_deplibs"
cannam@126 7618 else
cannam@126 7619 func_append compiler_flags " $deplib"
cannam@126 7620 if test lib = "$linkmode"; then
cannam@126 7621 case "$new_inherited_linker_flags " in
cannam@126 7622 *" $deplib "*) ;;
cannam@126 7623 * ) func_append new_inherited_linker_flags " $deplib" ;;
cannam@126 7624 esac
cannam@126 7625 fi
cannam@126 7626 fi
cannam@126 7627 continue
cannam@126 7628 ;;
cannam@126 7629 -l*)
cannam@126 7630 if test lib != "$linkmode" && test prog != "$linkmode"; then
cannam@126 7631 func_warning "'-l' is ignored for archives/objects"
cannam@126 7632 continue
cannam@126 7633 fi
cannam@126 7634 func_stripname '-l' '' "$deplib"
cannam@126 7635 name=$func_stripname_result
cannam@126 7636 if test lib = "$linkmode"; then
cannam@126 7637 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
cannam@126 7638 else
cannam@126 7639 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
cannam@126 7640 fi
cannam@126 7641 for searchdir in $searchdirs; do
cannam@126 7642 for search_ext in .la $std_shrext .so .a; do
cannam@126 7643 # Search the libtool library
cannam@126 7644 lib=$searchdir/lib$name$search_ext
cannam@126 7645 if test -f "$lib"; then
cannam@126 7646 if test .la = "$search_ext"; then
cannam@126 7647 found=:
cannam@126 7648 else
cannam@126 7649 found=false
cannam@126 7650 fi
cannam@126 7651 break 2
cannam@126 7652 fi
cannam@126 7653 done
cannam@126 7654 done
cannam@126 7655 if $found; then
cannam@126 7656 # deplib is a libtool library
cannam@126 7657 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
cannam@126 7658 # We need to do some special things here, and not later.
cannam@126 7659 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@126 7660 case " $predeps $postdeps " in
cannam@126 7661 *" $deplib "*)
cannam@126 7662 if func_lalib_p "$lib"; then
cannam@126 7663 library_names=
cannam@126 7664 old_library=
cannam@126 7665 func_source "$lib"
cannam@126 7666 for l in $old_library $library_names; do
cannam@126 7667 ll=$l
cannam@126 7668 done
cannam@126 7669 if test "X$ll" = "X$old_library"; then # only static version available
cannam@126 7670 found=false
cannam@126 7671 func_dirname "$lib" "" "."
cannam@126 7672 ladir=$func_dirname_result
cannam@126 7673 lib=$ladir/$old_library
cannam@126 7674 if test prog,link = "$linkmode,$pass"; then
cannam@126 7675 compile_deplibs="$deplib $compile_deplibs"
cannam@126 7676 finalize_deplibs="$deplib $finalize_deplibs"
cannam@126 7677 else
cannam@126 7678 deplibs="$deplib $deplibs"
cannam@126 7679 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
cannam@126 7680 fi
cannam@126 7681 continue
cannam@126 7682 fi
cannam@126 7683 fi
cannam@126 7684 ;;
cannam@126 7685 *) ;;
cannam@126 7686 esac
cannam@126 7687 fi
cannam@126 7688 else
cannam@126 7689 # deplib doesn't seem to be a libtool library
cannam@126 7690 if test prog,link = "$linkmode,$pass"; then
cannam@126 7691 compile_deplibs="$deplib $compile_deplibs"
cannam@126 7692 finalize_deplibs="$deplib $finalize_deplibs"
cannam@126 7693 else
cannam@126 7694 deplibs="$deplib $deplibs"
cannam@126 7695 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
cannam@126 7696 fi
cannam@126 7697 continue
cannam@126 7698 fi
cannam@126 7699 ;; # -l
cannam@126 7700 *.ltframework)
cannam@126 7701 if test prog,link = "$linkmode,$pass"; then
cannam@126 7702 compile_deplibs="$deplib $compile_deplibs"
cannam@126 7703 finalize_deplibs="$deplib $finalize_deplibs"
cannam@126 7704 else
cannam@126 7705 deplibs="$deplib $deplibs"
cannam@126 7706 if test lib = "$linkmode"; then
cannam@126 7707 case "$new_inherited_linker_flags " in
cannam@126 7708 *" $deplib "*) ;;
cannam@126 7709 * ) func_append new_inherited_linker_flags " $deplib" ;;
cannam@126 7710 esac
cannam@126 7711 fi
cannam@126 7712 fi
cannam@126 7713 continue
cannam@126 7714 ;;
cannam@126 7715 -L*)
cannam@126 7716 case $linkmode in
cannam@126 7717 lib)
cannam@126 7718 deplibs="$deplib $deplibs"
cannam@126 7719 test conv = "$pass" && continue
cannam@126 7720 newdependency_libs="$deplib $newdependency_libs"
cannam@126 7721 func_stripname '-L' '' "$deplib"
cannam@126 7722 func_resolve_sysroot "$func_stripname_result"
cannam@126 7723 func_append newlib_search_path " $func_resolve_sysroot_result"
cannam@126 7724 ;;
cannam@126 7725 prog)
cannam@126 7726 if test conv = "$pass"; then
cannam@126 7727 deplibs="$deplib $deplibs"
cannam@126 7728 continue
cannam@126 7729 fi
cannam@126 7730 if test scan = "$pass"; then
cannam@126 7731 deplibs="$deplib $deplibs"
cannam@126 7732 else
cannam@126 7733 compile_deplibs="$deplib $compile_deplibs"
cannam@126 7734 finalize_deplibs="$deplib $finalize_deplibs"
cannam@126 7735 fi
cannam@126 7736 func_stripname '-L' '' "$deplib"
cannam@126 7737 func_resolve_sysroot "$func_stripname_result"
cannam@126 7738 func_append newlib_search_path " $func_resolve_sysroot_result"
cannam@126 7739 ;;
cannam@126 7740 *)
cannam@126 7741 func_warning "'-L' is ignored for archives/objects"
cannam@126 7742 ;;
cannam@126 7743 esac # linkmode
cannam@126 7744 continue
cannam@126 7745 ;; # -L
cannam@126 7746 -R*)
cannam@126 7747 if test link = "$pass"; then
cannam@126 7748 func_stripname '-R' '' "$deplib"
cannam@126 7749 func_resolve_sysroot "$func_stripname_result"
cannam@126 7750 dir=$func_resolve_sysroot_result
cannam@126 7751 # Make sure the xrpath contains only unique directories.
cannam@126 7752 case "$xrpath " in
cannam@126 7753 *" $dir "*) ;;
cannam@126 7754 *) func_append xrpath " $dir" ;;
cannam@126 7755 esac
cannam@126 7756 fi
cannam@126 7757 deplibs="$deplib $deplibs"
cannam@126 7758 continue
cannam@126 7759 ;;
cannam@126 7760 *.la)
cannam@126 7761 func_resolve_sysroot "$deplib"
cannam@126 7762 lib=$func_resolve_sysroot_result
cannam@126 7763 ;;
cannam@126 7764 *.$libext)
cannam@126 7765 if test conv = "$pass"; then
cannam@126 7766 deplibs="$deplib $deplibs"
cannam@126 7767 continue
cannam@126 7768 fi
cannam@126 7769 case $linkmode in
cannam@126 7770 lib)
cannam@126 7771 # Linking convenience modules into shared libraries is allowed,
cannam@126 7772 # but linking other static libraries is non-portable.
cannam@126 7773 case " $dlpreconveniencelibs " in
cannam@126 7774 *" $deplib "*) ;;
cannam@126 7775 *)
cannam@126 7776 valid_a_lib=false
cannam@126 7777 case $deplibs_check_method in
cannam@126 7778 match_pattern*)
cannam@126 7779 set dummy $deplibs_check_method; shift
cannam@126 7780 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
cannam@126 7781 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
cannam@126 7782 | $EGREP "$match_pattern_regex" > /dev/null; then
cannam@126 7783 valid_a_lib=:
cannam@126 7784 fi
cannam@126 7785 ;;
cannam@126 7786 pass_all)
cannam@126 7787 valid_a_lib=:
cannam@126 7788 ;;
cannam@126 7789 esac
cannam@126 7790 if $valid_a_lib; then
cannam@126 7791 echo
cannam@126 7792 $ECHO "*** Warning: Linking the shared library $output against the"
cannam@126 7793 $ECHO "*** static library $deplib is not portable!"
cannam@126 7794 deplibs="$deplib $deplibs"
cannam@126 7795 else
cannam@126 7796 echo
cannam@126 7797 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
cannam@126 7798 echo "*** I have the capability to make that library automatically link in when"
cannam@126 7799 echo "*** you link to this library. But I can only do this if you have a"
cannam@126 7800 echo "*** shared version of the library, which you do not appear to have"
cannam@126 7801 echo "*** because the file extensions .$libext of this argument makes me believe"
cannam@126 7802 echo "*** that it is just a static archive that I should not use here."
cannam@126 7803 fi
cannam@126 7804 ;;
cannam@126 7805 esac
cannam@126 7806 continue
cannam@126 7807 ;;
cannam@126 7808 prog)
cannam@126 7809 if test link != "$pass"; then
cannam@126 7810 deplibs="$deplib $deplibs"
cannam@126 7811 else
cannam@126 7812 compile_deplibs="$deplib $compile_deplibs"
cannam@126 7813 finalize_deplibs="$deplib $finalize_deplibs"
cannam@126 7814 fi
cannam@126 7815 continue
cannam@126 7816 ;;
cannam@126 7817 esac # linkmode
cannam@126 7818 ;; # *.$libext
cannam@126 7819 *.lo | *.$objext)
cannam@126 7820 if test conv = "$pass"; then
cannam@126 7821 deplibs="$deplib $deplibs"
cannam@126 7822 elif test prog = "$linkmode"; then
cannam@126 7823 if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
cannam@126 7824 # If there is no dlopen support or we're linking statically,
cannam@126 7825 # we need to preload.
cannam@126 7826 func_append newdlprefiles " $deplib"
cannam@126 7827 compile_deplibs="$deplib $compile_deplibs"
cannam@126 7828 finalize_deplibs="$deplib $finalize_deplibs"
cannam@126 7829 else
cannam@126 7830 func_append newdlfiles " $deplib"
cannam@126 7831 fi
cannam@126 7832 fi
cannam@126 7833 continue
cannam@126 7834 ;;
cannam@126 7835 %DEPLIBS%)
cannam@126 7836 alldeplibs=:
cannam@126 7837 continue
cannam@126 7838 ;;
cannam@126 7839 esac # case $deplib
cannam@126 7840
cannam@126 7841 $found || test -f "$lib" \
cannam@126 7842 || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
cannam@126 7843
cannam@126 7844 # Check to see that this really is a libtool archive.
cannam@126 7845 func_lalib_unsafe_p "$lib" \
cannam@126 7846 || func_fatal_error "'$lib' is not a valid libtool archive"
cannam@126 7847
cannam@126 7848 func_dirname "$lib" "" "."
cannam@126 7849 ladir=$func_dirname_result
cannam@126 7850
cannam@126 7851 dlname=
cannam@126 7852 dlopen=
cannam@126 7853 dlpreopen=
cannam@126 7854 libdir=
cannam@126 7855 library_names=
cannam@126 7856 old_library=
cannam@126 7857 inherited_linker_flags=
cannam@126 7858 # If the library was installed with an old release of libtool,
cannam@126 7859 # it will not redefine variables installed, or shouldnotlink
cannam@126 7860 installed=yes
cannam@126 7861 shouldnotlink=no
cannam@126 7862 avoidtemprpath=
cannam@126 7863
cannam@126 7864
cannam@126 7865 # Read the .la file
cannam@126 7866 func_source "$lib"
cannam@126 7867
cannam@126 7868 # Convert "-framework foo" to "foo.ltframework"
cannam@126 7869 if test -n "$inherited_linker_flags"; then
cannam@126 7870 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
cannam@126 7871 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
cannam@126 7872 case " $new_inherited_linker_flags " in
cannam@126 7873 *" $tmp_inherited_linker_flag "*) ;;
cannam@126 7874 *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
cannam@126 7875 esac
cannam@126 7876 done
cannam@126 7877 fi
cannam@126 7878 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@126 7879 if test lib,link = "$linkmode,$pass" ||
cannam@126 7880 test prog,scan = "$linkmode,$pass" ||
cannam@126 7881 { test prog != "$linkmode" && test lib != "$linkmode"; }; then
cannam@126 7882 test -n "$dlopen" && func_append dlfiles " $dlopen"
cannam@126 7883 test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
cannam@126 7884 fi
cannam@126 7885
cannam@126 7886 if test conv = "$pass"; then
cannam@126 7887 # Only check for convenience libraries
cannam@126 7888 deplibs="$lib $deplibs"
cannam@126 7889 if test -z "$libdir"; then
cannam@126 7890 if test -z "$old_library"; then
cannam@126 7891 func_fatal_error "cannot find name of link library for '$lib'"
cannam@126 7892 fi
cannam@126 7893 # It is a libtool convenience library, so add in its objects.
cannam@126 7894 func_append convenience " $ladir/$objdir/$old_library"
cannam@126 7895 func_append old_convenience " $ladir/$objdir/$old_library"
cannam@126 7896 tmp_libs=
cannam@126 7897 for deplib in $dependency_libs; do
cannam@126 7898 deplibs="$deplib $deplibs"
cannam@126 7899 if $opt_preserve_dup_deps; then
cannam@126 7900 case "$tmp_libs " in
cannam@126 7901 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
cannam@126 7902 esac
cannam@126 7903 fi
cannam@126 7904 func_append tmp_libs " $deplib"
cannam@126 7905 done
cannam@126 7906 elif test prog != "$linkmode" && test lib != "$linkmode"; then
cannam@126 7907 func_fatal_error "'$lib' is not a convenience library"
cannam@126 7908 fi
cannam@126 7909 continue
cannam@126 7910 fi # $pass = conv
cannam@126 7911
cannam@126 7912
cannam@126 7913 # Get the name of the library we link against.
cannam@126 7914 linklib=
cannam@126 7915 if test -n "$old_library" &&
cannam@126 7916 { test yes = "$prefer_static_libs" ||
cannam@126 7917 test built,no = "$prefer_static_libs,$installed"; }; then
cannam@126 7918 linklib=$old_library
cannam@126 7919 else
cannam@126 7920 for l in $old_library $library_names; do
cannam@126 7921 linklib=$l
cannam@126 7922 done
cannam@126 7923 fi
cannam@126 7924 if test -z "$linklib"; then
cannam@126 7925 func_fatal_error "cannot find name of link library for '$lib'"
cannam@126 7926 fi
cannam@126 7927
cannam@126 7928 # This library was specified with -dlopen.
cannam@126 7929 if test dlopen = "$pass"; then
cannam@126 7930 test -z "$libdir" \
cannam@126 7931 && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
cannam@126 7932 if test -z "$dlname" ||
cannam@126 7933 test yes != "$dlopen_support" ||
cannam@126 7934 test no = "$build_libtool_libs"
cannam@126 7935 then
cannam@126 7936 # If there is no dlname, no dlopen support or we're linking
cannam@126 7937 # statically, we need to preload. We also need to preload any
cannam@126 7938 # dependent libraries so libltdl's deplib preloader doesn't
cannam@126 7939 # bomb out in the load deplibs phase.
cannam@126 7940 func_append dlprefiles " $lib $dependency_libs"
cannam@126 7941 else
cannam@126 7942 func_append newdlfiles " $lib"
cannam@126 7943 fi
cannam@126 7944 continue
cannam@126 7945 fi # $pass = dlopen
cannam@126 7946
cannam@126 7947 # We need an absolute path.
cannam@126 7948 case $ladir in
cannam@126 7949 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
cannam@126 7950 *)
cannam@126 7951 abs_ladir=`cd "$ladir" && pwd`
cannam@126 7952 if test -z "$abs_ladir"; then
cannam@126 7953 func_warning "cannot determine absolute directory name of '$ladir'"
cannam@126 7954 func_warning "passing it literally to the linker, although it might fail"
cannam@126 7955 abs_ladir=$ladir
cannam@126 7956 fi
cannam@126 7957 ;;
cannam@126 7958 esac
cannam@126 7959 func_basename "$lib"
cannam@126 7960 laname=$func_basename_result
cannam@126 7961
cannam@126 7962 # Find the relevant object directory and library name.
cannam@126 7963 if test yes = "$installed"; then
cannam@126 7964 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
cannam@126 7965 func_warning "library '$lib' was moved."
cannam@126 7966 dir=$ladir
cannam@126 7967 absdir=$abs_ladir
cannam@126 7968 libdir=$abs_ladir
cannam@126 7969 else
cannam@126 7970 dir=$lt_sysroot$libdir
cannam@126 7971 absdir=$lt_sysroot$libdir
cannam@126 7972 fi
cannam@126 7973 test yes = "$hardcode_automatic" && avoidtemprpath=yes
cannam@126 7974 else
cannam@126 7975 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
cannam@126 7976 dir=$ladir
cannam@126 7977 absdir=$abs_ladir
cannam@126 7978 # Remove this search path later
cannam@126 7979 func_append notinst_path " $abs_ladir"
cannam@126 7980 else
cannam@126 7981 dir=$ladir/$objdir
cannam@126 7982 absdir=$abs_ladir/$objdir
cannam@126 7983 # Remove this search path later
cannam@126 7984 func_append notinst_path " $abs_ladir"
cannam@126 7985 fi
cannam@126 7986 fi # $installed = yes
cannam@126 7987 func_stripname 'lib' '.la' "$laname"
cannam@126 7988 name=$func_stripname_result
cannam@126 7989
cannam@126 7990 # This library was specified with -dlpreopen.
cannam@126 7991 if test dlpreopen = "$pass"; then
cannam@126 7992 if test -z "$libdir" && test prog = "$linkmode"; then
cannam@126 7993 func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
cannam@126 7994 fi
cannam@126 7995 case $host in
cannam@126 7996 # special handling for platforms with PE-DLLs.
cannam@126 7997 *cygwin* | *mingw* | *cegcc* )
cannam@126 7998 # Linker will automatically link against shared library if both
cannam@126 7999 # static and shared are present. Therefore, ensure we extract
cannam@126 8000 # symbols from the import library if a shared library is present
cannam@126 8001 # (otherwise, the dlopen module name will be incorrect). We do
cannam@126 8002 # this by putting the import library name into $newdlprefiles.
cannam@126 8003 # We recover the dlopen module name by 'saving' the la file
cannam@126 8004 # name in a special purpose variable, and (later) extracting the
cannam@126 8005 # dlname from the la file.
cannam@126 8006 if test -n "$dlname"; then
cannam@126 8007 func_tr_sh "$dir/$linklib"
cannam@126 8008 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
cannam@126 8009 func_append newdlprefiles " $dir/$linklib"
cannam@126 8010 else
cannam@126 8011 func_append newdlprefiles " $dir/$old_library"
cannam@126 8012 # Keep a list of preopened convenience libraries to check
cannam@126 8013 # that they are being used correctly in the link pass.
cannam@126 8014 test -z "$libdir" && \
cannam@126 8015 func_append dlpreconveniencelibs " $dir/$old_library"
cannam@126 8016 fi
cannam@126 8017 ;;
cannam@126 8018 * )
cannam@126 8019 # Prefer using a static library (so that no silly _DYNAMIC symbols
cannam@126 8020 # are required to link).
cannam@126 8021 if test -n "$old_library"; then
cannam@126 8022 func_append newdlprefiles " $dir/$old_library"
cannam@126 8023 # Keep a list of preopened convenience libraries to check
cannam@126 8024 # that they are being used correctly in the link pass.
cannam@126 8025 test -z "$libdir" && \
cannam@126 8026 func_append dlpreconveniencelibs " $dir/$old_library"
cannam@126 8027 # Otherwise, use the dlname, so that lt_dlopen finds it.
cannam@126 8028 elif test -n "$dlname"; then
cannam@126 8029 func_append newdlprefiles " $dir/$dlname"
cannam@126 8030 else
cannam@126 8031 func_append newdlprefiles " $dir/$linklib"
cannam@126 8032 fi
cannam@126 8033 ;;
cannam@126 8034 esac
cannam@126 8035 fi # $pass = dlpreopen
cannam@126 8036
cannam@126 8037 if test -z "$libdir"; then
cannam@126 8038 # Link the convenience library
cannam@126 8039 if test lib = "$linkmode"; then
cannam@126 8040 deplibs="$dir/$old_library $deplibs"
cannam@126 8041 elif test prog,link = "$linkmode,$pass"; then
cannam@126 8042 compile_deplibs="$dir/$old_library $compile_deplibs"
cannam@126 8043 finalize_deplibs="$dir/$old_library $finalize_deplibs"
cannam@126 8044 else
cannam@126 8045 deplibs="$lib $deplibs" # used for prog,scan pass
cannam@126 8046 fi
cannam@126 8047 continue
cannam@126 8048 fi
cannam@126 8049
cannam@126 8050
cannam@126 8051 if test prog = "$linkmode" && test link != "$pass"; then
cannam@126 8052 func_append newlib_search_path " $ladir"
cannam@126 8053 deplibs="$lib $deplibs"
cannam@126 8054
cannam@126 8055 linkalldeplibs=false
cannam@126 8056 if test no != "$link_all_deplibs" || test -z "$library_names" ||
cannam@126 8057 test no = "$build_libtool_libs"; then
cannam@126 8058 linkalldeplibs=:
cannam@126 8059 fi
cannam@126 8060
cannam@126 8061 tmp_libs=
cannam@126 8062 for deplib in $dependency_libs; do
cannam@126 8063 case $deplib in
cannam@126 8064 -L*) func_stripname '-L' '' "$deplib"
cannam@126 8065 func_resolve_sysroot "$func_stripname_result"
cannam@126 8066 func_append newlib_search_path " $func_resolve_sysroot_result"
cannam@126 8067 ;;
cannam@126 8068 esac
cannam@126 8069 # Need to link against all dependency_libs?
cannam@126 8070 if $linkalldeplibs; then
cannam@126 8071 deplibs="$deplib $deplibs"
cannam@126 8072 else
cannam@126 8073 # Need to hardcode shared library paths
cannam@126 8074 # or/and link against static libraries
cannam@126 8075 newdependency_libs="$deplib $newdependency_libs"
cannam@126 8076 fi
cannam@126 8077 if $opt_preserve_dup_deps; then
cannam@126 8078 case "$tmp_libs " in
cannam@126 8079 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
cannam@126 8080 esac
cannam@126 8081 fi
cannam@126 8082 func_append tmp_libs " $deplib"
cannam@126 8083 done # for deplib
cannam@126 8084 continue
cannam@126 8085 fi # $linkmode = prog...
cannam@126 8086
cannam@126 8087 if test prog,link = "$linkmode,$pass"; then
cannam@126 8088 if test -n "$library_names" &&
cannam@126 8089 { { test no = "$prefer_static_libs" ||
cannam@126 8090 test built,yes = "$prefer_static_libs,$installed"; } ||
cannam@126 8091 test -z "$old_library"; }; then
cannam@126 8092 # We need to hardcode the library path
cannam@126 8093 if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
cannam@126 8094 # Make sure the rpath contains only unique directories.
cannam@126 8095 case $temp_rpath: in
cannam@126 8096 *"$absdir:"*) ;;
cannam@126 8097 *) func_append temp_rpath "$absdir:" ;;
cannam@126 8098 esac
cannam@126 8099 fi
cannam@126 8100
cannam@126 8101 # Hardcode the library path.
cannam@126 8102 # Skip directories that are in the system default run-time
cannam@126 8103 # search path.
cannam@126 8104 case " $sys_lib_dlsearch_path " in
cannam@126 8105 *" $absdir "*) ;;
cannam@126 8106 *)
cannam@126 8107 case "$compile_rpath " in
cannam@126 8108 *" $absdir "*) ;;
cannam@126 8109 *) func_append compile_rpath " $absdir" ;;
cannam@126 8110 esac
cannam@126 8111 ;;
cannam@126 8112 esac
cannam@126 8113 case " $sys_lib_dlsearch_path " in
cannam@126 8114 *" $libdir "*) ;;
cannam@126 8115 *)
cannam@126 8116 case "$finalize_rpath " in
cannam@126 8117 *" $libdir "*) ;;
cannam@126 8118 *) func_append finalize_rpath " $libdir" ;;
cannam@126 8119 esac
cannam@126 8120 ;;
cannam@126 8121 esac
cannam@126 8122 fi # $linkmode,$pass = prog,link...
cannam@126 8123
cannam@126 8124 if $alldeplibs &&
cannam@126 8125 { test pass_all = "$deplibs_check_method" ||
cannam@126 8126 { test yes = "$build_libtool_libs" &&
cannam@126 8127 test -n "$library_names"; }; }; then
cannam@126 8128 # We only need to search for static libraries
cannam@126 8129 continue
cannam@126 8130 fi
cannam@126 8131 fi
cannam@126 8132
cannam@126 8133 link_static=no # Whether the deplib will be linked statically
cannam@126 8134 use_static_libs=$prefer_static_libs
cannam@126 8135 if test built = "$use_static_libs" && test yes = "$installed"; then
cannam@126 8136 use_static_libs=no
cannam@126 8137 fi
cannam@126 8138 if test -n "$library_names" &&
cannam@126 8139 { test no = "$use_static_libs" || test -z "$old_library"; }; then
cannam@126 8140 case $host in
cannam@126 8141 *cygwin* | *mingw* | *cegcc* | *os2*)
cannam@126 8142 # No point in relinking DLLs because paths are not encoded
cannam@126 8143 func_append notinst_deplibs " $lib"
cannam@126 8144 need_relink=no
cannam@126 8145 ;;
cannam@126 8146 *)
cannam@126 8147 if test no = "$installed"; then
cannam@126 8148 func_append notinst_deplibs " $lib"
cannam@126 8149 need_relink=yes
cannam@126 8150 fi
cannam@126 8151 ;;
cannam@126 8152 esac
cannam@126 8153 # This is a shared library
cannam@126 8154
cannam@126 8155 # Warn about portability, can't link against -module's on some
cannam@126 8156 # systems (darwin). Don't bleat about dlopened modules though!
cannam@126 8157 dlopenmodule=
cannam@126 8158 for dlpremoduletest in $dlprefiles; do
cannam@126 8159 if test "X$dlpremoduletest" = "X$lib"; then
cannam@126 8160 dlopenmodule=$dlpremoduletest
cannam@126 8161 break
cannam@126 8162 fi
cannam@126 8163 done
cannam@126 8164 if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
cannam@126 8165 echo
cannam@126 8166 if test prog = "$linkmode"; then
cannam@126 8167 $ECHO "*** Warning: Linking the executable $output against the loadable module"
cannam@126 8168 else
cannam@126 8169 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
cannam@126 8170 fi
cannam@126 8171 $ECHO "*** $linklib is not portable!"
cannam@126 8172 fi
cannam@126 8173 if test lib = "$linkmode" &&
cannam@126 8174 test yes = "$hardcode_into_libs"; then
cannam@126 8175 # Hardcode the library path.
cannam@126 8176 # Skip directories that are in the system default run-time
cannam@126 8177 # search path.
cannam@126 8178 case " $sys_lib_dlsearch_path " in
cannam@126 8179 *" $absdir "*) ;;
cannam@126 8180 *)
cannam@126 8181 case "$compile_rpath " in
cannam@126 8182 *" $absdir "*) ;;
cannam@126 8183 *) func_append compile_rpath " $absdir" ;;
cannam@126 8184 esac
cannam@126 8185 ;;
cannam@126 8186 esac
cannam@126 8187 case " $sys_lib_dlsearch_path " in
cannam@126 8188 *" $libdir "*) ;;
cannam@126 8189 *)
cannam@126 8190 case "$finalize_rpath " in
cannam@126 8191 *" $libdir "*) ;;
cannam@126 8192 *) func_append finalize_rpath " $libdir" ;;
cannam@126 8193 esac
cannam@126 8194 ;;
cannam@126 8195 esac
cannam@126 8196 fi
cannam@126 8197
cannam@126 8198 if test -n "$old_archive_from_expsyms_cmds"; then
cannam@126 8199 # figure out the soname
cannam@126 8200 set dummy $library_names
cannam@126 8201 shift
cannam@126 8202 realname=$1
cannam@126 8203 shift
cannam@126 8204 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@126 8205 # use dlname if we got it. it's perfectly good, no?
cannam@126 8206 if test -n "$dlname"; then
cannam@126 8207 soname=$dlname
cannam@126 8208 elif test -n "$soname_spec"; then
cannam@126 8209 # bleh windows
cannam@126 8210 case $host in
cannam@126 8211 *cygwin* | mingw* | *cegcc* | *os2*)
cannam@126 8212 func_arith $current - $age
cannam@126 8213 major=$func_arith_result
cannam@126 8214 versuffix=-$major
cannam@126 8215 ;;
cannam@126 8216 esac
cannam@126 8217 eval soname=\"$soname_spec\"
cannam@126 8218 else
cannam@126 8219 soname=$realname
cannam@126 8220 fi
cannam@126 8221
cannam@126 8222 # Make a new name for the extract_expsyms_cmds to use
cannam@126 8223 soroot=$soname
cannam@126 8224 func_basename "$soroot"
cannam@126 8225 soname=$func_basename_result
cannam@126 8226 func_stripname 'lib' '.dll' "$soname"
cannam@126 8227 newlib=libimp-$func_stripname_result.a
cannam@126 8228
cannam@126 8229 # If the library has no export list, then create one now
cannam@126 8230 if test -f "$output_objdir/$soname-def"; then :
cannam@126 8231 else
cannam@126 8232 func_verbose "extracting exported symbol list from '$soname'"
cannam@126 8233 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
cannam@126 8234 fi
cannam@126 8235
cannam@126 8236 # Create $newlib
cannam@126 8237 if test -f "$output_objdir/$newlib"; then :; else
cannam@126 8238 func_verbose "generating import library for '$soname'"
cannam@126 8239 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
cannam@126 8240 fi
cannam@126 8241 # make sure the library variables are pointing to the new library
cannam@126 8242 dir=$output_objdir
cannam@126 8243 linklib=$newlib
cannam@126 8244 fi # test -n "$old_archive_from_expsyms_cmds"
cannam@126 8245
cannam@126 8246 if test prog = "$linkmode" || test relink != "$opt_mode"; then
cannam@126 8247 add_shlibpath=
cannam@126 8248 add_dir=
cannam@126 8249 add=
cannam@126 8250 lib_linked=yes
cannam@126 8251 case $hardcode_action in
cannam@126 8252 immediate | unsupported)
cannam@126 8253 if test no = "$hardcode_direct"; then
cannam@126 8254 add=$dir/$linklib
cannam@126 8255 case $host in
cannam@126 8256 *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
cannam@126 8257 *-*-sysv4*uw2*) add_dir=-L$dir ;;
cannam@126 8258 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
cannam@126 8259 *-*-unixware7*) add_dir=-L$dir ;;
cannam@126 8260 *-*-darwin* )
cannam@126 8261 # if the lib is a (non-dlopened) module then we cannot
cannam@126 8262 # link against it, someone is ignoring the earlier warnings
cannam@126 8263 if /usr/bin/file -L $add 2> /dev/null |
cannam@126 8264 $GREP ": [^:]* bundle" >/dev/null; then
cannam@126 8265 if test "X$dlopenmodule" != "X$lib"; then
cannam@126 8266 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
cannam@126 8267 if test -z "$old_library"; then
cannam@126 8268 echo
cannam@126 8269 echo "*** And there doesn't seem to be a static archive available"
cannam@126 8270 echo "*** The link will probably fail, sorry"
cannam@126 8271 else
cannam@126 8272 add=$dir/$old_library
cannam@126 8273 fi
cannam@126 8274 elif test -n "$old_library"; then
cannam@126 8275 add=$dir/$old_library
cannam@126 8276 fi
cannam@126 8277 fi
cannam@126 8278 esac
cannam@126 8279 elif test no = "$hardcode_minus_L"; then
cannam@126 8280 case $host in
cannam@126 8281 *-*-sunos*) add_shlibpath=$dir ;;
cannam@126 8282 esac
cannam@126 8283 add_dir=-L$dir
cannam@126 8284 add=-l$name
cannam@126 8285 elif test no = "$hardcode_shlibpath_var"; then
cannam@126 8286 add_shlibpath=$dir
cannam@126 8287 add=-l$name
cannam@126 8288 else
cannam@126 8289 lib_linked=no
cannam@126 8290 fi
cannam@126 8291 ;;
cannam@126 8292 relink)
cannam@126 8293 if test yes = "$hardcode_direct" &&
cannam@126 8294 test no = "$hardcode_direct_absolute"; then
cannam@126 8295 add=$dir/$linklib
cannam@126 8296 elif test yes = "$hardcode_minus_L"; then
cannam@126 8297 add_dir=-L$absdir
cannam@126 8298 # Try looking first in the location we're being installed to.
cannam@126 8299 if test -n "$inst_prefix_dir"; then
cannam@126 8300 case $libdir in
cannam@126 8301 [\\/]*)
cannam@126 8302 func_append add_dir " -L$inst_prefix_dir$libdir"
cannam@126 8303 ;;
cannam@126 8304 esac
cannam@126 8305 fi
cannam@126 8306 add=-l$name
cannam@126 8307 elif test yes = "$hardcode_shlibpath_var"; then
cannam@126 8308 add_shlibpath=$dir
cannam@126 8309 add=-l$name
cannam@126 8310 else
cannam@126 8311 lib_linked=no
cannam@126 8312 fi
cannam@126 8313 ;;
cannam@126 8314 *) lib_linked=no ;;
cannam@126 8315 esac
cannam@126 8316
cannam@126 8317 if test yes != "$lib_linked"; then
cannam@126 8318 func_fatal_configuration "unsupported hardcode properties"
cannam@126 8319 fi
cannam@126 8320
cannam@126 8321 if test -n "$add_shlibpath"; then
cannam@126 8322 case :$compile_shlibpath: in
cannam@126 8323 *":$add_shlibpath:"*) ;;
cannam@126 8324 *) func_append compile_shlibpath "$add_shlibpath:" ;;
cannam@126 8325 esac
cannam@126 8326 fi
cannam@126 8327 if test prog = "$linkmode"; then
cannam@126 8328 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
cannam@126 8329 test -n "$add" && compile_deplibs="$add $compile_deplibs"
cannam@126 8330 else
cannam@126 8331 test -n "$add_dir" && deplibs="$add_dir $deplibs"
cannam@126 8332 test -n "$add" && deplibs="$add $deplibs"
cannam@126 8333 if test yes != "$hardcode_direct" &&
cannam@126 8334 test yes != "$hardcode_minus_L" &&
cannam@126 8335 test yes = "$hardcode_shlibpath_var"; then
cannam@126 8336 case :$finalize_shlibpath: in
cannam@126 8337 *":$libdir:"*) ;;
cannam@126 8338 *) func_append finalize_shlibpath "$libdir:" ;;
cannam@126 8339 esac
cannam@126 8340 fi
cannam@126 8341 fi
cannam@126 8342 fi
cannam@126 8343
cannam@126 8344 if test prog = "$linkmode" || test relink = "$opt_mode"; then
cannam@126 8345 add_shlibpath=
cannam@126 8346 add_dir=
cannam@126 8347 add=
cannam@126 8348 # Finalize command for both is simple: just hardcode it.
cannam@126 8349 if test yes = "$hardcode_direct" &&
cannam@126 8350 test no = "$hardcode_direct_absolute"; then
cannam@126 8351 add=$libdir/$linklib
cannam@126 8352 elif test yes = "$hardcode_minus_L"; then
cannam@126 8353 add_dir=-L$libdir
cannam@126 8354 add=-l$name
cannam@126 8355 elif test yes = "$hardcode_shlibpath_var"; then
cannam@126 8356 case :$finalize_shlibpath: in
cannam@126 8357 *":$libdir:"*) ;;
cannam@126 8358 *) func_append finalize_shlibpath "$libdir:" ;;
cannam@126 8359 esac
cannam@126 8360 add=-l$name
cannam@126 8361 elif test yes = "$hardcode_automatic"; then
cannam@126 8362 if test -n "$inst_prefix_dir" &&
cannam@126 8363 test -f "$inst_prefix_dir$libdir/$linklib"; then
cannam@126 8364 add=$inst_prefix_dir$libdir/$linklib
cannam@126 8365 else
cannam@126 8366 add=$libdir/$linklib
cannam@126 8367 fi
cannam@126 8368 else
cannam@126 8369 # We cannot seem to hardcode it, guess we'll fake it.
cannam@126 8370 add_dir=-L$libdir
cannam@126 8371 # Try looking first in the location we're being installed to.
cannam@126 8372 if test -n "$inst_prefix_dir"; then
cannam@126 8373 case $libdir in
cannam@126 8374 [\\/]*)
cannam@126 8375 func_append add_dir " -L$inst_prefix_dir$libdir"
cannam@126 8376 ;;
cannam@126 8377 esac
cannam@126 8378 fi
cannam@126 8379 add=-l$name
cannam@126 8380 fi
cannam@126 8381
cannam@126 8382 if test prog = "$linkmode"; then
cannam@126 8383 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
cannam@126 8384 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
cannam@126 8385 else
cannam@126 8386 test -n "$add_dir" && deplibs="$add_dir $deplibs"
cannam@126 8387 test -n "$add" && deplibs="$add $deplibs"
cannam@126 8388 fi
cannam@126 8389 fi
cannam@126 8390 elif test prog = "$linkmode"; then
cannam@126 8391 # Here we assume that one of hardcode_direct or hardcode_minus_L
cannam@126 8392 # is not unsupported. This is valid on all known static and
cannam@126 8393 # shared platforms.
cannam@126 8394 if test unsupported != "$hardcode_direct"; then
cannam@126 8395 test -n "$old_library" && linklib=$old_library
cannam@126 8396 compile_deplibs="$dir/$linklib $compile_deplibs"
cannam@126 8397 finalize_deplibs="$dir/$linklib $finalize_deplibs"
cannam@126 8398 else
cannam@126 8399 compile_deplibs="-l$name -L$dir $compile_deplibs"
cannam@126 8400 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
cannam@126 8401 fi
cannam@126 8402 elif test yes = "$build_libtool_libs"; then
cannam@126 8403 # Not a shared library
cannam@126 8404 if test pass_all != "$deplibs_check_method"; then
cannam@126 8405 # We're trying link a shared library against a static one
cannam@126 8406 # but the system doesn't support it.
cannam@126 8407
cannam@126 8408 # Just print a warning and add the library to dependency_libs so
cannam@126 8409 # that the program can be linked against the static library.
cannam@126 8410 echo
cannam@126 8411 $ECHO "*** Warning: This system cannot link to static lib archive $lib."
cannam@126 8412 echo "*** I have the capability to make that library automatically link in when"
cannam@126 8413 echo "*** you link to this library. But I can only do this if you have a"
cannam@126 8414 echo "*** shared version of the library, which you do not appear to have."
cannam@126 8415 if test yes = "$module"; then
cannam@126 8416 echo "*** But as you try to build a module library, libtool will still create "
cannam@126 8417 echo "*** a static module, that should work as long as the dlopening application"
cannam@126 8418 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
cannam@126 8419 if test -z "$global_symbol_pipe"; then
cannam@126 8420 echo
cannam@126 8421 echo "*** However, this would only work if libtool was able to extract symbol"
cannam@126 8422 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
cannam@126 8423 echo "*** not find such a program. So, this module is probably useless."
cannam@126 8424 echo "*** 'nm' from GNU binutils and a full rebuild may help."
cannam@126 8425 fi
cannam@126 8426 if test no = "$build_old_libs"; then
cannam@126 8427 build_libtool_libs=module
cannam@126 8428 build_old_libs=yes
cannam@126 8429 else
cannam@126 8430 build_libtool_libs=no
cannam@126 8431 fi
cannam@126 8432 fi
cannam@126 8433 else
cannam@126 8434 deplibs="$dir/$old_library $deplibs"
cannam@126 8435 link_static=yes
cannam@126 8436 fi
cannam@126 8437 fi # link shared/static library?
cannam@126 8438
cannam@126 8439 if test lib = "$linkmode"; then
cannam@126 8440 if test -n "$dependency_libs" &&
cannam@126 8441 { test yes != "$hardcode_into_libs" ||
cannam@126 8442 test yes = "$build_old_libs" ||
cannam@126 8443 test yes = "$link_static"; }; then
cannam@126 8444 # Extract -R from dependency_libs
cannam@126 8445 temp_deplibs=
cannam@126 8446 for libdir in $dependency_libs; do
cannam@126 8447 case $libdir in
cannam@126 8448 -R*) func_stripname '-R' '' "$libdir"
cannam@126 8449 temp_xrpath=$func_stripname_result
cannam@126 8450 case " $xrpath " in
cannam@126 8451 *" $temp_xrpath "*) ;;
cannam@126 8452 *) func_append xrpath " $temp_xrpath";;
cannam@126 8453 esac;;
cannam@126 8454 *) func_append temp_deplibs " $libdir";;
cannam@126 8455 esac
cannam@126 8456 done
cannam@126 8457 dependency_libs=$temp_deplibs
cannam@126 8458 fi
cannam@126 8459
cannam@126 8460 func_append newlib_search_path " $absdir"
cannam@126 8461 # Link against this library
cannam@126 8462 test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
cannam@126 8463 # ... and its dependency_libs
cannam@126 8464 tmp_libs=
cannam@126 8465 for deplib in $dependency_libs; do
cannam@126 8466 newdependency_libs="$deplib $newdependency_libs"
cannam@126 8467 case $deplib in
cannam@126 8468 -L*) func_stripname '-L' '' "$deplib"
cannam@126 8469 func_resolve_sysroot "$func_stripname_result";;
cannam@126 8470 *) func_resolve_sysroot "$deplib" ;;
cannam@126 8471 esac
cannam@126 8472 if $opt_preserve_dup_deps; then
cannam@126 8473 case "$tmp_libs " in
cannam@126 8474 *" $func_resolve_sysroot_result "*)
cannam@126 8475 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
cannam@126 8476 esac
cannam@126 8477 fi
cannam@126 8478 func_append tmp_libs " $func_resolve_sysroot_result"
cannam@126 8479 done
cannam@126 8480
cannam@126 8481 if test no != "$link_all_deplibs"; then
cannam@126 8482 # Add the search paths of all dependency libraries
cannam@126 8483 for deplib in $dependency_libs; do
cannam@126 8484 path=
cannam@126 8485 case $deplib in
cannam@126 8486 -L*) path=$deplib ;;
cannam@126 8487 *.la)
cannam@126 8488 func_resolve_sysroot "$deplib"
cannam@126 8489 deplib=$func_resolve_sysroot_result
cannam@126 8490 func_dirname "$deplib" "" "."
cannam@126 8491 dir=$func_dirname_result
cannam@126 8492 # We need an absolute path.
cannam@126 8493 case $dir in
cannam@126 8494 [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
cannam@126 8495 *)
cannam@126 8496 absdir=`cd "$dir" && pwd`
cannam@126 8497 if test -z "$absdir"; then
cannam@126 8498 func_warning "cannot determine absolute directory name of '$dir'"
cannam@126 8499 absdir=$dir
cannam@126 8500 fi
cannam@126 8501 ;;
cannam@126 8502 esac
cannam@126 8503 if $GREP "^installed=no" $deplib > /dev/null; then
cannam@126 8504 case $host in
cannam@126 8505 *-*-darwin*)
cannam@126 8506 depdepl=
cannam@126 8507 eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
cannam@126 8508 if test -n "$deplibrary_names"; then
cannam@126 8509 for tmp in $deplibrary_names; do
cannam@126 8510 depdepl=$tmp
cannam@126 8511 done
cannam@126 8512 if test -f "$absdir/$objdir/$depdepl"; then
cannam@126 8513 depdepl=$absdir/$objdir/$depdepl
cannam@126 8514 darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
cannam@126 8515 if test -z "$darwin_install_name"; then
cannam@126 8516 darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
cannam@126 8517 fi
cannam@126 8518 func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
cannam@126 8519 func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
cannam@126 8520 path=
cannam@126 8521 fi
cannam@126 8522 fi
cannam@126 8523 ;;
cannam@126 8524 *)
cannam@126 8525 path=-L$absdir/$objdir
cannam@126 8526 ;;
cannam@126 8527 esac
cannam@126 8528 else
cannam@126 8529 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
cannam@126 8530 test -z "$libdir" && \
cannam@126 8531 func_fatal_error "'$deplib' is not a valid libtool archive"
cannam@126 8532 test "$absdir" != "$libdir" && \
cannam@126 8533 func_warning "'$deplib' seems to be moved"
cannam@126 8534
cannam@126 8535 path=-L$absdir
cannam@126 8536 fi
cannam@126 8537 ;;
cannam@126 8538 esac
cannam@126 8539 case " $deplibs " in
cannam@126 8540 *" $path "*) ;;
cannam@126 8541 *) deplibs="$path $deplibs" ;;
cannam@126 8542 esac
cannam@126 8543 done
cannam@126 8544 fi # link_all_deplibs != no
cannam@126 8545 fi # linkmode = lib
cannam@126 8546 done # for deplib in $libs
cannam@126 8547 if test link = "$pass"; then
cannam@126 8548 if test prog = "$linkmode"; then
cannam@126 8549 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
cannam@126 8550 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
cannam@126 8551 else
cannam@126 8552 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@126 8553 fi
cannam@126 8554 fi
cannam@126 8555 dependency_libs=$newdependency_libs
cannam@126 8556 if test dlpreopen = "$pass"; then
cannam@126 8557 # Link the dlpreopened libraries before other libraries
cannam@126 8558 for deplib in $save_deplibs; do
cannam@126 8559 deplibs="$deplib $deplibs"
cannam@126 8560 done
cannam@126 8561 fi
cannam@126 8562 if test dlopen != "$pass"; then
cannam@126 8563 test conv = "$pass" || {
cannam@126 8564 # Make sure lib_search_path contains only unique directories.
cannam@126 8565 lib_search_path=
cannam@126 8566 for dir in $newlib_search_path; do
cannam@126 8567 case "$lib_search_path " in
cannam@126 8568 *" $dir "*) ;;
cannam@126 8569 *) func_append lib_search_path " $dir" ;;
cannam@126 8570 esac
cannam@126 8571 done
cannam@126 8572 newlib_search_path=
cannam@126 8573 }
cannam@126 8574
cannam@126 8575 if test prog,link = "$linkmode,$pass"; then
cannam@126 8576 vars="compile_deplibs finalize_deplibs"
cannam@126 8577 else
cannam@126 8578 vars=deplibs
cannam@126 8579 fi
cannam@126 8580 for var in $vars dependency_libs; do
cannam@126 8581 # Add libraries to $var in reverse order
cannam@126 8582 eval tmp_libs=\"\$$var\"
cannam@126 8583 new_libs=
cannam@126 8584 for deplib in $tmp_libs; do
cannam@126 8585 # FIXME: Pedantically, this is the right thing to do, so
cannam@126 8586 # that some nasty dependency loop isn't accidentally
cannam@126 8587 # broken:
cannam@126 8588 #new_libs="$deplib $new_libs"
cannam@126 8589 # Pragmatically, this seems to cause very few problems in
cannam@126 8590 # practice:
cannam@126 8591 case $deplib in
cannam@126 8592 -L*) new_libs="$deplib $new_libs" ;;
cannam@126 8593 -R*) ;;
cannam@126 8594 *)
cannam@126 8595 # And here is the reason: when a library appears more
cannam@126 8596 # than once as an explicit dependence of a library, or
cannam@126 8597 # is implicitly linked in more than once by the
cannam@126 8598 # compiler, it is considered special, and multiple
cannam@126 8599 # occurrences thereof are not removed. Compare this
cannam@126 8600 # with having the same library being listed as a
cannam@126 8601 # dependency of multiple other libraries: in this case,
cannam@126 8602 # we know (pedantically, we assume) the library does not
cannam@126 8603 # need to be listed more than once, so we keep only the
cannam@126 8604 # last copy. This is not always right, but it is rare
cannam@126 8605 # enough that we require users that really mean to play
cannam@126 8606 # such unportable linking tricks to link the library
cannam@126 8607 # using -Wl,-lname, so that libtool does not consider it
cannam@126 8608 # for duplicate removal.
cannam@126 8609 case " $specialdeplibs " in
cannam@126 8610 *" $deplib "*) new_libs="$deplib $new_libs" ;;
cannam@126 8611 *)
cannam@126 8612 case " $new_libs " in
cannam@126 8613 *" $deplib "*) ;;
cannam@126 8614 *) new_libs="$deplib $new_libs" ;;
cannam@126 8615 esac
cannam@126 8616 ;;
cannam@126 8617 esac
cannam@126 8618 ;;
cannam@126 8619 esac
cannam@126 8620 done
cannam@126 8621 tmp_libs=
cannam@126 8622 for deplib in $new_libs; do
cannam@126 8623 case $deplib in
cannam@126 8624 -L*)
cannam@126 8625 case " $tmp_libs " in
cannam@126 8626 *" $deplib "*) ;;
cannam@126 8627 *) func_append tmp_libs " $deplib" ;;
cannam@126 8628 esac
cannam@126 8629 ;;
cannam@126 8630 *) func_append tmp_libs " $deplib" ;;
cannam@126 8631 esac
cannam@126 8632 done
cannam@126 8633 eval $var=\"$tmp_libs\"
cannam@126 8634 done # for var
cannam@126 8635 fi
cannam@126 8636
cannam@126 8637 # Add Sun CC postdeps if required:
cannam@126 8638 test CXX = "$tagname" && {
cannam@126 8639 case $host_os in
cannam@126 8640 linux*)
cannam@126 8641 case `$CC -V 2>&1 | sed 5q` in
cannam@126 8642 *Sun\ C*) # Sun C++ 5.9
cannam@126 8643 func_suncc_cstd_abi
cannam@126 8644
cannam@126 8645 if test no != "$suncc_use_cstd_abi"; then
cannam@126 8646 func_append postdeps ' -library=Cstd -library=Crun'
cannam@126 8647 fi
cannam@126 8648 ;;
cannam@126 8649 esac
cannam@126 8650 ;;
cannam@126 8651
cannam@126 8652 solaris*)
cannam@126 8653 func_cc_basename "$CC"
cannam@126 8654 case $func_cc_basename_result in
cannam@126 8655 CC* | sunCC*)
cannam@126 8656 func_suncc_cstd_abi
cannam@126 8657
cannam@126 8658 if test no != "$suncc_use_cstd_abi"; then
cannam@126 8659 func_append postdeps ' -library=Cstd -library=Crun'
cannam@126 8660 fi
cannam@126 8661 ;;
cannam@126 8662 esac
cannam@126 8663 ;;
cannam@126 8664 esac
cannam@126 8665 }
cannam@126 8666
cannam@126 8667 # Last step: remove runtime libs from dependency_libs
cannam@126 8668 # (they stay in deplibs)
cannam@126 8669 tmp_libs=
cannam@126 8670 for i in $dependency_libs; do
cannam@126 8671 case " $predeps $postdeps $compiler_lib_search_path " in
cannam@126 8672 *" $i "*)
cannam@126 8673 i=
cannam@126 8674 ;;
cannam@126 8675 esac
cannam@126 8676 if test -n "$i"; then
cannam@126 8677 func_append tmp_libs " $i"
cannam@126 8678 fi
cannam@126 8679 done
cannam@126 8680 dependency_libs=$tmp_libs
cannam@126 8681 done # for pass
cannam@126 8682 if test prog = "$linkmode"; then
cannam@126 8683 dlfiles=$newdlfiles
cannam@126 8684 fi
cannam@126 8685 if test prog = "$linkmode" || test lib = "$linkmode"; then
cannam@126 8686 dlprefiles=$newdlprefiles
cannam@126 8687 fi
cannam@126 8688
cannam@126 8689 case $linkmode in
cannam@126 8690 oldlib)
cannam@126 8691 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
cannam@126 8692 func_warning "'-dlopen' is ignored for archives"
cannam@126 8693 fi
cannam@126 8694
cannam@126 8695 case " $deplibs" in
cannam@126 8696 *\ -l* | *\ -L*)
cannam@126 8697 func_warning "'-l' and '-L' are ignored for archives" ;;
cannam@126 8698 esac
cannam@126 8699
cannam@126 8700 test -n "$rpath" && \
cannam@126 8701 func_warning "'-rpath' is ignored for archives"
cannam@126 8702
cannam@126 8703 test -n "$xrpath" && \
cannam@126 8704 func_warning "'-R' is ignored for archives"
cannam@126 8705
cannam@126 8706 test -n "$vinfo" && \
cannam@126 8707 func_warning "'-version-info/-version-number' is ignored for archives"
cannam@126 8708
cannam@126 8709 test -n "$release" && \
cannam@126 8710 func_warning "'-release' is ignored for archives"
cannam@126 8711
cannam@126 8712 test -n "$export_symbols$export_symbols_regex" && \
cannam@126 8713 func_warning "'-export-symbols' is ignored for archives"
cannam@126 8714
cannam@126 8715 # Now set the variables for building old libraries.
cannam@126 8716 build_libtool_libs=no
cannam@126 8717 oldlibs=$output
cannam@126 8718 func_append objs "$old_deplibs"
cannam@126 8719 ;;
cannam@126 8720
cannam@126 8721 lib)
cannam@126 8722 # Make sure we only generate libraries of the form 'libNAME.la'.
cannam@126 8723 case $outputname in
cannam@126 8724 lib*)
cannam@126 8725 func_stripname 'lib' '.la' "$outputname"
cannam@126 8726 name=$func_stripname_result
cannam@126 8727 eval shared_ext=\"$shrext_cmds\"
cannam@126 8728 eval libname=\"$libname_spec\"
cannam@126 8729 ;;
cannam@126 8730 *)
cannam@126 8731 test no = "$module" \
cannam@126 8732 && func_fatal_help "libtool library '$output' must begin with 'lib'"
cannam@126 8733
cannam@126 8734 if test no != "$need_lib_prefix"; then
cannam@126 8735 # Add the "lib" prefix for modules if required
cannam@126 8736 func_stripname '' '.la' "$outputname"
cannam@126 8737 name=$func_stripname_result
cannam@126 8738 eval shared_ext=\"$shrext_cmds\"
cannam@126 8739 eval libname=\"$libname_spec\"
cannam@126 8740 else
cannam@126 8741 func_stripname '' '.la' "$outputname"
cannam@126 8742 libname=$func_stripname_result
cannam@126 8743 fi
cannam@126 8744 ;;
cannam@126 8745 esac
cannam@126 8746
cannam@126 8747 if test -n "$objs"; then
cannam@126 8748 if test pass_all != "$deplibs_check_method"; then
cannam@126 8749 func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
cannam@126 8750 else
cannam@126 8751 echo
cannam@126 8752 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
cannam@126 8753 $ECHO "*** objects $objs is not portable!"
cannam@126 8754 func_append libobjs " $objs"
cannam@126 8755 fi
cannam@126 8756 fi
cannam@126 8757
cannam@126 8758 test no = "$dlself" \
cannam@126 8759 || func_warning "'-dlopen self' is ignored for libtool libraries"
cannam@126 8760
cannam@126 8761 set dummy $rpath
cannam@126 8762 shift
cannam@126 8763 test 1 -lt "$#" \
cannam@126 8764 && func_warning "ignoring multiple '-rpath's for a libtool library"
cannam@126 8765
cannam@126 8766 install_libdir=$1
cannam@126 8767
cannam@126 8768 oldlibs=
cannam@126 8769 if test -z "$rpath"; then
cannam@126 8770 if test yes = "$build_libtool_libs"; then
cannam@126 8771 # Building a libtool convenience library.
cannam@126 8772 # Some compilers have problems with a '.al' extension so
cannam@126 8773 # convenience libraries should have the same extension an
cannam@126 8774 # archive normally would.
cannam@126 8775 oldlibs="$output_objdir/$libname.$libext $oldlibs"
cannam@126 8776 build_libtool_libs=convenience
cannam@126 8777 build_old_libs=yes
cannam@126 8778 fi
cannam@126 8779
cannam@126 8780 test -n "$vinfo" && \
cannam@126 8781 func_warning "'-version-info/-version-number' is ignored for convenience libraries"
cannam@126 8782
cannam@126 8783 test -n "$release" && \
cannam@126 8784 func_warning "'-release' is ignored for convenience libraries"
cannam@126 8785 else
cannam@126 8786
cannam@126 8787 # Parse the version information argument.
cannam@126 8788 save_ifs=$IFS; IFS=:
cannam@126 8789 set dummy $vinfo 0 0 0
cannam@126 8790 shift
cannam@126 8791 IFS=$save_ifs
cannam@126 8792
cannam@126 8793 test -n "$7" && \
cannam@126 8794 func_fatal_help "too many parameters to '-version-info'"
cannam@126 8795
cannam@126 8796 # convert absolute version numbers to libtool ages
cannam@126 8797 # this retains compatibility with .la files and attempts
cannam@126 8798 # to make the code below a bit more comprehensible
cannam@126 8799
cannam@126 8800 case $vinfo_number in
cannam@126 8801 yes)
cannam@126 8802 number_major=$1
cannam@126 8803 number_minor=$2
cannam@126 8804 number_revision=$3
cannam@126 8805 #
cannam@126 8806 # There are really only two kinds -- those that
cannam@126 8807 # use the current revision as the major version
cannam@126 8808 # and those that subtract age and use age as
cannam@126 8809 # a minor version. But, then there is irix
cannam@126 8810 # that has an extra 1 added just for fun
cannam@126 8811 #
cannam@126 8812 case $version_type in
cannam@126 8813 # correct linux to gnu/linux during the next big refactor
cannam@126 8814 darwin|freebsd-elf|linux|osf|windows|none)
cannam@126 8815 func_arith $number_major + $number_minor
cannam@126 8816 current=$func_arith_result
cannam@126 8817 age=$number_minor
cannam@126 8818 revision=$number_revision
cannam@126 8819 ;;
cannam@126 8820 freebsd-aout|qnx|sunos)
cannam@126 8821 current=$number_major
cannam@126 8822 revision=$number_minor
cannam@126 8823 age=0
cannam@126 8824 ;;
cannam@126 8825 irix|nonstopux)
cannam@126 8826 func_arith $number_major + $number_minor
cannam@126 8827 current=$func_arith_result
cannam@126 8828 age=$number_minor
cannam@126 8829 revision=$number_minor
cannam@126 8830 lt_irix_increment=no
cannam@126 8831 ;;
cannam@126 8832 *)
cannam@126 8833 func_fatal_configuration "$modename: unknown library version type '$version_type'"
cannam@126 8834 ;;
cannam@126 8835 esac
cannam@126 8836 ;;
cannam@126 8837 no)
cannam@126 8838 current=$1
cannam@126 8839 revision=$2
cannam@126 8840 age=$3
cannam@126 8841 ;;
cannam@126 8842 esac
cannam@126 8843
cannam@126 8844 # Check that each of the things are valid numbers.
cannam@126 8845 case $current in
cannam@126 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@126 8847 *)
cannam@126 8848 func_error "CURRENT '$current' must be a nonnegative integer"
cannam@126 8849 func_fatal_error "'$vinfo' is not valid version information"
cannam@126 8850 ;;
cannam@126 8851 esac
cannam@126 8852
cannam@126 8853 case $revision in
cannam@126 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@126 8855 *)
cannam@126 8856 func_error "REVISION '$revision' must be a nonnegative integer"
cannam@126 8857 func_fatal_error "'$vinfo' is not valid version information"
cannam@126 8858 ;;
cannam@126 8859 esac
cannam@126 8860
cannam@126 8861 case $age in
cannam@126 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@126 8863 *)
cannam@126 8864 func_error "AGE '$age' must be a nonnegative integer"
cannam@126 8865 func_fatal_error "'$vinfo' is not valid version information"
cannam@126 8866 ;;
cannam@126 8867 esac
cannam@126 8868
cannam@126 8869 if test "$age" -gt "$current"; then
cannam@126 8870 func_error "AGE '$age' is greater than the current interface number '$current'"
cannam@126 8871 func_fatal_error "'$vinfo' is not valid version information"
cannam@126 8872 fi
cannam@126 8873
cannam@126 8874 # Calculate the version variables.
cannam@126 8875 major=
cannam@126 8876 versuffix=
cannam@126 8877 verstring=
cannam@126 8878 case $version_type in
cannam@126 8879 none) ;;
cannam@126 8880
cannam@126 8881 darwin)
cannam@126 8882 # Like Linux, but with the current version available in
cannam@126 8883 # verstring for coding it into the library header
cannam@126 8884 func_arith $current - $age
cannam@126 8885 major=.$func_arith_result
cannam@126 8886 versuffix=$major.$age.$revision
cannam@126 8887 # Darwin ld doesn't like 0 for these options...
cannam@126 8888 func_arith $current + 1
cannam@126 8889 minor_current=$func_arith_result
cannam@126 8890 xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
cannam@126 8891 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
cannam@126 8892 # On Darwin other compilers
cannam@126 8893 case $CC in
cannam@126 8894 nagfor*)
cannam@126 8895 verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
cannam@126 8896 ;;
cannam@126 8897 *)
cannam@126 8898 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
cannam@126 8899 ;;
cannam@126 8900 esac
cannam@126 8901 ;;
cannam@126 8902
cannam@126 8903 freebsd-aout)
cannam@126 8904 major=.$current
cannam@126 8905 versuffix=.$current.$revision
cannam@126 8906 ;;
cannam@126 8907
cannam@126 8908 freebsd-elf)
cannam@126 8909 func_arith $current - $age
cannam@126 8910 major=.$func_arith_result
cannam@126 8911 versuffix=$major.$age.$revision
cannam@126 8912 ;;
cannam@126 8913
cannam@126 8914 irix | nonstopux)
cannam@126 8915 if test no = "$lt_irix_increment"; then
cannam@126 8916 func_arith $current - $age
cannam@126 8917 else
cannam@126 8918 func_arith $current - $age + 1
cannam@126 8919 fi
cannam@126 8920 major=$func_arith_result
cannam@126 8921
cannam@126 8922 case $version_type in
cannam@126 8923 nonstopux) verstring_prefix=nonstopux ;;
cannam@126 8924 *) verstring_prefix=sgi ;;
cannam@126 8925 esac
cannam@126 8926 verstring=$verstring_prefix$major.$revision
cannam@126 8927
cannam@126 8928 # Add in all the interfaces that we are compatible with.
cannam@126 8929 loop=$revision
cannam@126 8930 while test 0 -ne "$loop"; do
cannam@126 8931 func_arith $revision - $loop
cannam@126 8932 iface=$func_arith_result
cannam@126 8933 func_arith $loop - 1
cannam@126 8934 loop=$func_arith_result
cannam@126 8935 verstring=$verstring_prefix$major.$iface:$verstring
cannam@126 8936 done
cannam@126 8937
cannam@126 8938 # Before this point, $major must not contain '.'.
cannam@126 8939 major=.$major
cannam@126 8940 versuffix=$major.$revision
cannam@126 8941 ;;
cannam@126 8942
cannam@126 8943 linux) # correct to gnu/linux during the next big refactor
cannam@126 8944 func_arith $current - $age
cannam@126 8945 major=.$func_arith_result
cannam@126 8946 versuffix=$major.$age.$revision
cannam@126 8947 ;;
cannam@126 8948
cannam@126 8949 osf)
cannam@126 8950 func_arith $current - $age
cannam@126 8951 major=.$func_arith_result
cannam@126 8952 versuffix=.$current.$age.$revision
cannam@126 8953 verstring=$current.$age.$revision
cannam@126 8954
cannam@126 8955 # Add in all the interfaces that we are compatible with.
cannam@126 8956 loop=$age
cannam@126 8957 while test 0 -ne "$loop"; do
cannam@126 8958 func_arith $current - $loop
cannam@126 8959 iface=$func_arith_result
cannam@126 8960 func_arith $loop - 1
cannam@126 8961 loop=$func_arith_result
cannam@126 8962 verstring=$verstring:$iface.0
cannam@126 8963 done
cannam@126 8964
cannam@126 8965 # Make executables depend on our current version.
cannam@126 8966 func_append verstring ":$current.0"
cannam@126 8967 ;;
cannam@126 8968
cannam@126 8969 qnx)
cannam@126 8970 major=.$current
cannam@126 8971 versuffix=.$current
cannam@126 8972 ;;
cannam@126 8973
cannam@126 8974 sco)
cannam@126 8975 major=.$current
cannam@126 8976 versuffix=.$current
cannam@126 8977 ;;
cannam@126 8978
cannam@126 8979 sunos)
cannam@126 8980 major=.$current
cannam@126 8981 versuffix=.$current.$revision
cannam@126 8982 ;;
cannam@126 8983
cannam@126 8984 windows)
cannam@126 8985 # Use '-' rather than '.', since we only want one
cannam@126 8986 # extension on DOS 8.3 file systems.
cannam@126 8987 func_arith $current - $age
cannam@126 8988 major=$func_arith_result
cannam@126 8989 versuffix=-$major
cannam@126 8990 ;;
cannam@126 8991
cannam@126 8992 *)
cannam@126 8993 func_fatal_configuration "unknown library version type '$version_type'"
cannam@126 8994 ;;
cannam@126 8995 esac
cannam@126 8996
cannam@126 8997 # Clear the version info if we defaulted, and they specified a release.
cannam@126 8998 if test -z "$vinfo" && test -n "$release"; then
cannam@126 8999 major=
cannam@126 9000 case $version_type in
cannam@126 9001 darwin)
cannam@126 9002 # we can't check for "0.0" in archive_cmds due to quoting
cannam@126 9003 # problems, so we reset it completely
cannam@126 9004 verstring=
cannam@126 9005 ;;
cannam@126 9006 *)
cannam@126 9007 verstring=0.0
cannam@126 9008 ;;
cannam@126 9009 esac
cannam@126 9010 if test no = "$need_version"; then
cannam@126 9011 versuffix=
cannam@126 9012 else
cannam@126 9013 versuffix=.0.0
cannam@126 9014 fi
cannam@126 9015 fi
cannam@126 9016
cannam@126 9017 # Remove version info from name if versioning should be avoided
cannam@126 9018 if test yes,no = "$avoid_version,$need_version"; then
cannam@126 9019 major=
cannam@126 9020 versuffix=
cannam@126 9021 verstring=
cannam@126 9022 fi
cannam@126 9023
cannam@126 9024 # Check to see if the archive will have undefined symbols.
cannam@126 9025 if test yes = "$allow_undefined"; then
cannam@126 9026 if test unsupported = "$allow_undefined_flag"; then
cannam@126 9027 if test yes = "$build_old_libs"; then
cannam@126 9028 func_warning "undefined symbols not allowed in $host shared libraries; building static only"
cannam@126 9029 build_libtool_libs=no
cannam@126 9030 else
cannam@126 9031 func_fatal_error "can't build $host shared library unless -no-undefined is specified"
cannam@126 9032 fi
cannam@126 9033 fi
cannam@126 9034 else
cannam@126 9035 # Don't allow undefined symbols.
cannam@126 9036 allow_undefined_flag=$no_undefined_flag
cannam@126 9037 fi
cannam@126 9038
cannam@126 9039 fi
cannam@126 9040
cannam@126 9041 func_generate_dlsyms "$libname" "$libname" :
cannam@126 9042 func_append libobjs " $symfileobj"
cannam@126 9043 test " " = "$libobjs" && libobjs=
cannam@126 9044
cannam@126 9045 if test relink != "$opt_mode"; then
cannam@126 9046 # Remove our outputs, but don't remove object files since they
cannam@126 9047 # may have been created when compiling PIC objects.
cannam@126 9048 removelist=
cannam@126 9049 tempremovelist=`$ECHO "$output_objdir/*"`
cannam@126 9050 for p in $tempremovelist; do
cannam@126 9051 case $p in
cannam@126 9052 *.$objext | *.gcno)
cannam@126 9053 ;;
cannam@126 9054 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
cannam@126 9055 if test -n "$precious_files_regex"; then
cannam@126 9056 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
cannam@126 9057 then
cannam@126 9058 continue
cannam@126 9059 fi
cannam@126 9060 fi
cannam@126 9061 func_append removelist " $p"
cannam@126 9062 ;;
cannam@126 9063 *) ;;
cannam@126 9064 esac
cannam@126 9065 done
cannam@126 9066 test -n "$removelist" && \
cannam@126 9067 func_show_eval "${RM}r \$removelist"
cannam@126 9068 fi
cannam@126 9069
cannam@126 9070 # Now set the variables for building old libraries.
cannam@126 9071 if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
cannam@126 9072 func_append oldlibs " $output_objdir/$libname.$libext"
cannam@126 9073
cannam@126 9074 # Transform .lo files to .o files.
cannam@126 9075 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
cannam@126 9076 fi
cannam@126 9077
cannam@126 9078 # Eliminate all temporary directories.
cannam@126 9079 #for path in $notinst_path; do
cannam@126 9080 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
cannam@126 9081 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
cannam@126 9082 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
cannam@126 9083 #done
cannam@126 9084
cannam@126 9085 if test -n "$xrpath"; then
cannam@126 9086 # If the user specified any rpath flags, then add them.
cannam@126 9087 temp_xrpath=
cannam@126 9088 for libdir in $xrpath; do
cannam@126 9089 func_replace_sysroot "$libdir"
cannam@126 9090 func_append temp_xrpath " -R$func_replace_sysroot_result"
cannam@126 9091 case "$finalize_rpath " in
cannam@126 9092 *" $libdir "*) ;;
cannam@126 9093 *) func_append finalize_rpath " $libdir" ;;
cannam@126 9094 esac
cannam@126 9095 done
cannam@126 9096 if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
cannam@126 9097 dependency_libs="$temp_xrpath $dependency_libs"
cannam@126 9098 fi
cannam@126 9099 fi
cannam@126 9100
cannam@126 9101 # Make sure dlfiles contains only unique files that won't be dlpreopened
cannam@126 9102 old_dlfiles=$dlfiles
cannam@126 9103 dlfiles=
cannam@126 9104 for lib in $old_dlfiles; do
cannam@126 9105 case " $dlprefiles $dlfiles " in
cannam@126 9106 *" $lib "*) ;;
cannam@126 9107 *) func_append dlfiles " $lib" ;;
cannam@126 9108 esac
cannam@126 9109 done
cannam@126 9110
cannam@126 9111 # Make sure dlprefiles contains only unique files
cannam@126 9112 old_dlprefiles=$dlprefiles
cannam@126 9113 dlprefiles=
cannam@126 9114 for lib in $old_dlprefiles; do
cannam@126 9115 case "$dlprefiles " in
cannam@126 9116 *" $lib "*) ;;
cannam@126 9117 *) func_append dlprefiles " $lib" ;;
cannam@126 9118 esac
cannam@126 9119 done
cannam@126 9120
cannam@126 9121 if test yes = "$build_libtool_libs"; then
cannam@126 9122 if test -n "$rpath"; then
cannam@126 9123 case $host in
cannam@126 9124 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
cannam@126 9125 # these systems don't actually have a c library (as such)!
cannam@126 9126 ;;
cannam@126 9127 *-*-rhapsody* | *-*-darwin1.[012])
cannam@126 9128 # Rhapsody C library is in the System framework
cannam@126 9129 func_append deplibs " System.ltframework"
cannam@126 9130 ;;
cannam@126 9131 *-*-netbsd*)
cannam@126 9132 # Don't link with libc until the a.out ld.so is fixed.
cannam@126 9133 ;;
cannam@126 9134 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
cannam@126 9135 # Do not include libc due to us having libc/libc_r.
cannam@126 9136 ;;
cannam@126 9137 *-*-sco3.2v5* | *-*-sco5v6*)
cannam@126 9138 # Causes problems with __ctype
cannam@126 9139 ;;
cannam@126 9140 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
cannam@126 9141 # Compiler inserts libc in the correct place for threads to work
cannam@126 9142 ;;
cannam@126 9143 *)
cannam@126 9144 # Add libc to deplibs on all other systems if necessary.
cannam@126 9145 if test yes = "$build_libtool_need_lc"; then
cannam@126 9146 func_append deplibs " -lc"
cannam@126 9147 fi
cannam@126 9148 ;;
cannam@126 9149 esac
cannam@126 9150 fi
cannam@126 9151
cannam@126 9152 # Transform deplibs into only deplibs that can be linked in shared.
cannam@126 9153 name_save=$name
cannam@126 9154 libname_save=$libname
cannam@126 9155 release_save=$release
cannam@126 9156 versuffix_save=$versuffix
cannam@126 9157 major_save=$major
cannam@126 9158 # I'm not sure if I'm treating the release correctly. I think
cannam@126 9159 # release should show up in the -l (ie -lgmp5) so we don't want to
cannam@126 9160 # add it in twice. Is that correct?
cannam@126 9161 release=
cannam@126 9162 versuffix=
cannam@126 9163 major=
cannam@126 9164 newdeplibs=
cannam@126 9165 droppeddeps=no
cannam@126 9166 case $deplibs_check_method in
cannam@126 9167 pass_all)
cannam@126 9168 # Don't check for shared/static. Everything works.
cannam@126 9169 # This might be a little naive. We might want to check
cannam@126 9170 # whether the library exists or not. But this is on
cannam@126 9171 # osf3 & osf4 and I'm not really sure... Just
cannam@126 9172 # implementing what was already the behavior.
cannam@126 9173 newdeplibs=$deplibs
cannam@126 9174 ;;
cannam@126 9175 test_compile)
cannam@126 9176 # This code stresses the "libraries are programs" paradigm to its
cannam@126 9177 # limits. Maybe even breaks it. We compile a program, linking it
cannam@126 9178 # against the deplibs as a proxy for the library. Then we can check
cannam@126 9179 # whether they linked in statically or dynamically with ldd.
cannam@126 9180 $opt_dry_run || $RM conftest.c
cannam@126 9181 cat > conftest.c <<EOF
cannam@126 9182 int main() { return 0; }
cannam@126 9183 EOF
cannam@126 9184 $opt_dry_run || $RM conftest
cannam@126 9185 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
cannam@126 9186 ldd_output=`ldd conftest`
cannam@126 9187 for i in $deplibs; do
cannam@126 9188 case $i in
cannam@126 9189 -l*)
cannam@126 9190 func_stripname -l '' "$i"
cannam@126 9191 name=$func_stripname_result
cannam@126 9192 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@126 9193 case " $predeps $postdeps " in
cannam@126 9194 *" $i "*)
cannam@126 9195 func_append newdeplibs " $i"
cannam@126 9196 i=
cannam@126 9197 ;;
cannam@126 9198 esac
cannam@126 9199 fi
cannam@126 9200 if test -n "$i"; then
cannam@126 9201 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@126 9202 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
cannam@126 9203 set dummy $deplib_matches; shift
cannam@126 9204 deplib_match=$1
cannam@126 9205 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
cannam@126 9206 func_append newdeplibs " $i"
cannam@126 9207 else
cannam@126 9208 droppeddeps=yes
cannam@126 9209 echo
cannam@126 9210 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
cannam@126 9211 echo "*** I have the capability to make that library automatically link in when"
cannam@126 9212 echo "*** you link to this library. But I can only do this if you have a"
cannam@126 9213 echo "*** shared version of the library, which I believe you do not have"
cannam@126 9214 echo "*** because a test_compile did reveal that the linker did not use it for"
cannam@126 9215 echo "*** its dynamic dependency list that programs get resolved with at runtime."
cannam@126 9216 fi
cannam@126 9217 fi
cannam@126 9218 ;;
cannam@126 9219 *)
cannam@126 9220 func_append newdeplibs " $i"
cannam@126 9221 ;;
cannam@126 9222 esac
cannam@126 9223 done
cannam@126 9224 else
cannam@126 9225 # Error occurred in the first compile. Let's try to salvage
cannam@126 9226 # the situation: Compile a separate program for each library.
cannam@126 9227 for i in $deplibs; do
cannam@126 9228 case $i in
cannam@126 9229 -l*)
cannam@126 9230 func_stripname -l '' "$i"
cannam@126 9231 name=$func_stripname_result
cannam@126 9232 $opt_dry_run || $RM conftest
cannam@126 9233 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
cannam@126 9234 ldd_output=`ldd conftest`
cannam@126 9235 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@126 9236 case " $predeps $postdeps " in
cannam@126 9237 *" $i "*)
cannam@126 9238 func_append newdeplibs " $i"
cannam@126 9239 i=
cannam@126 9240 ;;
cannam@126 9241 esac
cannam@126 9242 fi
cannam@126 9243 if test -n "$i"; then
cannam@126 9244 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@126 9245 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
cannam@126 9246 set dummy $deplib_matches; shift
cannam@126 9247 deplib_match=$1
cannam@126 9248 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
cannam@126 9249 func_append newdeplibs " $i"
cannam@126 9250 else
cannam@126 9251 droppeddeps=yes
cannam@126 9252 echo
cannam@126 9253 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
cannam@126 9254 echo "*** I have the capability to make that library automatically link in when"
cannam@126 9255 echo "*** you link to this library. But I can only do this if you have a"
cannam@126 9256 echo "*** shared version of the library, which you do not appear to have"
cannam@126 9257 echo "*** because a test_compile did reveal that the linker did not use this one"
cannam@126 9258 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
cannam@126 9259 fi
cannam@126 9260 fi
cannam@126 9261 else
cannam@126 9262 droppeddeps=yes
cannam@126 9263 echo
cannam@126 9264 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
cannam@126 9265 echo "*** make it link in! You will probably need to install it or some"
cannam@126 9266 echo "*** library that it depends on before this library will be fully"
cannam@126 9267 echo "*** functional. Installing it before continuing would be even better."
cannam@126 9268 fi
cannam@126 9269 ;;
cannam@126 9270 *)
cannam@126 9271 func_append newdeplibs " $i"
cannam@126 9272 ;;
cannam@126 9273 esac
cannam@126 9274 done
cannam@126 9275 fi
cannam@126 9276 ;;
cannam@126 9277 file_magic*)
cannam@126 9278 set dummy $deplibs_check_method; shift
cannam@126 9279 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
cannam@126 9280 for a_deplib in $deplibs; do
cannam@126 9281 case $a_deplib in
cannam@126 9282 -l*)
cannam@126 9283 func_stripname -l '' "$a_deplib"
cannam@126 9284 name=$func_stripname_result
cannam@126 9285 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@126 9286 case " $predeps $postdeps " in
cannam@126 9287 *" $a_deplib "*)
cannam@126 9288 func_append newdeplibs " $a_deplib"
cannam@126 9289 a_deplib=
cannam@126 9290 ;;
cannam@126 9291 esac
cannam@126 9292 fi
cannam@126 9293 if test -n "$a_deplib"; then
cannam@126 9294 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@126 9295 if test -n "$file_magic_glob"; then
cannam@126 9296 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
cannam@126 9297 else
cannam@126 9298 libnameglob=$libname
cannam@126 9299 fi
cannam@126 9300 test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
cannam@126 9301 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
cannam@126 9302 if test yes = "$want_nocaseglob"; then
cannam@126 9303 shopt -s nocaseglob
cannam@126 9304 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
cannam@126 9305 $nocaseglob
cannam@126 9306 else
cannam@126 9307 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
cannam@126 9308 fi
cannam@126 9309 for potent_lib in $potential_libs; do
cannam@126 9310 # Follow soft links.
cannam@126 9311 if ls -lLd "$potent_lib" 2>/dev/null |
cannam@126 9312 $GREP " -> " >/dev/null; then
cannam@126 9313 continue
cannam@126 9314 fi
cannam@126 9315 # The statement above tries to avoid entering an
cannam@126 9316 # endless loop below, in case of cyclic links.
cannam@126 9317 # We might still enter an endless loop, since a link
cannam@126 9318 # loop can be closed while we follow links,
cannam@126 9319 # but so what?
cannam@126 9320 potlib=$potent_lib
cannam@126 9321 while test -h "$potlib" 2>/dev/null; do
cannam@126 9322 potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
cannam@126 9323 case $potliblink in
cannam@126 9324 [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
cannam@126 9325 *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
cannam@126 9326 esac
cannam@126 9327 done
cannam@126 9328 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
cannam@126 9329 $SED -e 10q |
cannam@126 9330 $EGREP "$file_magic_regex" > /dev/null; then
cannam@126 9331 func_append newdeplibs " $a_deplib"
cannam@126 9332 a_deplib=
cannam@126 9333 break 2
cannam@126 9334 fi
cannam@126 9335 done
cannam@126 9336 done
cannam@126 9337 fi
cannam@126 9338 if test -n "$a_deplib"; then
cannam@126 9339 droppeddeps=yes
cannam@126 9340 echo
cannam@126 9341 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
cannam@126 9342 echo "*** I have the capability to make that library automatically link in when"
cannam@126 9343 echo "*** you link to this library. But I can only do this if you have a"
cannam@126 9344 echo "*** shared version of the library, which you do not appear to have"
cannam@126 9345 echo "*** because I did check the linker path looking for a file starting"
cannam@126 9346 if test -z "$potlib"; then
cannam@126 9347 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
cannam@126 9348 else
cannam@126 9349 $ECHO "*** with $libname and none of the candidates passed a file format test"
cannam@126 9350 $ECHO "*** using a file magic. Last file checked: $potlib"
cannam@126 9351 fi
cannam@126 9352 fi
cannam@126 9353 ;;
cannam@126 9354 *)
cannam@126 9355 # Add a -L argument.
cannam@126 9356 func_append newdeplibs " $a_deplib"
cannam@126 9357 ;;
cannam@126 9358 esac
cannam@126 9359 done # Gone through all deplibs.
cannam@126 9360 ;;
cannam@126 9361 match_pattern*)
cannam@126 9362 set dummy $deplibs_check_method; shift
cannam@126 9363 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
cannam@126 9364 for a_deplib in $deplibs; do
cannam@126 9365 case $a_deplib in
cannam@126 9366 -l*)
cannam@126 9367 func_stripname -l '' "$a_deplib"
cannam@126 9368 name=$func_stripname_result
cannam@126 9369 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@126 9370 case " $predeps $postdeps " in
cannam@126 9371 *" $a_deplib "*)
cannam@126 9372 func_append newdeplibs " $a_deplib"
cannam@126 9373 a_deplib=
cannam@126 9374 ;;
cannam@126 9375 esac
cannam@126 9376 fi
cannam@126 9377 if test -n "$a_deplib"; then
cannam@126 9378 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@126 9379 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
cannam@126 9380 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
cannam@126 9381 for potent_lib in $potential_libs; do
cannam@126 9382 potlib=$potent_lib # see symlink-check above in file_magic test
cannam@126 9383 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
cannam@126 9384 $EGREP "$match_pattern_regex" > /dev/null; then
cannam@126 9385 func_append newdeplibs " $a_deplib"
cannam@126 9386 a_deplib=
cannam@126 9387 break 2
cannam@126 9388 fi
cannam@126 9389 done
cannam@126 9390 done
cannam@126 9391 fi
cannam@126 9392 if test -n "$a_deplib"; then
cannam@126 9393 droppeddeps=yes
cannam@126 9394 echo
cannam@126 9395 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
cannam@126 9396 echo "*** I have the capability to make that library automatically link in when"
cannam@126 9397 echo "*** you link to this library. But I can only do this if you have a"
cannam@126 9398 echo "*** shared version of the library, which you do not appear to have"
cannam@126 9399 echo "*** because I did check the linker path looking for a file starting"
cannam@126 9400 if test -z "$potlib"; then
cannam@126 9401 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
cannam@126 9402 else
cannam@126 9403 $ECHO "*** with $libname and none of the candidates passed a file format test"
cannam@126 9404 $ECHO "*** using a regex pattern. Last file checked: $potlib"
cannam@126 9405 fi
cannam@126 9406 fi
cannam@126 9407 ;;
cannam@126 9408 *)
cannam@126 9409 # Add a -L argument.
cannam@126 9410 func_append newdeplibs " $a_deplib"
cannam@126 9411 ;;
cannam@126 9412 esac
cannam@126 9413 done # Gone through all deplibs.
cannam@126 9414 ;;
cannam@126 9415 none | unknown | *)
cannam@126 9416 newdeplibs=
cannam@126 9417 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
cannam@126 9418 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@126 9419 for i in $predeps $postdeps; do
cannam@126 9420 # can't use Xsed below, because $i might contain '/'
cannam@126 9421 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
cannam@126 9422 done
cannam@126 9423 fi
cannam@126 9424 case $tmp_deplibs in
cannam@126 9425 *[!\ \ ]*)
cannam@126 9426 echo
cannam@126 9427 if test none = "$deplibs_check_method"; then
cannam@126 9428 echo "*** Warning: inter-library dependencies are not supported in this platform."
cannam@126 9429 else
cannam@126 9430 echo "*** Warning: inter-library dependencies are not known to be supported."
cannam@126 9431 fi
cannam@126 9432 echo "*** All declared inter-library dependencies are being dropped."
cannam@126 9433 droppeddeps=yes
cannam@126 9434 ;;
cannam@126 9435 esac
cannam@126 9436 ;;
cannam@126 9437 esac
cannam@126 9438 versuffix=$versuffix_save
cannam@126 9439 major=$major_save
cannam@126 9440 release=$release_save
cannam@126 9441 libname=$libname_save
cannam@126 9442 name=$name_save
cannam@126 9443
cannam@126 9444 case $host in
cannam@126 9445 *-*-rhapsody* | *-*-darwin1.[012])
cannam@126 9446 # On Rhapsody replace the C library with the System framework
cannam@126 9447 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
cannam@126 9448 ;;
cannam@126 9449 esac
cannam@126 9450
cannam@126 9451 if test yes = "$droppeddeps"; then
cannam@126 9452 if test yes = "$module"; then
cannam@126 9453 echo
cannam@126 9454 echo "*** Warning: libtool could not satisfy all declared inter-library"
cannam@126 9455 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
cannam@126 9456 echo "*** a static module, that should work as long as the dlopening"
cannam@126 9457 echo "*** application is linked with the -dlopen flag."
cannam@126 9458 if test -z "$global_symbol_pipe"; then
cannam@126 9459 echo
cannam@126 9460 echo "*** However, this would only work if libtool was able to extract symbol"
cannam@126 9461 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
cannam@126 9462 echo "*** not find such a program. So, this module is probably useless."
cannam@126 9463 echo "*** 'nm' from GNU binutils and a full rebuild may help."
cannam@126 9464 fi
cannam@126 9465 if test no = "$build_old_libs"; then
cannam@126 9466 oldlibs=$output_objdir/$libname.$libext
cannam@126 9467 build_libtool_libs=module
cannam@126 9468 build_old_libs=yes
cannam@126 9469 else
cannam@126 9470 build_libtool_libs=no
cannam@126 9471 fi
cannam@126 9472 else
cannam@126 9473 echo "*** The inter-library dependencies that have been dropped here will be"
cannam@126 9474 echo "*** automatically added whenever a program is linked with this library"
cannam@126 9475 echo "*** or is declared to -dlopen it."
cannam@126 9476
cannam@126 9477 if test no = "$allow_undefined"; then
cannam@126 9478 echo
cannam@126 9479 echo "*** Since this library must not contain undefined symbols,"
cannam@126 9480 echo "*** because either the platform does not support them or"
cannam@126 9481 echo "*** it was explicitly requested with -no-undefined,"
cannam@126 9482 echo "*** libtool will only create a static version of it."
cannam@126 9483 if test no = "$build_old_libs"; then
cannam@126 9484 oldlibs=$output_objdir/$libname.$libext
cannam@126 9485 build_libtool_libs=module
cannam@126 9486 build_old_libs=yes
cannam@126 9487 else
cannam@126 9488 build_libtool_libs=no
cannam@126 9489 fi
cannam@126 9490 fi
cannam@126 9491 fi
cannam@126 9492 fi
cannam@126 9493 # Done checking deplibs!
cannam@126 9494 deplibs=$newdeplibs
cannam@126 9495 fi
cannam@126 9496 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
cannam@126 9497 case $host in
cannam@126 9498 *-*-darwin*)
cannam@126 9499 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@126 9500 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@126 9501 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@126 9502 ;;
cannam@126 9503 esac
cannam@126 9504
cannam@126 9505 # move library search paths that coincide with paths to not yet
cannam@126 9506 # installed libraries to the beginning of the library search list
cannam@126 9507 new_libs=
cannam@126 9508 for path in $notinst_path; do
cannam@126 9509 case " $new_libs " in
cannam@126 9510 *" -L$path/$objdir "*) ;;
cannam@126 9511 *)
cannam@126 9512 case " $deplibs " in
cannam@126 9513 *" -L$path/$objdir "*)
cannam@126 9514 func_append new_libs " -L$path/$objdir" ;;
cannam@126 9515 esac
cannam@126 9516 ;;
cannam@126 9517 esac
cannam@126 9518 done
cannam@126 9519 for deplib in $deplibs; do
cannam@126 9520 case $deplib in
cannam@126 9521 -L*)
cannam@126 9522 case " $new_libs " in
cannam@126 9523 *" $deplib "*) ;;
cannam@126 9524 *) func_append new_libs " $deplib" ;;
cannam@126 9525 esac
cannam@126 9526 ;;
cannam@126 9527 *) func_append new_libs " $deplib" ;;
cannam@126 9528 esac
cannam@126 9529 done
cannam@126 9530 deplibs=$new_libs
cannam@126 9531
cannam@126 9532 # All the library-specific variables (install_libdir is set above).
cannam@126 9533 library_names=
cannam@126 9534 old_library=
cannam@126 9535 dlname=
cannam@126 9536
cannam@126 9537 # Test again, we may have decided not to build it any more
cannam@126 9538 if test yes = "$build_libtool_libs"; then
cannam@126 9539 # Remove $wl instances when linking with ld.
cannam@126 9540 # FIXME: should test the right _cmds variable.
cannam@126 9541 case $archive_cmds in
cannam@126 9542 *\$LD\ *) wl= ;;
cannam@126 9543 esac
cannam@126 9544 if test yes = "$hardcode_into_libs"; then
cannam@126 9545 # Hardcode the library paths
cannam@126 9546 hardcode_libdirs=
cannam@126 9547 dep_rpath=
cannam@126 9548 rpath=$finalize_rpath
cannam@126 9549 test relink = "$opt_mode" || rpath=$compile_rpath$rpath
cannam@126 9550 for libdir in $rpath; do
cannam@126 9551 if test -n "$hardcode_libdir_flag_spec"; then
cannam@126 9552 if test -n "$hardcode_libdir_separator"; then
cannam@126 9553 func_replace_sysroot "$libdir"
cannam@126 9554 libdir=$func_replace_sysroot_result
cannam@126 9555 if test -z "$hardcode_libdirs"; then
cannam@126 9556 hardcode_libdirs=$libdir
cannam@126 9557 else
cannam@126 9558 # Just accumulate the unique libdirs.
cannam@126 9559 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
cannam@126 9560 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
cannam@126 9561 ;;
cannam@126 9562 *)
cannam@126 9563 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
cannam@126 9564 ;;
cannam@126 9565 esac
cannam@126 9566 fi
cannam@126 9567 else
cannam@126 9568 eval flag=\"$hardcode_libdir_flag_spec\"
cannam@126 9569 func_append dep_rpath " $flag"
cannam@126 9570 fi
cannam@126 9571 elif test -n "$runpath_var"; then
cannam@126 9572 case "$perm_rpath " in
cannam@126 9573 *" $libdir "*) ;;
cannam@126 9574 *) func_append perm_rpath " $libdir" ;;
cannam@126 9575 esac
cannam@126 9576 fi
cannam@126 9577 done
cannam@126 9578 # Substitute the hardcoded libdirs into the rpath.
cannam@126 9579 if test -n "$hardcode_libdir_separator" &&
cannam@126 9580 test -n "$hardcode_libdirs"; then
cannam@126 9581 libdir=$hardcode_libdirs
cannam@126 9582 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
cannam@126 9583 fi
cannam@126 9584 if test -n "$runpath_var" && test -n "$perm_rpath"; then
cannam@126 9585 # We should set the runpath_var.
cannam@126 9586 rpath=
cannam@126 9587 for dir in $perm_rpath; do
cannam@126 9588 func_append rpath "$dir:"
cannam@126 9589 done
cannam@126 9590 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
cannam@126 9591 fi
cannam@126 9592 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
cannam@126 9593 fi
cannam@126 9594
cannam@126 9595 shlibpath=$finalize_shlibpath
cannam@126 9596 test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
cannam@126 9597 if test -n "$shlibpath"; then
cannam@126 9598 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
cannam@126 9599 fi
cannam@126 9600
cannam@126 9601 # Get the real and link names of the library.
cannam@126 9602 eval shared_ext=\"$shrext_cmds\"
cannam@126 9603 eval library_names=\"$library_names_spec\"
cannam@126 9604 set dummy $library_names
cannam@126 9605 shift
cannam@126 9606 realname=$1
cannam@126 9607 shift
cannam@126 9608
cannam@126 9609 if test -n "$soname_spec"; then
cannam@126 9610 eval soname=\"$soname_spec\"
cannam@126 9611 else
cannam@126 9612 soname=$realname
cannam@126 9613 fi
cannam@126 9614 if test -z "$dlname"; then
cannam@126 9615 dlname=$soname
cannam@126 9616 fi
cannam@126 9617
cannam@126 9618 lib=$output_objdir/$realname
cannam@126 9619 linknames=
cannam@126 9620 for link
cannam@126 9621 do
cannam@126 9622 func_append linknames " $link"
cannam@126 9623 done
cannam@126 9624
cannam@126 9625 # Use standard objects if they are pic
cannam@126 9626 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
cannam@126 9627 test "X$libobjs" = "X " && libobjs=
cannam@126 9628
cannam@126 9629 delfiles=
cannam@126 9630 if test -n "$export_symbols" && test -n "$include_expsyms"; then
cannam@126 9631 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
cannam@126 9632 export_symbols=$output_objdir/$libname.uexp
cannam@126 9633 func_append delfiles " $export_symbols"
cannam@126 9634 fi
cannam@126 9635
cannam@126 9636 orig_export_symbols=
cannam@126 9637 case $host_os in
cannam@126 9638 cygwin* | mingw* | cegcc*)
cannam@126 9639 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
cannam@126 9640 # exporting using user supplied symfile
cannam@126 9641 func_dll_def_p "$export_symbols" || {
cannam@126 9642 # and it's NOT already a .def file. Must figure out
cannam@126 9643 # which of the given symbols are data symbols and tag
cannam@126 9644 # them as such. So, trigger use of export_symbols_cmds.
cannam@126 9645 # export_symbols gets reassigned inside the "prepare
cannam@126 9646 # the list of exported symbols" if statement, so the
cannam@126 9647 # include_expsyms logic still works.
cannam@126 9648 orig_export_symbols=$export_symbols
cannam@126 9649 export_symbols=
cannam@126 9650 always_export_symbols=yes
cannam@126 9651 }
cannam@126 9652 fi
cannam@126 9653 ;;
cannam@126 9654 esac
cannam@126 9655
cannam@126 9656 # Prepare the list of exported symbols
cannam@126 9657 if test -z "$export_symbols"; then
cannam@126 9658 if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
cannam@126 9659 func_verbose "generating symbol list for '$libname.la'"
cannam@126 9660 export_symbols=$output_objdir/$libname.exp
cannam@126 9661 $opt_dry_run || $RM $export_symbols
cannam@126 9662 cmds=$export_symbols_cmds
cannam@126 9663 save_ifs=$IFS; IFS='~'
cannam@126 9664 for cmd1 in $cmds; do
cannam@126 9665 IFS=$save_ifs
cannam@126 9666 # Take the normal branch if the nm_file_list_spec branch
cannam@126 9667 # doesn't work or if tool conversion is not needed.
cannam@126 9668 case $nm_file_list_spec~$to_tool_file_cmd in
cannam@126 9669 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
cannam@126 9670 try_normal_branch=yes
cannam@126 9671 eval cmd=\"$cmd1\"
cannam@126 9672 func_len " $cmd"
cannam@126 9673 len=$func_len_result
cannam@126 9674 ;;
cannam@126 9675 *)
cannam@126 9676 try_normal_branch=no
cannam@126 9677 ;;
cannam@126 9678 esac
cannam@126 9679 if test yes = "$try_normal_branch" \
cannam@126 9680 && { test "$len" -lt "$max_cmd_len" \
cannam@126 9681 || test "$max_cmd_len" -le -1; }
cannam@126 9682 then
cannam@126 9683 func_show_eval "$cmd" 'exit $?'
cannam@126 9684 skipped_export=false
cannam@126 9685 elif test -n "$nm_file_list_spec"; then
cannam@126 9686 func_basename "$output"
cannam@126 9687 output_la=$func_basename_result
cannam@126 9688 save_libobjs=$libobjs
cannam@126 9689 save_output=$output
cannam@126 9690 output=$output_objdir/$output_la.nm
cannam@126 9691 func_to_tool_file "$output"
cannam@126 9692 libobjs=$nm_file_list_spec$func_to_tool_file_result
cannam@126 9693 func_append delfiles " $output"
cannam@126 9694 func_verbose "creating $NM input file list: $output"
cannam@126 9695 for obj in $save_libobjs; do
cannam@126 9696 func_to_tool_file "$obj"
cannam@126 9697 $ECHO "$func_to_tool_file_result"
cannam@126 9698 done > "$output"
cannam@126 9699 eval cmd=\"$cmd1\"
cannam@126 9700 func_show_eval "$cmd" 'exit $?'
cannam@126 9701 output=$save_output
cannam@126 9702 libobjs=$save_libobjs
cannam@126 9703 skipped_export=false
cannam@126 9704 else
cannam@126 9705 # The command line is too long to execute in one step.
cannam@126 9706 func_verbose "using reloadable object file for export list..."
cannam@126 9707 skipped_export=:
cannam@126 9708 # Break out early, otherwise skipped_export may be
cannam@126 9709 # set to false by a later but shorter cmd.
cannam@126 9710 break
cannam@126 9711 fi
cannam@126 9712 done
cannam@126 9713 IFS=$save_ifs
cannam@126 9714 if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
cannam@126 9715 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
cannam@126 9716 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
cannam@126 9717 fi
cannam@126 9718 fi
cannam@126 9719 fi
cannam@126 9720
cannam@126 9721 if test -n "$export_symbols" && test -n "$include_expsyms"; then
cannam@126 9722 tmp_export_symbols=$export_symbols
cannam@126 9723 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
cannam@126 9724 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
cannam@126 9725 fi
cannam@126 9726
cannam@126 9727 if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
cannam@126 9728 # The given exports_symbols file has to be filtered, so filter it.
cannam@126 9729 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
cannam@126 9730 # FIXME: $output_objdir/$libname.filter potentially contains lots of
cannam@126 9731 # 's' commands, which not all seds can handle. GNU sed should be fine
cannam@126 9732 # though. Also, the filter scales superlinearly with the number of
cannam@126 9733 # global variables. join(1) would be nice here, but unfortunately
cannam@126 9734 # isn't a blessed tool.
cannam@126 9735 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
cannam@126 9736 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
cannam@126 9737 export_symbols=$output_objdir/$libname.def
cannam@126 9738 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
cannam@126 9739 fi
cannam@126 9740
cannam@126 9741 tmp_deplibs=
cannam@126 9742 for test_deplib in $deplibs; do
cannam@126 9743 case " $convenience " in
cannam@126 9744 *" $test_deplib "*) ;;
cannam@126 9745 *)
cannam@126 9746 func_append tmp_deplibs " $test_deplib"
cannam@126 9747 ;;
cannam@126 9748 esac
cannam@126 9749 done
cannam@126 9750 deplibs=$tmp_deplibs
cannam@126 9751
cannam@126 9752 if test -n "$convenience"; then
cannam@126 9753 if test -n "$whole_archive_flag_spec" &&
cannam@126 9754 test yes = "$compiler_needs_object" &&
cannam@126 9755 test -z "$libobjs"; then
cannam@126 9756 # extract the archives, so we have objects to list.
cannam@126 9757 # TODO: could optimize this to just extract one archive.
cannam@126 9758 whole_archive_flag_spec=
cannam@126 9759 fi
cannam@126 9760 if test -n "$whole_archive_flag_spec"; then
cannam@126 9761 save_libobjs=$libobjs
cannam@126 9762 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
cannam@126 9763 test "X$libobjs" = "X " && libobjs=
cannam@126 9764 else
cannam@126 9765 gentop=$output_objdir/${outputname}x
cannam@126 9766 func_append generated " $gentop"
cannam@126 9767
cannam@126 9768 func_extract_archives $gentop $convenience
cannam@126 9769 func_append libobjs " $func_extract_archives_result"
cannam@126 9770 test "X$libobjs" = "X " && libobjs=
cannam@126 9771 fi
cannam@126 9772 fi
cannam@126 9773
cannam@126 9774 if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
cannam@126 9775 eval flag=\"$thread_safe_flag_spec\"
cannam@126 9776 func_append linker_flags " $flag"
cannam@126 9777 fi
cannam@126 9778
cannam@126 9779 # Make a backup of the uninstalled library when relinking
cannam@126 9780 if test relink = "$opt_mode"; then
cannam@126 9781 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
cannam@126 9782 fi
cannam@126 9783
cannam@126 9784 # Do each of the archive commands.
cannam@126 9785 if test yes = "$module" && test -n "$module_cmds"; then
cannam@126 9786 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
cannam@126 9787 eval test_cmds=\"$module_expsym_cmds\"
cannam@126 9788 cmds=$module_expsym_cmds
cannam@126 9789 else
cannam@126 9790 eval test_cmds=\"$module_cmds\"
cannam@126 9791 cmds=$module_cmds
cannam@126 9792 fi
cannam@126 9793 else
cannam@126 9794 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
cannam@126 9795 eval test_cmds=\"$archive_expsym_cmds\"
cannam@126 9796 cmds=$archive_expsym_cmds
cannam@126 9797 else
cannam@126 9798 eval test_cmds=\"$archive_cmds\"
cannam@126 9799 cmds=$archive_cmds
cannam@126 9800 fi
cannam@126 9801 fi
cannam@126 9802
cannam@126 9803 if test : != "$skipped_export" &&
cannam@126 9804 func_len " $test_cmds" &&
cannam@126 9805 len=$func_len_result &&
cannam@126 9806 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
cannam@126 9807 :
cannam@126 9808 else
cannam@126 9809 # The command line is too long to link in one step, link piecewise
cannam@126 9810 # or, if using GNU ld and skipped_export is not :, use a linker
cannam@126 9811 # script.
cannam@126 9812
cannam@126 9813 # Save the value of $output and $libobjs because we want to
cannam@126 9814 # use them later. If we have whole_archive_flag_spec, we
cannam@126 9815 # want to use save_libobjs as it was before
cannam@126 9816 # whole_archive_flag_spec was expanded, because we can't
cannam@126 9817 # assume the linker understands whole_archive_flag_spec.
cannam@126 9818 # This may have to be revisited, in case too many
cannam@126 9819 # convenience libraries get linked in and end up exceeding
cannam@126 9820 # the spec.
cannam@126 9821 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
cannam@126 9822 save_libobjs=$libobjs
cannam@126 9823 fi
cannam@126 9824 save_output=$output
cannam@126 9825 func_basename "$output"
cannam@126 9826 output_la=$func_basename_result
cannam@126 9827
cannam@126 9828 # Clear the reloadable object creation command queue and
cannam@126 9829 # initialize k to one.
cannam@126 9830 test_cmds=
cannam@126 9831 concat_cmds=
cannam@126 9832 objlist=
cannam@126 9833 last_robj=
cannam@126 9834 k=1
cannam@126 9835
cannam@126 9836 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
cannam@126 9837 output=$output_objdir/$output_la.lnkscript
cannam@126 9838 func_verbose "creating GNU ld script: $output"
cannam@126 9839 echo 'INPUT (' > $output
cannam@126 9840 for obj in $save_libobjs
cannam@126 9841 do
cannam@126 9842 func_to_tool_file "$obj"
cannam@126 9843 $ECHO "$func_to_tool_file_result" >> $output
cannam@126 9844 done
cannam@126 9845 echo ')' >> $output
cannam@126 9846 func_append delfiles " $output"
cannam@126 9847 func_to_tool_file "$output"
cannam@126 9848 output=$func_to_tool_file_result
cannam@126 9849 elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
cannam@126 9850 output=$output_objdir/$output_la.lnk
cannam@126 9851 func_verbose "creating linker input file list: $output"
cannam@126 9852 : > $output
cannam@126 9853 set x $save_libobjs
cannam@126 9854 shift
cannam@126 9855 firstobj=
cannam@126 9856 if test yes = "$compiler_needs_object"; then
cannam@126 9857 firstobj="$1 "
cannam@126 9858 shift
cannam@126 9859 fi
cannam@126 9860 for obj
cannam@126 9861 do
cannam@126 9862 func_to_tool_file "$obj"
cannam@126 9863 $ECHO "$func_to_tool_file_result" >> $output
cannam@126 9864 done
cannam@126 9865 func_append delfiles " $output"
cannam@126 9866 func_to_tool_file "$output"
cannam@126 9867 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
cannam@126 9868 else
cannam@126 9869 if test -n "$save_libobjs"; then
cannam@126 9870 func_verbose "creating reloadable object files..."
cannam@126 9871 output=$output_objdir/$output_la-$k.$objext
cannam@126 9872 eval test_cmds=\"$reload_cmds\"
cannam@126 9873 func_len " $test_cmds"
cannam@126 9874 len0=$func_len_result
cannam@126 9875 len=$len0
cannam@126 9876
cannam@126 9877 # Loop over the list of objects to be linked.
cannam@126 9878 for obj in $save_libobjs
cannam@126 9879 do
cannam@126 9880 func_len " $obj"
cannam@126 9881 func_arith $len + $func_len_result
cannam@126 9882 len=$func_arith_result
cannam@126 9883 if test -z "$objlist" ||
cannam@126 9884 test "$len" -lt "$max_cmd_len"; then
cannam@126 9885 func_append objlist " $obj"
cannam@126 9886 else
cannam@126 9887 # The command $test_cmds is almost too long, add a
cannam@126 9888 # command to the queue.
cannam@126 9889 if test 1 -eq "$k"; then
cannam@126 9890 # The first file doesn't have a previous command to add.
cannam@126 9891 reload_objs=$objlist
cannam@126 9892 eval concat_cmds=\"$reload_cmds\"
cannam@126 9893 else
cannam@126 9894 # All subsequent reloadable object files will link in
cannam@126 9895 # the last one created.
cannam@126 9896 reload_objs="$objlist $last_robj"
cannam@126 9897 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
cannam@126 9898 fi
cannam@126 9899 last_robj=$output_objdir/$output_la-$k.$objext
cannam@126 9900 func_arith $k + 1
cannam@126 9901 k=$func_arith_result
cannam@126 9902 output=$output_objdir/$output_la-$k.$objext
cannam@126 9903 objlist=" $obj"
cannam@126 9904 func_len " $last_robj"
cannam@126 9905 func_arith $len0 + $func_len_result
cannam@126 9906 len=$func_arith_result
cannam@126 9907 fi
cannam@126 9908 done
cannam@126 9909 # Handle the remaining objects by creating one last
cannam@126 9910 # reloadable object file. All subsequent reloadable object
cannam@126 9911 # files will link in the last one created.
cannam@126 9912 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
cannam@126 9913 reload_objs="$objlist $last_robj"
cannam@126 9914 eval concat_cmds=\"\$concat_cmds$reload_cmds\"
cannam@126 9915 if test -n "$last_robj"; then
cannam@126 9916 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
cannam@126 9917 fi
cannam@126 9918 func_append delfiles " $output"
cannam@126 9919
cannam@126 9920 else
cannam@126 9921 output=
cannam@126 9922 fi
cannam@126 9923
cannam@126 9924 ${skipped_export-false} && {
cannam@126 9925 func_verbose "generating symbol list for '$libname.la'"
cannam@126 9926 export_symbols=$output_objdir/$libname.exp
cannam@126 9927 $opt_dry_run || $RM $export_symbols
cannam@126 9928 libobjs=$output
cannam@126 9929 # Append the command to create the export file.
cannam@126 9930 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
cannam@126 9931 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
cannam@126 9932 if test -n "$last_robj"; then
cannam@126 9933 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
cannam@126 9934 fi
cannam@126 9935 }
cannam@126 9936
cannam@126 9937 test -n "$save_libobjs" &&
cannam@126 9938 func_verbose "creating a temporary reloadable object file: $output"
cannam@126 9939
cannam@126 9940 # Loop through the commands generated above and execute them.
cannam@126 9941 save_ifs=$IFS; IFS='~'
cannam@126 9942 for cmd in $concat_cmds; do
cannam@126 9943 IFS=$save_ifs
cannam@126 9944 $opt_quiet || {
cannam@126 9945 func_quote_for_expand "$cmd"
cannam@126 9946 eval "func_echo $func_quote_for_expand_result"
cannam@126 9947 }
cannam@126 9948 $opt_dry_run || eval "$cmd" || {
cannam@126 9949 lt_exit=$?
cannam@126 9950
cannam@126 9951 # Restore the uninstalled library and exit
cannam@126 9952 if test relink = "$opt_mode"; then
cannam@126 9953 ( cd "$output_objdir" && \
cannam@126 9954 $RM "${realname}T" && \
cannam@126 9955 $MV "${realname}U" "$realname" )
cannam@126 9956 fi
cannam@126 9957
cannam@126 9958 exit $lt_exit
cannam@126 9959 }
cannam@126 9960 done
cannam@126 9961 IFS=$save_ifs
cannam@126 9962
cannam@126 9963 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
cannam@126 9964 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
cannam@126 9965 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
cannam@126 9966 fi
cannam@126 9967 fi
cannam@126 9968
cannam@126 9969 ${skipped_export-false} && {
cannam@126 9970 if test -n "$export_symbols" && test -n "$include_expsyms"; then
cannam@126 9971 tmp_export_symbols=$export_symbols
cannam@126 9972 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
cannam@126 9973 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
cannam@126 9974 fi
cannam@126 9975
cannam@126 9976 if test -n "$orig_export_symbols"; then
cannam@126 9977 # The given exports_symbols file has to be filtered, so filter it.
cannam@126 9978 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
cannam@126 9979 # FIXME: $output_objdir/$libname.filter potentially contains lots of
cannam@126 9980 # 's' commands, which not all seds can handle. GNU sed should be fine
cannam@126 9981 # though. Also, the filter scales superlinearly with the number of
cannam@126 9982 # global variables. join(1) would be nice here, but unfortunately
cannam@126 9983 # isn't a blessed tool.
cannam@126 9984 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
cannam@126 9985 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
cannam@126 9986 export_symbols=$output_objdir/$libname.def
cannam@126 9987 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
cannam@126 9988 fi
cannam@126 9989 }
cannam@126 9990
cannam@126 9991 libobjs=$output
cannam@126 9992 # Restore the value of output.
cannam@126 9993 output=$save_output
cannam@126 9994
cannam@126 9995 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
cannam@126 9996 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
cannam@126 9997 test "X$libobjs" = "X " && libobjs=
cannam@126 9998 fi
cannam@126 9999 # Expand the library linking commands again to reset the
cannam@126 10000 # value of $libobjs for piecewise linking.
cannam@126 10001
cannam@126 10002 # Do each of the archive commands.
cannam@126 10003 if test yes = "$module" && test -n "$module_cmds"; then
cannam@126 10004 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
cannam@126 10005 cmds=$module_expsym_cmds
cannam@126 10006 else
cannam@126 10007 cmds=$module_cmds
cannam@126 10008 fi
cannam@126 10009 else
cannam@126 10010 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
cannam@126 10011 cmds=$archive_expsym_cmds
cannam@126 10012 else
cannam@126 10013 cmds=$archive_cmds
cannam@126 10014 fi
cannam@126 10015 fi
cannam@126 10016 fi
cannam@126 10017
cannam@126 10018 if test -n "$delfiles"; then
cannam@126 10019 # Append the command to remove temporary files to $cmds.
cannam@126 10020 eval cmds=\"\$cmds~\$RM $delfiles\"
cannam@126 10021 fi
cannam@126 10022
cannam@126 10023 # Add any objects from preloaded convenience libraries
cannam@126 10024 if test -n "$dlprefiles"; then
cannam@126 10025 gentop=$output_objdir/${outputname}x
cannam@126 10026 func_append generated " $gentop"
cannam@126 10027
cannam@126 10028 func_extract_archives $gentop $dlprefiles
cannam@126 10029 func_append libobjs " $func_extract_archives_result"
cannam@126 10030 test "X$libobjs" = "X " && libobjs=
cannam@126 10031 fi
cannam@126 10032
cannam@126 10033 save_ifs=$IFS; IFS='~'
cannam@126 10034 for cmd in $cmds; do
cannam@126 10035 IFS=$sp$nl
cannam@126 10036 eval cmd=\"$cmd\"
cannam@126 10037 IFS=$save_ifs
cannam@126 10038 $opt_quiet || {
cannam@126 10039 func_quote_for_expand "$cmd"
cannam@126 10040 eval "func_echo $func_quote_for_expand_result"
cannam@126 10041 }
cannam@126 10042 $opt_dry_run || eval "$cmd" || {
cannam@126 10043 lt_exit=$?
cannam@126 10044
cannam@126 10045 # Restore the uninstalled library and exit
cannam@126 10046 if test relink = "$opt_mode"; then
cannam@126 10047 ( cd "$output_objdir" && \
cannam@126 10048 $RM "${realname}T" && \
cannam@126 10049 $MV "${realname}U" "$realname" )
cannam@126 10050 fi
cannam@126 10051
cannam@126 10052 exit $lt_exit
cannam@126 10053 }
cannam@126 10054 done
cannam@126 10055 IFS=$save_ifs
cannam@126 10056
cannam@126 10057 # Restore the uninstalled library and exit
cannam@126 10058 if test relink = "$opt_mode"; then
cannam@126 10059 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
cannam@126 10060
cannam@126 10061 if test -n "$convenience"; then
cannam@126 10062 if test -z "$whole_archive_flag_spec"; then
cannam@126 10063 func_show_eval '${RM}r "$gentop"'
cannam@126 10064 fi
cannam@126 10065 fi
cannam@126 10066
cannam@126 10067 exit $EXIT_SUCCESS
cannam@126 10068 fi
cannam@126 10069
cannam@126 10070 # Create links to the real library.
cannam@126 10071 for linkname in $linknames; do
cannam@126 10072 if test "$realname" != "$linkname"; then
cannam@126 10073 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
cannam@126 10074 fi
cannam@126 10075 done
cannam@126 10076
cannam@126 10077 # If -module or -export-dynamic was specified, set the dlname.
cannam@126 10078 if test yes = "$module" || test yes = "$export_dynamic"; then
cannam@126 10079 # On all known operating systems, these are identical.
cannam@126 10080 dlname=$soname
cannam@126 10081 fi
cannam@126 10082 fi
cannam@126 10083 ;;
cannam@126 10084
cannam@126 10085 obj)
cannam@126 10086 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
cannam@126 10087 func_warning "'-dlopen' is ignored for objects"
cannam@126 10088 fi
cannam@126 10089
cannam@126 10090 case " $deplibs" in
cannam@126 10091 *\ -l* | *\ -L*)
cannam@126 10092 func_warning "'-l' and '-L' are ignored for objects" ;;
cannam@126 10093 esac
cannam@126 10094
cannam@126 10095 test -n "$rpath" && \
cannam@126 10096 func_warning "'-rpath' is ignored for objects"
cannam@126 10097
cannam@126 10098 test -n "$xrpath" && \
cannam@126 10099 func_warning "'-R' is ignored for objects"
cannam@126 10100
cannam@126 10101 test -n "$vinfo" && \
cannam@126 10102 func_warning "'-version-info' is ignored for objects"
cannam@126 10103
cannam@126 10104 test -n "$release" && \
cannam@126 10105 func_warning "'-release' is ignored for objects"
cannam@126 10106
cannam@126 10107 case $output in
cannam@126 10108 *.lo)
cannam@126 10109 test -n "$objs$old_deplibs" && \
cannam@126 10110 func_fatal_error "cannot build library object '$output' from non-libtool objects"
cannam@126 10111
cannam@126 10112 libobj=$output
cannam@126 10113 func_lo2o "$libobj"
cannam@126 10114 obj=$func_lo2o_result
cannam@126 10115 ;;
cannam@126 10116 *)
cannam@126 10117 libobj=
cannam@126 10118 obj=$output
cannam@126 10119 ;;
cannam@126 10120 esac
cannam@126 10121
cannam@126 10122 # Delete the old objects.
cannam@126 10123 $opt_dry_run || $RM $obj $libobj
cannam@126 10124
cannam@126 10125 # Objects from convenience libraries. This assumes
cannam@126 10126 # single-version convenience libraries. Whenever we create
cannam@126 10127 # different ones for PIC/non-PIC, this we'll have to duplicate
cannam@126 10128 # the extraction.
cannam@126 10129 reload_conv_objs=
cannam@126 10130 gentop=
cannam@126 10131 # if reload_cmds runs $LD directly, get rid of -Wl from
cannam@126 10132 # whole_archive_flag_spec and hope we can get by with turning comma
cannam@126 10133 # into space.
cannam@126 10134 case $reload_cmds in
cannam@126 10135 *\$LD[\ \$]*) wl= ;;
cannam@126 10136 esac
cannam@126 10137 if test -n "$convenience"; then
cannam@126 10138 if test -n "$whole_archive_flag_spec"; then
cannam@126 10139 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
cannam@126 10140 test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
cannam@126 10141 reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
cannam@126 10142 else
cannam@126 10143 gentop=$output_objdir/${obj}x
cannam@126 10144 func_append generated " $gentop"
cannam@126 10145
cannam@126 10146 func_extract_archives $gentop $convenience
cannam@126 10147 reload_conv_objs="$reload_objs $func_extract_archives_result"
cannam@126 10148 fi
cannam@126 10149 fi
cannam@126 10150
cannam@126 10151 # If we're not building shared, we need to use non_pic_objs
cannam@126 10152 test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
cannam@126 10153
cannam@126 10154 # Create the old-style object.
cannam@126 10155 reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
cannam@126 10156
cannam@126 10157 output=$obj
cannam@126 10158 func_execute_cmds "$reload_cmds" 'exit $?'
cannam@126 10159
cannam@126 10160 # Exit if we aren't doing a library object file.
cannam@126 10161 if test -z "$libobj"; then
cannam@126 10162 if test -n "$gentop"; then
cannam@126 10163 func_show_eval '${RM}r "$gentop"'
cannam@126 10164 fi
cannam@126 10165
cannam@126 10166 exit $EXIT_SUCCESS
cannam@126 10167 fi
cannam@126 10168
cannam@126 10169 test yes = "$build_libtool_libs" || {
cannam@126 10170 if test -n "$gentop"; then
cannam@126 10171 func_show_eval '${RM}r "$gentop"'
cannam@126 10172 fi
cannam@126 10173
cannam@126 10174 # Create an invalid libtool object if no PIC, so that we don't
cannam@126 10175 # accidentally link it into a program.
cannam@126 10176 # $show "echo timestamp > $libobj"
cannam@126 10177 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
cannam@126 10178 exit $EXIT_SUCCESS
cannam@126 10179 }
cannam@126 10180
cannam@126 10181 if test -n "$pic_flag" || test default != "$pic_mode"; then
cannam@126 10182 # Only do commands if we really have different PIC objects.
cannam@126 10183 reload_objs="$libobjs $reload_conv_objs"
cannam@126 10184 output=$libobj
cannam@126 10185 func_execute_cmds "$reload_cmds" 'exit $?'
cannam@126 10186 fi
cannam@126 10187
cannam@126 10188 if test -n "$gentop"; then
cannam@126 10189 func_show_eval '${RM}r "$gentop"'
cannam@126 10190 fi
cannam@126 10191
cannam@126 10192 exit $EXIT_SUCCESS
cannam@126 10193 ;;
cannam@126 10194
cannam@126 10195 prog)
cannam@126 10196 case $host in
cannam@126 10197 *cygwin*) func_stripname '' '.exe' "$output"
cannam@126 10198 output=$func_stripname_result.exe;;
cannam@126 10199 esac
cannam@126 10200 test -n "$vinfo" && \
cannam@126 10201 func_warning "'-version-info' is ignored for programs"
cannam@126 10202
cannam@126 10203 test -n "$release" && \
cannam@126 10204 func_warning "'-release' is ignored for programs"
cannam@126 10205
cannam@126 10206 $preload \
cannam@126 10207 && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
cannam@126 10208 && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
cannam@126 10209
cannam@126 10210 case $host in
cannam@126 10211 *-*-rhapsody* | *-*-darwin1.[012])
cannam@126 10212 # On Rhapsody replace the C library is the System framework
cannam@126 10213 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
cannam@126 10214 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
cannam@126 10215 ;;
cannam@126 10216 esac
cannam@126 10217
cannam@126 10218 case $host in
cannam@126 10219 *-*-darwin*)
cannam@126 10220 # Don't allow lazy linking, it breaks C++ global constructors
cannam@126 10221 # But is supposedly fixed on 10.4 or later (yay!).
cannam@126 10222 if test CXX = "$tagname"; then
cannam@126 10223 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
cannam@126 10224 10.[0123])
cannam@126 10225 func_append compile_command " $wl-bind_at_load"
cannam@126 10226 func_append finalize_command " $wl-bind_at_load"
cannam@126 10227 ;;
cannam@126 10228 esac
cannam@126 10229 fi
cannam@126 10230 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
cannam@126 10231 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@126 10232 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@126 10233 ;;
cannam@126 10234 esac
cannam@126 10235
cannam@126 10236
cannam@126 10237 # move library search paths that coincide with paths to not yet
cannam@126 10238 # installed libraries to the beginning of the library search list
cannam@126 10239 new_libs=
cannam@126 10240 for path in $notinst_path; do
cannam@126 10241 case " $new_libs " in
cannam@126 10242 *" -L$path/$objdir "*) ;;
cannam@126 10243 *)
cannam@126 10244 case " $compile_deplibs " in
cannam@126 10245 *" -L$path/$objdir "*)
cannam@126 10246 func_append new_libs " -L$path/$objdir" ;;
cannam@126 10247 esac
cannam@126 10248 ;;
cannam@126 10249 esac
cannam@126 10250 done
cannam@126 10251 for deplib in $compile_deplibs; do
cannam@126 10252 case $deplib in
cannam@126 10253 -L*)
cannam@126 10254 case " $new_libs " in
cannam@126 10255 *" $deplib "*) ;;
cannam@126 10256 *) func_append new_libs " $deplib" ;;
cannam@126 10257 esac
cannam@126 10258 ;;
cannam@126 10259 *) func_append new_libs " $deplib" ;;
cannam@126 10260 esac
cannam@126 10261 done
cannam@126 10262 compile_deplibs=$new_libs
cannam@126 10263
cannam@126 10264
cannam@126 10265 func_append compile_command " $compile_deplibs"
cannam@126 10266 func_append finalize_command " $finalize_deplibs"
cannam@126 10267
cannam@126 10268 if test -n "$rpath$xrpath"; then
cannam@126 10269 # If the user specified any rpath flags, then add them.
cannam@126 10270 for libdir in $rpath $xrpath; do
cannam@126 10271 # This is the magic to use -rpath.
cannam@126 10272 case "$finalize_rpath " in
cannam@126 10273 *" $libdir "*) ;;
cannam@126 10274 *) func_append finalize_rpath " $libdir" ;;
cannam@126 10275 esac
cannam@126 10276 done
cannam@126 10277 fi
cannam@126 10278
cannam@126 10279 # Now hardcode the library paths
cannam@126 10280 rpath=
cannam@126 10281 hardcode_libdirs=
cannam@126 10282 for libdir in $compile_rpath $finalize_rpath; do
cannam@126 10283 if test -n "$hardcode_libdir_flag_spec"; then
cannam@126 10284 if test -n "$hardcode_libdir_separator"; then
cannam@126 10285 if test -z "$hardcode_libdirs"; then
cannam@126 10286 hardcode_libdirs=$libdir
cannam@126 10287 else
cannam@126 10288 # Just accumulate the unique libdirs.
cannam@126 10289 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
cannam@126 10290 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
cannam@126 10291 ;;
cannam@126 10292 *)
cannam@126 10293 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
cannam@126 10294 ;;
cannam@126 10295 esac
cannam@126 10296 fi
cannam@126 10297 else
cannam@126 10298 eval flag=\"$hardcode_libdir_flag_spec\"
cannam@126 10299 func_append rpath " $flag"
cannam@126 10300 fi
cannam@126 10301 elif test -n "$runpath_var"; then
cannam@126 10302 case "$perm_rpath " in
cannam@126 10303 *" $libdir "*) ;;
cannam@126 10304 *) func_append perm_rpath " $libdir" ;;
cannam@126 10305 esac
cannam@126 10306 fi
cannam@126 10307 case $host in
cannam@126 10308 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
cannam@126 10309 testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
cannam@126 10310 case :$dllsearchpath: in
cannam@126 10311 *":$libdir:"*) ;;
cannam@126 10312 ::) dllsearchpath=$libdir;;
cannam@126 10313 *) func_append dllsearchpath ":$libdir";;
cannam@126 10314 esac
cannam@126 10315 case :$dllsearchpath: in
cannam@126 10316 *":$testbindir:"*) ;;
cannam@126 10317 ::) dllsearchpath=$testbindir;;
cannam@126 10318 *) func_append dllsearchpath ":$testbindir";;
cannam@126 10319 esac
cannam@126 10320 ;;
cannam@126 10321 esac
cannam@126 10322 done
cannam@126 10323 # Substitute the hardcoded libdirs into the rpath.
cannam@126 10324 if test -n "$hardcode_libdir_separator" &&
cannam@126 10325 test -n "$hardcode_libdirs"; then
cannam@126 10326 libdir=$hardcode_libdirs
cannam@126 10327 eval rpath=\" $hardcode_libdir_flag_spec\"
cannam@126 10328 fi
cannam@126 10329 compile_rpath=$rpath
cannam@126 10330
cannam@126 10331 rpath=
cannam@126 10332 hardcode_libdirs=
cannam@126 10333 for libdir in $finalize_rpath; do
cannam@126 10334 if test -n "$hardcode_libdir_flag_spec"; then
cannam@126 10335 if test -n "$hardcode_libdir_separator"; then
cannam@126 10336 if test -z "$hardcode_libdirs"; then
cannam@126 10337 hardcode_libdirs=$libdir
cannam@126 10338 else
cannam@126 10339 # Just accumulate the unique libdirs.
cannam@126 10340 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
cannam@126 10341 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
cannam@126 10342 ;;
cannam@126 10343 *)
cannam@126 10344 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
cannam@126 10345 ;;
cannam@126 10346 esac
cannam@126 10347 fi
cannam@126 10348 else
cannam@126 10349 eval flag=\"$hardcode_libdir_flag_spec\"
cannam@126 10350 func_append rpath " $flag"
cannam@126 10351 fi
cannam@126 10352 elif test -n "$runpath_var"; then
cannam@126 10353 case "$finalize_perm_rpath " in
cannam@126 10354 *" $libdir "*) ;;
cannam@126 10355 *) func_append finalize_perm_rpath " $libdir" ;;
cannam@126 10356 esac
cannam@126 10357 fi
cannam@126 10358 done
cannam@126 10359 # Substitute the hardcoded libdirs into the rpath.
cannam@126 10360 if test -n "$hardcode_libdir_separator" &&
cannam@126 10361 test -n "$hardcode_libdirs"; then
cannam@126 10362 libdir=$hardcode_libdirs
cannam@126 10363 eval rpath=\" $hardcode_libdir_flag_spec\"
cannam@126 10364 fi
cannam@126 10365 finalize_rpath=$rpath
cannam@126 10366
cannam@126 10367 if test -n "$libobjs" && test yes = "$build_old_libs"; then
cannam@126 10368 # Transform all the library objects into standard objects.
cannam@126 10369 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
cannam@126 10370 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
cannam@126 10371 fi
cannam@126 10372
cannam@126 10373 func_generate_dlsyms "$outputname" "@PROGRAM@" false
cannam@126 10374
cannam@126 10375 # template prelinking step
cannam@126 10376 if test -n "$prelink_cmds"; then
cannam@126 10377 func_execute_cmds "$prelink_cmds" 'exit $?'
cannam@126 10378 fi
cannam@126 10379
cannam@126 10380 wrappers_required=:
cannam@126 10381 case $host in
cannam@126 10382 *cegcc* | *mingw32ce*)
cannam@126 10383 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
cannam@126 10384 wrappers_required=false
cannam@126 10385 ;;
cannam@126 10386 *cygwin* | *mingw* )
cannam@126 10387 test yes = "$build_libtool_libs" || wrappers_required=false
cannam@126 10388 ;;
cannam@126 10389 *)
cannam@126 10390 if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
cannam@126 10391 wrappers_required=false
cannam@126 10392 fi
cannam@126 10393 ;;
cannam@126 10394 esac
cannam@126 10395 $wrappers_required || {
cannam@126 10396 # Replace the output file specification.
cannam@126 10397 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
cannam@126 10398 link_command=$compile_command$compile_rpath
cannam@126 10399
cannam@126 10400 # We have no uninstalled library dependencies, so finalize right now.
cannam@126 10401 exit_status=0
cannam@126 10402 func_show_eval "$link_command" 'exit_status=$?'
cannam@126 10403
cannam@126 10404 if test -n "$postlink_cmds"; then
cannam@126 10405 func_to_tool_file "$output"
cannam@126 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@126 10407 func_execute_cmds "$postlink_cmds" 'exit $?'
cannam@126 10408 fi
cannam@126 10409
cannam@126 10410 # Delete the generated files.
cannam@126 10411 if test -f "$output_objdir/${outputname}S.$objext"; then
cannam@126 10412 func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
cannam@126 10413 fi
cannam@126 10414
cannam@126 10415 exit $exit_status
cannam@126 10416 }
cannam@126 10417
cannam@126 10418 if test -n "$compile_shlibpath$finalize_shlibpath"; then
cannam@126 10419 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
cannam@126 10420 fi
cannam@126 10421 if test -n "$finalize_shlibpath"; then
cannam@126 10422 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
cannam@126 10423 fi
cannam@126 10424
cannam@126 10425 compile_var=
cannam@126 10426 finalize_var=
cannam@126 10427 if test -n "$runpath_var"; then
cannam@126 10428 if test -n "$perm_rpath"; then
cannam@126 10429 # We should set the runpath_var.
cannam@126 10430 rpath=
cannam@126 10431 for dir in $perm_rpath; do
cannam@126 10432 func_append rpath "$dir:"
cannam@126 10433 done
cannam@126 10434 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
cannam@126 10435 fi
cannam@126 10436 if test -n "$finalize_perm_rpath"; then
cannam@126 10437 # We should set the runpath_var.
cannam@126 10438 rpath=
cannam@126 10439 for dir in $finalize_perm_rpath; do
cannam@126 10440 func_append rpath "$dir:"
cannam@126 10441 done
cannam@126 10442 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
cannam@126 10443 fi
cannam@126 10444 fi
cannam@126 10445
cannam@126 10446 if test yes = "$no_install"; then
cannam@126 10447 # We don't need to create a wrapper script.
cannam@126 10448 link_command=$compile_var$compile_command$compile_rpath
cannam@126 10449 # Replace the output file specification.
cannam@126 10450 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
cannam@126 10451 # Delete the old output file.
cannam@126 10452 $opt_dry_run || $RM $output
cannam@126 10453 # Link the executable and exit
cannam@126 10454 func_show_eval "$link_command" 'exit $?'
cannam@126 10455
cannam@126 10456 if test -n "$postlink_cmds"; then
cannam@126 10457 func_to_tool_file "$output"
cannam@126 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@126 10459 func_execute_cmds "$postlink_cmds" 'exit $?'
cannam@126 10460 fi
cannam@126 10461
cannam@126 10462 exit $EXIT_SUCCESS
cannam@126 10463 fi
cannam@126 10464
cannam@126 10465 case $hardcode_action,$fast_install in
cannam@126 10466 relink,*)
cannam@126 10467 # Fast installation is not supported
cannam@126 10468 link_command=$compile_var$compile_command$compile_rpath
cannam@126 10469 relink_command=$finalize_var$finalize_command$finalize_rpath
cannam@126 10470
cannam@126 10471 func_warning "this platform does not like uninstalled shared libraries"
cannam@126 10472 func_warning "'$output' will be relinked during installation"
cannam@126 10473 ;;
cannam@126 10474 *,yes)
cannam@126 10475 link_command=$finalize_var$compile_command$finalize_rpath
cannam@126 10476 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
cannam@126 10477 ;;
cannam@126 10478 *,no)
cannam@126 10479 link_command=$compile_var$compile_command$compile_rpath
cannam@126 10480 relink_command=$finalize_var$finalize_command$finalize_rpath
cannam@126 10481 ;;
cannam@126 10482 *,needless)
cannam@126 10483 link_command=$finalize_var$compile_command$finalize_rpath
cannam@126 10484 relink_command=
cannam@126 10485 ;;
cannam@126 10486 esac
cannam@126 10487
cannam@126 10488 # Replace the output file specification.
cannam@126 10489 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
cannam@126 10490
cannam@126 10491 # Delete the old output files.
cannam@126 10492 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
cannam@126 10493
cannam@126 10494 func_show_eval "$link_command" 'exit $?'
cannam@126 10495
cannam@126 10496 if test -n "$postlink_cmds"; then
cannam@126 10497 func_to_tool_file "$output_objdir/$outputname"
cannam@126 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@126 10499 func_execute_cmds "$postlink_cmds" 'exit $?'
cannam@126 10500 fi
cannam@126 10501
cannam@126 10502 # Now create the wrapper script.
cannam@126 10503 func_verbose "creating $output"
cannam@126 10504
cannam@126 10505 # Quote the relink command for shipping.
cannam@126 10506 if test -n "$relink_command"; then
cannam@126 10507 # Preserve any variables that may affect compiler behavior
cannam@126 10508 for var in $variables_saved_for_relink; do
cannam@126 10509 if eval test -z \"\${$var+set}\"; then
cannam@126 10510 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
cannam@126 10511 elif eval var_value=\$$var; test -z "$var_value"; then
cannam@126 10512 relink_command="$var=; export $var; $relink_command"
cannam@126 10513 else
cannam@126 10514 func_quote_for_eval "$var_value"
cannam@126 10515 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
cannam@126 10516 fi
cannam@126 10517 done
cannam@126 10518 relink_command="(cd `pwd`; $relink_command)"
cannam@126 10519 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
cannam@126 10520 fi
cannam@126 10521
cannam@126 10522 # Only actually do things if not in dry run mode.
cannam@126 10523 $opt_dry_run || {
cannam@126 10524 # win32 will think the script is a binary if it has
cannam@126 10525 # a .exe suffix, so we strip it off here.
cannam@126 10526 case $output in
cannam@126 10527 *.exe) func_stripname '' '.exe' "$output"
cannam@126 10528 output=$func_stripname_result ;;
cannam@126 10529 esac
cannam@126 10530 # test for cygwin because mv fails w/o .exe extensions
cannam@126 10531 case $host in
cannam@126 10532 *cygwin*)
cannam@126 10533 exeext=.exe
cannam@126 10534 func_stripname '' '.exe' "$outputname"
cannam@126 10535 outputname=$func_stripname_result ;;
cannam@126 10536 *) exeext= ;;
cannam@126 10537 esac
cannam@126 10538 case $host in
cannam@126 10539 *cygwin* | *mingw* )
cannam@126 10540 func_dirname_and_basename "$output" "" "."
cannam@126 10541 output_name=$func_basename_result
cannam@126 10542 output_path=$func_dirname_result
cannam@126 10543 cwrappersource=$output_path/$objdir/lt-$output_name.c
cannam@126 10544 cwrapper=$output_path/$output_name.exe
cannam@126 10545 $RM $cwrappersource $cwrapper
cannam@126 10546 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
cannam@126 10547
cannam@126 10548 func_emit_cwrapperexe_src > $cwrappersource
cannam@126 10549
cannam@126 10550 # The wrapper executable is built using the $host compiler,
cannam@126 10551 # because it contains $host paths and files. If cross-
cannam@126 10552 # compiling, it, like the target executable, must be
cannam@126 10553 # executed on the $host or under an emulation environment.
cannam@126 10554 $opt_dry_run || {
cannam@126 10555 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
cannam@126 10556 $STRIP $cwrapper
cannam@126 10557 }
cannam@126 10558
cannam@126 10559 # Now, create the wrapper script for func_source use:
cannam@126 10560 func_ltwrapper_scriptname $cwrapper
cannam@126 10561 $RM $func_ltwrapper_scriptname_result
cannam@126 10562 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
cannam@126 10563 $opt_dry_run || {
cannam@126 10564 # note: this script will not be executed, so do not chmod.
cannam@126 10565 if test "x$build" = "x$host"; then
cannam@126 10566 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
cannam@126 10567 else
cannam@126 10568 func_emit_wrapper no > $func_ltwrapper_scriptname_result
cannam@126 10569 fi
cannam@126 10570 }
cannam@126 10571 ;;
cannam@126 10572 * )
cannam@126 10573 $RM $output
cannam@126 10574 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
cannam@126 10575
cannam@126 10576 func_emit_wrapper no > $output
cannam@126 10577 chmod +x $output
cannam@126 10578 ;;
cannam@126 10579 esac
cannam@126 10580 }
cannam@126 10581 exit $EXIT_SUCCESS
cannam@126 10582 ;;
cannam@126 10583 esac
cannam@126 10584
cannam@126 10585 # See if we need to build an old-fashioned archive.
cannam@126 10586 for oldlib in $oldlibs; do
cannam@126 10587
cannam@126 10588 case $build_libtool_libs in
cannam@126 10589 convenience)
cannam@126 10590 oldobjs="$libobjs_save $symfileobj"
cannam@126 10591 addlibs=$convenience
cannam@126 10592 build_libtool_libs=no
cannam@126 10593 ;;
cannam@126 10594 module)
cannam@126 10595 oldobjs=$libobjs_save
cannam@126 10596 addlibs=$old_convenience
cannam@126 10597 build_libtool_libs=no
cannam@126 10598 ;;
cannam@126 10599 *)
cannam@126 10600 oldobjs="$old_deplibs $non_pic_objects"
cannam@126 10601 $preload && test -f "$symfileobj" \
cannam@126 10602 && func_append oldobjs " $symfileobj"
cannam@126 10603 addlibs=$old_convenience
cannam@126 10604 ;;
cannam@126 10605 esac
cannam@126 10606
cannam@126 10607 if test -n "$addlibs"; then
cannam@126 10608 gentop=$output_objdir/${outputname}x
cannam@126 10609 func_append generated " $gentop"
cannam@126 10610
cannam@126 10611 func_extract_archives $gentop $addlibs
cannam@126 10612 func_append oldobjs " $func_extract_archives_result"
cannam@126 10613 fi
cannam@126 10614
cannam@126 10615 # Do each command in the archive commands.
cannam@126 10616 if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
cannam@126 10617 cmds=$old_archive_from_new_cmds
cannam@126 10618 else
cannam@126 10619
cannam@126 10620 # Add any objects from preloaded convenience libraries
cannam@126 10621 if test -n "$dlprefiles"; then
cannam@126 10622 gentop=$output_objdir/${outputname}x
cannam@126 10623 func_append generated " $gentop"
cannam@126 10624
cannam@126 10625 func_extract_archives $gentop $dlprefiles
cannam@126 10626 func_append oldobjs " $func_extract_archives_result"
cannam@126 10627 fi
cannam@126 10628
cannam@126 10629 # POSIX demands no paths to be encoded in archives. We have
cannam@126 10630 # to avoid creating archives with duplicate basenames if we
cannam@126 10631 # might have to extract them afterwards, e.g., when creating a
cannam@126 10632 # static archive out of a convenience library, or when linking
cannam@126 10633 # the entirety of a libtool archive into another (currently
cannam@126 10634 # not supported by libtool).
cannam@126 10635 if (for obj in $oldobjs
cannam@126 10636 do
cannam@126 10637 func_basename "$obj"
cannam@126 10638 $ECHO "$func_basename_result"
cannam@126 10639 done | sort | sort -uc >/dev/null 2>&1); then
cannam@126 10640 :
cannam@126 10641 else
cannam@126 10642 echo "copying selected object files to avoid basename conflicts..."
cannam@126 10643 gentop=$output_objdir/${outputname}x
cannam@126 10644 func_append generated " $gentop"
cannam@126 10645 func_mkdir_p "$gentop"
cannam@126 10646 save_oldobjs=$oldobjs
cannam@126 10647 oldobjs=
cannam@126 10648 counter=1
cannam@126 10649 for obj in $save_oldobjs
cannam@126 10650 do
cannam@126 10651 func_basename "$obj"
cannam@126 10652 objbase=$func_basename_result
cannam@126 10653 case " $oldobjs " in
cannam@126 10654 " ") oldobjs=$obj ;;
cannam@126 10655 *[\ /]"$objbase "*)
cannam@126 10656 while :; do
cannam@126 10657 # Make sure we don't pick an alternate name that also
cannam@126 10658 # overlaps.
cannam@126 10659 newobj=lt$counter-$objbase
cannam@126 10660 func_arith $counter + 1
cannam@126 10661 counter=$func_arith_result
cannam@126 10662 case " $oldobjs " in
cannam@126 10663 *[\ /]"$newobj "*) ;;
cannam@126 10664 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
cannam@126 10665 esac
cannam@126 10666 done
cannam@126 10667 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
cannam@126 10668 func_append oldobjs " $gentop/$newobj"
cannam@126 10669 ;;
cannam@126 10670 *) func_append oldobjs " $obj" ;;
cannam@126 10671 esac
cannam@126 10672 done
cannam@126 10673 fi
cannam@126 10674 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
cannam@126 10675 tool_oldlib=$func_to_tool_file_result
cannam@126 10676 eval cmds=\"$old_archive_cmds\"
cannam@126 10677
cannam@126 10678 func_len " $cmds"
cannam@126 10679 len=$func_len_result
cannam@126 10680 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
cannam@126 10681 cmds=$old_archive_cmds
cannam@126 10682 elif test -n "$archiver_list_spec"; then
cannam@126 10683 func_verbose "using command file archive linking..."
cannam@126 10684 for obj in $oldobjs
cannam@126 10685 do
cannam@126 10686 func_to_tool_file "$obj"
cannam@126 10687 $ECHO "$func_to_tool_file_result"
cannam@126 10688 done > $output_objdir/$libname.libcmd
cannam@126 10689 func_to_tool_file "$output_objdir/$libname.libcmd"
cannam@126 10690 oldobjs=" $archiver_list_spec$func_to_tool_file_result"
cannam@126 10691 cmds=$old_archive_cmds
cannam@126 10692 else
cannam@126 10693 # the command line is too long to link in one step, link in parts
cannam@126 10694 func_verbose "using piecewise archive linking..."
cannam@126 10695 save_RANLIB=$RANLIB
cannam@126 10696 RANLIB=:
cannam@126 10697 objlist=
cannam@126 10698 concat_cmds=
cannam@126 10699 save_oldobjs=$oldobjs
cannam@126 10700 oldobjs=
cannam@126 10701 # Is there a better way of finding the last object in the list?
cannam@126 10702 for obj in $save_oldobjs
cannam@126 10703 do
cannam@126 10704 last_oldobj=$obj
cannam@126 10705 done
cannam@126 10706 eval test_cmds=\"$old_archive_cmds\"
cannam@126 10707 func_len " $test_cmds"
cannam@126 10708 len0=$func_len_result
cannam@126 10709 len=$len0
cannam@126 10710 for obj in $save_oldobjs
cannam@126 10711 do
cannam@126 10712 func_len " $obj"
cannam@126 10713 func_arith $len + $func_len_result
cannam@126 10714 len=$func_arith_result
cannam@126 10715 func_append objlist " $obj"
cannam@126 10716 if test "$len" -lt "$max_cmd_len"; then
cannam@126 10717 :
cannam@126 10718 else
cannam@126 10719 # the above command should be used before it gets too long
cannam@126 10720 oldobjs=$objlist
cannam@126 10721 if test "$obj" = "$last_oldobj"; then
cannam@126 10722 RANLIB=$save_RANLIB
cannam@126 10723 fi
cannam@126 10724 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
cannam@126 10725 eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
cannam@126 10726 objlist=
cannam@126 10727 len=$len0
cannam@126 10728 fi
cannam@126 10729 done
cannam@126 10730 RANLIB=$save_RANLIB
cannam@126 10731 oldobjs=$objlist
cannam@126 10732 if test -z "$oldobjs"; then
cannam@126 10733 eval cmds=\"\$concat_cmds\"
cannam@126 10734 else
cannam@126 10735 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
cannam@126 10736 fi
cannam@126 10737 fi
cannam@126 10738 fi
cannam@126 10739 func_execute_cmds "$cmds" 'exit $?'
cannam@126 10740 done
cannam@126 10741
cannam@126 10742 test -n "$generated" && \
cannam@126 10743 func_show_eval "${RM}r$generated"
cannam@126 10744
cannam@126 10745 # Now create the libtool archive.
cannam@126 10746 case $output in
cannam@126 10747 *.la)
cannam@126 10748 old_library=
cannam@126 10749 test yes = "$build_old_libs" && old_library=$libname.$libext
cannam@126 10750 func_verbose "creating $output"
cannam@126 10751
cannam@126 10752 # Preserve any variables that may affect compiler behavior
cannam@126 10753 for var in $variables_saved_for_relink; do
cannam@126 10754 if eval test -z \"\${$var+set}\"; then
cannam@126 10755 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
cannam@126 10756 elif eval var_value=\$$var; test -z "$var_value"; then
cannam@126 10757 relink_command="$var=; export $var; $relink_command"
cannam@126 10758 else
cannam@126 10759 func_quote_for_eval "$var_value"
cannam@126 10760 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
cannam@126 10761 fi
cannam@126 10762 done
cannam@126 10763 # Quote the link command for shipping.
cannam@126 10764 relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
cannam@126 10765 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
cannam@126 10766 if test yes = "$hardcode_automatic"; then
cannam@126 10767 relink_command=
cannam@126 10768 fi
cannam@126 10769
cannam@126 10770 # Only create the output if not a dry run.
cannam@126 10771 $opt_dry_run || {
cannam@126 10772 for installed in no yes; do
cannam@126 10773 if test yes = "$installed"; then
cannam@126 10774 if test -z "$install_libdir"; then
cannam@126 10775 break
cannam@126 10776 fi
cannam@126 10777 output=$output_objdir/${outputname}i
cannam@126 10778 # Replace all uninstalled libtool libraries with the installed ones
cannam@126 10779 newdependency_libs=
cannam@126 10780 for deplib in $dependency_libs; do
cannam@126 10781 case $deplib in
cannam@126 10782 *.la)
cannam@126 10783 func_basename "$deplib"
cannam@126 10784 name=$func_basename_result
cannam@126 10785 func_resolve_sysroot "$deplib"
cannam@126 10786 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
cannam@126 10787 test -z "$libdir" && \
cannam@126 10788 func_fatal_error "'$deplib' is not a valid libtool archive"
cannam@126 10789 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
cannam@126 10790 ;;
cannam@126 10791 -L*)
cannam@126 10792 func_stripname -L '' "$deplib"
cannam@126 10793 func_replace_sysroot "$func_stripname_result"
cannam@126 10794 func_append newdependency_libs " -L$func_replace_sysroot_result"
cannam@126 10795 ;;
cannam@126 10796 -R*)
cannam@126 10797 func_stripname -R '' "$deplib"
cannam@126 10798 func_replace_sysroot "$func_stripname_result"
cannam@126 10799 func_append newdependency_libs " -R$func_replace_sysroot_result"
cannam@126 10800 ;;
cannam@126 10801 *) func_append newdependency_libs " $deplib" ;;
cannam@126 10802 esac
cannam@126 10803 done
cannam@126 10804 dependency_libs=$newdependency_libs
cannam@126 10805 newdlfiles=
cannam@126 10806
cannam@126 10807 for lib in $dlfiles; do
cannam@126 10808 case $lib in
cannam@126 10809 *.la)
cannam@126 10810 func_basename "$lib"
cannam@126 10811 name=$func_basename_result
cannam@126 10812 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
cannam@126 10813 test -z "$libdir" && \
cannam@126 10814 func_fatal_error "'$lib' is not a valid libtool archive"
cannam@126 10815 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
cannam@126 10816 ;;
cannam@126 10817 *) func_append newdlfiles " $lib" ;;
cannam@126 10818 esac
cannam@126 10819 done
cannam@126 10820 dlfiles=$newdlfiles
cannam@126 10821 newdlprefiles=
cannam@126 10822 for lib in $dlprefiles; do
cannam@126 10823 case $lib in
cannam@126 10824 *.la)
cannam@126 10825 # Only pass preopened files to the pseudo-archive (for
cannam@126 10826 # eventual linking with the app. that links it) if we
cannam@126 10827 # didn't already link the preopened objects directly into
cannam@126 10828 # the library:
cannam@126 10829 func_basename "$lib"
cannam@126 10830 name=$func_basename_result
cannam@126 10831 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
cannam@126 10832 test -z "$libdir" && \
cannam@126 10833 func_fatal_error "'$lib' is not a valid libtool archive"
cannam@126 10834 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
cannam@126 10835 ;;
cannam@126 10836 esac
cannam@126 10837 done
cannam@126 10838 dlprefiles=$newdlprefiles
cannam@126 10839 else
cannam@126 10840 newdlfiles=
cannam@126 10841 for lib in $dlfiles; do
cannam@126 10842 case $lib in
cannam@126 10843 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
cannam@126 10844 *) abs=`pwd`"/$lib" ;;
cannam@126 10845 esac
cannam@126 10846 func_append newdlfiles " $abs"
cannam@126 10847 done
cannam@126 10848 dlfiles=$newdlfiles
cannam@126 10849 newdlprefiles=
cannam@126 10850 for lib in $dlprefiles; do
cannam@126 10851 case $lib in
cannam@126 10852 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
cannam@126 10853 *) abs=`pwd`"/$lib" ;;
cannam@126 10854 esac
cannam@126 10855 func_append newdlprefiles " $abs"
cannam@126 10856 done
cannam@126 10857 dlprefiles=$newdlprefiles
cannam@126 10858 fi
cannam@126 10859 $RM $output
cannam@126 10860 # place dlname in correct position for cygwin
cannam@126 10861 # In fact, it would be nice if we could use this code for all target
cannam@126 10862 # systems that can't hard-code library paths into their executables
cannam@126 10863 # and that have no shared library path variable independent of PATH,
cannam@126 10864 # but it turns out we can't easily determine that from inspecting
cannam@126 10865 # libtool variables, so we have to hard-code the OSs to which it
cannam@126 10866 # applies here; at the moment, that means platforms that use the PE
cannam@126 10867 # object format with DLL files. See the long comment at the top of
cannam@126 10868 # tests/bindir.at for full details.
cannam@126 10869 tdlname=$dlname
cannam@126 10870 case $host,$output,$installed,$module,$dlname in
cannam@126 10871 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
cannam@126 10872 # If a -bindir argument was supplied, place the dll there.
cannam@126 10873 if test -n "$bindir"; then
cannam@126 10874 func_relative_path "$install_libdir" "$bindir"
cannam@126 10875 tdlname=$func_relative_path_result/$dlname
cannam@126 10876 else
cannam@126 10877 # Otherwise fall back on heuristic.
cannam@126 10878 tdlname=../bin/$dlname
cannam@126 10879 fi
cannam@126 10880 ;;
cannam@126 10881 esac
cannam@126 10882 $ECHO > $output "\
cannam@126 10883 # $outputname - a libtool library file
cannam@126 10884 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
cannam@126 10885 #
cannam@126 10886 # Please DO NOT delete this file!
cannam@126 10887 # It is necessary for linking the library.
cannam@126 10888
cannam@126 10889 # The name that we can dlopen(3).
cannam@126 10890 dlname='$tdlname'
cannam@126 10891
cannam@126 10892 # Names of this library.
cannam@126 10893 library_names='$library_names'
cannam@126 10894
cannam@126 10895 # The name of the static archive.
cannam@126 10896 old_library='$old_library'
cannam@126 10897
cannam@126 10898 # Linker flags that cannot go in dependency_libs.
cannam@126 10899 inherited_linker_flags='$new_inherited_linker_flags'
cannam@126 10900
cannam@126 10901 # Libraries that this one depends upon.
cannam@126 10902 dependency_libs='$dependency_libs'
cannam@126 10903
cannam@126 10904 # Names of additional weak libraries provided by this library
cannam@126 10905 weak_library_names='$weak_libs'
cannam@126 10906
cannam@126 10907 # Version information for $libname.
cannam@126 10908 current=$current
cannam@126 10909 age=$age
cannam@126 10910 revision=$revision
cannam@126 10911
cannam@126 10912 # Is this an already installed library?
cannam@126 10913 installed=$installed
cannam@126 10914
cannam@126 10915 # Should we warn about portability when linking against -modules?
cannam@126 10916 shouldnotlink=$module
cannam@126 10917
cannam@126 10918 # Files to dlopen/dlpreopen
cannam@126 10919 dlopen='$dlfiles'
cannam@126 10920 dlpreopen='$dlprefiles'
cannam@126 10921
cannam@126 10922 # Directory that this library needs to be installed in:
cannam@126 10923 libdir='$install_libdir'"
cannam@126 10924 if test no,yes = "$installed,$need_relink"; then
cannam@126 10925 $ECHO >> $output "\
cannam@126 10926 relink_command=\"$relink_command\""
cannam@126 10927 fi
cannam@126 10928 done
cannam@126 10929 }
cannam@126 10930
cannam@126 10931 # Do a symbolic link so that the libtool archive can be found in
cannam@126 10932 # LD_LIBRARY_PATH before the program is installed.
cannam@126 10933 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
cannam@126 10934 ;;
cannam@126 10935 esac
cannam@126 10936 exit $EXIT_SUCCESS
cannam@126 10937 }
cannam@126 10938
cannam@126 10939 if test link = "$opt_mode" || test relink = "$opt_mode"; then
cannam@126 10940 func_mode_link ${1+"$@"}
cannam@126 10941 fi
cannam@126 10942
cannam@126 10943
cannam@126 10944 # func_mode_uninstall arg...
cannam@126 10945 func_mode_uninstall ()
cannam@126 10946 {
cannam@126 10947 $debug_cmd
cannam@126 10948
cannam@126 10949 RM=$nonopt
cannam@126 10950 files=
cannam@126 10951 rmforce=false
cannam@126 10952 exit_status=0
cannam@126 10953
cannam@126 10954 # This variable tells wrapper scripts just to set variables rather
cannam@126 10955 # than running their programs.
cannam@126 10956 libtool_install_magic=$magic
cannam@126 10957
cannam@126 10958 for arg
cannam@126 10959 do
cannam@126 10960 case $arg in
cannam@126 10961 -f) func_append RM " $arg"; rmforce=: ;;
cannam@126 10962 -*) func_append RM " $arg" ;;
cannam@126 10963 *) func_append files " $arg" ;;
cannam@126 10964 esac
cannam@126 10965 done
cannam@126 10966
cannam@126 10967 test -z "$RM" && \
cannam@126 10968 func_fatal_help "you must specify an RM program"
cannam@126 10969
cannam@126 10970 rmdirs=
cannam@126 10971
cannam@126 10972 for file in $files; do
cannam@126 10973 func_dirname "$file" "" "."
cannam@126 10974 dir=$func_dirname_result
cannam@126 10975 if test . = "$dir"; then
cannam@126 10976 odir=$objdir
cannam@126 10977 else
cannam@126 10978 odir=$dir/$objdir
cannam@126 10979 fi
cannam@126 10980 func_basename "$file"
cannam@126 10981 name=$func_basename_result
cannam@126 10982 test uninstall = "$opt_mode" && odir=$dir
cannam@126 10983
cannam@126 10984 # Remember odir for removal later, being careful to avoid duplicates
cannam@126 10985 if test clean = "$opt_mode"; then
cannam@126 10986 case " $rmdirs " in
cannam@126 10987 *" $odir "*) ;;
cannam@126 10988 *) func_append rmdirs " $odir" ;;
cannam@126 10989 esac
cannam@126 10990 fi
cannam@126 10991
cannam@126 10992 # Don't error if the file doesn't exist and rm -f was used.
cannam@126 10993 if { test -L "$file"; } >/dev/null 2>&1 ||
cannam@126 10994 { test -h "$file"; } >/dev/null 2>&1 ||
cannam@126 10995 test -f "$file"; then
cannam@126 10996 :
cannam@126 10997 elif test -d "$file"; then
cannam@126 10998 exit_status=1
cannam@126 10999 continue
cannam@126 11000 elif $rmforce; then
cannam@126 11001 continue
cannam@126 11002 fi
cannam@126 11003
cannam@126 11004 rmfiles=$file
cannam@126 11005
cannam@126 11006 case $name in
cannam@126 11007 *.la)
cannam@126 11008 # Possibly a libtool archive, so verify it.
cannam@126 11009 if func_lalib_p "$file"; then
cannam@126 11010 func_source $dir/$name
cannam@126 11011
cannam@126 11012 # Delete the libtool libraries and symlinks.
cannam@126 11013 for n in $library_names; do
cannam@126 11014 func_append rmfiles " $odir/$n"
cannam@126 11015 done
cannam@126 11016 test -n "$old_library" && func_append rmfiles " $odir/$old_library"
cannam@126 11017
cannam@126 11018 case $opt_mode in
cannam@126 11019 clean)
cannam@126 11020 case " $library_names " in
cannam@126 11021 *" $dlname "*) ;;
cannam@126 11022 *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
cannam@126 11023 esac
cannam@126 11024 test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
cannam@126 11025 ;;
cannam@126 11026 uninstall)
cannam@126 11027 if test -n "$library_names"; then
cannam@126 11028 # Do each command in the postuninstall commands.
cannam@126 11029 func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
cannam@126 11030 fi
cannam@126 11031
cannam@126 11032 if test -n "$old_library"; then
cannam@126 11033 # Do each command in the old_postuninstall commands.
cannam@126 11034 func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
cannam@126 11035 fi
cannam@126 11036 # FIXME: should reinstall the best remaining shared library.
cannam@126 11037 ;;
cannam@126 11038 esac
cannam@126 11039 fi
cannam@126 11040 ;;
cannam@126 11041
cannam@126 11042 *.lo)
cannam@126 11043 # Possibly a libtool object, so verify it.
cannam@126 11044 if func_lalib_p "$file"; then
cannam@126 11045
cannam@126 11046 # Read the .lo file
cannam@126 11047 func_source $dir/$name
cannam@126 11048
cannam@126 11049 # Add PIC object to the list of files to remove.
cannam@126 11050 if test -n "$pic_object" && test none != "$pic_object"; then
cannam@126 11051 func_append rmfiles " $dir/$pic_object"
cannam@126 11052 fi
cannam@126 11053
cannam@126 11054 # Add non-PIC object to the list of files to remove.
cannam@126 11055 if test -n "$non_pic_object" && test none != "$non_pic_object"; then
cannam@126 11056 func_append rmfiles " $dir/$non_pic_object"
cannam@126 11057 fi
cannam@126 11058 fi
cannam@126 11059 ;;
cannam@126 11060
cannam@126 11061 *)
cannam@126 11062 if test clean = "$opt_mode"; then
cannam@126 11063 noexename=$name
cannam@126 11064 case $file in
cannam@126 11065 *.exe)
cannam@126 11066 func_stripname '' '.exe' "$file"
cannam@126 11067 file=$func_stripname_result
cannam@126 11068 func_stripname '' '.exe' "$name"
cannam@126 11069 noexename=$func_stripname_result
cannam@126 11070 # $file with .exe has already been added to rmfiles,
cannam@126 11071 # add $file without .exe
cannam@126 11072 func_append rmfiles " $file"
cannam@126 11073 ;;
cannam@126 11074 esac
cannam@126 11075 # Do a test to see if this is a libtool program.
cannam@126 11076 if func_ltwrapper_p "$file"; then
cannam@126 11077 if func_ltwrapper_executable_p "$file"; then
cannam@126 11078 func_ltwrapper_scriptname "$file"
cannam@126 11079 relink_command=
cannam@126 11080 func_source $func_ltwrapper_scriptname_result
cannam@126 11081 func_append rmfiles " $func_ltwrapper_scriptname_result"
cannam@126 11082 else
cannam@126 11083 relink_command=
cannam@126 11084 func_source $dir/$noexename
cannam@126 11085 fi
cannam@126 11086
cannam@126 11087 # note $name still contains .exe if it was in $file originally
cannam@126 11088 # as does the version of $file that was added into $rmfiles
cannam@126 11089 func_append rmfiles " $odir/$name $odir/${name}S.$objext"
cannam@126 11090 if test yes = "$fast_install" && test -n "$relink_command"; then
cannam@126 11091 func_append rmfiles " $odir/lt-$name"
cannam@126 11092 fi
cannam@126 11093 if test "X$noexename" != "X$name"; then
cannam@126 11094 func_append rmfiles " $odir/lt-$noexename.c"
cannam@126 11095 fi
cannam@126 11096 fi
cannam@126 11097 fi
cannam@126 11098 ;;
cannam@126 11099 esac
cannam@126 11100 func_show_eval "$RM $rmfiles" 'exit_status=1'
cannam@126 11101 done
cannam@126 11102
cannam@126 11103 # Try to remove the $objdir's in the directories where we deleted files
cannam@126 11104 for dir in $rmdirs; do
cannam@126 11105 if test -d "$dir"; then
cannam@126 11106 func_show_eval "rmdir $dir >/dev/null 2>&1"
cannam@126 11107 fi
cannam@126 11108 done
cannam@126 11109
cannam@126 11110 exit $exit_status
cannam@126 11111 }
cannam@126 11112
cannam@126 11113 if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
cannam@126 11114 func_mode_uninstall ${1+"$@"}
cannam@126 11115 fi
cannam@126 11116
cannam@126 11117 test -z "$opt_mode" && {
cannam@126 11118 help=$generic_help
cannam@126 11119 func_fatal_help "you must specify a MODE"
cannam@126 11120 }
cannam@126 11121
cannam@126 11122 test -z "$exec_cmd" && \
cannam@126 11123 func_fatal_help "invalid operation mode '$opt_mode'"
cannam@126 11124
cannam@126 11125 if test -n "$exec_cmd"; then
cannam@126 11126 eval exec "$exec_cmd"
cannam@126 11127 exit $EXIT_FAILURE
cannam@126 11128 fi
cannam@126 11129
cannam@126 11130 exit $exit_status
cannam@126 11131
cannam@126 11132
cannam@126 11133 # The TAGs below are defined such that we never get into a situation
cannam@126 11134 # where we disable both kinds of libraries. Given conflicting
cannam@126 11135 # choices, we go for a static library, that is the most portable,
cannam@126 11136 # since we can't tell whether shared libraries were disabled because
cannam@126 11137 # the user asked for that or because the platform doesn't support
cannam@126 11138 # them. This is particularly important on AIX, because we don't
cannam@126 11139 # support having both static and shared libraries enabled at the same
cannam@126 11140 # time on that platform, so we default to a shared-only configuration.
cannam@126 11141 # If a disable-shared tag is given, we'll fallback to a static-only
cannam@126 11142 # configuration. But we'll never go from static-only to shared-only.
cannam@126 11143
cannam@126 11144 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
cannam@126 11145 build_libtool_libs=no
cannam@126 11146 build_old_libs=yes
cannam@126 11147 # ### END LIBTOOL TAG CONFIG: disable-shared
cannam@126 11148
cannam@126 11149 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
cannam@126 11150 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
cannam@126 11151 # ### END LIBTOOL TAG CONFIG: disable-static
cannam@126 11152
cannam@126 11153 # Local Variables:
cannam@126 11154 # mode:shell-script
cannam@126 11155 # sh-indentation:2
cannam@126 11156 # End: