Mercurial > hgrepos > Python2 > PyMuPDF
comparison mupdf-source/thirdparty/lcms2/ltmain.sh @ 2:b50eed0cc0ef upstream
ADD: MuPDF v1.26.7: the MuPDF source as downloaded by a default build of PyMuPDF 1.26.4.
The directory name has changed: no version number in the expanded directory now.
| author | Franz Glasner <fzglas.hg@dom66.de> |
|---|---|
| date | Mon, 15 Sep 2025 11:43:07 +0200 |
| parents | |
| children |
comparison
equal
deleted
inserted
replaced
| 1:1d09e1dec1d9 | 2:b50eed0cc0ef |
|---|---|
| 1 #! /usr/bin/env sh | |
| 2 ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in | |
| 3 ## by inline-source v2019-02-19.15 | |
| 4 | |
| 5 # libtool (GNU libtool) 2.4.7 | |
| 6 # Provide generalized library-building support services. | |
| 7 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996 | |
| 8 | |
| 9 # Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. | |
| 10 # This is free software; see the source for copying conditions. There is NO | |
| 11 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 12 | |
| 13 # GNU Libtool is free software; you can redistribute it and/or modify | |
| 14 # it under the terms of the GNU General Public License as published by | |
| 15 # the Free Software Foundation; either version 2 of the License, or | |
| 16 # (at your option) any later version. | |
| 17 # | |
| 18 # As a special exception to the GNU General Public License, | |
| 19 # if you distribute this file as part of a program or library that | |
| 20 # is built using GNU Libtool, you may include this file under the | |
| 21 # same distribution terms that you use for the rest of that program. | |
| 22 # | |
| 23 # GNU Libtool is distributed in the hope that it will be useful, but | |
| 24 # WITHOUT ANY WARRANTY; without even the implied warranty of | |
| 25 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU | |
| 26 # General Public License for more details. | |
| 27 # | |
| 28 # You should have received a copy of the GNU General Public License | |
| 29 # along with this program. If not, see <http://www.gnu.org/licenses/>. | |
| 30 | |
| 31 | |
| 32 PROGRAM=libtool | |
| 33 PACKAGE=libtool | |
| 34 VERSION="2.4.7 Debian-2.4.7-5" | |
| 35 package_revision=2.4.7 | |
| 36 | |
| 37 | |
| 38 ## ------ ## | |
| 39 ## Usage. ## | |
| 40 ## ------ ## | |
| 41 | |
| 42 # Run './libtool --help' for help with using this script from the | |
| 43 # command line. | |
| 44 | |
| 45 | |
| 46 ## ------------------------------- ## | |
| 47 ## User overridable command paths. ## | |
| 48 ## ------------------------------- ## | |
| 49 | |
| 50 # After configure completes, it has a better idea of some of the | |
| 51 # shell tools we need than the defaults used by the functions shared | |
| 52 # with bootstrap, so set those here where they can still be over- | |
| 53 # ridden by the user, but otherwise take precedence. | |
| 54 | |
| 55 : ${AUTOCONF="autoconf"} | |
| 56 : ${AUTOMAKE="automake"} | |
| 57 | |
| 58 | |
| 59 ## -------------------------- ## | |
| 60 ## Source external libraries. ## | |
| 61 ## -------------------------- ## | |
| 62 | |
| 63 # Much of our low-level functionality needs to be sourced from external | |
| 64 # libraries, which are installed to $pkgauxdir. | |
| 65 | |
| 66 # Set a version string for this script. | |
| 67 scriptversion=2019-02-19.15; # UTC | |
| 68 | |
| 69 # General shell script boiler plate, and helper functions. | |
| 70 # Written by Gary V. Vaughan, 2004 | |
| 71 | |
| 72 # This is free software. There is NO warranty; not even for | |
| 73 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 74 # | |
| 75 # Copyright (C) 2004-2019, 2021 Bootstrap Authors | |
| 76 # | |
| 77 # This file is dual licensed under the terms of the MIT license | |
| 78 # <https://opensource.org/license/MIT>, and GPL version 2 or later | |
| 79 # <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of | |
| 80 # these licenses when using or redistributing this software or any of | |
| 81 # the files within it. See the URLs above, or the file `LICENSE` | |
| 82 # included in the Bootstrap distribution for the full license texts. | |
| 83 | |
| 84 # Please report bugs or propose patches to: | |
| 85 # <https://github.com/gnulib-modules/bootstrap/issues> | |
| 86 | |
| 87 | |
| 88 ## ------ ## | |
| 89 ## Usage. ## | |
| 90 ## ------ ## | |
| 91 | |
| 92 # Evaluate this file near the top of your script to gain access to | |
| 93 # the functions and variables defined here: | |
| 94 # | |
| 95 # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh | |
| 96 # | |
| 97 # If you need to override any of the default environment variable | |
| 98 # settings, do that before evaluating this file. | |
| 99 | |
| 100 | |
| 101 ## -------------------- ## | |
| 102 ## Shell normalisation. ## | |
| 103 ## -------------------- ## | |
| 104 | |
| 105 # Some shells need a little help to be as Bourne compatible as possible. | |
| 106 # Before doing anything else, make sure all that help has been provided! | |
| 107 | |
| 108 DUALCASE=1; export DUALCASE # for MKS sh | |
| 109 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : | |
| 110 emulate sh | |
| 111 NULLCMD=: | |
| 112 # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which | |
| 113 # is contrary to our usage. Disable this feature. | |
| 114 alias -g '${1+"$@"}'='"$@"' | |
| 115 setopt NO_GLOB_SUBST | |
| 116 else | |
| 117 case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac | |
| 118 fi | |
| 119 | |
| 120 # NLS nuisances: We save the old values in case they are required later. | |
| 121 _G_user_locale= | |
| 122 _G_safe_locale= | |
| 123 for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES | |
| 124 do | |
| 125 eval "if test set = \"\${$_G_var+set}\"; then | |
| 126 save_$_G_var=\$$_G_var | |
| 127 $_G_var=C | |
| 128 export $_G_var | |
| 129 _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" | |
| 130 _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" | |
| 131 fi" | |
| 132 done | |
| 133 # These NLS vars are set unconditionally (bootstrap issue #24). Unset those | |
| 134 # in case the environment reset is needed later and the $save_* variant is not | |
| 135 # defined (see the code above). | |
| 136 LC_ALL=C | |
| 137 LANGUAGE=C | |
| 138 export LANGUAGE LC_ALL | |
| 139 | |
| 140 # Make sure IFS has a sensible default | |
| 141 sp=' ' | |
| 142 nl=' | |
| 143 ' | |
| 144 IFS="$sp $nl" | |
| 145 | |
| 146 # There are apparently some retarded systems that use ';' as a PATH separator! | |
| 147 if test "${PATH_SEPARATOR+set}" != set; then | |
| 148 PATH_SEPARATOR=: | |
| 149 (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { | |
| 150 (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || | |
| 151 PATH_SEPARATOR=';' | |
| 152 } | |
| 153 fi | |
| 154 | |
| 155 | |
| 156 # func_unset VAR | |
| 157 # -------------- | |
| 158 # Portably unset VAR. | |
| 159 # In some shells, an 'unset VAR' statement leaves a non-zero return | |
| 160 # status if VAR is already unset, which might be problematic if the | |
| 161 # statement is used at the end of a function (thus poisoning its return | |
| 162 # value) or when 'set -e' is active (causing even a spurious abort of | |
| 163 # the script in this case). | |
| 164 func_unset () | |
| 165 { | |
| 166 { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } | |
| 167 } | |
| 168 | |
| 169 | |
| 170 # Make sure CDPATH doesn't cause `cd` commands to output the target dir. | |
| 171 func_unset CDPATH | |
| 172 | |
| 173 # Make sure ${,E,F}GREP behave sanely. | |
| 174 func_unset GREP_OPTIONS | |
| 175 | |
| 176 | |
| 177 ## ------------------------- ## | |
| 178 ## Locate command utilities. ## | |
| 179 ## ------------------------- ## | |
| 180 | |
| 181 | |
| 182 # func_executable_p FILE | |
| 183 # ---------------------- | |
| 184 # Check that FILE is an executable regular file. | |
| 185 func_executable_p () | |
| 186 { | |
| 187 test -f "$1" && test -x "$1" | |
| 188 } | |
| 189 | |
| 190 | |
| 191 # func_path_progs PROGS_LIST CHECK_FUNC [PATH] | |
| 192 # -------------------------------------------- | |
| 193 # Search for either a program that responds to --version with output | |
| 194 # containing "GNU", or else returned by CHECK_FUNC otherwise, by | |
| 195 # trying all the directories in PATH with each of the elements of | |
| 196 # PROGS_LIST. | |
| 197 # | |
| 198 # CHECK_FUNC should accept the path to a candidate program, and | |
| 199 # set $func_check_prog_result if it truncates its output less than | |
| 200 # $_G_path_prog_max characters. | |
| 201 func_path_progs () | |
| 202 { | |
| 203 _G_progs_list=$1 | |
| 204 _G_check_func=$2 | |
| 205 _G_PATH=${3-"$PATH"} | |
| 206 | |
| 207 _G_path_prog_max=0 | |
| 208 _G_path_prog_found=false | |
| 209 _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} | |
| 210 for _G_dir in $_G_PATH; do | |
| 211 IFS=$_G_save_IFS | |
| 212 test -z "$_G_dir" && _G_dir=. | |
| 213 for _G_prog_name in $_G_progs_list; do | |
| 214 for _exeext in '' .EXE; do | |
| 215 _G_path_prog=$_G_dir/$_G_prog_name$_exeext | |
| 216 func_executable_p "$_G_path_prog" || continue | |
| 217 case `"$_G_path_prog" --version 2>&1` in | |
| 218 *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; | |
| 219 *) $_G_check_func $_G_path_prog | |
| 220 func_path_progs_result=$func_check_prog_result | |
| 221 ;; | |
| 222 esac | |
| 223 $_G_path_prog_found && break 3 | |
| 224 done | |
| 225 done | |
| 226 done | |
| 227 IFS=$_G_save_IFS | |
| 228 test -z "$func_path_progs_result" && { | |
| 229 echo "no acceptable sed could be found in \$PATH" >&2 | |
| 230 exit 1 | |
| 231 } | |
| 232 } | |
| 233 | |
| 234 | |
| 235 # We want to be able to use the functions in this file before configure | |
| 236 # has figured out where the best binaries are kept, which means we have | |
| 237 # to search for them ourselves - except when the results are already set | |
| 238 # where we skip the searches. | |
| 239 | |
| 240 # Unless the user overrides by setting SED, search the path for either GNU | |
| 241 # sed, or the sed that truncates its output the least. | |
| 242 test -z "$SED" && { | |
| 243 _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ | |
| 244 for _G_i in 1 2 3 4 5 6 7; do | |
| 245 _G_sed_script=$_G_sed_script$nl$_G_sed_script | |
| 246 done | |
| 247 echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed | |
| 248 _G_sed_script= | |
| 249 | |
| 250 func_check_prog_sed () | |
| 251 { | |
| 252 _G_path_prog=$1 | |
| 253 | |
| 254 _G_count=0 | |
| 255 printf 0123456789 >conftest.in | |
| 256 while : | |
| 257 do | |
| 258 cat conftest.in conftest.in >conftest.tmp | |
| 259 mv conftest.tmp conftest.in | |
| 260 cp conftest.in conftest.nl | |
| 261 echo '' >> conftest.nl | |
| 262 "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break | |
| 263 diff conftest.out conftest.nl >/dev/null 2>&1 || break | |
| 264 _G_count=`expr $_G_count + 1` | |
| 265 if test "$_G_count" -gt "$_G_path_prog_max"; then | |
| 266 # Best one so far, save it but keep looking for a better one | |
| 267 func_check_prog_result=$_G_path_prog | |
| 268 _G_path_prog_max=$_G_count | |
| 269 fi | |
| 270 # 10*(2^10) chars as input seems more than enough | |
| 271 test 10 -lt "$_G_count" && break | |
| 272 done | |
| 273 rm -f conftest.in conftest.tmp conftest.nl conftest.out | |
| 274 } | |
| 275 | |
| 276 func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" | |
| 277 rm -f conftest.sed | |
| 278 SED=$func_path_progs_result | |
| 279 } | |
| 280 | |
| 281 | |
| 282 # Unless the user overrides by setting GREP, search the path for either GNU | |
| 283 # grep, or the grep that truncates its output the least. | |
| 284 test -z "$GREP" && { | |
| 285 func_check_prog_grep () | |
| 286 { | |
| 287 _G_path_prog=$1 | |
| 288 | |
| 289 _G_count=0 | |
| 290 _G_path_prog_max=0 | |
| 291 printf 0123456789 >conftest.in | |
| 292 while : | |
| 293 do | |
| 294 cat conftest.in conftest.in >conftest.tmp | |
| 295 mv conftest.tmp conftest.in | |
| 296 cp conftest.in conftest.nl | |
| 297 echo 'GREP' >> conftest.nl | |
| 298 "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break | |
| 299 diff conftest.out conftest.nl >/dev/null 2>&1 || break | |
| 300 _G_count=`expr $_G_count + 1` | |
| 301 if test "$_G_count" -gt "$_G_path_prog_max"; then | |
| 302 # Best one so far, save it but keep looking for a better one | |
| 303 func_check_prog_result=$_G_path_prog | |
| 304 _G_path_prog_max=$_G_count | |
| 305 fi | |
| 306 # 10*(2^10) chars as input seems more than enough | |
| 307 test 10 -lt "$_G_count" && break | |
| 308 done | |
| 309 rm -f conftest.in conftest.tmp conftest.nl conftest.out | |
| 310 } | |
| 311 | |
| 312 func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" | |
| 313 GREP=$func_path_progs_result | |
| 314 } | |
| 315 | |
| 316 | |
| 317 ## ------------------------------- ## | |
| 318 ## User overridable command paths. ## | |
| 319 ## ------------------------------- ## | |
| 320 | |
| 321 # All uppercase variable names are used for environment variables. These | |
| 322 # variables can be overridden by the user before calling a script that | |
| 323 # uses them if a suitable command of that name is not already available | |
| 324 # in the command search PATH. | |
| 325 | |
| 326 : ${CP="cp -f"} | |
| 327 : ${ECHO="printf %s\n"} | |
| 328 : ${EGREP="$GREP -E"} | |
| 329 : ${FGREP="$GREP -F"} | |
| 330 : ${LN_S="ln -s"} | |
| 331 : ${MAKE="make"} | |
| 332 : ${MKDIR="mkdir"} | |
| 333 : ${MV="mv -f"} | |
| 334 : ${RM="rm -f"} | |
| 335 : ${SHELL="${CONFIG_SHELL-/bin/sh}"} | |
| 336 | |
| 337 | |
| 338 ## -------------------- ## | |
| 339 ## Useful sed snippets. ## | |
| 340 ## -------------------- ## | |
| 341 | |
| 342 sed_dirname='s|/[^/]*$||' | |
| 343 sed_basename='s|^.*/||' | |
| 344 | |
| 345 # Sed substitution that helps us do robust quoting. It backslashifies | |
| 346 # metacharacters that are still active within double-quoted strings. | |
| 347 sed_quote_subst='s|\([`"$\\]\)|\\\1|g' | |
| 348 | |
| 349 # Same as above, but do not quote variable references. | |
| 350 sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' | |
| 351 | |
| 352 # Sed substitution that turns a string into a regex matching for the | |
| 353 # string literally. | |
| 354 sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' | |
| 355 | |
| 356 # Sed substitution that converts a w32 file name or path | |
| 357 # that contains forward slashes, into one that contains | |
| 358 # (escaped) backslashes. A very naive implementation. | |
| 359 sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' | |
| 360 | |
| 361 # Re-'\' parameter expansions in output of sed_double_quote_subst that | |
| 362 # were '\'-ed in input to the same. If an odd number of '\' preceded a | |
| 363 # '$' in input to sed_double_quote_subst, that '$' was protected from | |
| 364 # expansion. Since each input '\' is now two '\'s, look for any number | |
| 365 # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. | |
| 366 _G_bs='\\' | |
| 367 _G_bs2='\\\\' | |
| 368 _G_bs4='\\\\\\\\' | |
| 369 _G_dollar='\$' | |
| 370 sed_double_backslash="\ | |
| 371 s/$_G_bs4/&\\ | |
| 372 /g | |
| 373 s/^$_G_bs2$_G_dollar/$_G_bs&/ | |
| 374 s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g | |
| 375 s/\n//g" | |
| 376 | |
| 377 # require_check_ifs_backslash | |
| 378 # --------------------------- | |
| 379 # Check if we can use backslash as IFS='\' separator, and set | |
| 380 # $check_ifs_backshlash_broken to ':' or 'false'. | |
| 381 require_check_ifs_backslash=func_require_check_ifs_backslash | |
| 382 func_require_check_ifs_backslash () | |
| 383 { | |
| 384 _G_save_IFS=$IFS | |
| 385 IFS='\' | |
| 386 _G_check_ifs_backshlash='a\\b' | |
| 387 for _G_i in $_G_check_ifs_backshlash | |
| 388 do | |
| 389 case $_G_i in | |
| 390 a) | |
| 391 check_ifs_backshlash_broken=false | |
| 392 ;; | |
| 393 '') | |
| 394 break | |
| 395 ;; | |
| 396 *) | |
| 397 check_ifs_backshlash_broken=: | |
| 398 break | |
| 399 ;; | |
| 400 esac | |
| 401 done | |
| 402 IFS=$_G_save_IFS | |
| 403 require_check_ifs_backslash=: | |
| 404 } | |
| 405 | |
| 406 | |
| 407 ## ----------------- ## | |
| 408 ## Global variables. ## | |
| 409 ## ----------------- ## | |
| 410 | |
| 411 # Except for the global variables explicitly listed below, the following | |
| 412 # functions in the '^func_' namespace, and the '^require_' namespace | |
| 413 # variables initialised in the 'Resource management' section, sourcing | |
| 414 # this file will not pollute your global namespace with anything | |
| 415 # else. There's no portable way to scope variables in Bourne shell | |
| 416 # though, so actually running these functions will sometimes place | |
| 417 # results into a variable named after the function, and often use | |
| 418 # temporary variables in the '^_G_' namespace. If you are careful to | |
| 419 # avoid using those namespaces casually in your sourcing script, things | |
| 420 # should continue to work as you expect. And, of course, you can freely | |
| 421 # overwrite any of the functions or variables defined here before | |
| 422 # calling anything to customize them. | |
| 423 | |
| 424 EXIT_SUCCESS=0 | |
| 425 EXIT_FAILURE=1 | |
| 426 EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. | |
| 427 EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. | |
| 428 | |
| 429 # Allow overriding, eg assuming that you follow the convention of | |
| 430 # putting '$debug_cmd' at the start of all your functions, you can get | |
| 431 # bash to show function call trace with: | |
| 432 # | |
| 433 # debug_cmd='echo "${FUNCNAME[0]} $*" >&2' bash your-script-name | |
| 434 debug_cmd=${debug_cmd-":"} | |
| 435 exit_cmd=: | |
| 436 | |
| 437 # By convention, finish your script with: | |
| 438 # | |
| 439 # exit $exit_status | |
| 440 # | |
| 441 # so that you can set exit_status to non-zero if you want to indicate | |
| 442 # something went wrong during execution without actually bailing out at | |
| 443 # the point of failure. | |
| 444 exit_status=$EXIT_SUCCESS | |
| 445 | |
| 446 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh | |
| 447 # is ksh but when the shell is invoked as "sh" and the current value of | |
| 448 # the _XPG environment variable is not equal to 1 (one), the special | |
| 449 # positional parameter $0, within a function call, is the name of the | |
| 450 # function. | |
| 451 progpath=$0 | |
| 452 | |
| 453 # The name of this program. | |
| 454 progname=`$ECHO "$progpath" |$SED "$sed_basename"` | |
| 455 | |
| 456 # Make sure we have an absolute progpath for reexecution: | |
| 457 case $progpath in | |
| 458 [\\/]*|[A-Za-z]:\\*) ;; | |
| 459 *[\\/]*) | |
| 460 progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` | |
| 461 progdir=`cd "$progdir" && pwd` | |
| 462 progpath=$progdir/$progname | |
| 463 ;; | |
| 464 *) | |
| 465 _G_IFS=$IFS | |
| 466 IFS=${PATH_SEPARATOR-:} | |
| 467 for progdir in $PATH; do | |
| 468 IFS=$_G_IFS | |
| 469 test -x "$progdir/$progname" && break | |
| 470 done | |
| 471 IFS=$_G_IFS | |
| 472 test -n "$progdir" || progdir=`pwd` | |
| 473 progpath=$progdir/$progname | |
| 474 ;; | |
| 475 esac | |
| 476 | |
| 477 | |
| 478 ## ----------------- ## | |
| 479 ## Standard options. ## | |
| 480 ## ----------------- ## | |
| 481 | |
| 482 # The following options affect the operation of the functions defined | |
| 483 # below, and should be set appropriately depending on run-time para- | |
| 484 # meters passed on the command line. | |
| 485 | |
| 486 opt_dry_run=false | |
| 487 opt_quiet=false | |
| 488 opt_verbose=false | |
| 489 | |
| 490 # Categories 'all' and 'none' are always available. Append any others | |
| 491 # you will pass as the first argument to func_warning from your own | |
| 492 # code. | |
| 493 warning_categories= | |
| 494 | |
| 495 # By default, display warnings according to 'opt_warning_types'. Set | |
| 496 # 'warning_func' to ':' to elide all warnings, or func_fatal_error to | |
| 497 # treat the next displayed warning as a fatal error. | |
| 498 warning_func=func_warn_and_continue | |
| 499 | |
| 500 # Set to 'all' to display all warnings, 'none' to suppress all | |
| 501 # warnings, or a space delimited list of some subset of | |
| 502 # 'warning_categories' to display only the listed warnings. | |
| 503 opt_warning_types=all | |
| 504 | |
| 505 | |
| 506 ## -------------------- ## | |
| 507 ## Resource management. ## | |
| 508 ## -------------------- ## | |
| 509 | |
| 510 # This section contains definitions for functions that each ensure a | |
| 511 # particular resource (a file, or a non-empty configuration variable for | |
| 512 # example) is available, and if appropriate to extract default values | |
| 513 # from pertinent package files. Call them using their associated | |
| 514 # 'require_*' variable to ensure that they are executed, at most, once. | |
| 515 # | |
| 516 # It's entirely deliberate that calling these functions can set | |
| 517 # variables that don't obey the namespace limitations obeyed by the rest | |
| 518 # of this file, in order that that they be as useful as possible to | |
| 519 # callers. | |
| 520 | |
| 521 | |
| 522 # require_term_colors | |
| 523 # ------------------- | |
| 524 # Allow display of bold text on terminals that support it. | |
| 525 require_term_colors=func_require_term_colors | |
| 526 func_require_term_colors () | |
| 527 { | |
| 528 $debug_cmd | |
| 529 | |
| 530 test -t 1 && { | |
| 531 # COLORTERM and USE_ANSI_COLORS environment variables take | |
| 532 # precedence, because most terminfo databases neglect to describe | |
| 533 # whether color sequences are supported. | |
| 534 test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} | |
| 535 | |
| 536 if test 1 = "$USE_ANSI_COLORS"; then | |
| 537 # Standard ANSI escape sequences | |
| 538 tc_reset='[0m' | |
| 539 tc_bold='[1m'; tc_standout='[7m' | |
| 540 tc_red='[31m'; tc_green='[32m' | |
| 541 tc_blue='[34m'; tc_cyan='[36m' | |
| 542 else | |
| 543 # Otherwise trust the terminfo database after all. | |
| 544 test -n "`tput sgr0 2>/dev/null`" && { | |
| 545 tc_reset=`tput sgr0` | |
| 546 test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` | |
| 547 tc_standout=$tc_bold | |
| 548 test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` | |
| 549 test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` | |
| 550 test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` | |
| 551 test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` | |
| 552 test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` | |
| 553 } | |
| 554 fi | |
| 555 } | |
| 556 | |
| 557 require_term_colors=: | |
| 558 } | |
| 559 | |
| 560 | |
| 561 ## ----------------- ## | |
| 562 ## Function library. ## | |
| 563 ## ----------------- ## | |
| 564 | |
| 565 # This section contains a variety of useful functions to call in your | |
| 566 # scripts. Take note of the portable wrappers for features provided by | |
| 567 # some modern shells, which will fall back to slower equivalents on | |
| 568 # less featureful shells. | |
| 569 | |
| 570 | |
| 571 # func_append VAR VALUE | |
| 572 # --------------------- | |
| 573 # Append VALUE onto the existing contents of VAR. | |
| 574 | |
| 575 # We should try to minimise forks, especially on Windows where they are | |
| 576 # unreasonably slow, so skip the feature probes when bash or zsh are | |
| 577 # being used: | |
| 578 if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then | |
| 579 : ${_G_HAVE_ARITH_OP="yes"} | |
| 580 : ${_G_HAVE_XSI_OPS="yes"} | |
| 581 # The += operator was introduced in bash 3.1 | |
| 582 case $BASH_VERSION in | |
| 583 [12].* | 3.0 | 3.0*) ;; | |
| 584 *) | |
| 585 : ${_G_HAVE_PLUSEQ_OP="yes"} | |
| 586 ;; | |
| 587 esac | |
| 588 fi | |
| 589 | |
| 590 # _G_HAVE_PLUSEQ_OP | |
| 591 # Can be empty, in which case the shell is probed, "yes" if += is | |
| 592 # useable or anything else if it does not work. | |
| 593 test -z "$_G_HAVE_PLUSEQ_OP" \ | |
| 594 && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ | |
| 595 && _G_HAVE_PLUSEQ_OP=yes | |
| 596 | |
| 597 if test yes = "$_G_HAVE_PLUSEQ_OP" | |
| 598 then | |
| 599 # This is an XSI compatible shell, allowing a faster implementation... | |
| 600 eval 'func_append () | |
| 601 { | |
| 602 $debug_cmd | |
| 603 | |
| 604 eval "$1+=\$2" | |
| 605 }' | |
| 606 else | |
| 607 # ...otherwise fall back to using expr, which is often a shell builtin. | |
| 608 func_append () | |
| 609 { | |
| 610 $debug_cmd | |
| 611 | |
| 612 eval "$1=\$$1\$2" | |
| 613 } | |
| 614 fi | |
| 615 | |
| 616 | |
| 617 # func_append_quoted VAR VALUE | |
| 618 # ---------------------------- | |
| 619 # Quote VALUE and append to the end of shell variable VAR, separated | |
| 620 # by a space. | |
| 621 if test yes = "$_G_HAVE_PLUSEQ_OP"; then | |
| 622 eval 'func_append_quoted () | |
| 623 { | |
| 624 $debug_cmd | |
| 625 | |
| 626 func_quote_arg pretty "$2" | |
| 627 eval "$1+=\\ \$func_quote_arg_result" | |
| 628 }' | |
| 629 else | |
| 630 func_append_quoted () | |
| 631 { | |
| 632 $debug_cmd | |
| 633 | |
| 634 func_quote_arg pretty "$2" | |
| 635 eval "$1=\$$1\\ \$func_quote_arg_result" | |
| 636 } | |
| 637 fi | |
| 638 | |
| 639 | |
| 640 # func_append_uniq VAR VALUE | |
| 641 # -------------------------- | |
| 642 # Append unique VALUE onto the existing contents of VAR, assuming | |
| 643 # entries are delimited by the first character of VALUE. For example: | |
| 644 # | |
| 645 # func_append_uniq options " --another-option option-argument" | |
| 646 # | |
| 647 # will only append to $options if " --another-option option-argument " | |
| 648 # is not already present somewhere in $options already (note spaces at | |
| 649 # each end implied by leading space in second argument). | |
| 650 func_append_uniq () | |
| 651 { | |
| 652 $debug_cmd | |
| 653 | |
| 654 eval _G_current_value='`$ECHO $'$1'`' | |
| 655 _G_delim=`expr "$2" : '\(.\)'` | |
| 656 | |
| 657 case $_G_delim$_G_current_value$_G_delim in | |
| 658 *"$2$_G_delim"*) ;; | |
| 659 *) func_append "$@" ;; | |
| 660 esac | |
| 661 } | |
| 662 | |
| 663 | |
| 664 # func_arith TERM... | |
| 665 # ------------------ | |
| 666 # Set func_arith_result to the result of evaluating TERMs. | |
| 667 test -z "$_G_HAVE_ARITH_OP" \ | |
| 668 && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ | |
| 669 && _G_HAVE_ARITH_OP=yes | |
| 670 | |
| 671 if test yes = "$_G_HAVE_ARITH_OP"; then | |
| 672 eval 'func_arith () | |
| 673 { | |
| 674 $debug_cmd | |
| 675 | |
| 676 func_arith_result=$(( $* )) | |
| 677 }' | |
| 678 else | |
| 679 func_arith () | |
| 680 { | |
| 681 $debug_cmd | |
| 682 | |
| 683 func_arith_result=`expr "$@"` | |
| 684 } | |
| 685 fi | |
| 686 | |
| 687 | |
| 688 # func_basename FILE | |
| 689 # ------------------ | |
| 690 # Set func_basename_result to FILE with everything up to and including | |
| 691 # the last / stripped. | |
| 692 if test yes = "$_G_HAVE_XSI_OPS"; then | |
| 693 # If this shell supports suffix pattern removal, then use it to avoid | |
| 694 # forking. Hide the definitions single quotes in case the shell chokes | |
| 695 # on unsupported syntax... | |
| 696 _b='func_basename_result=${1##*/}' | |
| 697 _d='case $1 in | |
| 698 */*) func_dirname_result=${1%/*}$2 ;; | |
| 699 * ) func_dirname_result=$3 ;; | |
| 700 esac' | |
| 701 | |
| 702 else | |
| 703 # ...otherwise fall back to using sed. | |
| 704 _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' | |
| 705 _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` | |
| 706 if test "X$func_dirname_result" = "X$1"; then | |
| 707 func_dirname_result=$3 | |
| 708 else | |
| 709 func_append func_dirname_result "$2" | |
| 710 fi' | |
| 711 fi | |
| 712 | |
| 713 eval 'func_basename () | |
| 714 { | |
| 715 $debug_cmd | |
| 716 | |
| 717 '"$_b"' | |
| 718 }' | |
| 719 | |
| 720 | |
| 721 # func_dirname FILE APPEND NONDIR_REPLACEMENT | |
| 722 # ------------------------------------------- | |
| 723 # Compute the dirname of FILE. If nonempty, add APPEND to the result, | |
| 724 # otherwise set result to NONDIR_REPLACEMENT. | |
| 725 eval 'func_dirname () | |
| 726 { | |
| 727 $debug_cmd | |
| 728 | |
| 729 '"$_d"' | |
| 730 }' | |
| 731 | |
| 732 | |
| 733 # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT | |
| 734 # -------------------------------------------------------- | |
| 735 # Perform func_basename and func_dirname in a single function | |
| 736 # call: | |
| 737 # dirname: Compute the dirname of FILE. If nonempty, | |
| 738 # add APPEND to the result, otherwise set result | |
| 739 # to NONDIR_REPLACEMENT. | |
| 740 # value returned in "$func_dirname_result" | |
| 741 # basename: Compute filename of FILE. | |
| 742 # value retuned in "$func_basename_result" | |
| 743 # For efficiency, we do not delegate to the functions above but instead | |
| 744 # duplicate the functionality here. | |
| 745 eval 'func_dirname_and_basename () | |
| 746 { | |
| 747 $debug_cmd | |
| 748 | |
| 749 '"$_b"' | |
| 750 '"$_d"' | |
| 751 }' | |
| 752 | |
| 753 | |
| 754 # func_echo ARG... | |
| 755 # ---------------- | |
| 756 # Echo program name prefixed message. | |
| 757 func_echo () | |
| 758 { | |
| 759 $debug_cmd | |
| 760 | |
| 761 _G_message=$* | |
| 762 | |
| 763 func_echo_IFS=$IFS | |
| 764 IFS=$nl | |
| 765 for _G_line in $_G_message; do | |
| 766 IFS=$func_echo_IFS | |
| 767 $ECHO "$progname: $_G_line" | |
| 768 done | |
| 769 IFS=$func_echo_IFS | |
| 770 } | |
| 771 | |
| 772 | |
| 773 # func_echo_all ARG... | |
| 774 # -------------------- | |
| 775 # Invoke $ECHO with all args, space-separated. | |
| 776 func_echo_all () | |
| 777 { | |
| 778 $ECHO "$*" | |
| 779 } | |
| 780 | |
| 781 | |
| 782 # func_echo_infix_1 INFIX ARG... | |
| 783 # ------------------------------ | |
| 784 # Echo program name, followed by INFIX on the first line, with any | |
| 785 # additional lines not showing INFIX. | |
| 786 func_echo_infix_1 () | |
| 787 { | |
| 788 $debug_cmd | |
| 789 | |
| 790 $require_term_colors | |
| 791 | |
| 792 _G_infix=$1; shift | |
| 793 _G_indent=$_G_infix | |
| 794 _G_prefix="$progname: $_G_infix: " | |
| 795 _G_message=$* | |
| 796 | |
| 797 # Strip color escape sequences before counting printable length | |
| 798 for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" | |
| 799 do | |
| 800 test -n "$_G_tc" && { | |
| 801 _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` | |
| 802 _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` | |
| 803 } | |
| 804 done | |
| 805 _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes | |
| 806 | |
| 807 func_echo_infix_1_IFS=$IFS | |
| 808 IFS=$nl | |
| 809 for _G_line in $_G_message; do | |
| 810 IFS=$func_echo_infix_1_IFS | |
| 811 $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 | |
| 812 _G_prefix=$_G_indent | |
| 813 done | |
| 814 IFS=$func_echo_infix_1_IFS | |
| 815 } | |
| 816 | |
| 817 | |
| 818 # func_error ARG... | |
| 819 # ----------------- | |
| 820 # Echo program name prefixed message to standard error. | |
| 821 func_error () | |
| 822 { | |
| 823 $debug_cmd | |
| 824 | |
| 825 $require_term_colors | |
| 826 | |
| 827 func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 | |
| 828 } | |
| 829 | |
| 830 | |
| 831 # func_fatal_error ARG... | |
| 832 # ----------------------- | |
| 833 # Echo program name prefixed message to standard error, and exit. | |
| 834 func_fatal_error () | |
| 835 { | |
| 836 $debug_cmd | |
| 837 | |
| 838 func_error "$*" | |
| 839 exit $EXIT_FAILURE | |
| 840 } | |
| 841 | |
| 842 | |
| 843 # func_grep EXPRESSION FILENAME | |
| 844 # ----------------------------- | |
| 845 # Check whether EXPRESSION matches any line of FILENAME, without output. | |
| 846 func_grep () | |
| 847 { | |
| 848 $debug_cmd | |
| 849 | |
| 850 $GREP "$1" "$2" >/dev/null 2>&1 | |
| 851 } | |
| 852 | |
| 853 | |
| 854 # func_len STRING | |
| 855 # --------------- | |
| 856 # Set func_len_result to the length of STRING. STRING may not | |
| 857 # start with a hyphen. | |
| 858 test -z "$_G_HAVE_XSI_OPS" \ | |
| 859 && (eval 'x=a/b/c; | |
| 860 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ | |
| 861 && _G_HAVE_XSI_OPS=yes | |
| 862 | |
| 863 if test yes = "$_G_HAVE_XSI_OPS"; then | |
| 864 eval 'func_len () | |
| 865 { | |
| 866 $debug_cmd | |
| 867 | |
| 868 func_len_result=${#1} | |
| 869 }' | |
| 870 else | |
| 871 func_len () | |
| 872 { | |
| 873 $debug_cmd | |
| 874 | |
| 875 func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` | |
| 876 } | |
| 877 fi | |
| 878 | |
| 879 | |
| 880 # func_mkdir_p DIRECTORY-PATH | |
| 881 # --------------------------- | |
| 882 # Make sure the entire path to DIRECTORY-PATH is available. | |
| 883 func_mkdir_p () | |
| 884 { | |
| 885 $debug_cmd | |
| 886 | |
| 887 _G_directory_path=$1 | |
| 888 _G_dir_list= | |
| 889 | |
| 890 if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then | |
| 891 | |
| 892 # Protect directory names starting with '-' | |
| 893 case $_G_directory_path in | |
| 894 -*) _G_directory_path=./$_G_directory_path ;; | |
| 895 esac | |
| 896 | |
| 897 # While some portion of DIR does not yet exist... | |
| 898 while test ! -d "$_G_directory_path"; do | |
| 899 # ...make a list in topmost first order. Use a colon delimited | |
| 900 # list incase some portion of path contains whitespace. | |
| 901 _G_dir_list=$_G_directory_path:$_G_dir_list | |
| 902 | |
| 903 # If the last portion added has no slash in it, the list is done | |
| 904 case $_G_directory_path in */*) ;; *) break ;; esac | |
| 905 | |
| 906 # ...otherwise throw away the child directory and loop | |
| 907 _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` | |
| 908 done | |
| 909 _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` | |
| 910 | |
| 911 func_mkdir_p_IFS=$IFS; IFS=: | |
| 912 for _G_dir in $_G_dir_list; do | |
| 913 IFS=$func_mkdir_p_IFS | |
| 914 # mkdir can fail with a 'File exist' error if two processes | |
| 915 # try to create one of the directories concurrently. Don't | |
| 916 # stop in that case! | |
| 917 $MKDIR "$_G_dir" 2>/dev/null || : | |
| 918 done | |
| 919 IFS=$func_mkdir_p_IFS | |
| 920 | |
| 921 # Bail out if we (or some other process) failed to create a directory. | |
| 922 test -d "$_G_directory_path" || \ | |
| 923 func_fatal_error "Failed to create '$1'" | |
| 924 fi | |
| 925 } | |
| 926 | |
| 927 | |
| 928 # func_mktempdir [BASENAME] | |
| 929 # ------------------------- | |
| 930 # Make a temporary directory that won't clash with other running | |
| 931 # libtool processes, and avoids race conditions if possible. If | |
| 932 # given, BASENAME is the basename for that directory. | |
| 933 func_mktempdir () | |
| 934 { | |
| 935 $debug_cmd | |
| 936 | |
| 937 _G_template=${TMPDIR-/tmp}/${1-$progname} | |
| 938 | |
| 939 if test : = "$opt_dry_run"; then | |
| 940 # Return a directory name, but don't create it in dry-run mode | |
| 941 _G_tmpdir=$_G_template-$$ | |
| 942 else | |
| 943 | |
| 944 # If mktemp works, use that first and foremost | |
| 945 _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` | |
| 946 | |
| 947 if test ! -d "$_G_tmpdir"; then | |
| 948 # Failing that, at least try and use $RANDOM to avoid a race | |
| 949 _G_tmpdir=$_G_template-${RANDOM-0}$$ | |
| 950 | |
| 951 func_mktempdir_umask=`umask` | |
| 952 umask 0077 | |
| 953 $MKDIR "$_G_tmpdir" | |
| 954 umask $func_mktempdir_umask | |
| 955 fi | |
| 956 | |
| 957 # If we're not in dry-run mode, bomb out on failure | |
| 958 test -d "$_G_tmpdir" || \ | |
| 959 func_fatal_error "cannot create temporary directory '$_G_tmpdir'" | |
| 960 fi | |
| 961 | |
| 962 $ECHO "$_G_tmpdir" | |
| 963 } | |
| 964 | |
| 965 | |
| 966 # func_normal_abspath PATH | |
| 967 # ------------------------ | |
| 968 # Remove doubled-up and trailing slashes, "." path components, | |
| 969 # and cancel out any ".." path components in PATH after making | |
| 970 # it an absolute path. | |
| 971 func_normal_abspath () | |
| 972 { | |
| 973 $debug_cmd | |
| 974 | |
| 975 # These SED scripts presuppose an absolute path with a trailing slash. | |
| 976 _G_pathcar='s|^/\([^/]*\).*$|\1|' | |
| 977 _G_pathcdr='s|^/[^/]*||' | |
| 978 _G_removedotparts=':dotsl | |
| 979 s|/\./|/|g | |
| 980 t dotsl | |
| 981 s|/\.$|/|' | |
| 982 _G_collapseslashes='s|/\{1,\}|/|g' | |
| 983 _G_finalslash='s|/*$|/|' | |
| 984 | |
| 985 # Start from root dir and reassemble the path. | |
| 986 func_normal_abspath_result= | |
| 987 func_normal_abspath_tpath=$1 | |
| 988 func_normal_abspath_altnamespace= | |
| 989 case $func_normal_abspath_tpath in | |
| 990 "") | |
| 991 # Empty path, that just means $cwd. | |
| 992 func_stripname '' '/' "`pwd`" | |
| 993 func_normal_abspath_result=$func_stripname_result | |
| 994 return | |
| 995 ;; | |
| 996 # The next three entries are used to spot a run of precisely | |
| 997 # two leading slashes without using negated character classes; | |
| 998 # we take advantage of case's first-match behaviour. | |
| 999 ///*) | |
| 1000 # Unusual form of absolute path, do nothing. | |
| 1001 ;; | |
| 1002 //*) | |
| 1003 # Not necessarily an ordinary path; POSIX reserves leading '//' | |
| 1004 # and for example Cygwin uses it to access remote file shares | |
| 1005 # over CIFS/SMB, so we conserve a leading double slash if found. | |
| 1006 func_normal_abspath_altnamespace=/ | |
| 1007 ;; | |
| 1008 /*) | |
| 1009 # Absolute path, do nothing. | |
| 1010 ;; | |
| 1011 *) | |
| 1012 # Relative path, prepend $cwd. | |
| 1013 func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath | |
| 1014 ;; | |
| 1015 esac | |
| 1016 | |
| 1017 # Cancel out all the simple stuff to save iterations. We also want | |
| 1018 # the path to end with a slash for ease of parsing, so make sure | |
| 1019 # there is one (and only one) here. | |
| 1020 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ | |
| 1021 -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` | |
| 1022 while :; do | |
| 1023 # Processed it all yet? | |
| 1024 if test / = "$func_normal_abspath_tpath"; then | |
| 1025 # If we ascended to the root using ".." the result may be empty now. | |
| 1026 if test -z "$func_normal_abspath_result"; then | |
| 1027 func_normal_abspath_result=/ | |
| 1028 fi | |
| 1029 break | |
| 1030 fi | |
| 1031 func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ | |
| 1032 -e "$_G_pathcar"` | |
| 1033 func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ | |
| 1034 -e "$_G_pathcdr"` | |
| 1035 # Figure out what to do with it | |
| 1036 case $func_normal_abspath_tcomponent in | |
| 1037 "") | |
| 1038 # Trailing empty path component, ignore it. | |
| 1039 ;; | |
| 1040 ..) | |
| 1041 # Parent dir; strip last assembled component from result. | |
| 1042 func_dirname "$func_normal_abspath_result" | |
| 1043 func_normal_abspath_result=$func_dirname_result | |
| 1044 ;; | |
| 1045 *) | |
| 1046 # Actual path component, append it. | |
| 1047 func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" | |
| 1048 ;; | |
| 1049 esac | |
| 1050 done | |
| 1051 # Restore leading double-slash if one was found on entry. | |
| 1052 func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result | |
| 1053 } | |
| 1054 | |
| 1055 | |
| 1056 # func_notquiet ARG... | |
| 1057 # -------------------- | |
| 1058 # Echo program name prefixed message only when not in quiet mode. | |
| 1059 func_notquiet () | |
| 1060 { | |
| 1061 $debug_cmd | |
| 1062 | |
| 1063 $opt_quiet || func_echo ${1+"$@"} | |
| 1064 | |
| 1065 # A bug in bash halts the script if the last line of a function | |
| 1066 # fails when set -e is in force, so we need another command to | |
| 1067 # work around that: | |
| 1068 : | |
| 1069 } | |
| 1070 | |
| 1071 | |
| 1072 # func_relative_path SRCDIR DSTDIR | |
| 1073 # -------------------------------- | |
| 1074 # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. | |
| 1075 func_relative_path () | |
| 1076 { | |
| 1077 $debug_cmd | |
| 1078 | |
| 1079 func_relative_path_result= | |
| 1080 func_normal_abspath "$1" | |
| 1081 func_relative_path_tlibdir=$func_normal_abspath_result | |
| 1082 func_normal_abspath "$2" | |
| 1083 func_relative_path_tbindir=$func_normal_abspath_result | |
| 1084 | |
| 1085 # Ascend the tree starting from libdir | |
| 1086 while :; do | |
| 1087 # check if we have found a prefix of bindir | |
| 1088 case $func_relative_path_tbindir in | |
| 1089 $func_relative_path_tlibdir) | |
| 1090 # found an exact match | |
| 1091 func_relative_path_tcancelled= | |
| 1092 break | |
| 1093 ;; | |
| 1094 $func_relative_path_tlibdir*) | |
| 1095 # found a matching prefix | |
| 1096 func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" | |
| 1097 func_relative_path_tcancelled=$func_stripname_result | |
| 1098 if test -z "$func_relative_path_result"; then | |
| 1099 func_relative_path_result=. | |
| 1100 fi | |
| 1101 break | |
| 1102 ;; | |
| 1103 *) | |
| 1104 func_dirname $func_relative_path_tlibdir | |
| 1105 func_relative_path_tlibdir=$func_dirname_result | |
| 1106 if test -z "$func_relative_path_tlibdir"; then | |
| 1107 # Have to descend all the way to the root! | |
| 1108 func_relative_path_result=../$func_relative_path_result | |
| 1109 func_relative_path_tcancelled=$func_relative_path_tbindir | |
| 1110 break | |
| 1111 fi | |
| 1112 func_relative_path_result=../$func_relative_path_result | |
| 1113 ;; | |
| 1114 esac | |
| 1115 done | |
| 1116 | |
| 1117 # Now calculate path; take care to avoid doubling-up slashes. | |
| 1118 func_stripname '' '/' "$func_relative_path_result" | |
| 1119 func_relative_path_result=$func_stripname_result | |
| 1120 func_stripname '/' '/' "$func_relative_path_tcancelled" | |
| 1121 if test -n "$func_stripname_result"; then | |
| 1122 func_append func_relative_path_result "/$func_stripname_result" | |
| 1123 fi | |
| 1124 | |
| 1125 # Normalisation. If bindir is libdir, return '.' else relative path. | |
| 1126 if test -n "$func_relative_path_result"; then | |
| 1127 func_stripname './' '' "$func_relative_path_result" | |
| 1128 func_relative_path_result=$func_stripname_result | |
| 1129 fi | |
| 1130 | |
| 1131 test -n "$func_relative_path_result" || func_relative_path_result=. | |
| 1132 | |
| 1133 : | |
| 1134 } | |
| 1135 | |
| 1136 | |
| 1137 # func_quote_portable EVAL ARG | |
| 1138 # ---------------------------- | |
| 1139 # Internal function to portably implement func_quote_arg. Note that we still | |
| 1140 # keep attention to performance here so we as much as possible try to avoid | |
| 1141 # calling sed binary (so far O(N) complexity as long as func_append is O(1)). | |
| 1142 func_quote_portable () | |
| 1143 { | |
| 1144 $debug_cmd | |
| 1145 | |
| 1146 $require_check_ifs_backslash | |
| 1147 | |
| 1148 func_quote_portable_result=$2 | |
| 1149 | |
| 1150 # one-time-loop (easy break) | |
| 1151 while true | |
| 1152 do | |
| 1153 if $1; then | |
| 1154 func_quote_portable_result=`$ECHO "$2" | $SED \ | |
| 1155 -e "$sed_double_quote_subst" -e "$sed_double_backslash"` | |
| 1156 break | |
| 1157 fi | |
| 1158 | |
| 1159 # Quote for eval. | |
| 1160 case $func_quote_portable_result in | |
| 1161 *[\\\`\"\$]*) | |
| 1162 # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string | |
| 1163 # contains the shell wildcard characters. | |
| 1164 case $check_ifs_backshlash_broken$func_quote_portable_result in | |
| 1165 :*|*[\[\*\?]*) | |
| 1166 func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ | |
| 1167 | $SED "$sed_quote_subst"` | |
| 1168 break | |
| 1169 ;; | |
| 1170 esac | |
| 1171 | |
| 1172 func_quote_portable_old_IFS=$IFS | |
| 1173 for _G_char in '\' '`' '"' '$' | |
| 1174 do | |
| 1175 # STATE($1) PREV($2) SEPARATOR($3) | |
| 1176 set start "" "" | |
| 1177 func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy | |
| 1178 IFS=$_G_char | |
| 1179 for _G_part in $func_quote_portable_result | |
| 1180 do | |
| 1181 case $1 in | |
| 1182 quote) | |
| 1183 func_append func_quote_portable_result "$3$2" | |
| 1184 set quote "$_G_part" "\\$_G_char" | |
| 1185 ;; | |
| 1186 start) | |
| 1187 set first "" "" | |
| 1188 func_quote_portable_result= | |
| 1189 ;; | |
| 1190 first) | |
| 1191 set quote "$_G_part" "" | |
| 1192 ;; | |
| 1193 esac | |
| 1194 done | |
| 1195 done | |
| 1196 IFS=$func_quote_portable_old_IFS | |
| 1197 ;; | |
| 1198 *) ;; | |
| 1199 esac | |
| 1200 break | |
| 1201 done | |
| 1202 | |
| 1203 func_quote_portable_unquoted_result=$func_quote_portable_result | |
| 1204 case $func_quote_portable_result in | |
| 1205 # double-quote args containing shell metacharacters to delay | |
| 1206 # word splitting, command substitution and variable expansion | |
| 1207 # for a subsequent eval. | |
| 1208 # many bourne shells cannot handle close brackets correctly | |
| 1209 # in scan sets, so we specify it separately. | |
| 1210 *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") | |
| 1211 func_quote_portable_result=\"$func_quote_portable_result\" | |
| 1212 ;; | |
| 1213 esac | |
| 1214 } | |
| 1215 | |
| 1216 | |
| 1217 # func_quotefast_eval ARG | |
| 1218 # ----------------------- | |
| 1219 # Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', | |
| 1220 # but optimized for speed. Result is stored in $func_quotefast_eval. | |
| 1221 if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then | |
| 1222 printf -v _GL_test_printf_tilde %q '~' | |
| 1223 if test '\~' = "$_GL_test_printf_tilde"; then | |
| 1224 func_quotefast_eval () | |
| 1225 { | |
| 1226 printf -v func_quotefast_eval_result %q "$1" | |
| 1227 } | |
| 1228 else | |
| 1229 # Broken older Bash implementations. Make those faster too if possible. | |
| 1230 func_quotefast_eval () | |
| 1231 { | |
| 1232 case $1 in | |
| 1233 '~'*) | |
| 1234 func_quote_portable false "$1" | |
| 1235 func_quotefast_eval_result=$func_quote_portable_result | |
| 1236 ;; | |
| 1237 *) | |
| 1238 printf -v func_quotefast_eval_result %q "$1" | |
| 1239 ;; | |
| 1240 esac | |
| 1241 } | |
| 1242 fi | |
| 1243 else | |
| 1244 func_quotefast_eval () | |
| 1245 { | |
| 1246 func_quote_portable false "$1" | |
| 1247 func_quotefast_eval_result=$func_quote_portable_result | |
| 1248 } | |
| 1249 fi | |
| 1250 | |
| 1251 | |
| 1252 # func_quote_arg MODEs ARG | |
| 1253 # ------------------------ | |
| 1254 # Quote one ARG to be evaled later. MODEs argument may contain zero or more | |
| 1255 # specifiers listed below separated by ',' character. This function returns two | |
| 1256 # values: | |
| 1257 # i) func_quote_arg_result | |
| 1258 # double-quoted (when needed), suitable for a subsequent eval | |
| 1259 # ii) func_quote_arg_unquoted_result | |
| 1260 # has all characters that are still active within double | |
| 1261 # quotes backslashified. Available only if 'unquoted' is specified. | |
| 1262 # | |
| 1263 # Available modes: | |
| 1264 # ---------------- | |
| 1265 # 'eval' (default) | |
| 1266 # - escape shell special characters | |
| 1267 # 'expand' | |
| 1268 # - the same as 'eval'; but do not quote variable references | |
| 1269 # 'pretty' | |
| 1270 # - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might | |
| 1271 # be used later in func_quote to get output like: 'echo "a b"' instead | |
| 1272 # of 'echo a\ b'. This is slower than default on some shells. | |
| 1273 # 'unquoted' | |
| 1274 # - produce also $func_quote_arg_unquoted_result which does not contain | |
| 1275 # wrapping double-quotes. | |
| 1276 # | |
| 1277 # Examples for 'func_quote_arg pretty,unquoted string': | |
| 1278 # | |
| 1279 # string | *_result | *_unquoted_result | |
| 1280 # ------------+-----------------------+------------------- | |
| 1281 # " | \" | \" | |
| 1282 # a b | "a b" | a b | |
| 1283 # "a b" | "\"a b\"" | \"a b\" | |
| 1284 # * | "*" | * | |
| 1285 # z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" | |
| 1286 # | |
| 1287 # Examples for 'func_quote_arg pretty,unquoted,expand string': | |
| 1288 # | |
| 1289 # string | *_result | *_unquoted_result | |
| 1290 # --------------+---------------------+-------------------- | |
| 1291 # z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" | |
| 1292 func_quote_arg () | |
| 1293 { | |
| 1294 _G_quote_expand=false | |
| 1295 case ,$1, in | |
| 1296 *,expand,*) | |
| 1297 _G_quote_expand=: | |
| 1298 ;; | |
| 1299 esac | |
| 1300 | |
| 1301 case ,$1, in | |
| 1302 *,pretty,*|*,expand,*|*,unquoted,*) | |
| 1303 func_quote_portable $_G_quote_expand "$2" | |
| 1304 func_quote_arg_result=$func_quote_portable_result | |
| 1305 func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result | |
| 1306 ;; | |
| 1307 *) | |
| 1308 # Faster quote-for-eval for some shells. | |
| 1309 func_quotefast_eval "$2" | |
| 1310 func_quote_arg_result=$func_quotefast_eval_result | |
| 1311 ;; | |
| 1312 esac | |
| 1313 } | |
| 1314 | |
| 1315 | |
| 1316 # func_quote MODEs ARGs... | |
| 1317 # ------------------------ | |
| 1318 # Quote all ARGs to be evaled later and join them into single command. See | |
| 1319 # func_quote_arg's description for more info. | |
| 1320 func_quote () | |
| 1321 { | |
| 1322 $debug_cmd | |
| 1323 _G_func_quote_mode=$1 ; shift | |
| 1324 func_quote_result= | |
| 1325 while test 0 -lt $#; do | |
| 1326 func_quote_arg "$_G_func_quote_mode" "$1" | |
| 1327 if test -n "$func_quote_result"; then | |
| 1328 func_append func_quote_result " $func_quote_arg_result" | |
| 1329 else | |
| 1330 func_append func_quote_result "$func_quote_arg_result" | |
| 1331 fi | |
| 1332 shift | |
| 1333 done | |
| 1334 } | |
| 1335 | |
| 1336 | |
| 1337 # func_stripname PREFIX SUFFIX NAME | |
| 1338 # --------------------------------- | |
| 1339 # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. | |
| 1340 # PREFIX and SUFFIX must not contain globbing or regex special | |
| 1341 # characters, hashes, percent signs, but SUFFIX may contain a leading | |
| 1342 # dot (in which case that matches only a dot). | |
| 1343 if test yes = "$_G_HAVE_XSI_OPS"; then | |
| 1344 eval 'func_stripname () | |
| 1345 { | |
| 1346 $debug_cmd | |
| 1347 | |
| 1348 # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are | |
| 1349 # positional parameters, so assign one to ordinary variable first. | |
| 1350 func_stripname_result=$3 | |
| 1351 func_stripname_result=${func_stripname_result#"$1"} | |
| 1352 func_stripname_result=${func_stripname_result%"$2"} | |
| 1353 }' | |
| 1354 else | |
| 1355 func_stripname () | |
| 1356 { | |
| 1357 $debug_cmd | |
| 1358 | |
| 1359 case $2 in | |
| 1360 .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; | |
| 1361 *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; | |
| 1362 esac | |
| 1363 } | |
| 1364 fi | |
| 1365 | |
| 1366 | |
| 1367 # func_show_eval CMD [FAIL_EXP] | |
| 1368 # ----------------------------- | |
| 1369 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is | |
| 1370 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP | |
| 1371 # is given, then evaluate it. | |
| 1372 func_show_eval () | |
| 1373 { | |
| 1374 $debug_cmd | |
| 1375 | |
| 1376 _G_cmd=$1 | |
| 1377 _G_fail_exp=${2-':'} | |
| 1378 | |
| 1379 func_quote_arg pretty,expand "$_G_cmd" | |
| 1380 eval "func_notquiet $func_quote_arg_result" | |
| 1381 | |
| 1382 $opt_dry_run || { | |
| 1383 eval "$_G_cmd" | |
| 1384 _G_status=$? | |
| 1385 if test 0 -ne "$_G_status"; then | |
| 1386 eval "(exit $_G_status); $_G_fail_exp" | |
| 1387 fi | |
| 1388 } | |
| 1389 } | |
| 1390 | |
| 1391 | |
| 1392 # func_show_eval_locale CMD [FAIL_EXP] | |
| 1393 # ------------------------------------ | |
| 1394 # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is | |
| 1395 # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP | |
| 1396 # is given, then evaluate it. Use the saved locale for evaluation. | |
| 1397 func_show_eval_locale () | |
| 1398 { | |
| 1399 $debug_cmd | |
| 1400 | |
| 1401 _G_cmd=$1 | |
| 1402 _G_fail_exp=${2-':'} | |
| 1403 | |
| 1404 $opt_quiet || { | |
| 1405 func_quote_arg expand,pretty "$_G_cmd" | |
| 1406 eval "func_echo $func_quote_arg_result" | |
| 1407 } | |
| 1408 | |
| 1409 $opt_dry_run || { | |
| 1410 eval "$_G_user_locale | |
| 1411 $_G_cmd" | |
| 1412 _G_status=$? | |
| 1413 eval "$_G_safe_locale" | |
| 1414 if test 0 -ne "$_G_status"; then | |
| 1415 eval "(exit $_G_status); $_G_fail_exp" | |
| 1416 fi | |
| 1417 } | |
| 1418 } | |
| 1419 | |
| 1420 | |
| 1421 # func_tr_sh | |
| 1422 # ---------- | |
| 1423 # Turn $1 into a string suitable for a shell variable name. | |
| 1424 # Result is stored in $func_tr_sh_result. All characters | |
| 1425 # not in the set a-zA-Z0-9_ are replaced with '_'. Further, | |
| 1426 # if $1 begins with a digit, a '_' is prepended as well. | |
| 1427 func_tr_sh () | |
| 1428 { | |
| 1429 $debug_cmd | |
| 1430 | |
| 1431 case $1 in | |
| 1432 [0-9]* | *[!a-zA-Z0-9_]*) | |
| 1433 func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` | |
| 1434 ;; | |
| 1435 * ) | |
| 1436 func_tr_sh_result=$1 | |
| 1437 ;; | |
| 1438 esac | |
| 1439 } | |
| 1440 | |
| 1441 | |
| 1442 # func_verbose ARG... | |
| 1443 # ------------------- | |
| 1444 # Echo program name prefixed message in verbose mode only. | |
| 1445 func_verbose () | |
| 1446 { | |
| 1447 $debug_cmd | |
| 1448 | |
| 1449 $opt_verbose && func_echo "$*" | |
| 1450 | |
| 1451 : | |
| 1452 } | |
| 1453 | |
| 1454 | |
| 1455 # func_warn_and_continue ARG... | |
| 1456 # ----------------------------- | |
| 1457 # Echo program name prefixed warning message to standard error. | |
| 1458 func_warn_and_continue () | |
| 1459 { | |
| 1460 $debug_cmd | |
| 1461 | |
| 1462 $require_term_colors | |
| 1463 | |
| 1464 func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 | |
| 1465 } | |
| 1466 | |
| 1467 | |
| 1468 # func_warning CATEGORY ARG... | |
| 1469 # ---------------------------- | |
| 1470 # Echo program name prefixed warning message to standard error. Warning | |
| 1471 # messages can be filtered according to CATEGORY, where this function | |
| 1472 # elides messages where CATEGORY is not listed in the global variable | |
| 1473 # 'opt_warning_types'. | |
| 1474 func_warning () | |
| 1475 { | |
| 1476 $debug_cmd | |
| 1477 | |
| 1478 # CATEGORY must be in the warning_categories list! | |
| 1479 case " $warning_categories " in | |
| 1480 *" $1 "*) ;; | |
| 1481 *) func_internal_error "invalid warning category '$1'" ;; | |
| 1482 esac | |
| 1483 | |
| 1484 _G_category=$1 | |
| 1485 shift | |
| 1486 | |
| 1487 case " $opt_warning_types " in | |
| 1488 *" $_G_category "*) $warning_func ${1+"$@"} ;; | |
| 1489 esac | |
| 1490 } | |
| 1491 | |
| 1492 | |
| 1493 # func_sort_ver VER1 VER2 | |
| 1494 # ----------------------- | |
| 1495 # 'sort -V' is not generally available. | |
| 1496 # Note this deviates from the version comparison in automake | |
| 1497 # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a | |
| 1498 # but this should suffice as we won't be specifying old | |
| 1499 # version formats or redundant trailing .0 in bootstrap.conf. | |
| 1500 # If we did want full compatibility then we should probably | |
| 1501 # use m4_version_compare from autoconf. | |
| 1502 func_sort_ver () | |
| 1503 { | |
| 1504 $debug_cmd | |
| 1505 | |
| 1506 printf '%s\n%s\n' "$1" "$2" \ | |
| 1507 | 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 | |
| 1508 } | |
| 1509 | |
| 1510 # func_lt_ver PREV CURR | |
| 1511 # --------------------- | |
| 1512 # Return true if PREV and CURR are in the correct order according to | |
| 1513 # func_sort_ver, otherwise false. Use it like this: | |
| 1514 # | |
| 1515 # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." | |
| 1516 func_lt_ver () | |
| 1517 { | |
| 1518 $debug_cmd | |
| 1519 | |
| 1520 test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` | |
| 1521 } | |
| 1522 | |
| 1523 | |
| 1524 # Local variables: | |
| 1525 # mode: shell-script | |
| 1526 # sh-indentation: 2 | |
| 1527 # eval: (add-hook 'before-save-hook 'time-stamp) | |
| 1528 # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" | |
| 1529 # time-stamp-time-zone: "UTC" | |
| 1530 # End: | |
| 1531 #! /bin/sh | |
| 1532 | |
| 1533 # A portable, pluggable option parser for Bourne shell. | |
| 1534 # Written by Gary V. Vaughan, 2010 | |
| 1535 | |
| 1536 # This is free software. There is NO warranty; not even for | |
| 1537 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. | |
| 1538 # | |
| 1539 # Copyright (C) 2010-2019, 2021 Bootstrap Authors | |
| 1540 # | |
| 1541 # This file is dual licensed under the terms of the MIT license | |
| 1542 # <https://opensource.org/license/MIT>, and GPL version 2 or later | |
| 1543 # <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of | |
| 1544 # these licenses when using or redistributing this software or any of | |
| 1545 # the files within it. See the URLs above, or the file `LICENSE` | |
| 1546 # included in the Bootstrap distribution for the full license texts. | |
| 1547 | |
| 1548 # Please report bugs or propose patches to: | |
| 1549 # <https://github.com/gnulib-modules/bootstrap/issues> | |
| 1550 | |
| 1551 # Set a version string for this script. | |
| 1552 scriptversion=2019-02-19.15; # UTC | |
| 1553 | |
| 1554 | |
| 1555 ## ------ ## | |
| 1556 ## Usage. ## | |
| 1557 ## ------ ## | |
| 1558 | |
| 1559 # This file is a library for parsing options in your shell scripts along | |
| 1560 # with assorted other useful supporting features that you can make use | |
| 1561 # of too. | |
| 1562 # | |
| 1563 # For the simplest scripts you might need only: | |
| 1564 # | |
| 1565 # #!/bin/sh | |
| 1566 # . relative/path/to/funclib.sh | |
| 1567 # . relative/path/to/options-parser | |
| 1568 # scriptversion=1.0 | |
| 1569 # func_options ${1+"$@"} | |
| 1570 # eval set dummy "$func_options_result"; shift | |
| 1571 # ...rest of your script... | |
| 1572 # | |
| 1573 # In order for the '--version' option to work, you will need to have a | |
| 1574 # suitably formatted comment like the one at the top of this file | |
| 1575 # starting with '# Written by ' and ending with '# Copyright'. | |
| 1576 # | |
| 1577 # For '-h' and '--help' to work, you will also need a one line | |
| 1578 # description of your script's purpose in a comment directly above the | |
| 1579 # '# Written by ' line, like the one at the top of this file. | |
| 1580 # | |
| 1581 # The default options also support '--debug', which will turn on shell | |
| 1582 # execution tracing (see the comment above debug_cmd below for another | |
| 1583 # use), and '--verbose' and the func_verbose function to allow your script | |
| 1584 # to display verbose messages only when your user has specified | |
| 1585 # '--verbose'. | |
| 1586 # | |
| 1587 # After sourcing this file, you can plug in processing for additional | |
| 1588 # options by amending the variables from the 'Configuration' section | |
| 1589 # below, and following the instructions in the 'Option parsing' | |
| 1590 # section further down. | |
| 1591 | |
| 1592 ## -------------- ## | |
| 1593 ## Configuration. ## | |
| 1594 ## -------------- ## | |
| 1595 | |
| 1596 # You should override these variables in your script after sourcing this | |
| 1597 # file so that they reflect the customisations you have added to the | |
| 1598 # option parser. | |
| 1599 | |
| 1600 # The usage line for option parsing errors and the start of '-h' and | |
| 1601 # '--help' output messages. You can embed shell variables for delayed | |
| 1602 # expansion at the time the message is displayed, but you will need to | |
| 1603 # quote other shell meta-characters carefully to prevent them being | |
| 1604 # expanded when the contents are evaled. | |
| 1605 usage='$progpath [OPTION]...' | |
| 1606 | |
| 1607 # Short help message in response to '-h' and '--help'. Add to this or | |
| 1608 # override it after sourcing this library to reflect the full set of | |
| 1609 # options your script accepts. | |
| 1610 usage_message="\ | |
| 1611 --debug enable verbose shell tracing | |
| 1612 -W, --warnings=CATEGORY | |
| 1613 report the warnings falling in CATEGORY [all] | |
| 1614 -v, --verbose verbosely report processing | |
| 1615 --version print version information and exit | |
| 1616 -h, --help print short or long help message and exit | |
| 1617 " | |
| 1618 | |
| 1619 # Additional text appended to 'usage_message' in response to '--help'. | |
| 1620 long_help_message=" | |
| 1621 Warning categories include: | |
| 1622 'all' show all warnings | |
| 1623 'none' turn off all the warnings | |
| 1624 'error' warnings are treated as fatal errors" | |
| 1625 | |
| 1626 # Help message printed before fatal option parsing errors. | |
| 1627 fatal_help="Try '\$progname --help' for more information." | |
| 1628 | |
| 1629 | |
| 1630 | |
| 1631 ## ------------------------- ## | |
| 1632 ## Hook function management. ## | |
| 1633 ## ------------------------- ## | |
| 1634 | |
| 1635 # This section contains functions for adding, removing, and running hooks | |
| 1636 # in the main code. A hook is just a list of function names that can be | |
| 1637 # run in order later on. | |
| 1638 | |
| 1639 # func_hookable FUNC_NAME | |
| 1640 # ----------------------- | |
| 1641 # Declare that FUNC_NAME will run hooks added with | |
| 1642 # 'func_add_hook FUNC_NAME ...'. | |
| 1643 func_hookable () | |
| 1644 { | |
| 1645 $debug_cmd | |
| 1646 | |
| 1647 func_append hookable_fns " $1" | |
| 1648 } | |
| 1649 | |
| 1650 | |
| 1651 # func_add_hook FUNC_NAME HOOK_FUNC | |
| 1652 # --------------------------------- | |
| 1653 # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must | |
| 1654 # first have been declared "hookable" by a call to 'func_hookable'. | |
| 1655 func_add_hook () | |
| 1656 { | |
| 1657 $debug_cmd | |
| 1658 | |
| 1659 case " $hookable_fns " in | |
| 1660 *" $1 "*) ;; | |
| 1661 *) func_fatal_error "'$1' does not accept hook functions." ;; | |
| 1662 esac | |
| 1663 | |
| 1664 eval func_append ${1}_hooks '" $2"' | |
| 1665 } | |
| 1666 | |
| 1667 | |
| 1668 # func_remove_hook FUNC_NAME HOOK_FUNC | |
| 1669 # ------------------------------------ | |
| 1670 # Remove HOOK_FUNC from the list of hook functions to be called by | |
| 1671 # FUNC_NAME. | |
| 1672 func_remove_hook () | |
| 1673 { | |
| 1674 $debug_cmd | |
| 1675 | |
| 1676 eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' | |
| 1677 } | |
| 1678 | |
| 1679 | |
| 1680 # func_propagate_result FUNC_NAME_A FUNC_NAME_B | |
| 1681 # --------------------------------------------- | |
| 1682 # If the *_result variable of FUNC_NAME_A _is set_, assign its value to | |
| 1683 # *_result variable of FUNC_NAME_B. | |
| 1684 func_propagate_result () | |
| 1685 { | |
| 1686 $debug_cmd | |
| 1687 | |
| 1688 func_propagate_result_result=: | |
| 1689 if eval "test \"\${${1}_result+set}\" = set" | |
| 1690 then | |
| 1691 eval "${2}_result=\$${1}_result" | |
| 1692 else | |
| 1693 func_propagate_result_result=false | |
| 1694 fi | |
| 1695 } | |
| 1696 | |
| 1697 | |
| 1698 # func_run_hooks FUNC_NAME [ARG]... | |
| 1699 # --------------------------------- | |
| 1700 # Run all hook functions registered to FUNC_NAME. | |
| 1701 # It's assumed that the list of hook functions contains nothing more | |
| 1702 # than a whitespace-delimited list of legal shell function names, and | |
| 1703 # no effort is wasted trying to catch shell meta-characters or preserve | |
| 1704 # whitespace. | |
| 1705 func_run_hooks () | |
| 1706 { | |
| 1707 $debug_cmd | |
| 1708 | |
| 1709 case " $hookable_fns " in | |
| 1710 *" $1 "*) ;; | |
| 1711 *) func_fatal_error "'$1' does not support hook functions." ;; | |
| 1712 esac | |
| 1713 | |
| 1714 eval _G_hook_fns=\$$1_hooks; shift | |
| 1715 | |
| 1716 for _G_hook in $_G_hook_fns; do | |
| 1717 func_unset "${_G_hook}_result" | |
| 1718 eval $_G_hook '${1+"$@"}' | |
| 1719 func_propagate_result $_G_hook func_run_hooks | |
| 1720 if $func_propagate_result_result; then | |
| 1721 eval set dummy "$func_run_hooks_result"; shift | |
| 1722 fi | |
| 1723 done | |
| 1724 } | |
| 1725 | |
| 1726 | |
| 1727 | |
| 1728 ## --------------- ## | |
| 1729 ## Option parsing. ## | |
| 1730 ## --------------- ## | |
| 1731 | |
| 1732 # In order to add your own option parsing hooks, you must accept the | |
| 1733 # full positional parameter list from your hook function. You may remove | |
| 1734 # or edit any options that you action, and then pass back the remaining | |
| 1735 # unprocessed options in '<hooked_function_name>_result', escaped | |
| 1736 # suitably for 'eval'. | |
| 1737 # | |
| 1738 # The '<hooked_function_name>_result' variable is automatically unset | |
| 1739 # before your hook gets called; for best performance, only set the | |
| 1740 # *_result variable when necessary (i.e. don't call the 'func_quote' | |
| 1741 # function unnecessarily because it can be an expensive operation on some | |
| 1742 # machines). | |
| 1743 # | |
| 1744 # Like this: | |
| 1745 # | |
| 1746 # my_options_prep () | |
| 1747 # { | |
| 1748 # $debug_cmd | |
| 1749 # | |
| 1750 # # Extend the existing usage message. | |
| 1751 # usage_message=$usage_message' | |
| 1752 # -s, --silent don'\''t print informational messages | |
| 1753 # ' | |
| 1754 # # No change in '$@' (ignored completely by this hook). Leave | |
| 1755 # # my_options_prep_result variable intact. | |
| 1756 # } | |
| 1757 # func_add_hook func_options_prep my_options_prep | |
| 1758 # | |
| 1759 # | |
| 1760 # my_silent_option () | |
| 1761 # { | |
| 1762 # $debug_cmd | |
| 1763 # | |
| 1764 # args_changed=false | |
| 1765 # | |
| 1766 # # Note that, for efficiency, we parse as many options as we can | |
| 1767 # # recognise in a loop before passing the remainder back to the | |
| 1768 # # caller on the first unrecognised argument we encounter. | |
| 1769 # while test $# -gt 0; do | |
| 1770 # opt=$1; shift | |
| 1771 # case $opt in | |
| 1772 # --silent|-s) opt_silent=: ;; | |
| 1773 # # Separate non-argument short options: | |
| 1774 # -s*) func_split_short_opt "$_G_opt" | |
| 1775 # set dummy "$func_split_short_opt_name" \ | |
| 1776 # "-$func_split_short_opt_arg" ${1+"$@"} | |
| 1777 # shift | |
| 1778 # ;; | |
| 1779 # *) # Make sure the first unrecognised option "$_G_opt" | |
| 1780 # # is added back to "$@" in case we need it later, | |
| 1781 # # if $args_changed was set to 'true'. | |
| 1782 # set dummy "$_G_opt" ${1+"$@"}; shift; break ;; | |
| 1783 # esac | |
| 1784 # done | |
| 1785 # | |
| 1786 # # Only call 'func_quote' here if we processed at least one argument. | |
| 1787 # if $args_changed; then | |
| 1788 # func_quote eval ${1+"$@"} | |
| 1789 # my_silent_option_result=$func_quote_result | |
| 1790 # fi | |
| 1791 # } | |
| 1792 # func_add_hook func_parse_options my_silent_option | |
| 1793 # | |
| 1794 # | |
| 1795 # my_option_validation () | |
| 1796 # { | |
| 1797 # $debug_cmd | |
| 1798 # | |
| 1799 # $opt_silent && $opt_verbose && func_fatal_help "\ | |
| 1800 # '--silent' and '--verbose' options are mutually exclusive." | |
| 1801 # } | |
| 1802 # func_add_hook func_validate_options my_option_validation | |
| 1803 # | |
| 1804 # You'll alse need to manually amend $usage_message to reflect the extra | |
| 1805 # options you parse. It's preferable to append if you can, so that | |
| 1806 # multiple option parsing hooks can be added safely. | |
| 1807 | |
| 1808 | |
| 1809 # func_options_finish [ARG]... | |
| 1810 # ---------------------------- | |
| 1811 # Finishing the option parse loop (call 'func_options' hooks ATM). | |
| 1812 func_options_finish () | |
| 1813 { | |
| 1814 $debug_cmd | |
| 1815 | |
| 1816 func_run_hooks func_options ${1+"$@"} | |
| 1817 func_propagate_result func_run_hooks func_options_finish | |
| 1818 } | |
| 1819 | |
| 1820 | |
| 1821 # func_options [ARG]... | |
| 1822 # --------------------- | |
| 1823 # All the functions called inside func_options are hookable. See the | |
| 1824 # individual implementations for details. | |
| 1825 func_hookable func_options | |
| 1826 func_options () | |
| 1827 { | |
| 1828 $debug_cmd | |
| 1829 | |
| 1830 _G_options_quoted=false | |
| 1831 | |
| 1832 for my_func in options_prep parse_options validate_options options_finish | |
| 1833 do | |
| 1834 func_unset func_${my_func}_result | |
| 1835 func_unset func_run_hooks_result | |
| 1836 eval func_$my_func '${1+"$@"}' | |
| 1837 func_propagate_result func_$my_func func_options | |
| 1838 if $func_propagate_result_result; then | |
| 1839 eval set dummy "$func_options_result"; shift | |
| 1840 _G_options_quoted=: | |
| 1841 fi | |
| 1842 done | |
| 1843 | |
| 1844 $_G_options_quoted || { | |
| 1845 # As we (func_options) are top-level options-parser function and | |
| 1846 # nobody quoted "$@" for us yet, we need to do it explicitly for | |
| 1847 # caller. | |
| 1848 func_quote eval ${1+"$@"} | |
| 1849 func_options_result=$func_quote_result | |
| 1850 } | |
| 1851 } | |
| 1852 | |
| 1853 | |
| 1854 # func_options_prep [ARG]... | |
| 1855 # -------------------------- | |
| 1856 # All initialisations required before starting the option parse loop. | |
| 1857 # Note that when calling hook functions, we pass through the list of | |
| 1858 # positional parameters. If a hook function modifies that list, and | |
| 1859 # needs to propagate that back to rest of this script, then the complete | |
| 1860 # modified list must be put in 'func_run_hooks_result' before returning. | |
| 1861 func_hookable func_options_prep | |
| 1862 func_options_prep () | |
| 1863 { | |
| 1864 $debug_cmd | |
| 1865 | |
| 1866 # Option defaults: | |
| 1867 opt_verbose=false | |
| 1868 opt_warning_types= | |
| 1869 | |
| 1870 func_run_hooks func_options_prep ${1+"$@"} | |
| 1871 func_propagate_result func_run_hooks func_options_prep | |
| 1872 } | |
| 1873 | |
| 1874 | |
| 1875 # func_parse_options [ARG]... | |
| 1876 # --------------------------- | |
| 1877 # The main option parsing loop. | |
| 1878 func_hookable func_parse_options | |
| 1879 func_parse_options () | |
| 1880 { | |
| 1881 $debug_cmd | |
| 1882 | |
| 1883 _G_parse_options_requote=false | |
| 1884 # this just eases exit handling | |
| 1885 while test $# -gt 0; do | |
| 1886 # Defer to hook functions for initial option parsing, so they | |
| 1887 # get priority in the event of reusing an option name. | |
| 1888 func_run_hooks func_parse_options ${1+"$@"} | |
| 1889 func_propagate_result func_run_hooks func_parse_options | |
| 1890 if $func_propagate_result_result; then | |
| 1891 eval set dummy "$func_parse_options_result"; shift | |
| 1892 # Even though we may have changed "$@", we passed the "$@" array | |
| 1893 # down into the hook and it quoted it for us (because we are in | |
| 1894 # this if-branch). No need to quote it again. | |
| 1895 _G_parse_options_requote=false | |
| 1896 fi | |
| 1897 | |
| 1898 # Break out of the loop if we already parsed every option. | |
| 1899 test $# -gt 0 || break | |
| 1900 | |
| 1901 # We expect that one of the options parsed in this function matches | |
| 1902 # and thus we remove _G_opt from "$@" and need to re-quote. | |
| 1903 _G_match_parse_options=: | |
| 1904 _G_opt=$1 | |
| 1905 shift | |
| 1906 case $_G_opt in | |
| 1907 --debug|-x) debug_cmd='set -x' | |
| 1908 func_echo "enabling shell trace mode" >&2 | |
| 1909 $debug_cmd | |
| 1910 ;; | |
| 1911 | |
| 1912 --no-warnings|--no-warning|--no-warn) | |
| 1913 set dummy --warnings none ${1+"$@"} | |
| 1914 shift | |
| 1915 ;; | |
| 1916 | |
| 1917 --warnings|--warning|-W) | |
| 1918 if test $# = 0 && func_missing_arg $_G_opt; then | |
| 1919 _G_parse_options_requote=: | |
| 1920 break | |
| 1921 fi | |
| 1922 case " $warning_categories $1" in | |
| 1923 *" $1 "*) | |
| 1924 # trailing space prevents matching last $1 above | |
| 1925 func_append_uniq opt_warning_types " $1" | |
| 1926 ;; | |
| 1927 *all) | |
| 1928 opt_warning_types=$warning_categories | |
| 1929 ;; | |
| 1930 *none) | |
| 1931 opt_warning_types=none | |
| 1932 warning_func=: | |
| 1933 ;; | |
| 1934 *error) | |
| 1935 opt_warning_types=$warning_categories | |
| 1936 warning_func=func_fatal_error | |
| 1937 ;; | |
| 1938 *) | |
| 1939 func_fatal_error \ | |
| 1940 "unsupported warning category: '$1'" | |
| 1941 ;; | |
| 1942 esac | |
| 1943 shift | |
| 1944 ;; | |
| 1945 | |
| 1946 --verbose|-v) opt_verbose=: ;; | |
| 1947 --version) func_version ;; | |
| 1948 -\?|-h) func_usage ;; | |
| 1949 --help) func_help ;; | |
| 1950 | |
| 1951 # Separate optargs to long options (plugins may need this): | |
| 1952 --*=*) func_split_equals "$_G_opt" | |
| 1953 set dummy "$func_split_equals_lhs" \ | |
| 1954 "$func_split_equals_rhs" ${1+"$@"} | |
| 1955 shift | |
| 1956 ;; | |
| 1957 | |
| 1958 # Separate optargs to short options: | |
| 1959 -W*) | |
| 1960 func_split_short_opt "$_G_opt" | |
| 1961 set dummy "$func_split_short_opt_name" \ | |
| 1962 "$func_split_short_opt_arg" ${1+"$@"} | |
| 1963 shift | |
| 1964 ;; | |
| 1965 | |
| 1966 # Separate non-argument short options: | |
| 1967 -\?*|-h*|-v*|-x*) | |
| 1968 func_split_short_opt "$_G_opt" | |
| 1969 set dummy "$func_split_short_opt_name" \ | |
| 1970 "-$func_split_short_opt_arg" ${1+"$@"} | |
| 1971 shift | |
| 1972 ;; | |
| 1973 | |
| 1974 --) _G_parse_options_requote=: ; break ;; | |
| 1975 -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; | |
| 1976 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; | |
| 1977 esac | |
| 1978 | |
| 1979 if $_G_match_parse_options; then | |
| 1980 _G_parse_options_requote=: | |
| 1981 fi | |
| 1982 done | |
| 1983 | |
| 1984 if $_G_parse_options_requote; then | |
| 1985 # save modified positional parameters for caller | |
| 1986 func_quote eval ${1+"$@"} | |
| 1987 func_parse_options_result=$func_quote_result | |
| 1988 fi | |
| 1989 } | |
| 1990 | |
| 1991 | |
| 1992 # func_validate_options [ARG]... | |
| 1993 # ------------------------------ | |
| 1994 # Perform any sanity checks on option settings and/or unconsumed | |
| 1995 # arguments. | |
| 1996 func_hookable func_validate_options | |
| 1997 func_validate_options () | |
| 1998 { | |
| 1999 $debug_cmd | |
| 2000 | |
| 2001 # Display all warnings if -W was not given. | |
| 2002 test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" | |
| 2003 | |
| 2004 func_run_hooks func_validate_options ${1+"$@"} | |
| 2005 func_propagate_result func_run_hooks func_validate_options | |
| 2006 | |
| 2007 # Bail if the options were screwed! | |
| 2008 $exit_cmd $EXIT_FAILURE | |
| 2009 } | |
| 2010 | |
| 2011 | |
| 2012 | |
| 2013 ## ----------------- ## | |
| 2014 ## Helper functions. ## | |
| 2015 ## ----------------- ## | |
| 2016 | |
| 2017 # This section contains the helper functions used by the rest of the | |
| 2018 # hookable option parser framework in ascii-betical order. | |
| 2019 | |
| 2020 | |
| 2021 # func_fatal_help ARG... | |
| 2022 # ---------------------- | |
| 2023 # Echo program name prefixed message to standard error, followed by | |
| 2024 # a help hint, and exit. | |
| 2025 func_fatal_help () | |
| 2026 { | |
| 2027 $debug_cmd | |
| 2028 | |
| 2029 eval \$ECHO \""Usage: $usage"\" | |
| 2030 eval \$ECHO \""$fatal_help"\" | |
| 2031 func_error ${1+"$@"} | |
| 2032 exit $EXIT_FAILURE | |
| 2033 } | |
| 2034 | |
| 2035 | |
| 2036 # func_help | |
| 2037 # --------- | |
| 2038 # Echo long help message to standard output and exit. | |
| 2039 func_help () | |
| 2040 { | |
| 2041 $debug_cmd | |
| 2042 | |
| 2043 func_usage_message | |
| 2044 $ECHO "$long_help_message" | |
| 2045 exit 0 | |
| 2046 } | |
| 2047 | |
| 2048 | |
| 2049 # func_missing_arg ARGNAME | |
| 2050 # ------------------------ | |
| 2051 # Echo program name prefixed message to standard error and set global | |
| 2052 # exit_cmd. | |
| 2053 func_missing_arg () | |
| 2054 { | |
| 2055 $debug_cmd | |
| 2056 | |
| 2057 func_error "Missing argument for '$1'." | |
| 2058 exit_cmd=exit | |
| 2059 } | |
| 2060 | |
| 2061 | |
| 2062 # func_split_equals STRING | |
| 2063 # ------------------------ | |
| 2064 # Set func_split_equals_lhs and func_split_equals_rhs shell variables | |
| 2065 # after splitting STRING at the '=' sign. | |
| 2066 test -z "$_G_HAVE_XSI_OPS" \ | |
| 2067 && (eval 'x=a/b/c; | |
| 2068 test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ | |
| 2069 && _G_HAVE_XSI_OPS=yes | |
| 2070 | |
| 2071 if test yes = "$_G_HAVE_XSI_OPS" | |
| 2072 then | |
| 2073 # This is an XSI compatible shell, allowing a faster implementation... | |
| 2074 eval 'func_split_equals () | |
| 2075 { | |
| 2076 $debug_cmd | |
| 2077 | |
| 2078 func_split_equals_lhs=${1%%=*} | |
| 2079 func_split_equals_rhs=${1#*=} | |
| 2080 if test "x$func_split_equals_lhs" = "x$1"; then | |
| 2081 func_split_equals_rhs= | |
| 2082 fi | |
| 2083 }' | |
| 2084 else | |
| 2085 # ...otherwise fall back to using expr, which is often a shell builtin. | |
| 2086 func_split_equals () | |
| 2087 { | |
| 2088 $debug_cmd | |
| 2089 | |
| 2090 func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` | |
| 2091 func_split_equals_rhs= | |
| 2092 test "x$func_split_equals_lhs=" = "x$1" \ | |
| 2093 || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` | |
| 2094 } | |
| 2095 fi #func_split_equals | |
| 2096 | |
| 2097 | |
| 2098 # func_split_short_opt SHORTOPT | |
| 2099 # ----------------------------- | |
| 2100 # Set func_split_short_opt_name and func_split_short_opt_arg shell | |
| 2101 # variables after splitting SHORTOPT after the 2nd character. | |
| 2102 if test yes = "$_G_HAVE_XSI_OPS" | |
| 2103 then | |
| 2104 # This is an XSI compatible shell, allowing a faster implementation... | |
| 2105 eval 'func_split_short_opt () | |
| 2106 { | |
| 2107 $debug_cmd | |
| 2108 | |
| 2109 func_split_short_opt_arg=${1#??} | |
| 2110 func_split_short_opt_name=${1%"$func_split_short_opt_arg"} | |
| 2111 }' | |
| 2112 else | |
| 2113 # ...otherwise fall back to using expr, which is often a shell builtin. | |
| 2114 func_split_short_opt () | |
| 2115 { | |
| 2116 $debug_cmd | |
| 2117 | |
| 2118 func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` | |
| 2119 func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` | |
| 2120 } | |
| 2121 fi #func_split_short_opt | |
| 2122 | |
| 2123 | |
| 2124 # func_usage | |
| 2125 # ---------- | |
| 2126 # Echo short help message to standard output and exit. | |
| 2127 func_usage () | |
| 2128 { | |
| 2129 $debug_cmd | |
| 2130 | |
| 2131 func_usage_message | |
| 2132 $ECHO "Run '$progname --help |${PAGER-more}' for full usage" | |
| 2133 exit 0 | |
| 2134 } | |
| 2135 | |
| 2136 | |
| 2137 # func_usage_message | |
| 2138 # ------------------ | |
| 2139 # Echo short help message to standard output. | |
| 2140 func_usage_message () | |
| 2141 { | |
| 2142 $debug_cmd | |
| 2143 | |
| 2144 eval \$ECHO \""Usage: $usage"\" | |
| 2145 echo | |
| 2146 $SED -n 's|^# || | |
| 2147 /^Written by/{ | |
| 2148 x;p;x | |
| 2149 } | |
| 2150 h | |
| 2151 /^Written by/q' < "$progpath" | |
| 2152 echo | |
| 2153 eval \$ECHO \""$usage_message"\" | |
| 2154 } | |
| 2155 | |
| 2156 | |
| 2157 # func_version | |
| 2158 # ------------ | |
| 2159 # Echo version message to standard output and exit. | |
| 2160 # The version message is extracted from the calling file's header | |
| 2161 # comments, with leading '# ' stripped: | |
| 2162 # 1. First display the progname and version | |
| 2163 # 2. Followed by the header comment line matching /^# Written by / | |
| 2164 # 3. Then a blank line followed by the first following line matching | |
| 2165 # /^# Copyright / | |
| 2166 # 4. Immediately followed by any lines between the previous matches, | |
| 2167 # except lines preceding the intervening completely blank line. | |
| 2168 # For example, see the header comments of this file. | |
| 2169 func_version () | |
| 2170 { | |
| 2171 $debug_cmd | |
| 2172 | |
| 2173 printf '%s\n' "$progname $scriptversion" | |
| 2174 $SED -n ' | |
| 2175 /^# Written by /!b | |
| 2176 s|^# ||; p; n | |
| 2177 | |
| 2178 :fwd2blnk | |
| 2179 /./ { | |
| 2180 n | |
| 2181 b fwd2blnk | |
| 2182 } | |
| 2183 p; n | |
| 2184 | |
| 2185 :holdwrnt | |
| 2186 s|^# || | |
| 2187 s|^# *$|| | |
| 2188 /^Copyright /!{ | |
| 2189 /./H | |
| 2190 n | |
| 2191 b holdwrnt | |
| 2192 } | |
| 2193 | |
| 2194 s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| | |
| 2195 G | |
| 2196 s|\(\n\)\n*|\1|g | |
| 2197 p; q' < "$progpath" | |
| 2198 | |
| 2199 exit $? | |
| 2200 } | |
| 2201 | |
| 2202 | |
| 2203 # Local variables: | |
| 2204 # mode: shell-script | |
| 2205 # sh-indentation: 2 | |
| 2206 # eval: (add-hook 'before-save-hook 'time-stamp) | |
| 2207 # time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" | |
| 2208 # time-stamp-time-zone: "UTC" | |
| 2209 # End: | |
| 2210 | |
| 2211 # Set a version string. | |
| 2212 scriptversion='(GNU libtool) 2.4.7' | |
| 2213 | |
| 2214 | |
| 2215 # func_echo ARG... | |
| 2216 # ---------------- | |
| 2217 # Libtool also displays the current mode in messages, so override | |
| 2218 # funclib.sh func_echo with this custom definition. | |
| 2219 func_echo () | |
| 2220 { | |
| 2221 $debug_cmd | |
| 2222 | |
| 2223 _G_message=$* | |
| 2224 | |
| 2225 func_echo_IFS=$IFS | |
| 2226 IFS=$nl | |
| 2227 for _G_line in $_G_message; do | |
| 2228 IFS=$func_echo_IFS | |
| 2229 $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" | |
| 2230 done | |
| 2231 IFS=$func_echo_IFS | |
| 2232 } | |
| 2233 | |
| 2234 | |
| 2235 # func_warning ARG... | |
| 2236 # ------------------- | |
| 2237 # Libtool warnings are not categorized, so override funclib.sh | |
| 2238 # func_warning with this simpler definition. | |
| 2239 func_warning () | |
| 2240 { | |
| 2241 $debug_cmd | |
| 2242 | |
| 2243 $warning_func ${1+"$@"} | |
| 2244 } | |
| 2245 | |
| 2246 | |
| 2247 ## ---------------- ## | |
| 2248 ## Options parsing. ## | |
| 2249 ## ---------------- ## | |
| 2250 | |
| 2251 # Hook in the functions to make sure our own options are parsed during | |
| 2252 # the option parsing loop. | |
| 2253 | |
| 2254 usage='$progpath [OPTION]... [MODE-ARG]...' | |
| 2255 | |
| 2256 # Short help message in response to '-h'. | |
| 2257 usage_message="Options: | |
| 2258 --config show all configuration variables | |
| 2259 --debug enable verbose shell tracing | |
| 2260 -n, --dry-run display commands without modifying any files | |
| 2261 --features display basic configuration information and exit | |
| 2262 --mode=MODE use operation mode MODE | |
| 2263 --no-warnings equivalent to '-Wnone' | |
| 2264 --preserve-dup-deps don't remove duplicate dependency libraries | |
| 2265 --quiet, --silent don't print informational messages | |
| 2266 --tag=TAG use configuration variables from tag TAG | |
| 2267 -v, --verbose print more informational messages than default | |
| 2268 --version print version information | |
| 2269 -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] | |
| 2270 -h, --help, --help-all print short, long, or detailed help message | |
| 2271 " | |
| 2272 | |
| 2273 # Additional text appended to 'usage_message' in response to '--help'. | |
| 2274 func_help () | |
| 2275 { | |
| 2276 $debug_cmd | |
| 2277 | |
| 2278 func_usage_message | |
| 2279 $ECHO "$long_help_message | |
| 2280 | |
| 2281 MODE must be one of the following: | |
| 2282 | |
| 2283 clean remove files from the build directory | |
| 2284 compile compile a source file into a libtool object | |
| 2285 execute automatically set library path, then run a program | |
| 2286 finish complete the installation of libtool libraries | |
| 2287 install install libraries or executables | |
| 2288 link create a library or an executable | |
| 2289 uninstall remove libraries from an installed directory | |
| 2290 | |
| 2291 MODE-ARGS vary depending on the MODE. When passed as first option, | |
| 2292 '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. | |
| 2293 Try '$progname --help --mode=MODE' for a more detailed description of MODE. | |
| 2294 | |
| 2295 When reporting a bug, please describe a test case to reproduce it and | |
| 2296 include the following information: | |
| 2297 | |
| 2298 host-triplet: $host | |
| 2299 shell: $SHELL | |
| 2300 compiler: $LTCC | |
| 2301 compiler flags: $LTCFLAGS | |
| 2302 linker: $LD (gnu? $with_gnu_ld) | |
| 2303 version: $progname $scriptversion Debian-2.4.7-5 | |
| 2304 automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` | |
| 2305 autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` | |
| 2306 | |
| 2307 Report bugs to <bug-libtool@gnu.org>. | |
| 2308 GNU libtool home page: <http://www.gnu.org/s/libtool/>. | |
| 2309 General help using GNU software: <http://www.gnu.org/gethelp/>." | |
| 2310 exit 0 | |
| 2311 } | |
| 2312 | |
| 2313 | |
| 2314 # func_lo2o OBJECT-NAME | |
| 2315 # --------------------- | |
| 2316 # Transform OBJECT-NAME from a '.lo' suffix to the platform specific | |
| 2317 # object suffix. | |
| 2318 | |
| 2319 lo2o=s/\\.lo\$/.$objext/ | |
| 2320 o2lo=s/\\.$objext\$/.lo/ | |
| 2321 | |
| 2322 if test yes = "$_G_HAVE_XSI_OPS"; then | |
| 2323 eval 'func_lo2o () | |
| 2324 { | |
| 2325 case $1 in | |
| 2326 *.lo) func_lo2o_result=${1%.lo}.$objext ;; | |
| 2327 * ) func_lo2o_result=$1 ;; | |
| 2328 esac | |
| 2329 }' | |
| 2330 | |
| 2331 # func_xform LIBOBJ-OR-SOURCE | |
| 2332 # --------------------------- | |
| 2333 # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) | |
| 2334 # suffix to a '.lo' libtool-object suffix. | |
| 2335 eval 'func_xform () | |
| 2336 { | |
| 2337 func_xform_result=${1%.*}.lo | |
| 2338 }' | |
| 2339 else | |
| 2340 # ...otherwise fall back to using sed. | |
| 2341 func_lo2o () | |
| 2342 { | |
| 2343 func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` | |
| 2344 } | |
| 2345 | |
| 2346 func_xform () | |
| 2347 { | |
| 2348 func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` | |
| 2349 } | |
| 2350 fi | |
| 2351 | |
| 2352 | |
| 2353 # func_fatal_configuration ARG... | |
| 2354 # ------------------------------- | |
| 2355 # Echo program name prefixed message to standard error, followed by | |
| 2356 # a configuration failure hint, and exit. | |
| 2357 func_fatal_configuration () | |
| 2358 { | |
| 2359 func_fatal_error ${1+"$@"} \ | |
| 2360 "See the $PACKAGE documentation for more information." \ | |
| 2361 "Fatal configuration error." | |
| 2362 } | |
| 2363 | |
| 2364 | |
| 2365 # func_config | |
| 2366 # ----------- | |
| 2367 # Display the configuration for all the tags in this script. | |
| 2368 func_config () | |
| 2369 { | |
| 2370 re_begincf='^# ### BEGIN LIBTOOL' | |
| 2371 re_endcf='^# ### END LIBTOOL' | |
| 2372 | |
| 2373 # Default configuration. | |
| 2374 $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" | |
| 2375 | |
| 2376 # Now print the configurations for the tags. | |
| 2377 for tagname in $taglist; do | |
| 2378 $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" | |
| 2379 done | |
| 2380 | |
| 2381 exit $? | |
| 2382 } | |
| 2383 | |
| 2384 | |
| 2385 # func_features | |
| 2386 # ------------- | |
| 2387 # Display the features supported by this script. | |
| 2388 func_features () | |
| 2389 { | |
| 2390 echo "host: $host" | |
| 2391 if test yes = "$build_libtool_libs"; then | |
| 2392 echo "enable shared libraries" | |
| 2393 else | |
| 2394 echo "disable shared libraries" | |
| 2395 fi | |
| 2396 if test yes = "$build_old_libs"; then | |
| 2397 echo "enable static libraries" | |
| 2398 else | |
| 2399 echo "disable static libraries" | |
| 2400 fi | |
| 2401 | |
| 2402 exit $? | |
| 2403 } | |
| 2404 | |
| 2405 | |
| 2406 # func_enable_tag TAGNAME | |
| 2407 # ----------------------- | |
| 2408 # Verify that TAGNAME is valid, and either flag an error and exit, or | |
| 2409 # enable the TAGNAME tag. We also add TAGNAME to the global $taglist | |
| 2410 # variable here. | |
| 2411 func_enable_tag () | |
| 2412 { | |
| 2413 # Global variable: | |
| 2414 tagname=$1 | |
| 2415 | |
| 2416 re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" | |
| 2417 re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" | |
| 2418 sed_extractcf=/$re_begincf/,/$re_endcf/p | |
| 2419 | |
| 2420 # Validate tagname. | |
| 2421 case $tagname in | |
| 2422 *[!-_A-Za-z0-9,/]*) | |
| 2423 func_fatal_error "invalid tag name: $tagname" | |
| 2424 ;; | |
| 2425 esac | |
| 2426 | |
| 2427 # Don't test for the "default" C tag, as we know it's | |
| 2428 # there but not specially marked. | |
| 2429 case $tagname in | |
| 2430 CC) ;; | |
| 2431 *) | |
| 2432 if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then | |
| 2433 taglist="$taglist $tagname" | |
| 2434 | |
| 2435 # Evaluate the configuration. Be careful to quote the path | |
| 2436 # and the sed script, to avoid splitting on whitespace, but | |
| 2437 # also don't use non-portable quotes within backquotes within | |
| 2438 # quotes we have to do it in 2 steps: | |
| 2439 extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` | |
| 2440 eval "$extractedcf" | |
| 2441 else | |
| 2442 func_error "ignoring unknown tag $tagname" | |
| 2443 fi | |
| 2444 ;; | |
| 2445 esac | |
| 2446 } | |
| 2447 | |
| 2448 | |
| 2449 # func_check_version_match | |
| 2450 # ------------------------ | |
| 2451 # Ensure that we are using m4 macros, and libtool script from the same | |
| 2452 # release of libtool. | |
| 2453 func_check_version_match () | |
| 2454 { | |
| 2455 if test "$package_revision" != "$macro_revision"; then | |
| 2456 if test "$VERSION" != "$macro_version"; then | |
| 2457 if test -z "$macro_version"; then | |
| 2458 cat >&2 <<_LT_EOF | |
| 2459 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the | |
| 2460 $progname: definition of this LT_INIT comes from an older release. | |
| 2461 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION | |
| 2462 $progname: and run autoconf again. | |
| 2463 _LT_EOF | |
| 2464 else | |
| 2465 cat >&2 <<_LT_EOF | |
| 2466 $progname: Version mismatch error. This is $PACKAGE $VERSION, but the | |
| 2467 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. | |
| 2468 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION | |
| 2469 $progname: and run autoconf again. | |
| 2470 _LT_EOF | |
| 2471 fi | |
| 2472 else | |
| 2473 cat >&2 <<_LT_EOF | |
| 2474 $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, | |
| 2475 $progname: but the definition of this LT_INIT comes from revision $macro_revision. | |
| 2476 $progname: You should recreate aclocal.m4 with macros from revision $package_revision | |
| 2477 $progname: of $PACKAGE $VERSION and run autoconf again. | |
| 2478 _LT_EOF | |
| 2479 fi | |
| 2480 | |
| 2481 exit $EXIT_MISMATCH | |
| 2482 fi | |
| 2483 } | |
| 2484 | |
| 2485 | |
| 2486 # libtool_options_prep [ARG]... | |
| 2487 # ----------------------------- | |
| 2488 # Preparation for options parsed by libtool. | |
| 2489 libtool_options_prep () | |
| 2490 { | |
| 2491 $debug_mode | |
| 2492 | |
| 2493 # Option defaults: | |
| 2494 opt_config=false | |
| 2495 opt_dlopen= | |
| 2496 opt_dry_run=false | |
| 2497 opt_help=false | |
| 2498 opt_mode= | |
| 2499 opt_preserve_dup_deps=false | |
| 2500 opt_quiet=false | |
| 2501 | |
| 2502 nonopt= | |
| 2503 preserve_args= | |
| 2504 | |
| 2505 _G_rc_lt_options_prep=: | |
| 2506 | |
| 2507 _G_rc_lt_options_prep=: | |
| 2508 | |
| 2509 # Shorthand for --mode=foo, only valid as the first argument | |
| 2510 case $1 in | |
| 2511 clean|clea|cle|cl) | |
| 2512 shift; set dummy --mode clean ${1+"$@"}; shift | |
| 2513 ;; | |
| 2514 compile|compil|compi|comp|com|co|c) | |
| 2515 shift; set dummy --mode compile ${1+"$@"}; shift | |
| 2516 ;; | |
| 2517 execute|execut|execu|exec|exe|ex|e) | |
| 2518 shift; set dummy --mode execute ${1+"$@"}; shift | |
| 2519 ;; | |
| 2520 finish|finis|fini|fin|fi|f) | |
| 2521 shift; set dummy --mode finish ${1+"$@"}; shift | |
| 2522 ;; | |
| 2523 install|instal|insta|inst|ins|in|i) | |
| 2524 shift; set dummy --mode install ${1+"$@"}; shift | |
| 2525 ;; | |
| 2526 link|lin|li|l) | |
| 2527 shift; set dummy --mode link ${1+"$@"}; shift | |
| 2528 ;; | |
| 2529 uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) | |
| 2530 shift; set dummy --mode uninstall ${1+"$@"}; shift | |
| 2531 ;; | |
| 2532 esac | |
| 2533 | |
| 2534 if $_G_rc_lt_options_prep; then | |
| 2535 # Pass back the list of options. | |
| 2536 func_quote eval ${1+"$@"} | |
| 2537 libtool_options_prep_result=$func_quote_result | |
| 2538 fi | |
| 2539 } | |
| 2540 func_add_hook func_options_prep libtool_options_prep | |
| 2541 | |
| 2542 | |
| 2543 # libtool_parse_options [ARG]... | |
| 2544 # --------------------------------- | |
| 2545 # Provide handling for libtool specific options. | |
| 2546 libtool_parse_options () | |
| 2547 { | |
| 2548 $debug_cmd | |
| 2549 | |
| 2550 # Perform our own loop to consume as many options as possible in | |
| 2551 # each iteration. | |
| 2552 while test $# -gt 0; do | |
| 2553 _G_opt=$1 | |
| 2554 shift | |
| 2555 case $_G_opt in | |
| 2556 --dry-run|--dryrun|-n) | |
| 2557 opt_dry_run=: | |
| 2558 ;; | |
| 2559 | |
| 2560 --config) func_config ;; | |
| 2561 | |
| 2562 --dlopen|-dlopen) | |
| 2563 opt_dlopen="${opt_dlopen+$opt_dlopen | |
| 2564 }$1" | |
| 2565 shift | |
| 2566 ;; | |
| 2567 | |
| 2568 --preserve-dup-deps) | |
| 2569 opt_preserve_dup_deps=: ;; | |
| 2570 | |
| 2571 --features) func_features ;; | |
| 2572 | |
| 2573 --finish) set dummy --mode finish ${1+"$@"}; shift ;; | |
| 2574 | |
| 2575 --help) opt_help=: ;; | |
| 2576 | |
| 2577 --help-all) opt_help=': help-all' ;; | |
| 2578 | |
| 2579 --mode) test $# = 0 && func_missing_arg $_G_opt && break | |
| 2580 opt_mode=$1 | |
| 2581 case $1 in | |
| 2582 # Valid mode arguments: | |
| 2583 clean|compile|execute|finish|install|link|relink|uninstall) ;; | |
| 2584 | |
| 2585 # Catch anything else as an error | |
| 2586 *) func_error "invalid argument for $_G_opt" | |
| 2587 exit_cmd=exit | |
| 2588 break | |
| 2589 ;; | |
| 2590 esac | |
| 2591 shift | |
| 2592 ;; | |
| 2593 | |
| 2594 --no-silent|--no-quiet) | |
| 2595 opt_quiet=false | |
| 2596 func_append preserve_args " $_G_opt" | |
| 2597 ;; | |
| 2598 | |
| 2599 --no-warnings|--no-warning|--no-warn) | |
| 2600 opt_warning=false | |
| 2601 func_append preserve_args " $_G_opt" | |
| 2602 ;; | |
| 2603 | |
| 2604 --no-verbose) | |
| 2605 opt_verbose=false | |
| 2606 func_append preserve_args " $_G_opt" | |
| 2607 ;; | |
| 2608 | |
| 2609 --silent|--quiet) | |
| 2610 opt_quiet=: | |
| 2611 opt_verbose=false | |
| 2612 func_append preserve_args " $_G_opt" | |
| 2613 ;; | |
| 2614 | |
| 2615 --tag) test $# = 0 && func_missing_arg $_G_opt && break | |
| 2616 opt_tag=$1 | |
| 2617 func_append preserve_args " $_G_opt $1" | |
| 2618 func_enable_tag "$1" | |
| 2619 shift | |
| 2620 ;; | |
| 2621 | |
| 2622 --verbose|-v) opt_quiet=false | |
| 2623 opt_verbose=: | |
| 2624 func_append preserve_args " $_G_opt" | |
| 2625 ;; | |
| 2626 | |
| 2627 # An option not handled by this hook function: | |
| 2628 *) set dummy "$_G_opt" ${1+"$@"}; shift; break ;; | |
| 2629 esac | |
| 2630 done | |
| 2631 | |
| 2632 if $_G_rc_lt_parse_options; then | |
| 2633 # save modified positional parameters for caller | |
| 2634 func_quote eval ${1+"$@"} | |
| 2635 libtool_parse_options_result=$func_quote_result | |
| 2636 fi | |
| 2637 } | |
| 2638 func_add_hook func_parse_options libtool_parse_options | |
| 2639 | |
| 2640 | |
| 2641 | |
| 2642 # libtool_validate_options [ARG]... | |
| 2643 # --------------------------------- | |
| 2644 # Perform any sanity checks on option settings and/or unconsumed | |
| 2645 # arguments. | |
| 2646 libtool_validate_options () | |
| 2647 { | |
| 2648 # save first non-option argument | |
| 2649 if test 0 -lt $#; then | |
| 2650 nonopt=$1 | |
| 2651 shift | |
| 2652 fi | |
| 2653 | |
| 2654 # preserve --debug | |
| 2655 test : = "$debug_cmd" || func_append preserve_args " --debug" | |
| 2656 | |
| 2657 case $host in | |
| 2658 # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 | |
| 2659 # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 | |
| 2660 *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) | |
| 2661 # don't eliminate duplications in $postdeps and $predeps | |
| 2662 opt_duplicate_compiler_generated_deps=: | |
| 2663 ;; | |
| 2664 *) | |
| 2665 opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps | |
| 2666 ;; | |
| 2667 esac | |
| 2668 | |
| 2669 $opt_help || { | |
| 2670 # Sanity checks first: | |
| 2671 func_check_version_match | |
| 2672 | |
| 2673 test yes != "$build_libtool_libs" \ | |
| 2674 && test yes != "$build_old_libs" \ | |
| 2675 && func_fatal_configuration "not configured to build any kind of library" | |
| 2676 | |
| 2677 # Darwin sucks | |
| 2678 eval std_shrext=\"$shrext_cmds\" | |
| 2679 | |
| 2680 # Only execute mode is allowed to have -dlopen flags. | |
| 2681 if test -n "$opt_dlopen" && test execute != "$opt_mode"; then | |
| 2682 func_error "unrecognized option '-dlopen'" | |
| 2683 $ECHO "$help" 1>&2 | |
| 2684 exit $EXIT_FAILURE | |
| 2685 fi | |
| 2686 | |
| 2687 # Change the help message to a mode-specific one. | |
| 2688 generic_help=$help | |
| 2689 help="Try '$progname --help --mode=$opt_mode' for more information." | |
| 2690 } | |
| 2691 | |
| 2692 # Pass back the unparsed argument list | |
| 2693 func_quote eval ${1+"$@"} | |
| 2694 libtool_validate_options_result=$func_quote_result | |
| 2695 } | |
| 2696 func_add_hook func_validate_options libtool_validate_options | |
| 2697 | |
| 2698 | |
| 2699 # Process options as early as possible so that --help and --version | |
| 2700 # can return quickly. | |
| 2701 func_options ${1+"$@"} | |
| 2702 eval set dummy "$func_options_result"; shift | |
| 2703 | |
| 2704 | |
| 2705 | |
| 2706 ## ----------- ## | |
| 2707 ## Main. ## | |
| 2708 ## ----------- ## | |
| 2709 | |
| 2710 magic='%%%MAGIC variable%%%' | |
| 2711 magic_exe='%%%MAGIC EXE variable%%%' | |
| 2712 | |
| 2713 # Global variables. | |
| 2714 extracted_archives= | |
| 2715 extracted_serial=0 | |
| 2716 | |
| 2717 # If this variable is set in any of the actions, the command in it | |
| 2718 # will be execed at the end. This prevents here-documents from being | |
| 2719 # left over by shells. | |
| 2720 exec_cmd= | |
| 2721 | |
| 2722 | |
| 2723 # A function that is used when there is no print builtin or printf. | |
| 2724 func_fallback_echo () | |
| 2725 { | |
| 2726 eval 'cat <<_LTECHO_EOF | |
| 2727 $1 | |
| 2728 _LTECHO_EOF' | |
| 2729 } | |
| 2730 | |
| 2731 # func_generated_by_libtool | |
| 2732 # True iff stdin has been generated by Libtool. This function is only | |
| 2733 # a basic sanity check; it will hardly flush out determined imposters. | |
| 2734 func_generated_by_libtool_p () | |
| 2735 { | |
| 2736 $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 | |
| 2737 } | |
| 2738 | |
| 2739 # func_lalib_p file | |
| 2740 # True iff FILE is a libtool '.la' library or '.lo' object file. | |
| 2741 # This function is only a basic sanity check; it will hardly flush out | |
| 2742 # determined imposters. | |
| 2743 func_lalib_p () | |
| 2744 { | |
| 2745 test -f "$1" && | |
| 2746 $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p | |
| 2747 } | |
| 2748 | |
| 2749 # func_lalib_unsafe_p file | |
| 2750 # True iff FILE is a libtool '.la' library or '.lo' object file. | |
| 2751 # This function implements the same check as func_lalib_p without | |
| 2752 # resorting to external programs. To this end, it redirects stdin and | |
| 2753 # closes it afterwards, without saving the original file descriptor. | |
| 2754 # As a safety measure, use it only where a negative result would be | |
| 2755 # fatal anyway. Works if 'file' does not exist. | |
| 2756 func_lalib_unsafe_p () | |
| 2757 { | |
| 2758 lalib_p=no | |
| 2759 if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then | |
| 2760 for lalib_p_l in 1 2 3 4 | |
| 2761 do | |
| 2762 read lalib_p_line | |
| 2763 case $lalib_p_line in | |
| 2764 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; | |
| 2765 esac | |
| 2766 done | |
| 2767 exec 0<&5 5<&- | |
| 2768 fi | |
| 2769 test yes = "$lalib_p" | |
| 2770 } | |
| 2771 | |
| 2772 # func_ltwrapper_script_p file | |
| 2773 # True iff FILE is a libtool wrapper script | |
| 2774 # This function is only a basic sanity check; it will hardly flush out | |
| 2775 # determined imposters. | |
| 2776 func_ltwrapper_script_p () | |
| 2777 { | |
| 2778 test -f "$1" && | |
| 2779 $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p | |
| 2780 } | |
| 2781 | |
| 2782 # func_ltwrapper_executable_p file | |
| 2783 # True iff FILE is a libtool wrapper executable | |
| 2784 # This function is only a basic sanity check; it will hardly flush out | |
| 2785 # determined imposters. | |
| 2786 func_ltwrapper_executable_p () | |
| 2787 { | |
| 2788 func_ltwrapper_exec_suffix= | |
| 2789 case $1 in | |
| 2790 *.exe) ;; | |
| 2791 *) func_ltwrapper_exec_suffix=.exe ;; | |
| 2792 esac | |
| 2793 $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 | |
| 2794 } | |
| 2795 | |
| 2796 # func_ltwrapper_scriptname file | |
| 2797 # Assumes file is an ltwrapper_executable | |
| 2798 # uses $file to determine the appropriate filename for a | |
| 2799 # temporary ltwrapper_script. | |
| 2800 func_ltwrapper_scriptname () | |
| 2801 { | |
| 2802 func_dirname_and_basename "$1" "" "." | |
| 2803 func_stripname '' '.exe' "$func_basename_result" | |
| 2804 func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper | |
| 2805 } | |
| 2806 | |
| 2807 # func_ltwrapper_p file | |
| 2808 # True iff FILE is a libtool wrapper script or wrapper executable | |
| 2809 # This function is only a basic sanity check; it will hardly flush out | |
| 2810 # determined imposters. | |
| 2811 func_ltwrapper_p () | |
| 2812 { | |
| 2813 func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" | |
| 2814 } | |
| 2815 | |
| 2816 | |
| 2817 # func_execute_cmds commands fail_cmd | |
| 2818 # Execute tilde-delimited COMMANDS. | |
| 2819 # If FAIL_CMD is given, eval that upon failure. | |
| 2820 # FAIL_CMD may read-access the current command in variable CMD! | |
| 2821 func_execute_cmds () | |
| 2822 { | |
| 2823 $debug_cmd | |
| 2824 | |
| 2825 save_ifs=$IFS; IFS='~' | |
| 2826 for cmd in $1; do | |
| 2827 IFS=$sp$nl | |
| 2828 eval cmd=\"$cmd\" | |
| 2829 IFS=$save_ifs | |
| 2830 func_show_eval "$cmd" "${2-:}" | |
| 2831 done | |
| 2832 IFS=$save_ifs | |
| 2833 } | |
| 2834 | |
| 2835 | |
| 2836 # func_source file | |
| 2837 # Source FILE, adding directory component if necessary. | |
| 2838 # Note that it is not necessary on cygwin/mingw to append a dot to | |
| 2839 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe | |
| 2840 # behavior happens only for exec(3), not for open(2)! Also, sourcing | |
| 2841 # 'FILE.' does not work on cygwin managed mounts. | |
| 2842 func_source () | |
| 2843 { | |
| 2844 $debug_cmd | |
| 2845 | |
| 2846 case $1 in | |
| 2847 */* | *\\*) . "$1" ;; | |
| 2848 *) . "./$1" ;; | |
| 2849 esac | |
| 2850 } | |
| 2851 | |
| 2852 | |
| 2853 # func_resolve_sysroot PATH | |
| 2854 # Replace a leading = in PATH with a sysroot. Store the result into | |
| 2855 # func_resolve_sysroot_result | |
| 2856 func_resolve_sysroot () | |
| 2857 { | |
| 2858 func_resolve_sysroot_result=$1 | |
| 2859 case $func_resolve_sysroot_result in | |
| 2860 =*) | |
| 2861 func_stripname '=' '' "$func_resolve_sysroot_result" | |
| 2862 func_resolve_sysroot_result=$lt_sysroot$func_stripname_result | |
| 2863 ;; | |
| 2864 esac | |
| 2865 } | |
| 2866 | |
| 2867 # func_replace_sysroot PATH | |
| 2868 # If PATH begins with the sysroot, replace it with = and | |
| 2869 # store the result into func_replace_sysroot_result. | |
| 2870 func_replace_sysroot () | |
| 2871 { | |
| 2872 case $lt_sysroot:$1 in | |
| 2873 ?*:"$lt_sysroot"*) | |
| 2874 func_stripname "$lt_sysroot" '' "$1" | |
| 2875 func_replace_sysroot_result='='$func_stripname_result | |
| 2876 ;; | |
| 2877 *) | |
| 2878 # Including no sysroot. | |
| 2879 func_replace_sysroot_result=$1 | |
| 2880 ;; | |
| 2881 esac | |
| 2882 } | |
| 2883 | |
| 2884 # func_infer_tag arg | |
| 2885 # Infer tagged configuration to use if any are available and | |
| 2886 # if one wasn't chosen via the "--tag" command line option. | |
| 2887 # Only attempt this if the compiler in the base compile | |
| 2888 # command doesn't match the default compiler. | |
| 2889 # arg is usually of the form 'gcc ...' | |
| 2890 func_infer_tag () | |
| 2891 { | |
| 2892 $debug_cmd | |
| 2893 | |
| 2894 if test -n "$available_tags" && test -z "$tagname"; then | |
| 2895 CC_quoted= | |
| 2896 for arg in $CC; do | |
| 2897 func_append_quoted CC_quoted "$arg" | |
| 2898 done | |
| 2899 CC_expanded=`func_echo_all $CC` | |
| 2900 CC_quoted_expanded=`func_echo_all $CC_quoted` | |
| 2901 case $@ in | |
| 2902 # Blanks in the command may have been stripped by the calling shell, | |
| 2903 # but not from the CC environment variable when configure was run. | |
| 2904 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ | |
| 2905 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; | |
| 2906 # Blanks at the start of $base_compile will cause this to fail | |
| 2907 # if we don't check for them as well. | |
| 2908 *) | |
| 2909 for z in $available_tags; do | |
| 2910 if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then | |
| 2911 # Evaluate the configuration. | |
| 2912 eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" | |
| 2913 CC_quoted= | |
| 2914 for arg in $CC; do | |
| 2915 # Double-quote args containing other shell metacharacters. | |
| 2916 func_append_quoted CC_quoted "$arg" | |
| 2917 done | |
| 2918 CC_expanded=`func_echo_all $CC` | |
| 2919 CC_quoted_expanded=`func_echo_all $CC_quoted` | |
| 2920 case "$@ " in | |
| 2921 " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ | |
| 2922 " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) | |
| 2923 # The compiler in the base compile command matches | |
| 2924 # the one in the tagged configuration. | |
| 2925 # Assume this is the tagged configuration we want. | |
| 2926 tagname=$z | |
| 2927 break | |
| 2928 ;; | |
| 2929 esac | |
| 2930 fi | |
| 2931 done | |
| 2932 # If $tagname still isn't set, then no tagged configuration | |
| 2933 # was found and let the user know that the "--tag" command | |
| 2934 # line option must be used. | |
| 2935 if test -z "$tagname"; then | |
| 2936 func_echo "unable to infer tagged configuration" | |
| 2937 func_fatal_error "specify a tag with '--tag'" | |
| 2938 # else | |
| 2939 # func_verbose "using $tagname tagged configuration" | |
| 2940 fi | |
| 2941 ;; | |
| 2942 esac | |
| 2943 fi | |
| 2944 } | |
| 2945 | |
| 2946 | |
| 2947 | |
| 2948 # func_write_libtool_object output_name pic_name nonpic_name | |
| 2949 # Create a libtool object file (analogous to a ".la" file), | |
| 2950 # but don't create it if we're doing a dry run. | |
| 2951 func_write_libtool_object () | |
| 2952 { | |
| 2953 write_libobj=$1 | |
| 2954 if test yes = "$build_libtool_libs"; then | |
| 2955 write_lobj=\'$2\' | |
| 2956 else | |
| 2957 write_lobj=none | |
| 2958 fi | |
| 2959 | |
| 2960 if test yes = "$build_old_libs"; then | |
| 2961 write_oldobj=\'$3\' | |
| 2962 else | |
| 2963 write_oldobj=none | |
| 2964 fi | |
| 2965 | |
| 2966 $opt_dry_run || { | |
| 2967 cat >${write_libobj}T <<EOF | |
| 2968 # $write_libobj - a libtool object file | |
| 2969 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION | |
| 2970 # | |
| 2971 # Please DO NOT delete this file! | |
| 2972 # It is necessary for linking the library. | |
| 2973 | |
| 2974 # Name of the PIC object. | |
| 2975 pic_object=$write_lobj | |
| 2976 | |
| 2977 # Name of the non-PIC object | |
| 2978 non_pic_object=$write_oldobj | |
| 2979 | |
| 2980 EOF | |
| 2981 $MV "${write_libobj}T" "$write_libobj" | |
| 2982 } | |
| 2983 } | |
| 2984 | |
| 2985 | |
| 2986 ################################################## | |
| 2987 # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # | |
| 2988 ################################################## | |
| 2989 | |
| 2990 # func_convert_core_file_wine_to_w32 ARG | |
| 2991 # Helper function used by file name conversion functions when $build is *nix, | |
| 2992 # and $host is mingw, cygwin, or some other w32 environment. Relies on a | |
| 2993 # correctly configured wine environment available, with the winepath program | |
| 2994 # in $build's $PATH. | |
| 2995 # | |
| 2996 # ARG is the $build file name to be converted to w32 format. | |
| 2997 # Result is available in $func_convert_core_file_wine_to_w32_result, and will | |
| 2998 # be empty on error (or when ARG is empty) | |
| 2999 func_convert_core_file_wine_to_w32 () | |
| 3000 { | |
| 3001 $debug_cmd | |
| 3002 | |
| 3003 func_convert_core_file_wine_to_w32_result=$1 | |
| 3004 if test -n "$1"; then | |
| 3005 # Unfortunately, winepath does not exit with a non-zero error code, so we | |
| 3006 # are forced to check the contents of stdout. On the other hand, if the | |
| 3007 # command is not found, the shell will set an exit code of 127 and print | |
| 3008 # *an error message* to stdout. So we must check for both error code of | |
| 3009 # zero AND non-empty stdout, which explains the odd construction: | |
| 3010 func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` | |
| 3011 if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then | |
| 3012 func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | | |
| 3013 $SED -e "$sed_naive_backslashify"` | |
| 3014 else | |
| 3015 func_convert_core_file_wine_to_w32_result= | |
| 3016 fi | |
| 3017 fi | |
| 3018 } | |
| 3019 # end: func_convert_core_file_wine_to_w32 | |
| 3020 | |
| 3021 | |
| 3022 # func_convert_core_path_wine_to_w32 ARG | |
| 3023 # Helper function used by path conversion functions when $build is *nix, and | |
| 3024 # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly | |
| 3025 # configured wine environment available, with the winepath program in $build's | |
| 3026 # $PATH. Assumes ARG has no leading or trailing path separator characters. | |
| 3027 # | |
| 3028 # ARG is path to be converted from $build format to win32. | |
| 3029 # Result is available in $func_convert_core_path_wine_to_w32_result. | |
| 3030 # Unconvertible file (directory) names in ARG are skipped; if no directory names | |
| 3031 # are convertible, then the result may be empty. | |
| 3032 func_convert_core_path_wine_to_w32 () | |
| 3033 { | |
| 3034 $debug_cmd | |
| 3035 | |
| 3036 # unfortunately, winepath doesn't convert paths, only file names | |
| 3037 func_convert_core_path_wine_to_w32_result= | |
| 3038 if test -n "$1"; then | |
| 3039 oldIFS=$IFS | |
| 3040 IFS=: | |
| 3041 for func_convert_core_path_wine_to_w32_f in $1; do | |
| 3042 IFS=$oldIFS | |
| 3043 func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" | |
| 3044 if test -n "$func_convert_core_file_wine_to_w32_result"; then | |
| 3045 if test -z "$func_convert_core_path_wine_to_w32_result"; then | |
| 3046 func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result | |
| 3047 else | |
| 3048 func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" | |
| 3049 fi | |
| 3050 fi | |
| 3051 done | |
| 3052 IFS=$oldIFS | |
| 3053 fi | |
| 3054 } | |
| 3055 # end: func_convert_core_path_wine_to_w32 | |
| 3056 | |
| 3057 | |
| 3058 # func_cygpath ARGS... | |
| 3059 # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when | |
| 3060 # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) | |
| 3061 # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or | |
| 3062 # (2), returns the Cygwin file name or path in func_cygpath_result (input | |
| 3063 # file name or path is assumed to be in w32 format, as previously converted | |
| 3064 # from $build's *nix or MSYS format). In case (3), returns the w32 file name | |
| 3065 # or path in func_cygpath_result (input file name or path is assumed to be in | |
| 3066 # Cygwin format). Returns an empty string on error. | |
| 3067 # | |
| 3068 # ARGS are passed to cygpath, with the last one being the file name or path to | |
| 3069 # be converted. | |
| 3070 # | |
| 3071 # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH | |
| 3072 # environment variable; do not put it in $PATH. | |
| 3073 func_cygpath () | |
| 3074 { | |
| 3075 $debug_cmd | |
| 3076 | |
| 3077 if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then | |
| 3078 func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` | |
| 3079 if test "$?" -ne 0; then | |
| 3080 # on failure, ensure result is empty | |
| 3081 func_cygpath_result= | |
| 3082 fi | |
| 3083 else | |
| 3084 func_cygpath_result= | |
| 3085 func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" | |
| 3086 fi | |
| 3087 } | |
| 3088 #end: func_cygpath | |
| 3089 | |
| 3090 | |
| 3091 # func_convert_core_msys_to_w32 ARG | |
| 3092 # Convert file name or path ARG from MSYS format to w32 format. Return | |
| 3093 # result in func_convert_core_msys_to_w32_result. | |
| 3094 func_convert_core_msys_to_w32 () | |
| 3095 { | |
| 3096 $debug_cmd | |
| 3097 | |
| 3098 # awkward: cmd appends spaces to result | |
| 3099 func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | | |
| 3100 $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` | |
| 3101 } | |
| 3102 #end: func_convert_core_msys_to_w32 | |
| 3103 | |
| 3104 | |
| 3105 # func_convert_file_check ARG1 ARG2 | |
| 3106 # Verify that ARG1 (a file name in $build format) was converted to $host | |
| 3107 # format in ARG2. Otherwise, emit an error message, but continue (resetting | |
| 3108 # func_to_host_file_result to ARG1). | |
| 3109 func_convert_file_check () | |
| 3110 { | |
| 3111 $debug_cmd | |
| 3112 | |
| 3113 if test -z "$2" && test -n "$1"; then | |
| 3114 func_error "Could not determine host file name corresponding to" | |
| 3115 func_error " '$1'" | |
| 3116 func_error "Continuing, but uninstalled executables may not work." | |
| 3117 # Fallback: | |
| 3118 func_to_host_file_result=$1 | |
| 3119 fi | |
| 3120 } | |
| 3121 # end func_convert_file_check | |
| 3122 | |
| 3123 | |
| 3124 # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH | |
| 3125 # Verify that FROM_PATH (a path in $build format) was converted to $host | |
| 3126 # format in TO_PATH. Otherwise, emit an error message, but continue, resetting | |
| 3127 # func_to_host_file_result to a simplistic fallback value (see below). | |
| 3128 func_convert_path_check () | |
| 3129 { | |
| 3130 $debug_cmd | |
| 3131 | |
| 3132 if test -z "$4" && test -n "$3"; then | |
| 3133 func_error "Could not determine the host path corresponding to" | |
| 3134 func_error " '$3'" | |
| 3135 func_error "Continuing, but uninstalled executables may not work." | |
| 3136 # Fallback. This is a deliberately simplistic "conversion" and | |
| 3137 # should not be "improved". See libtool.info. | |
| 3138 if test "x$1" != "x$2"; then | |
| 3139 lt_replace_pathsep_chars="s|$1|$2|g" | |
| 3140 func_to_host_path_result=`echo "$3" | | |
| 3141 $SED -e "$lt_replace_pathsep_chars"` | |
| 3142 else | |
| 3143 func_to_host_path_result=$3 | |
| 3144 fi | |
| 3145 fi | |
| 3146 } | |
| 3147 # end func_convert_path_check | |
| 3148 | |
| 3149 | |
| 3150 # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG | |
| 3151 # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT | |
| 3152 # and appending REPL if ORIG matches BACKPAT. | |
| 3153 func_convert_path_front_back_pathsep () | |
| 3154 { | |
| 3155 $debug_cmd | |
| 3156 | |
| 3157 case $4 in | |
| 3158 $1 ) func_to_host_path_result=$3$func_to_host_path_result | |
| 3159 ;; | |
| 3160 esac | |
| 3161 case $4 in | |
| 3162 $2 ) func_append func_to_host_path_result "$3" | |
| 3163 ;; | |
| 3164 esac | |
| 3165 } | |
| 3166 # end func_convert_path_front_back_pathsep | |
| 3167 | |
| 3168 | |
| 3169 ################################################## | |
| 3170 # $build to $host FILE NAME CONVERSION FUNCTIONS # | |
| 3171 ################################################## | |
| 3172 # invoked via '$to_host_file_cmd ARG' | |
| 3173 # | |
| 3174 # In each case, ARG is the path to be converted from $build to $host format. | |
| 3175 # Result will be available in $func_to_host_file_result. | |
| 3176 | |
| 3177 | |
| 3178 # func_to_host_file ARG | |
| 3179 # Converts the file name ARG from $build format to $host format. Return result | |
| 3180 # in func_to_host_file_result. | |
| 3181 func_to_host_file () | |
| 3182 { | |
| 3183 $debug_cmd | |
| 3184 | |
| 3185 $to_host_file_cmd "$1" | |
| 3186 } | |
| 3187 # end func_to_host_file | |
| 3188 | |
| 3189 | |
| 3190 # func_to_tool_file ARG LAZY | |
| 3191 # converts the file name ARG from $build format to toolchain format. Return | |
| 3192 # result in func_to_tool_file_result. If the conversion in use is listed | |
| 3193 # in (the comma separated) LAZY, no conversion takes place. | |
| 3194 func_to_tool_file () | |
| 3195 { | |
| 3196 $debug_cmd | |
| 3197 | |
| 3198 case ,$2, in | |
| 3199 *,"$to_tool_file_cmd",*) | |
| 3200 func_to_tool_file_result=$1 | |
| 3201 ;; | |
| 3202 *) | |
| 3203 $to_tool_file_cmd "$1" | |
| 3204 func_to_tool_file_result=$func_to_host_file_result | |
| 3205 ;; | |
| 3206 esac | |
| 3207 } | |
| 3208 # end func_to_tool_file | |
| 3209 | |
| 3210 | |
| 3211 # func_convert_file_noop ARG | |
| 3212 # Copy ARG to func_to_host_file_result. | |
| 3213 func_convert_file_noop () | |
| 3214 { | |
| 3215 func_to_host_file_result=$1 | |
| 3216 } | |
| 3217 # end func_convert_file_noop | |
| 3218 | |
| 3219 | |
| 3220 # func_convert_file_msys_to_w32 ARG | |
| 3221 # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic | |
| 3222 # conversion to w32 is not available inside the cwrapper. Returns result in | |
| 3223 # func_to_host_file_result. | |
| 3224 func_convert_file_msys_to_w32 () | |
| 3225 { | |
| 3226 $debug_cmd | |
| 3227 | |
| 3228 func_to_host_file_result=$1 | |
| 3229 if test -n "$1"; then | |
| 3230 func_convert_core_msys_to_w32 "$1" | |
| 3231 func_to_host_file_result=$func_convert_core_msys_to_w32_result | |
| 3232 fi | |
| 3233 func_convert_file_check "$1" "$func_to_host_file_result" | |
| 3234 } | |
| 3235 # end func_convert_file_msys_to_w32 | |
| 3236 | |
| 3237 | |
| 3238 # func_convert_file_cygwin_to_w32 ARG | |
| 3239 # Convert file name ARG from Cygwin to w32 format. Returns result in | |
| 3240 # func_to_host_file_result. | |
| 3241 func_convert_file_cygwin_to_w32 () | |
| 3242 { | |
| 3243 $debug_cmd | |
| 3244 | |
| 3245 func_to_host_file_result=$1 | |
| 3246 if test -n "$1"; then | |
| 3247 # because $build is cygwin, we call "the" cygpath in $PATH; no need to use | |
| 3248 # LT_CYGPATH in this case. | |
| 3249 func_to_host_file_result=`cygpath -m "$1"` | |
| 3250 fi | |
| 3251 func_convert_file_check "$1" "$func_to_host_file_result" | |
| 3252 } | |
| 3253 # end func_convert_file_cygwin_to_w32 | |
| 3254 | |
| 3255 | |
| 3256 # func_convert_file_nix_to_w32 ARG | |
| 3257 # Convert file name ARG from *nix to w32 format. Requires a wine environment | |
| 3258 # and a working winepath. Returns result in func_to_host_file_result. | |
| 3259 func_convert_file_nix_to_w32 () | |
| 3260 { | |
| 3261 $debug_cmd | |
| 3262 | |
| 3263 func_to_host_file_result=$1 | |
| 3264 if test -n "$1"; then | |
| 3265 func_convert_core_file_wine_to_w32 "$1" | |
| 3266 func_to_host_file_result=$func_convert_core_file_wine_to_w32_result | |
| 3267 fi | |
| 3268 func_convert_file_check "$1" "$func_to_host_file_result" | |
| 3269 } | |
| 3270 # end func_convert_file_nix_to_w32 | |
| 3271 | |
| 3272 | |
| 3273 # func_convert_file_msys_to_cygwin ARG | |
| 3274 # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. | |
| 3275 # Returns result in func_to_host_file_result. | |
| 3276 func_convert_file_msys_to_cygwin () | |
| 3277 { | |
| 3278 $debug_cmd | |
| 3279 | |
| 3280 func_to_host_file_result=$1 | |
| 3281 if test -n "$1"; then | |
| 3282 func_convert_core_msys_to_w32 "$1" | |
| 3283 func_cygpath -u "$func_convert_core_msys_to_w32_result" | |
| 3284 func_to_host_file_result=$func_cygpath_result | |
| 3285 fi | |
| 3286 func_convert_file_check "$1" "$func_to_host_file_result" | |
| 3287 } | |
| 3288 # end func_convert_file_msys_to_cygwin | |
| 3289 | |
| 3290 | |
| 3291 # func_convert_file_nix_to_cygwin ARG | |
| 3292 # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed | |
| 3293 # in a wine environment, working winepath, and LT_CYGPATH set. Returns result | |
| 3294 # in func_to_host_file_result. | |
| 3295 func_convert_file_nix_to_cygwin () | |
| 3296 { | |
| 3297 $debug_cmd | |
| 3298 | |
| 3299 func_to_host_file_result=$1 | |
| 3300 if test -n "$1"; then | |
| 3301 # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. | |
| 3302 func_convert_core_file_wine_to_w32 "$1" | |
| 3303 func_cygpath -u "$func_convert_core_file_wine_to_w32_result" | |
| 3304 func_to_host_file_result=$func_cygpath_result | |
| 3305 fi | |
| 3306 func_convert_file_check "$1" "$func_to_host_file_result" | |
| 3307 } | |
| 3308 # end func_convert_file_nix_to_cygwin | |
| 3309 | |
| 3310 | |
| 3311 ############################################# | |
| 3312 # $build to $host PATH CONVERSION FUNCTIONS # | |
| 3313 ############################################# | |
| 3314 # invoked via '$to_host_path_cmd ARG' | |
| 3315 # | |
| 3316 # In each case, ARG is the path to be converted from $build to $host format. | |
| 3317 # The result will be available in $func_to_host_path_result. | |
| 3318 # | |
| 3319 # Path separators are also converted from $build format to $host format. If | |
| 3320 # ARG begins or ends with a path separator character, it is preserved (but | |
| 3321 # converted to $host format) on output. | |
| 3322 # | |
| 3323 # All path conversion functions are named using the following convention: | |
| 3324 # file name conversion function : func_convert_file_X_to_Y () | |
| 3325 # path conversion function : func_convert_path_X_to_Y () | |
| 3326 # where, for any given $build/$host combination the 'X_to_Y' value is the | |
| 3327 # same. If conversion functions are added for new $build/$host combinations, | |
| 3328 # the two new functions must follow this pattern, or func_init_to_host_path_cmd | |
| 3329 # will break. | |
| 3330 | |
| 3331 | |
| 3332 # func_init_to_host_path_cmd | |
| 3333 # Ensures that function "pointer" variable $to_host_path_cmd is set to the | |
| 3334 # appropriate value, based on the value of $to_host_file_cmd. | |
| 3335 to_host_path_cmd= | |
| 3336 func_init_to_host_path_cmd () | |
| 3337 { | |
| 3338 $debug_cmd | |
| 3339 | |
| 3340 if test -z "$to_host_path_cmd"; then | |
| 3341 func_stripname 'func_convert_file_' '' "$to_host_file_cmd" | |
| 3342 to_host_path_cmd=func_convert_path_$func_stripname_result | |
| 3343 fi | |
| 3344 } | |
| 3345 | |
| 3346 | |
| 3347 # func_to_host_path ARG | |
| 3348 # Converts the path ARG from $build format to $host format. Return result | |
| 3349 # in func_to_host_path_result. | |
| 3350 func_to_host_path () | |
| 3351 { | |
| 3352 $debug_cmd | |
| 3353 | |
| 3354 func_init_to_host_path_cmd | |
| 3355 $to_host_path_cmd "$1" | |
| 3356 } | |
| 3357 # end func_to_host_path | |
| 3358 | |
| 3359 | |
| 3360 # func_convert_path_noop ARG | |
| 3361 # Copy ARG to func_to_host_path_result. | |
| 3362 func_convert_path_noop () | |
| 3363 { | |
| 3364 func_to_host_path_result=$1 | |
| 3365 } | |
| 3366 # end func_convert_path_noop | |
| 3367 | |
| 3368 | |
| 3369 # func_convert_path_msys_to_w32 ARG | |
| 3370 # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic | |
| 3371 # conversion to w32 is not available inside the cwrapper. Returns result in | |
| 3372 # func_to_host_path_result. | |
| 3373 func_convert_path_msys_to_w32 () | |
| 3374 { | |
| 3375 $debug_cmd | |
| 3376 | |
| 3377 func_to_host_path_result=$1 | |
| 3378 if test -n "$1"; then | |
| 3379 # Remove leading and trailing path separator characters from ARG. MSYS | |
| 3380 # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; | |
| 3381 # and winepath ignores them completely. | |
| 3382 func_stripname : : "$1" | |
| 3383 func_to_host_path_tmp1=$func_stripname_result | |
| 3384 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" | |
| 3385 func_to_host_path_result=$func_convert_core_msys_to_w32_result | |
| 3386 func_convert_path_check : ";" \ | |
| 3387 "$func_to_host_path_tmp1" "$func_to_host_path_result" | |
| 3388 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" | |
| 3389 fi | |
| 3390 } | |
| 3391 # end func_convert_path_msys_to_w32 | |
| 3392 | |
| 3393 | |
| 3394 # func_convert_path_cygwin_to_w32 ARG | |
| 3395 # Convert path ARG from Cygwin to w32 format. Returns result in | |
| 3396 # func_to_host_file_result. | |
| 3397 func_convert_path_cygwin_to_w32 () | |
| 3398 { | |
| 3399 $debug_cmd | |
| 3400 | |
| 3401 func_to_host_path_result=$1 | |
| 3402 if test -n "$1"; then | |
| 3403 # See func_convert_path_msys_to_w32: | |
| 3404 func_stripname : : "$1" | |
| 3405 func_to_host_path_tmp1=$func_stripname_result | |
| 3406 func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` | |
| 3407 func_convert_path_check : ";" \ | |
| 3408 "$func_to_host_path_tmp1" "$func_to_host_path_result" | |
| 3409 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" | |
| 3410 fi | |
| 3411 } | |
| 3412 # end func_convert_path_cygwin_to_w32 | |
| 3413 | |
| 3414 | |
| 3415 # func_convert_path_nix_to_w32 ARG | |
| 3416 # Convert path ARG from *nix to w32 format. Requires a wine environment and | |
| 3417 # a working winepath. Returns result in func_to_host_file_result. | |
| 3418 func_convert_path_nix_to_w32 () | |
| 3419 { | |
| 3420 $debug_cmd | |
| 3421 | |
| 3422 func_to_host_path_result=$1 | |
| 3423 if test -n "$1"; then | |
| 3424 # See func_convert_path_msys_to_w32: | |
| 3425 func_stripname : : "$1" | |
| 3426 func_to_host_path_tmp1=$func_stripname_result | |
| 3427 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" | |
| 3428 func_to_host_path_result=$func_convert_core_path_wine_to_w32_result | |
| 3429 func_convert_path_check : ";" \ | |
| 3430 "$func_to_host_path_tmp1" "$func_to_host_path_result" | |
| 3431 func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" | |
| 3432 fi | |
| 3433 } | |
| 3434 # end func_convert_path_nix_to_w32 | |
| 3435 | |
| 3436 | |
| 3437 # func_convert_path_msys_to_cygwin ARG | |
| 3438 # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. | |
| 3439 # Returns result in func_to_host_file_result. | |
| 3440 func_convert_path_msys_to_cygwin () | |
| 3441 { | |
| 3442 $debug_cmd | |
| 3443 | |
| 3444 func_to_host_path_result=$1 | |
| 3445 if test -n "$1"; then | |
| 3446 # See func_convert_path_msys_to_w32: | |
| 3447 func_stripname : : "$1" | |
| 3448 func_to_host_path_tmp1=$func_stripname_result | |
| 3449 func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" | |
| 3450 func_cygpath -u -p "$func_convert_core_msys_to_w32_result" | |
| 3451 func_to_host_path_result=$func_cygpath_result | |
| 3452 func_convert_path_check : : \ | |
| 3453 "$func_to_host_path_tmp1" "$func_to_host_path_result" | |
| 3454 func_convert_path_front_back_pathsep ":*" "*:" : "$1" | |
| 3455 fi | |
| 3456 } | |
| 3457 # end func_convert_path_msys_to_cygwin | |
| 3458 | |
| 3459 | |
| 3460 # func_convert_path_nix_to_cygwin ARG | |
| 3461 # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a | |
| 3462 # a wine environment, working winepath, and LT_CYGPATH set. Returns result in | |
| 3463 # func_to_host_file_result. | |
| 3464 func_convert_path_nix_to_cygwin () | |
| 3465 { | |
| 3466 $debug_cmd | |
| 3467 | |
| 3468 func_to_host_path_result=$1 | |
| 3469 if test -n "$1"; then | |
| 3470 # Remove leading and trailing path separator characters from | |
| 3471 # ARG. msys behavior is inconsistent here, cygpath turns them | |
| 3472 # into '.;' and ';.', and winepath ignores them completely. | |
| 3473 func_stripname : : "$1" | |
| 3474 func_to_host_path_tmp1=$func_stripname_result | |
| 3475 func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" | |
| 3476 func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" | |
| 3477 func_to_host_path_result=$func_cygpath_result | |
| 3478 func_convert_path_check : : \ | |
| 3479 "$func_to_host_path_tmp1" "$func_to_host_path_result" | |
| 3480 func_convert_path_front_back_pathsep ":*" "*:" : "$1" | |
| 3481 fi | |
| 3482 } | |
| 3483 # end func_convert_path_nix_to_cygwin | |
| 3484 | |
| 3485 | |
| 3486 # func_dll_def_p FILE | |
| 3487 # True iff FILE is a Windows DLL '.def' file. | |
| 3488 # Keep in sync with _LT_DLL_DEF_P in libtool.m4 | |
| 3489 func_dll_def_p () | |
| 3490 { | |
| 3491 $debug_cmd | |
| 3492 | |
| 3493 func_dll_def_p_tmp=`$SED -n \ | |
| 3494 -e 's/^[ ]*//' \ | |
| 3495 -e '/^\(;.*\)*$/d' \ | |
| 3496 -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ | |
| 3497 -e q \ | |
| 3498 "$1"` | |
| 3499 test DEF = "$func_dll_def_p_tmp" | |
| 3500 } | |
| 3501 | |
| 3502 | |
| 3503 # func_mode_compile arg... | |
| 3504 func_mode_compile () | |
| 3505 { | |
| 3506 $debug_cmd | |
| 3507 | |
| 3508 # Get the compilation command and the source file. | |
| 3509 base_compile= | |
| 3510 srcfile=$nonopt # always keep a non-empty value in "srcfile" | |
| 3511 suppress_opt=yes | |
| 3512 suppress_output= | |
| 3513 arg_mode=normal | |
| 3514 libobj= | |
| 3515 later= | |
| 3516 pie_flag= | |
| 3517 | |
| 3518 for arg | |
| 3519 do | |
| 3520 case $arg_mode in | |
| 3521 arg ) | |
| 3522 # do not "continue". Instead, add this to base_compile | |
| 3523 lastarg=$arg | |
| 3524 arg_mode=normal | |
| 3525 ;; | |
| 3526 | |
| 3527 target ) | |
| 3528 libobj=$arg | |
| 3529 arg_mode=normal | |
| 3530 continue | |
| 3531 ;; | |
| 3532 | |
| 3533 normal ) | |
| 3534 # Accept any command-line options. | |
| 3535 case $arg in | |
| 3536 -o) | |
| 3537 test -n "$libobj" && \ | |
| 3538 func_fatal_error "you cannot specify '-o' more than once" | |
| 3539 arg_mode=target | |
| 3540 continue | |
| 3541 ;; | |
| 3542 | |
| 3543 -pie | -fpie | -fPIE) | |
| 3544 func_append pie_flag " $arg" | |
| 3545 continue | |
| 3546 ;; | |
| 3547 | |
| 3548 -shared | -static | -prefer-pic | -prefer-non-pic) | |
| 3549 func_append later " $arg" | |
| 3550 continue | |
| 3551 ;; | |
| 3552 | |
| 3553 -no-suppress) | |
| 3554 suppress_opt=no | |
| 3555 continue | |
| 3556 ;; | |
| 3557 | |
| 3558 -Xcompiler) | |
| 3559 arg_mode=arg # the next one goes into the "base_compile" arg list | |
| 3560 continue # The current "srcfile" will either be retained or | |
| 3561 ;; # replaced later. I would guess that would be a bug. | |
| 3562 | |
| 3563 -Wc,*) | |
| 3564 func_stripname '-Wc,' '' "$arg" | |
| 3565 args=$func_stripname_result | |
| 3566 lastarg= | |
| 3567 save_ifs=$IFS; IFS=, | |
| 3568 for arg in $args; do | |
| 3569 IFS=$save_ifs | |
| 3570 func_append_quoted lastarg "$arg" | |
| 3571 done | |
| 3572 IFS=$save_ifs | |
| 3573 func_stripname ' ' '' "$lastarg" | |
| 3574 lastarg=$func_stripname_result | |
| 3575 | |
| 3576 # Add the arguments to base_compile. | |
| 3577 func_append base_compile " $lastarg" | |
| 3578 continue | |
| 3579 ;; | |
| 3580 | |
| 3581 *) | |
| 3582 # Accept the current argument as the source file. | |
| 3583 # The previous "srcfile" becomes the current argument. | |
| 3584 # | |
| 3585 lastarg=$srcfile | |
| 3586 srcfile=$arg | |
| 3587 ;; | |
| 3588 esac # case $arg | |
| 3589 ;; | |
| 3590 esac # case $arg_mode | |
| 3591 | |
| 3592 # Aesthetically quote the previous argument. | |
| 3593 func_append_quoted base_compile "$lastarg" | |
| 3594 done # for arg | |
| 3595 | |
| 3596 case $arg_mode in | |
| 3597 arg) | |
| 3598 func_fatal_error "you must specify an argument for -Xcompile" | |
| 3599 ;; | |
| 3600 target) | |
| 3601 func_fatal_error "you must specify a target with '-o'" | |
| 3602 ;; | |
| 3603 *) | |
| 3604 # Get the name of the library object. | |
| 3605 test -z "$libobj" && { | |
| 3606 func_basename "$srcfile" | |
| 3607 libobj=$func_basename_result | |
| 3608 } | |
| 3609 ;; | |
| 3610 esac | |
| 3611 | |
| 3612 # Recognize several different file suffixes. | |
| 3613 # If the user specifies -o file.o, it is replaced with file.lo | |
| 3614 case $libobj in | |
| 3615 *.[cCFSifmso] | \ | |
| 3616 *.ada | *.adb | *.ads | *.asm | \ | |
| 3617 *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ | |
| 3618 *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) | |
| 3619 func_xform "$libobj" | |
| 3620 libobj=$func_xform_result | |
| 3621 ;; | |
| 3622 esac | |
| 3623 | |
| 3624 case $libobj in | |
| 3625 *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; | |
| 3626 *) | |
| 3627 func_fatal_error "cannot determine name of library object from '$libobj'" | |
| 3628 ;; | |
| 3629 esac | |
| 3630 | |
| 3631 func_infer_tag $base_compile | |
| 3632 | |
| 3633 for arg in $later; do | |
| 3634 case $arg in | |
| 3635 -shared) | |
| 3636 test yes = "$build_libtool_libs" \ | |
| 3637 || func_fatal_configuration "cannot build a shared library" | |
| 3638 build_old_libs=no | |
| 3639 continue | |
| 3640 ;; | |
| 3641 | |
| 3642 -static) | |
| 3643 build_libtool_libs=no | |
| 3644 build_old_libs=yes | |
| 3645 continue | |
| 3646 ;; | |
| 3647 | |
| 3648 -prefer-pic) | |
| 3649 pic_mode=yes | |
| 3650 continue | |
| 3651 ;; | |
| 3652 | |
| 3653 -prefer-non-pic) | |
| 3654 pic_mode=no | |
| 3655 continue | |
| 3656 ;; | |
| 3657 esac | |
| 3658 done | |
| 3659 | |
| 3660 func_quote_arg pretty "$libobj" | |
| 3661 test "X$libobj" != "X$func_quote_arg_result" \ | |
| 3662 && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ | |
| 3663 && func_warning "libobj name '$libobj' may not contain shell special characters." | |
| 3664 func_dirname_and_basename "$obj" "/" "" | |
| 3665 objname=$func_basename_result | |
| 3666 xdir=$func_dirname_result | |
| 3667 lobj=$xdir$objdir/$objname | |
| 3668 | |
| 3669 test -z "$base_compile" && \ | |
| 3670 func_fatal_help "you must specify a compilation command" | |
| 3671 | |
| 3672 # Delete any leftover library objects. | |
| 3673 if test yes = "$build_old_libs"; then | |
| 3674 removelist="$obj $lobj $libobj ${libobj}T" | |
| 3675 else | |
| 3676 removelist="$lobj $libobj ${libobj}T" | |
| 3677 fi | |
| 3678 | |
| 3679 # On Cygwin there's no "real" PIC flag so we must build both object types | |
| 3680 case $host_os in | |
| 3681 cygwin* | mingw* | pw32* | os2* | cegcc*) | |
| 3682 pic_mode=default | |
| 3683 ;; | |
| 3684 esac | |
| 3685 if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then | |
| 3686 # non-PIC code in shared libraries is not supported | |
| 3687 pic_mode=default | |
| 3688 fi | |
| 3689 | |
| 3690 # Calculate the filename of the output object if compiler does | |
| 3691 # not support -o with -c | |
| 3692 if test no = "$compiler_c_o"; then | |
| 3693 output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext | |
| 3694 lockfile=$output_obj.lock | |
| 3695 else | |
| 3696 output_obj= | |
| 3697 need_locks=no | |
| 3698 lockfile= | |
| 3699 fi | |
| 3700 | |
| 3701 # Lock this critical section if it is needed | |
| 3702 # We use this script file to make the link, it avoids creating a new file | |
| 3703 if test yes = "$need_locks"; then | |
| 3704 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do | |
| 3705 func_echo "Waiting for $lockfile to be removed" | |
| 3706 sleep 2 | |
| 3707 done | |
| 3708 elif test warn = "$need_locks"; then | |
| 3709 if test -f "$lockfile"; then | |
| 3710 $ECHO "\ | |
| 3711 *** ERROR, $lockfile exists and contains: | |
| 3712 `cat $lockfile 2>/dev/null` | |
| 3713 | |
| 3714 This indicates that another process is trying to use the same | |
| 3715 temporary object file, and libtool could not work around it because | |
| 3716 your compiler does not support '-c' and '-o' together. If you | |
| 3717 repeat this compilation, it may succeed, by chance, but you had better | |
| 3718 avoid parallel builds (make -j) in this platform, or get a better | |
| 3719 compiler." | |
| 3720 | |
| 3721 $opt_dry_run || $RM $removelist | |
| 3722 exit $EXIT_FAILURE | |
| 3723 fi | |
| 3724 func_append removelist " $output_obj" | |
| 3725 $ECHO "$srcfile" > "$lockfile" | |
| 3726 fi | |
| 3727 | |
| 3728 $opt_dry_run || $RM $removelist | |
| 3729 func_append removelist " $lockfile" | |
| 3730 trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 | |
| 3731 | |
| 3732 func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 | |
| 3733 srcfile=$func_to_tool_file_result | |
| 3734 func_quote_arg pretty "$srcfile" | |
| 3735 qsrcfile=$func_quote_arg_result | |
| 3736 | |
| 3737 # Only build a PIC object if we are building libtool libraries. | |
| 3738 if test yes = "$build_libtool_libs"; then | |
| 3739 # Without this assignment, base_compile gets emptied. | |
| 3740 fbsd_hideous_sh_bug=$base_compile | |
| 3741 | |
| 3742 if test no != "$pic_mode"; then | |
| 3743 command="$base_compile $qsrcfile $pic_flag" | |
| 3744 else | |
| 3745 # Don't build PIC code | |
| 3746 command="$base_compile $qsrcfile" | |
| 3747 fi | |
| 3748 | |
| 3749 func_mkdir_p "$xdir$objdir" | |
| 3750 | |
| 3751 if test -z "$output_obj"; then | |
| 3752 # Place PIC objects in $objdir | |
| 3753 func_append command " -o $lobj" | |
| 3754 fi | |
| 3755 | |
| 3756 func_show_eval_locale "$command" \ | |
| 3757 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' | |
| 3758 | |
| 3759 if test warn = "$need_locks" && | |
| 3760 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then | |
| 3761 $ECHO "\ | |
| 3762 *** ERROR, $lockfile contains: | |
| 3763 `cat $lockfile 2>/dev/null` | |
| 3764 | |
| 3765 but it should contain: | |
| 3766 $srcfile | |
| 3767 | |
| 3768 This indicates that another process is trying to use the same | |
| 3769 temporary object file, and libtool could not work around it because | |
| 3770 your compiler does not support '-c' and '-o' together. If you | |
| 3771 repeat this compilation, it may succeed, by chance, but you had better | |
| 3772 avoid parallel builds (make -j) in this platform, or get a better | |
| 3773 compiler." | |
| 3774 | |
| 3775 $opt_dry_run || $RM $removelist | |
| 3776 exit $EXIT_FAILURE | |
| 3777 fi | |
| 3778 | |
| 3779 # Just move the object if needed, then go on to compile the next one | |
| 3780 if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then | |
| 3781 func_show_eval '$MV "$output_obj" "$lobj"' \ | |
| 3782 'error=$?; $opt_dry_run || $RM $removelist; exit $error' | |
| 3783 fi | |
| 3784 | |
| 3785 # Allow error messages only from the first compilation. | |
| 3786 if test yes = "$suppress_opt"; then | |
| 3787 suppress_output=' >/dev/null 2>&1' | |
| 3788 fi | |
| 3789 fi | |
| 3790 | |
| 3791 # Only build a position-dependent object if we build old libraries. | |
| 3792 if test yes = "$build_old_libs"; then | |
| 3793 if test yes != "$pic_mode"; then | |
| 3794 # Don't build PIC code | |
| 3795 command="$base_compile $qsrcfile$pie_flag" | |
| 3796 else | |
| 3797 command="$base_compile $qsrcfile $pic_flag" | |
| 3798 fi | |
| 3799 if test yes = "$compiler_c_o"; then | |
| 3800 func_append command " -o $obj" | |
| 3801 fi | |
| 3802 | |
| 3803 # Suppress compiler output if we already did a PIC compilation. | |
| 3804 func_append command "$suppress_output" | |
| 3805 func_show_eval_locale "$command" \ | |
| 3806 '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' | |
| 3807 | |
| 3808 if test warn = "$need_locks" && | |
| 3809 test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then | |
| 3810 $ECHO "\ | |
| 3811 *** ERROR, $lockfile contains: | |
| 3812 `cat $lockfile 2>/dev/null` | |
| 3813 | |
| 3814 but it should contain: | |
| 3815 $srcfile | |
| 3816 | |
| 3817 This indicates that another process is trying to use the same | |
| 3818 temporary object file, and libtool could not work around it because | |
| 3819 your compiler does not support '-c' and '-o' together. If you | |
| 3820 repeat this compilation, it may succeed, by chance, but you had better | |
| 3821 avoid parallel builds (make -j) in this platform, or get a better | |
| 3822 compiler." | |
| 3823 | |
| 3824 $opt_dry_run || $RM $removelist | |
| 3825 exit $EXIT_FAILURE | |
| 3826 fi | |
| 3827 | |
| 3828 # Just move the object if needed | |
| 3829 if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then | |
| 3830 func_show_eval '$MV "$output_obj" "$obj"' \ | |
| 3831 'error=$?; $opt_dry_run || $RM $removelist; exit $error' | |
| 3832 fi | |
| 3833 fi | |
| 3834 | |
| 3835 $opt_dry_run || { | |
| 3836 func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" | |
| 3837 | |
| 3838 # Unlock the critical section if it was locked | |
| 3839 if test no != "$need_locks"; then | |
| 3840 removelist=$lockfile | |
| 3841 $RM "$lockfile" | |
| 3842 fi | |
| 3843 } | |
| 3844 | |
| 3845 exit $EXIT_SUCCESS | |
| 3846 } | |
| 3847 | |
| 3848 $opt_help || { | |
| 3849 test compile = "$opt_mode" && func_mode_compile ${1+"$@"} | |
| 3850 } | |
| 3851 | |
| 3852 func_mode_help () | |
| 3853 { | |
| 3854 # We need to display help for each of the modes. | |
| 3855 case $opt_mode in | |
| 3856 "") | |
| 3857 # Generic help is extracted from the usage comments | |
| 3858 # at the start of this file. | |
| 3859 func_help | |
| 3860 ;; | |
| 3861 | |
| 3862 clean) | |
| 3863 $ECHO \ | |
| 3864 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... | |
| 3865 | |
| 3866 Remove files from the build directory. | |
| 3867 | |
| 3868 RM is the name of the program to use to delete files associated with each FILE | |
| 3869 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed | |
| 3870 to RM. | |
| 3871 | |
| 3872 If FILE is a libtool library, object or program, all the files associated | |
| 3873 with it are deleted. Otherwise, only FILE itself is deleted using RM." | |
| 3874 ;; | |
| 3875 | |
| 3876 compile) | |
| 3877 $ECHO \ | |
| 3878 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE | |
| 3879 | |
| 3880 Compile a source file into a libtool library object. | |
| 3881 | |
| 3882 This mode accepts the following additional options: | |
| 3883 | |
| 3884 -o OUTPUT-FILE set the output file name to OUTPUT-FILE | |
| 3885 -no-suppress do not suppress compiler output for multiple passes | |
| 3886 -prefer-pic try to build PIC objects only | |
| 3887 -prefer-non-pic try to build non-PIC objects only | |
| 3888 -shared do not build a '.o' file suitable for static linking | |
| 3889 -static only build a '.o' file suitable for static linking | |
| 3890 -Wc,FLAG | |
| 3891 -Xcompiler FLAG pass FLAG directly to the compiler | |
| 3892 | |
| 3893 COMPILE-COMMAND is a command to be used in creating a 'standard' object file | |
| 3894 from the given SOURCEFILE. | |
| 3895 | |
| 3896 The output file name is determined by removing the directory component from | |
| 3897 SOURCEFILE, then substituting the C source code suffix '.c' with the | |
| 3898 library object suffix, '.lo'." | |
| 3899 ;; | |
| 3900 | |
| 3901 execute) | |
| 3902 $ECHO \ | |
| 3903 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... | |
| 3904 | |
| 3905 Automatically set library path, then run a program. | |
| 3906 | |
| 3907 This mode accepts the following additional options: | |
| 3908 | |
| 3909 -dlopen FILE add the directory containing FILE to the library path | |
| 3910 | |
| 3911 This mode sets the library path environment variable according to '-dlopen' | |
| 3912 flags. | |
| 3913 | |
| 3914 If any of the ARGS are libtool executable wrappers, then they are translated | |
| 3915 into their corresponding uninstalled binary, and any of their required library | |
| 3916 directories are added to the library path. | |
| 3917 | |
| 3918 Then, COMMAND is executed, with ARGS as arguments." | |
| 3919 ;; | |
| 3920 | |
| 3921 finish) | |
| 3922 $ECHO \ | |
| 3923 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... | |
| 3924 | |
| 3925 Complete the installation of libtool libraries. | |
| 3926 | |
| 3927 Each LIBDIR is a directory that contains libtool libraries. | |
| 3928 | |
| 3929 The commands that this mode executes may require superuser privileges. Use | |
| 3930 the '--dry-run' option if you just want to see what would be executed." | |
| 3931 ;; | |
| 3932 | |
| 3933 install) | |
| 3934 $ECHO \ | |
| 3935 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... | |
| 3936 | |
| 3937 Install executables or libraries. | |
| 3938 | |
| 3939 INSTALL-COMMAND is the installation command. The first component should be | |
| 3940 either the 'install' or 'cp' program. | |
| 3941 | |
| 3942 The following components of INSTALL-COMMAND are treated specially: | |
| 3943 | |
| 3944 -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation | |
| 3945 | |
| 3946 The rest of the components are interpreted as arguments to that command (only | |
| 3947 BSD-compatible install options are recognized)." | |
| 3948 ;; | |
| 3949 | |
| 3950 link) | |
| 3951 $ECHO \ | |
| 3952 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... | |
| 3953 | |
| 3954 Link object files or libraries together to form another library, or to | |
| 3955 create an executable program. | |
| 3956 | |
| 3957 LINK-COMMAND is a command using the C compiler that you would use to create | |
| 3958 a program from several object files. | |
| 3959 | |
| 3960 The following components of LINK-COMMAND are treated specially: | |
| 3961 | |
| 3962 -all-static do not do any dynamic linking at all | |
| 3963 -avoid-version do not add a version suffix if possible | |
| 3964 -bindir BINDIR specify path to binaries directory (for systems where | |
| 3965 libraries must be found in the PATH setting at runtime) | |
| 3966 -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime | |
| 3967 -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols | |
| 3968 -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) | |
| 3969 -export-symbols SYMFILE | |
| 3970 try to export only the symbols listed in SYMFILE | |
| 3971 -export-symbols-regex REGEX | |
| 3972 try to export only the symbols matching REGEX | |
| 3973 -LLIBDIR search LIBDIR for required installed libraries | |
| 3974 -lNAME OUTPUT-FILE requires the installed library libNAME | |
| 3975 -module build a library that can dlopened | |
| 3976 -no-fast-install disable the fast-install mode | |
| 3977 -no-install link a not-installable executable | |
| 3978 -no-undefined declare that a library does not refer to external symbols | |
| 3979 -o OUTPUT-FILE create OUTPUT-FILE from the specified objects | |
| 3980 -objectlist FILE use a list of object files found in FILE to specify objects | |
| 3981 -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) | |
| 3982 -precious-files-regex REGEX | |
| 3983 don't remove output files matching REGEX | |
| 3984 -release RELEASE specify package release information | |
| 3985 -rpath LIBDIR the created library will eventually be installed in LIBDIR | |
| 3986 -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries | |
| 3987 -shared only do dynamic linking of libtool libraries | |
| 3988 -shrext SUFFIX override the standard shared library file extension | |
| 3989 -static do not do any dynamic linking of uninstalled libtool libraries | |
| 3990 -static-libtool-libs | |
| 3991 do not do any dynamic linking of libtool libraries | |
| 3992 -version-info CURRENT[:REVISION[:AGE]] | |
| 3993 specify library version info [each variable defaults to 0] | |
| 3994 -weak LIBNAME declare that the target provides the LIBNAME interface | |
| 3995 -Wc,FLAG | |
| 3996 -Xcompiler FLAG pass linker-specific FLAG directly to the compiler | |
| 3997 -Wa,FLAG | |
| 3998 -Xassembler FLAG pass linker-specific FLAG directly to the assembler | |
| 3999 -Wl,FLAG | |
| 4000 -Xlinker FLAG pass linker-specific FLAG directly to the linker | |
| 4001 -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) | |
| 4002 | |
| 4003 All other options (arguments beginning with '-') are ignored. | |
| 4004 | |
| 4005 Every other argument is treated as a filename. Files ending in '.la' are | |
| 4006 treated as uninstalled libtool libraries, other files are standard or library | |
| 4007 object files. | |
| 4008 | |
| 4009 If the OUTPUT-FILE ends in '.la', then a libtool library is created, | |
| 4010 only library objects ('.lo' files) may be specified, and '-rpath' is | |
| 4011 required, except when creating a convenience library. | |
| 4012 | |
| 4013 If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created | |
| 4014 using 'ar' and 'ranlib', or on Windows using 'lib'. | |
| 4015 | |
| 4016 If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file | |
| 4017 is created, otherwise an executable program is created." | |
| 4018 ;; | |
| 4019 | |
| 4020 uninstall) | |
| 4021 $ECHO \ | |
| 4022 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... | |
| 4023 | |
| 4024 Remove libraries from an installation directory. | |
| 4025 | |
| 4026 RM is the name of the program to use to delete files associated with each FILE | |
| 4027 (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed | |
| 4028 to RM. | |
| 4029 | |
| 4030 If FILE is a libtool library, all the files associated with it are deleted. | |
| 4031 Otherwise, only FILE itself is deleted using RM." | |
| 4032 ;; | |
| 4033 | |
| 4034 *) | |
| 4035 func_fatal_help "invalid operation mode '$opt_mode'" | |
| 4036 ;; | |
| 4037 esac | |
| 4038 | |
| 4039 echo | |
| 4040 $ECHO "Try '$progname --help' for more information about other modes." | |
| 4041 } | |
| 4042 | |
| 4043 # Now that we've collected a possible --mode arg, show help if necessary | |
| 4044 if $opt_help; then | |
| 4045 if test : = "$opt_help"; then | |
| 4046 func_mode_help | |
| 4047 else | |
| 4048 { | |
| 4049 func_help noexit | |
| 4050 for opt_mode in compile link execute install finish uninstall clean; do | |
| 4051 func_mode_help | |
| 4052 done | |
| 4053 } | $SED -n '1p; 2,$s/^Usage:/ or: /p' | |
| 4054 { | |
| 4055 func_help noexit | |
| 4056 for opt_mode in compile link execute install finish uninstall clean; do | |
| 4057 echo | |
| 4058 func_mode_help | |
| 4059 done | |
| 4060 } | | |
| 4061 $SED '1d | |
| 4062 /^When reporting/,/^Report/{ | |
| 4063 H | |
| 4064 d | |
| 4065 } | |
| 4066 $x | |
| 4067 /information about other modes/d | |
| 4068 /more detailed .*MODE/d | |
| 4069 s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' | |
| 4070 fi | |
| 4071 exit $? | |
| 4072 fi | |
| 4073 | |
| 4074 | |
| 4075 # func_mode_execute arg... | |
| 4076 func_mode_execute () | |
| 4077 { | |
| 4078 $debug_cmd | |
| 4079 | |
| 4080 # The first argument is the command name. | |
| 4081 cmd=$nonopt | |
| 4082 test -z "$cmd" && \ | |
| 4083 func_fatal_help "you must specify a COMMAND" | |
| 4084 | |
| 4085 # Handle -dlopen flags immediately. | |
| 4086 for file in $opt_dlopen; do | |
| 4087 test -f "$file" \ | |
| 4088 || func_fatal_help "'$file' is not a file" | |
| 4089 | |
| 4090 dir= | |
| 4091 case $file in | |
| 4092 *.la) | |
| 4093 func_resolve_sysroot "$file" | |
| 4094 file=$func_resolve_sysroot_result | |
| 4095 | |
| 4096 # Check to see that this really is a libtool archive. | |
| 4097 func_lalib_unsafe_p "$file" \ | |
| 4098 || func_fatal_help "'$lib' is not a valid libtool archive" | |
| 4099 | |
| 4100 # Read the libtool library. | |
| 4101 dlname= | |
| 4102 library_names= | |
| 4103 func_source "$file" | |
| 4104 | |
| 4105 # Skip this library if it cannot be dlopened. | |
| 4106 if test -z "$dlname"; then | |
| 4107 # Warn if it was a shared library. | |
| 4108 test -n "$library_names" && \ | |
| 4109 func_warning "'$file' was not linked with '-export-dynamic'" | |
| 4110 continue | |
| 4111 fi | |
| 4112 | |
| 4113 func_dirname "$file" "" "." | |
| 4114 dir=$func_dirname_result | |
| 4115 | |
| 4116 if test -f "$dir/$objdir/$dlname"; then | |
| 4117 func_append dir "/$objdir" | |
| 4118 else | |
| 4119 if test ! -f "$dir/$dlname"; then | |
| 4120 func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" | |
| 4121 fi | |
| 4122 fi | |
| 4123 ;; | |
| 4124 | |
| 4125 *.lo) | |
| 4126 # Just add the directory containing the .lo file. | |
| 4127 func_dirname "$file" "" "." | |
| 4128 dir=$func_dirname_result | |
| 4129 ;; | |
| 4130 | |
| 4131 *) | |
| 4132 func_warning "'-dlopen' is ignored for non-libtool libraries and objects" | |
| 4133 continue | |
| 4134 ;; | |
| 4135 esac | |
| 4136 | |
| 4137 # Get the absolute pathname. | |
| 4138 absdir=`cd "$dir" && pwd` | |
| 4139 test -n "$absdir" && dir=$absdir | |
| 4140 | |
| 4141 # Now add the directory to shlibpath_var. | |
| 4142 if eval "test -z \"\$$shlibpath_var\""; then | |
| 4143 eval "$shlibpath_var=\"\$dir\"" | |
| 4144 else | |
| 4145 eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" | |
| 4146 fi | |
| 4147 done | |
| 4148 | |
| 4149 # This variable tells wrapper scripts just to set shlibpath_var | |
| 4150 # rather than running their programs. | |
| 4151 libtool_execute_magic=$magic | |
| 4152 | |
| 4153 # Check if any of the arguments is a wrapper script. | |
| 4154 args= | |
| 4155 for file | |
| 4156 do | |
| 4157 case $file in | |
| 4158 -* | *.la | *.lo ) ;; | |
| 4159 *) | |
| 4160 # Do a test to see if this is really a libtool program. | |
| 4161 if func_ltwrapper_script_p "$file"; then | |
| 4162 func_source "$file" | |
| 4163 # Transform arg to wrapped name. | |
| 4164 file=$progdir/$program | |
| 4165 elif func_ltwrapper_executable_p "$file"; then | |
| 4166 func_ltwrapper_scriptname "$file" | |
| 4167 func_source "$func_ltwrapper_scriptname_result" | |
| 4168 # Transform arg to wrapped name. | |
| 4169 file=$progdir/$program | |
| 4170 fi | |
| 4171 ;; | |
| 4172 esac | |
| 4173 # Quote arguments (to preserve shell metacharacters). | |
| 4174 func_append_quoted args "$file" | |
| 4175 done | |
| 4176 | |
| 4177 if $opt_dry_run; then | |
| 4178 # Display what would be done. | |
| 4179 if test -n "$shlibpath_var"; then | |
| 4180 eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" | |
| 4181 echo "export $shlibpath_var" | |
| 4182 fi | |
| 4183 $ECHO "$cmd$args" | |
| 4184 exit $EXIT_SUCCESS | |
| 4185 else | |
| 4186 if test -n "$shlibpath_var"; then | |
| 4187 # Export the shlibpath_var. | |
| 4188 eval "export $shlibpath_var" | |
| 4189 fi | |
| 4190 | |
| 4191 # Restore saved environment variables | |
| 4192 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES | |
| 4193 do | |
| 4194 eval "if test \"\${save_$lt_var+set}\" = set; then | |
| 4195 $lt_var=\$save_$lt_var; export $lt_var | |
| 4196 else | |
| 4197 $lt_unset $lt_var | |
| 4198 fi" | |
| 4199 done | |
| 4200 | |
| 4201 # Now prepare to actually exec the command. | |
| 4202 exec_cmd=\$cmd$args | |
| 4203 fi | |
| 4204 } | |
| 4205 | |
| 4206 test execute = "$opt_mode" && func_mode_execute ${1+"$@"} | |
| 4207 | |
| 4208 | |
| 4209 # func_mode_finish arg... | |
| 4210 func_mode_finish () | |
| 4211 { | |
| 4212 $debug_cmd | |
| 4213 | |
| 4214 libs= | |
| 4215 libdirs= | |
| 4216 admincmds= | |
| 4217 | |
| 4218 for opt in "$nonopt" ${1+"$@"} | |
| 4219 do | |
| 4220 if test -d "$opt"; then | |
| 4221 func_append libdirs " $opt" | |
| 4222 | |
| 4223 elif test -f "$opt"; then | |
| 4224 if func_lalib_unsafe_p "$opt"; then | |
| 4225 func_append libs " $opt" | |
| 4226 else | |
| 4227 func_warning "'$opt' is not a valid libtool archive" | |
| 4228 fi | |
| 4229 | |
| 4230 else | |
| 4231 func_fatal_error "invalid argument '$opt'" | |
| 4232 fi | |
| 4233 done | |
| 4234 | |
| 4235 if test -n "$libs"; then | |
| 4236 if test -n "$lt_sysroot"; then | |
| 4237 sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` | |
| 4238 sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" | |
| 4239 else | |
| 4240 sysroot_cmd= | |
| 4241 fi | |
| 4242 | |
| 4243 # Remove sysroot references | |
| 4244 if $opt_dry_run; then | |
| 4245 for lib in $libs; do | |
| 4246 echo "removing references to $lt_sysroot and '=' prefixes from $lib" | |
| 4247 done | |
| 4248 else | |
| 4249 tmpdir=`func_mktempdir` | |
| 4250 for lib in $libs; do | |
| 4251 $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ | |
| 4252 > $tmpdir/tmp-la | |
| 4253 mv -f $tmpdir/tmp-la $lib | |
| 4254 done | |
| 4255 ${RM}r "$tmpdir" | |
| 4256 fi | |
| 4257 fi | |
| 4258 | |
| 4259 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then | |
| 4260 for libdir in $libdirs; do | |
| 4261 if test -n "$finish_cmds"; then | |
| 4262 # Do each command in the finish commands. | |
| 4263 func_execute_cmds "$finish_cmds" 'admincmds="$admincmds | |
| 4264 '"$cmd"'"' | |
| 4265 fi | |
| 4266 if test -n "$finish_eval"; then | |
| 4267 # Do the single finish_eval. | |
| 4268 eval cmds=\"$finish_eval\" | |
| 4269 $opt_dry_run || eval "$cmds" || func_append admincmds " | |
| 4270 $cmds" | |
| 4271 fi | |
| 4272 done | |
| 4273 fi | |
| 4274 | |
| 4275 # Exit here if they wanted silent mode. | |
| 4276 $opt_quiet && exit $EXIT_SUCCESS | |
| 4277 | |
| 4278 if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then | |
| 4279 echo "----------------------------------------------------------------------" | |
| 4280 echo "Libraries have been installed in:" | |
| 4281 for libdir in $libdirs; do | |
| 4282 $ECHO " $libdir" | |
| 4283 done | |
| 4284 echo | |
| 4285 echo "If you ever happen to want to link against installed libraries" | |
| 4286 echo "in a given directory, LIBDIR, you must either use libtool, and" | |
| 4287 echo "specify the full pathname of the library, or use the '-LLIBDIR'" | |
| 4288 echo "flag during linking and do at least one of the following:" | |
| 4289 if test -n "$shlibpath_var"; then | |
| 4290 echo " - add LIBDIR to the '$shlibpath_var' environment variable" | |
| 4291 echo " during execution" | |
| 4292 fi | |
| 4293 if test -n "$runpath_var"; then | |
| 4294 echo " - add LIBDIR to the '$runpath_var' environment variable" | |
| 4295 echo " during linking" | |
| 4296 fi | |
| 4297 if test -n "$hardcode_libdir_flag_spec"; then | |
| 4298 libdir=LIBDIR | |
| 4299 eval flag=\"$hardcode_libdir_flag_spec\" | |
| 4300 | |
| 4301 $ECHO " - use the '$flag' linker flag" | |
| 4302 fi | |
| 4303 if test -n "$admincmds"; then | |
| 4304 $ECHO " - have your system administrator run these commands:$admincmds" | |
| 4305 fi | |
| 4306 if test -f /etc/ld.so.conf; then | |
| 4307 echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" | |
| 4308 fi | |
| 4309 echo | |
| 4310 | |
| 4311 echo "See any operating system documentation about shared libraries for" | |
| 4312 case $host in | |
| 4313 solaris2.[6789]|solaris2.1[0-9]) | |
| 4314 echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" | |
| 4315 echo "pages." | |
| 4316 ;; | |
| 4317 *) | |
| 4318 echo "more information, such as the ld(1) and ld.so(8) manual pages." | |
| 4319 ;; | |
| 4320 esac | |
| 4321 echo "----------------------------------------------------------------------" | |
| 4322 fi | |
| 4323 exit $EXIT_SUCCESS | |
| 4324 } | |
| 4325 | |
| 4326 test finish = "$opt_mode" && func_mode_finish ${1+"$@"} | |
| 4327 | |
| 4328 | |
| 4329 # func_mode_install arg... | |
| 4330 func_mode_install () | |
| 4331 { | |
| 4332 $debug_cmd | |
| 4333 | |
| 4334 # There may be an optional sh(1) argument at the beginning of | |
| 4335 # install_prog (especially on Windows NT). | |
| 4336 if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || | |
| 4337 # Allow the use of GNU shtool's install command. | |
| 4338 case $nonopt in *shtool*) :;; *) false;; esac | |
| 4339 then | |
| 4340 # Aesthetically quote it. | |
| 4341 func_quote_arg pretty "$nonopt" | |
| 4342 install_prog="$func_quote_arg_result " | |
| 4343 arg=$1 | |
| 4344 shift | |
| 4345 else | |
| 4346 install_prog= | |
| 4347 arg=$nonopt | |
| 4348 fi | |
| 4349 | |
| 4350 # The real first argument should be the name of the installation program. | |
| 4351 # Aesthetically quote it. | |
| 4352 func_quote_arg pretty "$arg" | |
| 4353 func_append install_prog "$func_quote_arg_result" | |
| 4354 install_shared_prog=$install_prog | |
| 4355 case " $install_prog " in | |
| 4356 *[\\\ /]cp\ *) install_cp=: ;; | |
| 4357 *) install_cp=false ;; | |
| 4358 esac | |
| 4359 | |
| 4360 # We need to accept at least all the BSD install flags. | |
| 4361 dest= | |
| 4362 files= | |
| 4363 opts= | |
| 4364 prev= | |
| 4365 install_type= | |
| 4366 isdir=false | |
| 4367 stripme= | |
| 4368 no_mode=: | |
| 4369 for arg | |
| 4370 do | |
| 4371 arg2= | |
| 4372 if test -n "$dest"; then | |
| 4373 func_append files " $dest" | |
| 4374 dest=$arg | |
| 4375 continue | |
| 4376 fi | |
| 4377 | |
| 4378 case $arg in | |
| 4379 -d) isdir=: ;; | |
| 4380 -f) | |
| 4381 if $install_cp; then :; else | |
| 4382 prev=$arg | |
| 4383 fi | |
| 4384 ;; | |
| 4385 -g | -m | -o) | |
| 4386 prev=$arg | |
| 4387 ;; | |
| 4388 -s) | |
| 4389 stripme=" -s" | |
| 4390 continue | |
| 4391 ;; | |
| 4392 -*) | |
| 4393 ;; | |
| 4394 *) | |
| 4395 # If the previous option needed an argument, then skip it. | |
| 4396 if test -n "$prev"; then | |
| 4397 if test X-m = "X$prev" && test -n "$install_override_mode"; then | |
| 4398 arg2=$install_override_mode | |
| 4399 no_mode=false | |
| 4400 fi | |
| 4401 prev= | |
| 4402 else | |
| 4403 dest=$arg | |
| 4404 continue | |
| 4405 fi | |
| 4406 ;; | |
| 4407 esac | |
| 4408 | |
| 4409 # Aesthetically quote the argument. | |
| 4410 func_quote_arg pretty "$arg" | |
| 4411 func_append install_prog " $func_quote_arg_result" | |
| 4412 if test -n "$arg2"; then | |
| 4413 func_quote_arg pretty "$arg2" | |
| 4414 fi | |
| 4415 func_append install_shared_prog " $func_quote_arg_result" | |
| 4416 done | |
| 4417 | |
| 4418 test -z "$install_prog" && \ | |
| 4419 func_fatal_help "you must specify an install program" | |
| 4420 | |
| 4421 test -n "$prev" && \ | |
| 4422 func_fatal_help "the '$prev' option requires an argument" | |
| 4423 | |
| 4424 if test -n "$install_override_mode" && $no_mode; then | |
| 4425 if $install_cp; then :; else | |
| 4426 func_quote_arg pretty "$install_override_mode" | |
| 4427 func_append install_shared_prog " -m $func_quote_arg_result" | |
| 4428 fi | |
| 4429 fi | |
| 4430 | |
| 4431 if test -z "$files"; then | |
| 4432 if test -z "$dest"; then | |
| 4433 func_fatal_help "no file or destination specified" | |
| 4434 else | |
| 4435 func_fatal_help "you must specify a destination" | |
| 4436 fi | |
| 4437 fi | |
| 4438 | |
| 4439 # Strip any trailing slash from the destination. | |
| 4440 func_stripname '' '/' "$dest" | |
| 4441 dest=$func_stripname_result | |
| 4442 | |
| 4443 # Check to see that the destination is a directory. | |
| 4444 test -d "$dest" && isdir=: | |
| 4445 if $isdir; then | |
| 4446 destdir=$dest | |
| 4447 destname= | |
| 4448 else | |
| 4449 func_dirname_and_basename "$dest" "" "." | |
| 4450 destdir=$func_dirname_result | |
| 4451 destname=$func_basename_result | |
| 4452 | |
| 4453 # Not a directory, so check to see that there is only one file specified. | |
| 4454 set dummy $files; shift | |
| 4455 test "$#" -gt 1 && \ | |
| 4456 func_fatal_help "'$dest' is not a directory" | |
| 4457 fi | |
| 4458 case $destdir in | |
| 4459 [\\/]* | [A-Za-z]:[\\/]*) ;; | |
| 4460 *) | |
| 4461 for file in $files; do | |
| 4462 case $file in | |
| 4463 *.lo) ;; | |
| 4464 *) | |
| 4465 func_fatal_help "'$destdir' must be an absolute directory name" | |
| 4466 ;; | |
| 4467 esac | |
| 4468 done | |
| 4469 ;; | |
| 4470 esac | |
| 4471 | |
| 4472 # This variable tells wrapper scripts just to set variables rather | |
| 4473 # than running their programs. | |
| 4474 libtool_install_magic=$magic | |
| 4475 | |
| 4476 staticlibs= | |
| 4477 future_libdirs= | |
| 4478 current_libdirs= | |
| 4479 for file in $files; do | |
| 4480 | |
| 4481 # Do each installation. | |
| 4482 case $file in | |
| 4483 *.$libext) | |
| 4484 # Do the static libraries later. | |
| 4485 func_append staticlibs " $file" | |
| 4486 ;; | |
| 4487 | |
| 4488 *.la) | |
| 4489 func_resolve_sysroot "$file" | |
| 4490 file=$func_resolve_sysroot_result | |
| 4491 | |
| 4492 # Check to see that this really is a libtool archive. | |
| 4493 func_lalib_unsafe_p "$file" \ | |
| 4494 || func_fatal_help "'$file' is not a valid libtool archive" | |
| 4495 | |
| 4496 library_names= | |
| 4497 old_library= | |
| 4498 relink_command= | |
| 4499 func_source "$file" | |
| 4500 | |
| 4501 # Add the libdir to current_libdirs if it is the destination. | |
| 4502 if test "X$destdir" = "X$libdir"; then | |
| 4503 case "$current_libdirs " in | |
| 4504 *" $libdir "*) ;; | |
| 4505 *) func_append current_libdirs " $libdir" ;; | |
| 4506 esac | |
| 4507 else | |
| 4508 # Note the libdir as a future libdir. | |
| 4509 case "$future_libdirs " in | |
| 4510 *" $libdir "*) ;; | |
| 4511 *) func_append future_libdirs " $libdir" ;; | |
| 4512 esac | |
| 4513 fi | |
| 4514 | |
| 4515 func_dirname "$file" "/" "" | |
| 4516 dir=$func_dirname_result | |
| 4517 func_append dir "$objdir" | |
| 4518 | |
| 4519 if test -n "$relink_command"; then | |
| 4520 # Determine the prefix the user has applied to our future dir. | |
| 4521 inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` | |
| 4522 | |
| 4523 # Don't allow the user to place us outside of our expected | |
| 4524 # location b/c this prevents finding dependent libraries that | |
| 4525 # are installed to the same prefix. | |
| 4526 # At present, this check doesn't affect windows .dll's that | |
| 4527 # are installed into $libdir/../bin (currently, that works fine) | |
| 4528 # but it's something to keep an eye on. | |
| 4529 test "$inst_prefix_dir" = "$destdir" && \ | |
| 4530 func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" | |
| 4531 | |
| 4532 if test -n "$inst_prefix_dir"; then | |
| 4533 # Stick the inst_prefix_dir data into the link command. | |
| 4534 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` | |
| 4535 else | |
| 4536 relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` | |
| 4537 fi | |
| 4538 | |
| 4539 func_warning "relinking '$file'" | |
| 4540 func_show_eval "$relink_command" \ | |
| 4541 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' | |
| 4542 fi | |
| 4543 | |
| 4544 # See the names of the shared library. | |
| 4545 set dummy $library_names; shift | |
| 4546 if test -n "$1"; then | |
| 4547 realname=$1 | |
| 4548 shift | |
| 4549 | |
| 4550 srcname=$realname | |
| 4551 test -n "$relink_command" && srcname=${realname}T | |
| 4552 | |
| 4553 # Install the shared library and build the symlinks. | |
| 4554 func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ | |
| 4555 'exit $?' | |
| 4556 tstripme=$stripme | |
| 4557 case $host_os in | |
| 4558 cygwin* | mingw* | pw32* | cegcc*) | |
| 4559 case $realname in | |
| 4560 *.dll.a) | |
| 4561 tstripme= | |
| 4562 ;; | |
| 4563 esac | |
| 4564 ;; | |
| 4565 os2*) | |
| 4566 case $realname in | |
| 4567 *_dll.a) | |
| 4568 tstripme= | |
| 4569 ;; | |
| 4570 esac | |
| 4571 ;; | |
| 4572 esac | |
| 4573 if test -n "$tstripme" && test -n "$striplib"; then | |
| 4574 func_show_eval "$striplib $destdir/$realname" 'exit $?' | |
| 4575 fi | |
| 4576 | |
| 4577 if test "$#" -gt 0; then | |
| 4578 # Delete the old symlinks, and create new ones. | |
| 4579 # Try 'ln -sf' first, because the 'ln' binary might depend on | |
| 4580 # the symlink we replace! Solaris /bin/ln does not understand -f, | |
| 4581 # so we also need to try rm && ln -s. | |
| 4582 for linkname | |
| 4583 do | |
| 4584 test "$linkname" != "$realname" \ | |
| 4585 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" | |
| 4586 done | |
| 4587 fi | |
| 4588 | |
| 4589 # Do each command in the postinstall commands. | |
| 4590 lib=$destdir/$realname | |
| 4591 func_execute_cmds "$postinstall_cmds" 'exit $?' | |
| 4592 fi | |
| 4593 | |
| 4594 # Install the pseudo-library for information purposes. | |
| 4595 func_basename "$file" | |
| 4596 name=$func_basename_result | |
| 4597 instname=$dir/${name}i | |
| 4598 func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' | |
| 4599 | |
| 4600 # Maybe install the static library, too. | |
| 4601 test -n "$old_library" && func_append staticlibs " $dir/$old_library" | |
| 4602 ;; | |
| 4603 | |
| 4604 *.lo) | |
| 4605 # Install (i.e. copy) a libtool object. | |
| 4606 | |
| 4607 # Figure out destination file name, if it wasn't already specified. | |
| 4608 if test -n "$destname"; then | |
| 4609 destfile=$destdir/$destname | |
| 4610 else | |
| 4611 func_basename "$file" | |
| 4612 destfile=$func_basename_result | |
| 4613 destfile=$destdir/$destfile | |
| 4614 fi | |
| 4615 | |
| 4616 # Deduce the name of the destination old-style object file. | |
| 4617 case $destfile in | |
| 4618 *.lo) | |
| 4619 func_lo2o "$destfile" | |
| 4620 staticdest=$func_lo2o_result | |
| 4621 ;; | |
| 4622 *.$objext) | |
| 4623 staticdest=$destfile | |
| 4624 destfile= | |
| 4625 ;; | |
| 4626 *) | |
| 4627 func_fatal_help "cannot copy a libtool object to '$destfile'" | |
| 4628 ;; | |
| 4629 esac | |
| 4630 | |
| 4631 # Install the libtool object if requested. | |
| 4632 test -n "$destfile" && \ | |
| 4633 func_show_eval "$install_prog $file $destfile" 'exit $?' | |
| 4634 | |
| 4635 # Install the old object if enabled. | |
| 4636 if test yes = "$build_old_libs"; then | |
| 4637 # Deduce the name of the old-style object file. | |
| 4638 func_lo2o "$file" | |
| 4639 staticobj=$func_lo2o_result | |
| 4640 func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' | |
| 4641 fi | |
| 4642 exit $EXIT_SUCCESS | |
| 4643 ;; | |
| 4644 | |
| 4645 *) | |
| 4646 # Figure out destination file name, if it wasn't already specified. | |
| 4647 if test -n "$destname"; then | |
| 4648 destfile=$destdir/$destname | |
| 4649 else | |
| 4650 func_basename "$file" | |
| 4651 destfile=$func_basename_result | |
| 4652 destfile=$destdir/$destfile | |
| 4653 fi | |
| 4654 | |
| 4655 # If the file is missing, and there is a .exe on the end, strip it | |
| 4656 # because it is most likely a libtool script we actually want to | |
| 4657 # install | |
| 4658 stripped_ext= | |
| 4659 case $file in | |
| 4660 *.exe) | |
| 4661 if test ! -f "$file"; then | |
| 4662 func_stripname '' '.exe' "$file" | |
| 4663 file=$func_stripname_result | |
| 4664 stripped_ext=.exe | |
| 4665 fi | |
| 4666 ;; | |
| 4667 esac | |
| 4668 | |
| 4669 # Do a test to see if this is really a libtool program. | |
| 4670 case $host in | |
| 4671 *cygwin* | *mingw*) | |
| 4672 if func_ltwrapper_executable_p "$file"; then | |
| 4673 func_ltwrapper_scriptname "$file" | |
| 4674 wrapper=$func_ltwrapper_scriptname_result | |
| 4675 else | |
| 4676 func_stripname '' '.exe' "$file" | |
| 4677 wrapper=$func_stripname_result | |
| 4678 fi | |
| 4679 ;; | |
| 4680 *) | |
| 4681 wrapper=$file | |
| 4682 ;; | |
| 4683 esac | |
| 4684 if func_ltwrapper_script_p "$wrapper"; then | |
| 4685 notinst_deplibs= | |
| 4686 relink_command= | |
| 4687 | |
| 4688 func_source "$wrapper" | |
| 4689 | |
| 4690 # Check the variables that should have been set. | |
| 4691 test -z "$generated_by_libtool_version" && \ | |
| 4692 func_fatal_error "invalid libtool wrapper script '$wrapper'" | |
| 4693 | |
| 4694 finalize=: | |
| 4695 for lib in $notinst_deplibs; do | |
| 4696 # Check to see that each library is installed. | |
| 4697 libdir= | |
| 4698 if test -f "$lib"; then | |
| 4699 func_source "$lib" | |
| 4700 fi | |
| 4701 libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` | |
| 4702 if test -n "$libdir" && test ! -f "$libfile"; then | |
| 4703 func_warning "'$lib' has not been installed in '$libdir'" | |
| 4704 finalize=false | |
| 4705 fi | |
| 4706 done | |
| 4707 | |
| 4708 relink_command= | |
| 4709 func_source "$wrapper" | |
| 4710 | |
| 4711 outputname= | |
| 4712 if test no = "$fast_install" && test -n "$relink_command"; then | |
| 4713 $opt_dry_run || { | |
| 4714 if $finalize; then | |
| 4715 tmpdir=`func_mktempdir` | |
| 4716 func_basename "$file$stripped_ext" | |
| 4717 file=$func_basename_result | |
| 4718 outputname=$tmpdir/$file | |
| 4719 # Replace the output file specification. | |
| 4720 relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` | |
| 4721 | |
| 4722 $opt_quiet || { | |
| 4723 func_quote_arg expand,pretty "$relink_command" | |
| 4724 eval "func_echo $func_quote_arg_result" | |
| 4725 } | |
| 4726 if eval "$relink_command"; then : | |
| 4727 else | |
| 4728 func_error "error: relink '$file' with the above command before installing it" | |
| 4729 $opt_dry_run || ${RM}r "$tmpdir" | |
| 4730 continue | |
| 4731 fi | |
| 4732 file=$outputname | |
| 4733 else | |
| 4734 func_warning "cannot relink '$file'" | |
| 4735 fi | |
| 4736 } | |
| 4737 else | |
| 4738 # Install the binary that we compiled earlier. | |
| 4739 file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` | |
| 4740 fi | |
| 4741 fi | |
| 4742 | |
| 4743 # remove .exe since cygwin /usr/bin/install will append another | |
| 4744 # one anyway | |
| 4745 case $install_prog,$host in | |
| 4746 */usr/bin/install*,*cygwin*) | |
| 4747 case $file:$destfile in | |
| 4748 *.exe:*.exe) | |
| 4749 # this is ok | |
| 4750 ;; | |
| 4751 *.exe:*) | |
| 4752 destfile=$destfile.exe | |
| 4753 ;; | |
| 4754 *:*.exe) | |
| 4755 func_stripname '' '.exe' "$destfile" | |
| 4756 destfile=$func_stripname_result | |
| 4757 ;; | |
| 4758 esac | |
| 4759 ;; | |
| 4760 esac | |
| 4761 func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' | |
| 4762 $opt_dry_run || if test -n "$outputname"; then | |
| 4763 ${RM}r "$tmpdir" | |
| 4764 fi | |
| 4765 ;; | |
| 4766 esac | |
| 4767 done | |
| 4768 | |
| 4769 for file in $staticlibs; do | |
| 4770 func_basename "$file" | |
| 4771 name=$func_basename_result | |
| 4772 | |
| 4773 # Set up the ranlib parameters. | |
| 4774 oldlib=$destdir/$name | |
| 4775 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 | |
| 4776 tool_oldlib=$func_to_tool_file_result | |
| 4777 | |
| 4778 func_show_eval "$install_prog \$file \$oldlib" 'exit $?' | |
| 4779 | |
| 4780 if test -n "$stripme" && test -n "$old_striplib"; then | |
| 4781 func_show_eval "$old_striplib $tool_oldlib" 'exit $?' | |
| 4782 fi | |
| 4783 | |
| 4784 # Do each command in the postinstall commands. | |
| 4785 func_execute_cmds "$old_postinstall_cmds" 'exit $?' | |
| 4786 done | |
| 4787 | |
| 4788 test -n "$future_libdirs" && \ | |
| 4789 func_warning "remember to run '$progname --finish$future_libdirs'" | |
| 4790 | |
| 4791 if test -n "$current_libdirs"; then | |
| 4792 # Maybe just do a dry run. | |
| 4793 $opt_dry_run && current_libdirs=" -n$current_libdirs" | |
| 4794 exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' | |
| 4795 else | |
| 4796 exit $EXIT_SUCCESS | |
| 4797 fi | |
| 4798 } | |
| 4799 | |
| 4800 test install = "$opt_mode" && func_mode_install ${1+"$@"} | |
| 4801 | |
| 4802 | |
| 4803 # func_generate_dlsyms outputname originator pic_p | |
| 4804 # Extract symbols from dlprefiles and create ${outputname}S.o with | |
| 4805 # a dlpreopen symbol table. | |
| 4806 func_generate_dlsyms () | |
| 4807 { | |
| 4808 $debug_cmd | |
| 4809 | |
| 4810 my_outputname=$1 | |
| 4811 my_originator=$2 | |
| 4812 my_pic_p=${3-false} | |
| 4813 my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` | |
| 4814 my_dlsyms= | |
| 4815 | |
| 4816 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then | |
| 4817 if test -n "$NM" && test -n "$global_symbol_pipe"; then | |
| 4818 my_dlsyms=${my_outputname}S.c | |
| 4819 else | |
| 4820 func_error "not configured to extract global symbols from dlpreopened files" | |
| 4821 fi | |
| 4822 fi | |
| 4823 | |
| 4824 if test -n "$my_dlsyms"; then | |
| 4825 case $my_dlsyms in | |
| 4826 "") ;; | |
| 4827 *.c) | |
| 4828 # Discover the nlist of each of the dlfiles. | |
| 4829 nlist=$output_objdir/$my_outputname.nm | |
| 4830 | |
| 4831 func_show_eval "$RM $nlist ${nlist}S ${nlist}T" | |
| 4832 | |
| 4833 # Parse the name list into a source file. | |
| 4834 func_verbose "creating $output_objdir/$my_dlsyms" | |
| 4835 | |
| 4836 $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ | |
| 4837 /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ | |
| 4838 /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ | |
| 4839 | |
| 4840 #ifdef __cplusplus | |
| 4841 extern \"C\" { | |
| 4842 #endif | |
| 4843 | |
| 4844 #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) | |
| 4845 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" | |
| 4846 #endif | |
| 4847 | |
| 4848 /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ | |
| 4849 #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE | |
| 4850 /* DATA imports from DLLs on WIN32 can't be const, because runtime | |
| 4851 relocations are performed -- see ld's documentation on pseudo-relocs. */ | |
| 4852 # define LT_DLSYM_CONST | |
| 4853 #elif defined __osf__ | |
| 4854 /* This system does not cope well with relocations in const data. */ | |
| 4855 # define LT_DLSYM_CONST | |
| 4856 #else | |
| 4857 # define LT_DLSYM_CONST const | |
| 4858 #endif | |
| 4859 | |
| 4860 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) | |
| 4861 | |
| 4862 /* External symbol declarations for the compiler. */\ | |
| 4863 " | |
| 4864 | |
| 4865 if test yes = "$dlself"; then | |
| 4866 func_verbose "generating symbol list for '$output'" | |
| 4867 | |
| 4868 $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" | |
| 4869 | |
| 4870 # Add our own program objects to the symbol list. | |
| 4871 progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` | |
| 4872 for progfile in $progfiles; do | |
| 4873 func_to_tool_file "$progfile" func_convert_file_msys_to_w32 | |
| 4874 func_verbose "extracting global C symbols from '$func_to_tool_file_result'" | |
| 4875 $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" | |
| 4876 done | |
| 4877 | |
| 4878 if test -n "$exclude_expsyms"; then | |
| 4879 $opt_dry_run || { | |
| 4880 eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' | |
| 4881 eval '$MV "$nlist"T "$nlist"' | |
| 4882 } | |
| 4883 fi | |
| 4884 | |
| 4885 if test -n "$export_symbols_regex"; then | |
| 4886 $opt_dry_run || { | |
| 4887 eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' | |
| 4888 eval '$MV "$nlist"T "$nlist"' | |
| 4889 } | |
| 4890 fi | |
| 4891 | |
| 4892 # Prepare the list of exported symbols | |
| 4893 if test -z "$export_symbols"; then | |
| 4894 export_symbols=$output_objdir/$outputname.exp | |
| 4895 $opt_dry_run || { | |
| 4896 $RM $export_symbols | |
| 4897 eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' | |
| 4898 case $host in | |
| 4899 *cygwin* | *mingw* | *cegcc* ) | |
| 4900 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' | |
| 4901 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' | |
| 4902 ;; | |
| 4903 esac | |
| 4904 } | |
| 4905 else | |
| 4906 $opt_dry_run || { | |
| 4907 eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' | |
| 4908 eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' | |
| 4909 eval '$MV "$nlist"T "$nlist"' | |
| 4910 case $host in | |
| 4911 *cygwin* | *mingw* | *cegcc* ) | |
| 4912 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' | |
| 4913 eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' | |
| 4914 ;; | |
| 4915 esac | |
| 4916 } | |
| 4917 fi | |
| 4918 fi | |
| 4919 | |
| 4920 for dlprefile in $dlprefiles; do | |
| 4921 func_verbose "extracting global C symbols from '$dlprefile'" | |
| 4922 func_basename "$dlprefile" | |
| 4923 name=$func_basename_result | |
| 4924 case $host in | |
| 4925 *cygwin* | *mingw* | *cegcc* ) | |
| 4926 # if an import library, we need to obtain dlname | |
| 4927 if func_win32_import_lib_p "$dlprefile"; then | |
| 4928 func_tr_sh "$dlprefile" | |
| 4929 eval "curr_lafile=\$libfile_$func_tr_sh_result" | |
| 4930 dlprefile_dlbasename= | |
| 4931 if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then | |
| 4932 # Use subshell, to avoid clobbering current variable values | |
| 4933 dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` | |
| 4934 if test -n "$dlprefile_dlname"; then | |
| 4935 func_basename "$dlprefile_dlname" | |
| 4936 dlprefile_dlbasename=$func_basename_result | |
| 4937 else | |
| 4938 # no lafile. user explicitly requested -dlpreopen <import library>. | |
| 4939 $sharedlib_from_linklib_cmd "$dlprefile" | |
| 4940 dlprefile_dlbasename=$sharedlib_from_linklib_result | |
| 4941 fi | |
| 4942 fi | |
| 4943 $opt_dry_run || { | |
| 4944 if test -n "$dlprefile_dlbasename"; then | |
| 4945 eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' | |
| 4946 else | |
| 4947 func_warning "Could not compute DLL name from $name" | |
| 4948 eval '$ECHO ": $name " >> "$nlist"' | |
| 4949 fi | |
| 4950 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 | |
| 4951 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | | |
| 4952 $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" | |
| 4953 } | |
| 4954 else # not an import lib | |
| 4955 $opt_dry_run || { | |
| 4956 eval '$ECHO ": $name " >> "$nlist"' | |
| 4957 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 | |
| 4958 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" | |
| 4959 } | |
| 4960 fi | |
| 4961 ;; | |
| 4962 *) | |
| 4963 $opt_dry_run || { | |
| 4964 eval '$ECHO ": $name " >> "$nlist"' | |
| 4965 func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 | |
| 4966 eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" | |
| 4967 } | |
| 4968 ;; | |
| 4969 esac | |
| 4970 done | |
| 4971 | |
| 4972 $opt_dry_run || { | |
| 4973 # Make sure we have at least an empty file. | |
| 4974 test -f "$nlist" || : > "$nlist" | |
| 4975 | |
| 4976 if test -n "$exclude_expsyms"; then | |
| 4977 $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T | |
| 4978 $MV "$nlist"T "$nlist" | |
| 4979 fi | |
| 4980 | |
| 4981 # Try sorting and uniquifying the output. | |
| 4982 if $GREP -v "^: " < "$nlist" | | |
| 4983 if sort -k 3 </dev/null >/dev/null 2>&1; then | |
| 4984 sort -k 3 | |
| 4985 else | |
| 4986 sort +2 | |
| 4987 fi | | |
| 4988 uniq > "$nlist"S; then | |
| 4989 : | |
| 4990 else | |
| 4991 $GREP -v "^: " < "$nlist" > "$nlist"S | |
| 4992 fi | |
| 4993 | |
| 4994 if test -f "$nlist"S; then | |
| 4995 eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' | |
| 4996 else | |
| 4997 echo '/* NONE */' >> "$output_objdir/$my_dlsyms" | |
| 4998 fi | |
| 4999 | |
| 5000 func_show_eval '$RM "${nlist}I"' | |
| 5001 if test -n "$global_symbol_to_import"; then | |
| 5002 eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' | |
| 5003 fi | |
| 5004 | |
| 5005 echo >> "$output_objdir/$my_dlsyms" "\ | |
| 5006 | |
| 5007 /* The mapping between symbol names and symbols. */ | |
| 5008 typedef struct { | |
| 5009 const char *name; | |
| 5010 void *address; | |
| 5011 } lt_dlsymlist; | |
| 5012 extern LT_DLSYM_CONST lt_dlsymlist | |
| 5013 lt_${my_prefix}_LTX_preloaded_symbols[];\ | |
| 5014 " | |
| 5015 | |
| 5016 if test -s "$nlist"I; then | |
| 5017 echo >> "$output_objdir/$my_dlsyms" "\ | |
| 5018 static void lt_syminit(void) | |
| 5019 { | |
| 5020 LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; | |
| 5021 for (; symbol->name; ++symbol) | |
| 5022 {" | |
| 5023 $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" | |
| 5024 echo >> "$output_objdir/$my_dlsyms" "\ | |
| 5025 } | |
| 5026 }" | |
| 5027 fi | |
| 5028 echo >> "$output_objdir/$my_dlsyms" "\ | |
| 5029 LT_DLSYM_CONST lt_dlsymlist | |
| 5030 lt_${my_prefix}_LTX_preloaded_symbols[] = | |
| 5031 { {\"$my_originator\", (void *) 0}," | |
| 5032 | |
| 5033 if test -s "$nlist"I; then | |
| 5034 echo >> "$output_objdir/$my_dlsyms" "\ | |
| 5035 {\"@INIT@\", (void *) <_syminit}," | |
| 5036 fi | |
| 5037 | |
| 5038 case $need_lib_prefix in | |
| 5039 no) | |
| 5040 eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" | |
| 5041 ;; | |
| 5042 *) | |
| 5043 eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" | |
| 5044 ;; | |
| 5045 esac | |
| 5046 echo >> "$output_objdir/$my_dlsyms" "\ | |
| 5047 {0, (void *) 0} | |
| 5048 }; | |
| 5049 | |
| 5050 /* This works around a problem in FreeBSD linker */ | |
| 5051 #ifdef FREEBSD_WORKAROUND | |
| 5052 static const void *lt_preloaded_setup() { | |
| 5053 return lt_${my_prefix}_LTX_preloaded_symbols; | |
| 5054 } | |
| 5055 #endif | |
| 5056 | |
| 5057 #ifdef __cplusplus | |
| 5058 } | |
| 5059 #endif\ | |
| 5060 " | |
| 5061 } # !$opt_dry_run | |
| 5062 | |
| 5063 pic_flag_for_symtable= | |
| 5064 case "$compile_command " in | |
| 5065 *" -static "*) ;; | |
| 5066 *) | |
| 5067 case $host in | |
| 5068 # compiling the symbol table file with pic_flag works around | |
| 5069 # a FreeBSD bug that causes programs to crash when -lm is | |
| 5070 # linked before any other PIC object. But we must not use | |
| 5071 # pic_flag when linking with -static. The problem exists in | |
| 5072 # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. | |
| 5073 *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) | |
| 5074 pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; | |
| 5075 *-*-hpux*) | |
| 5076 pic_flag_for_symtable=" $pic_flag" ;; | |
| 5077 *) | |
| 5078 $my_pic_p && pic_flag_for_symtable=" $pic_flag" | |
| 5079 ;; | |
| 5080 esac | |
| 5081 ;; | |
| 5082 esac | |
| 5083 symtab_cflags= | |
| 5084 for arg in $LTCFLAGS; do | |
| 5085 case $arg in | |
| 5086 -pie | -fpie | -fPIE) ;; | |
| 5087 *) func_append symtab_cflags " $arg" ;; | |
| 5088 esac | |
| 5089 done | |
| 5090 | |
| 5091 # Now compile the dynamic symbol file. | |
| 5092 func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' | |
| 5093 | |
| 5094 # Clean up the generated files. | |
| 5095 func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' | |
| 5096 | |
| 5097 # Transform the symbol file into the correct name. | |
| 5098 symfileobj=$output_objdir/${my_outputname}S.$objext | |
| 5099 case $host in | |
| 5100 *cygwin* | *mingw* | *cegcc* ) | |
| 5101 if test -f "$output_objdir/$my_outputname.def"; then | |
| 5102 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` | |
| 5103 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` | |
| 5104 else | |
| 5105 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` | |
| 5106 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` | |
| 5107 fi | |
| 5108 ;; | |
| 5109 *) | |
| 5110 compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` | |
| 5111 finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` | |
| 5112 ;; | |
| 5113 esac | |
| 5114 ;; | |
| 5115 *) | |
| 5116 func_fatal_error "unknown suffix for '$my_dlsyms'" | |
| 5117 ;; | |
| 5118 esac | |
| 5119 else | |
| 5120 # We keep going just in case the user didn't refer to | |
| 5121 # lt_preloaded_symbols. The linker will fail if global_symbol_pipe | |
| 5122 # really was required. | |
| 5123 | |
| 5124 # Nullify the symbol file. | |
| 5125 compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` | |
| 5126 finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` | |
| 5127 fi | |
| 5128 } | |
| 5129 | |
| 5130 # func_cygming_gnu_implib_p ARG | |
| 5131 # This predicate returns with zero status (TRUE) if | |
| 5132 # ARG is a GNU/binutils-style import library. Returns | |
| 5133 # with nonzero status (FALSE) otherwise. | |
| 5134 func_cygming_gnu_implib_p () | |
| 5135 { | |
| 5136 $debug_cmd | |
| 5137 | |
| 5138 func_to_tool_file "$1" func_convert_file_msys_to_w32 | |
| 5139 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)$'` | |
| 5140 test -n "$func_cygming_gnu_implib_tmp" | |
| 5141 } | |
| 5142 | |
| 5143 # func_cygming_ms_implib_p ARG | |
| 5144 # This predicate returns with zero status (TRUE) if | |
| 5145 # ARG is an MS-style import library. Returns | |
| 5146 # with nonzero status (FALSE) otherwise. | |
| 5147 func_cygming_ms_implib_p () | |
| 5148 { | |
| 5149 $debug_cmd | |
| 5150 | |
| 5151 func_to_tool_file "$1" func_convert_file_msys_to_w32 | |
| 5152 func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` | |
| 5153 test -n "$func_cygming_ms_implib_tmp" | |
| 5154 } | |
| 5155 | |
| 5156 # func_win32_libid arg | |
| 5157 # return the library type of file 'arg' | |
| 5158 # | |
| 5159 # Need a lot of goo to handle *both* DLLs and import libs | |
| 5160 # Has to be a shell function in order to 'eat' the argument | |
| 5161 # that is supplied when $file_magic_command is called. | |
| 5162 # Despite the name, also deal with 64 bit binaries. | |
| 5163 func_win32_libid () | |
| 5164 { | |
| 5165 $debug_cmd | |
| 5166 | |
| 5167 win32_libid_type=unknown | |
| 5168 win32_fileres=`file -L $1 2>/dev/null` | |
| 5169 case $win32_fileres in | |
| 5170 *ar\ archive\ import\ library*) # definitely import | |
| 5171 win32_libid_type="x86 archive import" | |
| 5172 ;; | |
| 5173 *ar\ archive*) # could be an import, or static | |
| 5174 # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. | |
| 5175 if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | | |
| 5176 $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then | |
| 5177 case $nm_interface in | |
| 5178 "MS dumpbin") | |
| 5179 if func_cygming_ms_implib_p "$1" || | |
| 5180 func_cygming_gnu_implib_p "$1" | |
| 5181 then | |
| 5182 win32_nmres=import | |
| 5183 else | |
| 5184 win32_nmres= | |
| 5185 fi | |
| 5186 ;; | |
| 5187 *) | |
| 5188 func_to_tool_file "$1" func_convert_file_msys_to_w32 | |
| 5189 win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | | |
| 5190 $SED -n -e ' | |
| 5191 1,100{ | |
| 5192 / I /{ | |
| 5193 s|.*|import| | |
| 5194 p | |
| 5195 q | |
| 5196 } | |
| 5197 }'` | |
| 5198 ;; | |
| 5199 esac | |
| 5200 case $win32_nmres in | |
| 5201 import*) win32_libid_type="x86 archive import";; | |
| 5202 *) win32_libid_type="x86 archive static";; | |
| 5203 esac | |
| 5204 fi | |
| 5205 ;; | |
| 5206 *DLL*) | |
| 5207 win32_libid_type="x86 DLL" | |
| 5208 ;; | |
| 5209 *executable*) # but shell scripts are "executable" too... | |
| 5210 case $win32_fileres in | |
| 5211 *MS\ Windows\ PE\ Intel*) | |
| 5212 win32_libid_type="x86 DLL" | |
| 5213 ;; | |
| 5214 esac | |
| 5215 ;; | |
| 5216 esac | |
| 5217 $ECHO "$win32_libid_type" | |
| 5218 } | |
| 5219 | |
| 5220 # func_cygming_dll_for_implib ARG | |
| 5221 # | |
| 5222 # Platform-specific function to extract the | |
| 5223 # name of the DLL associated with the specified | |
| 5224 # import library ARG. | |
| 5225 # Invoked by eval'ing the libtool variable | |
| 5226 # $sharedlib_from_linklib_cmd | |
| 5227 # Result is available in the variable | |
| 5228 # $sharedlib_from_linklib_result | |
| 5229 func_cygming_dll_for_implib () | |
| 5230 { | |
| 5231 $debug_cmd | |
| 5232 | |
| 5233 sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` | |
| 5234 } | |
| 5235 | |
| 5236 # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs | |
| 5237 # | |
| 5238 # The is the core of a fallback implementation of a | |
| 5239 # platform-specific function to extract the name of the | |
| 5240 # DLL associated with the specified import library LIBNAME. | |
| 5241 # | |
| 5242 # SECTION_NAME is either .idata$6 or .idata$7, depending | |
| 5243 # on the platform and compiler that created the implib. | |
| 5244 # | |
| 5245 # Echos the name of the DLL associated with the | |
| 5246 # specified import library. | |
| 5247 func_cygming_dll_for_implib_fallback_core () | |
| 5248 { | |
| 5249 $debug_cmd | |
| 5250 | |
| 5251 match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` | |
| 5252 $OBJDUMP -s --section "$1" "$2" 2>/dev/null | | |
| 5253 $SED '/^Contents of section '"$match_literal"':/{ | |
| 5254 # Place marker at beginning of archive member dllname section | |
| 5255 s/.*/====MARK====/ | |
| 5256 p | |
| 5257 d | |
| 5258 } | |
| 5259 # These lines can sometimes be longer than 43 characters, but | |
| 5260 # are always uninteresting | |
| 5261 /:[ ]*file format pe[i]\{,1\}-/d | |
| 5262 /^In archive [^:]*:/d | |
| 5263 # Ensure marker is printed | |
| 5264 /^====MARK====/p | |
| 5265 # Remove all lines with less than 43 characters | |
| 5266 /^.\{43\}/!d | |
| 5267 # From remaining lines, remove first 43 characters | |
| 5268 s/^.\{43\}//' | | |
| 5269 $SED -n ' | |
| 5270 # Join marker and all lines until next marker into a single line | |
| 5271 /^====MARK====/ b para | |
| 5272 H | |
| 5273 $ b para | |
| 5274 b | |
| 5275 :para | |
| 5276 x | |
| 5277 s/\n//g | |
| 5278 # Remove the marker | |
| 5279 s/^====MARK====// | |
| 5280 # Remove trailing dots and whitespace | |
| 5281 s/[\. \t]*$// | |
| 5282 # Print | |
| 5283 /./p' | | |
| 5284 # we now have a list, one entry per line, of the stringified | |
| 5285 # contents of the appropriate section of all members of the | |
| 5286 # archive that possess that section. Heuristic: eliminate | |
| 5287 # all those that have a first or second character that is | |
| 5288 # a '.' (that is, objdump's representation of an unprintable | |
| 5289 # character.) This should work for all archives with less than | |
| 5290 # 0x302f exports -- but will fail for DLLs whose name actually | |
| 5291 # begins with a literal '.' or a single character followed by | |
| 5292 # a '.'. | |
| 5293 # | |
| 5294 # Of those that remain, print the first one. | |
| 5295 $SED -e '/^\./d;/^.\./d;q' | |
| 5296 } | |
| 5297 | |
| 5298 # func_cygming_dll_for_implib_fallback ARG | |
| 5299 # Platform-specific function to extract the | |
| 5300 # name of the DLL associated with the specified | |
| 5301 # import library ARG. | |
| 5302 # | |
| 5303 # This fallback implementation is for use when $DLLTOOL | |
| 5304 # does not support the --identify-strict option. | |
| 5305 # Invoked by eval'ing the libtool variable | |
| 5306 # $sharedlib_from_linklib_cmd | |
| 5307 # Result is available in the variable | |
| 5308 # $sharedlib_from_linklib_result | |
| 5309 func_cygming_dll_for_implib_fallback () | |
| 5310 { | |
| 5311 $debug_cmd | |
| 5312 | |
| 5313 if func_cygming_gnu_implib_p "$1"; then | |
| 5314 # binutils import library | |
| 5315 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` | |
| 5316 elif func_cygming_ms_implib_p "$1"; then | |
| 5317 # ms-generated import library | |
| 5318 sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` | |
| 5319 else | |
| 5320 # unknown | |
| 5321 sharedlib_from_linklib_result= | |
| 5322 fi | |
| 5323 } | |
| 5324 | |
| 5325 | |
| 5326 # func_extract_an_archive dir oldlib | |
| 5327 func_extract_an_archive () | |
| 5328 { | |
| 5329 $debug_cmd | |
| 5330 | |
| 5331 f_ex_an_ar_dir=$1; shift | |
| 5332 f_ex_an_ar_oldlib=$1 | |
| 5333 if test yes = "$lock_old_archive_extraction"; then | |
| 5334 lockfile=$f_ex_an_ar_oldlib.lock | |
| 5335 until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do | |
| 5336 func_echo "Waiting for $lockfile to be removed" | |
| 5337 sleep 2 | |
| 5338 done | |
| 5339 fi | |
| 5340 func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ | |
| 5341 'stat=$?; rm -f "$lockfile"; exit $stat' | |
| 5342 if test yes = "$lock_old_archive_extraction"; then | |
| 5343 $opt_dry_run || rm -f "$lockfile" | |
| 5344 fi | |
| 5345 if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then | |
| 5346 : | |
| 5347 else | |
| 5348 func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" | |
| 5349 fi | |
| 5350 } | |
| 5351 | |
| 5352 | |
| 5353 # func_extract_archives gentop oldlib ... | |
| 5354 func_extract_archives () | |
| 5355 { | |
| 5356 $debug_cmd | |
| 5357 | |
| 5358 my_gentop=$1; shift | |
| 5359 my_oldlibs=${1+"$@"} | |
| 5360 my_oldobjs= | |
| 5361 my_xlib= | |
| 5362 my_xabs= | |
| 5363 my_xdir= | |
| 5364 | |
| 5365 for my_xlib in $my_oldlibs; do | |
| 5366 # Extract the objects. | |
| 5367 case $my_xlib in | |
| 5368 [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; | |
| 5369 *) my_xabs=`pwd`"/$my_xlib" ;; | |
| 5370 esac | |
| 5371 func_basename "$my_xlib" | |
| 5372 my_xlib=$func_basename_result | |
| 5373 my_xlib_u=$my_xlib | |
| 5374 while :; do | |
| 5375 case " $extracted_archives " in | |
| 5376 *" $my_xlib_u "*) | |
| 5377 func_arith $extracted_serial + 1 | |
| 5378 extracted_serial=$func_arith_result | |
| 5379 my_xlib_u=lt$extracted_serial-$my_xlib ;; | |
| 5380 *) break ;; | |
| 5381 esac | |
| 5382 done | |
| 5383 extracted_archives="$extracted_archives $my_xlib_u" | |
| 5384 my_xdir=$my_gentop/$my_xlib_u | |
| 5385 | |
| 5386 func_mkdir_p "$my_xdir" | |
| 5387 | |
| 5388 case $host in | |
| 5389 *-darwin*) | |
| 5390 func_verbose "Extracting $my_xabs" | |
| 5391 # Do not bother doing anything if just a dry run | |
| 5392 $opt_dry_run || { | |
| 5393 darwin_orig_dir=`pwd` | |
| 5394 cd $my_xdir || exit $? | |
| 5395 darwin_archive=$my_xabs | |
| 5396 darwin_curdir=`pwd` | |
| 5397 func_basename "$darwin_archive" | |
| 5398 darwin_base_archive=$func_basename_result | |
| 5399 darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` | |
| 5400 if test -n "$darwin_arches"; then | |
| 5401 darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` | |
| 5402 darwin_arch= | |
| 5403 func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" | |
| 5404 for darwin_arch in $darwin_arches; do | |
| 5405 func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" | |
| 5406 $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" | |
| 5407 cd "unfat-$$/$darwin_base_archive-$darwin_arch" | |
| 5408 func_extract_an_archive "`pwd`" "$darwin_base_archive" | |
| 5409 cd "$darwin_curdir" | |
| 5410 $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" | |
| 5411 done # $darwin_arches | |
| 5412 ## Okay now we've a bunch of thin objects, gotta fatten them up :) | |
| 5413 darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` | |
| 5414 darwin_file= | |
| 5415 darwin_files= | |
| 5416 for darwin_file in $darwin_filelist; do | |
| 5417 darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` | |
| 5418 $LIPO -create -output "$darwin_file" $darwin_files | |
| 5419 done # $darwin_filelist | |
| 5420 $RM -rf unfat-$$ | |
| 5421 cd "$darwin_orig_dir" | |
| 5422 else | |
| 5423 cd $darwin_orig_dir | |
| 5424 func_extract_an_archive "$my_xdir" "$my_xabs" | |
| 5425 fi # $darwin_arches | |
| 5426 } # !$opt_dry_run | |
| 5427 ;; | |
| 5428 *) | |
| 5429 func_extract_an_archive "$my_xdir" "$my_xabs" | |
| 5430 ;; | |
| 5431 esac | |
| 5432 my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` | |
| 5433 done | |
| 5434 | |
| 5435 func_extract_archives_result=$my_oldobjs | |
| 5436 } | |
| 5437 | |
| 5438 | |
| 5439 # func_emit_wrapper [arg=no] | |
| 5440 # | |
| 5441 # Emit a libtool wrapper script on stdout. | |
| 5442 # Don't directly open a file because we may want to | |
| 5443 # incorporate the script contents within a cygwin/mingw | |
| 5444 # wrapper executable. Must ONLY be called from within | |
| 5445 # func_mode_link because it depends on a number of variables | |
| 5446 # set therein. | |
| 5447 # | |
| 5448 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR | |
| 5449 # variable will take. If 'yes', then the emitted script | |
| 5450 # will assume that the directory where it is stored is | |
| 5451 # the $objdir directory. This is a cygwin/mingw-specific | |
| 5452 # behavior. | |
| 5453 func_emit_wrapper () | |
| 5454 { | |
| 5455 func_emit_wrapper_arg1=${1-no} | |
| 5456 | |
| 5457 $ECHO "\ | |
| 5458 #! $SHELL | |
| 5459 | |
| 5460 # $output - temporary wrapper script for $objdir/$outputname | |
| 5461 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION | |
| 5462 # | |
| 5463 # The $output program cannot be directly executed until all the libtool | |
| 5464 # libraries that it depends on are installed. | |
| 5465 # | |
| 5466 # This wrapper script should never be moved out of the build directory. | |
| 5467 # If it is, it will not operate correctly. | |
| 5468 | |
| 5469 # Sed substitution that helps us do robust quoting. It backslashifies | |
| 5470 # metacharacters that are still active within double-quoted strings. | |
| 5471 sed_quote_subst='$sed_quote_subst' | |
| 5472 | |
| 5473 # Be Bourne compatible | |
| 5474 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then | |
| 5475 emulate sh | |
| 5476 NULLCMD=: | |
| 5477 # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which | |
| 5478 # is contrary to our usage. Disable this feature. | |
| 5479 alias -g '\${1+\"\$@\"}'='\"\$@\"' | |
| 5480 setopt NO_GLOB_SUBST | |
| 5481 else | |
| 5482 case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac | |
| 5483 fi | |
| 5484 BIN_SH=xpg4; export BIN_SH # for Tru64 | |
| 5485 DUALCASE=1; export DUALCASE # for MKS sh | |
| 5486 | |
| 5487 # The HP-UX ksh and POSIX shell print the target directory to stdout | |
| 5488 # if CDPATH is set. | |
| 5489 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH | |
| 5490 | |
| 5491 relink_command=\"$relink_command\" | |
| 5492 | |
| 5493 # This environment variable determines our operation mode. | |
| 5494 if test \"\$libtool_install_magic\" = \"$magic\"; then | |
| 5495 # install mode needs the following variables: | |
| 5496 generated_by_libtool_version='$macro_version' | |
| 5497 notinst_deplibs='$notinst_deplibs' | |
| 5498 else | |
| 5499 # When we are sourced in execute mode, \$file and \$ECHO are already set. | |
| 5500 if test \"\$libtool_execute_magic\" != \"$magic\"; then | |
| 5501 file=\"\$0\"" | |
| 5502 | |
| 5503 func_quote_arg pretty "$ECHO" | |
| 5504 qECHO=$func_quote_arg_result | |
| 5505 $ECHO "\ | |
| 5506 | |
| 5507 # A function that is used when there is no print builtin or printf. | |
| 5508 func_fallback_echo () | |
| 5509 { | |
| 5510 eval 'cat <<_LTECHO_EOF | |
| 5511 \$1 | |
| 5512 _LTECHO_EOF' | |
| 5513 } | |
| 5514 ECHO=$qECHO | |
| 5515 fi | |
| 5516 | |
| 5517 # Very basic option parsing. These options are (a) specific to | |
| 5518 # the libtool wrapper, (b) are identical between the wrapper | |
| 5519 # /script/ and the wrapper /executable/ that is used only on | |
| 5520 # windows platforms, and (c) all begin with the string "--lt-" | |
| 5521 # (application programs are unlikely to have options that match | |
| 5522 # this pattern). | |
| 5523 # | |
| 5524 # There are only two supported options: --lt-debug and | |
| 5525 # --lt-dump-script. There is, deliberately, no --lt-help. | |
| 5526 # | |
| 5527 # The first argument to this parsing function should be the | |
| 5528 # script's $0 value, followed by "$@". | |
| 5529 lt_option_debug= | |
| 5530 func_parse_lt_options () | |
| 5531 { | |
| 5532 lt_script_arg0=\$0 | |
| 5533 shift | |
| 5534 for lt_opt | |
| 5535 do | |
| 5536 case \"\$lt_opt\" in | |
| 5537 --lt-debug) lt_option_debug=1 ;; | |
| 5538 --lt-dump-script) | |
| 5539 lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` | |
| 5540 test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. | |
| 5541 lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` | |
| 5542 cat \"\$lt_dump_D/\$lt_dump_F\" | |
| 5543 exit 0 | |
| 5544 ;; | |
| 5545 --lt-*) | |
| 5546 \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 | |
| 5547 exit 1 | |
| 5548 ;; | |
| 5549 esac | |
| 5550 done | |
| 5551 | |
| 5552 # Print the debug banner immediately: | |
| 5553 if test -n \"\$lt_option_debug\"; then | |
| 5554 echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 | |
| 5555 fi | |
| 5556 } | |
| 5557 | |
| 5558 # Used when --lt-debug. Prints its arguments to stdout | |
| 5559 # (redirection is the responsibility of the caller) | |
| 5560 func_lt_dump_args () | |
| 5561 { | |
| 5562 lt_dump_args_N=1; | |
| 5563 for lt_arg | |
| 5564 do | |
| 5565 \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" | |
| 5566 lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` | |
| 5567 done | |
| 5568 } | |
| 5569 | |
| 5570 # Core function for launching the target application | |
| 5571 func_exec_program_core () | |
| 5572 { | |
| 5573 " | |
| 5574 case $host in | |
| 5575 # Backslashes separate directories on plain windows | |
| 5576 *-*-mingw | *-*-os2* | *-cegcc*) | |
| 5577 $ECHO "\ | |
| 5578 if test -n \"\$lt_option_debug\"; then | |
| 5579 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 | |
| 5580 func_lt_dump_args \${1+\"\$@\"} 1>&2 | |
| 5581 fi | |
| 5582 exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} | |
| 5583 " | |
| 5584 ;; | |
| 5585 | |
| 5586 *) | |
| 5587 $ECHO "\ | |
| 5588 if test -n \"\$lt_option_debug\"; then | |
| 5589 \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 | |
| 5590 func_lt_dump_args \${1+\"\$@\"} 1>&2 | |
| 5591 fi | |
| 5592 exec \"\$progdir/\$program\" \${1+\"\$@\"} | |
| 5593 " | |
| 5594 ;; | |
| 5595 esac | |
| 5596 $ECHO "\ | |
| 5597 \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 | |
| 5598 exit 1 | |
| 5599 } | |
| 5600 | |
| 5601 # A function to encapsulate launching the target application | |
| 5602 # Strips options in the --lt-* namespace from \$@ and | |
| 5603 # launches target application with the remaining arguments. | |
| 5604 func_exec_program () | |
| 5605 { | |
| 5606 case \" \$* \" in | |
| 5607 *\\ --lt-*) | |
| 5608 for lt_wr_arg | |
| 5609 do | |
| 5610 case \$lt_wr_arg in | |
| 5611 --lt-*) ;; | |
| 5612 *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; | |
| 5613 esac | |
| 5614 shift | |
| 5615 done ;; | |
| 5616 esac | |
| 5617 func_exec_program_core \${1+\"\$@\"} | |
| 5618 } | |
| 5619 | |
| 5620 # Parse options | |
| 5621 func_parse_lt_options \"\$0\" \${1+\"\$@\"} | |
| 5622 | |
| 5623 # Find the directory that this script lives in. | |
| 5624 thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` | |
| 5625 test \"x\$thisdir\" = \"x\$file\" && thisdir=. | |
| 5626 | |
| 5627 # Follow symbolic links until we get to the real thisdir. | |
| 5628 file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` | |
| 5629 while test -n \"\$file\"; do | |
| 5630 destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` | |
| 5631 | |
| 5632 # If there was a directory component, then change thisdir. | |
| 5633 if test \"x\$destdir\" != \"x\$file\"; then | |
| 5634 case \"\$destdir\" in | |
| 5635 [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; | |
| 5636 *) thisdir=\"\$thisdir/\$destdir\" ;; | |
| 5637 esac | |
| 5638 fi | |
| 5639 | |
| 5640 file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` | |
| 5641 file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` | |
| 5642 done | |
| 5643 | |
| 5644 # Usually 'no', except on cygwin/mingw when embedded into | |
| 5645 # the cwrapper. | |
| 5646 WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 | |
| 5647 if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then | |
| 5648 # special case for '.' | |
| 5649 if test \"\$thisdir\" = \".\"; then | |
| 5650 thisdir=\`pwd\` | |
| 5651 fi | |
| 5652 # remove .libs from thisdir | |
| 5653 case \"\$thisdir\" in | |
| 5654 *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; | |
| 5655 $objdir ) thisdir=. ;; | |
| 5656 esac | |
| 5657 fi | |
| 5658 | |
| 5659 # Try to get the absolute directory name. | |
| 5660 absdir=\`cd \"\$thisdir\" && pwd\` | |
| 5661 test -n \"\$absdir\" && thisdir=\"\$absdir\" | |
| 5662 " | |
| 5663 | |
| 5664 if test yes = "$fast_install"; then | |
| 5665 $ECHO "\ | |
| 5666 program=lt-'$outputname'$exeext | |
| 5667 progdir=\"\$thisdir/$objdir\" | |
| 5668 | |
| 5669 if test ! -f \"\$progdir/\$program\" || | |
| 5670 { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ | |
| 5671 test \"X\$file\" != \"X\$progdir/\$program\"; }; then | |
| 5672 | |
| 5673 file=\"\$\$-\$program\" | |
| 5674 | |
| 5675 if test ! -d \"\$progdir\"; then | |
| 5676 $MKDIR \"\$progdir\" | |
| 5677 else | |
| 5678 $RM \"\$progdir/\$file\" | |
| 5679 fi" | |
| 5680 | |
| 5681 $ECHO "\ | |
| 5682 | |
| 5683 # relink executable if necessary | |
| 5684 if test -n \"\$relink_command\"; then | |
| 5685 if relink_command_output=\`eval \$relink_command 2>&1\`; then : | |
| 5686 else | |
| 5687 \$ECHO \"\$relink_command_output\" >&2 | |
| 5688 $RM \"\$progdir/\$file\" | |
| 5689 exit 1 | |
| 5690 fi | |
| 5691 fi | |
| 5692 | |
| 5693 $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || | |
| 5694 { $RM \"\$progdir/\$program\"; | |
| 5695 $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } | |
| 5696 $RM \"\$progdir/\$file\" | |
| 5697 fi" | |
| 5698 else | |
| 5699 $ECHO "\ | |
| 5700 program='$outputname' | |
| 5701 progdir=\"\$thisdir/$objdir\" | |
| 5702 " | |
| 5703 fi | |
| 5704 | |
| 5705 $ECHO "\ | |
| 5706 | |
| 5707 if test -f \"\$progdir/\$program\"; then" | |
| 5708 | |
| 5709 # fixup the dll searchpath if we need to. | |
| 5710 # | |
| 5711 # Fix the DLL searchpath if we need to. Do this before prepending | |
| 5712 # to shlibpath, because on Windows, both are PATH and uninstalled | |
| 5713 # libraries must come first. | |
| 5714 if test -n "$dllsearchpath"; then | |
| 5715 $ECHO "\ | |
| 5716 # Add the dll search path components to the executable PATH | |
| 5717 PATH=$dllsearchpath:\$PATH | |
| 5718 " | |
| 5719 fi | |
| 5720 | |
| 5721 # Export our shlibpath_var if we have one. | |
| 5722 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then | |
| 5723 $ECHO "\ | |
| 5724 # Add our own library path to $shlibpath_var | |
| 5725 $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" | |
| 5726 | |
| 5727 # Some systems cannot cope with colon-terminated $shlibpath_var | |
| 5728 # The second colon is a workaround for a bug in BeOS R4 sed | |
| 5729 $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` | |
| 5730 | |
| 5731 export $shlibpath_var | |
| 5732 " | |
| 5733 fi | |
| 5734 | |
| 5735 $ECHO "\ | |
| 5736 if test \"\$libtool_execute_magic\" != \"$magic\"; then | |
| 5737 # Run the actual program with our arguments. | |
| 5738 func_exec_program \${1+\"\$@\"} | |
| 5739 fi | |
| 5740 else | |
| 5741 # The program doesn't exist. | |
| 5742 \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 | |
| 5743 \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 | |
| 5744 \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 | |
| 5745 exit 1 | |
| 5746 fi | |
| 5747 fi\ | |
| 5748 " | |
| 5749 } | |
| 5750 | |
| 5751 | |
| 5752 # func_emit_cwrapperexe_src | |
| 5753 # emit the source code for a wrapper executable on stdout | |
| 5754 # Must ONLY be called from within func_mode_link because | |
| 5755 # it depends on a number of variable set therein. | |
| 5756 func_emit_cwrapperexe_src () | |
| 5757 { | |
| 5758 cat <<EOF | |
| 5759 | |
| 5760 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname | |
| 5761 Generated by $PROGRAM (GNU $PACKAGE) $VERSION | |
| 5762 | |
| 5763 The $output program cannot be directly executed until all the libtool | |
| 5764 libraries that it depends on are installed. | |
| 5765 | |
| 5766 This wrapper executable should never be moved out of the build directory. | |
| 5767 If it is, it will not operate correctly. | |
| 5768 */ | |
| 5769 EOF | |
| 5770 cat <<"EOF" | |
| 5771 #ifdef _MSC_VER | |
| 5772 # define _CRT_SECURE_NO_DEPRECATE 1 | |
| 5773 #endif | |
| 5774 #include <stdio.h> | |
| 5775 #include <stdlib.h> | |
| 5776 #ifdef _MSC_VER | |
| 5777 # include <direct.h> | |
| 5778 # include <process.h> | |
| 5779 # include <io.h> | |
| 5780 #else | |
| 5781 # include <unistd.h> | |
| 5782 # include <stdint.h> | |
| 5783 # ifdef __CYGWIN__ | |
| 5784 # include <io.h> | |
| 5785 # endif | |
| 5786 #endif | |
| 5787 #include <malloc.h> | |
| 5788 #include <stdarg.h> | |
| 5789 #include <assert.h> | |
| 5790 #include <string.h> | |
| 5791 #include <ctype.h> | |
| 5792 #include <errno.h> | |
| 5793 #include <fcntl.h> | |
| 5794 #include <sys/stat.h> | |
| 5795 | |
| 5796 #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) | |
| 5797 | |
| 5798 /* declarations of non-ANSI functions */ | |
| 5799 #if defined __MINGW32__ | |
| 5800 # ifdef __STRICT_ANSI__ | |
| 5801 int _putenv (const char *); | |
| 5802 # endif | |
| 5803 #elif defined __CYGWIN__ | |
| 5804 # ifdef __STRICT_ANSI__ | |
| 5805 char *realpath (const char *, char *); | |
| 5806 int putenv (char *); | |
| 5807 int setenv (const char *, const char *, int); | |
| 5808 # endif | |
| 5809 /* #elif defined other_platform || defined ... */ | |
| 5810 #endif | |
| 5811 | |
| 5812 /* portability defines, excluding path handling macros */ | |
| 5813 #if defined _MSC_VER | |
| 5814 # define setmode _setmode | |
| 5815 # define stat _stat | |
| 5816 # define chmod _chmod | |
| 5817 # define getcwd _getcwd | |
| 5818 # define putenv _putenv | |
| 5819 # define S_IXUSR _S_IEXEC | |
| 5820 #elif defined __MINGW32__ | |
| 5821 # define setmode _setmode | |
| 5822 # define stat _stat | |
| 5823 # define chmod _chmod | |
| 5824 # define getcwd _getcwd | |
| 5825 # define putenv _putenv | |
| 5826 #elif defined __CYGWIN__ | |
| 5827 # define HAVE_SETENV | |
| 5828 # define FOPEN_WB "wb" | |
| 5829 /* #elif defined other platforms ... */ | |
| 5830 #endif | |
| 5831 | |
| 5832 #if defined PATH_MAX | |
| 5833 # define LT_PATHMAX PATH_MAX | |
| 5834 #elif defined MAXPATHLEN | |
| 5835 # define LT_PATHMAX MAXPATHLEN | |
| 5836 #else | |
| 5837 # define LT_PATHMAX 1024 | |
| 5838 #endif | |
| 5839 | |
| 5840 #ifndef S_IXOTH | |
| 5841 # define S_IXOTH 0 | |
| 5842 #endif | |
| 5843 #ifndef S_IXGRP | |
| 5844 # define S_IXGRP 0 | |
| 5845 #endif | |
| 5846 | |
| 5847 /* path handling portability macros */ | |
| 5848 #ifndef DIR_SEPARATOR | |
| 5849 # define DIR_SEPARATOR '/' | |
| 5850 # define PATH_SEPARATOR ':' | |
| 5851 #endif | |
| 5852 | |
| 5853 #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ | |
| 5854 defined __OS2__ | |
| 5855 # define HAVE_DOS_BASED_FILE_SYSTEM | |
| 5856 # define FOPEN_WB "wb" | |
| 5857 # ifndef DIR_SEPARATOR_2 | |
| 5858 # define DIR_SEPARATOR_2 '\\' | |
| 5859 # endif | |
| 5860 # ifndef PATH_SEPARATOR_2 | |
| 5861 # define PATH_SEPARATOR_2 ';' | |
| 5862 # endif | |
| 5863 #endif | |
| 5864 | |
| 5865 #ifndef DIR_SEPARATOR_2 | |
| 5866 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) | |
| 5867 #else /* DIR_SEPARATOR_2 */ | |
| 5868 # define IS_DIR_SEPARATOR(ch) \ | |
| 5869 (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) | |
| 5870 #endif /* DIR_SEPARATOR_2 */ | |
| 5871 | |
| 5872 #ifndef PATH_SEPARATOR_2 | |
| 5873 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) | |
| 5874 #else /* PATH_SEPARATOR_2 */ | |
| 5875 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) | |
| 5876 #endif /* PATH_SEPARATOR_2 */ | |
| 5877 | |
| 5878 #ifndef FOPEN_WB | |
| 5879 # define FOPEN_WB "w" | |
| 5880 #endif | |
| 5881 #ifndef _O_BINARY | |
| 5882 # define _O_BINARY 0 | |
| 5883 #endif | |
| 5884 | |
| 5885 #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) | |
| 5886 #define XFREE(stale) do { \ | |
| 5887 if (stale) { free (stale); stale = 0; } \ | |
| 5888 } while (0) | |
| 5889 | |
| 5890 #if defined LT_DEBUGWRAPPER | |
| 5891 static int lt_debug = 1; | |
| 5892 #else | |
| 5893 static int lt_debug = 0; | |
| 5894 #endif | |
| 5895 | |
| 5896 const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ | |
| 5897 | |
| 5898 void *xmalloc (size_t num); | |
| 5899 char *xstrdup (const char *string); | |
| 5900 const char *base_name (const char *name); | |
| 5901 char *find_executable (const char *wrapper); | |
| 5902 char *chase_symlinks (const char *pathspec); | |
| 5903 int make_executable (const char *path); | |
| 5904 int check_executable (const char *path); | |
| 5905 char *strendzap (char *str, const char *pat); | |
| 5906 void lt_debugprintf (const char *file, int line, const char *fmt, ...); | |
| 5907 void lt_fatal (const char *file, int line, const char *message, ...); | |
| 5908 static const char *nonnull (const char *s); | |
| 5909 static const char *nonempty (const char *s); | |
| 5910 void lt_setenv (const char *name, const char *value); | |
| 5911 char *lt_extend_str (const char *orig_value, const char *add, int to_end); | |
| 5912 void lt_update_exe_path (const char *name, const char *value); | |
| 5913 void lt_update_lib_path (const char *name, const char *value); | |
| 5914 char **prepare_spawn (char **argv); | |
| 5915 void lt_dump_script (FILE *f); | |
| 5916 EOF | |
| 5917 | |
| 5918 cat <<EOF | |
| 5919 #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) | |
| 5920 # define externally_visible volatile | |
| 5921 #else | |
| 5922 # define externally_visible __attribute__((externally_visible)) volatile | |
| 5923 #endif | |
| 5924 externally_visible const char * MAGIC_EXE = "$magic_exe"; | |
| 5925 const char * LIB_PATH_VARNAME = "$shlibpath_var"; | |
| 5926 EOF | |
| 5927 | |
| 5928 if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then | |
| 5929 func_to_host_path "$temp_rpath" | |
| 5930 cat <<EOF | |
| 5931 const char * LIB_PATH_VALUE = "$func_to_host_path_result"; | |
| 5932 EOF | |
| 5933 else | |
| 5934 cat <<"EOF" | |
| 5935 const char * LIB_PATH_VALUE = ""; | |
| 5936 EOF | |
| 5937 fi | |
| 5938 | |
| 5939 if test -n "$dllsearchpath"; then | |
| 5940 func_to_host_path "$dllsearchpath:" | |
| 5941 cat <<EOF | |
| 5942 const char * EXE_PATH_VARNAME = "PATH"; | |
| 5943 const char * EXE_PATH_VALUE = "$func_to_host_path_result"; | |
| 5944 EOF | |
| 5945 else | |
| 5946 cat <<"EOF" | |
| 5947 const char * EXE_PATH_VARNAME = ""; | |
| 5948 const char * EXE_PATH_VALUE = ""; | |
| 5949 EOF | |
| 5950 fi | |
| 5951 | |
| 5952 if test yes = "$fast_install"; then | |
| 5953 cat <<EOF | |
| 5954 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ | |
| 5955 EOF | |
| 5956 else | |
| 5957 cat <<EOF | |
| 5958 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ | |
| 5959 EOF | |
| 5960 fi | |
| 5961 | |
| 5962 | |
| 5963 cat <<"EOF" | |
| 5964 | |
| 5965 #define LTWRAPPER_OPTION_PREFIX "--lt-" | |
| 5966 | |
| 5967 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; | |
| 5968 static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; | |
| 5969 static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; | |
| 5970 | |
| 5971 int | |
| 5972 main (int argc, char *argv[]) | |
| 5973 { | |
| 5974 char **newargz; | |
| 5975 int newargc; | |
| 5976 char *tmp_pathspec; | |
| 5977 char *actual_cwrapper_path; | |
| 5978 char *actual_cwrapper_name; | |
| 5979 char *target_name; | |
| 5980 char *lt_argv_zero; | |
| 5981 int rval = 127; | |
| 5982 | |
| 5983 int i; | |
| 5984 | |
| 5985 program_name = (char *) xstrdup (base_name (argv[0])); | |
| 5986 newargz = XMALLOC (char *, (size_t) argc + 1); | |
| 5987 | |
| 5988 /* very simple arg parsing; don't want to rely on getopt | |
| 5989 * also, copy all non cwrapper options to newargz, except | |
| 5990 * argz[0], which is handled differently | |
| 5991 */ | |
| 5992 newargc=0; | |
| 5993 for (i = 1; i < argc; i++) | |
| 5994 { | |
| 5995 if (STREQ (argv[i], dumpscript_opt)) | |
| 5996 { | |
| 5997 EOF | |
| 5998 case $host in | |
| 5999 *mingw* | *cygwin* ) | |
| 6000 # make stdout use "unix" line endings | |
| 6001 echo " setmode(1,_O_BINARY);" | |
| 6002 ;; | |
| 6003 esac | |
| 6004 | |
| 6005 cat <<"EOF" | |
| 6006 lt_dump_script (stdout); | |
| 6007 return 0; | |
| 6008 } | |
| 6009 if (STREQ (argv[i], debug_opt)) | |
| 6010 { | |
| 6011 lt_debug = 1; | |
| 6012 continue; | |
| 6013 } | |
| 6014 if (STREQ (argv[i], ltwrapper_option_prefix)) | |
| 6015 { | |
| 6016 /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX | |
| 6017 namespace, but it is not one of the ones we know about and | |
| 6018 have already dealt with, above (inluding dump-script), then | |
| 6019 report an error. Otherwise, targets might begin to believe | |
| 6020 they are allowed to use options in the LTWRAPPER_OPTION_PREFIX | |
| 6021 namespace. The first time any user complains about this, we'll | |
| 6022 need to make LTWRAPPER_OPTION_PREFIX a configure-time option | |
| 6023 or a configure.ac-settable value. | |
| 6024 */ | |
| 6025 lt_fatal (__FILE__, __LINE__, | |
| 6026 "unrecognized %s option: '%s'", | |
| 6027 ltwrapper_option_prefix, argv[i]); | |
| 6028 } | |
| 6029 /* otherwise ... */ | |
| 6030 newargz[++newargc] = xstrdup (argv[i]); | |
| 6031 } | |
| 6032 newargz[++newargc] = NULL; | |
| 6033 | |
| 6034 EOF | |
| 6035 cat <<EOF | |
| 6036 /* The GNU banner must be the first non-error debug message */ | |
| 6037 lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); | |
| 6038 EOF | |
| 6039 cat <<"EOF" | |
| 6040 lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); | |
| 6041 lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); | |
| 6042 | |
| 6043 tmp_pathspec = find_executable (argv[0]); | |
| 6044 if (tmp_pathspec == NULL) | |
| 6045 lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); | |
| 6046 lt_debugprintf (__FILE__, __LINE__, | |
| 6047 "(main) found exe (before symlink chase) at: %s\n", | |
| 6048 tmp_pathspec); | |
| 6049 | |
| 6050 actual_cwrapper_path = chase_symlinks (tmp_pathspec); | |
| 6051 lt_debugprintf (__FILE__, __LINE__, | |
| 6052 "(main) found exe (after symlink chase) at: %s\n", | |
| 6053 actual_cwrapper_path); | |
| 6054 XFREE (tmp_pathspec); | |
| 6055 | |
| 6056 actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); | |
| 6057 strendzap (actual_cwrapper_path, actual_cwrapper_name); | |
| 6058 | |
| 6059 /* wrapper name transforms */ | |
| 6060 strendzap (actual_cwrapper_name, ".exe"); | |
| 6061 tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); | |
| 6062 XFREE (actual_cwrapper_name); | |
| 6063 actual_cwrapper_name = tmp_pathspec; | |
| 6064 tmp_pathspec = 0; | |
| 6065 | |
| 6066 /* target_name transforms -- use actual target program name; might have lt- prefix */ | |
| 6067 target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); | |
| 6068 strendzap (target_name, ".exe"); | |
| 6069 tmp_pathspec = lt_extend_str (target_name, ".exe", 1); | |
| 6070 XFREE (target_name); | |
| 6071 target_name = tmp_pathspec; | |
| 6072 tmp_pathspec = 0; | |
| 6073 | |
| 6074 lt_debugprintf (__FILE__, __LINE__, | |
| 6075 "(main) libtool target name: %s\n", | |
| 6076 target_name); | |
| 6077 EOF | |
| 6078 | |
| 6079 cat <<EOF | |
| 6080 newargz[0] = | |
| 6081 XMALLOC (char, (strlen (actual_cwrapper_path) + | |
| 6082 strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); | |
| 6083 strcpy (newargz[0], actual_cwrapper_path); | |
| 6084 strcat (newargz[0], "$objdir"); | |
| 6085 strcat (newargz[0], "/"); | |
| 6086 EOF | |
| 6087 | |
| 6088 cat <<"EOF" | |
| 6089 /* stop here, and copy so we don't have to do this twice */ | |
| 6090 tmp_pathspec = xstrdup (newargz[0]); | |
| 6091 | |
| 6092 /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ | |
| 6093 strcat (newargz[0], actual_cwrapper_name); | |
| 6094 | |
| 6095 /* DO want the lt- prefix here if it exists, so use target_name */ | |
| 6096 lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); | |
| 6097 XFREE (tmp_pathspec); | |
| 6098 tmp_pathspec = NULL; | |
| 6099 EOF | |
| 6100 | |
| 6101 case $host_os in | |
| 6102 mingw*) | |
| 6103 cat <<"EOF" | |
| 6104 { | |
| 6105 char* p; | |
| 6106 while ((p = strchr (newargz[0], '\\')) != NULL) | |
| 6107 { | |
| 6108 *p = '/'; | |
| 6109 } | |
| 6110 while ((p = strchr (lt_argv_zero, '\\')) != NULL) | |
| 6111 { | |
| 6112 *p = '/'; | |
| 6113 } | |
| 6114 } | |
| 6115 EOF | |
| 6116 ;; | |
| 6117 esac | |
| 6118 | |
| 6119 cat <<"EOF" | |
| 6120 XFREE (target_name); | |
| 6121 XFREE (actual_cwrapper_path); | |
| 6122 XFREE (actual_cwrapper_name); | |
| 6123 | |
| 6124 lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ | |
| 6125 lt_setenv ("DUALCASE", "1"); /* for MSK sh */ | |
| 6126 /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must | |
| 6127 be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) | |
| 6128 because on Windows, both *_VARNAMEs are PATH but uninstalled | |
| 6129 libraries must come first. */ | |
| 6130 lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); | |
| 6131 lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); | |
| 6132 | |
| 6133 lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", | |
| 6134 nonnull (lt_argv_zero)); | |
| 6135 for (i = 0; i < newargc; i++) | |
| 6136 { | |
| 6137 lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", | |
| 6138 i, nonnull (newargz[i])); | |
| 6139 } | |
| 6140 | |
| 6141 EOF | |
| 6142 | |
| 6143 case $host_os in | |
| 6144 mingw*) | |
| 6145 cat <<"EOF" | |
| 6146 /* execv doesn't actually work on mingw as expected on unix */ | |
| 6147 newargz = prepare_spawn (newargz); | |
| 6148 rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); | |
| 6149 if (rval == -1) | |
| 6150 { | |
| 6151 /* failed to start process */ | |
| 6152 lt_debugprintf (__FILE__, __LINE__, | |
| 6153 "(main) failed to launch target \"%s\": %s\n", | |
| 6154 lt_argv_zero, nonnull (strerror (errno))); | |
| 6155 return 127; | |
| 6156 } | |
| 6157 return rval; | |
| 6158 EOF | |
| 6159 ;; | |
| 6160 *) | |
| 6161 cat <<"EOF" | |
| 6162 execv (lt_argv_zero, newargz); | |
| 6163 return rval; /* =127, but avoids unused variable warning */ | |
| 6164 EOF | |
| 6165 ;; | |
| 6166 esac | |
| 6167 | |
| 6168 cat <<"EOF" | |
| 6169 } | |
| 6170 | |
| 6171 void * | |
| 6172 xmalloc (size_t num) | |
| 6173 { | |
| 6174 void *p = (void *) malloc (num); | |
| 6175 if (!p) | |
| 6176 lt_fatal (__FILE__, __LINE__, "memory exhausted"); | |
| 6177 | |
| 6178 return p; | |
| 6179 } | |
| 6180 | |
| 6181 char * | |
| 6182 xstrdup (const char *string) | |
| 6183 { | |
| 6184 return string ? strcpy ((char *) xmalloc (strlen (string) + 1), | |
| 6185 string) : NULL; | |
| 6186 } | |
| 6187 | |
| 6188 const char * | |
| 6189 base_name (const char *name) | |
| 6190 { | |
| 6191 const char *base; | |
| 6192 | |
| 6193 #if defined HAVE_DOS_BASED_FILE_SYSTEM | |
| 6194 /* Skip over the disk name in MSDOS pathnames. */ | |
| 6195 if (isalpha ((unsigned char) name[0]) && name[1] == ':') | |
| 6196 name += 2; | |
| 6197 #endif | |
| 6198 | |
| 6199 for (base = name; *name; name++) | |
| 6200 if (IS_DIR_SEPARATOR (*name)) | |
| 6201 base = name + 1; | |
| 6202 return base; | |
| 6203 } | |
| 6204 | |
| 6205 int | |
| 6206 check_executable (const char *path) | |
| 6207 { | |
| 6208 struct stat st; | |
| 6209 | |
| 6210 lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", | |
| 6211 nonempty (path)); | |
| 6212 if ((!path) || (!*path)) | |
| 6213 return 0; | |
| 6214 | |
| 6215 if ((stat (path, &st) >= 0) | |
| 6216 && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) | |
| 6217 return 1; | |
| 6218 else | |
| 6219 return 0; | |
| 6220 } | |
| 6221 | |
| 6222 int | |
| 6223 make_executable (const char *path) | |
| 6224 { | |
| 6225 int rval = 0; | |
| 6226 struct stat st; | |
| 6227 | |
| 6228 lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", | |
| 6229 nonempty (path)); | |
| 6230 if ((!path) || (!*path)) | |
| 6231 return 0; | |
| 6232 | |
| 6233 if (stat (path, &st) >= 0) | |
| 6234 { | |
| 6235 rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); | |
| 6236 } | |
| 6237 return rval; | |
| 6238 } | |
| 6239 | |
| 6240 /* Searches for the full path of the wrapper. Returns | |
| 6241 newly allocated full path name if found, NULL otherwise | |
| 6242 Does not chase symlinks, even on platforms that support them. | |
| 6243 */ | |
| 6244 char * | |
| 6245 find_executable (const char *wrapper) | |
| 6246 { | |
| 6247 int has_slash = 0; | |
| 6248 const char *p; | |
| 6249 const char *p_next; | |
| 6250 /* static buffer for getcwd */ | |
| 6251 char tmp[LT_PATHMAX + 1]; | |
| 6252 size_t tmp_len; | |
| 6253 char *concat_name; | |
| 6254 | |
| 6255 lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", | |
| 6256 nonempty (wrapper)); | |
| 6257 | |
| 6258 if ((wrapper == NULL) || (*wrapper == '\0')) | |
| 6259 return NULL; | |
| 6260 | |
| 6261 /* Absolute path? */ | |
| 6262 #if defined HAVE_DOS_BASED_FILE_SYSTEM | |
| 6263 if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') | |
| 6264 { | |
| 6265 concat_name = xstrdup (wrapper); | |
| 6266 if (check_executable (concat_name)) | |
| 6267 return concat_name; | |
| 6268 XFREE (concat_name); | |
| 6269 } | |
| 6270 else | |
| 6271 { | |
| 6272 #endif | |
| 6273 if (IS_DIR_SEPARATOR (wrapper[0])) | |
| 6274 { | |
| 6275 concat_name = xstrdup (wrapper); | |
| 6276 if (check_executable (concat_name)) | |
| 6277 return concat_name; | |
| 6278 XFREE (concat_name); | |
| 6279 } | |
| 6280 #if defined HAVE_DOS_BASED_FILE_SYSTEM | |
| 6281 } | |
| 6282 #endif | |
| 6283 | |
| 6284 for (p = wrapper; *p; p++) | |
| 6285 if (*p == '/') | |
| 6286 { | |
| 6287 has_slash = 1; | |
| 6288 break; | |
| 6289 } | |
| 6290 if (!has_slash) | |
| 6291 { | |
| 6292 /* no slashes; search PATH */ | |
| 6293 const char *path = getenv ("PATH"); | |
| 6294 if (path != NULL) | |
| 6295 { | |
| 6296 for (p = path; *p; p = p_next) | |
| 6297 { | |
| 6298 const char *q; | |
| 6299 size_t p_len; | |
| 6300 for (q = p; *q; q++) | |
| 6301 if (IS_PATH_SEPARATOR (*q)) | |
| 6302 break; | |
| 6303 p_len = (size_t) (q - p); | |
| 6304 p_next = (*q == '\0' ? q : q + 1); | |
| 6305 if (p_len == 0) | |
| 6306 { | |
| 6307 /* empty path: current directory */ | |
| 6308 if (getcwd (tmp, LT_PATHMAX) == NULL) | |
| 6309 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", | |
| 6310 nonnull (strerror (errno))); | |
| 6311 tmp_len = strlen (tmp); | |
| 6312 concat_name = | |
| 6313 XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); | |
| 6314 memcpy (concat_name, tmp, tmp_len); | |
| 6315 concat_name[tmp_len] = '/'; | |
| 6316 strcpy (concat_name + tmp_len + 1, wrapper); | |
| 6317 } | |
| 6318 else | |
| 6319 { | |
| 6320 concat_name = | |
| 6321 XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); | |
| 6322 memcpy (concat_name, p, p_len); | |
| 6323 concat_name[p_len] = '/'; | |
| 6324 strcpy (concat_name + p_len + 1, wrapper); | |
| 6325 } | |
| 6326 if (check_executable (concat_name)) | |
| 6327 return concat_name; | |
| 6328 XFREE (concat_name); | |
| 6329 } | |
| 6330 } | |
| 6331 /* not found in PATH; assume curdir */ | |
| 6332 } | |
| 6333 /* Relative path | not found in path: prepend cwd */ | |
| 6334 if (getcwd (tmp, LT_PATHMAX) == NULL) | |
| 6335 lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", | |
| 6336 nonnull (strerror (errno))); | |
| 6337 tmp_len = strlen (tmp); | |
| 6338 concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); | |
| 6339 memcpy (concat_name, tmp, tmp_len); | |
| 6340 concat_name[tmp_len] = '/'; | |
| 6341 strcpy (concat_name + tmp_len + 1, wrapper); | |
| 6342 | |
| 6343 if (check_executable (concat_name)) | |
| 6344 return concat_name; | |
| 6345 XFREE (concat_name); | |
| 6346 return NULL; | |
| 6347 } | |
| 6348 | |
| 6349 char * | |
| 6350 chase_symlinks (const char *pathspec) | |
| 6351 { | |
| 6352 #ifndef S_ISLNK | |
| 6353 return xstrdup (pathspec); | |
| 6354 #else | |
| 6355 char buf[LT_PATHMAX]; | |
| 6356 struct stat s; | |
| 6357 char *tmp_pathspec = xstrdup (pathspec); | |
| 6358 char *p; | |
| 6359 int has_symlinks = 0; | |
| 6360 while (strlen (tmp_pathspec) && !has_symlinks) | |
| 6361 { | |
| 6362 lt_debugprintf (__FILE__, __LINE__, | |
| 6363 "checking path component for symlinks: %s\n", | |
| 6364 tmp_pathspec); | |
| 6365 if (lstat (tmp_pathspec, &s) == 0) | |
| 6366 { | |
| 6367 if (S_ISLNK (s.st_mode) != 0) | |
| 6368 { | |
| 6369 has_symlinks = 1; | |
| 6370 break; | |
| 6371 } | |
| 6372 | |
| 6373 /* search backwards for last DIR_SEPARATOR */ | |
| 6374 p = tmp_pathspec + strlen (tmp_pathspec) - 1; | |
| 6375 while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) | |
| 6376 p--; | |
| 6377 if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) | |
| 6378 { | |
| 6379 /* no more DIR_SEPARATORS left */ | |
| 6380 break; | |
| 6381 } | |
| 6382 *p = '\0'; | |
| 6383 } | |
| 6384 else | |
| 6385 { | |
| 6386 lt_fatal (__FILE__, __LINE__, | |
| 6387 "error accessing file \"%s\": %s", | |
| 6388 tmp_pathspec, nonnull (strerror (errno))); | |
| 6389 } | |
| 6390 } | |
| 6391 XFREE (tmp_pathspec); | |
| 6392 | |
| 6393 if (!has_symlinks) | |
| 6394 { | |
| 6395 return xstrdup (pathspec); | |
| 6396 } | |
| 6397 | |
| 6398 tmp_pathspec = realpath (pathspec, buf); | |
| 6399 if (tmp_pathspec == 0) | |
| 6400 { | |
| 6401 lt_fatal (__FILE__, __LINE__, | |
| 6402 "could not follow symlinks for %s", pathspec); | |
| 6403 } | |
| 6404 return xstrdup (tmp_pathspec); | |
| 6405 #endif | |
| 6406 } | |
| 6407 | |
| 6408 char * | |
| 6409 strendzap (char *str, const char *pat) | |
| 6410 { | |
| 6411 size_t len, patlen; | |
| 6412 | |
| 6413 assert (str != NULL); | |
| 6414 assert (pat != NULL); | |
| 6415 | |
| 6416 len = strlen (str); | |
| 6417 patlen = strlen (pat); | |
| 6418 | |
| 6419 if (patlen <= len) | |
| 6420 { | |
| 6421 str += len - patlen; | |
| 6422 if (STREQ (str, pat)) | |
| 6423 *str = '\0'; | |
| 6424 } | |
| 6425 return str; | |
| 6426 } | |
| 6427 | |
| 6428 void | |
| 6429 lt_debugprintf (const char *file, int line, const char *fmt, ...) | |
| 6430 { | |
| 6431 va_list args; | |
| 6432 if (lt_debug) | |
| 6433 { | |
| 6434 (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); | |
| 6435 va_start (args, fmt); | |
| 6436 (void) vfprintf (stderr, fmt, args); | |
| 6437 va_end (args); | |
| 6438 } | |
| 6439 } | |
| 6440 | |
| 6441 static void | |
| 6442 lt_error_core (int exit_status, const char *file, | |
| 6443 int line, const char *mode, | |
| 6444 const char *message, va_list ap) | |
| 6445 { | |
| 6446 fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); | |
| 6447 vfprintf (stderr, message, ap); | |
| 6448 fprintf (stderr, ".\n"); | |
| 6449 | |
| 6450 if (exit_status >= 0) | |
| 6451 exit (exit_status); | |
| 6452 } | |
| 6453 | |
| 6454 void | |
| 6455 lt_fatal (const char *file, int line, const char *message, ...) | |
| 6456 { | |
| 6457 va_list ap; | |
| 6458 va_start (ap, message); | |
| 6459 lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); | |
| 6460 va_end (ap); | |
| 6461 } | |
| 6462 | |
| 6463 static const char * | |
| 6464 nonnull (const char *s) | |
| 6465 { | |
| 6466 return s ? s : "(null)"; | |
| 6467 } | |
| 6468 | |
| 6469 static const char * | |
| 6470 nonempty (const char *s) | |
| 6471 { | |
| 6472 return (s && !*s) ? "(empty)" : nonnull (s); | |
| 6473 } | |
| 6474 | |
| 6475 void | |
| 6476 lt_setenv (const char *name, const char *value) | |
| 6477 { | |
| 6478 lt_debugprintf (__FILE__, __LINE__, | |
| 6479 "(lt_setenv) setting '%s' to '%s'\n", | |
| 6480 nonnull (name), nonnull (value)); | |
| 6481 { | |
| 6482 #ifdef HAVE_SETENV | |
| 6483 /* always make a copy, for consistency with !HAVE_SETENV */ | |
| 6484 char *str = xstrdup (value); | |
| 6485 setenv (name, str, 1); | |
| 6486 #else | |
| 6487 size_t len = strlen (name) + 1 + strlen (value) + 1; | |
| 6488 char *str = XMALLOC (char, len); | |
| 6489 sprintf (str, "%s=%s", name, value); | |
| 6490 if (putenv (str) != EXIT_SUCCESS) | |
| 6491 { | |
| 6492 XFREE (str); | |
| 6493 } | |
| 6494 #endif | |
| 6495 } | |
| 6496 } | |
| 6497 | |
| 6498 char * | |
| 6499 lt_extend_str (const char *orig_value, const char *add, int to_end) | |
| 6500 { | |
| 6501 char *new_value; | |
| 6502 if (orig_value && *orig_value) | |
| 6503 { | |
| 6504 size_t orig_value_len = strlen (orig_value); | |
| 6505 size_t add_len = strlen (add); | |
| 6506 new_value = XMALLOC (char, add_len + orig_value_len + 1); | |
| 6507 if (to_end) | |
| 6508 { | |
| 6509 strcpy (new_value, orig_value); | |
| 6510 strcpy (new_value + orig_value_len, add); | |
| 6511 } | |
| 6512 else | |
| 6513 { | |
| 6514 strcpy (new_value, add); | |
| 6515 strcpy (new_value + add_len, orig_value); | |
| 6516 } | |
| 6517 } | |
| 6518 else | |
| 6519 { | |
| 6520 new_value = xstrdup (add); | |
| 6521 } | |
| 6522 return new_value; | |
| 6523 } | |
| 6524 | |
| 6525 void | |
| 6526 lt_update_exe_path (const char *name, const char *value) | |
| 6527 { | |
| 6528 lt_debugprintf (__FILE__, __LINE__, | |
| 6529 "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", | |
| 6530 nonnull (name), nonnull (value)); | |
| 6531 | |
| 6532 if (name && *name && value && *value) | |
| 6533 { | |
| 6534 char *new_value = lt_extend_str (getenv (name), value, 0); | |
| 6535 /* some systems can't cope with a ':'-terminated path #' */ | |
| 6536 size_t len = strlen (new_value); | |
| 6537 while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) | |
| 6538 { | |
| 6539 new_value[--len] = '\0'; | |
| 6540 } | |
| 6541 lt_setenv (name, new_value); | |
| 6542 XFREE (new_value); | |
| 6543 } | |
| 6544 } | |
| 6545 | |
| 6546 void | |
| 6547 lt_update_lib_path (const char *name, const char *value) | |
| 6548 { | |
| 6549 lt_debugprintf (__FILE__, __LINE__, | |
| 6550 "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", | |
| 6551 nonnull (name), nonnull (value)); | |
| 6552 | |
| 6553 if (name && *name && value && *value) | |
| 6554 { | |
| 6555 char *new_value = lt_extend_str (getenv (name), value, 0); | |
| 6556 lt_setenv (name, new_value); | |
| 6557 XFREE (new_value); | |
| 6558 } | |
| 6559 } | |
| 6560 | |
| 6561 EOF | |
| 6562 case $host_os in | |
| 6563 mingw*) | |
| 6564 cat <<"EOF" | |
| 6565 | |
| 6566 /* Prepares an argument vector before calling spawn(). | |
| 6567 Note that spawn() does not by itself call the command interpreter | |
| 6568 (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : | |
| 6569 ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); | |
| 6570 GetVersionEx(&v); | |
| 6571 v.dwPlatformId == VER_PLATFORM_WIN32_NT; | |
| 6572 }) ? "cmd.exe" : "command.com"). | |
| 6573 Instead it simply concatenates the arguments, separated by ' ', and calls | |
| 6574 CreateProcess(). We must quote the arguments since Win32 CreateProcess() | |
| 6575 interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a | |
| 6576 special way: | |
| 6577 - Space and tab are interpreted as delimiters. They are not treated as | |
| 6578 delimiters if they are surrounded by double quotes: "...". | |
| 6579 - Unescaped double quotes are removed from the input. Their only effect is | |
| 6580 that within double quotes, space and tab are treated like normal | |
| 6581 characters. | |
| 6582 - Backslashes not followed by double quotes are not special. | |
| 6583 - But 2*n+1 backslashes followed by a double quote become | |
| 6584 n backslashes followed by a double quote (n >= 0): | |
| 6585 \" -> " | |
| 6586 \\\" -> \" | |
| 6587 \\\\\" -> \\" | |
| 6588 */ | |
| 6589 #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" | |
| 6590 #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" | |
| 6591 char ** | |
| 6592 prepare_spawn (char **argv) | |
| 6593 { | |
| 6594 size_t argc; | |
| 6595 char **new_argv; | |
| 6596 size_t i; | |
| 6597 | |
| 6598 /* Count number of arguments. */ | |
| 6599 for (argc = 0; argv[argc] != NULL; argc++) | |
| 6600 ; | |
| 6601 | |
| 6602 /* Allocate new argument vector. */ | |
| 6603 new_argv = XMALLOC (char *, argc + 1); | |
| 6604 | |
| 6605 /* Put quoted arguments into the new argument vector. */ | |
| 6606 for (i = 0; i < argc; i++) | |
| 6607 { | |
| 6608 const char *string = argv[i]; | |
| 6609 | |
| 6610 if (string[0] == '\0') | |
| 6611 new_argv[i] = xstrdup ("\"\""); | |
| 6612 else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) | |
| 6613 { | |
| 6614 int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); | |
| 6615 size_t length; | |
| 6616 unsigned int backslashes; | |
| 6617 const char *s; | |
| 6618 char *quoted_string; | |
| 6619 char *p; | |
| 6620 | |
| 6621 length = 0; | |
| 6622 backslashes = 0; | |
| 6623 if (quote_around) | |
| 6624 length++; | |
| 6625 for (s = string; *s != '\0'; s++) | |
| 6626 { | |
| 6627 char c = *s; | |
| 6628 if (c == '"') | |
| 6629 length += backslashes + 1; | |
| 6630 length++; | |
| 6631 if (c == '\\') | |
| 6632 backslashes++; | |
| 6633 else | |
| 6634 backslashes = 0; | |
| 6635 } | |
| 6636 if (quote_around) | |
| 6637 length += backslashes + 1; | |
| 6638 | |
| 6639 quoted_string = XMALLOC (char, length + 1); | |
| 6640 | |
| 6641 p = quoted_string; | |
| 6642 backslashes = 0; | |
| 6643 if (quote_around) | |
| 6644 *p++ = '"'; | |
| 6645 for (s = string; *s != '\0'; s++) | |
| 6646 { | |
| 6647 char c = *s; | |
| 6648 if (c == '"') | |
| 6649 { | |
| 6650 unsigned int j; | |
| 6651 for (j = backslashes + 1; j > 0; j--) | |
| 6652 *p++ = '\\'; | |
| 6653 } | |
| 6654 *p++ = c; | |
| 6655 if (c == '\\') | |
| 6656 backslashes++; | |
| 6657 else | |
| 6658 backslashes = 0; | |
| 6659 } | |
| 6660 if (quote_around) | |
| 6661 { | |
| 6662 unsigned int j; | |
| 6663 for (j = backslashes; j > 0; j--) | |
| 6664 *p++ = '\\'; | |
| 6665 *p++ = '"'; | |
| 6666 } | |
| 6667 *p = '\0'; | |
| 6668 | |
| 6669 new_argv[i] = quoted_string; | |
| 6670 } | |
| 6671 else | |
| 6672 new_argv[i] = (char *) string; | |
| 6673 } | |
| 6674 new_argv[argc] = NULL; | |
| 6675 | |
| 6676 return new_argv; | |
| 6677 } | |
| 6678 EOF | |
| 6679 ;; | |
| 6680 esac | |
| 6681 | |
| 6682 cat <<"EOF" | |
| 6683 void lt_dump_script (FILE* f) | |
| 6684 { | |
| 6685 EOF | |
| 6686 func_emit_wrapper yes | | |
| 6687 $SED -n -e ' | |
| 6688 s/^\(.\{79\}\)\(..*\)/\1\ | |
| 6689 \2/ | |
| 6690 h | |
| 6691 s/\([\\"]\)/\\\1/g | |
| 6692 s/$/\\n/ | |
| 6693 s/\([^\n]*\).*/ fputs ("\1", f);/p | |
| 6694 g | |
| 6695 D' | |
| 6696 cat <<"EOF" | |
| 6697 } | |
| 6698 EOF | |
| 6699 } | |
| 6700 # end: func_emit_cwrapperexe_src | |
| 6701 | |
| 6702 # func_win32_import_lib_p ARG | |
| 6703 # True if ARG is an import lib, as indicated by $file_magic_cmd | |
| 6704 func_win32_import_lib_p () | |
| 6705 { | |
| 6706 $debug_cmd | |
| 6707 | |
| 6708 case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in | |
| 6709 *import*) : ;; | |
| 6710 *) false ;; | |
| 6711 esac | |
| 6712 } | |
| 6713 | |
| 6714 # func_suncc_cstd_abi | |
| 6715 # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! | |
| 6716 # Several compiler flags select an ABI that is incompatible with the | |
| 6717 # Cstd library. Avoid specifying it if any are in CXXFLAGS. | |
| 6718 func_suncc_cstd_abi () | |
| 6719 { | |
| 6720 $debug_cmd | |
| 6721 | |
| 6722 case " $compile_command " in | |
| 6723 *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) | |
| 6724 suncc_use_cstd_abi=no | |
| 6725 ;; | |
| 6726 *) | |
| 6727 suncc_use_cstd_abi=yes | |
| 6728 ;; | |
| 6729 esac | |
| 6730 } | |
| 6731 | |
| 6732 # func_mode_link arg... | |
| 6733 func_mode_link () | |
| 6734 { | |
| 6735 $debug_cmd | |
| 6736 | |
| 6737 case $host in | |
| 6738 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) | |
| 6739 # It is impossible to link a dll without this setting, and | |
| 6740 # we shouldn't force the makefile maintainer to figure out | |
| 6741 # what system we are compiling for in order to pass an extra | |
| 6742 # flag for every libtool invocation. | |
| 6743 # allow_undefined=no | |
| 6744 | |
| 6745 # FIXME: Unfortunately, there are problems with the above when trying | |
| 6746 # to make a dll that has undefined symbols, in which case not | |
| 6747 # even a static library is built. For now, we need to specify | |
| 6748 # -no-undefined on the libtool link line when we can be certain | |
| 6749 # that all symbols are satisfied, otherwise we get a static library. | |
| 6750 allow_undefined=yes | |
| 6751 ;; | |
| 6752 *) | |
| 6753 allow_undefined=yes | |
| 6754 ;; | |
| 6755 esac | |
| 6756 libtool_args=$nonopt | |
| 6757 base_compile="$nonopt $@" | |
| 6758 compile_command=$nonopt | |
| 6759 finalize_command=$nonopt | |
| 6760 | |
| 6761 compile_rpath= | |
| 6762 finalize_rpath= | |
| 6763 compile_shlibpath= | |
| 6764 finalize_shlibpath= | |
| 6765 convenience= | |
| 6766 old_convenience= | |
| 6767 deplibs= | |
| 6768 old_deplibs= | |
| 6769 compiler_flags= | |
| 6770 linker_flags= | |
| 6771 dllsearchpath= | |
| 6772 lib_search_path=`pwd` | |
| 6773 inst_prefix_dir= | |
| 6774 new_inherited_linker_flags= | |
| 6775 | |
| 6776 avoid_version=no | |
| 6777 bindir= | |
| 6778 dlfiles= | |
| 6779 dlprefiles= | |
| 6780 dlself=no | |
| 6781 export_dynamic=no | |
| 6782 export_symbols= | |
| 6783 export_symbols_regex= | |
| 6784 generated= | |
| 6785 libobjs= | |
| 6786 ltlibs= | |
| 6787 module=no | |
| 6788 no_install=no | |
| 6789 objs= | |
| 6790 os2dllname= | |
| 6791 non_pic_objects= | |
| 6792 precious_files_regex= | |
| 6793 prefer_static_libs=no | |
| 6794 preload=false | |
| 6795 prev= | |
| 6796 prevarg= | |
| 6797 release= | |
| 6798 rpath= | |
| 6799 xrpath= | |
| 6800 perm_rpath= | |
| 6801 temp_rpath= | |
| 6802 thread_safe=no | |
| 6803 vinfo= | |
| 6804 vinfo_number=no | |
| 6805 weak_libs= | |
| 6806 single_module=$wl-single_module | |
| 6807 func_infer_tag $base_compile | |
| 6808 | |
| 6809 # We need to know -static, to get the right output filenames. | |
| 6810 for arg | |
| 6811 do | |
| 6812 case $arg in | |
| 6813 -shared) | |
| 6814 test yes != "$build_libtool_libs" \ | |
| 6815 && func_fatal_configuration "cannot build a shared library" | |
| 6816 build_old_libs=no | |
| 6817 break | |
| 6818 ;; | |
| 6819 -all-static | -static | -static-libtool-libs) | |
| 6820 case $arg in | |
| 6821 -all-static) | |
| 6822 if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then | |
| 6823 func_warning "complete static linking is impossible in this configuration" | |
| 6824 fi | |
| 6825 if test -n "$link_static_flag"; then | |
| 6826 dlopen_self=$dlopen_self_static | |
| 6827 fi | |
| 6828 prefer_static_libs=yes | |
| 6829 ;; | |
| 6830 -static) | |
| 6831 if test -z "$pic_flag" && test -n "$link_static_flag"; then | |
| 6832 dlopen_self=$dlopen_self_static | |
| 6833 fi | |
| 6834 prefer_static_libs=built | |
| 6835 ;; | |
| 6836 -static-libtool-libs) | |
| 6837 if test -z "$pic_flag" && test -n "$link_static_flag"; then | |
| 6838 dlopen_self=$dlopen_self_static | |
| 6839 fi | |
| 6840 prefer_static_libs=yes | |
| 6841 ;; | |
| 6842 esac | |
| 6843 build_libtool_libs=no | |
| 6844 build_old_libs=yes | |
| 6845 break | |
| 6846 ;; | |
| 6847 esac | |
| 6848 done | |
| 6849 | |
| 6850 # See if our shared archives depend on static archives. | |
| 6851 test -n "$old_archive_from_new_cmds" && build_old_libs=yes | |
| 6852 | |
| 6853 # Go through the arguments, transforming them on the way. | |
| 6854 while test "$#" -gt 0; do | |
| 6855 arg=$1 | |
| 6856 shift | |
| 6857 func_quote_arg pretty,unquoted "$arg" | |
| 6858 qarg=$func_quote_arg_unquoted_result | |
| 6859 func_append libtool_args " $func_quote_arg_result" | |
| 6860 | |
| 6861 # If the previous option needs an argument, assign it. | |
| 6862 if test -n "$prev"; then | |
| 6863 case $prev in | |
| 6864 output) | |
| 6865 func_append compile_command " @OUTPUT@" | |
| 6866 func_append finalize_command " @OUTPUT@" | |
| 6867 ;; | |
| 6868 esac | |
| 6869 | |
| 6870 case $prev in | |
| 6871 bindir) | |
| 6872 bindir=$arg | |
| 6873 prev= | |
| 6874 continue | |
| 6875 ;; | |
| 6876 dlfiles|dlprefiles) | |
| 6877 $preload || { | |
| 6878 # Add the symbol object into the linking commands. | |
| 6879 func_append compile_command " @SYMFILE@" | |
| 6880 func_append finalize_command " @SYMFILE@" | |
| 6881 preload=: | |
| 6882 } | |
| 6883 case $arg in | |
| 6884 *.la | *.lo) ;; # We handle these cases below. | |
| 6885 force) | |
| 6886 if test no = "$dlself"; then | |
| 6887 dlself=needless | |
| 6888 export_dynamic=yes | |
| 6889 fi | |
| 6890 prev= | |
| 6891 continue | |
| 6892 ;; | |
| 6893 self) | |
| 6894 if test dlprefiles = "$prev"; then | |
| 6895 dlself=yes | |
| 6896 elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then | |
| 6897 dlself=yes | |
| 6898 else | |
| 6899 dlself=needless | |
| 6900 export_dynamic=yes | |
| 6901 fi | |
| 6902 prev= | |
| 6903 continue | |
| 6904 ;; | |
| 6905 *) | |
| 6906 if test dlfiles = "$prev"; then | |
| 6907 func_append dlfiles " $arg" | |
| 6908 else | |
| 6909 func_append dlprefiles " $arg" | |
| 6910 fi | |
| 6911 prev= | |
| 6912 continue | |
| 6913 ;; | |
| 6914 esac | |
| 6915 ;; | |
| 6916 expsyms) | |
| 6917 export_symbols=$arg | |
| 6918 test -f "$arg" \ | |
| 6919 || func_fatal_error "symbol file '$arg' does not exist" | |
| 6920 prev= | |
| 6921 continue | |
| 6922 ;; | |
| 6923 expsyms_regex) | |
| 6924 export_symbols_regex=$arg | |
| 6925 prev= | |
| 6926 continue | |
| 6927 ;; | |
| 6928 framework) | |
| 6929 case $host in | |
| 6930 *-*-darwin*) | |
| 6931 case "$deplibs " in | |
| 6932 *" $qarg.ltframework "*) ;; | |
| 6933 *) func_append deplibs " $qarg.ltframework" # this is fixed later | |
| 6934 ;; | |
| 6935 esac | |
| 6936 ;; | |
| 6937 esac | |
| 6938 prev= | |
| 6939 continue | |
| 6940 ;; | |
| 6941 inst_prefix) | |
| 6942 inst_prefix_dir=$arg | |
| 6943 prev= | |
| 6944 continue | |
| 6945 ;; | |
| 6946 mllvm) | |
| 6947 # Clang does not use LLVM to link, so we can simply discard any | |
| 6948 # '-mllvm $arg' options when doing the link step. | |
| 6949 prev= | |
| 6950 continue | |
| 6951 ;; | |
| 6952 objectlist) | |
| 6953 if test -f "$arg"; then | |
| 6954 save_arg=$arg | |
| 6955 moreargs= | |
| 6956 for fil in `cat "$save_arg"` | |
| 6957 do | |
| 6958 # func_append moreargs " $fil" | |
| 6959 arg=$fil | |
| 6960 # A libtool-controlled object. | |
| 6961 | |
| 6962 # Check to see that this really is a libtool object. | |
| 6963 if func_lalib_unsafe_p "$arg"; then | |
| 6964 pic_object= | |
| 6965 non_pic_object= | |
| 6966 | |
| 6967 # Read the .lo file | |
| 6968 func_source "$arg" | |
| 6969 | |
| 6970 if test -z "$pic_object" || | |
| 6971 test -z "$non_pic_object" || | |
| 6972 test none = "$pic_object" && | |
| 6973 test none = "$non_pic_object"; then | |
| 6974 func_fatal_error "cannot find name of object for '$arg'" | |
| 6975 fi | |
| 6976 | |
| 6977 # Extract subdirectory from the argument. | |
| 6978 func_dirname "$arg" "/" "" | |
| 6979 xdir=$func_dirname_result | |
| 6980 | |
| 6981 if test none != "$pic_object"; then | |
| 6982 # Prepend the subdirectory the object is found in. | |
| 6983 pic_object=$xdir$pic_object | |
| 6984 | |
| 6985 if test dlfiles = "$prev"; then | |
| 6986 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then | |
| 6987 func_append dlfiles " $pic_object" | |
| 6988 prev= | |
| 6989 continue | |
| 6990 else | |
| 6991 # If libtool objects are unsupported, then we need to preload. | |
| 6992 prev=dlprefiles | |
| 6993 fi | |
| 6994 fi | |
| 6995 | |
| 6996 # CHECK ME: I think I busted this. -Ossama | |
| 6997 if test dlprefiles = "$prev"; then | |
| 6998 # Preload the old-style object. | |
| 6999 func_append dlprefiles " $pic_object" | |
| 7000 prev= | |
| 7001 fi | |
| 7002 | |
| 7003 # A PIC object. | |
| 7004 func_append libobjs " $pic_object" | |
| 7005 arg=$pic_object | |
| 7006 fi | |
| 7007 | |
| 7008 # Non-PIC object. | |
| 7009 if test none != "$non_pic_object"; then | |
| 7010 # Prepend the subdirectory the object is found in. | |
| 7011 non_pic_object=$xdir$non_pic_object | |
| 7012 | |
| 7013 # A standard non-PIC object | |
| 7014 func_append non_pic_objects " $non_pic_object" | |
| 7015 if test -z "$pic_object" || test none = "$pic_object"; then | |
| 7016 arg=$non_pic_object | |
| 7017 fi | |
| 7018 else | |
| 7019 # If the PIC object exists, use it instead. | |
| 7020 # $xdir was prepended to $pic_object above. | |
| 7021 non_pic_object=$pic_object | |
| 7022 func_append non_pic_objects " $non_pic_object" | |
| 7023 fi | |
| 7024 else | |
| 7025 # Only an error if not doing a dry-run. | |
| 7026 if $opt_dry_run; then | |
| 7027 # Extract subdirectory from the argument. | |
| 7028 func_dirname "$arg" "/" "" | |
| 7029 xdir=$func_dirname_result | |
| 7030 | |
| 7031 func_lo2o "$arg" | |
| 7032 pic_object=$xdir$objdir/$func_lo2o_result | |
| 7033 non_pic_object=$xdir$func_lo2o_result | |
| 7034 func_append libobjs " $pic_object" | |
| 7035 func_append non_pic_objects " $non_pic_object" | |
| 7036 else | |
| 7037 func_fatal_error "'$arg' is not a valid libtool object" | |
| 7038 fi | |
| 7039 fi | |
| 7040 done | |
| 7041 else | |
| 7042 func_fatal_error "link input file '$arg' does not exist" | |
| 7043 fi | |
| 7044 arg=$save_arg | |
| 7045 prev= | |
| 7046 continue | |
| 7047 ;; | |
| 7048 os2dllname) | |
| 7049 os2dllname=$arg | |
| 7050 prev= | |
| 7051 continue | |
| 7052 ;; | |
| 7053 precious_regex) | |
| 7054 precious_files_regex=$arg | |
| 7055 prev= | |
| 7056 continue | |
| 7057 ;; | |
| 7058 release) | |
| 7059 release=-$arg | |
| 7060 prev= | |
| 7061 continue | |
| 7062 ;; | |
| 7063 rpath | xrpath) | |
| 7064 # We need an absolute path. | |
| 7065 case $arg in | |
| 7066 [\\/]* | [A-Za-z]:[\\/]*) ;; | |
| 7067 *) | |
| 7068 func_fatal_error "only absolute run-paths are allowed" | |
| 7069 ;; | |
| 7070 esac | |
| 7071 if test rpath = "$prev"; then | |
| 7072 case "$rpath " in | |
| 7073 *" $arg "*) ;; | |
| 7074 *) func_append rpath " $arg" ;; | |
| 7075 esac | |
| 7076 else | |
| 7077 case "$xrpath " in | |
| 7078 *" $arg "*) ;; | |
| 7079 *) func_append xrpath " $arg" ;; | |
| 7080 esac | |
| 7081 fi | |
| 7082 prev= | |
| 7083 continue | |
| 7084 ;; | |
| 7085 shrext) | |
| 7086 shrext_cmds=$arg | |
| 7087 prev= | |
| 7088 continue | |
| 7089 ;; | |
| 7090 weak) | |
| 7091 func_append weak_libs " $arg" | |
| 7092 prev= | |
| 7093 continue | |
| 7094 ;; | |
| 7095 xassembler) | |
| 7096 func_append compiler_flags " -Xassembler $qarg" | |
| 7097 prev= | |
| 7098 func_append compile_command " -Xassembler $qarg" | |
| 7099 func_append finalize_command " -Xassembler $qarg" | |
| 7100 continue | |
| 7101 ;; | |
| 7102 xcclinker) | |
| 7103 func_append linker_flags " $qarg" | |
| 7104 func_append compiler_flags " $qarg" | |
| 7105 prev= | |
| 7106 func_append compile_command " $qarg" | |
| 7107 func_append finalize_command " $qarg" | |
| 7108 continue | |
| 7109 ;; | |
| 7110 xcompiler) | |
| 7111 func_append compiler_flags " $qarg" | |
| 7112 prev= | |
| 7113 func_append compile_command " $qarg" | |
| 7114 func_append finalize_command " $qarg" | |
| 7115 continue | |
| 7116 ;; | |
| 7117 xlinker) | |
| 7118 func_append linker_flags " $qarg" | |
| 7119 func_append compiler_flags " $wl$qarg" | |
| 7120 prev= | |
| 7121 func_append compile_command " $wl$qarg" | |
| 7122 func_append finalize_command " $wl$qarg" | |
| 7123 continue | |
| 7124 ;; | |
| 7125 *) | |
| 7126 eval "$prev=\"\$arg\"" | |
| 7127 prev= | |
| 7128 continue | |
| 7129 ;; | |
| 7130 esac | |
| 7131 fi # test -n "$prev" | |
| 7132 | |
| 7133 prevarg=$arg | |
| 7134 | |
| 7135 case $arg in | |
| 7136 -all-static) | |
| 7137 if test -n "$link_static_flag"; then | |
| 7138 # See comment for -static flag below, for more details. | |
| 7139 func_append compile_command " $link_static_flag" | |
| 7140 func_append finalize_command " $link_static_flag" | |
| 7141 fi | |
| 7142 continue | |
| 7143 ;; | |
| 7144 | |
| 7145 -allow-undefined) | |
| 7146 # FIXME: remove this flag sometime in the future. | |
| 7147 func_fatal_error "'-allow-undefined' must not be used because it is the default" | |
| 7148 ;; | |
| 7149 | |
| 7150 -avoid-version) | |
| 7151 avoid_version=yes | |
| 7152 continue | |
| 7153 ;; | |
| 7154 | |
| 7155 -bindir) | |
| 7156 prev=bindir | |
| 7157 continue | |
| 7158 ;; | |
| 7159 | |
| 7160 -dlopen) | |
| 7161 prev=dlfiles | |
| 7162 continue | |
| 7163 ;; | |
| 7164 | |
| 7165 -dlpreopen) | |
| 7166 prev=dlprefiles | |
| 7167 continue | |
| 7168 ;; | |
| 7169 | |
| 7170 -export-dynamic) | |
| 7171 export_dynamic=yes | |
| 7172 continue | |
| 7173 ;; | |
| 7174 | |
| 7175 -export-symbols | -export-symbols-regex) | |
| 7176 if test -n "$export_symbols" || test -n "$export_symbols_regex"; then | |
| 7177 func_fatal_error "more than one -exported-symbols argument is not allowed" | |
| 7178 fi | |
| 7179 if test X-export-symbols = "X$arg"; then | |
| 7180 prev=expsyms | |
| 7181 else | |
| 7182 prev=expsyms_regex | |
| 7183 fi | |
| 7184 continue | |
| 7185 ;; | |
| 7186 | |
| 7187 -framework) | |
| 7188 prev=framework | |
| 7189 continue | |
| 7190 ;; | |
| 7191 | |
| 7192 -inst-prefix-dir) | |
| 7193 prev=inst_prefix | |
| 7194 continue | |
| 7195 ;; | |
| 7196 | |
| 7197 # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* | |
| 7198 # so, if we see these flags be careful not to treat them like -L | |
| 7199 -L[A-Z][A-Z]*:*) | |
| 7200 case $with_gcc/$host in | |
| 7201 no/*-*-irix* | /*-*-irix*) | |
| 7202 func_append compile_command " $arg" | |
| 7203 func_append finalize_command " $arg" | |
| 7204 ;; | |
| 7205 esac | |
| 7206 continue | |
| 7207 ;; | |
| 7208 | |
| 7209 -L*) | |
| 7210 func_stripname "-L" '' "$arg" | |
| 7211 if test -z "$func_stripname_result"; then | |
| 7212 if test "$#" -gt 0; then | |
| 7213 func_fatal_error "require no space between '-L' and '$1'" | |
| 7214 else | |
| 7215 func_fatal_error "need path for '-L' option" | |
| 7216 fi | |
| 7217 fi | |
| 7218 func_resolve_sysroot "$func_stripname_result" | |
| 7219 dir=$func_resolve_sysroot_result | |
| 7220 # We need an absolute path. | |
| 7221 case $dir in | |
| 7222 [\\/]* | [A-Za-z]:[\\/]*) ;; | |
| 7223 *) | |
| 7224 absdir=`cd "$dir" && pwd` | |
| 7225 test -z "$absdir" && \ | |
| 7226 func_fatal_error "cannot determine absolute directory name of '$dir'" | |
| 7227 dir=$absdir | |
| 7228 ;; | |
| 7229 esac | |
| 7230 case "$deplibs " in | |
| 7231 *" -L$dir "* | *" $arg "*) | |
| 7232 # Will only happen for absolute or sysroot arguments | |
| 7233 ;; | |
| 7234 *) | |
| 7235 # Preserve sysroot, but never include relative directories | |
| 7236 case $dir in | |
| 7237 [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; | |
| 7238 *) func_append deplibs " -L$dir" ;; | |
| 7239 esac | |
| 7240 func_append lib_search_path " $dir" | |
| 7241 ;; | |
| 7242 esac | |
| 7243 case $host in | |
| 7244 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) | |
| 7245 testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` | |
| 7246 case :$dllsearchpath: in | |
| 7247 *":$dir:"*) ;; | |
| 7248 ::) dllsearchpath=$dir;; | |
| 7249 *) func_append dllsearchpath ":$dir";; | |
| 7250 esac | |
| 7251 case :$dllsearchpath: in | |
| 7252 *":$testbindir:"*) ;; | |
| 7253 ::) dllsearchpath=$testbindir;; | |
| 7254 *) func_append dllsearchpath ":$testbindir";; | |
| 7255 esac | |
| 7256 ;; | |
| 7257 esac | |
| 7258 continue | |
| 7259 ;; | |
| 7260 | |
| 7261 -l*) | |
| 7262 if test X-lc = "X$arg" || test X-lm = "X$arg"; then | |
| 7263 case $host in | |
| 7264 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) | |
| 7265 # These systems don't actually have a C or math library (as such) | |
| 7266 continue | |
| 7267 ;; | |
| 7268 *-*-os2*) | |
| 7269 # These systems don't actually have a C library (as such) | |
| 7270 test X-lc = "X$arg" && continue | |
| 7271 ;; | |
| 7272 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) | |
| 7273 # Do not include libc due to us having libc/libc_r. | |
| 7274 test X-lc = "X$arg" && continue | |
| 7275 ;; | |
| 7276 *-*-rhapsody* | *-*-darwin1.[012]) | |
| 7277 # Rhapsody C and math libraries are in the System framework | |
| 7278 func_append deplibs " System.ltframework" | |
| 7279 continue | |
| 7280 ;; | |
| 7281 *-*-sco3.2v5* | *-*-sco5v6*) | |
| 7282 # Causes problems with __ctype | |
| 7283 test X-lc = "X$arg" && continue | |
| 7284 ;; | |
| 7285 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) | |
| 7286 # Compiler inserts libc in the correct place for threads to work | |
| 7287 test X-lc = "X$arg" && continue | |
| 7288 ;; | |
| 7289 esac | |
| 7290 elif test X-lc_r = "X$arg"; then | |
| 7291 case $host in | |
| 7292 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) | |
| 7293 # Do not include libc_r directly, use -pthread flag. | |
| 7294 continue | |
| 7295 ;; | |
| 7296 esac | |
| 7297 fi | |
| 7298 func_append deplibs " $arg" | |
| 7299 continue | |
| 7300 ;; | |
| 7301 | |
| 7302 -mllvm) | |
| 7303 prev=mllvm | |
| 7304 continue | |
| 7305 ;; | |
| 7306 | |
| 7307 -module) | |
| 7308 module=yes | |
| 7309 continue | |
| 7310 ;; | |
| 7311 | |
| 7312 # Tru64 UNIX uses -model [arg] to determine the layout of C++ | |
| 7313 # classes, name mangling, and exception handling. | |
| 7314 # Darwin uses the -arch flag to determine output architecture. | |
| 7315 -model|-arch|-isysroot|--sysroot) | |
| 7316 func_append compiler_flags " $arg" | |
| 7317 func_append compile_command " $arg" | |
| 7318 func_append finalize_command " $arg" | |
| 7319 prev=xcompiler | |
| 7320 continue | |
| 7321 ;; | |
| 7322 # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. | |
| 7323 -pthread) | |
| 7324 case $host in | |
| 7325 *solaris2*) ;; | |
| 7326 *) | |
| 7327 case "$new_inherited_linker_flags " in | |
| 7328 *" $arg "*) ;; | |
| 7329 * ) func_append new_inherited_linker_flags " $arg" ;; | |
| 7330 esac | |
| 7331 ;; | |
| 7332 esac | |
| 7333 continue | |
| 7334 ;; | |
| 7335 -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ | |
| 7336 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) | |
| 7337 func_append compiler_flags " $arg" | |
| 7338 func_append compile_command " $arg" | |
| 7339 func_append finalize_command " $arg" | |
| 7340 case "$new_inherited_linker_flags " in | |
| 7341 *" $arg "*) ;; | |
| 7342 * ) func_append new_inherited_linker_flags " $arg" ;; | |
| 7343 esac | |
| 7344 continue | |
| 7345 ;; | |
| 7346 | |
| 7347 -multi_module) | |
| 7348 single_module=$wl-multi_module | |
| 7349 continue | |
| 7350 ;; | |
| 7351 | |
| 7352 -no-fast-install) | |
| 7353 fast_install=no | |
| 7354 continue | |
| 7355 ;; | |
| 7356 | |
| 7357 -no-install) | |
| 7358 case $host in | |
| 7359 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) | |
| 7360 # The PATH hackery in wrapper scripts is required on Windows | |
| 7361 # and Darwin in order for the loader to find any dlls it needs. | |
| 7362 func_warning "'-no-install' is ignored for $host" | |
| 7363 func_warning "assuming '-no-fast-install' instead" | |
| 7364 fast_install=no | |
| 7365 ;; | |
| 7366 *) no_install=yes ;; | |
| 7367 esac | |
| 7368 continue | |
| 7369 ;; | |
| 7370 | |
| 7371 -no-undefined) | |
| 7372 allow_undefined=no | |
| 7373 continue | |
| 7374 ;; | |
| 7375 | |
| 7376 -objectlist) | |
| 7377 prev=objectlist | |
| 7378 continue | |
| 7379 ;; | |
| 7380 | |
| 7381 -os2dllname) | |
| 7382 prev=os2dllname | |
| 7383 continue | |
| 7384 ;; | |
| 7385 | |
| 7386 -o) prev=output ;; | |
| 7387 | |
| 7388 -precious-files-regex) | |
| 7389 prev=precious_regex | |
| 7390 continue | |
| 7391 ;; | |
| 7392 | |
| 7393 -release) | |
| 7394 prev=release | |
| 7395 continue | |
| 7396 ;; | |
| 7397 | |
| 7398 -rpath) | |
| 7399 prev=rpath | |
| 7400 continue | |
| 7401 ;; | |
| 7402 | |
| 7403 -R) | |
| 7404 prev=xrpath | |
| 7405 continue | |
| 7406 ;; | |
| 7407 | |
| 7408 -R*) | |
| 7409 func_stripname '-R' '' "$arg" | |
| 7410 dir=$func_stripname_result | |
| 7411 # We need an absolute path. | |
| 7412 case $dir in | |
| 7413 [\\/]* | [A-Za-z]:[\\/]*) ;; | |
| 7414 =*) | |
| 7415 func_stripname '=' '' "$dir" | |
| 7416 dir=$lt_sysroot$func_stripname_result | |
| 7417 ;; | |
| 7418 *) | |
| 7419 func_fatal_error "only absolute run-paths are allowed" | |
| 7420 ;; | |
| 7421 esac | |
| 7422 case "$xrpath " in | |
| 7423 *" $dir "*) ;; | |
| 7424 *) func_append xrpath " $dir" ;; | |
| 7425 esac | |
| 7426 continue | |
| 7427 ;; | |
| 7428 | |
| 7429 -shared) | |
| 7430 # The effects of -shared are defined in a previous loop. | |
| 7431 continue | |
| 7432 ;; | |
| 7433 | |
| 7434 -shrext) | |
| 7435 prev=shrext | |
| 7436 continue | |
| 7437 ;; | |
| 7438 | |
| 7439 -static | -static-libtool-libs) | |
| 7440 # The effects of -static are defined in a previous loop. | |
| 7441 # We used to do the same as -all-static on platforms that | |
| 7442 # didn't have a PIC flag, but the assumption that the effects | |
| 7443 # would be equivalent was wrong. It would break on at least | |
| 7444 # Digital Unix and AIX. | |
| 7445 continue | |
| 7446 ;; | |
| 7447 | |
| 7448 -thread-safe) | |
| 7449 thread_safe=yes | |
| 7450 continue | |
| 7451 ;; | |
| 7452 | |
| 7453 -version-info) | |
| 7454 prev=vinfo | |
| 7455 continue | |
| 7456 ;; | |
| 7457 | |
| 7458 -version-number) | |
| 7459 prev=vinfo | |
| 7460 vinfo_number=yes | |
| 7461 continue | |
| 7462 ;; | |
| 7463 | |
| 7464 -weak) | |
| 7465 prev=weak | |
| 7466 continue | |
| 7467 ;; | |
| 7468 | |
| 7469 -Wc,*) | |
| 7470 func_stripname '-Wc,' '' "$arg" | |
| 7471 args=$func_stripname_result | |
| 7472 arg= | |
| 7473 save_ifs=$IFS; IFS=, | |
| 7474 for flag in $args; do | |
| 7475 IFS=$save_ifs | |
| 7476 func_quote_arg pretty "$flag" | |
| 7477 func_append arg " $func_quote_arg_result" | |
| 7478 func_append compiler_flags " $func_quote_arg_result" | |
| 7479 done | |
| 7480 IFS=$save_ifs | |
| 7481 func_stripname ' ' '' "$arg" | |
| 7482 arg=$func_stripname_result | |
| 7483 ;; | |
| 7484 | |
| 7485 -Wl,*) | |
| 7486 func_stripname '-Wl,' '' "$arg" | |
| 7487 args=$func_stripname_result | |
| 7488 arg= | |
| 7489 save_ifs=$IFS; IFS=, | |
| 7490 for flag in $args; do | |
| 7491 IFS=$save_ifs | |
| 7492 func_quote_arg pretty "$flag" | |
| 7493 func_append arg " $wl$func_quote_arg_result" | |
| 7494 func_append compiler_flags " $wl$func_quote_arg_result" | |
| 7495 func_append linker_flags " $func_quote_arg_result" | |
| 7496 done | |
| 7497 IFS=$save_ifs | |
| 7498 func_stripname ' ' '' "$arg" | |
| 7499 arg=$func_stripname_result | |
| 7500 ;; | |
| 7501 | |
| 7502 -Xassembler) | |
| 7503 prev=xassembler | |
| 7504 continue | |
| 7505 ;; | |
| 7506 | |
| 7507 -Xcompiler) | |
| 7508 prev=xcompiler | |
| 7509 continue | |
| 7510 ;; | |
| 7511 | |
| 7512 -Xlinker) | |
| 7513 prev=xlinker | |
| 7514 continue | |
| 7515 ;; | |
| 7516 | |
| 7517 -XCClinker) | |
| 7518 prev=xcclinker | |
| 7519 continue | |
| 7520 ;; | |
| 7521 | |
| 7522 # -msg_* for osf cc | |
| 7523 -msg_*) | |
| 7524 func_quote_arg pretty "$arg" | |
| 7525 arg=$func_quote_arg_result | |
| 7526 ;; | |
| 7527 | |
| 7528 # Flags to be passed through unchanged, with rationale: | |
| 7529 # -64, -mips[0-9] enable 64-bit mode for the SGI compiler | |
| 7530 # -r[0-9][0-9]* specify processor for the SGI compiler | |
| 7531 # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler | |
| 7532 # +DA*, +DD* enable 64-bit mode for the HP compiler | |
| 7533 # -q* compiler args for the IBM compiler | |
| 7534 # -m*, -t[45]*, -txscale* architecture-specific flags for GCC | |
| 7535 # -F/path path to uninstalled frameworks, gcc on darwin | |
| 7536 # -p, -pg, --coverage, -fprofile-* profiling flags for GCC | |
| 7537 # -fstack-protector* stack protector flags for GCC | |
| 7538 # @file GCC response files | |
| 7539 # -tp=* Portland pgcc target processor selection | |
| 7540 # --sysroot=* for sysroot support | |
| 7541 # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization | |
| 7542 # -specs=* GCC specs files | |
| 7543 # -stdlib=* select c++ std lib with clang | |
| 7544 # -fsanitize=* Clang/GCC memory and address sanitizer | |
| 7545 # -fuse-ld=* Linker select flags for GCC | |
| 7546 # -static-* direct GCC to link specific libraries statically | |
| 7547 # -fcilkplus Cilk Plus language extension features for C/C++ | |
| 7548 # -Wa,* Pass flags directly to the assembler | |
| 7549 -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ | |
| 7550 -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ | |
| 7551 -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ | |
| 7552 -specs=*|-fsanitize=*|-fuse-ld=*|-static-*|-fcilkplus|-Wa,*) | |
| 7553 func_quote_arg pretty "$arg" | |
| 7554 arg=$func_quote_arg_result | |
| 7555 func_append compile_command " $arg" | |
| 7556 func_append finalize_command " $arg" | |
| 7557 func_append compiler_flags " $arg" | |
| 7558 continue | |
| 7559 ;; | |
| 7560 | |
| 7561 -Z*) | |
| 7562 if test os2 = "`expr $host : '.*\(os2\)'`"; then | |
| 7563 # OS/2 uses -Zxxx to specify OS/2-specific options | |
| 7564 compiler_flags="$compiler_flags $arg" | |
| 7565 func_append compile_command " $arg" | |
| 7566 func_append finalize_command " $arg" | |
| 7567 case $arg in | |
| 7568 -Zlinker | -Zstack) | |
| 7569 prev=xcompiler | |
| 7570 ;; | |
| 7571 esac | |
| 7572 continue | |
| 7573 else | |
| 7574 # Otherwise treat like 'Some other compiler flag' below | |
| 7575 func_quote_arg pretty "$arg" | |
| 7576 arg=$func_quote_arg_result | |
| 7577 fi | |
| 7578 ;; | |
| 7579 | |
| 7580 # Some other compiler flag. | |
| 7581 -* | +*) | |
| 7582 func_quote_arg pretty "$arg" | |
| 7583 arg=$func_quote_arg_result | |
| 7584 ;; | |
| 7585 | |
| 7586 *.$objext) | |
| 7587 # A standard object. | |
| 7588 func_append objs " $arg" | |
| 7589 ;; | |
| 7590 | |
| 7591 *.lo) | |
| 7592 # A libtool-controlled object. | |
| 7593 | |
| 7594 # Check to see that this really is a libtool object. | |
| 7595 if func_lalib_unsafe_p "$arg"; then | |
| 7596 pic_object= | |
| 7597 non_pic_object= | |
| 7598 | |
| 7599 # Read the .lo file | |
| 7600 func_source "$arg" | |
| 7601 | |
| 7602 if test -z "$pic_object" || | |
| 7603 test -z "$non_pic_object" || | |
| 7604 test none = "$pic_object" && | |
| 7605 test none = "$non_pic_object"; then | |
| 7606 func_fatal_error "cannot find name of object for '$arg'" | |
| 7607 fi | |
| 7608 | |
| 7609 # Extract subdirectory from the argument. | |
| 7610 func_dirname "$arg" "/" "" | |
| 7611 xdir=$func_dirname_result | |
| 7612 | |
| 7613 test none = "$pic_object" || { | |
| 7614 # Prepend the subdirectory the object is found in. | |
| 7615 pic_object=$xdir$pic_object | |
| 7616 | |
| 7617 if test dlfiles = "$prev"; then | |
| 7618 if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then | |
| 7619 func_append dlfiles " $pic_object" | |
| 7620 prev= | |
| 7621 continue | |
| 7622 else | |
| 7623 # If libtool objects are unsupported, then we need to preload. | |
| 7624 prev=dlprefiles | |
| 7625 fi | |
| 7626 fi | |
| 7627 | |
| 7628 # CHECK ME: I think I busted this. -Ossama | |
| 7629 if test dlprefiles = "$prev"; then | |
| 7630 # Preload the old-style object. | |
| 7631 func_append dlprefiles " $pic_object" | |
| 7632 prev= | |
| 7633 fi | |
| 7634 | |
| 7635 # A PIC object. | |
| 7636 func_append libobjs " $pic_object" | |
| 7637 arg=$pic_object | |
| 7638 } | |
| 7639 | |
| 7640 # Non-PIC object. | |
| 7641 if test none != "$non_pic_object"; then | |
| 7642 # Prepend the subdirectory the object is found in. | |
| 7643 non_pic_object=$xdir$non_pic_object | |
| 7644 | |
| 7645 # A standard non-PIC object | |
| 7646 func_append non_pic_objects " $non_pic_object" | |
| 7647 if test -z "$pic_object" || test none = "$pic_object"; then | |
| 7648 arg=$non_pic_object | |
| 7649 fi | |
| 7650 else | |
| 7651 # If the PIC object exists, use it instead. | |
| 7652 # $xdir was prepended to $pic_object above. | |
| 7653 non_pic_object=$pic_object | |
| 7654 func_append non_pic_objects " $non_pic_object" | |
| 7655 fi | |
| 7656 else | |
| 7657 # Only an error if not doing a dry-run. | |
| 7658 if $opt_dry_run; then | |
| 7659 # Extract subdirectory from the argument. | |
| 7660 func_dirname "$arg" "/" "" | |
| 7661 xdir=$func_dirname_result | |
| 7662 | |
| 7663 func_lo2o "$arg" | |
| 7664 pic_object=$xdir$objdir/$func_lo2o_result | |
| 7665 non_pic_object=$xdir$func_lo2o_result | |
| 7666 func_append libobjs " $pic_object" | |
| 7667 func_append non_pic_objects " $non_pic_object" | |
| 7668 else | |
| 7669 func_fatal_error "'$arg' is not a valid libtool object" | |
| 7670 fi | |
| 7671 fi | |
| 7672 ;; | |
| 7673 | |
| 7674 *.$libext) | |
| 7675 # An archive. | |
| 7676 func_append deplibs " $arg" | |
| 7677 func_append old_deplibs " $arg" | |
| 7678 continue | |
| 7679 ;; | |
| 7680 | |
| 7681 *.la) | |
| 7682 # A libtool-controlled library. | |
| 7683 | |
| 7684 func_resolve_sysroot "$arg" | |
| 7685 if test dlfiles = "$prev"; then | |
| 7686 # This library was specified with -dlopen. | |
| 7687 func_append dlfiles " $func_resolve_sysroot_result" | |
| 7688 prev= | |
| 7689 elif test dlprefiles = "$prev"; then | |
| 7690 # The library was specified with -dlpreopen. | |
| 7691 func_append dlprefiles " $func_resolve_sysroot_result" | |
| 7692 prev= | |
| 7693 else | |
| 7694 func_append deplibs " $func_resolve_sysroot_result" | |
| 7695 fi | |
| 7696 continue | |
| 7697 ;; | |
| 7698 | |
| 7699 # Some other compiler argument. | |
| 7700 *) | |
| 7701 # Unknown arguments in both finalize_command and compile_command need | |
| 7702 # to be aesthetically quoted because they are evaled later. | |
| 7703 func_quote_arg pretty "$arg" | |
| 7704 arg=$func_quote_arg_result | |
| 7705 ;; | |
| 7706 esac # arg | |
| 7707 | |
| 7708 # Now actually substitute the argument into the commands. | |
| 7709 if test -n "$arg"; then | |
| 7710 func_append compile_command " $arg" | |
| 7711 func_append finalize_command " $arg" | |
| 7712 fi | |
| 7713 done # argument parsing loop | |
| 7714 | |
| 7715 test -n "$prev" && \ | |
| 7716 func_fatal_help "the '$prevarg' option requires an argument" | |
| 7717 | |
| 7718 if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then | |
| 7719 eval arg=\"$export_dynamic_flag_spec\" | |
| 7720 func_append compile_command " $arg" | |
| 7721 func_append finalize_command " $arg" | |
| 7722 fi | |
| 7723 | |
| 7724 oldlibs= | |
| 7725 # calculate the name of the file, without its directory | |
| 7726 func_basename "$output" | |
| 7727 outputname=$func_basename_result | |
| 7728 libobjs_save=$libobjs | |
| 7729 | |
| 7730 if test -n "$shlibpath_var"; then | |
| 7731 # get the directories listed in $shlibpath_var | |
| 7732 eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` | |
| 7733 else | |
| 7734 shlib_search_path= | |
| 7735 fi | |
| 7736 eval sys_lib_search_path=\"$sys_lib_search_path_spec\" | |
| 7737 eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" | |
| 7738 | |
| 7739 # Definition is injected by LT_CONFIG during libtool generation. | |
| 7740 func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" | |
| 7741 | |
| 7742 func_dirname "$output" "/" "" | |
| 7743 output_objdir=$func_dirname_result$objdir | |
| 7744 func_to_tool_file "$output_objdir/" | |
| 7745 tool_output_objdir=$func_to_tool_file_result | |
| 7746 # Create the object directory. | |
| 7747 func_mkdir_p "$output_objdir" | |
| 7748 | |
| 7749 # Determine the type of output | |
| 7750 case $output in | |
| 7751 "") | |
| 7752 func_fatal_help "you must specify an output file" | |
| 7753 ;; | |
| 7754 *.$libext) linkmode=oldlib ;; | |
| 7755 *.lo | *.$objext) linkmode=obj ;; | |
| 7756 *.la) linkmode=lib ;; | |
| 7757 *) linkmode=prog ;; # Anything else should be a program. | |
| 7758 esac | |
| 7759 | |
| 7760 specialdeplibs= | |
| 7761 | |
| 7762 libs= | |
| 7763 # Find all interdependent deplibs by searching for libraries | |
| 7764 # that are linked more than once (e.g. -la -lb -la) | |
| 7765 for deplib in $deplibs; do | |
| 7766 if $opt_preserve_dup_deps; then | |
| 7767 case "$libs " in | |
| 7768 *" $deplib "*) func_append specialdeplibs " $deplib" ;; | |
| 7769 esac | |
| 7770 fi | |
| 7771 func_append libs " $deplib" | |
| 7772 done | |
| 7773 | |
| 7774 if test lib = "$linkmode"; then | |
| 7775 libs="$predeps $libs $compiler_lib_search_path $postdeps" | |
| 7776 | |
| 7777 # Compute libraries that are listed more than once in $predeps | |
| 7778 # $postdeps and mark them as special (i.e., whose duplicates are | |
| 7779 # not to be eliminated). | |
| 7780 pre_post_deps= | |
| 7781 if $opt_duplicate_compiler_generated_deps; then | |
| 7782 for pre_post_dep in $predeps $postdeps; do | |
| 7783 case "$pre_post_deps " in | |
| 7784 *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; | |
| 7785 esac | |
| 7786 func_append pre_post_deps " $pre_post_dep" | |
| 7787 done | |
| 7788 fi | |
| 7789 pre_post_deps= | |
| 7790 fi | |
| 7791 | |
| 7792 deplibs= | |
| 7793 newdependency_libs= | |
| 7794 newlib_search_path= | |
| 7795 need_relink=no # whether we're linking any uninstalled libtool libraries | |
| 7796 notinst_deplibs= # not-installed libtool libraries | |
| 7797 notinst_path= # paths that contain not-installed libtool libraries | |
| 7798 | |
| 7799 case $linkmode in | |
| 7800 lib) | |
| 7801 passes="conv dlpreopen link" | |
| 7802 for file in $dlfiles $dlprefiles; do | |
| 7803 case $file in | |
| 7804 *.la) ;; | |
| 7805 *) | |
| 7806 func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" | |
| 7807 ;; | |
| 7808 esac | |
| 7809 done | |
| 7810 ;; | |
| 7811 prog) | |
| 7812 compile_deplibs= | |
| 7813 finalize_deplibs= | |
| 7814 alldeplibs=false | |
| 7815 newdlfiles= | |
| 7816 newdlprefiles= | |
| 7817 passes="conv scan dlopen dlpreopen link" | |
| 7818 ;; | |
| 7819 *) passes="conv" | |
| 7820 ;; | |
| 7821 esac | |
| 7822 | |
| 7823 for pass in $passes; do | |
| 7824 # The preopen pass in lib mode reverses $deplibs; put it back here | |
| 7825 # so that -L comes before libs that need it for instance... | |
| 7826 if test lib,link = "$linkmode,$pass"; then | |
| 7827 ## FIXME: Find the place where the list is rebuilt in the wrong | |
| 7828 ## order, and fix it there properly | |
| 7829 tmp_deplibs= | |
| 7830 for deplib in $deplibs; do | |
| 7831 tmp_deplibs="$deplib $tmp_deplibs" | |
| 7832 done | |
| 7833 deplibs=$tmp_deplibs | |
| 7834 fi | |
| 7835 | |
| 7836 if test lib,link = "$linkmode,$pass" || | |
| 7837 test prog,scan = "$linkmode,$pass"; then | |
| 7838 libs=$deplibs | |
| 7839 deplibs= | |
| 7840 fi | |
| 7841 if test prog = "$linkmode"; then | |
| 7842 case $pass in | |
| 7843 dlopen) libs=$dlfiles ;; | |
| 7844 dlpreopen) libs=$dlprefiles ;; | |
| 7845 link) | |
| 7846 libs="$deplibs %DEPLIBS%" | |
| 7847 test "X$link_all_deplibs" != Xno && libs="$libs $dependency_libs" | |
| 7848 ;; | |
| 7849 esac | |
| 7850 fi | |
| 7851 if test lib,dlpreopen = "$linkmode,$pass"; then | |
| 7852 # Collect and forward deplibs of preopened libtool libs | |
| 7853 for lib in $dlprefiles; do | |
| 7854 # Ignore non-libtool-libs | |
| 7855 dependency_libs= | |
| 7856 func_resolve_sysroot "$lib" | |
| 7857 case $lib in | |
| 7858 *.la) func_source "$func_resolve_sysroot_result" ;; | |
| 7859 esac | |
| 7860 | |
| 7861 # Collect preopened libtool deplibs, except any this library | |
| 7862 # has declared as weak libs | |
| 7863 for deplib in $dependency_libs; do | |
| 7864 func_basename "$deplib" | |
| 7865 deplib_base=$func_basename_result | |
| 7866 case " $weak_libs " in | |
| 7867 *" $deplib_base "*) ;; | |
| 7868 *) func_append deplibs " $deplib" ;; | |
| 7869 esac | |
| 7870 done | |
| 7871 done | |
| 7872 libs=$dlprefiles | |
| 7873 fi | |
| 7874 if test dlopen = "$pass"; then | |
| 7875 # Collect dlpreopened libraries | |
| 7876 save_deplibs=$deplibs | |
| 7877 deplibs= | |
| 7878 fi | |
| 7879 | |
| 7880 for deplib in $libs; do | |
| 7881 lib= | |
| 7882 found=false | |
| 7883 case $deplib in | |
| 7884 -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ | |
| 7885 |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) | |
| 7886 if test prog,link = "$linkmode,$pass"; then | |
| 7887 compile_deplibs="$deplib $compile_deplibs" | |
| 7888 finalize_deplibs="$deplib $finalize_deplibs" | |
| 7889 else | |
| 7890 func_append compiler_flags " $deplib" | |
| 7891 if test lib = "$linkmode"; then | |
| 7892 case "$new_inherited_linker_flags " in | |
| 7893 *" $deplib "*) ;; | |
| 7894 * ) func_append new_inherited_linker_flags " $deplib" ;; | |
| 7895 esac | |
| 7896 fi | |
| 7897 fi | |
| 7898 continue | |
| 7899 ;; | |
| 7900 -l*) | |
| 7901 if test lib != "$linkmode" && test prog != "$linkmode"; then | |
| 7902 func_warning "'-l' is ignored for archives/objects" | |
| 7903 continue | |
| 7904 fi | |
| 7905 func_stripname '-l' '' "$deplib" | |
| 7906 name=$func_stripname_result | |
| 7907 if test lib = "$linkmode"; then | |
| 7908 searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" | |
| 7909 else | |
| 7910 searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" | |
| 7911 fi | |
| 7912 for searchdir in $searchdirs; do | |
| 7913 for search_ext in .la $std_shrext .so .a; do | |
| 7914 # Search the libtool library | |
| 7915 lib=$searchdir/lib$name$search_ext | |
| 7916 if test -f "$lib"; then | |
| 7917 if test .la = "$search_ext"; then | |
| 7918 found=: | |
| 7919 else | |
| 7920 found=false | |
| 7921 fi | |
| 7922 break 2 | |
| 7923 fi | |
| 7924 done | |
| 7925 done | |
| 7926 if $found; then | |
| 7927 # deplib is a libtool library | |
| 7928 # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, | |
| 7929 # We need to do some special things here, and not later. | |
| 7930 if test yes = "$allow_libtool_libs_with_static_runtimes"; then | |
| 7931 case " $predeps $postdeps " in | |
| 7932 *" $deplib "*) | |
| 7933 if func_lalib_p "$lib"; then | |
| 7934 library_names= | |
| 7935 old_library= | |
| 7936 func_source "$lib" | |
| 7937 for l in $old_library $library_names; do | |
| 7938 ll=$l | |
| 7939 done | |
| 7940 if test "X$ll" = "X$old_library"; then # only static version available | |
| 7941 found=false | |
| 7942 func_dirname "$lib" "" "." | |
| 7943 ladir=$func_dirname_result | |
| 7944 lib=$ladir/$old_library | |
| 7945 if test prog,link = "$linkmode,$pass"; then | |
| 7946 compile_deplibs="$deplib $compile_deplibs" | |
| 7947 finalize_deplibs="$deplib $finalize_deplibs" | |
| 7948 else | |
| 7949 deplibs="$deplib $deplibs" | |
| 7950 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" | |
| 7951 fi | |
| 7952 continue | |
| 7953 fi | |
| 7954 fi | |
| 7955 ;; | |
| 7956 *) ;; | |
| 7957 esac | |
| 7958 fi | |
| 7959 else | |
| 7960 # deplib doesn't seem to be a libtool library | |
| 7961 if test prog,link = "$linkmode,$pass"; then | |
| 7962 compile_deplibs="$deplib $compile_deplibs" | |
| 7963 finalize_deplibs="$deplib $finalize_deplibs" | |
| 7964 else | |
| 7965 deplibs="$deplib $deplibs" | |
| 7966 test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" | |
| 7967 fi | |
| 7968 continue | |
| 7969 fi | |
| 7970 ;; # -l | |
| 7971 *.ltframework) | |
| 7972 if test prog,link = "$linkmode,$pass"; then | |
| 7973 compile_deplibs="$deplib $compile_deplibs" | |
| 7974 finalize_deplibs="$deplib $finalize_deplibs" | |
| 7975 else | |
| 7976 deplibs="$deplib $deplibs" | |
| 7977 if test lib = "$linkmode"; then | |
| 7978 case "$new_inherited_linker_flags " in | |
| 7979 *" $deplib "*) ;; | |
| 7980 * ) func_append new_inherited_linker_flags " $deplib" ;; | |
| 7981 esac | |
| 7982 fi | |
| 7983 fi | |
| 7984 continue | |
| 7985 ;; | |
| 7986 -L*) | |
| 7987 case $linkmode in | |
| 7988 lib) | |
| 7989 deplibs="$deplib $deplibs" | |
| 7990 test conv = "$pass" && continue | |
| 7991 newdependency_libs="$deplib $newdependency_libs" | |
| 7992 func_stripname '-L' '' "$deplib" | |
| 7993 func_resolve_sysroot "$func_stripname_result" | |
| 7994 func_append newlib_search_path " $func_resolve_sysroot_result" | |
| 7995 ;; | |
| 7996 prog) | |
| 7997 if test conv = "$pass"; then | |
| 7998 deplibs="$deplib $deplibs" | |
| 7999 continue | |
| 8000 fi | |
| 8001 if test scan = "$pass"; then | |
| 8002 deplibs="$deplib $deplibs" | |
| 8003 else | |
| 8004 compile_deplibs="$deplib $compile_deplibs" | |
| 8005 finalize_deplibs="$deplib $finalize_deplibs" | |
| 8006 fi | |
| 8007 func_stripname '-L' '' "$deplib" | |
| 8008 func_resolve_sysroot "$func_stripname_result" | |
| 8009 func_append newlib_search_path " $func_resolve_sysroot_result" | |
| 8010 ;; | |
| 8011 *) | |
| 8012 func_warning "'-L' is ignored for archives/objects" | |
| 8013 ;; | |
| 8014 esac # linkmode | |
| 8015 continue | |
| 8016 ;; # -L | |
| 8017 -R*) | |
| 8018 if test link = "$pass"; then | |
| 8019 func_stripname '-R' '' "$deplib" | |
| 8020 func_resolve_sysroot "$func_stripname_result" | |
| 8021 dir=$func_resolve_sysroot_result | |
| 8022 # Make sure the xrpath contains only unique directories. | |
| 8023 case "$xrpath " in | |
| 8024 *" $dir "*) ;; | |
| 8025 *) func_append xrpath " $dir" ;; | |
| 8026 esac | |
| 8027 fi | |
| 8028 deplibs="$deplib $deplibs" | |
| 8029 continue | |
| 8030 ;; | |
| 8031 *.la) | |
| 8032 func_resolve_sysroot "$deplib" | |
| 8033 lib=$func_resolve_sysroot_result | |
| 8034 ;; | |
| 8035 *.$libext) | |
| 8036 if test conv = "$pass"; then | |
| 8037 deplibs="$deplib $deplibs" | |
| 8038 continue | |
| 8039 fi | |
| 8040 case $linkmode in | |
| 8041 lib) | |
| 8042 # Linking convenience modules into shared libraries is allowed, | |
| 8043 # but linking other static libraries is non-portable. | |
| 8044 case " $dlpreconveniencelibs " in | |
| 8045 *" $deplib "*) ;; | |
| 8046 *) | |
| 8047 valid_a_lib=false | |
| 8048 case $deplibs_check_method in | |
| 8049 match_pattern*) | |
| 8050 set dummy $deplibs_check_method; shift | |
| 8051 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` | |
| 8052 if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ | |
| 8053 | $EGREP "$match_pattern_regex" > /dev/null; then | |
| 8054 valid_a_lib=: | |
| 8055 fi | |
| 8056 ;; | |
| 8057 pass_all) | |
| 8058 valid_a_lib=: | |
| 8059 ;; | |
| 8060 esac | |
| 8061 if $valid_a_lib; then | |
| 8062 echo | |
| 8063 $ECHO "*** Warning: Linking the shared library $output against the" | |
| 8064 $ECHO "*** static library $deplib is not portable!" | |
| 8065 deplibs="$deplib $deplibs" | |
| 8066 else | |
| 8067 echo | |
| 8068 $ECHO "*** Warning: Trying to link with static lib archive $deplib." | |
| 8069 echo "*** I have the capability to make that library automatically link in when" | |
| 8070 echo "*** you link to this library. But I can only do this if you have a" | |
| 8071 echo "*** shared version of the library, which you do not appear to have" | |
| 8072 echo "*** because the file extensions .$libext of this argument makes me believe" | |
| 8073 echo "*** that it is just a static archive that I should not use here." | |
| 8074 fi | |
| 8075 ;; | |
| 8076 esac | |
| 8077 continue | |
| 8078 ;; | |
| 8079 prog) | |
| 8080 if test link != "$pass"; then | |
| 8081 deplibs="$deplib $deplibs" | |
| 8082 else | |
| 8083 compile_deplibs="$deplib $compile_deplibs" | |
| 8084 finalize_deplibs="$deplib $finalize_deplibs" | |
| 8085 fi | |
| 8086 continue | |
| 8087 ;; | |
| 8088 esac # linkmode | |
| 8089 ;; # *.$libext | |
| 8090 *.lo | *.$objext) | |
| 8091 if test conv = "$pass"; then | |
| 8092 deplibs="$deplib $deplibs" | |
| 8093 elif test prog = "$linkmode"; then | |
| 8094 if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then | |
| 8095 # If there is no dlopen support or we're linking statically, | |
| 8096 # we need to preload. | |
| 8097 func_append newdlprefiles " $deplib" | |
| 8098 compile_deplibs="$deplib $compile_deplibs" | |
| 8099 finalize_deplibs="$deplib $finalize_deplibs" | |
| 8100 else | |
| 8101 func_append newdlfiles " $deplib" | |
| 8102 fi | |
| 8103 fi | |
| 8104 continue | |
| 8105 ;; | |
| 8106 %DEPLIBS%) | |
| 8107 alldeplibs=: | |
| 8108 continue | |
| 8109 ;; | |
| 8110 esac # case $deplib | |
| 8111 | |
| 8112 $found || test -f "$lib" \ | |
| 8113 || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" | |
| 8114 | |
| 8115 # Check to see that this really is a libtool archive. | |
| 8116 func_lalib_unsafe_p "$lib" \ | |
| 8117 || func_fatal_error "'$lib' is not a valid libtool archive" | |
| 8118 | |
| 8119 func_dirname "$lib" "" "." | |
| 8120 ladir=$func_dirname_result | |
| 8121 | |
| 8122 dlname= | |
| 8123 dlopen= | |
| 8124 dlpreopen= | |
| 8125 libdir= | |
| 8126 library_names= | |
| 8127 old_library= | |
| 8128 inherited_linker_flags= | |
| 8129 # If the library was installed with an old release of libtool, | |
| 8130 # it will not redefine variables installed, or shouldnotlink | |
| 8131 installed=yes | |
| 8132 shouldnotlink=no | |
| 8133 avoidtemprpath= | |
| 8134 | |
| 8135 | |
| 8136 # Read the .la file | |
| 8137 func_source "$lib" | |
| 8138 | |
| 8139 # Convert "-framework foo" to "foo.ltframework" | |
| 8140 if test -n "$inherited_linker_flags"; then | |
| 8141 tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` | |
| 8142 for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do | |
| 8143 case " $new_inherited_linker_flags " in | |
| 8144 *" $tmp_inherited_linker_flag "*) ;; | |
| 8145 *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; | |
| 8146 esac | |
| 8147 done | |
| 8148 fi | |
| 8149 dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` | |
| 8150 if test lib,link = "$linkmode,$pass" || | |
| 8151 test prog,scan = "$linkmode,$pass" || | |
| 8152 { test prog != "$linkmode" && test lib != "$linkmode"; }; then | |
| 8153 test -n "$dlopen" && func_append dlfiles " $dlopen" | |
| 8154 test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" | |
| 8155 fi | |
| 8156 | |
| 8157 if test conv = "$pass"; then | |
| 8158 # Only check for convenience libraries | |
| 8159 deplibs="$lib $deplibs" | |
| 8160 if test -z "$libdir"; then | |
| 8161 if test -z "$old_library"; then | |
| 8162 func_fatal_error "cannot find name of link library for '$lib'" | |
| 8163 fi | |
| 8164 # It is a libtool convenience library, so add in its objects. | |
| 8165 func_append convenience " $ladir/$objdir/$old_library" | |
| 8166 func_append old_convenience " $ladir/$objdir/$old_library" | |
| 8167 tmp_libs= | |
| 8168 for deplib in $dependency_libs; do | |
| 8169 deplibs="$deplib $deplibs" | |
| 8170 if $opt_preserve_dup_deps; then | |
| 8171 case "$tmp_libs " in | |
| 8172 *" $deplib "*) func_append specialdeplibs " $deplib" ;; | |
| 8173 esac | |
| 8174 fi | |
| 8175 func_append tmp_libs " $deplib" | |
| 8176 done | |
| 8177 elif test prog != "$linkmode" && test lib != "$linkmode"; then | |
| 8178 func_fatal_error "'$lib' is not a convenience library" | |
| 8179 fi | |
| 8180 continue | |
| 8181 fi # $pass = conv | |
| 8182 | |
| 8183 | |
| 8184 # Get the name of the library we link against. | |
| 8185 linklib= | |
| 8186 if test -n "$old_library" && | |
| 8187 { test yes = "$prefer_static_libs" || | |
| 8188 test built,no = "$prefer_static_libs,$installed"; }; then | |
| 8189 linklib=$old_library | |
| 8190 else | |
| 8191 for l in $old_library $library_names; do | |
| 8192 linklib=$l | |
| 8193 done | |
| 8194 fi | |
| 8195 if test -z "$linklib"; then | |
| 8196 func_fatal_error "cannot find name of link library for '$lib'" | |
| 8197 fi | |
| 8198 | |
| 8199 # This library was specified with -dlopen. | |
| 8200 if test dlopen = "$pass"; then | |
| 8201 test -z "$libdir" \ | |
| 8202 && func_fatal_error "cannot -dlopen a convenience library: '$lib'" | |
| 8203 if test -z "$dlname" || | |
| 8204 test yes != "$dlopen_support" || | |
| 8205 test no = "$build_libtool_libs" | |
| 8206 then | |
| 8207 # If there is no dlname, no dlopen support or we're linking | |
| 8208 # statically, we need to preload. We also need to preload any | |
| 8209 # dependent libraries so libltdl's deplib preloader doesn't | |
| 8210 # bomb out in the load deplibs phase. | |
| 8211 func_append dlprefiles " $lib $dependency_libs" | |
| 8212 else | |
| 8213 func_append newdlfiles " $lib" | |
| 8214 fi | |
| 8215 continue | |
| 8216 fi # $pass = dlopen | |
| 8217 | |
| 8218 # We need an absolute path. | |
| 8219 case $ladir in | |
| 8220 [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; | |
| 8221 *) | |
| 8222 abs_ladir=`cd "$ladir" && pwd` | |
| 8223 if test -z "$abs_ladir"; then | |
| 8224 func_warning "cannot determine absolute directory name of '$ladir'" | |
| 8225 func_warning "passing it literally to the linker, although it might fail" | |
| 8226 abs_ladir=$ladir | |
| 8227 fi | |
| 8228 ;; | |
| 8229 esac | |
| 8230 func_basename "$lib" | |
| 8231 laname=$func_basename_result | |
| 8232 | |
| 8233 # Find the relevant object directory and library name. | |
| 8234 if test yes = "$installed"; then | |
| 8235 if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then | |
| 8236 func_warning "library '$lib' was moved." | |
| 8237 dir=$ladir | |
| 8238 absdir=$abs_ladir | |
| 8239 libdir=$abs_ladir | |
| 8240 else | |
| 8241 dir=$lt_sysroot$libdir | |
| 8242 absdir=$lt_sysroot$libdir | |
| 8243 fi | |
| 8244 test yes = "$hardcode_automatic" && avoidtemprpath=yes | |
| 8245 else | |
| 8246 if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then | |
| 8247 dir=$ladir | |
| 8248 absdir=$abs_ladir | |
| 8249 # Remove this search path later | |
| 8250 func_append notinst_path " $abs_ladir" | |
| 8251 else | |
| 8252 dir=$ladir/$objdir | |
| 8253 absdir=$abs_ladir/$objdir | |
| 8254 # Remove this search path later | |
| 8255 func_append notinst_path " $abs_ladir" | |
| 8256 fi | |
| 8257 fi # $installed = yes | |
| 8258 func_stripname 'lib' '.la' "$laname" | |
| 8259 name=$func_stripname_result | |
| 8260 | |
| 8261 # This library was specified with -dlpreopen. | |
| 8262 if test dlpreopen = "$pass"; then | |
| 8263 if test -z "$libdir" && test prog = "$linkmode"; then | |
| 8264 func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" | |
| 8265 fi | |
| 8266 case $host in | |
| 8267 # special handling for platforms with PE-DLLs. | |
| 8268 *cygwin* | *mingw* | *cegcc* ) | |
| 8269 # Linker will automatically link against shared library if both | |
| 8270 # static and shared are present. Therefore, ensure we extract | |
| 8271 # symbols from the import library if a shared library is present | |
| 8272 # (otherwise, the dlopen module name will be incorrect). We do | |
| 8273 # this by putting the import library name into $newdlprefiles. | |
| 8274 # We recover the dlopen module name by 'saving' the la file | |
| 8275 # name in a special purpose variable, and (later) extracting the | |
| 8276 # dlname from the la file. | |
| 8277 if test -n "$dlname"; then | |
| 8278 func_tr_sh "$dir/$linklib" | |
| 8279 eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" | |
| 8280 func_append newdlprefiles " $dir/$linklib" | |
| 8281 else | |
| 8282 func_append newdlprefiles " $dir/$old_library" | |
| 8283 # Keep a list of preopened convenience libraries to check | |
| 8284 # that they are being used correctly in the link pass. | |
| 8285 test -z "$libdir" && \ | |
| 8286 func_append dlpreconveniencelibs " $dir/$old_library" | |
| 8287 fi | |
| 8288 ;; | |
| 8289 * ) | |
| 8290 # Prefer using a static library (so that no silly _DYNAMIC symbols | |
| 8291 # are required to link). | |
| 8292 if test -n "$old_library"; then | |
| 8293 func_append newdlprefiles " $dir/$old_library" | |
| 8294 # Keep a list of preopened convenience libraries to check | |
| 8295 # that they are being used correctly in the link pass. | |
| 8296 test -z "$libdir" && \ | |
| 8297 func_append dlpreconveniencelibs " $dir/$old_library" | |
| 8298 # Otherwise, use the dlname, so that lt_dlopen finds it. | |
| 8299 elif test -n "$dlname"; then | |
| 8300 func_append newdlprefiles " $dir/$dlname" | |
| 8301 else | |
| 8302 func_append newdlprefiles " $dir/$linklib" | |
| 8303 fi | |
| 8304 ;; | |
| 8305 esac | |
| 8306 fi # $pass = dlpreopen | |
| 8307 | |
| 8308 if test -z "$libdir"; then | |
| 8309 # Link the convenience library | |
| 8310 if test lib = "$linkmode"; then | |
| 8311 deplibs="$dir/$old_library $deplibs" | |
| 8312 elif test prog,link = "$linkmode,$pass"; then | |
| 8313 compile_deplibs="$dir/$old_library $compile_deplibs" | |
| 8314 finalize_deplibs="$dir/$old_library $finalize_deplibs" | |
| 8315 else | |
| 8316 deplibs="$lib $deplibs" # used for prog,scan pass | |
| 8317 fi | |
| 8318 continue | |
| 8319 fi | |
| 8320 | |
| 8321 | |
| 8322 if test prog = "$linkmode" && test link != "$pass"; then | |
| 8323 func_append newlib_search_path " $ladir" | |
| 8324 deplibs="$lib $deplibs" | |
| 8325 | |
| 8326 linkalldeplibs=false | |
| 8327 if test no != "$link_all_deplibs" || test -z "$library_names" || | |
| 8328 test no = "$build_libtool_libs"; then | |
| 8329 linkalldeplibs=: | |
| 8330 fi | |
| 8331 | |
| 8332 tmp_libs= | |
| 8333 for deplib in $dependency_libs; do | |
| 8334 case $deplib in | |
| 8335 -L*) func_stripname '-L' '' "$deplib" | |
| 8336 func_resolve_sysroot "$func_stripname_result" | |
| 8337 func_append newlib_search_path " $func_resolve_sysroot_result" | |
| 8338 ;; | |
| 8339 esac | |
| 8340 # Need to link against all dependency_libs? | |
| 8341 if $linkalldeplibs; then | |
| 8342 deplibs="$deplib $deplibs" | |
| 8343 else | |
| 8344 # Need to hardcode shared library paths | |
| 8345 # or/and link against static libraries | |
| 8346 newdependency_libs="$deplib $newdependency_libs" | |
| 8347 fi | |
| 8348 if $opt_preserve_dup_deps; then | |
| 8349 case "$tmp_libs " in | |
| 8350 *" $deplib "*) func_append specialdeplibs " $deplib" ;; | |
| 8351 esac | |
| 8352 fi | |
| 8353 func_append tmp_libs " $deplib" | |
| 8354 done # for deplib | |
| 8355 continue | |
| 8356 fi # $linkmode = prog... | |
| 8357 | |
| 8358 if test prog,link = "$linkmode,$pass"; then | |
| 8359 if test -n "$library_names" && | |
| 8360 { { test no = "$prefer_static_libs" || | |
| 8361 test built,yes = "$prefer_static_libs,$installed"; } || | |
| 8362 test -z "$old_library"; }; then | |
| 8363 # We need to hardcode the library path | |
| 8364 if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then | |
| 8365 # Make sure the rpath contains only unique directories. | |
| 8366 case $temp_rpath: in | |
| 8367 *"$absdir:"*) ;; | |
| 8368 *) func_append temp_rpath "$absdir:" ;; | |
| 8369 esac | |
| 8370 fi | |
| 8371 | |
| 8372 # Hardcode the library path. | |
| 8373 # Skip directories that are in the system default run-time | |
| 8374 # search path. | |
| 8375 case " $sys_lib_dlsearch_path " in | |
| 8376 *" $absdir "*) ;; | |
| 8377 *) | |
| 8378 case "$compile_rpath " in | |
| 8379 *" $absdir "*) ;; | |
| 8380 *) func_append compile_rpath " $absdir" ;; | |
| 8381 esac | |
| 8382 ;; | |
| 8383 esac | |
| 8384 case " $sys_lib_dlsearch_path " in | |
| 8385 *" $libdir "*) ;; | |
| 8386 *) | |
| 8387 case "$finalize_rpath " in | |
| 8388 *" $libdir "*) ;; | |
| 8389 *) func_append finalize_rpath " $libdir" ;; | |
| 8390 esac | |
| 8391 ;; | |
| 8392 esac | |
| 8393 fi # $linkmode,$pass = prog,link... | |
| 8394 | |
| 8395 if $alldeplibs && | |
| 8396 { test pass_all = "$deplibs_check_method" || | |
| 8397 { test yes = "$build_libtool_libs" && | |
| 8398 test -n "$library_names"; }; }; then | |
| 8399 # We only need to search for static libraries | |
| 8400 continue | |
| 8401 fi | |
| 8402 fi | |
| 8403 | |
| 8404 link_static=no # Whether the deplib will be linked statically | |
| 8405 use_static_libs=$prefer_static_libs | |
| 8406 if test built = "$use_static_libs" && test yes = "$installed"; then | |
| 8407 use_static_libs=no | |
| 8408 fi | |
| 8409 if test -n "$library_names" && | |
| 8410 { test no = "$use_static_libs" || test -z "$old_library"; }; then | |
| 8411 case $host in | |
| 8412 *cygwin* | *mingw* | *cegcc* | *os2*) | |
| 8413 # No point in relinking DLLs because paths are not encoded | |
| 8414 func_append notinst_deplibs " $lib" | |
| 8415 need_relink=no | |
| 8416 ;; | |
| 8417 *) | |
| 8418 if test no = "$installed"; then | |
| 8419 func_append notinst_deplibs " $lib" | |
| 8420 need_relink=yes | |
| 8421 fi | |
| 8422 ;; | |
| 8423 esac | |
| 8424 # This is a shared library | |
| 8425 | |
| 8426 # Warn about portability, can't link against -module's on some | |
| 8427 # systems (darwin). Don't bleat about dlopened modules though! | |
| 8428 dlopenmodule= | |
| 8429 for dlpremoduletest in $dlprefiles; do | |
| 8430 if test "X$dlpremoduletest" = "X$lib"; then | |
| 8431 dlopenmodule=$dlpremoduletest | |
| 8432 break | |
| 8433 fi | |
| 8434 done | |
| 8435 if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then | |
| 8436 echo | |
| 8437 if test prog = "$linkmode"; then | |
| 8438 $ECHO "*** Warning: Linking the executable $output against the loadable module" | |
| 8439 else | |
| 8440 $ECHO "*** Warning: Linking the shared library $output against the loadable module" | |
| 8441 fi | |
| 8442 $ECHO "*** $linklib is not portable!" | |
| 8443 fi | |
| 8444 if test lib = "$linkmode" && | |
| 8445 test yes = "$hardcode_into_libs"; then | |
| 8446 # Hardcode the library path. | |
| 8447 # Skip directories that are in the system default run-time | |
| 8448 # search path. | |
| 8449 case " $sys_lib_dlsearch_path " in | |
| 8450 *" $absdir "*) ;; | |
| 8451 *) | |
| 8452 case "$compile_rpath " in | |
| 8453 *" $absdir "*) ;; | |
| 8454 *) func_append compile_rpath " $absdir" ;; | |
| 8455 esac | |
| 8456 ;; | |
| 8457 esac | |
| 8458 case " $sys_lib_dlsearch_path " in | |
| 8459 *" $libdir "*) ;; | |
| 8460 *) | |
| 8461 case "$finalize_rpath " in | |
| 8462 *" $libdir "*) ;; | |
| 8463 *) func_append finalize_rpath " $libdir" ;; | |
| 8464 esac | |
| 8465 ;; | |
| 8466 esac | |
| 8467 fi | |
| 8468 | |
| 8469 if test -n "$old_archive_from_expsyms_cmds"; then | |
| 8470 # figure out the soname | |
| 8471 set dummy $library_names | |
| 8472 shift | |
| 8473 realname=$1 | |
| 8474 shift | |
| 8475 libname=`eval "\\$ECHO \"$libname_spec\""` | |
| 8476 # use dlname if we got it. it's perfectly good, no? | |
| 8477 if test -n "$dlname"; then | |
| 8478 soname=$dlname | |
| 8479 elif test -n "$soname_spec"; then | |
| 8480 # bleh windows | |
| 8481 case $host in | |
| 8482 *cygwin* | mingw* | *cegcc* | *os2*) | |
| 8483 func_arith $current - $age | |
| 8484 major=$func_arith_result | |
| 8485 versuffix=-$major | |
| 8486 ;; | |
| 8487 esac | |
| 8488 eval soname=\"$soname_spec\" | |
| 8489 else | |
| 8490 soname=$realname | |
| 8491 fi | |
| 8492 | |
| 8493 # Make a new name for the extract_expsyms_cmds to use | |
| 8494 soroot=$soname | |
| 8495 func_basename "$soroot" | |
| 8496 soname=$func_basename_result | |
| 8497 func_stripname 'lib' '.dll' "$soname" | |
| 8498 newlib=libimp-$func_stripname_result.a | |
| 8499 | |
| 8500 # If the library has no export list, then create one now | |
| 8501 if test -f "$output_objdir/$soname-def"; then : | |
| 8502 else | |
| 8503 func_verbose "extracting exported symbol list from '$soname'" | |
| 8504 func_execute_cmds "$extract_expsyms_cmds" 'exit $?' | |
| 8505 fi | |
| 8506 | |
| 8507 # Create $newlib | |
| 8508 if test -f "$output_objdir/$newlib"; then :; else | |
| 8509 func_verbose "generating import library for '$soname'" | |
| 8510 func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' | |
| 8511 fi | |
| 8512 # make sure the library variables are pointing to the new library | |
| 8513 dir=$output_objdir | |
| 8514 linklib=$newlib | |
| 8515 fi # test -n "$old_archive_from_expsyms_cmds" | |
| 8516 | |
| 8517 if test prog = "$linkmode" || test relink != "$opt_mode"; then | |
| 8518 add_shlibpath= | |
| 8519 add_dir= | |
| 8520 add= | |
| 8521 lib_linked=yes | |
| 8522 case $hardcode_action in | |
| 8523 immediate | unsupported) | |
| 8524 if test no = "$hardcode_direct"; then | |
| 8525 add=$dir/$linklib | |
| 8526 case $host in | |
| 8527 *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; | |
| 8528 *-*-sysv4*uw2*) add_dir=-L$dir ;; | |
| 8529 *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ | |
| 8530 *-*-unixware7*) add_dir=-L$dir ;; | |
| 8531 *-*-darwin* ) | |
| 8532 # if the lib is a (non-dlopened) module then we cannot | |
| 8533 # link against it, someone is ignoring the earlier warnings | |
| 8534 if /usr/bin/file -L $add 2> /dev/null | | |
| 8535 $GREP ": [^:]* bundle" >/dev/null; then | |
| 8536 if test "X$dlopenmodule" != "X$lib"; then | |
| 8537 $ECHO "*** Warning: lib $linklib is a module, not a shared library" | |
| 8538 if test -z "$old_library"; then | |
| 8539 echo | |
| 8540 echo "*** And there doesn't seem to be a static archive available" | |
| 8541 echo "*** The link will probably fail, sorry" | |
| 8542 else | |
| 8543 add=$dir/$old_library | |
| 8544 fi | |
| 8545 elif test -n "$old_library"; then | |
| 8546 add=$dir/$old_library | |
| 8547 fi | |
| 8548 fi | |
| 8549 esac | |
| 8550 elif test no = "$hardcode_minus_L"; then | |
| 8551 case $host in | |
| 8552 *-*-sunos*) add_shlibpath=$dir ;; | |
| 8553 esac | |
| 8554 add_dir=-L$dir | |
| 8555 add=-l$name | |
| 8556 elif test no = "$hardcode_shlibpath_var"; then | |
| 8557 add_shlibpath=$dir | |
| 8558 add=-l$name | |
| 8559 else | |
| 8560 lib_linked=no | |
| 8561 fi | |
| 8562 ;; | |
| 8563 relink) | |
| 8564 if test yes = "$hardcode_direct" && | |
| 8565 test no = "$hardcode_direct_absolute"; then | |
| 8566 add=$dir/$linklib | |
| 8567 elif test yes = "$hardcode_minus_L"; then | |
| 8568 add_dir=-L$absdir | |
| 8569 # Try looking first in the location we're being installed to. | |
| 8570 if test -n "$inst_prefix_dir"; then | |
| 8571 case $libdir in | |
| 8572 [\\/]*) | |
| 8573 func_append add_dir " -L$inst_prefix_dir$libdir" | |
| 8574 ;; | |
| 8575 esac | |
| 8576 fi | |
| 8577 add=-l$name | |
| 8578 elif test yes = "$hardcode_shlibpath_var"; then | |
| 8579 add_shlibpath=$dir | |
| 8580 add=-l$name | |
| 8581 else | |
| 8582 lib_linked=no | |
| 8583 fi | |
| 8584 ;; | |
| 8585 *) lib_linked=no ;; | |
| 8586 esac | |
| 8587 | |
| 8588 if test yes != "$lib_linked"; then | |
| 8589 func_fatal_configuration "unsupported hardcode properties" | |
| 8590 fi | |
| 8591 | |
| 8592 if test -n "$add_shlibpath"; then | |
| 8593 case :$compile_shlibpath: in | |
| 8594 *":$add_shlibpath:"*) ;; | |
| 8595 *) func_append compile_shlibpath "$add_shlibpath:" ;; | |
| 8596 esac | |
| 8597 fi | |
| 8598 if test prog = "$linkmode"; then | |
| 8599 test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" | |
| 8600 test -n "$add" && compile_deplibs="$add $compile_deplibs" | |
| 8601 else | |
| 8602 test -n "$add_dir" && deplibs="$add_dir $deplibs" | |
| 8603 test -n "$add" && deplibs="$add $deplibs" | |
| 8604 if test yes != "$hardcode_direct" && | |
| 8605 test yes != "$hardcode_minus_L" && | |
| 8606 test yes = "$hardcode_shlibpath_var"; then | |
| 8607 case :$finalize_shlibpath: in | |
| 8608 *":$libdir:"*) ;; | |
| 8609 *) func_append finalize_shlibpath "$libdir:" ;; | |
| 8610 esac | |
| 8611 fi | |
| 8612 fi | |
| 8613 fi | |
| 8614 | |
| 8615 if test prog = "$linkmode" || test relink = "$opt_mode"; then | |
| 8616 add_shlibpath= | |
| 8617 add_dir= | |
| 8618 add= | |
| 8619 # Finalize command for both is simple: just hardcode it. | |
| 8620 if test yes = "$hardcode_direct" && | |
| 8621 test no = "$hardcode_direct_absolute"; then | |
| 8622 add=$libdir/$linklib | |
| 8623 elif test yes = "$hardcode_minus_L"; then | |
| 8624 add_dir=-L$libdir | |
| 8625 add=-l$name | |
| 8626 elif test yes = "$hardcode_shlibpath_var"; then | |
| 8627 case :$finalize_shlibpath: in | |
| 8628 *":$libdir:"*) ;; | |
| 8629 *) func_append finalize_shlibpath "$libdir:" ;; | |
| 8630 esac | |
| 8631 add=-l$name | |
| 8632 elif test yes = "$hardcode_automatic"; then | |
| 8633 if test -n "$inst_prefix_dir" && | |
| 8634 test -f "$inst_prefix_dir$libdir/$linklib"; then | |
| 8635 add=$inst_prefix_dir$libdir/$linklib | |
| 8636 else | |
| 8637 add=$libdir/$linklib | |
| 8638 fi | |
| 8639 else | |
| 8640 # We cannot seem to hardcode it, guess we'll fake it. | |
| 8641 add_dir=-L$libdir | |
| 8642 # Try looking first in the location we're being installed to. | |
| 8643 if test -n "$inst_prefix_dir"; then | |
| 8644 case $libdir in | |
| 8645 [\\/]*) | |
| 8646 func_append add_dir " -L$inst_prefix_dir$libdir" | |
| 8647 ;; | |
| 8648 esac | |
| 8649 fi | |
| 8650 add=-l$name | |
| 8651 fi | |
| 8652 | |
| 8653 if test prog = "$linkmode"; then | |
| 8654 test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" | |
| 8655 test -n "$add" && finalize_deplibs="$add $finalize_deplibs" | |
| 8656 else | |
| 8657 test -n "$add_dir" && deplibs="$add_dir $deplibs" | |
| 8658 test -n "$add" && deplibs="$add $deplibs" | |
| 8659 fi | |
| 8660 fi | |
| 8661 elif test prog = "$linkmode"; then | |
| 8662 # Here we assume that one of hardcode_direct or hardcode_minus_L | |
| 8663 # is not unsupported. This is valid on all known static and | |
| 8664 # shared platforms. | |
| 8665 if test unsupported != "$hardcode_direct"; then | |
| 8666 test -n "$old_library" && linklib=$old_library | |
| 8667 compile_deplibs="$dir/$linklib $compile_deplibs" | |
| 8668 finalize_deplibs="$dir/$linklib $finalize_deplibs" | |
| 8669 else | |
| 8670 compile_deplibs="-l$name -L$dir $compile_deplibs" | |
| 8671 finalize_deplibs="-l$name -L$dir $finalize_deplibs" | |
| 8672 fi | |
| 8673 elif test yes = "$build_libtool_libs"; then | |
| 8674 # Not a shared library | |
| 8675 if test pass_all != "$deplibs_check_method"; then | |
| 8676 # We're trying link a shared library against a static one | |
| 8677 # but the system doesn't support it. | |
| 8678 | |
| 8679 # Just print a warning and add the library to dependency_libs so | |
| 8680 # that the program can be linked against the static library. | |
| 8681 echo | |
| 8682 $ECHO "*** Warning: This system cannot link to static lib archive $lib." | |
| 8683 echo "*** I have the capability to make that library automatically link in when" | |
| 8684 echo "*** you link to this library. But I can only do this if you have a" | |
| 8685 echo "*** shared version of the library, which you do not appear to have." | |
| 8686 if test yes = "$module"; then | |
| 8687 echo "*** But as you try to build a module library, libtool will still create " | |
| 8688 echo "*** a static module, that should work as long as the dlopening application" | |
| 8689 echo "*** is linked with the -dlopen flag to resolve symbols at runtime." | |
| 8690 if test -z "$global_symbol_pipe"; then | |
| 8691 echo | |
| 8692 echo "*** However, this would only work if libtool was able to extract symbol" | |
| 8693 echo "*** lists from a program, using 'nm' or equivalent, but libtool could" | |
| 8694 echo "*** not find such a program. So, this module is probably useless." | |
| 8695 echo "*** 'nm' from GNU binutils and a full rebuild may help." | |
| 8696 fi | |
| 8697 if test no = "$build_old_libs"; then | |
| 8698 build_libtool_libs=module | |
| 8699 build_old_libs=yes | |
| 8700 else | |
| 8701 build_libtool_libs=no | |
| 8702 fi | |
| 8703 fi | |
| 8704 else | |
| 8705 deplibs="$dir/$old_library $deplibs" | |
| 8706 link_static=yes | |
| 8707 fi | |
| 8708 fi # link shared/static library? | |
| 8709 | |
| 8710 if test lib = "$linkmode"; then | |
| 8711 if test -n "$dependency_libs" && | |
| 8712 { test yes != "$hardcode_into_libs" || | |
| 8713 test yes = "$build_old_libs" || | |
| 8714 test yes = "$link_static"; }; then | |
| 8715 # Extract -R from dependency_libs | |
| 8716 temp_deplibs= | |
| 8717 for libdir in $dependency_libs; do | |
| 8718 case $libdir in | |
| 8719 -R*) func_stripname '-R' '' "$libdir" | |
| 8720 temp_xrpath=$func_stripname_result | |
| 8721 case " $xrpath " in | |
| 8722 *" $temp_xrpath "*) ;; | |
| 8723 *) func_append xrpath " $temp_xrpath";; | |
| 8724 esac;; | |
| 8725 *) func_append temp_deplibs " $libdir";; | |
| 8726 esac | |
| 8727 done | |
| 8728 dependency_libs=$temp_deplibs | |
| 8729 fi | |
| 8730 | |
| 8731 func_append newlib_search_path " $absdir" | |
| 8732 # Link against this library | |
| 8733 test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" | |
| 8734 # ... and its dependency_libs | |
| 8735 tmp_libs= | |
| 8736 for deplib in $dependency_libs; do | |
| 8737 newdependency_libs="$deplib $newdependency_libs" | |
| 8738 case $deplib in | |
| 8739 -L*) func_stripname '-L' '' "$deplib" | |
| 8740 func_resolve_sysroot "$func_stripname_result";; | |
| 8741 *) func_resolve_sysroot "$deplib" ;; | |
| 8742 esac | |
| 8743 if $opt_preserve_dup_deps; then | |
| 8744 case "$tmp_libs " in | |
| 8745 *" $func_resolve_sysroot_result "*) | |
| 8746 func_append specialdeplibs " $func_resolve_sysroot_result" ;; | |
| 8747 esac | |
| 8748 fi | |
| 8749 func_append tmp_libs " $func_resolve_sysroot_result" | |
| 8750 done | |
| 8751 | |
| 8752 if test no != "$link_all_deplibs"; then | |
| 8753 # Add the search paths of all dependency libraries | |
| 8754 for deplib in $dependency_libs; do | |
| 8755 path= | |
| 8756 case $deplib in | |
| 8757 -L*) path=$deplib ;; | |
| 8758 *.la) | |
| 8759 func_resolve_sysroot "$deplib" | |
| 8760 deplib=$func_resolve_sysroot_result | |
| 8761 func_dirname "$deplib" "" "." | |
| 8762 dir=$func_dirname_result | |
| 8763 # We need an absolute path. | |
| 8764 case $dir in | |
| 8765 [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; | |
| 8766 *) | |
| 8767 absdir=`cd "$dir" && pwd` | |
| 8768 if test -z "$absdir"; then | |
| 8769 func_warning "cannot determine absolute directory name of '$dir'" | |
| 8770 absdir=$dir | |
| 8771 fi | |
| 8772 ;; | |
| 8773 esac | |
| 8774 if $GREP "^installed=no" $deplib > /dev/null; then | |
| 8775 case $host in | |
| 8776 *-*-darwin*) | |
| 8777 depdepl= | |
| 8778 eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` | |
| 8779 if test -n "$deplibrary_names"; then | |
| 8780 for tmp in $deplibrary_names; do | |
| 8781 depdepl=$tmp | |
| 8782 done | |
| 8783 if test -f "$absdir/$objdir/$depdepl"; then | |
| 8784 depdepl=$absdir/$objdir/$depdepl | |
| 8785 darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` | |
| 8786 if test -z "$darwin_install_name"; then | |
| 8787 darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` | |
| 8788 fi | |
| 8789 func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" | |
| 8790 func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" | |
| 8791 path= | |
| 8792 fi | |
| 8793 fi | |
| 8794 ;; | |
| 8795 *) | |
| 8796 path=-L$absdir/$objdir | |
| 8797 ;; | |
| 8798 esac | |
| 8799 else | |
| 8800 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` | |
| 8801 test -z "$libdir" && \ | |
| 8802 func_fatal_error "'$deplib' is not a valid libtool archive" | |
| 8803 test "$absdir" != "$libdir" && \ | |
| 8804 func_warning "'$deplib' seems to be moved" | |
| 8805 | |
| 8806 path=-L$absdir | |
| 8807 fi | |
| 8808 ;; | |
| 8809 esac | |
| 8810 case " $deplibs " in | |
| 8811 *" $path "*) ;; | |
| 8812 *) deplibs="$path $deplibs" ;; | |
| 8813 esac | |
| 8814 done | |
| 8815 fi # link_all_deplibs != no | |
| 8816 fi # linkmode = lib | |
| 8817 done # for deplib in $libs | |
| 8818 if test link = "$pass"; then | |
| 8819 if test prog = "$linkmode"; then | |
| 8820 compile_deplibs="$new_inherited_linker_flags $compile_deplibs" | |
| 8821 finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" | |
| 8822 else | |
| 8823 compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` | |
| 8824 fi | |
| 8825 fi | |
| 8826 dependency_libs=$newdependency_libs | |
| 8827 if test dlpreopen = "$pass"; then | |
| 8828 # Link the dlpreopened libraries before other libraries | |
| 8829 for deplib in $save_deplibs; do | |
| 8830 deplibs="$deplib $deplibs" | |
| 8831 done | |
| 8832 fi | |
| 8833 if test dlopen != "$pass"; then | |
| 8834 test conv = "$pass" || { | |
| 8835 # Make sure lib_search_path contains only unique directories. | |
| 8836 lib_search_path= | |
| 8837 for dir in $newlib_search_path; do | |
| 8838 case "$lib_search_path " in | |
| 8839 *" $dir "*) ;; | |
| 8840 *) func_append lib_search_path " $dir" ;; | |
| 8841 esac | |
| 8842 done | |
| 8843 newlib_search_path= | |
| 8844 } | |
| 8845 | |
| 8846 if test prog,link = "$linkmode,$pass"; then | |
| 8847 vars="compile_deplibs finalize_deplibs" | |
| 8848 else | |
| 8849 vars=deplibs | |
| 8850 fi | |
| 8851 for var in $vars dependency_libs; do | |
| 8852 # Add libraries to $var in reverse order | |
| 8853 eval tmp_libs=\"\$$var\" | |
| 8854 new_libs= | |
| 8855 for deplib in $tmp_libs; do | |
| 8856 # FIXME: Pedantically, this is the right thing to do, so | |
| 8857 # that some nasty dependency loop isn't accidentally | |
| 8858 # broken: | |
| 8859 #new_libs="$deplib $new_libs" | |
| 8860 # Pragmatically, this seems to cause very few problems in | |
| 8861 # practice: | |
| 8862 case $deplib in | |
| 8863 -L*) new_libs="$deplib $new_libs" ;; | |
| 8864 -R*) ;; | |
| 8865 *) | |
| 8866 # And here is the reason: when a library appears more | |
| 8867 # than once as an explicit dependence of a library, or | |
| 8868 # is implicitly linked in more than once by the | |
| 8869 # compiler, it is considered special, and multiple | |
| 8870 # occurrences thereof are not removed. Compare this | |
| 8871 # with having the same library being listed as a | |
| 8872 # dependency of multiple other libraries: in this case, | |
| 8873 # we know (pedantically, we assume) the library does not | |
| 8874 # need to be listed more than once, so we keep only the | |
| 8875 # last copy. This is not always right, but it is rare | |
| 8876 # enough that we require users that really mean to play | |
| 8877 # such unportable linking tricks to link the library | |
| 8878 # using -Wl,-lname, so that libtool does not consider it | |
| 8879 # for duplicate removal. | |
| 8880 case " $specialdeplibs " in | |
| 8881 *" $deplib "*) new_libs="$deplib $new_libs" ;; | |
| 8882 *) | |
| 8883 case " $new_libs " in | |
| 8884 *" $deplib "*) ;; | |
| 8885 *) new_libs="$deplib $new_libs" ;; | |
| 8886 esac | |
| 8887 ;; | |
| 8888 esac | |
| 8889 ;; | |
| 8890 esac | |
| 8891 done | |
| 8892 tmp_libs= | |
| 8893 for deplib in $new_libs; do | |
| 8894 case $deplib in | |
| 8895 -L*) | |
| 8896 case " $tmp_libs " in | |
| 8897 *" $deplib "*) ;; | |
| 8898 *) func_append tmp_libs " $deplib" ;; | |
| 8899 esac | |
| 8900 ;; | |
| 8901 *) func_append tmp_libs " $deplib" ;; | |
| 8902 esac | |
| 8903 done | |
| 8904 eval $var=\"$tmp_libs\" | |
| 8905 done # for var | |
| 8906 fi | |
| 8907 | |
| 8908 # Add Sun CC postdeps if required: | |
| 8909 test CXX = "$tagname" && { | |
| 8910 case $host_os in | |
| 8911 linux*) | |
| 8912 case `$CC -V 2>&1 | $SED 5q` in | |
| 8913 *Sun\ C*) # Sun C++ 5.9 | |
| 8914 func_suncc_cstd_abi | |
| 8915 | |
| 8916 if test no != "$suncc_use_cstd_abi"; then | |
| 8917 func_append postdeps ' -library=Cstd -library=Crun' | |
| 8918 fi | |
| 8919 ;; | |
| 8920 esac | |
| 8921 ;; | |
| 8922 | |
| 8923 solaris*) | |
| 8924 func_cc_basename "$CC" | |
| 8925 case $func_cc_basename_result in | |
| 8926 CC* | sunCC*) | |
| 8927 func_suncc_cstd_abi | |
| 8928 | |
| 8929 if test no != "$suncc_use_cstd_abi"; then | |
| 8930 func_append postdeps ' -library=Cstd -library=Crun' | |
| 8931 fi | |
| 8932 ;; | |
| 8933 esac | |
| 8934 ;; | |
| 8935 esac | |
| 8936 } | |
| 8937 | |
| 8938 # Last step: remove runtime libs from dependency_libs | |
| 8939 # (they stay in deplibs) | |
| 8940 tmp_libs= | |
| 8941 for i in $dependency_libs; do | |
| 8942 case " $predeps $postdeps $compiler_lib_search_path " in | |
| 8943 *" $i "*) | |
| 8944 i= | |
| 8945 ;; | |
| 8946 esac | |
| 8947 if test -n "$i"; then | |
| 8948 func_append tmp_libs " $i" | |
| 8949 fi | |
| 8950 done | |
| 8951 dependency_libs=$tmp_libs | |
| 8952 done # for pass | |
| 8953 if test prog = "$linkmode"; then | |
| 8954 dlfiles=$newdlfiles | |
| 8955 fi | |
| 8956 if test prog = "$linkmode" || test lib = "$linkmode"; then | |
| 8957 dlprefiles=$newdlprefiles | |
| 8958 fi | |
| 8959 | |
| 8960 case $linkmode in | |
| 8961 oldlib) | |
| 8962 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then | |
| 8963 func_warning "'-dlopen' is ignored for archives" | |
| 8964 fi | |
| 8965 | |
| 8966 case " $deplibs" in | |
| 8967 *\ -l* | *\ -L*) | |
| 8968 func_warning "'-l' and '-L' are ignored for archives" ;; | |
| 8969 esac | |
| 8970 | |
| 8971 test -n "$rpath" && \ | |
| 8972 func_warning "'-rpath' is ignored for archives" | |
| 8973 | |
| 8974 test -n "$xrpath" && \ | |
| 8975 func_warning "'-R' is ignored for archives" | |
| 8976 | |
| 8977 test -n "$vinfo" && \ | |
| 8978 func_warning "'-version-info/-version-number' is ignored for archives" | |
| 8979 | |
| 8980 test -n "$release" && \ | |
| 8981 func_warning "'-release' is ignored for archives" | |
| 8982 | |
| 8983 test -n "$export_symbols$export_symbols_regex" && \ | |
| 8984 func_warning "'-export-symbols' is ignored for archives" | |
| 8985 | |
| 8986 # Now set the variables for building old libraries. | |
| 8987 build_libtool_libs=no | |
| 8988 oldlibs=$output | |
| 8989 func_append objs "$old_deplibs" | |
| 8990 ;; | |
| 8991 | |
| 8992 lib) | |
| 8993 # Make sure we only generate libraries of the form 'libNAME.la'. | |
| 8994 case $outputname in | |
| 8995 lib*) | |
| 8996 func_stripname 'lib' '.la' "$outputname" | |
| 8997 name=$func_stripname_result | |
| 8998 eval shared_ext=\"$shrext_cmds\" | |
| 8999 eval libname=\"$libname_spec\" | |
| 9000 ;; | |
| 9001 *) | |
| 9002 test no = "$module" \ | |
| 9003 && func_fatal_help "libtool library '$output' must begin with 'lib'" | |
| 9004 | |
| 9005 if test no != "$need_lib_prefix"; then | |
| 9006 # Add the "lib" prefix for modules if required | |
| 9007 func_stripname '' '.la' "$outputname" | |
| 9008 name=$func_stripname_result | |
| 9009 eval shared_ext=\"$shrext_cmds\" | |
| 9010 eval libname=\"$libname_spec\" | |
| 9011 else | |
| 9012 func_stripname '' '.la' "$outputname" | |
| 9013 libname=$func_stripname_result | |
| 9014 fi | |
| 9015 ;; | |
| 9016 esac | |
| 9017 | |
| 9018 if test -n "$objs"; then | |
| 9019 if test pass_all != "$deplibs_check_method"; then | |
| 9020 func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" | |
| 9021 else | |
| 9022 echo | |
| 9023 $ECHO "*** Warning: Linking the shared library $output against the non-libtool" | |
| 9024 $ECHO "*** objects $objs is not portable!" | |
| 9025 func_append libobjs " $objs" | |
| 9026 fi | |
| 9027 fi | |
| 9028 | |
| 9029 test no = "$dlself" \ | |
| 9030 || func_warning "'-dlopen self' is ignored for libtool libraries" | |
| 9031 | |
| 9032 set dummy $rpath | |
| 9033 shift | |
| 9034 test 1 -lt "$#" \ | |
| 9035 && func_warning "ignoring multiple '-rpath's for a libtool library" | |
| 9036 | |
| 9037 install_libdir=$1 | |
| 9038 | |
| 9039 oldlibs= | |
| 9040 if test -z "$rpath"; then | |
| 9041 if test yes = "$build_libtool_libs"; then | |
| 9042 # Building a libtool convenience library. | |
| 9043 # Some compilers have problems with a '.al' extension so | |
| 9044 # convenience libraries should have the same extension an | |
| 9045 # archive normally would. | |
| 9046 oldlibs="$output_objdir/$libname.$libext $oldlibs" | |
| 9047 build_libtool_libs=convenience | |
| 9048 build_old_libs=yes | |
| 9049 fi | |
| 9050 | |
| 9051 test -n "$vinfo" && \ | |
| 9052 func_warning "'-version-info/-version-number' is ignored for convenience libraries" | |
| 9053 | |
| 9054 test -n "$release" && \ | |
| 9055 func_warning "'-release' is ignored for convenience libraries" | |
| 9056 else | |
| 9057 | |
| 9058 # Parse the version information argument. | |
| 9059 save_ifs=$IFS; IFS=: | |
| 9060 set dummy $vinfo 0 0 0 | |
| 9061 shift | |
| 9062 IFS=$save_ifs | |
| 9063 | |
| 9064 test -n "$7" && \ | |
| 9065 func_fatal_help "too many parameters to '-version-info'" | |
| 9066 | |
| 9067 # convert absolute version numbers to libtool ages | |
| 9068 # this retains compatibility with .la files and attempts | |
| 9069 # to make the code below a bit more comprehensible | |
| 9070 | |
| 9071 case $vinfo_number in | |
| 9072 yes) | |
| 9073 number_major=$1 | |
| 9074 number_minor=$2 | |
| 9075 number_revision=$3 | |
| 9076 # | |
| 9077 # There are really only two kinds -- those that | |
| 9078 # use the current revision as the major version | |
| 9079 # and those that subtract age and use age as | |
| 9080 # a minor version. But, then there is irix | |
| 9081 # that has an extra 1 added just for fun | |
| 9082 # | |
| 9083 case $version_type in | |
| 9084 # correct linux to gnu/linux during the next big refactor | |
| 9085 darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) | |
| 9086 func_arith $number_major + $number_minor | |
| 9087 current=$func_arith_result | |
| 9088 age=$number_minor | |
| 9089 revision=$number_revision | |
| 9090 ;; | |
| 9091 freebsd-aout|qnx|sunos) | |
| 9092 current=$number_major | |
| 9093 revision=$number_minor | |
| 9094 age=0 | |
| 9095 ;; | |
| 9096 irix|nonstopux) | |
| 9097 func_arith $number_major + $number_minor | |
| 9098 current=$func_arith_result | |
| 9099 age=$number_minor | |
| 9100 revision=$number_minor | |
| 9101 lt_irix_increment=no | |
| 9102 ;; | |
| 9103 *) | |
| 9104 func_fatal_configuration "$modename: unknown library version type '$version_type'" | |
| 9105 ;; | |
| 9106 esac | |
| 9107 ;; | |
| 9108 no) | |
| 9109 current=$1 | |
| 9110 revision=$2 | |
| 9111 age=$3 | |
| 9112 ;; | |
| 9113 esac | |
| 9114 | |
| 9115 # Check that each of the things are valid numbers. | |
| 9116 case $current in | |
| 9117 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]) ;; | |
| 9118 *) | |
| 9119 func_error "CURRENT '$current' must be a nonnegative integer" | |
| 9120 func_fatal_error "'$vinfo' is not valid version information" | |
| 9121 ;; | |
| 9122 esac | |
| 9123 | |
| 9124 case $revision in | |
| 9125 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]) ;; | |
| 9126 *) | |
| 9127 func_error "REVISION '$revision' must be a nonnegative integer" | |
| 9128 func_fatal_error "'$vinfo' is not valid version information" | |
| 9129 ;; | |
| 9130 esac | |
| 9131 | |
| 9132 case $age in | |
| 9133 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]) ;; | |
| 9134 *) | |
| 9135 func_error "AGE '$age' must be a nonnegative integer" | |
| 9136 func_fatal_error "'$vinfo' is not valid version information" | |
| 9137 ;; | |
| 9138 esac | |
| 9139 | |
| 9140 if test "$age" -gt "$current"; then | |
| 9141 func_error "AGE '$age' is greater than the current interface number '$current'" | |
| 9142 func_fatal_error "'$vinfo' is not valid version information" | |
| 9143 fi | |
| 9144 | |
| 9145 # Calculate the version variables. | |
| 9146 major= | |
| 9147 versuffix= | |
| 9148 verstring= | |
| 9149 case $version_type in | |
| 9150 none) ;; | |
| 9151 | |
| 9152 darwin) | |
| 9153 # Like Linux, but with the current version available in | |
| 9154 # verstring for coding it into the library header | |
| 9155 func_arith $current - $age | |
| 9156 major=.$func_arith_result | |
| 9157 versuffix=$major.$age.$revision | |
| 9158 # Darwin ld doesn't like 0 for these options... | |
| 9159 func_arith $current + 1 | |
| 9160 minor_current=$func_arith_result | |
| 9161 xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" | |
| 9162 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" | |
| 9163 # On Darwin other compilers | |
| 9164 case $CC in | |
| 9165 nagfor*) | |
| 9166 verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" | |
| 9167 ;; | |
| 9168 *) | |
| 9169 verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" | |
| 9170 ;; | |
| 9171 esac | |
| 9172 ;; | |
| 9173 | |
| 9174 freebsd-aout) | |
| 9175 major=.$current | |
| 9176 versuffix=.$current.$revision | |
| 9177 ;; | |
| 9178 | |
| 9179 freebsd-elf | midnightbsd-elf) | |
| 9180 func_arith $current - $age | |
| 9181 major=.$func_arith_result | |
| 9182 versuffix=$major.$age.$revision | |
| 9183 ;; | |
| 9184 | |
| 9185 irix | nonstopux) | |
| 9186 if test no = "$lt_irix_increment"; then | |
| 9187 func_arith $current - $age | |
| 9188 else | |
| 9189 func_arith $current - $age + 1 | |
| 9190 fi | |
| 9191 major=$func_arith_result | |
| 9192 | |
| 9193 case $version_type in | |
| 9194 nonstopux) verstring_prefix=nonstopux ;; | |
| 9195 *) verstring_prefix=sgi ;; | |
| 9196 esac | |
| 9197 verstring=$verstring_prefix$major.$revision | |
| 9198 | |
| 9199 # Add in all the interfaces that we are compatible with. | |
| 9200 loop=$revision | |
| 9201 while test 0 -ne "$loop"; do | |
| 9202 func_arith $revision - $loop | |
| 9203 iface=$func_arith_result | |
| 9204 func_arith $loop - 1 | |
| 9205 loop=$func_arith_result | |
| 9206 verstring=$verstring_prefix$major.$iface:$verstring | |
| 9207 done | |
| 9208 | |
| 9209 # Before this point, $major must not contain '.'. | |
| 9210 major=.$major | |
| 9211 versuffix=$major.$revision | |
| 9212 ;; | |
| 9213 | |
| 9214 linux) # correct to gnu/linux during the next big refactor | |
| 9215 func_arith $current - $age | |
| 9216 major=.$func_arith_result | |
| 9217 versuffix=$major.$age.$revision | |
| 9218 ;; | |
| 9219 | |
| 9220 osf) | |
| 9221 func_arith $current - $age | |
| 9222 major=.$func_arith_result | |
| 9223 versuffix=.$current.$age.$revision | |
| 9224 verstring=$current.$age.$revision | |
| 9225 | |
| 9226 # Add in all the interfaces that we are compatible with. | |
| 9227 loop=$age | |
| 9228 while test 0 -ne "$loop"; do | |
| 9229 func_arith $current - $loop | |
| 9230 iface=$func_arith_result | |
| 9231 func_arith $loop - 1 | |
| 9232 loop=$func_arith_result | |
| 9233 verstring=$verstring:$iface.0 | |
| 9234 done | |
| 9235 | |
| 9236 # Make executables depend on our current version. | |
| 9237 func_append verstring ":$current.0" | |
| 9238 ;; | |
| 9239 | |
| 9240 qnx) | |
| 9241 major=.$current | |
| 9242 versuffix=.$current | |
| 9243 ;; | |
| 9244 | |
| 9245 sco) | |
| 9246 major=.$current | |
| 9247 versuffix=.$current | |
| 9248 ;; | |
| 9249 | |
| 9250 sunos) | |
| 9251 major=.$current | |
| 9252 versuffix=.$current.$revision | |
| 9253 ;; | |
| 9254 | |
| 9255 windows) | |
| 9256 # Use '-' rather than '.', since we only want one | |
| 9257 # extension on DOS 8.3 file systems. | |
| 9258 func_arith $current - $age | |
| 9259 major=$func_arith_result | |
| 9260 versuffix=-$major | |
| 9261 ;; | |
| 9262 | |
| 9263 *) | |
| 9264 func_fatal_configuration "unknown library version type '$version_type'" | |
| 9265 ;; | |
| 9266 esac | |
| 9267 | |
| 9268 # Clear the version info if we defaulted, and they specified a release. | |
| 9269 if test -z "$vinfo" && test -n "$release"; then | |
| 9270 major= | |
| 9271 case $version_type in | |
| 9272 darwin) | |
| 9273 # we can't check for "0.0" in archive_cmds due to quoting | |
| 9274 # problems, so we reset it completely | |
| 9275 verstring= | |
| 9276 ;; | |
| 9277 *) | |
| 9278 verstring=0.0 | |
| 9279 ;; | |
| 9280 esac | |
| 9281 if test no = "$need_version"; then | |
| 9282 versuffix= | |
| 9283 else | |
| 9284 versuffix=.0.0 | |
| 9285 fi | |
| 9286 fi | |
| 9287 | |
| 9288 # Remove version info from name if versioning should be avoided | |
| 9289 if test yes,no = "$avoid_version,$need_version"; then | |
| 9290 major= | |
| 9291 versuffix= | |
| 9292 verstring= | |
| 9293 fi | |
| 9294 | |
| 9295 # Check to see if the archive will have undefined symbols. | |
| 9296 if test yes = "$allow_undefined"; then | |
| 9297 if test unsupported = "$allow_undefined_flag"; then | |
| 9298 if test yes = "$build_old_libs"; then | |
| 9299 func_warning "undefined symbols not allowed in $host shared libraries; building static only" | |
| 9300 build_libtool_libs=no | |
| 9301 else | |
| 9302 func_fatal_error "can't build $host shared library unless -no-undefined is specified" | |
| 9303 fi | |
| 9304 fi | |
| 9305 else | |
| 9306 # Don't allow undefined symbols. | |
| 9307 allow_undefined_flag=$no_undefined_flag | |
| 9308 fi | |
| 9309 | |
| 9310 fi | |
| 9311 | |
| 9312 func_generate_dlsyms "$libname" "$libname" : | |
| 9313 func_append libobjs " $symfileobj" | |
| 9314 test " " = "$libobjs" && libobjs= | |
| 9315 | |
| 9316 if test relink != "$opt_mode"; then | |
| 9317 # Remove our outputs, but don't remove object files since they | |
| 9318 # may have been created when compiling PIC objects. | |
| 9319 removelist= | |
| 9320 tempremovelist=`$ECHO "$output_objdir/*"` | |
| 9321 for p in $tempremovelist; do | |
| 9322 case $p in | |
| 9323 *.$objext | *.gcno) | |
| 9324 ;; | |
| 9325 $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) | |
| 9326 if test -n "$precious_files_regex"; then | |
| 9327 if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 | |
| 9328 then | |
| 9329 continue | |
| 9330 fi | |
| 9331 fi | |
| 9332 func_append removelist " $p" | |
| 9333 ;; | |
| 9334 *) ;; | |
| 9335 esac | |
| 9336 done | |
| 9337 test -n "$removelist" && \ | |
| 9338 func_show_eval "${RM}r \$removelist" | |
| 9339 fi | |
| 9340 | |
| 9341 # Now set the variables for building old libraries. | |
| 9342 if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then | |
| 9343 func_append oldlibs " $output_objdir/$libname.$libext" | |
| 9344 | |
| 9345 # Transform .lo files to .o files. | |
| 9346 oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` | |
| 9347 fi | |
| 9348 | |
| 9349 # Eliminate all temporary directories. | |
| 9350 #for path in $notinst_path; do | |
| 9351 # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` | |
| 9352 # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` | |
| 9353 # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` | |
| 9354 #done | |
| 9355 | |
| 9356 if test -n "$xrpath"; then | |
| 9357 # If the user specified any rpath flags, then add them. | |
| 9358 temp_xrpath= | |
| 9359 for libdir in $xrpath; do | |
| 9360 func_replace_sysroot "$libdir" | |
| 9361 func_append temp_xrpath " -R$func_replace_sysroot_result" | |
| 9362 case "$finalize_rpath " in | |
| 9363 *" $libdir "*) ;; | |
| 9364 *) func_append finalize_rpath " $libdir" ;; | |
| 9365 esac | |
| 9366 done | |
| 9367 if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then | |
| 9368 dependency_libs="$temp_xrpath $dependency_libs" | |
| 9369 fi | |
| 9370 fi | |
| 9371 | |
| 9372 # Make sure dlfiles contains only unique files that won't be dlpreopened | |
| 9373 old_dlfiles=$dlfiles | |
| 9374 dlfiles= | |
| 9375 for lib in $old_dlfiles; do | |
| 9376 case " $dlprefiles $dlfiles " in | |
| 9377 *" $lib "*) ;; | |
| 9378 *) func_append dlfiles " $lib" ;; | |
| 9379 esac | |
| 9380 done | |
| 9381 | |
| 9382 # Make sure dlprefiles contains only unique files | |
| 9383 old_dlprefiles=$dlprefiles | |
| 9384 dlprefiles= | |
| 9385 for lib in $old_dlprefiles; do | |
| 9386 case "$dlprefiles " in | |
| 9387 *" $lib "*) ;; | |
| 9388 *) func_append dlprefiles " $lib" ;; | |
| 9389 esac | |
| 9390 done | |
| 9391 | |
| 9392 if test yes = "$build_libtool_libs"; then | |
| 9393 if test -n "$rpath"; then | |
| 9394 case $host in | |
| 9395 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) | |
| 9396 # these systems don't actually have a c library (as such)! | |
| 9397 ;; | |
| 9398 *-*-rhapsody* | *-*-darwin1.[012]) | |
| 9399 # Rhapsody C library is in the System framework | |
| 9400 func_append deplibs " System.ltframework" | |
| 9401 ;; | |
| 9402 *-*-netbsd*) | |
| 9403 # Don't link with libc until the a.out ld.so is fixed. | |
| 9404 ;; | |
| 9405 *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) | |
| 9406 # Do not include libc due to us having libc/libc_r. | |
| 9407 ;; | |
| 9408 *-*-sco3.2v5* | *-*-sco5v6*) | |
| 9409 # Causes problems with __ctype | |
| 9410 ;; | |
| 9411 *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) | |
| 9412 # Compiler inserts libc in the correct place for threads to work | |
| 9413 ;; | |
| 9414 *) | |
| 9415 # Add libc to deplibs on all other systems if necessary. | |
| 9416 if test yes = "$build_libtool_need_lc"; then | |
| 9417 func_append deplibs " -lc" | |
| 9418 fi | |
| 9419 ;; | |
| 9420 esac | |
| 9421 fi | |
| 9422 | |
| 9423 # Transform deplibs into only deplibs that can be linked in shared. | |
| 9424 name_save=$name | |
| 9425 libname_save=$libname | |
| 9426 release_save=$release | |
| 9427 versuffix_save=$versuffix | |
| 9428 major_save=$major | |
| 9429 # I'm not sure if I'm treating the release correctly. I think | |
| 9430 # release should show up in the -l (ie -lgmp5) so we don't want to | |
| 9431 # add it in twice. Is that correct? | |
| 9432 release= | |
| 9433 versuffix= | |
| 9434 major= | |
| 9435 newdeplibs= | |
| 9436 droppeddeps=no | |
| 9437 case $deplibs_check_method in | |
| 9438 pass_all) | |
| 9439 # Don't check for shared/static. Everything works. | |
| 9440 # This might be a little naive. We might want to check | |
| 9441 # whether the library exists or not. But this is on | |
| 9442 # osf3 & osf4 and I'm not really sure... Just | |
| 9443 # implementing what was already the behavior. | |
| 9444 newdeplibs=$deplibs | |
| 9445 ;; | |
| 9446 test_compile) | |
| 9447 # This code stresses the "libraries are programs" paradigm to its | |
| 9448 # limits. Maybe even breaks it. We compile a program, linking it | |
| 9449 # against the deplibs as a proxy for the library. Then we can check | |
| 9450 # whether they linked in statically or dynamically with ldd. | |
| 9451 $opt_dry_run || $RM conftest.c | |
| 9452 cat > conftest.c <<EOF | |
| 9453 int main() { return 0; } | |
| 9454 EOF | |
| 9455 $opt_dry_run || $RM conftest | |
| 9456 if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then | |
| 9457 ldd_output=`ldd conftest` | |
| 9458 for i in $deplibs; do | |
| 9459 case $i in | |
| 9460 -l*) | |
| 9461 func_stripname -l '' "$i" | |
| 9462 name=$func_stripname_result | |
| 9463 if test yes = "$allow_libtool_libs_with_static_runtimes"; then | |
| 9464 case " $predeps $postdeps " in | |
| 9465 *" $i "*) | |
| 9466 func_append newdeplibs " $i" | |
| 9467 i= | |
| 9468 ;; | |
| 9469 esac | |
| 9470 fi | |
| 9471 if test -n "$i"; then | |
| 9472 libname=`eval "\\$ECHO \"$libname_spec\""` | |
| 9473 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` | |
| 9474 set dummy $deplib_matches; shift | |
| 9475 deplib_match=$1 | |
| 9476 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then | |
| 9477 func_append newdeplibs " $i" | |
| 9478 else | |
| 9479 droppeddeps=yes | |
| 9480 echo | |
| 9481 $ECHO "*** Warning: dynamic linker does not accept needed library $i." | |
| 9482 echo "*** I have the capability to make that library automatically link in when" | |
| 9483 echo "*** you link to this library. But I can only do this if you have a" | |
| 9484 echo "*** shared version of the library, which I believe you do not have" | |
| 9485 echo "*** because a test_compile did reveal that the linker did not use it for" | |
| 9486 echo "*** its dynamic dependency list that programs get resolved with at runtime." | |
| 9487 fi | |
| 9488 fi | |
| 9489 ;; | |
| 9490 *) | |
| 9491 func_append newdeplibs " $i" | |
| 9492 ;; | |
| 9493 esac | |
| 9494 done | |
| 9495 else | |
| 9496 # Error occurred in the first compile. Let's try to salvage | |
| 9497 # the situation: Compile a separate program for each library. | |
| 9498 for i in $deplibs; do | |
| 9499 case $i in | |
| 9500 -l*) | |
| 9501 func_stripname -l '' "$i" | |
| 9502 name=$func_stripname_result | |
| 9503 $opt_dry_run || $RM conftest | |
| 9504 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then | |
| 9505 ldd_output=`ldd conftest` | |
| 9506 if test yes = "$allow_libtool_libs_with_static_runtimes"; then | |
| 9507 case " $predeps $postdeps " in | |
| 9508 *" $i "*) | |
| 9509 func_append newdeplibs " $i" | |
| 9510 i= | |
| 9511 ;; | |
| 9512 esac | |
| 9513 fi | |
| 9514 if test -n "$i"; then | |
| 9515 libname=`eval "\\$ECHO \"$libname_spec\""` | |
| 9516 deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` | |
| 9517 set dummy $deplib_matches; shift | |
| 9518 deplib_match=$1 | |
| 9519 if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then | |
| 9520 func_append newdeplibs " $i" | |
| 9521 else | |
| 9522 droppeddeps=yes | |
| 9523 echo | |
| 9524 $ECHO "*** Warning: dynamic linker does not accept needed library $i." | |
| 9525 echo "*** I have the capability to make that library automatically link in when" | |
| 9526 echo "*** you link to this library. But I can only do this if you have a" | |
| 9527 echo "*** shared version of the library, which you do not appear to have" | |
| 9528 echo "*** because a test_compile did reveal that the linker did not use this one" | |
| 9529 echo "*** as a dynamic dependency that programs can get resolved with at runtime." | |
| 9530 fi | |
| 9531 fi | |
| 9532 else | |
| 9533 droppeddeps=yes | |
| 9534 echo | |
| 9535 $ECHO "*** Warning! Library $i is needed by this library but I was not able to" | |
| 9536 echo "*** make it link in! You will probably need to install it or some" | |
| 9537 echo "*** library that it depends on before this library will be fully" | |
| 9538 echo "*** functional. Installing it before continuing would be even better." | |
| 9539 fi | |
| 9540 ;; | |
| 9541 *) | |
| 9542 func_append newdeplibs " $i" | |
| 9543 ;; | |
| 9544 esac | |
| 9545 done | |
| 9546 fi | |
| 9547 ;; | |
| 9548 file_magic*) | |
| 9549 set dummy $deplibs_check_method; shift | |
| 9550 file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` | |
| 9551 for a_deplib in $deplibs; do | |
| 9552 case $a_deplib in | |
| 9553 -l*) | |
| 9554 func_stripname -l '' "$a_deplib" | |
| 9555 name=$func_stripname_result | |
| 9556 if test yes = "$allow_libtool_libs_with_static_runtimes"; then | |
| 9557 case " $predeps $postdeps " in | |
| 9558 *" $a_deplib "*) | |
| 9559 func_append newdeplibs " $a_deplib" | |
| 9560 a_deplib= | |
| 9561 ;; | |
| 9562 esac | |
| 9563 fi | |
| 9564 if test -n "$a_deplib"; then | |
| 9565 libname=`eval "\\$ECHO \"$libname_spec\""` | |
| 9566 if test -n "$file_magic_glob"; then | |
| 9567 libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` | |
| 9568 else | |
| 9569 libnameglob=$libname | |
| 9570 fi | |
| 9571 test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` | |
| 9572 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do | |
| 9573 if test yes = "$want_nocaseglob"; then | |
| 9574 shopt -s nocaseglob | |
| 9575 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` | |
| 9576 $nocaseglob | |
| 9577 else | |
| 9578 potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` | |
| 9579 fi | |
| 9580 for potent_lib in $potential_libs; do | |
| 9581 # Follow soft links. | |
| 9582 if ls -lLd "$potent_lib" 2>/dev/null | | |
| 9583 $GREP " -> " >/dev/null; then | |
| 9584 continue | |
| 9585 fi | |
| 9586 # The statement above tries to avoid entering an | |
| 9587 # endless loop below, in case of cyclic links. | |
| 9588 # We might still enter an endless loop, since a link | |
| 9589 # loop can be closed while we follow links, | |
| 9590 # but so what? | |
| 9591 potlib=$potent_lib | |
| 9592 while test -h "$potlib" 2>/dev/null; do | |
| 9593 potliblink=`ls -ld $potlib | $SED 's/.* -> //'` | |
| 9594 case $potliblink in | |
| 9595 [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; | |
| 9596 *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; | |
| 9597 esac | |
| 9598 done | |
| 9599 if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | | |
| 9600 $SED -e 10q | | |
| 9601 $EGREP "$file_magic_regex" > /dev/null; then | |
| 9602 func_append newdeplibs " $a_deplib" | |
| 9603 a_deplib= | |
| 9604 break 2 | |
| 9605 fi | |
| 9606 done | |
| 9607 done | |
| 9608 fi | |
| 9609 if test -n "$a_deplib"; then | |
| 9610 droppeddeps=yes | |
| 9611 echo | |
| 9612 $ECHO "*** Warning: linker path does not have real file for library $a_deplib." | |
| 9613 echo "*** I have the capability to make that library automatically link in when" | |
| 9614 echo "*** you link to this library. But I can only do this if you have a" | |
| 9615 echo "*** shared version of the library, which you do not appear to have" | |
| 9616 echo "*** because I did check the linker path looking for a file starting" | |
| 9617 if test -z "$potlib"; then | |
| 9618 $ECHO "*** with $libname but no candidates were found. (...for file magic test)" | |
| 9619 else | |
| 9620 $ECHO "*** with $libname and none of the candidates passed a file format test" | |
| 9621 $ECHO "*** using a file magic. Last file checked: $potlib" | |
| 9622 fi | |
| 9623 fi | |
| 9624 ;; | |
| 9625 *) | |
| 9626 # Add a -L argument. | |
| 9627 func_append newdeplibs " $a_deplib" | |
| 9628 ;; | |
| 9629 esac | |
| 9630 done # Gone through all deplibs. | |
| 9631 ;; | |
| 9632 match_pattern*) | |
| 9633 set dummy $deplibs_check_method; shift | |
| 9634 match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` | |
| 9635 for a_deplib in $deplibs; do | |
| 9636 case $a_deplib in | |
| 9637 -l*) | |
| 9638 func_stripname -l '' "$a_deplib" | |
| 9639 name=$func_stripname_result | |
| 9640 if test yes = "$allow_libtool_libs_with_static_runtimes"; then | |
| 9641 case " $predeps $postdeps " in | |
| 9642 *" $a_deplib "*) | |
| 9643 func_append newdeplibs " $a_deplib" | |
| 9644 a_deplib= | |
| 9645 ;; | |
| 9646 esac | |
| 9647 fi | |
| 9648 if test -n "$a_deplib"; then | |
| 9649 libname=`eval "\\$ECHO \"$libname_spec\""` | |
| 9650 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do | |
| 9651 potential_libs=`ls $i/$libname[.-]* 2>/dev/null` | |
| 9652 for potent_lib in $potential_libs; do | |
| 9653 potlib=$potent_lib # see symlink-check above in file_magic test | |
| 9654 if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ | |
| 9655 $EGREP "$match_pattern_regex" > /dev/null; then | |
| 9656 func_append newdeplibs " $a_deplib" | |
| 9657 a_deplib= | |
| 9658 break 2 | |
| 9659 fi | |
| 9660 done | |
| 9661 done | |
| 9662 fi | |
| 9663 if test -n "$a_deplib"; then | |
| 9664 droppeddeps=yes | |
| 9665 echo | |
| 9666 $ECHO "*** Warning: linker path does not have real file for library $a_deplib." | |
| 9667 echo "*** I have the capability to make that library automatically link in when" | |
| 9668 echo "*** you link to this library. But I can only do this if you have a" | |
| 9669 echo "*** shared version of the library, which you do not appear to have" | |
| 9670 echo "*** because I did check the linker path looking for a file starting" | |
| 9671 if test -z "$potlib"; then | |
| 9672 $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" | |
| 9673 else | |
| 9674 $ECHO "*** with $libname and none of the candidates passed a file format test" | |
| 9675 $ECHO "*** using a regex pattern. Last file checked: $potlib" | |
| 9676 fi | |
| 9677 fi | |
| 9678 ;; | |
| 9679 *) | |
| 9680 # Add a -L argument. | |
| 9681 func_append newdeplibs " $a_deplib" | |
| 9682 ;; | |
| 9683 esac | |
| 9684 done # Gone through all deplibs. | |
| 9685 ;; | |
| 9686 none | unknown | *) | |
| 9687 newdeplibs= | |
| 9688 tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` | |
| 9689 if test yes = "$allow_libtool_libs_with_static_runtimes"; then | |
| 9690 for i in $predeps $postdeps; do | |
| 9691 # can't use Xsed below, because $i might contain '/' | |
| 9692 tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` | |
| 9693 done | |
| 9694 fi | |
| 9695 case $tmp_deplibs in | |
| 9696 *[!\ \ ]*) | |
| 9697 echo | |
| 9698 if test none = "$deplibs_check_method"; then | |
| 9699 echo "*** Warning: inter-library dependencies are not supported in this platform." | |
| 9700 else | |
| 9701 echo "*** Warning: inter-library dependencies are not known to be supported." | |
| 9702 fi | |
| 9703 echo "*** All declared inter-library dependencies are being dropped." | |
| 9704 droppeddeps=yes | |
| 9705 ;; | |
| 9706 esac | |
| 9707 ;; | |
| 9708 esac | |
| 9709 versuffix=$versuffix_save | |
| 9710 major=$major_save | |
| 9711 release=$release_save | |
| 9712 libname=$libname_save | |
| 9713 name=$name_save | |
| 9714 | |
| 9715 case $host in | |
| 9716 *-*-rhapsody* | *-*-darwin1.[012]) | |
| 9717 # On Rhapsody replace the C library with the System framework | |
| 9718 newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` | |
| 9719 ;; | |
| 9720 esac | |
| 9721 | |
| 9722 if test yes = "$droppeddeps"; then | |
| 9723 if test yes = "$module"; then | |
| 9724 echo | |
| 9725 echo "*** Warning: libtool could not satisfy all declared inter-library" | |
| 9726 $ECHO "*** dependencies of module $libname. Therefore, libtool will create" | |
| 9727 echo "*** a static module, that should work as long as the dlopening" | |
| 9728 echo "*** application is linked with the -dlopen flag." | |
| 9729 if test -z "$global_symbol_pipe"; then | |
| 9730 echo | |
| 9731 echo "*** However, this would only work if libtool was able to extract symbol" | |
| 9732 echo "*** lists from a program, using 'nm' or equivalent, but libtool could" | |
| 9733 echo "*** not find such a program. So, this module is probably useless." | |
| 9734 echo "*** 'nm' from GNU binutils and a full rebuild may help." | |
| 9735 fi | |
| 9736 if test no = "$build_old_libs"; then | |
| 9737 oldlibs=$output_objdir/$libname.$libext | |
| 9738 build_libtool_libs=module | |
| 9739 build_old_libs=yes | |
| 9740 else | |
| 9741 build_libtool_libs=no | |
| 9742 fi | |
| 9743 else | |
| 9744 echo "*** The inter-library dependencies that have been dropped here will be" | |
| 9745 echo "*** automatically added whenever a program is linked with this library" | |
| 9746 echo "*** or is declared to -dlopen it." | |
| 9747 | |
| 9748 if test no = "$allow_undefined"; then | |
| 9749 echo | |
| 9750 echo "*** Since this library must not contain undefined symbols," | |
| 9751 echo "*** because either the platform does not support them or" | |
| 9752 echo "*** it was explicitly requested with -no-undefined," | |
| 9753 echo "*** libtool will only create a static version of it." | |
| 9754 if test no = "$build_old_libs"; then | |
| 9755 oldlibs=$output_objdir/$libname.$libext | |
| 9756 build_libtool_libs=module | |
| 9757 build_old_libs=yes | |
| 9758 else | |
| 9759 build_libtool_libs=no | |
| 9760 fi | |
| 9761 fi | |
| 9762 fi | |
| 9763 fi | |
| 9764 # Done checking deplibs! | |
| 9765 deplibs=$newdeplibs | |
| 9766 fi | |
| 9767 # Time to change all our "foo.ltframework" stuff back to "-framework foo" | |
| 9768 case $host in | |
| 9769 *-*-darwin*) | |
| 9770 newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` | |
| 9771 new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` | |
| 9772 deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` | |
| 9773 ;; | |
| 9774 esac | |
| 9775 | |
| 9776 # move library search paths that coincide with paths to not yet | |
| 9777 # installed libraries to the beginning of the library search list | |
| 9778 new_libs= | |
| 9779 for path in $notinst_path; do | |
| 9780 case " $new_libs " in | |
| 9781 *" -L$path/$objdir "*) ;; | |
| 9782 *) | |
| 9783 case " $deplibs " in | |
| 9784 *" -L$path/$objdir "*) | |
| 9785 func_append new_libs " -L$path/$objdir" ;; | |
| 9786 esac | |
| 9787 ;; | |
| 9788 esac | |
| 9789 done | |
| 9790 for deplib in $deplibs; do | |
| 9791 case $deplib in | |
| 9792 -L*) | |
| 9793 case " $new_libs " in | |
| 9794 *" $deplib "*) ;; | |
| 9795 *) func_append new_libs " $deplib" ;; | |
| 9796 esac | |
| 9797 ;; | |
| 9798 *) func_append new_libs " $deplib" ;; | |
| 9799 esac | |
| 9800 done | |
| 9801 deplibs=$new_libs | |
| 9802 | |
| 9803 # All the library-specific variables (install_libdir is set above). | |
| 9804 library_names= | |
| 9805 old_library= | |
| 9806 dlname= | |
| 9807 | |
| 9808 # Test again, we may have decided not to build it any more | |
| 9809 if test yes = "$build_libtool_libs"; then | |
| 9810 # Remove $wl instances when linking with ld. | |
| 9811 # FIXME: should test the right _cmds variable. | |
| 9812 case $archive_cmds in | |
| 9813 *\$LD\ *) wl= ;; | |
| 9814 esac | |
| 9815 if test yes = "$hardcode_into_libs"; then | |
| 9816 # Hardcode the library paths | |
| 9817 hardcode_libdirs= | |
| 9818 dep_rpath= | |
| 9819 rpath=$finalize_rpath | |
| 9820 test relink = "$opt_mode" || rpath=$compile_rpath$rpath | |
| 9821 for libdir in $rpath; do | |
| 9822 if test -n "$hardcode_libdir_flag_spec"; then | |
| 9823 if test -n "$hardcode_libdir_separator"; then | |
| 9824 func_replace_sysroot "$libdir" | |
| 9825 libdir=$func_replace_sysroot_result | |
| 9826 if test -z "$hardcode_libdirs"; then | |
| 9827 hardcode_libdirs=$libdir | |
| 9828 else | |
| 9829 # Just accumulate the unique libdirs. | |
| 9830 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in | |
| 9831 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) | |
| 9832 ;; | |
| 9833 *) | |
| 9834 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" | |
| 9835 ;; | |
| 9836 esac | |
| 9837 fi | |
| 9838 else | |
| 9839 eval flag=\"$hardcode_libdir_flag_spec\" | |
| 9840 func_append dep_rpath " $flag" | |
| 9841 fi | |
| 9842 elif test -n "$runpath_var"; then | |
| 9843 case "$perm_rpath " in | |
| 9844 *" $libdir "*) ;; | |
| 9845 *) func_append perm_rpath " $libdir" ;; | |
| 9846 esac | |
| 9847 fi | |
| 9848 done | |
| 9849 # Substitute the hardcoded libdirs into the rpath. | |
| 9850 if test -n "$hardcode_libdir_separator" && | |
| 9851 test -n "$hardcode_libdirs"; then | |
| 9852 libdir=$hardcode_libdirs | |
| 9853 eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" | |
| 9854 fi | |
| 9855 if test -n "$runpath_var" && test -n "$perm_rpath"; then | |
| 9856 # We should set the runpath_var. | |
| 9857 rpath= | |
| 9858 for dir in $perm_rpath; do | |
| 9859 func_append rpath "$dir:" | |
| 9860 done | |
| 9861 eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" | |
| 9862 fi | |
| 9863 test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" | |
| 9864 fi | |
| 9865 | |
| 9866 shlibpath=$finalize_shlibpath | |
| 9867 test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath | |
| 9868 if test -n "$shlibpath"; then | |
| 9869 eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" | |
| 9870 fi | |
| 9871 | |
| 9872 # Get the real and link names of the library. | |
| 9873 eval shared_ext=\"$shrext_cmds\" | |
| 9874 eval library_names=\"$library_names_spec\" | |
| 9875 set dummy $library_names | |
| 9876 shift | |
| 9877 realname=$1 | |
| 9878 shift | |
| 9879 | |
| 9880 if test -n "$soname_spec"; then | |
| 9881 eval soname=\"$soname_spec\" | |
| 9882 else | |
| 9883 soname=$realname | |
| 9884 fi | |
| 9885 if test -z "$dlname"; then | |
| 9886 dlname=$soname | |
| 9887 fi | |
| 9888 | |
| 9889 lib=$output_objdir/$realname | |
| 9890 linknames= | |
| 9891 for link | |
| 9892 do | |
| 9893 func_append linknames " $link" | |
| 9894 done | |
| 9895 | |
| 9896 # Use standard objects if they are pic | |
| 9897 test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` | |
| 9898 test "X$libobjs" = "X " && libobjs= | |
| 9899 | |
| 9900 delfiles= | |
| 9901 if test -n "$export_symbols" && test -n "$include_expsyms"; then | |
| 9902 $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" | |
| 9903 export_symbols=$output_objdir/$libname.uexp | |
| 9904 func_append delfiles " $export_symbols" | |
| 9905 fi | |
| 9906 | |
| 9907 orig_export_symbols= | |
| 9908 case $host_os in | |
| 9909 cygwin* | mingw* | cegcc*) | |
| 9910 if test -n "$export_symbols" && test -z "$export_symbols_regex"; then | |
| 9911 # exporting using user supplied symfile | |
| 9912 func_dll_def_p "$export_symbols" || { | |
| 9913 # and it's NOT already a .def file. Must figure out | |
| 9914 # which of the given symbols are data symbols and tag | |
| 9915 # them as such. So, trigger use of export_symbols_cmds. | |
| 9916 # export_symbols gets reassigned inside the "prepare | |
| 9917 # the list of exported symbols" if statement, so the | |
| 9918 # include_expsyms logic still works. | |
| 9919 orig_export_symbols=$export_symbols | |
| 9920 export_symbols= | |
| 9921 always_export_symbols=yes | |
| 9922 } | |
| 9923 fi | |
| 9924 ;; | |
| 9925 esac | |
| 9926 | |
| 9927 # Prepare the list of exported symbols | |
| 9928 if test -z "$export_symbols"; then | |
| 9929 if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then | |
| 9930 func_verbose "generating symbol list for '$libname.la'" | |
| 9931 export_symbols=$output_objdir/$libname.exp | |
| 9932 $opt_dry_run || $RM $export_symbols | |
| 9933 cmds=$export_symbols_cmds | |
| 9934 save_ifs=$IFS; IFS='~' | |
| 9935 for cmd1 in $cmds; do | |
| 9936 IFS=$save_ifs | |
| 9937 # Take the normal branch if the nm_file_list_spec branch | |
| 9938 # doesn't work or if tool conversion is not needed. | |
| 9939 case $nm_file_list_spec~$to_tool_file_cmd in | |
| 9940 *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) | |
| 9941 try_normal_branch=yes | |
| 9942 eval cmd=\"$cmd1\" | |
| 9943 func_len " $cmd" | |
| 9944 len=$func_len_result | |
| 9945 ;; | |
| 9946 *) | |
| 9947 try_normal_branch=no | |
| 9948 ;; | |
| 9949 esac | |
| 9950 if test yes = "$try_normal_branch" \ | |
| 9951 && { test "$len" -lt "$max_cmd_len" \ | |
| 9952 || test "$max_cmd_len" -le -1; } | |
| 9953 then | |
| 9954 func_show_eval "$cmd" 'exit $?' | |
| 9955 skipped_export=false | |
| 9956 elif test -n "$nm_file_list_spec"; then | |
| 9957 func_basename "$output" | |
| 9958 output_la=$func_basename_result | |
| 9959 save_libobjs=$libobjs | |
| 9960 save_output=$output | |
| 9961 output=$output_objdir/$output_la.nm | |
| 9962 func_to_tool_file "$output" | |
| 9963 libobjs=$nm_file_list_spec$func_to_tool_file_result | |
| 9964 func_append delfiles " $output" | |
| 9965 func_verbose "creating $NM input file list: $output" | |
| 9966 for obj in $save_libobjs; do | |
| 9967 func_to_tool_file "$obj" | |
| 9968 $ECHO "$func_to_tool_file_result" | |
| 9969 done > "$output" | |
| 9970 eval cmd=\"$cmd1\" | |
| 9971 func_show_eval "$cmd" 'exit $?' | |
| 9972 output=$save_output | |
| 9973 libobjs=$save_libobjs | |
| 9974 skipped_export=false | |
| 9975 else | |
| 9976 # The command line is too long to execute in one step. | |
| 9977 func_verbose "using reloadable object file for export list..." | |
| 9978 skipped_export=: | |
| 9979 # Break out early, otherwise skipped_export may be | |
| 9980 # set to false by a later but shorter cmd. | |
| 9981 break | |
| 9982 fi | |
| 9983 done | |
| 9984 IFS=$save_ifs | |
| 9985 if test -n "$export_symbols_regex" && test : != "$skipped_export"; then | |
| 9986 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' | |
| 9987 func_show_eval '$MV "${export_symbols}T" "$export_symbols"' | |
| 9988 fi | |
| 9989 fi | |
| 9990 fi | |
| 9991 | |
| 9992 if test -n "$export_symbols" && test -n "$include_expsyms"; then | |
| 9993 tmp_export_symbols=$export_symbols | |
| 9994 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols | |
| 9995 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' | |
| 9996 fi | |
| 9997 | |
| 9998 if test : != "$skipped_export" && test -n "$orig_export_symbols"; then | |
| 9999 # The given exports_symbols file has to be filtered, so filter it. | |
| 10000 func_verbose "filter symbol list for '$libname.la' to tag DATA exports" | |
| 10001 # FIXME: $output_objdir/$libname.filter potentially contains lots of | |
| 10002 # 's' commands, which not all seds can handle. GNU sed should be fine | |
| 10003 # though. Also, the filter scales superlinearly with the number of | |
| 10004 # global variables. join(1) would be nice here, but unfortunately | |
| 10005 # isn't a blessed tool. | |
| 10006 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter | |
| 10007 func_append delfiles " $export_symbols $output_objdir/$libname.filter" | |
| 10008 export_symbols=$output_objdir/$libname.def | |
| 10009 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols | |
| 10010 fi | |
| 10011 | |
| 10012 tmp_deplibs= | |
| 10013 for test_deplib in $deplibs; do | |
| 10014 case " $convenience " in | |
| 10015 *" $test_deplib "*) ;; | |
| 10016 *) | |
| 10017 func_append tmp_deplibs " $test_deplib" | |
| 10018 ;; | |
| 10019 esac | |
| 10020 done | |
| 10021 deplibs=$tmp_deplibs | |
| 10022 | |
| 10023 if test -n "$convenience"; then | |
| 10024 if test -n "$whole_archive_flag_spec" && | |
| 10025 test yes = "$compiler_needs_object" && | |
| 10026 test -z "$libobjs"; then | |
| 10027 # extract the archives, so we have objects to list. | |
| 10028 # TODO: could optimize this to just extract one archive. | |
| 10029 whole_archive_flag_spec= | |
| 10030 fi | |
| 10031 if test -n "$whole_archive_flag_spec"; then | |
| 10032 save_libobjs=$libobjs | |
| 10033 eval libobjs=\"\$libobjs $whole_archive_flag_spec\" | |
| 10034 test "X$libobjs" = "X " && libobjs= | |
| 10035 else | |
| 10036 gentop=$output_objdir/${outputname}x | |
| 10037 func_append generated " $gentop" | |
| 10038 | |
| 10039 func_extract_archives $gentop $convenience | |
| 10040 func_append libobjs " $func_extract_archives_result" | |
| 10041 test "X$libobjs" = "X " && libobjs= | |
| 10042 fi | |
| 10043 fi | |
| 10044 | |
| 10045 if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then | |
| 10046 eval flag=\"$thread_safe_flag_spec\" | |
| 10047 func_append linker_flags " $flag" | |
| 10048 fi | |
| 10049 | |
| 10050 # Make a backup of the uninstalled library when relinking | |
| 10051 if test relink = "$opt_mode"; then | |
| 10052 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? | |
| 10053 fi | |
| 10054 | |
| 10055 # Do each of the archive commands. | |
| 10056 if test yes = "$module" && test -n "$module_cmds"; then | |
| 10057 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then | |
| 10058 eval test_cmds=\"$module_expsym_cmds\" | |
| 10059 cmds=$module_expsym_cmds | |
| 10060 else | |
| 10061 eval test_cmds=\"$module_cmds\" | |
| 10062 cmds=$module_cmds | |
| 10063 fi | |
| 10064 else | |
| 10065 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then | |
| 10066 eval test_cmds=\"$archive_expsym_cmds\" | |
| 10067 cmds=$archive_expsym_cmds | |
| 10068 else | |
| 10069 eval test_cmds=\"$archive_cmds\" | |
| 10070 cmds=$archive_cmds | |
| 10071 fi | |
| 10072 fi | |
| 10073 | |
| 10074 if test : != "$skipped_export" && | |
| 10075 func_len " $test_cmds" && | |
| 10076 len=$func_len_result && | |
| 10077 test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then | |
| 10078 : | |
| 10079 else | |
| 10080 # The command line is too long to link in one step, link piecewise | |
| 10081 # or, if using GNU ld and skipped_export is not :, use a linker | |
| 10082 # script. | |
| 10083 | |
| 10084 # Save the value of $output and $libobjs because we want to | |
| 10085 # use them later. If we have whole_archive_flag_spec, we | |
| 10086 # want to use save_libobjs as it was before | |
| 10087 # whole_archive_flag_spec was expanded, because we can't | |
| 10088 # assume the linker understands whole_archive_flag_spec. | |
| 10089 # This may have to be revisited, in case too many | |
| 10090 # convenience libraries get linked in and end up exceeding | |
| 10091 # the spec. | |
| 10092 if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then | |
| 10093 save_libobjs=$libobjs | |
| 10094 fi | |
| 10095 save_output=$output | |
| 10096 func_basename "$output" | |
| 10097 output_la=$func_basename_result | |
| 10098 | |
| 10099 # Clear the reloadable object creation command queue and | |
| 10100 # initialize k to one. | |
| 10101 test_cmds= | |
| 10102 concat_cmds= | |
| 10103 objlist= | |
| 10104 last_robj= | |
| 10105 k=1 | |
| 10106 | |
| 10107 if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then | |
| 10108 output=$output_objdir/$output_la.lnkscript | |
| 10109 func_verbose "creating GNU ld script: $output" | |
| 10110 echo 'INPUT (' > $output | |
| 10111 for obj in $save_libobjs | |
| 10112 do | |
| 10113 func_to_tool_file "$obj" | |
| 10114 $ECHO "$func_to_tool_file_result" >> $output | |
| 10115 done | |
| 10116 echo ')' >> $output | |
| 10117 func_append delfiles " $output" | |
| 10118 func_to_tool_file "$output" | |
| 10119 output=$func_to_tool_file_result | |
| 10120 elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then | |
| 10121 output=$output_objdir/$output_la.lnk | |
| 10122 func_verbose "creating linker input file list: $output" | |
| 10123 : > $output | |
| 10124 set x $save_libobjs | |
| 10125 shift | |
| 10126 firstobj= | |
| 10127 if test yes = "$compiler_needs_object"; then | |
| 10128 firstobj="$1 " | |
| 10129 shift | |
| 10130 fi | |
| 10131 for obj | |
| 10132 do | |
| 10133 func_to_tool_file "$obj" | |
| 10134 $ECHO "$func_to_tool_file_result" >> $output | |
| 10135 done | |
| 10136 func_append delfiles " $output" | |
| 10137 func_to_tool_file "$output" | |
| 10138 output=$firstobj\"$file_list_spec$func_to_tool_file_result\" | |
| 10139 else | |
| 10140 if test -n "$save_libobjs"; then | |
| 10141 func_verbose "creating reloadable object files..." | |
| 10142 output=$output_objdir/$output_la-$k.$objext | |
| 10143 eval test_cmds=\"$reload_cmds\" | |
| 10144 func_len " $test_cmds" | |
| 10145 len0=$func_len_result | |
| 10146 len=$len0 | |
| 10147 | |
| 10148 # Loop over the list of objects to be linked. | |
| 10149 for obj in $save_libobjs | |
| 10150 do | |
| 10151 func_len " $obj" | |
| 10152 func_arith $len + $func_len_result | |
| 10153 len=$func_arith_result | |
| 10154 if test -z "$objlist" || | |
| 10155 test "$len" -lt "$max_cmd_len"; then | |
| 10156 func_append objlist " $obj" | |
| 10157 else | |
| 10158 # The command $test_cmds is almost too long, add a | |
| 10159 # command to the queue. | |
| 10160 if test 1 -eq "$k"; then | |
| 10161 # The first file doesn't have a previous command to add. | |
| 10162 reload_objs=$objlist | |
| 10163 eval concat_cmds=\"$reload_cmds\" | |
| 10164 else | |
| 10165 # All subsequent reloadable object files will link in | |
| 10166 # the last one created. | |
| 10167 reload_objs="$objlist $last_robj" | |
| 10168 eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" | |
| 10169 fi | |
| 10170 last_robj=$output_objdir/$output_la-$k.$objext | |
| 10171 func_arith $k + 1 | |
| 10172 k=$func_arith_result | |
| 10173 output=$output_objdir/$output_la-$k.$objext | |
| 10174 objlist=" $obj" | |
| 10175 func_len " $last_robj" | |
| 10176 func_arith $len0 + $func_len_result | |
| 10177 len=$func_arith_result | |
| 10178 fi | |
| 10179 done | |
| 10180 # Handle the remaining objects by creating one last | |
| 10181 # reloadable object file. All subsequent reloadable object | |
| 10182 # files will link in the last one created. | |
| 10183 test -z "$concat_cmds" || concat_cmds=$concat_cmds~ | |
| 10184 reload_objs="$objlist $last_robj" | |
| 10185 eval concat_cmds=\"\$concat_cmds$reload_cmds\" | |
| 10186 if test -n "$last_robj"; then | |
| 10187 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" | |
| 10188 fi | |
| 10189 func_append delfiles " $output" | |
| 10190 | |
| 10191 else | |
| 10192 output= | |
| 10193 fi | |
| 10194 | |
| 10195 ${skipped_export-false} && { | |
| 10196 func_verbose "generating symbol list for '$libname.la'" | |
| 10197 export_symbols=$output_objdir/$libname.exp | |
| 10198 $opt_dry_run || $RM $export_symbols | |
| 10199 libobjs=$output | |
| 10200 # Append the command to create the export file. | |
| 10201 test -z "$concat_cmds" || concat_cmds=$concat_cmds~ | |
| 10202 eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" | |
| 10203 if test -n "$last_robj"; then | |
| 10204 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" | |
| 10205 fi | |
| 10206 } | |
| 10207 | |
| 10208 test -n "$save_libobjs" && | |
| 10209 func_verbose "creating a temporary reloadable object file: $output" | |
| 10210 | |
| 10211 # Loop through the commands generated above and execute them. | |
| 10212 save_ifs=$IFS; IFS='~' | |
| 10213 for cmd in $concat_cmds; do | |
| 10214 IFS=$save_ifs | |
| 10215 $opt_quiet || { | |
| 10216 func_quote_arg expand,pretty "$cmd" | |
| 10217 eval "func_echo $func_quote_arg_result" | |
| 10218 } | |
| 10219 $opt_dry_run || eval "$cmd" || { | |
| 10220 lt_exit=$? | |
| 10221 | |
| 10222 # Restore the uninstalled library and exit | |
| 10223 if test relink = "$opt_mode"; then | |
| 10224 ( cd "$output_objdir" && \ | |
| 10225 $RM "${realname}T" && \ | |
| 10226 $MV "${realname}U" "$realname" ) | |
| 10227 fi | |
| 10228 | |
| 10229 exit $lt_exit | |
| 10230 } | |
| 10231 done | |
| 10232 IFS=$save_ifs | |
| 10233 | |
| 10234 if test -n "$export_symbols_regex" && ${skipped_export-false}; then | |
| 10235 func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' | |
| 10236 func_show_eval '$MV "${export_symbols}T" "$export_symbols"' | |
| 10237 fi | |
| 10238 fi | |
| 10239 | |
| 10240 ${skipped_export-false} && { | |
| 10241 if test -n "$export_symbols" && test -n "$include_expsyms"; then | |
| 10242 tmp_export_symbols=$export_symbols | |
| 10243 test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols | |
| 10244 $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' | |
| 10245 fi | |
| 10246 | |
| 10247 if test -n "$orig_export_symbols"; then | |
| 10248 # The given exports_symbols file has to be filtered, so filter it. | |
| 10249 func_verbose "filter symbol list for '$libname.la' to tag DATA exports" | |
| 10250 # FIXME: $output_objdir/$libname.filter potentially contains lots of | |
| 10251 # 's' commands, which not all seds can handle. GNU sed should be fine | |
| 10252 # though. Also, the filter scales superlinearly with the number of | |
| 10253 # global variables. join(1) would be nice here, but unfortunately | |
| 10254 # isn't a blessed tool. | |
| 10255 $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter | |
| 10256 func_append delfiles " $export_symbols $output_objdir/$libname.filter" | |
| 10257 export_symbols=$output_objdir/$libname.def | |
| 10258 $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols | |
| 10259 fi | |
| 10260 } | |
| 10261 | |
| 10262 libobjs=$output | |
| 10263 # Restore the value of output. | |
| 10264 output=$save_output | |
| 10265 | |
| 10266 if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then | |
| 10267 eval libobjs=\"\$libobjs $whole_archive_flag_spec\" | |
| 10268 test "X$libobjs" = "X " && libobjs= | |
| 10269 fi | |
| 10270 # Expand the library linking commands again to reset the | |
| 10271 # value of $libobjs for piecewise linking. | |
| 10272 | |
| 10273 # Do each of the archive commands. | |
| 10274 if test yes = "$module" && test -n "$module_cmds"; then | |
| 10275 if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then | |
| 10276 cmds=$module_expsym_cmds | |
| 10277 else | |
| 10278 cmds=$module_cmds | |
| 10279 fi | |
| 10280 else | |
| 10281 if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then | |
| 10282 cmds=$archive_expsym_cmds | |
| 10283 else | |
| 10284 cmds=$archive_cmds | |
| 10285 fi | |
| 10286 fi | |
| 10287 fi | |
| 10288 | |
| 10289 if test -n "$delfiles"; then | |
| 10290 # Append the command to remove temporary files to $cmds. | |
| 10291 eval cmds=\"\$cmds~\$RM $delfiles\" | |
| 10292 fi | |
| 10293 | |
| 10294 # Add any objects from preloaded convenience libraries | |
| 10295 if test -n "$dlprefiles"; then | |
| 10296 gentop=$output_objdir/${outputname}x | |
| 10297 func_append generated " $gentop" | |
| 10298 | |
| 10299 func_extract_archives $gentop $dlprefiles | |
| 10300 func_append libobjs " $func_extract_archives_result" | |
| 10301 test "X$libobjs" = "X " && libobjs= | |
| 10302 fi | |
| 10303 | |
| 10304 save_ifs=$IFS; IFS='~' | |
| 10305 for cmd in $cmds; do | |
| 10306 IFS=$sp$nl | |
| 10307 eval cmd=\"$cmd\" | |
| 10308 IFS=$save_ifs | |
| 10309 $opt_quiet || { | |
| 10310 func_quote_arg expand,pretty "$cmd" | |
| 10311 eval "func_echo $func_quote_arg_result" | |
| 10312 } | |
| 10313 $opt_dry_run || eval "$cmd" || { | |
| 10314 lt_exit=$? | |
| 10315 | |
| 10316 # Restore the uninstalled library and exit | |
| 10317 if test relink = "$opt_mode"; then | |
| 10318 ( cd "$output_objdir" && \ | |
| 10319 $RM "${realname}T" && \ | |
| 10320 $MV "${realname}U" "$realname" ) | |
| 10321 fi | |
| 10322 | |
| 10323 exit $lt_exit | |
| 10324 } | |
| 10325 done | |
| 10326 IFS=$save_ifs | |
| 10327 | |
| 10328 # Restore the uninstalled library and exit | |
| 10329 if test relink = "$opt_mode"; then | |
| 10330 $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? | |
| 10331 | |
| 10332 if test -n "$convenience"; then | |
| 10333 if test -z "$whole_archive_flag_spec"; then | |
| 10334 func_show_eval '${RM}r "$gentop"' | |
| 10335 fi | |
| 10336 fi | |
| 10337 | |
| 10338 exit $EXIT_SUCCESS | |
| 10339 fi | |
| 10340 | |
| 10341 # Create links to the real library. | |
| 10342 for linkname in $linknames; do | |
| 10343 if test "$realname" != "$linkname"; then | |
| 10344 func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' | |
| 10345 fi | |
| 10346 done | |
| 10347 | |
| 10348 # If -module or -export-dynamic was specified, set the dlname. | |
| 10349 if test yes = "$module" || test yes = "$export_dynamic"; then | |
| 10350 # On all known operating systems, these are identical. | |
| 10351 dlname=$soname | |
| 10352 fi | |
| 10353 fi | |
| 10354 ;; | |
| 10355 | |
| 10356 obj) | |
| 10357 if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then | |
| 10358 func_warning "'-dlopen' is ignored for objects" | |
| 10359 fi | |
| 10360 | |
| 10361 case " $deplibs" in | |
| 10362 *\ -l* | *\ -L*) | |
| 10363 func_warning "'-l' and '-L' are ignored for objects" ;; | |
| 10364 esac | |
| 10365 | |
| 10366 test -n "$rpath" && \ | |
| 10367 func_warning "'-rpath' is ignored for objects" | |
| 10368 | |
| 10369 test -n "$xrpath" && \ | |
| 10370 func_warning "'-R' is ignored for objects" | |
| 10371 | |
| 10372 test -n "$vinfo" && \ | |
| 10373 func_warning "'-version-info' is ignored for objects" | |
| 10374 | |
| 10375 test -n "$release" && \ | |
| 10376 func_warning "'-release' is ignored for objects" | |
| 10377 | |
| 10378 case $output in | |
| 10379 *.lo) | |
| 10380 test -n "$objs$old_deplibs" && \ | |
| 10381 func_fatal_error "cannot build library object '$output' from non-libtool objects" | |
| 10382 | |
| 10383 libobj=$output | |
| 10384 func_lo2o "$libobj" | |
| 10385 obj=$func_lo2o_result | |
| 10386 ;; | |
| 10387 *) | |
| 10388 libobj= | |
| 10389 obj=$output | |
| 10390 ;; | |
| 10391 esac | |
| 10392 | |
| 10393 # Delete the old objects. | |
| 10394 $opt_dry_run || $RM $obj $libobj | |
| 10395 | |
| 10396 # Objects from convenience libraries. This assumes | |
| 10397 # single-version convenience libraries. Whenever we create | |
| 10398 # different ones for PIC/non-PIC, this we'll have to duplicate | |
| 10399 # the extraction. | |
| 10400 reload_conv_objs= | |
| 10401 gentop= | |
| 10402 # if reload_cmds runs $LD directly, get rid of -Wl from | |
| 10403 # whole_archive_flag_spec and hope we can get by with turning comma | |
| 10404 # into space. | |
| 10405 case $reload_cmds in | |
| 10406 *\$LD[\ \$]*) wl= ;; | |
| 10407 esac | |
| 10408 if test -n "$convenience"; then | |
| 10409 if test -n "$whole_archive_flag_spec"; then | |
| 10410 eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" | |
| 10411 test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` | |
| 10412 reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags | |
| 10413 else | |
| 10414 gentop=$output_objdir/${obj}x | |
| 10415 func_append generated " $gentop" | |
| 10416 | |
| 10417 func_extract_archives $gentop $convenience | |
| 10418 reload_conv_objs="$reload_objs $func_extract_archives_result" | |
| 10419 fi | |
| 10420 fi | |
| 10421 | |
| 10422 # If we're not building shared, we need to use non_pic_objs | |
| 10423 test yes = "$build_libtool_libs" || libobjs=$non_pic_objects | |
| 10424 | |
| 10425 # Create the old-style object. | |
| 10426 reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs | |
| 10427 | |
| 10428 output=$obj | |
| 10429 func_execute_cmds "$reload_cmds" 'exit $?' | |
| 10430 | |
| 10431 # Exit if we aren't doing a library object file. | |
| 10432 if test -z "$libobj"; then | |
| 10433 if test -n "$gentop"; then | |
| 10434 func_show_eval '${RM}r "$gentop"' | |
| 10435 fi | |
| 10436 | |
| 10437 exit $EXIT_SUCCESS | |
| 10438 fi | |
| 10439 | |
| 10440 test yes = "$build_libtool_libs" || { | |
| 10441 if test -n "$gentop"; then | |
| 10442 func_show_eval '${RM}r "$gentop"' | |
| 10443 fi | |
| 10444 | |
| 10445 # Create an invalid libtool object if no PIC, so that we don't | |
| 10446 # accidentally link it into a program. | |
| 10447 # $show "echo timestamp > $libobj" | |
| 10448 # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? | |
| 10449 exit $EXIT_SUCCESS | |
| 10450 } | |
| 10451 | |
| 10452 if test -n "$pic_flag" || test default != "$pic_mode"; then | |
| 10453 # Only do commands if we really have different PIC objects. | |
| 10454 reload_objs="$libobjs $reload_conv_objs" | |
| 10455 output=$libobj | |
| 10456 func_execute_cmds "$reload_cmds" 'exit $?' | |
| 10457 fi | |
| 10458 | |
| 10459 if test -n "$gentop"; then | |
| 10460 func_show_eval '${RM}r "$gentop"' | |
| 10461 fi | |
| 10462 | |
| 10463 exit $EXIT_SUCCESS | |
| 10464 ;; | |
| 10465 | |
| 10466 prog) | |
| 10467 case $host in | |
| 10468 *cygwin*) func_stripname '' '.exe' "$output" | |
| 10469 output=$func_stripname_result.exe;; | |
| 10470 esac | |
| 10471 test -n "$vinfo" && \ | |
| 10472 func_warning "'-version-info' is ignored for programs" | |
| 10473 | |
| 10474 test -n "$release" && \ | |
| 10475 func_warning "'-release' is ignored for programs" | |
| 10476 | |
| 10477 $preload \ | |
| 10478 && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ | |
| 10479 && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." | |
| 10480 | |
| 10481 case $host in | |
| 10482 *-*-rhapsody* | *-*-darwin1.[012]) | |
| 10483 # On Rhapsody replace the C library is the System framework | |
| 10484 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` | |
| 10485 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` | |
| 10486 ;; | |
| 10487 esac | |
| 10488 | |
| 10489 case $host in | |
| 10490 *-*-darwin*) | |
| 10491 # Don't allow lazy linking, it breaks C++ global constructors | |
| 10492 # But is supposedly fixed on 10.4 or later (yay!). | |
| 10493 if test CXX = "$tagname"; then | |
| 10494 case ${MACOSX_DEPLOYMENT_TARGET-10.0} in | |
| 10495 10.[0123]) | |
| 10496 func_append compile_command " $wl-bind_at_load" | |
| 10497 func_append finalize_command " $wl-bind_at_load" | |
| 10498 ;; | |
| 10499 esac | |
| 10500 fi | |
| 10501 # Time to change all our "foo.ltframework" stuff back to "-framework foo" | |
| 10502 compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` | |
| 10503 finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` | |
| 10504 ;; | |
| 10505 esac | |
| 10506 | |
| 10507 | |
| 10508 # move library search paths that coincide with paths to not yet | |
| 10509 # installed libraries to the beginning of the library search list | |
| 10510 new_libs= | |
| 10511 for path in $notinst_path; do | |
| 10512 case " $new_libs " in | |
| 10513 *" -L$path/$objdir "*) ;; | |
| 10514 *) | |
| 10515 case " $compile_deplibs " in | |
| 10516 *" -L$path/$objdir "*) | |
| 10517 func_append new_libs " -L$path/$objdir" ;; | |
| 10518 esac | |
| 10519 ;; | |
| 10520 esac | |
| 10521 done | |
| 10522 for deplib in $compile_deplibs; do | |
| 10523 case $deplib in | |
| 10524 -L*) | |
| 10525 case " $new_libs " in | |
| 10526 *" $deplib "*) ;; | |
| 10527 *) func_append new_libs " $deplib" ;; | |
| 10528 esac | |
| 10529 ;; | |
| 10530 *) func_append new_libs " $deplib" ;; | |
| 10531 esac | |
| 10532 done | |
| 10533 compile_deplibs=$new_libs | |
| 10534 | |
| 10535 | |
| 10536 func_append compile_command " $compile_deplibs" | |
| 10537 func_append finalize_command " $finalize_deplibs" | |
| 10538 | |
| 10539 if test -n "$rpath$xrpath"; then | |
| 10540 # If the user specified any rpath flags, then add them. | |
| 10541 for libdir in $rpath $xrpath; do | |
| 10542 # This is the magic to use -rpath. | |
| 10543 case "$finalize_rpath " in | |
| 10544 *" $libdir "*) ;; | |
| 10545 *) func_append finalize_rpath " $libdir" ;; | |
| 10546 esac | |
| 10547 done | |
| 10548 fi | |
| 10549 | |
| 10550 # Now hardcode the library paths | |
| 10551 rpath= | |
| 10552 hardcode_libdirs= | |
| 10553 for libdir in $compile_rpath $finalize_rpath; do | |
| 10554 if test -n "$hardcode_libdir_flag_spec"; then | |
| 10555 if test -n "$hardcode_libdir_separator"; then | |
| 10556 if test -z "$hardcode_libdirs"; then | |
| 10557 hardcode_libdirs=$libdir | |
| 10558 else | |
| 10559 # Just accumulate the unique libdirs. | |
| 10560 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in | |
| 10561 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) | |
| 10562 ;; | |
| 10563 *) | |
| 10564 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" | |
| 10565 ;; | |
| 10566 esac | |
| 10567 fi | |
| 10568 else | |
| 10569 eval flag=\"$hardcode_libdir_flag_spec\" | |
| 10570 func_append rpath " $flag" | |
| 10571 fi | |
| 10572 elif test -n "$runpath_var"; then | |
| 10573 case "$perm_rpath " in | |
| 10574 *" $libdir "*) ;; | |
| 10575 *) func_append perm_rpath " $libdir" ;; | |
| 10576 esac | |
| 10577 fi | |
| 10578 case $host in | |
| 10579 *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) | |
| 10580 testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` | |
| 10581 case :$dllsearchpath: in | |
| 10582 *":$libdir:"*) ;; | |
| 10583 ::) dllsearchpath=$libdir;; | |
| 10584 *) func_append dllsearchpath ":$libdir";; | |
| 10585 esac | |
| 10586 case :$dllsearchpath: in | |
| 10587 *":$testbindir:"*) ;; | |
| 10588 ::) dllsearchpath=$testbindir;; | |
| 10589 *) func_append dllsearchpath ":$testbindir";; | |
| 10590 esac | |
| 10591 ;; | |
| 10592 esac | |
| 10593 done | |
| 10594 # Substitute the hardcoded libdirs into the rpath. | |
| 10595 if test -n "$hardcode_libdir_separator" && | |
| 10596 test -n "$hardcode_libdirs"; then | |
| 10597 libdir=$hardcode_libdirs | |
| 10598 eval rpath=\" $hardcode_libdir_flag_spec\" | |
| 10599 fi | |
| 10600 compile_rpath=$rpath | |
| 10601 | |
| 10602 rpath= | |
| 10603 hardcode_libdirs= | |
| 10604 for libdir in $finalize_rpath; do | |
| 10605 if test -n "$hardcode_libdir_flag_spec"; then | |
| 10606 if test -n "$hardcode_libdir_separator"; then | |
| 10607 if test -z "$hardcode_libdirs"; then | |
| 10608 hardcode_libdirs=$libdir | |
| 10609 else | |
| 10610 # Just accumulate the unique libdirs. | |
| 10611 case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in | |
| 10612 *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) | |
| 10613 ;; | |
| 10614 *) | |
| 10615 func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" | |
| 10616 ;; | |
| 10617 esac | |
| 10618 fi | |
| 10619 else | |
| 10620 eval flag=\"$hardcode_libdir_flag_spec\" | |
| 10621 func_append rpath " $flag" | |
| 10622 fi | |
| 10623 elif test -n "$runpath_var"; then | |
| 10624 case "$finalize_perm_rpath " in | |
| 10625 *" $libdir "*) ;; | |
| 10626 *) func_append finalize_perm_rpath " $libdir" ;; | |
| 10627 esac | |
| 10628 fi | |
| 10629 done | |
| 10630 # Substitute the hardcoded libdirs into the rpath. | |
| 10631 if test -n "$hardcode_libdir_separator" && | |
| 10632 test -n "$hardcode_libdirs"; then | |
| 10633 libdir=$hardcode_libdirs | |
| 10634 eval rpath=\" $hardcode_libdir_flag_spec\" | |
| 10635 fi | |
| 10636 finalize_rpath=$rpath | |
| 10637 | |
| 10638 if test -n "$libobjs" && test yes = "$build_old_libs"; then | |
| 10639 # Transform all the library objects into standard objects. | |
| 10640 compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` | |
| 10641 finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` | |
| 10642 fi | |
| 10643 | |
| 10644 func_generate_dlsyms "$outputname" "@PROGRAM@" false | |
| 10645 | |
| 10646 # template prelinking step | |
| 10647 if test -n "$prelink_cmds"; then | |
| 10648 func_execute_cmds "$prelink_cmds" 'exit $?' | |
| 10649 fi | |
| 10650 | |
| 10651 wrappers_required=: | |
| 10652 case $host in | |
| 10653 *cegcc* | *mingw32ce*) | |
| 10654 # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. | |
| 10655 wrappers_required=false | |
| 10656 ;; | |
| 10657 *cygwin* | *mingw* ) | |
| 10658 test yes = "$build_libtool_libs" || wrappers_required=false | |
| 10659 ;; | |
| 10660 *) | |
| 10661 if test no = "$need_relink" || test yes != "$build_libtool_libs"; then | |
| 10662 wrappers_required=false | |
| 10663 fi | |
| 10664 ;; | |
| 10665 esac | |
| 10666 $wrappers_required || { | |
| 10667 # Replace the output file specification. | |
| 10668 compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` | |
| 10669 link_command=$compile_command$compile_rpath | |
| 10670 | |
| 10671 # We have no uninstalled library dependencies, so finalize right now. | |
| 10672 exit_status=0 | |
| 10673 func_show_eval "$link_command" 'exit_status=$?' | |
| 10674 | |
| 10675 if test -n "$postlink_cmds"; then | |
| 10676 func_to_tool_file "$output" | |
| 10677 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` | |
| 10678 func_execute_cmds "$postlink_cmds" 'exit $?' | |
| 10679 fi | |
| 10680 | |
| 10681 # Delete the generated files. | |
| 10682 if test -f "$output_objdir/${outputname}S.$objext"; then | |
| 10683 func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' | |
| 10684 fi | |
| 10685 | |
| 10686 exit $exit_status | |
| 10687 } | |
| 10688 | |
| 10689 if test -n "$compile_shlibpath$finalize_shlibpath"; then | |
| 10690 compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" | |
| 10691 fi | |
| 10692 if test -n "$finalize_shlibpath"; then | |
| 10693 finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" | |
| 10694 fi | |
| 10695 | |
| 10696 compile_var= | |
| 10697 finalize_var= | |
| 10698 if test -n "$runpath_var"; then | |
| 10699 if test -n "$perm_rpath"; then | |
| 10700 # We should set the runpath_var. | |
| 10701 rpath= | |
| 10702 for dir in $perm_rpath; do | |
| 10703 func_append rpath "$dir:" | |
| 10704 done | |
| 10705 compile_var="$runpath_var=\"$rpath\$$runpath_var\" " | |
| 10706 fi | |
| 10707 if test -n "$finalize_perm_rpath"; then | |
| 10708 # We should set the runpath_var. | |
| 10709 rpath= | |
| 10710 for dir in $finalize_perm_rpath; do | |
| 10711 func_append rpath "$dir:" | |
| 10712 done | |
| 10713 finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " | |
| 10714 fi | |
| 10715 fi | |
| 10716 | |
| 10717 if test yes = "$no_install"; then | |
| 10718 # We don't need to create a wrapper script. | |
| 10719 link_command=$compile_var$compile_command$compile_rpath | |
| 10720 # Replace the output file specification. | |
| 10721 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` | |
| 10722 # Delete the old output file. | |
| 10723 $opt_dry_run || $RM $output | |
| 10724 # Link the executable and exit | |
| 10725 func_show_eval "$link_command" 'exit $?' | |
| 10726 | |
| 10727 if test -n "$postlink_cmds"; then | |
| 10728 func_to_tool_file "$output" | |
| 10729 postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` | |
| 10730 func_execute_cmds "$postlink_cmds" 'exit $?' | |
| 10731 fi | |
| 10732 | |
| 10733 exit $EXIT_SUCCESS | |
| 10734 fi | |
| 10735 | |
| 10736 case $hardcode_action,$fast_install in | |
| 10737 relink,*) | |
| 10738 # Fast installation is not supported | |
| 10739 link_command=$compile_var$compile_command$compile_rpath | |
| 10740 relink_command=$finalize_var$finalize_command$finalize_rpath | |
| 10741 | |
| 10742 func_warning "this platform does not like uninstalled shared libraries" | |
| 10743 func_warning "'$output' will be relinked during installation" | |
| 10744 ;; | |
| 10745 *,yes) | |
| 10746 link_command=$finalize_var$compile_command$finalize_rpath | |
| 10747 relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` | |
| 10748 ;; | |
| 10749 *,no) | |
| 10750 link_command=$compile_var$compile_command$compile_rpath | |
| 10751 relink_command=$finalize_var$finalize_command$finalize_rpath | |
| 10752 ;; | |
| 10753 *,needless) | |
| 10754 link_command=$finalize_var$compile_command$finalize_rpath | |
| 10755 relink_command= | |
| 10756 ;; | |
| 10757 esac | |
| 10758 | |
| 10759 # Replace the output file specification. | |
| 10760 link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` | |
| 10761 | |
| 10762 # Delete the old output files. | |
| 10763 $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname | |
| 10764 | |
| 10765 func_show_eval "$link_command" 'exit $?' | |
| 10766 | |
| 10767 if test -n "$postlink_cmds"; then | |
| 10768 func_to_tool_file "$output_objdir/$outputname" | |
| 10769 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'` | |
| 10770 func_execute_cmds "$postlink_cmds" 'exit $?' | |
| 10771 fi | |
| 10772 | |
| 10773 # Now create the wrapper script. | |
| 10774 func_verbose "creating $output" | |
| 10775 | |
| 10776 # Quote the relink command for shipping. | |
| 10777 if test -n "$relink_command"; then | |
| 10778 # Preserve any variables that may affect compiler behavior | |
| 10779 for var in $variables_saved_for_relink; do | |
| 10780 if eval test -z \"\${$var+set}\"; then | |
| 10781 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" | |
| 10782 elif eval var_value=\$$var; test -z "$var_value"; then | |
| 10783 relink_command="$var=; export $var; $relink_command" | |
| 10784 else | |
| 10785 func_quote_arg pretty "$var_value" | |
| 10786 relink_command="$var=$func_quote_arg_result; export $var; $relink_command" | |
| 10787 fi | |
| 10788 done | |
| 10789 func_quote eval cd "`pwd`" | |
| 10790 func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" | |
| 10791 relink_command=$func_quote_arg_unquoted_result | |
| 10792 fi | |
| 10793 | |
| 10794 # Only actually do things if not in dry run mode. | |
| 10795 $opt_dry_run || { | |
| 10796 # win32 will think the script is a binary if it has | |
| 10797 # a .exe suffix, so we strip it off here. | |
| 10798 case $output in | |
| 10799 *.exe) func_stripname '' '.exe' "$output" | |
| 10800 output=$func_stripname_result ;; | |
| 10801 esac | |
| 10802 # test for cygwin because mv fails w/o .exe extensions | |
| 10803 case $host in | |
| 10804 *cygwin*) | |
| 10805 exeext=.exe | |
| 10806 func_stripname '' '.exe' "$outputname" | |
| 10807 outputname=$func_stripname_result ;; | |
| 10808 *) exeext= ;; | |
| 10809 esac | |
| 10810 case $host in | |
| 10811 *cygwin* | *mingw* ) | |
| 10812 func_dirname_and_basename "$output" "" "." | |
| 10813 output_name=$func_basename_result | |
| 10814 output_path=$func_dirname_result | |
| 10815 cwrappersource=$output_path/$objdir/lt-$output_name.c | |
| 10816 cwrapper=$output_path/$output_name.exe | |
| 10817 $RM $cwrappersource $cwrapper | |
| 10818 trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 | |
| 10819 | |
| 10820 func_emit_cwrapperexe_src > $cwrappersource | |
| 10821 | |
| 10822 # The wrapper executable is built using the $host compiler, | |
| 10823 # because it contains $host paths and files. If cross- | |
| 10824 # compiling, it, like the target executable, must be | |
| 10825 # executed on the $host or under an emulation environment. | |
| 10826 $opt_dry_run || { | |
| 10827 $LTCC $LTCFLAGS -o $cwrapper $cwrappersource | |
| 10828 $STRIP $cwrapper | |
| 10829 } | |
| 10830 | |
| 10831 # Now, create the wrapper script for func_source use: | |
| 10832 func_ltwrapper_scriptname $cwrapper | |
| 10833 $RM $func_ltwrapper_scriptname_result | |
| 10834 trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 | |
| 10835 $opt_dry_run || { | |
| 10836 # note: this script will not be executed, so do not chmod. | |
| 10837 if test "x$build" = "x$host"; then | |
| 10838 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result | |
| 10839 else | |
| 10840 func_emit_wrapper no > $func_ltwrapper_scriptname_result | |
| 10841 fi | |
| 10842 } | |
| 10843 ;; | |
| 10844 * ) | |
| 10845 $RM $output | |
| 10846 trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 | |
| 10847 | |
| 10848 func_emit_wrapper no > $output | |
| 10849 chmod +x $output | |
| 10850 ;; | |
| 10851 esac | |
| 10852 } | |
| 10853 exit $EXIT_SUCCESS | |
| 10854 ;; | |
| 10855 esac | |
| 10856 | |
| 10857 # See if we need to build an old-fashioned archive. | |
| 10858 for oldlib in $oldlibs; do | |
| 10859 | |
| 10860 case $build_libtool_libs in | |
| 10861 convenience) | |
| 10862 oldobjs="$libobjs_save $symfileobj" | |
| 10863 addlibs=$convenience | |
| 10864 build_libtool_libs=no | |
| 10865 ;; | |
| 10866 module) | |
| 10867 oldobjs=$libobjs_save | |
| 10868 addlibs=$old_convenience | |
| 10869 build_libtool_libs=no | |
| 10870 ;; | |
| 10871 *) | |
| 10872 oldobjs="$old_deplibs $non_pic_objects" | |
| 10873 $preload && test -f "$symfileobj" \ | |
| 10874 && func_append oldobjs " $symfileobj" | |
| 10875 addlibs=$old_convenience | |
| 10876 ;; | |
| 10877 esac | |
| 10878 | |
| 10879 if test -n "$addlibs"; then | |
| 10880 gentop=$output_objdir/${outputname}x | |
| 10881 func_append generated " $gentop" | |
| 10882 | |
| 10883 func_extract_archives $gentop $addlibs | |
| 10884 func_append oldobjs " $func_extract_archives_result" | |
| 10885 fi | |
| 10886 | |
| 10887 # Do each command in the archive commands. | |
| 10888 if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then | |
| 10889 cmds=$old_archive_from_new_cmds | |
| 10890 else | |
| 10891 | |
| 10892 # Add any objects from preloaded convenience libraries | |
| 10893 if test -n "$dlprefiles"; then | |
| 10894 gentop=$output_objdir/${outputname}x | |
| 10895 func_append generated " $gentop" | |
| 10896 | |
| 10897 func_extract_archives $gentop $dlprefiles | |
| 10898 func_append oldobjs " $func_extract_archives_result" | |
| 10899 fi | |
| 10900 | |
| 10901 # POSIX demands no paths to be encoded in archives. We have | |
| 10902 # to avoid creating archives with duplicate basenames if we | |
| 10903 # might have to extract them afterwards, e.g., when creating a | |
| 10904 # static archive out of a convenience library, or when linking | |
| 10905 # the entirety of a libtool archive into another (currently | |
| 10906 # not supported by libtool). | |
| 10907 if (for obj in $oldobjs | |
| 10908 do | |
| 10909 func_basename "$obj" | |
| 10910 $ECHO "$func_basename_result" | |
| 10911 done | sort | sort -uc >/dev/null 2>&1); then | |
| 10912 : | |
| 10913 else | |
| 10914 echo "copying selected object files to avoid basename conflicts..." | |
| 10915 gentop=$output_objdir/${outputname}x | |
| 10916 func_append generated " $gentop" | |
| 10917 func_mkdir_p "$gentop" | |
| 10918 save_oldobjs=$oldobjs | |
| 10919 oldobjs= | |
| 10920 counter=1 | |
| 10921 for obj in $save_oldobjs | |
| 10922 do | |
| 10923 func_basename "$obj" | |
| 10924 objbase=$func_basename_result | |
| 10925 case " $oldobjs " in | |
| 10926 " ") oldobjs=$obj ;; | |
| 10927 *[\ /]"$objbase "*) | |
| 10928 while :; do | |
| 10929 # Make sure we don't pick an alternate name that also | |
| 10930 # overlaps. | |
| 10931 newobj=lt$counter-$objbase | |
| 10932 func_arith $counter + 1 | |
| 10933 counter=$func_arith_result | |
| 10934 case " $oldobjs " in | |
| 10935 *[\ /]"$newobj "*) ;; | |
| 10936 *) if test ! -f "$gentop/$newobj"; then break; fi ;; | |
| 10937 esac | |
| 10938 done | |
| 10939 func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" | |
| 10940 func_append oldobjs " $gentop/$newobj" | |
| 10941 ;; | |
| 10942 *) func_append oldobjs " $obj" ;; | |
| 10943 esac | |
| 10944 done | |
| 10945 fi | |
| 10946 func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 | |
| 10947 tool_oldlib=$func_to_tool_file_result | |
| 10948 eval cmds=\"$old_archive_cmds\" | |
| 10949 | |
| 10950 func_len " $cmds" | |
| 10951 len=$func_len_result | |
| 10952 if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then | |
| 10953 cmds=$old_archive_cmds | |
| 10954 elif test -n "$archiver_list_spec"; then | |
| 10955 func_verbose "using command file archive linking..." | |
| 10956 for obj in $oldobjs | |
| 10957 do | |
| 10958 func_to_tool_file "$obj" | |
| 10959 $ECHO "$func_to_tool_file_result" | |
| 10960 done > $output_objdir/$libname.libcmd | |
| 10961 func_to_tool_file "$output_objdir/$libname.libcmd" | |
| 10962 oldobjs=" $archiver_list_spec$func_to_tool_file_result" | |
| 10963 cmds=$old_archive_cmds | |
| 10964 else | |
| 10965 # the command line is too long to link in one step, link in parts | |
| 10966 func_verbose "using piecewise archive linking..." | |
| 10967 save_RANLIB=$RANLIB | |
| 10968 RANLIB=: | |
| 10969 objlist= | |
| 10970 concat_cmds= | |
| 10971 save_oldobjs=$oldobjs | |
| 10972 oldobjs= | |
| 10973 # Is there a better way of finding the last object in the list? | |
| 10974 for obj in $save_oldobjs | |
| 10975 do | |
| 10976 last_oldobj=$obj | |
| 10977 done | |
| 10978 eval test_cmds=\"$old_archive_cmds\" | |
| 10979 func_len " $test_cmds" | |
| 10980 len0=$func_len_result | |
| 10981 len=$len0 | |
| 10982 for obj in $save_oldobjs | |
| 10983 do | |
| 10984 func_len " $obj" | |
| 10985 func_arith $len + $func_len_result | |
| 10986 len=$func_arith_result | |
| 10987 func_append objlist " $obj" | |
| 10988 if test "$len" -lt "$max_cmd_len"; then | |
| 10989 : | |
| 10990 else | |
| 10991 # the above command should be used before it gets too long | |
| 10992 oldobjs=$objlist | |
| 10993 if test "$obj" = "$last_oldobj"; then | |
| 10994 RANLIB=$save_RANLIB | |
| 10995 fi | |
| 10996 test -z "$concat_cmds" || concat_cmds=$concat_cmds~ | |
| 10997 eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" | |
| 10998 objlist= | |
| 10999 len=$len0 | |
| 11000 fi | |
| 11001 done | |
| 11002 RANLIB=$save_RANLIB | |
| 11003 oldobjs=$objlist | |
| 11004 if test -z "$oldobjs"; then | |
| 11005 eval cmds=\"\$concat_cmds\" | |
| 11006 else | |
| 11007 eval cmds=\"\$concat_cmds~\$old_archive_cmds\" | |
| 11008 fi | |
| 11009 fi | |
| 11010 fi | |
| 11011 func_execute_cmds "$cmds" 'exit $?' | |
| 11012 done | |
| 11013 | |
| 11014 test -n "$generated" && \ | |
| 11015 func_show_eval "${RM}r$generated" | |
| 11016 | |
| 11017 # Now create the libtool archive. | |
| 11018 case $output in | |
| 11019 *.la) | |
| 11020 old_library= | |
| 11021 test yes = "$build_old_libs" && old_library=$libname.$libext | |
| 11022 func_verbose "creating $output" | |
| 11023 | |
| 11024 # Preserve any variables that may affect compiler behavior | |
| 11025 for var in $variables_saved_for_relink; do | |
| 11026 if eval test -z \"\${$var+set}\"; then | |
| 11027 relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" | |
| 11028 elif eval var_value=\$$var; test -z "$var_value"; then | |
| 11029 relink_command="$var=; export $var; $relink_command" | |
| 11030 else | |
| 11031 func_quote_arg pretty,unquoted "$var_value" | |
| 11032 relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" | |
| 11033 fi | |
| 11034 done | |
| 11035 # Quote the link command for shipping. | |
| 11036 func_quote eval cd "`pwd`" | |
| 11037 relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" | |
| 11038 func_quote_arg pretty,unquoted "$relink_command" | |
| 11039 relink_command=$func_quote_arg_unquoted_result | |
| 11040 if test yes = "$hardcode_automatic"; then | |
| 11041 relink_command= | |
| 11042 fi | |
| 11043 | |
| 11044 # Only create the output if not a dry run. | |
| 11045 $opt_dry_run || { | |
| 11046 for installed in no yes; do | |
| 11047 if test yes = "$installed"; then | |
| 11048 if test -z "$install_libdir"; then | |
| 11049 break | |
| 11050 fi | |
| 11051 output=$output_objdir/${outputname}i | |
| 11052 # Replace all uninstalled libtool libraries with the installed ones | |
| 11053 newdependency_libs= | |
| 11054 for deplib in $dependency_libs; do | |
| 11055 case $deplib in | |
| 11056 *.la) | |
| 11057 func_basename "$deplib" | |
| 11058 name=$func_basename_result | |
| 11059 func_resolve_sysroot "$deplib" | |
| 11060 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` | |
| 11061 test -z "$libdir" && \ | |
| 11062 func_fatal_error "'$deplib' is not a valid libtool archive" | |
| 11063 func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" | |
| 11064 ;; | |
| 11065 -L*) | |
| 11066 func_stripname -L '' "$deplib" | |
| 11067 func_replace_sysroot "$func_stripname_result" | |
| 11068 func_append newdependency_libs " -L$func_replace_sysroot_result" | |
| 11069 ;; | |
| 11070 -R*) | |
| 11071 func_stripname -R '' "$deplib" | |
| 11072 func_replace_sysroot "$func_stripname_result" | |
| 11073 func_append newdependency_libs " -R$func_replace_sysroot_result" | |
| 11074 ;; | |
| 11075 *) func_append newdependency_libs " $deplib" ;; | |
| 11076 esac | |
| 11077 done | |
| 11078 dependency_libs=$newdependency_libs | |
| 11079 newdlfiles= | |
| 11080 | |
| 11081 for lib in $dlfiles; do | |
| 11082 case $lib in | |
| 11083 *.la) | |
| 11084 func_basename "$lib" | |
| 11085 name=$func_basename_result | |
| 11086 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` | |
| 11087 test -z "$libdir" && \ | |
| 11088 func_fatal_error "'$lib' is not a valid libtool archive" | |
| 11089 func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" | |
| 11090 ;; | |
| 11091 *) func_append newdlfiles " $lib" ;; | |
| 11092 esac | |
| 11093 done | |
| 11094 dlfiles=$newdlfiles | |
| 11095 newdlprefiles= | |
| 11096 for lib in $dlprefiles; do | |
| 11097 case $lib in | |
| 11098 *.la) | |
| 11099 # Only pass preopened files to the pseudo-archive (for | |
| 11100 # eventual linking with the app. that links it) if we | |
| 11101 # didn't already link the preopened objects directly into | |
| 11102 # the library: | |
| 11103 func_basename "$lib" | |
| 11104 name=$func_basename_result | |
| 11105 eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` | |
| 11106 test -z "$libdir" && \ | |
| 11107 func_fatal_error "'$lib' is not a valid libtool archive" | |
| 11108 func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" | |
| 11109 ;; | |
| 11110 esac | |
| 11111 done | |
| 11112 dlprefiles=$newdlprefiles | |
| 11113 else | |
| 11114 newdlfiles= | |
| 11115 for lib in $dlfiles; do | |
| 11116 case $lib in | |
| 11117 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; | |
| 11118 *) abs=`pwd`"/$lib" ;; | |
| 11119 esac | |
| 11120 func_append newdlfiles " $abs" | |
| 11121 done | |
| 11122 dlfiles=$newdlfiles | |
| 11123 newdlprefiles= | |
| 11124 for lib in $dlprefiles; do | |
| 11125 case $lib in | |
| 11126 [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; | |
| 11127 *) abs=`pwd`"/$lib" ;; | |
| 11128 esac | |
| 11129 func_append newdlprefiles " $abs" | |
| 11130 done | |
| 11131 dlprefiles=$newdlprefiles | |
| 11132 fi | |
| 11133 $RM $output | |
| 11134 # place dlname in correct position for cygwin | |
| 11135 # In fact, it would be nice if we could use this code for all target | |
| 11136 # systems that can't hard-code library paths into their executables | |
| 11137 # and that have no shared library path variable independent of PATH, | |
| 11138 # but it turns out we can't easily determine that from inspecting | |
| 11139 # libtool variables, so we have to hard-code the OSs to which it | |
| 11140 # applies here; at the moment, that means platforms that use the PE | |
| 11141 # object format with DLL files. See the long comment at the top of | |
| 11142 # tests/bindir.at for full details. | |
| 11143 tdlname=$dlname | |
| 11144 case $host,$output,$installed,$module,$dlname in | |
| 11145 *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) | |
| 11146 # If a -bindir argument was supplied, place the dll there. | |
| 11147 if test -n "$bindir"; then | |
| 11148 func_relative_path "$install_libdir" "$bindir" | |
| 11149 tdlname=$func_relative_path_result/$dlname | |
| 11150 else | |
| 11151 # Otherwise fall back on heuristic. | |
| 11152 tdlname=../bin/$dlname | |
| 11153 fi | |
| 11154 ;; | |
| 11155 esac | |
| 11156 $ECHO > $output "\ | |
| 11157 # $outputname - a libtool library file | |
| 11158 # Generated by $PROGRAM (GNU $PACKAGE) $VERSION | |
| 11159 # | |
| 11160 # Please DO NOT delete this file! | |
| 11161 # It is necessary for linking the library. | |
| 11162 | |
| 11163 # The name that we can dlopen(3). | |
| 11164 dlname='$tdlname' | |
| 11165 | |
| 11166 # Names of this library. | |
| 11167 library_names='$library_names' | |
| 11168 | |
| 11169 # The name of the static archive. | |
| 11170 old_library='$old_library' | |
| 11171 | |
| 11172 # Linker flags that cannot go in dependency_libs. | |
| 11173 inherited_linker_flags='$new_inherited_linker_flags' | |
| 11174 | |
| 11175 # Libraries that this one depends upon. | |
| 11176 dependency_libs='$dependency_libs' | |
| 11177 | |
| 11178 # Names of additional weak libraries provided by this library | |
| 11179 weak_library_names='$weak_libs' | |
| 11180 | |
| 11181 # Version information for $libname. | |
| 11182 current=$current | |
| 11183 age=$age | |
| 11184 revision=$revision | |
| 11185 | |
| 11186 # Is this an already installed library? | |
| 11187 installed=$installed | |
| 11188 | |
| 11189 # Should we warn about portability when linking against -modules? | |
| 11190 shouldnotlink=$module | |
| 11191 | |
| 11192 # Files to dlopen/dlpreopen | |
| 11193 dlopen='$dlfiles' | |
| 11194 dlpreopen='$dlprefiles' | |
| 11195 | |
| 11196 # Directory that this library needs to be installed in: | |
| 11197 libdir='$install_libdir'" | |
| 11198 if test no,yes = "$installed,$need_relink"; then | |
| 11199 $ECHO >> $output "\ | |
| 11200 relink_command=\"$relink_command\"" | |
| 11201 fi | |
| 11202 done | |
| 11203 } | |
| 11204 | |
| 11205 # Do a symbolic link so that the libtool archive can be found in | |
| 11206 # LD_LIBRARY_PATH before the program is installed. | |
| 11207 func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' | |
| 11208 ;; | |
| 11209 esac | |
| 11210 exit $EXIT_SUCCESS | |
| 11211 } | |
| 11212 | |
| 11213 if test link = "$opt_mode" || test relink = "$opt_mode"; then | |
| 11214 func_mode_link ${1+"$@"} | |
| 11215 fi | |
| 11216 | |
| 11217 | |
| 11218 # func_mode_uninstall arg... | |
| 11219 func_mode_uninstall () | |
| 11220 { | |
| 11221 $debug_cmd | |
| 11222 | |
| 11223 RM=$nonopt | |
| 11224 files= | |
| 11225 rmforce=false | |
| 11226 exit_status=0 | |
| 11227 | |
| 11228 # This variable tells wrapper scripts just to set variables rather | |
| 11229 # than running their programs. | |
| 11230 libtool_install_magic=$magic | |
| 11231 | |
| 11232 for arg | |
| 11233 do | |
| 11234 case $arg in | |
| 11235 -f) func_append RM " $arg"; rmforce=: ;; | |
| 11236 -*) func_append RM " $arg" ;; | |
| 11237 *) func_append files " $arg" ;; | |
| 11238 esac | |
| 11239 done | |
| 11240 | |
| 11241 test -z "$RM" && \ | |
| 11242 func_fatal_help "you must specify an RM program" | |
| 11243 | |
| 11244 rmdirs= | |
| 11245 | |
| 11246 for file in $files; do | |
| 11247 func_dirname "$file" "" "." | |
| 11248 dir=$func_dirname_result | |
| 11249 if test . = "$dir"; then | |
| 11250 odir=$objdir | |
| 11251 else | |
| 11252 odir=$dir/$objdir | |
| 11253 fi | |
| 11254 func_basename "$file" | |
| 11255 name=$func_basename_result | |
| 11256 test uninstall = "$opt_mode" && odir=$dir | |
| 11257 | |
| 11258 # Remember odir for removal later, being careful to avoid duplicates | |
| 11259 if test clean = "$opt_mode"; then | |
| 11260 case " $rmdirs " in | |
| 11261 *" $odir "*) ;; | |
| 11262 *) func_append rmdirs " $odir" ;; | |
| 11263 esac | |
| 11264 fi | |
| 11265 | |
| 11266 # Don't error if the file doesn't exist and rm -f was used. | |
| 11267 if { test -L "$file"; } >/dev/null 2>&1 || | |
| 11268 { test -h "$file"; } >/dev/null 2>&1 || | |
| 11269 test -f "$file"; then | |
| 11270 : | |
| 11271 elif test -d "$file"; then | |
| 11272 exit_status=1 | |
| 11273 continue | |
| 11274 elif $rmforce; then | |
| 11275 continue | |
| 11276 fi | |
| 11277 | |
| 11278 rmfiles=$file | |
| 11279 | |
| 11280 case $name in | |
| 11281 *.la) | |
| 11282 # Possibly a libtool archive, so verify it. | |
| 11283 if func_lalib_p "$file"; then | |
| 11284 func_source $dir/$name | |
| 11285 | |
| 11286 # Delete the libtool libraries and symlinks. | |
| 11287 for n in $library_names; do | |
| 11288 func_append rmfiles " $odir/$n" | |
| 11289 done | |
| 11290 test -n "$old_library" && func_append rmfiles " $odir/$old_library" | |
| 11291 | |
| 11292 case $opt_mode in | |
| 11293 clean) | |
| 11294 case " $library_names " in | |
| 11295 *" $dlname "*) ;; | |
| 11296 *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; | |
| 11297 esac | |
| 11298 test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" | |
| 11299 ;; | |
| 11300 uninstall) | |
| 11301 if test -n "$library_names"; then | |
| 11302 # Do each command in the postuninstall commands. | |
| 11303 func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' | |
| 11304 fi | |
| 11305 | |
| 11306 if test -n "$old_library"; then | |
| 11307 # Do each command in the old_postuninstall commands. | |
| 11308 func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' | |
| 11309 fi | |
| 11310 # FIXME: should reinstall the best remaining shared library. | |
| 11311 ;; | |
| 11312 esac | |
| 11313 fi | |
| 11314 ;; | |
| 11315 | |
| 11316 *.lo) | |
| 11317 # Possibly a libtool object, so verify it. | |
| 11318 if func_lalib_p "$file"; then | |
| 11319 | |
| 11320 # Read the .lo file | |
| 11321 func_source $dir/$name | |
| 11322 | |
| 11323 # Add PIC object to the list of files to remove. | |
| 11324 if test -n "$pic_object" && test none != "$pic_object"; then | |
| 11325 func_append rmfiles " $dir/$pic_object" | |
| 11326 fi | |
| 11327 | |
| 11328 # Add non-PIC object to the list of files to remove. | |
| 11329 if test -n "$non_pic_object" && test none != "$non_pic_object"; then | |
| 11330 func_append rmfiles " $dir/$non_pic_object" | |
| 11331 fi | |
| 11332 fi | |
| 11333 ;; | |
| 11334 | |
| 11335 *) | |
| 11336 if test clean = "$opt_mode"; then | |
| 11337 noexename=$name | |
| 11338 case $file in | |
| 11339 *.exe) | |
| 11340 func_stripname '' '.exe' "$file" | |
| 11341 file=$func_stripname_result | |
| 11342 func_stripname '' '.exe' "$name" | |
| 11343 noexename=$func_stripname_result | |
| 11344 # $file with .exe has already been added to rmfiles, | |
| 11345 # add $file without .exe | |
| 11346 func_append rmfiles " $file" | |
| 11347 ;; | |
| 11348 esac | |
| 11349 # Do a test to see if this is a libtool program. | |
| 11350 if func_ltwrapper_p "$file"; then | |
| 11351 if func_ltwrapper_executable_p "$file"; then | |
| 11352 func_ltwrapper_scriptname "$file" | |
| 11353 relink_command= | |
| 11354 func_source $func_ltwrapper_scriptname_result | |
| 11355 func_append rmfiles " $func_ltwrapper_scriptname_result" | |
| 11356 else | |
| 11357 relink_command= | |
| 11358 func_source $dir/$noexename | |
| 11359 fi | |
| 11360 | |
| 11361 # note $name still contains .exe if it was in $file originally | |
| 11362 # as does the version of $file that was added into $rmfiles | |
| 11363 func_append rmfiles " $odir/$name $odir/${name}S.$objext" | |
| 11364 if test yes = "$fast_install" && test -n "$relink_command"; then | |
| 11365 func_append rmfiles " $odir/lt-$name" | |
| 11366 fi | |
| 11367 if test "X$noexename" != "X$name"; then | |
| 11368 func_append rmfiles " $odir/lt-$noexename.c" | |
| 11369 fi | |
| 11370 fi | |
| 11371 fi | |
| 11372 ;; | |
| 11373 esac | |
| 11374 func_show_eval "$RM $rmfiles" 'exit_status=1' | |
| 11375 done | |
| 11376 | |
| 11377 # Try to remove the $objdir's in the directories where we deleted files | |
| 11378 for dir in $rmdirs; do | |
| 11379 if test -d "$dir"; then | |
| 11380 func_show_eval "rmdir $dir >/dev/null 2>&1" | |
| 11381 fi | |
| 11382 done | |
| 11383 | |
| 11384 exit $exit_status | |
| 11385 } | |
| 11386 | |
| 11387 if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then | |
| 11388 func_mode_uninstall ${1+"$@"} | |
| 11389 fi | |
| 11390 | |
| 11391 test -z "$opt_mode" && { | |
| 11392 help=$generic_help | |
| 11393 func_fatal_help "you must specify a MODE" | |
| 11394 } | |
| 11395 | |
| 11396 test -z "$exec_cmd" && \ | |
| 11397 func_fatal_help "invalid operation mode '$opt_mode'" | |
| 11398 | |
| 11399 if test -n "$exec_cmd"; then | |
| 11400 eval exec "$exec_cmd" | |
| 11401 exit $EXIT_FAILURE | |
| 11402 fi | |
| 11403 | |
| 11404 exit $exit_status | |
| 11405 | |
| 11406 | |
| 11407 # The TAGs below are defined such that we never get into a situation | |
| 11408 # where we disable both kinds of libraries. Given conflicting | |
| 11409 # choices, we go for a static library, that is the most portable, | |
| 11410 # since we can't tell whether shared libraries were disabled because | |
| 11411 # the user asked for that or because the platform doesn't support | |
| 11412 # them. This is particularly important on AIX, because we don't | |
| 11413 # support having both static and shared libraries enabled at the same | |
| 11414 # time on that platform, so we default to a shared-only configuration. | |
| 11415 # If a disable-shared tag is given, we'll fallback to a static-only | |
| 11416 # configuration. But we'll never go from static-only to shared-only. | |
| 11417 | |
| 11418 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared | |
| 11419 build_libtool_libs=no | |
| 11420 build_old_libs=yes | |
| 11421 # ### END LIBTOOL TAG CONFIG: disable-shared | |
| 11422 | |
| 11423 # ### BEGIN LIBTOOL TAG CONFIG: disable-static | |
| 11424 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` | |
| 11425 # ### END LIBTOOL TAG CONFIG: disable-static | |
| 11426 | |
| 11427 # Local Variables: | |
| 11428 # mode:shell-script | |
| 11429 # sh-indentation:2 | |
| 11430 # End: |
