annotate src/fftw-3.3.8/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 bd3cc4d1df30
children
rev   line source
cannam@167 1 #! /bin/sh
cannam@167 2 ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
cannam@167 3 ## by inline-source v2014-01-03.01
cannam@167 4
cannam@167 5 # libtool (GNU libtool) 2.4.6
cannam@167 6 # Provide generalized library-building support services.
cannam@167 7 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
cannam@167 8
cannam@167 9 # Copyright (C) 1996-2015 Free Software Foundation, Inc.
cannam@167 10 # This is free software; see the source for copying conditions. There is NO
cannam@167 11 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cannam@167 12
cannam@167 13 # GNU Libtool is free software; you can redistribute it and/or modify
cannam@167 14 # it under the terms of the GNU General Public License as published by
cannam@167 15 # the Free Software Foundation; either version 2 of the License, or
cannam@167 16 # (at your option) any later version.
cannam@167 17 #
cannam@167 18 # As a special exception to the GNU General Public License,
cannam@167 19 # if you distribute this file as part of a program or library that
cannam@167 20 # is built using GNU Libtool, you may include this file under the
cannam@167 21 # same distribution terms that you use for the rest of that program.
cannam@167 22 #
cannam@167 23 # GNU Libtool is distributed in the hope that it will be useful, but
cannam@167 24 # WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@167 25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
cannam@167 26 # General Public License for more details.
cannam@167 27 #
cannam@167 28 # You should have received a copy of the GNU General Public License
cannam@167 29 # along with this program. If not, see <http://www.gnu.org/licenses/>.
cannam@167 30
cannam@167 31
cannam@167 32 PROGRAM=libtool
cannam@167 33 PACKAGE=libtool
cannam@167 34 VERSION="2.4.6 Debian-2.4.6-2"
cannam@167 35 package_revision=2.4.6
cannam@167 36
cannam@167 37
cannam@167 38 ## ------ ##
cannam@167 39 ## Usage. ##
cannam@167 40 ## ------ ##
cannam@167 41
cannam@167 42 # Run './libtool --help' for help with using this script from the
cannam@167 43 # command line.
cannam@167 44
cannam@167 45
cannam@167 46 ## ------------------------------- ##
cannam@167 47 ## User overridable command paths. ##
cannam@167 48 ## ------------------------------- ##
cannam@167 49
cannam@167 50 # After configure completes, it has a better idea of some of the
cannam@167 51 # shell tools we need than the defaults used by the functions shared
cannam@167 52 # with bootstrap, so set those here where they can still be over-
cannam@167 53 # ridden by the user, but otherwise take precedence.
cannam@167 54
cannam@167 55 : ${AUTOCONF="autoconf"}
cannam@167 56 : ${AUTOMAKE="automake"}
cannam@167 57
cannam@167 58
cannam@167 59 ## -------------------------- ##
cannam@167 60 ## Source external libraries. ##
cannam@167 61 ## -------------------------- ##
cannam@167 62
cannam@167 63 # Much of our low-level functionality needs to be sourced from external
cannam@167 64 # libraries, which are installed to $pkgauxdir.
cannam@167 65
cannam@167 66 # Set a version string for this script.
cannam@167 67 scriptversion=2015-01-20.17; # UTC
cannam@167 68
cannam@167 69 # General shell script boiler plate, and helper functions.
cannam@167 70 # Written by Gary V. Vaughan, 2004
cannam@167 71
cannam@167 72 # Copyright (C) 2004-2015 Free Software Foundation, Inc.
cannam@167 73 # This is free software; see the source for copying conditions. There is NO
cannam@167 74 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cannam@167 75
cannam@167 76 # This program is free software; you can redistribute it and/or modify
cannam@167 77 # it under the terms of the GNU General Public License as published by
cannam@167 78 # the Free Software Foundation; either version 3 of the License, or
cannam@167 79 # (at your option) any later version.
cannam@167 80
cannam@167 81 # As a special exception to the GNU General Public License, if you distribute
cannam@167 82 # this file as part of a program or library that is built using GNU Libtool,
cannam@167 83 # you may include this file under the same distribution terms that you use
cannam@167 84 # for the rest of that program.
cannam@167 85
cannam@167 86 # This program is distributed in the hope that it will be useful,
cannam@167 87 # but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@167 88 # MERCHANTABILITY or FITNES FOR A PARTICULAR PURPOSE. See the GNU
cannam@167 89 # General Public License for more details.
cannam@167 90
cannam@167 91 # You should have received a copy of the GNU General Public License
cannam@167 92 # along with this program. If not, see <http://www.gnu.org/licenses/>.
cannam@167 93
cannam@167 94 # Please report bugs or propose patches to gary@gnu.org.
cannam@167 95
cannam@167 96
cannam@167 97 ## ------ ##
cannam@167 98 ## Usage. ##
cannam@167 99 ## ------ ##
cannam@167 100
cannam@167 101 # Evaluate this file near the top of your script to gain access to
cannam@167 102 # the functions and variables defined here:
cannam@167 103 #
cannam@167 104 # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
cannam@167 105 #
cannam@167 106 # If you need to override any of the default environment variable
cannam@167 107 # settings, do that before evaluating this file.
cannam@167 108
cannam@167 109
cannam@167 110 ## -------------------- ##
cannam@167 111 ## Shell normalisation. ##
cannam@167 112 ## -------------------- ##
cannam@167 113
cannam@167 114 # Some shells need a little help to be as Bourne compatible as possible.
cannam@167 115 # Before doing anything else, make sure all that help has been provided!
cannam@167 116
cannam@167 117 DUALCASE=1; export DUALCASE # for MKS sh
cannam@167 118 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
cannam@167 119 emulate sh
cannam@167 120 NULLCMD=:
cannam@167 121 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
cannam@167 122 # is contrary to our usage. Disable this feature.
cannam@167 123 alias -g '${1+"$@"}'='"$@"'
cannam@167 124 setopt NO_GLOB_SUBST
cannam@167 125 else
cannam@167 126 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
cannam@167 127 fi
cannam@167 128
cannam@167 129 # NLS nuisances: We save the old values in case they are required later.
cannam@167 130 _G_user_locale=
cannam@167 131 _G_safe_locale=
cannam@167 132 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
cannam@167 133 do
cannam@167 134 eval "if test set = \"\${$_G_var+set}\"; then
cannam@167 135 save_$_G_var=\$$_G_var
cannam@167 136 $_G_var=C
cannam@167 137 export $_G_var
cannam@167 138 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
cannam@167 139 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
cannam@167 140 fi"
cannam@167 141 done
cannam@167 142
cannam@167 143 # CDPATH.
cannam@167 144 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
cannam@167 145
cannam@167 146 # Make sure IFS has a sensible default
cannam@167 147 sp=' '
cannam@167 148 nl='
cannam@167 149 '
cannam@167 150 IFS="$sp $nl"
cannam@167 151
cannam@167 152 # There are apparently some retarded systems that use ';' as a PATH separator!
cannam@167 153 if test "${PATH_SEPARATOR+set}" != set; then
cannam@167 154 PATH_SEPARATOR=:
cannam@167 155 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
cannam@167 156 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
cannam@167 157 PATH_SEPARATOR=';'
cannam@167 158 }
cannam@167 159 fi
cannam@167 160
cannam@167 161
cannam@167 162
cannam@167 163 ## ------------------------- ##
cannam@167 164 ## Locate command utilities. ##
cannam@167 165 ## ------------------------- ##
cannam@167 166
cannam@167 167
cannam@167 168 # func_executable_p FILE
cannam@167 169 # ----------------------
cannam@167 170 # Check that FILE is an executable regular file.
cannam@167 171 func_executable_p ()
cannam@167 172 {
cannam@167 173 test -f "$1" && test -x "$1"
cannam@167 174 }
cannam@167 175
cannam@167 176
cannam@167 177 # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
cannam@167 178 # --------------------------------------------
cannam@167 179 # Search for either a program that responds to --version with output
cannam@167 180 # containing "GNU", or else returned by CHECK_FUNC otherwise, by
cannam@167 181 # trying all the directories in PATH with each of the elements of
cannam@167 182 # PROGS_LIST.
cannam@167 183 #
cannam@167 184 # CHECK_FUNC should accept the path to a candidate program, and
cannam@167 185 # set $func_check_prog_result if it truncates its output less than
cannam@167 186 # $_G_path_prog_max characters.
cannam@167 187 func_path_progs ()
cannam@167 188 {
cannam@167 189 _G_progs_list=$1
cannam@167 190 _G_check_func=$2
cannam@167 191 _G_PATH=${3-"$PATH"}
cannam@167 192
cannam@167 193 _G_path_prog_max=0
cannam@167 194 _G_path_prog_found=false
cannam@167 195 _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
cannam@167 196 for _G_dir in $_G_PATH; do
cannam@167 197 IFS=$_G_save_IFS
cannam@167 198 test -z "$_G_dir" && _G_dir=.
cannam@167 199 for _G_prog_name in $_G_progs_list; do
cannam@167 200 for _exeext in '' .EXE; do
cannam@167 201 _G_path_prog=$_G_dir/$_G_prog_name$_exeext
cannam@167 202 func_executable_p "$_G_path_prog" || continue
cannam@167 203 case `"$_G_path_prog" --version 2>&1` in
cannam@167 204 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
cannam@167 205 *) $_G_check_func $_G_path_prog
cannam@167 206 func_path_progs_result=$func_check_prog_result
cannam@167 207 ;;
cannam@167 208 esac
cannam@167 209 $_G_path_prog_found && break 3
cannam@167 210 done
cannam@167 211 done
cannam@167 212 done
cannam@167 213 IFS=$_G_save_IFS
cannam@167 214 test -z "$func_path_progs_result" && {
cannam@167 215 echo "no acceptable sed could be found in \$PATH" >&2
cannam@167 216 exit 1
cannam@167 217 }
cannam@167 218 }
cannam@167 219
cannam@167 220
cannam@167 221 # We want to be able to use the functions in this file before configure
cannam@167 222 # has figured out where the best binaries are kept, which means we have
cannam@167 223 # to search for them ourselves - except when the results are already set
cannam@167 224 # where we skip the searches.
cannam@167 225
cannam@167 226 # Unless the user overrides by setting SED, search the path for either GNU
cannam@167 227 # sed, or the sed that truncates its output the least.
cannam@167 228 test -z "$SED" && {
cannam@167 229 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
cannam@167 230 for _G_i in 1 2 3 4 5 6 7; do
cannam@167 231 _G_sed_script=$_G_sed_script$nl$_G_sed_script
cannam@167 232 done
cannam@167 233 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
cannam@167 234 _G_sed_script=
cannam@167 235
cannam@167 236 func_check_prog_sed ()
cannam@167 237 {
cannam@167 238 _G_path_prog=$1
cannam@167 239
cannam@167 240 _G_count=0
cannam@167 241 printf 0123456789 >conftest.in
cannam@167 242 while :
cannam@167 243 do
cannam@167 244 cat conftest.in conftest.in >conftest.tmp
cannam@167 245 mv conftest.tmp conftest.in
cannam@167 246 cp conftest.in conftest.nl
cannam@167 247 echo '' >> conftest.nl
cannam@167 248 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
cannam@167 249 diff conftest.out conftest.nl >/dev/null 2>&1 || break
cannam@167 250 _G_count=`expr $_G_count + 1`
cannam@167 251 if test "$_G_count" -gt "$_G_path_prog_max"; then
cannam@167 252 # Best one so far, save it but keep looking for a better one
cannam@167 253 func_check_prog_result=$_G_path_prog
cannam@167 254 _G_path_prog_max=$_G_count
cannam@167 255 fi
cannam@167 256 # 10*(2^10) chars as input seems more than enough
cannam@167 257 test 10 -lt "$_G_count" && break
cannam@167 258 done
cannam@167 259 rm -f conftest.in conftest.tmp conftest.nl conftest.out
cannam@167 260 }
cannam@167 261
cannam@167 262 func_path_progs "sed gsed" func_check_prog_sed $PATH:/usr/xpg4/bin
cannam@167 263 rm -f conftest.sed
cannam@167 264 SED=$func_path_progs_result
cannam@167 265 }
cannam@167 266
cannam@167 267
cannam@167 268 # Unless the user overrides by setting GREP, search the path for either GNU
cannam@167 269 # grep, or the grep that truncates its output the least.
cannam@167 270 test -z "$GREP" && {
cannam@167 271 func_check_prog_grep ()
cannam@167 272 {
cannam@167 273 _G_path_prog=$1
cannam@167 274
cannam@167 275 _G_count=0
cannam@167 276 _G_path_prog_max=0
cannam@167 277 printf 0123456789 >conftest.in
cannam@167 278 while :
cannam@167 279 do
cannam@167 280 cat conftest.in conftest.in >conftest.tmp
cannam@167 281 mv conftest.tmp conftest.in
cannam@167 282 cp conftest.in conftest.nl
cannam@167 283 echo 'GREP' >> conftest.nl
cannam@167 284 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
cannam@167 285 diff conftest.out conftest.nl >/dev/null 2>&1 || break
cannam@167 286 _G_count=`expr $_G_count + 1`
cannam@167 287 if test "$_G_count" -gt "$_G_path_prog_max"; then
cannam@167 288 # Best one so far, save it but keep looking for a better one
cannam@167 289 func_check_prog_result=$_G_path_prog
cannam@167 290 _G_path_prog_max=$_G_count
cannam@167 291 fi
cannam@167 292 # 10*(2^10) chars as input seems more than enough
cannam@167 293 test 10 -lt "$_G_count" && break
cannam@167 294 done
cannam@167 295 rm -f conftest.in conftest.tmp conftest.nl conftest.out
cannam@167 296 }
cannam@167 297
cannam@167 298 func_path_progs "grep ggrep" func_check_prog_grep $PATH:/usr/xpg4/bin
cannam@167 299 GREP=$func_path_progs_result
cannam@167 300 }
cannam@167 301
cannam@167 302
cannam@167 303 ## ------------------------------- ##
cannam@167 304 ## User overridable command paths. ##
cannam@167 305 ## ------------------------------- ##
cannam@167 306
cannam@167 307 # All uppercase variable names are used for environment variables. These
cannam@167 308 # variables can be overridden by the user before calling a script that
cannam@167 309 # uses them if a suitable command of that name is not already available
cannam@167 310 # in the command search PATH.
cannam@167 311
cannam@167 312 : ${CP="cp -f"}
cannam@167 313 : ${ECHO="printf %s\n"}
cannam@167 314 : ${EGREP="$GREP -E"}
cannam@167 315 : ${FGREP="$GREP -F"}
cannam@167 316 : ${LN_S="ln -s"}
cannam@167 317 : ${MAKE="make"}
cannam@167 318 : ${MKDIR="mkdir"}
cannam@167 319 : ${MV="mv -f"}
cannam@167 320 : ${RM="rm -f"}
cannam@167 321 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
cannam@167 322
cannam@167 323
cannam@167 324 ## -------------------- ##
cannam@167 325 ## Useful sed snippets. ##
cannam@167 326 ## -------------------- ##
cannam@167 327
cannam@167 328 sed_dirname='s|/[^/]*$||'
cannam@167 329 sed_basename='s|^.*/||'
cannam@167 330
cannam@167 331 # Sed substitution that helps us do robust quoting. It backslashifies
cannam@167 332 # metacharacters that are still active within double-quoted strings.
cannam@167 333 sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
cannam@167 334
cannam@167 335 # Same as above, but do not quote variable references.
cannam@167 336 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
cannam@167 337
cannam@167 338 # Sed substitution that turns a string into a regex matching for the
cannam@167 339 # string literally.
cannam@167 340 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
cannam@167 341
cannam@167 342 # Sed substitution that converts a w32 file name or path
cannam@167 343 # that contains forward slashes, into one that contains
cannam@167 344 # (escaped) backslashes. A very naive implementation.
cannam@167 345 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
cannam@167 346
cannam@167 347 # Re-'\' parameter expansions in output of sed_double_quote_subst that
cannam@167 348 # were '\'-ed in input to the same. If an odd number of '\' preceded a
cannam@167 349 # '$' in input to sed_double_quote_subst, that '$' was protected from
cannam@167 350 # expansion. Since each input '\' is now two '\'s, look for any number
cannam@167 351 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
cannam@167 352 _G_bs='\\'
cannam@167 353 _G_bs2='\\\\'
cannam@167 354 _G_bs4='\\\\\\\\'
cannam@167 355 _G_dollar='\$'
cannam@167 356 sed_double_backslash="\
cannam@167 357 s/$_G_bs4/&\\
cannam@167 358 /g
cannam@167 359 s/^$_G_bs2$_G_dollar/$_G_bs&/
cannam@167 360 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
cannam@167 361 s/\n//g"
cannam@167 362
cannam@167 363
cannam@167 364 ## ----------------- ##
cannam@167 365 ## Global variables. ##
cannam@167 366 ## ----------------- ##
cannam@167 367
cannam@167 368 # Except for the global variables explicitly listed below, the following
cannam@167 369 # functions in the '^func_' namespace, and the '^require_' namespace
cannam@167 370 # variables initialised in the 'Resource management' section, sourcing
cannam@167 371 # this file will not pollute your global namespace with anything
cannam@167 372 # else. There's no portable way to scope variables in Bourne shell
cannam@167 373 # though, so actually running these functions will sometimes place
cannam@167 374 # results into a variable named after the function, and often use
cannam@167 375 # temporary variables in the '^_G_' namespace. If you are careful to
cannam@167 376 # avoid using those namespaces casually in your sourcing script, things
cannam@167 377 # should continue to work as you expect. And, of course, you can freely
cannam@167 378 # overwrite any of the functions or variables defined here before
cannam@167 379 # calling anything to customize them.
cannam@167 380
cannam@167 381 EXIT_SUCCESS=0
cannam@167 382 EXIT_FAILURE=1
cannam@167 383 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
cannam@167 384 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
cannam@167 385
cannam@167 386 # Allow overriding, eg assuming that you follow the convention of
cannam@167 387 # putting '$debug_cmd' at the start of all your functions, you can get
cannam@167 388 # bash to show function call trace with:
cannam@167 389 #
cannam@167 390 # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
cannam@167 391 debug_cmd=${debug_cmd-":"}
cannam@167 392 exit_cmd=:
cannam@167 393
cannam@167 394 # By convention, finish your script with:
cannam@167 395 #
cannam@167 396 # exit $exit_status
cannam@167 397 #
cannam@167 398 # so that you can set exit_status to non-zero if you want to indicate
cannam@167 399 # something went wrong during execution without actually bailing out at
cannam@167 400 # the point of failure.
cannam@167 401 exit_status=$EXIT_SUCCESS
cannam@167 402
cannam@167 403 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
cannam@167 404 # is ksh but when the shell is invoked as "sh" and the current value of
cannam@167 405 # the _XPG environment variable is not equal to 1 (one), the special
cannam@167 406 # positional parameter $0, within a function call, is the name of the
cannam@167 407 # function.
cannam@167 408 progpath=$0
cannam@167 409
cannam@167 410 # The name of this program.
cannam@167 411 progname=`$ECHO "$progpath" |$SED "$sed_basename"`
cannam@167 412
cannam@167 413 # Make sure we have an absolute progpath for reexecution:
cannam@167 414 case $progpath in
cannam@167 415 [\\/]*|[A-Za-z]:\\*) ;;
cannam@167 416 *[\\/]*)
cannam@167 417 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
cannam@167 418 progdir=`cd "$progdir" && pwd`
cannam@167 419 progpath=$progdir/$progname
cannam@167 420 ;;
cannam@167 421 *)
cannam@167 422 _G_IFS=$IFS
cannam@167 423 IFS=${PATH_SEPARATOR-:}
cannam@167 424 for progdir in $PATH; do
cannam@167 425 IFS=$_G_IFS
cannam@167 426 test -x "$progdir/$progname" && break
cannam@167 427 done
cannam@167 428 IFS=$_G_IFS
cannam@167 429 test -n "$progdir" || progdir=`pwd`
cannam@167 430 progpath=$progdir/$progname
cannam@167 431 ;;
cannam@167 432 esac
cannam@167 433
cannam@167 434
cannam@167 435 ## ----------------- ##
cannam@167 436 ## Standard options. ##
cannam@167 437 ## ----------------- ##
cannam@167 438
cannam@167 439 # The following options affect the operation of the functions defined
cannam@167 440 # below, and should be set appropriately depending on run-time para-
cannam@167 441 # meters passed on the command line.
cannam@167 442
cannam@167 443 opt_dry_run=false
cannam@167 444 opt_quiet=false
cannam@167 445 opt_verbose=false
cannam@167 446
cannam@167 447 # Categories 'all' and 'none' are always available. Append any others
cannam@167 448 # you will pass as the first argument to func_warning from your own
cannam@167 449 # code.
cannam@167 450 warning_categories=
cannam@167 451
cannam@167 452 # By default, display warnings according to 'opt_warning_types'. Set
cannam@167 453 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
cannam@167 454 # treat the next displayed warning as a fatal error.
cannam@167 455 warning_func=func_warn_and_continue
cannam@167 456
cannam@167 457 # Set to 'all' to display all warnings, 'none' to suppress all
cannam@167 458 # warnings, or a space delimited list of some subset of
cannam@167 459 # 'warning_categories' to display only the listed warnings.
cannam@167 460 opt_warning_types=all
cannam@167 461
cannam@167 462
cannam@167 463 ## -------------------- ##
cannam@167 464 ## Resource management. ##
cannam@167 465 ## -------------------- ##
cannam@167 466
cannam@167 467 # This section contains definitions for functions that each ensure a
cannam@167 468 # particular resource (a file, or a non-empty configuration variable for
cannam@167 469 # example) is available, and if appropriate to extract default values
cannam@167 470 # from pertinent package files. Call them using their associated
cannam@167 471 # 'require_*' variable to ensure that they are executed, at most, once.
cannam@167 472 #
cannam@167 473 # It's entirely deliberate that calling these functions can set
cannam@167 474 # variables that don't obey the namespace limitations obeyed by the rest
cannam@167 475 # of this file, in order that that they be as useful as possible to
cannam@167 476 # callers.
cannam@167 477
cannam@167 478
cannam@167 479 # require_term_colors
cannam@167 480 # -------------------
cannam@167 481 # Allow display of bold text on terminals that support it.
cannam@167 482 require_term_colors=func_require_term_colors
cannam@167 483 func_require_term_colors ()
cannam@167 484 {
cannam@167 485 $debug_cmd
cannam@167 486
cannam@167 487 test -t 1 && {
cannam@167 488 # COLORTERM and USE_ANSI_COLORS environment variables take
cannam@167 489 # precedence, because most terminfo databases neglect to describe
cannam@167 490 # whether color sequences are supported.
cannam@167 491 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
cannam@167 492
cannam@167 493 if test 1 = "$USE_ANSI_COLORS"; then
cannam@167 494 # Standard ANSI escape sequences
cannam@167 495 tc_reset=''
cannam@167 496 tc_bold=''; tc_standout=''
cannam@167 497 tc_red=''; tc_green=''
cannam@167 498 tc_blue=''; tc_cyan=''
cannam@167 499 else
cannam@167 500 # Otherwise trust the terminfo database after all.
cannam@167 501 test -n "`tput sgr0 2>/dev/null`" && {
cannam@167 502 tc_reset=`tput sgr0`
cannam@167 503 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
cannam@167 504 tc_standout=$tc_bold
cannam@167 505 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
cannam@167 506 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
cannam@167 507 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
cannam@167 508 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
cannam@167 509 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
cannam@167 510 }
cannam@167 511 fi
cannam@167 512 }
cannam@167 513
cannam@167 514 require_term_colors=:
cannam@167 515 }
cannam@167 516
cannam@167 517
cannam@167 518 ## ----------------- ##
cannam@167 519 ## Function library. ##
cannam@167 520 ## ----------------- ##
cannam@167 521
cannam@167 522 # This section contains a variety of useful functions to call in your
cannam@167 523 # scripts. Take note of the portable wrappers for features provided by
cannam@167 524 # some modern shells, which will fall back to slower equivalents on
cannam@167 525 # less featureful shells.
cannam@167 526
cannam@167 527
cannam@167 528 # func_append VAR VALUE
cannam@167 529 # ---------------------
cannam@167 530 # Append VALUE onto the existing contents of VAR.
cannam@167 531
cannam@167 532 # We should try to minimise forks, especially on Windows where they are
cannam@167 533 # unreasonably slow, so skip the feature probes when bash or zsh are
cannam@167 534 # being used:
cannam@167 535 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
cannam@167 536 : ${_G_HAVE_ARITH_OP="yes"}
cannam@167 537 : ${_G_HAVE_XSI_OPS="yes"}
cannam@167 538 # The += operator was introduced in bash 3.1
cannam@167 539 case $BASH_VERSION in
cannam@167 540 [12].* | 3.0 | 3.0*) ;;
cannam@167 541 *)
cannam@167 542 : ${_G_HAVE_PLUSEQ_OP="yes"}
cannam@167 543 ;;
cannam@167 544 esac
cannam@167 545 fi
cannam@167 546
cannam@167 547 # _G_HAVE_PLUSEQ_OP
cannam@167 548 # Can be empty, in which case the shell is probed, "yes" if += is
cannam@167 549 # useable or anything else if it does not work.
cannam@167 550 test -z "$_G_HAVE_PLUSEQ_OP" \
cannam@167 551 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
cannam@167 552 && _G_HAVE_PLUSEQ_OP=yes
cannam@167 553
cannam@167 554 if test yes = "$_G_HAVE_PLUSEQ_OP"
cannam@167 555 then
cannam@167 556 # This is an XSI compatible shell, allowing a faster implementation...
cannam@167 557 eval 'func_append ()
cannam@167 558 {
cannam@167 559 $debug_cmd
cannam@167 560
cannam@167 561 eval "$1+=\$2"
cannam@167 562 }'
cannam@167 563 else
cannam@167 564 # ...otherwise fall back to using expr, which is often a shell builtin.
cannam@167 565 func_append ()
cannam@167 566 {
cannam@167 567 $debug_cmd
cannam@167 568
cannam@167 569 eval "$1=\$$1\$2"
cannam@167 570 }
cannam@167 571 fi
cannam@167 572
cannam@167 573
cannam@167 574 # func_append_quoted VAR VALUE
cannam@167 575 # ----------------------------
cannam@167 576 # Quote VALUE and append to the end of shell variable VAR, separated
cannam@167 577 # by a space.
cannam@167 578 if test yes = "$_G_HAVE_PLUSEQ_OP"; then
cannam@167 579 eval 'func_append_quoted ()
cannam@167 580 {
cannam@167 581 $debug_cmd
cannam@167 582
cannam@167 583 func_quote_for_eval "$2"
cannam@167 584 eval "$1+=\\ \$func_quote_for_eval_result"
cannam@167 585 }'
cannam@167 586 else
cannam@167 587 func_append_quoted ()
cannam@167 588 {
cannam@167 589 $debug_cmd
cannam@167 590
cannam@167 591 func_quote_for_eval "$2"
cannam@167 592 eval "$1=\$$1\\ \$func_quote_for_eval_result"
cannam@167 593 }
cannam@167 594 fi
cannam@167 595
cannam@167 596
cannam@167 597 # func_append_uniq VAR VALUE
cannam@167 598 # --------------------------
cannam@167 599 # Append unique VALUE onto the existing contents of VAR, assuming
cannam@167 600 # entries are delimited by the first character of VALUE. For example:
cannam@167 601 #
cannam@167 602 # func_append_uniq options " --another-option option-argument"
cannam@167 603 #
cannam@167 604 # will only append to $options if " --another-option option-argument "
cannam@167 605 # is not already present somewhere in $options already (note spaces at
cannam@167 606 # each end implied by leading space in second argument).
cannam@167 607 func_append_uniq ()
cannam@167 608 {
cannam@167 609 $debug_cmd
cannam@167 610
cannam@167 611 eval _G_current_value='`$ECHO $'$1'`'
cannam@167 612 _G_delim=`expr "$2" : '\(.\)'`
cannam@167 613
cannam@167 614 case $_G_delim$_G_current_value$_G_delim in
cannam@167 615 *"$2$_G_delim"*) ;;
cannam@167 616 *) func_append "$@" ;;
cannam@167 617 esac
cannam@167 618 }
cannam@167 619
cannam@167 620
cannam@167 621 # func_arith TERM...
cannam@167 622 # ------------------
cannam@167 623 # Set func_arith_result to the result of evaluating TERMs.
cannam@167 624 test -z "$_G_HAVE_ARITH_OP" \
cannam@167 625 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
cannam@167 626 && _G_HAVE_ARITH_OP=yes
cannam@167 627
cannam@167 628 if test yes = "$_G_HAVE_ARITH_OP"; then
cannam@167 629 eval 'func_arith ()
cannam@167 630 {
cannam@167 631 $debug_cmd
cannam@167 632
cannam@167 633 func_arith_result=$(( $* ))
cannam@167 634 }'
cannam@167 635 else
cannam@167 636 func_arith ()
cannam@167 637 {
cannam@167 638 $debug_cmd
cannam@167 639
cannam@167 640 func_arith_result=`expr "$@"`
cannam@167 641 }
cannam@167 642 fi
cannam@167 643
cannam@167 644
cannam@167 645 # func_basename FILE
cannam@167 646 # ------------------
cannam@167 647 # Set func_basename_result to FILE with everything up to and including
cannam@167 648 # the last / stripped.
cannam@167 649 if test yes = "$_G_HAVE_XSI_OPS"; then
cannam@167 650 # If this shell supports suffix pattern removal, then use it to avoid
cannam@167 651 # forking. Hide the definitions single quotes in case the shell chokes
cannam@167 652 # on unsupported syntax...
cannam@167 653 _b='func_basename_result=${1##*/}'
cannam@167 654 _d='case $1 in
cannam@167 655 */*) func_dirname_result=${1%/*}$2 ;;
cannam@167 656 * ) func_dirname_result=$3 ;;
cannam@167 657 esac'
cannam@167 658
cannam@167 659 else
cannam@167 660 # ...otherwise fall back to using sed.
cannam@167 661 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
cannam@167 662 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
cannam@167 663 if test "X$func_dirname_result" = "X$1"; then
cannam@167 664 func_dirname_result=$3
cannam@167 665 else
cannam@167 666 func_append func_dirname_result "$2"
cannam@167 667 fi'
cannam@167 668 fi
cannam@167 669
cannam@167 670 eval 'func_basename ()
cannam@167 671 {
cannam@167 672 $debug_cmd
cannam@167 673
cannam@167 674 '"$_b"'
cannam@167 675 }'
cannam@167 676
cannam@167 677
cannam@167 678 # func_dirname FILE APPEND NONDIR_REPLACEMENT
cannam@167 679 # -------------------------------------------
cannam@167 680 # Compute the dirname of FILE. If nonempty, add APPEND to the result,
cannam@167 681 # otherwise set result to NONDIR_REPLACEMENT.
cannam@167 682 eval 'func_dirname ()
cannam@167 683 {
cannam@167 684 $debug_cmd
cannam@167 685
cannam@167 686 '"$_d"'
cannam@167 687 }'
cannam@167 688
cannam@167 689
cannam@167 690 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
cannam@167 691 # --------------------------------------------------------
cannam@167 692 # Perform func_basename and func_dirname in a single function
cannam@167 693 # call:
cannam@167 694 # dirname: Compute the dirname of FILE. If nonempty,
cannam@167 695 # add APPEND to the result, otherwise set result
cannam@167 696 # to NONDIR_REPLACEMENT.
cannam@167 697 # value returned in "$func_dirname_result"
cannam@167 698 # basename: Compute filename of FILE.
cannam@167 699 # value retuned in "$func_basename_result"
cannam@167 700 # For efficiency, we do not delegate to the functions above but instead
cannam@167 701 # duplicate the functionality here.
cannam@167 702 eval 'func_dirname_and_basename ()
cannam@167 703 {
cannam@167 704 $debug_cmd
cannam@167 705
cannam@167 706 '"$_b"'
cannam@167 707 '"$_d"'
cannam@167 708 }'
cannam@167 709
cannam@167 710
cannam@167 711 # func_echo ARG...
cannam@167 712 # ----------------
cannam@167 713 # Echo program name prefixed message.
cannam@167 714 func_echo ()
cannam@167 715 {
cannam@167 716 $debug_cmd
cannam@167 717
cannam@167 718 _G_message=$*
cannam@167 719
cannam@167 720 func_echo_IFS=$IFS
cannam@167 721 IFS=$nl
cannam@167 722 for _G_line in $_G_message; do
cannam@167 723 IFS=$func_echo_IFS
cannam@167 724 $ECHO "$progname: $_G_line"
cannam@167 725 done
cannam@167 726 IFS=$func_echo_IFS
cannam@167 727 }
cannam@167 728
cannam@167 729
cannam@167 730 # func_echo_all ARG...
cannam@167 731 # --------------------
cannam@167 732 # Invoke $ECHO with all args, space-separated.
cannam@167 733 func_echo_all ()
cannam@167 734 {
cannam@167 735 $ECHO "$*"
cannam@167 736 }
cannam@167 737
cannam@167 738
cannam@167 739 # func_echo_infix_1 INFIX ARG...
cannam@167 740 # ------------------------------
cannam@167 741 # Echo program name, followed by INFIX on the first line, with any
cannam@167 742 # additional lines not showing INFIX.
cannam@167 743 func_echo_infix_1 ()
cannam@167 744 {
cannam@167 745 $debug_cmd
cannam@167 746
cannam@167 747 $require_term_colors
cannam@167 748
cannam@167 749 _G_infix=$1; shift
cannam@167 750 _G_indent=$_G_infix
cannam@167 751 _G_prefix="$progname: $_G_infix: "
cannam@167 752 _G_message=$*
cannam@167 753
cannam@167 754 # Strip color escape sequences before counting printable length
cannam@167 755 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
cannam@167 756 do
cannam@167 757 test -n "$_G_tc" && {
cannam@167 758 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
cannam@167 759 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
cannam@167 760 }
cannam@167 761 done
cannam@167 762 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
cannam@167 763
cannam@167 764 func_echo_infix_1_IFS=$IFS
cannam@167 765 IFS=$nl
cannam@167 766 for _G_line in $_G_message; do
cannam@167 767 IFS=$func_echo_infix_1_IFS
cannam@167 768 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
cannam@167 769 _G_prefix=$_G_indent
cannam@167 770 done
cannam@167 771 IFS=$func_echo_infix_1_IFS
cannam@167 772 }
cannam@167 773
cannam@167 774
cannam@167 775 # func_error ARG...
cannam@167 776 # -----------------
cannam@167 777 # Echo program name prefixed message to standard error.
cannam@167 778 func_error ()
cannam@167 779 {
cannam@167 780 $debug_cmd
cannam@167 781
cannam@167 782 $require_term_colors
cannam@167 783
cannam@167 784 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
cannam@167 785 }
cannam@167 786
cannam@167 787
cannam@167 788 # func_fatal_error ARG...
cannam@167 789 # -----------------------
cannam@167 790 # Echo program name prefixed message to standard error, and exit.
cannam@167 791 func_fatal_error ()
cannam@167 792 {
cannam@167 793 $debug_cmd
cannam@167 794
cannam@167 795 func_error "$*"
cannam@167 796 exit $EXIT_FAILURE
cannam@167 797 }
cannam@167 798
cannam@167 799
cannam@167 800 # func_grep EXPRESSION FILENAME
cannam@167 801 # -----------------------------
cannam@167 802 # Check whether EXPRESSION matches any line of FILENAME, without output.
cannam@167 803 func_grep ()
cannam@167 804 {
cannam@167 805 $debug_cmd
cannam@167 806
cannam@167 807 $GREP "$1" "$2" >/dev/null 2>&1
cannam@167 808 }
cannam@167 809
cannam@167 810
cannam@167 811 # func_len STRING
cannam@167 812 # ---------------
cannam@167 813 # Set func_len_result to the length of STRING. STRING may not
cannam@167 814 # start with a hyphen.
cannam@167 815 test -z "$_G_HAVE_XSI_OPS" \
cannam@167 816 && (eval 'x=a/b/c;
cannam@167 817 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
cannam@167 818 && _G_HAVE_XSI_OPS=yes
cannam@167 819
cannam@167 820 if test yes = "$_G_HAVE_XSI_OPS"; then
cannam@167 821 eval 'func_len ()
cannam@167 822 {
cannam@167 823 $debug_cmd
cannam@167 824
cannam@167 825 func_len_result=${#1}
cannam@167 826 }'
cannam@167 827 else
cannam@167 828 func_len ()
cannam@167 829 {
cannam@167 830 $debug_cmd
cannam@167 831
cannam@167 832 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
cannam@167 833 }
cannam@167 834 fi
cannam@167 835
cannam@167 836
cannam@167 837 # func_mkdir_p DIRECTORY-PATH
cannam@167 838 # ---------------------------
cannam@167 839 # Make sure the entire path to DIRECTORY-PATH is available.
cannam@167 840 func_mkdir_p ()
cannam@167 841 {
cannam@167 842 $debug_cmd
cannam@167 843
cannam@167 844 _G_directory_path=$1
cannam@167 845 _G_dir_list=
cannam@167 846
cannam@167 847 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
cannam@167 848
cannam@167 849 # Protect directory names starting with '-'
cannam@167 850 case $_G_directory_path in
cannam@167 851 -*) _G_directory_path=./$_G_directory_path ;;
cannam@167 852 esac
cannam@167 853
cannam@167 854 # While some portion of DIR does not yet exist...
cannam@167 855 while test ! -d "$_G_directory_path"; do
cannam@167 856 # ...make a list in topmost first order. Use a colon delimited
cannam@167 857 # list incase some portion of path contains whitespace.
cannam@167 858 _G_dir_list=$_G_directory_path:$_G_dir_list
cannam@167 859
cannam@167 860 # If the last portion added has no slash in it, the list is done
cannam@167 861 case $_G_directory_path in */*) ;; *) break ;; esac
cannam@167 862
cannam@167 863 # ...otherwise throw away the child directory and loop
cannam@167 864 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
cannam@167 865 done
cannam@167 866 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
cannam@167 867
cannam@167 868 func_mkdir_p_IFS=$IFS; IFS=:
cannam@167 869 for _G_dir in $_G_dir_list; do
cannam@167 870 IFS=$func_mkdir_p_IFS
cannam@167 871 # mkdir can fail with a 'File exist' error if two processes
cannam@167 872 # try to create one of the directories concurrently. Don't
cannam@167 873 # stop in that case!
cannam@167 874 $MKDIR "$_G_dir" 2>/dev/null || :
cannam@167 875 done
cannam@167 876 IFS=$func_mkdir_p_IFS
cannam@167 877
cannam@167 878 # Bail out if we (or some other process) failed to create a directory.
cannam@167 879 test -d "$_G_directory_path" || \
cannam@167 880 func_fatal_error "Failed to create '$1'"
cannam@167 881 fi
cannam@167 882 }
cannam@167 883
cannam@167 884
cannam@167 885 # func_mktempdir [BASENAME]
cannam@167 886 # -------------------------
cannam@167 887 # Make a temporary directory that won't clash with other running
cannam@167 888 # libtool processes, and avoids race conditions if possible. If
cannam@167 889 # given, BASENAME is the basename for that directory.
cannam@167 890 func_mktempdir ()
cannam@167 891 {
cannam@167 892 $debug_cmd
cannam@167 893
cannam@167 894 _G_template=${TMPDIR-/tmp}/${1-$progname}
cannam@167 895
cannam@167 896 if test : = "$opt_dry_run"; then
cannam@167 897 # Return a directory name, but don't create it in dry-run mode
cannam@167 898 _G_tmpdir=$_G_template-$$
cannam@167 899 else
cannam@167 900
cannam@167 901 # If mktemp works, use that first and foremost
cannam@167 902 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
cannam@167 903
cannam@167 904 if test ! -d "$_G_tmpdir"; then
cannam@167 905 # Failing that, at least try and use $RANDOM to avoid a race
cannam@167 906 _G_tmpdir=$_G_template-${RANDOM-0}$$
cannam@167 907
cannam@167 908 func_mktempdir_umask=`umask`
cannam@167 909 umask 0077
cannam@167 910 $MKDIR "$_G_tmpdir"
cannam@167 911 umask $func_mktempdir_umask
cannam@167 912 fi
cannam@167 913
cannam@167 914 # If we're not in dry-run mode, bomb out on failure
cannam@167 915 test -d "$_G_tmpdir" || \
cannam@167 916 func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
cannam@167 917 fi
cannam@167 918
cannam@167 919 $ECHO "$_G_tmpdir"
cannam@167 920 }
cannam@167 921
cannam@167 922
cannam@167 923 # func_normal_abspath PATH
cannam@167 924 # ------------------------
cannam@167 925 # Remove doubled-up and trailing slashes, "." path components,
cannam@167 926 # and cancel out any ".." path components in PATH after making
cannam@167 927 # it an absolute path.
cannam@167 928 func_normal_abspath ()
cannam@167 929 {
cannam@167 930 $debug_cmd
cannam@167 931
cannam@167 932 # These SED scripts presuppose an absolute path with a trailing slash.
cannam@167 933 _G_pathcar='s|^/\([^/]*\).*$|\1|'
cannam@167 934 _G_pathcdr='s|^/[^/]*||'
cannam@167 935 _G_removedotparts=':dotsl
cannam@167 936 s|/\./|/|g
cannam@167 937 t dotsl
cannam@167 938 s|/\.$|/|'
cannam@167 939 _G_collapseslashes='s|/\{1,\}|/|g'
cannam@167 940 _G_finalslash='s|/*$|/|'
cannam@167 941
cannam@167 942 # Start from root dir and reassemble the path.
cannam@167 943 func_normal_abspath_result=
cannam@167 944 func_normal_abspath_tpath=$1
cannam@167 945 func_normal_abspath_altnamespace=
cannam@167 946 case $func_normal_abspath_tpath in
cannam@167 947 "")
cannam@167 948 # Empty path, that just means $cwd.
cannam@167 949 func_stripname '' '/' "`pwd`"
cannam@167 950 func_normal_abspath_result=$func_stripname_result
cannam@167 951 return
cannam@167 952 ;;
cannam@167 953 # The next three entries are used to spot a run of precisely
cannam@167 954 # two leading slashes without using negated character classes;
cannam@167 955 # we take advantage of case's first-match behaviour.
cannam@167 956 ///*)
cannam@167 957 # Unusual form of absolute path, do nothing.
cannam@167 958 ;;
cannam@167 959 //*)
cannam@167 960 # Not necessarily an ordinary path; POSIX reserves leading '//'
cannam@167 961 # and for example Cygwin uses it to access remote file shares
cannam@167 962 # over CIFS/SMB, so we conserve a leading double slash if found.
cannam@167 963 func_normal_abspath_altnamespace=/
cannam@167 964 ;;
cannam@167 965 /*)
cannam@167 966 # Absolute path, do nothing.
cannam@167 967 ;;
cannam@167 968 *)
cannam@167 969 # Relative path, prepend $cwd.
cannam@167 970 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
cannam@167 971 ;;
cannam@167 972 esac
cannam@167 973
cannam@167 974 # Cancel out all the simple stuff to save iterations. We also want
cannam@167 975 # the path to end with a slash for ease of parsing, so make sure
cannam@167 976 # there is one (and only one) here.
cannam@167 977 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
cannam@167 978 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
cannam@167 979 while :; do
cannam@167 980 # Processed it all yet?
cannam@167 981 if test / = "$func_normal_abspath_tpath"; then
cannam@167 982 # If we ascended to the root using ".." the result may be empty now.
cannam@167 983 if test -z "$func_normal_abspath_result"; then
cannam@167 984 func_normal_abspath_result=/
cannam@167 985 fi
cannam@167 986 break
cannam@167 987 fi
cannam@167 988 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
cannam@167 989 -e "$_G_pathcar"`
cannam@167 990 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
cannam@167 991 -e "$_G_pathcdr"`
cannam@167 992 # Figure out what to do with it
cannam@167 993 case $func_normal_abspath_tcomponent in
cannam@167 994 "")
cannam@167 995 # Trailing empty path component, ignore it.
cannam@167 996 ;;
cannam@167 997 ..)
cannam@167 998 # Parent dir; strip last assembled component from result.
cannam@167 999 func_dirname "$func_normal_abspath_result"
cannam@167 1000 func_normal_abspath_result=$func_dirname_result
cannam@167 1001 ;;
cannam@167 1002 *)
cannam@167 1003 # Actual path component, append it.
cannam@167 1004 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
cannam@167 1005 ;;
cannam@167 1006 esac
cannam@167 1007 done
cannam@167 1008 # Restore leading double-slash if one was found on entry.
cannam@167 1009 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
cannam@167 1010 }
cannam@167 1011
cannam@167 1012
cannam@167 1013 # func_notquiet ARG...
cannam@167 1014 # --------------------
cannam@167 1015 # Echo program name prefixed message only when not in quiet mode.
cannam@167 1016 func_notquiet ()
cannam@167 1017 {
cannam@167 1018 $debug_cmd
cannam@167 1019
cannam@167 1020 $opt_quiet || func_echo ${1+"$@"}
cannam@167 1021
cannam@167 1022 # A bug in bash halts the script if the last line of a function
cannam@167 1023 # fails when set -e is in force, so we need another command to
cannam@167 1024 # work around that:
cannam@167 1025 :
cannam@167 1026 }
cannam@167 1027
cannam@167 1028
cannam@167 1029 # func_relative_path SRCDIR DSTDIR
cannam@167 1030 # --------------------------------
cannam@167 1031 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
cannam@167 1032 func_relative_path ()
cannam@167 1033 {
cannam@167 1034 $debug_cmd
cannam@167 1035
cannam@167 1036 func_relative_path_result=
cannam@167 1037 func_normal_abspath "$1"
cannam@167 1038 func_relative_path_tlibdir=$func_normal_abspath_result
cannam@167 1039 func_normal_abspath "$2"
cannam@167 1040 func_relative_path_tbindir=$func_normal_abspath_result
cannam@167 1041
cannam@167 1042 # Ascend the tree starting from libdir
cannam@167 1043 while :; do
cannam@167 1044 # check if we have found a prefix of bindir
cannam@167 1045 case $func_relative_path_tbindir in
cannam@167 1046 $func_relative_path_tlibdir)
cannam@167 1047 # found an exact match
cannam@167 1048 func_relative_path_tcancelled=
cannam@167 1049 break
cannam@167 1050 ;;
cannam@167 1051 $func_relative_path_tlibdir*)
cannam@167 1052 # found a matching prefix
cannam@167 1053 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
cannam@167 1054 func_relative_path_tcancelled=$func_stripname_result
cannam@167 1055 if test -z "$func_relative_path_result"; then
cannam@167 1056 func_relative_path_result=.
cannam@167 1057 fi
cannam@167 1058 break
cannam@167 1059 ;;
cannam@167 1060 *)
cannam@167 1061 func_dirname $func_relative_path_tlibdir
cannam@167 1062 func_relative_path_tlibdir=$func_dirname_result
cannam@167 1063 if test -z "$func_relative_path_tlibdir"; then
cannam@167 1064 # Have to descend all the way to the root!
cannam@167 1065 func_relative_path_result=../$func_relative_path_result
cannam@167 1066 func_relative_path_tcancelled=$func_relative_path_tbindir
cannam@167 1067 break
cannam@167 1068 fi
cannam@167 1069 func_relative_path_result=../$func_relative_path_result
cannam@167 1070 ;;
cannam@167 1071 esac
cannam@167 1072 done
cannam@167 1073
cannam@167 1074 # Now calculate path; take care to avoid doubling-up slashes.
cannam@167 1075 func_stripname '' '/' "$func_relative_path_result"
cannam@167 1076 func_relative_path_result=$func_stripname_result
cannam@167 1077 func_stripname '/' '/' "$func_relative_path_tcancelled"
cannam@167 1078 if test -n "$func_stripname_result"; then
cannam@167 1079 func_append func_relative_path_result "/$func_stripname_result"
cannam@167 1080 fi
cannam@167 1081
cannam@167 1082 # Normalisation. If bindir is libdir, return '.' else relative path.
cannam@167 1083 if test -n "$func_relative_path_result"; then
cannam@167 1084 func_stripname './' '' "$func_relative_path_result"
cannam@167 1085 func_relative_path_result=$func_stripname_result
cannam@167 1086 fi
cannam@167 1087
cannam@167 1088 test -n "$func_relative_path_result" || func_relative_path_result=.
cannam@167 1089
cannam@167 1090 :
cannam@167 1091 }
cannam@167 1092
cannam@167 1093
cannam@167 1094 # func_quote_for_eval ARG...
cannam@167 1095 # --------------------------
cannam@167 1096 # Aesthetically quote ARGs to be evaled later.
cannam@167 1097 # This function returns two values:
cannam@167 1098 # i) func_quote_for_eval_result
cannam@167 1099 # double-quoted, suitable for a subsequent eval
cannam@167 1100 # ii) func_quote_for_eval_unquoted_result
cannam@167 1101 # has all characters that are still active within double
cannam@167 1102 # quotes backslashified.
cannam@167 1103 func_quote_for_eval ()
cannam@167 1104 {
cannam@167 1105 $debug_cmd
cannam@167 1106
cannam@167 1107 func_quote_for_eval_unquoted_result=
cannam@167 1108 func_quote_for_eval_result=
cannam@167 1109 while test 0 -lt $#; do
cannam@167 1110 case $1 in
cannam@167 1111 *[\\\`\"\$]*)
cannam@167 1112 _G_unquoted_arg=`printf '%s\n' "$1" |$SED "$sed_quote_subst"` ;;
cannam@167 1113 *)
cannam@167 1114 _G_unquoted_arg=$1 ;;
cannam@167 1115 esac
cannam@167 1116 if test -n "$func_quote_for_eval_unquoted_result"; then
cannam@167 1117 func_append func_quote_for_eval_unquoted_result " $_G_unquoted_arg"
cannam@167 1118 else
cannam@167 1119 func_append func_quote_for_eval_unquoted_result "$_G_unquoted_arg"
cannam@167 1120 fi
cannam@167 1121
cannam@167 1122 case $_G_unquoted_arg in
cannam@167 1123 # Double-quote args containing shell metacharacters to delay
cannam@167 1124 # word splitting, command substitution and variable expansion
cannam@167 1125 # for a subsequent eval.
cannam@167 1126 # Many Bourne shells cannot handle close brackets correctly
cannam@167 1127 # in scan sets, so we specify it separately.
cannam@167 1128 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
cannam@167 1129 _G_quoted_arg=\"$_G_unquoted_arg\"
cannam@167 1130 ;;
cannam@167 1131 *)
cannam@167 1132 _G_quoted_arg=$_G_unquoted_arg
cannam@167 1133 ;;
cannam@167 1134 esac
cannam@167 1135
cannam@167 1136 if test -n "$func_quote_for_eval_result"; then
cannam@167 1137 func_append func_quote_for_eval_result " $_G_quoted_arg"
cannam@167 1138 else
cannam@167 1139 func_append func_quote_for_eval_result "$_G_quoted_arg"
cannam@167 1140 fi
cannam@167 1141 shift
cannam@167 1142 done
cannam@167 1143 }
cannam@167 1144
cannam@167 1145
cannam@167 1146 # func_quote_for_expand ARG
cannam@167 1147 # -------------------------
cannam@167 1148 # Aesthetically quote ARG to be evaled later; same as above,
cannam@167 1149 # but do not quote variable references.
cannam@167 1150 func_quote_for_expand ()
cannam@167 1151 {
cannam@167 1152 $debug_cmd
cannam@167 1153
cannam@167 1154 case $1 in
cannam@167 1155 *[\\\`\"]*)
cannam@167 1156 _G_arg=`$ECHO "$1" | $SED \
cannam@167 1157 -e "$sed_double_quote_subst" -e "$sed_double_backslash"` ;;
cannam@167 1158 *)
cannam@167 1159 _G_arg=$1 ;;
cannam@167 1160 esac
cannam@167 1161
cannam@167 1162 case $_G_arg in
cannam@167 1163 # Double-quote args containing shell metacharacters to delay
cannam@167 1164 # word splitting and command substitution for a subsequent eval.
cannam@167 1165 # Many Bourne shells cannot handle close brackets correctly
cannam@167 1166 # in scan sets, so we specify it separately.
cannam@167 1167 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
cannam@167 1168 _G_arg=\"$_G_arg\"
cannam@167 1169 ;;
cannam@167 1170 esac
cannam@167 1171
cannam@167 1172 func_quote_for_expand_result=$_G_arg
cannam@167 1173 }
cannam@167 1174
cannam@167 1175
cannam@167 1176 # func_stripname PREFIX SUFFIX NAME
cannam@167 1177 # ---------------------------------
cannam@167 1178 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
cannam@167 1179 # PREFIX and SUFFIX must not contain globbing or regex special
cannam@167 1180 # characters, hashes, percent signs, but SUFFIX may contain a leading
cannam@167 1181 # dot (in which case that matches only a dot).
cannam@167 1182 if test yes = "$_G_HAVE_XSI_OPS"; then
cannam@167 1183 eval 'func_stripname ()
cannam@167 1184 {
cannam@167 1185 $debug_cmd
cannam@167 1186
cannam@167 1187 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
cannam@167 1188 # positional parameters, so assign one to ordinary variable first.
cannam@167 1189 func_stripname_result=$3
cannam@167 1190 func_stripname_result=${func_stripname_result#"$1"}
cannam@167 1191 func_stripname_result=${func_stripname_result%"$2"}
cannam@167 1192 }'
cannam@167 1193 else
cannam@167 1194 func_stripname ()
cannam@167 1195 {
cannam@167 1196 $debug_cmd
cannam@167 1197
cannam@167 1198 case $2 in
cannam@167 1199 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
cannam@167 1200 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
cannam@167 1201 esac
cannam@167 1202 }
cannam@167 1203 fi
cannam@167 1204
cannam@167 1205
cannam@167 1206 # func_show_eval CMD [FAIL_EXP]
cannam@167 1207 # -----------------------------
cannam@167 1208 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
cannam@167 1209 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
cannam@167 1210 # is given, then evaluate it.
cannam@167 1211 func_show_eval ()
cannam@167 1212 {
cannam@167 1213 $debug_cmd
cannam@167 1214
cannam@167 1215 _G_cmd=$1
cannam@167 1216 _G_fail_exp=${2-':'}
cannam@167 1217
cannam@167 1218 func_quote_for_expand "$_G_cmd"
cannam@167 1219 eval "func_notquiet $func_quote_for_expand_result"
cannam@167 1220
cannam@167 1221 $opt_dry_run || {
cannam@167 1222 eval "$_G_cmd"
cannam@167 1223 _G_status=$?
cannam@167 1224 if test 0 -ne "$_G_status"; then
cannam@167 1225 eval "(exit $_G_status); $_G_fail_exp"
cannam@167 1226 fi
cannam@167 1227 }
cannam@167 1228 }
cannam@167 1229
cannam@167 1230
cannam@167 1231 # func_show_eval_locale CMD [FAIL_EXP]
cannam@167 1232 # ------------------------------------
cannam@167 1233 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
cannam@167 1234 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
cannam@167 1235 # is given, then evaluate it. Use the saved locale for evaluation.
cannam@167 1236 func_show_eval_locale ()
cannam@167 1237 {
cannam@167 1238 $debug_cmd
cannam@167 1239
cannam@167 1240 _G_cmd=$1
cannam@167 1241 _G_fail_exp=${2-':'}
cannam@167 1242
cannam@167 1243 $opt_quiet || {
cannam@167 1244 func_quote_for_expand "$_G_cmd"
cannam@167 1245 eval "func_echo $func_quote_for_expand_result"
cannam@167 1246 }
cannam@167 1247
cannam@167 1248 $opt_dry_run || {
cannam@167 1249 eval "$_G_user_locale
cannam@167 1250 $_G_cmd"
cannam@167 1251 _G_status=$?
cannam@167 1252 eval "$_G_safe_locale"
cannam@167 1253 if test 0 -ne "$_G_status"; then
cannam@167 1254 eval "(exit $_G_status); $_G_fail_exp"
cannam@167 1255 fi
cannam@167 1256 }
cannam@167 1257 }
cannam@167 1258
cannam@167 1259
cannam@167 1260 # func_tr_sh
cannam@167 1261 # ----------
cannam@167 1262 # Turn $1 into a string suitable for a shell variable name.
cannam@167 1263 # Result is stored in $func_tr_sh_result. All characters
cannam@167 1264 # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
cannam@167 1265 # if $1 begins with a digit, a '_' is prepended as well.
cannam@167 1266 func_tr_sh ()
cannam@167 1267 {
cannam@167 1268 $debug_cmd
cannam@167 1269
cannam@167 1270 case $1 in
cannam@167 1271 [0-9]* | *[!a-zA-Z0-9_]*)
cannam@167 1272 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
cannam@167 1273 ;;
cannam@167 1274 * )
cannam@167 1275 func_tr_sh_result=$1
cannam@167 1276 ;;
cannam@167 1277 esac
cannam@167 1278 }
cannam@167 1279
cannam@167 1280
cannam@167 1281 # func_verbose ARG...
cannam@167 1282 # -------------------
cannam@167 1283 # Echo program name prefixed message in verbose mode only.
cannam@167 1284 func_verbose ()
cannam@167 1285 {
cannam@167 1286 $debug_cmd
cannam@167 1287
cannam@167 1288 $opt_verbose && func_echo "$*"
cannam@167 1289
cannam@167 1290 :
cannam@167 1291 }
cannam@167 1292
cannam@167 1293
cannam@167 1294 # func_warn_and_continue ARG...
cannam@167 1295 # -----------------------------
cannam@167 1296 # Echo program name prefixed warning message to standard error.
cannam@167 1297 func_warn_and_continue ()
cannam@167 1298 {
cannam@167 1299 $debug_cmd
cannam@167 1300
cannam@167 1301 $require_term_colors
cannam@167 1302
cannam@167 1303 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
cannam@167 1304 }
cannam@167 1305
cannam@167 1306
cannam@167 1307 # func_warning CATEGORY ARG...
cannam@167 1308 # ----------------------------
cannam@167 1309 # Echo program name prefixed warning message to standard error. Warning
cannam@167 1310 # messages can be filtered according to CATEGORY, where this function
cannam@167 1311 # elides messages where CATEGORY is not listed in the global variable
cannam@167 1312 # 'opt_warning_types'.
cannam@167 1313 func_warning ()
cannam@167 1314 {
cannam@167 1315 $debug_cmd
cannam@167 1316
cannam@167 1317 # CATEGORY must be in the warning_categories list!
cannam@167 1318 case " $warning_categories " in
cannam@167 1319 *" $1 "*) ;;
cannam@167 1320 *) func_internal_error "invalid warning category '$1'" ;;
cannam@167 1321 esac
cannam@167 1322
cannam@167 1323 _G_category=$1
cannam@167 1324 shift
cannam@167 1325
cannam@167 1326 case " $opt_warning_types " in
cannam@167 1327 *" $_G_category "*) $warning_func ${1+"$@"} ;;
cannam@167 1328 esac
cannam@167 1329 }
cannam@167 1330
cannam@167 1331
cannam@167 1332 # func_sort_ver VER1 VER2
cannam@167 1333 # -----------------------
cannam@167 1334 # 'sort -V' is not generally available.
cannam@167 1335 # Note this deviates from the version comparison in automake
cannam@167 1336 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
cannam@167 1337 # but this should suffice as we won't be specifying old
cannam@167 1338 # version formats or redundant trailing .0 in bootstrap.conf.
cannam@167 1339 # If we did want full compatibility then we should probably
cannam@167 1340 # use m4_version_compare from autoconf.
cannam@167 1341 func_sort_ver ()
cannam@167 1342 {
cannam@167 1343 $debug_cmd
cannam@167 1344
cannam@167 1345 printf '%s\n%s\n' "$1" "$2" \
cannam@167 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@167 1347 }
cannam@167 1348
cannam@167 1349 # func_lt_ver PREV CURR
cannam@167 1350 # ---------------------
cannam@167 1351 # Return true if PREV and CURR are in the correct order according to
cannam@167 1352 # func_sort_ver, otherwise false. Use it like this:
cannam@167 1353 #
cannam@167 1354 # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
cannam@167 1355 func_lt_ver ()
cannam@167 1356 {
cannam@167 1357 $debug_cmd
cannam@167 1358
cannam@167 1359 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
cannam@167 1360 }
cannam@167 1361
cannam@167 1362
cannam@167 1363 # Local variables:
cannam@167 1364 # mode: shell-script
cannam@167 1365 # sh-indentation: 2
cannam@167 1366 # eval: (add-hook 'before-save-hook 'time-stamp)
cannam@167 1367 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
cannam@167 1368 # time-stamp-time-zone: "UTC"
cannam@167 1369 # End:
cannam@167 1370 #! /bin/sh
cannam@167 1371
cannam@167 1372 # Set a version string for this script.
cannam@167 1373 scriptversion=2014-01-07.03; # UTC
cannam@167 1374
cannam@167 1375 # A portable, pluggable option parser for Bourne shell.
cannam@167 1376 # Written by Gary V. Vaughan, 2010
cannam@167 1377
cannam@167 1378 # Copyright (C) 2010-2015 Free Software Foundation, Inc.
cannam@167 1379 # This is free software; see the source for copying conditions. There is NO
cannam@167 1380 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
cannam@167 1381
cannam@167 1382 # This program is free software: you can redistribute it and/or modify
cannam@167 1383 # it under the terms of the GNU General Public License as published by
cannam@167 1384 # the Free Software Foundation, either version 3 of the License, or
cannam@167 1385 # (at your option) any later version.
cannam@167 1386
cannam@167 1387 # This program is distributed in the hope that it will be useful,
cannam@167 1388 # but WITHOUT ANY WARRANTY; without even the implied warranty of
cannam@167 1389 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
cannam@167 1390 # GNU General Public License for more details.
cannam@167 1391
cannam@167 1392 # You should have received a copy of the GNU General Public License
cannam@167 1393 # along with this program. If not, see <http://www.gnu.org/licenses/>.
cannam@167 1394
cannam@167 1395 # Please report bugs or propose patches to gary@gnu.org.
cannam@167 1396
cannam@167 1397
cannam@167 1398 ## ------ ##
cannam@167 1399 ## Usage. ##
cannam@167 1400 ## ------ ##
cannam@167 1401
cannam@167 1402 # This file is a library for parsing options in your shell scripts along
cannam@167 1403 # with assorted other useful supporting features that you can make use
cannam@167 1404 # of too.
cannam@167 1405 #
cannam@167 1406 # For the simplest scripts you might need only:
cannam@167 1407 #
cannam@167 1408 # #!/bin/sh
cannam@167 1409 # . relative/path/to/funclib.sh
cannam@167 1410 # . relative/path/to/options-parser
cannam@167 1411 # scriptversion=1.0
cannam@167 1412 # func_options ${1+"$@"}
cannam@167 1413 # eval set dummy "$func_options_result"; shift
cannam@167 1414 # ...rest of your script...
cannam@167 1415 #
cannam@167 1416 # In order for the '--version' option to work, you will need to have a
cannam@167 1417 # suitably formatted comment like the one at the top of this file
cannam@167 1418 # starting with '# Written by ' and ending with '# warranty; '.
cannam@167 1419 #
cannam@167 1420 # For '-h' and '--help' to work, you will also need a one line
cannam@167 1421 # description of your script's purpose in a comment directly above the
cannam@167 1422 # '# Written by ' line, like the one at the top of this file.
cannam@167 1423 #
cannam@167 1424 # The default options also support '--debug', which will turn on shell
cannam@167 1425 # execution tracing (see the comment above debug_cmd below for another
cannam@167 1426 # use), and '--verbose' and the func_verbose function to allow your script
cannam@167 1427 # to display verbose messages only when your user has specified
cannam@167 1428 # '--verbose'.
cannam@167 1429 #
cannam@167 1430 # After sourcing this file, you can plug processing for additional
cannam@167 1431 # options by amending the variables from the 'Configuration' section
cannam@167 1432 # below, and following the instructions in the 'Option parsing'
cannam@167 1433 # section further down.
cannam@167 1434
cannam@167 1435 ## -------------- ##
cannam@167 1436 ## Configuration. ##
cannam@167 1437 ## -------------- ##
cannam@167 1438
cannam@167 1439 # You should override these variables in your script after sourcing this
cannam@167 1440 # file so that they reflect the customisations you have added to the
cannam@167 1441 # option parser.
cannam@167 1442
cannam@167 1443 # The usage line for option parsing errors and the start of '-h' and
cannam@167 1444 # '--help' output messages. You can embed shell variables for delayed
cannam@167 1445 # expansion at the time the message is displayed, but you will need to
cannam@167 1446 # quote other shell meta-characters carefully to prevent them being
cannam@167 1447 # expanded when the contents are evaled.
cannam@167 1448 usage='$progpath [OPTION]...'
cannam@167 1449
cannam@167 1450 # Short help message in response to '-h' and '--help'. Add to this or
cannam@167 1451 # override it after sourcing this library to reflect the full set of
cannam@167 1452 # options your script accepts.
cannam@167 1453 usage_message="\
cannam@167 1454 --debug enable verbose shell tracing
cannam@167 1455 -W, --warnings=CATEGORY
cannam@167 1456 report the warnings falling in CATEGORY [all]
cannam@167 1457 -v, --verbose verbosely report processing
cannam@167 1458 --version print version information and exit
cannam@167 1459 -h, --help print short or long help message and exit
cannam@167 1460 "
cannam@167 1461
cannam@167 1462 # Additional text appended to 'usage_message' in response to '--help'.
cannam@167 1463 long_help_message="
cannam@167 1464 Warning categories include:
cannam@167 1465 'all' show all warnings
cannam@167 1466 'none' turn off all the warnings
cannam@167 1467 'error' warnings are treated as fatal errors"
cannam@167 1468
cannam@167 1469 # Help message printed before fatal option parsing errors.
cannam@167 1470 fatal_help="Try '\$progname --help' for more information."
cannam@167 1471
cannam@167 1472
cannam@167 1473
cannam@167 1474 ## ------------------------- ##
cannam@167 1475 ## Hook function management. ##
cannam@167 1476 ## ------------------------- ##
cannam@167 1477
cannam@167 1478 # This section contains functions for adding, removing, and running hooks
cannam@167 1479 # to the main code. A hook is just a named list of of function, that can
cannam@167 1480 # be run in order later on.
cannam@167 1481
cannam@167 1482 # func_hookable FUNC_NAME
cannam@167 1483 # -----------------------
cannam@167 1484 # Declare that FUNC_NAME will run hooks added with
cannam@167 1485 # 'func_add_hook FUNC_NAME ...'.
cannam@167 1486 func_hookable ()
cannam@167 1487 {
cannam@167 1488 $debug_cmd
cannam@167 1489
cannam@167 1490 func_append hookable_fns " $1"
cannam@167 1491 }
cannam@167 1492
cannam@167 1493
cannam@167 1494 # func_add_hook FUNC_NAME HOOK_FUNC
cannam@167 1495 # ---------------------------------
cannam@167 1496 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
cannam@167 1497 # first have been declared "hookable" by a call to 'func_hookable'.
cannam@167 1498 func_add_hook ()
cannam@167 1499 {
cannam@167 1500 $debug_cmd
cannam@167 1501
cannam@167 1502 case " $hookable_fns " in
cannam@167 1503 *" $1 "*) ;;
cannam@167 1504 *) func_fatal_error "'$1' does not accept hook functions." ;;
cannam@167 1505 esac
cannam@167 1506
cannam@167 1507 eval func_append ${1}_hooks '" $2"'
cannam@167 1508 }
cannam@167 1509
cannam@167 1510
cannam@167 1511 # func_remove_hook FUNC_NAME HOOK_FUNC
cannam@167 1512 # ------------------------------------
cannam@167 1513 # Remove HOOK_FUNC from the list of functions called by FUNC_NAME.
cannam@167 1514 func_remove_hook ()
cannam@167 1515 {
cannam@167 1516 $debug_cmd
cannam@167 1517
cannam@167 1518 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
cannam@167 1519 }
cannam@167 1520
cannam@167 1521
cannam@167 1522 # func_run_hooks FUNC_NAME [ARG]...
cannam@167 1523 # ---------------------------------
cannam@167 1524 # Run all hook functions registered to FUNC_NAME.
cannam@167 1525 # It is assumed that the list of hook functions contains nothing more
cannam@167 1526 # than a whitespace-delimited list of legal shell function names, and
cannam@167 1527 # no effort is wasted trying to catch shell meta-characters or preserve
cannam@167 1528 # whitespace.
cannam@167 1529 func_run_hooks ()
cannam@167 1530 {
cannam@167 1531 $debug_cmd
cannam@167 1532
cannam@167 1533 case " $hookable_fns " in
cannam@167 1534 *" $1 "*) ;;
cannam@167 1535 *) func_fatal_error "'$1' does not support hook funcions.n" ;;
cannam@167 1536 esac
cannam@167 1537
cannam@167 1538 eval _G_hook_fns=\$$1_hooks; shift
cannam@167 1539
cannam@167 1540 for _G_hook in $_G_hook_fns; do
cannam@167 1541 eval $_G_hook '"$@"'
cannam@167 1542
cannam@167 1543 # store returned options list back into positional
cannam@167 1544 # parameters for next 'cmd' execution.
cannam@167 1545 eval _G_hook_result=\$${_G_hook}_result
cannam@167 1546 eval set dummy "$_G_hook_result"; shift
cannam@167 1547 done
cannam@167 1548
cannam@167 1549 func_quote_for_eval ${1+"$@"}
cannam@167 1550 func_run_hooks_result=$func_quote_for_eval_result
cannam@167 1551 }
cannam@167 1552
cannam@167 1553
cannam@167 1554
cannam@167 1555 ## --------------- ##
cannam@167 1556 ## Option parsing. ##
cannam@167 1557 ## --------------- ##
cannam@167 1558
cannam@167 1559 # In order to add your own option parsing hooks, you must accept the
cannam@167 1560 # full positional parameter list in your hook function, remove any
cannam@167 1561 # options that you action, and then pass back the remaining unprocessed
cannam@167 1562 # options in '<hooked_function_name>_result', escaped suitably for
cannam@167 1563 # 'eval'. Like this:
cannam@167 1564 #
cannam@167 1565 # my_options_prep ()
cannam@167 1566 # {
cannam@167 1567 # $debug_cmd
cannam@167 1568 #
cannam@167 1569 # # Extend the existing usage message.
cannam@167 1570 # usage_message=$usage_message'
cannam@167 1571 # -s, --silent don'\''t print informational messages
cannam@167 1572 # '
cannam@167 1573 #
cannam@167 1574 # func_quote_for_eval ${1+"$@"}
cannam@167 1575 # my_options_prep_result=$func_quote_for_eval_result
cannam@167 1576 # }
cannam@167 1577 # func_add_hook func_options_prep my_options_prep
cannam@167 1578 #
cannam@167 1579 #
cannam@167 1580 # my_silent_option ()
cannam@167 1581 # {
cannam@167 1582 # $debug_cmd
cannam@167 1583 #
cannam@167 1584 # # Note that for efficiency, we parse as many options as we can
cannam@167 1585 # # recognise in a loop before passing the remainder back to the
cannam@167 1586 # # caller on the first unrecognised argument we encounter.
cannam@167 1587 # while test $# -gt 0; do
cannam@167 1588 # opt=$1; shift
cannam@167 1589 # case $opt in
cannam@167 1590 # --silent|-s) opt_silent=: ;;
cannam@167 1591 # # Separate non-argument short options:
cannam@167 1592 # -s*) func_split_short_opt "$_G_opt"
cannam@167 1593 # set dummy "$func_split_short_opt_name" \
cannam@167 1594 # "-$func_split_short_opt_arg" ${1+"$@"}
cannam@167 1595 # shift
cannam@167 1596 # ;;
cannam@167 1597 # *) set dummy "$_G_opt" "$*"; shift; break ;;
cannam@167 1598 # esac
cannam@167 1599 # done
cannam@167 1600 #
cannam@167 1601 # func_quote_for_eval ${1+"$@"}
cannam@167 1602 # my_silent_option_result=$func_quote_for_eval_result
cannam@167 1603 # }
cannam@167 1604 # func_add_hook func_parse_options my_silent_option
cannam@167 1605 #
cannam@167 1606 #
cannam@167 1607 # my_option_validation ()
cannam@167 1608 # {
cannam@167 1609 # $debug_cmd
cannam@167 1610 #
cannam@167 1611 # $opt_silent && $opt_verbose && func_fatal_help "\
cannam@167 1612 # '--silent' and '--verbose' options are mutually exclusive."
cannam@167 1613 #
cannam@167 1614 # func_quote_for_eval ${1+"$@"}
cannam@167 1615 # my_option_validation_result=$func_quote_for_eval_result
cannam@167 1616 # }
cannam@167 1617 # func_add_hook func_validate_options my_option_validation
cannam@167 1618 #
cannam@167 1619 # You'll alse need to manually amend $usage_message to reflect the extra
cannam@167 1620 # options you parse. It's preferable to append if you can, so that
cannam@167 1621 # multiple option parsing hooks can be added safely.
cannam@167 1622
cannam@167 1623
cannam@167 1624 # func_options [ARG]...
cannam@167 1625 # ---------------------
cannam@167 1626 # All the functions called inside func_options are hookable. See the
cannam@167 1627 # individual implementations for details.
cannam@167 1628 func_hookable func_options
cannam@167 1629 func_options ()
cannam@167 1630 {
cannam@167 1631 $debug_cmd
cannam@167 1632
cannam@167 1633 func_options_prep ${1+"$@"}
cannam@167 1634 eval func_parse_options \
cannam@167 1635 ${func_options_prep_result+"$func_options_prep_result"}
cannam@167 1636 eval func_validate_options \
cannam@167 1637 ${func_parse_options_result+"$func_parse_options_result"}
cannam@167 1638
cannam@167 1639 eval func_run_hooks func_options \
cannam@167 1640 ${func_validate_options_result+"$func_validate_options_result"}
cannam@167 1641
cannam@167 1642 # save modified positional parameters for caller
cannam@167 1643 func_options_result=$func_run_hooks_result
cannam@167 1644 }
cannam@167 1645
cannam@167 1646
cannam@167 1647 # func_options_prep [ARG]...
cannam@167 1648 # --------------------------
cannam@167 1649 # All initialisations required before starting the option parse loop.
cannam@167 1650 # Note that when calling hook functions, we pass through the list of
cannam@167 1651 # positional parameters. If a hook function modifies that list, and
cannam@167 1652 # needs to propogate that back to rest of this script, then the complete
cannam@167 1653 # modified list must be put in 'func_run_hooks_result' before
cannam@167 1654 # returning.
cannam@167 1655 func_hookable func_options_prep
cannam@167 1656 func_options_prep ()
cannam@167 1657 {
cannam@167 1658 $debug_cmd
cannam@167 1659
cannam@167 1660 # Option defaults:
cannam@167 1661 opt_verbose=false
cannam@167 1662 opt_warning_types=
cannam@167 1663
cannam@167 1664 func_run_hooks func_options_prep ${1+"$@"}
cannam@167 1665
cannam@167 1666 # save modified positional parameters for caller
cannam@167 1667 func_options_prep_result=$func_run_hooks_result
cannam@167 1668 }
cannam@167 1669
cannam@167 1670
cannam@167 1671 # func_parse_options [ARG]...
cannam@167 1672 # ---------------------------
cannam@167 1673 # The main option parsing loop.
cannam@167 1674 func_hookable func_parse_options
cannam@167 1675 func_parse_options ()
cannam@167 1676 {
cannam@167 1677 $debug_cmd
cannam@167 1678
cannam@167 1679 func_parse_options_result=
cannam@167 1680
cannam@167 1681 # this just eases exit handling
cannam@167 1682 while test $# -gt 0; do
cannam@167 1683 # Defer to hook functions for initial option parsing, so they
cannam@167 1684 # get priority in the event of reusing an option name.
cannam@167 1685 func_run_hooks func_parse_options ${1+"$@"}
cannam@167 1686
cannam@167 1687 # Adjust func_parse_options positional parameters to match
cannam@167 1688 eval set dummy "$func_run_hooks_result"; shift
cannam@167 1689
cannam@167 1690 # Break out of the loop if we already parsed every option.
cannam@167 1691 test $# -gt 0 || break
cannam@167 1692
cannam@167 1693 _G_opt=$1
cannam@167 1694 shift
cannam@167 1695 case $_G_opt in
cannam@167 1696 --debug|-x) debug_cmd='set -x'
cannam@167 1697 func_echo "enabling shell trace mode"
cannam@167 1698 $debug_cmd
cannam@167 1699 ;;
cannam@167 1700
cannam@167 1701 --no-warnings|--no-warning|--no-warn)
cannam@167 1702 set dummy --warnings none ${1+"$@"}
cannam@167 1703 shift
cannam@167 1704 ;;
cannam@167 1705
cannam@167 1706 --warnings|--warning|-W)
cannam@167 1707 test $# = 0 && func_missing_arg $_G_opt && break
cannam@167 1708 case " $warning_categories $1" in
cannam@167 1709 *" $1 "*)
cannam@167 1710 # trailing space prevents matching last $1 above
cannam@167 1711 func_append_uniq opt_warning_types " $1"
cannam@167 1712 ;;
cannam@167 1713 *all)
cannam@167 1714 opt_warning_types=$warning_categories
cannam@167 1715 ;;
cannam@167 1716 *none)
cannam@167 1717 opt_warning_types=none
cannam@167 1718 warning_func=:
cannam@167 1719 ;;
cannam@167 1720 *error)
cannam@167 1721 opt_warning_types=$warning_categories
cannam@167 1722 warning_func=func_fatal_error
cannam@167 1723 ;;
cannam@167 1724 *)
cannam@167 1725 func_fatal_error \
cannam@167 1726 "unsupported warning category: '$1'"
cannam@167 1727 ;;
cannam@167 1728 esac
cannam@167 1729 shift
cannam@167 1730 ;;
cannam@167 1731
cannam@167 1732 --verbose|-v) opt_verbose=: ;;
cannam@167 1733 --version) func_version ;;
cannam@167 1734 -\?|-h) func_usage ;;
cannam@167 1735 --help) func_help ;;
cannam@167 1736
cannam@167 1737 # Separate optargs to long options (plugins may need this):
cannam@167 1738 --*=*) func_split_equals "$_G_opt"
cannam@167 1739 set dummy "$func_split_equals_lhs" \
cannam@167 1740 "$func_split_equals_rhs" ${1+"$@"}
cannam@167 1741 shift
cannam@167 1742 ;;
cannam@167 1743
cannam@167 1744 # Separate optargs to short options:
cannam@167 1745 -W*)
cannam@167 1746 func_split_short_opt "$_G_opt"
cannam@167 1747 set dummy "$func_split_short_opt_name" \
cannam@167 1748 "$func_split_short_opt_arg" ${1+"$@"}
cannam@167 1749 shift
cannam@167 1750 ;;
cannam@167 1751
cannam@167 1752 # Separate non-argument short options:
cannam@167 1753 -\?*|-h*|-v*|-x*)
cannam@167 1754 func_split_short_opt "$_G_opt"
cannam@167 1755 set dummy "$func_split_short_opt_name" \
cannam@167 1756 "-$func_split_short_opt_arg" ${1+"$@"}
cannam@167 1757 shift
cannam@167 1758 ;;
cannam@167 1759
cannam@167 1760 --) break ;;
cannam@167 1761 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
cannam@167 1762 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
cannam@167 1763 esac
cannam@167 1764 done
cannam@167 1765
cannam@167 1766 # save modified positional parameters for caller
cannam@167 1767 func_quote_for_eval ${1+"$@"}
cannam@167 1768 func_parse_options_result=$func_quote_for_eval_result
cannam@167 1769 }
cannam@167 1770
cannam@167 1771
cannam@167 1772 # func_validate_options [ARG]...
cannam@167 1773 # ------------------------------
cannam@167 1774 # Perform any sanity checks on option settings and/or unconsumed
cannam@167 1775 # arguments.
cannam@167 1776 func_hookable func_validate_options
cannam@167 1777 func_validate_options ()
cannam@167 1778 {
cannam@167 1779 $debug_cmd
cannam@167 1780
cannam@167 1781 # Display all warnings if -W was not given.
cannam@167 1782 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
cannam@167 1783
cannam@167 1784 func_run_hooks func_validate_options ${1+"$@"}
cannam@167 1785
cannam@167 1786 # Bail if the options were screwed!
cannam@167 1787 $exit_cmd $EXIT_FAILURE
cannam@167 1788
cannam@167 1789 # save modified positional parameters for caller
cannam@167 1790 func_validate_options_result=$func_run_hooks_result
cannam@167 1791 }
cannam@167 1792
cannam@167 1793
cannam@167 1794
cannam@167 1795 ## ----------------- ##
cannam@167 1796 ## Helper functions. ##
cannam@167 1797 ## ----------------- ##
cannam@167 1798
cannam@167 1799 # This section contains the helper functions used by the rest of the
cannam@167 1800 # hookable option parser framework in ascii-betical order.
cannam@167 1801
cannam@167 1802
cannam@167 1803 # func_fatal_help ARG...
cannam@167 1804 # ----------------------
cannam@167 1805 # Echo program name prefixed message to standard error, followed by
cannam@167 1806 # a help hint, and exit.
cannam@167 1807 func_fatal_help ()
cannam@167 1808 {
cannam@167 1809 $debug_cmd
cannam@167 1810
cannam@167 1811 eval \$ECHO \""Usage: $usage"\"
cannam@167 1812 eval \$ECHO \""$fatal_help"\"
cannam@167 1813 func_error ${1+"$@"}
cannam@167 1814 exit $EXIT_FAILURE
cannam@167 1815 }
cannam@167 1816
cannam@167 1817
cannam@167 1818 # func_help
cannam@167 1819 # ---------
cannam@167 1820 # Echo long help message to standard output and exit.
cannam@167 1821 func_help ()
cannam@167 1822 {
cannam@167 1823 $debug_cmd
cannam@167 1824
cannam@167 1825 func_usage_message
cannam@167 1826 $ECHO "$long_help_message"
cannam@167 1827 exit 0
cannam@167 1828 }
cannam@167 1829
cannam@167 1830
cannam@167 1831 # func_missing_arg ARGNAME
cannam@167 1832 # ------------------------
cannam@167 1833 # Echo program name prefixed message to standard error and set global
cannam@167 1834 # exit_cmd.
cannam@167 1835 func_missing_arg ()
cannam@167 1836 {
cannam@167 1837 $debug_cmd
cannam@167 1838
cannam@167 1839 func_error "Missing argument for '$1'."
cannam@167 1840 exit_cmd=exit
cannam@167 1841 }
cannam@167 1842
cannam@167 1843
cannam@167 1844 # func_split_equals STRING
cannam@167 1845 # ------------------------
cannam@167 1846 # Set func_split_equals_lhs and func_split_equals_rhs shell variables after
cannam@167 1847 # splitting STRING at the '=' sign.
cannam@167 1848 test -z "$_G_HAVE_XSI_OPS" \
cannam@167 1849 && (eval 'x=a/b/c;
cannam@167 1850 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
cannam@167 1851 && _G_HAVE_XSI_OPS=yes
cannam@167 1852
cannam@167 1853 if test yes = "$_G_HAVE_XSI_OPS"
cannam@167 1854 then
cannam@167 1855 # This is an XSI compatible shell, allowing a faster implementation...
cannam@167 1856 eval 'func_split_equals ()
cannam@167 1857 {
cannam@167 1858 $debug_cmd
cannam@167 1859
cannam@167 1860 func_split_equals_lhs=${1%%=*}
cannam@167 1861 func_split_equals_rhs=${1#*=}
cannam@167 1862 test "x$func_split_equals_lhs" = "x$1" \
cannam@167 1863 && func_split_equals_rhs=
cannam@167 1864 }'
cannam@167 1865 else
cannam@167 1866 # ...otherwise fall back to using expr, which is often a shell builtin.
cannam@167 1867 func_split_equals ()
cannam@167 1868 {
cannam@167 1869 $debug_cmd
cannam@167 1870
cannam@167 1871 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
cannam@167 1872 func_split_equals_rhs=
cannam@167 1873 test "x$func_split_equals_lhs" = "x$1" \
cannam@167 1874 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
cannam@167 1875 }
cannam@167 1876 fi #func_split_equals
cannam@167 1877
cannam@167 1878
cannam@167 1879 # func_split_short_opt SHORTOPT
cannam@167 1880 # -----------------------------
cannam@167 1881 # Set func_split_short_opt_name and func_split_short_opt_arg shell
cannam@167 1882 # variables after splitting SHORTOPT after the 2nd character.
cannam@167 1883 if test yes = "$_G_HAVE_XSI_OPS"
cannam@167 1884 then
cannam@167 1885 # This is an XSI compatible shell, allowing a faster implementation...
cannam@167 1886 eval 'func_split_short_opt ()
cannam@167 1887 {
cannam@167 1888 $debug_cmd
cannam@167 1889
cannam@167 1890 func_split_short_opt_arg=${1#??}
cannam@167 1891 func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
cannam@167 1892 }'
cannam@167 1893 else
cannam@167 1894 # ...otherwise fall back to using expr, which is often a shell builtin.
cannam@167 1895 func_split_short_opt ()
cannam@167 1896 {
cannam@167 1897 $debug_cmd
cannam@167 1898
cannam@167 1899 func_split_short_opt_name=`expr "x$1" : 'x-\(.\)'`
cannam@167 1900 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
cannam@167 1901 }
cannam@167 1902 fi #func_split_short_opt
cannam@167 1903
cannam@167 1904
cannam@167 1905 # func_usage
cannam@167 1906 # ----------
cannam@167 1907 # Echo short help message to standard output and exit.
cannam@167 1908 func_usage ()
cannam@167 1909 {
cannam@167 1910 $debug_cmd
cannam@167 1911
cannam@167 1912 func_usage_message
cannam@167 1913 $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
cannam@167 1914 exit 0
cannam@167 1915 }
cannam@167 1916
cannam@167 1917
cannam@167 1918 # func_usage_message
cannam@167 1919 # ------------------
cannam@167 1920 # Echo short help message to standard output.
cannam@167 1921 func_usage_message ()
cannam@167 1922 {
cannam@167 1923 $debug_cmd
cannam@167 1924
cannam@167 1925 eval \$ECHO \""Usage: $usage"\"
cannam@167 1926 echo
cannam@167 1927 $SED -n 's|^# ||
cannam@167 1928 /^Written by/{
cannam@167 1929 x;p;x
cannam@167 1930 }
cannam@167 1931 h
cannam@167 1932 /^Written by/q' < "$progpath"
cannam@167 1933 echo
cannam@167 1934 eval \$ECHO \""$usage_message"\"
cannam@167 1935 }
cannam@167 1936
cannam@167 1937
cannam@167 1938 # func_version
cannam@167 1939 # ------------
cannam@167 1940 # Echo version message to standard output and exit.
cannam@167 1941 func_version ()
cannam@167 1942 {
cannam@167 1943 $debug_cmd
cannam@167 1944
cannam@167 1945 printf '%s\n' "$progname $scriptversion"
cannam@167 1946 $SED -n '
cannam@167 1947 /(C)/!b go
cannam@167 1948 :more
cannam@167 1949 /\./!{
cannam@167 1950 N
cannam@167 1951 s|\n# | |
cannam@167 1952 b more
cannam@167 1953 }
cannam@167 1954 :go
cannam@167 1955 /^# Written by /,/# warranty; / {
cannam@167 1956 s|^# ||
cannam@167 1957 s|^# *$||
cannam@167 1958 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
cannam@167 1959 p
cannam@167 1960 }
cannam@167 1961 /^# Written by / {
cannam@167 1962 s|^# ||
cannam@167 1963 p
cannam@167 1964 }
cannam@167 1965 /^warranty; /q' < "$progpath"
cannam@167 1966
cannam@167 1967 exit $?
cannam@167 1968 }
cannam@167 1969
cannam@167 1970
cannam@167 1971 # Local variables:
cannam@167 1972 # mode: shell-script
cannam@167 1973 # sh-indentation: 2
cannam@167 1974 # eval: (add-hook 'before-save-hook 'time-stamp)
cannam@167 1975 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
cannam@167 1976 # time-stamp-time-zone: "UTC"
cannam@167 1977 # End:
cannam@167 1978
cannam@167 1979 # Set a version string.
cannam@167 1980 scriptversion='(GNU libtool) 2.4.6'
cannam@167 1981
cannam@167 1982
cannam@167 1983 # func_echo ARG...
cannam@167 1984 # ----------------
cannam@167 1985 # Libtool also displays the current mode in messages, so override
cannam@167 1986 # funclib.sh func_echo with this custom definition.
cannam@167 1987 func_echo ()
cannam@167 1988 {
cannam@167 1989 $debug_cmd
cannam@167 1990
cannam@167 1991 _G_message=$*
cannam@167 1992
cannam@167 1993 func_echo_IFS=$IFS
cannam@167 1994 IFS=$nl
cannam@167 1995 for _G_line in $_G_message; do
cannam@167 1996 IFS=$func_echo_IFS
cannam@167 1997 $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
cannam@167 1998 done
cannam@167 1999 IFS=$func_echo_IFS
cannam@167 2000 }
cannam@167 2001
cannam@167 2002
cannam@167 2003 # func_warning ARG...
cannam@167 2004 # -------------------
cannam@167 2005 # Libtool warnings are not categorized, so override funclib.sh
cannam@167 2006 # func_warning with this simpler definition.
cannam@167 2007 func_warning ()
cannam@167 2008 {
cannam@167 2009 $debug_cmd
cannam@167 2010
cannam@167 2011 $warning_func ${1+"$@"}
cannam@167 2012 }
cannam@167 2013
cannam@167 2014
cannam@167 2015 ## ---------------- ##
cannam@167 2016 ## Options parsing. ##
cannam@167 2017 ## ---------------- ##
cannam@167 2018
cannam@167 2019 # Hook in the functions to make sure our own options are parsed during
cannam@167 2020 # the option parsing loop.
cannam@167 2021
cannam@167 2022 usage='$progpath [OPTION]... [MODE-ARG]...'
cannam@167 2023
cannam@167 2024 # Short help message in response to '-h'.
cannam@167 2025 usage_message="Options:
cannam@167 2026 --config show all configuration variables
cannam@167 2027 --debug enable verbose shell tracing
cannam@167 2028 -n, --dry-run display commands without modifying any files
cannam@167 2029 --features display basic configuration information and exit
cannam@167 2030 --mode=MODE use operation mode MODE
cannam@167 2031 --no-warnings equivalent to '-Wnone'
cannam@167 2032 --preserve-dup-deps don't remove duplicate dependency libraries
cannam@167 2033 --quiet, --silent don't print informational messages
cannam@167 2034 --tag=TAG use configuration variables from tag TAG
cannam@167 2035 -v, --verbose print more informational messages than default
cannam@167 2036 --version print version information
cannam@167 2037 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
cannam@167 2038 -h, --help, --help-all print short, long, or detailed help message
cannam@167 2039 "
cannam@167 2040
cannam@167 2041 # Additional text appended to 'usage_message' in response to '--help'.
cannam@167 2042 func_help ()
cannam@167 2043 {
cannam@167 2044 $debug_cmd
cannam@167 2045
cannam@167 2046 func_usage_message
cannam@167 2047 $ECHO "$long_help_message
cannam@167 2048
cannam@167 2049 MODE must be one of the following:
cannam@167 2050
cannam@167 2051 clean remove files from the build directory
cannam@167 2052 compile compile a source file into a libtool object
cannam@167 2053 execute automatically set library path, then run a program
cannam@167 2054 finish complete the installation of libtool libraries
cannam@167 2055 install install libraries or executables
cannam@167 2056 link create a library or an executable
cannam@167 2057 uninstall remove libraries from an installed directory
cannam@167 2058
cannam@167 2059 MODE-ARGS vary depending on the MODE. When passed as first option,
cannam@167 2060 '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
cannam@167 2061 Try '$progname --help --mode=MODE' for a more detailed description of MODE.
cannam@167 2062
cannam@167 2063 When reporting a bug, please describe a test case to reproduce it and
cannam@167 2064 include the following information:
cannam@167 2065
cannam@167 2066 host-triplet: $host
cannam@167 2067 shell: $SHELL
cannam@167 2068 compiler: $LTCC
cannam@167 2069 compiler flags: $LTCFLAGS
cannam@167 2070 linker: $LD (gnu? $with_gnu_ld)
cannam@167 2071 version: $progname $scriptversion Debian-2.4.6-2
cannam@167 2072 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
cannam@167 2073 autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
cannam@167 2074
cannam@167 2075 Report bugs to <bug-libtool@gnu.org>.
cannam@167 2076 GNU libtool home page: <http://www.gnu.org/s/libtool/>.
cannam@167 2077 General help using GNU software: <http://www.gnu.org/gethelp/>."
cannam@167 2078 exit 0
cannam@167 2079 }
cannam@167 2080
cannam@167 2081
cannam@167 2082 # func_lo2o OBJECT-NAME
cannam@167 2083 # ---------------------
cannam@167 2084 # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
cannam@167 2085 # object suffix.
cannam@167 2086
cannam@167 2087 lo2o=s/\\.lo\$/.$objext/
cannam@167 2088 o2lo=s/\\.$objext\$/.lo/
cannam@167 2089
cannam@167 2090 if test yes = "$_G_HAVE_XSI_OPS"; then
cannam@167 2091 eval 'func_lo2o ()
cannam@167 2092 {
cannam@167 2093 case $1 in
cannam@167 2094 *.lo) func_lo2o_result=${1%.lo}.$objext ;;
cannam@167 2095 * ) func_lo2o_result=$1 ;;
cannam@167 2096 esac
cannam@167 2097 }'
cannam@167 2098
cannam@167 2099 # func_xform LIBOBJ-OR-SOURCE
cannam@167 2100 # ---------------------------
cannam@167 2101 # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
cannam@167 2102 # suffix to a '.lo' libtool-object suffix.
cannam@167 2103 eval 'func_xform ()
cannam@167 2104 {
cannam@167 2105 func_xform_result=${1%.*}.lo
cannam@167 2106 }'
cannam@167 2107 else
cannam@167 2108 # ...otherwise fall back to using sed.
cannam@167 2109 func_lo2o ()
cannam@167 2110 {
cannam@167 2111 func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
cannam@167 2112 }
cannam@167 2113
cannam@167 2114 func_xform ()
cannam@167 2115 {
cannam@167 2116 func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
cannam@167 2117 }
cannam@167 2118 fi
cannam@167 2119
cannam@167 2120
cannam@167 2121 # func_fatal_configuration ARG...
cannam@167 2122 # -------------------------------
cannam@167 2123 # Echo program name prefixed message to standard error, followed by
cannam@167 2124 # a configuration failure hint, and exit.
cannam@167 2125 func_fatal_configuration ()
cannam@167 2126 {
cannam@167 2127 func__fatal_error ${1+"$@"} \
cannam@167 2128 "See the $PACKAGE documentation for more information." \
cannam@167 2129 "Fatal configuration error."
cannam@167 2130 }
cannam@167 2131
cannam@167 2132
cannam@167 2133 # func_config
cannam@167 2134 # -----------
cannam@167 2135 # Display the configuration for all the tags in this script.
cannam@167 2136 func_config ()
cannam@167 2137 {
cannam@167 2138 re_begincf='^# ### BEGIN LIBTOOL'
cannam@167 2139 re_endcf='^# ### END LIBTOOL'
cannam@167 2140
cannam@167 2141 # Default configuration.
cannam@167 2142 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
cannam@167 2143
cannam@167 2144 # Now print the configurations for the tags.
cannam@167 2145 for tagname in $taglist; do
cannam@167 2146 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
cannam@167 2147 done
cannam@167 2148
cannam@167 2149 exit $?
cannam@167 2150 }
cannam@167 2151
cannam@167 2152
cannam@167 2153 # func_features
cannam@167 2154 # -------------
cannam@167 2155 # Display the features supported by this script.
cannam@167 2156 func_features ()
cannam@167 2157 {
cannam@167 2158 echo "host: $host"
cannam@167 2159 if test yes = "$build_libtool_libs"; then
cannam@167 2160 echo "enable shared libraries"
cannam@167 2161 else
cannam@167 2162 echo "disable shared libraries"
cannam@167 2163 fi
cannam@167 2164 if test yes = "$build_old_libs"; then
cannam@167 2165 echo "enable static libraries"
cannam@167 2166 else
cannam@167 2167 echo "disable static libraries"
cannam@167 2168 fi
cannam@167 2169
cannam@167 2170 exit $?
cannam@167 2171 }
cannam@167 2172
cannam@167 2173
cannam@167 2174 # func_enable_tag TAGNAME
cannam@167 2175 # -----------------------
cannam@167 2176 # Verify that TAGNAME is valid, and either flag an error and exit, or
cannam@167 2177 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
cannam@167 2178 # variable here.
cannam@167 2179 func_enable_tag ()
cannam@167 2180 {
cannam@167 2181 # Global variable:
cannam@167 2182 tagname=$1
cannam@167 2183
cannam@167 2184 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
cannam@167 2185 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
cannam@167 2186 sed_extractcf=/$re_begincf/,/$re_endcf/p
cannam@167 2187
cannam@167 2188 # Validate tagname.
cannam@167 2189 case $tagname in
cannam@167 2190 *[!-_A-Za-z0-9,/]*)
cannam@167 2191 func_fatal_error "invalid tag name: $tagname"
cannam@167 2192 ;;
cannam@167 2193 esac
cannam@167 2194
cannam@167 2195 # Don't test for the "default" C tag, as we know it's
cannam@167 2196 # there but not specially marked.
cannam@167 2197 case $tagname in
cannam@167 2198 CC) ;;
cannam@167 2199 *)
cannam@167 2200 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
cannam@167 2201 taglist="$taglist $tagname"
cannam@167 2202
cannam@167 2203 # Evaluate the configuration. Be careful to quote the path
cannam@167 2204 # and the sed script, to avoid splitting on whitespace, but
cannam@167 2205 # also don't use non-portable quotes within backquotes within
cannam@167 2206 # quotes we have to do it in 2 steps:
cannam@167 2207 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
cannam@167 2208 eval "$extractedcf"
cannam@167 2209 else
cannam@167 2210 func_error "ignoring unknown tag $tagname"
cannam@167 2211 fi
cannam@167 2212 ;;
cannam@167 2213 esac
cannam@167 2214 }
cannam@167 2215
cannam@167 2216
cannam@167 2217 # func_check_version_match
cannam@167 2218 # ------------------------
cannam@167 2219 # Ensure that we are using m4 macros, and libtool script from the same
cannam@167 2220 # release of libtool.
cannam@167 2221 func_check_version_match ()
cannam@167 2222 {
cannam@167 2223 if test "$package_revision" != "$macro_revision"; then
cannam@167 2224 if test "$VERSION" != "$macro_version"; then
cannam@167 2225 if test -z "$macro_version"; then
cannam@167 2226 cat >&2 <<_LT_EOF
cannam@167 2227 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
cannam@167 2228 $progname: definition of this LT_INIT comes from an older release.
cannam@167 2229 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
cannam@167 2230 $progname: and run autoconf again.
cannam@167 2231 _LT_EOF
cannam@167 2232 else
cannam@167 2233 cat >&2 <<_LT_EOF
cannam@167 2234 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
cannam@167 2235 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
cannam@167 2236 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
cannam@167 2237 $progname: and run autoconf again.
cannam@167 2238 _LT_EOF
cannam@167 2239 fi
cannam@167 2240 else
cannam@167 2241 cat >&2 <<_LT_EOF
cannam@167 2242 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
cannam@167 2243 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
cannam@167 2244 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
cannam@167 2245 $progname: of $PACKAGE $VERSION and run autoconf again.
cannam@167 2246 _LT_EOF
cannam@167 2247 fi
cannam@167 2248
cannam@167 2249 exit $EXIT_MISMATCH
cannam@167 2250 fi
cannam@167 2251 }
cannam@167 2252
cannam@167 2253
cannam@167 2254 # libtool_options_prep [ARG]...
cannam@167 2255 # -----------------------------
cannam@167 2256 # Preparation for options parsed by libtool.
cannam@167 2257 libtool_options_prep ()
cannam@167 2258 {
cannam@167 2259 $debug_mode
cannam@167 2260
cannam@167 2261 # Option defaults:
cannam@167 2262 opt_config=false
cannam@167 2263 opt_dlopen=
cannam@167 2264 opt_dry_run=false
cannam@167 2265 opt_help=false
cannam@167 2266 opt_mode=
cannam@167 2267 opt_preserve_dup_deps=false
cannam@167 2268 opt_quiet=false
cannam@167 2269
cannam@167 2270 nonopt=
cannam@167 2271 preserve_args=
cannam@167 2272
cannam@167 2273 # Shorthand for --mode=foo, only valid as the first argument
cannam@167 2274 case $1 in
cannam@167 2275 clean|clea|cle|cl)
cannam@167 2276 shift; set dummy --mode clean ${1+"$@"}; shift
cannam@167 2277 ;;
cannam@167 2278 compile|compil|compi|comp|com|co|c)
cannam@167 2279 shift; set dummy --mode compile ${1+"$@"}; shift
cannam@167 2280 ;;
cannam@167 2281 execute|execut|execu|exec|exe|ex|e)
cannam@167 2282 shift; set dummy --mode execute ${1+"$@"}; shift
cannam@167 2283 ;;
cannam@167 2284 finish|finis|fini|fin|fi|f)
cannam@167 2285 shift; set dummy --mode finish ${1+"$@"}; shift
cannam@167 2286 ;;
cannam@167 2287 install|instal|insta|inst|ins|in|i)
cannam@167 2288 shift; set dummy --mode install ${1+"$@"}; shift
cannam@167 2289 ;;
cannam@167 2290 link|lin|li|l)
cannam@167 2291 shift; set dummy --mode link ${1+"$@"}; shift
cannam@167 2292 ;;
cannam@167 2293 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
cannam@167 2294 shift; set dummy --mode uninstall ${1+"$@"}; shift
cannam@167 2295 ;;
cannam@167 2296 esac
cannam@167 2297
cannam@167 2298 # Pass back the list of options.
cannam@167 2299 func_quote_for_eval ${1+"$@"}
cannam@167 2300 libtool_options_prep_result=$func_quote_for_eval_result
cannam@167 2301 }
cannam@167 2302 func_add_hook func_options_prep libtool_options_prep
cannam@167 2303
cannam@167 2304
cannam@167 2305 # libtool_parse_options [ARG]...
cannam@167 2306 # ---------------------------------
cannam@167 2307 # Provide handling for libtool specific options.
cannam@167 2308 libtool_parse_options ()
cannam@167 2309 {
cannam@167 2310 $debug_cmd
cannam@167 2311
cannam@167 2312 # Perform our own loop to consume as many options as possible in
cannam@167 2313 # each iteration.
cannam@167 2314 while test $# -gt 0; do
cannam@167 2315 _G_opt=$1
cannam@167 2316 shift
cannam@167 2317 case $_G_opt in
cannam@167 2318 --dry-run|--dryrun|-n)
cannam@167 2319 opt_dry_run=:
cannam@167 2320 ;;
cannam@167 2321
cannam@167 2322 --config) func_config ;;
cannam@167 2323
cannam@167 2324 --dlopen|-dlopen)
cannam@167 2325 opt_dlopen="${opt_dlopen+$opt_dlopen
cannam@167 2326 }$1"
cannam@167 2327 shift
cannam@167 2328 ;;
cannam@167 2329
cannam@167 2330 --preserve-dup-deps)
cannam@167 2331 opt_preserve_dup_deps=: ;;
cannam@167 2332
cannam@167 2333 --features) func_features ;;
cannam@167 2334
cannam@167 2335 --finish) set dummy --mode finish ${1+"$@"}; shift ;;
cannam@167 2336
cannam@167 2337 --help) opt_help=: ;;
cannam@167 2338
cannam@167 2339 --help-all) opt_help=': help-all' ;;
cannam@167 2340
cannam@167 2341 --mode) test $# = 0 && func_missing_arg $_G_opt && break
cannam@167 2342 opt_mode=$1
cannam@167 2343 case $1 in
cannam@167 2344 # Valid mode arguments:
cannam@167 2345 clean|compile|execute|finish|install|link|relink|uninstall) ;;
cannam@167 2346
cannam@167 2347 # Catch anything else as an error
cannam@167 2348 *) func_error "invalid argument for $_G_opt"
cannam@167 2349 exit_cmd=exit
cannam@167 2350 break
cannam@167 2351 ;;
cannam@167 2352 esac
cannam@167 2353 shift
cannam@167 2354 ;;
cannam@167 2355
cannam@167 2356 --no-silent|--no-quiet)
cannam@167 2357 opt_quiet=false
cannam@167 2358 func_append preserve_args " $_G_opt"
cannam@167 2359 ;;
cannam@167 2360
cannam@167 2361 --no-warnings|--no-warning|--no-warn)
cannam@167 2362 opt_warning=false
cannam@167 2363 func_append preserve_args " $_G_opt"
cannam@167 2364 ;;
cannam@167 2365
cannam@167 2366 --no-verbose)
cannam@167 2367 opt_verbose=false
cannam@167 2368 func_append preserve_args " $_G_opt"
cannam@167 2369 ;;
cannam@167 2370
cannam@167 2371 --silent|--quiet)
cannam@167 2372 opt_quiet=:
cannam@167 2373 opt_verbose=false
cannam@167 2374 func_append preserve_args " $_G_opt"
cannam@167 2375 ;;
cannam@167 2376
cannam@167 2377 --tag) test $# = 0 && func_missing_arg $_G_opt && break
cannam@167 2378 opt_tag=$1
cannam@167 2379 func_append preserve_args " $_G_opt $1"
cannam@167 2380 func_enable_tag "$1"
cannam@167 2381 shift
cannam@167 2382 ;;
cannam@167 2383
cannam@167 2384 --verbose|-v) opt_quiet=false
cannam@167 2385 opt_verbose=:
cannam@167 2386 func_append preserve_args " $_G_opt"
cannam@167 2387 ;;
cannam@167 2388
cannam@167 2389 # An option not handled by this hook function:
cannam@167 2390 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
cannam@167 2391 esac
cannam@167 2392 done
cannam@167 2393
cannam@167 2394
cannam@167 2395 # save modified positional parameters for caller
cannam@167 2396 func_quote_for_eval ${1+"$@"}
cannam@167 2397 libtool_parse_options_result=$func_quote_for_eval_result
cannam@167 2398 }
cannam@167 2399 func_add_hook func_parse_options libtool_parse_options
cannam@167 2400
cannam@167 2401
cannam@167 2402
cannam@167 2403 # libtool_validate_options [ARG]...
cannam@167 2404 # ---------------------------------
cannam@167 2405 # Perform any sanity checks on option settings and/or unconsumed
cannam@167 2406 # arguments.
cannam@167 2407 libtool_validate_options ()
cannam@167 2408 {
cannam@167 2409 # save first non-option argument
cannam@167 2410 if test 0 -lt $#; then
cannam@167 2411 nonopt=$1
cannam@167 2412 shift
cannam@167 2413 fi
cannam@167 2414
cannam@167 2415 # preserve --debug
cannam@167 2416 test : = "$debug_cmd" || func_append preserve_args " --debug"
cannam@167 2417
cannam@167 2418 case $host in
cannam@167 2419 # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
cannam@167 2420 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
cannam@167 2421 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*)
cannam@167 2422 # don't eliminate duplications in $postdeps and $predeps
cannam@167 2423 opt_duplicate_compiler_generated_deps=:
cannam@167 2424 ;;
cannam@167 2425 *)
cannam@167 2426 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
cannam@167 2427 ;;
cannam@167 2428 esac
cannam@167 2429
cannam@167 2430 $opt_help || {
cannam@167 2431 # Sanity checks first:
cannam@167 2432 func_check_version_match
cannam@167 2433
cannam@167 2434 test yes != "$build_libtool_libs" \
cannam@167 2435 && test yes != "$build_old_libs" \
cannam@167 2436 && func_fatal_configuration "not configured to build any kind of library"
cannam@167 2437
cannam@167 2438 # Darwin sucks
cannam@167 2439 eval std_shrext=\"$shrext_cmds\"
cannam@167 2440
cannam@167 2441 # Only execute mode is allowed to have -dlopen flags.
cannam@167 2442 if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
cannam@167 2443 func_error "unrecognized option '-dlopen'"
cannam@167 2444 $ECHO "$help" 1>&2
cannam@167 2445 exit $EXIT_FAILURE
cannam@167 2446 fi
cannam@167 2447
cannam@167 2448 # Change the help message to a mode-specific one.
cannam@167 2449 generic_help=$help
cannam@167 2450 help="Try '$progname --help --mode=$opt_mode' for more information."
cannam@167 2451 }
cannam@167 2452
cannam@167 2453 # Pass back the unparsed argument list
cannam@167 2454 func_quote_for_eval ${1+"$@"}
cannam@167 2455 libtool_validate_options_result=$func_quote_for_eval_result
cannam@167 2456 }
cannam@167 2457 func_add_hook func_validate_options libtool_validate_options
cannam@167 2458
cannam@167 2459
cannam@167 2460 # Process options as early as possible so that --help and --version
cannam@167 2461 # can return quickly.
cannam@167 2462 func_options ${1+"$@"}
cannam@167 2463 eval set dummy "$func_options_result"; shift
cannam@167 2464
cannam@167 2465
cannam@167 2466
cannam@167 2467 ## ----------- ##
cannam@167 2468 ## Main. ##
cannam@167 2469 ## ----------- ##
cannam@167 2470
cannam@167 2471 magic='%%%MAGIC variable%%%'
cannam@167 2472 magic_exe='%%%MAGIC EXE variable%%%'
cannam@167 2473
cannam@167 2474 # Global variables.
cannam@167 2475 extracted_archives=
cannam@167 2476 extracted_serial=0
cannam@167 2477
cannam@167 2478 # If this variable is set in any of the actions, the command in it
cannam@167 2479 # will be execed at the end. This prevents here-documents from being
cannam@167 2480 # left over by shells.
cannam@167 2481 exec_cmd=
cannam@167 2482
cannam@167 2483
cannam@167 2484 # A function that is used when there is no print builtin or printf.
cannam@167 2485 func_fallback_echo ()
cannam@167 2486 {
cannam@167 2487 eval 'cat <<_LTECHO_EOF
cannam@167 2488 $1
cannam@167 2489 _LTECHO_EOF'
cannam@167 2490 }
cannam@167 2491
cannam@167 2492 # func_generated_by_libtool
cannam@167 2493 # True iff stdin has been generated by Libtool. This function is only
cannam@167 2494 # a basic sanity check; it will hardly flush out determined imposters.
cannam@167 2495 func_generated_by_libtool_p ()
cannam@167 2496 {
cannam@167 2497 $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
cannam@167 2498 }
cannam@167 2499
cannam@167 2500 # func_lalib_p file
cannam@167 2501 # True iff FILE is a libtool '.la' library or '.lo' object file.
cannam@167 2502 # This function is only a basic sanity check; it will hardly flush out
cannam@167 2503 # determined imposters.
cannam@167 2504 func_lalib_p ()
cannam@167 2505 {
cannam@167 2506 test -f "$1" &&
cannam@167 2507 $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
cannam@167 2508 }
cannam@167 2509
cannam@167 2510 # func_lalib_unsafe_p file
cannam@167 2511 # True iff FILE is a libtool '.la' library or '.lo' object file.
cannam@167 2512 # This function implements the same check as func_lalib_p without
cannam@167 2513 # resorting to external programs. To this end, it redirects stdin and
cannam@167 2514 # closes it afterwards, without saving the original file descriptor.
cannam@167 2515 # As a safety measure, use it only where a negative result would be
cannam@167 2516 # fatal anyway. Works if 'file' does not exist.
cannam@167 2517 func_lalib_unsafe_p ()
cannam@167 2518 {
cannam@167 2519 lalib_p=no
cannam@167 2520 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
cannam@167 2521 for lalib_p_l in 1 2 3 4
cannam@167 2522 do
cannam@167 2523 read lalib_p_line
cannam@167 2524 case $lalib_p_line in
cannam@167 2525 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
cannam@167 2526 esac
cannam@167 2527 done
cannam@167 2528 exec 0<&5 5<&-
cannam@167 2529 fi
cannam@167 2530 test yes = "$lalib_p"
cannam@167 2531 }
cannam@167 2532
cannam@167 2533 # func_ltwrapper_script_p file
cannam@167 2534 # True iff FILE is a libtool wrapper script
cannam@167 2535 # This function is only a basic sanity check; it will hardly flush out
cannam@167 2536 # determined imposters.
cannam@167 2537 func_ltwrapper_script_p ()
cannam@167 2538 {
cannam@167 2539 test -f "$1" &&
cannam@167 2540 $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
cannam@167 2541 }
cannam@167 2542
cannam@167 2543 # func_ltwrapper_executable_p file
cannam@167 2544 # True iff FILE is a libtool wrapper executable
cannam@167 2545 # This function is only a basic sanity check; it will hardly flush out
cannam@167 2546 # determined imposters.
cannam@167 2547 func_ltwrapper_executable_p ()
cannam@167 2548 {
cannam@167 2549 func_ltwrapper_exec_suffix=
cannam@167 2550 case $1 in
cannam@167 2551 *.exe) ;;
cannam@167 2552 *) func_ltwrapper_exec_suffix=.exe ;;
cannam@167 2553 esac
cannam@167 2554 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
cannam@167 2555 }
cannam@167 2556
cannam@167 2557 # func_ltwrapper_scriptname file
cannam@167 2558 # Assumes file is an ltwrapper_executable
cannam@167 2559 # uses $file to determine the appropriate filename for a
cannam@167 2560 # temporary ltwrapper_script.
cannam@167 2561 func_ltwrapper_scriptname ()
cannam@167 2562 {
cannam@167 2563 func_dirname_and_basename "$1" "" "."
cannam@167 2564 func_stripname '' '.exe' "$func_basename_result"
cannam@167 2565 func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
cannam@167 2566 }
cannam@167 2567
cannam@167 2568 # func_ltwrapper_p file
cannam@167 2569 # True iff FILE is a libtool wrapper script or wrapper executable
cannam@167 2570 # This function is only a basic sanity check; it will hardly flush out
cannam@167 2571 # determined imposters.
cannam@167 2572 func_ltwrapper_p ()
cannam@167 2573 {
cannam@167 2574 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
cannam@167 2575 }
cannam@167 2576
cannam@167 2577
cannam@167 2578 # func_execute_cmds commands fail_cmd
cannam@167 2579 # Execute tilde-delimited COMMANDS.
cannam@167 2580 # If FAIL_CMD is given, eval that upon failure.
cannam@167 2581 # FAIL_CMD may read-access the current command in variable CMD!
cannam@167 2582 func_execute_cmds ()
cannam@167 2583 {
cannam@167 2584 $debug_cmd
cannam@167 2585
cannam@167 2586 save_ifs=$IFS; IFS='~'
cannam@167 2587 for cmd in $1; do
cannam@167 2588 IFS=$sp$nl
cannam@167 2589 eval cmd=\"$cmd\"
cannam@167 2590 IFS=$save_ifs
cannam@167 2591 func_show_eval "$cmd" "${2-:}"
cannam@167 2592 done
cannam@167 2593 IFS=$save_ifs
cannam@167 2594 }
cannam@167 2595
cannam@167 2596
cannam@167 2597 # func_source file
cannam@167 2598 # Source FILE, adding directory component if necessary.
cannam@167 2599 # Note that it is not necessary on cygwin/mingw to append a dot to
cannam@167 2600 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
cannam@167 2601 # behavior happens only for exec(3), not for open(2)! Also, sourcing
cannam@167 2602 # 'FILE.' does not work on cygwin managed mounts.
cannam@167 2603 func_source ()
cannam@167 2604 {
cannam@167 2605 $debug_cmd
cannam@167 2606
cannam@167 2607 case $1 in
cannam@167 2608 */* | *\\*) . "$1" ;;
cannam@167 2609 *) . "./$1" ;;
cannam@167 2610 esac
cannam@167 2611 }
cannam@167 2612
cannam@167 2613
cannam@167 2614 # func_resolve_sysroot PATH
cannam@167 2615 # Replace a leading = in PATH with a sysroot. Store the result into
cannam@167 2616 # func_resolve_sysroot_result
cannam@167 2617 func_resolve_sysroot ()
cannam@167 2618 {
cannam@167 2619 func_resolve_sysroot_result=$1
cannam@167 2620 case $func_resolve_sysroot_result in
cannam@167 2621 =*)
cannam@167 2622 func_stripname '=' '' "$func_resolve_sysroot_result"
cannam@167 2623 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
cannam@167 2624 ;;
cannam@167 2625 esac
cannam@167 2626 }
cannam@167 2627
cannam@167 2628 # func_replace_sysroot PATH
cannam@167 2629 # If PATH begins with the sysroot, replace it with = and
cannam@167 2630 # store the result into func_replace_sysroot_result.
cannam@167 2631 func_replace_sysroot ()
cannam@167 2632 {
cannam@167 2633 case $lt_sysroot:$1 in
cannam@167 2634 ?*:"$lt_sysroot"*)
cannam@167 2635 func_stripname "$lt_sysroot" '' "$1"
cannam@167 2636 func_replace_sysroot_result='='$func_stripname_result
cannam@167 2637 ;;
cannam@167 2638 *)
cannam@167 2639 # Including no sysroot.
cannam@167 2640 func_replace_sysroot_result=$1
cannam@167 2641 ;;
cannam@167 2642 esac
cannam@167 2643 }
cannam@167 2644
cannam@167 2645 # func_infer_tag arg
cannam@167 2646 # Infer tagged configuration to use if any are available and
cannam@167 2647 # if one wasn't chosen via the "--tag" command line option.
cannam@167 2648 # Only attempt this if the compiler in the base compile
cannam@167 2649 # command doesn't match the default compiler.
cannam@167 2650 # arg is usually of the form 'gcc ...'
cannam@167 2651 func_infer_tag ()
cannam@167 2652 {
cannam@167 2653 $debug_cmd
cannam@167 2654
cannam@167 2655 if test -n "$available_tags" && test -z "$tagname"; then
cannam@167 2656 CC_quoted=
cannam@167 2657 for arg in $CC; do
cannam@167 2658 func_append_quoted CC_quoted "$arg"
cannam@167 2659 done
cannam@167 2660 CC_expanded=`func_echo_all $CC`
cannam@167 2661 CC_quoted_expanded=`func_echo_all $CC_quoted`
cannam@167 2662 case $@ in
cannam@167 2663 # Blanks in the command may have been stripped by the calling shell,
cannam@167 2664 # but not from the CC environment variable when configure was run.
cannam@167 2665 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
cannam@167 2666 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
cannam@167 2667 # Blanks at the start of $base_compile will cause this to fail
cannam@167 2668 # if we don't check for them as well.
cannam@167 2669 *)
cannam@167 2670 for z in $available_tags; do
cannam@167 2671 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
cannam@167 2672 # Evaluate the configuration.
cannam@167 2673 eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
cannam@167 2674 CC_quoted=
cannam@167 2675 for arg in $CC; do
cannam@167 2676 # Double-quote args containing other shell metacharacters.
cannam@167 2677 func_append_quoted CC_quoted "$arg"
cannam@167 2678 done
cannam@167 2679 CC_expanded=`func_echo_all $CC`
cannam@167 2680 CC_quoted_expanded=`func_echo_all $CC_quoted`
cannam@167 2681 case "$@ " in
cannam@167 2682 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
cannam@167 2683 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
cannam@167 2684 # The compiler in the base compile command matches
cannam@167 2685 # the one in the tagged configuration.
cannam@167 2686 # Assume this is the tagged configuration we want.
cannam@167 2687 tagname=$z
cannam@167 2688 break
cannam@167 2689 ;;
cannam@167 2690 esac
cannam@167 2691 fi
cannam@167 2692 done
cannam@167 2693 # If $tagname still isn't set, then no tagged configuration
cannam@167 2694 # was found and let the user know that the "--tag" command
cannam@167 2695 # line option must be used.
cannam@167 2696 if test -z "$tagname"; then
cannam@167 2697 func_echo "unable to infer tagged configuration"
cannam@167 2698 func_fatal_error "specify a tag with '--tag'"
cannam@167 2699 # else
cannam@167 2700 # func_verbose "using $tagname tagged configuration"
cannam@167 2701 fi
cannam@167 2702 ;;
cannam@167 2703 esac
cannam@167 2704 fi
cannam@167 2705 }
cannam@167 2706
cannam@167 2707
cannam@167 2708
cannam@167 2709 # func_write_libtool_object output_name pic_name nonpic_name
cannam@167 2710 # Create a libtool object file (analogous to a ".la" file),
cannam@167 2711 # but don't create it if we're doing a dry run.
cannam@167 2712 func_write_libtool_object ()
cannam@167 2713 {
cannam@167 2714 write_libobj=$1
cannam@167 2715 if test yes = "$build_libtool_libs"; then
cannam@167 2716 write_lobj=\'$2\'
cannam@167 2717 else
cannam@167 2718 write_lobj=none
cannam@167 2719 fi
cannam@167 2720
cannam@167 2721 if test yes = "$build_old_libs"; then
cannam@167 2722 write_oldobj=\'$3\'
cannam@167 2723 else
cannam@167 2724 write_oldobj=none
cannam@167 2725 fi
cannam@167 2726
cannam@167 2727 $opt_dry_run || {
cannam@167 2728 cat >${write_libobj}T <<EOF
cannam@167 2729 # $write_libobj - a libtool object file
cannam@167 2730 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
cannam@167 2731 #
cannam@167 2732 # Please DO NOT delete this file!
cannam@167 2733 # It is necessary for linking the library.
cannam@167 2734
cannam@167 2735 # Name of the PIC object.
cannam@167 2736 pic_object=$write_lobj
cannam@167 2737
cannam@167 2738 # Name of the non-PIC object
cannam@167 2739 non_pic_object=$write_oldobj
cannam@167 2740
cannam@167 2741 EOF
cannam@167 2742 $MV "${write_libobj}T" "$write_libobj"
cannam@167 2743 }
cannam@167 2744 }
cannam@167 2745
cannam@167 2746
cannam@167 2747 ##################################################
cannam@167 2748 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
cannam@167 2749 ##################################################
cannam@167 2750
cannam@167 2751 # func_convert_core_file_wine_to_w32 ARG
cannam@167 2752 # Helper function used by file name conversion functions when $build is *nix,
cannam@167 2753 # and $host is mingw, cygwin, or some other w32 environment. Relies on a
cannam@167 2754 # correctly configured wine environment available, with the winepath program
cannam@167 2755 # in $build's $PATH.
cannam@167 2756 #
cannam@167 2757 # ARG is the $build file name to be converted to w32 format.
cannam@167 2758 # Result is available in $func_convert_core_file_wine_to_w32_result, and will
cannam@167 2759 # be empty on error (or when ARG is empty)
cannam@167 2760 func_convert_core_file_wine_to_w32 ()
cannam@167 2761 {
cannam@167 2762 $debug_cmd
cannam@167 2763
cannam@167 2764 func_convert_core_file_wine_to_w32_result=$1
cannam@167 2765 if test -n "$1"; then
cannam@167 2766 # Unfortunately, winepath does not exit with a non-zero error code, so we
cannam@167 2767 # are forced to check the contents of stdout. On the other hand, if the
cannam@167 2768 # command is not found, the shell will set an exit code of 127 and print
cannam@167 2769 # *an error message* to stdout. So we must check for both error code of
cannam@167 2770 # zero AND non-empty stdout, which explains the odd construction:
cannam@167 2771 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
cannam@167 2772 if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
cannam@167 2773 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
cannam@167 2774 $SED -e "$sed_naive_backslashify"`
cannam@167 2775 else
cannam@167 2776 func_convert_core_file_wine_to_w32_result=
cannam@167 2777 fi
cannam@167 2778 fi
cannam@167 2779 }
cannam@167 2780 # end: func_convert_core_file_wine_to_w32
cannam@167 2781
cannam@167 2782
cannam@167 2783 # func_convert_core_path_wine_to_w32 ARG
cannam@167 2784 # Helper function used by path conversion functions when $build is *nix, and
cannam@167 2785 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly
cannam@167 2786 # configured wine environment available, with the winepath program in $build's
cannam@167 2787 # $PATH. Assumes ARG has no leading or trailing path separator characters.
cannam@167 2788 #
cannam@167 2789 # ARG is path to be converted from $build format to win32.
cannam@167 2790 # Result is available in $func_convert_core_path_wine_to_w32_result.
cannam@167 2791 # Unconvertible file (directory) names in ARG are skipped; if no directory names
cannam@167 2792 # are convertible, then the result may be empty.
cannam@167 2793 func_convert_core_path_wine_to_w32 ()
cannam@167 2794 {
cannam@167 2795 $debug_cmd
cannam@167 2796
cannam@167 2797 # unfortunately, winepath doesn't convert paths, only file names
cannam@167 2798 func_convert_core_path_wine_to_w32_result=
cannam@167 2799 if test -n "$1"; then
cannam@167 2800 oldIFS=$IFS
cannam@167 2801 IFS=:
cannam@167 2802 for func_convert_core_path_wine_to_w32_f in $1; do
cannam@167 2803 IFS=$oldIFS
cannam@167 2804 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
cannam@167 2805 if test -n "$func_convert_core_file_wine_to_w32_result"; then
cannam@167 2806 if test -z "$func_convert_core_path_wine_to_w32_result"; then
cannam@167 2807 func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
cannam@167 2808 else
cannam@167 2809 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
cannam@167 2810 fi
cannam@167 2811 fi
cannam@167 2812 done
cannam@167 2813 IFS=$oldIFS
cannam@167 2814 fi
cannam@167 2815 }
cannam@167 2816 # end: func_convert_core_path_wine_to_w32
cannam@167 2817
cannam@167 2818
cannam@167 2819 # func_cygpath ARGS...
cannam@167 2820 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
cannam@167 2821 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
cannam@167 2822 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
cannam@167 2823 # (2), returns the Cygwin file name or path in func_cygpath_result (input
cannam@167 2824 # file name or path is assumed to be in w32 format, as previously converted
cannam@167 2825 # from $build's *nix or MSYS format). In case (3), returns the w32 file name
cannam@167 2826 # or path in func_cygpath_result (input file name or path is assumed to be in
cannam@167 2827 # Cygwin format). Returns an empty string on error.
cannam@167 2828 #
cannam@167 2829 # ARGS are passed to cygpath, with the last one being the file name or path to
cannam@167 2830 # be converted.
cannam@167 2831 #
cannam@167 2832 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
cannam@167 2833 # environment variable; do not put it in $PATH.
cannam@167 2834 func_cygpath ()
cannam@167 2835 {
cannam@167 2836 $debug_cmd
cannam@167 2837
cannam@167 2838 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
cannam@167 2839 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
cannam@167 2840 if test "$?" -ne 0; then
cannam@167 2841 # on failure, ensure result is empty
cannam@167 2842 func_cygpath_result=
cannam@167 2843 fi
cannam@167 2844 else
cannam@167 2845 func_cygpath_result=
cannam@167 2846 func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
cannam@167 2847 fi
cannam@167 2848 }
cannam@167 2849 #end: func_cygpath
cannam@167 2850
cannam@167 2851
cannam@167 2852 # func_convert_core_msys_to_w32 ARG
cannam@167 2853 # Convert file name or path ARG from MSYS format to w32 format. Return
cannam@167 2854 # result in func_convert_core_msys_to_w32_result.
cannam@167 2855 func_convert_core_msys_to_w32 ()
cannam@167 2856 {
cannam@167 2857 $debug_cmd
cannam@167 2858
cannam@167 2859 # awkward: cmd appends spaces to result
cannam@167 2860 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
cannam@167 2861 $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
cannam@167 2862 }
cannam@167 2863 #end: func_convert_core_msys_to_w32
cannam@167 2864
cannam@167 2865
cannam@167 2866 # func_convert_file_check ARG1 ARG2
cannam@167 2867 # Verify that ARG1 (a file name in $build format) was converted to $host
cannam@167 2868 # format in ARG2. Otherwise, emit an error message, but continue (resetting
cannam@167 2869 # func_to_host_file_result to ARG1).
cannam@167 2870 func_convert_file_check ()
cannam@167 2871 {
cannam@167 2872 $debug_cmd
cannam@167 2873
cannam@167 2874 if test -z "$2" && test -n "$1"; then
cannam@167 2875 func_error "Could not determine host file name corresponding to"
cannam@167 2876 func_error " '$1'"
cannam@167 2877 func_error "Continuing, but uninstalled executables may not work."
cannam@167 2878 # Fallback:
cannam@167 2879 func_to_host_file_result=$1
cannam@167 2880 fi
cannam@167 2881 }
cannam@167 2882 # end func_convert_file_check
cannam@167 2883
cannam@167 2884
cannam@167 2885 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
cannam@167 2886 # Verify that FROM_PATH (a path in $build format) was converted to $host
cannam@167 2887 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
cannam@167 2888 # func_to_host_file_result to a simplistic fallback value (see below).
cannam@167 2889 func_convert_path_check ()
cannam@167 2890 {
cannam@167 2891 $debug_cmd
cannam@167 2892
cannam@167 2893 if test -z "$4" && test -n "$3"; then
cannam@167 2894 func_error "Could not determine the host path corresponding to"
cannam@167 2895 func_error " '$3'"
cannam@167 2896 func_error "Continuing, but uninstalled executables may not work."
cannam@167 2897 # Fallback. This is a deliberately simplistic "conversion" and
cannam@167 2898 # should not be "improved". See libtool.info.
cannam@167 2899 if test "x$1" != "x$2"; then
cannam@167 2900 lt_replace_pathsep_chars="s|$1|$2|g"
cannam@167 2901 func_to_host_path_result=`echo "$3" |
cannam@167 2902 $SED -e "$lt_replace_pathsep_chars"`
cannam@167 2903 else
cannam@167 2904 func_to_host_path_result=$3
cannam@167 2905 fi
cannam@167 2906 fi
cannam@167 2907 }
cannam@167 2908 # end func_convert_path_check
cannam@167 2909
cannam@167 2910
cannam@167 2911 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
cannam@167 2912 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
cannam@167 2913 # and appending REPL if ORIG matches BACKPAT.
cannam@167 2914 func_convert_path_front_back_pathsep ()
cannam@167 2915 {
cannam@167 2916 $debug_cmd
cannam@167 2917
cannam@167 2918 case $4 in
cannam@167 2919 $1 ) func_to_host_path_result=$3$func_to_host_path_result
cannam@167 2920 ;;
cannam@167 2921 esac
cannam@167 2922 case $4 in
cannam@167 2923 $2 ) func_append func_to_host_path_result "$3"
cannam@167 2924 ;;
cannam@167 2925 esac
cannam@167 2926 }
cannam@167 2927 # end func_convert_path_front_back_pathsep
cannam@167 2928
cannam@167 2929
cannam@167 2930 ##################################################
cannam@167 2931 # $build to $host FILE NAME CONVERSION FUNCTIONS #
cannam@167 2932 ##################################################
cannam@167 2933 # invoked via '$to_host_file_cmd ARG'
cannam@167 2934 #
cannam@167 2935 # In each case, ARG is the path to be converted from $build to $host format.
cannam@167 2936 # Result will be available in $func_to_host_file_result.
cannam@167 2937
cannam@167 2938
cannam@167 2939 # func_to_host_file ARG
cannam@167 2940 # Converts the file name ARG from $build format to $host format. Return result
cannam@167 2941 # in func_to_host_file_result.
cannam@167 2942 func_to_host_file ()
cannam@167 2943 {
cannam@167 2944 $debug_cmd
cannam@167 2945
cannam@167 2946 $to_host_file_cmd "$1"
cannam@167 2947 }
cannam@167 2948 # end func_to_host_file
cannam@167 2949
cannam@167 2950
cannam@167 2951 # func_to_tool_file ARG LAZY
cannam@167 2952 # converts the file name ARG from $build format to toolchain format. Return
cannam@167 2953 # result in func_to_tool_file_result. If the conversion in use is listed
cannam@167 2954 # in (the comma separated) LAZY, no conversion takes place.
cannam@167 2955 func_to_tool_file ()
cannam@167 2956 {
cannam@167 2957 $debug_cmd
cannam@167 2958
cannam@167 2959 case ,$2, in
cannam@167 2960 *,"$to_tool_file_cmd",*)
cannam@167 2961 func_to_tool_file_result=$1
cannam@167 2962 ;;
cannam@167 2963 *)
cannam@167 2964 $to_tool_file_cmd "$1"
cannam@167 2965 func_to_tool_file_result=$func_to_host_file_result
cannam@167 2966 ;;
cannam@167 2967 esac
cannam@167 2968 }
cannam@167 2969 # end func_to_tool_file
cannam@167 2970
cannam@167 2971
cannam@167 2972 # func_convert_file_noop ARG
cannam@167 2973 # Copy ARG to func_to_host_file_result.
cannam@167 2974 func_convert_file_noop ()
cannam@167 2975 {
cannam@167 2976 func_to_host_file_result=$1
cannam@167 2977 }
cannam@167 2978 # end func_convert_file_noop
cannam@167 2979
cannam@167 2980
cannam@167 2981 # func_convert_file_msys_to_w32 ARG
cannam@167 2982 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
cannam@167 2983 # conversion to w32 is not available inside the cwrapper. Returns result in
cannam@167 2984 # func_to_host_file_result.
cannam@167 2985 func_convert_file_msys_to_w32 ()
cannam@167 2986 {
cannam@167 2987 $debug_cmd
cannam@167 2988
cannam@167 2989 func_to_host_file_result=$1
cannam@167 2990 if test -n "$1"; then
cannam@167 2991 func_convert_core_msys_to_w32 "$1"
cannam@167 2992 func_to_host_file_result=$func_convert_core_msys_to_w32_result
cannam@167 2993 fi
cannam@167 2994 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@167 2995 }
cannam@167 2996 # end func_convert_file_msys_to_w32
cannam@167 2997
cannam@167 2998
cannam@167 2999 # func_convert_file_cygwin_to_w32 ARG
cannam@167 3000 # Convert file name ARG from Cygwin to w32 format. Returns result in
cannam@167 3001 # func_to_host_file_result.
cannam@167 3002 func_convert_file_cygwin_to_w32 ()
cannam@167 3003 {
cannam@167 3004 $debug_cmd
cannam@167 3005
cannam@167 3006 func_to_host_file_result=$1
cannam@167 3007 if test -n "$1"; then
cannam@167 3008 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
cannam@167 3009 # LT_CYGPATH in this case.
cannam@167 3010 func_to_host_file_result=`cygpath -m "$1"`
cannam@167 3011 fi
cannam@167 3012 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@167 3013 }
cannam@167 3014 # end func_convert_file_cygwin_to_w32
cannam@167 3015
cannam@167 3016
cannam@167 3017 # func_convert_file_nix_to_w32 ARG
cannam@167 3018 # Convert file name ARG from *nix to w32 format. Requires a wine environment
cannam@167 3019 # and a working winepath. Returns result in func_to_host_file_result.
cannam@167 3020 func_convert_file_nix_to_w32 ()
cannam@167 3021 {
cannam@167 3022 $debug_cmd
cannam@167 3023
cannam@167 3024 func_to_host_file_result=$1
cannam@167 3025 if test -n "$1"; then
cannam@167 3026 func_convert_core_file_wine_to_w32 "$1"
cannam@167 3027 func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
cannam@167 3028 fi
cannam@167 3029 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@167 3030 }
cannam@167 3031 # end func_convert_file_nix_to_w32
cannam@167 3032
cannam@167 3033
cannam@167 3034 # func_convert_file_msys_to_cygwin ARG
cannam@167 3035 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
cannam@167 3036 # Returns result in func_to_host_file_result.
cannam@167 3037 func_convert_file_msys_to_cygwin ()
cannam@167 3038 {
cannam@167 3039 $debug_cmd
cannam@167 3040
cannam@167 3041 func_to_host_file_result=$1
cannam@167 3042 if test -n "$1"; then
cannam@167 3043 func_convert_core_msys_to_w32 "$1"
cannam@167 3044 func_cygpath -u "$func_convert_core_msys_to_w32_result"
cannam@167 3045 func_to_host_file_result=$func_cygpath_result
cannam@167 3046 fi
cannam@167 3047 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@167 3048 }
cannam@167 3049 # end func_convert_file_msys_to_cygwin
cannam@167 3050
cannam@167 3051
cannam@167 3052 # func_convert_file_nix_to_cygwin ARG
cannam@167 3053 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
cannam@167 3054 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
cannam@167 3055 # in func_to_host_file_result.
cannam@167 3056 func_convert_file_nix_to_cygwin ()
cannam@167 3057 {
cannam@167 3058 $debug_cmd
cannam@167 3059
cannam@167 3060 func_to_host_file_result=$1
cannam@167 3061 if test -n "$1"; then
cannam@167 3062 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
cannam@167 3063 func_convert_core_file_wine_to_w32 "$1"
cannam@167 3064 func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
cannam@167 3065 func_to_host_file_result=$func_cygpath_result
cannam@167 3066 fi
cannam@167 3067 func_convert_file_check "$1" "$func_to_host_file_result"
cannam@167 3068 }
cannam@167 3069 # end func_convert_file_nix_to_cygwin
cannam@167 3070
cannam@167 3071
cannam@167 3072 #############################################
cannam@167 3073 # $build to $host PATH CONVERSION FUNCTIONS #
cannam@167 3074 #############################################
cannam@167 3075 # invoked via '$to_host_path_cmd ARG'
cannam@167 3076 #
cannam@167 3077 # In each case, ARG is the path to be converted from $build to $host format.
cannam@167 3078 # The result will be available in $func_to_host_path_result.
cannam@167 3079 #
cannam@167 3080 # Path separators are also converted from $build format to $host format. If
cannam@167 3081 # ARG begins or ends with a path separator character, it is preserved (but
cannam@167 3082 # converted to $host format) on output.
cannam@167 3083 #
cannam@167 3084 # All path conversion functions are named using the following convention:
cannam@167 3085 # file name conversion function : func_convert_file_X_to_Y ()
cannam@167 3086 # path conversion function : func_convert_path_X_to_Y ()
cannam@167 3087 # where, for any given $build/$host combination the 'X_to_Y' value is the
cannam@167 3088 # same. If conversion functions are added for new $build/$host combinations,
cannam@167 3089 # the two new functions must follow this pattern, or func_init_to_host_path_cmd
cannam@167 3090 # will break.
cannam@167 3091
cannam@167 3092
cannam@167 3093 # func_init_to_host_path_cmd
cannam@167 3094 # Ensures that function "pointer" variable $to_host_path_cmd is set to the
cannam@167 3095 # appropriate value, based on the value of $to_host_file_cmd.
cannam@167 3096 to_host_path_cmd=
cannam@167 3097 func_init_to_host_path_cmd ()
cannam@167 3098 {
cannam@167 3099 $debug_cmd
cannam@167 3100
cannam@167 3101 if test -z "$to_host_path_cmd"; then
cannam@167 3102 func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
cannam@167 3103 to_host_path_cmd=func_convert_path_$func_stripname_result
cannam@167 3104 fi
cannam@167 3105 }
cannam@167 3106
cannam@167 3107
cannam@167 3108 # func_to_host_path ARG
cannam@167 3109 # Converts the path ARG from $build format to $host format. Return result
cannam@167 3110 # in func_to_host_path_result.
cannam@167 3111 func_to_host_path ()
cannam@167 3112 {
cannam@167 3113 $debug_cmd
cannam@167 3114
cannam@167 3115 func_init_to_host_path_cmd
cannam@167 3116 $to_host_path_cmd "$1"
cannam@167 3117 }
cannam@167 3118 # end func_to_host_path
cannam@167 3119
cannam@167 3120
cannam@167 3121 # func_convert_path_noop ARG
cannam@167 3122 # Copy ARG to func_to_host_path_result.
cannam@167 3123 func_convert_path_noop ()
cannam@167 3124 {
cannam@167 3125 func_to_host_path_result=$1
cannam@167 3126 }
cannam@167 3127 # end func_convert_path_noop
cannam@167 3128
cannam@167 3129
cannam@167 3130 # func_convert_path_msys_to_w32 ARG
cannam@167 3131 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
cannam@167 3132 # conversion to w32 is not available inside the cwrapper. Returns result in
cannam@167 3133 # func_to_host_path_result.
cannam@167 3134 func_convert_path_msys_to_w32 ()
cannam@167 3135 {
cannam@167 3136 $debug_cmd
cannam@167 3137
cannam@167 3138 func_to_host_path_result=$1
cannam@167 3139 if test -n "$1"; then
cannam@167 3140 # Remove leading and trailing path separator characters from ARG. MSYS
cannam@167 3141 # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
cannam@167 3142 # and winepath ignores them completely.
cannam@167 3143 func_stripname : : "$1"
cannam@167 3144 func_to_host_path_tmp1=$func_stripname_result
cannam@167 3145 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
cannam@167 3146 func_to_host_path_result=$func_convert_core_msys_to_w32_result
cannam@167 3147 func_convert_path_check : ";" \
cannam@167 3148 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@167 3149 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
cannam@167 3150 fi
cannam@167 3151 }
cannam@167 3152 # end func_convert_path_msys_to_w32
cannam@167 3153
cannam@167 3154
cannam@167 3155 # func_convert_path_cygwin_to_w32 ARG
cannam@167 3156 # Convert path ARG from Cygwin to w32 format. Returns result in
cannam@167 3157 # func_to_host_file_result.
cannam@167 3158 func_convert_path_cygwin_to_w32 ()
cannam@167 3159 {
cannam@167 3160 $debug_cmd
cannam@167 3161
cannam@167 3162 func_to_host_path_result=$1
cannam@167 3163 if test -n "$1"; then
cannam@167 3164 # See func_convert_path_msys_to_w32:
cannam@167 3165 func_stripname : : "$1"
cannam@167 3166 func_to_host_path_tmp1=$func_stripname_result
cannam@167 3167 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
cannam@167 3168 func_convert_path_check : ";" \
cannam@167 3169 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@167 3170 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
cannam@167 3171 fi
cannam@167 3172 }
cannam@167 3173 # end func_convert_path_cygwin_to_w32
cannam@167 3174
cannam@167 3175
cannam@167 3176 # func_convert_path_nix_to_w32 ARG
cannam@167 3177 # Convert path ARG from *nix to w32 format. Requires a wine environment and
cannam@167 3178 # a working winepath. Returns result in func_to_host_file_result.
cannam@167 3179 func_convert_path_nix_to_w32 ()
cannam@167 3180 {
cannam@167 3181 $debug_cmd
cannam@167 3182
cannam@167 3183 func_to_host_path_result=$1
cannam@167 3184 if test -n "$1"; then
cannam@167 3185 # See func_convert_path_msys_to_w32:
cannam@167 3186 func_stripname : : "$1"
cannam@167 3187 func_to_host_path_tmp1=$func_stripname_result
cannam@167 3188 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
cannam@167 3189 func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
cannam@167 3190 func_convert_path_check : ";" \
cannam@167 3191 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@167 3192 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
cannam@167 3193 fi
cannam@167 3194 }
cannam@167 3195 # end func_convert_path_nix_to_w32
cannam@167 3196
cannam@167 3197
cannam@167 3198 # func_convert_path_msys_to_cygwin ARG
cannam@167 3199 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
cannam@167 3200 # Returns result in func_to_host_file_result.
cannam@167 3201 func_convert_path_msys_to_cygwin ()
cannam@167 3202 {
cannam@167 3203 $debug_cmd
cannam@167 3204
cannam@167 3205 func_to_host_path_result=$1
cannam@167 3206 if test -n "$1"; then
cannam@167 3207 # See func_convert_path_msys_to_w32:
cannam@167 3208 func_stripname : : "$1"
cannam@167 3209 func_to_host_path_tmp1=$func_stripname_result
cannam@167 3210 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
cannam@167 3211 func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
cannam@167 3212 func_to_host_path_result=$func_cygpath_result
cannam@167 3213 func_convert_path_check : : \
cannam@167 3214 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@167 3215 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
cannam@167 3216 fi
cannam@167 3217 }
cannam@167 3218 # end func_convert_path_msys_to_cygwin
cannam@167 3219
cannam@167 3220
cannam@167 3221 # func_convert_path_nix_to_cygwin ARG
cannam@167 3222 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
cannam@167 3223 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
cannam@167 3224 # func_to_host_file_result.
cannam@167 3225 func_convert_path_nix_to_cygwin ()
cannam@167 3226 {
cannam@167 3227 $debug_cmd
cannam@167 3228
cannam@167 3229 func_to_host_path_result=$1
cannam@167 3230 if test -n "$1"; then
cannam@167 3231 # Remove leading and trailing path separator characters from
cannam@167 3232 # ARG. msys behavior is inconsistent here, cygpath turns them
cannam@167 3233 # into '.;' and ';.', and winepath ignores them completely.
cannam@167 3234 func_stripname : : "$1"
cannam@167 3235 func_to_host_path_tmp1=$func_stripname_result
cannam@167 3236 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
cannam@167 3237 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
cannam@167 3238 func_to_host_path_result=$func_cygpath_result
cannam@167 3239 func_convert_path_check : : \
cannam@167 3240 "$func_to_host_path_tmp1" "$func_to_host_path_result"
cannam@167 3241 func_convert_path_front_back_pathsep ":*" "*:" : "$1"
cannam@167 3242 fi
cannam@167 3243 }
cannam@167 3244 # end func_convert_path_nix_to_cygwin
cannam@167 3245
cannam@167 3246
cannam@167 3247 # func_dll_def_p FILE
cannam@167 3248 # True iff FILE is a Windows DLL '.def' file.
cannam@167 3249 # Keep in sync with _LT_DLL_DEF_P in libtool.m4
cannam@167 3250 func_dll_def_p ()
cannam@167 3251 {
cannam@167 3252 $debug_cmd
cannam@167 3253
cannam@167 3254 func_dll_def_p_tmp=`$SED -n \
cannam@167 3255 -e 's/^[ ]*//' \
cannam@167 3256 -e '/^\(;.*\)*$/d' \
cannam@167 3257 -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
cannam@167 3258 -e q \
cannam@167 3259 "$1"`
cannam@167 3260 test DEF = "$func_dll_def_p_tmp"
cannam@167 3261 }
cannam@167 3262
cannam@167 3263
cannam@167 3264 # func_mode_compile arg...
cannam@167 3265 func_mode_compile ()
cannam@167 3266 {
cannam@167 3267 $debug_cmd
cannam@167 3268
cannam@167 3269 # Get the compilation command and the source file.
cannam@167 3270 base_compile=
cannam@167 3271 srcfile=$nonopt # always keep a non-empty value in "srcfile"
cannam@167 3272 suppress_opt=yes
cannam@167 3273 suppress_output=
cannam@167 3274 arg_mode=normal
cannam@167 3275 libobj=
cannam@167 3276 later=
cannam@167 3277 pie_flag=
cannam@167 3278
cannam@167 3279 for arg
cannam@167 3280 do
cannam@167 3281 case $arg_mode in
cannam@167 3282 arg )
cannam@167 3283 # do not "continue". Instead, add this to base_compile
cannam@167 3284 lastarg=$arg
cannam@167 3285 arg_mode=normal
cannam@167 3286 ;;
cannam@167 3287
cannam@167 3288 target )
cannam@167 3289 libobj=$arg
cannam@167 3290 arg_mode=normal
cannam@167 3291 continue
cannam@167 3292 ;;
cannam@167 3293
cannam@167 3294 normal )
cannam@167 3295 # Accept any command-line options.
cannam@167 3296 case $arg in
cannam@167 3297 -o)
cannam@167 3298 test -n "$libobj" && \
cannam@167 3299 func_fatal_error "you cannot specify '-o' more than once"
cannam@167 3300 arg_mode=target
cannam@167 3301 continue
cannam@167 3302 ;;
cannam@167 3303
cannam@167 3304 -pie | -fpie | -fPIE)
cannam@167 3305 func_append pie_flag " $arg"
cannam@167 3306 continue
cannam@167 3307 ;;
cannam@167 3308
cannam@167 3309 -shared | -static | -prefer-pic | -prefer-non-pic)
cannam@167 3310 func_append later " $arg"
cannam@167 3311 continue
cannam@167 3312 ;;
cannam@167 3313
cannam@167 3314 -no-suppress)
cannam@167 3315 suppress_opt=no
cannam@167 3316 continue
cannam@167 3317 ;;
cannam@167 3318
cannam@167 3319 -Xcompiler)
cannam@167 3320 arg_mode=arg # the next one goes into the "base_compile" arg list
cannam@167 3321 continue # The current "srcfile" will either be retained or
cannam@167 3322 ;; # replaced later. I would guess that would be a bug.
cannam@167 3323
cannam@167 3324 -Wc,*)
cannam@167 3325 func_stripname '-Wc,' '' "$arg"
cannam@167 3326 args=$func_stripname_result
cannam@167 3327 lastarg=
cannam@167 3328 save_ifs=$IFS; IFS=,
cannam@167 3329 for arg in $args; do
cannam@167 3330 IFS=$save_ifs
cannam@167 3331 func_append_quoted lastarg "$arg"
cannam@167 3332 done
cannam@167 3333 IFS=$save_ifs
cannam@167 3334 func_stripname ' ' '' "$lastarg"
cannam@167 3335 lastarg=$func_stripname_result
cannam@167 3336
cannam@167 3337 # Add the arguments to base_compile.
cannam@167 3338 func_append base_compile " $lastarg"
cannam@167 3339 continue
cannam@167 3340 ;;
cannam@167 3341
cannam@167 3342 *)
cannam@167 3343 # Accept the current argument as the source file.
cannam@167 3344 # The previous "srcfile" becomes the current argument.
cannam@167 3345 #
cannam@167 3346 lastarg=$srcfile
cannam@167 3347 srcfile=$arg
cannam@167 3348 ;;
cannam@167 3349 esac # case $arg
cannam@167 3350 ;;
cannam@167 3351 esac # case $arg_mode
cannam@167 3352
cannam@167 3353 # Aesthetically quote the previous argument.
cannam@167 3354 func_append_quoted base_compile "$lastarg"
cannam@167 3355 done # for arg
cannam@167 3356
cannam@167 3357 case $arg_mode in
cannam@167 3358 arg)
cannam@167 3359 func_fatal_error "you must specify an argument for -Xcompile"
cannam@167 3360 ;;
cannam@167 3361 target)
cannam@167 3362 func_fatal_error "you must specify a target with '-o'"
cannam@167 3363 ;;
cannam@167 3364 *)
cannam@167 3365 # Get the name of the library object.
cannam@167 3366 test -z "$libobj" && {
cannam@167 3367 func_basename "$srcfile"
cannam@167 3368 libobj=$func_basename_result
cannam@167 3369 }
cannam@167 3370 ;;
cannam@167 3371 esac
cannam@167 3372
cannam@167 3373 # Recognize several different file suffixes.
cannam@167 3374 # If the user specifies -o file.o, it is replaced with file.lo
cannam@167 3375 case $libobj in
cannam@167 3376 *.[cCFSifmso] | \
cannam@167 3377 *.ada | *.adb | *.ads | *.asm | \
cannam@167 3378 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
cannam@167 3379 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
cannam@167 3380 func_xform "$libobj"
cannam@167 3381 libobj=$func_xform_result
cannam@167 3382 ;;
cannam@167 3383 esac
cannam@167 3384
cannam@167 3385 case $libobj in
cannam@167 3386 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
cannam@167 3387 *)
cannam@167 3388 func_fatal_error "cannot determine name of library object from '$libobj'"
cannam@167 3389 ;;
cannam@167 3390 esac
cannam@167 3391
cannam@167 3392 func_infer_tag $base_compile
cannam@167 3393
cannam@167 3394 for arg in $later; do
cannam@167 3395 case $arg in
cannam@167 3396 -shared)
cannam@167 3397 test yes = "$build_libtool_libs" \
cannam@167 3398 || func_fatal_configuration "cannot build a shared library"
cannam@167 3399 build_old_libs=no
cannam@167 3400 continue
cannam@167 3401 ;;
cannam@167 3402
cannam@167 3403 -static)
cannam@167 3404 build_libtool_libs=no
cannam@167 3405 build_old_libs=yes
cannam@167 3406 continue
cannam@167 3407 ;;
cannam@167 3408
cannam@167 3409 -prefer-pic)
cannam@167 3410 pic_mode=yes
cannam@167 3411 continue
cannam@167 3412 ;;
cannam@167 3413
cannam@167 3414 -prefer-non-pic)
cannam@167 3415 pic_mode=no
cannam@167 3416 continue
cannam@167 3417 ;;
cannam@167 3418 esac
cannam@167 3419 done
cannam@167 3420
cannam@167 3421 func_quote_for_eval "$libobj"
cannam@167 3422 test "X$libobj" != "X$func_quote_for_eval_result" \
cannam@167 3423 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
cannam@167 3424 && func_warning "libobj name '$libobj' may not contain shell special characters."
cannam@167 3425 func_dirname_and_basename "$obj" "/" ""
cannam@167 3426 objname=$func_basename_result
cannam@167 3427 xdir=$func_dirname_result
cannam@167 3428 lobj=$xdir$objdir/$objname
cannam@167 3429
cannam@167 3430 test -z "$base_compile" && \
cannam@167 3431 func_fatal_help "you must specify a compilation command"
cannam@167 3432
cannam@167 3433 # Delete any leftover library objects.
cannam@167 3434 if test yes = "$build_old_libs"; then
cannam@167 3435 removelist="$obj $lobj $libobj ${libobj}T"
cannam@167 3436 else
cannam@167 3437 removelist="$lobj $libobj ${libobj}T"
cannam@167 3438 fi
cannam@167 3439
cannam@167 3440 # On Cygwin there's no "real" PIC flag so we must build both object types
cannam@167 3441 case $host_os in
cannam@167 3442 cygwin* | mingw* | pw32* | os2* | cegcc*)
cannam@167 3443 pic_mode=default
cannam@167 3444 ;;
cannam@167 3445 esac
cannam@167 3446 if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
cannam@167 3447 # non-PIC code in shared libraries is not supported
cannam@167 3448 pic_mode=default
cannam@167 3449 fi
cannam@167 3450
cannam@167 3451 # Calculate the filename of the output object if compiler does
cannam@167 3452 # not support -o with -c
cannam@167 3453 if test no = "$compiler_c_o"; then
cannam@167 3454 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
cannam@167 3455 lockfile=$output_obj.lock
cannam@167 3456 else
cannam@167 3457 output_obj=
cannam@167 3458 need_locks=no
cannam@167 3459 lockfile=
cannam@167 3460 fi
cannam@167 3461
cannam@167 3462 # Lock this critical section if it is needed
cannam@167 3463 # We use this script file to make the link, it avoids creating a new file
cannam@167 3464 if test yes = "$need_locks"; then
cannam@167 3465 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
cannam@167 3466 func_echo "Waiting for $lockfile to be removed"
cannam@167 3467 sleep 2
cannam@167 3468 done
cannam@167 3469 elif test warn = "$need_locks"; then
cannam@167 3470 if test -f "$lockfile"; then
cannam@167 3471 $ECHO "\
cannam@167 3472 *** ERROR, $lockfile exists and contains:
cannam@167 3473 `cat $lockfile 2>/dev/null`
cannam@167 3474
cannam@167 3475 This indicates that another process is trying to use the same
cannam@167 3476 temporary object file, and libtool could not work around it because
cannam@167 3477 your compiler does not support '-c' and '-o' together. If you
cannam@167 3478 repeat this compilation, it may succeed, by chance, but you had better
cannam@167 3479 avoid parallel builds (make -j) in this platform, or get a better
cannam@167 3480 compiler."
cannam@167 3481
cannam@167 3482 $opt_dry_run || $RM $removelist
cannam@167 3483 exit $EXIT_FAILURE
cannam@167 3484 fi
cannam@167 3485 func_append removelist " $output_obj"
cannam@167 3486 $ECHO "$srcfile" > "$lockfile"
cannam@167 3487 fi
cannam@167 3488
cannam@167 3489 $opt_dry_run || $RM $removelist
cannam@167 3490 func_append removelist " $lockfile"
cannam@167 3491 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
cannam@167 3492
cannam@167 3493 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
cannam@167 3494 srcfile=$func_to_tool_file_result
cannam@167 3495 func_quote_for_eval "$srcfile"
cannam@167 3496 qsrcfile=$func_quote_for_eval_result
cannam@167 3497
cannam@167 3498 # Only build a PIC object if we are building libtool libraries.
cannam@167 3499 if test yes = "$build_libtool_libs"; then
cannam@167 3500 # Without this assignment, base_compile gets emptied.
cannam@167 3501 fbsd_hideous_sh_bug=$base_compile
cannam@167 3502
cannam@167 3503 if test no != "$pic_mode"; then
cannam@167 3504 command="$base_compile $qsrcfile $pic_flag"
cannam@167 3505 else
cannam@167 3506 # Don't build PIC code
cannam@167 3507 command="$base_compile $qsrcfile"
cannam@167 3508 fi
cannam@167 3509
cannam@167 3510 func_mkdir_p "$xdir$objdir"
cannam@167 3511
cannam@167 3512 if test -z "$output_obj"; then
cannam@167 3513 # Place PIC objects in $objdir
cannam@167 3514 func_append command " -o $lobj"
cannam@167 3515 fi
cannam@167 3516
cannam@167 3517 func_show_eval_locale "$command" \
cannam@167 3518 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
cannam@167 3519
cannam@167 3520 if test warn = "$need_locks" &&
cannam@167 3521 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
cannam@167 3522 $ECHO "\
cannam@167 3523 *** ERROR, $lockfile contains:
cannam@167 3524 `cat $lockfile 2>/dev/null`
cannam@167 3525
cannam@167 3526 but it should contain:
cannam@167 3527 $srcfile
cannam@167 3528
cannam@167 3529 This indicates that another process is trying to use the same
cannam@167 3530 temporary object file, and libtool could not work around it because
cannam@167 3531 your compiler does not support '-c' and '-o' together. If you
cannam@167 3532 repeat this compilation, it may succeed, by chance, but you had better
cannam@167 3533 avoid parallel builds (make -j) in this platform, or get a better
cannam@167 3534 compiler."
cannam@167 3535
cannam@167 3536 $opt_dry_run || $RM $removelist
cannam@167 3537 exit $EXIT_FAILURE
cannam@167 3538 fi
cannam@167 3539
cannam@167 3540 # Just move the object if needed, then go on to compile the next one
cannam@167 3541 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
cannam@167 3542 func_show_eval '$MV "$output_obj" "$lobj"' \
cannam@167 3543 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
cannam@167 3544 fi
cannam@167 3545
cannam@167 3546 # Allow error messages only from the first compilation.
cannam@167 3547 if test yes = "$suppress_opt"; then
cannam@167 3548 suppress_output=' >/dev/null 2>&1'
cannam@167 3549 fi
cannam@167 3550 fi
cannam@167 3551
cannam@167 3552 # Only build a position-dependent object if we build old libraries.
cannam@167 3553 if test yes = "$build_old_libs"; then
cannam@167 3554 if test yes != "$pic_mode"; then
cannam@167 3555 # Don't build PIC code
cannam@167 3556 command="$base_compile $qsrcfile$pie_flag"
cannam@167 3557 else
cannam@167 3558 command="$base_compile $qsrcfile $pic_flag"
cannam@167 3559 fi
cannam@167 3560 if test yes = "$compiler_c_o"; then
cannam@167 3561 func_append command " -o $obj"
cannam@167 3562 fi
cannam@167 3563
cannam@167 3564 # Suppress compiler output if we already did a PIC compilation.
cannam@167 3565 func_append command "$suppress_output"
cannam@167 3566 func_show_eval_locale "$command" \
cannam@167 3567 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
cannam@167 3568
cannam@167 3569 if test warn = "$need_locks" &&
cannam@167 3570 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
cannam@167 3571 $ECHO "\
cannam@167 3572 *** ERROR, $lockfile contains:
cannam@167 3573 `cat $lockfile 2>/dev/null`
cannam@167 3574
cannam@167 3575 but it should contain:
cannam@167 3576 $srcfile
cannam@167 3577
cannam@167 3578 This indicates that another process is trying to use the same
cannam@167 3579 temporary object file, and libtool could not work around it because
cannam@167 3580 your compiler does not support '-c' and '-o' together. If you
cannam@167 3581 repeat this compilation, it may succeed, by chance, but you had better
cannam@167 3582 avoid parallel builds (make -j) in this platform, or get a better
cannam@167 3583 compiler."
cannam@167 3584
cannam@167 3585 $opt_dry_run || $RM $removelist
cannam@167 3586 exit $EXIT_FAILURE
cannam@167 3587 fi
cannam@167 3588
cannam@167 3589 # Just move the object if needed
cannam@167 3590 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
cannam@167 3591 func_show_eval '$MV "$output_obj" "$obj"' \
cannam@167 3592 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
cannam@167 3593 fi
cannam@167 3594 fi
cannam@167 3595
cannam@167 3596 $opt_dry_run || {
cannam@167 3597 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
cannam@167 3598
cannam@167 3599 # Unlock the critical section if it was locked
cannam@167 3600 if test no != "$need_locks"; then
cannam@167 3601 removelist=$lockfile
cannam@167 3602 $RM "$lockfile"
cannam@167 3603 fi
cannam@167 3604 }
cannam@167 3605
cannam@167 3606 exit $EXIT_SUCCESS
cannam@167 3607 }
cannam@167 3608
cannam@167 3609 $opt_help || {
cannam@167 3610 test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
cannam@167 3611 }
cannam@167 3612
cannam@167 3613 func_mode_help ()
cannam@167 3614 {
cannam@167 3615 # We need to display help for each of the modes.
cannam@167 3616 case $opt_mode in
cannam@167 3617 "")
cannam@167 3618 # Generic help is extracted from the usage comments
cannam@167 3619 # at the start of this file.
cannam@167 3620 func_help
cannam@167 3621 ;;
cannam@167 3622
cannam@167 3623 clean)
cannam@167 3624 $ECHO \
cannam@167 3625 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
cannam@167 3626
cannam@167 3627 Remove files from the build directory.
cannam@167 3628
cannam@167 3629 RM is the name of the program to use to delete files associated with each FILE
cannam@167 3630 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
cannam@167 3631 to RM.
cannam@167 3632
cannam@167 3633 If FILE is a libtool library, object or program, all the files associated
cannam@167 3634 with it are deleted. Otherwise, only FILE itself is deleted using RM."
cannam@167 3635 ;;
cannam@167 3636
cannam@167 3637 compile)
cannam@167 3638 $ECHO \
cannam@167 3639 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
cannam@167 3640
cannam@167 3641 Compile a source file into a libtool library object.
cannam@167 3642
cannam@167 3643 This mode accepts the following additional options:
cannam@167 3644
cannam@167 3645 -o OUTPUT-FILE set the output file name to OUTPUT-FILE
cannam@167 3646 -no-suppress do not suppress compiler output for multiple passes
cannam@167 3647 -prefer-pic try to build PIC objects only
cannam@167 3648 -prefer-non-pic try to build non-PIC objects only
cannam@167 3649 -shared do not build a '.o' file suitable for static linking
cannam@167 3650 -static only build a '.o' file suitable for static linking
cannam@167 3651 -Wc,FLAG pass FLAG directly to the compiler
cannam@167 3652
cannam@167 3653 COMPILE-COMMAND is a command to be used in creating a 'standard' object file
cannam@167 3654 from the given SOURCEFILE.
cannam@167 3655
cannam@167 3656 The output file name is determined by removing the directory component from
cannam@167 3657 SOURCEFILE, then substituting the C source code suffix '.c' with the
cannam@167 3658 library object suffix, '.lo'."
cannam@167 3659 ;;
cannam@167 3660
cannam@167 3661 execute)
cannam@167 3662 $ECHO \
cannam@167 3663 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
cannam@167 3664
cannam@167 3665 Automatically set library path, then run a program.
cannam@167 3666
cannam@167 3667 This mode accepts the following additional options:
cannam@167 3668
cannam@167 3669 -dlopen FILE add the directory containing FILE to the library path
cannam@167 3670
cannam@167 3671 This mode sets the library path environment variable according to '-dlopen'
cannam@167 3672 flags.
cannam@167 3673
cannam@167 3674 If any of the ARGS are libtool executable wrappers, then they are translated
cannam@167 3675 into their corresponding uninstalled binary, and any of their required library
cannam@167 3676 directories are added to the library path.
cannam@167 3677
cannam@167 3678 Then, COMMAND is executed, with ARGS as arguments."
cannam@167 3679 ;;
cannam@167 3680
cannam@167 3681 finish)
cannam@167 3682 $ECHO \
cannam@167 3683 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
cannam@167 3684
cannam@167 3685 Complete the installation of libtool libraries.
cannam@167 3686
cannam@167 3687 Each LIBDIR is a directory that contains libtool libraries.
cannam@167 3688
cannam@167 3689 The commands that this mode executes may require superuser privileges. Use
cannam@167 3690 the '--dry-run' option if you just want to see what would be executed."
cannam@167 3691 ;;
cannam@167 3692
cannam@167 3693 install)
cannam@167 3694 $ECHO \
cannam@167 3695 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
cannam@167 3696
cannam@167 3697 Install executables or libraries.
cannam@167 3698
cannam@167 3699 INSTALL-COMMAND is the installation command. The first component should be
cannam@167 3700 either the 'install' or 'cp' program.
cannam@167 3701
cannam@167 3702 The following components of INSTALL-COMMAND are treated specially:
cannam@167 3703
cannam@167 3704 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
cannam@167 3705
cannam@167 3706 The rest of the components are interpreted as arguments to that command (only
cannam@167 3707 BSD-compatible install options are recognized)."
cannam@167 3708 ;;
cannam@167 3709
cannam@167 3710 link)
cannam@167 3711 $ECHO \
cannam@167 3712 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
cannam@167 3713
cannam@167 3714 Link object files or libraries together to form another library, or to
cannam@167 3715 create an executable program.
cannam@167 3716
cannam@167 3717 LINK-COMMAND is a command using the C compiler that you would use to create
cannam@167 3718 a program from several object files.
cannam@167 3719
cannam@167 3720 The following components of LINK-COMMAND are treated specially:
cannam@167 3721
cannam@167 3722 -all-static do not do any dynamic linking at all
cannam@167 3723 -avoid-version do not add a version suffix if possible
cannam@167 3724 -bindir BINDIR specify path to binaries directory (for systems where
cannam@167 3725 libraries must be found in the PATH setting at runtime)
cannam@167 3726 -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
cannam@167 3727 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
cannam@167 3728 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
cannam@167 3729 -export-symbols SYMFILE
cannam@167 3730 try to export only the symbols listed in SYMFILE
cannam@167 3731 -export-symbols-regex REGEX
cannam@167 3732 try to export only the symbols matching REGEX
cannam@167 3733 -LLIBDIR search LIBDIR for required installed libraries
cannam@167 3734 -lNAME OUTPUT-FILE requires the installed library libNAME
cannam@167 3735 -module build a library that can dlopened
cannam@167 3736 -no-fast-install disable the fast-install mode
cannam@167 3737 -no-install link a not-installable executable
cannam@167 3738 -no-undefined declare that a library does not refer to external symbols
cannam@167 3739 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
cannam@167 3740 -objectlist FILE use a list of object files found in FILE to specify objects
cannam@167 3741 -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
cannam@167 3742 -precious-files-regex REGEX
cannam@167 3743 don't remove output files matching REGEX
cannam@167 3744 -release RELEASE specify package release information
cannam@167 3745 -rpath LIBDIR the created library will eventually be installed in LIBDIR
cannam@167 3746 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
cannam@167 3747 -shared only do dynamic linking of libtool libraries
cannam@167 3748 -shrext SUFFIX override the standard shared library file extension
cannam@167 3749 -static do not do any dynamic linking of uninstalled libtool libraries
cannam@167 3750 -static-libtool-libs
cannam@167 3751 do not do any dynamic linking of libtool libraries
cannam@167 3752 -version-info CURRENT[:REVISION[:AGE]]
cannam@167 3753 specify library version info [each variable defaults to 0]
cannam@167 3754 -weak LIBNAME declare that the target provides the LIBNAME interface
cannam@167 3755 -Wc,FLAG
cannam@167 3756 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
cannam@167 3757 -Wl,FLAG
cannam@167 3758 -Xlinker FLAG pass linker-specific FLAG directly to the linker
cannam@167 3759 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
cannam@167 3760
cannam@167 3761 All other options (arguments beginning with '-') are ignored.
cannam@167 3762
cannam@167 3763 Every other argument is treated as a filename. Files ending in '.la' are
cannam@167 3764 treated as uninstalled libtool libraries, other files are standard or library
cannam@167 3765 object files.
cannam@167 3766
cannam@167 3767 If the OUTPUT-FILE ends in '.la', then a libtool library is created,
cannam@167 3768 only library objects ('.lo' files) may be specified, and '-rpath' is
cannam@167 3769 required, except when creating a convenience library.
cannam@167 3770
cannam@167 3771 If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
cannam@167 3772 using 'ar' and 'ranlib', or on Windows using 'lib'.
cannam@167 3773
cannam@167 3774 If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
cannam@167 3775 is created, otherwise an executable program is created."
cannam@167 3776 ;;
cannam@167 3777
cannam@167 3778 uninstall)
cannam@167 3779 $ECHO \
cannam@167 3780 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
cannam@167 3781
cannam@167 3782 Remove libraries from an installation directory.
cannam@167 3783
cannam@167 3784 RM is the name of the program to use to delete files associated with each FILE
cannam@167 3785 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
cannam@167 3786 to RM.
cannam@167 3787
cannam@167 3788 If FILE is a libtool library, all the files associated with it are deleted.
cannam@167 3789 Otherwise, only FILE itself is deleted using RM."
cannam@167 3790 ;;
cannam@167 3791
cannam@167 3792 *)
cannam@167 3793 func_fatal_help "invalid operation mode '$opt_mode'"
cannam@167 3794 ;;
cannam@167 3795 esac
cannam@167 3796
cannam@167 3797 echo
cannam@167 3798 $ECHO "Try '$progname --help' for more information about other modes."
cannam@167 3799 }
cannam@167 3800
cannam@167 3801 # Now that we've collected a possible --mode arg, show help if necessary
cannam@167 3802 if $opt_help; then
cannam@167 3803 if test : = "$opt_help"; then
cannam@167 3804 func_mode_help
cannam@167 3805 else
cannam@167 3806 {
cannam@167 3807 func_help noexit
cannam@167 3808 for opt_mode in compile link execute install finish uninstall clean; do
cannam@167 3809 func_mode_help
cannam@167 3810 done
cannam@167 3811 } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
cannam@167 3812 {
cannam@167 3813 func_help noexit
cannam@167 3814 for opt_mode in compile link execute install finish uninstall clean; do
cannam@167 3815 echo
cannam@167 3816 func_mode_help
cannam@167 3817 done
cannam@167 3818 } |
cannam@167 3819 $SED '1d
cannam@167 3820 /^When reporting/,/^Report/{
cannam@167 3821 H
cannam@167 3822 d
cannam@167 3823 }
cannam@167 3824 $x
cannam@167 3825 /information about other modes/d
cannam@167 3826 /more detailed .*MODE/d
cannam@167 3827 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
cannam@167 3828 fi
cannam@167 3829 exit $?
cannam@167 3830 fi
cannam@167 3831
cannam@167 3832
cannam@167 3833 # func_mode_execute arg...
cannam@167 3834 func_mode_execute ()
cannam@167 3835 {
cannam@167 3836 $debug_cmd
cannam@167 3837
cannam@167 3838 # The first argument is the command name.
cannam@167 3839 cmd=$nonopt
cannam@167 3840 test -z "$cmd" && \
cannam@167 3841 func_fatal_help "you must specify a COMMAND"
cannam@167 3842
cannam@167 3843 # Handle -dlopen flags immediately.
cannam@167 3844 for file in $opt_dlopen; do
cannam@167 3845 test -f "$file" \
cannam@167 3846 || func_fatal_help "'$file' is not a file"
cannam@167 3847
cannam@167 3848 dir=
cannam@167 3849 case $file in
cannam@167 3850 *.la)
cannam@167 3851 func_resolve_sysroot "$file"
cannam@167 3852 file=$func_resolve_sysroot_result
cannam@167 3853
cannam@167 3854 # Check to see that this really is a libtool archive.
cannam@167 3855 func_lalib_unsafe_p "$file" \
cannam@167 3856 || func_fatal_help "'$lib' is not a valid libtool archive"
cannam@167 3857
cannam@167 3858 # Read the libtool library.
cannam@167 3859 dlname=
cannam@167 3860 library_names=
cannam@167 3861 func_source "$file"
cannam@167 3862
cannam@167 3863 # Skip this library if it cannot be dlopened.
cannam@167 3864 if test -z "$dlname"; then
cannam@167 3865 # Warn if it was a shared library.
cannam@167 3866 test -n "$library_names" && \
cannam@167 3867 func_warning "'$file' was not linked with '-export-dynamic'"
cannam@167 3868 continue
cannam@167 3869 fi
cannam@167 3870
cannam@167 3871 func_dirname "$file" "" "."
cannam@167 3872 dir=$func_dirname_result
cannam@167 3873
cannam@167 3874 if test -f "$dir/$objdir/$dlname"; then
cannam@167 3875 func_append dir "/$objdir"
cannam@167 3876 else
cannam@167 3877 if test ! -f "$dir/$dlname"; then
cannam@167 3878 func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
cannam@167 3879 fi
cannam@167 3880 fi
cannam@167 3881 ;;
cannam@167 3882
cannam@167 3883 *.lo)
cannam@167 3884 # Just add the directory containing the .lo file.
cannam@167 3885 func_dirname "$file" "" "."
cannam@167 3886 dir=$func_dirname_result
cannam@167 3887 ;;
cannam@167 3888
cannam@167 3889 *)
cannam@167 3890 func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
cannam@167 3891 continue
cannam@167 3892 ;;
cannam@167 3893 esac
cannam@167 3894
cannam@167 3895 # Get the absolute pathname.
cannam@167 3896 absdir=`cd "$dir" && pwd`
cannam@167 3897 test -n "$absdir" && dir=$absdir
cannam@167 3898
cannam@167 3899 # Now add the directory to shlibpath_var.
cannam@167 3900 if eval "test -z \"\$$shlibpath_var\""; then
cannam@167 3901 eval "$shlibpath_var=\"\$dir\""
cannam@167 3902 else
cannam@167 3903 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
cannam@167 3904 fi
cannam@167 3905 done
cannam@167 3906
cannam@167 3907 # This variable tells wrapper scripts just to set shlibpath_var
cannam@167 3908 # rather than running their programs.
cannam@167 3909 libtool_execute_magic=$magic
cannam@167 3910
cannam@167 3911 # Check if any of the arguments is a wrapper script.
cannam@167 3912 args=
cannam@167 3913 for file
cannam@167 3914 do
cannam@167 3915 case $file in
cannam@167 3916 -* | *.la | *.lo ) ;;
cannam@167 3917 *)
cannam@167 3918 # Do a test to see if this is really a libtool program.
cannam@167 3919 if func_ltwrapper_script_p "$file"; then
cannam@167 3920 func_source "$file"
cannam@167 3921 # Transform arg to wrapped name.
cannam@167 3922 file=$progdir/$program
cannam@167 3923 elif func_ltwrapper_executable_p "$file"; then
cannam@167 3924 func_ltwrapper_scriptname "$file"
cannam@167 3925 func_source "$func_ltwrapper_scriptname_result"
cannam@167 3926 # Transform arg to wrapped name.
cannam@167 3927 file=$progdir/$program
cannam@167 3928 fi
cannam@167 3929 ;;
cannam@167 3930 esac
cannam@167 3931 # Quote arguments (to preserve shell metacharacters).
cannam@167 3932 func_append_quoted args "$file"
cannam@167 3933 done
cannam@167 3934
cannam@167 3935 if $opt_dry_run; then
cannam@167 3936 # Display what would be done.
cannam@167 3937 if test -n "$shlibpath_var"; then
cannam@167 3938 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
cannam@167 3939 echo "export $shlibpath_var"
cannam@167 3940 fi
cannam@167 3941 $ECHO "$cmd$args"
cannam@167 3942 exit $EXIT_SUCCESS
cannam@167 3943 else
cannam@167 3944 if test -n "$shlibpath_var"; then
cannam@167 3945 # Export the shlibpath_var.
cannam@167 3946 eval "export $shlibpath_var"
cannam@167 3947 fi
cannam@167 3948
cannam@167 3949 # Restore saved environment variables
cannam@167 3950 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
cannam@167 3951 do
cannam@167 3952 eval "if test \"\${save_$lt_var+set}\" = set; then
cannam@167 3953 $lt_var=\$save_$lt_var; export $lt_var
cannam@167 3954 else
cannam@167 3955 $lt_unset $lt_var
cannam@167 3956 fi"
cannam@167 3957 done
cannam@167 3958
cannam@167 3959 # Now prepare to actually exec the command.
cannam@167 3960 exec_cmd=\$cmd$args
cannam@167 3961 fi
cannam@167 3962 }
cannam@167 3963
cannam@167 3964 test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
cannam@167 3965
cannam@167 3966
cannam@167 3967 # func_mode_finish arg...
cannam@167 3968 func_mode_finish ()
cannam@167 3969 {
cannam@167 3970 $debug_cmd
cannam@167 3971
cannam@167 3972 libs=
cannam@167 3973 libdirs=
cannam@167 3974 admincmds=
cannam@167 3975
cannam@167 3976 for opt in "$nonopt" ${1+"$@"}
cannam@167 3977 do
cannam@167 3978 if test -d "$opt"; then
cannam@167 3979 func_append libdirs " $opt"
cannam@167 3980
cannam@167 3981 elif test -f "$opt"; then
cannam@167 3982 if func_lalib_unsafe_p "$opt"; then
cannam@167 3983 func_append libs " $opt"
cannam@167 3984 else
cannam@167 3985 func_warning "'$opt' is not a valid libtool archive"
cannam@167 3986 fi
cannam@167 3987
cannam@167 3988 else
cannam@167 3989 func_fatal_error "invalid argument '$opt'"
cannam@167 3990 fi
cannam@167 3991 done
cannam@167 3992
cannam@167 3993 if test -n "$libs"; then
cannam@167 3994 if test -n "$lt_sysroot"; then
cannam@167 3995 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
cannam@167 3996 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
cannam@167 3997 else
cannam@167 3998 sysroot_cmd=
cannam@167 3999 fi
cannam@167 4000
cannam@167 4001 # Remove sysroot references
cannam@167 4002 if $opt_dry_run; then
cannam@167 4003 for lib in $libs; do
cannam@167 4004 echo "removing references to $lt_sysroot and '=' prefixes from $lib"
cannam@167 4005 done
cannam@167 4006 else
cannam@167 4007 tmpdir=`func_mktempdir`
cannam@167 4008 for lib in $libs; do
cannam@167 4009 $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
cannam@167 4010 > $tmpdir/tmp-la
cannam@167 4011 mv -f $tmpdir/tmp-la $lib
cannam@167 4012 done
cannam@167 4013 ${RM}r "$tmpdir"
cannam@167 4014 fi
cannam@167 4015 fi
cannam@167 4016
cannam@167 4017 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
cannam@167 4018 for libdir in $libdirs; do
cannam@167 4019 if test -n "$finish_cmds"; then
cannam@167 4020 # Do each command in the finish commands.
cannam@167 4021 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
cannam@167 4022 '"$cmd"'"'
cannam@167 4023 fi
cannam@167 4024 if test -n "$finish_eval"; then
cannam@167 4025 # Do the single finish_eval.
cannam@167 4026 eval cmds=\"$finish_eval\"
cannam@167 4027 $opt_dry_run || eval "$cmds" || func_append admincmds "
cannam@167 4028 $cmds"
cannam@167 4029 fi
cannam@167 4030 done
cannam@167 4031 fi
cannam@167 4032
cannam@167 4033 # Exit here if they wanted silent mode.
cannam@167 4034 $opt_quiet && exit $EXIT_SUCCESS
cannam@167 4035
cannam@167 4036 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
cannam@167 4037 echo "----------------------------------------------------------------------"
cannam@167 4038 echo "Libraries have been installed in:"
cannam@167 4039 for libdir in $libdirs; do
cannam@167 4040 $ECHO " $libdir"
cannam@167 4041 done
cannam@167 4042 echo
cannam@167 4043 echo "If you ever happen to want to link against installed libraries"
cannam@167 4044 echo "in a given directory, LIBDIR, you must either use libtool, and"
cannam@167 4045 echo "specify the full pathname of the library, or use the '-LLIBDIR'"
cannam@167 4046 echo "flag during linking and do at least one of the following:"
cannam@167 4047 if test -n "$shlibpath_var"; then
cannam@167 4048 echo " - add LIBDIR to the '$shlibpath_var' environment variable"
cannam@167 4049 echo " during execution"
cannam@167 4050 fi
cannam@167 4051 if test -n "$runpath_var"; then
cannam@167 4052 echo " - add LIBDIR to the '$runpath_var' environment variable"
cannam@167 4053 echo " during linking"
cannam@167 4054 fi
cannam@167 4055 if test -n "$hardcode_libdir_flag_spec"; then
cannam@167 4056 libdir=LIBDIR
cannam@167 4057 eval flag=\"$hardcode_libdir_flag_spec\"
cannam@167 4058
cannam@167 4059 $ECHO " - use the '$flag' linker flag"
cannam@167 4060 fi
cannam@167 4061 if test -n "$admincmds"; then
cannam@167 4062 $ECHO " - have your system administrator run these commands:$admincmds"
cannam@167 4063 fi
cannam@167 4064 if test -f /etc/ld.so.conf; then
cannam@167 4065 echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
cannam@167 4066 fi
cannam@167 4067 echo
cannam@167 4068
cannam@167 4069 echo "See any operating system documentation about shared libraries for"
cannam@167 4070 case $host in
cannam@167 4071 solaris2.[6789]|solaris2.1[0-9])
cannam@167 4072 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
cannam@167 4073 echo "pages."
cannam@167 4074 ;;
cannam@167 4075 *)
cannam@167 4076 echo "more information, such as the ld(1) and ld.so(8) manual pages."
cannam@167 4077 ;;
cannam@167 4078 esac
cannam@167 4079 echo "----------------------------------------------------------------------"
cannam@167 4080 fi
cannam@167 4081 exit $EXIT_SUCCESS
cannam@167 4082 }
cannam@167 4083
cannam@167 4084 test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
cannam@167 4085
cannam@167 4086
cannam@167 4087 # func_mode_install arg...
cannam@167 4088 func_mode_install ()
cannam@167 4089 {
cannam@167 4090 $debug_cmd
cannam@167 4091
cannam@167 4092 # There may be an optional sh(1) argument at the beginning of
cannam@167 4093 # install_prog (especially on Windows NT).
cannam@167 4094 if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
cannam@167 4095 # Allow the use of GNU shtool's install command.
cannam@167 4096 case $nonopt in *shtool*) :;; *) false;; esac
cannam@167 4097 then
cannam@167 4098 # Aesthetically quote it.
cannam@167 4099 func_quote_for_eval "$nonopt"
cannam@167 4100 install_prog="$func_quote_for_eval_result "
cannam@167 4101 arg=$1
cannam@167 4102 shift
cannam@167 4103 else
cannam@167 4104 install_prog=
cannam@167 4105 arg=$nonopt
cannam@167 4106 fi
cannam@167 4107
cannam@167 4108 # The real first argument should be the name of the installation program.
cannam@167 4109 # Aesthetically quote it.
cannam@167 4110 func_quote_for_eval "$arg"
cannam@167 4111 func_append install_prog "$func_quote_for_eval_result"
cannam@167 4112 install_shared_prog=$install_prog
cannam@167 4113 case " $install_prog " in
cannam@167 4114 *[\\\ /]cp\ *) install_cp=: ;;
cannam@167 4115 *) install_cp=false ;;
cannam@167 4116 esac
cannam@167 4117
cannam@167 4118 # We need to accept at least all the BSD install flags.
cannam@167 4119 dest=
cannam@167 4120 files=
cannam@167 4121 opts=
cannam@167 4122 prev=
cannam@167 4123 install_type=
cannam@167 4124 isdir=false
cannam@167 4125 stripme=
cannam@167 4126 no_mode=:
cannam@167 4127 for arg
cannam@167 4128 do
cannam@167 4129 arg2=
cannam@167 4130 if test -n "$dest"; then
cannam@167 4131 func_append files " $dest"
cannam@167 4132 dest=$arg
cannam@167 4133 continue
cannam@167 4134 fi
cannam@167 4135
cannam@167 4136 case $arg in
cannam@167 4137 -d) isdir=: ;;
cannam@167 4138 -f)
cannam@167 4139 if $install_cp; then :; else
cannam@167 4140 prev=$arg
cannam@167 4141 fi
cannam@167 4142 ;;
cannam@167 4143 -g | -m | -o)
cannam@167 4144 prev=$arg
cannam@167 4145 ;;
cannam@167 4146 -s)
cannam@167 4147 stripme=" -s"
cannam@167 4148 continue
cannam@167 4149 ;;
cannam@167 4150 -*)
cannam@167 4151 ;;
cannam@167 4152 *)
cannam@167 4153 # If the previous option needed an argument, then skip it.
cannam@167 4154 if test -n "$prev"; then
cannam@167 4155 if test X-m = "X$prev" && test -n "$install_override_mode"; then
cannam@167 4156 arg2=$install_override_mode
cannam@167 4157 no_mode=false
cannam@167 4158 fi
cannam@167 4159 prev=
cannam@167 4160 else
cannam@167 4161 dest=$arg
cannam@167 4162 continue
cannam@167 4163 fi
cannam@167 4164 ;;
cannam@167 4165 esac
cannam@167 4166
cannam@167 4167 # Aesthetically quote the argument.
cannam@167 4168 func_quote_for_eval "$arg"
cannam@167 4169 func_append install_prog " $func_quote_for_eval_result"
cannam@167 4170 if test -n "$arg2"; then
cannam@167 4171 func_quote_for_eval "$arg2"
cannam@167 4172 fi
cannam@167 4173 func_append install_shared_prog " $func_quote_for_eval_result"
cannam@167 4174 done
cannam@167 4175
cannam@167 4176 test -z "$install_prog" && \
cannam@167 4177 func_fatal_help "you must specify an install program"
cannam@167 4178
cannam@167 4179 test -n "$prev" && \
cannam@167 4180 func_fatal_help "the '$prev' option requires an argument"
cannam@167 4181
cannam@167 4182 if test -n "$install_override_mode" && $no_mode; then
cannam@167 4183 if $install_cp; then :; else
cannam@167 4184 func_quote_for_eval "$install_override_mode"
cannam@167 4185 func_append install_shared_prog " -m $func_quote_for_eval_result"
cannam@167 4186 fi
cannam@167 4187 fi
cannam@167 4188
cannam@167 4189 if test -z "$files"; then
cannam@167 4190 if test -z "$dest"; then
cannam@167 4191 func_fatal_help "no file or destination specified"
cannam@167 4192 else
cannam@167 4193 func_fatal_help "you must specify a destination"
cannam@167 4194 fi
cannam@167 4195 fi
cannam@167 4196
cannam@167 4197 # Strip any trailing slash from the destination.
cannam@167 4198 func_stripname '' '/' "$dest"
cannam@167 4199 dest=$func_stripname_result
cannam@167 4200
cannam@167 4201 # Check to see that the destination is a directory.
cannam@167 4202 test -d "$dest" && isdir=:
cannam@167 4203 if $isdir; then
cannam@167 4204 destdir=$dest
cannam@167 4205 destname=
cannam@167 4206 else
cannam@167 4207 func_dirname_and_basename "$dest" "" "."
cannam@167 4208 destdir=$func_dirname_result
cannam@167 4209 destname=$func_basename_result
cannam@167 4210
cannam@167 4211 # Not a directory, so check to see that there is only one file specified.
cannam@167 4212 set dummy $files; shift
cannam@167 4213 test "$#" -gt 1 && \
cannam@167 4214 func_fatal_help "'$dest' is not a directory"
cannam@167 4215 fi
cannam@167 4216 case $destdir in
cannam@167 4217 [\\/]* | [A-Za-z]:[\\/]*) ;;
cannam@167 4218 *)
cannam@167 4219 for file in $files; do
cannam@167 4220 case $file in
cannam@167 4221 *.lo) ;;
cannam@167 4222 *)
cannam@167 4223 func_fatal_help "'$destdir' must be an absolute directory name"
cannam@167 4224 ;;
cannam@167 4225 esac
cannam@167 4226 done
cannam@167 4227 ;;
cannam@167 4228 esac
cannam@167 4229
cannam@167 4230 # This variable tells wrapper scripts just to set variables rather
cannam@167 4231 # than running their programs.
cannam@167 4232 libtool_install_magic=$magic
cannam@167 4233
cannam@167 4234 staticlibs=
cannam@167 4235 future_libdirs=
cannam@167 4236 current_libdirs=
cannam@167 4237 for file in $files; do
cannam@167 4238
cannam@167 4239 # Do each installation.
cannam@167 4240 case $file in
cannam@167 4241 *.$libext)
cannam@167 4242 # Do the static libraries later.
cannam@167 4243 func_append staticlibs " $file"
cannam@167 4244 ;;
cannam@167 4245
cannam@167 4246 *.la)
cannam@167 4247 func_resolve_sysroot "$file"
cannam@167 4248 file=$func_resolve_sysroot_result
cannam@167 4249
cannam@167 4250 # Check to see that this really is a libtool archive.
cannam@167 4251 func_lalib_unsafe_p "$file" \
cannam@167 4252 || func_fatal_help "'$file' is not a valid libtool archive"
cannam@167 4253
cannam@167 4254 library_names=
cannam@167 4255 old_library=
cannam@167 4256 relink_command=
cannam@167 4257 func_source "$file"
cannam@167 4258
cannam@167 4259 # Add the libdir to current_libdirs if it is the destination.
cannam@167 4260 if test "X$destdir" = "X$libdir"; then
cannam@167 4261 case "$current_libdirs " in
cannam@167 4262 *" $libdir "*) ;;
cannam@167 4263 *) func_append current_libdirs " $libdir" ;;
cannam@167 4264 esac
cannam@167 4265 else
cannam@167 4266 # Note the libdir as a future libdir.
cannam@167 4267 case "$future_libdirs " in
cannam@167 4268 *" $libdir "*) ;;
cannam@167 4269 *) func_append future_libdirs " $libdir" ;;
cannam@167 4270 esac
cannam@167 4271 fi
cannam@167 4272
cannam@167 4273 func_dirname "$file" "/" ""
cannam@167 4274 dir=$func_dirname_result
cannam@167 4275 func_append dir "$objdir"
cannam@167 4276
cannam@167 4277 if test -n "$relink_command"; then
cannam@167 4278 # Determine the prefix the user has applied to our future dir.
cannam@167 4279 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
cannam@167 4280
cannam@167 4281 # Don't allow the user to place us outside of our expected
cannam@167 4282 # location b/c this prevents finding dependent libraries that
cannam@167 4283 # are installed to the same prefix.
cannam@167 4284 # At present, this check doesn't affect windows .dll's that
cannam@167 4285 # are installed into $libdir/../bin (currently, that works fine)
cannam@167 4286 # but it's something to keep an eye on.
cannam@167 4287 test "$inst_prefix_dir" = "$destdir" && \
cannam@167 4288 func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
cannam@167 4289
cannam@167 4290 if test -n "$inst_prefix_dir"; then
cannam@167 4291 # Stick the inst_prefix_dir data into the link command.
cannam@167 4292 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
cannam@167 4293 else
cannam@167 4294 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
cannam@167 4295 fi
cannam@167 4296
cannam@167 4297 func_warning "relinking '$file'"
cannam@167 4298 func_show_eval "$relink_command" \
cannam@167 4299 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
cannam@167 4300 fi
cannam@167 4301
cannam@167 4302 # See the names of the shared library.
cannam@167 4303 set dummy $library_names; shift
cannam@167 4304 if test -n "$1"; then
cannam@167 4305 realname=$1
cannam@167 4306 shift
cannam@167 4307
cannam@167 4308 srcname=$realname
cannam@167 4309 test -n "$relink_command" && srcname=${realname}T
cannam@167 4310
cannam@167 4311 # Install the shared library and build the symlinks.
cannam@167 4312 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
cannam@167 4313 'exit $?'
cannam@167 4314 tstripme=$stripme
cannam@167 4315 case $host_os in
cannam@167 4316 cygwin* | mingw* | pw32* | cegcc*)
cannam@167 4317 case $realname in
cannam@167 4318 *.dll.a)
cannam@167 4319 tstripme=
cannam@167 4320 ;;
cannam@167 4321 esac
cannam@167 4322 ;;
cannam@167 4323 os2*)
cannam@167 4324 case $realname in
cannam@167 4325 *_dll.a)
cannam@167 4326 tstripme=
cannam@167 4327 ;;
cannam@167 4328 esac
cannam@167 4329 ;;
cannam@167 4330 esac
cannam@167 4331 if test -n "$tstripme" && test -n "$striplib"; then
cannam@167 4332 func_show_eval "$striplib $destdir/$realname" 'exit $?'
cannam@167 4333 fi
cannam@167 4334
cannam@167 4335 if test "$#" -gt 0; then
cannam@167 4336 # Delete the old symlinks, and create new ones.
cannam@167 4337 # Try 'ln -sf' first, because the 'ln' binary might depend on
cannam@167 4338 # the symlink we replace! Solaris /bin/ln does not understand -f,
cannam@167 4339 # so we also need to try rm && ln -s.
cannam@167 4340 for linkname
cannam@167 4341 do
cannam@167 4342 test "$linkname" != "$realname" \
cannam@167 4343 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
cannam@167 4344 done
cannam@167 4345 fi
cannam@167 4346
cannam@167 4347 # Do each command in the postinstall commands.
cannam@167 4348 lib=$destdir/$realname
cannam@167 4349 func_execute_cmds "$postinstall_cmds" 'exit $?'
cannam@167 4350 fi
cannam@167 4351
cannam@167 4352 # Install the pseudo-library for information purposes.
cannam@167 4353 func_basename "$file"
cannam@167 4354 name=$func_basename_result
cannam@167 4355 instname=$dir/${name}i
cannam@167 4356 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
cannam@167 4357
cannam@167 4358 # Maybe install the static library, too.
cannam@167 4359 test -n "$old_library" && func_append staticlibs " $dir/$old_library"
cannam@167 4360 ;;
cannam@167 4361
cannam@167 4362 *.lo)
cannam@167 4363 # Install (i.e. copy) a libtool object.
cannam@167 4364
cannam@167 4365 # Figure out destination file name, if it wasn't already specified.
cannam@167 4366 if test -n "$destname"; then
cannam@167 4367 destfile=$destdir/$destname
cannam@167 4368 else
cannam@167 4369 func_basename "$file"
cannam@167 4370 destfile=$func_basename_result
cannam@167 4371 destfile=$destdir/$destfile
cannam@167 4372 fi
cannam@167 4373
cannam@167 4374 # Deduce the name of the destination old-style object file.
cannam@167 4375 case $destfile in
cannam@167 4376 *.lo)
cannam@167 4377 func_lo2o "$destfile"
cannam@167 4378 staticdest=$func_lo2o_result
cannam@167 4379 ;;
cannam@167 4380 *.$objext)
cannam@167 4381 staticdest=$destfile
cannam@167 4382 destfile=
cannam@167 4383 ;;
cannam@167 4384 *)
cannam@167 4385 func_fatal_help "cannot copy a libtool object to '$destfile'"
cannam@167 4386 ;;
cannam@167 4387 esac
cannam@167 4388
cannam@167 4389 # Install the libtool object if requested.
cannam@167 4390 test -n "$destfile" && \
cannam@167 4391 func_show_eval "$install_prog $file $destfile" 'exit $?'
cannam@167 4392
cannam@167 4393 # Install the old object if enabled.
cannam@167 4394 if test yes = "$build_old_libs"; then
cannam@167 4395 # Deduce the name of the old-style object file.
cannam@167 4396 func_lo2o "$file"
cannam@167 4397 staticobj=$func_lo2o_result
cannam@167 4398 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
cannam@167 4399 fi
cannam@167 4400 exit $EXIT_SUCCESS
cannam@167 4401 ;;
cannam@167 4402
cannam@167 4403 *)
cannam@167 4404 # Figure out destination file name, if it wasn't already specified.
cannam@167 4405 if test -n "$destname"; then
cannam@167 4406 destfile=$destdir/$destname
cannam@167 4407 else
cannam@167 4408 func_basename "$file"
cannam@167 4409 destfile=$func_basename_result
cannam@167 4410 destfile=$destdir/$destfile
cannam@167 4411 fi
cannam@167 4412
cannam@167 4413 # If the file is missing, and there is a .exe on the end, strip it
cannam@167 4414 # because it is most likely a libtool script we actually want to
cannam@167 4415 # install
cannam@167 4416 stripped_ext=
cannam@167 4417 case $file in
cannam@167 4418 *.exe)
cannam@167 4419 if test ! -f "$file"; then
cannam@167 4420 func_stripname '' '.exe' "$file"
cannam@167 4421 file=$func_stripname_result
cannam@167 4422 stripped_ext=.exe
cannam@167 4423 fi
cannam@167 4424 ;;
cannam@167 4425 esac
cannam@167 4426
cannam@167 4427 # Do a test to see if this is really a libtool program.
cannam@167 4428 case $host in
cannam@167 4429 *cygwin* | *mingw*)
cannam@167 4430 if func_ltwrapper_executable_p "$file"; then
cannam@167 4431 func_ltwrapper_scriptname "$file"
cannam@167 4432 wrapper=$func_ltwrapper_scriptname_result
cannam@167 4433 else
cannam@167 4434 func_stripname '' '.exe' "$file"
cannam@167 4435 wrapper=$func_stripname_result
cannam@167 4436 fi
cannam@167 4437 ;;
cannam@167 4438 *)
cannam@167 4439 wrapper=$file
cannam@167 4440 ;;
cannam@167 4441 esac
cannam@167 4442 if func_ltwrapper_script_p "$wrapper"; then
cannam@167 4443 notinst_deplibs=
cannam@167 4444 relink_command=
cannam@167 4445
cannam@167 4446 func_source "$wrapper"
cannam@167 4447
cannam@167 4448 # Check the variables that should have been set.
cannam@167 4449 test -z "$generated_by_libtool_version" && \
cannam@167 4450 func_fatal_error "invalid libtool wrapper script '$wrapper'"
cannam@167 4451
cannam@167 4452 finalize=:
cannam@167 4453 for lib in $notinst_deplibs; do
cannam@167 4454 # Check to see that each library is installed.
cannam@167 4455 libdir=
cannam@167 4456 if test -f "$lib"; then
cannam@167 4457 func_source "$lib"
cannam@167 4458 fi
cannam@167 4459 libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
cannam@167 4460 if test -n "$libdir" && test ! -f "$libfile"; then
cannam@167 4461 func_warning "'$lib' has not been installed in '$libdir'"
cannam@167 4462 finalize=false
cannam@167 4463 fi
cannam@167 4464 done
cannam@167 4465
cannam@167 4466 relink_command=
cannam@167 4467 func_source "$wrapper"
cannam@167 4468
cannam@167 4469 outputname=
cannam@167 4470 if test no = "$fast_install" && test -n "$relink_command"; then
cannam@167 4471 $opt_dry_run || {
cannam@167 4472 if $finalize; then
cannam@167 4473 tmpdir=`func_mktempdir`
cannam@167 4474 func_basename "$file$stripped_ext"
cannam@167 4475 file=$func_basename_result
cannam@167 4476 outputname=$tmpdir/$file
cannam@167 4477 # Replace the output file specification.
cannam@167 4478 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
cannam@167 4479
cannam@167 4480 $opt_quiet || {
cannam@167 4481 func_quote_for_expand "$relink_command"
cannam@167 4482 eval "func_echo $func_quote_for_expand_result"
cannam@167 4483 }
cannam@167 4484 if eval "$relink_command"; then :
cannam@167 4485 else
cannam@167 4486 func_error "error: relink '$file' with the above command before installing it"
cannam@167 4487 $opt_dry_run || ${RM}r "$tmpdir"
cannam@167 4488 continue
cannam@167 4489 fi
cannam@167 4490 file=$outputname
cannam@167 4491 else
cannam@167 4492 func_warning "cannot relink '$file'"
cannam@167 4493 fi
cannam@167 4494 }
cannam@167 4495 else
cannam@167 4496 # Install the binary that we compiled earlier.
cannam@167 4497 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
cannam@167 4498 fi
cannam@167 4499 fi
cannam@167 4500
cannam@167 4501 # remove .exe since cygwin /usr/bin/install will append another
cannam@167 4502 # one anyway
cannam@167 4503 case $install_prog,$host in
cannam@167 4504 */usr/bin/install*,*cygwin*)
cannam@167 4505 case $file:$destfile in
cannam@167 4506 *.exe:*.exe)
cannam@167 4507 # this is ok
cannam@167 4508 ;;
cannam@167 4509 *.exe:*)
cannam@167 4510 destfile=$destfile.exe
cannam@167 4511 ;;
cannam@167 4512 *:*.exe)
cannam@167 4513 func_stripname '' '.exe' "$destfile"
cannam@167 4514 destfile=$func_stripname_result
cannam@167 4515 ;;
cannam@167 4516 esac
cannam@167 4517 ;;
cannam@167 4518 esac
cannam@167 4519 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
cannam@167 4520 $opt_dry_run || if test -n "$outputname"; then
cannam@167 4521 ${RM}r "$tmpdir"
cannam@167 4522 fi
cannam@167 4523 ;;
cannam@167 4524 esac
cannam@167 4525 done
cannam@167 4526
cannam@167 4527 for file in $staticlibs; do
cannam@167 4528 func_basename "$file"
cannam@167 4529 name=$func_basename_result
cannam@167 4530
cannam@167 4531 # Set up the ranlib parameters.
cannam@167 4532 oldlib=$destdir/$name
cannam@167 4533 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
cannam@167 4534 tool_oldlib=$func_to_tool_file_result
cannam@167 4535
cannam@167 4536 func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
cannam@167 4537
cannam@167 4538 if test -n "$stripme" && test -n "$old_striplib"; then
cannam@167 4539 func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
cannam@167 4540 fi
cannam@167 4541
cannam@167 4542 # Do each command in the postinstall commands.
cannam@167 4543 func_execute_cmds "$old_postinstall_cmds" 'exit $?'
cannam@167 4544 done
cannam@167 4545
cannam@167 4546 test -n "$future_libdirs" && \
cannam@167 4547 func_warning "remember to run '$progname --finish$future_libdirs'"
cannam@167 4548
cannam@167 4549 if test -n "$current_libdirs"; then
cannam@167 4550 # Maybe just do a dry run.
cannam@167 4551 $opt_dry_run && current_libdirs=" -n$current_libdirs"
cannam@167 4552 exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
cannam@167 4553 else
cannam@167 4554 exit $EXIT_SUCCESS
cannam@167 4555 fi
cannam@167 4556 }
cannam@167 4557
cannam@167 4558 test install = "$opt_mode" && func_mode_install ${1+"$@"}
cannam@167 4559
cannam@167 4560
cannam@167 4561 # func_generate_dlsyms outputname originator pic_p
cannam@167 4562 # Extract symbols from dlprefiles and create ${outputname}S.o with
cannam@167 4563 # a dlpreopen symbol table.
cannam@167 4564 func_generate_dlsyms ()
cannam@167 4565 {
cannam@167 4566 $debug_cmd
cannam@167 4567
cannam@167 4568 my_outputname=$1
cannam@167 4569 my_originator=$2
cannam@167 4570 my_pic_p=${3-false}
cannam@167 4571 my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
cannam@167 4572 my_dlsyms=
cannam@167 4573
cannam@167 4574 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
cannam@167 4575 if test -n "$NM" && test -n "$global_symbol_pipe"; then
cannam@167 4576 my_dlsyms=${my_outputname}S.c
cannam@167 4577 else
cannam@167 4578 func_error "not configured to extract global symbols from dlpreopened files"
cannam@167 4579 fi
cannam@167 4580 fi
cannam@167 4581
cannam@167 4582 if test -n "$my_dlsyms"; then
cannam@167 4583 case $my_dlsyms in
cannam@167 4584 "") ;;
cannam@167 4585 *.c)
cannam@167 4586 # Discover the nlist of each of the dlfiles.
cannam@167 4587 nlist=$output_objdir/$my_outputname.nm
cannam@167 4588
cannam@167 4589 func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
cannam@167 4590
cannam@167 4591 # Parse the name list into a source file.
cannam@167 4592 func_verbose "creating $output_objdir/$my_dlsyms"
cannam@167 4593
cannam@167 4594 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
cannam@167 4595 /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
cannam@167 4596 /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
cannam@167 4597
cannam@167 4598 #ifdef __cplusplus
cannam@167 4599 extern \"C\" {
cannam@167 4600 #endif
cannam@167 4601
cannam@167 4602 #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
cannam@167 4603 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
cannam@167 4604 #endif
cannam@167 4605
cannam@167 4606 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
cannam@167 4607 #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
cannam@167 4608 /* DATA imports from DLLs on WIN32 can't be const, because runtime
cannam@167 4609 relocations are performed -- see ld's documentation on pseudo-relocs. */
cannam@167 4610 # define LT_DLSYM_CONST
cannam@167 4611 #elif defined __osf__
cannam@167 4612 /* This system does not cope well with relocations in const data. */
cannam@167 4613 # define LT_DLSYM_CONST
cannam@167 4614 #else
cannam@167 4615 # define LT_DLSYM_CONST const
cannam@167 4616 #endif
cannam@167 4617
cannam@167 4618 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
cannam@167 4619
cannam@167 4620 /* External symbol declarations for the compiler. */\
cannam@167 4621 "
cannam@167 4622
cannam@167 4623 if test yes = "$dlself"; then
cannam@167 4624 func_verbose "generating symbol list for '$output'"
cannam@167 4625
cannam@167 4626 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
cannam@167 4627
cannam@167 4628 # Add our own program objects to the symbol list.
cannam@167 4629 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
cannam@167 4630 for progfile in $progfiles; do
cannam@167 4631 func_to_tool_file "$progfile" func_convert_file_msys_to_w32
cannam@167 4632 func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
cannam@167 4633 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
cannam@167 4634 done
cannam@167 4635
cannam@167 4636 if test -n "$exclude_expsyms"; then
cannam@167 4637 $opt_dry_run || {
cannam@167 4638 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
cannam@167 4639 eval '$MV "$nlist"T "$nlist"'
cannam@167 4640 }
cannam@167 4641 fi
cannam@167 4642
cannam@167 4643 if test -n "$export_symbols_regex"; then
cannam@167 4644 $opt_dry_run || {
cannam@167 4645 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
cannam@167 4646 eval '$MV "$nlist"T "$nlist"'
cannam@167 4647 }
cannam@167 4648 fi
cannam@167 4649
cannam@167 4650 # Prepare the list of exported symbols
cannam@167 4651 if test -z "$export_symbols"; then
cannam@167 4652 export_symbols=$output_objdir/$outputname.exp
cannam@167 4653 $opt_dry_run || {
cannam@167 4654 $RM $export_symbols
cannam@167 4655 eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
cannam@167 4656 case $host in
cannam@167 4657 *cygwin* | *mingw* | *cegcc* )
cannam@167 4658 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
cannam@167 4659 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
cannam@167 4660 ;;
cannam@167 4661 esac
cannam@167 4662 }
cannam@167 4663 else
cannam@167 4664 $opt_dry_run || {
cannam@167 4665 eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
cannam@167 4666 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
cannam@167 4667 eval '$MV "$nlist"T "$nlist"'
cannam@167 4668 case $host in
cannam@167 4669 *cygwin* | *mingw* | *cegcc* )
cannam@167 4670 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
cannam@167 4671 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
cannam@167 4672 ;;
cannam@167 4673 esac
cannam@167 4674 }
cannam@167 4675 fi
cannam@167 4676 fi
cannam@167 4677
cannam@167 4678 for dlprefile in $dlprefiles; do
cannam@167 4679 func_verbose "extracting global C symbols from '$dlprefile'"
cannam@167 4680 func_basename "$dlprefile"
cannam@167 4681 name=$func_basename_result
cannam@167 4682 case $host in
cannam@167 4683 *cygwin* | *mingw* | *cegcc* )
cannam@167 4684 # if an import library, we need to obtain dlname
cannam@167 4685 if func_win32_import_lib_p "$dlprefile"; then
cannam@167 4686 func_tr_sh "$dlprefile"
cannam@167 4687 eval "curr_lafile=\$libfile_$func_tr_sh_result"
cannam@167 4688 dlprefile_dlbasename=
cannam@167 4689 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
cannam@167 4690 # Use subshell, to avoid clobbering current variable values
cannam@167 4691 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
cannam@167 4692 if test -n "$dlprefile_dlname"; then
cannam@167 4693 func_basename "$dlprefile_dlname"
cannam@167 4694 dlprefile_dlbasename=$func_basename_result
cannam@167 4695 else
cannam@167 4696 # no lafile. user explicitly requested -dlpreopen <import library>.
cannam@167 4697 $sharedlib_from_linklib_cmd "$dlprefile"
cannam@167 4698 dlprefile_dlbasename=$sharedlib_from_linklib_result
cannam@167 4699 fi
cannam@167 4700 fi
cannam@167 4701 $opt_dry_run || {
cannam@167 4702 if test -n "$dlprefile_dlbasename"; then
cannam@167 4703 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
cannam@167 4704 else
cannam@167 4705 func_warning "Could not compute DLL name from $name"
cannam@167 4706 eval '$ECHO ": $name " >> "$nlist"'
cannam@167 4707 fi
cannam@167 4708 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
cannam@167 4709 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
cannam@167 4710 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
cannam@167 4711 }
cannam@167 4712 else # not an import lib
cannam@167 4713 $opt_dry_run || {
cannam@167 4714 eval '$ECHO ": $name " >> "$nlist"'
cannam@167 4715 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
cannam@167 4716 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
cannam@167 4717 }
cannam@167 4718 fi
cannam@167 4719 ;;
cannam@167 4720 *)
cannam@167 4721 $opt_dry_run || {
cannam@167 4722 eval '$ECHO ": $name " >> "$nlist"'
cannam@167 4723 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
cannam@167 4724 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
cannam@167 4725 }
cannam@167 4726 ;;
cannam@167 4727 esac
cannam@167 4728 done
cannam@167 4729
cannam@167 4730 $opt_dry_run || {
cannam@167 4731 # Make sure we have at least an empty file.
cannam@167 4732 test -f "$nlist" || : > "$nlist"
cannam@167 4733
cannam@167 4734 if test -n "$exclude_expsyms"; then
cannam@167 4735 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
cannam@167 4736 $MV "$nlist"T "$nlist"
cannam@167 4737 fi
cannam@167 4738
cannam@167 4739 # Try sorting and uniquifying the output.
cannam@167 4740 if $GREP -v "^: " < "$nlist" |
cannam@167 4741 if sort -k 3 </dev/null >/dev/null 2>&1; then
cannam@167 4742 sort -k 3
cannam@167 4743 else
cannam@167 4744 sort +2
cannam@167 4745 fi |
cannam@167 4746 uniq > "$nlist"S; then
cannam@167 4747 :
cannam@167 4748 else
cannam@167 4749 $GREP -v "^: " < "$nlist" > "$nlist"S
cannam@167 4750 fi
cannam@167 4751
cannam@167 4752 if test -f "$nlist"S; then
cannam@167 4753 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
cannam@167 4754 else
cannam@167 4755 echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
cannam@167 4756 fi
cannam@167 4757
cannam@167 4758 func_show_eval '$RM "${nlist}I"'
cannam@167 4759 if test -n "$global_symbol_to_import"; then
cannam@167 4760 eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
cannam@167 4761 fi
cannam@167 4762
cannam@167 4763 echo >> "$output_objdir/$my_dlsyms" "\
cannam@167 4764
cannam@167 4765 /* The mapping between symbol names and symbols. */
cannam@167 4766 typedef struct {
cannam@167 4767 const char *name;
cannam@167 4768 void *address;
cannam@167 4769 } lt_dlsymlist;
cannam@167 4770 extern LT_DLSYM_CONST lt_dlsymlist
cannam@167 4771 lt_${my_prefix}_LTX_preloaded_symbols[];\
cannam@167 4772 "
cannam@167 4773
cannam@167 4774 if test -s "$nlist"I; then
cannam@167 4775 echo >> "$output_objdir/$my_dlsyms" "\
cannam@167 4776 static void lt_syminit(void)
cannam@167 4777 {
cannam@167 4778 LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
cannam@167 4779 for (; symbol->name; ++symbol)
cannam@167 4780 {"
cannam@167 4781 $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
cannam@167 4782 echo >> "$output_objdir/$my_dlsyms" "\
cannam@167 4783 }
cannam@167 4784 }"
cannam@167 4785 fi
cannam@167 4786 echo >> "$output_objdir/$my_dlsyms" "\
cannam@167 4787 LT_DLSYM_CONST lt_dlsymlist
cannam@167 4788 lt_${my_prefix}_LTX_preloaded_symbols[] =
cannam@167 4789 { {\"$my_originator\", (void *) 0},"
cannam@167 4790
cannam@167 4791 if test -s "$nlist"I; then
cannam@167 4792 echo >> "$output_objdir/$my_dlsyms" "\
cannam@167 4793 {\"@INIT@\", (void *) &lt_syminit},"
cannam@167 4794 fi
cannam@167 4795
cannam@167 4796 case $need_lib_prefix in
cannam@167 4797 no)
cannam@167 4798 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
cannam@167 4799 ;;
cannam@167 4800 *)
cannam@167 4801 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
cannam@167 4802 ;;
cannam@167 4803 esac
cannam@167 4804 echo >> "$output_objdir/$my_dlsyms" "\
cannam@167 4805 {0, (void *) 0}
cannam@167 4806 };
cannam@167 4807
cannam@167 4808 /* This works around a problem in FreeBSD linker */
cannam@167 4809 #ifdef FREEBSD_WORKAROUND
cannam@167 4810 static const void *lt_preloaded_setup() {
cannam@167 4811 return lt_${my_prefix}_LTX_preloaded_symbols;
cannam@167 4812 }
cannam@167 4813 #endif
cannam@167 4814
cannam@167 4815 #ifdef __cplusplus
cannam@167 4816 }
cannam@167 4817 #endif\
cannam@167 4818 "
cannam@167 4819 } # !$opt_dry_run
cannam@167 4820
cannam@167 4821 pic_flag_for_symtable=
cannam@167 4822 case "$compile_command " in
cannam@167 4823 *" -static "*) ;;
cannam@167 4824 *)
cannam@167 4825 case $host in
cannam@167 4826 # compiling the symbol table file with pic_flag works around
cannam@167 4827 # a FreeBSD bug that causes programs to crash when -lm is
cannam@167 4828 # linked before any other PIC object. But we must not use
cannam@167 4829 # pic_flag when linking with -static. The problem exists in
cannam@167 4830 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
cannam@167 4831 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
cannam@167 4832 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
cannam@167 4833 *-*-hpux*)
cannam@167 4834 pic_flag_for_symtable=" $pic_flag" ;;
cannam@167 4835 *)
cannam@167 4836 $my_pic_p && pic_flag_for_symtable=" $pic_flag"
cannam@167 4837 ;;
cannam@167 4838 esac
cannam@167 4839 ;;
cannam@167 4840 esac
cannam@167 4841 symtab_cflags=
cannam@167 4842 for arg in $LTCFLAGS; do
cannam@167 4843 case $arg in
cannam@167 4844 -pie | -fpie | -fPIE) ;;
cannam@167 4845 *) func_append symtab_cflags " $arg" ;;
cannam@167 4846 esac
cannam@167 4847 done
cannam@167 4848
cannam@167 4849 # Now compile the dynamic symbol file.
cannam@167 4850 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
cannam@167 4851
cannam@167 4852 # Clean up the generated files.
cannam@167 4853 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
cannam@167 4854
cannam@167 4855 # Transform the symbol file into the correct name.
cannam@167 4856 symfileobj=$output_objdir/${my_outputname}S.$objext
cannam@167 4857 case $host in
cannam@167 4858 *cygwin* | *mingw* | *cegcc* )
cannam@167 4859 if test -f "$output_objdir/$my_outputname.def"; then
cannam@167 4860 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
cannam@167 4861 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
cannam@167 4862 else
cannam@167 4863 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
cannam@167 4864 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
cannam@167 4865 fi
cannam@167 4866 ;;
cannam@167 4867 *)
cannam@167 4868 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
cannam@167 4869 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
cannam@167 4870 ;;
cannam@167 4871 esac
cannam@167 4872 ;;
cannam@167 4873 *)
cannam@167 4874 func_fatal_error "unknown suffix for '$my_dlsyms'"
cannam@167 4875 ;;
cannam@167 4876 esac
cannam@167 4877 else
cannam@167 4878 # We keep going just in case the user didn't refer to
cannam@167 4879 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
cannam@167 4880 # really was required.
cannam@167 4881
cannam@167 4882 # Nullify the symbol file.
cannam@167 4883 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
cannam@167 4884 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
cannam@167 4885 fi
cannam@167 4886 }
cannam@167 4887
cannam@167 4888 # func_cygming_gnu_implib_p ARG
cannam@167 4889 # This predicate returns with zero status (TRUE) if
cannam@167 4890 # ARG is a GNU/binutils-style import library. Returns
cannam@167 4891 # with nonzero status (FALSE) otherwise.
cannam@167 4892 func_cygming_gnu_implib_p ()
cannam@167 4893 {
cannam@167 4894 $debug_cmd
cannam@167 4895
cannam@167 4896 func_to_tool_file "$1" func_convert_file_msys_to_w32
cannam@167 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@167 4898 test -n "$func_cygming_gnu_implib_tmp"
cannam@167 4899 }
cannam@167 4900
cannam@167 4901 # func_cygming_ms_implib_p ARG
cannam@167 4902 # This predicate returns with zero status (TRUE) if
cannam@167 4903 # ARG is an MS-style import library. Returns
cannam@167 4904 # with nonzero status (FALSE) otherwise.
cannam@167 4905 func_cygming_ms_implib_p ()
cannam@167 4906 {
cannam@167 4907 $debug_cmd
cannam@167 4908
cannam@167 4909 func_to_tool_file "$1" func_convert_file_msys_to_w32
cannam@167 4910 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
cannam@167 4911 test -n "$func_cygming_ms_implib_tmp"
cannam@167 4912 }
cannam@167 4913
cannam@167 4914 # func_win32_libid arg
cannam@167 4915 # return the library type of file 'arg'
cannam@167 4916 #
cannam@167 4917 # Need a lot of goo to handle *both* DLLs and import libs
cannam@167 4918 # Has to be a shell function in order to 'eat' the argument
cannam@167 4919 # that is supplied when $file_magic_command is called.
cannam@167 4920 # Despite the name, also deal with 64 bit binaries.
cannam@167 4921 func_win32_libid ()
cannam@167 4922 {
cannam@167 4923 $debug_cmd
cannam@167 4924
cannam@167 4925 win32_libid_type=unknown
cannam@167 4926 win32_fileres=`file -L $1 2>/dev/null`
cannam@167 4927 case $win32_fileres in
cannam@167 4928 *ar\ archive\ import\ library*) # definitely import
cannam@167 4929 win32_libid_type="x86 archive import"
cannam@167 4930 ;;
cannam@167 4931 *ar\ archive*) # could be an import, or static
cannam@167 4932 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
cannam@167 4933 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
cannam@167 4934 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
cannam@167 4935 case $nm_interface in
cannam@167 4936 "MS dumpbin")
cannam@167 4937 if func_cygming_ms_implib_p "$1" ||
cannam@167 4938 func_cygming_gnu_implib_p "$1"
cannam@167 4939 then
cannam@167 4940 win32_nmres=import
cannam@167 4941 else
cannam@167 4942 win32_nmres=
cannam@167 4943 fi
cannam@167 4944 ;;
cannam@167 4945 *)
cannam@167 4946 func_to_tool_file "$1" func_convert_file_msys_to_w32
cannam@167 4947 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
cannam@167 4948 $SED -n -e '
cannam@167 4949 1,100{
cannam@167 4950 / I /{
cannam@167 4951 s|.*|import|
cannam@167 4952 p
cannam@167 4953 q
cannam@167 4954 }
cannam@167 4955 }'`
cannam@167 4956 ;;
cannam@167 4957 esac
cannam@167 4958 case $win32_nmres in
cannam@167 4959 import*) win32_libid_type="x86 archive import";;
cannam@167 4960 *) win32_libid_type="x86 archive static";;
cannam@167 4961 esac
cannam@167 4962 fi
cannam@167 4963 ;;
cannam@167 4964 *DLL*)
cannam@167 4965 win32_libid_type="x86 DLL"
cannam@167 4966 ;;
cannam@167 4967 *executable*) # but shell scripts are "executable" too...
cannam@167 4968 case $win32_fileres in
cannam@167 4969 *MS\ Windows\ PE\ Intel*)
cannam@167 4970 win32_libid_type="x86 DLL"
cannam@167 4971 ;;
cannam@167 4972 esac
cannam@167 4973 ;;
cannam@167 4974 esac
cannam@167 4975 $ECHO "$win32_libid_type"
cannam@167 4976 }
cannam@167 4977
cannam@167 4978 # func_cygming_dll_for_implib ARG
cannam@167 4979 #
cannam@167 4980 # Platform-specific function to extract the
cannam@167 4981 # name of the DLL associated with the specified
cannam@167 4982 # import library ARG.
cannam@167 4983 # Invoked by eval'ing the libtool variable
cannam@167 4984 # $sharedlib_from_linklib_cmd
cannam@167 4985 # Result is available in the variable
cannam@167 4986 # $sharedlib_from_linklib_result
cannam@167 4987 func_cygming_dll_for_implib ()
cannam@167 4988 {
cannam@167 4989 $debug_cmd
cannam@167 4990
cannam@167 4991 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
cannam@167 4992 }
cannam@167 4993
cannam@167 4994 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
cannam@167 4995 #
cannam@167 4996 # The is the core of a fallback implementation of a
cannam@167 4997 # platform-specific function to extract the name of the
cannam@167 4998 # DLL associated with the specified import library LIBNAME.
cannam@167 4999 #
cannam@167 5000 # SECTION_NAME is either .idata$6 or .idata$7, depending
cannam@167 5001 # on the platform and compiler that created the implib.
cannam@167 5002 #
cannam@167 5003 # Echos the name of the DLL associated with the
cannam@167 5004 # specified import library.
cannam@167 5005 func_cygming_dll_for_implib_fallback_core ()
cannam@167 5006 {
cannam@167 5007 $debug_cmd
cannam@167 5008
cannam@167 5009 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
cannam@167 5010 $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
cannam@167 5011 $SED '/^Contents of section '"$match_literal"':/{
cannam@167 5012 # Place marker at beginning of archive member dllname section
cannam@167 5013 s/.*/====MARK====/
cannam@167 5014 p
cannam@167 5015 d
cannam@167 5016 }
cannam@167 5017 # These lines can sometimes be longer than 43 characters, but
cannam@167 5018 # are always uninteresting
cannam@167 5019 /:[ ]*file format pe[i]\{,1\}-/d
cannam@167 5020 /^In archive [^:]*:/d
cannam@167 5021 # Ensure marker is printed
cannam@167 5022 /^====MARK====/p
cannam@167 5023 # Remove all lines with less than 43 characters
cannam@167 5024 /^.\{43\}/!d
cannam@167 5025 # From remaining lines, remove first 43 characters
cannam@167 5026 s/^.\{43\}//' |
cannam@167 5027 $SED -n '
cannam@167 5028 # Join marker and all lines until next marker into a single line
cannam@167 5029 /^====MARK====/ b para
cannam@167 5030 H
cannam@167 5031 $ b para
cannam@167 5032 b
cannam@167 5033 :para
cannam@167 5034 x
cannam@167 5035 s/\n//g
cannam@167 5036 # Remove the marker
cannam@167 5037 s/^====MARK====//
cannam@167 5038 # Remove trailing dots and whitespace
cannam@167 5039 s/[\. \t]*$//
cannam@167 5040 # Print
cannam@167 5041 /./p' |
cannam@167 5042 # we now have a list, one entry per line, of the stringified
cannam@167 5043 # contents of the appropriate section of all members of the
cannam@167 5044 # archive that possess that section. Heuristic: eliminate
cannam@167 5045 # all those that have a first or second character that is
cannam@167 5046 # a '.' (that is, objdump's representation of an unprintable
cannam@167 5047 # character.) This should work for all archives with less than
cannam@167 5048 # 0x302f exports -- but will fail for DLLs whose name actually
cannam@167 5049 # begins with a literal '.' or a single character followed by
cannam@167 5050 # a '.'.
cannam@167 5051 #
cannam@167 5052 # Of those that remain, print the first one.
cannam@167 5053 $SED -e '/^\./d;/^.\./d;q'
cannam@167 5054 }
cannam@167 5055
cannam@167 5056 # func_cygming_dll_for_implib_fallback ARG
cannam@167 5057 # Platform-specific function to extract the
cannam@167 5058 # name of the DLL associated with the specified
cannam@167 5059 # import library ARG.
cannam@167 5060 #
cannam@167 5061 # This fallback implementation is for use when $DLLTOOL
cannam@167 5062 # does not support the --identify-strict option.
cannam@167 5063 # Invoked by eval'ing the libtool variable
cannam@167 5064 # $sharedlib_from_linklib_cmd
cannam@167 5065 # Result is available in the variable
cannam@167 5066 # $sharedlib_from_linklib_result
cannam@167 5067 func_cygming_dll_for_implib_fallback ()
cannam@167 5068 {
cannam@167 5069 $debug_cmd
cannam@167 5070
cannam@167 5071 if func_cygming_gnu_implib_p "$1"; then
cannam@167 5072 # binutils import library
cannam@167 5073 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
cannam@167 5074 elif func_cygming_ms_implib_p "$1"; then
cannam@167 5075 # ms-generated import library
cannam@167 5076 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
cannam@167 5077 else
cannam@167 5078 # unknown
cannam@167 5079 sharedlib_from_linklib_result=
cannam@167 5080 fi
cannam@167 5081 }
cannam@167 5082
cannam@167 5083
cannam@167 5084 # func_extract_an_archive dir oldlib
cannam@167 5085 func_extract_an_archive ()
cannam@167 5086 {
cannam@167 5087 $debug_cmd
cannam@167 5088
cannam@167 5089 f_ex_an_ar_dir=$1; shift
cannam@167 5090 f_ex_an_ar_oldlib=$1
cannam@167 5091 if test yes = "$lock_old_archive_extraction"; then
cannam@167 5092 lockfile=$f_ex_an_ar_oldlib.lock
cannam@167 5093 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
cannam@167 5094 func_echo "Waiting for $lockfile to be removed"
cannam@167 5095 sleep 2
cannam@167 5096 done
cannam@167 5097 fi
cannam@167 5098 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
cannam@167 5099 'stat=$?; rm -f "$lockfile"; exit $stat'
cannam@167 5100 if test yes = "$lock_old_archive_extraction"; then
cannam@167 5101 $opt_dry_run || rm -f "$lockfile"
cannam@167 5102 fi
cannam@167 5103 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
cannam@167 5104 :
cannam@167 5105 else
cannam@167 5106 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
cannam@167 5107 fi
cannam@167 5108 }
cannam@167 5109
cannam@167 5110
cannam@167 5111 # func_extract_archives gentop oldlib ...
cannam@167 5112 func_extract_archives ()
cannam@167 5113 {
cannam@167 5114 $debug_cmd
cannam@167 5115
cannam@167 5116 my_gentop=$1; shift
cannam@167 5117 my_oldlibs=${1+"$@"}
cannam@167 5118 my_oldobjs=
cannam@167 5119 my_xlib=
cannam@167 5120 my_xabs=
cannam@167 5121 my_xdir=
cannam@167 5122
cannam@167 5123 for my_xlib in $my_oldlibs; do
cannam@167 5124 # Extract the objects.
cannam@167 5125 case $my_xlib in
cannam@167 5126 [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
cannam@167 5127 *) my_xabs=`pwd`"/$my_xlib" ;;
cannam@167 5128 esac
cannam@167 5129 func_basename "$my_xlib"
cannam@167 5130 my_xlib=$func_basename_result
cannam@167 5131 my_xlib_u=$my_xlib
cannam@167 5132 while :; do
cannam@167 5133 case " $extracted_archives " in
cannam@167 5134 *" $my_xlib_u "*)
cannam@167 5135 func_arith $extracted_serial + 1
cannam@167 5136 extracted_serial=$func_arith_result
cannam@167 5137 my_xlib_u=lt$extracted_serial-$my_xlib ;;
cannam@167 5138 *) break ;;
cannam@167 5139 esac
cannam@167 5140 done
cannam@167 5141 extracted_archives="$extracted_archives $my_xlib_u"
cannam@167 5142 my_xdir=$my_gentop/$my_xlib_u
cannam@167 5143
cannam@167 5144 func_mkdir_p "$my_xdir"
cannam@167 5145
cannam@167 5146 case $host in
cannam@167 5147 *-darwin*)
cannam@167 5148 func_verbose "Extracting $my_xabs"
cannam@167 5149 # Do not bother doing anything if just a dry run
cannam@167 5150 $opt_dry_run || {
cannam@167 5151 darwin_orig_dir=`pwd`
cannam@167 5152 cd $my_xdir || exit $?
cannam@167 5153 darwin_archive=$my_xabs
cannam@167 5154 darwin_curdir=`pwd`
cannam@167 5155 func_basename "$darwin_archive"
cannam@167 5156 darwin_base_archive=$func_basename_result
cannam@167 5157 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
cannam@167 5158 if test -n "$darwin_arches"; then
cannam@167 5159 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
cannam@167 5160 darwin_arch=
cannam@167 5161 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
cannam@167 5162 for darwin_arch in $darwin_arches; do
cannam@167 5163 func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
cannam@167 5164 $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
cannam@167 5165 cd "unfat-$$/$darwin_base_archive-$darwin_arch"
cannam@167 5166 func_extract_an_archive "`pwd`" "$darwin_base_archive"
cannam@167 5167 cd "$darwin_curdir"
cannam@167 5168 $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
cannam@167 5169 done # $darwin_arches
cannam@167 5170 ## Okay now we've a bunch of thin objects, gotta fatten them up :)
cannam@167 5171 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
cannam@167 5172 darwin_file=
cannam@167 5173 darwin_files=
cannam@167 5174 for darwin_file in $darwin_filelist; do
cannam@167 5175 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
cannam@167 5176 $LIPO -create -output "$darwin_file" $darwin_files
cannam@167 5177 done # $darwin_filelist
cannam@167 5178 $RM -rf unfat-$$
cannam@167 5179 cd "$darwin_orig_dir"
cannam@167 5180 else
cannam@167 5181 cd $darwin_orig_dir
cannam@167 5182 func_extract_an_archive "$my_xdir" "$my_xabs"
cannam@167 5183 fi # $darwin_arches
cannam@167 5184 } # !$opt_dry_run
cannam@167 5185 ;;
cannam@167 5186 *)
cannam@167 5187 func_extract_an_archive "$my_xdir" "$my_xabs"
cannam@167 5188 ;;
cannam@167 5189 esac
cannam@167 5190 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
cannam@167 5191 done
cannam@167 5192
cannam@167 5193 func_extract_archives_result=$my_oldobjs
cannam@167 5194 }
cannam@167 5195
cannam@167 5196
cannam@167 5197 # func_emit_wrapper [arg=no]
cannam@167 5198 #
cannam@167 5199 # Emit a libtool wrapper script on stdout.
cannam@167 5200 # Don't directly open a file because we may want to
cannam@167 5201 # incorporate the script contents within a cygwin/mingw
cannam@167 5202 # wrapper executable. Must ONLY be called from within
cannam@167 5203 # func_mode_link because it depends on a number of variables
cannam@167 5204 # set therein.
cannam@167 5205 #
cannam@167 5206 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
cannam@167 5207 # variable will take. If 'yes', then the emitted script
cannam@167 5208 # will assume that the directory where it is stored is
cannam@167 5209 # the $objdir directory. This is a cygwin/mingw-specific
cannam@167 5210 # behavior.
cannam@167 5211 func_emit_wrapper ()
cannam@167 5212 {
cannam@167 5213 func_emit_wrapper_arg1=${1-no}
cannam@167 5214
cannam@167 5215 $ECHO "\
cannam@167 5216 #! $SHELL
cannam@167 5217
cannam@167 5218 # $output - temporary wrapper script for $objdir/$outputname
cannam@167 5219 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
cannam@167 5220 #
cannam@167 5221 # The $output program cannot be directly executed until all the libtool
cannam@167 5222 # libraries that it depends on are installed.
cannam@167 5223 #
cannam@167 5224 # This wrapper script should never be moved out of the build directory.
cannam@167 5225 # If it is, it will not operate correctly.
cannam@167 5226
cannam@167 5227 # Sed substitution that helps us do robust quoting. It backslashifies
cannam@167 5228 # metacharacters that are still active within double-quoted strings.
cannam@167 5229 sed_quote_subst='$sed_quote_subst'
cannam@167 5230
cannam@167 5231 # Be Bourne compatible
cannam@167 5232 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
cannam@167 5233 emulate sh
cannam@167 5234 NULLCMD=:
cannam@167 5235 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
cannam@167 5236 # is contrary to our usage. Disable this feature.
cannam@167 5237 alias -g '\${1+\"\$@\"}'='\"\$@\"'
cannam@167 5238 setopt NO_GLOB_SUBST
cannam@167 5239 else
cannam@167 5240 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
cannam@167 5241 fi
cannam@167 5242 BIN_SH=xpg4; export BIN_SH # for Tru64
cannam@167 5243 DUALCASE=1; export DUALCASE # for MKS sh
cannam@167 5244
cannam@167 5245 # The HP-UX ksh and POSIX shell print the target directory to stdout
cannam@167 5246 # if CDPATH is set.
cannam@167 5247 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
cannam@167 5248
cannam@167 5249 relink_command=\"$relink_command\"
cannam@167 5250
cannam@167 5251 # This environment variable determines our operation mode.
cannam@167 5252 if test \"\$libtool_install_magic\" = \"$magic\"; then
cannam@167 5253 # install mode needs the following variables:
cannam@167 5254 generated_by_libtool_version='$macro_version'
cannam@167 5255 notinst_deplibs='$notinst_deplibs'
cannam@167 5256 else
cannam@167 5257 # When we are sourced in execute mode, \$file and \$ECHO are already set.
cannam@167 5258 if test \"\$libtool_execute_magic\" != \"$magic\"; then
cannam@167 5259 file=\"\$0\""
cannam@167 5260
cannam@167 5261 qECHO=`$ECHO "$ECHO" | $SED "$sed_quote_subst"`
cannam@167 5262 $ECHO "\
cannam@167 5263
cannam@167 5264 # A function that is used when there is no print builtin or printf.
cannam@167 5265 func_fallback_echo ()
cannam@167 5266 {
cannam@167 5267 eval 'cat <<_LTECHO_EOF
cannam@167 5268 \$1
cannam@167 5269 _LTECHO_EOF'
cannam@167 5270 }
cannam@167 5271 ECHO=\"$qECHO\"
cannam@167 5272 fi
cannam@167 5273
cannam@167 5274 # Very basic option parsing. These options are (a) specific to
cannam@167 5275 # the libtool wrapper, (b) are identical between the wrapper
cannam@167 5276 # /script/ and the wrapper /executable/ that is used only on
cannam@167 5277 # windows platforms, and (c) all begin with the string "--lt-"
cannam@167 5278 # (application programs are unlikely to have options that match
cannam@167 5279 # this pattern).
cannam@167 5280 #
cannam@167 5281 # There are only two supported options: --lt-debug and
cannam@167 5282 # --lt-dump-script. There is, deliberately, no --lt-help.
cannam@167 5283 #
cannam@167 5284 # The first argument to this parsing function should be the
cannam@167 5285 # script's $0 value, followed by "$@".
cannam@167 5286 lt_option_debug=
cannam@167 5287 func_parse_lt_options ()
cannam@167 5288 {
cannam@167 5289 lt_script_arg0=\$0
cannam@167 5290 shift
cannam@167 5291 for lt_opt
cannam@167 5292 do
cannam@167 5293 case \"\$lt_opt\" in
cannam@167 5294 --lt-debug) lt_option_debug=1 ;;
cannam@167 5295 --lt-dump-script)
cannam@167 5296 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
cannam@167 5297 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
cannam@167 5298 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
cannam@167 5299 cat \"\$lt_dump_D/\$lt_dump_F\"
cannam@167 5300 exit 0
cannam@167 5301 ;;
cannam@167 5302 --lt-*)
cannam@167 5303 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
cannam@167 5304 exit 1
cannam@167 5305 ;;
cannam@167 5306 esac
cannam@167 5307 done
cannam@167 5308
cannam@167 5309 # Print the debug banner immediately:
cannam@167 5310 if test -n \"\$lt_option_debug\"; then
cannam@167 5311 echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
cannam@167 5312 fi
cannam@167 5313 }
cannam@167 5314
cannam@167 5315 # Used when --lt-debug. Prints its arguments to stdout
cannam@167 5316 # (redirection is the responsibility of the caller)
cannam@167 5317 func_lt_dump_args ()
cannam@167 5318 {
cannam@167 5319 lt_dump_args_N=1;
cannam@167 5320 for lt_arg
cannam@167 5321 do
cannam@167 5322 \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
cannam@167 5323 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
cannam@167 5324 done
cannam@167 5325 }
cannam@167 5326
cannam@167 5327 # Core function for launching the target application
cannam@167 5328 func_exec_program_core ()
cannam@167 5329 {
cannam@167 5330 "
cannam@167 5331 case $host in
cannam@167 5332 # Backslashes separate directories on plain windows
cannam@167 5333 *-*-mingw | *-*-os2* | *-cegcc*)
cannam@167 5334 $ECHO "\
cannam@167 5335 if test -n \"\$lt_option_debug\"; then
cannam@167 5336 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
cannam@167 5337 func_lt_dump_args \${1+\"\$@\"} 1>&2
cannam@167 5338 fi
cannam@167 5339 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
cannam@167 5340 "
cannam@167 5341 ;;
cannam@167 5342
cannam@167 5343 *)
cannam@167 5344 $ECHO "\
cannam@167 5345 if test -n \"\$lt_option_debug\"; then
cannam@167 5346 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
cannam@167 5347 func_lt_dump_args \${1+\"\$@\"} 1>&2
cannam@167 5348 fi
cannam@167 5349 exec \"\$progdir/\$program\" \${1+\"\$@\"}
cannam@167 5350 "
cannam@167 5351 ;;
cannam@167 5352 esac
cannam@167 5353 $ECHO "\
cannam@167 5354 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
cannam@167 5355 exit 1
cannam@167 5356 }
cannam@167 5357
cannam@167 5358 # A function to encapsulate launching the target application
cannam@167 5359 # Strips options in the --lt-* namespace from \$@ and
cannam@167 5360 # launches target application with the remaining arguments.
cannam@167 5361 func_exec_program ()
cannam@167 5362 {
cannam@167 5363 case \" \$* \" in
cannam@167 5364 *\\ --lt-*)
cannam@167 5365 for lt_wr_arg
cannam@167 5366 do
cannam@167 5367 case \$lt_wr_arg in
cannam@167 5368 --lt-*) ;;
cannam@167 5369 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
cannam@167 5370 esac
cannam@167 5371 shift
cannam@167 5372 done ;;
cannam@167 5373 esac
cannam@167 5374 func_exec_program_core \${1+\"\$@\"}
cannam@167 5375 }
cannam@167 5376
cannam@167 5377 # Parse options
cannam@167 5378 func_parse_lt_options \"\$0\" \${1+\"\$@\"}
cannam@167 5379
cannam@167 5380 # Find the directory that this script lives in.
cannam@167 5381 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
cannam@167 5382 test \"x\$thisdir\" = \"x\$file\" && thisdir=.
cannam@167 5383
cannam@167 5384 # Follow symbolic links until we get to the real thisdir.
cannam@167 5385 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
cannam@167 5386 while test -n \"\$file\"; do
cannam@167 5387 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
cannam@167 5388
cannam@167 5389 # If there was a directory component, then change thisdir.
cannam@167 5390 if test \"x\$destdir\" != \"x\$file\"; then
cannam@167 5391 case \"\$destdir\" in
cannam@167 5392 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
cannam@167 5393 *) thisdir=\"\$thisdir/\$destdir\" ;;
cannam@167 5394 esac
cannam@167 5395 fi
cannam@167 5396
cannam@167 5397 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
cannam@167 5398 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
cannam@167 5399 done
cannam@167 5400
cannam@167 5401 # Usually 'no', except on cygwin/mingw when embedded into
cannam@167 5402 # the cwrapper.
cannam@167 5403 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
cannam@167 5404 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
cannam@167 5405 # special case for '.'
cannam@167 5406 if test \"\$thisdir\" = \".\"; then
cannam@167 5407 thisdir=\`pwd\`
cannam@167 5408 fi
cannam@167 5409 # remove .libs from thisdir
cannam@167 5410 case \"\$thisdir\" in
cannam@167 5411 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
cannam@167 5412 $objdir ) thisdir=. ;;
cannam@167 5413 esac
cannam@167 5414 fi
cannam@167 5415
cannam@167 5416 # Try to get the absolute directory name.
cannam@167 5417 absdir=\`cd \"\$thisdir\" && pwd\`
cannam@167 5418 test -n \"\$absdir\" && thisdir=\"\$absdir\"
cannam@167 5419 "
cannam@167 5420
cannam@167 5421 if test yes = "$fast_install"; then
cannam@167 5422 $ECHO "\
cannam@167 5423 program=lt-'$outputname'$exeext
cannam@167 5424 progdir=\"\$thisdir/$objdir\"
cannam@167 5425
cannam@167 5426 if test ! -f \"\$progdir/\$program\" ||
cannam@167 5427 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
cannam@167 5428 test \"X\$file\" != \"X\$progdir/\$program\"; }; then
cannam@167 5429
cannam@167 5430 file=\"\$\$-\$program\"
cannam@167 5431
cannam@167 5432 if test ! -d \"\$progdir\"; then
cannam@167 5433 $MKDIR \"\$progdir\"
cannam@167 5434 else
cannam@167 5435 $RM \"\$progdir/\$file\"
cannam@167 5436 fi"
cannam@167 5437
cannam@167 5438 $ECHO "\
cannam@167 5439
cannam@167 5440 # relink executable if necessary
cannam@167 5441 if test -n \"\$relink_command\"; then
cannam@167 5442 if relink_command_output=\`eval \$relink_command 2>&1\`; then :
cannam@167 5443 else
cannam@167 5444 \$ECHO \"\$relink_command_output\" >&2
cannam@167 5445 $RM \"\$progdir/\$file\"
cannam@167 5446 exit 1
cannam@167 5447 fi
cannam@167 5448 fi
cannam@167 5449
cannam@167 5450 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
cannam@167 5451 { $RM \"\$progdir/\$program\";
cannam@167 5452 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
cannam@167 5453 $RM \"\$progdir/\$file\"
cannam@167 5454 fi"
cannam@167 5455 else
cannam@167 5456 $ECHO "\
cannam@167 5457 program='$outputname'
cannam@167 5458 progdir=\"\$thisdir/$objdir\"
cannam@167 5459 "
cannam@167 5460 fi
cannam@167 5461
cannam@167 5462 $ECHO "\
cannam@167 5463
cannam@167 5464 if test -f \"\$progdir/\$program\"; then"
cannam@167 5465
cannam@167 5466 # fixup the dll searchpath if we need to.
cannam@167 5467 #
cannam@167 5468 # Fix the DLL searchpath if we need to. Do this before prepending
cannam@167 5469 # to shlibpath, because on Windows, both are PATH and uninstalled
cannam@167 5470 # libraries must come first.
cannam@167 5471 if test -n "$dllsearchpath"; then
cannam@167 5472 $ECHO "\
cannam@167 5473 # Add the dll search path components to the executable PATH
cannam@167 5474 PATH=$dllsearchpath:\$PATH
cannam@167 5475 "
cannam@167 5476 fi
cannam@167 5477
cannam@167 5478 # Export our shlibpath_var if we have one.
cannam@167 5479 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
cannam@167 5480 $ECHO "\
cannam@167 5481 # Add our own library path to $shlibpath_var
cannam@167 5482 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
cannam@167 5483
cannam@167 5484 # Some systems cannot cope with colon-terminated $shlibpath_var
cannam@167 5485 # The second colon is a workaround for a bug in BeOS R4 sed
cannam@167 5486 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
cannam@167 5487
cannam@167 5488 export $shlibpath_var
cannam@167 5489 "
cannam@167 5490 fi
cannam@167 5491
cannam@167 5492 $ECHO "\
cannam@167 5493 if test \"\$libtool_execute_magic\" != \"$magic\"; then
cannam@167 5494 # Run the actual program with our arguments.
cannam@167 5495 func_exec_program \${1+\"\$@\"}
cannam@167 5496 fi
cannam@167 5497 else
cannam@167 5498 # The program doesn't exist.
cannam@167 5499 \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
cannam@167 5500 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
cannam@167 5501 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
cannam@167 5502 exit 1
cannam@167 5503 fi
cannam@167 5504 fi\
cannam@167 5505 "
cannam@167 5506 }
cannam@167 5507
cannam@167 5508
cannam@167 5509 # func_emit_cwrapperexe_src
cannam@167 5510 # emit the source code for a wrapper executable on stdout
cannam@167 5511 # Must ONLY be called from within func_mode_link because
cannam@167 5512 # it depends on a number of variable set therein.
cannam@167 5513 func_emit_cwrapperexe_src ()
cannam@167 5514 {
cannam@167 5515 cat <<EOF
cannam@167 5516
cannam@167 5517 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
cannam@167 5518 Generated by $PROGRAM (GNU $PACKAGE) $VERSION
cannam@167 5519
cannam@167 5520 The $output program cannot be directly executed until all the libtool
cannam@167 5521 libraries that it depends on are installed.
cannam@167 5522
cannam@167 5523 This wrapper executable should never be moved out of the build directory.
cannam@167 5524 If it is, it will not operate correctly.
cannam@167 5525 */
cannam@167 5526 EOF
cannam@167 5527 cat <<"EOF"
cannam@167 5528 #ifdef _MSC_VER
cannam@167 5529 # define _CRT_SECURE_NO_DEPRECATE 1
cannam@167 5530 #endif
cannam@167 5531 #include <stdio.h>
cannam@167 5532 #include <stdlib.h>
cannam@167 5533 #ifdef _MSC_VER
cannam@167 5534 # include <direct.h>
cannam@167 5535 # include <process.h>
cannam@167 5536 # include <io.h>
cannam@167 5537 #else
cannam@167 5538 # include <unistd.h>
cannam@167 5539 # include <stdint.h>
cannam@167 5540 # ifdef __CYGWIN__
cannam@167 5541 # include <io.h>
cannam@167 5542 # endif
cannam@167 5543 #endif
cannam@167 5544 #include <malloc.h>
cannam@167 5545 #include <stdarg.h>
cannam@167 5546 #include <assert.h>
cannam@167 5547 #include <string.h>
cannam@167 5548 #include <ctype.h>
cannam@167 5549 #include <errno.h>
cannam@167 5550 #include <fcntl.h>
cannam@167 5551 #include <sys/stat.h>
cannam@167 5552
cannam@167 5553 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
cannam@167 5554
cannam@167 5555 /* declarations of non-ANSI functions */
cannam@167 5556 #if defined __MINGW32__
cannam@167 5557 # ifdef __STRICT_ANSI__
cannam@167 5558 int _putenv (const char *);
cannam@167 5559 # endif
cannam@167 5560 #elif defined __CYGWIN__
cannam@167 5561 # ifdef __STRICT_ANSI__
cannam@167 5562 char *realpath (const char *, char *);
cannam@167 5563 int putenv (char *);
cannam@167 5564 int setenv (const char *, const char *, int);
cannam@167 5565 # endif
cannam@167 5566 /* #elif defined other_platform || defined ... */
cannam@167 5567 #endif
cannam@167 5568
cannam@167 5569 /* portability defines, excluding path handling macros */
cannam@167 5570 #if defined _MSC_VER
cannam@167 5571 # define setmode _setmode
cannam@167 5572 # define stat _stat
cannam@167 5573 # define chmod _chmod
cannam@167 5574 # define getcwd _getcwd
cannam@167 5575 # define putenv _putenv
cannam@167 5576 # define S_IXUSR _S_IEXEC
cannam@167 5577 #elif defined __MINGW32__
cannam@167 5578 # define setmode _setmode
cannam@167 5579 # define stat _stat
cannam@167 5580 # define chmod _chmod
cannam@167 5581 # define getcwd _getcwd
cannam@167 5582 # define putenv _putenv
cannam@167 5583 #elif defined __CYGWIN__
cannam@167 5584 # define HAVE_SETENV
cannam@167 5585 # define FOPEN_WB "wb"
cannam@167 5586 /* #elif defined other platforms ... */
cannam@167 5587 #endif
cannam@167 5588
cannam@167 5589 #if defined PATH_MAX
cannam@167 5590 # define LT_PATHMAX PATH_MAX
cannam@167 5591 #elif defined MAXPATHLEN
cannam@167 5592 # define LT_PATHMAX MAXPATHLEN
cannam@167 5593 #else
cannam@167 5594 # define LT_PATHMAX 1024
cannam@167 5595 #endif
cannam@167 5596
cannam@167 5597 #ifndef S_IXOTH
cannam@167 5598 # define S_IXOTH 0
cannam@167 5599 #endif
cannam@167 5600 #ifndef S_IXGRP
cannam@167 5601 # define S_IXGRP 0
cannam@167 5602 #endif
cannam@167 5603
cannam@167 5604 /* path handling portability macros */
cannam@167 5605 #ifndef DIR_SEPARATOR
cannam@167 5606 # define DIR_SEPARATOR '/'
cannam@167 5607 # define PATH_SEPARATOR ':'
cannam@167 5608 #endif
cannam@167 5609
cannam@167 5610 #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
cannam@167 5611 defined __OS2__
cannam@167 5612 # define HAVE_DOS_BASED_FILE_SYSTEM
cannam@167 5613 # define FOPEN_WB "wb"
cannam@167 5614 # ifndef DIR_SEPARATOR_2
cannam@167 5615 # define DIR_SEPARATOR_2 '\\'
cannam@167 5616 # endif
cannam@167 5617 # ifndef PATH_SEPARATOR_2
cannam@167 5618 # define PATH_SEPARATOR_2 ';'
cannam@167 5619 # endif
cannam@167 5620 #endif
cannam@167 5621
cannam@167 5622 #ifndef DIR_SEPARATOR_2
cannam@167 5623 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
cannam@167 5624 #else /* DIR_SEPARATOR_2 */
cannam@167 5625 # define IS_DIR_SEPARATOR(ch) \
cannam@167 5626 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
cannam@167 5627 #endif /* DIR_SEPARATOR_2 */
cannam@167 5628
cannam@167 5629 #ifndef PATH_SEPARATOR_2
cannam@167 5630 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
cannam@167 5631 #else /* PATH_SEPARATOR_2 */
cannam@167 5632 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
cannam@167 5633 #endif /* PATH_SEPARATOR_2 */
cannam@167 5634
cannam@167 5635 #ifndef FOPEN_WB
cannam@167 5636 # define FOPEN_WB "w"
cannam@167 5637 #endif
cannam@167 5638 #ifndef _O_BINARY
cannam@167 5639 # define _O_BINARY 0
cannam@167 5640 #endif
cannam@167 5641
cannam@167 5642 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
cannam@167 5643 #define XFREE(stale) do { \
cannam@167 5644 if (stale) { free (stale); stale = 0; } \
cannam@167 5645 } while (0)
cannam@167 5646
cannam@167 5647 #if defined LT_DEBUGWRAPPER
cannam@167 5648 static int lt_debug = 1;
cannam@167 5649 #else
cannam@167 5650 static int lt_debug = 0;
cannam@167 5651 #endif
cannam@167 5652
cannam@167 5653 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
cannam@167 5654
cannam@167 5655 void *xmalloc (size_t num);
cannam@167 5656 char *xstrdup (const char *string);
cannam@167 5657 const char *base_name (const char *name);
cannam@167 5658 char *find_executable (const char *wrapper);
cannam@167 5659 char *chase_symlinks (const char *pathspec);
cannam@167 5660 int make_executable (const char *path);
cannam@167 5661 int check_executable (const char *path);
cannam@167 5662 char *strendzap (char *str, const char *pat);
cannam@167 5663 void lt_debugprintf (const char *file, int line, const char *fmt, ...);
cannam@167 5664 void lt_fatal (const char *file, int line, const char *message, ...);
cannam@167 5665 static const char *nonnull (const char *s);
cannam@167 5666 static const char *nonempty (const char *s);
cannam@167 5667 void lt_setenv (const char *name, const char *value);
cannam@167 5668 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
cannam@167 5669 void lt_update_exe_path (const char *name, const char *value);
cannam@167 5670 void lt_update_lib_path (const char *name, const char *value);
cannam@167 5671 char **prepare_spawn (char **argv);
cannam@167 5672 void lt_dump_script (FILE *f);
cannam@167 5673 EOF
cannam@167 5674
cannam@167 5675 cat <<EOF
cannam@167 5676 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
cannam@167 5677 # define externally_visible volatile
cannam@167 5678 #else
cannam@167 5679 # define externally_visible __attribute__((externally_visible)) volatile
cannam@167 5680 #endif
cannam@167 5681 externally_visible const char * MAGIC_EXE = "$magic_exe";
cannam@167 5682 const char * LIB_PATH_VARNAME = "$shlibpath_var";
cannam@167 5683 EOF
cannam@167 5684
cannam@167 5685 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
cannam@167 5686 func_to_host_path "$temp_rpath"
cannam@167 5687 cat <<EOF
cannam@167 5688 const char * LIB_PATH_VALUE = "$func_to_host_path_result";
cannam@167 5689 EOF
cannam@167 5690 else
cannam@167 5691 cat <<"EOF"
cannam@167 5692 const char * LIB_PATH_VALUE = "";
cannam@167 5693 EOF
cannam@167 5694 fi
cannam@167 5695
cannam@167 5696 if test -n "$dllsearchpath"; then
cannam@167 5697 func_to_host_path "$dllsearchpath:"
cannam@167 5698 cat <<EOF
cannam@167 5699 const char * EXE_PATH_VARNAME = "PATH";
cannam@167 5700 const char * EXE_PATH_VALUE = "$func_to_host_path_result";
cannam@167 5701 EOF
cannam@167 5702 else
cannam@167 5703 cat <<"EOF"
cannam@167 5704 const char * EXE_PATH_VARNAME = "";
cannam@167 5705 const char * EXE_PATH_VALUE = "";
cannam@167 5706 EOF
cannam@167 5707 fi
cannam@167 5708
cannam@167 5709 if test yes = "$fast_install"; then
cannam@167 5710 cat <<EOF
cannam@167 5711 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
cannam@167 5712 EOF
cannam@167 5713 else
cannam@167 5714 cat <<EOF
cannam@167 5715 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
cannam@167 5716 EOF
cannam@167 5717 fi
cannam@167 5718
cannam@167 5719
cannam@167 5720 cat <<"EOF"
cannam@167 5721
cannam@167 5722 #define LTWRAPPER_OPTION_PREFIX "--lt-"
cannam@167 5723
cannam@167 5724 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
cannam@167 5725 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
cannam@167 5726 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
cannam@167 5727
cannam@167 5728 int
cannam@167 5729 main (int argc, char *argv[])
cannam@167 5730 {
cannam@167 5731 char **newargz;
cannam@167 5732 int newargc;
cannam@167 5733 char *tmp_pathspec;
cannam@167 5734 char *actual_cwrapper_path;
cannam@167 5735 char *actual_cwrapper_name;
cannam@167 5736 char *target_name;
cannam@167 5737 char *lt_argv_zero;
cannam@167 5738 int rval = 127;
cannam@167 5739
cannam@167 5740 int i;
cannam@167 5741
cannam@167 5742 program_name = (char *) xstrdup (base_name (argv[0]));
cannam@167 5743 newargz = XMALLOC (char *, (size_t) argc + 1);
cannam@167 5744
cannam@167 5745 /* very simple arg parsing; don't want to rely on getopt
cannam@167 5746 * also, copy all non cwrapper options to newargz, except
cannam@167 5747 * argz[0], which is handled differently
cannam@167 5748 */
cannam@167 5749 newargc=0;
cannam@167 5750 for (i = 1; i < argc; i++)
cannam@167 5751 {
cannam@167 5752 if (STREQ (argv[i], dumpscript_opt))
cannam@167 5753 {
cannam@167 5754 EOF
cannam@167 5755 case $host in
cannam@167 5756 *mingw* | *cygwin* )
cannam@167 5757 # make stdout use "unix" line endings
cannam@167 5758 echo " setmode(1,_O_BINARY);"
cannam@167 5759 ;;
cannam@167 5760 esac
cannam@167 5761
cannam@167 5762 cat <<"EOF"
cannam@167 5763 lt_dump_script (stdout);
cannam@167 5764 return 0;
cannam@167 5765 }
cannam@167 5766 if (STREQ (argv[i], debug_opt))
cannam@167 5767 {
cannam@167 5768 lt_debug = 1;
cannam@167 5769 continue;
cannam@167 5770 }
cannam@167 5771 if (STREQ (argv[i], ltwrapper_option_prefix))
cannam@167 5772 {
cannam@167 5773 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
cannam@167 5774 namespace, but it is not one of the ones we know about and
cannam@167 5775 have already dealt with, above (inluding dump-script), then
cannam@167 5776 report an error. Otherwise, targets might begin to believe
cannam@167 5777 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
cannam@167 5778 namespace. The first time any user complains about this, we'll
cannam@167 5779 need to make LTWRAPPER_OPTION_PREFIX a configure-time option
cannam@167 5780 or a configure.ac-settable value.
cannam@167 5781 */
cannam@167 5782 lt_fatal (__FILE__, __LINE__,
cannam@167 5783 "unrecognized %s option: '%s'",
cannam@167 5784 ltwrapper_option_prefix, argv[i]);
cannam@167 5785 }
cannam@167 5786 /* otherwise ... */
cannam@167 5787 newargz[++newargc] = xstrdup (argv[i]);
cannam@167 5788 }
cannam@167 5789 newargz[++newargc] = NULL;
cannam@167 5790
cannam@167 5791 EOF
cannam@167 5792 cat <<EOF
cannam@167 5793 /* The GNU banner must be the first non-error debug message */
cannam@167 5794 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
cannam@167 5795 EOF
cannam@167 5796 cat <<"EOF"
cannam@167 5797 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
cannam@167 5798 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
cannam@167 5799
cannam@167 5800 tmp_pathspec = find_executable (argv[0]);
cannam@167 5801 if (tmp_pathspec == NULL)
cannam@167 5802 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
cannam@167 5803 lt_debugprintf (__FILE__, __LINE__,
cannam@167 5804 "(main) found exe (before symlink chase) at: %s\n",
cannam@167 5805 tmp_pathspec);
cannam@167 5806
cannam@167 5807 actual_cwrapper_path = chase_symlinks (tmp_pathspec);
cannam@167 5808 lt_debugprintf (__FILE__, __LINE__,
cannam@167 5809 "(main) found exe (after symlink chase) at: %s\n",
cannam@167 5810 actual_cwrapper_path);
cannam@167 5811 XFREE (tmp_pathspec);
cannam@167 5812
cannam@167 5813 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
cannam@167 5814 strendzap (actual_cwrapper_path, actual_cwrapper_name);
cannam@167 5815
cannam@167 5816 /* wrapper name transforms */
cannam@167 5817 strendzap (actual_cwrapper_name, ".exe");
cannam@167 5818 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
cannam@167 5819 XFREE (actual_cwrapper_name);
cannam@167 5820 actual_cwrapper_name = tmp_pathspec;
cannam@167 5821 tmp_pathspec = 0;
cannam@167 5822
cannam@167 5823 /* target_name transforms -- use actual target program name; might have lt- prefix */
cannam@167 5824 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
cannam@167 5825 strendzap (target_name, ".exe");
cannam@167 5826 tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
cannam@167 5827 XFREE (target_name);
cannam@167 5828 target_name = tmp_pathspec;
cannam@167 5829 tmp_pathspec = 0;
cannam@167 5830
cannam@167 5831 lt_debugprintf (__FILE__, __LINE__,
cannam@167 5832 "(main) libtool target name: %s\n",
cannam@167 5833 target_name);
cannam@167 5834 EOF
cannam@167 5835
cannam@167 5836 cat <<EOF
cannam@167 5837 newargz[0] =
cannam@167 5838 XMALLOC (char, (strlen (actual_cwrapper_path) +
cannam@167 5839 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
cannam@167 5840 strcpy (newargz[0], actual_cwrapper_path);
cannam@167 5841 strcat (newargz[0], "$objdir");
cannam@167 5842 strcat (newargz[0], "/");
cannam@167 5843 EOF
cannam@167 5844
cannam@167 5845 cat <<"EOF"
cannam@167 5846 /* stop here, and copy so we don't have to do this twice */
cannam@167 5847 tmp_pathspec = xstrdup (newargz[0]);
cannam@167 5848
cannam@167 5849 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
cannam@167 5850 strcat (newargz[0], actual_cwrapper_name);
cannam@167 5851
cannam@167 5852 /* DO want the lt- prefix here if it exists, so use target_name */
cannam@167 5853 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
cannam@167 5854 XFREE (tmp_pathspec);
cannam@167 5855 tmp_pathspec = NULL;
cannam@167 5856 EOF
cannam@167 5857
cannam@167 5858 case $host_os in
cannam@167 5859 mingw*)
cannam@167 5860 cat <<"EOF"
cannam@167 5861 {
cannam@167 5862 char* p;
cannam@167 5863 while ((p = strchr (newargz[0], '\\')) != NULL)
cannam@167 5864 {
cannam@167 5865 *p = '/';
cannam@167 5866 }
cannam@167 5867 while ((p = strchr (lt_argv_zero, '\\')) != NULL)
cannam@167 5868 {
cannam@167 5869 *p = '/';
cannam@167 5870 }
cannam@167 5871 }
cannam@167 5872 EOF
cannam@167 5873 ;;
cannam@167 5874 esac
cannam@167 5875
cannam@167 5876 cat <<"EOF"
cannam@167 5877 XFREE (target_name);
cannam@167 5878 XFREE (actual_cwrapper_path);
cannam@167 5879 XFREE (actual_cwrapper_name);
cannam@167 5880
cannam@167 5881 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
cannam@167 5882 lt_setenv ("DUALCASE", "1"); /* for MSK sh */
cannam@167 5883 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
cannam@167 5884 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
cannam@167 5885 because on Windows, both *_VARNAMEs are PATH but uninstalled
cannam@167 5886 libraries must come first. */
cannam@167 5887 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
cannam@167 5888 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
cannam@167 5889
cannam@167 5890 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
cannam@167 5891 nonnull (lt_argv_zero));
cannam@167 5892 for (i = 0; i < newargc; i++)
cannam@167 5893 {
cannam@167 5894 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
cannam@167 5895 i, nonnull (newargz[i]));
cannam@167 5896 }
cannam@167 5897
cannam@167 5898 EOF
cannam@167 5899
cannam@167 5900 case $host_os in
cannam@167 5901 mingw*)
cannam@167 5902 cat <<"EOF"
cannam@167 5903 /* execv doesn't actually work on mingw as expected on unix */
cannam@167 5904 newargz = prepare_spawn (newargz);
cannam@167 5905 rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
cannam@167 5906 if (rval == -1)
cannam@167 5907 {
cannam@167 5908 /* failed to start process */
cannam@167 5909 lt_debugprintf (__FILE__, __LINE__,
cannam@167 5910 "(main) failed to launch target \"%s\": %s\n",
cannam@167 5911 lt_argv_zero, nonnull (strerror (errno)));
cannam@167 5912 return 127;
cannam@167 5913 }
cannam@167 5914 return rval;
cannam@167 5915 EOF
cannam@167 5916 ;;
cannam@167 5917 *)
cannam@167 5918 cat <<"EOF"
cannam@167 5919 execv (lt_argv_zero, newargz);
cannam@167 5920 return rval; /* =127, but avoids unused variable warning */
cannam@167 5921 EOF
cannam@167 5922 ;;
cannam@167 5923 esac
cannam@167 5924
cannam@167 5925 cat <<"EOF"
cannam@167 5926 }
cannam@167 5927
cannam@167 5928 void *
cannam@167 5929 xmalloc (size_t num)
cannam@167 5930 {
cannam@167 5931 void *p = (void *) malloc (num);
cannam@167 5932 if (!p)
cannam@167 5933 lt_fatal (__FILE__, __LINE__, "memory exhausted");
cannam@167 5934
cannam@167 5935 return p;
cannam@167 5936 }
cannam@167 5937
cannam@167 5938 char *
cannam@167 5939 xstrdup (const char *string)
cannam@167 5940 {
cannam@167 5941 return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
cannam@167 5942 string) : NULL;
cannam@167 5943 }
cannam@167 5944
cannam@167 5945 const char *
cannam@167 5946 base_name (const char *name)
cannam@167 5947 {
cannam@167 5948 const char *base;
cannam@167 5949
cannam@167 5950 #if defined HAVE_DOS_BASED_FILE_SYSTEM
cannam@167 5951 /* Skip over the disk name in MSDOS pathnames. */
cannam@167 5952 if (isalpha ((unsigned char) name[0]) && name[1] == ':')
cannam@167 5953 name += 2;
cannam@167 5954 #endif
cannam@167 5955
cannam@167 5956 for (base = name; *name; name++)
cannam@167 5957 if (IS_DIR_SEPARATOR (*name))
cannam@167 5958 base = name + 1;
cannam@167 5959 return base;
cannam@167 5960 }
cannam@167 5961
cannam@167 5962 int
cannam@167 5963 check_executable (const char *path)
cannam@167 5964 {
cannam@167 5965 struct stat st;
cannam@167 5966
cannam@167 5967 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
cannam@167 5968 nonempty (path));
cannam@167 5969 if ((!path) || (!*path))
cannam@167 5970 return 0;
cannam@167 5971
cannam@167 5972 if ((stat (path, &st) >= 0)
cannam@167 5973 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
cannam@167 5974 return 1;
cannam@167 5975 else
cannam@167 5976 return 0;
cannam@167 5977 }
cannam@167 5978
cannam@167 5979 int
cannam@167 5980 make_executable (const char *path)
cannam@167 5981 {
cannam@167 5982 int rval = 0;
cannam@167 5983 struct stat st;
cannam@167 5984
cannam@167 5985 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
cannam@167 5986 nonempty (path));
cannam@167 5987 if ((!path) || (!*path))
cannam@167 5988 return 0;
cannam@167 5989
cannam@167 5990 if (stat (path, &st) >= 0)
cannam@167 5991 {
cannam@167 5992 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
cannam@167 5993 }
cannam@167 5994 return rval;
cannam@167 5995 }
cannam@167 5996
cannam@167 5997 /* Searches for the full path of the wrapper. Returns
cannam@167 5998 newly allocated full path name if found, NULL otherwise
cannam@167 5999 Does not chase symlinks, even on platforms that support them.
cannam@167 6000 */
cannam@167 6001 char *
cannam@167 6002 find_executable (const char *wrapper)
cannam@167 6003 {
cannam@167 6004 int has_slash = 0;
cannam@167 6005 const char *p;
cannam@167 6006 const char *p_next;
cannam@167 6007 /* static buffer for getcwd */
cannam@167 6008 char tmp[LT_PATHMAX + 1];
cannam@167 6009 size_t tmp_len;
cannam@167 6010 char *concat_name;
cannam@167 6011
cannam@167 6012 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
cannam@167 6013 nonempty (wrapper));
cannam@167 6014
cannam@167 6015 if ((wrapper == NULL) || (*wrapper == '\0'))
cannam@167 6016 return NULL;
cannam@167 6017
cannam@167 6018 /* Absolute path? */
cannam@167 6019 #if defined HAVE_DOS_BASED_FILE_SYSTEM
cannam@167 6020 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
cannam@167 6021 {
cannam@167 6022 concat_name = xstrdup (wrapper);
cannam@167 6023 if (check_executable (concat_name))
cannam@167 6024 return concat_name;
cannam@167 6025 XFREE (concat_name);
cannam@167 6026 }
cannam@167 6027 else
cannam@167 6028 {
cannam@167 6029 #endif
cannam@167 6030 if (IS_DIR_SEPARATOR (wrapper[0]))
cannam@167 6031 {
cannam@167 6032 concat_name = xstrdup (wrapper);
cannam@167 6033 if (check_executable (concat_name))
cannam@167 6034 return concat_name;
cannam@167 6035 XFREE (concat_name);
cannam@167 6036 }
cannam@167 6037 #if defined HAVE_DOS_BASED_FILE_SYSTEM
cannam@167 6038 }
cannam@167 6039 #endif
cannam@167 6040
cannam@167 6041 for (p = wrapper; *p; p++)
cannam@167 6042 if (*p == '/')
cannam@167 6043 {
cannam@167 6044 has_slash = 1;
cannam@167 6045 break;
cannam@167 6046 }
cannam@167 6047 if (!has_slash)
cannam@167 6048 {
cannam@167 6049 /* no slashes; search PATH */
cannam@167 6050 const char *path = getenv ("PATH");
cannam@167 6051 if (path != NULL)
cannam@167 6052 {
cannam@167 6053 for (p = path; *p; p = p_next)
cannam@167 6054 {
cannam@167 6055 const char *q;
cannam@167 6056 size_t p_len;
cannam@167 6057 for (q = p; *q; q++)
cannam@167 6058 if (IS_PATH_SEPARATOR (*q))
cannam@167 6059 break;
cannam@167 6060 p_len = (size_t) (q - p);
cannam@167 6061 p_next = (*q == '\0' ? q : q + 1);
cannam@167 6062 if (p_len == 0)
cannam@167 6063 {
cannam@167 6064 /* empty path: current directory */
cannam@167 6065 if (getcwd (tmp, LT_PATHMAX) == NULL)
cannam@167 6066 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
cannam@167 6067 nonnull (strerror (errno)));
cannam@167 6068 tmp_len = strlen (tmp);
cannam@167 6069 concat_name =
cannam@167 6070 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
cannam@167 6071 memcpy (concat_name, tmp, tmp_len);
cannam@167 6072 concat_name[tmp_len] = '/';
cannam@167 6073 strcpy (concat_name + tmp_len + 1, wrapper);
cannam@167 6074 }
cannam@167 6075 else
cannam@167 6076 {
cannam@167 6077 concat_name =
cannam@167 6078 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
cannam@167 6079 memcpy (concat_name, p, p_len);
cannam@167 6080 concat_name[p_len] = '/';
cannam@167 6081 strcpy (concat_name + p_len + 1, wrapper);
cannam@167 6082 }
cannam@167 6083 if (check_executable (concat_name))
cannam@167 6084 return concat_name;
cannam@167 6085 XFREE (concat_name);
cannam@167 6086 }
cannam@167 6087 }
cannam@167 6088 /* not found in PATH; assume curdir */
cannam@167 6089 }
cannam@167 6090 /* Relative path | not found in path: prepend cwd */
cannam@167 6091 if (getcwd (tmp, LT_PATHMAX) == NULL)
cannam@167 6092 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
cannam@167 6093 nonnull (strerror (errno)));
cannam@167 6094 tmp_len = strlen (tmp);
cannam@167 6095 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
cannam@167 6096 memcpy (concat_name, tmp, tmp_len);
cannam@167 6097 concat_name[tmp_len] = '/';
cannam@167 6098 strcpy (concat_name + tmp_len + 1, wrapper);
cannam@167 6099
cannam@167 6100 if (check_executable (concat_name))
cannam@167 6101 return concat_name;
cannam@167 6102 XFREE (concat_name);
cannam@167 6103 return NULL;
cannam@167 6104 }
cannam@167 6105
cannam@167 6106 char *
cannam@167 6107 chase_symlinks (const char *pathspec)
cannam@167 6108 {
cannam@167 6109 #ifndef S_ISLNK
cannam@167 6110 return xstrdup (pathspec);
cannam@167 6111 #else
cannam@167 6112 char buf[LT_PATHMAX];
cannam@167 6113 struct stat s;
cannam@167 6114 char *tmp_pathspec = xstrdup (pathspec);
cannam@167 6115 char *p;
cannam@167 6116 int has_symlinks = 0;
cannam@167 6117 while (strlen (tmp_pathspec) && !has_symlinks)
cannam@167 6118 {
cannam@167 6119 lt_debugprintf (__FILE__, __LINE__,
cannam@167 6120 "checking path component for symlinks: %s\n",
cannam@167 6121 tmp_pathspec);
cannam@167 6122 if (lstat (tmp_pathspec, &s) == 0)
cannam@167 6123 {
cannam@167 6124 if (S_ISLNK (s.st_mode) != 0)
cannam@167 6125 {
cannam@167 6126 has_symlinks = 1;
cannam@167 6127 break;
cannam@167 6128 }
cannam@167 6129
cannam@167 6130 /* search backwards for last DIR_SEPARATOR */
cannam@167 6131 p = tmp_pathspec + strlen (tmp_pathspec) - 1;
cannam@167 6132 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
cannam@167 6133 p--;
cannam@167 6134 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
cannam@167 6135 {
cannam@167 6136 /* no more DIR_SEPARATORS left */
cannam@167 6137 break;
cannam@167 6138 }
cannam@167 6139 *p = '\0';
cannam@167 6140 }
cannam@167 6141 else
cannam@167 6142 {
cannam@167 6143 lt_fatal (__FILE__, __LINE__,
cannam@167 6144 "error accessing file \"%s\": %s",
cannam@167 6145 tmp_pathspec, nonnull (strerror (errno)));
cannam@167 6146 }
cannam@167 6147 }
cannam@167 6148 XFREE (tmp_pathspec);
cannam@167 6149
cannam@167 6150 if (!has_symlinks)
cannam@167 6151 {
cannam@167 6152 return xstrdup (pathspec);
cannam@167 6153 }
cannam@167 6154
cannam@167 6155 tmp_pathspec = realpath (pathspec, buf);
cannam@167 6156 if (tmp_pathspec == 0)
cannam@167 6157 {
cannam@167 6158 lt_fatal (__FILE__, __LINE__,
cannam@167 6159 "could not follow symlinks for %s", pathspec);
cannam@167 6160 }
cannam@167 6161 return xstrdup (tmp_pathspec);
cannam@167 6162 #endif
cannam@167 6163 }
cannam@167 6164
cannam@167 6165 char *
cannam@167 6166 strendzap (char *str, const char *pat)
cannam@167 6167 {
cannam@167 6168 size_t len, patlen;
cannam@167 6169
cannam@167 6170 assert (str != NULL);
cannam@167 6171 assert (pat != NULL);
cannam@167 6172
cannam@167 6173 len = strlen (str);
cannam@167 6174 patlen = strlen (pat);
cannam@167 6175
cannam@167 6176 if (patlen <= len)
cannam@167 6177 {
cannam@167 6178 str += len - patlen;
cannam@167 6179 if (STREQ (str, pat))
cannam@167 6180 *str = '\0';
cannam@167 6181 }
cannam@167 6182 return str;
cannam@167 6183 }
cannam@167 6184
cannam@167 6185 void
cannam@167 6186 lt_debugprintf (const char *file, int line, const char *fmt, ...)
cannam@167 6187 {
cannam@167 6188 va_list args;
cannam@167 6189 if (lt_debug)
cannam@167 6190 {
cannam@167 6191 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
cannam@167 6192 va_start (args, fmt);
cannam@167 6193 (void) vfprintf (stderr, fmt, args);
cannam@167 6194 va_end (args);
cannam@167 6195 }
cannam@167 6196 }
cannam@167 6197
cannam@167 6198 static void
cannam@167 6199 lt_error_core (int exit_status, const char *file,
cannam@167 6200 int line, const char *mode,
cannam@167 6201 const char *message, va_list ap)
cannam@167 6202 {
cannam@167 6203 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
cannam@167 6204 vfprintf (stderr, message, ap);
cannam@167 6205 fprintf (stderr, ".\n");
cannam@167 6206
cannam@167 6207 if (exit_status >= 0)
cannam@167 6208 exit (exit_status);
cannam@167 6209 }
cannam@167 6210
cannam@167 6211 void
cannam@167 6212 lt_fatal (const char *file, int line, const char *message, ...)
cannam@167 6213 {
cannam@167 6214 va_list ap;
cannam@167 6215 va_start (ap, message);
cannam@167 6216 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
cannam@167 6217 va_end (ap);
cannam@167 6218 }
cannam@167 6219
cannam@167 6220 static const char *
cannam@167 6221 nonnull (const char *s)
cannam@167 6222 {
cannam@167 6223 return s ? s : "(null)";
cannam@167 6224 }
cannam@167 6225
cannam@167 6226 static const char *
cannam@167 6227 nonempty (const char *s)
cannam@167 6228 {
cannam@167 6229 return (s && !*s) ? "(empty)" : nonnull (s);
cannam@167 6230 }
cannam@167 6231
cannam@167 6232 void
cannam@167 6233 lt_setenv (const char *name, const char *value)
cannam@167 6234 {
cannam@167 6235 lt_debugprintf (__FILE__, __LINE__,
cannam@167 6236 "(lt_setenv) setting '%s' to '%s'\n",
cannam@167 6237 nonnull (name), nonnull (value));
cannam@167 6238 {
cannam@167 6239 #ifdef HAVE_SETENV
cannam@167 6240 /* always make a copy, for consistency with !HAVE_SETENV */
cannam@167 6241 char *str = xstrdup (value);
cannam@167 6242 setenv (name, str, 1);
cannam@167 6243 #else
cannam@167 6244 size_t len = strlen (name) + 1 + strlen (value) + 1;
cannam@167 6245 char *str = XMALLOC (char, len);
cannam@167 6246 sprintf (str, "%s=%s", name, value);
cannam@167 6247 if (putenv (str) != EXIT_SUCCESS)
cannam@167 6248 {
cannam@167 6249 XFREE (str);
cannam@167 6250 }
cannam@167 6251 #endif
cannam@167 6252 }
cannam@167 6253 }
cannam@167 6254
cannam@167 6255 char *
cannam@167 6256 lt_extend_str (const char *orig_value, const char *add, int to_end)
cannam@167 6257 {
cannam@167 6258 char *new_value;
cannam@167 6259 if (orig_value && *orig_value)
cannam@167 6260 {
cannam@167 6261 size_t orig_value_len = strlen (orig_value);
cannam@167 6262 size_t add_len = strlen (add);
cannam@167 6263 new_value = XMALLOC (char, add_len + orig_value_len + 1);
cannam@167 6264 if (to_end)
cannam@167 6265 {
cannam@167 6266 strcpy (new_value, orig_value);
cannam@167 6267 strcpy (new_value + orig_value_len, add);
cannam@167 6268 }
cannam@167 6269 else
cannam@167 6270 {
cannam@167 6271 strcpy (new_value, add);
cannam@167 6272 strcpy (new_value + add_len, orig_value);
cannam@167 6273 }
cannam@167 6274 }
cannam@167 6275 else
cannam@167 6276 {
cannam@167 6277 new_value = xstrdup (add);
cannam@167 6278 }
cannam@167 6279 return new_value;
cannam@167 6280 }
cannam@167 6281
cannam@167 6282 void
cannam@167 6283 lt_update_exe_path (const char *name, const char *value)
cannam@167 6284 {
cannam@167 6285 lt_debugprintf (__FILE__, __LINE__,
cannam@167 6286 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
cannam@167 6287 nonnull (name), nonnull (value));
cannam@167 6288
cannam@167 6289 if (name && *name && value && *value)
cannam@167 6290 {
cannam@167 6291 char *new_value = lt_extend_str (getenv (name), value, 0);
cannam@167 6292 /* some systems can't cope with a ':'-terminated path #' */
cannam@167 6293 size_t len = strlen (new_value);
cannam@167 6294 while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
cannam@167 6295 {
cannam@167 6296 new_value[--len] = '\0';
cannam@167 6297 }
cannam@167 6298 lt_setenv (name, new_value);
cannam@167 6299 XFREE (new_value);
cannam@167 6300 }
cannam@167 6301 }
cannam@167 6302
cannam@167 6303 void
cannam@167 6304 lt_update_lib_path (const char *name, const char *value)
cannam@167 6305 {
cannam@167 6306 lt_debugprintf (__FILE__, __LINE__,
cannam@167 6307 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
cannam@167 6308 nonnull (name), nonnull (value));
cannam@167 6309
cannam@167 6310 if (name && *name && value && *value)
cannam@167 6311 {
cannam@167 6312 char *new_value = lt_extend_str (getenv (name), value, 0);
cannam@167 6313 lt_setenv (name, new_value);
cannam@167 6314 XFREE (new_value);
cannam@167 6315 }
cannam@167 6316 }
cannam@167 6317
cannam@167 6318 EOF
cannam@167 6319 case $host_os in
cannam@167 6320 mingw*)
cannam@167 6321 cat <<"EOF"
cannam@167 6322
cannam@167 6323 /* Prepares an argument vector before calling spawn().
cannam@167 6324 Note that spawn() does not by itself call the command interpreter
cannam@167 6325 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
cannam@167 6326 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
cannam@167 6327 GetVersionEx(&v);
cannam@167 6328 v.dwPlatformId == VER_PLATFORM_WIN32_NT;
cannam@167 6329 }) ? "cmd.exe" : "command.com").
cannam@167 6330 Instead it simply concatenates the arguments, separated by ' ', and calls
cannam@167 6331 CreateProcess(). We must quote the arguments since Win32 CreateProcess()
cannam@167 6332 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
cannam@167 6333 special way:
cannam@167 6334 - Space and tab are interpreted as delimiters. They are not treated as
cannam@167 6335 delimiters if they are surrounded by double quotes: "...".
cannam@167 6336 - Unescaped double quotes are removed from the input. Their only effect is
cannam@167 6337 that within double quotes, space and tab are treated like normal
cannam@167 6338 characters.
cannam@167 6339 - Backslashes not followed by double quotes are not special.
cannam@167 6340 - But 2*n+1 backslashes followed by a double quote become
cannam@167 6341 n backslashes followed by a double quote (n >= 0):
cannam@167 6342 \" -> "
cannam@167 6343 \\\" -> \"
cannam@167 6344 \\\\\" -> \\"
cannam@167 6345 */
cannam@167 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@167 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@167 6348 char **
cannam@167 6349 prepare_spawn (char **argv)
cannam@167 6350 {
cannam@167 6351 size_t argc;
cannam@167 6352 char **new_argv;
cannam@167 6353 size_t i;
cannam@167 6354
cannam@167 6355 /* Count number of arguments. */
cannam@167 6356 for (argc = 0; argv[argc] != NULL; argc++)
cannam@167 6357 ;
cannam@167 6358
cannam@167 6359 /* Allocate new argument vector. */
cannam@167 6360 new_argv = XMALLOC (char *, argc + 1);
cannam@167 6361
cannam@167 6362 /* Put quoted arguments into the new argument vector. */
cannam@167 6363 for (i = 0; i < argc; i++)
cannam@167 6364 {
cannam@167 6365 const char *string = argv[i];
cannam@167 6366
cannam@167 6367 if (string[0] == '\0')
cannam@167 6368 new_argv[i] = xstrdup ("\"\"");
cannam@167 6369 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
cannam@167 6370 {
cannam@167 6371 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
cannam@167 6372 size_t length;
cannam@167 6373 unsigned int backslashes;
cannam@167 6374 const char *s;
cannam@167 6375 char *quoted_string;
cannam@167 6376 char *p;
cannam@167 6377
cannam@167 6378 length = 0;
cannam@167 6379 backslashes = 0;
cannam@167 6380 if (quote_around)
cannam@167 6381 length++;
cannam@167 6382 for (s = string; *s != '\0'; s++)
cannam@167 6383 {
cannam@167 6384 char c = *s;
cannam@167 6385 if (c == '"')
cannam@167 6386 length += backslashes + 1;
cannam@167 6387 length++;
cannam@167 6388 if (c == '\\')
cannam@167 6389 backslashes++;
cannam@167 6390 else
cannam@167 6391 backslashes = 0;
cannam@167 6392 }
cannam@167 6393 if (quote_around)
cannam@167 6394 length += backslashes + 1;
cannam@167 6395
cannam@167 6396 quoted_string = XMALLOC (char, length + 1);
cannam@167 6397
cannam@167 6398 p = quoted_string;
cannam@167 6399 backslashes = 0;
cannam@167 6400 if (quote_around)
cannam@167 6401 *p++ = '"';
cannam@167 6402 for (s = string; *s != '\0'; s++)
cannam@167 6403 {
cannam@167 6404 char c = *s;
cannam@167 6405 if (c == '"')
cannam@167 6406 {
cannam@167 6407 unsigned int j;
cannam@167 6408 for (j = backslashes + 1; j > 0; j--)
cannam@167 6409 *p++ = '\\';
cannam@167 6410 }
cannam@167 6411 *p++ = c;
cannam@167 6412 if (c == '\\')
cannam@167 6413 backslashes++;
cannam@167 6414 else
cannam@167 6415 backslashes = 0;
cannam@167 6416 }
cannam@167 6417 if (quote_around)
cannam@167 6418 {
cannam@167 6419 unsigned int j;
cannam@167 6420 for (j = backslashes; j > 0; j--)
cannam@167 6421 *p++ = '\\';
cannam@167 6422 *p++ = '"';
cannam@167 6423 }
cannam@167 6424 *p = '\0';
cannam@167 6425
cannam@167 6426 new_argv[i] = quoted_string;
cannam@167 6427 }
cannam@167 6428 else
cannam@167 6429 new_argv[i] = (char *) string;
cannam@167 6430 }
cannam@167 6431 new_argv[argc] = NULL;
cannam@167 6432
cannam@167 6433 return new_argv;
cannam@167 6434 }
cannam@167 6435 EOF
cannam@167 6436 ;;
cannam@167 6437 esac
cannam@167 6438
cannam@167 6439 cat <<"EOF"
cannam@167 6440 void lt_dump_script (FILE* f)
cannam@167 6441 {
cannam@167 6442 EOF
cannam@167 6443 func_emit_wrapper yes |
cannam@167 6444 $SED -n -e '
cannam@167 6445 s/^\(.\{79\}\)\(..*\)/\1\
cannam@167 6446 \2/
cannam@167 6447 h
cannam@167 6448 s/\([\\"]\)/\\\1/g
cannam@167 6449 s/$/\\n/
cannam@167 6450 s/\([^\n]*\).*/ fputs ("\1", f);/p
cannam@167 6451 g
cannam@167 6452 D'
cannam@167 6453 cat <<"EOF"
cannam@167 6454 }
cannam@167 6455 EOF
cannam@167 6456 }
cannam@167 6457 # end: func_emit_cwrapperexe_src
cannam@167 6458
cannam@167 6459 # func_win32_import_lib_p ARG
cannam@167 6460 # True if ARG is an import lib, as indicated by $file_magic_cmd
cannam@167 6461 func_win32_import_lib_p ()
cannam@167 6462 {
cannam@167 6463 $debug_cmd
cannam@167 6464
cannam@167 6465 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
cannam@167 6466 *import*) : ;;
cannam@167 6467 *) false ;;
cannam@167 6468 esac
cannam@167 6469 }
cannam@167 6470
cannam@167 6471 # func_suncc_cstd_abi
cannam@167 6472 # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
cannam@167 6473 # Several compiler flags select an ABI that is incompatible with the
cannam@167 6474 # Cstd library. Avoid specifying it if any are in CXXFLAGS.
cannam@167 6475 func_suncc_cstd_abi ()
cannam@167 6476 {
cannam@167 6477 $debug_cmd
cannam@167 6478
cannam@167 6479 case " $compile_command " in
cannam@167 6480 *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
cannam@167 6481 suncc_use_cstd_abi=no
cannam@167 6482 ;;
cannam@167 6483 *)
cannam@167 6484 suncc_use_cstd_abi=yes
cannam@167 6485 ;;
cannam@167 6486 esac
cannam@167 6487 }
cannam@167 6488
cannam@167 6489 # func_mode_link arg...
cannam@167 6490 func_mode_link ()
cannam@167 6491 {
cannam@167 6492 $debug_cmd
cannam@167 6493
cannam@167 6494 case $host in
cannam@167 6495 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
cannam@167 6496 # It is impossible to link a dll without this setting, and
cannam@167 6497 # we shouldn't force the makefile maintainer to figure out
cannam@167 6498 # what system we are compiling for in order to pass an extra
cannam@167 6499 # flag for every libtool invocation.
cannam@167 6500 # allow_undefined=no
cannam@167 6501
cannam@167 6502 # FIXME: Unfortunately, there are problems with the above when trying
cannam@167 6503 # to make a dll that has undefined symbols, in which case not
cannam@167 6504 # even a static library is built. For now, we need to specify
cannam@167 6505 # -no-undefined on the libtool link line when we can be certain
cannam@167 6506 # that all symbols are satisfied, otherwise we get a static library.
cannam@167 6507 allow_undefined=yes
cannam@167 6508 ;;
cannam@167 6509 *)
cannam@167 6510 allow_undefined=yes
cannam@167 6511 ;;
cannam@167 6512 esac
cannam@167 6513 libtool_args=$nonopt
cannam@167 6514 base_compile="$nonopt $@"
cannam@167 6515 compile_command=$nonopt
cannam@167 6516 finalize_command=$nonopt
cannam@167 6517
cannam@167 6518 compile_rpath=
cannam@167 6519 finalize_rpath=
cannam@167 6520 compile_shlibpath=
cannam@167 6521 finalize_shlibpath=
cannam@167 6522 convenience=
cannam@167 6523 old_convenience=
cannam@167 6524 deplibs=
cannam@167 6525 old_deplibs=
cannam@167 6526 compiler_flags=
cannam@167 6527 linker_flags=
cannam@167 6528 dllsearchpath=
cannam@167 6529 lib_search_path=`pwd`
cannam@167 6530 inst_prefix_dir=
cannam@167 6531 new_inherited_linker_flags=
cannam@167 6532
cannam@167 6533 avoid_version=no
cannam@167 6534 bindir=
cannam@167 6535 dlfiles=
cannam@167 6536 dlprefiles=
cannam@167 6537 dlself=no
cannam@167 6538 export_dynamic=no
cannam@167 6539 export_symbols=
cannam@167 6540 export_symbols_regex=
cannam@167 6541 generated=
cannam@167 6542 libobjs=
cannam@167 6543 ltlibs=
cannam@167 6544 module=no
cannam@167 6545 no_install=no
cannam@167 6546 objs=
cannam@167 6547 os2dllname=
cannam@167 6548 non_pic_objects=
cannam@167 6549 precious_files_regex=
cannam@167 6550 prefer_static_libs=no
cannam@167 6551 preload=false
cannam@167 6552 prev=
cannam@167 6553 prevarg=
cannam@167 6554 release=
cannam@167 6555 rpath=
cannam@167 6556 xrpath=
cannam@167 6557 perm_rpath=
cannam@167 6558 temp_rpath=
cannam@167 6559 thread_safe=no
cannam@167 6560 vinfo=
cannam@167 6561 vinfo_number=no
cannam@167 6562 weak_libs=
cannam@167 6563 single_module=$wl-single_module
cannam@167 6564 func_infer_tag $base_compile
cannam@167 6565
cannam@167 6566 # We need to know -static, to get the right output filenames.
cannam@167 6567 for arg
cannam@167 6568 do
cannam@167 6569 case $arg in
cannam@167 6570 -shared)
cannam@167 6571 test yes != "$build_libtool_libs" \
cannam@167 6572 && func_fatal_configuration "cannot build a shared library"
cannam@167 6573 build_old_libs=no
cannam@167 6574 break
cannam@167 6575 ;;
cannam@167 6576 -all-static | -static | -static-libtool-libs)
cannam@167 6577 case $arg in
cannam@167 6578 -all-static)
cannam@167 6579 if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
cannam@167 6580 func_warning "complete static linking is impossible in this configuration"
cannam@167 6581 fi
cannam@167 6582 if test -n "$link_static_flag"; then
cannam@167 6583 dlopen_self=$dlopen_self_static
cannam@167 6584 fi
cannam@167 6585 prefer_static_libs=yes
cannam@167 6586 ;;
cannam@167 6587 -static)
cannam@167 6588 if test -z "$pic_flag" && test -n "$link_static_flag"; then
cannam@167 6589 dlopen_self=$dlopen_self_static
cannam@167 6590 fi
cannam@167 6591 prefer_static_libs=built
cannam@167 6592 ;;
cannam@167 6593 -static-libtool-libs)
cannam@167 6594 if test -z "$pic_flag" && test -n "$link_static_flag"; then
cannam@167 6595 dlopen_self=$dlopen_self_static
cannam@167 6596 fi
cannam@167 6597 prefer_static_libs=yes
cannam@167 6598 ;;
cannam@167 6599 esac
cannam@167 6600 build_libtool_libs=no
cannam@167 6601 build_old_libs=yes
cannam@167 6602 break
cannam@167 6603 ;;
cannam@167 6604 esac
cannam@167 6605 done
cannam@167 6606
cannam@167 6607 # See if our shared archives depend on static archives.
cannam@167 6608 test -n "$old_archive_from_new_cmds" && build_old_libs=yes
cannam@167 6609
cannam@167 6610 # Go through the arguments, transforming them on the way.
cannam@167 6611 while test "$#" -gt 0; do
cannam@167 6612 arg=$1
cannam@167 6613 shift
cannam@167 6614 func_quote_for_eval "$arg"
cannam@167 6615 qarg=$func_quote_for_eval_unquoted_result
cannam@167 6616 func_append libtool_args " $func_quote_for_eval_result"
cannam@167 6617
cannam@167 6618 # If the previous option needs an argument, assign it.
cannam@167 6619 if test -n "$prev"; then
cannam@167 6620 case $prev in
cannam@167 6621 output)
cannam@167 6622 func_append compile_command " @OUTPUT@"
cannam@167 6623 func_append finalize_command " @OUTPUT@"
cannam@167 6624 ;;
cannam@167 6625 esac
cannam@167 6626
cannam@167 6627 case $prev in
cannam@167 6628 bindir)
cannam@167 6629 bindir=$arg
cannam@167 6630 prev=
cannam@167 6631 continue
cannam@167 6632 ;;
cannam@167 6633 dlfiles|dlprefiles)
cannam@167 6634 $preload || {
cannam@167 6635 # Add the symbol object into the linking commands.
cannam@167 6636 func_append compile_command " @SYMFILE@"
cannam@167 6637 func_append finalize_command " @SYMFILE@"
cannam@167 6638 preload=:
cannam@167 6639 }
cannam@167 6640 case $arg in
cannam@167 6641 *.la | *.lo) ;; # We handle these cases below.
cannam@167 6642 force)
cannam@167 6643 if test no = "$dlself"; then
cannam@167 6644 dlself=needless
cannam@167 6645 export_dynamic=yes
cannam@167 6646 fi
cannam@167 6647 prev=
cannam@167 6648 continue
cannam@167 6649 ;;
cannam@167 6650 self)
cannam@167 6651 if test dlprefiles = "$prev"; then
cannam@167 6652 dlself=yes
cannam@167 6653 elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
cannam@167 6654 dlself=yes
cannam@167 6655 else
cannam@167 6656 dlself=needless
cannam@167 6657 export_dynamic=yes
cannam@167 6658 fi
cannam@167 6659 prev=
cannam@167 6660 continue
cannam@167 6661 ;;
cannam@167 6662 *)
cannam@167 6663 if test dlfiles = "$prev"; then
cannam@167 6664 func_append dlfiles " $arg"
cannam@167 6665 else
cannam@167 6666 func_append dlprefiles " $arg"
cannam@167 6667 fi
cannam@167 6668 prev=
cannam@167 6669 continue
cannam@167 6670 ;;
cannam@167 6671 esac
cannam@167 6672 ;;
cannam@167 6673 expsyms)
cannam@167 6674 export_symbols=$arg
cannam@167 6675 test -f "$arg" \
cannam@167 6676 || func_fatal_error "symbol file '$arg' does not exist"
cannam@167 6677 prev=
cannam@167 6678 continue
cannam@167 6679 ;;
cannam@167 6680 expsyms_regex)
cannam@167 6681 export_symbols_regex=$arg
cannam@167 6682 prev=
cannam@167 6683 continue
cannam@167 6684 ;;
cannam@167 6685 framework)
cannam@167 6686 case $host in
cannam@167 6687 *-*-darwin*)
cannam@167 6688 case "$deplibs " in
cannam@167 6689 *" $qarg.ltframework "*) ;;
cannam@167 6690 *) func_append deplibs " $qarg.ltframework" # this is fixed later
cannam@167 6691 ;;
cannam@167 6692 esac
cannam@167 6693 ;;
cannam@167 6694 esac
cannam@167 6695 prev=
cannam@167 6696 continue
cannam@167 6697 ;;
cannam@167 6698 inst_prefix)
cannam@167 6699 inst_prefix_dir=$arg
cannam@167 6700 prev=
cannam@167 6701 continue
cannam@167 6702 ;;
cannam@167 6703 mllvm)
cannam@167 6704 # Clang does not use LLVM to link, so we can simply discard any
cannam@167 6705 # '-mllvm $arg' options when doing the link step.
cannam@167 6706 prev=
cannam@167 6707 continue
cannam@167 6708 ;;
cannam@167 6709 objectlist)
cannam@167 6710 if test -f "$arg"; then
cannam@167 6711 save_arg=$arg
cannam@167 6712 moreargs=
cannam@167 6713 for fil in `cat "$save_arg"`
cannam@167 6714 do
cannam@167 6715 # func_append moreargs " $fil"
cannam@167 6716 arg=$fil
cannam@167 6717 # A libtool-controlled object.
cannam@167 6718
cannam@167 6719 # Check to see that this really is a libtool object.
cannam@167 6720 if func_lalib_unsafe_p "$arg"; then
cannam@167 6721 pic_object=
cannam@167 6722 non_pic_object=
cannam@167 6723
cannam@167 6724 # Read the .lo file
cannam@167 6725 func_source "$arg"
cannam@167 6726
cannam@167 6727 if test -z "$pic_object" ||
cannam@167 6728 test -z "$non_pic_object" ||
cannam@167 6729 test none = "$pic_object" &&
cannam@167 6730 test none = "$non_pic_object"; then
cannam@167 6731 func_fatal_error "cannot find name of object for '$arg'"
cannam@167 6732 fi
cannam@167 6733
cannam@167 6734 # Extract subdirectory from the argument.
cannam@167 6735 func_dirname "$arg" "/" ""
cannam@167 6736 xdir=$func_dirname_result
cannam@167 6737
cannam@167 6738 if test none != "$pic_object"; then
cannam@167 6739 # Prepend the subdirectory the object is found in.
cannam@167 6740 pic_object=$xdir$pic_object
cannam@167 6741
cannam@167 6742 if test dlfiles = "$prev"; then
cannam@167 6743 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
cannam@167 6744 func_append dlfiles " $pic_object"
cannam@167 6745 prev=
cannam@167 6746 continue
cannam@167 6747 else
cannam@167 6748 # If libtool objects are unsupported, then we need to preload.
cannam@167 6749 prev=dlprefiles
cannam@167 6750 fi
cannam@167 6751 fi
cannam@167 6752
cannam@167 6753 # CHECK ME: I think I busted this. -Ossama
cannam@167 6754 if test dlprefiles = "$prev"; then
cannam@167 6755 # Preload the old-style object.
cannam@167 6756 func_append dlprefiles " $pic_object"
cannam@167 6757 prev=
cannam@167 6758 fi
cannam@167 6759
cannam@167 6760 # A PIC object.
cannam@167 6761 func_append libobjs " $pic_object"
cannam@167 6762 arg=$pic_object
cannam@167 6763 fi
cannam@167 6764
cannam@167 6765 # Non-PIC object.
cannam@167 6766 if test none != "$non_pic_object"; then
cannam@167 6767 # Prepend the subdirectory the object is found in.
cannam@167 6768 non_pic_object=$xdir$non_pic_object
cannam@167 6769
cannam@167 6770 # A standard non-PIC object
cannam@167 6771 func_append non_pic_objects " $non_pic_object"
cannam@167 6772 if test -z "$pic_object" || test none = "$pic_object"; then
cannam@167 6773 arg=$non_pic_object
cannam@167 6774 fi
cannam@167 6775 else
cannam@167 6776 # If the PIC object exists, use it instead.
cannam@167 6777 # $xdir was prepended to $pic_object above.
cannam@167 6778 non_pic_object=$pic_object
cannam@167 6779 func_append non_pic_objects " $non_pic_object"
cannam@167 6780 fi
cannam@167 6781 else
cannam@167 6782 # Only an error if not doing a dry-run.
cannam@167 6783 if $opt_dry_run; then
cannam@167 6784 # Extract subdirectory from the argument.
cannam@167 6785 func_dirname "$arg" "/" ""
cannam@167 6786 xdir=$func_dirname_result
cannam@167 6787
cannam@167 6788 func_lo2o "$arg"
cannam@167 6789 pic_object=$xdir$objdir/$func_lo2o_result
cannam@167 6790 non_pic_object=$xdir$func_lo2o_result
cannam@167 6791 func_append libobjs " $pic_object"
cannam@167 6792 func_append non_pic_objects " $non_pic_object"
cannam@167 6793 else
cannam@167 6794 func_fatal_error "'$arg' is not a valid libtool object"
cannam@167 6795 fi
cannam@167 6796 fi
cannam@167 6797 done
cannam@167 6798 else
cannam@167 6799 func_fatal_error "link input file '$arg' does not exist"
cannam@167 6800 fi
cannam@167 6801 arg=$save_arg
cannam@167 6802 prev=
cannam@167 6803 continue
cannam@167 6804 ;;
cannam@167 6805 os2dllname)
cannam@167 6806 os2dllname=$arg
cannam@167 6807 prev=
cannam@167 6808 continue
cannam@167 6809 ;;
cannam@167 6810 precious_regex)
cannam@167 6811 precious_files_regex=$arg
cannam@167 6812 prev=
cannam@167 6813 continue
cannam@167 6814 ;;
cannam@167 6815 release)
cannam@167 6816 release=-$arg
cannam@167 6817 prev=
cannam@167 6818 continue
cannam@167 6819 ;;
cannam@167 6820 rpath | xrpath)
cannam@167 6821 # We need an absolute path.
cannam@167 6822 case $arg in
cannam@167 6823 [\\/]* | [A-Za-z]:[\\/]*) ;;
cannam@167 6824 *)
cannam@167 6825 func_fatal_error "only absolute run-paths are allowed"
cannam@167 6826 ;;
cannam@167 6827 esac
cannam@167 6828 if test rpath = "$prev"; then
cannam@167 6829 case "$rpath " in
cannam@167 6830 *" $arg "*) ;;
cannam@167 6831 *) func_append rpath " $arg" ;;
cannam@167 6832 esac
cannam@167 6833 else
cannam@167 6834 case "$xrpath " in
cannam@167 6835 *" $arg "*) ;;
cannam@167 6836 *) func_append xrpath " $arg" ;;
cannam@167 6837 esac
cannam@167 6838 fi
cannam@167 6839 prev=
cannam@167 6840 continue
cannam@167 6841 ;;
cannam@167 6842 shrext)
cannam@167 6843 shrext_cmds=$arg
cannam@167 6844 prev=
cannam@167 6845 continue
cannam@167 6846 ;;
cannam@167 6847 weak)
cannam@167 6848 func_append weak_libs " $arg"
cannam@167 6849 prev=
cannam@167 6850 continue
cannam@167 6851 ;;
cannam@167 6852 xcclinker)
cannam@167 6853 func_append linker_flags " $qarg"
cannam@167 6854 func_append compiler_flags " $qarg"
cannam@167 6855 prev=
cannam@167 6856 func_append compile_command " $qarg"
cannam@167 6857 func_append finalize_command " $qarg"
cannam@167 6858 continue
cannam@167 6859 ;;
cannam@167 6860 xcompiler)
cannam@167 6861 func_append compiler_flags " $qarg"
cannam@167 6862 prev=
cannam@167 6863 func_append compile_command " $qarg"
cannam@167 6864 func_append finalize_command " $qarg"
cannam@167 6865 continue
cannam@167 6866 ;;
cannam@167 6867 xlinker)
cannam@167 6868 func_append linker_flags " $qarg"
cannam@167 6869 func_append compiler_flags " $wl$qarg"
cannam@167 6870 prev=
cannam@167 6871 func_append compile_command " $wl$qarg"
cannam@167 6872 func_append finalize_command " $wl$qarg"
cannam@167 6873 continue
cannam@167 6874 ;;
cannam@167 6875 *)
cannam@167 6876 eval "$prev=\"\$arg\""
cannam@167 6877 prev=
cannam@167 6878 continue
cannam@167 6879 ;;
cannam@167 6880 esac
cannam@167 6881 fi # test -n "$prev"
cannam@167 6882
cannam@167 6883 prevarg=$arg
cannam@167 6884
cannam@167 6885 case $arg in
cannam@167 6886 -all-static)
cannam@167 6887 if test -n "$link_static_flag"; then
cannam@167 6888 # See comment for -static flag below, for more details.
cannam@167 6889 func_append compile_command " $link_static_flag"
cannam@167 6890 func_append finalize_command " $link_static_flag"
cannam@167 6891 fi
cannam@167 6892 continue
cannam@167 6893 ;;
cannam@167 6894
cannam@167 6895 -allow-undefined)
cannam@167 6896 # FIXME: remove this flag sometime in the future.
cannam@167 6897 func_fatal_error "'-allow-undefined' must not be used because it is the default"
cannam@167 6898 ;;
cannam@167 6899
cannam@167 6900 -avoid-version)
cannam@167 6901 avoid_version=yes
cannam@167 6902 continue
cannam@167 6903 ;;
cannam@167 6904
cannam@167 6905 -bindir)
cannam@167 6906 prev=bindir
cannam@167 6907 continue
cannam@167 6908 ;;
cannam@167 6909
cannam@167 6910 -dlopen)
cannam@167 6911 prev=dlfiles
cannam@167 6912 continue
cannam@167 6913 ;;
cannam@167 6914
cannam@167 6915 -dlpreopen)
cannam@167 6916 prev=dlprefiles
cannam@167 6917 continue
cannam@167 6918 ;;
cannam@167 6919
cannam@167 6920 -export-dynamic)
cannam@167 6921 export_dynamic=yes
cannam@167 6922 continue
cannam@167 6923 ;;
cannam@167 6924
cannam@167 6925 -export-symbols | -export-symbols-regex)
cannam@167 6926 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
cannam@167 6927 func_fatal_error "more than one -exported-symbols argument is not allowed"
cannam@167 6928 fi
cannam@167 6929 if test X-export-symbols = "X$arg"; then
cannam@167 6930 prev=expsyms
cannam@167 6931 else
cannam@167 6932 prev=expsyms_regex
cannam@167 6933 fi
cannam@167 6934 continue
cannam@167 6935 ;;
cannam@167 6936
cannam@167 6937 -framework)
cannam@167 6938 prev=framework
cannam@167 6939 continue
cannam@167 6940 ;;
cannam@167 6941
cannam@167 6942 -inst-prefix-dir)
cannam@167 6943 prev=inst_prefix
cannam@167 6944 continue
cannam@167 6945 ;;
cannam@167 6946
cannam@167 6947 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
cannam@167 6948 # so, if we see these flags be careful not to treat them like -L
cannam@167 6949 -L[A-Z][A-Z]*:*)
cannam@167 6950 case $with_gcc/$host in
cannam@167 6951 no/*-*-irix* | /*-*-irix*)
cannam@167 6952 func_append compile_command " $arg"
cannam@167 6953 func_append finalize_command " $arg"
cannam@167 6954 ;;
cannam@167 6955 esac
cannam@167 6956 continue
cannam@167 6957 ;;
cannam@167 6958
cannam@167 6959 -L*)
cannam@167 6960 func_stripname "-L" '' "$arg"
cannam@167 6961 if test -z "$func_stripname_result"; then
cannam@167 6962 if test "$#" -gt 0; then
cannam@167 6963 func_fatal_error "require no space between '-L' and '$1'"
cannam@167 6964 else
cannam@167 6965 func_fatal_error "need path for '-L' option"
cannam@167 6966 fi
cannam@167 6967 fi
cannam@167 6968 func_resolve_sysroot "$func_stripname_result"
cannam@167 6969 dir=$func_resolve_sysroot_result
cannam@167 6970 # We need an absolute path.
cannam@167 6971 case $dir in
cannam@167 6972 [\\/]* | [A-Za-z]:[\\/]*) ;;
cannam@167 6973 *)
cannam@167 6974 absdir=`cd "$dir" && pwd`
cannam@167 6975 test -z "$absdir" && \
cannam@167 6976 func_fatal_error "cannot determine absolute directory name of '$dir'"
cannam@167 6977 dir=$absdir
cannam@167 6978 ;;
cannam@167 6979 esac
cannam@167 6980 case "$deplibs " in
cannam@167 6981 *" -L$dir "* | *" $arg "*)
cannam@167 6982 # Will only happen for absolute or sysroot arguments
cannam@167 6983 ;;
cannam@167 6984 *)
cannam@167 6985 # Preserve sysroot, but never include relative directories
cannam@167 6986 case $dir in
cannam@167 6987 [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
cannam@167 6988 *) func_append deplibs " -L$dir" ;;
cannam@167 6989 esac
cannam@167 6990 func_append lib_search_path " $dir"
cannam@167 6991 ;;
cannam@167 6992 esac
cannam@167 6993 case $host in
cannam@167 6994 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
cannam@167 6995 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
cannam@167 6996 case :$dllsearchpath: in
cannam@167 6997 *":$dir:"*) ;;
cannam@167 6998 ::) dllsearchpath=$dir;;
cannam@167 6999 *) func_append dllsearchpath ":$dir";;
cannam@167 7000 esac
cannam@167 7001 case :$dllsearchpath: in
cannam@167 7002 *":$testbindir:"*) ;;
cannam@167 7003 ::) dllsearchpath=$testbindir;;
cannam@167 7004 *) func_append dllsearchpath ":$testbindir";;
cannam@167 7005 esac
cannam@167 7006 ;;
cannam@167 7007 esac
cannam@167 7008 continue
cannam@167 7009 ;;
cannam@167 7010
cannam@167 7011 -l*)
cannam@167 7012 if test X-lc = "X$arg" || test X-lm = "X$arg"; then
cannam@167 7013 case $host in
cannam@167 7014 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
cannam@167 7015 # These systems don't actually have a C or math library (as such)
cannam@167 7016 continue
cannam@167 7017 ;;
cannam@167 7018 *-*-os2*)
cannam@167 7019 # These systems don't actually have a C library (as such)
cannam@167 7020 test X-lc = "X$arg" && continue
cannam@167 7021 ;;
cannam@167 7022 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
cannam@167 7023 # Do not include libc due to us having libc/libc_r.
cannam@167 7024 test X-lc = "X$arg" && continue
cannam@167 7025 ;;
cannam@167 7026 *-*-rhapsody* | *-*-darwin1.[012])
cannam@167 7027 # Rhapsody C and math libraries are in the System framework
cannam@167 7028 func_append deplibs " System.ltframework"
cannam@167 7029 continue
cannam@167 7030 ;;
cannam@167 7031 *-*-sco3.2v5* | *-*-sco5v6*)
cannam@167 7032 # Causes problems with __ctype
cannam@167 7033 test X-lc = "X$arg" && continue
cannam@167 7034 ;;
cannam@167 7035 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
cannam@167 7036 # Compiler inserts libc in the correct place for threads to work
cannam@167 7037 test X-lc = "X$arg" && continue
cannam@167 7038 ;;
cannam@167 7039 esac
cannam@167 7040 elif test X-lc_r = "X$arg"; then
cannam@167 7041 case $host in
cannam@167 7042 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig*)
cannam@167 7043 # Do not include libc_r directly, use -pthread flag.
cannam@167 7044 continue
cannam@167 7045 ;;
cannam@167 7046 esac
cannam@167 7047 fi
cannam@167 7048 func_append deplibs " $arg"
cannam@167 7049 continue
cannam@167 7050 ;;
cannam@167 7051
cannam@167 7052 -mllvm)
cannam@167 7053 prev=mllvm
cannam@167 7054 continue
cannam@167 7055 ;;
cannam@167 7056
cannam@167 7057 -module)
cannam@167 7058 module=yes
cannam@167 7059 continue
cannam@167 7060 ;;
cannam@167 7061
cannam@167 7062 # Tru64 UNIX uses -model [arg] to determine the layout of C++
cannam@167 7063 # classes, name mangling, and exception handling.
cannam@167 7064 # Darwin uses the -arch flag to determine output architecture.
cannam@167 7065 -model|-arch|-isysroot|--sysroot)
cannam@167 7066 func_append compiler_flags " $arg"
cannam@167 7067 func_append compile_command " $arg"
cannam@167 7068 func_append finalize_command " $arg"
cannam@167 7069 prev=xcompiler
cannam@167 7070 continue
cannam@167 7071 ;;
cannam@167 7072
cannam@167 7073 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
cannam@167 7074 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
cannam@167 7075 func_append compiler_flags " $arg"
cannam@167 7076 func_append compile_command " $arg"
cannam@167 7077 func_append finalize_command " $arg"
cannam@167 7078 case "$new_inherited_linker_flags " in
cannam@167 7079 *" $arg "*) ;;
cannam@167 7080 * ) func_append new_inherited_linker_flags " $arg" ;;
cannam@167 7081 esac
cannam@167 7082 continue
cannam@167 7083 ;;
cannam@167 7084
cannam@167 7085 -multi_module)
cannam@167 7086 single_module=$wl-multi_module
cannam@167 7087 continue
cannam@167 7088 ;;
cannam@167 7089
cannam@167 7090 -no-fast-install)
cannam@167 7091 fast_install=no
cannam@167 7092 continue
cannam@167 7093 ;;
cannam@167 7094
cannam@167 7095 -no-install)
cannam@167 7096 case $host in
cannam@167 7097 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
cannam@167 7098 # The PATH hackery in wrapper scripts is required on Windows
cannam@167 7099 # and Darwin in order for the loader to find any dlls it needs.
cannam@167 7100 func_warning "'-no-install' is ignored for $host"
cannam@167 7101 func_warning "assuming '-no-fast-install' instead"
cannam@167 7102 fast_install=no
cannam@167 7103 ;;
cannam@167 7104 *) no_install=yes ;;
cannam@167 7105 esac
cannam@167 7106 continue
cannam@167 7107 ;;
cannam@167 7108
cannam@167 7109 -no-undefined)
cannam@167 7110 allow_undefined=no
cannam@167 7111 continue
cannam@167 7112 ;;
cannam@167 7113
cannam@167 7114 -objectlist)
cannam@167 7115 prev=objectlist
cannam@167 7116 continue
cannam@167 7117 ;;
cannam@167 7118
cannam@167 7119 -os2dllname)
cannam@167 7120 prev=os2dllname
cannam@167 7121 continue
cannam@167 7122 ;;
cannam@167 7123
cannam@167 7124 -o) prev=output ;;
cannam@167 7125
cannam@167 7126 -precious-files-regex)
cannam@167 7127 prev=precious_regex
cannam@167 7128 continue
cannam@167 7129 ;;
cannam@167 7130
cannam@167 7131 -release)
cannam@167 7132 prev=release
cannam@167 7133 continue
cannam@167 7134 ;;
cannam@167 7135
cannam@167 7136 -rpath)
cannam@167 7137 prev=rpath
cannam@167 7138 continue
cannam@167 7139 ;;
cannam@167 7140
cannam@167 7141 -R)
cannam@167 7142 prev=xrpath
cannam@167 7143 continue
cannam@167 7144 ;;
cannam@167 7145
cannam@167 7146 -R*)
cannam@167 7147 func_stripname '-R' '' "$arg"
cannam@167 7148 dir=$func_stripname_result
cannam@167 7149 # We need an absolute path.
cannam@167 7150 case $dir in
cannam@167 7151 [\\/]* | [A-Za-z]:[\\/]*) ;;
cannam@167 7152 =*)
cannam@167 7153 func_stripname '=' '' "$dir"
cannam@167 7154 dir=$lt_sysroot$func_stripname_result
cannam@167 7155 ;;
cannam@167 7156 *)
cannam@167 7157 func_fatal_error "only absolute run-paths are allowed"
cannam@167 7158 ;;
cannam@167 7159 esac
cannam@167 7160 case "$xrpath " in
cannam@167 7161 *" $dir "*) ;;
cannam@167 7162 *) func_append xrpath " $dir" ;;
cannam@167 7163 esac
cannam@167 7164 continue
cannam@167 7165 ;;
cannam@167 7166
cannam@167 7167 -shared)
cannam@167 7168 # The effects of -shared are defined in a previous loop.
cannam@167 7169 continue
cannam@167 7170 ;;
cannam@167 7171
cannam@167 7172 -shrext)
cannam@167 7173 prev=shrext
cannam@167 7174 continue
cannam@167 7175 ;;
cannam@167 7176
cannam@167 7177 -static | -static-libtool-libs)
cannam@167 7178 # The effects of -static are defined in a previous loop.
cannam@167 7179 # We used to do the same as -all-static on platforms that
cannam@167 7180 # didn't have a PIC flag, but the assumption that the effects
cannam@167 7181 # would be equivalent was wrong. It would break on at least
cannam@167 7182 # Digital Unix and AIX.
cannam@167 7183 continue
cannam@167 7184 ;;
cannam@167 7185
cannam@167 7186 -thread-safe)
cannam@167 7187 thread_safe=yes
cannam@167 7188 continue
cannam@167 7189 ;;
cannam@167 7190
cannam@167 7191 -version-info)
cannam@167 7192 prev=vinfo
cannam@167 7193 continue
cannam@167 7194 ;;
cannam@167 7195
cannam@167 7196 -version-number)
cannam@167 7197 prev=vinfo
cannam@167 7198 vinfo_number=yes
cannam@167 7199 continue
cannam@167 7200 ;;
cannam@167 7201
cannam@167 7202 -weak)
cannam@167 7203 prev=weak
cannam@167 7204 continue
cannam@167 7205 ;;
cannam@167 7206
cannam@167 7207 -Wc,*)
cannam@167 7208 func_stripname '-Wc,' '' "$arg"
cannam@167 7209 args=$func_stripname_result
cannam@167 7210 arg=
cannam@167 7211 save_ifs=$IFS; IFS=,
cannam@167 7212 for flag in $args; do
cannam@167 7213 IFS=$save_ifs
cannam@167 7214 func_quote_for_eval "$flag"
cannam@167 7215 func_append arg " $func_quote_for_eval_result"
cannam@167 7216 func_append compiler_flags " $func_quote_for_eval_result"
cannam@167 7217 done
cannam@167 7218 IFS=$save_ifs
cannam@167 7219 func_stripname ' ' '' "$arg"
cannam@167 7220 arg=$func_stripname_result
cannam@167 7221 ;;
cannam@167 7222
cannam@167 7223 -Wl,*)
cannam@167 7224 func_stripname '-Wl,' '' "$arg"
cannam@167 7225 args=$func_stripname_result
cannam@167 7226 arg=
cannam@167 7227 save_ifs=$IFS; IFS=,
cannam@167 7228 for flag in $args; do
cannam@167 7229 IFS=$save_ifs
cannam@167 7230 func_quote_for_eval "$flag"
cannam@167 7231 func_append arg " $wl$func_quote_for_eval_result"
cannam@167 7232 func_append compiler_flags " $wl$func_quote_for_eval_result"
cannam@167 7233 func_append linker_flags " $func_quote_for_eval_result"
cannam@167 7234 done
cannam@167 7235 IFS=$save_ifs
cannam@167 7236 func_stripname ' ' '' "$arg"
cannam@167 7237 arg=$func_stripname_result
cannam@167 7238 ;;
cannam@167 7239
cannam@167 7240 -Xcompiler)
cannam@167 7241 prev=xcompiler
cannam@167 7242 continue
cannam@167 7243 ;;
cannam@167 7244
cannam@167 7245 -Xlinker)
cannam@167 7246 prev=xlinker
cannam@167 7247 continue
cannam@167 7248 ;;
cannam@167 7249
cannam@167 7250 -XCClinker)
cannam@167 7251 prev=xcclinker
cannam@167 7252 continue
cannam@167 7253 ;;
cannam@167 7254
cannam@167 7255 # -msg_* for osf cc
cannam@167 7256 -msg_*)
cannam@167 7257 func_quote_for_eval "$arg"
cannam@167 7258 arg=$func_quote_for_eval_result
cannam@167 7259 ;;
cannam@167 7260
cannam@167 7261 # Flags to be passed through unchanged, with rationale:
cannam@167 7262 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
cannam@167 7263 # -r[0-9][0-9]* specify processor for the SGI compiler
cannam@167 7264 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
cannam@167 7265 # +DA*, +DD* enable 64-bit mode for the HP compiler
cannam@167 7266 # -q* compiler args for the IBM compiler
cannam@167 7267 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
cannam@167 7268 # -F/path path to uninstalled frameworks, gcc on darwin
cannam@167 7269 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
cannam@167 7270 # -fstack-protector* stack protector flags for GCC
cannam@167 7271 # @file GCC response files
cannam@167 7272 # -tp=* Portland pgcc target processor selection
cannam@167 7273 # --sysroot=* for sysroot support
cannam@167 7274 # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
cannam@167 7275 # -specs=* GCC specs files
cannam@167 7276 # -stdlib=* select c++ std lib with clang
cannam@167 7277 # -fsanitize=* Clang/GCC memory and address sanitizer
cannam@167 7278 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
cannam@167 7279 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
cannam@167 7280 -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \
cannam@167 7281 -specs=*|-fsanitize=*)
cannam@167 7282 func_quote_for_eval "$arg"
cannam@167 7283 arg=$func_quote_for_eval_result
cannam@167 7284 func_append compile_command " $arg"
cannam@167 7285 func_append finalize_command " $arg"
cannam@167 7286 func_append compiler_flags " $arg"
cannam@167 7287 continue
cannam@167 7288 ;;
cannam@167 7289
cannam@167 7290 -Z*)
cannam@167 7291 if test os2 = "`expr $host : '.*\(os2\)'`"; then
cannam@167 7292 # OS/2 uses -Zxxx to specify OS/2-specific options
cannam@167 7293 compiler_flags="$compiler_flags $arg"
cannam@167 7294 func_append compile_command " $arg"
cannam@167 7295 func_append finalize_command " $arg"
cannam@167 7296 case $arg in
cannam@167 7297 -Zlinker | -Zstack)
cannam@167 7298 prev=xcompiler
cannam@167 7299 ;;
cannam@167 7300 esac
cannam@167 7301 continue
cannam@167 7302 else
cannam@167 7303 # Otherwise treat like 'Some other compiler flag' below
cannam@167 7304 func_quote_for_eval "$arg"
cannam@167 7305 arg=$func_quote_for_eval_result
cannam@167 7306 fi
cannam@167 7307 ;;
cannam@167 7308
cannam@167 7309 # Some other compiler flag.
cannam@167 7310 -* | +*)
cannam@167 7311 func_quote_for_eval "$arg"
cannam@167 7312 arg=$func_quote_for_eval_result
cannam@167 7313 ;;
cannam@167 7314
cannam@167 7315 *.$objext)
cannam@167 7316 # A standard object.
cannam@167 7317 func_append objs " $arg"
cannam@167 7318 ;;
cannam@167 7319
cannam@167 7320 *.lo)
cannam@167 7321 # A libtool-controlled object.
cannam@167 7322
cannam@167 7323 # Check to see that this really is a libtool object.
cannam@167 7324 if func_lalib_unsafe_p "$arg"; then
cannam@167 7325 pic_object=
cannam@167 7326 non_pic_object=
cannam@167 7327
cannam@167 7328 # Read the .lo file
cannam@167 7329 func_source "$arg"
cannam@167 7330
cannam@167 7331 if test -z "$pic_object" ||
cannam@167 7332 test -z "$non_pic_object" ||
cannam@167 7333 test none = "$pic_object" &&
cannam@167 7334 test none = "$non_pic_object"; then
cannam@167 7335 func_fatal_error "cannot find name of object for '$arg'"
cannam@167 7336 fi
cannam@167 7337
cannam@167 7338 # Extract subdirectory from the argument.
cannam@167 7339 func_dirname "$arg" "/" ""
cannam@167 7340 xdir=$func_dirname_result
cannam@167 7341
cannam@167 7342 test none = "$pic_object" || {
cannam@167 7343 # Prepend the subdirectory the object is found in.
cannam@167 7344 pic_object=$xdir$pic_object
cannam@167 7345
cannam@167 7346 if test dlfiles = "$prev"; then
cannam@167 7347 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
cannam@167 7348 func_append dlfiles " $pic_object"
cannam@167 7349 prev=
cannam@167 7350 continue
cannam@167 7351 else
cannam@167 7352 # If libtool objects are unsupported, then we need to preload.
cannam@167 7353 prev=dlprefiles
cannam@167 7354 fi
cannam@167 7355 fi
cannam@167 7356
cannam@167 7357 # CHECK ME: I think I busted this. -Ossama
cannam@167 7358 if test dlprefiles = "$prev"; then
cannam@167 7359 # Preload the old-style object.
cannam@167 7360 func_append dlprefiles " $pic_object"
cannam@167 7361 prev=
cannam@167 7362 fi
cannam@167 7363
cannam@167 7364 # A PIC object.
cannam@167 7365 func_append libobjs " $pic_object"
cannam@167 7366 arg=$pic_object
cannam@167 7367 }
cannam@167 7368
cannam@167 7369 # Non-PIC object.
cannam@167 7370 if test none != "$non_pic_object"; then
cannam@167 7371 # Prepend the subdirectory the object is found in.
cannam@167 7372 non_pic_object=$xdir$non_pic_object
cannam@167 7373
cannam@167 7374 # A standard non-PIC object
cannam@167 7375 func_append non_pic_objects " $non_pic_object"
cannam@167 7376 if test -z "$pic_object" || test none = "$pic_object"; then
cannam@167 7377 arg=$non_pic_object
cannam@167 7378 fi
cannam@167 7379 else
cannam@167 7380 # If the PIC object exists, use it instead.
cannam@167 7381 # $xdir was prepended to $pic_object above.
cannam@167 7382 non_pic_object=$pic_object
cannam@167 7383 func_append non_pic_objects " $non_pic_object"
cannam@167 7384 fi
cannam@167 7385 else
cannam@167 7386 # Only an error if not doing a dry-run.
cannam@167 7387 if $opt_dry_run; then
cannam@167 7388 # Extract subdirectory from the argument.
cannam@167 7389 func_dirname "$arg" "/" ""
cannam@167 7390 xdir=$func_dirname_result
cannam@167 7391
cannam@167 7392 func_lo2o "$arg"
cannam@167 7393 pic_object=$xdir$objdir/$func_lo2o_result
cannam@167 7394 non_pic_object=$xdir$func_lo2o_result
cannam@167 7395 func_append libobjs " $pic_object"
cannam@167 7396 func_append non_pic_objects " $non_pic_object"
cannam@167 7397 else
cannam@167 7398 func_fatal_error "'$arg' is not a valid libtool object"
cannam@167 7399 fi
cannam@167 7400 fi
cannam@167 7401 ;;
cannam@167 7402
cannam@167 7403 *.$libext)
cannam@167 7404 # An archive.
cannam@167 7405 func_append deplibs " $arg"
cannam@167 7406 func_append old_deplibs " $arg"
cannam@167 7407 continue
cannam@167 7408 ;;
cannam@167 7409
cannam@167 7410 *.la)
cannam@167 7411 # A libtool-controlled library.
cannam@167 7412
cannam@167 7413 func_resolve_sysroot "$arg"
cannam@167 7414 if test dlfiles = "$prev"; then
cannam@167 7415 # This library was specified with -dlopen.
cannam@167 7416 func_append dlfiles " $func_resolve_sysroot_result"
cannam@167 7417 prev=
cannam@167 7418 elif test dlprefiles = "$prev"; then
cannam@167 7419 # The library was specified with -dlpreopen.
cannam@167 7420 func_append dlprefiles " $func_resolve_sysroot_result"
cannam@167 7421 prev=
cannam@167 7422 else
cannam@167 7423 func_append deplibs " $func_resolve_sysroot_result"
cannam@167 7424 fi
cannam@167 7425 continue
cannam@167 7426 ;;
cannam@167 7427
cannam@167 7428 # Some other compiler argument.
cannam@167 7429 *)
cannam@167 7430 # Unknown arguments in both finalize_command and compile_command need
cannam@167 7431 # to be aesthetically quoted because they are evaled later.
cannam@167 7432 func_quote_for_eval "$arg"
cannam@167 7433 arg=$func_quote_for_eval_result
cannam@167 7434 ;;
cannam@167 7435 esac # arg
cannam@167 7436
cannam@167 7437 # Now actually substitute the argument into the commands.
cannam@167 7438 if test -n "$arg"; then
cannam@167 7439 func_append compile_command " $arg"
cannam@167 7440 func_append finalize_command " $arg"
cannam@167 7441 fi
cannam@167 7442 done # argument parsing loop
cannam@167 7443
cannam@167 7444 test -n "$prev" && \
cannam@167 7445 func_fatal_help "the '$prevarg' option requires an argument"
cannam@167 7446
cannam@167 7447 if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
cannam@167 7448 eval arg=\"$export_dynamic_flag_spec\"
cannam@167 7449 func_append compile_command " $arg"
cannam@167 7450 func_append finalize_command " $arg"
cannam@167 7451 fi
cannam@167 7452
cannam@167 7453 oldlibs=
cannam@167 7454 # calculate the name of the file, without its directory
cannam@167 7455 func_basename "$output"
cannam@167 7456 outputname=$func_basename_result
cannam@167 7457 libobjs_save=$libobjs
cannam@167 7458
cannam@167 7459 if test -n "$shlibpath_var"; then
cannam@167 7460 # get the directories listed in $shlibpath_var
cannam@167 7461 eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
cannam@167 7462 else
cannam@167 7463 shlib_search_path=
cannam@167 7464 fi
cannam@167 7465 eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
cannam@167 7466 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
cannam@167 7467
cannam@167 7468 # Definition is injected by LT_CONFIG during libtool generation.
cannam@167 7469 func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
cannam@167 7470
cannam@167 7471 func_dirname "$output" "/" ""
cannam@167 7472 output_objdir=$func_dirname_result$objdir
cannam@167 7473 func_to_tool_file "$output_objdir/"
cannam@167 7474 tool_output_objdir=$func_to_tool_file_result
cannam@167 7475 # Create the object directory.
cannam@167 7476 func_mkdir_p "$output_objdir"
cannam@167 7477
cannam@167 7478 # Determine the type of output
cannam@167 7479 case $output in
cannam@167 7480 "")
cannam@167 7481 func_fatal_help "you must specify an output file"
cannam@167 7482 ;;
cannam@167 7483 *.$libext) linkmode=oldlib ;;
cannam@167 7484 *.lo | *.$objext) linkmode=obj ;;
cannam@167 7485 *.la) linkmode=lib ;;
cannam@167 7486 *) linkmode=prog ;; # Anything else should be a program.
cannam@167 7487 esac
cannam@167 7488
cannam@167 7489 specialdeplibs=
cannam@167 7490
cannam@167 7491 libs=
cannam@167 7492 # Find all interdependent deplibs by searching for libraries
cannam@167 7493 # that are linked more than once (e.g. -la -lb -la)
cannam@167 7494 for deplib in $deplibs; do
cannam@167 7495 if $opt_preserve_dup_deps; then
cannam@167 7496 case "$libs " in
cannam@167 7497 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
cannam@167 7498 esac
cannam@167 7499 fi
cannam@167 7500 func_append libs " $deplib"
cannam@167 7501 done
cannam@167 7502
cannam@167 7503 if test lib = "$linkmode"; then
cannam@167 7504 libs="$predeps $libs $compiler_lib_search_path $postdeps"
cannam@167 7505
cannam@167 7506 # Compute libraries that are listed more than once in $predeps
cannam@167 7507 # $postdeps and mark them as special (i.e., whose duplicates are
cannam@167 7508 # not to be eliminated).
cannam@167 7509 pre_post_deps=
cannam@167 7510 if $opt_duplicate_compiler_generated_deps; then
cannam@167 7511 for pre_post_dep in $predeps $postdeps; do
cannam@167 7512 case "$pre_post_deps " in
cannam@167 7513 *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
cannam@167 7514 esac
cannam@167 7515 func_append pre_post_deps " $pre_post_dep"
cannam@167 7516 done
cannam@167 7517 fi
cannam@167 7518 pre_post_deps=
cannam@167 7519 fi
cannam@167 7520
cannam@167 7521 deplibs=
cannam@167 7522 newdependency_libs=
cannam@167 7523 newlib_search_path=
cannam@167 7524 need_relink=no # whether we're linking any uninstalled libtool libraries
cannam@167 7525 notinst_deplibs= # not-installed libtool libraries
cannam@167 7526 notinst_path= # paths that contain not-installed libtool libraries
cannam@167 7527
cannam@167 7528 case $linkmode in
cannam@167 7529 lib)
cannam@167 7530 passes="conv dlpreopen link"
cannam@167 7531 for file in $dlfiles $dlprefiles; do
cannam@167 7532 case $file in
cannam@167 7533 *.la) ;;
cannam@167 7534 *)
cannam@167 7535 func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
cannam@167 7536 ;;
cannam@167 7537 esac
cannam@167 7538 done
cannam@167 7539 ;;
cannam@167 7540 prog)
cannam@167 7541 compile_deplibs=
cannam@167 7542 finalize_deplibs=
cannam@167 7543 alldeplibs=false
cannam@167 7544 newdlfiles=
cannam@167 7545 newdlprefiles=
cannam@167 7546 passes="conv scan dlopen dlpreopen link"
cannam@167 7547 ;;
cannam@167 7548 *) passes="conv"
cannam@167 7549 ;;
cannam@167 7550 esac
cannam@167 7551
cannam@167 7552 for pass in $passes; do
cannam@167 7553 # The preopen pass in lib mode reverses $deplibs; put it back here
cannam@167 7554 # so that -L comes before libs that need it for instance...
cannam@167 7555 if test lib,link = "$linkmode,$pass"; then
cannam@167 7556 ## FIXME: Find the place where the list is rebuilt in the wrong
cannam@167 7557 ## order, and fix it there properly
cannam@167 7558 tmp_deplibs=
cannam@167 7559 for deplib in $deplibs; do
cannam@167 7560 tmp_deplibs="$deplib $tmp_deplibs"
cannam@167 7561 done
cannam@167 7562 deplibs=$tmp_deplibs
cannam@167 7563 fi
cannam@167 7564
cannam@167 7565 if test lib,link = "$linkmode,$pass" ||
cannam@167 7566 test prog,scan = "$linkmode,$pass"; then
cannam@167 7567 libs=$deplibs
cannam@167 7568 deplibs=
cannam@167 7569 fi
cannam@167 7570 if test prog = "$linkmode"; then
cannam@167 7571 case $pass in
cannam@167 7572 dlopen) libs=$dlfiles ;;
cannam@167 7573 dlpreopen) libs=$dlprefiles ;;
cannam@167 7574 link)
cannam@167 7575 libs="$deplibs %DEPLIBS%"
cannam@167 7576 test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs"
cannam@167 7577 ;;
cannam@167 7578 esac
cannam@167 7579 fi
cannam@167 7580 if test lib,dlpreopen = "$linkmode,$pass"; then
cannam@167 7581 # Collect and forward deplibs of preopened libtool libs
cannam@167 7582 for lib in $dlprefiles; do
cannam@167 7583 # Ignore non-libtool-libs
cannam@167 7584 dependency_libs=
cannam@167 7585 func_resolve_sysroot "$lib"
cannam@167 7586 case $lib in
cannam@167 7587 *.la) func_source "$func_resolve_sysroot_result" ;;
cannam@167 7588 esac
cannam@167 7589
cannam@167 7590 # Collect preopened libtool deplibs, except any this library
cannam@167 7591 # has declared as weak libs
cannam@167 7592 for deplib in $dependency_libs; do
cannam@167 7593 func_basename "$deplib"
cannam@167 7594 deplib_base=$func_basename_result
cannam@167 7595 case " $weak_libs " in
cannam@167 7596 *" $deplib_base "*) ;;
cannam@167 7597 *) func_append deplibs " $deplib" ;;
cannam@167 7598 esac
cannam@167 7599 done
cannam@167 7600 done
cannam@167 7601 libs=$dlprefiles
cannam@167 7602 fi
cannam@167 7603 if test dlopen = "$pass"; then
cannam@167 7604 # Collect dlpreopened libraries
cannam@167 7605 save_deplibs=$deplibs
cannam@167 7606 deplibs=
cannam@167 7607 fi
cannam@167 7608
cannam@167 7609 for deplib in $libs; do
cannam@167 7610 lib=
cannam@167 7611 found=false
cannam@167 7612 case $deplib in
cannam@167 7613 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
cannam@167 7614 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
cannam@167 7615 if test prog,link = "$linkmode,$pass"; then
cannam@167 7616 compile_deplibs="$deplib $compile_deplibs"
cannam@167 7617 finalize_deplibs="$deplib $finalize_deplibs"
cannam@167 7618 else
cannam@167 7619 func_append compiler_flags " $deplib"
cannam@167 7620 if test lib = "$linkmode"; then
cannam@167 7621 case "$new_inherited_linker_flags " in
cannam@167 7622 *" $deplib "*) ;;
cannam@167 7623 * ) func_append new_inherited_linker_flags " $deplib" ;;
cannam@167 7624 esac
cannam@167 7625 fi
cannam@167 7626 fi
cannam@167 7627 continue
cannam@167 7628 ;;
cannam@167 7629 -l*)
cannam@167 7630 if test lib != "$linkmode" && test prog != "$linkmode"; then
cannam@167 7631 func_warning "'-l' is ignored for archives/objects"
cannam@167 7632 continue
cannam@167 7633 fi
cannam@167 7634 func_stripname '-l' '' "$deplib"
cannam@167 7635 name=$func_stripname_result
cannam@167 7636 if test lib = "$linkmode"; then
cannam@167 7637 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
cannam@167 7638 else
cannam@167 7639 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
cannam@167 7640 fi
cannam@167 7641 for searchdir in $searchdirs; do
cannam@167 7642 for search_ext in .la $std_shrext .so .a; do
cannam@167 7643 # Search the libtool library
cannam@167 7644 lib=$searchdir/lib$name$search_ext
cannam@167 7645 if test -f "$lib"; then
cannam@167 7646 if test .la = "$search_ext"; then
cannam@167 7647 found=:
cannam@167 7648 else
cannam@167 7649 found=false
cannam@167 7650 fi
cannam@167 7651 break 2
cannam@167 7652 fi
cannam@167 7653 done
cannam@167 7654 done
cannam@167 7655 if $found; then
cannam@167 7656 # deplib is a libtool library
cannam@167 7657 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
cannam@167 7658 # We need to do some special things here, and not later.
cannam@167 7659 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@167 7660 case " $predeps $postdeps " in
cannam@167 7661 *" $deplib "*)
cannam@167 7662 if func_lalib_p "$lib"; then
cannam@167 7663 library_names=
cannam@167 7664 old_library=
cannam@167 7665 func_source "$lib"
cannam@167 7666 for l in $old_library $library_names; do
cannam@167 7667 ll=$l
cannam@167 7668 done
cannam@167 7669 if test "X$ll" = "X$old_library"; then # only static version available
cannam@167 7670 found=false
cannam@167 7671 func_dirname "$lib" "" "."
cannam@167 7672 ladir=$func_dirname_result
cannam@167 7673 lib=$ladir/$old_library
cannam@167 7674 if test prog,link = "$linkmode,$pass"; then
cannam@167 7675 compile_deplibs="$deplib $compile_deplibs"
cannam@167 7676 finalize_deplibs="$deplib $finalize_deplibs"
cannam@167 7677 else
cannam@167 7678 deplibs="$deplib $deplibs"
cannam@167 7679 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
cannam@167 7680 fi
cannam@167 7681 continue
cannam@167 7682 fi
cannam@167 7683 fi
cannam@167 7684 ;;
cannam@167 7685 *) ;;
cannam@167 7686 esac
cannam@167 7687 fi
cannam@167 7688 else
cannam@167 7689 # deplib doesn't seem to be a libtool library
cannam@167 7690 if test prog,link = "$linkmode,$pass"; then
cannam@167 7691 compile_deplibs="$deplib $compile_deplibs"
cannam@167 7692 finalize_deplibs="$deplib $finalize_deplibs"
cannam@167 7693 else
cannam@167 7694 deplibs="$deplib $deplibs"
cannam@167 7695 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
cannam@167 7696 fi
cannam@167 7697 continue
cannam@167 7698 fi
cannam@167 7699 ;; # -l
cannam@167 7700 *.ltframework)
cannam@167 7701 if test prog,link = "$linkmode,$pass"; then
cannam@167 7702 compile_deplibs="$deplib $compile_deplibs"
cannam@167 7703 finalize_deplibs="$deplib $finalize_deplibs"
cannam@167 7704 else
cannam@167 7705 deplibs="$deplib $deplibs"
cannam@167 7706 if test lib = "$linkmode"; then
cannam@167 7707 case "$new_inherited_linker_flags " in
cannam@167 7708 *" $deplib "*) ;;
cannam@167 7709 * ) func_append new_inherited_linker_flags " $deplib" ;;
cannam@167 7710 esac
cannam@167 7711 fi
cannam@167 7712 fi
cannam@167 7713 continue
cannam@167 7714 ;;
cannam@167 7715 -L*)
cannam@167 7716 case $linkmode in
cannam@167 7717 lib)
cannam@167 7718 deplibs="$deplib $deplibs"
cannam@167 7719 test conv = "$pass" && continue
cannam@167 7720 newdependency_libs="$deplib $newdependency_libs"
cannam@167 7721 func_stripname '-L' '' "$deplib"
cannam@167 7722 func_resolve_sysroot "$func_stripname_result"
cannam@167 7723 func_append newlib_search_path " $func_resolve_sysroot_result"
cannam@167 7724 ;;
cannam@167 7725 prog)
cannam@167 7726 if test conv = "$pass"; then
cannam@167 7727 deplibs="$deplib $deplibs"
cannam@167 7728 continue
cannam@167 7729 fi
cannam@167 7730 if test scan = "$pass"; then
cannam@167 7731 deplibs="$deplib $deplibs"
cannam@167 7732 else
cannam@167 7733 compile_deplibs="$deplib $compile_deplibs"
cannam@167 7734 finalize_deplibs="$deplib $finalize_deplibs"
cannam@167 7735 fi
cannam@167 7736 func_stripname '-L' '' "$deplib"
cannam@167 7737 func_resolve_sysroot "$func_stripname_result"
cannam@167 7738 func_append newlib_search_path " $func_resolve_sysroot_result"
cannam@167 7739 ;;
cannam@167 7740 *)
cannam@167 7741 func_warning "'-L' is ignored for archives/objects"
cannam@167 7742 ;;
cannam@167 7743 esac # linkmode
cannam@167 7744 continue
cannam@167 7745 ;; # -L
cannam@167 7746 -R*)
cannam@167 7747 if test link = "$pass"; then
cannam@167 7748 func_stripname '-R' '' "$deplib"
cannam@167 7749 func_resolve_sysroot "$func_stripname_result"
cannam@167 7750 dir=$func_resolve_sysroot_result
cannam@167 7751 # Make sure the xrpath contains only unique directories.
cannam@167 7752 case "$xrpath " in
cannam@167 7753 *" $dir "*) ;;
cannam@167 7754 *) func_append xrpath " $dir" ;;
cannam@167 7755 esac
cannam@167 7756 fi
cannam@167 7757 deplibs="$deplib $deplibs"
cannam@167 7758 continue
cannam@167 7759 ;;
cannam@167 7760 *.la)
cannam@167 7761 func_resolve_sysroot "$deplib"
cannam@167 7762 lib=$func_resolve_sysroot_result
cannam@167 7763 ;;
cannam@167 7764 *.$libext)
cannam@167 7765 if test conv = "$pass"; then
cannam@167 7766 deplibs="$deplib $deplibs"
cannam@167 7767 continue
cannam@167 7768 fi
cannam@167 7769 case $linkmode in
cannam@167 7770 lib)
cannam@167 7771 # Linking convenience modules into shared libraries is allowed,
cannam@167 7772 # but linking other static libraries is non-portable.
cannam@167 7773 case " $dlpreconveniencelibs " in
cannam@167 7774 *" $deplib "*) ;;
cannam@167 7775 *)
cannam@167 7776 valid_a_lib=false
cannam@167 7777 case $deplibs_check_method in
cannam@167 7778 match_pattern*)
cannam@167 7779 set dummy $deplibs_check_method; shift
cannam@167 7780 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
cannam@167 7781 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
cannam@167 7782 | $EGREP "$match_pattern_regex" > /dev/null; then
cannam@167 7783 valid_a_lib=:
cannam@167 7784 fi
cannam@167 7785 ;;
cannam@167 7786 pass_all)
cannam@167 7787 valid_a_lib=:
cannam@167 7788 ;;
cannam@167 7789 esac
cannam@167 7790 if $valid_a_lib; then
cannam@167 7791 echo
cannam@167 7792 $ECHO "*** Warning: Linking the shared library $output against the"
cannam@167 7793 $ECHO "*** static library $deplib is not portable!"
cannam@167 7794 deplibs="$deplib $deplibs"
cannam@167 7795 else
cannam@167 7796 echo
cannam@167 7797 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
cannam@167 7798 echo "*** I have the capability to make that library automatically link in when"
cannam@167 7799 echo "*** you link to this library. But I can only do this if you have a"
cannam@167 7800 echo "*** shared version of the library, which you do not appear to have"
cannam@167 7801 echo "*** because the file extensions .$libext of this argument makes me believe"
cannam@167 7802 echo "*** that it is just a static archive that I should not use here."
cannam@167 7803 fi
cannam@167 7804 ;;
cannam@167 7805 esac
cannam@167 7806 continue
cannam@167 7807 ;;
cannam@167 7808 prog)
cannam@167 7809 if test link != "$pass"; then
cannam@167 7810 deplibs="$deplib $deplibs"
cannam@167 7811 else
cannam@167 7812 compile_deplibs="$deplib $compile_deplibs"
cannam@167 7813 finalize_deplibs="$deplib $finalize_deplibs"
cannam@167 7814 fi
cannam@167 7815 continue
cannam@167 7816 ;;
cannam@167 7817 esac # linkmode
cannam@167 7818 ;; # *.$libext
cannam@167 7819 *.lo | *.$objext)
cannam@167 7820 if test conv = "$pass"; then
cannam@167 7821 deplibs="$deplib $deplibs"
cannam@167 7822 elif test prog = "$linkmode"; then
cannam@167 7823 if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
cannam@167 7824 # If there is no dlopen support or we're linking statically,
cannam@167 7825 # we need to preload.
cannam@167 7826 func_append newdlprefiles " $deplib"
cannam@167 7827 compile_deplibs="$deplib $compile_deplibs"
cannam@167 7828 finalize_deplibs="$deplib $finalize_deplibs"
cannam@167 7829 else
cannam@167 7830 func_append newdlfiles " $deplib"
cannam@167 7831 fi
cannam@167 7832 fi
cannam@167 7833 continue
cannam@167 7834 ;;
cannam@167 7835 %DEPLIBS%)
cannam@167 7836 alldeplibs=:
cannam@167 7837 continue
cannam@167 7838 ;;
cannam@167 7839 esac # case $deplib
cannam@167 7840
cannam@167 7841 $found || test -f "$lib" \
cannam@167 7842 || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
cannam@167 7843
cannam@167 7844 # Check to see that this really is a libtool archive.
cannam@167 7845 func_lalib_unsafe_p "$lib" \
cannam@167 7846 || func_fatal_error "'$lib' is not a valid libtool archive"
cannam@167 7847
cannam@167 7848 func_dirname "$lib" "" "."
cannam@167 7849 ladir=$func_dirname_result
cannam@167 7850
cannam@167 7851 dlname=
cannam@167 7852 dlopen=
cannam@167 7853 dlpreopen=
cannam@167 7854 libdir=
cannam@167 7855 library_names=
cannam@167 7856 old_library=
cannam@167 7857 inherited_linker_flags=
cannam@167 7858 # If the library was installed with an old release of libtool,
cannam@167 7859 # it will not redefine variables installed, or shouldnotlink
cannam@167 7860 installed=yes
cannam@167 7861 shouldnotlink=no
cannam@167 7862 avoidtemprpath=
cannam@167 7863
cannam@167 7864
cannam@167 7865 # Read the .la file
cannam@167 7866 func_source "$lib"
cannam@167 7867
cannam@167 7868 # Convert "-framework foo" to "foo.ltframework"
cannam@167 7869 if test -n "$inherited_linker_flags"; then
cannam@167 7870 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
cannam@167 7871 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
cannam@167 7872 case " $new_inherited_linker_flags " in
cannam@167 7873 *" $tmp_inherited_linker_flag "*) ;;
cannam@167 7874 *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
cannam@167 7875 esac
cannam@167 7876 done
cannam@167 7877 fi
cannam@167 7878 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@167 7879 if test lib,link = "$linkmode,$pass" ||
cannam@167 7880 test prog,scan = "$linkmode,$pass" ||
cannam@167 7881 { test prog != "$linkmode" && test lib != "$linkmode"; }; then
cannam@167 7882 test -n "$dlopen" && func_append dlfiles " $dlopen"
cannam@167 7883 test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
cannam@167 7884 fi
cannam@167 7885
cannam@167 7886 if test conv = "$pass"; then
cannam@167 7887 # Only check for convenience libraries
cannam@167 7888 deplibs="$lib $deplibs"
cannam@167 7889 if test -z "$libdir"; then
cannam@167 7890 if test -z "$old_library"; then
cannam@167 7891 func_fatal_error "cannot find name of link library for '$lib'"
cannam@167 7892 fi
cannam@167 7893 # It is a libtool convenience library, so add in its objects.
cannam@167 7894 func_append convenience " $ladir/$objdir/$old_library"
cannam@167 7895 func_append old_convenience " $ladir/$objdir/$old_library"
cannam@167 7896 tmp_libs=
cannam@167 7897 for deplib in $dependency_libs; do
cannam@167 7898 deplibs="$deplib $deplibs"
cannam@167 7899 if $opt_preserve_dup_deps; then
cannam@167 7900 case "$tmp_libs " in
cannam@167 7901 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
cannam@167 7902 esac
cannam@167 7903 fi
cannam@167 7904 func_append tmp_libs " $deplib"
cannam@167 7905 done
cannam@167 7906 elif test prog != "$linkmode" && test lib != "$linkmode"; then
cannam@167 7907 func_fatal_error "'$lib' is not a convenience library"
cannam@167 7908 fi
cannam@167 7909 continue
cannam@167 7910 fi # $pass = conv
cannam@167 7911
cannam@167 7912
cannam@167 7913 # Get the name of the library we link against.
cannam@167 7914 linklib=
cannam@167 7915 if test -n "$old_library" &&
cannam@167 7916 { test yes = "$prefer_static_libs" ||
cannam@167 7917 test built,no = "$prefer_static_libs,$installed"; }; then
cannam@167 7918 linklib=$old_library
cannam@167 7919 else
cannam@167 7920 for l in $old_library $library_names; do
cannam@167 7921 linklib=$l
cannam@167 7922 done
cannam@167 7923 fi
cannam@167 7924 if test -z "$linklib"; then
cannam@167 7925 func_fatal_error "cannot find name of link library for '$lib'"
cannam@167 7926 fi
cannam@167 7927
cannam@167 7928 # This library was specified with -dlopen.
cannam@167 7929 if test dlopen = "$pass"; then
cannam@167 7930 test -z "$libdir" \
cannam@167 7931 && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
cannam@167 7932 if test -z "$dlname" ||
cannam@167 7933 test yes != "$dlopen_support" ||
cannam@167 7934 test no = "$build_libtool_libs"
cannam@167 7935 then
cannam@167 7936 # If there is no dlname, no dlopen support or we're linking
cannam@167 7937 # statically, we need to preload. We also need to preload any
cannam@167 7938 # dependent libraries so libltdl's deplib preloader doesn't
cannam@167 7939 # bomb out in the load deplibs phase.
cannam@167 7940 func_append dlprefiles " $lib $dependency_libs"
cannam@167 7941 else
cannam@167 7942 func_append newdlfiles " $lib"
cannam@167 7943 fi
cannam@167 7944 continue
cannam@167 7945 fi # $pass = dlopen
cannam@167 7946
cannam@167 7947 # We need an absolute path.
cannam@167 7948 case $ladir in
cannam@167 7949 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
cannam@167 7950 *)
cannam@167 7951 abs_ladir=`cd "$ladir" && pwd`
cannam@167 7952 if test -z "$abs_ladir"; then
cannam@167 7953 func_warning "cannot determine absolute directory name of '$ladir'"
cannam@167 7954 func_warning "passing it literally to the linker, although it might fail"
cannam@167 7955 abs_ladir=$ladir
cannam@167 7956 fi
cannam@167 7957 ;;
cannam@167 7958 esac
cannam@167 7959 func_basename "$lib"
cannam@167 7960 laname=$func_basename_result
cannam@167 7961
cannam@167 7962 # Find the relevant object directory and library name.
cannam@167 7963 if test yes = "$installed"; then
cannam@167 7964 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
cannam@167 7965 func_warning "library '$lib' was moved."
cannam@167 7966 dir=$ladir
cannam@167 7967 absdir=$abs_ladir
cannam@167 7968 libdir=$abs_ladir
cannam@167 7969 else
cannam@167 7970 dir=$lt_sysroot$libdir
cannam@167 7971 absdir=$lt_sysroot$libdir
cannam@167 7972 fi
cannam@167 7973 test yes = "$hardcode_automatic" && avoidtemprpath=yes
cannam@167 7974 else
cannam@167 7975 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
cannam@167 7976 dir=$ladir
cannam@167 7977 absdir=$abs_ladir
cannam@167 7978 # Remove this search path later
cannam@167 7979 func_append notinst_path " $abs_ladir"
cannam@167 7980 else
cannam@167 7981 dir=$ladir/$objdir
cannam@167 7982 absdir=$abs_ladir/$objdir
cannam@167 7983 # Remove this search path later
cannam@167 7984 func_append notinst_path " $abs_ladir"
cannam@167 7985 fi
cannam@167 7986 fi # $installed = yes
cannam@167 7987 func_stripname 'lib' '.la' "$laname"
cannam@167 7988 name=$func_stripname_result
cannam@167 7989
cannam@167 7990 # This library was specified with -dlpreopen.
cannam@167 7991 if test dlpreopen = "$pass"; then
cannam@167 7992 if test -z "$libdir" && test prog = "$linkmode"; then
cannam@167 7993 func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
cannam@167 7994 fi
cannam@167 7995 case $host in
cannam@167 7996 # special handling for platforms with PE-DLLs.
cannam@167 7997 *cygwin* | *mingw* | *cegcc* )
cannam@167 7998 # Linker will automatically link against shared library if both
cannam@167 7999 # static and shared are present. Therefore, ensure we extract
cannam@167 8000 # symbols from the import library if a shared library is present
cannam@167 8001 # (otherwise, the dlopen module name will be incorrect). We do
cannam@167 8002 # this by putting the import library name into $newdlprefiles.
cannam@167 8003 # We recover the dlopen module name by 'saving' the la file
cannam@167 8004 # name in a special purpose variable, and (later) extracting the
cannam@167 8005 # dlname from the la file.
cannam@167 8006 if test -n "$dlname"; then
cannam@167 8007 func_tr_sh "$dir/$linklib"
cannam@167 8008 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
cannam@167 8009 func_append newdlprefiles " $dir/$linklib"
cannam@167 8010 else
cannam@167 8011 func_append newdlprefiles " $dir/$old_library"
cannam@167 8012 # Keep a list of preopened convenience libraries to check
cannam@167 8013 # that they are being used correctly in the link pass.
cannam@167 8014 test -z "$libdir" && \
cannam@167 8015 func_append dlpreconveniencelibs " $dir/$old_library"
cannam@167 8016 fi
cannam@167 8017 ;;
cannam@167 8018 * )
cannam@167 8019 # Prefer using a static library (so that no silly _DYNAMIC symbols
cannam@167 8020 # are required to link).
cannam@167 8021 if test -n "$old_library"; then
cannam@167 8022 func_append newdlprefiles " $dir/$old_library"
cannam@167 8023 # Keep a list of preopened convenience libraries to check
cannam@167 8024 # that they are being used correctly in the link pass.
cannam@167 8025 test -z "$libdir" && \
cannam@167 8026 func_append dlpreconveniencelibs " $dir/$old_library"
cannam@167 8027 # Otherwise, use the dlname, so that lt_dlopen finds it.
cannam@167 8028 elif test -n "$dlname"; then
cannam@167 8029 func_append newdlprefiles " $dir/$dlname"
cannam@167 8030 else
cannam@167 8031 func_append newdlprefiles " $dir/$linklib"
cannam@167 8032 fi
cannam@167 8033 ;;
cannam@167 8034 esac
cannam@167 8035 fi # $pass = dlpreopen
cannam@167 8036
cannam@167 8037 if test -z "$libdir"; then
cannam@167 8038 # Link the convenience library
cannam@167 8039 if test lib = "$linkmode"; then
cannam@167 8040 deplibs="$dir/$old_library $deplibs"
cannam@167 8041 elif test prog,link = "$linkmode,$pass"; then
cannam@167 8042 compile_deplibs="$dir/$old_library $compile_deplibs"
cannam@167 8043 finalize_deplibs="$dir/$old_library $finalize_deplibs"
cannam@167 8044 else
cannam@167 8045 deplibs="$lib $deplibs" # used for prog,scan pass
cannam@167 8046 fi
cannam@167 8047 continue
cannam@167 8048 fi
cannam@167 8049
cannam@167 8050
cannam@167 8051 if test prog = "$linkmode" && test link != "$pass"; then
cannam@167 8052 func_append newlib_search_path " $ladir"
cannam@167 8053 deplibs="$lib $deplibs"
cannam@167 8054
cannam@167 8055 linkalldeplibs=false
cannam@167 8056 if test no != "$link_all_deplibs" || test -z "$library_names" ||
cannam@167 8057 test no = "$build_libtool_libs"; then
cannam@167 8058 linkalldeplibs=:
cannam@167 8059 fi
cannam@167 8060
cannam@167 8061 tmp_libs=
cannam@167 8062 for deplib in $dependency_libs; do
cannam@167 8063 case $deplib in
cannam@167 8064 -L*) func_stripname '-L' '' "$deplib"
cannam@167 8065 func_resolve_sysroot "$func_stripname_result"
cannam@167 8066 func_append newlib_search_path " $func_resolve_sysroot_result"
cannam@167 8067 ;;
cannam@167 8068 esac
cannam@167 8069 # Need to link against all dependency_libs?
cannam@167 8070 if $linkalldeplibs; then
cannam@167 8071 deplibs="$deplib $deplibs"
cannam@167 8072 else
cannam@167 8073 # Need to hardcode shared library paths
cannam@167 8074 # or/and link against static libraries
cannam@167 8075 newdependency_libs="$deplib $newdependency_libs"
cannam@167 8076 fi
cannam@167 8077 if $opt_preserve_dup_deps; then
cannam@167 8078 case "$tmp_libs " in
cannam@167 8079 *" $deplib "*) func_append specialdeplibs " $deplib" ;;
cannam@167 8080 esac
cannam@167 8081 fi
cannam@167 8082 func_append tmp_libs " $deplib"
cannam@167 8083 done # for deplib
cannam@167 8084 continue
cannam@167 8085 fi # $linkmode = prog...
cannam@167 8086
cannam@167 8087 if test prog,link = "$linkmode,$pass"; then
cannam@167 8088 if test -n "$library_names" &&
cannam@167 8089 { { test no = "$prefer_static_libs" ||
cannam@167 8090 test built,yes = "$prefer_static_libs,$installed"; } ||
cannam@167 8091 test -z "$old_library"; }; then
cannam@167 8092 # We need to hardcode the library path
cannam@167 8093 if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
cannam@167 8094 # Make sure the rpath contains only unique directories.
cannam@167 8095 case $temp_rpath: in
cannam@167 8096 *"$absdir:"*) ;;
cannam@167 8097 *) func_append temp_rpath "$absdir:" ;;
cannam@167 8098 esac
cannam@167 8099 fi
cannam@167 8100
cannam@167 8101 # Hardcode the library path.
cannam@167 8102 # Skip directories that are in the system default run-time
cannam@167 8103 # search path.
cannam@167 8104 case " $sys_lib_dlsearch_path " in
cannam@167 8105 *" $absdir "*) ;;
cannam@167 8106 *)
cannam@167 8107 case "$compile_rpath " in
cannam@167 8108 *" $absdir "*) ;;
cannam@167 8109 *) func_append compile_rpath " $absdir" ;;
cannam@167 8110 esac
cannam@167 8111 ;;
cannam@167 8112 esac
cannam@167 8113 case " $sys_lib_dlsearch_path " in
cannam@167 8114 *" $libdir "*) ;;
cannam@167 8115 *)
cannam@167 8116 case "$finalize_rpath " in
cannam@167 8117 *" $libdir "*) ;;
cannam@167 8118 *) func_append finalize_rpath " $libdir" ;;
cannam@167 8119 esac
cannam@167 8120 ;;
cannam@167 8121 esac
cannam@167 8122 fi # $linkmode,$pass = prog,link...
cannam@167 8123
cannam@167 8124 if $alldeplibs &&
cannam@167 8125 { test pass_all = "$deplibs_check_method" ||
cannam@167 8126 { test yes = "$build_libtool_libs" &&
cannam@167 8127 test -n "$library_names"; }; }; then
cannam@167 8128 # We only need to search for static libraries
cannam@167 8129 continue
cannam@167 8130 fi
cannam@167 8131 fi
cannam@167 8132
cannam@167 8133 link_static=no # Whether the deplib will be linked statically
cannam@167 8134 use_static_libs=$prefer_static_libs
cannam@167 8135 if test built = "$use_static_libs" && test yes = "$installed"; then
cannam@167 8136 use_static_libs=no
cannam@167 8137 fi
cannam@167 8138 if test -n "$library_names" &&
cannam@167 8139 { test no = "$use_static_libs" || test -z "$old_library"; }; then
cannam@167 8140 case $host in
cannam@167 8141 *cygwin* | *mingw* | *cegcc* | *os2*)
cannam@167 8142 # No point in relinking DLLs because paths are not encoded
cannam@167 8143 func_append notinst_deplibs " $lib"
cannam@167 8144 need_relink=no
cannam@167 8145 ;;
cannam@167 8146 *)
cannam@167 8147 if test no = "$installed"; then
cannam@167 8148 func_append notinst_deplibs " $lib"
cannam@167 8149 need_relink=yes
cannam@167 8150 fi
cannam@167 8151 ;;
cannam@167 8152 esac
cannam@167 8153 # This is a shared library
cannam@167 8154
cannam@167 8155 # Warn about portability, can't link against -module's on some
cannam@167 8156 # systems (darwin). Don't bleat about dlopened modules though!
cannam@167 8157 dlopenmodule=
cannam@167 8158 for dlpremoduletest in $dlprefiles; do
cannam@167 8159 if test "X$dlpremoduletest" = "X$lib"; then
cannam@167 8160 dlopenmodule=$dlpremoduletest
cannam@167 8161 break
cannam@167 8162 fi
cannam@167 8163 done
cannam@167 8164 if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
cannam@167 8165 echo
cannam@167 8166 if test prog = "$linkmode"; then
cannam@167 8167 $ECHO "*** Warning: Linking the executable $output against the loadable module"
cannam@167 8168 else
cannam@167 8169 $ECHO "*** Warning: Linking the shared library $output against the loadable module"
cannam@167 8170 fi
cannam@167 8171 $ECHO "*** $linklib is not portable!"
cannam@167 8172 fi
cannam@167 8173 if test lib = "$linkmode" &&
cannam@167 8174 test yes = "$hardcode_into_libs"; then
cannam@167 8175 # Hardcode the library path.
cannam@167 8176 # Skip directories that are in the system default run-time
cannam@167 8177 # search path.
cannam@167 8178 case " $sys_lib_dlsearch_path " in
cannam@167 8179 *" $absdir "*) ;;
cannam@167 8180 *)
cannam@167 8181 case "$compile_rpath " in
cannam@167 8182 *" $absdir "*) ;;
cannam@167 8183 *) func_append compile_rpath " $absdir" ;;
cannam@167 8184 esac
cannam@167 8185 ;;
cannam@167 8186 esac
cannam@167 8187 case " $sys_lib_dlsearch_path " in
cannam@167 8188 *" $libdir "*) ;;
cannam@167 8189 *)
cannam@167 8190 case "$finalize_rpath " in
cannam@167 8191 *" $libdir "*) ;;
cannam@167 8192 *) func_append finalize_rpath " $libdir" ;;
cannam@167 8193 esac
cannam@167 8194 ;;
cannam@167 8195 esac
cannam@167 8196 fi
cannam@167 8197
cannam@167 8198 if test -n "$old_archive_from_expsyms_cmds"; then
cannam@167 8199 # figure out the soname
cannam@167 8200 set dummy $library_names
cannam@167 8201 shift
cannam@167 8202 realname=$1
cannam@167 8203 shift
cannam@167 8204 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@167 8205 # use dlname if we got it. it's perfectly good, no?
cannam@167 8206 if test -n "$dlname"; then
cannam@167 8207 soname=$dlname
cannam@167 8208 elif test -n "$soname_spec"; then
cannam@167 8209 # bleh windows
cannam@167 8210 case $host in
cannam@167 8211 *cygwin* | mingw* | *cegcc* | *os2*)
cannam@167 8212 func_arith $current - $age
cannam@167 8213 major=$func_arith_result
cannam@167 8214 versuffix=-$major
cannam@167 8215 ;;
cannam@167 8216 esac
cannam@167 8217 eval soname=\"$soname_spec\"
cannam@167 8218 else
cannam@167 8219 soname=$realname
cannam@167 8220 fi
cannam@167 8221
cannam@167 8222 # Make a new name for the extract_expsyms_cmds to use
cannam@167 8223 soroot=$soname
cannam@167 8224 func_basename "$soroot"
cannam@167 8225 soname=$func_basename_result
cannam@167 8226 func_stripname 'lib' '.dll' "$soname"
cannam@167 8227 newlib=libimp-$func_stripname_result.a
cannam@167 8228
cannam@167 8229 # If the library has no export list, then create one now
cannam@167 8230 if test -f "$output_objdir/$soname-def"; then :
cannam@167 8231 else
cannam@167 8232 func_verbose "extracting exported symbol list from '$soname'"
cannam@167 8233 func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
cannam@167 8234 fi
cannam@167 8235
cannam@167 8236 # Create $newlib
cannam@167 8237 if test -f "$output_objdir/$newlib"; then :; else
cannam@167 8238 func_verbose "generating import library for '$soname'"
cannam@167 8239 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
cannam@167 8240 fi
cannam@167 8241 # make sure the library variables are pointing to the new library
cannam@167 8242 dir=$output_objdir
cannam@167 8243 linklib=$newlib
cannam@167 8244 fi # test -n "$old_archive_from_expsyms_cmds"
cannam@167 8245
cannam@167 8246 if test prog = "$linkmode" || test relink != "$opt_mode"; then
cannam@167 8247 add_shlibpath=
cannam@167 8248 add_dir=
cannam@167 8249 add=
cannam@167 8250 lib_linked=yes
cannam@167 8251 case $hardcode_action in
cannam@167 8252 immediate | unsupported)
cannam@167 8253 if test no = "$hardcode_direct"; then
cannam@167 8254 add=$dir/$linklib
cannam@167 8255 case $host in
cannam@167 8256 *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
cannam@167 8257 *-*-sysv4*uw2*) add_dir=-L$dir ;;
cannam@167 8258 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
cannam@167 8259 *-*-unixware7*) add_dir=-L$dir ;;
cannam@167 8260 *-*-darwin* )
cannam@167 8261 # if the lib is a (non-dlopened) module then we cannot
cannam@167 8262 # link against it, someone is ignoring the earlier warnings
cannam@167 8263 if /usr/bin/file -L $add 2> /dev/null |
cannam@167 8264 $GREP ": [^:]* bundle" >/dev/null; then
cannam@167 8265 if test "X$dlopenmodule" != "X$lib"; then
cannam@167 8266 $ECHO "*** Warning: lib $linklib is a module, not a shared library"
cannam@167 8267 if test -z "$old_library"; then
cannam@167 8268 echo
cannam@167 8269 echo "*** And there doesn't seem to be a static archive available"
cannam@167 8270 echo "*** The link will probably fail, sorry"
cannam@167 8271 else
cannam@167 8272 add=$dir/$old_library
cannam@167 8273 fi
cannam@167 8274 elif test -n "$old_library"; then
cannam@167 8275 add=$dir/$old_library
cannam@167 8276 fi
cannam@167 8277 fi
cannam@167 8278 esac
cannam@167 8279 elif test no = "$hardcode_minus_L"; then
cannam@167 8280 case $host in
cannam@167 8281 *-*-sunos*) add_shlibpath=$dir ;;
cannam@167 8282 esac
cannam@167 8283 add_dir=-L$dir
cannam@167 8284 add=-l$name
cannam@167 8285 elif test no = "$hardcode_shlibpath_var"; then
cannam@167 8286 add_shlibpath=$dir
cannam@167 8287 add=-l$name
cannam@167 8288 else
cannam@167 8289 lib_linked=no
cannam@167 8290 fi
cannam@167 8291 ;;
cannam@167 8292 relink)
cannam@167 8293 if test yes = "$hardcode_direct" &&
cannam@167 8294 test no = "$hardcode_direct_absolute"; then
cannam@167 8295 add=$dir/$linklib
cannam@167 8296 elif test yes = "$hardcode_minus_L"; then
cannam@167 8297 add_dir=-L$absdir
cannam@167 8298 # Try looking first in the location we're being installed to.
cannam@167 8299 if test -n "$inst_prefix_dir"; then
cannam@167 8300 case $libdir in
cannam@167 8301 [\\/]*)
cannam@167 8302 func_append add_dir " -L$inst_prefix_dir$libdir"
cannam@167 8303 ;;
cannam@167 8304 esac
cannam@167 8305 fi
cannam@167 8306 add=-l$name
cannam@167 8307 elif test yes = "$hardcode_shlibpath_var"; then
cannam@167 8308 add_shlibpath=$dir
cannam@167 8309 add=-l$name
cannam@167 8310 else
cannam@167 8311 lib_linked=no
cannam@167 8312 fi
cannam@167 8313 ;;
cannam@167 8314 *) lib_linked=no ;;
cannam@167 8315 esac
cannam@167 8316
cannam@167 8317 if test yes != "$lib_linked"; then
cannam@167 8318 func_fatal_configuration "unsupported hardcode properties"
cannam@167 8319 fi
cannam@167 8320
cannam@167 8321 if test -n "$add_shlibpath"; then
cannam@167 8322 case :$compile_shlibpath: in
cannam@167 8323 *":$add_shlibpath:"*) ;;
cannam@167 8324 *) func_append compile_shlibpath "$add_shlibpath:" ;;
cannam@167 8325 esac
cannam@167 8326 fi
cannam@167 8327 if test prog = "$linkmode"; then
cannam@167 8328 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
cannam@167 8329 test -n "$add" && compile_deplibs="$add $compile_deplibs"
cannam@167 8330 else
cannam@167 8331 test -n "$add_dir" && deplibs="$add_dir $deplibs"
cannam@167 8332 test -n "$add" && deplibs="$add $deplibs"
cannam@167 8333 if test yes != "$hardcode_direct" &&
cannam@167 8334 test yes != "$hardcode_minus_L" &&
cannam@167 8335 test yes = "$hardcode_shlibpath_var"; then
cannam@167 8336 case :$finalize_shlibpath: in
cannam@167 8337 *":$libdir:"*) ;;
cannam@167 8338 *) func_append finalize_shlibpath "$libdir:" ;;
cannam@167 8339 esac
cannam@167 8340 fi
cannam@167 8341 fi
cannam@167 8342 fi
cannam@167 8343
cannam@167 8344 if test prog = "$linkmode" || test relink = "$opt_mode"; then
cannam@167 8345 add_shlibpath=
cannam@167 8346 add_dir=
cannam@167 8347 add=
cannam@167 8348 # Finalize command for both is simple: just hardcode it.
cannam@167 8349 if test yes = "$hardcode_direct" &&
cannam@167 8350 test no = "$hardcode_direct_absolute"; then
cannam@167 8351 add=$libdir/$linklib
cannam@167 8352 elif test yes = "$hardcode_minus_L"; then
cannam@167 8353 add_dir=-L$libdir
cannam@167 8354 add=-l$name
cannam@167 8355 elif test yes = "$hardcode_shlibpath_var"; then
cannam@167 8356 case :$finalize_shlibpath: in
cannam@167 8357 *":$libdir:"*) ;;
cannam@167 8358 *) func_append finalize_shlibpath "$libdir:" ;;
cannam@167 8359 esac
cannam@167 8360 add=-l$name
cannam@167 8361 elif test yes = "$hardcode_automatic"; then
cannam@167 8362 if test -n "$inst_prefix_dir" &&
cannam@167 8363 test -f "$inst_prefix_dir$libdir/$linklib"; then
cannam@167 8364 add=$inst_prefix_dir$libdir/$linklib
cannam@167 8365 else
cannam@167 8366 add=$libdir/$linklib
cannam@167 8367 fi
cannam@167 8368 else
cannam@167 8369 # We cannot seem to hardcode it, guess we'll fake it.
cannam@167 8370 add_dir=-L$libdir
cannam@167 8371 # Try looking first in the location we're being installed to.
cannam@167 8372 if test -n "$inst_prefix_dir"; then
cannam@167 8373 case $libdir in
cannam@167 8374 [\\/]*)
cannam@167 8375 func_append add_dir " -L$inst_prefix_dir$libdir"
cannam@167 8376 ;;
cannam@167 8377 esac
cannam@167 8378 fi
cannam@167 8379 add=-l$name
cannam@167 8380 fi
cannam@167 8381
cannam@167 8382 if test prog = "$linkmode"; then
cannam@167 8383 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
cannam@167 8384 test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
cannam@167 8385 else
cannam@167 8386 test -n "$add_dir" && deplibs="$add_dir $deplibs"
cannam@167 8387 test -n "$add" && deplibs="$add $deplibs"
cannam@167 8388 fi
cannam@167 8389 fi
cannam@167 8390 elif test prog = "$linkmode"; then
cannam@167 8391 # Here we assume that one of hardcode_direct or hardcode_minus_L
cannam@167 8392 # is not unsupported. This is valid on all known static and
cannam@167 8393 # shared platforms.
cannam@167 8394 if test unsupported != "$hardcode_direct"; then
cannam@167 8395 test -n "$old_library" && linklib=$old_library
cannam@167 8396 compile_deplibs="$dir/$linklib $compile_deplibs"
cannam@167 8397 finalize_deplibs="$dir/$linklib $finalize_deplibs"
cannam@167 8398 else
cannam@167 8399 compile_deplibs="-l$name -L$dir $compile_deplibs"
cannam@167 8400 finalize_deplibs="-l$name -L$dir $finalize_deplibs"
cannam@167 8401 fi
cannam@167 8402 elif test yes = "$build_libtool_libs"; then
cannam@167 8403 # Not a shared library
cannam@167 8404 if test pass_all != "$deplibs_check_method"; then
cannam@167 8405 # We're trying link a shared library against a static one
cannam@167 8406 # but the system doesn't support it.
cannam@167 8407
cannam@167 8408 # Just print a warning and add the library to dependency_libs so
cannam@167 8409 # that the program can be linked against the static library.
cannam@167 8410 echo
cannam@167 8411 $ECHO "*** Warning: This system cannot link to static lib archive $lib."
cannam@167 8412 echo "*** I have the capability to make that library automatically link in when"
cannam@167 8413 echo "*** you link to this library. But I can only do this if you have a"
cannam@167 8414 echo "*** shared version of the library, which you do not appear to have."
cannam@167 8415 if test yes = "$module"; then
cannam@167 8416 echo "*** But as you try to build a module library, libtool will still create "
cannam@167 8417 echo "*** a static module, that should work as long as the dlopening application"
cannam@167 8418 echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
cannam@167 8419 if test -z "$global_symbol_pipe"; then
cannam@167 8420 echo
cannam@167 8421 echo "*** However, this would only work if libtool was able to extract symbol"
cannam@167 8422 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
cannam@167 8423 echo "*** not find such a program. So, this module is probably useless."
cannam@167 8424 echo "*** 'nm' from GNU binutils and a full rebuild may help."
cannam@167 8425 fi
cannam@167 8426 if test no = "$build_old_libs"; then
cannam@167 8427 build_libtool_libs=module
cannam@167 8428 build_old_libs=yes
cannam@167 8429 else
cannam@167 8430 build_libtool_libs=no
cannam@167 8431 fi
cannam@167 8432 fi
cannam@167 8433 else
cannam@167 8434 deplibs="$dir/$old_library $deplibs"
cannam@167 8435 link_static=yes
cannam@167 8436 fi
cannam@167 8437 fi # link shared/static library?
cannam@167 8438
cannam@167 8439 if test lib = "$linkmode"; then
cannam@167 8440 if test -n "$dependency_libs" &&
cannam@167 8441 { test yes != "$hardcode_into_libs" ||
cannam@167 8442 test yes = "$build_old_libs" ||
cannam@167 8443 test yes = "$link_static"; }; then
cannam@167 8444 # Extract -R from dependency_libs
cannam@167 8445 temp_deplibs=
cannam@167 8446 for libdir in $dependency_libs; do
cannam@167 8447 case $libdir in
cannam@167 8448 -R*) func_stripname '-R' '' "$libdir"
cannam@167 8449 temp_xrpath=$func_stripname_result
cannam@167 8450 case " $xrpath " in
cannam@167 8451 *" $temp_xrpath "*) ;;
cannam@167 8452 *) func_append xrpath " $temp_xrpath";;
cannam@167 8453 esac;;
cannam@167 8454 *) func_append temp_deplibs " $libdir";;
cannam@167 8455 esac
cannam@167 8456 done
cannam@167 8457 dependency_libs=$temp_deplibs
cannam@167 8458 fi
cannam@167 8459
cannam@167 8460 func_append newlib_search_path " $absdir"
cannam@167 8461 # Link against this library
cannam@167 8462 test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
cannam@167 8463 # ... and its dependency_libs
cannam@167 8464 tmp_libs=
cannam@167 8465 for deplib in $dependency_libs; do
cannam@167 8466 newdependency_libs="$deplib $newdependency_libs"
cannam@167 8467 case $deplib in
cannam@167 8468 -L*) func_stripname '-L' '' "$deplib"
cannam@167 8469 func_resolve_sysroot "$func_stripname_result";;
cannam@167 8470 *) func_resolve_sysroot "$deplib" ;;
cannam@167 8471 esac
cannam@167 8472 if $opt_preserve_dup_deps; then
cannam@167 8473 case "$tmp_libs " in
cannam@167 8474 *" $func_resolve_sysroot_result "*)
cannam@167 8475 func_append specialdeplibs " $func_resolve_sysroot_result" ;;
cannam@167 8476 esac
cannam@167 8477 fi
cannam@167 8478 func_append tmp_libs " $func_resolve_sysroot_result"
cannam@167 8479 done
cannam@167 8480
cannam@167 8481 if test no != "$link_all_deplibs"; then
cannam@167 8482 # Add the search paths of all dependency libraries
cannam@167 8483 for deplib in $dependency_libs; do
cannam@167 8484 path=
cannam@167 8485 case $deplib in
cannam@167 8486 -L*) path=$deplib ;;
cannam@167 8487 *.la)
cannam@167 8488 func_resolve_sysroot "$deplib"
cannam@167 8489 deplib=$func_resolve_sysroot_result
cannam@167 8490 func_dirname "$deplib" "" "."
cannam@167 8491 dir=$func_dirname_result
cannam@167 8492 # We need an absolute path.
cannam@167 8493 case $dir in
cannam@167 8494 [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
cannam@167 8495 *)
cannam@167 8496 absdir=`cd "$dir" && pwd`
cannam@167 8497 if test -z "$absdir"; then
cannam@167 8498 func_warning "cannot determine absolute directory name of '$dir'"
cannam@167 8499 absdir=$dir
cannam@167 8500 fi
cannam@167 8501 ;;
cannam@167 8502 esac
cannam@167 8503 if $GREP "^installed=no" $deplib > /dev/null; then
cannam@167 8504 case $host in
cannam@167 8505 *-*-darwin*)
cannam@167 8506 depdepl=
cannam@167 8507 eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
cannam@167 8508 if test -n "$deplibrary_names"; then
cannam@167 8509 for tmp in $deplibrary_names; do
cannam@167 8510 depdepl=$tmp
cannam@167 8511 done
cannam@167 8512 if test -f "$absdir/$objdir/$depdepl"; then
cannam@167 8513 depdepl=$absdir/$objdir/$depdepl
cannam@167 8514 darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
cannam@167 8515 if test -z "$darwin_install_name"; then
cannam@167 8516 darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
cannam@167 8517 fi
cannam@167 8518 func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
cannam@167 8519 func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
cannam@167 8520 path=
cannam@167 8521 fi
cannam@167 8522 fi
cannam@167 8523 ;;
cannam@167 8524 *)
cannam@167 8525 path=-L$absdir/$objdir
cannam@167 8526 ;;
cannam@167 8527 esac
cannam@167 8528 else
cannam@167 8529 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
cannam@167 8530 test -z "$libdir" && \
cannam@167 8531 func_fatal_error "'$deplib' is not a valid libtool archive"
cannam@167 8532 test "$absdir" != "$libdir" && \
cannam@167 8533 func_warning "'$deplib' seems to be moved"
cannam@167 8534
cannam@167 8535 path=-L$absdir
cannam@167 8536 fi
cannam@167 8537 ;;
cannam@167 8538 esac
cannam@167 8539 case " $deplibs " in
cannam@167 8540 *" $path "*) ;;
cannam@167 8541 *) deplibs="$path $deplibs" ;;
cannam@167 8542 esac
cannam@167 8543 done
cannam@167 8544 fi # link_all_deplibs != no
cannam@167 8545 fi # linkmode = lib
cannam@167 8546 done # for deplib in $libs
cannam@167 8547 if test link = "$pass"; then
cannam@167 8548 if test prog = "$linkmode"; then
cannam@167 8549 compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
cannam@167 8550 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
cannam@167 8551 else
cannam@167 8552 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@167 8553 fi
cannam@167 8554 fi
cannam@167 8555 dependency_libs=$newdependency_libs
cannam@167 8556 if test dlpreopen = "$pass"; then
cannam@167 8557 # Link the dlpreopened libraries before other libraries
cannam@167 8558 for deplib in $save_deplibs; do
cannam@167 8559 deplibs="$deplib $deplibs"
cannam@167 8560 done
cannam@167 8561 fi
cannam@167 8562 if test dlopen != "$pass"; then
cannam@167 8563 test conv = "$pass" || {
cannam@167 8564 # Make sure lib_search_path contains only unique directories.
cannam@167 8565 lib_search_path=
cannam@167 8566 for dir in $newlib_search_path; do
cannam@167 8567 case "$lib_search_path " in
cannam@167 8568 *" $dir "*) ;;
cannam@167 8569 *) func_append lib_search_path " $dir" ;;
cannam@167 8570 esac
cannam@167 8571 done
cannam@167 8572 newlib_search_path=
cannam@167 8573 }
cannam@167 8574
cannam@167 8575 if test prog,link = "$linkmode,$pass"; then
cannam@167 8576 vars="compile_deplibs finalize_deplibs"
cannam@167 8577 else
cannam@167 8578 vars=deplibs
cannam@167 8579 fi
cannam@167 8580 for var in $vars dependency_libs; do
cannam@167 8581 # Add libraries to $var in reverse order
cannam@167 8582 eval tmp_libs=\"\$$var\"
cannam@167 8583 new_libs=
cannam@167 8584 for deplib in $tmp_libs; do
cannam@167 8585 # FIXME: Pedantically, this is the right thing to do, so
cannam@167 8586 # that some nasty dependency loop isn't accidentally
cannam@167 8587 # broken:
cannam@167 8588 #new_libs="$deplib $new_libs"
cannam@167 8589 # Pragmatically, this seems to cause very few problems in
cannam@167 8590 # practice:
cannam@167 8591 case $deplib in
cannam@167 8592 -L*) new_libs="$deplib $new_libs" ;;
cannam@167 8593 -R*) ;;
cannam@167 8594 *)
cannam@167 8595 # And here is the reason: when a library appears more
cannam@167 8596 # than once as an explicit dependence of a library, or
cannam@167 8597 # is implicitly linked in more than once by the
cannam@167 8598 # compiler, it is considered special, and multiple
cannam@167 8599 # occurrences thereof are not removed. Compare this
cannam@167 8600 # with having the same library being listed as a
cannam@167 8601 # dependency of multiple other libraries: in this case,
cannam@167 8602 # we know (pedantically, we assume) the library does not
cannam@167 8603 # need to be listed more than once, so we keep only the
cannam@167 8604 # last copy. This is not always right, but it is rare
cannam@167 8605 # enough that we require users that really mean to play
cannam@167 8606 # such unportable linking tricks to link the library
cannam@167 8607 # using -Wl,-lname, so that libtool does not consider it
cannam@167 8608 # for duplicate removal.
cannam@167 8609 case " $specialdeplibs " in
cannam@167 8610 *" $deplib "*) new_libs="$deplib $new_libs" ;;
cannam@167 8611 *)
cannam@167 8612 case " $new_libs " in
cannam@167 8613 *" $deplib "*) ;;
cannam@167 8614 *) new_libs="$deplib $new_libs" ;;
cannam@167 8615 esac
cannam@167 8616 ;;
cannam@167 8617 esac
cannam@167 8618 ;;
cannam@167 8619 esac
cannam@167 8620 done
cannam@167 8621 tmp_libs=
cannam@167 8622 for deplib in $new_libs; do
cannam@167 8623 case $deplib in
cannam@167 8624 -L*)
cannam@167 8625 case " $tmp_libs " in
cannam@167 8626 *" $deplib "*) ;;
cannam@167 8627 *) func_append tmp_libs " $deplib" ;;
cannam@167 8628 esac
cannam@167 8629 ;;
cannam@167 8630 *) func_append tmp_libs " $deplib" ;;
cannam@167 8631 esac
cannam@167 8632 done
cannam@167 8633 eval $var=\"$tmp_libs\"
cannam@167 8634 done # for var
cannam@167 8635 fi
cannam@167 8636
cannam@167 8637 # Add Sun CC postdeps if required:
cannam@167 8638 test CXX = "$tagname" && {
cannam@167 8639 case $host_os in
cannam@167 8640 linux*)
cannam@167 8641 case `$CC -V 2>&1 | sed 5q` in
cannam@167 8642 *Sun\ C*) # Sun C++ 5.9
cannam@167 8643 func_suncc_cstd_abi
cannam@167 8644
cannam@167 8645 if test no != "$suncc_use_cstd_abi"; then
cannam@167 8646 func_append postdeps ' -library=Cstd -library=Crun'
cannam@167 8647 fi
cannam@167 8648 ;;
cannam@167 8649 esac
cannam@167 8650 ;;
cannam@167 8651
cannam@167 8652 solaris*)
cannam@167 8653 func_cc_basename "$CC"
cannam@167 8654 case $func_cc_basename_result in
cannam@167 8655 CC* | sunCC*)
cannam@167 8656 func_suncc_cstd_abi
cannam@167 8657
cannam@167 8658 if test no != "$suncc_use_cstd_abi"; then
cannam@167 8659 func_append postdeps ' -library=Cstd -library=Crun'
cannam@167 8660 fi
cannam@167 8661 ;;
cannam@167 8662 esac
cannam@167 8663 ;;
cannam@167 8664 esac
cannam@167 8665 }
cannam@167 8666
cannam@167 8667 # Last step: remove runtime libs from dependency_libs
cannam@167 8668 # (they stay in deplibs)
cannam@167 8669 tmp_libs=
cannam@167 8670 for i in $dependency_libs; do
cannam@167 8671 case " $predeps $postdeps $compiler_lib_search_path " in
cannam@167 8672 *" $i "*)
cannam@167 8673 i=
cannam@167 8674 ;;
cannam@167 8675 esac
cannam@167 8676 if test -n "$i"; then
cannam@167 8677 func_append tmp_libs " $i"
cannam@167 8678 fi
cannam@167 8679 done
cannam@167 8680 dependency_libs=$tmp_libs
cannam@167 8681 done # for pass
cannam@167 8682 if test prog = "$linkmode"; then
cannam@167 8683 dlfiles=$newdlfiles
cannam@167 8684 fi
cannam@167 8685 if test prog = "$linkmode" || test lib = "$linkmode"; then
cannam@167 8686 dlprefiles=$newdlprefiles
cannam@167 8687 fi
cannam@167 8688
cannam@167 8689 case $linkmode in
cannam@167 8690 oldlib)
cannam@167 8691 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
cannam@167 8692 func_warning "'-dlopen' is ignored for archives"
cannam@167 8693 fi
cannam@167 8694
cannam@167 8695 case " $deplibs" in
cannam@167 8696 *\ -l* | *\ -L*)
cannam@167 8697 func_warning "'-l' and '-L' are ignored for archives" ;;
cannam@167 8698 esac
cannam@167 8699
cannam@167 8700 test -n "$rpath" && \
cannam@167 8701 func_warning "'-rpath' is ignored for archives"
cannam@167 8702
cannam@167 8703 test -n "$xrpath" && \
cannam@167 8704 func_warning "'-R' is ignored for archives"
cannam@167 8705
cannam@167 8706 test -n "$vinfo" && \
cannam@167 8707 func_warning "'-version-info/-version-number' is ignored for archives"
cannam@167 8708
cannam@167 8709 test -n "$release" && \
cannam@167 8710 func_warning "'-release' is ignored for archives"
cannam@167 8711
cannam@167 8712 test -n "$export_symbols$export_symbols_regex" && \
cannam@167 8713 func_warning "'-export-symbols' is ignored for archives"
cannam@167 8714
cannam@167 8715 # Now set the variables for building old libraries.
cannam@167 8716 build_libtool_libs=no
cannam@167 8717 oldlibs=$output
cannam@167 8718 func_append objs "$old_deplibs"
cannam@167 8719 ;;
cannam@167 8720
cannam@167 8721 lib)
cannam@167 8722 # Make sure we only generate libraries of the form 'libNAME.la'.
cannam@167 8723 case $outputname in
cannam@167 8724 lib*)
cannam@167 8725 func_stripname 'lib' '.la' "$outputname"
cannam@167 8726 name=$func_stripname_result
cannam@167 8727 eval shared_ext=\"$shrext_cmds\"
cannam@167 8728 eval libname=\"$libname_spec\"
cannam@167 8729 ;;
cannam@167 8730 *)
cannam@167 8731 test no = "$module" \
cannam@167 8732 && func_fatal_help "libtool library '$output' must begin with 'lib'"
cannam@167 8733
cannam@167 8734 if test no != "$need_lib_prefix"; then
cannam@167 8735 # Add the "lib" prefix for modules if required
cannam@167 8736 func_stripname '' '.la' "$outputname"
cannam@167 8737 name=$func_stripname_result
cannam@167 8738 eval shared_ext=\"$shrext_cmds\"
cannam@167 8739 eval libname=\"$libname_spec\"
cannam@167 8740 else
cannam@167 8741 func_stripname '' '.la' "$outputname"
cannam@167 8742 libname=$func_stripname_result
cannam@167 8743 fi
cannam@167 8744 ;;
cannam@167 8745 esac
cannam@167 8746
cannam@167 8747 if test -n "$objs"; then
cannam@167 8748 if test pass_all != "$deplibs_check_method"; then
cannam@167 8749 func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
cannam@167 8750 else
cannam@167 8751 echo
cannam@167 8752 $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
cannam@167 8753 $ECHO "*** objects $objs is not portable!"
cannam@167 8754 func_append libobjs " $objs"
cannam@167 8755 fi
cannam@167 8756 fi
cannam@167 8757
cannam@167 8758 test no = "$dlself" \
cannam@167 8759 || func_warning "'-dlopen self' is ignored for libtool libraries"
cannam@167 8760
cannam@167 8761 set dummy $rpath
cannam@167 8762 shift
cannam@167 8763 test 1 -lt "$#" \
cannam@167 8764 && func_warning "ignoring multiple '-rpath's for a libtool library"
cannam@167 8765
cannam@167 8766 install_libdir=$1
cannam@167 8767
cannam@167 8768 oldlibs=
cannam@167 8769 if test -z "$rpath"; then
cannam@167 8770 if test yes = "$build_libtool_libs"; then
cannam@167 8771 # Building a libtool convenience library.
cannam@167 8772 # Some compilers have problems with a '.al' extension so
cannam@167 8773 # convenience libraries should have the same extension an
cannam@167 8774 # archive normally would.
cannam@167 8775 oldlibs="$output_objdir/$libname.$libext $oldlibs"
cannam@167 8776 build_libtool_libs=convenience
cannam@167 8777 build_old_libs=yes
cannam@167 8778 fi
cannam@167 8779
cannam@167 8780 test -n "$vinfo" && \
cannam@167 8781 func_warning "'-version-info/-version-number' is ignored for convenience libraries"
cannam@167 8782
cannam@167 8783 test -n "$release" && \
cannam@167 8784 func_warning "'-release' is ignored for convenience libraries"
cannam@167 8785 else
cannam@167 8786
cannam@167 8787 # Parse the version information argument.
cannam@167 8788 save_ifs=$IFS; IFS=:
cannam@167 8789 set dummy $vinfo 0 0 0
cannam@167 8790 shift
cannam@167 8791 IFS=$save_ifs
cannam@167 8792
cannam@167 8793 test -n "$7" && \
cannam@167 8794 func_fatal_help "too many parameters to '-version-info'"
cannam@167 8795
cannam@167 8796 # convert absolute version numbers to libtool ages
cannam@167 8797 # this retains compatibility with .la files and attempts
cannam@167 8798 # to make the code below a bit more comprehensible
cannam@167 8799
cannam@167 8800 case $vinfo_number in
cannam@167 8801 yes)
cannam@167 8802 number_major=$1
cannam@167 8803 number_minor=$2
cannam@167 8804 number_revision=$3
cannam@167 8805 #
cannam@167 8806 # There are really only two kinds -- those that
cannam@167 8807 # use the current revision as the major version
cannam@167 8808 # and those that subtract age and use age as
cannam@167 8809 # a minor version. But, then there is irix
cannam@167 8810 # that has an extra 1 added just for fun
cannam@167 8811 #
cannam@167 8812 case $version_type in
cannam@167 8813 # correct linux to gnu/linux during the next big refactor
cannam@167 8814 darwin|freebsd-elf|linux|osf|windows|none)
cannam@167 8815 func_arith $number_major + $number_minor
cannam@167 8816 current=$func_arith_result
cannam@167 8817 age=$number_minor
cannam@167 8818 revision=$number_revision
cannam@167 8819 ;;
cannam@167 8820 freebsd-aout|qnx|sunos)
cannam@167 8821 current=$number_major
cannam@167 8822 revision=$number_minor
cannam@167 8823 age=0
cannam@167 8824 ;;
cannam@167 8825 irix|nonstopux)
cannam@167 8826 func_arith $number_major + $number_minor
cannam@167 8827 current=$func_arith_result
cannam@167 8828 age=$number_minor
cannam@167 8829 revision=$number_minor
cannam@167 8830 lt_irix_increment=no
cannam@167 8831 ;;
cannam@167 8832 *)
cannam@167 8833 func_fatal_configuration "$modename: unknown library version type '$version_type'"
cannam@167 8834 ;;
cannam@167 8835 esac
cannam@167 8836 ;;
cannam@167 8837 no)
cannam@167 8838 current=$1
cannam@167 8839 revision=$2
cannam@167 8840 age=$3
cannam@167 8841 ;;
cannam@167 8842 esac
cannam@167 8843
cannam@167 8844 # Check that each of the things are valid numbers.
cannam@167 8845 case $current in
cannam@167 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@167 8847 *)
cannam@167 8848 func_error "CURRENT '$current' must be a nonnegative integer"
cannam@167 8849 func_fatal_error "'$vinfo' is not valid version information"
cannam@167 8850 ;;
cannam@167 8851 esac
cannam@167 8852
cannam@167 8853 case $revision in
cannam@167 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@167 8855 *)
cannam@167 8856 func_error "REVISION '$revision' must be a nonnegative integer"
cannam@167 8857 func_fatal_error "'$vinfo' is not valid version information"
cannam@167 8858 ;;
cannam@167 8859 esac
cannam@167 8860
cannam@167 8861 case $age in
cannam@167 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@167 8863 *)
cannam@167 8864 func_error "AGE '$age' must be a nonnegative integer"
cannam@167 8865 func_fatal_error "'$vinfo' is not valid version information"
cannam@167 8866 ;;
cannam@167 8867 esac
cannam@167 8868
cannam@167 8869 if test "$age" -gt "$current"; then
cannam@167 8870 func_error "AGE '$age' is greater than the current interface number '$current'"
cannam@167 8871 func_fatal_error "'$vinfo' is not valid version information"
cannam@167 8872 fi
cannam@167 8873
cannam@167 8874 # Calculate the version variables.
cannam@167 8875 major=
cannam@167 8876 versuffix=
cannam@167 8877 verstring=
cannam@167 8878 case $version_type in
cannam@167 8879 none) ;;
cannam@167 8880
cannam@167 8881 darwin)
cannam@167 8882 # Like Linux, but with the current version available in
cannam@167 8883 # verstring for coding it into the library header
cannam@167 8884 func_arith $current - $age
cannam@167 8885 major=.$func_arith_result
cannam@167 8886 versuffix=$major.$age.$revision
cannam@167 8887 # Darwin ld doesn't like 0 for these options...
cannam@167 8888 func_arith $current + 1
cannam@167 8889 minor_current=$func_arith_result
cannam@167 8890 xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
cannam@167 8891 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
cannam@167 8892 # On Darwin other compilers
cannam@167 8893 case $CC in
cannam@167 8894 nagfor*)
cannam@167 8895 verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
cannam@167 8896 ;;
cannam@167 8897 *)
cannam@167 8898 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
cannam@167 8899 ;;
cannam@167 8900 esac
cannam@167 8901 ;;
cannam@167 8902
cannam@167 8903 freebsd-aout)
cannam@167 8904 major=.$current
cannam@167 8905 versuffix=.$current.$revision
cannam@167 8906 ;;
cannam@167 8907
cannam@167 8908 freebsd-elf)
cannam@167 8909 func_arith $current - $age
cannam@167 8910 major=.$func_arith_result
cannam@167 8911 versuffix=$major.$age.$revision
cannam@167 8912 ;;
cannam@167 8913
cannam@167 8914 irix | nonstopux)
cannam@167 8915 if test no = "$lt_irix_increment"; then
cannam@167 8916 func_arith $current - $age
cannam@167 8917 else
cannam@167 8918 func_arith $current - $age + 1
cannam@167 8919 fi
cannam@167 8920 major=$func_arith_result
cannam@167 8921
cannam@167 8922 case $version_type in
cannam@167 8923 nonstopux) verstring_prefix=nonstopux ;;
cannam@167 8924 *) verstring_prefix=sgi ;;
cannam@167 8925 esac
cannam@167 8926 verstring=$verstring_prefix$major.$revision
cannam@167 8927
cannam@167 8928 # Add in all the interfaces that we are compatible with.
cannam@167 8929 loop=$revision
cannam@167 8930 while test 0 -ne "$loop"; do
cannam@167 8931 func_arith $revision - $loop
cannam@167 8932 iface=$func_arith_result
cannam@167 8933 func_arith $loop - 1
cannam@167 8934 loop=$func_arith_result
cannam@167 8935 verstring=$verstring_prefix$major.$iface:$verstring
cannam@167 8936 done
cannam@167 8937
cannam@167 8938 # Before this point, $major must not contain '.'.
cannam@167 8939 major=.$major
cannam@167 8940 versuffix=$major.$revision
cannam@167 8941 ;;
cannam@167 8942
cannam@167 8943 linux) # correct to gnu/linux during the next big refactor
cannam@167 8944 func_arith $current - $age
cannam@167 8945 major=.$func_arith_result
cannam@167 8946 versuffix=$major.$age.$revision
cannam@167 8947 ;;
cannam@167 8948
cannam@167 8949 osf)
cannam@167 8950 func_arith $current - $age
cannam@167 8951 major=.$func_arith_result
cannam@167 8952 versuffix=.$current.$age.$revision
cannam@167 8953 verstring=$current.$age.$revision
cannam@167 8954
cannam@167 8955 # Add in all the interfaces that we are compatible with.
cannam@167 8956 loop=$age
cannam@167 8957 while test 0 -ne "$loop"; do
cannam@167 8958 func_arith $current - $loop
cannam@167 8959 iface=$func_arith_result
cannam@167 8960 func_arith $loop - 1
cannam@167 8961 loop=$func_arith_result
cannam@167 8962 verstring=$verstring:$iface.0
cannam@167 8963 done
cannam@167 8964
cannam@167 8965 # Make executables depend on our current version.
cannam@167 8966 func_append verstring ":$current.0"
cannam@167 8967 ;;
cannam@167 8968
cannam@167 8969 qnx)
cannam@167 8970 major=.$current
cannam@167 8971 versuffix=.$current
cannam@167 8972 ;;
cannam@167 8973
cannam@167 8974 sco)
cannam@167 8975 major=.$current
cannam@167 8976 versuffix=.$current
cannam@167 8977 ;;
cannam@167 8978
cannam@167 8979 sunos)
cannam@167 8980 major=.$current
cannam@167 8981 versuffix=.$current.$revision
cannam@167 8982 ;;
cannam@167 8983
cannam@167 8984 windows)
cannam@167 8985 # Use '-' rather than '.', since we only want one
cannam@167 8986 # extension on DOS 8.3 file systems.
cannam@167 8987 func_arith $current - $age
cannam@167 8988 major=$func_arith_result
cannam@167 8989 versuffix=-$major
cannam@167 8990 ;;
cannam@167 8991
cannam@167 8992 *)
cannam@167 8993 func_fatal_configuration "unknown library version type '$version_type'"
cannam@167 8994 ;;
cannam@167 8995 esac
cannam@167 8996
cannam@167 8997 # Clear the version info if we defaulted, and they specified a release.
cannam@167 8998 if test -z "$vinfo" && test -n "$release"; then
cannam@167 8999 major=
cannam@167 9000 case $version_type in
cannam@167 9001 darwin)
cannam@167 9002 # we can't check for "0.0" in archive_cmds due to quoting
cannam@167 9003 # problems, so we reset it completely
cannam@167 9004 verstring=
cannam@167 9005 ;;
cannam@167 9006 *)
cannam@167 9007 verstring=0.0
cannam@167 9008 ;;
cannam@167 9009 esac
cannam@167 9010 if test no = "$need_version"; then
cannam@167 9011 versuffix=
cannam@167 9012 else
cannam@167 9013 versuffix=.0.0
cannam@167 9014 fi
cannam@167 9015 fi
cannam@167 9016
cannam@167 9017 # Remove version info from name if versioning should be avoided
cannam@167 9018 if test yes,no = "$avoid_version,$need_version"; then
cannam@167 9019 major=
cannam@167 9020 versuffix=
cannam@167 9021 verstring=
cannam@167 9022 fi
cannam@167 9023
cannam@167 9024 # Check to see if the archive will have undefined symbols.
cannam@167 9025 if test yes = "$allow_undefined"; then
cannam@167 9026 if test unsupported = "$allow_undefined_flag"; then
cannam@167 9027 if test yes = "$build_old_libs"; then
cannam@167 9028 func_warning "undefined symbols not allowed in $host shared libraries; building static only"
cannam@167 9029 build_libtool_libs=no
cannam@167 9030 else
cannam@167 9031 func_fatal_error "can't build $host shared library unless -no-undefined is specified"
cannam@167 9032 fi
cannam@167 9033 fi
cannam@167 9034 else
cannam@167 9035 # Don't allow undefined symbols.
cannam@167 9036 allow_undefined_flag=$no_undefined_flag
cannam@167 9037 fi
cannam@167 9038
cannam@167 9039 fi
cannam@167 9040
cannam@167 9041 func_generate_dlsyms "$libname" "$libname" :
cannam@167 9042 func_append libobjs " $symfileobj"
cannam@167 9043 test " " = "$libobjs" && libobjs=
cannam@167 9044
cannam@167 9045 if test relink != "$opt_mode"; then
cannam@167 9046 # Remove our outputs, but don't remove object files since they
cannam@167 9047 # may have been created when compiling PIC objects.
cannam@167 9048 removelist=
cannam@167 9049 tempremovelist=`$ECHO "$output_objdir/*"`
cannam@167 9050 for p in $tempremovelist; do
cannam@167 9051 case $p in
cannam@167 9052 *.$objext | *.gcno)
cannam@167 9053 ;;
cannam@167 9054 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
cannam@167 9055 if test -n "$precious_files_regex"; then
cannam@167 9056 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
cannam@167 9057 then
cannam@167 9058 continue
cannam@167 9059 fi
cannam@167 9060 fi
cannam@167 9061 func_append removelist " $p"
cannam@167 9062 ;;
cannam@167 9063 *) ;;
cannam@167 9064 esac
cannam@167 9065 done
cannam@167 9066 test -n "$removelist" && \
cannam@167 9067 func_show_eval "${RM}r \$removelist"
cannam@167 9068 fi
cannam@167 9069
cannam@167 9070 # Now set the variables for building old libraries.
cannam@167 9071 if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
cannam@167 9072 func_append oldlibs " $output_objdir/$libname.$libext"
cannam@167 9073
cannam@167 9074 # Transform .lo files to .o files.
cannam@167 9075 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
cannam@167 9076 fi
cannam@167 9077
cannam@167 9078 # Eliminate all temporary directories.
cannam@167 9079 #for path in $notinst_path; do
cannam@167 9080 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
cannam@167 9081 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
cannam@167 9082 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
cannam@167 9083 #done
cannam@167 9084
cannam@167 9085 if test -n "$xrpath"; then
cannam@167 9086 # If the user specified any rpath flags, then add them.
cannam@167 9087 temp_xrpath=
cannam@167 9088 for libdir in $xrpath; do
cannam@167 9089 func_replace_sysroot "$libdir"
cannam@167 9090 func_append temp_xrpath " -R$func_replace_sysroot_result"
cannam@167 9091 case "$finalize_rpath " in
cannam@167 9092 *" $libdir "*) ;;
cannam@167 9093 *) func_append finalize_rpath " $libdir" ;;
cannam@167 9094 esac
cannam@167 9095 done
cannam@167 9096 if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
cannam@167 9097 dependency_libs="$temp_xrpath $dependency_libs"
cannam@167 9098 fi
cannam@167 9099 fi
cannam@167 9100
cannam@167 9101 # Make sure dlfiles contains only unique files that won't be dlpreopened
cannam@167 9102 old_dlfiles=$dlfiles
cannam@167 9103 dlfiles=
cannam@167 9104 for lib in $old_dlfiles; do
cannam@167 9105 case " $dlprefiles $dlfiles " in
cannam@167 9106 *" $lib "*) ;;
cannam@167 9107 *) func_append dlfiles " $lib" ;;
cannam@167 9108 esac
cannam@167 9109 done
cannam@167 9110
cannam@167 9111 # Make sure dlprefiles contains only unique files
cannam@167 9112 old_dlprefiles=$dlprefiles
cannam@167 9113 dlprefiles=
cannam@167 9114 for lib in $old_dlprefiles; do
cannam@167 9115 case "$dlprefiles " in
cannam@167 9116 *" $lib "*) ;;
cannam@167 9117 *) func_append dlprefiles " $lib" ;;
cannam@167 9118 esac
cannam@167 9119 done
cannam@167 9120
cannam@167 9121 if test yes = "$build_libtool_libs"; then
cannam@167 9122 if test -n "$rpath"; then
cannam@167 9123 case $host in
cannam@167 9124 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
cannam@167 9125 # these systems don't actually have a c library (as such)!
cannam@167 9126 ;;
cannam@167 9127 *-*-rhapsody* | *-*-darwin1.[012])
cannam@167 9128 # Rhapsody C library is in the System framework
cannam@167 9129 func_append deplibs " System.ltframework"
cannam@167 9130 ;;
cannam@167 9131 *-*-netbsd*)
cannam@167 9132 # Don't link with libc until the a.out ld.so is fixed.
cannam@167 9133 ;;
cannam@167 9134 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
cannam@167 9135 # Do not include libc due to us having libc/libc_r.
cannam@167 9136 ;;
cannam@167 9137 *-*-sco3.2v5* | *-*-sco5v6*)
cannam@167 9138 # Causes problems with __ctype
cannam@167 9139 ;;
cannam@167 9140 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
cannam@167 9141 # Compiler inserts libc in the correct place for threads to work
cannam@167 9142 ;;
cannam@167 9143 *)
cannam@167 9144 # Add libc to deplibs on all other systems if necessary.
cannam@167 9145 if test yes = "$build_libtool_need_lc"; then
cannam@167 9146 func_append deplibs " -lc"
cannam@167 9147 fi
cannam@167 9148 ;;
cannam@167 9149 esac
cannam@167 9150 fi
cannam@167 9151
cannam@167 9152 # Transform deplibs into only deplibs that can be linked in shared.
cannam@167 9153 name_save=$name
cannam@167 9154 libname_save=$libname
cannam@167 9155 release_save=$release
cannam@167 9156 versuffix_save=$versuffix
cannam@167 9157 major_save=$major
cannam@167 9158 # I'm not sure if I'm treating the release correctly. I think
cannam@167 9159 # release should show up in the -l (ie -lgmp5) so we don't want to
cannam@167 9160 # add it in twice. Is that correct?
cannam@167 9161 release=
cannam@167 9162 versuffix=
cannam@167 9163 major=
cannam@167 9164 newdeplibs=
cannam@167 9165 droppeddeps=no
cannam@167 9166 case $deplibs_check_method in
cannam@167 9167 pass_all)
cannam@167 9168 # Don't check for shared/static. Everything works.
cannam@167 9169 # This might be a little naive. We might want to check
cannam@167 9170 # whether the library exists or not. But this is on
cannam@167 9171 # osf3 & osf4 and I'm not really sure... Just
cannam@167 9172 # implementing what was already the behavior.
cannam@167 9173 newdeplibs=$deplibs
cannam@167 9174 ;;
cannam@167 9175 test_compile)
cannam@167 9176 # This code stresses the "libraries are programs" paradigm to its
cannam@167 9177 # limits. Maybe even breaks it. We compile a program, linking it
cannam@167 9178 # against the deplibs as a proxy for the library. Then we can check
cannam@167 9179 # whether they linked in statically or dynamically with ldd.
cannam@167 9180 $opt_dry_run || $RM conftest.c
cannam@167 9181 cat > conftest.c <<EOF
cannam@167 9182 int main() { return 0; }
cannam@167 9183 EOF
cannam@167 9184 $opt_dry_run || $RM conftest
cannam@167 9185 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
cannam@167 9186 ldd_output=`ldd conftest`
cannam@167 9187 for i in $deplibs; do
cannam@167 9188 case $i in
cannam@167 9189 -l*)
cannam@167 9190 func_stripname -l '' "$i"
cannam@167 9191 name=$func_stripname_result
cannam@167 9192 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@167 9193 case " $predeps $postdeps " in
cannam@167 9194 *" $i "*)
cannam@167 9195 func_append newdeplibs " $i"
cannam@167 9196 i=
cannam@167 9197 ;;
cannam@167 9198 esac
cannam@167 9199 fi
cannam@167 9200 if test -n "$i"; then
cannam@167 9201 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@167 9202 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
cannam@167 9203 set dummy $deplib_matches; shift
cannam@167 9204 deplib_match=$1
cannam@167 9205 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
cannam@167 9206 func_append newdeplibs " $i"
cannam@167 9207 else
cannam@167 9208 droppeddeps=yes
cannam@167 9209 echo
cannam@167 9210 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
cannam@167 9211 echo "*** I have the capability to make that library automatically link in when"
cannam@167 9212 echo "*** you link to this library. But I can only do this if you have a"
cannam@167 9213 echo "*** shared version of the library, which I believe you do not have"
cannam@167 9214 echo "*** because a test_compile did reveal that the linker did not use it for"
cannam@167 9215 echo "*** its dynamic dependency list that programs get resolved with at runtime."
cannam@167 9216 fi
cannam@167 9217 fi
cannam@167 9218 ;;
cannam@167 9219 *)
cannam@167 9220 func_append newdeplibs " $i"
cannam@167 9221 ;;
cannam@167 9222 esac
cannam@167 9223 done
cannam@167 9224 else
cannam@167 9225 # Error occurred in the first compile. Let's try to salvage
cannam@167 9226 # the situation: Compile a separate program for each library.
cannam@167 9227 for i in $deplibs; do
cannam@167 9228 case $i in
cannam@167 9229 -l*)
cannam@167 9230 func_stripname -l '' "$i"
cannam@167 9231 name=$func_stripname_result
cannam@167 9232 $opt_dry_run || $RM conftest
cannam@167 9233 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
cannam@167 9234 ldd_output=`ldd conftest`
cannam@167 9235 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@167 9236 case " $predeps $postdeps " in
cannam@167 9237 *" $i "*)
cannam@167 9238 func_append newdeplibs " $i"
cannam@167 9239 i=
cannam@167 9240 ;;
cannam@167 9241 esac
cannam@167 9242 fi
cannam@167 9243 if test -n "$i"; then
cannam@167 9244 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@167 9245 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
cannam@167 9246 set dummy $deplib_matches; shift
cannam@167 9247 deplib_match=$1
cannam@167 9248 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then
cannam@167 9249 func_append newdeplibs " $i"
cannam@167 9250 else
cannam@167 9251 droppeddeps=yes
cannam@167 9252 echo
cannam@167 9253 $ECHO "*** Warning: dynamic linker does not accept needed library $i."
cannam@167 9254 echo "*** I have the capability to make that library automatically link in when"
cannam@167 9255 echo "*** you link to this library. But I can only do this if you have a"
cannam@167 9256 echo "*** shared version of the library, which you do not appear to have"
cannam@167 9257 echo "*** because a test_compile did reveal that the linker did not use this one"
cannam@167 9258 echo "*** as a dynamic dependency that programs can get resolved with at runtime."
cannam@167 9259 fi
cannam@167 9260 fi
cannam@167 9261 else
cannam@167 9262 droppeddeps=yes
cannam@167 9263 echo
cannam@167 9264 $ECHO "*** Warning! Library $i is needed by this library but I was not able to"
cannam@167 9265 echo "*** make it link in! You will probably need to install it or some"
cannam@167 9266 echo "*** library that it depends on before this library will be fully"
cannam@167 9267 echo "*** functional. Installing it before continuing would be even better."
cannam@167 9268 fi
cannam@167 9269 ;;
cannam@167 9270 *)
cannam@167 9271 func_append newdeplibs " $i"
cannam@167 9272 ;;
cannam@167 9273 esac
cannam@167 9274 done
cannam@167 9275 fi
cannam@167 9276 ;;
cannam@167 9277 file_magic*)
cannam@167 9278 set dummy $deplibs_check_method; shift
cannam@167 9279 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
cannam@167 9280 for a_deplib in $deplibs; do
cannam@167 9281 case $a_deplib in
cannam@167 9282 -l*)
cannam@167 9283 func_stripname -l '' "$a_deplib"
cannam@167 9284 name=$func_stripname_result
cannam@167 9285 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@167 9286 case " $predeps $postdeps " in
cannam@167 9287 *" $a_deplib "*)
cannam@167 9288 func_append newdeplibs " $a_deplib"
cannam@167 9289 a_deplib=
cannam@167 9290 ;;
cannam@167 9291 esac
cannam@167 9292 fi
cannam@167 9293 if test -n "$a_deplib"; then
cannam@167 9294 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@167 9295 if test -n "$file_magic_glob"; then
cannam@167 9296 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
cannam@167 9297 else
cannam@167 9298 libnameglob=$libname
cannam@167 9299 fi
cannam@167 9300 test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
cannam@167 9301 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
cannam@167 9302 if test yes = "$want_nocaseglob"; then
cannam@167 9303 shopt -s nocaseglob
cannam@167 9304 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
cannam@167 9305 $nocaseglob
cannam@167 9306 else
cannam@167 9307 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
cannam@167 9308 fi
cannam@167 9309 for potent_lib in $potential_libs; do
cannam@167 9310 # Follow soft links.
cannam@167 9311 if ls -lLd "$potent_lib" 2>/dev/null |
cannam@167 9312 $GREP " -> " >/dev/null; then
cannam@167 9313 continue
cannam@167 9314 fi
cannam@167 9315 # The statement above tries to avoid entering an
cannam@167 9316 # endless loop below, in case of cyclic links.
cannam@167 9317 # We might still enter an endless loop, since a link
cannam@167 9318 # loop can be closed while we follow links,
cannam@167 9319 # but so what?
cannam@167 9320 potlib=$potent_lib
cannam@167 9321 while test -h "$potlib" 2>/dev/null; do
cannam@167 9322 potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
cannam@167 9323 case $potliblink in
cannam@167 9324 [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
cannam@167 9325 *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
cannam@167 9326 esac
cannam@167 9327 done
cannam@167 9328 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
cannam@167 9329 $SED -e 10q |
cannam@167 9330 $EGREP "$file_magic_regex" > /dev/null; then
cannam@167 9331 func_append newdeplibs " $a_deplib"
cannam@167 9332 a_deplib=
cannam@167 9333 break 2
cannam@167 9334 fi
cannam@167 9335 done
cannam@167 9336 done
cannam@167 9337 fi
cannam@167 9338 if test -n "$a_deplib"; then
cannam@167 9339 droppeddeps=yes
cannam@167 9340 echo
cannam@167 9341 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
cannam@167 9342 echo "*** I have the capability to make that library automatically link in when"
cannam@167 9343 echo "*** you link to this library. But I can only do this if you have a"
cannam@167 9344 echo "*** shared version of the library, which you do not appear to have"
cannam@167 9345 echo "*** because I did check the linker path looking for a file starting"
cannam@167 9346 if test -z "$potlib"; then
cannam@167 9347 $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
cannam@167 9348 else
cannam@167 9349 $ECHO "*** with $libname and none of the candidates passed a file format test"
cannam@167 9350 $ECHO "*** using a file magic. Last file checked: $potlib"
cannam@167 9351 fi
cannam@167 9352 fi
cannam@167 9353 ;;
cannam@167 9354 *)
cannam@167 9355 # Add a -L argument.
cannam@167 9356 func_append newdeplibs " $a_deplib"
cannam@167 9357 ;;
cannam@167 9358 esac
cannam@167 9359 done # Gone through all deplibs.
cannam@167 9360 ;;
cannam@167 9361 match_pattern*)
cannam@167 9362 set dummy $deplibs_check_method; shift
cannam@167 9363 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
cannam@167 9364 for a_deplib in $deplibs; do
cannam@167 9365 case $a_deplib in
cannam@167 9366 -l*)
cannam@167 9367 func_stripname -l '' "$a_deplib"
cannam@167 9368 name=$func_stripname_result
cannam@167 9369 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@167 9370 case " $predeps $postdeps " in
cannam@167 9371 *" $a_deplib "*)
cannam@167 9372 func_append newdeplibs " $a_deplib"
cannam@167 9373 a_deplib=
cannam@167 9374 ;;
cannam@167 9375 esac
cannam@167 9376 fi
cannam@167 9377 if test -n "$a_deplib"; then
cannam@167 9378 libname=`eval "\\$ECHO \"$libname_spec\""`
cannam@167 9379 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
cannam@167 9380 potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
cannam@167 9381 for potent_lib in $potential_libs; do
cannam@167 9382 potlib=$potent_lib # see symlink-check above in file_magic test
cannam@167 9383 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
cannam@167 9384 $EGREP "$match_pattern_regex" > /dev/null; then
cannam@167 9385 func_append newdeplibs " $a_deplib"
cannam@167 9386 a_deplib=
cannam@167 9387 break 2
cannam@167 9388 fi
cannam@167 9389 done
cannam@167 9390 done
cannam@167 9391 fi
cannam@167 9392 if test -n "$a_deplib"; then
cannam@167 9393 droppeddeps=yes
cannam@167 9394 echo
cannam@167 9395 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
cannam@167 9396 echo "*** I have the capability to make that library automatically link in when"
cannam@167 9397 echo "*** you link to this library. But I can only do this if you have a"
cannam@167 9398 echo "*** shared version of the library, which you do not appear to have"
cannam@167 9399 echo "*** because I did check the linker path looking for a file starting"
cannam@167 9400 if test -z "$potlib"; then
cannam@167 9401 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
cannam@167 9402 else
cannam@167 9403 $ECHO "*** with $libname and none of the candidates passed a file format test"
cannam@167 9404 $ECHO "*** using a regex pattern. Last file checked: $potlib"
cannam@167 9405 fi
cannam@167 9406 fi
cannam@167 9407 ;;
cannam@167 9408 *)
cannam@167 9409 # Add a -L argument.
cannam@167 9410 func_append newdeplibs " $a_deplib"
cannam@167 9411 ;;
cannam@167 9412 esac
cannam@167 9413 done # Gone through all deplibs.
cannam@167 9414 ;;
cannam@167 9415 none | unknown | *)
cannam@167 9416 newdeplibs=
cannam@167 9417 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
cannam@167 9418 if test yes = "$allow_libtool_libs_with_static_runtimes"; then
cannam@167 9419 for i in $predeps $postdeps; do
cannam@167 9420 # can't use Xsed below, because $i might contain '/'
cannam@167 9421 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
cannam@167 9422 done
cannam@167 9423 fi
cannam@167 9424 case $tmp_deplibs in
cannam@167 9425 *[!\ \ ]*)
cannam@167 9426 echo
cannam@167 9427 if test none = "$deplibs_check_method"; then
cannam@167 9428 echo "*** Warning: inter-library dependencies are not supported in this platform."
cannam@167 9429 else
cannam@167 9430 echo "*** Warning: inter-library dependencies are not known to be supported."
cannam@167 9431 fi
cannam@167 9432 echo "*** All declared inter-library dependencies are being dropped."
cannam@167 9433 droppeddeps=yes
cannam@167 9434 ;;
cannam@167 9435 esac
cannam@167 9436 ;;
cannam@167 9437 esac
cannam@167 9438 versuffix=$versuffix_save
cannam@167 9439 major=$major_save
cannam@167 9440 release=$release_save
cannam@167 9441 libname=$libname_save
cannam@167 9442 name=$name_save
cannam@167 9443
cannam@167 9444 case $host in
cannam@167 9445 *-*-rhapsody* | *-*-darwin1.[012])
cannam@167 9446 # On Rhapsody replace the C library with the System framework
cannam@167 9447 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
cannam@167 9448 ;;
cannam@167 9449 esac
cannam@167 9450
cannam@167 9451 if test yes = "$droppeddeps"; then
cannam@167 9452 if test yes = "$module"; then
cannam@167 9453 echo
cannam@167 9454 echo "*** Warning: libtool could not satisfy all declared inter-library"
cannam@167 9455 $ECHO "*** dependencies of module $libname. Therefore, libtool will create"
cannam@167 9456 echo "*** a static module, that should work as long as the dlopening"
cannam@167 9457 echo "*** application is linked with the -dlopen flag."
cannam@167 9458 if test -z "$global_symbol_pipe"; then
cannam@167 9459 echo
cannam@167 9460 echo "*** However, this would only work if libtool was able to extract symbol"
cannam@167 9461 echo "*** lists from a program, using 'nm' or equivalent, but libtool could"
cannam@167 9462 echo "*** not find such a program. So, this module is probably useless."
cannam@167 9463 echo "*** 'nm' from GNU binutils and a full rebuild may help."
cannam@167 9464 fi
cannam@167 9465 if test no = "$build_old_libs"; then
cannam@167 9466 oldlibs=$output_objdir/$libname.$libext
cannam@167 9467 build_libtool_libs=module
cannam@167 9468 build_old_libs=yes
cannam@167 9469 else
cannam@167 9470 build_libtool_libs=no
cannam@167 9471 fi
cannam@167 9472 else
cannam@167 9473 echo "*** The inter-library dependencies that have been dropped here will be"
cannam@167 9474 echo "*** automatically added whenever a program is linked with this library"
cannam@167 9475 echo "*** or is declared to -dlopen it."
cannam@167 9476
cannam@167 9477 if test no = "$allow_undefined"; then
cannam@167 9478 echo
cannam@167 9479 echo "*** Since this library must not contain undefined symbols,"
cannam@167 9480 echo "*** because either the platform does not support them or"
cannam@167 9481 echo "*** it was explicitly requested with -no-undefined,"
cannam@167 9482 echo "*** libtool will only create a static version of it."
cannam@167 9483 if test no = "$build_old_libs"; then
cannam@167 9484 oldlibs=$output_objdir/$libname.$libext
cannam@167 9485 build_libtool_libs=module
cannam@167 9486 build_old_libs=yes
cannam@167 9487 else
cannam@167 9488 build_libtool_libs=no
cannam@167 9489 fi
cannam@167 9490 fi
cannam@167 9491 fi
cannam@167 9492 fi
cannam@167 9493 # Done checking deplibs!
cannam@167 9494 deplibs=$newdeplibs
cannam@167 9495 fi
cannam@167 9496 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
cannam@167 9497 case $host in
cannam@167 9498 *-*-darwin*)
cannam@167 9499 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@167 9500 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@167 9501 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@167 9502 ;;
cannam@167 9503 esac
cannam@167 9504
cannam@167 9505 # move library search paths that coincide with paths to not yet
cannam@167 9506 # installed libraries to the beginning of the library search list
cannam@167 9507 new_libs=
cannam@167 9508 for path in $notinst_path; do
cannam@167 9509 case " $new_libs " in
cannam@167 9510 *" -L$path/$objdir "*) ;;
cannam@167 9511 *)
cannam@167 9512 case " $deplibs " in
cannam@167 9513 *" -L$path/$objdir "*)
cannam@167 9514 func_append new_libs " -L$path/$objdir" ;;
cannam@167 9515 esac
cannam@167 9516 ;;
cannam@167 9517 esac
cannam@167 9518 done
cannam@167 9519 for deplib in $deplibs; do
cannam@167 9520 case $deplib in
cannam@167 9521 -L*)
cannam@167 9522 case " $new_libs " in
cannam@167 9523 *" $deplib "*) ;;
cannam@167 9524 *) func_append new_libs " $deplib" ;;
cannam@167 9525 esac
cannam@167 9526 ;;
cannam@167 9527 *) func_append new_libs " $deplib" ;;
cannam@167 9528 esac
cannam@167 9529 done
cannam@167 9530 deplibs=$new_libs
cannam@167 9531
cannam@167 9532 # All the library-specific variables (install_libdir is set above).
cannam@167 9533 library_names=
cannam@167 9534 old_library=
cannam@167 9535 dlname=
cannam@167 9536
cannam@167 9537 # Test again, we may have decided not to build it any more
cannam@167 9538 if test yes = "$build_libtool_libs"; then
cannam@167 9539 # Remove $wl instances when linking with ld.
cannam@167 9540 # FIXME: should test the right _cmds variable.
cannam@167 9541 case $archive_cmds in
cannam@167 9542 *\$LD\ *) wl= ;;
cannam@167 9543 esac
cannam@167 9544 if test yes = "$hardcode_into_libs"; then
cannam@167 9545 # Hardcode the library paths
cannam@167 9546 hardcode_libdirs=
cannam@167 9547 dep_rpath=
cannam@167 9548 rpath=$finalize_rpath
cannam@167 9549 test relink = "$opt_mode" || rpath=$compile_rpath$rpath
cannam@167 9550 for libdir in $rpath; do
cannam@167 9551 if test -n "$hardcode_libdir_flag_spec"; then
cannam@167 9552 if test -n "$hardcode_libdir_separator"; then
cannam@167 9553 func_replace_sysroot "$libdir"
cannam@167 9554 libdir=$func_replace_sysroot_result
cannam@167 9555 if test -z "$hardcode_libdirs"; then
cannam@167 9556 hardcode_libdirs=$libdir
cannam@167 9557 else
cannam@167 9558 # Just accumulate the unique libdirs.
cannam@167 9559 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
cannam@167 9560 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
cannam@167 9561 ;;
cannam@167 9562 *)
cannam@167 9563 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
cannam@167 9564 ;;
cannam@167 9565 esac
cannam@167 9566 fi
cannam@167 9567 else
cannam@167 9568 eval flag=\"$hardcode_libdir_flag_spec\"
cannam@167 9569 func_append dep_rpath " $flag"
cannam@167 9570 fi
cannam@167 9571 elif test -n "$runpath_var"; then
cannam@167 9572 case "$perm_rpath " in
cannam@167 9573 *" $libdir "*) ;;
cannam@167 9574 *) func_append perm_rpath " $libdir" ;;
cannam@167 9575 esac
cannam@167 9576 fi
cannam@167 9577 done
cannam@167 9578 # Substitute the hardcoded libdirs into the rpath.
cannam@167 9579 if test -n "$hardcode_libdir_separator" &&
cannam@167 9580 test -n "$hardcode_libdirs"; then
cannam@167 9581 libdir=$hardcode_libdirs
cannam@167 9582 eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
cannam@167 9583 fi
cannam@167 9584 if test -n "$runpath_var" && test -n "$perm_rpath"; then
cannam@167 9585 # We should set the runpath_var.
cannam@167 9586 rpath=
cannam@167 9587 for dir in $perm_rpath; do
cannam@167 9588 func_append rpath "$dir:"
cannam@167 9589 done
cannam@167 9590 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
cannam@167 9591 fi
cannam@167 9592 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
cannam@167 9593 fi
cannam@167 9594
cannam@167 9595 shlibpath=$finalize_shlibpath
cannam@167 9596 test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
cannam@167 9597 if test -n "$shlibpath"; then
cannam@167 9598 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
cannam@167 9599 fi
cannam@167 9600
cannam@167 9601 # Get the real and link names of the library.
cannam@167 9602 eval shared_ext=\"$shrext_cmds\"
cannam@167 9603 eval library_names=\"$library_names_spec\"
cannam@167 9604 set dummy $library_names
cannam@167 9605 shift
cannam@167 9606 realname=$1
cannam@167 9607 shift
cannam@167 9608
cannam@167 9609 if test -n "$soname_spec"; then
cannam@167 9610 eval soname=\"$soname_spec\"
cannam@167 9611 else
cannam@167 9612 soname=$realname
cannam@167 9613 fi
cannam@167 9614 if test -z "$dlname"; then
cannam@167 9615 dlname=$soname
cannam@167 9616 fi
cannam@167 9617
cannam@167 9618 lib=$output_objdir/$realname
cannam@167 9619 linknames=
cannam@167 9620 for link
cannam@167 9621 do
cannam@167 9622 func_append linknames " $link"
cannam@167 9623 done
cannam@167 9624
cannam@167 9625 # Use standard objects if they are pic
cannam@167 9626 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
cannam@167 9627 test "X$libobjs" = "X " && libobjs=
cannam@167 9628
cannam@167 9629 delfiles=
cannam@167 9630 if test -n "$export_symbols" && test -n "$include_expsyms"; then
cannam@167 9631 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
cannam@167 9632 export_symbols=$output_objdir/$libname.uexp
cannam@167 9633 func_append delfiles " $export_symbols"
cannam@167 9634 fi
cannam@167 9635
cannam@167 9636 orig_export_symbols=
cannam@167 9637 case $host_os in
cannam@167 9638 cygwin* | mingw* | cegcc*)
cannam@167 9639 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
cannam@167 9640 # exporting using user supplied symfile
cannam@167 9641 func_dll_def_p "$export_symbols" || {
cannam@167 9642 # and it's NOT already a .def file. Must figure out
cannam@167 9643 # which of the given symbols are data symbols and tag
cannam@167 9644 # them as such. So, trigger use of export_symbols_cmds.
cannam@167 9645 # export_symbols gets reassigned inside the "prepare
cannam@167 9646 # the list of exported symbols" if statement, so the
cannam@167 9647 # include_expsyms logic still works.
cannam@167 9648 orig_export_symbols=$export_symbols
cannam@167 9649 export_symbols=
cannam@167 9650 always_export_symbols=yes
cannam@167 9651 }
cannam@167 9652 fi
cannam@167 9653 ;;
cannam@167 9654 esac
cannam@167 9655
cannam@167 9656 # Prepare the list of exported symbols
cannam@167 9657 if test -z "$export_symbols"; then
cannam@167 9658 if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
cannam@167 9659 func_verbose "generating symbol list for '$libname.la'"
cannam@167 9660 export_symbols=$output_objdir/$libname.exp
cannam@167 9661 $opt_dry_run || $RM $export_symbols
cannam@167 9662 cmds=$export_symbols_cmds
cannam@167 9663 save_ifs=$IFS; IFS='~'
cannam@167 9664 for cmd1 in $cmds; do
cannam@167 9665 IFS=$save_ifs
cannam@167 9666 # Take the normal branch if the nm_file_list_spec branch
cannam@167 9667 # doesn't work or if tool conversion is not needed.
cannam@167 9668 case $nm_file_list_spec~$to_tool_file_cmd in
cannam@167 9669 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
cannam@167 9670 try_normal_branch=yes
cannam@167 9671 eval cmd=\"$cmd1\"
cannam@167 9672 func_len " $cmd"
cannam@167 9673 len=$func_len_result
cannam@167 9674 ;;
cannam@167 9675 *)
cannam@167 9676 try_normal_branch=no
cannam@167 9677 ;;
cannam@167 9678 esac
cannam@167 9679 if test yes = "$try_normal_branch" \
cannam@167 9680 && { test "$len" -lt "$max_cmd_len" \
cannam@167 9681 || test "$max_cmd_len" -le -1; }
cannam@167 9682 then
cannam@167 9683 func_show_eval "$cmd" 'exit $?'
cannam@167 9684 skipped_export=false
cannam@167 9685 elif test -n "$nm_file_list_spec"; then
cannam@167 9686 func_basename "$output"
cannam@167 9687 output_la=$func_basename_result
cannam@167 9688 save_libobjs=$libobjs
cannam@167 9689 save_output=$output
cannam@167 9690 output=$output_objdir/$output_la.nm
cannam@167 9691 func_to_tool_file "$output"
cannam@167 9692 libobjs=$nm_file_list_spec$func_to_tool_file_result
cannam@167 9693 func_append delfiles " $output"
cannam@167 9694 func_verbose "creating $NM input file list: $output"
cannam@167 9695 for obj in $save_libobjs; do
cannam@167 9696 func_to_tool_file "$obj"
cannam@167 9697 $ECHO "$func_to_tool_file_result"
cannam@167 9698 done > "$output"
cannam@167 9699 eval cmd=\"$cmd1\"
cannam@167 9700 func_show_eval "$cmd" 'exit $?'
cannam@167 9701 output=$save_output
cannam@167 9702 libobjs=$save_libobjs
cannam@167 9703 skipped_export=false
cannam@167 9704 else
cannam@167 9705 # The command line is too long to execute in one step.
cannam@167 9706 func_verbose "using reloadable object file for export list..."
cannam@167 9707 skipped_export=:
cannam@167 9708 # Break out early, otherwise skipped_export may be
cannam@167 9709 # set to false by a later but shorter cmd.
cannam@167 9710 break
cannam@167 9711 fi
cannam@167 9712 done
cannam@167 9713 IFS=$save_ifs
cannam@167 9714 if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
cannam@167 9715 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
cannam@167 9716 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
cannam@167 9717 fi
cannam@167 9718 fi
cannam@167 9719 fi
cannam@167 9720
cannam@167 9721 if test -n "$export_symbols" && test -n "$include_expsyms"; then
cannam@167 9722 tmp_export_symbols=$export_symbols
cannam@167 9723 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
cannam@167 9724 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
cannam@167 9725 fi
cannam@167 9726
cannam@167 9727 if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
cannam@167 9728 # The given exports_symbols file has to be filtered, so filter it.
cannam@167 9729 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
cannam@167 9730 # FIXME: $output_objdir/$libname.filter potentially contains lots of
cannam@167 9731 # 's' commands, which not all seds can handle. GNU sed should be fine
cannam@167 9732 # though. Also, the filter scales superlinearly with the number of
cannam@167 9733 # global variables. join(1) would be nice here, but unfortunately
cannam@167 9734 # isn't a blessed tool.
cannam@167 9735 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
cannam@167 9736 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
cannam@167 9737 export_symbols=$output_objdir/$libname.def
cannam@167 9738 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
cannam@167 9739 fi
cannam@167 9740
cannam@167 9741 tmp_deplibs=
cannam@167 9742 for test_deplib in $deplibs; do
cannam@167 9743 case " $convenience " in
cannam@167 9744 *" $test_deplib "*) ;;
cannam@167 9745 *)
cannam@167 9746 func_append tmp_deplibs " $test_deplib"
cannam@167 9747 ;;
cannam@167 9748 esac
cannam@167 9749 done
cannam@167 9750 deplibs=$tmp_deplibs
cannam@167 9751
cannam@167 9752 if test -n "$convenience"; then
cannam@167 9753 if test -n "$whole_archive_flag_spec" &&
cannam@167 9754 test yes = "$compiler_needs_object" &&
cannam@167 9755 test -z "$libobjs"; then
cannam@167 9756 # extract the archives, so we have objects to list.
cannam@167 9757 # TODO: could optimize this to just extract one archive.
cannam@167 9758 whole_archive_flag_spec=
cannam@167 9759 fi
cannam@167 9760 if test -n "$whole_archive_flag_spec"; then
cannam@167 9761 save_libobjs=$libobjs
cannam@167 9762 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
cannam@167 9763 test "X$libobjs" = "X " && libobjs=
cannam@167 9764 else
cannam@167 9765 gentop=$output_objdir/${outputname}x
cannam@167 9766 func_append generated " $gentop"
cannam@167 9767
cannam@167 9768 func_extract_archives $gentop $convenience
cannam@167 9769 func_append libobjs " $func_extract_archives_result"
cannam@167 9770 test "X$libobjs" = "X " && libobjs=
cannam@167 9771 fi
cannam@167 9772 fi
cannam@167 9773
cannam@167 9774 if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
cannam@167 9775 eval flag=\"$thread_safe_flag_spec\"
cannam@167 9776 func_append linker_flags " $flag"
cannam@167 9777 fi
cannam@167 9778
cannam@167 9779 # Make a backup of the uninstalled library when relinking
cannam@167 9780 if test relink = "$opt_mode"; then
cannam@167 9781 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
cannam@167 9782 fi
cannam@167 9783
cannam@167 9784 # Do each of the archive commands.
cannam@167 9785 if test yes = "$module" && test -n "$module_cmds"; then
cannam@167 9786 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
cannam@167 9787 eval test_cmds=\"$module_expsym_cmds\"
cannam@167 9788 cmds=$module_expsym_cmds
cannam@167 9789 else
cannam@167 9790 eval test_cmds=\"$module_cmds\"
cannam@167 9791 cmds=$module_cmds
cannam@167 9792 fi
cannam@167 9793 else
cannam@167 9794 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
cannam@167 9795 eval test_cmds=\"$archive_expsym_cmds\"
cannam@167 9796 cmds=$archive_expsym_cmds
cannam@167 9797 else
cannam@167 9798 eval test_cmds=\"$archive_cmds\"
cannam@167 9799 cmds=$archive_cmds
cannam@167 9800 fi
cannam@167 9801 fi
cannam@167 9802
cannam@167 9803 if test : != "$skipped_export" &&
cannam@167 9804 func_len " $test_cmds" &&
cannam@167 9805 len=$func_len_result &&
cannam@167 9806 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
cannam@167 9807 :
cannam@167 9808 else
cannam@167 9809 # The command line is too long to link in one step, link piecewise
cannam@167 9810 # or, if using GNU ld and skipped_export is not :, use a linker
cannam@167 9811 # script.
cannam@167 9812
cannam@167 9813 # Save the value of $output and $libobjs because we want to
cannam@167 9814 # use them later. If we have whole_archive_flag_spec, we
cannam@167 9815 # want to use save_libobjs as it was before
cannam@167 9816 # whole_archive_flag_spec was expanded, because we can't
cannam@167 9817 # assume the linker understands whole_archive_flag_spec.
cannam@167 9818 # This may have to be revisited, in case too many
cannam@167 9819 # convenience libraries get linked in and end up exceeding
cannam@167 9820 # the spec.
cannam@167 9821 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
cannam@167 9822 save_libobjs=$libobjs
cannam@167 9823 fi
cannam@167 9824 save_output=$output
cannam@167 9825 func_basename "$output"
cannam@167 9826 output_la=$func_basename_result
cannam@167 9827
cannam@167 9828 # Clear the reloadable object creation command queue and
cannam@167 9829 # initialize k to one.
cannam@167 9830 test_cmds=
cannam@167 9831 concat_cmds=
cannam@167 9832 objlist=
cannam@167 9833 last_robj=
cannam@167 9834 k=1
cannam@167 9835
cannam@167 9836 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
cannam@167 9837 output=$output_objdir/$output_la.lnkscript
cannam@167 9838 func_verbose "creating GNU ld script: $output"
cannam@167 9839 echo 'INPUT (' > $output
cannam@167 9840 for obj in $save_libobjs
cannam@167 9841 do
cannam@167 9842 func_to_tool_file "$obj"
cannam@167 9843 $ECHO "$func_to_tool_file_result" >> $output
cannam@167 9844 done
cannam@167 9845 echo ')' >> $output
cannam@167 9846 func_append delfiles " $output"
cannam@167 9847 func_to_tool_file "$output"
cannam@167 9848 output=$func_to_tool_file_result
cannam@167 9849 elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
cannam@167 9850 output=$output_objdir/$output_la.lnk
cannam@167 9851 func_verbose "creating linker input file list: $output"
cannam@167 9852 : > $output
cannam@167 9853 set x $save_libobjs
cannam@167 9854 shift
cannam@167 9855 firstobj=
cannam@167 9856 if test yes = "$compiler_needs_object"; then
cannam@167 9857 firstobj="$1 "
cannam@167 9858 shift
cannam@167 9859 fi
cannam@167 9860 for obj
cannam@167 9861 do
cannam@167 9862 func_to_tool_file "$obj"
cannam@167 9863 $ECHO "$func_to_tool_file_result" >> $output
cannam@167 9864 done
cannam@167 9865 func_append delfiles " $output"
cannam@167 9866 func_to_tool_file "$output"
cannam@167 9867 output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
cannam@167 9868 else
cannam@167 9869 if test -n "$save_libobjs"; then
cannam@167 9870 func_verbose "creating reloadable object files..."
cannam@167 9871 output=$output_objdir/$output_la-$k.$objext
cannam@167 9872 eval test_cmds=\"$reload_cmds\"
cannam@167 9873 func_len " $test_cmds"
cannam@167 9874 len0=$func_len_result
cannam@167 9875 len=$len0
cannam@167 9876
cannam@167 9877 # Loop over the list of objects to be linked.
cannam@167 9878 for obj in $save_libobjs
cannam@167 9879 do
cannam@167 9880 func_len " $obj"
cannam@167 9881 func_arith $len + $func_len_result
cannam@167 9882 len=$func_arith_result
cannam@167 9883 if test -z "$objlist" ||
cannam@167 9884 test "$len" -lt "$max_cmd_len"; then
cannam@167 9885 func_append objlist " $obj"
cannam@167 9886 else
cannam@167 9887 # The command $test_cmds is almost too long, add a
cannam@167 9888 # command to the queue.
cannam@167 9889 if test 1 -eq "$k"; then
cannam@167 9890 # The first file doesn't have a previous command to add.
cannam@167 9891 reload_objs=$objlist
cannam@167 9892 eval concat_cmds=\"$reload_cmds\"
cannam@167 9893 else
cannam@167 9894 # All subsequent reloadable object files will link in
cannam@167 9895 # the last one created.
cannam@167 9896 reload_objs="$objlist $last_robj"
cannam@167 9897 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
cannam@167 9898 fi
cannam@167 9899 last_robj=$output_objdir/$output_la-$k.$objext
cannam@167 9900 func_arith $k + 1
cannam@167 9901 k=$func_arith_result
cannam@167 9902 output=$output_objdir/$output_la-$k.$objext
cannam@167 9903 objlist=" $obj"
cannam@167 9904 func_len " $last_robj"
cannam@167 9905 func_arith $len0 + $func_len_result
cannam@167 9906 len=$func_arith_result
cannam@167 9907 fi
cannam@167 9908 done
cannam@167 9909 # Handle the remaining objects by creating one last
cannam@167 9910 # reloadable object file. All subsequent reloadable object
cannam@167 9911 # files will link in the last one created.
cannam@167 9912 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
cannam@167 9913 reload_objs="$objlist $last_robj"
cannam@167 9914 eval concat_cmds=\"\$concat_cmds$reload_cmds\"
cannam@167 9915 if test -n "$last_robj"; then
cannam@167 9916 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
cannam@167 9917 fi
cannam@167 9918 func_append delfiles " $output"
cannam@167 9919
cannam@167 9920 else
cannam@167 9921 output=
cannam@167 9922 fi
cannam@167 9923
cannam@167 9924 ${skipped_export-false} && {
cannam@167 9925 func_verbose "generating symbol list for '$libname.la'"
cannam@167 9926 export_symbols=$output_objdir/$libname.exp
cannam@167 9927 $opt_dry_run || $RM $export_symbols
cannam@167 9928 libobjs=$output
cannam@167 9929 # Append the command to create the export file.
cannam@167 9930 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
cannam@167 9931 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
cannam@167 9932 if test -n "$last_robj"; then
cannam@167 9933 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
cannam@167 9934 fi
cannam@167 9935 }
cannam@167 9936
cannam@167 9937 test -n "$save_libobjs" &&
cannam@167 9938 func_verbose "creating a temporary reloadable object file: $output"
cannam@167 9939
cannam@167 9940 # Loop through the commands generated above and execute them.
cannam@167 9941 save_ifs=$IFS; IFS='~'
cannam@167 9942 for cmd in $concat_cmds; do
cannam@167 9943 IFS=$save_ifs
cannam@167 9944 $opt_quiet || {
cannam@167 9945 func_quote_for_expand "$cmd"
cannam@167 9946 eval "func_echo $func_quote_for_expand_result"
cannam@167 9947 }
cannam@167 9948 $opt_dry_run || eval "$cmd" || {
cannam@167 9949 lt_exit=$?
cannam@167 9950
cannam@167 9951 # Restore the uninstalled library and exit
cannam@167 9952 if test relink = "$opt_mode"; then
cannam@167 9953 ( cd "$output_objdir" && \
cannam@167 9954 $RM "${realname}T" && \
cannam@167 9955 $MV "${realname}U" "$realname" )
cannam@167 9956 fi
cannam@167 9957
cannam@167 9958 exit $lt_exit
cannam@167 9959 }
cannam@167 9960 done
cannam@167 9961 IFS=$save_ifs
cannam@167 9962
cannam@167 9963 if test -n "$export_symbols_regex" && ${skipped_export-false}; then
cannam@167 9964 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
cannam@167 9965 func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
cannam@167 9966 fi
cannam@167 9967 fi
cannam@167 9968
cannam@167 9969 ${skipped_export-false} && {
cannam@167 9970 if test -n "$export_symbols" && test -n "$include_expsyms"; then
cannam@167 9971 tmp_export_symbols=$export_symbols
cannam@167 9972 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
cannam@167 9973 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
cannam@167 9974 fi
cannam@167 9975
cannam@167 9976 if test -n "$orig_export_symbols"; then
cannam@167 9977 # The given exports_symbols file has to be filtered, so filter it.
cannam@167 9978 func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
cannam@167 9979 # FIXME: $output_objdir/$libname.filter potentially contains lots of
cannam@167 9980 # 's' commands, which not all seds can handle. GNU sed should be fine
cannam@167 9981 # though. Also, the filter scales superlinearly with the number of
cannam@167 9982 # global variables. join(1) would be nice here, but unfortunately
cannam@167 9983 # isn't a blessed tool.
cannam@167 9984 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
cannam@167 9985 func_append delfiles " $export_symbols $output_objdir/$libname.filter"
cannam@167 9986 export_symbols=$output_objdir/$libname.def
cannam@167 9987 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
cannam@167 9988 fi
cannam@167 9989 }
cannam@167 9990
cannam@167 9991 libobjs=$output
cannam@167 9992 # Restore the value of output.
cannam@167 9993 output=$save_output
cannam@167 9994
cannam@167 9995 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
cannam@167 9996 eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
cannam@167 9997 test "X$libobjs" = "X " && libobjs=
cannam@167 9998 fi
cannam@167 9999 # Expand the library linking commands again to reset the
cannam@167 10000 # value of $libobjs for piecewise linking.
cannam@167 10001
cannam@167 10002 # Do each of the archive commands.
cannam@167 10003 if test yes = "$module" && test -n "$module_cmds"; then
cannam@167 10004 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
cannam@167 10005 cmds=$module_expsym_cmds
cannam@167 10006 else
cannam@167 10007 cmds=$module_cmds
cannam@167 10008 fi
cannam@167 10009 else
cannam@167 10010 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
cannam@167 10011 cmds=$archive_expsym_cmds
cannam@167 10012 else
cannam@167 10013 cmds=$archive_cmds
cannam@167 10014 fi
cannam@167 10015 fi
cannam@167 10016 fi
cannam@167 10017
cannam@167 10018 if test -n "$delfiles"; then
cannam@167 10019 # Append the command to remove temporary files to $cmds.
cannam@167 10020 eval cmds=\"\$cmds~\$RM $delfiles\"
cannam@167 10021 fi
cannam@167 10022
cannam@167 10023 # Add any objects from preloaded convenience libraries
cannam@167 10024 if test -n "$dlprefiles"; then
cannam@167 10025 gentop=$output_objdir/${outputname}x
cannam@167 10026 func_append generated " $gentop"
cannam@167 10027
cannam@167 10028 func_extract_archives $gentop $dlprefiles
cannam@167 10029 func_append libobjs " $func_extract_archives_result"
cannam@167 10030 test "X$libobjs" = "X " && libobjs=
cannam@167 10031 fi
cannam@167 10032
cannam@167 10033 save_ifs=$IFS; IFS='~'
cannam@167 10034 for cmd in $cmds; do
cannam@167 10035 IFS=$sp$nl
cannam@167 10036 eval cmd=\"$cmd\"
cannam@167 10037 IFS=$save_ifs
cannam@167 10038 $opt_quiet || {
cannam@167 10039 func_quote_for_expand "$cmd"
cannam@167 10040 eval "func_echo $func_quote_for_expand_result"
cannam@167 10041 }
cannam@167 10042 $opt_dry_run || eval "$cmd" || {
cannam@167 10043 lt_exit=$?
cannam@167 10044
cannam@167 10045 # Restore the uninstalled library and exit
cannam@167 10046 if test relink = "$opt_mode"; then
cannam@167 10047 ( cd "$output_objdir" && \
cannam@167 10048 $RM "${realname}T" && \
cannam@167 10049 $MV "${realname}U" "$realname" )
cannam@167 10050 fi
cannam@167 10051
cannam@167 10052 exit $lt_exit
cannam@167 10053 }
cannam@167 10054 done
cannam@167 10055 IFS=$save_ifs
cannam@167 10056
cannam@167 10057 # Restore the uninstalled library and exit
cannam@167 10058 if test relink = "$opt_mode"; then
cannam@167 10059 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
cannam@167 10060
cannam@167 10061 if test -n "$convenience"; then
cannam@167 10062 if test -z "$whole_archive_flag_spec"; then
cannam@167 10063 func_show_eval '${RM}r "$gentop"'
cannam@167 10064 fi
cannam@167 10065 fi
cannam@167 10066
cannam@167 10067 exit $EXIT_SUCCESS
cannam@167 10068 fi
cannam@167 10069
cannam@167 10070 # Create links to the real library.
cannam@167 10071 for linkname in $linknames; do
cannam@167 10072 if test "$realname" != "$linkname"; then
cannam@167 10073 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
cannam@167 10074 fi
cannam@167 10075 done
cannam@167 10076
cannam@167 10077 # If -module or -export-dynamic was specified, set the dlname.
cannam@167 10078 if test yes = "$module" || test yes = "$export_dynamic"; then
cannam@167 10079 # On all known operating systems, these are identical.
cannam@167 10080 dlname=$soname
cannam@167 10081 fi
cannam@167 10082 fi
cannam@167 10083 ;;
cannam@167 10084
cannam@167 10085 obj)
cannam@167 10086 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
cannam@167 10087 func_warning "'-dlopen' is ignored for objects"
cannam@167 10088 fi
cannam@167 10089
cannam@167 10090 case " $deplibs" in
cannam@167 10091 *\ -l* | *\ -L*)
cannam@167 10092 func_warning "'-l' and '-L' are ignored for objects" ;;
cannam@167 10093 esac
cannam@167 10094
cannam@167 10095 test -n "$rpath" && \
cannam@167 10096 func_warning "'-rpath' is ignored for objects"
cannam@167 10097
cannam@167 10098 test -n "$xrpath" && \
cannam@167 10099 func_warning "'-R' is ignored for objects"
cannam@167 10100
cannam@167 10101 test -n "$vinfo" && \
cannam@167 10102 func_warning "'-version-info' is ignored for objects"
cannam@167 10103
cannam@167 10104 test -n "$release" && \
cannam@167 10105 func_warning "'-release' is ignored for objects"
cannam@167 10106
cannam@167 10107 case $output in
cannam@167 10108 *.lo)
cannam@167 10109 test -n "$objs$old_deplibs" && \
cannam@167 10110 func_fatal_error "cannot build library object '$output' from non-libtool objects"
cannam@167 10111
cannam@167 10112 libobj=$output
cannam@167 10113 func_lo2o "$libobj"
cannam@167 10114 obj=$func_lo2o_result
cannam@167 10115 ;;
cannam@167 10116 *)
cannam@167 10117 libobj=
cannam@167 10118 obj=$output
cannam@167 10119 ;;
cannam@167 10120 esac
cannam@167 10121
cannam@167 10122 # Delete the old objects.
cannam@167 10123 $opt_dry_run || $RM $obj $libobj
cannam@167 10124
cannam@167 10125 # Objects from convenience libraries. This assumes
cannam@167 10126 # single-version convenience libraries. Whenever we create
cannam@167 10127 # different ones for PIC/non-PIC, this we'll have to duplicate
cannam@167 10128 # the extraction.
cannam@167 10129 reload_conv_objs=
cannam@167 10130 gentop=
cannam@167 10131 # if reload_cmds runs $LD directly, get rid of -Wl from
cannam@167 10132 # whole_archive_flag_spec and hope we can get by with turning comma
cannam@167 10133 # into space.
cannam@167 10134 case $reload_cmds in
cannam@167 10135 *\$LD[\ \$]*) wl= ;;
cannam@167 10136 esac
cannam@167 10137 if test -n "$convenience"; then
cannam@167 10138 if test -n "$whole_archive_flag_spec"; then
cannam@167 10139 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
cannam@167 10140 test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
cannam@167 10141 reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
cannam@167 10142 else
cannam@167 10143 gentop=$output_objdir/${obj}x
cannam@167 10144 func_append generated " $gentop"
cannam@167 10145
cannam@167 10146 func_extract_archives $gentop $convenience
cannam@167 10147 reload_conv_objs="$reload_objs $func_extract_archives_result"
cannam@167 10148 fi
cannam@167 10149 fi
cannam@167 10150
cannam@167 10151 # If we're not building shared, we need to use non_pic_objs
cannam@167 10152 test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
cannam@167 10153
cannam@167 10154 # Create the old-style object.
cannam@167 10155 reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
cannam@167 10156
cannam@167 10157 output=$obj
cannam@167 10158 func_execute_cmds "$reload_cmds" 'exit $?'
cannam@167 10159
cannam@167 10160 # Exit if we aren't doing a library object file.
cannam@167 10161 if test -z "$libobj"; then
cannam@167 10162 if test -n "$gentop"; then
cannam@167 10163 func_show_eval '${RM}r "$gentop"'
cannam@167 10164 fi
cannam@167 10165
cannam@167 10166 exit $EXIT_SUCCESS
cannam@167 10167 fi
cannam@167 10168
cannam@167 10169 test yes = "$build_libtool_libs" || {
cannam@167 10170 if test -n "$gentop"; then
cannam@167 10171 func_show_eval '${RM}r "$gentop"'
cannam@167 10172 fi
cannam@167 10173
cannam@167 10174 # Create an invalid libtool object if no PIC, so that we don't
cannam@167 10175 # accidentally link it into a program.
cannam@167 10176 # $show "echo timestamp > $libobj"
cannam@167 10177 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
cannam@167 10178 exit $EXIT_SUCCESS
cannam@167 10179 }
cannam@167 10180
cannam@167 10181 if test -n "$pic_flag" || test default != "$pic_mode"; then
cannam@167 10182 # Only do commands if we really have different PIC objects.
cannam@167 10183 reload_objs="$libobjs $reload_conv_objs"
cannam@167 10184 output=$libobj
cannam@167 10185 func_execute_cmds "$reload_cmds" 'exit $?'
cannam@167 10186 fi
cannam@167 10187
cannam@167 10188 if test -n "$gentop"; then
cannam@167 10189 func_show_eval '${RM}r "$gentop"'
cannam@167 10190 fi
cannam@167 10191
cannam@167 10192 exit $EXIT_SUCCESS
cannam@167 10193 ;;
cannam@167 10194
cannam@167 10195 prog)
cannam@167 10196 case $host in
cannam@167 10197 *cygwin*) func_stripname '' '.exe' "$output"
cannam@167 10198 output=$func_stripname_result.exe;;
cannam@167 10199 esac
cannam@167 10200 test -n "$vinfo" && \
cannam@167 10201 func_warning "'-version-info' is ignored for programs"
cannam@167 10202
cannam@167 10203 test -n "$release" && \
cannam@167 10204 func_warning "'-release' is ignored for programs"
cannam@167 10205
cannam@167 10206 $preload \
cannam@167 10207 && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
cannam@167 10208 && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
cannam@167 10209
cannam@167 10210 case $host in
cannam@167 10211 *-*-rhapsody* | *-*-darwin1.[012])
cannam@167 10212 # On Rhapsody replace the C library is the System framework
cannam@167 10213 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
cannam@167 10214 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
cannam@167 10215 ;;
cannam@167 10216 esac
cannam@167 10217
cannam@167 10218 case $host in
cannam@167 10219 *-*-darwin*)
cannam@167 10220 # Don't allow lazy linking, it breaks C++ global constructors
cannam@167 10221 # But is supposedly fixed on 10.4 or later (yay!).
cannam@167 10222 if test CXX = "$tagname"; then
cannam@167 10223 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
cannam@167 10224 10.[0123])
cannam@167 10225 func_append compile_command " $wl-bind_at_load"
cannam@167 10226 func_append finalize_command " $wl-bind_at_load"
cannam@167 10227 ;;
cannam@167 10228 esac
cannam@167 10229 fi
cannam@167 10230 # Time to change all our "foo.ltframework" stuff back to "-framework foo"
cannam@167 10231 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@167 10232 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
cannam@167 10233 ;;
cannam@167 10234 esac
cannam@167 10235
cannam@167 10236
cannam@167 10237 # move library search paths that coincide with paths to not yet
cannam@167 10238 # installed libraries to the beginning of the library search list
cannam@167 10239 new_libs=
cannam@167 10240 for path in $notinst_path; do
cannam@167 10241 case " $new_libs " in
cannam@167 10242 *" -L$path/$objdir "*) ;;
cannam@167 10243 *)
cannam@167 10244 case " $compile_deplibs " in
cannam@167 10245 *" -L$path/$objdir "*)
cannam@167 10246 func_append new_libs " -L$path/$objdir" ;;
cannam@167 10247 esac
cannam@167 10248 ;;
cannam@167 10249 esac
cannam@167 10250 done
cannam@167 10251 for deplib in $compile_deplibs; do
cannam@167 10252 case $deplib in
cannam@167 10253 -L*)
cannam@167 10254 case " $new_libs " in
cannam@167 10255 *" $deplib "*) ;;
cannam@167 10256 *) func_append new_libs " $deplib" ;;
cannam@167 10257 esac
cannam@167 10258 ;;
cannam@167 10259 *) func_append new_libs " $deplib" ;;
cannam@167 10260 esac
cannam@167 10261 done
cannam@167 10262 compile_deplibs=$new_libs
cannam@167 10263
cannam@167 10264
cannam@167 10265 func_append compile_command " $compile_deplibs"
cannam@167 10266 func_append finalize_command " $finalize_deplibs"
cannam@167 10267
cannam@167 10268 if test -n "$rpath$xrpath"; then
cannam@167 10269 # If the user specified any rpath flags, then add them.
cannam@167 10270 for libdir in $rpath $xrpath; do
cannam@167 10271 # This is the magic to use -rpath.
cannam@167 10272 case "$finalize_rpath " in
cannam@167 10273 *" $libdir "*) ;;
cannam@167 10274 *) func_append finalize_rpath " $libdir" ;;
cannam@167 10275 esac
cannam@167 10276 done
cannam@167 10277 fi
cannam@167 10278
cannam@167 10279 # Now hardcode the library paths
cannam@167 10280 rpath=
cannam@167 10281 hardcode_libdirs=
cannam@167 10282 for libdir in $compile_rpath $finalize_rpath; do
cannam@167 10283 if test -n "$hardcode_libdir_flag_spec"; then
cannam@167 10284 if test -n "$hardcode_libdir_separator"; then
cannam@167 10285 if test -z "$hardcode_libdirs"; then
cannam@167 10286 hardcode_libdirs=$libdir
cannam@167 10287 else
cannam@167 10288 # Just accumulate the unique libdirs.
cannam@167 10289 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
cannam@167 10290 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
cannam@167 10291 ;;
cannam@167 10292 *)
cannam@167 10293 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
cannam@167 10294 ;;
cannam@167 10295 esac
cannam@167 10296 fi
cannam@167 10297 else
cannam@167 10298 eval flag=\"$hardcode_libdir_flag_spec\"
cannam@167 10299 func_append rpath " $flag"
cannam@167 10300 fi
cannam@167 10301 elif test -n "$runpath_var"; then
cannam@167 10302 case "$perm_rpath " in
cannam@167 10303 *" $libdir "*) ;;
cannam@167 10304 *) func_append perm_rpath " $libdir" ;;
cannam@167 10305 esac
cannam@167 10306 fi
cannam@167 10307 case $host in
cannam@167 10308 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
cannam@167 10309 testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
cannam@167 10310 case :$dllsearchpath: in
cannam@167 10311 *":$libdir:"*) ;;
cannam@167 10312 ::) dllsearchpath=$libdir;;
cannam@167 10313 *) func_append dllsearchpath ":$libdir";;
cannam@167 10314 esac
cannam@167 10315 case :$dllsearchpath: in
cannam@167 10316 *":$testbindir:"*) ;;
cannam@167 10317 ::) dllsearchpath=$testbindir;;
cannam@167 10318 *) func_append dllsearchpath ":$testbindir";;
cannam@167 10319 esac
cannam@167 10320 ;;
cannam@167 10321 esac
cannam@167 10322 done
cannam@167 10323 # Substitute the hardcoded libdirs into the rpath.
cannam@167 10324 if test -n "$hardcode_libdir_separator" &&
cannam@167 10325 test -n "$hardcode_libdirs"; then
cannam@167 10326 libdir=$hardcode_libdirs
cannam@167 10327 eval rpath=\" $hardcode_libdir_flag_spec\"
cannam@167 10328 fi
cannam@167 10329 compile_rpath=$rpath
cannam@167 10330
cannam@167 10331 rpath=
cannam@167 10332 hardcode_libdirs=
cannam@167 10333 for libdir in $finalize_rpath; do
cannam@167 10334 if test -n "$hardcode_libdir_flag_spec"; then
cannam@167 10335 if test -n "$hardcode_libdir_separator"; then
cannam@167 10336 if test -z "$hardcode_libdirs"; then
cannam@167 10337 hardcode_libdirs=$libdir
cannam@167 10338 else
cannam@167 10339 # Just accumulate the unique libdirs.
cannam@167 10340 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
cannam@167 10341 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
cannam@167 10342 ;;
cannam@167 10343 *)
cannam@167 10344 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
cannam@167 10345 ;;
cannam@167 10346 esac
cannam@167 10347 fi
cannam@167 10348 else
cannam@167 10349 eval flag=\"$hardcode_libdir_flag_spec\"
cannam@167 10350 func_append rpath " $flag"
cannam@167 10351 fi
cannam@167 10352 elif test -n "$runpath_var"; then
cannam@167 10353 case "$finalize_perm_rpath " in
cannam@167 10354 *" $libdir "*) ;;
cannam@167 10355 *) func_append finalize_perm_rpath " $libdir" ;;
cannam@167 10356 esac
cannam@167 10357 fi
cannam@167 10358 done
cannam@167 10359 # Substitute the hardcoded libdirs into the rpath.
cannam@167 10360 if test -n "$hardcode_libdir_separator" &&
cannam@167 10361 test -n "$hardcode_libdirs"; then
cannam@167 10362 libdir=$hardcode_libdirs
cannam@167 10363 eval rpath=\" $hardcode_libdir_flag_spec\"
cannam@167 10364 fi
cannam@167 10365 finalize_rpath=$rpath
cannam@167 10366
cannam@167 10367 if test -n "$libobjs" && test yes = "$build_old_libs"; then
cannam@167 10368 # Transform all the library objects into standard objects.
cannam@167 10369 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
cannam@167 10370 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
cannam@167 10371 fi
cannam@167 10372
cannam@167 10373 func_generate_dlsyms "$outputname" "@PROGRAM@" false
cannam@167 10374
cannam@167 10375 # template prelinking step
cannam@167 10376 if test -n "$prelink_cmds"; then
cannam@167 10377 func_execute_cmds "$prelink_cmds" 'exit $?'
cannam@167 10378 fi
cannam@167 10379
cannam@167 10380 wrappers_required=:
cannam@167 10381 case $host in
cannam@167 10382 *cegcc* | *mingw32ce*)
cannam@167 10383 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
cannam@167 10384 wrappers_required=false
cannam@167 10385 ;;
cannam@167 10386 *cygwin* | *mingw* )
cannam@167 10387 test yes = "$build_libtool_libs" || wrappers_required=false
cannam@167 10388 ;;
cannam@167 10389 *)
cannam@167 10390 if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
cannam@167 10391 wrappers_required=false
cannam@167 10392 fi
cannam@167 10393 ;;
cannam@167 10394 esac
cannam@167 10395 $wrappers_required || {
cannam@167 10396 # Replace the output file specification.
cannam@167 10397 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
cannam@167 10398 link_command=$compile_command$compile_rpath
cannam@167 10399
cannam@167 10400 # We have no uninstalled library dependencies, so finalize right now.
cannam@167 10401 exit_status=0
cannam@167 10402 func_show_eval "$link_command" 'exit_status=$?'
cannam@167 10403
cannam@167 10404 if test -n "$postlink_cmds"; then
cannam@167 10405 func_to_tool_file "$output"
cannam@167 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@167 10407 func_execute_cmds "$postlink_cmds" 'exit $?'
cannam@167 10408 fi
cannam@167 10409
cannam@167 10410 # Delete the generated files.
cannam@167 10411 if test -f "$output_objdir/${outputname}S.$objext"; then
cannam@167 10412 func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
cannam@167 10413 fi
cannam@167 10414
cannam@167 10415 exit $exit_status
cannam@167 10416 }
cannam@167 10417
cannam@167 10418 if test -n "$compile_shlibpath$finalize_shlibpath"; then
cannam@167 10419 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
cannam@167 10420 fi
cannam@167 10421 if test -n "$finalize_shlibpath"; then
cannam@167 10422 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
cannam@167 10423 fi
cannam@167 10424
cannam@167 10425 compile_var=
cannam@167 10426 finalize_var=
cannam@167 10427 if test -n "$runpath_var"; then
cannam@167 10428 if test -n "$perm_rpath"; then
cannam@167 10429 # We should set the runpath_var.
cannam@167 10430 rpath=
cannam@167 10431 for dir in $perm_rpath; do
cannam@167 10432 func_append rpath "$dir:"
cannam@167 10433 done
cannam@167 10434 compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
cannam@167 10435 fi
cannam@167 10436 if test -n "$finalize_perm_rpath"; then
cannam@167 10437 # We should set the runpath_var.
cannam@167 10438 rpath=
cannam@167 10439 for dir in $finalize_perm_rpath; do
cannam@167 10440 func_append rpath "$dir:"
cannam@167 10441 done
cannam@167 10442 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
cannam@167 10443 fi
cannam@167 10444 fi
cannam@167 10445
cannam@167 10446 if test yes = "$no_install"; then
cannam@167 10447 # We don't need to create a wrapper script.
cannam@167 10448 link_command=$compile_var$compile_command$compile_rpath
cannam@167 10449 # Replace the output file specification.
cannam@167 10450 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
cannam@167 10451 # Delete the old output file.
cannam@167 10452 $opt_dry_run || $RM $output
cannam@167 10453 # Link the executable and exit
cannam@167 10454 func_show_eval "$link_command" 'exit $?'
cannam@167 10455
cannam@167 10456 if test -n "$postlink_cmds"; then
cannam@167 10457 func_to_tool_file "$output"
cannam@167 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@167 10459 func_execute_cmds "$postlink_cmds" 'exit $?'
cannam@167 10460 fi
cannam@167 10461
cannam@167 10462 exit $EXIT_SUCCESS
cannam@167 10463 fi
cannam@167 10464
cannam@167 10465 case $hardcode_action,$fast_install in
cannam@167 10466 relink,*)
cannam@167 10467 # Fast installation is not supported
cannam@167 10468 link_command=$compile_var$compile_command$compile_rpath
cannam@167 10469 relink_command=$finalize_var$finalize_command$finalize_rpath
cannam@167 10470
cannam@167 10471 func_warning "this platform does not like uninstalled shared libraries"
cannam@167 10472 func_warning "'$output' will be relinked during installation"
cannam@167 10473 ;;
cannam@167 10474 *,yes)
cannam@167 10475 link_command=$finalize_var$compile_command$finalize_rpath
cannam@167 10476 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
cannam@167 10477 ;;
cannam@167 10478 *,no)
cannam@167 10479 link_command=$compile_var$compile_command$compile_rpath
cannam@167 10480 relink_command=$finalize_var$finalize_command$finalize_rpath
cannam@167 10481 ;;
cannam@167 10482 *,needless)
cannam@167 10483 link_command=$finalize_var$compile_command$finalize_rpath
cannam@167 10484 relink_command=
cannam@167 10485 ;;
cannam@167 10486 esac
cannam@167 10487
cannam@167 10488 # Replace the output file specification.
cannam@167 10489 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
cannam@167 10490
cannam@167 10491 # Delete the old output files.
cannam@167 10492 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
cannam@167 10493
cannam@167 10494 func_show_eval "$link_command" 'exit $?'
cannam@167 10495
cannam@167 10496 if test -n "$postlink_cmds"; then
cannam@167 10497 func_to_tool_file "$output_objdir/$outputname"
cannam@167 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@167 10499 func_execute_cmds "$postlink_cmds" 'exit $?'
cannam@167 10500 fi
cannam@167 10501
cannam@167 10502 # Now create the wrapper script.
cannam@167 10503 func_verbose "creating $output"
cannam@167 10504
cannam@167 10505 # Quote the relink command for shipping.
cannam@167 10506 if test -n "$relink_command"; then
cannam@167 10507 # Preserve any variables that may affect compiler behavior
cannam@167 10508 for var in $variables_saved_for_relink; do
cannam@167 10509 if eval test -z \"\${$var+set}\"; then
cannam@167 10510 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
cannam@167 10511 elif eval var_value=\$$var; test -z "$var_value"; then
cannam@167 10512 relink_command="$var=; export $var; $relink_command"
cannam@167 10513 else
cannam@167 10514 func_quote_for_eval "$var_value"
cannam@167 10515 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
cannam@167 10516 fi
cannam@167 10517 done
cannam@167 10518 relink_command="(cd `pwd`; $relink_command)"
cannam@167 10519 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
cannam@167 10520 fi
cannam@167 10521
cannam@167 10522 # Only actually do things if not in dry run mode.
cannam@167 10523 $opt_dry_run || {
cannam@167 10524 # win32 will think the script is a binary if it has
cannam@167 10525 # a .exe suffix, so we strip it off here.
cannam@167 10526 case $output in
cannam@167 10527 *.exe) func_stripname '' '.exe' "$output"
cannam@167 10528 output=$func_stripname_result ;;
cannam@167 10529 esac
cannam@167 10530 # test for cygwin because mv fails w/o .exe extensions
cannam@167 10531 case $host in
cannam@167 10532 *cygwin*)
cannam@167 10533 exeext=.exe
cannam@167 10534 func_stripname '' '.exe' "$outputname"
cannam@167 10535 outputname=$func_stripname_result ;;
cannam@167 10536 *) exeext= ;;
cannam@167 10537 esac
cannam@167 10538 case $host in
cannam@167 10539 *cygwin* | *mingw* )
cannam@167 10540 func_dirname_and_basename "$output" "" "."
cannam@167 10541 output_name=$func_basename_result
cannam@167 10542 output_path=$func_dirname_result
cannam@167 10543 cwrappersource=$output_path/$objdir/lt-$output_name.c
cannam@167 10544 cwrapper=$output_path/$output_name.exe
cannam@167 10545 $RM $cwrappersource $cwrapper
cannam@167 10546 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
cannam@167 10547
cannam@167 10548 func_emit_cwrapperexe_src > $cwrappersource
cannam@167 10549
cannam@167 10550 # The wrapper executable is built using the $host compiler,
cannam@167 10551 # because it contains $host paths and files. If cross-
cannam@167 10552 # compiling, it, like the target executable, must be
cannam@167 10553 # executed on the $host or under an emulation environment.
cannam@167 10554 $opt_dry_run || {
cannam@167 10555 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
cannam@167 10556 $STRIP $cwrapper
cannam@167 10557 }
cannam@167 10558
cannam@167 10559 # Now, create the wrapper script for func_source use:
cannam@167 10560 func_ltwrapper_scriptname $cwrapper
cannam@167 10561 $RM $func_ltwrapper_scriptname_result
cannam@167 10562 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
cannam@167 10563 $opt_dry_run || {
cannam@167 10564 # note: this script will not be executed, so do not chmod.
cannam@167 10565 if test "x$build" = "x$host"; then
cannam@167 10566 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
cannam@167 10567 else
cannam@167 10568 func_emit_wrapper no > $func_ltwrapper_scriptname_result
cannam@167 10569 fi
cannam@167 10570 }
cannam@167 10571 ;;
cannam@167 10572 * )
cannam@167 10573 $RM $output
cannam@167 10574 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
cannam@167 10575
cannam@167 10576 func_emit_wrapper no > $output
cannam@167 10577 chmod +x $output
cannam@167 10578 ;;
cannam@167 10579 esac
cannam@167 10580 }
cannam@167 10581 exit $EXIT_SUCCESS
cannam@167 10582 ;;
cannam@167 10583 esac
cannam@167 10584
cannam@167 10585 # See if we need to build an old-fashioned archive.
cannam@167 10586 for oldlib in $oldlibs; do
cannam@167 10587
cannam@167 10588 case $build_libtool_libs in
cannam@167 10589 convenience)
cannam@167 10590 oldobjs="$libobjs_save $symfileobj"
cannam@167 10591 addlibs=$convenience
cannam@167 10592 build_libtool_libs=no
cannam@167 10593 ;;
cannam@167 10594 module)
cannam@167 10595 oldobjs=$libobjs_save
cannam@167 10596 addlibs=$old_convenience
cannam@167 10597 build_libtool_libs=no
cannam@167 10598 ;;
cannam@167 10599 *)
cannam@167 10600 oldobjs="$old_deplibs $non_pic_objects"
cannam@167 10601 $preload && test -f "$symfileobj" \
cannam@167 10602 && func_append oldobjs " $symfileobj"
cannam@167 10603 addlibs=$old_convenience
cannam@167 10604 ;;
cannam@167 10605 esac
cannam@167 10606
cannam@167 10607 if test -n "$addlibs"; then
cannam@167 10608 gentop=$output_objdir/${outputname}x
cannam@167 10609 func_append generated " $gentop"
cannam@167 10610
cannam@167 10611 func_extract_archives $gentop $addlibs
cannam@167 10612 func_append oldobjs " $func_extract_archives_result"
cannam@167 10613 fi
cannam@167 10614
cannam@167 10615 # Do each command in the archive commands.
cannam@167 10616 if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
cannam@167 10617 cmds=$old_archive_from_new_cmds
cannam@167 10618 else
cannam@167 10619
cannam@167 10620 # Add any objects from preloaded convenience libraries
cannam@167 10621 if test -n "$dlprefiles"; then
cannam@167 10622 gentop=$output_objdir/${outputname}x
cannam@167 10623 func_append generated " $gentop"
cannam@167 10624
cannam@167 10625 func_extract_archives $gentop $dlprefiles
cannam@167 10626 func_append oldobjs " $func_extract_archives_result"
cannam@167 10627 fi
cannam@167 10628
cannam@167 10629 # POSIX demands no paths to be encoded in archives. We have
cannam@167 10630 # to avoid creating archives with duplicate basenames if we
cannam@167 10631 # might have to extract them afterwards, e.g., when creating a
cannam@167 10632 # static archive out of a convenience library, or when linking
cannam@167 10633 # the entirety of a libtool archive into another (currently
cannam@167 10634 # not supported by libtool).
cannam@167 10635 if (for obj in $oldobjs
cannam@167 10636 do
cannam@167 10637 func_basename "$obj"
cannam@167 10638 $ECHO "$func_basename_result"
cannam@167 10639 done | sort | sort -uc >/dev/null 2>&1); then
cannam@167 10640 :
cannam@167 10641 else
cannam@167 10642 echo "copying selected object files to avoid basename conflicts..."
cannam@167 10643 gentop=$output_objdir/${outputname}x
cannam@167 10644 func_append generated " $gentop"
cannam@167 10645 func_mkdir_p "$gentop"
cannam@167 10646 save_oldobjs=$oldobjs
cannam@167 10647 oldobjs=
cannam@167 10648 counter=1
cannam@167 10649 for obj in $save_oldobjs
cannam@167 10650 do
cannam@167 10651 func_basename "$obj"
cannam@167 10652 objbase=$func_basename_result
cannam@167 10653 case " $oldobjs " in
cannam@167 10654 " ") oldobjs=$obj ;;
cannam@167 10655 *[\ /]"$objbase "*)
cannam@167 10656 while :; do
cannam@167 10657 # Make sure we don't pick an alternate name that also
cannam@167 10658 # overlaps.
cannam@167 10659 newobj=lt$counter-$objbase
cannam@167 10660 func_arith $counter + 1
cannam@167 10661 counter=$func_arith_result
cannam@167 10662 case " $oldobjs " in
cannam@167 10663 *[\ /]"$newobj "*) ;;
cannam@167 10664 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
cannam@167 10665 esac
cannam@167 10666 done
cannam@167 10667 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
cannam@167 10668 func_append oldobjs " $gentop/$newobj"
cannam@167 10669 ;;
cannam@167 10670 *) func_append oldobjs " $obj" ;;
cannam@167 10671 esac
cannam@167 10672 done
cannam@167 10673 fi
cannam@167 10674 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
cannam@167 10675 tool_oldlib=$func_to_tool_file_result
cannam@167 10676 eval cmds=\"$old_archive_cmds\"
cannam@167 10677
cannam@167 10678 func_len " $cmds"
cannam@167 10679 len=$func_len_result
cannam@167 10680 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
cannam@167 10681 cmds=$old_archive_cmds
cannam@167 10682 elif test -n "$archiver_list_spec"; then
cannam@167 10683 func_verbose "using command file archive linking..."
cannam@167 10684 for obj in $oldobjs
cannam@167 10685 do
cannam@167 10686 func_to_tool_file "$obj"
cannam@167 10687 $ECHO "$func_to_tool_file_result"
cannam@167 10688 done > $output_objdir/$libname.libcmd
cannam@167 10689 func_to_tool_file "$output_objdir/$libname.libcmd"
cannam@167 10690 oldobjs=" $archiver_list_spec$func_to_tool_file_result"
cannam@167 10691 cmds=$old_archive_cmds
cannam@167 10692 else
cannam@167 10693 # the command line is too long to link in one step, link in parts
cannam@167 10694 func_verbose "using piecewise archive linking..."
cannam@167 10695 save_RANLIB=$RANLIB
cannam@167 10696 RANLIB=:
cannam@167 10697 objlist=
cannam@167 10698 concat_cmds=
cannam@167 10699 save_oldobjs=$oldobjs
cannam@167 10700 oldobjs=
cannam@167 10701 # Is there a better way of finding the last object in the list?
cannam@167 10702 for obj in $save_oldobjs
cannam@167 10703 do
cannam@167 10704 last_oldobj=$obj
cannam@167 10705 done
cannam@167 10706 eval test_cmds=\"$old_archive_cmds\"
cannam@167 10707 func_len " $test_cmds"
cannam@167 10708 len0=$func_len_result
cannam@167 10709 len=$len0
cannam@167 10710 for obj in $save_oldobjs
cannam@167 10711 do
cannam@167 10712 func_len " $obj"
cannam@167 10713 func_arith $len + $func_len_result
cannam@167 10714 len=$func_arith_result
cannam@167 10715 func_append objlist " $obj"
cannam@167 10716 if test "$len" -lt "$max_cmd_len"; then
cannam@167 10717 :
cannam@167 10718 else
cannam@167 10719 # the above command should be used before it gets too long
cannam@167 10720 oldobjs=$objlist
cannam@167 10721 if test "$obj" = "$last_oldobj"; then
cannam@167 10722 RANLIB=$save_RANLIB
cannam@167 10723 fi
cannam@167 10724 test -z "$concat_cmds" || concat_cmds=$concat_cmds~
cannam@167 10725 eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
cannam@167 10726 objlist=
cannam@167 10727 len=$len0
cannam@167 10728 fi
cannam@167 10729 done
cannam@167 10730 RANLIB=$save_RANLIB
cannam@167 10731 oldobjs=$objlist
cannam@167 10732 if test -z "$oldobjs"; then
cannam@167 10733 eval cmds=\"\$concat_cmds\"
cannam@167 10734 else
cannam@167 10735 eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
cannam@167 10736 fi
cannam@167 10737 fi
cannam@167 10738 fi
cannam@167 10739 func_execute_cmds "$cmds" 'exit $?'
cannam@167 10740 done
cannam@167 10741
cannam@167 10742 test -n "$generated" && \
cannam@167 10743 func_show_eval "${RM}r$generated"
cannam@167 10744
cannam@167 10745 # Now create the libtool archive.
cannam@167 10746 case $output in
cannam@167 10747 *.la)
cannam@167 10748 old_library=
cannam@167 10749 test yes = "$build_old_libs" && old_library=$libname.$libext
cannam@167 10750 func_verbose "creating $output"
cannam@167 10751
cannam@167 10752 # Preserve any variables that may affect compiler behavior
cannam@167 10753 for var in $variables_saved_for_relink; do
cannam@167 10754 if eval test -z \"\${$var+set}\"; then
cannam@167 10755 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
cannam@167 10756 elif eval var_value=\$$var; test -z "$var_value"; then
cannam@167 10757 relink_command="$var=; export $var; $relink_command"
cannam@167 10758 else
cannam@167 10759 func_quote_for_eval "$var_value"
cannam@167 10760 relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
cannam@167 10761 fi
cannam@167 10762 done
cannam@167 10763 # Quote the link command for shipping.
cannam@167 10764 relink_command="(cd `pwd`; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
cannam@167 10765 relink_command=`$ECHO "$relink_command" | $SED "$sed_quote_subst"`
cannam@167 10766 if test yes = "$hardcode_automatic"; then
cannam@167 10767 relink_command=
cannam@167 10768 fi
cannam@167 10769
cannam@167 10770 # Only create the output if not a dry run.
cannam@167 10771 $opt_dry_run || {
cannam@167 10772 for installed in no yes; do
cannam@167 10773 if test yes = "$installed"; then
cannam@167 10774 if test -z "$install_libdir"; then
cannam@167 10775 break
cannam@167 10776 fi
cannam@167 10777 output=$output_objdir/${outputname}i
cannam@167 10778 # Replace all uninstalled libtool libraries with the installed ones
cannam@167 10779 newdependency_libs=
cannam@167 10780 for deplib in $dependency_libs; do
cannam@167 10781 case $deplib in
cannam@167 10782 *.la)
cannam@167 10783 func_basename "$deplib"
cannam@167 10784 name=$func_basename_result
cannam@167 10785 func_resolve_sysroot "$deplib"
cannam@167 10786 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
cannam@167 10787 test -z "$libdir" && \
cannam@167 10788 func_fatal_error "'$deplib' is not a valid libtool archive"
cannam@167 10789 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
cannam@167 10790 ;;
cannam@167 10791 -L*)
cannam@167 10792 func_stripname -L '' "$deplib"
cannam@167 10793 func_replace_sysroot "$func_stripname_result"
cannam@167 10794 func_append newdependency_libs " -L$func_replace_sysroot_result"
cannam@167 10795 ;;
cannam@167 10796 -R*)
cannam@167 10797 func_stripname -R '' "$deplib"
cannam@167 10798 func_replace_sysroot "$func_stripname_result"
cannam@167 10799 func_append newdependency_libs " -R$func_replace_sysroot_result"
cannam@167 10800 ;;
cannam@167 10801 *) func_append newdependency_libs " $deplib" ;;
cannam@167 10802 esac
cannam@167 10803 done
cannam@167 10804 dependency_libs=$newdependency_libs
cannam@167 10805 newdlfiles=
cannam@167 10806
cannam@167 10807 for lib in $dlfiles; do
cannam@167 10808 case $lib in
cannam@167 10809 *.la)
cannam@167 10810 func_basename "$lib"
cannam@167 10811 name=$func_basename_result
cannam@167 10812 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
cannam@167 10813 test -z "$libdir" && \
cannam@167 10814 func_fatal_error "'$lib' is not a valid libtool archive"
cannam@167 10815 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
cannam@167 10816 ;;
cannam@167 10817 *) func_append newdlfiles " $lib" ;;
cannam@167 10818 esac
cannam@167 10819 done
cannam@167 10820 dlfiles=$newdlfiles
cannam@167 10821 newdlprefiles=
cannam@167 10822 for lib in $dlprefiles; do
cannam@167 10823 case $lib in
cannam@167 10824 *.la)
cannam@167 10825 # Only pass preopened files to the pseudo-archive (for
cannam@167 10826 # eventual linking with the app. that links it) if we
cannam@167 10827 # didn't already link the preopened objects directly into
cannam@167 10828 # the library:
cannam@167 10829 func_basename "$lib"
cannam@167 10830 name=$func_basename_result
cannam@167 10831 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
cannam@167 10832 test -z "$libdir" && \
cannam@167 10833 func_fatal_error "'$lib' is not a valid libtool archive"
cannam@167 10834 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
cannam@167 10835 ;;
cannam@167 10836 esac
cannam@167 10837 done
cannam@167 10838 dlprefiles=$newdlprefiles
cannam@167 10839 else
cannam@167 10840 newdlfiles=
cannam@167 10841 for lib in $dlfiles; do
cannam@167 10842 case $lib in
cannam@167 10843 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
cannam@167 10844 *) abs=`pwd`"/$lib" ;;
cannam@167 10845 esac
cannam@167 10846 func_append newdlfiles " $abs"
cannam@167 10847 done
cannam@167 10848 dlfiles=$newdlfiles
cannam@167 10849 newdlprefiles=
cannam@167 10850 for lib in $dlprefiles; do
cannam@167 10851 case $lib in
cannam@167 10852 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
cannam@167 10853 *) abs=`pwd`"/$lib" ;;
cannam@167 10854 esac
cannam@167 10855 func_append newdlprefiles " $abs"
cannam@167 10856 done
cannam@167 10857 dlprefiles=$newdlprefiles
cannam@167 10858 fi
cannam@167 10859 $RM $output
cannam@167 10860 # place dlname in correct position for cygwin
cannam@167 10861 # In fact, it would be nice if we could use this code for all target
cannam@167 10862 # systems that can't hard-code library paths into their executables
cannam@167 10863 # and that have no shared library path variable independent of PATH,
cannam@167 10864 # but it turns out we can't easily determine that from inspecting
cannam@167 10865 # libtool variables, so we have to hard-code the OSs to which it
cannam@167 10866 # applies here; at the moment, that means platforms that use the PE
cannam@167 10867 # object format with DLL files. See the long comment at the top of
cannam@167 10868 # tests/bindir.at for full details.
cannam@167 10869 tdlname=$dlname
cannam@167 10870 case $host,$output,$installed,$module,$dlname in
cannam@167 10871 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
cannam@167 10872 # If a -bindir argument was supplied, place the dll there.
cannam@167 10873 if test -n "$bindir"; then
cannam@167 10874 func_relative_path "$install_libdir" "$bindir"
cannam@167 10875 tdlname=$func_relative_path_result/$dlname
cannam@167 10876 else
cannam@167 10877 # Otherwise fall back on heuristic.
cannam@167 10878 tdlname=../bin/$dlname
cannam@167 10879 fi
cannam@167 10880 ;;
cannam@167 10881 esac
cannam@167 10882 $ECHO > $output "\
cannam@167 10883 # $outputname - a libtool library file
cannam@167 10884 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
cannam@167 10885 #
cannam@167 10886 # Please DO NOT delete this file!
cannam@167 10887 # It is necessary for linking the library.
cannam@167 10888
cannam@167 10889 # The name that we can dlopen(3).
cannam@167 10890 dlname='$tdlname'
cannam@167 10891
cannam@167 10892 # Names of this library.
cannam@167 10893 library_names='$library_names'
cannam@167 10894
cannam@167 10895 # The name of the static archive.
cannam@167 10896 old_library='$old_library'
cannam@167 10897
cannam@167 10898 # Linker flags that cannot go in dependency_libs.
cannam@167 10899 inherited_linker_flags='$new_inherited_linker_flags'
cannam@167 10900
cannam@167 10901 # Libraries that this one depends upon.
cannam@167 10902 dependency_libs='$dependency_libs'
cannam@167 10903
cannam@167 10904 # Names of additional weak libraries provided by this library
cannam@167 10905 weak_library_names='$weak_libs'
cannam@167 10906
cannam@167 10907 # Version information for $libname.
cannam@167 10908 current=$current
cannam@167 10909 age=$age
cannam@167 10910 revision=$revision
cannam@167 10911
cannam@167 10912 # Is this an already installed library?
cannam@167 10913 installed=$installed
cannam@167 10914
cannam@167 10915 # Should we warn about portability when linking against -modules?
cannam@167 10916 shouldnotlink=$module
cannam@167 10917
cannam@167 10918 # Files to dlopen/dlpreopen
cannam@167 10919 dlopen='$dlfiles'
cannam@167 10920 dlpreopen='$dlprefiles'
cannam@167 10921
cannam@167 10922 # Directory that this library needs to be installed in:
cannam@167 10923 libdir='$install_libdir'"
cannam@167 10924 if test no,yes = "$installed,$need_relink"; then
cannam@167 10925 $ECHO >> $output "\
cannam@167 10926 relink_command=\"$relink_command\""
cannam@167 10927 fi
cannam@167 10928 done
cannam@167 10929 }
cannam@167 10930
cannam@167 10931 # Do a symbolic link so that the libtool archive can be found in
cannam@167 10932 # LD_LIBRARY_PATH before the program is installed.
cannam@167 10933 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
cannam@167 10934 ;;
cannam@167 10935 esac
cannam@167 10936 exit $EXIT_SUCCESS
cannam@167 10937 }
cannam@167 10938
cannam@167 10939 if test link = "$opt_mode" || test relink = "$opt_mode"; then
cannam@167 10940 func_mode_link ${1+"$@"}
cannam@167 10941 fi
cannam@167 10942
cannam@167 10943
cannam@167 10944 # func_mode_uninstall arg...
cannam@167 10945 func_mode_uninstall ()
cannam@167 10946 {
cannam@167 10947 $debug_cmd
cannam@167 10948
cannam@167 10949 RM=$nonopt
cannam@167 10950 files=
cannam@167 10951 rmforce=false
cannam@167 10952 exit_status=0
cannam@167 10953
cannam@167 10954 # This variable tells wrapper scripts just to set variables rather
cannam@167 10955 # than running their programs.
cannam@167 10956 libtool_install_magic=$magic
cannam@167 10957
cannam@167 10958 for arg
cannam@167 10959 do
cannam@167 10960 case $arg in
cannam@167 10961 -f) func_append RM " $arg"; rmforce=: ;;
cannam@167 10962 -*) func_append RM " $arg" ;;
cannam@167 10963 *) func_append files " $arg" ;;
cannam@167 10964 esac
cannam@167 10965 done
cannam@167 10966
cannam@167 10967 test -z "$RM" && \
cannam@167 10968 func_fatal_help "you must specify an RM program"
cannam@167 10969
cannam@167 10970 rmdirs=
cannam@167 10971
cannam@167 10972 for file in $files; do
cannam@167 10973 func_dirname "$file" "" "."
cannam@167 10974 dir=$func_dirname_result
cannam@167 10975 if test . = "$dir"; then
cannam@167 10976 odir=$objdir
cannam@167 10977 else
cannam@167 10978 odir=$dir/$objdir
cannam@167 10979 fi
cannam@167 10980 func_basename "$file"
cannam@167 10981 name=$func_basename_result
cannam@167 10982 test uninstall = "$opt_mode" && odir=$dir
cannam@167 10983
cannam@167 10984 # Remember odir for removal later, being careful to avoid duplicates
cannam@167 10985 if test clean = "$opt_mode"; then
cannam@167 10986 case " $rmdirs " in
cannam@167 10987 *" $odir "*) ;;
cannam@167 10988 *) func_append rmdirs " $odir" ;;
cannam@167 10989 esac
cannam@167 10990 fi
cannam@167 10991
cannam@167 10992 # Don't error if the file doesn't exist and rm -f was used.
cannam@167 10993 if { test -L "$file"; } >/dev/null 2>&1 ||
cannam@167 10994 { test -h "$file"; } >/dev/null 2>&1 ||
cannam@167 10995 test -f "$file"; then
cannam@167 10996 :
cannam@167 10997 elif test -d "$file"; then
cannam@167 10998 exit_status=1
cannam@167 10999 continue
cannam@167 11000 elif $rmforce; then
cannam@167 11001 continue
cannam@167 11002 fi
cannam@167 11003
cannam@167 11004 rmfiles=$file
cannam@167 11005
cannam@167 11006 case $name in
cannam@167 11007 *.la)
cannam@167 11008 # Possibly a libtool archive, so verify it.
cannam@167 11009 if func_lalib_p "$file"; then
cannam@167 11010 func_source $dir/$name
cannam@167 11011
cannam@167 11012 # Delete the libtool libraries and symlinks.
cannam@167 11013 for n in $library_names; do
cannam@167 11014 func_append rmfiles " $odir/$n"
cannam@167 11015 done
cannam@167 11016 test -n "$old_library" && func_append rmfiles " $odir/$old_library"
cannam@167 11017
cannam@167 11018 case $opt_mode in
cannam@167 11019 clean)
cannam@167 11020 case " $library_names " in
cannam@167 11021 *" $dlname "*) ;;
cannam@167 11022 *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
cannam@167 11023 esac
cannam@167 11024 test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
cannam@167 11025 ;;
cannam@167 11026 uninstall)
cannam@167 11027 if test -n "$library_names"; then
cannam@167 11028 # Do each command in the postuninstall commands.
cannam@167 11029 func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
cannam@167 11030 fi
cannam@167 11031
cannam@167 11032 if test -n "$old_library"; then
cannam@167 11033 # Do each command in the old_postuninstall commands.
cannam@167 11034 func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
cannam@167 11035 fi
cannam@167 11036 # FIXME: should reinstall the best remaining shared library.
cannam@167 11037 ;;
cannam@167 11038 esac
cannam@167 11039 fi
cannam@167 11040 ;;
cannam@167 11041
cannam@167 11042 *.lo)
cannam@167 11043 # Possibly a libtool object, so verify it.
cannam@167 11044 if func_lalib_p "$file"; then
cannam@167 11045
cannam@167 11046 # Read the .lo file
cannam@167 11047 func_source $dir/$name
cannam@167 11048
cannam@167 11049 # Add PIC object to the list of files to remove.
cannam@167 11050 if test -n "$pic_object" && test none != "$pic_object"; then
cannam@167 11051 func_append rmfiles " $dir/$pic_object"
cannam@167 11052 fi
cannam@167 11053
cannam@167 11054 # Add non-PIC object to the list of files to remove.
cannam@167 11055 if test -n "$non_pic_object" && test none != "$non_pic_object"; then
cannam@167 11056 func_append rmfiles " $dir/$non_pic_object"
cannam@167 11057 fi
cannam@167 11058 fi
cannam@167 11059 ;;
cannam@167 11060
cannam@167 11061 *)
cannam@167 11062 if test clean = "$opt_mode"; then
cannam@167 11063 noexename=$name
cannam@167 11064 case $file in
cannam@167 11065 *.exe)
cannam@167 11066 func_stripname '' '.exe' "$file"
cannam@167 11067 file=$func_stripname_result
cannam@167 11068 func_stripname '' '.exe' "$name"
cannam@167 11069 noexename=$func_stripname_result
cannam@167 11070 # $file with .exe has already been added to rmfiles,
cannam@167 11071 # add $file without .exe
cannam@167 11072 func_append rmfiles " $file"
cannam@167 11073 ;;
cannam@167 11074 esac
cannam@167 11075 # Do a test to see if this is a libtool program.
cannam@167 11076 if func_ltwrapper_p "$file"; then
cannam@167 11077 if func_ltwrapper_executable_p "$file"; then
cannam@167 11078 func_ltwrapper_scriptname "$file"
cannam@167 11079 relink_command=
cannam@167 11080 func_source $func_ltwrapper_scriptname_result
cannam@167 11081 func_append rmfiles " $func_ltwrapper_scriptname_result"
cannam@167 11082 else
cannam@167 11083 relink_command=
cannam@167 11084 func_source $dir/$noexename
cannam@167 11085 fi
cannam@167 11086
cannam@167 11087 # note $name still contains .exe if it was in $file originally
cannam@167 11088 # as does the version of $file that was added into $rmfiles
cannam@167 11089 func_append rmfiles " $odir/$name $odir/${name}S.$objext"
cannam@167 11090 if test yes = "$fast_install" && test -n "$relink_command"; then
cannam@167 11091 func_append rmfiles " $odir/lt-$name"
cannam@167 11092 fi
cannam@167 11093 if test "X$noexename" != "X$name"; then
cannam@167 11094 func_append rmfiles " $odir/lt-$noexename.c"
cannam@167 11095 fi
cannam@167 11096 fi
cannam@167 11097 fi
cannam@167 11098 ;;
cannam@167 11099 esac
cannam@167 11100 func_show_eval "$RM $rmfiles" 'exit_status=1'
cannam@167 11101 done
cannam@167 11102
cannam@167 11103 # Try to remove the $objdir's in the directories where we deleted files
cannam@167 11104 for dir in $rmdirs; do
cannam@167 11105 if test -d "$dir"; then
cannam@167 11106 func_show_eval "rmdir $dir >/dev/null 2>&1"
cannam@167 11107 fi
cannam@167 11108 done
cannam@167 11109
cannam@167 11110 exit $exit_status
cannam@167 11111 }
cannam@167 11112
cannam@167 11113 if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
cannam@167 11114 func_mode_uninstall ${1+"$@"}
cannam@167 11115 fi
cannam@167 11116
cannam@167 11117 test -z "$opt_mode" && {
cannam@167 11118 help=$generic_help
cannam@167 11119 func_fatal_help "you must specify a MODE"
cannam@167 11120 }
cannam@167 11121
cannam@167 11122 test -z "$exec_cmd" && \
cannam@167 11123 func_fatal_help "invalid operation mode '$opt_mode'"
cannam@167 11124
cannam@167 11125 if test -n "$exec_cmd"; then
cannam@167 11126 eval exec "$exec_cmd"
cannam@167 11127 exit $EXIT_FAILURE
cannam@167 11128 fi
cannam@167 11129
cannam@167 11130 exit $exit_status
cannam@167 11131
cannam@167 11132
cannam@167 11133 # The TAGs below are defined such that we never get into a situation
cannam@167 11134 # where we disable both kinds of libraries. Given conflicting
cannam@167 11135 # choices, we go for a static library, that is the most portable,
cannam@167 11136 # since we can't tell whether shared libraries were disabled because
cannam@167 11137 # the user asked for that or because the platform doesn't support
cannam@167 11138 # them. This is particularly important on AIX, because we don't
cannam@167 11139 # support having both static and shared libraries enabled at the same
cannam@167 11140 # time on that platform, so we default to a shared-only configuration.
cannam@167 11141 # If a disable-shared tag is given, we'll fallback to a static-only
cannam@167 11142 # configuration. But we'll never go from static-only to shared-only.
cannam@167 11143
cannam@167 11144 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
cannam@167 11145 build_libtool_libs=no
cannam@167 11146 build_old_libs=yes
cannam@167 11147 # ### END LIBTOOL TAG CONFIG: disable-shared
cannam@167 11148
cannam@167 11149 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
cannam@167 11150 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
cannam@167 11151 # ### END LIBTOOL TAG CONFIG: disable-static
cannam@167 11152
cannam@167 11153 # Local Variables:
cannam@167 11154 # mode:shell-script
cannam@167 11155 # sh-indentation:2
cannam@167 11156 # End: