1 1.1 mrg #!/bin/sh 2 1.1 mrg ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in 3 1.1.1.2 mrg ## by inline-source v2019-02-19.15 4 1.1 mrg 5 1.1.1.2 mrg # libtool (GNU libtool) 2.4.7 6 1.1 mrg # Provide generalized library-building support services. 7 1.1 mrg # Written by Gordon Matzigkeit <gord (at] gnu.ai.mit.edu>, 1996 8 1.1 mrg 9 1.1.1.2 mrg # Copyright (C) 1996-2019, 2021-2022 Free Software Foundation, Inc. 10 1.1 mrg # This is free software; see the source for copying conditions. There is NO 11 1.1 mrg # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 12 1.1 mrg 13 1.1 mrg # GNU Libtool is free software; you can redistribute it and/or modify 14 1.1 mrg # it under the terms of the GNU General Public License as published by 15 1.1 mrg # the Free Software Foundation; either version 2 of the License, or 16 1.1 mrg # (at your option) any later version. 17 1.1 mrg # 18 1.1 mrg # As a special exception to the GNU General Public License, 19 1.1 mrg # if you distribute this file as part of a program or library that 20 1.1 mrg # is built using GNU Libtool, you may include this file under the 21 1.1 mrg # same distribution terms that you use for the rest of that program. 22 1.1 mrg # 23 1.1 mrg # GNU Libtool is distributed in the hope that it will be useful, but 24 1.1 mrg # WITHOUT ANY WARRANTY; without even the implied warranty of 25 1.1 mrg # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 26 1.1 mrg # General Public License for more details. 27 1.1 mrg # 28 1.1 mrg # You should have received a copy of the GNU General Public License 29 1.1 mrg # along with this program. If not, see <http://www.gnu.org/licenses/>. 30 1.1 mrg 31 1.1 mrg 32 1.1 mrg PROGRAM=libtool 33 1.1 mrg PACKAGE=libtool 34 1.1.1.2 mrg VERSION=2.4.7 35 1.1.1.2 mrg package_revision=2.4.7 36 1.1 mrg 37 1.1 mrg 38 1.1 mrg ## ------ ## 39 1.1 mrg ## Usage. ## 40 1.1 mrg ## ------ ## 41 1.1 mrg 42 1.1 mrg # Run './libtool --help' for help with using this script from the 43 1.1 mrg # command line. 44 1.1 mrg 45 1.1 mrg 46 1.1 mrg ## ------------------------------- ## 47 1.1 mrg ## User overridable command paths. ## 48 1.1 mrg ## ------------------------------- ## 49 1.1 mrg 50 1.1 mrg # After configure completes, it has a better idea of some of the 51 1.1 mrg # shell tools we need than the defaults used by the functions shared 52 1.1 mrg # with bootstrap, so set those here where they can still be over- 53 1.1 mrg # ridden by the user, but otherwise take precedence. 54 1.1 mrg 55 1.1 mrg : ${AUTOCONF="autoconf"} 56 1.1 mrg : ${AUTOMAKE="automake"} 57 1.1 mrg 58 1.1 mrg 59 1.1 mrg ## -------------------------- ## 60 1.1 mrg ## Source external libraries. ## 61 1.1 mrg ## -------------------------- ## 62 1.1 mrg 63 1.1 mrg # Much of our low-level functionality needs to be sourced from external 64 1.1 mrg # libraries, which are installed to $pkgauxdir. 65 1.1 mrg 66 1.1 mrg # Set a version string for this script. 67 1.1.1.2 mrg scriptversion=2019-02-19.15; # UTC 68 1.1 mrg 69 1.1 mrg # General shell script boiler plate, and helper functions. 70 1.1 mrg # Written by Gary V. Vaughan, 2004 71 1.1 mrg 72 1.1.1.2 mrg # This is free software. There is NO warranty; not even for 73 1.1.1.2 mrg # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 74 1.1.1.2 mrg # 75 1.1.1.2 mrg # Copyright (C) 2004-2019, 2021 Bootstrap Authors 76 1.1.1.2 mrg # 77 1.1.1.2 mrg # This file is dual licensed under the terms of the MIT license 78 1.1.1.2 mrg # <https://opensource.org/license/MIT>, and GPL version 2 or later 79 1.1.1.2 mrg # <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 80 1.1.1.2 mrg # these licenses when using or redistributing this software or any of 81 1.1.1.2 mrg # the files within it. See the URLs above, or the file `LICENSE` 82 1.1.1.2 mrg # included in the Bootstrap distribution for the full license texts. 83 1.1 mrg 84 1.1.1.2 mrg # Please report bugs or propose patches to: 85 1.1.1.2 mrg # <https://github.com/gnulib-modules/bootstrap/issues> 86 1.1 mrg 87 1.1 mrg 88 1.1 mrg ## ------ ## 89 1.1 mrg ## Usage. ## 90 1.1 mrg ## ------ ## 91 1.1 mrg 92 1.1 mrg # Evaluate this file near the top of your script to gain access to 93 1.1 mrg # the functions and variables defined here: 94 1.1 mrg # 95 1.1 mrg # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh 96 1.1 mrg # 97 1.1 mrg # If you need to override any of the default environment variable 98 1.1 mrg # settings, do that before evaluating this file. 99 1.1 mrg 100 1.1 mrg 101 1.1 mrg ## -------------------- ## 102 1.1 mrg ## Shell normalisation. ## 103 1.1 mrg ## -------------------- ## 104 1.1 mrg 105 1.1 mrg # Some shells need a little help to be as Bourne compatible as possible. 106 1.1 mrg # Before doing anything else, make sure all that help has been provided! 107 1.1 mrg 108 1.1 mrg DUALCASE=1; export DUALCASE # for MKS sh 109 1.1 mrg if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then : 110 1.1 mrg emulate sh 111 1.1 mrg NULLCMD=: 112 1.1 mrg # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which 113 1.1 mrg # is contrary to our usage. Disable this feature. 114 1.1 mrg alias -g '${1+"$@"}'='"$@"' 115 1.1 mrg setopt NO_GLOB_SUBST 116 1.1 mrg else 117 1.1 mrg case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac 118 1.1 mrg fi 119 1.1 mrg 120 1.1 mrg # NLS nuisances: We save the old values in case they are required later. 121 1.1 mrg _G_user_locale= 122 1.1 mrg _G_safe_locale= 123 1.1 mrg for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 124 1.1 mrg do 125 1.1 mrg eval "if test set = \"\${$_G_var+set}\"; then 126 1.1 mrg save_$_G_var=\$$_G_var 127 1.1 mrg $_G_var=C 128 1.1 mrg export $_G_var 129 1.1 mrg _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\" 130 1.1 mrg _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\" 131 1.1 mrg fi" 132 1.1 mrg done 133 1.1.1.2 mrg # These NLS vars are set unconditionally (bootstrap issue #24). Unset those 134 1.1.1.2 mrg # in case the environment reset is needed later and the $save_* variant is not 135 1.1.1.2 mrg # defined (see the code above). 136 1.1.1.2 mrg LC_ALL=C 137 1.1.1.2 mrg LANGUAGE=C 138 1.1.1.2 mrg export LANGUAGE LC_ALL 139 1.1 mrg 140 1.1 mrg # Make sure IFS has a sensible default 141 1.1 mrg sp=' ' 142 1.1 mrg nl=' 143 1.1 mrg ' 144 1.1 mrg IFS="$sp $nl" 145 1.1 mrg 146 1.1 mrg # There are apparently some retarded systems that use ';' as a PATH separator! 147 1.1 mrg if test "${PATH_SEPARATOR+set}" != set; then 148 1.1 mrg PATH_SEPARATOR=: 149 1.1 mrg (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && { 150 1.1 mrg (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 || 151 1.1 mrg PATH_SEPARATOR=';' 152 1.1 mrg } 153 1.1 mrg fi 154 1.1 mrg 155 1.1 mrg 156 1.1.1.2 mrg # func_unset VAR 157 1.1.1.2 mrg # -------------- 158 1.1.1.2 mrg # Portably unset VAR. 159 1.1.1.2 mrg # In some shells, an 'unset VAR' statement leaves a non-zero return 160 1.1.1.2 mrg # status if VAR is already unset, which might be problematic if the 161 1.1.1.2 mrg # statement is used at the end of a function (thus poisoning its return 162 1.1.1.2 mrg # value) or when 'set -e' is active (causing even a spurious abort of 163 1.1.1.2 mrg # the script in this case). 164 1.1.1.2 mrg func_unset () 165 1.1.1.2 mrg { 166 1.1.1.2 mrg { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; } 167 1.1.1.2 mrg } 168 1.1.1.2 mrg 169 1.1.1.2 mrg 170 1.1.1.2 mrg # Make sure CDPATH doesn't cause `cd` commands to output the target dir. 171 1.1.1.2 mrg func_unset CDPATH 172 1.1.1.2 mrg 173 1.1.1.2 mrg # Make sure ${,E,F}GREP behave sanely. 174 1.1.1.2 mrg func_unset GREP_OPTIONS 175 1.1.1.2 mrg 176 1.1 mrg 177 1.1 mrg ## ------------------------- ## 178 1.1 mrg ## Locate command utilities. ## 179 1.1 mrg ## ------------------------- ## 180 1.1 mrg 181 1.1 mrg 182 1.1 mrg # func_executable_p FILE 183 1.1 mrg # ---------------------- 184 1.1 mrg # Check that FILE is an executable regular file. 185 1.1 mrg func_executable_p () 186 1.1 mrg { 187 1.1 mrg test -f "$1" && test -x "$1" 188 1.1 mrg } 189 1.1 mrg 190 1.1 mrg 191 1.1 mrg # func_path_progs PROGS_LIST CHECK_FUNC [PATH] 192 1.1 mrg # -------------------------------------------- 193 1.1 mrg # Search for either a program that responds to --version with output 194 1.1 mrg # containing "GNU", or else returned by CHECK_FUNC otherwise, by 195 1.1 mrg # trying all the directories in PATH with each of the elements of 196 1.1 mrg # PROGS_LIST. 197 1.1 mrg # 198 1.1 mrg # CHECK_FUNC should accept the path to a candidate program, and 199 1.1 mrg # set $func_check_prog_result if it truncates its output less than 200 1.1 mrg # $_G_path_prog_max characters. 201 1.1 mrg func_path_progs () 202 1.1 mrg { 203 1.1 mrg _G_progs_list=$1 204 1.1 mrg _G_check_func=$2 205 1.1 mrg _G_PATH=${3-"$PATH"} 206 1.1 mrg 207 1.1 mrg _G_path_prog_max=0 208 1.1 mrg _G_path_prog_found=false 209 1.1 mrg _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:} 210 1.1 mrg for _G_dir in $_G_PATH; do 211 1.1 mrg IFS=$_G_save_IFS 212 1.1 mrg test -z "$_G_dir" && _G_dir=. 213 1.1 mrg for _G_prog_name in $_G_progs_list; do 214 1.1 mrg for _exeext in '' .EXE; do 215 1.1 mrg _G_path_prog=$_G_dir/$_G_prog_name$_exeext 216 1.1 mrg func_executable_p "$_G_path_prog" || continue 217 1.1 mrg case `"$_G_path_prog" --version 2>&1` in 218 1.1 mrg *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;; 219 1.1 mrg *) $_G_check_func $_G_path_prog 220 1.1 mrg func_path_progs_result=$func_check_prog_result 221 1.1 mrg ;; 222 1.1 mrg esac 223 1.1 mrg $_G_path_prog_found && break 3 224 1.1 mrg done 225 1.1 mrg done 226 1.1 mrg done 227 1.1 mrg IFS=$_G_save_IFS 228 1.1 mrg test -z "$func_path_progs_result" && { 229 1.1 mrg echo "no acceptable sed could be found in \$PATH" >&2 230 1.1 mrg exit 1 231 1.1 mrg } 232 1.1 mrg } 233 1.1 mrg 234 1.1 mrg 235 1.1 mrg # We want to be able to use the functions in this file before configure 236 1.1 mrg # has figured out where the best binaries are kept, which means we have 237 1.1 mrg # to search for them ourselves - except when the results are already set 238 1.1 mrg # where we skip the searches. 239 1.1 mrg 240 1.1 mrg # Unless the user overrides by setting SED, search the path for either GNU 241 1.1 mrg # sed, or the sed that truncates its output the least. 242 1.1 mrg test -z "$SED" && { 243 1.1 mrg _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/ 244 1.1 mrg for _G_i in 1 2 3 4 5 6 7; do 245 1.1 mrg _G_sed_script=$_G_sed_script$nl$_G_sed_script 246 1.1 mrg done 247 1.1 mrg echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed 248 1.1 mrg _G_sed_script= 249 1.1 mrg 250 1.1 mrg func_check_prog_sed () 251 1.1 mrg { 252 1.1 mrg _G_path_prog=$1 253 1.1 mrg 254 1.1 mrg _G_count=0 255 1.1 mrg printf 0123456789 >conftest.in 256 1.1 mrg while : 257 1.1 mrg do 258 1.1 mrg cat conftest.in conftest.in >conftest.tmp 259 1.1 mrg mv conftest.tmp conftest.in 260 1.1 mrg cp conftest.in conftest.nl 261 1.1 mrg echo '' >> conftest.nl 262 1.1 mrg "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break 263 1.1 mrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 264 1.1 mrg _G_count=`expr $_G_count + 1` 265 1.1 mrg if test "$_G_count" -gt "$_G_path_prog_max"; then 266 1.1 mrg # Best one so far, save it but keep looking for a better one 267 1.1 mrg func_check_prog_result=$_G_path_prog 268 1.1 mrg _G_path_prog_max=$_G_count 269 1.1 mrg fi 270 1.1 mrg # 10*(2^10) chars as input seems more than enough 271 1.1 mrg test 10 -lt "$_G_count" && break 272 1.1 mrg done 273 1.1 mrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 274 1.1 mrg } 275 1.1 mrg 276 1.1.1.2 mrg func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin" 277 1.1 mrg rm -f conftest.sed 278 1.1 mrg SED=$func_path_progs_result 279 1.1 mrg } 280 1.1 mrg 281 1.1 mrg 282 1.1 mrg # Unless the user overrides by setting GREP, search the path for either GNU 283 1.1 mrg # grep, or the grep that truncates its output the least. 284 1.1 mrg test -z "$GREP" && { 285 1.1 mrg func_check_prog_grep () 286 1.1 mrg { 287 1.1 mrg _G_path_prog=$1 288 1.1 mrg 289 1.1 mrg _G_count=0 290 1.1 mrg _G_path_prog_max=0 291 1.1 mrg printf 0123456789 >conftest.in 292 1.1 mrg while : 293 1.1 mrg do 294 1.1 mrg cat conftest.in conftest.in >conftest.tmp 295 1.1 mrg mv conftest.tmp conftest.in 296 1.1 mrg cp conftest.in conftest.nl 297 1.1 mrg echo 'GREP' >> conftest.nl 298 1.1 mrg "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break 299 1.1 mrg diff conftest.out conftest.nl >/dev/null 2>&1 || break 300 1.1 mrg _G_count=`expr $_G_count + 1` 301 1.1 mrg if test "$_G_count" -gt "$_G_path_prog_max"; then 302 1.1 mrg # Best one so far, save it but keep looking for a better one 303 1.1 mrg func_check_prog_result=$_G_path_prog 304 1.1 mrg _G_path_prog_max=$_G_count 305 1.1 mrg fi 306 1.1 mrg # 10*(2^10) chars as input seems more than enough 307 1.1 mrg test 10 -lt "$_G_count" && break 308 1.1 mrg done 309 1.1 mrg rm -f conftest.in conftest.tmp conftest.nl conftest.out 310 1.1 mrg } 311 1.1 mrg 312 1.1.1.2 mrg func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin" 313 1.1 mrg GREP=$func_path_progs_result 314 1.1 mrg } 315 1.1 mrg 316 1.1 mrg 317 1.1 mrg ## ------------------------------- ## 318 1.1 mrg ## User overridable command paths. ## 319 1.1 mrg ## ------------------------------- ## 320 1.1 mrg 321 1.1 mrg # All uppercase variable names are used for environment variables. These 322 1.1 mrg # variables can be overridden by the user before calling a script that 323 1.1 mrg # uses them if a suitable command of that name is not already available 324 1.1 mrg # in the command search PATH. 325 1.1 mrg 326 1.1 mrg : ${CP="cp -f"} 327 1.1 mrg : ${ECHO="printf %s\n"} 328 1.1 mrg : ${EGREP="$GREP -E"} 329 1.1 mrg : ${FGREP="$GREP -F"} 330 1.1 mrg : ${LN_S="ln -s"} 331 1.1 mrg : ${MAKE="make"} 332 1.1 mrg : ${MKDIR="mkdir"} 333 1.1 mrg : ${MV="mv -f"} 334 1.1 mrg : ${RM="rm -f"} 335 1.1 mrg : ${SHELL="${CONFIG_SHELL-/bin/sh}"} 336 1.1 mrg 337 1.1 mrg 338 1.1 mrg ## -------------------- ## 339 1.1 mrg ## Useful sed snippets. ## 340 1.1 mrg ## -------------------- ## 341 1.1 mrg 342 1.1 mrg sed_dirname='s|/[^/]*$||' 343 1.1 mrg sed_basename='s|^.*/||' 344 1.1 mrg 345 1.1 mrg # Sed substitution that helps us do robust quoting. It backslashifies 346 1.1 mrg # metacharacters that are still active within double-quoted strings. 347 1.1 mrg sed_quote_subst='s|\([`"$\\]\)|\\\1|g' 348 1.1 mrg 349 1.1 mrg # Same as above, but do not quote variable references. 350 1.1 mrg sed_double_quote_subst='s/\(["`\\]\)/\\\1/g' 351 1.1 mrg 352 1.1 mrg # Sed substitution that turns a string into a regex matching for the 353 1.1 mrg # string literally. 354 1.1 mrg sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g' 355 1.1 mrg 356 1.1 mrg # Sed substitution that converts a w32 file name or path 357 1.1 mrg # that contains forward slashes, into one that contains 358 1.1 mrg # (escaped) backslashes. A very naive implementation. 359 1.1 mrg sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g' 360 1.1 mrg 361 1.1 mrg # Re-'\' parameter expansions in output of sed_double_quote_subst that 362 1.1 mrg # were '\'-ed in input to the same. If an odd number of '\' preceded a 363 1.1 mrg # '$' in input to sed_double_quote_subst, that '$' was protected from 364 1.1 mrg # expansion. Since each input '\' is now two '\'s, look for any number 365 1.1 mrg # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'. 366 1.1 mrg _G_bs='\\' 367 1.1 mrg _G_bs2='\\\\' 368 1.1 mrg _G_bs4='\\\\\\\\' 369 1.1 mrg _G_dollar='\$' 370 1.1 mrg sed_double_backslash="\ 371 1.1 mrg s/$_G_bs4/&\\ 372 1.1 mrg /g 373 1.1 mrg s/^$_G_bs2$_G_dollar/$_G_bs&/ 374 1.1 mrg s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g 375 1.1 mrg s/\n//g" 376 1.1 mrg 377 1.1.1.2 mrg # require_check_ifs_backslash 378 1.1.1.2 mrg # --------------------------- 379 1.1.1.2 mrg # Check if we can use backslash as IFS='\' separator, and set 380 1.1.1.2 mrg # $check_ifs_backshlash_broken to ':' or 'false'. 381 1.1.1.2 mrg require_check_ifs_backslash=func_require_check_ifs_backslash 382 1.1.1.2 mrg func_require_check_ifs_backslash () 383 1.1.1.2 mrg { 384 1.1.1.2 mrg _G_save_IFS=$IFS 385 1.1.1.2 mrg IFS='\' 386 1.1.1.2 mrg _G_check_ifs_backshlash='a\\b' 387 1.1.1.2 mrg for _G_i in $_G_check_ifs_backshlash 388 1.1.1.2 mrg do 389 1.1.1.2 mrg case $_G_i in 390 1.1.1.2 mrg a) 391 1.1.1.2 mrg check_ifs_backshlash_broken=false 392 1.1.1.2 mrg ;; 393 1.1.1.2 mrg '') 394 1.1.1.2 mrg break 395 1.1.1.2 mrg ;; 396 1.1.1.2 mrg *) 397 1.1.1.2 mrg check_ifs_backshlash_broken=: 398 1.1.1.2 mrg break 399 1.1.1.2 mrg ;; 400 1.1.1.2 mrg esac 401 1.1.1.2 mrg done 402 1.1.1.2 mrg IFS=$_G_save_IFS 403 1.1.1.2 mrg require_check_ifs_backslash=: 404 1.1.1.2 mrg } 405 1.1.1.2 mrg 406 1.1 mrg 407 1.1 mrg ## ----------------- ## 408 1.1 mrg ## Global variables. ## 409 1.1 mrg ## ----------------- ## 410 1.1 mrg 411 1.1 mrg # Except for the global variables explicitly listed below, the following 412 1.1 mrg # functions in the '^func_' namespace, and the '^require_' namespace 413 1.1 mrg # variables initialised in the 'Resource management' section, sourcing 414 1.1 mrg # this file will not pollute your global namespace with anything 415 1.1 mrg # else. There's no portable way to scope variables in Bourne shell 416 1.1 mrg # though, so actually running these functions will sometimes place 417 1.1 mrg # results into a variable named after the function, and often use 418 1.1 mrg # temporary variables in the '^_G_' namespace. If you are careful to 419 1.1 mrg # avoid using those namespaces casually in your sourcing script, things 420 1.1 mrg # should continue to work as you expect. And, of course, you can freely 421 1.1 mrg # overwrite any of the functions or variables defined here before 422 1.1 mrg # calling anything to customize them. 423 1.1 mrg 424 1.1 mrg EXIT_SUCCESS=0 425 1.1 mrg EXIT_FAILURE=1 426 1.1 mrg EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing. 427 1.1 mrg EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake. 428 1.1 mrg 429 1.1 mrg # Allow overriding, eg assuming that you follow the convention of 430 1.1 mrg # putting '$debug_cmd' at the start of all your functions, you can get 431 1.1 mrg # bash to show function call trace with: 432 1.1 mrg # 433 1.1 mrg # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name 434 1.1 mrg debug_cmd=${debug_cmd-":"} 435 1.1 mrg exit_cmd=: 436 1.1 mrg 437 1.1 mrg # By convention, finish your script with: 438 1.1 mrg # 439 1.1 mrg # exit $exit_status 440 1.1 mrg # 441 1.1 mrg # so that you can set exit_status to non-zero if you want to indicate 442 1.1 mrg # something went wrong during execution without actually bailing out at 443 1.1 mrg # the point of failure. 444 1.1 mrg exit_status=$EXIT_SUCCESS 445 1.1 mrg 446 1.1 mrg # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh 447 1.1 mrg # is ksh but when the shell is invoked as "sh" and the current value of 448 1.1 mrg # the _XPG environment variable is not equal to 1 (one), the special 449 1.1 mrg # positional parameter $0, within a function call, is the name of the 450 1.1 mrg # function. 451 1.1 mrg progpath=$0 452 1.1 mrg 453 1.1 mrg # The name of this program. 454 1.1 mrg progname=`$ECHO "$progpath" |$SED "$sed_basename"` 455 1.1 mrg 456 1.1 mrg # Make sure we have an absolute progpath for reexecution: 457 1.1 mrg case $progpath in 458 1.1 mrg [\\/]*|[A-Za-z]:\\*) ;; 459 1.1 mrg *[\\/]*) 460 1.1 mrg progdir=`$ECHO "$progpath" |$SED "$sed_dirname"` 461 1.1 mrg progdir=`cd "$progdir" && pwd` 462 1.1 mrg progpath=$progdir/$progname 463 1.1 mrg ;; 464 1.1 mrg *) 465 1.1 mrg _G_IFS=$IFS 466 1.1 mrg IFS=${PATH_SEPARATOR-:} 467 1.1 mrg for progdir in $PATH; do 468 1.1 mrg IFS=$_G_IFS 469 1.1 mrg test -x "$progdir/$progname" && break 470 1.1 mrg done 471 1.1 mrg IFS=$_G_IFS 472 1.1 mrg test -n "$progdir" || progdir=`pwd` 473 1.1 mrg progpath=$progdir/$progname 474 1.1 mrg ;; 475 1.1 mrg esac 476 1.1 mrg 477 1.1 mrg 478 1.1 mrg ## ----------------- ## 479 1.1 mrg ## Standard options. ## 480 1.1 mrg ## ----------------- ## 481 1.1 mrg 482 1.1 mrg # The following options affect the operation of the functions defined 483 1.1 mrg # below, and should be set appropriately depending on run-time para- 484 1.1 mrg # meters passed on the command line. 485 1.1 mrg 486 1.1 mrg opt_dry_run=false 487 1.1 mrg opt_quiet=false 488 1.1 mrg opt_verbose=false 489 1.1 mrg 490 1.1 mrg # Categories 'all' and 'none' are always available. Append any others 491 1.1 mrg # you will pass as the first argument to func_warning from your own 492 1.1 mrg # code. 493 1.1 mrg warning_categories= 494 1.1 mrg 495 1.1 mrg # By default, display warnings according to 'opt_warning_types'. Set 496 1.1 mrg # 'warning_func' to ':' to elide all warnings, or func_fatal_error to 497 1.1 mrg # treat the next displayed warning as a fatal error. 498 1.1 mrg warning_func=func_warn_and_continue 499 1.1 mrg 500 1.1 mrg # Set to 'all' to display all warnings, 'none' to suppress all 501 1.1 mrg # warnings, or a space delimited list of some subset of 502 1.1 mrg # 'warning_categories' to display only the listed warnings. 503 1.1 mrg opt_warning_types=all 504 1.1 mrg 505 1.1 mrg 506 1.1 mrg ## -------------------- ## 507 1.1 mrg ## Resource management. ## 508 1.1 mrg ## -------------------- ## 509 1.1 mrg 510 1.1 mrg # This section contains definitions for functions that each ensure a 511 1.1 mrg # particular resource (a file, or a non-empty configuration variable for 512 1.1 mrg # example) is available, and if appropriate to extract default values 513 1.1 mrg # from pertinent package files. Call them using their associated 514 1.1 mrg # 'require_*' variable to ensure that they are executed, at most, once. 515 1.1 mrg # 516 1.1 mrg # It's entirely deliberate that calling these functions can set 517 1.1 mrg # variables that don't obey the namespace limitations obeyed by the rest 518 1.1 mrg # of this file, in order that that they be as useful as possible to 519 1.1 mrg # callers. 520 1.1 mrg 521 1.1 mrg 522 1.1 mrg # require_term_colors 523 1.1 mrg # ------------------- 524 1.1 mrg # Allow display of bold text on terminals that support it. 525 1.1 mrg require_term_colors=func_require_term_colors 526 1.1 mrg func_require_term_colors () 527 1.1 mrg { 528 1.1 mrg $debug_cmd 529 1.1 mrg 530 1.1 mrg test -t 1 && { 531 1.1 mrg # COLORTERM and USE_ANSI_COLORS environment variables take 532 1.1 mrg # precedence, because most terminfo databases neglect to describe 533 1.1 mrg # whether color sequences are supported. 534 1.1 mrg test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"} 535 1.1 mrg 536 1.1 mrg if test 1 = "$USE_ANSI_COLORS"; then 537 1.1 mrg # Standard ANSI escape sequences 538 1.1 mrg tc_reset='[0m' 539 1.1 mrg tc_bold='[1m'; tc_standout='[7m' 540 1.1 mrg tc_red='[31m'; tc_green='[32m' 541 1.1 mrg tc_blue='[34m'; tc_cyan='[36m' 542 1.1 mrg else 543 1.1 mrg # Otherwise trust the terminfo database after all. 544 1.1 mrg test -n "`tput sgr0 2>/dev/null`" && { 545 1.1 mrg tc_reset=`tput sgr0` 546 1.1 mrg test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold` 547 1.1 mrg tc_standout=$tc_bold 548 1.1 mrg test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso` 549 1.1 mrg test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1` 550 1.1 mrg test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2` 551 1.1 mrg test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4` 552 1.1 mrg test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5` 553 1.1 mrg } 554 1.1 mrg fi 555 1.1 mrg } 556 1.1 mrg 557 1.1 mrg require_term_colors=: 558 1.1 mrg } 559 1.1 mrg 560 1.1 mrg 561 1.1 mrg ## ----------------- ## 562 1.1 mrg ## Function library. ## 563 1.1 mrg ## ----------------- ## 564 1.1 mrg 565 1.1 mrg # This section contains a variety of useful functions to call in your 566 1.1 mrg # scripts. Take note of the portable wrappers for features provided by 567 1.1 mrg # some modern shells, which will fall back to slower equivalents on 568 1.1 mrg # less featureful shells. 569 1.1 mrg 570 1.1 mrg 571 1.1 mrg # func_append VAR VALUE 572 1.1 mrg # --------------------- 573 1.1 mrg # Append VALUE onto the existing contents of VAR. 574 1.1 mrg 575 1.1 mrg # We should try to minimise forks, especially on Windows where they are 576 1.1 mrg # unreasonably slow, so skip the feature probes when bash or zsh are 577 1.1 mrg # being used: 578 1.1 mrg if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then 579 1.1 mrg : ${_G_HAVE_ARITH_OP="yes"} 580 1.1 mrg : ${_G_HAVE_XSI_OPS="yes"} 581 1.1 mrg # The += operator was introduced in bash 3.1 582 1.1 mrg case $BASH_VERSION in 583 1.1 mrg [12].* | 3.0 | 3.0*) ;; 584 1.1 mrg *) 585 1.1 mrg : ${_G_HAVE_PLUSEQ_OP="yes"} 586 1.1 mrg ;; 587 1.1 mrg esac 588 1.1 mrg fi 589 1.1 mrg 590 1.1 mrg # _G_HAVE_PLUSEQ_OP 591 1.1 mrg # Can be empty, in which case the shell is probed, "yes" if += is 592 1.1 mrg # useable or anything else if it does not work. 593 1.1 mrg test -z "$_G_HAVE_PLUSEQ_OP" \ 594 1.1 mrg && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \ 595 1.1 mrg && _G_HAVE_PLUSEQ_OP=yes 596 1.1 mrg 597 1.1 mrg if test yes = "$_G_HAVE_PLUSEQ_OP" 598 1.1 mrg then 599 1.1 mrg # This is an XSI compatible shell, allowing a faster implementation... 600 1.1 mrg eval 'func_append () 601 1.1 mrg { 602 1.1 mrg $debug_cmd 603 1.1 mrg 604 1.1 mrg eval "$1+=\$2" 605 1.1 mrg }' 606 1.1 mrg else 607 1.1 mrg # ...otherwise fall back to using expr, which is often a shell builtin. 608 1.1 mrg func_append () 609 1.1 mrg { 610 1.1 mrg $debug_cmd 611 1.1 mrg 612 1.1 mrg eval "$1=\$$1\$2" 613 1.1 mrg } 614 1.1 mrg fi 615 1.1 mrg 616 1.1 mrg 617 1.1 mrg # func_append_quoted VAR VALUE 618 1.1 mrg # ---------------------------- 619 1.1 mrg # Quote VALUE and append to the end of shell variable VAR, separated 620 1.1 mrg # by a space. 621 1.1 mrg if test yes = "$_G_HAVE_PLUSEQ_OP"; then 622 1.1 mrg eval 'func_append_quoted () 623 1.1 mrg { 624 1.1 mrg $debug_cmd 625 1.1 mrg 626 1.1.1.2 mrg func_quote_arg pretty "$2" 627 1.1.1.2 mrg eval "$1+=\\ \$func_quote_arg_result" 628 1.1 mrg }' 629 1.1 mrg else 630 1.1 mrg func_append_quoted () 631 1.1 mrg { 632 1.1 mrg $debug_cmd 633 1.1 mrg 634 1.1.1.2 mrg func_quote_arg pretty "$2" 635 1.1.1.2 mrg eval "$1=\$$1\\ \$func_quote_arg_result" 636 1.1 mrg } 637 1.1 mrg fi 638 1.1 mrg 639 1.1 mrg 640 1.1 mrg # func_append_uniq VAR VALUE 641 1.1 mrg # -------------------------- 642 1.1 mrg # Append unique VALUE onto the existing contents of VAR, assuming 643 1.1 mrg # entries are delimited by the first character of VALUE. For example: 644 1.1 mrg # 645 1.1 mrg # func_append_uniq options " --another-option option-argument" 646 1.1 mrg # 647 1.1 mrg # will only append to $options if " --another-option option-argument " 648 1.1 mrg # is not already present somewhere in $options already (note spaces at 649 1.1 mrg # each end implied by leading space in second argument). 650 1.1 mrg func_append_uniq () 651 1.1 mrg { 652 1.1 mrg $debug_cmd 653 1.1 mrg 654 1.1 mrg eval _G_current_value='`$ECHO $'$1'`' 655 1.1 mrg _G_delim=`expr "$2" : '\(.\)'` 656 1.1 mrg 657 1.1 mrg case $_G_delim$_G_current_value$_G_delim in 658 1.1 mrg *"$2$_G_delim"*) ;; 659 1.1 mrg *) func_append "$@" ;; 660 1.1 mrg esac 661 1.1 mrg } 662 1.1 mrg 663 1.1 mrg 664 1.1 mrg # func_arith TERM... 665 1.1 mrg # ------------------ 666 1.1 mrg # Set func_arith_result to the result of evaluating TERMs. 667 1.1 mrg test -z "$_G_HAVE_ARITH_OP" \ 668 1.1 mrg && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \ 669 1.1 mrg && _G_HAVE_ARITH_OP=yes 670 1.1 mrg 671 1.1 mrg if test yes = "$_G_HAVE_ARITH_OP"; then 672 1.1 mrg eval 'func_arith () 673 1.1 mrg { 674 1.1 mrg $debug_cmd 675 1.1 mrg 676 1.1 mrg func_arith_result=$(( $* )) 677 1.1 mrg }' 678 1.1 mrg else 679 1.1 mrg func_arith () 680 1.1 mrg { 681 1.1 mrg $debug_cmd 682 1.1 mrg 683 1.1 mrg func_arith_result=`expr "$@"` 684 1.1 mrg } 685 1.1 mrg fi 686 1.1 mrg 687 1.1 mrg 688 1.1 mrg # func_basename FILE 689 1.1 mrg # ------------------ 690 1.1 mrg # Set func_basename_result to FILE with everything up to and including 691 1.1 mrg # the last / stripped. 692 1.1 mrg if test yes = "$_G_HAVE_XSI_OPS"; then 693 1.1 mrg # If this shell supports suffix pattern removal, then use it to avoid 694 1.1 mrg # forking. Hide the definitions single quotes in case the shell chokes 695 1.1 mrg # on unsupported syntax... 696 1.1 mrg _b='func_basename_result=${1##*/}' 697 1.1 mrg _d='case $1 in 698 1.1 mrg */*) func_dirname_result=${1%/*}$2 ;; 699 1.1 mrg * ) func_dirname_result=$3 ;; 700 1.1 mrg esac' 701 1.1 mrg 702 1.1 mrg else 703 1.1 mrg # ...otherwise fall back to using sed. 704 1.1 mrg _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`' 705 1.1 mrg _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"` 706 1.1 mrg if test "X$func_dirname_result" = "X$1"; then 707 1.1 mrg func_dirname_result=$3 708 1.1 mrg else 709 1.1 mrg func_append func_dirname_result "$2" 710 1.1 mrg fi' 711 1.1 mrg fi 712 1.1 mrg 713 1.1 mrg eval 'func_basename () 714 1.1 mrg { 715 1.1 mrg $debug_cmd 716 1.1 mrg 717 1.1 mrg '"$_b"' 718 1.1 mrg }' 719 1.1 mrg 720 1.1 mrg 721 1.1 mrg # func_dirname FILE APPEND NONDIR_REPLACEMENT 722 1.1 mrg # ------------------------------------------- 723 1.1 mrg # Compute the dirname of FILE. If nonempty, add APPEND to the result, 724 1.1 mrg # otherwise set result to NONDIR_REPLACEMENT. 725 1.1 mrg eval 'func_dirname () 726 1.1 mrg { 727 1.1 mrg $debug_cmd 728 1.1 mrg 729 1.1 mrg '"$_d"' 730 1.1 mrg }' 731 1.1 mrg 732 1.1 mrg 733 1.1 mrg # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT 734 1.1 mrg # -------------------------------------------------------- 735 1.1 mrg # Perform func_basename and func_dirname in a single function 736 1.1 mrg # call: 737 1.1 mrg # dirname: Compute the dirname of FILE. If nonempty, 738 1.1 mrg # add APPEND to the result, otherwise set result 739 1.1 mrg # to NONDIR_REPLACEMENT. 740 1.1 mrg # value returned in "$func_dirname_result" 741 1.1 mrg # basename: Compute filename of FILE. 742 1.1 mrg # value retuned in "$func_basename_result" 743 1.1 mrg # For efficiency, we do not delegate to the functions above but instead 744 1.1 mrg # duplicate the functionality here. 745 1.1 mrg eval 'func_dirname_and_basename () 746 1.1 mrg { 747 1.1 mrg $debug_cmd 748 1.1 mrg 749 1.1 mrg '"$_b"' 750 1.1 mrg '"$_d"' 751 1.1 mrg }' 752 1.1 mrg 753 1.1 mrg 754 1.1 mrg # func_echo ARG... 755 1.1 mrg # ---------------- 756 1.1 mrg # Echo program name prefixed message. 757 1.1 mrg func_echo () 758 1.1 mrg { 759 1.1 mrg $debug_cmd 760 1.1 mrg 761 1.1 mrg _G_message=$* 762 1.1 mrg 763 1.1 mrg func_echo_IFS=$IFS 764 1.1 mrg IFS=$nl 765 1.1 mrg for _G_line in $_G_message; do 766 1.1 mrg IFS=$func_echo_IFS 767 1.1 mrg $ECHO "$progname: $_G_line" 768 1.1 mrg done 769 1.1 mrg IFS=$func_echo_IFS 770 1.1 mrg } 771 1.1 mrg 772 1.1 mrg 773 1.1 mrg # func_echo_all ARG... 774 1.1 mrg # -------------------- 775 1.1 mrg # Invoke $ECHO with all args, space-separated. 776 1.1 mrg func_echo_all () 777 1.1 mrg { 778 1.1 mrg $ECHO "$*" 779 1.1 mrg } 780 1.1 mrg 781 1.1 mrg 782 1.1 mrg # func_echo_infix_1 INFIX ARG... 783 1.1 mrg # ------------------------------ 784 1.1 mrg # Echo program name, followed by INFIX on the first line, with any 785 1.1 mrg # additional lines not showing INFIX. 786 1.1 mrg func_echo_infix_1 () 787 1.1 mrg { 788 1.1 mrg $debug_cmd 789 1.1 mrg 790 1.1 mrg $require_term_colors 791 1.1 mrg 792 1.1 mrg _G_infix=$1; shift 793 1.1 mrg _G_indent=$_G_infix 794 1.1 mrg _G_prefix="$progname: $_G_infix: " 795 1.1 mrg _G_message=$* 796 1.1 mrg 797 1.1 mrg # Strip color escape sequences before counting printable length 798 1.1 mrg for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan" 799 1.1 mrg do 800 1.1 mrg test -n "$_G_tc" && { 801 1.1 mrg _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"` 802 1.1 mrg _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"` 803 1.1 mrg } 804 1.1 mrg done 805 1.1 mrg _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes 806 1.1 mrg 807 1.1 mrg func_echo_infix_1_IFS=$IFS 808 1.1 mrg IFS=$nl 809 1.1 mrg for _G_line in $_G_message; do 810 1.1 mrg IFS=$func_echo_infix_1_IFS 811 1.1 mrg $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2 812 1.1 mrg _G_prefix=$_G_indent 813 1.1 mrg done 814 1.1 mrg IFS=$func_echo_infix_1_IFS 815 1.1 mrg } 816 1.1 mrg 817 1.1 mrg 818 1.1 mrg # func_error ARG... 819 1.1 mrg # ----------------- 820 1.1 mrg # Echo program name prefixed message to standard error. 821 1.1 mrg func_error () 822 1.1 mrg { 823 1.1 mrg $debug_cmd 824 1.1 mrg 825 1.1 mrg $require_term_colors 826 1.1 mrg 827 1.1 mrg func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2 828 1.1 mrg } 829 1.1 mrg 830 1.1 mrg 831 1.1 mrg # func_fatal_error ARG... 832 1.1 mrg # ----------------------- 833 1.1 mrg # Echo program name prefixed message to standard error, and exit. 834 1.1 mrg func_fatal_error () 835 1.1 mrg { 836 1.1 mrg $debug_cmd 837 1.1 mrg 838 1.1 mrg func_error "$*" 839 1.1 mrg exit $EXIT_FAILURE 840 1.1 mrg } 841 1.1 mrg 842 1.1 mrg 843 1.1 mrg # func_grep EXPRESSION FILENAME 844 1.1 mrg # ----------------------------- 845 1.1 mrg # Check whether EXPRESSION matches any line of FILENAME, without output. 846 1.1 mrg func_grep () 847 1.1 mrg { 848 1.1 mrg $debug_cmd 849 1.1 mrg 850 1.1 mrg $GREP "$1" "$2" >/dev/null 2>&1 851 1.1 mrg } 852 1.1 mrg 853 1.1 mrg 854 1.1 mrg # func_len STRING 855 1.1 mrg # --------------- 856 1.1 mrg # Set func_len_result to the length of STRING. STRING may not 857 1.1 mrg # start with a hyphen. 858 1.1 mrg test -z "$_G_HAVE_XSI_OPS" \ 859 1.1 mrg && (eval 'x=a/b/c; 860 1.1 mrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 861 1.1 mrg && _G_HAVE_XSI_OPS=yes 862 1.1 mrg 863 1.1 mrg if test yes = "$_G_HAVE_XSI_OPS"; then 864 1.1 mrg eval 'func_len () 865 1.1 mrg { 866 1.1 mrg $debug_cmd 867 1.1 mrg 868 1.1 mrg func_len_result=${#1} 869 1.1 mrg }' 870 1.1 mrg else 871 1.1 mrg func_len () 872 1.1 mrg { 873 1.1 mrg $debug_cmd 874 1.1 mrg 875 1.1 mrg func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len` 876 1.1 mrg } 877 1.1 mrg fi 878 1.1 mrg 879 1.1 mrg 880 1.1 mrg # func_mkdir_p DIRECTORY-PATH 881 1.1 mrg # --------------------------- 882 1.1 mrg # Make sure the entire path to DIRECTORY-PATH is available. 883 1.1 mrg func_mkdir_p () 884 1.1 mrg { 885 1.1 mrg $debug_cmd 886 1.1 mrg 887 1.1 mrg _G_directory_path=$1 888 1.1 mrg _G_dir_list= 889 1.1 mrg 890 1.1 mrg if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then 891 1.1 mrg 892 1.1 mrg # Protect directory names starting with '-' 893 1.1 mrg case $_G_directory_path in 894 1.1 mrg -*) _G_directory_path=./$_G_directory_path ;; 895 1.1 mrg esac 896 1.1 mrg 897 1.1 mrg # While some portion of DIR does not yet exist... 898 1.1 mrg while test ! -d "$_G_directory_path"; do 899 1.1 mrg # ...make a list in topmost first order. Use a colon delimited 900 1.1 mrg # list incase some portion of path contains whitespace. 901 1.1 mrg _G_dir_list=$_G_directory_path:$_G_dir_list 902 1.1 mrg 903 1.1 mrg # If the last portion added has no slash in it, the list is done 904 1.1 mrg case $_G_directory_path in */*) ;; *) break ;; esac 905 1.1 mrg 906 1.1 mrg # ...otherwise throw away the child directory and loop 907 1.1 mrg _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"` 908 1.1 mrg done 909 1.1 mrg _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'` 910 1.1 mrg 911 1.1 mrg func_mkdir_p_IFS=$IFS; IFS=: 912 1.1 mrg for _G_dir in $_G_dir_list; do 913 1.1 mrg IFS=$func_mkdir_p_IFS 914 1.1 mrg # mkdir can fail with a 'File exist' error if two processes 915 1.1 mrg # try to create one of the directories concurrently. Don't 916 1.1 mrg # stop in that case! 917 1.1 mrg $MKDIR "$_G_dir" 2>/dev/null || : 918 1.1 mrg done 919 1.1 mrg IFS=$func_mkdir_p_IFS 920 1.1 mrg 921 1.1 mrg # Bail out if we (or some other process) failed to create a directory. 922 1.1 mrg test -d "$_G_directory_path" || \ 923 1.1 mrg func_fatal_error "Failed to create '$1'" 924 1.1 mrg fi 925 1.1 mrg } 926 1.1 mrg 927 1.1 mrg 928 1.1 mrg # func_mktempdir [BASENAME] 929 1.1 mrg # ------------------------- 930 1.1 mrg # Make a temporary directory that won't clash with other running 931 1.1 mrg # libtool processes, and avoids race conditions if possible. If 932 1.1 mrg # given, BASENAME is the basename for that directory. 933 1.1 mrg func_mktempdir () 934 1.1 mrg { 935 1.1 mrg $debug_cmd 936 1.1 mrg 937 1.1 mrg _G_template=${TMPDIR-/tmp}/${1-$progname} 938 1.1 mrg 939 1.1 mrg if test : = "$opt_dry_run"; then 940 1.1 mrg # Return a directory name, but don't create it in dry-run mode 941 1.1 mrg _G_tmpdir=$_G_template-$$ 942 1.1 mrg else 943 1.1 mrg 944 1.1 mrg # If mktemp works, use that first and foremost 945 1.1 mrg _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null` 946 1.1 mrg 947 1.1 mrg if test ! -d "$_G_tmpdir"; then 948 1.1 mrg # Failing that, at least try and use $RANDOM to avoid a race 949 1.1 mrg _G_tmpdir=$_G_template-${RANDOM-0}$$ 950 1.1 mrg 951 1.1 mrg func_mktempdir_umask=`umask` 952 1.1 mrg umask 0077 953 1.1 mrg $MKDIR "$_G_tmpdir" 954 1.1 mrg umask $func_mktempdir_umask 955 1.1 mrg fi 956 1.1 mrg 957 1.1 mrg # If we're not in dry-run mode, bomb out on failure 958 1.1 mrg test -d "$_G_tmpdir" || \ 959 1.1 mrg func_fatal_error "cannot create temporary directory '$_G_tmpdir'" 960 1.1 mrg fi 961 1.1 mrg 962 1.1 mrg $ECHO "$_G_tmpdir" 963 1.1 mrg } 964 1.1 mrg 965 1.1 mrg 966 1.1 mrg # func_normal_abspath PATH 967 1.1 mrg # ------------------------ 968 1.1 mrg # Remove doubled-up and trailing slashes, "." path components, 969 1.1 mrg # and cancel out any ".." path components in PATH after making 970 1.1 mrg # it an absolute path. 971 1.1 mrg func_normal_abspath () 972 1.1 mrg { 973 1.1 mrg $debug_cmd 974 1.1 mrg 975 1.1 mrg # These SED scripts presuppose an absolute path with a trailing slash. 976 1.1 mrg _G_pathcar='s|^/\([^/]*\).*$|\1|' 977 1.1 mrg _G_pathcdr='s|^/[^/]*||' 978 1.1 mrg _G_removedotparts=':dotsl 979 1.1 mrg s|/\./|/|g 980 1.1 mrg t dotsl 981 1.1 mrg s|/\.$|/|' 982 1.1 mrg _G_collapseslashes='s|/\{1,\}|/|g' 983 1.1 mrg _G_finalslash='s|/*$|/|' 984 1.1 mrg 985 1.1 mrg # Start from root dir and reassemble the path. 986 1.1 mrg func_normal_abspath_result= 987 1.1 mrg func_normal_abspath_tpath=$1 988 1.1 mrg func_normal_abspath_altnamespace= 989 1.1 mrg case $func_normal_abspath_tpath in 990 1.1 mrg "") 991 1.1 mrg # Empty path, that just means $cwd. 992 1.1 mrg func_stripname '' '/' "`pwd`" 993 1.1 mrg func_normal_abspath_result=$func_stripname_result 994 1.1 mrg return 995 1.1 mrg ;; 996 1.1 mrg # The next three entries are used to spot a run of precisely 997 1.1 mrg # two leading slashes without using negated character classes; 998 1.1 mrg # we take advantage of case's first-match behaviour. 999 1.1 mrg ///*) 1000 1.1 mrg # Unusual form of absolute path, do nothing. 1001 1.1 mrg ;; 1002 1.1 mrg //*) 1003 1.1 mrg # Not necessarily an ordinary path; POSIX reserves leading '//' 1004 1.1 mrg # and for example Cygwin uses it to access remote file shares 1005 1.1 mrg # over CIFS/SMB, so we conserve a leading double slash if found. 1006 1.1 mrg func_normal_abspath_altnamespace=/ 1007 1.1 mrg ;; 1008 1.1 mrg /*) 1009 1.1 mrg # Absolute path, do nothing. 1010 1.1 mrg ;; 1011 1.1 mrg *) 1012 1.1 mrg # Relative path, prepend $cwd. 1013 1.1 mrg func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath 1014 1.1 mrg ;; 1015 1.1 mrg esac 1016 1.1 mrg 1017 1.1 mrg # Cancel out all the simple stuff to save iterations. We also want 1018 1.1 mrg # the path to end with a slash for ease of parsing, so make sure 1019 1.1 mrg # there is one (and only one) here. 1020 1.1 mrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1021 1.1 mrg -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"` 1022 1.1 mrg while :; do 1023 1.1 mrg # Processed it all yet? 1024 1.1 mrg if test / = "$func_normal_abspath_tpath"; then 1025 1.1 mrg # If we ascended to the root using ".." the result may be empty now. 1026 1.1 mrg if test -z "$func_normal_abspath_result"; then 1027 1.1 mrg func_normal_abspath_result=/ 1028 1.1 mrg fi 1029 1.1 mrg break 1030 1.1 mrg fi 1031 1.1 mrg func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1032 1.1 mrg -e "$_G_pathcar"` 1033 1.1 mrg func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \ 1034 1.1 mrg -e "$_G_pathcdr"` 1035 1.1 mrg # Figure out what to do with it 1036 1.1 mrg case $func_normal_abspath_tcomponent in 1037 1.1 mrg "") 1038 1.1 mrg # Trailing empty path component, ignore it. 1039 1.1 mrg ;; 1040 1.1 mrg ..) 1041 1.1 mrg # Parent dir; strip last assembled component from result. 1042 1.1 mrg func_dirname "$func_normal_abspath_result" 1043 1.1 mrg func_normal_abspath_result=$func_dirname_result 1044 1.1 mrg ;; 1045 1.1 mrg *) 1046 1.1 mrg # Actual path component, append it. 1047 1.1 mrg func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent" 1048 1.1 mrg ;; 1049 1.1 mrg esac 1050 1.1 mrg done 1051 1.1 mrg # Restore leading double-slash if one was found on entry. 1052 1.1 mrg func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result 1053 1.1 mrg } 1054 1.1 mrg 1055 1.1 mrg 1056 1.1 mrg # func_notquiet ARG... 1057 1.1 mrg # -------------------- 1058 1.1 mrg # Echo program name prefixed message only when not in quiet mode. 1059 1.1 mrg func_notquiet () 1060 1.1 mrg { 1061 1.1 mrg $debug_cmd 1062 1.1 mrg 1063 1.1 mrg $opt_quiet || func_echo ${1+"$@"} 1064 1.1 mrg 1065 1.1 mrg # A bug in bash halts the script if the last line of a function 1066 1.1 mrg # fails when set -e is in force, so we need another command to 1067 1.1 mrg # work around that: 1068 1.1 mrg : 1069 1.1 mrg } 1070 1.1 mrg 1071 1.1 mrg 1072 1.1 mrg # func_relative_path SRCDIR DSTDIR 1073 1.1 mrg # -------------------------------- 1074 1.1 mrg # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR. 1075 1.1 mrg func_relative_path () 1076 1.1 mrg { 1077 1.1 mrg $debug_cmd 1078 1.1 mrg 1079 1.1 mrg func_relative_path_result= 1080 1.1 mrg func_normal_abspath "$1" 1081 1.1 mrg func_relative_path_tlibdir=$func_normal_abspath_result 1082 1.1 mrg func_normal_abspath "$2" 1083 1.1 mrg func_relative_path_tbindir=$func_normal_abspath_result 1084 1.1 mrg 1085 1.1 mrg # Ascend the tree starting from libdir 1086 1.1 mrg while :; do 1087 1.1 mrg # check if we have found a prefix of bindir 1088 1.1 mrg case $func_relative_path_tbindir in 1089 1.1 mrg $func_relative_path_tlibdir) 1090 1.1 mrg # found an exact match 1091 1.1 mrg func_relative_path_tcancelled= 1092 1.1 mrg break 1093 1.1 mrg ;; 1094 1.1 mrg $func_relative_path_tlibdir*) 1095 1.1 mrg # found a matching prefix 1096 1.1 mrg func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir" 1097 1.1 mrg func_relative_path_tcancelled=$func_stripname_result 1098 1.1 mrg if test -z "$func_relative_path_result"; then 1099 1.1 mrg func_relative_path_result=. 1100 1.1 mrg fi 1101 1.1 mrg break 1102 1.1 mrg ;; 1103 1.1 mrg *) 1104 1.1 mrg func_dirname $func_relative_path_tlibdir 1105 1.1 mrg func_relative_path_tlibdir=$func_dirname_result 1106 1.1 mrg if test -z "$func_relative_path_tlibdir"; then 1107 1.1 mrg # Have to descend all the way to the root! 1108 1.1 mrg func_relative_path_result=../$func_relative_path_result 1109 1.1 mrg func_relative_path_tcancelled=$func_relative_path_tbindir 1110 1.1 mrg break 1111 1.1 mrg fi 1112 1.1 mrg func_relative_path_result=../$func_relative_path_result 1113 1.1 mrg ;; 1114 1.1 mrg esac 1115 1.1 mrg done 1116 1.1 mrg 1117 1.1 mrg # Now calculate path; take care to avoid doubling-up slashes. 1118 1.1 mrg func_stripname '' '/' "$func_relative_path_result" 1119 1.1 mrg func_relative_path_result=$func_stripname_result 1120 1.1 mrg func_stripname '/' '/' "$func_relative_path_tcancelled" 1121 1.1 mrg if test -n "$func_stripname_result"; then 1122 1.1 mrg func_append func_relative_path_result "/$func_stripname_result" 1123 1.1 mrg fi 1124 1.1 mrg 1125 1.1 mrg # Normalisation. If bindir is libdir, return '.' else relative path. 1126 1.1 mrg if test -n "$func_relative_path_result"; then 1127 1.1 mrg func_stripname './' '' "$func_relative_path_result" 1128 1.1 mrg func_relative_path_result=$func_stripname_result 1129 1.1 mrg fi 1130 1.1 mrg 1131 1.1 mrg test -n "$func_relative_path_result" || func_relative_path_result=. 1132 1.1 mrg 1133 1.1 mrg : 1134 1.1 mrg } 1135 1.1 mrg 1136 1.1 mrg 1137 1.1.1.2 mrg # func_quote_portable EVAL ARG 1138 1.1.1.2 mrg # ---------------------------- 1139 1.1.1.2 mrg # Internal function to portably implement func_quote_arg. Note that we still 1140 1.1.1.2 mrg # keep attention to performance here so we as much as possible try to avoid 1141 1.1.1.2 mrg # calling sed binary (so far O(N) complexity as long as func_append is O(1)). 1142 1.1.1.2 mrg func_quote_portable () 1143 1.1 mrg { 1144 1.1 mrg $debug_cmd 1145 1.1 mrg 1146 1.1.1.2 mrg $require_check_ifs_backslash 1147 1.1.1.2 mrg 1148 1.1.1.2 mrg func_quote_portable_result=$2 1149 1.1.1.2 mrg 1150 1.1.1.2 mrg # one-time-loop (easy break) 1151 1.1.1.2 mrg while true 1152 1.1.1.2 mrg do 1153 1.1.1.2 mrg if $1; then 1154 1.1.1.2 mrg func_quote_portable_result=`$ECHO "$2" | $SED \ 1155 1.1.1.2 mrg -e "$sed_double_quote_subst" -e "$sed_double_backslash"` 1156 1.1.1.2 mrg break 1157 1.1 mrg fi 1158 1.1 mrg 1159 1.1.1.2 mrg # Quote for eval. 1160 1.1.1.2 mrg case $func_quote_portable_result in 1161 1.1.1.2 mrg *[\\\`\"\$]*) 1162 1.1.1.2 mrg # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string 1163 1.1.1.2 mrg # contains the shell wildcard characters. 1164 1.1.1.2 mrg case $check_ifs_backshlash_broken$func_quote_portable_result in 1165 1.1.1.2 mrg :*|*[\[\*\?]*) 1166 1.1.1.2 mrg func_quote_portable_result=`$ECHO "$func_quote_portable_result" \ 1167 1.1.1.2 mrg | $SED "$sed_quote_subst"` 1168 1.1.1.2 mrg break 1169 1.1.1.2 mrg ;; 1170 1.1.1.2 mrg esac 1171 1.1.1.2 mrg 1172 1.1.1.2 mrg func_quote_portable_old_IFS=$IFS 1173 1.1.1.2 mrg for _G_char in '\' '`' '"' '$' 1174 1.1.1.2 mrg do 1175 1.1.1.2 mrg # STATE($1) PREV($2) SEPARATOR($3) 1176 1.1.1.2 mrg set start "" "" 1177 1.1.1.2 mrg func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy 1178 1.1.1.2 mrg IFS=$_G_char 1179 1.1.1.2 mrg for _G_part in $func_quote_portable_result 1180 1.1.1.2 mrg do 1181 1.1.1.2 mrg case $1 in 1182 1.1.1.2 mrg quote) 1183 1.1.1.2 mrg func_append func_quote_portable_result "$3$2" 1184 1.1.1.2 mrg set quote "$_G_part" "\\$_G_char" 1185 1.1.1.2 mrg ;; 1186 1.1.1.2 mrg start) 1187 1.1.1.2 mrg set first "" "" 1188 1.1.1.2 mrg func_quote_portable_result= 1189 1.1.1.2 mrg ;; 1190 1.1.1.2 mrg first) 1191 1.1.1.2 mrg set quote "$_G_part" "" 1192 1.1.1.2 mrg ;; 1193 1.1.1.2 mrg esac 1194 1.1.1.2 mrg done 1195 1.1.1.2 mrg done 1196 1.1.1.2 mrg IFS=$func_quote_portable_old_IFS 1197 1.1 mrg ;; 1198 1.1.1.2 mrg *) ;; 1199 1.1 mrg esac 1200 1.1.1.2 mrg break 1201 1.1 mrg done 1202 1.1.1.2 mrg 1203 1.1.1.2 mrg func_quote_portable_unquoted_result=$func_quote_portable_result 1204 1.1.1.2 mrg case $func_quote_portable_result in 1205 1.1.1.2 mrg # double-quote args containing shell metacharacters to delay 1206 1.1.1.2 mrg # word splitting, command substitution and variable expansion 1207 1.1.1.2 mrg # for a subsequent eval. 1208 1.1.1.2 mrg # many bourne shells cannot handle close brackets correctly 1209 1.1.1.2 mrg # in scan sets, so we specify it separately. 1210 1.1.1.2 mrg *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"") 1211 1.1.1.2 mrg func_quote_portable_result=\"$func_quote_portable_result\" 1212 1.1.1.2 mrg ;; 1213 1.1.1.2 mrg esac 1214 1.1 mrg } 1215 1.1 mrg 1216 1.1 mrg 1217 1.1.1.2 mrg # func_quotefast_eval ARG 1218 1.1.1.2 mrg # ----------------------- 1219 1.1.1.2 mrg # Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG', 1220 1.1.1.2 mrg # but optimized for speed. Result is stored in $func_quotefast_eval. 1221 1.1.1.2 mrg if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then 1222 1.1.1.2 mrg printf -v _GL_test_printf_tilde %q '~' 1223 1.1.1.2 mrg if test '\~' = "$_GL_test_printf_tilde"; then 1224 1.1.1.2 mrg func_quotefast_eval () 1225 1.1.1.2 mrg { 1226 1.1.1.2 mrg printf -v func_quotefast_eval_result %q "$1" 1227 1.1.1.2 mrg } 1228 1.1.1.2 mrg else 1229 1.1.1.2 mrg # Broken older Bash implementations. Make those faster too if possible. 1230 1.1.1.2 mrg func_quotefast_eval () 1231 1.1.1.2 mrg { 1232 1.1.1.2 mrg case $1 in 1233 1.1.1.2 mrg '~'*) 1234 1.1.1.2 mrg func_quote_portable false "$1" 1235 1.1.1.2 mrg func_quotefast_eval_result=$func_quote_portable_result 1236 1.1.1.2 mrg ;; 1237 1.1.1.2 mrg *) 1238 1.1.1.2 mrg printf -v func_quotefast_eval_result %q "$1" 1239 1.1.1.2 mrg ;; 1240 1.1.1.2 mrg esac 1241 1.1.1.2 mrg } 1242 1.1.1.2 mrg fi 1243 1.1.1.2 mrg else 1244 1.1.1.2 mrg func_quotefast_eval () 1245 1.1.1.2 mrg { 1246 1.1.1.2 mrg func_quote_portable false "$1" 1247 1.1.1.2 mrg func_quotefast_eval_result=$func_quote_portable_result 1248 1.1.1.2 mrg } 1249 1.1.1.2 mrg fi 1250 1.1 mrg 1251 1.1.1.2 mrg 1252 1.1.1.2 mrg # func_quote_arg MODEs ARG 1253 1.1.1.2 mrg # ------------------------ 1254 1.1.1.2 mrg # Quote one ARG to be evaled later. MODEs argument may contain zero or more 1255 1.1.1.2 mrg # specifiers listed below separated by ',' character. This function returns two 1256 1.1.1.2 mrg # values: 1257 1.1.1.2 mrg # i) func_quote_arg_result 1258 1.1.1.2 mrg # double-quoted (when needed), suitable for a subsequent eval 1259 1.1.1.2 mrg # ii) func_quote_arg_unquoted_result 1260 1.1.1.2 mrg # has all characters that are still active within double 1261 1.1.1.2 mrg # quotes backslashified. Available only if 'unquoted' is specified. 1262 1.1.1.2 mrg # 1263 1.1.1.2 mrg # Available modes: 1264 1.1.1.2 mrg # ---------------- 1265 1.1.1.2 mrg # 'eval' (default) 1266 1.1.1.2 mrg # - escape shell special characters 1267 1.1.1.2 mrg # 'expand' 1268 1.1.1.2 mrg # - the same as 'eval'; but do not quote variable references 1269 1.1.1.2 mrg # 'pretty' 1270 1.1.1.2 mrg # - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might 1271 1.1.1.2 mrg # be used later in func_quote to get output like: 'echo "a b"' instead 1272 1.1.1.2 mrg # of 'echo a\ b'. This is slower than default on some shells. 1273 1.1.1.2 mrg # 'unquoted' 1274 1.1.1.2 mrg # - produce also $func_quote_arg_unquoted_result which does not contain 1275 1.1.1.2 mrg # wrapping double-quotes. 1276 1.1.1.2 mrg # 1277 1.1.1.2 mrg # Examples for 'func_quote_arg pretty,unquoted string': 1278 1.1.1.2 mrg # 1279 1.1.1.2 mrg # string | *_result | *_unquoted_result 1280 1.1.1.2 mrg # ------------+-----------------------+------------------- 1281 1.1.1.2 mrg # " | \" | \" 1282 1.1.1.2 mrg # a b | "a b" | a b 1283 1.1.1.2 mrg # "a b" | "\"a b\"" | \"a b\" 1284 1.1.1.2 mrg # * | "*" | * 1285 1.1.1.2 mrg # z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\" 1286 1.1.1.2 mrg # 1287 1.1.1.2 mrg # Examples for 'func_quote_arg pretty,unquoted,expand string': 1288 1.1.1.2 mrg # 1289 1.1.1.2 mrg # string | *_result | *_unquoted_result 1290 1.1.1.2 mrg # --------------+---------------------+-------------------- 1291 1.1.1.2 mrg # z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\" 1292 1.1.1.2 mrg func_quote_arg () 1293 1.1.1.2 mrg { 1294 1.1.1.2 mrg _G_quote_expand=false 1295 1.1.1.2 mrg case ,$1, in 1296 1.1.1.2 mrg *,expand,*) 1297 1.1.1.2 mrg _G_quote_expand=: 1298 1.1.1.2 mrg ;; 1299 1.1 mrg esac 1300 1.1 mrg 1301 1.1.1.2 mrg case ,$1, in 1302 1.1.1.2 mrg *,pretty,*|*,expand,*|*,unquoted,*) 1303 1.1.1.2 mrg func_quote_portable $_G_quote_expand "$2" 1304 1.1.1.2 mrg func_quote_arg_result=$func_quote_portable_result 1305 1.1.1.2 mrg func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result 1306 1.1.1.2 mrg ;; 1307 1.1.1.2 mrg *) 1308 1.1.1.2 mrg # Faster quote-for-eval for some shells. 1309 1.1.1.2 mrg func_quotefast_eval "$2" 1310 1.1.1.2 mrg func_quote_arg_result=$func_quotefast_eval_result 1311 1.1 mrg ;; 1312 1.1 mrg esac 1313 1.1.1.2 mrg } 1314 1.1.1.2 mrg 1315 1.1 mrg 1316 1.1.1.2 mrg # func_quote MODEs ARGs... 1317 1.1.1.2 mrg # ------------------------ 1318 1.1.1.2 mrg # Quote all ARGs to be evaled later and join them into single command. See 1319 1.1.1.2 mrg # func_quote_arg's description for more info. 1320 1.1.1.2 mrg func_quote () 1321 1.1.1.2 mrg { 1322 1.1.1.2 mrg $debug_cmd 1323 1.1.1.2 mrg _G_func_quote_mode=$1 ; shift 1324 1.1.1.2 mrg func_quote_result= 1325 1.1.1.2 mrg while test 0 -lt $#; do 1326 1.1.1.2 mrg func_quote_arg "$_G_func_quote_mode" "$1" 1327 1.1.1.2 mrg if test -n "$func_quote_result"; then 1328 1.1.1.2 mrg func_append func_quote_result " $func_quote_arg_result" 1329 1.1.1.2 mrg else 1330 1.1.1.2 mrg func_append func_quote_result "$func_quote_arg_result" 1331 1.1.1.2 mrg fi 1332 1.1.1.2 mrg shift 1333 1.1.1.2 mrg done 1334 1.1 mrg } 1335 1.1 mrg 1336 1.1 mrg 1337 1.1 mrg # func_stripname PREFIX SUFFIX NAME 1338 1.1 mrg # --------------------------------- 1339 1.1 mrg # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result. 1340 1.1 mrg # PREFIX and SUFFIX must not contain globbing or regex special 1341 1.1 mrg # characters, hashes, percent signs, but SUFFIX may contain a leading 1342 1.1 mrg # dot (in which case that matches only a dot). 1343 1.1 mrg if test yes = "$_G_HAVE_XSI_OPS"; then 1344 1.1 mrg eval 'func_stripname () 1345 1.1 mrg { 1346 1.1 mrg $debug_cmd 1347 1.1 mrg 1348 1.1 mrg # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are 1349 1.1 mrg # positional parameters, so assign one to ordinary variable first. 1350 1.1 mrg func_stripname_result=$3 1351 1.1 mrg func_stripname_result=${func_stripname_result#"$1"} 1352 1.1 mrg func_stripname_result=${func_stripname_result%"$2"} 1353 1.1 mrg }' 1354 1.1 mrg else 1355 1.1 mrg func_stripname () 1356 1.1 mrg { 1357 1.1 mrg $debug_cmd 1358 1.1 mrg 1359 1.1 mrg case $2 in 1360 1.1 mrg .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;; 1361 1.1 mrg *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;; 1362 1.1 mrg esac 1363 1.1 mrg } 1364 1.1 mrg fi 1365 1.1 mrg 1366 1.1 mrg 1367 1.1 mrg # func_show_eval CMD [FAIL_EXP] 1368 1.1 mrg # ----------------------------- 1369 1.1 mrg # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1370 1.1 mrg # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1371 1.1 mrg # is given, then evaluate it. 1372 1.1 mrg func_show_eval () 1373 1.1 mrg { 1374 1.1 mrg $debug_cmd 1375 1.1 mrg 1376 1.1 mrg _G_cmd=$1 1377 1.1 mrg _G_fail_exp=${2-':'} 1378 1.1 mrg 1379 1.1.1.2 mrg func_quote_arg pretty,expand "$_G_cmd" 1380 1.1.1.2 mrg eval "func_notquiet $func_quote_arg_result" 1381 1.1 mrg 1382 1.1 mrg $opt_dry_run || { 1383 1.1 mrg eval "$_G_cmd" 1384 1.1 mrg _G_status=$? 1385 1.1 mrg if test 0 -ne "$_G_status"; then 1386 1.1 mrg eval "(exit $_G_status); $_G_fail_exp" 1387 1.1 mrg fi 1388 1.1 mrg } 1389 1.1 mrg } 1390 1.1 mrg 1391 1.1 mrg 1392 1.1 mrg # func_show_eval_locale CMD [FAIL_EXP] 1393 1.1 mrg # ------------------------------------ 1394 1.1 mrg # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is 1395 1.1 mrg # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP 1396 1.1 mrg # is given, then evaluate it. Use the saved locale for evaluation. 1397 1.1 mrg func_show_eval_locale () 1398 1.1 mrg { 1399 1.1 mrg $debug_cmd 1400 1.1 mrg 1401 1.1 mrg _G_cmd=$1 1402 1.1 mrg _G_fail_exp=${2-':'} 1403 1.1 mrg 1404 1.1 mrg $opt_quiet || { 1405 1.1.1.2 mrg func_quote_arg expand,pretty "$_G_cmd" 1406 1.1.1.2 mrg eval "func_echo $func_quote_arg_result" 1407 1.1 mrg } 1408 1.1 mrg 1409 1.1 mrg $opt_dry_run || { 1410 1.1 mrg eval "$_G_user_locale 1411 1.1 mrg $_G_cmd" 1412 1.1 mrg _G_status=$? 1413 1.1 mrg eval "$_G_safe_locale" 1414 1.1 mrg if test 0 -ne "$_G_status"; then 1415 1.1 mrg eval "(exit $_G_status); $_G_fail_exp" 1416 1.1 mrg fi 1417 1.1 mrg } 1418 1.1 mrg } 1419 1.1 mrg 1420 1.1 mrg 1421 1.1 mrg # func_tr_sh 1422 1.1 mrg # ---------- 1423 1.1 mrg # Turn $1 into a string suitable for a shell variable name. 1424 1.1 mrg # Result is stored in $func_tr_sh_result. All characters 1425 1.1 mrg # not in the set a-zA-Z0-9_ are replaced with '_'. Further, 1426 1.1 mrg # if $1 begins with a digit, a '_' is prepended as well. 1427 1.1 mrg func_tr_sh () 1428 1.1 mrg { 1429 1.1 mrg $debug_cmd 1430 1.1 mrg 1431 1.1 mrg case $1 in 1432 1.1 mrg [0-9]* | *[!a-zA-Z0-9_]*) 1433 1.1 mrg func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'` 1434 1.1 mrg ;; 1435 1.1 mrg * ) 1436 1.1 mrg func_tr_sh_result=$1 1437 1.1 mrg ;; 1438 1.1 mrg esac 1439 1.1 mrg } 1440 1.1 mrg 1441 1.1 mrg 1442 1.1 mrg # func_verbose ARG... 1443 1.1 mrg # ------------------- 1444 1.1 mrg # Echo program name prefixed message in verbose mode only. 1445 1.1 mrg func_verbose () 1446 1.1 mrg { 1447 1.1 mrg $debug_cmd 1448 1.1 mrg 1449 1.1 mrg $opt_verbose && func_echo "$*" 1450 1.1 mrg 1451 1.1 mrg : 1452 1.1 mrg } 1453 1.1 mrg 1454 1.1 mrg 1455 1.1 mrg # func_warn_and_continue ARG... 1456 1.1 mrg # ----------------------------- 1457 1.1 mrg # Echo program name prefixed warning message to standard error. 1458 1.1 mrg func_warn_and_continue () 1459 1.1 mrg { 1460 1.1 mrg $debug_cmd 1461 1.1 mrg 1462 1.1 mrg $require_term_colors 1463 1.1 mrg 1464 1.1 mrg func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2 1465 1.1 mrg } 1466 1.1 mrg 1467 1.1 mrg 1468 1.1 mrg # func_warning CATEGORY ARG... 1469 1.1 mrg # ---------------------------- 1470 1.1 mrg # Echo program name prefixed warning message to standard error. Warning 1471 1.1 mrg # messages can be filtered according to CATEGORY, where this function 1472 1.1 mrg # elides messages where CATEGORY is not listed in the global variable 1473 1.1 mrg # 'opt_warning_types'. 1474 1.1 mrg func_warning () 1475 1.1 mrg { 1476 1.1 mrg $debug_cmd 1477 1.1 mrg 1478 1.1 mrg # CATEGORY must be in the warning_categories list! 1479 1.1 mrg case " $warning_categories " in 1480 1.1 mrg *" $1 "*) ;; 1481 1.1 mrg *) func_internal_error "invalid warning category '$1'" ;; 1482 1.1 mrg esac 1483 1.1 mrg 1484 1.1 mrg _G_category=$1 1485 1.1 mrg shift 1486 1.1 mrg 1487 1.1 mrg case " $opt_warning_types " in 1488 1.1 mrg *" $_G_category "*) $warning_func ${1+"$@"} ;; 1489 1.1 mrg esac 1490 1.1 mrg } 1491 1.1 mrg 1492 1.1 mrg 1493 1.1 mrg # func_sort_ver VER1 VER2 1494 1.1 mrg # ----------------------- 1495 1.1 mrg # 'sort -V' is not generally available. 1496 1.1 mrg # Note this deviates from the version comparison in automake 1497 1.1 mrg # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a 1498 1.1 mrg # but this should suffice as we won't be specifying old 1499 1.1 mrg # version formats or redundant trailing .0 in bootstrap.conf. 1500 1.1 mrg # If we did want full compatibility then we should probably 1501 1.1 mrg # use m4_version_compare from autoconf. 1502 1.1 mrg func_sort_ver () 1503 1.1 mrg { 1504 1.1 mrg $debug_cmd 1505 1.1 mrg 1506 1.1 mrg printf '%s\n%s\n' "$1" "$2" \ 1507 1.1 mrg | 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 1.1 mrg } 1509 1.1 mrg 1510 1.1 mrg # func_lt_ver PREV CURR 1511 1.1 mrg # --------------------- 1512 1.1 mrg # Return true if PREV and CURR are in the correct order according to 1513 1.1 mrg # func_sort_ver, otherwise false. Use it like this: 1514 1.1 mrg # 1515 1.1 mrg # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..." 1516 1.1 mrg func_lt_ver () 1517 1.1 mrg { 1518 1.1 mrg $debug_cmd 1519 1.1 mrg 1520 1.1 mrg test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q` 1521 1.1 mrg } 1522 1.1 mrg 1523 1.1 mrg 1524 1.1 mrg # Local variables: 1525 1.1 mrg # mode: shell-script 1526 1.1 mrg # sh-indentation: 2 1527 1.1 mrg # eval: (add-hook 'before-save-hook 'time-stamp) 1528 1.1 mrg # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC" 1529 1.1 mrg # time-stamp-time-zone: "UTC" 1530 1.1 mrg # End: 1531 1.1 mrg #!/bin/sh 1532 1.1 mrg 1533 1.1 mrg # A portable, pluggable option parser for Bourne shell. 1534 1.1 mrg # Written by Gary V. Vaughan, 2010 1535 1.1 mrg 1536 1.1.1.2 mrg # This is free software. There is NO warranty; not even for 1537 1.1.1.2 mrg # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. 1538 1.1.1.2 mrg # 1539 1.1.1.2 mrg # Copyright (C) 2010-2019, 2021 Bootstrap Authors 1540 1.1.1.2 mrg # 1541 1.1.1.2 mrg # This file is dual licensed under the terms of the MIT license 1542 1.1.1.2 mrg # <https://opensource.org/license/MIT>, and GPL version 2 or later 1543 1.1.1.2 mrg # <http://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of 1544 1.1.1.2 mrg # these licenses when using or redistributing this software or any of 1545 1.1.1.2 mrg # the files within it. See the URLs above, or the file `LICENSE` 1546 1.1.1.2 mrg # included in the Bootstrap distribution for the full license texts. 1547 1.1 mrg 1548 1.1.1.2 mrg # Please report bugs or propose patches to: 1549 1.1.1.2 mrg # <https://github.com/gnulib-modules/bootstrap/issues> 1550 1.1 mrg 1551 1.1.1.2 mrg # Set a version string for this script. 1552 1.1.1.2 mrg scriptversion=2019-02-19.15; # UTC 1553 1.1 mrg 1554 1.1 mrg 1555 1.1 mrg ## ------ ## 1556 1.1 mrg ## Usage. ## 1557 1.1 mrg ## ------ ## 1558 1.1 mrg 1559 1.1 mrg # This file is a library for parsing options in your shell scripts along 1560 1.1 mrg # with assorted other useful supporting features that you can make use 1561 1.1 mrg # of too. 1562 1.1 mrg # 1563 1.1 mrg # For the simplest scripts you might need only: 1564 1.1 mrg # 1565 1.1 mrg # #!/bin/sh 1566 1.1 mrg # . relative/path/to/funclib.sh 1567 1.1 mrg # . relative/path/to/options-parser 1568 1.1 mrg # scriptversion=1.0 1569 1.1 mrg # func_options ${1+"$@"} 1570 1.1 mrg # eval set dummy "$func_options_result"; shift 1571 1.1 mrg # ...rest of your script... 1572 1.1 mrg # 1573 1.1 mrg # In order for the '--version' option to work, you will need to have a 1574 1.1 mrg # suitably formatted comment like the one at the top of this file 1575 1.1.1.2 mrg # starting with '# Written by ' and ending with '# Copyright'. 1576 1.1 mrg # 1577 1.1 mrg # For '-h' and '--help' to work, you will also need a one line 1578 1.1 mrg # description of your script's purpose in a comment directly above the 1579 1.1 mrg # '# Written by ' line, like the one at the top of this file. 1580 1.1 mrg # 1581 1.1 mrg # The default options also support '--debug', which will turn on shell 1582 1.1 mrg # execution tracing (see the comment above debug_cmd below for another 1583 1.1 mrg # use), and '--verbose' and the func_verbose function to allow your script 1584 1.1 mrg # to display verbose messages only when your user has specified 1585 1.1 mrg # '--verbose'. 1586 1.1 mrg # 1587 1.1.1.2 mrg # After sourcing this file, you can plug in processing for additional 1588 1.1 mrg # options by amending the variables from the 'Configuration' section 1589 1.1 mrg # below, and following the instructions in the 'Option parsing' 1590 1.1 mrg # section further down. 1591 1.1 mrg 1592 1.1 mrg ## -------------- ## 1593 1.1 mrg ## Configuration. ## 1594 1.1 mrg ## -------------- ## 1595 1.1 mrg 1596 1.1 mrg # You should override these variables in your script after sourcing this 1597 1.1 mrg # file so that they reflect the customisations you have added to the 1598 1.1 mrg # option parser. 1599 1.1 mrg 1600 1.1 mrg # The usage line for option parsing errors and the start of '-h' and 1601 1.1 mrg # '--help' output messages. You can embed shell variables for delayed 1602 1.1 mrg # expansion at the time the message is displayed, but you will need to 1603 1.1 mrg # quote other shell meta-characters carefully to prevent them being 1604 1.1 mrg # expanded when the contents are evaled. 1605 1.1 mrg usage='$progpath [OPTION]...' 1606 1.1 mrg 1607 1.1 mrg # Short help message in response to '-h' and '--help'. Add to this or 1608 1.1 mrg # override it after sourcing this library to reflect the full set of 1609 1.1 mrg # options your script accepts. 1610 1.1 mrg usage_message="\ 1611 1.1 mrg --debug enable verbose shell tracing 1612 1.1 mrg -W, --warnings=CATEGORY 1613 1.1 mrg report the warnings falling in CATEGORY [all] 1614 1.1 mrg -v, --verbose verbosely report processing 1615 1.1 mrg --version print version information and exit 1616 1.1 mrg -h, --help print short or long help message and exit 1617 1.1 mrg " 1618 1.1 mrg 1619 1.1 mrg # Additional text appended to 'usage_message' in response to '--help'. 1620 1.1 mrg long_help_message=" 1621 1.1 mrg Warning categories include: 1622 1.1 mrg 'all' show all warnings 1623 1.1 mrg 'none' turn off all the warnings 1624 1.1 mrg 'error' warnings are treated as fatal errors" 1625 1.1 mrg 1626 1.1 mrg # Help message printed before fatal option parsing errors. 1627 1.1 mrg fatal_help="Try '\$progname --help' for more information." 1628 1.1 mrg 1629 1.1 mrg 1630 1.1 mrg 1631 1.1 mrg ## ------------------------- ## 1632 1.1 mrg ## Hook function management. ## 1633 1.1 mrg ## ------------------------- ## 1634 1.1 mrg 1635 1.1 mrg # This section contains functions for adding, removing, and running hooks 1636 1.1.1.2 mrg # in the main code. A hook is just a list of function names that can be 1637 1.1.1.2 mrg # run in order later on. 1638 1.1 mrg 1639 1.1 mrg # func_hookable FUNC_NAME 1640 1.1 mrg # ----------------------- 1641 1.1 mrg # Declare that FUNC_NAME will run hooks added with 1642 1.1 mrg # 'func_add_hook FUNC_NAME ...'. 1643 1.1 mrg func_hookable () 1644 1.1 mrg { 1645 1.1 mrg $debug_cmd 1646 1.1 mrg 1647 1.1 mrg func_append hookable_fns " $1" 1648 1.1 mrg } 1649 1.1 mrg 1650 1.1 mrg 1651 1.1 mrg # func_add_hook FUNC_NAME HOOK_FUNC 1652 1.1 mrg # --------------------------------- 1653 1.1 mrg # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must 1654 1.1 mrg # first have been declared "hookable" by a call to 'func_hookable'. 1655 1.1 mrg func_add_hook () 1656 1.1 mrg { 1657 1.1 mrg $debug_cmd 1658 1.1 mrg 1659 1.1 mrg case " $hookable_fns " in 1660 1.1 mrg *" $1 "*) ;; 1661 1.1 mrg *) func_fatal_error "'$1' does not accept hook functions." ;; 1662 1.1 mrg esac 1663 1.1 mrg 1664 1.1 mrg eval func_append ${1}_hooks '" $2"' 1665 1.1 mrg } 1666 1.1 mrg 1667 1.1 mrg 1668 1.1 mrg # func_remove_hook FUNC_NAME HOOK_FUNC 1669 1.1 mrg # ------------------------------------ 1670 1.1.1.2 mrg # Remove HOOK_FUNC from the list of hook functions to be called by 1671 1.1.1.2 mrg # FUNC_NAME. 1672 1.1 mrg func_remove_hook () 1673 1.1 mrg { 1674 1.1 mrg $debug_cmd 1675 1.1 mrg 1676 1.1 mrg eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`' 1677 1.1 mrg } 1678 1.1 mrg 1679 1.1 mrg 1680 1.1.1.2 mrg # func_propagate_result FUNC_NAME_A FUNC_NAME_B 1681 1.1.1.2 mrg # --------------------------------------------- 1682 1.1.1.2 mrg # If the *_result variable of FUNC_NAME_A _is set_, assign its value to 1683 1.1.1.2 mrg # *_result variable of FUNC_NAME_B. 1684 1.1.1.2 mrg func_propagate_result () 1685 1.1.1.2 mrg { 1686 1.1.1.2 mrg $debug_cmd 1687 1.1.1.2 mrg 1688 1.1.1.2 mrg func_propagate_result_result=: 1689 1.1.1.2 mrg if eval "test \"\${${1}_result+set}\" = set" 1690 1.1.1.2 mrg then 1691 1.1.1.2 mrg eval "${2}_result=\$${1}_result" 1692 1.1.1.2 mrg else 1693 1.1.1.2 mrg func_propagate_result_result=false 1694 1.1.1.2 mrg fi 1695 1.1.1.2 mrg } 1696 1.1.1.2 mrg 1697 1.1.1.2 mrg 1698 1.1 mrg # func_run_hooks FUNC_NAME [ARG]... 1699 1.1 mrg # --------------------------------- 1700 1.1 mrg # Run all hook functions registered to FUNC_NAME. 1701 1.1.1.2 mrg # It's assumed that the list of hook functions contains nothing more 1702 1.1 mrg # than a whitespace-delimited list of legal shell function names, and 1703 1.1 mrg # no effort is wasted trying to catch shell meta-characters or preserve 1704 1.1 mrg # whitespace. 1705 1.1 mrg func_run_hooks () 1706 1.1 mrg { 1707 1.1 mrg $debug_cmd 1708 1.1 mrg 1709 1.1 mrg case " $hookable_fns " in 1710 1.1 mrg *" $1 "*) ;; 1711 1.1.1.2 mrg *) func_fatal_error "'$1' does not support hook functions." ;; 1712 1.1 mrg esac 1713 1.1 mrg 1714 1.1 mrg eval _G_hook_fns=\$$1_hooks; shift 1715 1.1 mrg 1716 1.1 mrg for _G_hook in $_G_hook_fns; do 1717 1.1.1.2 mrg func_unset "${_G_hook}_result" 1718 1.1.1.2 mrg eval $_G_hook '${1+"$@"}' 1719 1.1.1.2 mrg func_propagate_result $_G_hook func_run_hooks 1720 1.1.1.2 mrg if $func_propagate_result_result; then 1721 1.1.1.2 mrg eval set dummy "$func_run_hooks_result"; shift 1722 1.1.1.2 mrg fi 1723 1.1 mrg done 1724 1.1 mrg } 1725 1.1 mrg 1726 1.1 mrg 1727 1.1 mrg 1728 1.1 mrg ## --------------- ## 1729 1.1 mrg ## Option parsing. ## 1730 1.1 mrg ## --------------- ## 1731 1.1 mrg 1732 1.1 mrg # In order to add your own option parsing hooks, you must accept the 1733 1.1.1.2 mrg # full positional parameter list from your hook function. You may remove 1734 1.1.1.2 mrg # or edit any options that you action, and then pass back the remaining 1735 1.1.1.2 mrg # unprocessed options in '<hooked_function_name>_result', escaped 1736 1.1.1.2 mrg # suitably for 'eval'. 1737 1.1.1.2 mrg # 1738 1.1.1.2 mrg # The '<hooked_function_name>_result' variable is automatically unset 1739 1.1.1.2 mrg # before your hook gets called; for best performance, only set the 1740 1.1.1.2 mrg # *_result variable when necessary (i.e. don't call the 'func_quote' 1741 1.1.1.2 mrg # function unnecessarily because it can be an expensive operation on some 1742 1.1.1.2 mrg # machines). 1743 1.1.1.2 mrg # 1744 1.1.1.2 mrg # Like this: 1745 1.1 mrg # 1746 1.1 mrg # my_options_prep () 1747 1.1 mrg # { 1748 1.1 mrg # $debug_cmd 1749 1.1 mrg # 1750 1.1 mrg # # Extend the existing usage message. 1751 1.1 mrg # usage_message=$usage_message' 1752 1.1 mrg # -s, --silent don'\''t print informational messages 1753 1.1 mrg # ' 1754 1.1.1.2 mrg # # No change in '$@' (ignored completely by this hook). Leave 1755 1.1.1.2 mrg # # my_options_prep_result variable intact. 1756 1.1 mrg # } 1757 1.1 mrg # func_add_hook func_options_prep my_options_prep 1758 1.1 mrg # 1759 1.1 mrg # 1760 1.1 mrg # my_silent_option () 1761 1.1 mrg # { 1762 1.1 mrg # $debug_cmd 1763 1.1 mrg # 1764 1.1.1.2 mrg # args_changed=false 1765 1.1.1.2 mrg # 1766 1.1.1.2 mrg # # Note that, for efficiency, we parse as many options as we can 1767 1.1 mrg # # recognise in a loop before passing the remainder back to the 1768 1.1 mrg # # caller on the first unrecognised argument we encounter. 1769 1.1 mrg # while test $# -gt 0; do 1770 1.1 mrg # opt=$1; shift 1771 1.1 mrg # case $opt in 1772 1.1.1.2 mrg # --silent|-s) opt_silent=: 1773 1.1.1.2 mrg # args_changed=: 1774 1.1.1.2 mrg # ;; 1775 1.1 mrg # # Separate non-argument short options: 1776 1.1 mrg # -s*) func_split_short_opt "$_G_opt" 1777 1.1 mrg # set dummy "$func_split_short_opt_name" \ 1778 1.1 mrg # "-$func_split_short_opt_arg" ${1+"$@"} 1779 1.1 mrg # shift 1780 1.1.1.2 mrg # args_changed=: 1781 1.1 mrg # ;; 1782 1.1.1.2 mrg # *) # Make sure the first unrecognised option "$_G_opt" 1783 1.1.1.2 mrg # # is added back to "$@" in case we need it later, 1784 1.1.1.2 mrg # # if $args_changed was set to 'true'. 1785 1.1.1.2 mrg # set dummy "$_G_opt" ${1+"$@"}; shift; break ;; 1786 1.1 mrg # esac 1787 1.1 mrg # done 1788 1.1 mrg # 1789 1.1.1.2 mrg # # Only call 'func_quote' here if we processed at least one argument. 1790 1.1.1.2 mrg # if $args_changed; then 1791 1.1.1.2 mrg # func_quote eval ${1+"$@"} 1792 1.1.1.2 mrg # my_silent_option_result=$func_quote_result 1793 1.1.1.2 mrg # fi 1794 1.1 mrg # } 1795 1.1 mrg # func_add_hook func_parse_options my_silent_option 1796 1.1 mrg # 1797 1.1 mrg # 1798 1.1 mrg # my_option_validation () 1799 1.1 mrg # { 1800 1.1 mrg # $debug_cmd 1801 1.1 mrg # 1802 1.1 mrg # $opt_silent && $opt_verbose && func_fatal_help "\ 1803 1.1 mrg # '--silent' and '--verbose' options are mutually exclusive." 1804 1.1 mrg # } 1805 1.1 mrg # func_add_hook func_validate_options my_option_validation 1806 1.1 mrg # 1807 1.1.1.2 mrg # You'll also need to manually amend $usage_message to reflect the extra 1808 1.1 mrg # options you parse. It's preferable to append if you can, so that 1809 1.1 mrg # multiple option parsing hooks can be added safely. 1810 1.1 mrg 1811 1.1 mrg 1812 1.1.1.2 mrg # func_options_finish [ARG]... 1813 1.1.1.2 mrg # ---------------------------- 1814 1.1.1.2 mrg # Finishing the option parse loop (call 'func_options' hooks ATM). 1815 1.1.1.2 mrg func_options_finish () 1816 1.1.1.2 mrg { 1817 1.1.1.2 mrg $debug_cmd 1818 1.1.1.2 mrg 1819 1.1.1.2 mrg func_run_hooks func_options ${1+"$@"} 1820 1.1.1.2 mrg func_propagate_result func_run_hooks func_options_finish 1821 1.1.1.2 mrg } 1822 1.1.1.2 mrg 1823 1.1.1.2 mrg 1824 1.1 mrg # func_options [ARG]... 1825 1.1 mrg # --------------------- 1826 1.1 mrg # All the functions called inside func_options are hookable. See the 1827 1.1 mrg # individual implementations for details. 1828 1.1 mrg func_hookable func_options 1829 1.1 mrg func_options () 1830 1.1 mrg { 1831 1.1 mrg $debug_cmd 1832 1.1 mrg 1833 1.1.1.2 mrg _G_options_quoted=false 1834 1.1 mrg 1835 1.1.1.2 mrg for my_func in options_prep parse_options validate_options options_finish 1836 1.1.1.2 mrg do 1837 1.1.1.2 mrg func_unset func_${my_func}_result 1838 1.1.1.2 mrg func_unset func_run_hooks_result 1839 1.1.1.2 mrg eval func_$my_func '${1+"$@"}' 1840 1.1.1.2 mrg func_propagate_result func_$my_func func_options 1841 1.1.1.2 mrg if $func_propagate_result_result; then 1842 1.1.1.2 mrg eval set dummy "$func_options_result"; shift 1843 1.1.1.2 mrg _G_options_quoted=: 1844 1.1.1.2 mrg fi 1845 1.1.1.2 mrg done 1846 1.1 mrg 1847 1.1.1.2 mrg $_G_options_quoted || { 1848 1.1.1.2 mrg # As we (func_options) are top-level options-parser function and 1849 1.1.1.2 mrg # nobody quoted "$@" for us yet, we need to do it explicitly for 1850 1.1.1.2 mrg # caller. 1851 1.1.1.2 mrg func_quote eval ${1+"$@"} 1852 1.1.1.2 mrg func_options_result=$func_quote_result 1853 1.1.1.2 mrg } 1854 1.1 mrg } 1855 1.1 mrg 1856 1.1 mrg 1857 1.1 mrg # func_options_prep [ARG]... 1858 1.1 mrg # -------------------------- 1859 1.1 mrg # All initialisations required before starting the option parse loop. 1860 1.1 mrg # Note that when calling hook functions, we pass through the list of 1861 1.1 mrg # positional parameters. If a hook function modifies that list, and 1862 1.1.1.2 mrg # needs to propagate that back to rest of this script, then the complete 1863 1.1.1.2 mrg # modified list must be put in 'func_run_hooks_result' before returning. 1864 1.1 mrg func_hookable func_options_prep 1865 1.1 mrg func_options_prep () 1866 1.1 mrg { 1867 1.1 mrg $debug_cmd 1868 1.1 mrg 1869 1.1 mrg # Option defaults: 1870 1.1 mrg opt_verbose=false 1871 1.1 mrg opt_warning_types= 1872 1.1 mrg 1873 1.1 mrg func_run_hooks func_options_prep ${1+"$@"} 1874 1.1.1.2 mrg func_propagate_result func_run_hooks func_options_prep 1875 1.1 mrg } 1876 1.1 mrg 1877 1.1 mrg 1878 1.1 mrg # func_parse_options [ARG]... 1879 1.1 mrg # --------------------------- 1880 1.1 mrg # The main option parsing loop. 1881 1.1 mrg func_hookable func_parse_options 1882 1.1 mrg func_parse_options () 1883 1.1 mrg { 1884 1.1 mrg $debug_cmd 1885 1.1 mrg 1886 1.1.1.2 mrg _G_parse_options_requote=false 1887 1.1 mrg # this just eases exit handling 1888 1.1 mrg while test $# -gt 0; do 1889 1.1 mrg # Defer to hook functions for initial option parsing, so they 1890 1.1 mrg # get priority in the event of reusing an option name. 1891 1.1 mrg func_run_hooks func_parse_options ${1+"$@"} 1892 1.1.1.2 mrg func_propagate_result func_run_hooks func_parse_options 1893 1.1.1.2 mrg if $func_propagate_result_result; then 1894 1.1.1.2 mrg eval set dummy "$func_parse_options_result"; shift 1895 1.1.1.2 mrg # Even though we may have changed "$@", we passed the "$@" array 1896 1.1.1.2 mrg # down into the hook and it quoted it for us (because we are in 1897 1.1.1.2 mrg # this if-branch). No need to quote it again. 1898 1.1.1.2 mrg _G_parse_options_requote=false 1899 1.1.1.2 mrg fi 1900 1.1 mrg 1901 1.1 mrg # Break out of the loop if we already parsed every option. 1902 1.1 mrg test $# -gt 0 || break 1903 1.1 mrg 1904 1.1.1.2 mrg # We expect that one of the options parsed in this function matches 1905 1.1.1.2 mrg # and thus we remove _G_opt from "$@" and need to re-quote. 1906 1.1.1.2 mrg _G_match_parse_options=: 1907 1.1 mrg _G_opt=$1 1908 1.1 mrg shift 1909 1.1 mrg case $_G_opt in 1910 1.1 mrg --debug|-x) debug_cmd='set -x' 1911 1.1.1.2 mrg func_echo "enabling shell trace mode" >&2 1912 1.1 mrg $debug_cmd 1913 1.1 mrg ;; 1914 1.1 mrg 1915 1.1 mrg --no-warnings|--no-warning|--no-warn) 1916 1.1 mrg set dummy --warnings none ${1+"$@"} 1917 1.1 mrg shift 1918 1.1 mrg ;; 1919 1.1 mrg 1920 1.1 mrg --warnings|--warning|-W) 1921 1.1.1.2 mrg if test $# = 0 && func_missing_arg $_G_opt; then 1922 1.1.1.2 mrg _G_parse_options_requote=: 1923 1.1.1.2 mrg break 1924 1.1.1.2 mrg fi 1925 1.1 mrg case " $warning_categories $1" in 1926 1.1 mrg *" $1 "*) 1927 1.1 mrg # trailing space prevents matching last $1 above 1928 1.1 mrg func_append_uniq opt_warning_types " $1" 1929 1.1 mrg ;; 1930 1.1 mrg *all) 1931 1.1 mrg opt_warning_types=$warning_categories 1932 1.1 mrg ;; 1933 1.1 mrg *none) 1934 1.1 mrg opt_warning_types=none 1935 1.1 mrg warning_func=: 1936 1.1 mrg ;; 1937 1.1 mrg *error) 1938 1.1 mrg opt_warning_types=$warning_categories 1939 1.1 mrg warning_func=func_fatal_error 1940 1.1 mrg ;; 1941 1.1 mrg *) 1942 1.1 mrg func_fatal_error \ 1943 1.1 mrg "unsupported warning category: '$1'" 1944 1.1 mrg ;; 1945 1.1 mrg esac 1946 1.1 mrg shift 1947 1.1 mrg ;; 1948 1.1 mrg 1949 1.1 mrg --verbose|-v) opt_verbose=: ;; 1950 1.1 mrg --version) func_version ;; 1951 1.1 mrg -\?|-h) func_usage ;; 1952 1.1 mrg --help) func_help ;; 1953 1.1 mrg 1954 1.1 mrg # Separate optargs to long options (plugins may need this): 1955 1.1 mrg --*=*) func_split_equals "$_G_opt" 1956 1.1 mrg set dummy "$func_split_equals_lhs" \ 1957 1.1 mrg "$func_split_equals_rhs" ${1+"$@"} 1958 1.1 mrg shift 1959 1.1 mrg ;; 1960 1.1 mrg 1961 1.1 mrg # Separate optargs to short options: 1962 1.1 mrg -W*) 1963 1.1 mrg func_split_short_opt "$_G_opt" 1964 1.1 mrg set dummy "$func_split_short_opt_name" \ 1965 1.1 mrg "$func_split_short_opt_arg" ${1+"$@"} 1966 1.1 mrg shift 1967 1.1 mrg ;; 1968 1.1 mrg 1969 1.1 mrg # Separate non-argument short options: 1970 1.1 mrg -\?*|-h*|-v*|-x*) 1971 1.1 mrg func_split_short_opt "$_G_opt" 1972 1.1 mrg set dummy "$func_split_short_opt_name" \ 1973 1.1 mrg "-$func_split_short_opt_arg" ${1+"$@"} 1974 1.1 mrg shift 1975 1.1 mrg ;; 1976 1.1 mrg 1977 1.1.1.2 mrg --) _G_parse_options_requote=: ; break ;; 1978 1.1 mrg -*) func_fatal_help "unrecognised option: '$_G_opt'" ;; 1979 1.1.1.2 mrg *) set dummy "$_G_opt" ${1+"$@"}; shift 1980 1.1.1.2 mrg _G_match_parse_options=false 1981 1.1.1.2 mrg break 1982 1.1.1.2 mrg ;; 1983 1.1 mrg esac 1984 1.1.1.2 mrg 1985 1.1.1.2 mrg if $_G_match_parse_options; then 1986 1.1.1.2 mrg _G_parse_options_requote=: 1987 1.1.1.2 mrg fi 1988 1.1 mrg done 1989 1.1 mrg 1990 1.1.1.2 mrg if $_G_parse_options_requote; then 1991 1.1.1.2 mrg # save modified positional parameters for caller 1992 1.1.1.2 mrg func_quote eval ${1+"$@"} 1993 1.1.1.2 mrg func_parse_options_result=$func_quote_result 1994 1.1.1.2 mrg fi 1995 1.1 mrg } 1996 1.1 mrg 1997 1.1 mrg 1998 1.1 mrg # func_validate_options [ARG]... 1999 1.1 mrg # ------------------------------ 2000 1.1 mrg # Perform any sanity checks on option settings and/or unconsumed 2001 1.1 mrg # arguments. 2002 1.1 mrg func_hookable func_validate_options 2003 1.1 mrg func_validate_options () 2004 1.1 mrg { 2005 1.1 mrg $debug_cmd 2006 1.1 mrg 2007 1.1 mrg # Display all warnings if -W was not given. 2008 1.1 mrg test -n "$opt_warning_types" || opt_warning_types=" $warning_categories" 2009 1.1 mrg 2010 1.1 mrg func_run_hooks func_validate_options ${1+"$@"} 2011 1.1.1.2 mrg func_propagate_result func_run_hooks func_validate_options 2012 1.1 mrg 2013 1.1 mrg # Bail if the options were screwed! 2014 1.1 mrg $exit_cmd $EXIT_FAILURE 2015 1.1 mrg } 2016 1.1 mrg 2017 1.1 mrg 2018 1.1 mrg 2019 1.1 mrg ## ----------------- ## 2020 1.1 mrg ## Helper functions. ## 2021 1.1 mrg ## ----------------- ## 2022 1.1 mrg 2023 1.1 mrg # This section contains the helper functions used by the rest of the 2024 1.1 mrg # hookable option parser framework in ascii-betical order. 2025 1.1 mrg 2026 1.1 mrg 2027 1.1 mrg # func_fatal_help ARG... 2028 1.1 mrg # ---------------------- 2029 1.1 mrg # Echo program name prefixed message to standard error, followed by 2030 1.1 mrg # a help hint, and exit. 2031 1.1 mrg func_fatal_help () 2032 1.1 mrg { 2033 1.1 mrg $debug_cmd 2034 1.1 mrg 2035 1.1 mrg eval \$ECHO \""Usage: $usage"\" 2036 1.1 mrg eval \$ECHO \""$fatal_help"\" 2037 1.1 mrg func_error ${1+"$@"} 2038 1.1 mrg exit $EXIT_FAILURE 2039 1.1 mrg } 2040 1.1 mrg 2041 1.1 mrg 2042 1.1 mrg # func_help 2043 1.1 mrg # --------- 2044 1.1 mrg # Echo long help message to standard output and exit. 2045 1.1 mrg func_help () 2046 1.1 mrg { 2047 1.1 mrg $debug_cmd 2048 1.1 mrg 2049 1.1 mrg func_usage_message 2050 1.1 mrg $ECHO "$long_help_message" 2051 1.1 mrg exit 0 2052 1.1 mrg } 2053 1.1 mrg 2054 1.1 mrg 2055 1.1 mrg # func_missing_arg ARGNAME 2056 1.1 mrg # ------------------------ 2057 1.1 mrg # Echo program name prefixed message to standard error and set global 2058 1.1 mrg # exit_cmd. 2059 1.1 mrg func_missing_arg () 2060 1.1 mrg { 2061 1.1 mrg $debug_cmd 2062 1.1 mrg 2063 1.1 mrg func_error "Missing argument for '$1'." 2064 1.1 mrg exit_cmd=exit 2065 1.1 mrg } 2066 1.1 mrg 2067 1.1 mrg 2068 1.1 mrg # func_split_equals STRING 2069 1.1 mrg # ------------------------ 2070 1.1.1.2 mrg # Set func_split_equals_lhs and func_split_equals_rhs shell variables 2071 1.1.1.2 mrg # after splitting STRING at the '=' sign. 2072 1.1 mrg test -z "$_G_HAVE_XSI_OPS" \ 2073 1.1 mrg && (eval 'x=a/b/c; 2074 1.1 mrg test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \ 2075 1.1 mrg && _G_HAVE_XSI_OPS=yes 2076 1.1 mrg 2077 1.1 mrg if test yes = "$_G_HAVE_XSI_OPS" 2078 1.1 mrg then 2079 1.1 mrg # This is an XSI compatible shell, allowing a faster implementation... 2080 1.1 mrg eval 'func_split_equals () 2081 1.1 mrg { 2082 1.1 mrg $debug_cmd 2083 1.1 mrg 2084 1.1 mrg func_split_equals_lhs=${1%%=*} 2085 1.1 mrg func_split_equals_rhs=${1#*=} 2086 1.1.1.2 mrg if test "x$func_split_equals_lhs" = "x$1"; then 2087 1.1.1.2 mrg func_split_equals_rhs= 2088 1.1.1.2 mrg fi 2089 1.1 mrg }' 2090 1.1 mrg else 2091 1.1 mrg # ...otherwise fall back to using expr, which is often a shell builtin. 2092 1.1 mrg func_split_equals () 2093 1.1 mrg { 2094 1.1 mrg $debug_cmd 2095 1.1 mrg 2096 1.1 mrg func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'` 2097 1.1 mrg func_split_equals_rhs= 2098 1.1.1.2 mrg test "x$func_split_equals_lhs=" = "x$1" \ 2099 1.1 mrg || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'` 2100 1.1 mrg } 2101 1.1 mrg fi #func_split_equals 2102 1.1 mrg 2103 1.1 mrg 2104 1.1 mrg # func_split_short_opt SHORTOPT 2105 1.1 mrg # ----------------------------- 2106 1.1 mrg # Set func_split_short_opt_name and func_split_short_opt_arg shell 2107 1.1 mrg # variables after splitting SHORTOPT after the 2nd character. 2108 1.1 mrg if test yes = "$_G_HAVE_XSI_OPS" 2109 1.1 mrg then 2110 1.1 mrg # This is an XSI compatible shell, allowing a faster implementation... 2111 1.1 mrg eval 'func_split_short_opt () 2112 1.1 mrg { 2113 1.1 mrg $debug_cmd 2114 1.1 mrg 2115 1.1 mrg func_split_short_opt_arg=${1#??} 2116 1.1 mrg func_split_short_opt_name=${1%"$func_split_short_opt_arg"} 2117 1.1 mrg }' 2118 1.1 mrg else 2119 1.1 mrg # ...otherwise fall back to using expr, which is often a shell builtin. 2120 1.1 mrg func_split_short_opt () 2121 1.1 mrg { 2122 1.1 mrg $debug_cmd 2123 1.1 mrg 2124 1.1.1.2 mrg func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'` 2125 1.1 mrg func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'` 2126 1.1 mrg } 2127 1.1 mrg fi #func_split_short_opt 2128 1.1 mrg 2129 1.1 mrg 2130 1.1 mrg # func_usage 2131 1.1 mrg # ---------- 2132 1.1 mrg # Echo short help message to standard output and exit. 2133 1.1 mrg func_usage () 2134 1.1 mrg { 2135 1.1 mrg $debug_cmd 2136 1.1 mrg 2137 1.1 mrg func_usage_message 2138 1.1 mrg $ECHO "Run '$progname --help |${PAGER-more}' for full usage" 2139 1.1 mrg exit 0 2140 1.1 mrg } 2141 1.1 mrg 2142 1.1 mrg 2143 1.1 mrg # func_usage_message 2144 1.1 mrg # ------------------ 2145 1.1 mrg # Echo short help message to standard output. 2146 1.1 mrg func_usage_message () 2147 1.1 mrg { 2148 1.1 mrg $debug_cmd 2149 1.1 mrg 2150 1.1 mrg eval \$ECHO \""Usage: $usage"\" 2151 1.1 mrg echo 2152 1.1 mrg $SED -n 's|^# || 2153 1.1 mrg /^Written by/{ 2154 1.1 mrg x;p;x 2155 1.1 mrg } 2156 1.1 mrg h 2157 1.1 mrg /^Written by/q' < "$progpath" 2158 1.1 mrg echo 2159 1.1 mrg eval \$ECHO \""$usage_message"\" 2160 1.1 mrg } 2161 1.1 mrg 2162 1.1 mrg 2163 1.1 mrg # func_version 2164 1.1 mrg # ------------ 2165 1.1 mrg # Echo version message to standard output and exit. 2166 1.1.1.2 mrg # The version message is extracted from the calling file's header 2167 1.1.1.2 mrg # comments, with leading '# ' stripped: 2168 1.1.1.2 mrg # 1. First display the progname and version 2169 1.1.1.2 mrg # 2. Followed by the header comment line matching /^# Written by / 2170 1.1.1.2 mrg # 3. Then a blank line followed by the first following line matching 2171 1.1.1.2 mrg # /^# Copyright / 2172 1.1.1.2 mrg # 4. Immediately followed by any lines between the previous matches, 2173 1.1.1.2 mrg # except lines preceding the intervening completely blank line. 2174 1.1.1.2 mrg # For example, see the header comments of this file. 2175 1.1 mrg func_version () 2176 1.1 mrg { 2177 1.1 mrg $debug_cmd 2178 1.1 mrg 2179 1.1 mrg printf '%s\n' "$progname $scriptversion" 2180 1.1 mrg $SED -n ' 2181 1.1.1.2 mrg /^# Written by /!b 2182 1.1.1.2 mrg s|^# ||; p; n 2183 1.1.1.2 mrg 2184 1.1.1.2 mrg :fwd2blnk 2185 1.1.1.2 mrg /./ { 2186 1.1.1.2 mrg n 2187 1.1.1.2 mrg b fwd2blnk 2188 1.1 mrg } 2189 1.1.1.2 mrg p; n 2190 1.1.1.2 mrg 2191 1.1.1.2 mrg :holdwrnt 2192 1.1.1.2 mrg s|^# || 2193 1.1.1.2 mrg s|^# *$|| 2194 1.1.1.2 mrg /^Copyright /!{ 2195 1.1.1.2 mrg /./H 2196 1.1.1.2 mrg n 2197 1.1.1.2 mrg b holdwrnt 2198 1.1 mrg } 2199 1.1.1.2 mrg 2200 1.1.1.2 mrg s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2| 2201 1.1.1.2 mrg G 2202 1.1.1.2 mrg s|\(\n\)\n*|\1|g 2203 1.1.1.2 mrg p; q' < "$progpath" 2204 1.1 mrg 2205 1.1 mrg exit $? 2206 1.1 mrg } 2207 1.1 mrg 2208 1.1 mrg 2209 1.1 mrg # Local variables: 2210 1.1 mrg # mode: shell-script 2211 1.1 mrg # sh-indentation: 2 2212 1.1 mrg # eval: (add-hook 'before-save-hook 'time-stamp) 2213 1.1.1.2 mrg # time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC" 2214 1.1 mrg # time-stamp-time-zone: "UTC" 2215 1.1 mrg # End: 2216 1.1 mrg 2217 1.1 mrg # Set a version string. 2218 1.1.1.2 mrg scriptversion='(GNU libtool) 2.4.7' 2219 1.1 mrg 2220 1.1 mrg 2221 1.1 mrg # func_echo ARG... 2222 1.1 mrg # ---------------- 2223 1.1 mrg # Libtool also displays the current mode in messages, so override 2224 1.1 mrg # funclib.sh func_echo with this custom definition. 2225 1.1 mrg func_echo () 2226 1.1 mrg { 2227 1.1 mrg $debug_cmd 2228 1.1 mrg 2229 1.1 mrg _G_message=$* 2230 1.1 mrg 2231 1.1 mrg func_echo_IFS=$IFS 2232 1.1 mrg IFS=$nl 2233 1.1 mrg for _G_line in $_G_message; do 2234 1.1 mrg IFS=$func_echo_IFS 2235 1.1 mrg $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line" 2236 1.1 mrg done 2237 1.1 mrg IFS=$func_echo_IFS 2238 1.1 mrg } 2239 1.1 mrg 2240 1.1 mrg 2241 1.1 mrg # func_warning ARG... 2242 1.1 mrg # ------------------- 2243 1.1 mrg # Libtool warnings are not categorized, so override funclib.sh 2244 1.1 mrg # func_warning with this simpler definition. 2245 1.1 mrg func_warning () 2246 1.1 mrg { 2247 1.1 mrg $debug_cmd 2248 1.1 mrg 2249 1.1 mrg $warning_func ${1+"$@"} 2250 1.1 mrg } 2251 1.1 mrg 2252 1.1 mrg 2253 1.1 mrg ## ---------------- ## 2254 1.1 mrg ## Options parsing. ## 2255 1.1 mrg ## ---------------- ## 2256 1.1 mrg 2257 1.1 mrg # Hook in the functions to make sure our own options are parsed during 2258 1.1 mrg # the option parsing loop. 2259 1.1 mrg 2260 1.1 mrg usage='$progpath [OPTION]... [MODE-ARG]...' 2261 1.1 mrg 2262 1.1 mrg # Short help message in response to '-h'. 2263 1.1 mrg usage_message="Options: 2264 1.1 mrg --config show all configuration variables 2265 1.1 mrg --debug enable verbose shell tracing 2266 1.1 mrg -n, --dry-run display commands without modifying any files 2267 1.1 mrg --features display basic configuration information and exit 2268 1.1 mrg --mode=MODE use operation mode MODE 2269 1.1 mrg --no-warnings equivalent to '-Wnone' 2270 1.1 mrg --preserve-dup-deps don't remove duplicate dependency libraries 2271 1.1 mrg --quiet, --silent don't print informational messages 2272 1.1 mrg --tag=TAG use configuration variables from tag TAG 2273 1.1 mrg -v, --verbose print more informational messages than default 2274 1.1 mrg --version print version information 2275 1.1 mrg -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all] 2276 1.1 mrg -h, --help, --help-all print short, long, or detailed help message 2277 1.1 mrg " 2278 1.1 mrg 2279 1.1 mrg # Additional text appended to 'usage_message' in response to '--help'. 2280 1.1 mrg func_help () 2281 1.1 mrg { 2282 1.1 mrg $debug_cmd 2283 1.1 mrg 2284 1.1 mrg func_usage_message 2285 1.1 mrg $ECHO "$long_help_message 2286 1.1 mrg 2287 1.1 mrg MODE must be one of the following: 2288 1.1 mrg 2289 1.1 mrg clean remove files from the build directory 2290 1.1 mrg compile compile a source file into a libtool object 2291 1.1 mrg execute automatically set library path, then run a program 2292 1.1 mrg finish complete the installation of libtool libraries 2293 1.1 mrg install install libraries or executables 2294 1.1 mrg link create a library or an executable 2295 1.1 mrg uninstall remove libraries from an installed directory 2296 1.1 mrg 2297 1.1 mrg MODE-ARGS vary depending on the MODE. When passed as first option, 2298 1.1 mrg '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that. 2299 1.1 mrg Try '$progname --help --mode=MODE' for a more detailed description of MODE. 2300 1.1 mrg 2301 1.1 mrg When reporting a bug, please describe a test case to reproduce it and 2302 1.1 mrg include the following information: 2303 1.1 mrg 2304 1.1 mrg host-triplet: $host 2305 1.1 mrg shell: $SHELL 2306 1.1 mrg compiler: $LTCC 2307 1.1 mrg compiler flags: $LTCFLAGS 2308 1.1 mrg linker: $LD (gnu? $with_gnu_ld) 2309 1.1.1.2 mrg version: $progname (GNU libtool) 2.4.7 2310 1.1 mrg automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q` 2311 1.1 mrg autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q` 2312 1.1 mrg 2313 1.1 mrg Report bugs to <bug-libtool (at] gnu.org>. 2314 1.1 mrg GNU libtool home page: <http://www.gnu.org/software/libtool/>. 2315 1.1 mrg General help using GNU software: <http://www.gnu.org/gethelp/>." 2316 1.1 mrg exit 0 2317 1.1 mrg } 2318 1.1 mrg 2319 1.1 mrg 2320 1.1 mrg # func_lo2o OBJECT-NAME 2321 1.1 mrg # --------------------- 2322 1.1 mrg # Transform OBJECT-NAME from a '.lo' suffix to the platform specific 2323 1.1 mrg # object suffix. 2324 1.1 mrg 2325 1.1 mrg lo2o=s/\\.lo\$/.$objext/ 2326 1.1 mrg o2lo=s/\\.$objext\$/.lo/ 2327 1.1 mrg 2328 1.1 mrg if test yes = "$_G_HAVE_XSI_OPS"; then 2329 1.1 mrg eval 'func_lo2o () 2330 1.1 mrg { 2331 1.1 mrg case $1 in 2332 1.1 mrg *.lo) func_lo2o_result=${1%.lo}.$objext ;; 2333 1.1 mrg * ) func_lo2o_result=$1 ;; 2334 1.1 mrg esac 2335 1.1 mrg }' 2336 1.1 mrg 2337 1.1 mrg # func_xform LIBOBJ-OR-SOURCE 2338 1.1 mrg # --------------------------- 2339 1.1 mrg # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise) 2340 1.1 mrg # suffix to a '.lo' libtool-object suffix. 2341 1.1 mrg eval 'func_xform () 2342 1.1 mrg { 2343 1.1 mrg func_xform_result=${1%.*}.lo 2344 1.1 mrg }' 2345 1.1 mrg else 2346 1.1 mrg # ...otherwise fall back to using sed. 2347 1.1 mrg func_lo2o () 2348 1.1 mrg { 2349 1.1 mrg func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"` 2350 1.1 mrg } 2351 1.1 mrg 2352 1.1 mrg func_xform () 2353 1.1 mrg { 2354 1.1 mrg func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'` 2355 1.1 mrg } 2356 1.1 mrg fi 2357 1.1 mrg 2358 1.1 mrg 2359 1.1 mrg # func_fatal_configuration ARG... 2360 1.1 mrg # ------------------------------- 2361 1.1 mrg # Echo program name prefixed message to standard error, followed by 2362 1.1 mrg # a configuration failure hint, and exit. 2363 1.1 mrg func_fatal_configuration () 2364 1.1 mrg { 2365 1.1.1.2 mrg func_fatal_error ${1+"$@"} \ 2366 1.1 mrg "See the $PACKAGE documentation for more information." \ 2367 1.1 mrg "Fatal configuration error." 2368 1.1 mrg } 2369 1.1 mrg 2370 1.1 mrg 2371 1.1 mrg # func_config 2372 1.1 mrg # ----------- 2373 1.1 mrg # Display the configuration for all the tags in this script. 2374 1.1 mrg func_config () 2375 1.1 mrg { 2376 1.1 mrg re_begincf='^# ### BEGIN LIBTOOL' 2377 1.1 mrg re_endcf='^# ### END LIBTOOL' 2378 1.1 mrg 2379 1.1 mrg # Default configuration. 2380 1.1 mrg $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath" 2381 1.1 mrg 2382 1.1 mrg # Now print the configurations for the tags. 2383 1.1 mrg for tagname in $taglist; do 2384 1.1 mrg $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath" 2385 1.1 mrg done 2386 1.1 mrg 2387 1.1 mrg exit $? 2388 1.1 mrg } 2389 1.1 mrg 2390 1.1 mrg 2391 1.1 mrg # func_features 2392 1.1 mrg # ------------- 2393 1.1 mrg # Display the features supported by this script. 2394 1.1 mrg func_features () 2395 1.1 mrg { 2396 1.1 mrg echo "host: $host" 2397 1.1 mrg if test yes = "$build_libtool_libs"; then 2398 1.1 mrg echo "enable shared libraries" 2399 1.1 mrg else 2400 1.1 mrg echo "disable shared libraries" 2401 1.1 mrg fi 2402 1.1 mrg if test yes = "$build_old_libs"; then 2403 1.1 mrg echo "enable static libraries" 2404 1.1 mrg else 2405 1.1 mrg echo "disable static libraries" 2406 1.1 mrg fi 2407 1.1 mrg 2408 1.1 mrg exit $? 2409 1.1 mrg } 2410 1.1 mrg 2411 1.1 mrg 2412 1.1 mrg # func_enable_tag TAGNAME 2413 1.1 mrg # ----------------------- 2414 1.1 mrg # Verify that TAGNAME is valid, and either flag an error and exit, or 2415 1.1 mrg # enable the TAGNAME tag. We also add TAGNAME to the global $taglist 2416 1.1 mrg # variable here. 2417 1.1 mrg func_enable_tag () 2418 1.1 mrg { 2419 1.1 mrg # Global variable: 2420 1.1 mrg tagname=$1 2421 1.1 mrg 2422 1.1 mrg re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$" 2423 1.1 mrg re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$" 2424 1.1 mrg sed_extractcf=/$re_begincf/,/$re_endcf/p 2425 1.1 mrg 2426 1.1 mrg # Validate tagname. 2427 1.1 mrg case $tagname in 2428 1.1 mrg *[!-_A-Za-z0-9,/]*) 2429 1.1 mrg func_fatal_error "invalid tag name: $tagname" 2430 1.1 mrg ;; 2431 1.1 mrg esac 2432 1.1 mrg 2433 1.1 mrg # Don't test for the "default" C tag, as we know it's 2434 1.1 mrg # there but not specially marked. 2435 1.1 mrg case $tagname in 2436 1.1 mrg CC) ;; 2437 1.1 mrg *) 2438 1.1 mrg if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then 2439 1.1 mrg taglist="$taglist $tagname" 2440 1.1 mrg 2441 1.1 mrg # Evaluate the configuration. Be careful to quote the path 2442 1.1 mrg # and the sed script, to avoid splitting on whitespace, but 2443 1.1 mrg # also don't use non-portable quotes within backquotes within 2444 1.1 mrg # quotes we have to do it in 2 steps: 2445 1.1 mrg extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"` 2446 1.1 mrg eval "$extractedcf" 2447 1.1 mrg else 2448 1.1 mrg func_error "ignoring unknown tag $tagname" 2449 1.1 mrg fi 2450 1.1 mrg ;; 2451 1.1 mrg esac 2452 1.1 mrg } 2453 1.1 mrg 2454 1.1 mrg 2455 1.1 mrg # func_check_version_match 2456 1.1 mrg # ------------------------ 2457 1.1 mrg # Ensure that we are using m4 macros, and libtool script from the same 2458 1.1 mrg # release of libtool. 2459 1.1 mrg func_check_version_match () 2460 1.1 mrg { 2461 1.1 mrg if test "$package_revision" != "$macro_revision"; then 2462 1.1 mrg if test "$VERSION" != "$macro_version"; then 2463 1.1 mrg if test -z "$macro_version"; then 2464 1.1 mrg cat >&2 <<_LT_EOF 2465 1.1 mrg $progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2466 1.1 mrg $progname: definition of this LT_INIT comes from an older release. 2467 1.1 mrg $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2468 1.1 mrg $progname: and run autoconf again. 2469 1.1 mrg _LT_EOF 2470 1.1 mrg else 2471 1.1 mrg cat >&2 <<_LT_EOF 2472 1.1 mrg $progname: Version mismatch error. This is $PACKAGE $VERSION, but the 2473 1.1 mrg $progname: definition of this LT_INIT comes from $PACKAGE $macro_version. 2474 1.1 mrg $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION 2475 1.1 mrg $progname: and run autoconf again. 2476 1.1 mrg _LT_EOF 2477 1.1 mrg fi 2478 1.1 mrg else 2479 1.1 mrg cat >&2 <<_LT_EOF 2480 1.1 mrg $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision, 2481 1.1 mrg $progname: but the definition of this LT_INIT comes from revision $macro_revision. 2482 1.1 mrg $progname: You should recreate aclocal.m4 with macros from revision $package_revision 2483 1.1 mrg $progname: of $PACKAGE $VERSION and run autoconf again. 2484 1.1 mrg _LT_EOF 2485 1.1 mrg fi 2486 1.1 mrg 2487 1.1 mrg exit $EXIT_MISMATCH 2488 1.1 mrg fi 2489 1.1 mrg } 2490 1.1 mrg 2491 1.1 mrg 2492 1.1 mrg # libtool_options_prep [ARG]... 2493 1.1 mrg # ----------------------------- 2494 1.1 mrg # Preparation for options parsed by libtool. 2495 1.1 mrg libtool_options_prep () 2496 1.1 mrg { 2497 1.1 mrg $debug_mode 2498 1.1 mrg 2499 1.1 mrg # Option defaults: 2500 1.1 mrg opt_config=false 2501 1.1 mrg opt_dlopen= 2502 1.1 mrg opt_dry_run=false 2503 1.1 mrg opt_help=false 2504 1.1 mrg opt_mode= 2505 1.1 mrg opt_preserve_dup_deps=false 2506 1.1 mrg opt_quiet=false 2507 1.1 mrg 2508 1.1 mrg nonopt= 2509 1.1 mrg preserve_args= 2510 1.1 mrg 2511 1.1.1.2 mrg _G_rc_lt_options_prep=: 2512 1.1.1.2 mrg 2513 1.1 mrg # Shorthand for --mode=foo, only valid as the first argument 2514 1.1 mrg case $1 in 2515 1.1 mrg clean|clea|cle|cl) 2516 1.1 mrg shift; set dummy --mode clean ${1+"$@"}; shift 2517 1.1 mrg ;; 2518 1.1 mrg compile|compil|compi|comp|com|co|c) 2519 1.1 mrg shift; set dummy --mode compile ${1+"$@"}; shift 2520 1.1 mrg ;; 2521 1.1 mrg execute|execut|execu|exec|exe|ex|e) 2522 1.1 mrg shift; set dummy --mode execute ${1+"$@"}; shift 2523 1.1 mrg ;; 2524 1.1 mrg finish|finis|fini|fin|fi|f) 2525 1.1 mrg shift; set dummy --mode finish ${1+"$@"}; shift 2526 1.1 mrg ;; 2527 1.1 mrg install|instal|insta|inst|ins|in|i) 2528 1.1 mrg shift; set dummy --mode install ${1+"$@"}; shift 2529 1.1 mrg ;; 2530 1.1 mrg link|lin|li|l) 2531 1.1 mrg shift; set dummy --mode link ${1+"$@"}; shift 2532 1.1 mrg ;; 2533 1.1 mrg uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u) 2534 1.1 mrg shift; set dummy --mode uninstall ${1+"$@"}; shift 2535 1.1 mrg ;; 2536 1.1.1.2 mrg *) 2537 1.1.1.2 mrg _G_rc_lt_options_prep=false 2538 1.1.1.2 mrg ;; 2539 1.1 mrg esac 2540 1.1 mrg 2541 1.1.1.2 mrg if $_G_rc_lt_options_prep; then 2542 1.1.1.2 mrg # Pass back the list of options. 2543 1.1.1.2 mrg func_quote eval ${1+"$@"} 2544 1.1.1.2 mrg libtool_options_prep_result=$func_quote_result 2545 1.1.1.2 mrg fi 2546 1.1 mrg } 2547 1.1 mrg func_add_hook func_options_prep libtool_options_prep 2548 1.1 mrg 2549 1.1 mrg 2550 1.1 mrg # libtool_parse_options [ARG]... 2551 1.1 mrg # --------------------------------- 2552 1.1 mrg # Provide handling for libtool specific options. 2553 1.1 mrg libtool_parse_options () 2554 1.1 mrg { 2555 1.1 mrg $debug_cmd 2556 1.1 mrg 2557 1.1.1.2 mrg _G_rc_lt_parse_options=false 2558 1.1.1.2 mrg 2559 1.1 mrg # Perform our own loop to consume as many options as possible in 2560 1.1 mrg # each iteration. 2561 1.1 mrg while test $# -gt 0; do 2562 1.1.1.2 mrg _G_match_lt_parse_options=: 2563 1.1 mrg _G_opt=$1 2564 1.1 mrg shift 2565 1.1 mrg case $_G_opt in 2566 1.1 mrg --dry-run|--dryrun|-n) 2567 1.1 mrg opt_dry_run=: 2568 1.1 mrg ;; 2569 1.1 mrg 2570 1.1 mrg --config) func_config ;; 2571 1.1 mrg 2572 1.1 mrg --dlopen|-dlopen) 2573 1.1 mrg opt_dlopen="${opt_dlopen+$opt_dlopen 2574 1.1 mrg }$1" 2575 1.1 mrg shift 2576 1.1 mrg ;; 2577 1.1 mrg 2578 1.1 mrg --preserve-dup-deps) 2579 1.1 mrg opt_preserve_dup_deps=: ;; 2580 1.1 mrg 2581 1.1 mrg --features) func_features ;; 2582 1.1 mrg 2583 1.1 mrg --finish) set dummy --mode finish ${1+"$@"}; shift ;; 2584 1.1 mrg 2585 1.1 mrg --help) opt_help=: ;; 2586 1.1 mrg 2587 1.1 mrg --help-all) opt_help=': help-all' ;; 2588 1.1 mrg 2589 1.1 mrg --mode) test $# = 0 && func_missing_arg $_G_opt && break 2590 1.1 mrg opt_mode=$1 2591 1.1 mrg case $1 in 2592 1.1 mrg # Valid mode arguments: 2593 1.1 mrg clean|compile|execute|finish|install|link|relink|uninstall) ;; 2594 1.1 mrg 2595 1.1 mrg # Catch anything else as an error 2596 1.1 mrg *) func_error "invalid argument for $_G_opt" 2597 1.1 mrg exit_cmd=exit 2598 1.1 mrg break 2599 1.1 mrg ;; 2600 1.1 mrg esac 2601 1.1 mrg shift 2602 1.1 mrg ;; 2603 1.1 mrg 2604 1.1 mrg --no-silent|--no-quiet) 2605 1.1 mrg opt_quiet=false 2606 1.1 mrg func_append preserve_args " $_G_opt" 2607 1.1 mrg ;; 2608 1.1 mrg 2609 1.1 mrg --no-warnings|--no-warning|--no-warn) 2610 1.1 mrg opt_warning=false 2611 1.1 mrg func_append preserve_args " $_G_opt" 2612 1.1 mrg ;; 2613 1.1 mrg 2614 1.1 mrg --no-verbose) 2615 1.1 mrg opt_verbose=false 2616 1.1 mrg func_append preserve_args " $_G_opt" 2617 1.1 mrg ;; 2618 1.1 mrg 2619 1.1 mrg --silent|--quiet) 2620 1.1 mrg opt_quiet=: 2621 1.1 mrg opt_verbose=false 2622 1.1 mrg func_append preserve_args " $_G_opt" 2623 1.1 mrg ;; 2624 1.1 mrg 2625 1.1 mrg --tag) test $# = 0 && func_missing_arg $_G_opt && break 2626 1.1 mrg opt_tag=$1 2627 1.1 mrg func_append preserve_args " $_G_opt $1" 2628 1.1 mrg func_enable_tag "$1" 2629 1.1 mrg shift 2630 1.1 mrg ;; 2631 1.1 mrg 2632 1.1 mrg --verbose|-v) opt_quiet=false 2633 1.1 mrg opt_verbose=: 2634 1.1 mrg func_append preserve_args " $_G_opt" 2635 1.1 mrg ;; 2636 1.1 mrg 2637 1.1.1.2 mrg # An option not handled by this hook function: 2638 1.1.1.2 mrg *) set dummy "$_G_opt" ${1+"$@"} ; shift 2639 1.1.1.2 mrg _G_match_lt_parse_options=false 2640 1.1.1.2 mrg break 2641 1.1.1.2 mrg ;; 2642 1.1 mrg esac 2643 1.1.1.2 mrg $_G_match_lt_parse_options && _G_rc_lt_parse_options=: 2644 1.1 mrg done 2645 1.1 mrg 2646 1.1.1.2 mrg if $_G_rc_lt_parse_options; then 2647 1.1.1.2 mrg # save modified positional parameters for caller 2648 1.1.1.2 mrg func_quote eval ${1+"$@"} 2649 1.1.1.2 mrg libtool_parse_options_result=$func_quote_result 2650 1.1.1.2 mrg fi 2651 1.1 mrg } 2652 1.1 mrg func_add_hook func_parse_options libtool_parse_options 2653 1.1 mrg 2654 1.1 mrg 2655 1.1 mrg 2656 1.1 mrg # libtool_validate_options [ARG]... 2657 1.1 mrg # --------------------------------- 2658 1.1 mrg # Perform any sanity checks on option settings and/or unconsumed 2659 1.1 mrg # arguments. 2660 1.1 mrg libtool_validate_options () 2661 1.1 mrg { 2662 1.1 mrg # save first non-option argument 2663 1.1 mrg if test 0 -lt $#; then 2664 1.1 mrg nonopt=$1 2665 1.1 mrg shift 2666 1.1 mrg fi 2667 1.1 mrg 2668 1.1 mrg # preserve --debug 2669 1.1 mrg test : = "$debug_cmd" || func_append preserve_args " --debug" 2670 1.1 mrg 2671 1.1 mrg case $host in 2672 1.1 mrg # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452 2673 1.1 mrg # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788 2674 1.1 mrg *cygwin* | *mingw* | *pw32* | *cegcc* | *solaris2* | *os2*) 2675 1.1 mrg # don't eliminate duplications in $postdeps and $predeps 2676 1.1 mrg opt_duplicate_compiler_generated_deps=: 2677 1.1 mrg ;; 2678 1.1 mrg *) 2679 1.1 mrg opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps 2680 1.1 mrg ;; 2681 1.1 mrg esac 2682 1.1 mrg 2683 1.1 mrg $opt_help || { 2684 1.1 mrg # Sanity checks first: 2685 1.1 mrg func_check_version_match 2686 1.1 mrg 2687 1.1 mrg test yes != "$build_libtool_libs" \ 2688 1.1 mrg && test yes != "$build_old_libs" \ 2689 1.1 mrg && func_fatal_configuration "not configured to build any kind of library" 2690 1.1 mrg 2691 1.1 mrg # Darwin sucks 2692 1.1 mrg eval std_shrext=\"$shrext_cmds\" 2693 1.1 mrg 2694 1.1 mrg # Only execute mode is allowed to have -dlopen flags. 2695 1.1 mrg if test -n "$opt_dlopen" && test execute != "$opt_mode"; then 2696 1.1 mrg func_error "unrecognized option '-dlopen'" 2697 1.1 mrg $ECHO "$help" 1>&2 2698 1.1 mrg exit $EXIT_FAILURE 2699 1.1 mrg fi 2700 1.1 mrg 2701 1.1 mrg # Change the help message to a mode-specific one. 2702 1.1 mrg generic_help=$help 2703 1.1 mrg help="Try '$progname --help --mode=$opt_mode' for more information." 2704 1.1 mrg } 2705 1.1 mrg 2706 1.1 mrg # Pass back the unparsed argument list 2707 1.1.1.2 mrg func_quote eval ${1+"$@"} 2708 1.1.1.2 mrg libtool_validate_options_result=$func_quote_result 2709 1.1 mrg } 2710 1.1 mrg func_add_hook func_validate_options libtool_validate_options 2711 1.1 mrg 2712 1.1 mrg 2713 1.1 mrg # Process options as early as possible so that --help and --version 2714 1.1 mrg # can return quickly. 2715 1.1 mrg func_options ${1+"$@"} 2716 1.1 mrg eval set dummy "$func_options_result"; shift 2717 1.1 mrg 2718 1.1 mrg 2719 1.1 mrg 2720 1.1 mrg ## ----------- ## 2721 1.1 mrg ## Main. ## 2722 1.1 mrg ## ----------- ## 2723 1.1 mrg 2724 1.1 mrg magic='%%%MAGIC variable%%%' 2725 1.1 mrg magic_exe='%%%MAGIC EXE variable%%%' 2726 1.1 mrg 2727 1.1 mrg # Global variables. 2728 1.1 mrg extracted_archives= 2729 1.1 mrg extracted_serial=0 2730 1.1 mrg 2731 1.1 mrg # If this variable is set in any of the actions, the command in it 2732 1.1 mrg # will be execed at the end. This prevents here-documents from being 2733 1.1 mrg # left over by shells. 2734 1.1 mrg exec_cmd= 2735 1.1 mrg 2736 1.1 mrg 2737 1.1 mrg # A function that is used when there is no print builtin or printf. 2738 1.1 mrg func_fallback_echo () 2739 1.1 mrg { 2740 1.1 mrg eval 'cat <<_LTECHO_EOF 2741 1.1 mrg $1 2742 1.1 mrg _LTECHO_EOF' 2743 1.1 mrg } 2744 1.1 mrg 2745 1.1 mrg # func_generated_by_libtool 2746 1.1 mrg # True iff stdin has been generated by Libtool. This function is only 2747 1.1 mrg # a basic sanity check; it will hardly flush out determined imposters. 2748 1.1 mrg func_generated_by_libtool_p () 2749 1.1 mrg { 2750 1.1 mrg $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1 2751 1.1 mrg } 2752 1.1 mrg 2753 1.1 mrg # func_lalib_p file 2754 1.1 mrg # True iff FILE is a libtool '.la' library or '.lo' object file. 2755 1.1 mrg # This function is only a basic sanity check; it will hardly flush out 2756 1.1 mrg # determined imposters. 2757 1.1 mrg func_lalib_p () 2758 1.1 mrg { 2759 1.1 mrg test -f "$1" && 2760 1.1 mrg $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p 2761 1.1 mrg } 2762 1.1 mrg 2763 1.1 mrg # func_lalib_unsafe_p file 2764 1.1 mrg # True iff FILE is a libtool '.la' library or '.lo' object file. 2765 1.1 mrg # This function implements the same check as func_lalib_p without 2766 1.1 mrg # resorting to external programs. To this end, it redirects stdin and 2767 1.1 mrg # closes it afterwards, without saving the original file descriptor. 2768 1.1 mrg # As a safety measure, use it only where a negative result would be 2769 1.1 mrg # fatal anyway. Works if 'file' does not exist. 2770 1.1 mrg func_lalib_unsafe_p () 2771 1.1 mrg { 2772 1.1 mrg lalib_p=no 2773 1.1 mrg if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then 2774 1.1 mrg for lalib_p_l in 1 2 3 4 2775 1.1 mrg do 2776 1.1 mrg read lalib_p_line 2777 1.1 mrg case $lalib_p_line in 2778 1.1 mrg \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;; 2779 1.1 mrg esac 2780 1.1 mrg done 2781 1.1 mrg exec 0<&5 5<&- 2782 1.1 mrg fi 2783 1.1 mrg test yes = "$lalib_p" 2784 1.1 mrg } 2785 1.1 mrg 2786 1.1 mrg # func_ltwrapper_script_p file 2787 1.1 mrg # True iff FILE is a libtool wrapper script 2788 1.1 mrg # This function is only a basic sanity check; it will hardly flush out 2789 1.1 mrg # determined imposters. 2790 1.1 mrg func_ltwrapper_script_p () 2791 1.1 mrg { 2792 1.1 mrg test -f "$1" && 2793 1.1 mrg $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p 2794 1.1 mrg } 2795 1.1 mrg 2796 1.1 mrg # func_ltwrapper_executable_p file 2797 1.1 mrg # True iff FILE is a libtool wrapper executable 2798 1.1 mrg # This function is only a basic sanity check; it will hardly flush out 2799 1.1 mrg # determined imposters. 2800 1.1 mrg func_ltwrapper_executable_p () 2801 1.1 mrg { 2802 1.1 mrg func_ltwrapper_exec_suffix= 2803 1.1 mrg case $1 in 2804 1.1 mrg *.exe) ;; 2805 1.1 mrg *) func_ltwrapper_exec_suffix=.exe ;; 2806 1.1 mrg esac 2807 1.1 mrg $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1 2808 1.1 mrg } 2809 1.1 mrg 2810 1.1 mrg # func_ltwrapper_scriptname file 2811 1.1 mrg # Assumes file is an ltwrapper_executable 2812 1.1 mrg # uses $file to determine the appropriate filename for a 2813 1.1 mrg # temporary ltwrapper_script. 2814 1.1 mrg func_ltwrapper_scriptname () 2815 1.1 mrg { 2816 1.1 mrg func_dirname_and_basename "$1" "" "." 2817 1.1 mrg func_stripname '' '.exe' "$func_basename_result" 2818 1.1 mrg func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper 2819 1.1 mrg } 2820 1.1 mrg 2821 1.1 mrg # func_ltwrapper_p file 2822 1.1 mrg # True iff FILE is a libtool wrapper script or wrapper executable 2823 1.1 mrg # This function is only a basic sanity check; it will hardly flush out 2824 1.1 mrg # determined imposters. 2825 1.1 mrg func_ltwrapper_p () 2826 1.1 mrg { 2827 1.1 mrg func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1" 2828 1.1 mrg } 2829 1.1 mrg 2830 1.1 mrg 2831 1.1 mrg # func_execute_cmds commands fail_cmd 2832 1.1 mrg # Execute tilde-delimited COMMANDS. 2833 1.1 mrg # If FAIL_CMD is given, eval that upon failure. 2834 1.1 mrg # FAIL_CMD may read-access the current command in variable CMD! 2835 1.1 mrg func_execute_cmds () 2836 1.1 mrg { 2837 1.1 mrg $debug_cmd 2838 1.1 mrg 2839 1.1 mrg save_ifs=$IFS; IFS='~' 2840 1.1 mrg for cmd in $1; do 2841 1.1 mrg IFS=$sp$nl 2842 1.1 mrg eval cmd=\"$cmd\" 2843 1.1 mrg IFS=$save_ifs 2844 1.1 mrg func_show_eval "$cmd" "${2-:}" 2845 1.1 mrg done 2846 1.1 mrg IFS=$save_ifs 2847 1.1 mrg } 2848 1.1 mrg 2849 1.1 mrg 2850 1.1 mrg # func_source file 2851 1.1 mrg # Source FILE, adding directory component if necessary. 2852 1.1 mrg # Note that it is not necessary on cygwin/mingw to append a dot to 2853 1.1 mrg # FILE even if both FILE and FILE.exe exist: automatic-append-.exe 2854 1.1 mrg # behavior happens only for exec(3), not for open(2)! Also, sourcing 2855 1.1 mrg # 'FILE.' does not work on cygwin managed mounts. 2856 1.1 mrg func_source () 2857 1.1 mrg { 2858 1.1 mrg $debug_cmd 2859 1.1 mrg 2860 1.1 mrg case $1 in 2861 1.1 mrg */* | *\\*) . "$1" ;; 2862 1.1 mrg *) . "./$1" ;; 2863 1.1 mrg esac 2864 1.1 mrg } 2865 1.1 mrg 2866 1.1 mrg 2867 1.1 mrg # func_resolve_sysroot PATH 2868 1.1 mrg # Replace a leading = in PATH with a sysroot. Store the result into 2869 1.1 mrg # func_resolve_sysroot_result 2870 1.1 mrg func_resolve_sysroot () 2871 1.1 mrg { 2872 1.1 mrg func_resolve_sysroot_result=$1 2873 1.1 mrg case $func_resolve_sysroot_result in 2874 1.1 mrg =*) 2875 1.1 mrg func_stripname '=' '' "$func_resolve_sysroot_result" 2876 1.1 mrg func_resolve_sysroot_result=$lt_sysroot$func_stripname_result 2877 1.1 mrg ;; 2878 1.1 mrg esac 2879 1.1 mrg } 2880 1.1 mrg 2881 1.1 mrg # func_replace_sysroot PATH 2882 1.1 mrg # If PATH begins with the sysroot, replace it with = and 2883 1.1 mrg # store the result into func_replace_sysroot_result. 2884 1.1 mrg func_replace_sysroot () 2885 1.1 mrg { 2886 1.1 mrg case $lt_sysroot:$1 in 2887 1.1 mrg ?*:"$lt_sysroot"*) 2888 1.1 mrg func_stripname "$lt_sysroot" '' "$1" 2889 1.1 mrg func_replace_sysroot_result='='$func_stripname_result 2890 1.1 mrg ;; 2891 1.1 mrg *) 2892 1.1 mrg # Including no sysroot. 2893 1.1 mrg func_replace_sysroot_result=$1 2894 1.1 mrg ;; 2895 1.1 mrg esac 2896 1.1 mrg } 2897 1.1 mrg 2898 1.1 mrg # func_infer_tag arg 2899 1.1 mrg # Infer tagged configuration to use if any are available and 2900 1.1 mrg # if one wasn't chosen via the "--tag" command line option. 2901 1.1 mrg # Only attempt this if the compiler in the base compile 2902 1.1 mrg # command doesn't match the default compiler. 2903 1.1 mrg # arg is usually of the form 'gcc ...' 2904 1.1 mrg func_infer_tag () 2905 1.1 mrg { 2906 1.1 mrg $debug_cmd 2907 1.1 mrg 2908 1.1 mrg if test -n "$available_tags" && test -z "$tagname"; then 2909 1.1 mrg CC_quoted= 2910 1.1 mrg for arg in $CC; do 2911 1.1 mrg func_append_quoted CC_quoted "$arg" 2912 1.1 mrg done 2913 1.1 mrg CC_expanded=`func_echo_all $CC` 2914 1.1 mrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2915 1.1 mrg case $@ in 2916 1.1 mrg # Blanks in the command may have been stripped by the calling shell, 2917 1.1 mrg # but not from the CC environment variable when configure was run. 2918 1.1 mrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2919 1.1 mrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;; 2920 1.1 mrg # Blanks at the start of $base_compile will cause this to fail 2921 1.1 mrg # if we don't check for them as well. 2922 1.1 mrg *) 2923 1.1 mrg for z in $available_tags; do 2924 1.1 mrg if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then 2925 1.1 mrg # Evaluate the configuration. 2926 1.1 mrg eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`" 2927 1.1 mrg CC_quoted= 2928 1.1 mrg for arg in $CC; do 2929 1.1 mrg # Double-quote args containing other shell metacharacters. 2930 1.1 mrg func_append_quoted CC_quoted "$arg" 2931 1.1 mrg done 2932 1.1 mrg CC_expanded=`func_echo_all $CC` 2933 1.1 mrg CC_quoted_expanded=`func_echo_all $CC_quoted` 2934 1.1 mrg case "$@ " in 2935 1.1 mrg " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \ 2936 1.1 mrg " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) 2937 1.1 mrg # The compiler in the base compile command matches 2938 1.1 mrg # the one in the tagged configuration. 2939 1.1 mrg # Assume this is the tagged configuration we want. 2940 1.1 mrg tagname=$z 2941 1.1 mrg break 2942 1.1 mrg ;; 2943 1.1 mrg esac 2944 1.1 mrg fi 2945 1.1 mrg done 2946 1.1 mrg # If $tagname still isn't set, then no tagged configuration 2947 1.1 mrg # was found and let the user know that the "--tag" command 2948 1.1 mrg # line option must be used. 2949 1.1 mrg if test -z "$tagname"; then 2950 1.1 mrg func_echo "unable to infer tagged configuration" 2951 1.1 mrg func_fatal_error "specify a tag with '--tag'" 2952 1.1 mrg # else 2953 1.1 mrg # func_verbose "using $tagname tagged configuration" 2954 1.1 mrg fi 2955 1.1 mrg ;; 2956 1.1 mrg esac 2957 1.1 mrg fi 2958 1.1 mrg } 2959 1.1 mrg 2960 1.1 mrg 2961 1.1 mrg 2962 1.1 mrg # func_write_libtool_object output_name pic_name nonpic_name 2963 1.1 mrg # Create a libtool object file (analogous to a ".la" file), 2964 1.1 mrg # but don't create it if we're doing a dry run. 2965 1.1 mrg func_write_libtool_object () 2966 1.1 mrg { 2967 1.1 mrg write_libobj=$1 2968 1.1 mrg if test yes = "$build_libtool_libs"; then 2969 1.1 mrg write_lobj=\'$2\' 2970 1.1 mrg else 2971 1.1 mrg write_lobj=none 2972 1.1 mrg fi 2973 1.1 mrg 2974 1.1 mrg if test yes = "$build_old_libs"; then 2975 1.1 mrg write_oldobj=\'$3\' 2976 1.1 mrg else 2977 1.1 mrg write_oldobj=none 2978 1.1 mrg fi 2979 1.1 mrg 2980 1.1 mrg $opt_dry_run || { 2981 1.1 mrg cat >${write_libobj}T <<EOF 2982 1.1 mrg # $write_libobj - a libtool object file 2983 1.1 mrg # Generated by $PROGRAM (GNU $PACKAGE) $VERSION 2984 1.1 mrg # 2985 1.1 mrg # Please DO NOT delete this file! 2986 1.1 mrg # It is necessary for linking the library. 2987 1.1 mrg 2988 1.1 mrg # Name of the PIC object. 2989 1.1 mrg pic_object=$write_lobj 2990 1.1 mrg 2991 1.1 mrg # Name of the non-PIC object 2992 1.1 mrg non_pic_object=$write_oldobj 2993 1.1 mrg 2994 1.1 mrg EOF 2995 1.1 mrg $MV "${write_libobj}T" "$write_libobj" 2996 1.1 mrg } 2997 1.1 mrg } 2998 1.1 mrg 2999 1.1 mrg 3000 1.1 mrg ################################################## 3001 1.1 mrg # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS # 3002 1.1 mrg ################################################## 3003 1.1 mrg 3004 1.1 mrg # func_convert_core_file_wine_to_w32 ARG 3005 1.1 mrg # Helper function used by file name conversion functions when $build is *nix, 3006 1.1 mrg # and $host is mingw, cygwin, or some other w32 environment. Relies on a 3007 1.1 mrg # correctly configured wine environment available, with the winepath program 3008 1.1 mrg # in $build's $PATH. 3009 1.1 mrg # 3010 1.1 mrg # ARG is the $build file name to be converted to w32 format. 3011 1.1 mrg # Result is available in $func_convert_core_file_wine_to_w32_result, and will 3012 1.1 mrg # be empty on error (or when ARG is empty) 3013 1.1 mrg func_convert_core_file_wine_to_w32 () 3014 1.1 mrg { 3015 1.1 mrg $debug_cmd 3016 1.1 mrg 3017 1.1 mrg func_convert_core_file_wine_to_w32_result=$1 3018 1.1 mrg if test -n "$1"; then 3019 1.1 mrg # Unfortunately, winepath does not exit with a non-zero error code, so we 3020 1.1 mrg # are forced to check the contents of stdout. On the other hand, if the 3021 1.1 mrg # command is not found, the shell will set an exit code of 127 and print 3022 1.1 mrg # *an error message* to stdout. So we must check for both error code of 3023 1.1 mrg # zero AND non-empty stdout, which explains the odd construction: 3024 1.1 mrg func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null` 3025 1.1 mrg if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then 3026 1.1 mrg func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" | 3027 1.1 mrg $SED -e "$sed_naive_backslashify"` 3028 1.1 mrg else 3029 1.1 mrg func_convert_core_file_wine_to_w32_result= 3030 1.1 mrg fi 3031 1.1 mrg fi 3032 1.1 mrg } 3033 1.1 mrg # end: func_convert_core_file_wine_to_w32 3034 1.1 mrg 3035 1.1 mrg 3036 1.1 mrg # func_convert_core_path_wine_to_w32 ARG 3037 1.1 mrg # Helper function used by path conversion functions when $build is *nix, and 3038 1.1 mrg # $host is mingw, cygwin, or some other w32 environment. Relies on a correctly 3039 1.1 mrg # configured wine environment available, with the winepath program in $build's 3040 1.1 mrg # $PATH. Assumes ARG has no leading or trailing path separator characters. 3041 1.1 mrg # 3042 1.1 mrg # ARG is path to be converted from $build format to win32. 3043 1.1 mrg # Result is available in $func_convert_core_path_wine_to_w32_result. 3044 1.1 mrg # Unconvertible file (directory) names in ARG are skipped; if no directory names 3045 1.1 mrg # are convertible, then the result may be empty. 3046 1.1 mrg func_convert_core_path_wine_to_w32 () 3047 1.1 mrg { 3048 1.1 mrg $debug_cmd 3049 1.1 mrg 3050 1.1 mrg # unfortunately, winepath doesn't convert paths, only file names 3051 1.1 mrg func_convert_core_path_wine_to_w32_result= 3052 1.1 mrg if test -n "$1"; then 3053 1.1 mrg oldIFS=$IFS 3054 1.1 mrg IFS=: 3055 1.1 mrg for func_convert_core_path_wine_to_w32_f in $1; do 3056 1.1 mrg IFS=$oldIFS 3057 1.1 mrg func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f" 3058 1.1 mrg if test -n "$func_convert_core_file_wine_to_w32_result"; then 3059 1.1 mrg if test -z "$func_convert_core_path_wine_to_w32_result"; then 3060 1.1 mrg func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result 3061 1.1 mrg else 3062 1.1 mrg func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result" 3063 1.1 mrg fi 3064 1.1 mrg fi 3065 1.1 mrg done 3066 1.1 mrg IFS=$oldIFS 3067 1.1 mrg fi 3068 1.1 mrg } 3069 1.1 mrg # end: func_convert_core_path_wine_to_w32 3070 1.1 mrg 3071 1.1 mrg 3072 1.1 mrg # func_cygpath ARGS... 3073 1.1 mrg # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when 3074 1.1 mrg # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2) 3075 1.1 mrg # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or 3076 1.1 mrg # (2), returns the Cygwin file name or path in func_cygpath_result (input 3077 1.1 mrg # file name or path is assumed to be in w32 format, as previously converted 3078 1.1 mrg # from $build's *nix or MSYS format). In case (3), returns the w32 file name 3079 1.1 mrg # or path in func_cygpath_result (input file name or path is assumed to be in 3080 1.1 mrg # Cygwin format). Returns an empty string on error. 3081 1.1 mrg # 3082 1.1 mrg # ARGS are passed to cygpath, with the last one being the file name or path to 3083 1.1 mrg # be converted. 3084 1.1 mrg # 3085 1.1 mrg # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH 3086 1.1 mrg # environment variable; do not put it in $PATH. 3087 1.1 mrg func_cygpath () 3088 1.1 mrg { 3089 1.1 mrg $debug_cmd 3090 1.1 mrg 3091 1.1 mrg if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then 3092 1.1 mrg func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null` 3093 1.1 mrg if test "$?" -ne 0; then 3094 1.1 mrg # on failure, ensure result is empty 3095 1.1 mrg func_cygpath_result= 3096 1.1 mrg fi 3097 1.1 mrg else 3098 1.1 mrg func_cygpath_result= 3099 1.1 mrg func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'" 3100 1.1 mrg fi 3101 1.1 mrg } 3102 1.1 mrg #end: func_cygpath 3103 1.1 mrg 3104 1.1 mrg 3105 1.1 mrg # func_convert_core_msys_to_w32 ARG 3106 1.1 mrg # Convert file name or path ARG from MSYS format to w32 format. Return 3107 1.1 mrg # result in func_convert_core_msys_to_w32_result. 3108 1.1 mrg func_convert_core_msys_to_w32 () 3109 1.1 mrg { 3110 1.1 mrg $debug_cmd 3111 1.1 mrg 3112 1.1 mrg # awkward: cmd appends spaces to result 3113 1.1 mrg func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null | 3114 1.1 mrg $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"` 3115 1.1 mrg } 3116 1.1 mrg #end: func_convert_core_msys_to_w32 3117 1.1 mrg 3118 1.1 mrg 3119 1.1 mrg # func_convert_file_check ARG1 ARG2 3120 1.1 mrg # Verify that ARG1 (a file name in $build format) was converted to $host 3121 1.1 mrg # format in ARG2. Otherwise, emit an error message, but continue (resetting 3122 1.1 mrg # func_to_host_file_result to ARG1). 3123 1.1 mrg func_convert_file_check () 3124 1.1 mrg { 3125 1.1 mrg $debug_cmd 3126 1.1 mrg 3127 1.1 mrg if test -z "$2" && test -n "$1"; then 3128 1.1 mrg func_error "Could not determine host file name corresponding to" 3129 1.1 mrg func_error " '$1'" 3130 1.1 mrg func_error "Continuing, but uninstalled executables may not work." 3131 1.1 mrg # Fallback: 3132 1.1 mrg func_to_host_file_result=$1 3133 1.1 mrg fi 3134 1.1 mrg } 3135 1.1 mrg # end func_convert_file_check 3136 1.1 mrg 3137 1.1 mrg 3138 1.1 mrg # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH 3139 1.1 mrg # Verify that FROM_PATH (a path in $build format) was converted to $host 3140 1.1 mrg # format in TO_PATH. Otherwise, emit an error message, but continue, resetting 3141 1.1 mrg # func_to_host_file_result to a simplistic fallback value (see below). 3142 1.1 mrg func_convert_path_check () 3143 1.1 mrg { 3144 1.1 mrg $debug_cmd 3145 1.1 mrg 3146 1.1 mrg if test -z "$4" && test -n "$3"; then 3147 1.1 mrg func_error "Could not determine the host path corresponding to" 3148 1.1 mrg func_error " '$3'" 3149 1.1 mrg func_error "Continuing, but uninstalled executables may not work." 3150 1.1 mrg # Fallback. This is a deliberately simplistic "conversion" and 3151 1.1 mrg # should not be "improved". See libtool.info. 3152 1.1 mrg if test "x$1" != "x$2"; then 3153 1.1 mrg lt_replace_pathsep_chars="s|$1|$2|g" 3154 1.1 mrg func_to_host_path_result=`echo "$3" | 3155 1.1 mrg $SED -e "$lt_replace_pathsep_chars"` 3156 1.1 mrg else 3157 1.1 mrg func_to_host_path_result=$3 3158 1.1 mrg fi 3159 1.1 mrg fi 3160 1.1 mrg } 3161 1.1 mrg # end func_convert_path_check 3162 1.1 mrg 3163 1.1 mrg 3164 1.1 mrg # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG 3165 1.1 mrg # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT 3166 1.1 mrg # and appending REPL if ORIG matches BACKPAT. 3167 1.1 mrg func_convert_path_front_back_pathsep () 3168 1.1 mrg { 3169 1.1 mrg $debug_cmd 3170 1.1 mrg 3171 1.1 mrg case $4 in 3172 1.1 mrg $1 ) func_to_host_path_result=$3$func_to_host_path_result 3173 1.1 mrg ;; 3174 1.1 mrg esac 3175 1.1 mrg case $4 in 3176 1.1 mrg $2 ) func_append func_to_host_path_result "$3" 3177 1.1 mrg ;; 3178 1.1 mrg esac 3179 1.1 mrg } 3180 1.1 mrg # end func_convert_path_front_back_pathsep 3181 1.1 mrg 3182 1.1 mrg 3183 1.1 mrg ################################################## 3184 1.1 mrg # $build to $host FILE NAME CONVERSION FUNCTIONS # 3185 1.1 mrg ################################################## 3186 1.1 mrg # invoked via '$to_host_file_cmd ARG' 3187 1.1 mrg # 3188 1.1 mrg # In each case, ARG is the path to be converted from $build to $host format. 3189 1.1 mrg # Result will be available in $func_to_host_file_result. 3190 1.1 mrg 3191 1.1 mrg 3192 1.1 mrg # func_to_host_file ARG 3193 1.1 mrg # Converts the file name ARG from $build format to $host format. Return result 3194 1.1 mrg # in func_to_host_file_result. 3195 1.1 mrg func_to_host_file () 3196 1.1 mrg { 3197 1.1 mrg $debug_cmd 3198 1.1 mrg 3199 1.1 mrg $to_host_file_cmd "$1" 3200 1.1 mrg } 3201 1.1 mrg # end func_to_host_file 3202 1.1 mrg 3203 1.1 mrg 3204 1.1 mrg # func_to_tool_file ARG LAZY 3205 1.1 mrg # converts the file name ARG from $build format to toolchain format. Return 3206 1.1 mrg # result in func_to_tool_file_result. If the conversion in use is listed 3207 1.1 mrg # in (the comma separated) LAZY, no conversion takes place. 3208 1.1 mrg func_to_tool_file () 3209 1.1 mrg { 3210 1.1 mrg $debug_cmd 3211 1.1 mrg 3212 1.1 mrg case ,$2, in 3213 1.1 mrg *,"$to_tool_file_cmd",*) 3214 1.1 mrg func_to_tool_file_result=$1 3215 1.1 mrg ;; 3216 1.1 mrg *) 3217 1.1 mrg $to_tool_file_cmd "$1" 3218 1.1 mrg func_to_tool_file_result=$func_to_host_file_result 3219 1.1 mrg ;; 3220 1.1 mrg esac 3221 1.1 mrg } 3222 1.1 mrg # end func_to_tool_file 3223 1.1 mrg 3224 1.1 mrg 3225 1.1 mrg # func_convert_file_noop ARG 3226 1.1 mrg # Copy ARG to func_to_host_file_result. 3227 1.1 mrg func_convert_file_noop () 3228 1.1 mrg { 3229 1.1 mrg func_to_host_file_result=$1 3230 1.1 mrg } 3231 1.1 mrg # end func_convert_file_noop 3232 1.1 mrg 3233 1.1 mrg 3234 1.1 mrg # func_convert_file_msys_to_w32 ARG 3235 1.1 mrg # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic 3236 1.1 mrg # conversion to w32 is not available inside the cwrapper. Returns result in 3237 1.1 mrg # func_to_host_file_result. 3238 1.1 mrg func_convert_file_msys_to_w32 () 3239 1.1 mrg { 3240 1.1 mrg $debug_cmd 3241 1.1 mrg 3242 1.1 mrg func_to_host_file_result=$1 3243 1.1 mrg if test -n "$1"; then 3244 1.1 mrg func_convert_core_msys_to_w32 "$1" 3245 1.1 mrg func_to_host_file_result=$func_convert_core_msys_to_w32_result 3246 1.1 mrg fi 3247 1.1 mrg func_convert_file_check "$1" "$func_to_host_file_result" 3248 1.1 mrg } 3249 1.1 mrg # end func_convert_file_msys_to_w32 3250 1.1 mrg 3251 1.1 mrg 3252 1.1 mrg # func_convert_file_cygwin_to_w32 ARG 3253 1.1 mrg # Convert file name ARG from Cygwin to w32 format. Returns result in 3254 1.1 mrg # func_to_host_file_result. 3255 1.1 mrg func_convert_file_cygwin_to_w32 () 3256 1.1 mrg { 3257 1.1 mrg $debug_cmd 3258 1.1 mrg 3259 1.1 mrg func_to_host_file_result=$1 3260 1.1 mrg if test -n "$1"; then 3261 1.1 mrg # because $build is cygwin, we call "the" cygpath in $PATH; no need to use 3262 1.1 mrg # LT_CYGPATH in this case. 3263 1.1 mrg func_to_host_file_result=`cygpath -m "$1"` 3264 1.1 mrg fi 3265 1.1 mrg func_convert_file_check "$1" "$func_to_host_file_result" 3266 1.1 mrg } 3267 1.1 mrg # end func_convert_file_cygwin_to_w32 3268 1.1 mrg 3269 1.1 mrg 3270 1.1 mrg # func_convert_file_nix_to_w32 ARG 3271 1.1 mrg # Convert file name ARG from *nix to w32 format. Requires a wine environment 3272 1.1 mrg # and a working winepath. Returns result in func_to_host_file_result. 3273 1.1 mrg func_convert_file_nix_to_w32 () 3274 1.1 mrg { 3275 1.1 mrg $debug_cmd 3276 1.1 mrg 3277 1.1 mrg func_to_host_file_result=$1 3278 1.1 mrg if test -n "$1"; then 3279 1.1 mrg func_convert_core_file_wine_to_w32 "$1" 3280 1.1 mrg func_to_host_file_result=$func_convert_core_file_wine_to_w32_result 3281 1.1 mrg fi 3282 1.1 mrg func_convert_file_check "$1" "$func_to_host_file_result" 3283 1.1 mrg } 3284 1.1 mrg # end func_convert_file_nix_to_w32 3285 1.1 mrg 3286 1.1 mrg 3287 1.1 mrg # func_convert_file_msys_to_cygwin ARG 3288 1.1 mrg # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3289 1.1 mrg # Returns result in func_to_host_file_result. 3290 1.1 mrg func_convert_file_msys_to_cygwin () 3291 1.1 mrg { 3292 1.1 mrg $debug_cmd 3293 1.1 mrg 3294 1.1 mrg func_to_host_file_result=$1 3295 1.1 mrg if test -n "$1"; then 3296 1.1 mrg func_convert_core_msys_to_w32 "$1" 3297 1.1 mrg func_cygpath -u "$func_convert_core_msys_to_w32_result" 3298 1.1 mrg func_to_host_file_result=$func_cygpath_result 3299 1.1 mrg fi 3300 1.1 mrg func_convert_file_check "$1" "$func_to_host_file_result" 3301 1.1 mrg } 3302 1.1 mrg # end func_convert_file_msys_to_cygwin 3303 1.1 mrg 3304 1.1 mrg 3305 1.1 mrg # func_convert_file_nix_to_cygwin ARG 3306 1.1 mrg # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed 3307 1.1 mrg # in a wine environment, working winepath, and LT_CYGPATH set. Returns result 3308 1.1 mrg # in func_to_host_file_result. 3309 1.1 mrg func_convert_file_nix_to_cygwin () 3310 1.1 mrg { 3311 1.1 mrg $debug_cmd 3312 1.1 mrg 3313 1.1 mrg func_to_host_file_result=$1 3314 1.1 mrg if test -n "$1"; then 3315 1.1 mrg # convert from *nix to w32, then use cygpath to convert from w32 to cygwin. 3316 1.1 mrg func_convert_core_file_wine_to_w32 "$1" 3317 1.1 mrg func_cygpath -u "$func_convert_core_file_wine_to_w32_result" 3318 1.1 mrg func_to_host_file_result=$func_cygpath_result 3319 1.1 mrg fi 3320 1.1 mrg func_convert_file_check "$1" "$func_to_host_file_result" 3321 1.1 mrg } 3322 1.1 mrg # end func_convert_file_nix_to_cygwin 3323 1.1 mrg 3324 1.1 mrg 3325 1.1 mrg ############################################# 3326 1.1 mrg # $build to $host PATH CONVERSION FUNCTIONS # 3327 1.1 mrg ############################################# 3328 1.1 mrg # invoked via '$to_host_path_cmd ARG' 3329 1.1 mrg # 3330 1.1 mrg # In each case, ARG is the path to be converted from $build to $host format. 3331 1.1 mrg # The result will be available in $func_to_host_path_result. 3332 1.1 mrg # 3333 1.1 mrg # Path separators are also converted from $build format to $host format. If 3334 1.1 mrg # ARG begins or ends with a path separator character, it is preserved (but 3335 1.1 mrg # converted to $host format) on output. 3336 1.1 mrg # 3337 1.1 mrg # All path conversion functions are named using the following convention: 3338 1.1 mrg # file name conversion function : func_convert_file_X_to_Y () 3339 1.1 mrg # path conversion function : func_convert_path_X_to_Y () 3340 1.1 mrg # where, for any given $build/$host combination the 'X_to_Y' value is the 3341 1.1 mrg # same. If conversion functions are added for new $build/$host combinations, 3342 1.1 mrg # the two new functions must follow this pattern, or func_init_to_host_path_cmd 3343 1.1 mrg # will break. 3344 1.1 mrg 3345 1.1 mrg 3346 1.1 mrg # func_init_to_host_path_cmd 3347 1.1 mrg # Ensures that function "pointer" variable $to_host_path_cmd is set to the 3348 1.1 mrg # appropriate value, based on the value of $to_host_file_cmd. 3349 1.1 mrg to_host_path_cmd= 3350 1.1 mrg func_init_to_host_path_cmd () 3351 1.1 mrg { 3352 1.1 mrg $debug_cmd 3353 1.1 mrg 3354 1.1 mrg if test -z "$to_host_path_cmd"; then 3355 1.1 mrg func_stripname 'func_convert_file_' '' "$to_host_file_cmd" 3356 1.1 mrg to_host_path_cmd=func_convert_path_$func_stripname_result 3357 1.1 mrg fi 3358 1.1 mrg } 3359 1.1 mrg 3360 1.1 mrg 3361 1.1 mrg # func_to_host_path ARG 3362 1.1 mrg # Converts the path ARG from $build format to $host format. Return result 3363 1.1 mrg # in func_to_host_path_result. 3364 1.1 mrg func_to_host_path () 3365 1.1 mrg { 3366 1.1 mrg $debug_cmd 3367 1.1 mrg 3368 1.1 mrg func_init_to_host_path_cmd 3369 1.1 mrg $to_host_path_cmd "$1" 3370 1.1 mrg } 3371 1.1 mrg # end func_to_host_path 3372 1.1 mrg 3373 1.1 mrg 3374 1.1 mrg # func_convert_path_noop ARG 3375 1.1 mrg # Copy ARG to func_to_host_path_result. 3376 1.1 mrg func_convert_path_noop () 3377 1.1 mrg { 3378 1.1 mrg func_to_host_path_result=$1 3379 1.1 mrg } 3380 1.1 mrg # end func_convert_path_noop 3381 1.1 mrg 3382 1.1 mrg 3383 1.1 mrg # func_convert_path_msys_to_w32 ARG 3384 1.1 mrg # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic 3385 1.1 mrg # conversion to w32 is not available inside the cwrapper. Returns result in 3386 1.1 mrg # func_to_host_path_result. 3387 1.1 mrg func_convert_path_msys_to_w32 () 3388 1.1 mrg { 3389 1.1 mrg $debug_cmd 3390 1.1 mrg 3391 1.1 mrg func_to_host_path_result=$1 3392 1.1 mrg if test -n "$1"; then 3393 1.1 mrg # Remove leading and trailing path separator characters from ARG. MSYS 3394 1.1 mrg # behavior is inconsistent here; cygpath turns them into '.;' and ';.'; 3395 1.1 mrg # and winepath ignores them completely. 3396 1.1 mrg func_stripname : : "$1" 3397 1.1 mrg func_to_host_path_tmp1=$func_stripname_result 3398 1.1 mrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3399 1.1 mrg func_to_host_path_result=$func_convert_core_msys_to_w32_result 3400 1.1 mrg func_convert_path_check : ";" \ 3401 1.1 mrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3402 1.1 mrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3403 1.1 mrg fi 3404 1.1 mrg } 3405 1.1 mrg # end func_convert_path_msys_to_w32 3406 1.1 mrg 3407 1.1 mrg 3408 1.1 mrg # func_convert_path_cygwin_to_w32 ARG 3409 1.1 mrg # Convert path ARG from Cygwin to w32 format. Returns result in 3410 1.1 mrg # func_to_host_file_result. 3411 1.1 mrg func_convert_path_cygwin_to_w32 () 3412 1.1 mrg { 3413 1.1 mrg $debug_cmd 3414 1.1 mrg 3415 1.1 mrg func_to_host_path_result=$1 3416 1.1 mrg if test -n "$1"; then 3417 1.1 mrg # See func_convert_path_msys_to_w32: 3418 1.1 mrg func_stripname : : "$1" 3419 1.1 mrg func_to_host_path_tmp1=$func_stripname_result 3420 1.1 mrg func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"` 3421 1.1 mrg func_convert_path_check : ";" \ 3422 1.1 mrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3423 1.1 mrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3424 1.1 mrg fi 3425 1.1 mrg } 3426 1.1 mrg # end func_convert_path_cygwin_to_w32 3427 1.1 mrg 3428 1.1 mrg 3429 1.1 mrg # func_convert_path_nix_to_w32 ARG 3430 1.1 mrg # Convert path ARG from *nix to w32 format. Requires a wine environment and 3431 1.1 mrg # a working winepath. Returns result in func_to_host_file_result. 3432 1.1 mrg func_convert_path_nix_to_w32 () 3433 1.1 mrg { 3434 1.1 mrg $debug_cmd 3435 1.1 mrg 3436 1.1 mrg func_to_host_path_result=$1 3437 1.1 mrg if test -n "$1"; then 3438 1.1 mrg # See func_convert_path_msys_to_w32: 3439 1.1 mrg func_stripname : : "$1" 3440 1.1 mrg func_to_host_path_tmp1=$func_stripname_result 3441 1.1 mrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3442 1.1 mrg func_to_host_path_result=$func_convert_core_path_wine_to_w32_result 3443 1.1 mrg func_convert_path_check : ";" \ 3444 1.1 mrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3445 1.1 mrg func_convert_path_front_back_pathsep ":*" "*:" ";" "$1" 3446 1.1 mrg fi 3447 1.1 mrg } 3448 1.1 mrg # end func_convert_path_nix_to_w32 3449 1.1 mrg 3450 1.1 mrg 3451 1.1 mrg # func_convert_path_msys_to_cygwin ARG 3452 1.1 mrg # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set. 3453 1.1 mrg # Returns result in func_to_host_file_result. 3454 1.1 mrg func_convert_path_msys_to_cygwin () 3455 1.1 mrg { 3456 1.1 mrg $debug_cmd 3457 1.1 mrg 3458 1.1 mrg func_to_host_path_result=$1 3459 1.1 mrg if test -n "$1"; then 3460 1.1 mrg # See func_convert_path_msys_to_w32: 3461 1.1 mrg func_stripname : : "$1" 3462 1.1 mrg func_to_host_path_tmp1=$func_stripname_result 3463 1.1 mrg func_convert_core_msys_to_w32 "$func_to_host_path_tmp1" 3464 1.1 mrg func_cygpath -u -p "$func_convert_core_msys_to_w32_result" 3465 1.1 mrg func_to_host_path_result=$func_cygpath_result 3466 1.1 mrg func_convert_path_check : : \ 3467 1.1 mrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3468 1.1 mrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3469 1.1 mrg fi 3470 1.1 mrg } 3471 1.1 mrg # end func_convert_path_msys_to_cygwin 3472 1.1 mrg 3473 1.1 mrg 3474 1.1 mrg # func_convert_path_nix_to_cygwin ARG 3475 1.1 mrg # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a 3476 1.1 mrg # a wine environment, working winepath, and LT_CYGPATH set. Returns result in 3477 1.1 mrg # func_to_host_file_result. 3478 1.1 mrg func_convert_path_nix_to_cygwin () 3479 1.1 mrg { 3480 1.1 mrg $debug_cmd 3481 1.1 mrg 3482 1.1 mrg func_to_host_path_result=$1 3483 1.1 mrg if test -n "$1"; then 3484 1.1 mrg # Remove leading and trailing path separator characters from 3485 1.1 mrg # ARG. msys behavior is inconsistent here, cygpath turns them 3486 1.1 mrg # into '.;' and ';.', and winepath ignores them completely. 3487 1.1 mrg func_stripname : : "$1" 3488 1.1 mrg func_to_host_path_tmp1=$func_stripname_result 3489 1.1 mrg func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1" 3490 1.1 mrg func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result" 3491 1.1 mrg func_to_host_path_result=$func_cygpath_result 3492 1.1 mrg func_convert_path_check : : \ 3493 1.1 mrg "$func_to_host_path_tmp1" "$func_to_host_path_result" 3494 1.1 mrg func_convert_path_front_back_pathsep ":*" "*:" : "$1" 3495 1.1 mrg fi 3496 1.1 mrg } 3497 1.1 mrg # end func_convert_path_nix_to_cygwin 3498 1.1 mrg 3499 1.1 mrg 3500 1.1 mrg # func_dll_def_p FILE 3501 1.1 mrg # True iff FILE is a Windows DLL '.def' file. 3502 1.1 mrg # Keep in sync with _LT_DLL_DEF_P in libtool.m4 3503 1.1 mrg func_dll_def_p () 3504 1.1 mrg { 3505 1.1 mrg $debug_cmd 3506 1.1 mrg 3507 1.1 mrg func_dll_def_p_tmp=`$SED -n \ 3508 1.1 mrg -e 's/^[ ]*//' \ 3509 1.1 mrg -e '/^\(;.*\)*$/d' \ 3510 1.1 mrg -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \ 3511 1.1 mrg -e q \ 3512 1.1 mrg "$1"` 3513 1.1 mrg test DEF = "$func_dll_def_p_tmp" 3514 1.1 mrg } 3515 1.1 mrg 3516 1.1 mrg 3517 1.1 mrg # func_mode_compile arg... 3518 1.1 mrg func_mode_compile () 3519 1.1 mrg { 3520 1.1 mrg $debug_cmd 3521 1.1 mrg 3522 1.1 mrg # Get the compilation command and the source file. 3523 1.1 mrg base_compile= 3524 1.1 mrg srcfile=$nonopt # always keep a non-empty value in "srcfile" 3525 1.1 mrg suppress_opt=yes 3526 1.1 mrg suppress_output= 3527 1.1 mrg arg_mode=normal 3528 1.1 mrg libobj= 3529 1.1 mrg later= 3530 1.1 mrg pie_flag= 3531 1.1 mrg 3532 1.1 mrg for arg 3533 1.1 mrg do 3534 1.1 mrg case $arg_mode in 3535 1.1 mrg arg ) 3536 1.1 mrg # do not "continue". Instead, add this to base_compile 3537 1.1 mrg lastarg=$arg 3538 1.1 mrg arg_mode=normal 3539 1.1 mrg ;; 3540 1.1 mrg 3541 1.1 mrg target ) 3542 1.1 mrg libobj=$arg 3543 1.1 mrg arg_mode=normal 3544 1.1 mrg continue 3545 1.1 mrg ;; 3546 1.1 mrg 3547 1.1 mrg normal ) 3548 1.1 mrg # Accept any command-line options. 3549 1.1 mrg case $arg in 3550 1.1 mrg -o) 3551 1.1 mrg test -n "$libobj" && \ 3552 1.1 mrg func_fatal_error "you cannot specify '-o' more than once" 3553 1.1 mrg arg_mode=target 3554 1.1 mrg continue 3555 1.1 mrg ;; 3556 1.1 mrg 3557 1.1 mrg -pie | -fpie | -fPIE) 3558 1.1 mrg func_append pie_flag " $arg" 3559 1.1 mrg continue 3560 1.1 mrg ;; 3561 1.1 mrg 3562 1.1 mrg -shared | -static | -prefer-pic | -prefer-non-pic) 3563 1.1 mrg func_append later " $arg" 3564 1.1 mrg continue 3565 1.1 mrg ;; 3566 1.1 mrg 3567 1.1 mrg -no-suppress) 3568 1.1 mrg suppress_opt=no 3569 1.1 mrg continue 3570 1.1 mrg ;; 3571 1.1 mrg 3572 1.1 mrg -Xcompiler) 3573 1.1 mrg arg_mode=arg # the next one goes into the "base_compile" arg list 3574 1.1 mrg continue # The current "srcfile" will either be retained or 3575 1.1 mrg ;; # replaced later. I would guess that would be a bug. 3576 1.1 mrg 3577 1.1 mrg -Wc,*) 3578 1.1 mrg func_stripname '-Wc,' '' "$arg" 3579 1.1 mrg args=$func_stripname_result 3580 1.1 mrg lastarg= 3581 1.1 mrg save_ifs=$IFS; IFS=, 3582 1.1 mrg for arg in $args; do 3583 1.1 mrg IFS=$save_ifs 3584 1.1 mrg func_append_quoted lastarg "$arg" 3585 1.1 mrg done 3586 1.1 mrg IFS=$save_ifs 3587 1.1 mrg func_stripname ' ' '' "$lastarg" 3588 1.1 mrg lastarg=$func_stripname_result 3589 1.1 mrg 3590 1.1 mrg # Add the arguments to base_compile. 3591 1.1 mrg func_append base_compile " $lastarg" 3592 1.1 mrg continue 3593 1.1 mrg ;; 3594 1.1 mrg 3595 1.1 mrg *) 3596 1.1 mrg # Accept the current argument as the source file. 3597 1.1 mrg # The previous "srcfile" becomes the current argument. 3598 1.1 mrg # 3599 1.1 mrg lastarg=$srcfile 3600 1.1 mrg srcfile=$arg 3601 1.1 mrg ;; 3602 1.1 mrg esac # case $arg 3603 1.1 mrg ;; 3604 1.1 mrg esac # case $arg_mode 3605 1.1 mrg 3606 1.1 mrg # Aesthetically quote the previous argument. 3607 1.1 mrg func_append_quoted base_compile "$lastarg" 3608 1.1 mrg done # for arg 3609 1.1 mrg 3610 1.1 mrg case $arg_mode in 3611 1.1 mrg arg) 3612 1.1 mrg func_fatal_error "you must specify an argument for -Xcompile" 3613 1.1 mrg ;; 3614 1.1 mrg target) 3615 1.1 mrg func_fatal_error "you must specify a target with '-o'" 3616 1.1 mrg ;; 3617 1.1 mrg *) 3618 1.1 mrg # Get the name of the library object. 3619 1.1 mrg test -z "$libobj" && { 3620 1.1 mrg func_basename "$srcfile" 3621 1.1 mrg libobj=$func_basename_result 3622 1.1 mrg } 3623 1.1 mrg ;; 3624 1.1 mrg esac 3625 1.1 mrg 3626 1.1 mrg # Recognize several different file suffixes. 3627 1.1 mrg # If the user specifies -o file.o, it is replaced with file.lo 3628 1.1 mrg case $libobj in 3629 1.1 mrg *.[cCFSifmso] | \ 3630 1.1 mrg *.ada | *.adb | *.ads | *.asm | \ 3631 1.1 mrg *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \ 3632 1.1 mrg *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup) 3633 1.1 mrg func_xform "$libobj" 3634 1.1 mrg libobj=$func_xform_result 3635 1.1 mrg ;; 3636 1.1 mrg esac 3637 1.1 mrg 3638 1.1 mrg case $libobj in 3639 1.1 mrg *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;; 3640 1.1 mrg *) 3641 1.1 mrg func_fatal_error "cannot determine name of library object from '$libobj'" 3642 1.1 mrg ;; 3643 1.1 mrg esac 3644 1.1 mrg 3645 1.1 mrg func_infer_tag $base_compile 3646 1.1 mrg 3647 1.1 mrg for arg in $later; do 3648 1.1 mrg case $arg in 3649 1.1 mrg -shared) 3650 1.1 mrg test yes = "$build_libtool_libs" \ 3651 1.1 mrg || func_fatal_configuration "cannot build a shared library" 3652 1.1 mrg build_old_libs=no 3653 1.1 mrg continue 3654 1.1 mrg ;; 3655 1.1 mrg 3656 1.1 mrg -static) 3657 1.1 mrg build_libtool_libs=no 3658 1.1 mrg build_old_libs=yes 3659 1.1 mrg continue 3660 1.1 mrg ;; 3661 1.1 mrg 3662 1.1 mrg -prefer-pic) 3663 1.1 mrg pic_mode=yes 3664 1.1 mrg continue 3665 1.1 mrg ;; 3666 1.1 mrg 3667 1.1 mrg -prefer-non-pic) 3668 1.1 mrg pic_mode=no 3669 1.1 mrg continue 3670 1.1 mrg ;; 3671 1.1 mrg esac 3672 1.1 mrg done 3673 1.1 mrg 3674 1.1.1.2 mrg func_quote_arg pretty "$libobj" 3675 1.1.1.2 mrg test "X$libobj" != "X$func_quote_arg_result" \ 3676 1.1 mrg && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \ 3677 1.1 mrg && func_warning "libobj name '$libobj' may not contain shell special characters." 3678 1.1 mrg func_dirname_and_basename "$obj" "/" "" 3679 1.1 mrg objname=$func_basename_result 3680 1.1 mrg xdir=$func_dirname_result 3681 1.1 mrg lobj=$xdir$objdir/$objname 3682 1.1 mrg 3683 1.1 mrg test -z "$base_compile" && \ 3684 1.1 mrg func_fatal_help "you must specify a compilation command" 3685 1.1 mrg 3686 1.1 mrg # Delete any leftover library objects. 3687 1.1 mrg if test yes = "$build_old_libs"; then 3688 1.1 mrg removelist="$obj $lobj $libobj ${libobj}T" 3689 1.1 mrg else 3690 1.1 mrg removelist="$lobj $libobj ${libobj}T" 3691 1.1 mrg fi 3692 1.1 mrg 3693 1.1 mrg # On Cygwin there's no "real" PIC flag so we must build both object types 3694 1.1 mrg case $host_os in 3695 1.1 mrg cygwin* | mingw* | pw32* | os2* | cegcc*) 3696 1.1 mrg pic_mode=default 3697 1.1 mrg ;; 3698 1.1 mrg esac 3699 1.1 mrg if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then 3700 1.1 mrg # non-PIC code in shared libraries is not supported 3701 1.1 mrg pic_mode=default 3702 1.1 mrg fi 3703 1.1 mrg 3704 1.1 mrg # Calculate the filename of the output object if compiler does 3705 1.1 mrg # not support -o with -c 3706 1.1 mrg if test no = "$compiler_c_o"; then 3707 1.1 mrg output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext 3708 1.1 mrg lockfile=$output_obj.lock 3709 1.1 mrg else 3710 1.1 mrg output_obj= 3711 1.1 mrg need_locks=no 3712 1.1 mrg lockfile= 3713 1.1 mrg fi 3714 1.1 mrg 3715 1.1 mrg # Lock this critical section if it is needed 3716 1.1 mrg # We use this script file to make the link, it avoids creating a new file 3717 1.1 mrg if test yes = "$need_locks"; then 3718 1.1 mrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 3719 1.1 mrg func_echo "Waiting for $lockfile to be removed" 3720 1.1 mrg sleep 2 3721 1.1 mrg done 3722 1.1 mrg elif test warn = "$need_locks"; then 3723 1.1 mrg if test -f "$lockfile"; then 3724 1.1 mrg $ECHO "\ 3725 1.1 mrg *** ERROR, $lockfile exists and contains: 3726 1.1 mrg `cat $lockfile 2>/dev/null` 3727 1.1 mrg 3728 1.1 mrg This indicates that another process is trying to use the same 3729 1.1 mrg temporary object file, and libtool could not work around it because 3730 1.1 mrg your compiler does not support '-c' and '-o' together. If you 3731 1.1 mrg repeat this compilation, it may succeed, by chance, but you had better 3732 1.1 mrg avoid parallel builds (make -j) in this platform, or get a better 3733 1.1 mrg compiler." 3734 1.1 mrg 3735 1.1 mrg $opt_dry_run || $RM $removelist 3736 1.1 mrg exit $EXIT_FAILURE 3737 1.1 mrg fi 3738 1.1 mrg func_append removelist " $output_obj" 3739 1.1 mrg $ECHO "$srcfile" > "$lockfile" 3740 1.1 mrg fi 3741 1.1 mrg 3742 1.1 mrg $opt_dry_run || $RM $removelist 3743 1.1 mrg func_append removelist " $lockfile" 3744 1.1 mrg trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15 3745 1.1 mrg 3746 1.1 mrg func_to_tool_file "$srcfile" func_convert_file_msys_to_w32 3747 1.1 mrg srcfile=$func_to_tool_file_result 3748 1.1.1.2 mrg func_quote_arg pretty "$srcfile" 3749 1.1.1.2 mrg qsrcfile=$func_quote_arg_result 3750 1.1 mrg 3751 1.1 mrg # Only build a PIC object if we are building libtool libraries. 3752 1.1 mrg if test yes = "$build_libtool_libs"; then 3753 1.1 mrg # Without this assignment, base_compile gets emptied. 3754 1.1 mrg fbsd_hideous_sh_bug=$base_compile 3755 1.1 mrg 3756 1.1 mrg if test no != "$pic_mode"; then 3757 1.1 mrg command="$base_compile $qsrcfile $pic_flag" 3758 1.1 mrg else 3759 1.1 mrg # Don't build PIC code 3760 1.1 mrg command="$base_compile $qsrcfile" 3761 1.1 mrg fi 3762 1.1 mrg 3763 1.1 mrg func_mkdir_p "$xdir$objdir" 3764 1.1 mrg 3765 1.1 mrg if test -z "$output_obj"; then 3766 1.1 mrg # Place PIC objects in $objdir 3767 1.1 mrg func_append command " -o $lobj" 3768 1.1 mrg fi 3769 1.1 mrg 3770 1.1 mrg func_show_eval_locale "$command" \ 3771 1.1 mrg 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE' 3772 1.1 mrg 3773 1.1 mrg if test warn = "$need_locks" && 3774 1.1 mrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3775 1.1 mrg $ECHO "\ 3776 1.1 mrg *** ERROR, $lockfile contains: 3777 1.1 mrg `cat $lockfile 2>/dev/null` 3778 1.1 mrg 3779 1.1 mrg but it should contain: 3780 1.1 mrg $srcfile 3781 1.1 mrg 3782 1.1 mrg This indicates that another process is trying to use the same 3783 1.1 mrg temporary object file, and libtool could not work around it because 3784 1.1 mrg your compiler does not support '-c' and '-o' together. If you 3785 1.1 mrg repeat this compilation, it may succeed, by chance, but you had better 3786 1.1 mrg avoid parallel builds (make -j) in this platform, or get a better 3787 1.1 mrg compiler." 3788 1.1 mrg 3789 1.1 mrg $opt_dry_run || $RM $removelist 3790 1.1 mrg exit $EXIT_FAILURE 3791 1.1 mrg fi 3792 1.1 mrg 3793 1.1 mrg # Just move the object if needed, then go on to compile the next one 3794 1.1 mrg if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then 3795 1.1 mrg func_show_eval '$MV "$output_obj" "$lobj"' \ 3796 1.1 mrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3797 1.1 mrg fi 3798 1.1 mrg 3799 1.1 mrg # Allow error messages only from the first compilation. 3800 1.1 mrg if test yes = "$suppress_opt"; then 3801 1.1 mrg suppress_output=' >/dev/null 2>&1' 3802 1.1 mrg fi 3803 1.1 mrg fi 3804 1.1 mrg 3805 1.1 mrg # Only build a position-dependent object if we build old libraries. 3806 1.1 mrg if test yes = "$build_old_libs"; then 3807 1.1 mrg if test yes != "$pic_mode"; then 3808 1.1 mrg # Don't build PIC code 3809 1.1 mrg command="$base_compile $qsrcfile$pie_flag" 3810 1.1 mrg else 3811 1.1 mrg command="$base_compile $qsrcfile $pic_flag" 3812 1.1 mrg fi 3813 1.1 mrg if test yes = "$compiler_c_o"; then 3814 1.1 mrg func_append command " -o $obj" 3815 1.1 mrg fi 3816 1.1 mrg 3817 1.1 mrg # Suppress compiler output if we already did a PIC compilation. 3818 1.1 mrg func_append command "$suppress_output" 3819 1.1 mrg func_show_eval_locale "$command" \ 3820 1.1 mrg '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 3821 1.1 mrg 3822 1.1 mrg if test warn = "$need_locks" && 3823 1.1 mrg test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then 3824 1.1 mrg $ECHO "\ 3825 1.1 mrg *** ERROR, $lockfile contains: 3826 1.1 mrg `cat $lockfile 2>/dev/null` 3827 1.1 mrg 3828 1.1 mrg but it should contain: 3829 1.1 mrg $srcfile 3830 1.1 mrg 3831 1.1 mrg This indicates that another process is trying to use the same 3832 1.1 mrg temporary object file, and libtool could not work around it because 3833 1.1 mrg your compiler does not support '-c' and '-o' together. If you 3834 1.1 mrg repeat this compilation, it may succeed, by chance, but you had better 3835 1.1 mrg avoid parallel builds (make -j) in this platform, or get a better 3836 1.1 mrg compiler." 3837 1.1 mrg 3838 1.1 mrg $opt_dry_run || $RM $removelist 3839 1.1 mrg exit $EXIT_FAILURE 3840 1.1 mrg fi 3841 1.1 mrg 3842 1.1 mrg # Just move the object if needed 3843 1.1 mrg if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then 3844 1.1 mrg func_show_eval '$MV "$output_obj" "$obj"' \ 3845 1.1 mrg 'error=$?; $opt_dry_run || $RM $removelist; exit $error' 3846 1.1 mrg fi 3847 1.1 mrg fi 3848 1.1 mrg 3849 1.1 mrg $opt_dry_run || { 3850 1.1 mrg func_write_libtool_object "$libobj" "$objdir/$objname" "$objname" 3851 1.1 mrg 3852 1.1 mrg # Unlock the critical section if it was locked 3853 1.1 mrg if test no != "$need_locks"; then 3854 1.1 mrg removelist=$lockfile 3855 1.1 mrg $RM "$lockfile" 3856 1.1 mrg fi 3857 1.1 mrg } 3858 1.1 mrg 3859 1.1 mrg exit $EXIT_SUCCESS 3860 1.1 mrg } 3861 1.1 mrg 3862 1.1 mrg $opt_help || { 3863 1.1 mrg test compile = "$opt_mode" && func_mode_compile ${1+"$@"} 3864 1.1 mrg } 3865 1.1 mrg 3866 1.1 mrg func_mode_help () 3867 1.1 mrg { 3868 1.1 mrg # We need to display help for each of the modes. 3869 1.1 mrg case $opt_mode in 3870 1.1 mrg "") 3871 1.1 mrg # Generic help is extracted from the usage comments 3872 1.1 mrg # at the start of this file. 3873 1.1 mrg func_help 3874 1.1 mrg ;; 3875 1.1 mrg 3876 1.1 mrg clean) 3877 1.1 mrg $ECHO \ 3878 1.1 mrg "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE... 3879 1.1 mrg 3880 1.1 mrg Remove files from the build directory. 3881 1.1 mrg 3882 1.1 mrg RM is the name of the program to use to delete files associated with each FILE 3883 1.1 mrg (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 3884 1.1 mrg to RM. 3885 1.1 mrg 3886 1.1 mrg If FILE is a libtool library, object or program, all the files associated 3887 1.1 mrg with it are deleted. Otherwise, only FILE itself is deleted using RM." 3888 1.1 mrg ;; 3889 1.1 mrg 3890 1.1 mrg compile) 3891 1.1 mrg $ECHO \ 3892 1.1 mrg "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE 3893 1.1 mrg 3894 1.1 mrg Compile a source file into a libtool library object. 3895 1.1 mrg 3896 1.1 mrg This mode accepts the following additional options: 3897 1.1 mrg 3898 1.1 mrg -o OUTPUT-FILE set the output file name to OUTPUT-FILE 3899 1.1 mrg -no-suppress do not suppress compiler output for multiple passes 3900 1.1 mrg -prefer-pic try to build PIC objects only 3901 1.1 mrg -prefer-non-pic try to build non-PIC objects only 3902 1.1 mrg -shared do not build a '.o' file suitable for static linking 3903 1.1 mrg -static only build a '.o' file suitable for static linking 3904 1.1.1.2 mrg -Wc,FLAG 3905 1.1.1.2 mrg -Xcompiler FLAG pass FLAG directly to the compiler 3906 1.1 mrg 3907 1.1 mrg COMPILE-COMMAND is a command to be used in creating a 'standard' object file 3908 1.1 mrg from the given SOURCEFILE. 3909 1.1 mrg 3910 1.1 mrg The output file name is determined by removing the directory component from 3911 1.1 mrg SOURCEFILE, then substituting the C source code suffix '.c' with the 3912 1.1 mrg library object suffix, '.lo'." 3913 1.1 mrg ;; 3914 1.1 mrg 3915 1.1 mrg execute) 3916 1.1 mrg $ECHO \ 3917 1.1 mrg "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]... 3918 1.1 mrg 3919 1.1 mrg Automatically set library path, then run a program. 3920 1.1 mrg 3921 1.1 mrg This mode accepts the following additional options: 3922 1.1 mrg 3923 1.1 mrg -dlopen FILE add the directory containing FILE to the library path 3924 1.1 mrg 3925 1.1 mrg This mode sets the library path environment variable according to '-dlopen' 3926 1.1 mrg flags. 3927 1.1 mrg 3928 1.1 mrg If any of the ARGS are libtool executable wrappers, then they are translated 3929 1.1 mrg into their corresponding uninstalled binary, and any of their required library 3930 1.1 mrg directories are added to the library path. 3931 1.1 mrg 3932 1.1 mrg Then, COMMAND is executed, with ARGS as arguments." 3933 1.1 mrg ;; 3934 1.1 mrg 3935 1.1 mrg finish) 3936 1.1 mrg $ECHO \ 3937 1.1 mrg "Usage: $progname [OPTION]... --mode=finish [LIBDIR]... 3938 1.1 mrg 3939 1.1 mrg Complete the installation of libtool libraries. 3940 1.1 mrg 3941 1.1 mrg Each LIBDIR is a directory that contains libtool libraries. 3942 1.1 mrg 3943 1.1 mrg The commands that this mode executes may require superuser privileges. Use 3944 1.1 mrg the '--dry-run' option if you just want to see what would be executed." 3945 1.1 mrg ;; 3946 1.1 mrg 3947 1.1 mrg install) 3948 1.1 mrg $ECHO \ 3949 1.1 mrg "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND... 3950 1.1 mrg 3951 1.1 mrg Install executables or libraries. 3952 1.1 mrg 3953 1.1 mrg INSTALL-COMMAND is the installation command. The first component should be 3954 1.1 mrg either the 'install' or 'cp' program. 3955 1.1 mrg 3956 1.1 mrg The following components of INSTALL-COMMAND are treated specially: 3957 1.1 mrg 3958 1.1 mrg -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation 3959 1.1 mrg 3960 1.1 mrg The rest of the components are interpreted as arguments to that command (only 3961 1.1 mrg BSD-compatible install options are recognized)." 3962 1.1 mrg ;; 3963 1.1 mrg 3964 1.1 mrg link) 3965 1.1 mrg $ECHO \ 3966 1.1 mrg "Usage: $progname [OPTION]... --mode=link LINK-COMMAND... 3967 1.1 mrg 3968 1.1 mrg Link object files or libraries together to form another library, or to 3969 1.1 mrg create an executable program. 3970 1.1 mrg 3971 1.1 mrg LINK-COMMAND is a command using the C compiler that you would use to create 3972 1.1 mrg a program from several object files. 3973 1.1 mrg 3974 1.1 mrg The following components of LINK-COMMAND are treated specially: 3975 1.1 mrg 3976 1.1 mrg -all-static do not do any dynamic linking at all 3977 1.1 mrg -avoid-version do not add a version suffix if possible 3978 1.1 mrg -bindir BINDIR specify path to binaries directory (for systems where 3979 1.1 mrg libraries must be found in the PATH setting at runtime) 3980 1.1 mrg -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime 3981 1.1 mrg -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols 3982 1.1 mrg -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3) 3983 1.1 mrg -export-symbols SYMFILE 3984 1.1 mrg try to export only the symbols listed in SYMFILE 3985 1.1 mrg -export-symbols-regex REGEX 3986 1.1 mrg try to export only the symbols matching REGEX 3987 1.1 mrg -LLIBDIR search LIBDIR for required installed libraries 3988 1.1 mrg -lNAME OUTPUT-FILE requires the installed library libNAME 3989 1.1 mrg -module build a library that can dlopened 3990 1.1 mrg -no-fast-install disable the fast-install mode 3991 1.1 mrg -no-install link a not-installable executable 3992 1.1 mrg -no-undefined declare that a library does not refer to external symbols 3993 1.1 mrg -o OUTPUT-FILE create OUTPUT-FILE from the specified objects 3994 1.1 mrg -objectlist FILE use a list of object files found in FILE to specify objects 3995 1.1 mrg -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes) 3996 1.1 mrg -precious-files-regex REGEX 3997 1.1 mrg don't remove output files matching REGEX 3998 1.1 mrg -release RELEASE specify package release information 3999 1.1 mrg -rpath LIBDIR the created library will eventually be installed in LIBDIR 4000 1.1 mrg -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries 4001 1.1 mrg -shared only do dynamic linking of libtool libraries 4002 1.1 mrg -shrext SUFFIX override the standard shared library file extension 4003 1.1 mrg -static do not do any dynamic linking of uninstalled libtool libraries 4004 1.1 mrg -static-libtool-libs 4005 1.1 mrg do not do any dynamic linking of libtool libraries 4006 1.1 mrg -version-info CURRENT[:REVISION[:AGE]] 4007 1.1 mrg specify library version info [each variable defaults to 0] 4008 1.1 mrg -weak LIBNAME declare that the target provides the LIBNAME interface 4009 1.1 mrg -Wc,FLAG 4010 1.1 mrg -Xcompiler FLAG pass linker-specific FLAG directly to the compiler 4011 1.1.1.2 mrg -Wa,FLAG 4012 1.1.1.2 mrg -Xassembler FLAG pass linker-specific FLAG directly to the assembler 4013 1.1 mrg -Wl,FLAG 4014 1.1 mrg -Xlinker FLAG pass linker-specific FLAG directly to the linker 4015 1.1 mrg -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC) 4016 1.1 mrg 4017 1.1 mrg All other options (arguments beginning with '-') are ignored. 4018 1.1 mrg 4019 1.1 mrg Every other argument is treated as a filename. Files ending in '.la' are 4020 1.1 mrg treated as uninstalled libtool libraries, other files are standard or library 4021 1.1 mrg object files. 4022 1.1 mrg 4023 1.1 mrg If the OUTPUT-FILE ends in '.la', then a libtool library is created, 4024 1.1 mrg only library objects ('.lo' files) may be specified, and '-rpath' is 4025 1.1 mrg required, except when creating a convenience library. 4026 1.1 mrg 4027 1.1 mrg If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created 4028 1.1 mrg using 'ar' and 'ranlib', or on Windows using 'lib'. 4029 1.1 mrg 4030 1.1 mrg If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file 4031 1.1 mrg is created, otherwise an executable program is created." 4032 1.1 mrg ;; 4033 1.1 mrg 4034 1.1 mrg uninstall) 4035 1.1 mrg $ECHO \ 4036 1.1 mrg "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE... 4037 1.1 mrg 4038 1.1 mrg Remove libraries from an installation directory. 4039 1.1 mrg 4040 1.1 mrg RM is the name of the program to use to delete files associated with each FILE 4041 1.1 mrg (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed 4042 1.1 mrg to RM. 4043 1.1 mrg 4044 1.1 mrg If FILE is a libtool library, all the files associated with it are deleted. 4045 1.1 mrg Otherwise, only FILE itself is deleted using RM." 4046 1.1 mrg ;; 4047 1.1 mrg 4048 1.1 mrg *) 4049 1.1 mrg func_fatal_help "invalid operation mode '$opt_mode'" 4050 1.1 mrg ;; 4051 1.1 mrg esac 4052 1.1 mrg 4053 1.1 mrg echo 4054 1.1 mrg $ECHO "Try '$progname --help' for more information about other modes." 4055 1.1 mrg } 4056 1.1 mrg 4057 1.1 mrg # Now that we've collected a possible --mode arg, show help if necessary 4058 1.1 mrg if $opt_help; then 4059 1.1 mrg if test : = "$opt_help"; then 4060 1.1 mrg func_mode_help 4061 1.1 mrg else 4062 1.1 mrg { 4063 1.1 mrg func_help noexit 4064 1.1 mrg for opt_mode in compile link execute install finish uninstall clean; do 4065 1.1 mrg func_mode_help 4066 1.1 mrg done 4067 1.1 mrg } | $SED -n '1p; 2,$s/^Usage:/ or: /p' 4068 1.1 mrg { 4069 1.1 mrg func_help noexit 4070 1.1 mrg for opt_mode in compile link execute install finish uninstall clean; do 4071 1.1 mrg echo 4072 1.1 mrg func_mode_help 4073 1.1 mrg done 4074 1.1 mrg } | 4075 1.1 mrg $SED '1d 4076 1.1 mrg /^When reporting/,/^Report/{ 4077 1.1 mrg H 4078 1.1 mrg d 4079 1.1 mrg } 4080 1.1 mrg $x 4081 1.1 mrg /information about other modes/d 4082 1.1 mrg /more detailed .*MODE/d 4083 1.1 mrg s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/' 4084 1.1 mrg fi 4085 1.1 mrg exit $? 4086 1.1 mrg fi 4087 1.1 mrg 4088 1.1 mrg 4089 1.1 mrg # func_mode_execute arg... 4090 1.1 mrg func_mode_execute () 4091 1.1 mrg { 4092 1.1 mrg $debug_cmd 4093 1.1 mrg 4094 1.1 mrg # The first argument is the command name. 4095 1.1 mrg cmd=$nonopt 4096 1.1 mrg test -z "$cmd" && \ 4097 1.1 mrg func_fatal_help "you must specify a COMMAND" 4098 1.1 mrg 4099 1.1 mrg # Handle -dlopen flags immediately. 4100 1.1 mrg for file in $opt_dlopen; do 4101 1.1 mrg test -f "$file" \ 4102 1.1 mrg || func_fatal_help "'$file' is not a file" 4103 1.1 mrg 4104 1.1 mrg dir= 4105 1.1 mrg case $file in 4106 1.1 mrg *.la) 4107 1.1 mrg func_resolve_sysroot "$file" 4108 1.1 mrg file=$func_resolve_sysroot_result 4109 1.1 mrg 4110 1.1 mrg # Check to see that this really is a libtool archive. 4111 1.1 mrg func_lalib_unsafe_p "$file" \ 4112 1.1 mrg || func_fatal_help "'$lib' is not a valid libtool archive" 4113 1.1 mrg 4114 1.1 mrg # Read the libtool library. 4115 1.1 mrg dlname= 4116 1.1 mrg library_names= 4117 1.1 mrg func_source "$file" 4118 1.1 mrg 4119 1.1 mrg # Skip this library if it cannot be dlopened. 4120 1.1 mrg if test -z "$dlname"; then 4121 1.1 mrg # Warn if it was a shared library. 4122 1.1 mrg test -n "$library_names" && \ 4123 1.1 mrg func_warning "'$file' was not linked with '-export-dynamic'" 4124 1.1 mrg continue 4125 1.1 mrg fi 4126 1.1 mrg 4127 1.1 mrg func_dirname "$file" "" "." 4128 1.1 mrg dir=$func_dirname_result 4129 1.1 mrg 4130 1.1 mrg if test -f "$dir/$objdir/$dlname"; then 4131 1.1 mrg func_append dir "/$objdir" 4132 1.1 mrg else 4133 1.1 mrg if test ! -f "$dir/$dlname"; then 4134 1.1 mrg func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'" 4135 1.1 mrg fi 4136 1.1 mrg fi 4137 1.1 mrg ;; 4138 1.1 mrg 4139 1.1 mrg *.lo) 4140 1.1 mrg # Just add the directory containing the .lo file. 4141 1.1 mrg func_dirname "$file" "" "." 4142 1.1 mrg dir=$func_dirname_result 4143 1.1 mrg ;; 4144 1.1 mrg 4145 1.1 mrg *) 4146 1.1 mrg func_warning "'-dlopen' is ignored for non-libtool libraries and objects" 4147 1.1 mrg continue 4148 1.1 mrg ;; 4149 1.1 mrg esac 4150 1.1 mrg 4151 1.1 mrg # Get the absolute pathname. 4152 1.1 mrg absdir=`cd "$dir" && pwd` 4153 1.1 mrg test -n "$absdir" && dir=$absdir 4154 1.1 mrg 4155 1.1 mrg # Now add the directory to shlibpath_var. 4156 1.1 mrg if eval "test -z \"\$$shlibpath_var\""; then 4157 1.1 mrg eval "$shlibpath_var=\"\$dir\"" 4158 1.1 mrg else 4159 1.1 mrg eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\"" 4160 1.1 mrg fi 4161 1.1 mrg done 4162 1.1 mrg 4163 1.1 mrg # This variable tells wrapper scripts just to set shlibpath_var 4164 1.1 mrg # rather than running their programs. 4165 1.1 mrg libtool_execute_magic=$magic 4166 1.1 mrg 4167 1.1 mrg # Check if any of the arguments is a wrapper script. 4168 1.1 mrg args= 4169 1.1 mrg for file 4170 1.1 mrg do 4171 1.1 mrg case $file in 4172 1.1 mrg -* | *.la | *.lo ) ;; 4173 1.1 mrg *) 4174 1.1 mrg # Do a test to see if this is really a libtool program. 4175 1.1 mrg if func_ltwrapper_script_p "$file"; then 4176 1.1 mrg func_source "$file" 4177 1.1 mrg # Transform arg to wrapped name. 4178 1.1 mrg file=$progdir/$program 4179 1.1 mrg elif func_ltwrapper_executable_p "$file"; then 4180 1.1 mrg func_ltwrapper_scriptname "$file" 4181 1.1 mrg func_source "$func_ltwrapper_scriptname_result" 4182 1.1 mrg # Transform arg to wrapped name. 4183 1.1 mrg file=$progdir/$program 4184 1.1 mrg fi 4185 1.1 mrg ;; 4186 1.1 mrg esac 4187 1.1 mrg # Quote arguments (to preserve shell metacharacters). 4188 1.1 mrg func_append_quoted args "$file" 4189 1.1 mrg done 4190 1.1 mrg 4191 1.1 mrg if $opt_dry_run; then 4192 1.1 mrg # Display what would be done. 4193 1.1 mrg if test -n "$shlibpath_var"; then 4194 1.1 mrg eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\"" 4195 1.1 mrg echo "export $shlibpath_var" 4196 1.1 mrg fi 4197 1.1 mrg $ECHO "$cmd$args" 4198 1.1 mrg exit $EXIT_SUCCESS 4199 1.1 mrg else 4200 1.1 mrg if test -n "$shlibpath_var"; then 4201 1.1 mrg # Export the shlibpath_var. 4202 1.1 mrg eval "export $shlibpath_var" 4203 1.1 mrg fi 4204 1.1 mrg 4205 1.1 mrg # Restore saved environment variables 4206 1.1 mrg for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES 4207 1.1 mrg do 4208 1.1 mrg eval "if test \"\${save_$lt_var+set}\" = set; then 4209 1.1 mrg $lt_var=\$save_$lt_var; export $lt_var 4210 1.1 mrg else 4211 1.1 mrg $lt_unset $lt_var 4212 1.1 mrg fi" 4213 1.1 mrg done 4214 1.1 mrg 4215 1.1 mrg # Now prepare to actually exec the command. 4216 1.1 mrg exec_cmd=\$cmd$args 4217 1.1 mrg fi 4218 1.1 mrg } 4219 1.1 mrg 4220 1.1 mrg test execute = "$opt_mode" && func_mode_execute ${1+"$@"} 4221 1.1 mrg 4222 1.1 mrg 4223 1.1 mrg # func_mode_finish arg... 4224 1.1 mrg func_mode_finish () 4225 1.1 mrg { 4226 1.1 mrg $debug_cmd 4227 1.1 mrg 4228 1.1 mrg libs= 4229 1.1 mrg libdirs= 4230 1.1 mrg admincmds= 4231 1.1 mrg 4232 1.1 mrg for opt in "$nonopt" ${1+"$@"} 4233 1.1 mrg do 4234 1.1 mrg if test -d "$opt"; then 4235 1.1 mrg func_append libdirs " $opt" 4236 1.1 mrg 4237 1.1 mrg elif test -f "$opt"; then 4238 1.1 mrg if func_lalib_unsafe_p "$opt"; then 4239 1.1 mrg func_append libs " $opt" 4240 1.1 mrg else 4241 1.1 mrg func_warning "'$opt' is not a valid libtool archive" 4242 1.1 mrg fi 4243 1.1 mrg 4244 1.1 mrg else 4245 1.1 mrg func_fatal_error "invalid argument '$opt'" 4246 1.1 mrg fi 4247 1.1 mrg done 4248 1.1 mrg 4249 1.1 mrg if test -n "$libs"; then 4250 1.1 mrg if test -n "$lt_sysroot"; then 4251 1.1 mrg sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"` 4252 1.1 mrg sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;" 4253 1.1 mrg else 4254 1.1 mrg sysroot_cmd= 4255 1.1 mrg fi 4256 1.1 mrg 4257 1.1 mrg # Remove sysroot references 4258 1.1 mrg if $opt_dry_run; then 4259 1.1 mrg for lib in $libs; do 4260 1.1 mrg echo "removing references to $lt_sysroot and '=' prefixes from $lib" 4261 1.1 mrg done 4262 1.1 mrg else 4263 1.1 mrg tmpdir=`func_mktempdir` 4264 1.1 mrg for lib in $libs; do 4265 1.1 mrg $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \ 4266 1.1 mrg > $tmpdir/tmp-la 4267 1.1 mrg mv -f $tmpdir/tmp-la $lib 4268 1.1 mrg done 4269 1.1 mrg ${RM}r "$tmpdir" 4270 1.1 mrg fi 4271 1.1 mrg fi 4272 1.1 mrg 4273 1.1 mrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4274 1.1 mrg for libdir in $libdirs; do 4275 1.1 mrg if test -n "$finish_cmds"; then 4276 1.1 mrg # Do each command in the finish commands. 4277 1.1 mrg func_execute_cmds "$finish_cmds" 'admincmds="$admincmds 4278 1.1 mrg '"$cmd"'"' 4279 1.1 mrg fi 4280 1.1 mrg if test -n "$finish_eval"; then 4281 1.1 mrg # Do the single finish_eval. 4282 1.1 mrg eval cmds=\"$finish_eval\" 4283 1.1 mrg $opt_dry_run || eval "$cmds" || func_append admincmds " 4284 1.1 mrg $cmds" 4285 1.1 mrg fi 4286 1.1 mrg done 4287 1.1 mrg fi 4288 1.1 mrg 4289 1.1 mrg # Exit here if they wanted silent mode. 4290 1.1 mrg $opt_quiet && exit $EXIT_SUCCESS 4291 1.1 mrg 4292 1.1 mrg if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then 4293 1.1 mrg echo "----------------------------------------------------------------------" 4294 1.1 mrg echo "Libraries have been installed in:" 4295 1.1 mrg for libdir in $libdirs; do 4296 1.1 mrg $ECHO " $libdir" 4297 1.1 mrg done 4298 1.1 mrg echo 4299 1.1 mrg echo "If you ever happen to want to link against installed libraries" 4300 1.1 mrg echo "in a given directory, LIBDIR, you must either use libtool, and" 4301 1.1 mrg echo "specify the full pathname of the library, or use the '-LLIBDIR'" 4302 1.1 mrg echo "flag during linking and do at least one of the following:" 4303 1.1 mrg if test -n "$shlibpath_var"; then 4304 1.1 mrg echo " - add LIBDIR to the '$shlibpath_var' environment variable" 4305 1.1 mrg echo " during execution" 4306 1.1 mrg fi 4307 1.1 mrg if test -n "$runpath_var"; then 4308 1.1 mrg echo " - add LIBDIR to the '$runpath_var' environment variable" 4309 1.1 mrg echo " during linking" 4310 1.1 mrg fi 4311 1.1 mrg if test -n "$hardcode_libdir_flag_spec"; then 4312 1.1 mrg libdir=LIBDIR 4313 1.1 mrg eval flag=\"$hardcode_libdir_flag_spec\" 4314 1.1 mrg 4315 1.1 mrg $ECHO " - use the '$flag' linker flag" 4316 1.1 mrg fi 4317 1.1 mrg if test -n "$admincmds"; then 4318 1.1 mrg $ECHO " - have your system administrator run these commands:$admincmds" 4319 1.1 mrg fi 4320 1.1 mrg if test -f /etc/ld.so.conf; then 4321 1.1 mrg echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'" 4322 1.1 mrg fi 4323 1.1 mrg echo 4324 1.1 mrg 4325 1.1 mrg echo "See any operating system documentation about shared libraries for" 4326 1.1 mrg case $host in 4327 1.1 mrg solaris2.[6789]|solaris2.1[0-9]) 4328 1.1 mrg echo "more information, such as the ld(1), crle(1) and ld.so(8) manual" 4329 1.1 mrg echo "pages." 4330 1.1 mrg ;; 4331 1.1 mrg *) 4332 1.1 mrg echo "more information, such as the ld(1) and ld.so(8) manual pages." 4333 1.1 mrg ;; 4334 1.1 mrg esac 4335 1.1 mrg echo "----------------------------------------------------------------------" 4336 1.1 mrg fi 4337 1.1 mrg exit $EXIT_SUCCESS 4338 1.1 mrg } 4339 1.1 mrg 4340 1.1 mrg test finish = "$opt_mode" && func_mode_finish ${1+"$@"} 4341 1.1 mrg 4342 1.1 mrg 4343 1.1 mrg # func_mode_install arg... 4344 1.1 mrg func_mode_install () 4345 1.1 mrg { 4346 1.1 mrg $debug_cmd 4347 1.1 mrg 4348 1.1 mrg # There may be an optional sh(1) argument at the beginning of 4349 1.1 mrg # install_prog (especially on Windows NT). 4350 1.1 mrg if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" || 4351 1.1 mrg # Allow the use of GNU shtool's install command. 4352 1.1 mrg case $nonopt in *shtool*) :;; *) false;; esac 4353 1.1 mrg then 4354 1.1 mrg # Aesthetically quote it. 4355 1.1.1.2 mrg func_quote_arg pretty "$nonopt" 4356 1.1.1.2 mrg install_prog="$func_quote_arg_result " 4357 1.1 mrg arg=$1 4358 1.1 mrg shift 4359 1.1 mrg else 4360 1.1 mrg install_prog= 4361 1.1 mrg arg=$nonopt 4362 1.1 mrg fi 4363 1.1 mrg 4364 1.1 mrg # The real first argument should be the name of the installation program. 4365 1.1 mrg # Aesthetically quote it. 4366 1.1.1.2 mrg func_quote_arg pretty "$arg" 4367 1.1.1.2 mrg func_append install_prog "$func_quote_arg_result" 4368 1.1 mrg install_shared_prog=$install_prog 4369 1.1 mrg case " $install_prog " in 4370 1.1 mrg *[\\\ /]cp\ *) install_cp=: ;; 4371 1.1 mrg *) install_cp=false ;; 4372 1.1 mrg esac 4373 1.1 mrg 4374 1.1 mrg # We need to accept at least all the BSD install flags. 4375 1.1 mrg dest= 4376 1.1 mrg files= 4377 1.1 mrg opts= 4378 1.1 mrg prev= 4379 1.1 mrg install_type= 4380 1.1 mrg isdir=false 4381 1.1 mrg stripme= 4382 1.1 mrg no_mode=: 4383 1.1 mrg for arg 4384 1.1 mrg do 4385 1.1 mrg arg2= 4386 1.1 mrg if test -n "$dest"; then 4387 1.1 mrg func_append files " $dest" 4388 1.1 mrg dest=$arg 4389 1.1 mrg continue 4390 1.1 mrg fi 4391 1.1 mrg 4392 1.1 mrg case $arg in 4393 1.1 mrg -d) isdir=: ;; 4394 1.1 mrg -f) 4395 1.1 mrg if $install_cp; then :; else 4396 1.1 mrg prev=$arg 4397 1.1 mrg fi 4398 1.1 mrg ;; 4399 1.1 mrg -g | -m | -o) 4400 1.1 mrg prev=$arg 4401 1.1 mrg ;; 4402 1.1 mrg -s) 4403 1.1 mrg stripme=" -s" 4404 1.1 mrg continue 4405 1.1 mrg ;; 4406 1.1 mrg -*) 4407 1.1 mrg ;; 4408 1.1 mrg *) 4409 1.1 mrg # If the previous option needed an argument, then skip it. 4410 1.1 mrg if test -n "$prev"; then 4411 1.1 mrg if test X-m = "X$prev" && test -n "$install_override_mode"; then 4412 1.1 mrg arg2=$install_override_mode 4413 1.1 mrg no_mode=false 4414 1.1 mrg fi 4415 1.1 mrg prev= 4416 1.1 mrg else 4417 1.1 mrg dest=$arg 4418 1.1 mrg continue 4419 1.1 mrg fi 4420 1.1 mrg ;; 4421 1.1 mrg esac 4422 1.1 mrg 4423 1.1 mrg # Aesthetically quote the argument. 4424 1.1.1.2 mrg func_quote_arg pretty "$arg" 4425 1.1.1.2 mrg func_append install_prog " $func_quote_arg_result" 4426 1.1 mrg if test -n "$arg2"; then 4427 1.1.1.2 mrg func_quote_arg pretty "$arg2" 4428 1.1 mrg fi 4429 1.1.1.2 mrg func_append install_shared_prog " $func_quote_arg_result" 4430 1.1 mrg done 4431 1.1 mrg 4432 1.1 mrg test -z "$install_prog" && \ 4433 1.1 mrg func_fatal_help "you must specify an install program" 4434 1.1 mrg 4435 1.1 mrg test -n "$prev" && \ 4436 1.1 mrg func_fatal_help "the '$prev' option requires an argument" 4437 1.1 mrg 4438 1.1 mrg if test -n "$install_override_mode" && $no_mode; then 4439 1.1 mrg if $install_cp; then :; else 4440 1.1.1.2 mrg func_quote_arg pretty "$install_override_mode" 4441 1.1.1.2 mrg func_append install_shared_prog " -m $func_quote_arg_result" 4442 1.1 mrg fi 4443 1.1 mrg fi 4444 1.1 mrg 4445 1.1 mrg if test -z "$files"; then 4446 1.1 mrg if test -z "$dest"; then 4447 1.1 mrg func_fatal_help "no file or destination specified" 4448 1.1 mrg else 4449 1.1 mrg func_fatal_help "you must specify a destination" 4450 1.1 mrg fi 4451 1.1 mrg fi 4452 1.1 mrg 4453 1.1 mrg # Strip any trailing slash from the destination. 4454 1.1 mrg func_stripname '' '/' "$dest" 4455 1.1 mrg dest=$func_stripname_result 4456 1.1 mrg 4457 1.1 mrg # Check to see that the destination is a directory. 4458 1.1 mrg test -d "$dest" && isdir=: 4459 1.1 mrg if $isdir; then 4460 1.1 mrg destdir=$dest 4461 1.1 mrg destname= 4462 1.1 mrg else 4463 1.1 mrg func_dirname_and_basename "$dest" "" "." 4464 1.1 mrg destdir=$func_dirname_result 4465 1.1 mrg destname=$func_basename_result 4466 1.1 mrg 4467 1.1 mrg # Not a directory, so check to see that there is only one file specified. 4468 1.1 mrg set dummy $files; shift 4469 1.1 mrg test "$#" -gt 1 && \ 4470 1.1 mrg func_fatal_help "'$dest' is not a directory" 4471 1.1 mrg fi 4472 1.1 mrg case $destdir in 4473 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) ;; 4474 1.1 mrg *) 4475 1.1 mrg for file in $files; do 4476 1.1 mrg case $file in 4477 1.1 mrg *.lo) ;; 4478 1.1 mrg *) 4479 1.1 mrg func_fatal_help "'$destdir' must be an absolute directory name" 4480 1.1 mrg ;; 4481 1.1 mrg esac 4482 1.1 mrg done 4483 1.1 mrg ;; 4484 1.1 mrg esac 4485 1.1 mrg 4486 1.1 mrg # This variable tells wrapper scripts just to set variables rather 4487 1.1 mrg # than running their programs. 4488 1.1 mrg libtool_install_magic=$magic 4489 1.1 mrg 4490 1.1 mrg staticlibs= 4491 1.1 mrg future_libdirs= 4492 1.1 mrg current_libdirs= 4493 1.1 mrg for file in $files; do 4494 1.1 mrg 4495 1.1 mrg # Do each installation. 4496 1.1 mrg case $file in 4497 1.1 mrg *.$libext) 4498 1.1 mrg # Do the static libraries later. 4499 1.1 mrg func_append staticlibs " $file" 4500 1.1 mrg ;; 4501 1.1 mrg 4502 1.1 mrg *.la) 4503 1.1 mrg func_resolve_sysroot "$file" 4504 1.1 mrg file=$func_resolve_sysroot_result 4505 1.1 mrg 4506 1.1 mrg # Check to see that this really is a libtool archive. 4507 1.1 mrg func_lalib_unsafe_p "$file" \ 4508 1.1 mrg || func_fatal_help "'$file' is not a valid libtool archive" 4509 1.1 mrg 4510 1.1 mrg library_names= 4511 1.1 mrg old_library= 4512 1.1 mrg relink_command= 4513 1.1 mrg func_source "$file" 4514 1.1 mrg 4515 1.1 mrg # Add the libdir to current_libdirs if it is the destination. 4516 1.1 mrg if test "X$destdir" = "X$libdir"; then 4517 1.1 mrg case "$current_libdirs " in 4518 1.1 mrg *" $libdir "*) ;; 4519 1.1 mrg *) func_append current_libdirs " $libdir" ;; 4520 1.1 mrg esac 4521 1.1 mrg else 4522 1.1 mrg # Note the libdir as a future libdir. 4523 1.1 mrg case "$future_libdirs " in 4524 1.1 mrg *" $libdir "*) ;; 4525 1.1 mrg *) func_append future_libdirs " $libdir" ;; 4526 1.1 mrg esac 4527 1.1 mrg fi 4528 1.1 mrg 4529 1.1 mrg func_dirname "$file" "/" "" 4530 1.1 mrg dir=$func_dirname_result 4531 1.1 mrg func_append dir "$objdir" 4532 1.1 mrg 4533 1.1 mrg if test -n "$relink_command"; then 4534 1.1 mrg # Determine the prefix the user has applied to our future dir. 4535 1.1 mrg inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"` 4536 1.1 mrg 4537 1.1 mrg # Don't allow the user to place us outside of our expected 4538 1.1 mrg # location b/c this prevents finding dependent libraries that 4539 1.1 mrg # are installed to the same prefix. 4540 1.1 mrg # At present, this check doesn't affect windows .dll's that 4541 1.1 mrg # are installed into $libdir/../bin (currently, that works fine) 4542 1.1 mrg # but it's something to keep an eye on. 4543 1.1 mrg test "$inst_prefix_dir" = "$destdir" && \ 4544 1.1 mrg func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir" 4545 1.1 mrg 4546 1.1 mrg if test -n "$inst_prefix_dir"; then 4547 1.1 mrg # Stick the inst_prefix_dir data into the link command. 4548 1.1 mrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"` 4549 1.1 mrg else 4550 1.1 mrg relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"` 4551 1.1 mrg fi 4552 1.1 mrg 4553 1.1 mrg func_warning "relinking '$file'" 4554 1.1 mrg func_show_eval "$relink_command" \ 4555 1.1 mrg 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"' 4556 1.1 mrg fi 4557 1.1 mrg 4558 1.1 mrg # See the names of the shared library. 4559 1.1 mrg set dummy $library_names; shift 4560 1.1 mrg if test -n "$1"; then 4561 1.1 mrg realname=$1 4562 1.1 mrg shift 4563 1.1 mrg 4564 1.1 mrg srcname=$realname 4565 1.1 mrg test -n "$relink_command" && srcname=${realname}T 4566 1.1 mrg 4567 1.1 mrg # Install the shared library and build the symlinks. 4568 1.1 mrg func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \ 4569 1.1 mrg 'exit $?' 4570 1.1 mrg tstripme=$stripme 4571 1.1 mrg case $host_os in 4572 1.1 mrg cygwin* | mingw* | pw32* | cegcc*) 4573 1.1 mrg case $realname in 4574 1.1 mrg *.dll.a) 4575 1.1 mrg tstripme= 4576 1.1 mrg ;; 4577 1.1 mrg esac 4578 1.1 mrg ;; 4579 1.1 mrg os2*) 4580 1.1 mrg case $realname in 4581 1.1 mrg *_dll.a) 4582 1.1 mrg tstripme= 4583 1.1 mrg ;; 4584 1.1 mrg esac 4585 1.1 mrg ;; 4586 1.1 mrg esac 4587 1.1 mrg if test -n "$tstripme" && test -n "$striplib"; then 4588 1.1 mrg func_show_eval "$striplib $destdir/$realname" 'exit $?' 4589 1.1 mrg fi 4590 1.1 mrg 4591 1.1 mrg if test "$#" -gt 0; then 4592 1.1 mrg # Delete the old symlinks, and create new ones. 4593 1.1 mrg # Try 'ln -sf' first, because the 'ln' binary might depend on 4594 1.1 mrg # the symlink we replace! Solaris /bin/ln does not understand -f, 4595 1.1 mrg # so we also need to try rm && ln -s. 4596 1.1 mrg for linkname 4597 1.1 mrg do 4598 1.1 mrg test "$linkname" != "$realname" \ 4599 1.1 mrg && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })" 4600 1.1 mrg done 4601 1.1 mrg fi 4602 1.1 mrg 4603 1.1 mrg # Do each command in the postinstall commands. 4604 1.1 mrg lib=$destdir/$realname 4605 1.1 mrg func_execute_cmds "$postinstall_cmds" 'exit $?' 4606 1.1 mrg fi 4607 1.1 mrg 4608 1.1 mrg # Install the pseudo-library for information purposes. 4609 1.1 mrg func_basename "$file" 4610 1.1 mrg name=$func_basename_result 4611 1.1 mrg instname=$dir/${name}i 4612 1.1 mrg func_show_eval "$install_prog $instname $destdir/$name" 'exit $?' 4613 1.1 mrg 4614 1.1 mrg # Maybe install the static library, too. 4615 1.1 mrg test -n "$old_library" && func_append staticlibs " $dir/$old_library" 4616 1.1 mrg ;; 4617 1.1 mrg 4618 1.1 mrg *.lo) 4619 1.1 mrg # Install (i.e. copy) a libtool object. 4620 1.1 mrg 4621 1.1 mrg # Figure out destination file name, if it wasn't already specified. 4622 1.1 mrg if test -n "$destname"; then 4623 1.1 mrg destfile=$destdir/$destname 4624 1.1 mrg else 4625 1.1 mrg func_basename "$file" 4626 1.1 mrg destfile=$func_basename_result 4627 1.1 mrg destfile=$destdir/$destfile 4628 1.1 mrg fi 4629 1.1 mrg 4630 1.1 mrg # Deduce the name of the destination old-style object file. 4631 1.1 mrg case $destfile in 4632 1.1 mrg *.lo) 4633 1.1 mrg func_lo2o "$destfile" 4634 1.1 mrg staticdest=$func_lo2o_result 4635 1.1 mrg ;; 4636 1.1 mrg *.$objext) 4637 1.1 mrg staticdest=$destfile 4638 1.1 mrg destfile= 4639 1.1 mrg ;; 4640 1.1 mrg *) 4641 1.1 mrg func_fatal_help "cannot copy a libtool object to '$destfile'" 4642 1.1 mrg ;; 4643 1.1 mrg esac 4644 1.1 mrg 4645 1.1 mrg # Install the libtool object if requested. 4646 1.1 mrg test -n "$destfile" && \ 4647 1.1 mrg func_show_eval "$install_prog $file $destfile" 'exit $?' 4648 1.1 mrg 4649 1.1 mrg # Install the old object if enabled. 4650 1.1 mrg if test yes = "$build_old_libs"; then 4651 1.1 mrg # Deduce the name of the old-style object file. 4652 1.1 mrg func_lo2o "$file" 4653 1.1 mrg staticobj=$func_lo2o_result 4654 1.1 mrg func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?' 4655 1.1 mrg fi 4656 1.1 mrg exit $EXIT_SUCCESS 4657 1.1 mrg ;; 4658 1.1 mrg 4659 1.1 mrg *) 4660 1.1 mrg # Figure out destination file name, if it wasn't already specified. 4661 1.1 mrg if test -n "$destname"; then 4662 1.1 mrg destfile=$destdir/$destname 4663 1.1 mrg else 4664 1.1 mrg func_basename "$file" 4665 1.1 mrg destfile=$func_basename_result 4666 1.1 mrg destfile=$destdir/$destfile 4667 1.1 mrg fi 4668 1.1 mrg 4669 1.1 mrg # If the file is missing, and there is a .exe on the end, strip it 4670 1.1 mrg # because it is most likely a libtool script we actually want to 4671 1.1 mrg # install 4672 1.1 mrg stripped_ext= 4673 1.1 mrg case $file in 4674 1.1 mrg *.exe) 4675 1.1 mrg if test ! -f "$file"; then 4676 1.1 mrg func_stripname '' '.exe' "$file" 4677 1.1 mrg file=$func_stripname_result 4678 1.1 mrg stripped_ext=.exe 4679 1.1 mrg fi 4680 1.1 mrg ;; 4681 1.1 mrg esac 4682 1.1 mrg 4683 1.1 mrg # Do a test to see if this is really a libtool program. 4684 1.1 mrg case $host in 4685 1.1 mrg *cygwin* | *mingw*) 4686 1.1 mrg if func_ltwrapper_executable_p "$file"; then 4687 1.1 mrg func_ltwrapper_scriptname "$file" 4688 1.1 mrg wrapper=$func_ltwrapper_scriptname_result 4689 1.1 mrg else 4690 1.1 mrg func_stripname '' '.exe' "$file" 4691 1.1 mrg wrapper=$func_stripname_result 4692 1.1 mrg fi 4693 1.1 mrg ;; 4694 1.1 mrg *) 4695 1.1 mrg wrapper=$file 4696 1.1 mrg ;; 4697 1.1 mrg esac 4698 1.1 mrg if func_ltwrapper_script_p "$wrapper"; then 4699 1.1 mrg notinst_deplibs= 4700 1.1 mrg relink_command= 4701 1.1 mrg 4702 1.1 mrg func_source "$wrapper" 4703 1.1 mrg 4704 1.1 mrg # Check the variables that should have been set. 4705 1.1 mrg test -z "$generated_by_libtool_version" && \ 4706 1.1 mrg func_fatal_error "invalid libtool wrapper script '$wrapper'" 4707 1.1 mrg 4708 1.1 mrg finalize=: 4709 1.1 mrg for lib in $notinst_deplibs; do 4710 1.1 mrg # Check to see that each library is installed. 4711 1.1 mrg libdir= 4712 1.1 mrg if test -f "$lib"; then 4713 1.1 mrg func_source "$lib" 4714 1.1 mrg fi 4715 1.1 mrg libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'` 4716 1.1 mrg if test -n "$libdir" && test ! -f "$libfile"; then 4717 1.1 mrg func_warning "'$lib' has not been installed in '$libdir'" 4718 1.1 mrg finalize=false 4719 1.1 mrg fi 4720 1.1 mrg done 4721 1.1 mrg 4722 1.1 mrg relink_command= 4723 1.1 mrg func_source "$wrapper" 4724 1.1 mrg 4725 1.1 mrg outputname= 4726 1.1 mrg if test no = "$fast_install" && test -n "$relink_command"; then 4727 1.1 mrg $opt_dry_run || { 4728 1.1 mrg if $finalize; then 4729 1.1 mrg tmpdir=`func_mktempdir` 4730 1.1 mrg func_basename "$file$stripped_ext" 4731 1.1 mrg file=$func_basename_result 4732 1.1 mrg outputname=$tmpdir/$file 4733 1.1 mrg # Replace the output file specification. 4734 1.1 mrg relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'` 4735 1.1 mrg 4736 1.1 mrg $opt_quiet || { 4737 1.1.1.2 mrg func_quote_arg expand,pretty "$relink_command" 4738 1.1.1.2 mrg eval "func_echo $func_quote_arg_result" 4739 1.1 mrg } 4740 1.1 mrg if eval "$relink_command"; then : 4741 1.1 mrg else 4742 1.1 mrg func_error "error: relink '$file' with the above command before installing it" 4743 1.1 mrg $opt_dry_run || ${RM}r "$tmpdir" 4744 1.1 mrg continue 4745 1.1 mrg fi 4746 1.1 mrg file=$outputname 4747 1.1 mrg else 4748 1.1 mrg func_warning "cannot relink '$file'" 4749 1.1 mrg fi 4750 1.1 mrg } 4751 1.1 mrg else 4752 1.1 mrg # Install the binary that we compiled earlier. 4753 1.1 mrg file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"` 4754 1.1 mrg fi 4755 1.1 mrg fi 4756 1.1 mrg 4757 1.1 mrg # remove .exe since cygwin /usr/bin/install will append another 4758 1.1 mrg # one anyway 4759 1.1 mrg case $install_prog,$host in 4760 1.1 mrg */usr/bin/install*,*cygwin*) 4761 1.1 mrg case $file:$destfile in 4762 1.1 mrg *.exe:*.exe) 4763 1.1 mrg # this is ok 4764 1.1 mrg ;; 4765 1.1 mrg *.exe:*) 4766 1.1 mrg destfile=$destfile.exe 4767 1.1 mrg ;; 4768 1.1 mrg *:*.exe) 4769 1.1 mrg func_stripname '' '.exe' "$destfile" 4770 1.1 mrg destfile=$func_stripname_result 4771 1.1 mrg ;; 4772 1.1 mrg esac 4773 1.1 mrg ;; 4774 1.1 mrg esac 4775 1.1 mrg func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?' 4776 1.1 mrg $opt_dry_run || if test -n "$outputname"; then 4777 1.1 mrg ${RM}r "$tmpdir" 4778 1.1 mrg fi 4779 1.1 mrg ;; 4780 1.1 mrg esac 4781 1.1 mrg done 4782 1.1 mrg 4783 1.1 mrg for file in $staticlibs; do 4784 1.1 mrg func_basename "$file" 4785 1.1 mrg name=$func_basename_result 4786 1.1 mrg 4787 1.1 mrg # Set up the ranlib parameters. 4788 1.1 mrg oldlib=$destdir/$name 4789 1.1 mrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 4790 1.1 mrg tool_oldlib=$func_to_tool_file_result 4791 1.1 mrg 4792 1.1 mrg func_show_eval "$install_prog \$file \$oldlib" 'exit $?' 4793 1.1 mrg 4794 1.1 mrg if test -n "$stripme" && test -n "$old_striplib"; then 4795 1.1 mrg func_show_eval "$old_striplib $tool_oldlib" 'exit $?' 4796 1.1 mrg fi 4797 1.1 mrg 4798 1.1 mrg # Do each command in the postinstall commands. 4799 1.1 mrg func_execute_cmds "$old_postinstall_cmds" 'exit $?' 4800 1.1 mrg done 4801 1.1 mrg 4802 1.1 mrg test -n "$future_libdirs" && \ 4803 1.1 mrg func_warning "remember to run '$progname --finish$future_libdirs'" 4804 1.1 mrg 4805 1.1 mrg if test -n "$current_libdirs"; then 4806 1.1 mrg # Maybe just do a dry run. 4807 1.1 mrg $opt_dry_run && current_libdirs=" -n$current_libdirs" 4808 1.1 mrg exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs' 4809 1.1 mrg else 4810 1.1 mrg exit $EXIT_SUCCESS 4811 1.1 mrg fi 4812 1.1 mrg } 4813 1.1 mrg 4814 1.1 mrg test install = "$opt_mode" && func_mode_install ${1+"$@"} 4815 1.1 mrg 4816 1.1 mrg 4817 1.1 mrg # func_generate_dlsyms outputname originator pic_p 4818 1.1 mrg # Extract symbols from dlprefiles and create ${outputname}S.o with 4819 1.1 mrg # a dlpreopen symbol table. 4820 1.1 mrg func_generate_dlsyms () 4821 1.1 mrg { 4822 1.1 mrg $debug_cmd 4823 1.1 mrg 4824 1.1 mrg my_outputname=$1 4825 1.1 mrg my_originator=$2 4826 1.1 mrg my_pic_p=${3-false} 4827 1.1 mrg my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'` 4828 1.1 mrg my_dlsyms= 4829 1.1 mrg 4830 1.1 mrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 4831 1.1 mrg if test -n "$NM" && test -n "$global_symbol_pipe"; then 4832 1.1 mrg my_dlsyms=${my_outputname}S.c 4833 1.1 mrg else 4834 1.1 mrg func_error "not configured to extract global symbols from dlpreopened files" 4835 1.1 mrg fi 4836 1.1 mrg fi 4837 1.1 mrg 4838 1.1 mrg if test -n "$my_dlsyms"; then 4839 1.1 mrg case $my_dlsyms in 4840 1.1 mrg "") ;; 4841 1.1 mrg *.c) 4842 1.1 mrg # Discover the nlist of each of the dlfiles. 4843 1.1 mrg nlist=$output_objdir/$my_outputname.nm 4844 1.1 mrg 4845 1.1 mrg func_show_eval "$RM $nlist ${nlist}S ${nlist}T" 4846 1.1 mrg 4847 1.1 mrg # Parse the name list into a source file. 4848 1.1 mrg func_verbose "creating $output_objdir/$my_dlsyms" 4849 1.1 mrg 4850 1.1 mrg $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\ 4851 1.1 mrg /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */ 4852 1.1 mrg /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */ 4853 1.1 mrg 4854 1.1 mrg #ifdef __cplusplus 4855 1.1 mrg extern \"C\" { 4856 1.1 mrg #endif 4857 1.1 mrg 4858 1.1 mrg #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4)) 4859 1.1 mrg #pragma GCC diagnostic ignored \"-Wstrict-prototypes\" 4860 1.1 mrg #endif 4861 1.1 mrg 4862 1.1 mrg /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */ 4863 1.1 mrg #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE 4864 1.1 mrg /* DATA imports from DLLs on WIN32 can't be const, because runtime 4865 1.1 mrg relocations are performed -- see ld's documentation on pseudo-relocs. */ 4866 1.1 mrg # define LT_DLSYM_CONST 4867 1.1 mrg #elif defined __osf__ 4868 1.1 mrg /* This system does not cope well with relocations in const data. */ 4869 1.1 mrg # define LT_DLSYM_CONST 4870 1.1 mrg #else 4871 1.1 mrg # define LT_DLSYM_CONST const 4872 1.1 mrg #endif 4873 1.1 mrg 4874 1.1 mrg #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 4875 1.1 mrg 4876 1.1 mrg /* External symbol declarations for the compiler. */\ 4877 1.1 mrg " 4878 1.1 mrg 4879 1.1 mrg if test yes = "$dlself"; then 4880 1.1 mrg func_verbose "generating symbol list for '$output'" 4881 1.1 mrg 4882 1.1 mrg $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist" 4883 1.1 mrg 4884 1.1 mrg # Add our own program objects to the symbol list. 4885 1.1 mrg progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP` 4886 1.1 mrg for progfile in $progfiles; do 4887 1.1 mrg func_to_tool_file "$progfile" func_convert_file_msys_to_w32 4888 1.1 mrg func_verbose "extracting global C symbols from '$func_to_tool_file_result'" 4889 1.1 mrg $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'" 4890 1.1 mrg done 4891 1.1 mrg 4892 1.1 mrg if test -n "$exclude_expsyms"; then 4893 1.1 mrg $opt_dry_run || { 4894 1.1 mrg eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T' 4895 1.1 mrg eval '$MV "$nlist"T "$nlist"' 4896 1.1 mrg } 4897 1.1 mrg fi 4898 1.1 mrg 4899 1.1 mrg if test -n "$export_symbols_regex"; then 4900 1.1 mrg $opt_dry_run || { 4901 1.1 mrg eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T' 4902 1.1 mrg eval '$MV "$nlist"T "$nlist"' 4903 1.1 mrg } 4904 1.1 mrg fi 4905 1.1 mrg 4906 1.1 mrg # Prepare the list of exported symbols 4907 1.1 mrg if test -z "$export_symbols"; then 4908 1.1 mrg export_symbols=$output_objdir/$outputname.exp 4909 1.1 mrg $opt_dry_run || { 4910 1.1 mrg $RM $export_symbols 4911 1.1 mrg eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"' 4912 1.1 mrg case $host in 4913 1.1 mrg *cygwin* | *mingw* | *cegcc* ) 4914 1.1 mrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4915 1.1 mrg eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"' 4916 1.1 mrg ;; 4917 1.1 mrg esac 4918 1.1 mrg } 4919 1.1 mrg else 4920 1.1 mrg $opt_dry_run || { 4921 1.1 mrg eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"' 4922 1.1 mrg eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T' 4923 1.1 mrg eval '$MV "$nlist"T "$nlist"' 4924 1.1 mrg case $host in 4925 1.1 mrg *cygwin* | *mingw* | *cegcc* ) 4926 1.1 mrg eval "echo EXPORTS "'> "$output_objdir/$outputname.def"' 4927 1.1 mrg eval 'cat "$nlist" >> "$output_objdir/$outputname.def"' 4928 1.1 mrg ;; 4929 1.1 mrg esac 4930 1.1 mrg } 4931 1.1 mrg fi 4932 1.1 mrg fi 4933 1.1 mrg 4934 1.1 mrg for dlprefile in $dlprefiles; do 4935 1.1 mrg func_verbose "extracting global C symbols from '$dlprefile'" 4936 1.1 mrg func_basename "$dlprefile" 4937 1.1 mrg name=$func_basename_result 4938 1.1 mrg case $host in 4939 1.1 mrg *cygwin* | *mingw* | *cegcc* ) 4940 1.1 mrg # if an import library, we need to obtain dlname 4941 1.1 mrg if func_win32_import_lib_p "$dlprefile"; then 4942 1.1 mrg func_tr_sh "$dlprefile" 4943 1.1 mrg eval "curr_lafile=\$libfile_$func_tr_sh_result" 4944 1.1 mrg dlprefile_dlbasename= 4945 1.1 mrg if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then 4946 1.1 mrg # Use subshell, to avoid clobbering current variable values 4947 1.1 mrg dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"` 4948 1.1 mrg if test -n "$dlprefile_dlname"; then 4949 1.1 mrg func_basename "$dlprefile_dlname" 4950 1.1 mrg dlprefile_dlbasename=$func_basename_result 4951 1.1 mrg else 4952 1.1 mrg # no lafile. user explicitly requested -dlpreopen <import library>. 4953 1.1 mrg $sharedlib_from_linklib_cmd "$dlprefile" 4954 1.1 mrg dlprefile_dlbasename=$sharedlib_from_linklib_result 4955 1.1 mrg fi 4956 1.1 mrg fi 4957 1.1 mrg $opt_dry_run || { 4958 1.1 mrg if test -n "$dlprefile_dlbasename"; then 4959 1.1 mrg eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"' 4960 1.1 mrg else 4961 1.1 mrg func_warning "Could not compute DLL name from $name" 4962 1.1 mrg eval '$ECHO ": $name " >> "$nlist"' 4963 1.1 mrg fi 4964 1.1 mrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4965 1.1 mrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe | 4966 1.1 mrg $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'" 4967 1.1 mrg } 4968 1.1 mrg else # not an import lib 4969 1.1 mrg $opt_dry_run || { 4970 1.1 mrg eval '$ECHO ": $name " >> "$nlist"' 4971 1.1 mrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4972 1.1 mrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4973 1.1 mrg } 4974 1.1 mrg fi 4975 1.1 mrg ;; 4976 1.1 mrg *) 4977 1.1 mrg $opt_dry_run || { 4978 1.1 mrg eval '$ECHO ": $name " >> "$nlist"' 4979 1.1 mrg func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32 4980 1.1 mrg eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'" 4981 1.1 mrg } 4982 1.1 mrg ;; 4983 1.1 mrg esac 4984 1.1 mrg done 4985 1.1 mrg 4986 1.1 mrg $opt_dry_run || { 4987 1.1 mrg # Make sure we have at least an empty file. 4988 1.1 mrg test -f "$nlist" || : > "$nlist" 4989 1.1 mrg 4990 1.1 mrg if test -n "$exclude_expsyms"; then 4991 1.1 mrg $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T 4992 1.1 mrg $MV "$nlist"T "$nlist" 4993 1.1 mrg fi 4994 1.1 mrg 4995 1.1 mrg # Try sorting and uniquifying the output. 4996 1.1 mrg if $GREP -v "^: " < "$nlist" | 4997 1.1 mrg if sort -k 3 </dev/null >/dev/null 2>&1; then 4998 1.1 mrg sort -k 3 4999 1.1 mrg else 5000 1.1 mrg sort +2 5001 1.1 mrg fi | 5002 1.1 mrg uniq > "$nlist"S; then 5003 1.1 mrg : 5004 1.1 mrg else 5005 1.1 mrg $GREP -v "^: " < "$nlist" > "$nlist"S 5006 1.1 mrg fi 5007 1.1 mrg 5008 1.1 mrg if test -f "$nlist"S; then 5009 1.1 mrg eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"' 5010 1.1 mrg else 5011 1.1 mrg echo '/* NONE */' >> "$output_objdir/$my_dlsyms" 5012 1.1 mrg fi 5013 1.1 mrg 5014 1.1 mrg func_show_eval '$RM "${nlist}I"' 5015 1.1 mrg if test -n "$global_symbol_to_import"; then 5016 1.1 mrg eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I' 5017 1.1 mrg fi 5018 1.1 mrg 5019 1.1 mrg echo >> "$output_objdir/$my_dlsyms" "\ 5020 1.1 mrg 5021 1.1 mrg /* The mapping between symbol names and symbols. */ 5022 1.1 mrg typedef struct { 5023 1.1 mrg const char *name; 5024 1.1 mrg void *address; 5025 1.1 mrg } lt_dlsymlist; 5026 1.1 mrg extern LT_DLSYM_CONST lt_dlsymlist 5027 1.1 mrg lt_${my_prefix}_LTX_preloaded_symbols[];\ 5028 1.1 mrg " 5029 1.1 mrg 5030 1.1 mrg if test -s "$nlist"I; then 5031 1.1 mrg echo >> "$output_objdir/$my_dlsyms" "\ 5032 1.1 mrg static void lt_syminit(void) 5033 1.1 mrg { 5034 1.1 mrg LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols; 5035 1.1 mrg for (; symbol->name; ++symbol) 5036 1.1 mrg {" 5037 1.1 mrg $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms" 5038 1.1 mrg echo >> "$output_objdir/$my_dlsyms" "\ 5039 1.1 mrg } 5040 1.1 mrg }" 5041 1.1 mrg fi 5042 1.1 mrg echo >> "$output_objdir/$my_dlsyms" "\ 5043 1.1 mrg LT_DLSYM_CONST lt_dlsymlist 5044 1.1 mrg lt_${my_prefix}_LTX_preloaded_symbols[] = 5045 1.1 mrg { {\"$my_originator\", (void *) 0}," 5046 1.1 mrg 5047 1.1 mrg if test -s "$nlist"I; then 5048 1.1 mrg echo >> "$output_objdir/$my_dlsyms" "\ 5049 1.1 mrg {\"@INIT@\", (void *) <_syminit}," 5050 1.1 mrg fi 5051 1.1 mrg 5052 1.1 mrg case $need_lib_prefix in 5053 1.1 mrg no) 5054 1.1 mrg eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms" 5055 1.1 mrg ;; 5056 1.1 mrg *) 5057 1.1 mrg eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms" 5058 1.1 mrg ;; 5059 1.1 mrg esac 5060 1.1 mrg echo >> "$output_objdir/$my_dlsyms" "\ 5061 1.1 mrg {0, (void *) 0} 5062 1.1 mrg }; 5063 1.1 mrg 5064 1.1 mrg /* This works around a problem in FreeBSD linker */ 5065 1.1 mrg #ifdef FREEBSD_WORKAROUND 5066 1.1 mrg static const void *lt_preloaded_setup() { 5067 1.1 mrg return lt_${my_prefix}_LTX_preloaded_symbols; 5068 1.1 mrg } 5069 1.1 mrg #endif 5070 1.1 mrg 5071 1.1 mrg #ifdef __cplusplus 5072 1.1 mrg } 5073 1.1 mrg #endif\ 5074 1.1 mrg " 5075 1.1 mrg } # !$opt_dry_run 5076 1.1 mrg 5077 1.1 mrg pic_flag_for_symtable= 5078 1.1 mrg case "$compile_command " in 5079 1.1 mrg *" -static "*) ;; 5080 1.1 mrg *) 5081 1.1 mrg case $host in 5082 1.1 mrg # compiling the symbol table file with pic_flag works around 5083 1.1 mrg # a FreeBSD bug that causes programs to crash when -lm is 5084 1.1 mrg # linked before any other PIC object. But we must not use 5085 1.1 mrg # pic_flag when linking with -static. The problem exists in 5086 1.1 mrg # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1. 5087 1.1 mrg *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*) 5088 1.1 mrg pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;; 5089 1.1 mrg *-*-hpux*) 5090 1.1 mrg pic_flag_for_symtable=" $pic_flag" ;; 5091 1.1 mrg *) 5092 1.1 mrg $my_pic_p && pic_flag_for_symtable=" $pic_flag" 5093 1.1 mrg ;; 5094 1.1 mrg esac 5095 1.1 mrg ;; 5096 1.1 mrg esac 5097 1.1 mrg symtab_cflags= 5098 1.1 mrg for arg in $LTCFLAGS; do 5099 1.1 mrg case $arg in 5100 1.1 mrg -pie | -fpie | -fPIE) ;; 5101 1.1 mrg *) func_append symtab_cflags " $arg" ;; 5102 1.1 mrg esac 5103 1.1 mrg done 5104 1.1 mrg 5105 1.1 mrg # Now compile the dynamic symbol file. 5106 1.1 mrg func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?' 5107 1.1 mrg 5108 1.1 mrg # Clean up the generated files. 5109 1.1 mrg func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"' 5110 1.1 mrg 5111 1.1 mrg # Transform the symbol file into the correct name. 5112 1.1 mrg symfileobj=$output_objdir/${my_outputname}S.$objext 5113 1.1 mrg case $host in 5114 1.1 mrg *cygwin* | *mingw* | *cegcc* ) 5115 1.1 mrg if test -f "$output_objdir/$my_outputname.def"; then 5116 1.1 mrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5117 1.1 mrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"` 5118 1.1 mrg else 5119 1.1 mrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5120 1.1 mrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5121 1.1 mrg fi 5122 1.1 mrg ;; 5123 1.1 mrg *) 5124 1.1 mrg compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5125 1.1 mrg finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"` 5126 1.1 mrg ;; 5127 1.1 mrg esac 5128 1.1 mrg ;; 5129 1.1 mrg *) 5130 1.1 mrg func_fatal_error "unknown suffix for '$my_dlsyms'" 5131 1.1 mrg ;; 5132 1.1 mrg esac 5133 1.1 mrg else 5134 1.1 mrg # We keep going just in case the user didn't refer to 5135 1.1 mrg # lt_preloaded_symbols. The linker will fail if global_symbol_pipe 5136 1.1 mrg # really was required. 5137 1.1 mrg 5138 1.1 mrg # Nullify the symbol file. 5139 1.1 mrg compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"` 5140 1.1 mrg finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"` 5141 1.1 mrg fi 5142 1.1 mrg } 5143 1.1 mrg 5144 1.1 mrg # func_cygming_gnu_implib_p ARG 5145 1.1 mrg # This predicate returns with zero status (TRUE) if 5146 1.1 mrg # ARG is a GNU/binutils-style import library. Returns 5147 1.1 mrg # with nonzero status (FALSE) otherwise. 5148 1.1 mrg func_cygming_gnu_implib_p () 5149 1.1 mrg { 5150 1.1 mrg $debug_cmd 5151 1.1 mrg 5152 1.1 mrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5153 1.1 mrg 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)$'` 5154 1.1 mrg test -n "$func_cygming_gnu_implib_tmp" 5155 1.1 mrg } 5156 1.1 mrg 5157 1.1 mrg # func_cygming_ms_implib_p ARG 5158 1.1 mrg # This predicate returns with zero status (TRUE) if 5159 1.1 mrg # ARG is an MS-style import library. Returns 5160 1.1 mrg # with nonzero status (FALSE) otherwise. 5161 1.1 mrg func_cygming_ms_implib_p () 5162 1.1 mrg { 5163 1.1 mrg $debug_cmd 5164 1.1 mrg 5165 1.1 mrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5166 1.1 mrg func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'` 5167 1.1 mrg test -n "$func_cygming_ms_implib_tmp" 5168 1.1 mrg } 5169 1.1 mrg 5170 1.1 mrg # func_win32_libid arg 5171 1.1 mrg # return the library type of file 'arg' 5172 1.1 mrg # 5173 1.1 mrg # Need a lot of goo to handle *both* DLLs and import libs 5174 1.1 mrg # Has to be a shell function in order to 'eat' the argument 5175 1.1 mrg # that is supplied when $file_magic_command is called. 5176 1.1 mrg # Despite the name, also deal with 64 bit binaries. 5177 1.1 mrg func_win32_libid () 5178 1.1 mrg { 5179 1.1 mrg $debug_cmd 5180 1.1 mrg 5181 1.1 mrg win32_libid_type=unknown 5182 1.1 mrg win32_fileres=`file -L $1 2>/dev/null` 5183 1.1 mrg case $win32_fileres in 5184 1.1 mrg *ar\ archive\ import\ library*) # definitely import 5185 1.1 mrg win32_libid_type="x86 archive import" 5186 1.1 mrg ;; 5187 1.1 mrg *ar\ archive*) # could be an import, or static 5188 1.1 mrg # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD. 5189 1.1 mrg if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | 5190 1.1 mrg $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then 5191 1.1 mrg case $nm_interface in 5192 1.1 mrg "MS dumpbin") 5193 1.1 mrg if func_cygming_ms_implib_p "$1" || 5194 1.1 mrg func_cygming_gnu_implib_p "$1" 5195 1.1 mrg then 5196 1.1 mrg win32_nmres=import 5197 1.1 mrg else 5198 1.1 mrg win32_nmres= 5199 1.1 mrg fi 5200 1.1 mrg ;; 5201 1.1 mrg *) 5202 1.1 mrg func_to_tool_file "$1" func_convert_file_msys_to_w32 5203 1.1 mrg win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" | 5204 1.1 mrg $SED -n -e ' 5205 1.1 mrg 1,100{ 5206 1.1 mrg / I /{ 5207 1.1 mrg s|.*|import| 5208 1.1 mrg p 5209 1.1 mrg q 5210 1.1 mrg } 5211 1.1 mrg }'` 5212 1.1 mrg ;; 5213 1.1 mrg esac 5214 1.1 mrg case $win32_nmres in 5215 1.1 mrg import*) win32_libid_type="x86 archive import";; 5216 1.1 mrg *) win32_libid_type="x86 archive static";; 5217 1.1 mrg esac 5218 1.1 mrg fi 5219 1.1 mrg ;; 5220 1.1 mrg *DLL*) 5221 1.1 mrg win32_libid_type="x86 DLL" 5222 1.1 mrg ;; 5223 1.1 mrg *executable*) # but shell scripts are "executable" too... 5224 1.1 mrg case $win32_fileres in 5225 1.1 mrg *MS\ Windows\ PE\ Intel*) 5226 1.1 mrg win32_libid_type="x86 DLL" 5227 1.1 mrg ;; 5228 1.1 mrg esac 5229 1.1 mrg ;; 5230 1.1 mrg esac 5231 1.1 mrg $ECHO "$win32_libid_type" 5232 1.1 mrg } 5233 1.1 mrg 5234 1.1 mrg # func_cygming_dll_for_implib ARG 5235 1.1 mrg # 5236 1.1 mrg # Platform-specific function to extract the 5237 1.1 mrg # name of the DLL associated with the specified 5238 1.1 mrg # import library ARG. 5239 1.1 mrg # Invoked by eval'ing the libtool variable 5240 1.1 mrg # $sharedlib_from_linklib_cmd 5241 1.1 mrg # Result is available in the variable 5242 1.1 mrg # $sharedlib_from_linklib_result 5243 1.1 mrg func_cygming_dll_for_implib () 5244 1.1 mrg { 5245 1.1 mrg $debug_cmd 5246 1.1 mrg 5247 1.1 mrg sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"` 5248 1.1 mrg } 5249 1.1 mrg 5250 1.1 mrg # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs 5251 1.1 mrg # 5252 1.1 mrg # The is the core of a fallback implementation of a 5253 1.1 mrg # platform-specific function to extract the name of the 5254 1.1 mrg # DLL associated with the specified import library LIBNAME. 5255 1.1 mrg # 5256 1.1 mrg # SECTION_NAME is either .idata$6 or .idata$7, depending 5257 1.1 mrg # on the platform and compiler that created the implib. 5258 1.1 mrg # 5259 1.1 mrg # Echos the name of the DLL associated with the 5260 1.1 mrg # specified import library. 5261 1.1 mrg func_cygming_dll_for_implib_fallback_core () 5262 1.1 mrg { 5263 1.1 mrg $debug_cmd 5264 1.1 mrg 5265 1.1 mrg match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"` 5266 1.1 mrg $OBJDUMP -s --section "$1" "$2" 2>/dev/null | 5267 1.1 mrg $SED '/^Contents of section '"$match_literal"':/{ 5268 1.1 mrg # Place marker at beginning of archive member dllname section 5269 1.1 mrg s/.*/====MARK====/ 5270 1.1 mrg p 5271 1.1 mrg d 5272 1.1 mrg } 5273 1.1 mrg # These lines can sometimes be longer than 43 characters, but 5274 1.1 mrg # are always uninteresting 5275 1.1 mrg /:[ ]*file format pe[i]\{,1\}-/d 5276 1.1 mrg /^In archive [^:]*:/d 5277 1.1 mrg # Ensure marker is printed 5278 1.1 mrg /^====MARK====/p 5279 1.1 mrg # Remove all lines with less than 43 characters 5280 1.1 mrg /^.\{43\}/!d 5281 1.1 mrg # From remaining lines, remove first 43 characters 5282 1.1 mrg s/^.\{43\}//' | 5283 1.1 mrg $SED -n ' 5284 1.1 mrg # Join marker and all lines until next marker into a single line 5285 1.1 mrg /^====MARK====/ b para 5286 1.1 mrg H 5287 1.1 mrg $ b para 5288 1.1 mrg b 5289 1.1 mrg :para 5290 1.1 mrg x 5291 1.1 mrg s/\n//g 5292 1.1 mrg # Remove the marker 5293 1.1 mrg s/^====MARK====// 5294 1.1 mrg # Remove trailing dots and whitespace 5295 1.1 mrg s/[\. \t]*$// 5296 1.1 mrg # Print 5297 1.1 mrg /./p' | 5298 1.1 mrg # we now have a list, one entry per line, of the stringified 5299 1.1 mrg # contents of the appropriate section of all members of the 5300 1.1 mrg # archive that possess that section. Heuristic: eliminate 5301 1.1 mrg # all those that have a first or second character that is 5302 1.1 mrg # a '.' (that is, objdump's representation of an unprintable 5303 1.1 mrg # character.) This should work for all archives with less than 5304 1.1 mrg # 0x302f exports -- but will fail for DLLs whose name actually 5305 1.1 mrg # begins with a literal '.' or a single character followed by 5306 1.1 mrg # a '.'. 5307 1.1 mrg # 5308 1.1 mrg # Of those that remain, print the first one. 5309 1.1 mrg $SED -e '/^\./d;/^.\./d;q' 5310 1.1 mrg } 5311 1.1 mrg 5312 1.1 mrg # func_cygming_dll_for_implib_fallback ARG 5313 1.1 mrg # Platform-specific function to extract the 5314 1.1 mrg # name of the DLL associated with the specified 5315 1.1 mrg # import library ARG. 5316 1.1 mrg # 5317 1.1 mrg # This fallback implementation is for use when $DLLTOOL 5318 1.1 mrg # does not support the --identify-strict option. 5319 1.1 mrg # Invoked by eval'ing the libtool variable 5320 1.1 mrg # $sharedlib_from_linklib_cmd 5321 1.1 mrg # Result is available in the variable 5322 1.1 mrg # $sharedlib_from_linklib_result 5323 1.1 mrg func_cygming_dll_for_implib_fallback () 5324 1.1 mrg { 5325 1.1 mrg $debug_cmd 5326 1.1 mrg 5327 1.1 mrg if func_cygming_gnu_implib_p "$1"; then 5328 1.1 mrg # binutils import library 5329 1.1 mrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"` 5330 1.1 mrg elif func_cygming_ms_implib_p "$1"; then 5331 1.1 mrg # ms-generated import library 5332 1.1 mrg sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"` 5333 1.1 mrg else 5334 1.1 mrg # unknown 5335 1.1 mrg sharedlib_from_linklib_result= 5336 1.1 mrg fi 5337 1.1 mrg } 5338 1.1 mrg 5339 1.1 mrg 5340 1.1 mrg # func_extract_an_archive dir oldlib 5341 1.1 mrg func_extract_an_archive () 5342 1.1 mrg { 5343 1.1 mrg $debug_cmd 5344 1.1 mrg 5345 1.1 mrg f_ex_an_ar_dir=$1; shift 5346 1.1 mrg f_ex_an_ar_oldlib=$1 5347 1.1 mrg if test yes = "$lock_old_archive_extraction"; then 5348 1.1 mrg lockfile=$f_ex_an_ar_oldlib.lock 5349 1.1 mrg until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do 5350 1.1 mrg func_echo "Waiting for $lockfile to be removed" 5351 1.1 mrg sleep 2 5352 1.1 mrg done 5353 1.1 mrg fi 5354 1.1 mrg func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \ 5355 1.1 mrg 'stat=$?; rm -f "$lockfile"; exit $stat' 5356 1.1 mrg if test yes = "$lock_old_archive_extraction"; then 5357 1.1 mrg $opt_dry_run || rm -f "$lockfile" 5358 1.1 mrg fi 5359 1.1 mrg if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then 5360 1.1 mrg : 5361 1.1 mrg else 5362 1.1 mrg func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib" 5363 1.1 mrg fi 5364 1.1 mrg } 5365 1.1 mrg 5366 1.1 mrg 5367 1.1 mrg # func_extract_archives gentop oldlib ... 5368 1.1 mrg func_extract_archives () 5369 1.1 mrg { 5370 1.1 mrg $debug_cmd 5371 1.1 mrg 5372 1.1 mrg my_gentop=$1; shift 5373 1.1 mrg my_oldlibs=${1+"$@"} 5374 1.1 mrg my_oldobjs= 5375 1.1 mrg my_xlib= 5376 1.1 mrg my_xabs= 5377 1.1 mrg my_xdir= 5378 1.1 mrg 5379 1.1 mrg for my_xlib in $my_oldlibs; do 5380 1.1 mrg # Extract the objects. 5381 1.1 mrg case $my_xlib in 5382 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;; 5383 1.1 mrg *) my_xabs=`pwd`"/$my_xlib" ;; 5384 1.1 mrg esac 5385 1.1 mrg func_basename "$my_xlib" 5386 1.1 mrg my_xlib=$func_basename_result 5387 1.1 mrg my_xlib_u=$my_xlib 5388 1.1 mrg while :; do 5389 1.1 mrg case " $extracted_archives " in 5390 1.1 mrg *" $my_xlib_u "*) 5391 1.1 mrg func_arith $extracted_serial + 1 5392 1.1 mrg extracted_serial=$func_arith_result 5393 1.1 mrg my_xlib_u=lt$extracted_serial-$my_xlib ;; 5394 1.1 mrg *) break ;; 5395 1.1 mrg esac 5396 1.1 mrg done 5397 1.1 mrg extracted_archives="$extracted_archives $my_xlib_u" 5398 1.1 mrg my_xdir=$my_gentop/$my_xlib_u 5399 1.1 mrg 5400 1.1 mrg func_mkdir_p "$my_xdir" 5401 1.1 mrg 5402 1.1 mrg case $host in 5403 1.1 mrg *-darwin*) 5404 1.1 mrg func_verbose "Extracting $my_xabs" 5405 1.1 mrg # Do not bother doing anything if just a dry run 5406 1.1 mrg $opt_dry_run || { 5407 1.1 mrg darwin_orig_dir=`pwd` 5408 1.1 mrg cd $my_xdir || exit $? 5409 1.1 mrg darwin_archive=$my_xabs 5410 1.1 mrg darwin_curdir=`pwd` 5411 1.1 mrg func_basename "$darwin_archive" 5412 1.1 mrg darwin_base_archive=$func_basename_result 5413 1.1 mrg darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true` 5414 1.1 mrg if test -n "$darwin_arches"; then 5415 1.1 mrg darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'` 5416 1.1 mrg darwin_arch= 5417 1.1 mrg func_verbose "$darwin_base_archive has multiple architectures $darwin_arches" 5418 1.1 mrg for darwin_arch in $darwin_arches; do 5419 1.1 mrg func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch" 5420 1.1 mrg $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive" 5421 1.1 mrg cd "unfat-$$/$darwin_base_archive-$darwin_arch" 5422 1.1 mrg func_extract_an_archive "`pwd`" "$darwin_base_archive" 5423 1.1 mrg cd "$darwin_curdir" 5424 1.1 mrg $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" 5425 1.1 mrg done # $darwin_arches 5426 1.1 mrg ## Okay now we've a bunch of thin objects, gotta fatten them up :) 5427 1.1 mrg darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u` 5428 1.1 mrg darwin_file= 5429 1.1 mrg darwin_files= 5430 1.1 mrg for darwin_file in $darwin_filelist; do 5431 1.1 mrg darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP` 5432 1.1 mrg $LIPO -create -output "$darwin_file" $darwin_files 5433 1.1 mrg done # $darwin_filelist 5434 1.1 mrg $RM -rf unfat-$$ 5435 1.1 mrg cd "$darwin_orig_dir" 5436 1.1 mrg else 5437 1.1 mrg cd $darwin_orig_dir 5438 1.1 mrg func_extract_an_archive "$my_xdir" "$my_xabs" 5439 1.1 mrg fi # $darwin_arches 5440 1.1 mrg } # !$opt_dry_run 5441 1.1 mrg ;; 5442 1.1 mrg *) 5443 1.1 mrg func_extract_an_archive "$my_xdir" "$my_xabs" 5444 1.1 mrg ;; 5445 1.1 mrg esac 5446 1.1 mrg my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP` 5447 1.1 mrg done 5448 1.1 mrg 5449 1.1 mrg func_extract_archives_result=$my_oldobjs 5450 1.1 mrg } 5451 1.1 mrg 5452 1.1 mrg 5453 1.1 mrg # func_emit_wrapper [arg=no] 5454 1.1 mrg # 5455 1.1 mrg # Emit a libtool wrapper script on stdout. 5456 1.1 mrg # Don't directly open a file because we may want to 5457 1.1 mrg # incorporate the script contents within a cygwin/mingw 5458 1.1 mrg # wrapper executable. Must ONLY be called from within 5459 1.1 mrg # func_mode_link because it depends on a number of variables 5460 1.1 mrg # set therein. 5461 1.1 mrg # 5462 1.1 mrg # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR 5463 1.1 mrg # variable will take. If 'yes', then the emitted script 5464 1.1 mrg # will assume that the directory where it is stored is 5465 1.1 mrg # the $objdir directory. This is a cygwin/mingw-specific 5466 1.1 mrg # behavior. 5467 1.1 mrg func_emit_wrapper () 5468 1.1 mrg { 5469 1.1 mrg func_emit_wrapper_arg1=${1-no} 5470 1.1 mrg 5471 1.1 mrg $ECHO "\ 5472 1.1 mrg #! $SHELL 5473 1.1 mrg 5474 1.1 mrg # $output - temporary wrapper script for $objdir/$outputname 5475 1.1 mrg # Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5476 1.1 mrg # 5477 1.1 mrg # The $output program cannot be directly executed until all the libtool 5478 1.1 mrg # libraries that it depends on are installed. 5479 1.1 mrg # 5480 1.1 mrg # This wrapper script should never be moved out of the build directory. 5481 1.1 mrg # If it is, it will not operate correctly. 5482 1.1 mrg 5483 1.1 mrg # Sed substitution that helps us do robust quoting. It backslashifies 5484 1.1 mrg # metacharacters that are still active within double-quoted strings. 5485 1.1 mrg sed_quote_subst='$sed_quote_subst' 5486 1.1 mrg 5487 1.1 mrg # Be Bourne compatible 5488 1.1 mrg if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then 5489 1.1 mrg emulate sh 5490 1.1 mrg NULLCMD=: 5491 1.1 mrg # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which 5492 1.1 mrg # is contrary to our usage. Disable this feature. 5493 1.1 mrg alias -g '\${1+\"\$@\"}'='\"\$@\"' 5494 1.1 mrg setopt NO_GLOB_SUBST 5495 1.1 mrg else 5496 1.1 mrg case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac 5497 1.1 mrg fi 5498 1.1 mrg BIN_SH=xpg4; export BIN_SH # for Tru64 5499 1.1 mrg DUALCASE=1; export DUALCASE # for MKS sh 5500 1.1 mrg 5501 1.1 mrg # The HP-UX ksh and POSIX shell print the target directory to stdout 5502 1.1 mrg # if CDPATH is set. 5503 1.1 mrg (unset CDPATH) >/dev/null 2>&1 && unset CDPATH 5504 1.1 mrg 5505 1.1 mrg relink_command=\"$relink_command\" 5506 1.1 mrg 5507 1.1 mrg # This environment variable determines our operation mode. 5508 1.1 mrg if test \"\$libtool_install_magic\" = \"$magic\"; then 5509 1.1 mrg # install mode needs the following variables: 5510 1.1 mrg generated_by_libtool_version='$macro_version' 5511 1.1 mrg notinst_deplibs='$notinst_deplibs' 5512 1.1 mrg else 5513 1.1 mrg # When we are sourced in execute mode, \$file and \$ECHO are already set. 5514 1.1 mrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5515 1.1 mrg file=\"\$0\"" 5516 1.1 mrg 5517 1.1.1.2 mrg func_quote_arg pretty "$ECHO" 5518 1.1.1.2 mrg qECHO=$func_quote_arg_result 5519 1.1 mrg $ECHO "\ 5520 1.1 mrg 5521 1.1 mrg # A function that is used when there is no print builtin or printf. 5522 1.1 mrg func_fallback_echo () 5523 1.1 mrg { 5524 1.1 mrg eval 'cat <<_LTECHO_EOF 5525 1.1 mrg \$1 5526 1.1 mrg _LTECHO_EOF' 5527 1.1 mrg } 5528 1.1.1.2 mrg ECHO=$qECHO 5529 1.1 mrg fi 5530 1.1 mrg 5531 1.1 mrg # Very basic option parsing. These options are (a) specific to 5532 1.1 mrg # the libtool wrapper, (b) are identical between the wrapper 5533 1.1 mrg # /script/ and the wrapper /executable/ that is used only on 5534 1.1 mrg # windows platforms, and (c) all begin with the string "--lt-" 5535 1.1 mrg # (application programs are unlikely to have options that match 5536 1.1 mrg # this pattern). 5537 1.1 mrg # 5538 1.1 mrg # There are only two supported options: --lt-debug and 5539 1.1 mrg # --lt-dump-script. There is, deliberately, no --lt-help. 5540 1.1 mrg # 5541 1.1 mrg # The first argument to this parsing function should be the 5542 1.1 mrg # script's $0 value, followed by "$@". 5543 1.1 mrg lt_option_debug= 5544 1.1 mrg func_parse_lt_options () 5545 1.1 mrg { 5546 1.1 mrg lt_script_arg0=\$0 5547 1.1 mrg shift 5548 1.1 mrg for lt_opt 5549 1.1 mrg do 5550 1.1 mrg case \"\$lt_opt\" in 5551 1.1 mrg --lt-debug) lt_option_debug=1 ;; 5552 1.1 mrg --lt-dump-script) 5553 1.1 mrg lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\` 5554 1.1 mrg test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=. 5555 1.1 mrg lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\` 5556 1.1 mrg cat \"\$lt_dump_D/\$lt_dump_F\" 5557 1.1 mrg exit 0 5558 1.1 mrg ;; 5559 1.1 mrg --lt-*) 5560 1.1 mrg \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2 5561 1.1 mrg exit 1 5562 1.1 mrg ;; 5563 1.1 mrg esac 5564 1.1 mrg done 5565 1.1 mrg 5566 1.1 mrg # Print the debug banner immediately: 5567 1.1 mrg if test -n \"\$lt_option_debug\"; then 5568 1.1 mrg echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2 5569 1.1 mrg fi 5570 1.1 mrg } 5571 1.1 mrg 5572 1.1 mrg # Used when --lt-debug. Prints its arguments to stdout 5573 1.1 mrg # (redirection is the responsibility of the caller) 5574 1.1 mrg func_lt_dump_args () 5575 1.1 mrg { 5576 1.1 mrg lt_dump_args_N=1; 5577 1.1 mrg for lt_arg 5578 1.1 mrg do 5579 1.1 mrg \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\" 5580 1.1 mrg lt_dump_args_N=\`expr \$lt_dump_args_N + 1\` 5581 1.1 mrg done 5582 1.1 mrg } 5583 1.1 mrg 5584 1.1 mrg # Core function for launching the target application 5585 1.1 mrg func_exec_program_core () 5586 1.1 mrg { 5587 1.1 mrg " 5588 1.1 mrg case $host in 5589 1.1 mrg # Backslashes separate directories on plain windows 5590 1.1 mrg *-*-mingw | *-*-os2* | *-cegcc*) 5591 1.1 mrg $ECHO "\ 5592 1.1 mrg if test -n \"\$lt_option_debug\"; then 5593 1.1 mrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2 5594 1.1 mrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5595 1.1 mrg fi 5596 1.1 mrg exec \"\$progdir\\\\\$program\" \${1+\"\$@\"} 5597 1.1 mrg " 5598 1.1 mrg ;; 5599 1.1 mrg 5600 1.1 mrg *) 5601 1.1 mrg $ECHO "\ 5602 1.1 mrg if test -n \"\$lt_option_debug\"; then 5603 1.1 mrg \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2 5604 1.1 mrg func_lt_dump_args \${1+\"\$@\"} 1>&2 5605 1.1 mrg fi 5606 1.1 mrg exec \"\$progdir/\$program\" \${1+\"\$@\"} 5607 1.1 mrg " 5608 1.1 mrg ;; 5609 1.1 mrg esac 5610 1.1 mrg $ECHO "\ 5611 1.1 mrg \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2 5612 1.1 mrg exit 1 5613 1.1 mrg } 5614 1.1 mrg 5615 1.1 mrg # A function to encapsulate launching the target application 5616 1.1 mrg # Strips options in the --lt-* namespace from \$@ and 5617 1.1 mrg # launches target application with the remaining arguments. 5618 1.1 mrg func_exec_program () 5619 1.1 mrg { 5620 1.1 mrg case \" \$* \" in 5621 1.1 mrg *\\ --lt-*) 5622 1.1 mrg for lt_wr_arg 5623 1.1 mrg do 5624 1.1 mrg case \$lt_wr_arg in 5625 1.1 mrg --lt-*) ;; 5626 1.1 mrg *) set x \"\$@\" \"\$lt_wr_arg\"; shift;; 5627 1.1 mrg esac 5628 1.1 mrg shift 5629 1.1 mrg done ;; 5630 1.1 mrg esac 5631 1.1 mrg func_exec_program_core \${1+\"\$@\"} 5632 1.1 mrg } 5633 1.1 mrg 5634 1.1 mrg # Parse options 5635 1.1 mrg func_parse_lt_options \"\$0\" \${1+\"\$@\"} 5636 1.1 mrg 5637 1.1 mrg # Find the directory that this script lives in. 5638 1.1 mrg thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\` 5639 1.1 mrg test \"x\$thisdir\" = \"x\$file\" && thisdir=. 5640 1.1 mrg 5641 1.1 mrg # Follow symbolic links until we get to the real thisdir. 5642 1.1 mrg file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\` 5643 1.1 mrg while test -n \"\$file\"; do 5644 1.1 mrg destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\` 5645 1.1 mrg 5646 1.1 mrg # If there was a directory component, then change thisdir. 5647 1.1 mrg if test \"x\$destdir\" != \"x\$file\"; then 5648 1.1 mrg case \"\$destdir\" in 5649 1.1 mrg [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;; 5650 1.1 mrg *) thisdir=\"\$thisdir/\$destdir\" ;; 5651 1.1 mrg esac 5652 1.1 mrg fi 5653 1.1 mrg 5654 1.1 mrg file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\` 5655 1.1 mrg file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\` 5656 1.1 mrg done 5657 1.1 mrg 5658 1.1 mrg # Usually 'no', except on cygwin/mingw when embedded into 5659 1.1 mrg # the cwrapper. 5660 1.1 mrg WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1 5661 1.1 mrg if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then 5662 1.1 mrg # special case for '.' 5663 1.1 mrg if test \"\$thisdir\" = \".\"; then 5664 1.1 mrg thisdir=\`pwd\` 5665 1.1 mrg fi 5666 1.1 mrg # remove .libs from thisdir 5667 1.1 mrg case \"\$thisdir\" in 5668 1.1 mrg *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;; 5669 1.1 mrg $objdir ) thisdir=. ;; 5670 1.1 mrg esac 5671 1.1 mrg fi 5672 1.1 mrg 5673 1.1 mrg # Try to get the absolute directory name. 5674 1.1 mrg absdir=\`cd \"\$thisdir\" && pwd\` 5675 1.1 mrg test -n \"\$absdir\" && thisdir=\"\$absdir\" 5676 1.1 mrg " 5677 1.1 mrg 5678 1.1 mrg if test yes = "$fast_install"; then 5679 1.1 mrg $ECHO "\ 5680 1.1 mrg program=lt-'$outputname'$exeext 5681 1.1 mrg progdir=\"\$thisdir/$objdir\" 5682 1.1 mrg 5683 1.1 mrg if test ! -f \"\$progdir/\$program\" || 5684 1.1 mrg { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\ 5685 1.1 mrg test \"X\$file\" != \"X\$progdir/\$program\"; }; then 5686 1.1 mrg 5687 1.1 mrg file=\"\$\$-\$program\" 5688 1.1 mrg 5689 1.1 mrg if test ! -d \"\$progdir\"; then 5690 1.1 mrg $MKDIR \"\$progdir\" 5691 1.1 mrg else 5692 1.1 mrg $RM \"\$progdir/\$file\" 5693 1.1 mrg fi" 5694 1.1 mrg 5695 1.1 mrg $ECHO "\ 5696 1.1 mrg 5697 1.1 mrg # relink executable if necessary 5698 1.1 mrg if test -n \"\$relink_command\"; then 5699 1.1 mrg if relink_command_output=\`eval \$relink_command 2>&1\`; then : 5700 1.1 mrg else 5701 1.1 mrg \$ECHO \"\$relink_command_output\" >&2 5702 1.1 mrg $RM \"\$progdir/\$file\" 5703 1.1 mrg exit 1 5704 1.1 mrg fi 5705 1.1 mrg fi 5706 1.1 mrg 5707 1.1 mrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null || 5708 1.1 mrg { $RM \"\$progdir/\$program\"; 5709 1.1 mrg $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; } 5710 1.1 mrg $RM \"\$progdir/\$file\" 5711 1.1 mrg fi" 5712 1.1 mrg else 5713 1.1 mrg $ECHO "\ 5714 1.1 mrg program='$outputname' 5715 1.1 mrg progdir=\"\$thisdir/$objdir\" 5716 1.1 mrg " 5717 1.1 mrg fi 5718 1.1 mrg 5719 1.1 mrg $ECHO "\ 5720 1.1 mrg 5721 1.1 mrg if test -f \"\$progdir/\$program\"; then" 5722 1.1 mrg 5723 1.1 mrg # fixup the dll searchpath if we need to. 5724 1.1 mrg # 5725 1.1 mrg # Fix the DLL searchpath if we need to. Do this before prepending 5726 1.1 mrg # to shlibpath, because on Windows, both are PATH and uninstalled 5727 1.1 mrg # libraries must come first. 5728 1.1 mrg if test -n "$dllsearchpath"; then 5729 1.1 mrg $ECHO "\ 5730 1.1 mrg # Add the dll search path components to the executable PATH 5731 1.1 mrg PATH=$dllsearchpath:\$PATH 5732 1.1 mrg " 5733 1.1 mrg fi 5734 1.1 mrg 5735 1.1 mrg # Export our shlibpath_var if we have one. 5736 1.1 mrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5737 1.1 mrg $ECHO "\ 5738 1.1 mrg # Add our own library path to $shlibpath_var 5739 1.1 mrg $shlibpath_var=\"$temp_rpath\$$shlibpath_var\" 5740 1.1 mrg 5741 1.1 mrg # Some systems cannot cope with colon-terminated $shlibpath_var 5742 1.1 mrg # The second colon is a workaround for a bug in BeOS R4 sed 5743 1.1 mrg $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\` 5744 1.1 mrg 5745 1.1 mrg export $shlibpath_var 5746 1.1 mrg " 5747 1.1 mrg fi 5748 1.1 mrg 5749 1.1 mrg $ECHO "\ 5750 1.1 mrg if test \"\$libtool_execute_magic\" != \"$magic\"; then 5751 1.1 mrg # Run the actual program with our arguments. 5752 1.1 mrg func_exec_program \${1+\"\$@\"} 5753 1.1 mrg fi 5754 1.1 mrg else 5755 1.1 mrg # The program doesn't exist. 5756 1.1 mrg \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2 5757 1.1 mrg \$ECHO \"This script is just a wrapper for \$program.\" 1>&2 5758 1.1 mrg \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2 5759 1.1 mrg exit 1 5760 1.1 mrg fi 5761 1.1 mrg fi\ 5762 1.1 mrg " 5763 1.1 mrg } 5764 1.1 mrg 5765 1.1 mrg 5766 1.1 mrg # func_emit_cwrapperexe_src 5767 1.1 mrg # emit the source code for a wrapper executable on stdout 5768 1.1 mrg # Must ONLY be called from within func_mode_link because 5769 1.1 mrg # it depends on a number of variable set therein. 5770 1.1 mrg func_emit_cwrapperexe_src () 5771 1.1 mrg { 5772 1.1 mrg cat <<EOF 5773 1.1 mrg 5774 1.1 mrg /* $cwrappersource - temporary wrapper executable for $objdir/$outputname 5775 1.1 mrg Generated by $PROGRAM (GNU $PACKAGE) $VERSION 5776 1.1 mrg 5777 1.1 mrg The $output program cannot be directly executed until all the libtool 5778 1.1 mrg libraries that it depends on are installed. 5779 1.1 mrg 5780 1.1 mrg This wrapper executable should never be moved out of the build directory. 5781 1.1 mrg If it is, it will not operate correctly. 5782 1.1 mrg */ 5783 1.1 mrg EOF 5784 1.1 mrg cat <<"EOF" 5785 1.1 mrg #ifdef _MSC_VER 5786 1.1 mrg # define _CRT_SECURE_NO_DEPRECATE 1 5787 1.1 mrg #endif 5788 1.1 mrg #include <stdio.h> 5789 1.1 mrg #include <stdlib.h> 5790 1.1 mrg #ifdef _MSC_VER 5791 1.1 mrg # include <direct.h> 5792 1.1 mrg # include <process.h> 5793 1.1 mrg # include <io.h> 5794 1.1 mrg #else 5795 1.1 mrg # include <unistd.h> 5796 1.1 mrg # include <stdint.h> 5797 1.1 mrg # ifdef __CYGWIN__ 5798 1.1 mrg # include <io.h> 5799 1.1 mrg # endif 5800 1.1 mrg #endif 5801 1.1 mrg #include <malloc.h> 5802 1.1 mrg #include <stdarg.h> 5803 1.1 mrg #include <assert.h> 5804 1.1 mrg #include <string.h> 5805 1.1 mrg #include <ctype.h> 5806 1.1 mrg #include <errno.h> 5807 1.1 mrg #include <fcntl.h> 5808 1.1 mrg #include <sys/stat.h> 5809 1.1 mrg 5810 1.1 mrg #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0) 5811 1.1 mrg 5812 1.1 mrg /* declarations of non-ANSI functions */ 5813 1.1 mrg #if defined __MINGW32__ 5814 1.1 mrg # ifdef __STRICT_ANSI__ 5815 1.1 mrg int _putenv (const char *); 5816 1.1 mrg # endif 5817 1.1 mrg #elif defined __CYGWIN__ 5818 1.1 mrg # ifdef __STRICT_ANSI__ 5819 1.1 mrg char *realpath (const char *, char *); 5820 1.1 mrg int putenv (char *); 5821 1.1 mrg int setenv (const char *, const char *, int); 5822 1.1 mrg # endif 5823 1.1 mrg /* #elif defined other_platform || defined ... */ 5824 1.1 mrg #endif 5825 1.1 mrg 5826 1.1 mrg /* portability defines, excluding path handling macros */ 5827 1.1 mrg #if defined _MSC_VER 5828 1.1 mrg # define setmode _setmode 5829 1.1 mrg # define stat _stat 5830 1.1 mrg # define chmod _chmod 5831 1.1 mrg # define getcwd _getcwd 5832 1.1 mrg # define putenv _putenv 5833 1.1 mrg # define S_IXUSR _S_IEXEC 5834 1.1 mrg #elif defined __MINGW32__ 5835 1.1 mrg # define setmode _setmode 5836 1.1 mrg # define stat _stat 5837 1.1 mrg # define chmod _chmod 5838 1.1 mrg # define getcwd _getcwd 5839 1.1 mrg # define putenv _putenv 5840 1.1 mrg #elif defined __CYGWIN__ 5841 1.1 mrg # define HAVE_SETENV 5842 1.1 mrg # define FOPEN_WB "wb" 5843 1.1 mrg /* #elif defined other platforms ... */ 5844 1.1 mrg #endif 5845 1.1 mrg 5846 1.1 mrg #if defined PATH_MAX 5847 1.1 mrg # define LT_PATHMAX PATH_MAX 5848 1.1 mrg #elif defined MAXPATHLEN 5849 1.1 mrg # define LT_PATHMAX MAXPATHLEN 5850 1.1 mrg #else 5851 1.1 mrg # define LT_PATHMAX 1024 5852 1.1 mrg #endif 5853 1.1 mrg 5854 1.1 mrg #ifndef S_IXOTH 5855 1.1 mrg # define S_IXOTH 0 5856 1.1 mrg #endif 5857 1.1 mrg #ifndef S_IXGRP 5858 1.1 mrg # define S_IXGRP 0 5859 1.1 mrg #endif 5860 1.1 mrg 5861 1.1 mrg /* path handling portability macros */ 5862 1.1 mrg #ifndef DIR_SEPARATOR 5863 1.1 mrg # define DIR_SEPARATOR '/' 5864 1.1 mrg # define PATH_SEPARATOR ':' 5865 1.1 mrg #endif 5866 1.1 mrg 5867 1.1 mrg #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \ 5868 1.1 mrg defined __OS2__ 5869 1.1 mrg # define HAVE_DOS_BASED_FILE_SYSTEM 5870 1.1 mrg # define FOPEN_WB "wb" 5871 1.1 mrg # ifndef DIR_SEPARATOR_2 5872 1.1 mrg # define DIR_SEPARATOR_2 '\\' 5873 1.1 mrg # endif 5874 1.1 mrg # ifndef PATH_SEPARATOR_2 5875 1.1 mrg # define PATH_SEPARATOR_2 ';' 5876 1.1 mrg # endif 5877 1.1 mrg #endif 5878 1.1 mrg 5879 1.1 mrg #ifndef DIR_SEPARATOR_2 5880 1.1 mrg # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR) 5881 1.1 mrg #else /* DIR_SEPARATOR_2 */ 5882 1.1 mrg # define IS_DIR_SEPARATOR(ch) \ 5883 1.1 mrg (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2)) 5884 1.1 mrg #endif /* DIR_SEPARATOR_2 */ 5885 1.1 mrg 5886 1.1 mrg #ifndef PATH_SEPARATOR_2 5887 1.1 mrg # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR) 5888 1.1 mrg #else /* PATH_SEPARATOR_2 */ 5889 1.1 mrg # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2) 5890 1.1 mrg #endif /* PATH_SEPARATOR_2 */ 5891 1.1 mrg 5892 1.1 mrg #ifndef FOPEN_WB 5893 1.1 mrg # define FOPEN_WB "w" 5894 1.1 mrg #endif 5895 1.1 mrg #ifndef _O_BINARY 5896 1.1 mrg # define _O_BINARY 0 5897 1.1 mrg #endif 5898 1.1 mrg 5899 1.1 mrg #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type))) 5900 1.1 mrg #define XFREE(stale) do { \ 5901 1.1 mrg if (stale) { free (stale); stale = 0; } \ 5902 1.1 mrg } while (0) 5903 1.1 mrg 5904 1.1 mrg #if defined LT_DEBUGWRAPPER 5905 1.1 mrg static int lt_debug = 1; 5906 1.1 mrg #else 5907 1.1 mrg static int lt_debug = 0; 5908 1.1 mrg #endif 5909 1.1 mrg 5910 1.1 mrg const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */ 5911 1.1 mrg 5912 1.1 mrg void *xmalloc (size_t num); 5913 1.1 mrg char *xstrdup (const char *string); 5914 1.1 mrg const char *base_name (const char *name); 5915 1.1 mrg char *find_executable (const char *wrapper); 5916 1.1 mrg char *chase_symlinks (const char *pathspec); 5917 1.1 mrg int make_executable (const char *path); 5918 1.1 mrg int check_executable (const char *path); 5919 1.1 mrg char *strendzap (char *str, const char *pat); 5920 1.1 mrg void lt_debugprintf (const char *file, int line, const char *fmt, ...); 5921 1.1 mrg void lt_fatal (const char *file, int line, const char *message, ...); 5922 1.1 mrg static const char *nonnull (const char *s); 5923 1.1 mrg static const char *nonempty (const char *s); 5924 1.1 mrg void lt_setenv (const char *name, const char *value); 5925 1.1 mrg char *lt_extend_str (const char *orig_value, const char *add, int to_end); 5926 1.1 mrg void lt_update_exe_path (const char *name, const char *value); 5927 1.1 mrg void lt_update_lib_path (const char *name, const char *value); 5928 1.1 mrg char **prepare_spawn (char **argv); 5929 1.1 mrg void lt_dump_script (FILE *f); 5930 1.1 mrg EOF 5931 1.1 mrg 5932 1.1 mrg cat <<EOF 5933 1.1 mrg #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5) 5934 1.1 mrg # define externally_visible volatile 5935 1.1 mrg #else 5936 1.1 mrg # define externally_visible __attribute__((externally_visible)) volatile 5937 1.1 mrg #endif 5938 1.1 mrg externally_visible const char * MAGIC_EXE = "$magic_exe"; 5939 1.1 mrg const char * LIB_PATH_VARNAME = "$shlibpath_var"; 5940 1.1 mrg EOF 5941 1.1 mrg 5942 1.1 mrg if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then 5943 1.1 mrg func_to_host_path "$temp_rpath" 5944 1.1 mrg cat <<EOF 5945 1.1 mrg const char * LIB_PATH_VALUE = "$func_to_host_path_result"; 5946 1.1 mrg EOF 5947 1.1 mrg else 5948 1.1 mrg cat <<"EOF" 5949 1.1 mrg const char * LIB_PATH_VALUE = ""; 5950 1.1 mrg EOF 5951 1.1 mrg fi 5952 1.1 mrg 5953 1.1 mrg if test -n "$dllsearchpath"; then 5954 1.1 mrg func_to_host_path "$dllsearchpath:" 5955 1.1 mrg cat <<EOF 5956 1.1 mrg const char * EXE_PATH_VARNAME = "PATH"; 5957 1.1 mrg const char * EXE_PATH_VALUE = "$func_to_host_path_result"; 5958 1.1 mrg EOF 5959 1.1 mrg else 5960 1.1 mrg cat <<"EOF" 5961 1.1 mrg const char * EXE_PATH_VARNAME = ""; 5962 1.1 mrg const char * EXE_PATH_VALUE = ""; 5963 1.1 mrg EOF 5964 1.1 mrg fi 5965 1.1 mrg 5966 1.1 mrg if test yes = "$fast_install"; then 5967 1.1 mrg cat <<EOF 5968 1.1 mrg const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */ 5969 1.1 mrg EOF 5970 1.1 mrg else 5971 1.1 mrg cat <<EOF 5972 1.1 mrg const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */ 5973 1.1 mrg EOF 5974 1.1 mrg fi 5975 1.1 mrg 5976 1.1 mrg 5977 1.1 mrg cat <<"EOF" 5978 1.1 mrg 5979 1.1 mrg #define LTWRAPPER_OPTION_PREFIX "--lt-" 5980 1.1 mrg 5981 1.1 mrg static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX; 5982 1.1 mrg static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script"; 5983 1.1 mrg static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug"; 5984 1.1 mrg 5985 1.1 mrg int 5986 1.1 mrg main (int argc, char *argv[]) 5987 1.1 mrg { 5988 1.1 mrg char **newargz; 5989 1.1 mrg int newargc; 5990 1.1 mrg char *tmp_pathspec; 5991 1.1 mrg char *actual_cwrapper_path; 5992 1.1 mrg char *actual_cwrapper_name; 5993 1.1 mrg char *target_name; 5994 1.1 mrg char *lt_argv_zero; 5995 1.1 mrg int rval = 127; 5996 1.1 mrg 5997 1.1 mrg int i; 5998 1.1 mrg 5999 1.1 mrg program_name = (char *) xstrdup (base_name (argv[0])); 6000 1.1 mrg newargz = XMALLOC (char *, (size_t) argc + 1); 6001 1.1 mrg 6002 1.1 mrg /* very simple arg parsing; don't want to rely on getopt 6003 1.1 mrg * also, copy all non cwrapper options to newargz, except 6004 1.1 mrg * argz[0], which is handled differently 6005 1.1 mrg */ 6006 1.1 mrg newargc=0; 6007 1.1 mrg for (i = 1; i < argc; i++) 6008 1.1 mrg { 6009 1.1 mrg if (STREQ (argv[i], dumpscript_opt)) 6010 1.1 mrg { 6011 1.1 mrg EOF 6012 1.1 mrg case $host in 6013 1.1 mrg *mingw* | *cygwin* ) 6014 1.1 mrg # make stdout use "unix" line endings 6015 1.1 mrg echo " setmode(1,_O_BINARY);" 6016 1.1 mrg ;; 6017 1.1 mrg esac 6018 1.1 mrg 6019 1.1 mrg cat <<"EOF" 6020 1.1 mrg lt_dump_script (stdout); 6021 1.1 mrg return 0; 6022 1.1 mrg } 6023 1.1 mrg if (STREQ (argv[i], debug_opt)) 6024 1.1 mrg { 6025 1.1 mrg lt_debug = 1; 6026 1.1 mrg continue; 6027 1.1 mrg } 6028 1.1 mrg if (STREQ (argv[i], ltwrapper_option_prefix)) 6029 1.1 mrg { 6030 1.1 mrg /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX 6031 1.1 mrg namespace, but it is not one of the ones we know about and 6032 1.1 mrg have already dealt with, above (inluding dump-script), then 6033 1.1 mrg report an error. Otherwise, targets might begin to believe 6034 1.1 mrg they are allowed to use options in the LTWRAPPER_OPTION_PREFIX 6035 1.1 mrg namespace. The first time any user complains about this, we'll 6036 1.1 mrg need to make LTWRAPPER_OPTION_PREFIX a configure-time option 6037 1.1 mrg or a configure.ac-settable value. 6038 1.1 mrg */ 6039 1.1 mrg lt_fatal (__FILE__, __LINE__, 6040 1.1 mrg "unrecognized %s option: '%s'", 6041 1.1 mrg ltwrapper_option_prefix, argv[i]); 6042 1.1 mrg } 6043 1.1 mrg /* otherwise ... */ 6044 1.1 mrg newargz[++newargc] = xstrdup (argv[i]); 6045 1.1 mrg } 6046 1.1 mrg newargz[++newargc] = NULL; 6047 1.1 mrg 6048 1.1 mrg EOF 6049 1.1 mrg cat <<EOF 6050 1.1 mrg /* The GNU banner must be the first non-error debug message */ 6051 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n"); 6052 1.1 mrg EOF 6053 1.1 mrg cat <<"EOF" 6054 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]); 6055 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name); 6056 1.1 mrg 6057 1.1 mrg tmp_pathspec = find_executable (argv[0]); 6058 1.1 mrg if (tmp_pathspec == NULL) 6059 1.1 mrg lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]); 6060 1.1 mrg lt_debugprintf (__FILE__, __LINE__, 6061 1.1 mrg "(main) found exe (before symlink chase) at: %s\n", 6062 1.1 mrg tmp_pathspec); 6063 1.1 mrg 6064 1.1 mrg actual_cwrapper_path = chase_symlinks (tmp_pathspec); 6065 1.1 mrg lt_debugprintf (__FILE__, __LINE__, 6066 1.1 mrg "(main) found exe (after symlink chase) at: %s\n", 6067 1.1 mrg actual_cwrapper_path); 6068 1.1 mrg XFREE (tmp_pathspec); 6069 1.1 mrg 6070 1.1 mrg actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path)); 6071 1.1 mrg strendzap (actual_cwrapper_path, actual_cwrapper_name); 6072 1.1 mrg 6073 1.1 mrg /* wrapper name transforms */ 6074 1.1 mrg strendzap (actual_cwrapper_name, ".exe"); 6075 1.1 mrg tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1); 6076 1.1 mrg XFREE (actual_cwrapper_name); 6077 1.1 mrg actual_cwrapper_name = tmp_pathspec; 6078 1.1 mrg tmp_pathspec = 0; 6079 1.1 mrg 6080 1.1 mrg /* target_name transforms -- use actual target program name; might have lt- prefix */ 6081 1.1 mrg target_name = xstrdup (base_name (TARGET_PROGRAM_NAME)); 6082 1.1 mrg strendzap (target_name, ".exe"); 6083 1.1 mrg tmp_pathspec = lt_extend_str (target_name, ".exe", 1); 6084 1.1 mrg XFREE (target_name); 6085 1.1 mrg target_name = tmp_pathspec; 6086 1.1 mrg tmp_pathspec = 0; 6087 1.1 mrg 6088 1.1 mrg lt_debugprintf (__FILE__, __LINE__, 6089 1.1 mrg "(main) libtool target name: %s\n", 6090 1.1 mrg target_name); 6091 1.1 mrg EOF 6092 1.1 mrg 6093 1.1 mrg cat <<EOF 6094 1.1 mrg newargz[0] = 6095 1.1 mrg XMALLOC (char, (strlen (actual_cwrapper_path) + 6096 1.1 mrg strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1)); 6097 1.1 mrg strcpy (newargz[0], actual_cwrapper_path); 6098 1.1 mrg strcat (newargz[0], "$objdir"); 6099 1.1 mrg strcat (newargz[0], "/"); 6100 1.1 mrg EOF 6101 1.1 mrg 6102 1.1 mrg cat <<"EOF" 6103 1.1 mrg /* stop here, and copy so we don't have to do this twice */ 6104 1.1 mrg tmp_pathspec = xstrdup (newargz[0]); 6105 1.1 mrg 6106 1.1 mrg /* do NOT want the lt- prefix here, so use actual_cwrapper_name */ 6107 1.1 mrg strcat (newargz[0], actual_cwrapper_name); 6108 1.1 mrg 6109 1.1 mrg /* DO want the lt- prefix here if it exists, so use target_name */ 6110 1.1 mrg lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1); 6111 1.1 mrg XFREE (tmp_pathspec); 6112 1.1 mrg tmp_pathspec = NULL; 6113 1.1 mrg EOF 6114 1.1 mrg 6115 1.1 mrg case $host_os in 6116 1.1 mrg mingw*) 6117 1.1 mrg cat <<"EOF" 6118 1.1 mrg { 6119 1.1 mrg char* p; 6120 1.1 mrg while ((p = strchr (newargz[0], '\\')) != NULL) 6121 1.1 mrg { 6122 1.1 mrg *p = '/'; 6123 1.1 mrg } 6124 1.1 mrg while ((p = strchr (lt_argv_zero, '\\')) != NULL) 6125 1.1 mrg { 6126 1.1 mrg *p = '/'; 6127 1.1 mrg } 6128 1.1 mrg } 6129 1.1 mrg EOF 6130 1.1 mrg ;; 6131 1.1 mrg esac 6132 1.1 mrg 6133 1.1 mrg cat <<"EOF" 6134 1.1 mrg XFREE (target_name); 6135 1.1 mrg XFREE (actual_cwrapper_path); 6136 1.1 mrg XFREE (actual_cwrapper_name); 6137 1.1 mrg 6138 1.1 mrg lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */ 6139 1.1 mrg lt_setenv ("DUALCASE", "1"); /* for MSK sh */ 6140 1.1 mrg /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must 6141 1.1 mrg be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath) 6142 1.1 mrg because on Windows, both *_VARNAMEs are PATH but uninstalled 6143 1.1 mrg libraries must come first. */ 6144 1.1 mrg lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE); 6145 1.1 mrg lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE); 6146 1.1 mrg 6147 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n", 6148 1.1 mrg nonnull (lt_argv_zero)); 6149 1.1 mrg for (i = 0; i < newargc; i++) 6150 1.1 mrg { 6151 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n", 6152 1.1 mrg i, nonnull (newargz[i])); 6153 1.1 mrg } 6154 1.1 mrg 6155 1.1 mrg EOF 6156 1.1 mrg 6157 1.1 mrg case $host_os in 6158 1.1 mrg mingw*) 6159 1.1 mrg cat <<"EOF" 6160 1.1 mrg /* execv doesn't actually work on mingw as expected on unix */ 6161 1.1 mrg newargz = prepare_spawn (newargz); 6162 1.1 mrg rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz); 6163 1.1 mrg if (rval == -1) 6164 1.1 mrg { 6165 1.1 mrg /* failed to start process */ 6166 1.1 mrg lt_debugprintf (__FILE__, __LINE__, 6167 1.1 mrg "(main) failed to launch target \"%s\": %s\n", 6168 1.1 mrg lt_argv_zero, nonnull (strerror (errno))); 6169 1.1 mrg return 127; 6170 1.1 mrg } 6171 1.1 mrg return rval; 6172 1.1 mrg EOF 6173 1.1 mrg ;; 6174 1.1 mrg *) 6175 1.1 mrg cat <<"EOF" 6176 1.1 mrg execv (lt_argv_zero, newargz); 6177 1.1 mrg return rval; /* =127, but avoids unused variable warning */ 6178 1.1 mrg EOF 6179 1.1 mrg ;; 6180 1.1 mrg esac 6181 1.1 mrg 6182 1.1 mrg cat <<"EOF" 6183 1.1 mrg } 6184 1.1 mrg 6185 1.1 mrg void * 6186 1.1 mrg xmalloc (size_t num) 6187 1.1 mrg { 6188 1.1 mrg void *p = (void *) malloc (num); 6189 1.1 mrg if (!p) 6190 1.1 mrg lt_fatal (__FILE__, __LINE__, "memory exhausted"); 6191 1.1 mrg 6192 1.1 mrg return p; 6193 1.1 mrg } 6194 1.1 mrg 6195 1.1 mrg char * 6196 1.1 mrg xstrdup (const char *string) 6197 1.1 mrg { 6198 1.1 mrg return string ? strcpy ((char *) xmalloc (strlen (string) + 1), 6199 1.1 mrg string) : NULL; 6200 1.1 mrg } 6201 1.1 mrg 6202 1.1 mrg const char * 6203 1.1 mrg base_name (const char *name) 6204 1.1 mrg { 6205 1.1 mrg const char *base; 6206 1.1 mrg 6207 1.1 mrg #if defined HAVE_DOS_BASED_FILE_SYSTEM 6208 1.1 mrg /* Skip over the disk name in MSDOS pathnames. */ 6209 1.1 mrg if (isalpha ((unsigned char) name[0]) && name[1] == ':') 6210 1.1 mrg name += 2; 6211 1.1 mrg #endif 6212 1.1 mrg 6213 1.1 mrg for (base = name; *name; name++) 6214 1.1 mrg if (IS_DIR_SEPARATOR (*name)) 6215 1.1 mrg base = name + 1; 6216 1.1 mrg return base; 6217 1.1 mrg } 6218 1.1 mrg 6219 1.1 mrg int 6220 1.1 mrg check_executable (const char *path) 6221 1.1 mrg { 6222 1.1 mrg struct stat st; 6223 1.1 mrg 6224 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n", 6225 1.1 mrg nonempty (path)); 6226 1.1 mrg if ((!path) || (!*path)) 6227 1.1 mrg return 0; 6228 1.1 mrg 6229 1.1 mrg if ((stat (path, &st) >= 0) 6230 1.1 mrg && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH))) 6231 1.1 mrg return 1; 6232 1.1 mrg else 6233 1.1 mrg return 0; 6234 1.1 mrg } 6235 1.1 mrg 6236 1.1 mrg int 6237 1.1 mrg make_executable (const char *path) 6238 1.1 mrg { 6239 1.1 mrg int rval = 0; 6240 1.1 mrg struct stat st; 6241 1.1 mrg 6242 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n", 6243 1.1 mrg nonempty (path)); 6244 1.1 mrg if ((!path) || (!*path)) 6245 1.1 mrg return 0; 6246 1.1 mrg 6247 1.1 mrg if (stat (path, &st) >= 0) 6248 1.1 mrg { 6249 1.1 mrg rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR); 6250 1.1 mrg } 6251 1.1 mrg return rval; 6252 1.1 mrg } 6253 1.1 mrg 6254 1.1 mrg /* Searches for the full path of the wrapper. Returns 6255 1.1 mrg newly allocated full path name if found, NULL otherwise 6256 1.1 mrg Does not chase symlinks, even on platforms that support them. 6257 1.1 mrg */ 6258 1.1 mrg char * 6259 1.1 mrg find_executable (const char *wrapper) 6260 1.1 mrg { 6261 1.1 mrg int has_slash = 0; 6262 1.1 mrg const char *p; 6263 1.1 mrg const char *p_next; 6264 1.1 mrg /* static buffer for getcwd */ 6265 1.1 mrg char tmp[LT_PATHMAX + 1]; 6266 1.1 mrg size_t tmp_len; 6267 1.1 mrg char *concat_name; 6268 1.1 mrg 6269 1.1 mrg lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n", 6270 1.1 mrg nonempty (wrapper)); 6271 1.1 mrg 6272 1.1 mrg if ((wrapper == NULL) || (*wrapper == '\0')) 6273 1.1 mrg return NULL; 6274 1.1 mrg 6275 1.1 mrg /* Absolute path? */ 6276 1.1 mrg #if defined HAVE_DOS_BASED_FILE_SYSTEM 6277 1.1 mrg if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':') 6278 1.1 mrg { 6279 1.1 mrg concat_name = xstrdup (wrapper); 6280 1.1 mrg if (check_executable (concat_name)) 6281 1.1 mrg return concat_name; 6282 1.1 mrg XFREE (concat_name); 6283 1.1 mrg } 6284 1.1 mrg else 6285 1.1 mrg { 6286 1.1 mrg #endif 6287 1.1 mrg if (IS_DIR_SEPARATOR (wrapper[0])) 6288 1.1 mrg { 6289 1.1 mrg concat_name = xstrdup (wrapper); 6290 1.1 mrg if (check_executable (concat_name)) 6291 1.1 mrg return concat_name; 6292 1.1 mrg XFREE (concat_name); 6293 1.1 mrg } 6294 1.1 mrg #if defined HAVE_DOS_BASED_FILE_SYSTEM 6295 1.1 mrg } 6296 1.1 mrg #endif 6297 1.1 mrg 6298 1.1 mrg for (p = wrapper; *p; p++) 6299 1.1 mrg if (*p == '/') 6300 1.1 mrg { 6301 1.1 mrg has_slash = 1; 6302 1.1 mrg break; 6303 1.1 mrg } 6304 1.1 mrg if (!has_slash) 6305 1.1 mrg { 6306 1.1 mrg /* no slashes; search PATH */ 6307 1.1 mrg const char *path = getenv ("PATH"); 6308 1.1 mrg if (path != NULL) 6309 1.1 mrg { 6310 1.1 mrg for (p = path; *p; p = p_next) 6311 1.1 mrg { 6312 1.1 mrg const char *q; 6313 1.1 mrg size_t p_len; 6314 1.1 mrg for (q = p; *q; q++) 6315 1.1 mrg if (IS_PATH_SEPARATOR (*q)) 6316 1.1 mrg break; 6317 1.1 mrg p_len = (size_t) (q - p); 6318 1.1 mrg p_next = (*q == '\0' ? q : q + 1); 6319 1.1 mrg if (p_len == 0) 6320 1.1 mrg { 6321 1.1 mrg /* empty path: current directory */ 6322 1.1 mrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6323 1.1 mrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6324 1.1 mrg nonnull (strerror (errno))); 6325 1.1 mrg tmp_len = strlen (tmp); 6326 1.1 mrg concat_name = 6327 1.1 mrg XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6328 1.1 mrg memcpy (concat_name, tmp, tmp_len); 6329 1.1 mrg concat_name[tmp_len] = '/'; 6330 1.1 mrg strcpy (concat_name + tmp_len + 1, wrapper); 6331 1.1 mrg } 6332 1.1 mrg else 6333 1.1 mrg { 6334 1.1 mrg concat_name = 6335 1.1 mrg XMALLOC (char, p_len + 1 + strlen (wrapper) + 1); 6336 1.1 mrg memcpy (concat_name, p, p_len); 6337 1.1 mrg concat_name[p_len] = '/'; 6338 1.1 mrg strcpy (concat_name + p_len + 1, wrapper); 6339 1.1 mrg } 6340 1.1 mrg if (check_executable (concat_name)) 6341 1.1 mrg return concat_name; 6342 1.1 mrg XFREE (concat_name); 6343 1.1 mrg } 6344 1.1 mrg } 6345 1.1 mrg /* not found in PATH; assume curdir */ 6346 1.1 mrg } 6347 1.1 mrg /* Relative path | not found in path: prepend cwd */ 6348 1.1 mrg if (getcwd (tmp, LT_PATHMAX) == NULL) 6349 1.1 mrg lt_fatal (__FILE__, __LINE__, "getcwd failed: %s", 6350 1.1 mrg nonnull (strerror (errno))); 6351 1.1 mrg tmp_len = strlen (tmp); 6352 1.1 mrg concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1); 6353 1.1 mrg memcpy (concat_name, tmp, tmp_len); 6354 1.1 mrg concat_name[tmp_len] = '/'; 6355 1.1 mrg strcpy (concat_name + tmp_len + 1, wrapper); 6356 1.1 mrg 6357 1.1 mrg if (check_executable (concat_name)) 6358 1.1 mrg return concat_name; 6359 1.1 mrg XFREE (concat_name); 6360 1.1 mrg return NULL; 6361 1.1 mrg } 6362 1.1 mrg 6363 1.1 mrg char * 6364 1.1 mrg chase_symlinks (const char *pathspec) 6365 1.1 mrg { 6366 1.1 mrg #ifndef S_ISLNK 6367 1.1 mrg return xstrdup (pathspec); 6368 1.1 mrg #else 6369 1.1 mrg char buf[LT_PATHMAX]; 6370 1.1 mrg struct stat s; 6371 1.1 mrg char *tmp_pathspec = xstrdup (pathspec); 6372 1.1 mrg char *p; 6373 1.1 mrg int has_symlinks = 0; 6374 1.1 mrg while (strlen (tmp_pathspec) && !has_symlinks) 6375 1.1 mrg { 6376 1.1 mrg lt_debugprintf (__FILE__, __LINE__, 6377 1.1 mrg "checking path component for symlinks: %s\n", 6378 1.1 mrg tmp_pathspec); 6379 1.1 mrg if (lstat (tmp_pathspec, &s) == 0) 6380 1.1 mrg { 6381 1.1 mrg if (S_ISLNK (s.st_mode) != 0) 6382 1.1 mrg { 6383 1.1 mrg has_symlinks = 1; 6384 1.1 mrg break; 6385 1.1 mrg } 6386 1.1 mrg 6387 1.1 mrg /* search backwards for last DIR_SEPARATOR */ 6388 1.1 mrg p = tmp_pathspec + strlen (tmp_pathspec) - 1; 6389 1.1 mrg while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6390 1.1 mrg p--; 6391 1.1 mrg if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p))) 6392 1.1 mrg { 6393 1.1 mrg /* no more DIR_SEPARATORS left */ 6394 1.1 mrg break; 6395 1.1 mrg } 6396 1.1 mrg *p = '\0'; 6397 1.1 mrg } 6398 1.1 mrg else 6399 1.1 mrg { 6400 1.1 mrg lt_fatal (__FILE__, __LINE__, 6401 1.1 mrg "error accessing file \"%s\": %s", 6402 1.1 mrg tmp_pathspec, nonnull (strerror (errno))); 6403 1.1 mrg } 6404 1.1 mrg } 6405 1.1 mrg XFREE (tmp_pathspec); 6406 1.1 mrg 6407 1.1 mrg if (!has_symlinks) 6408 1.1 mrg { 6409 1.1 mrg return xstrdup (pathspec); 6410 1.1 mrg } 6411 1.1 mrg 6412 1.1 mrg tmp_pathspec = realpath (pathspec, buf); 6413 1.1 mrg if (tmp_pathspec == 0) 6414 1.1 mrg { 6415 1.1 mrg lt_fatal (__FILE__, __LINE__, 6416 1.1 mrg "could not follow symlinks for %s", pathspec); 6417 1.1 mrg } 6418 1.1 mrg return xstrdup (tmp_pathspec); 6419 1.1 mrg #endif 6420 1.1 mrg } 6421 1.1 mrg 6422 1.1 mrg char * 6423 1.1 mrg strendzap (char *str, const char *pat) 6424 1.1 mrg { 6425 1.1 mrg size_t len, patlen; 6426 1.1 mrg 6427 1.1 mrg assert (str != NULL); 6428 1.1 mrg assert (pat != NULL); 6429 1.1 mrg 6430 1.1 mrg len = strlen (str); 6431 1.1 mrg patlen = strlen (pat); 6432 1.1 mrg 6433 1.1 mrg if (patlen <= len) 6434 1.1 mrg { 6435 1.1 mrg str += len - patlen; 6436 1.1 mrg if (STREQ (str, pat)) 6437 1.1 mrg *str = '\0'; 6438 1.1 mrg } 6439 1.1 mrg return str; 6440 1.1 mrg } 6441 1.1 mrg 6442 1.1 mrg void 6443 1.1 mrg lt_debugprintf (const char *file, int line, const char *fmt, ...) 6444 1.1 mrg { 6445 1.1 mrg va_list args; 6446 1.1 mrg if (lt_debug) 6447 1.1 mrg { 6448 1.1 mrg (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line); 6449 1.1 mrg va_start (args, fmt); 6450 1.1 mrg (void) vfprintf (stderr, fmt, args); 6451 1.1 mrg va_end (args); 6452 1.1 mrg } 6453 1.1 mrg } 6454 1.1 mrg 6455 1.1 mrg static void 6456 1.1 mrg lt_error_core (int exit_status, const char *file, 6457 1.1 mrg int line, const char *mode, 6458 1.1 mrg const char *message, va_list ap) 6459 1.1 mrg { 6460 1.1 mrg fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode); 6461 1.1 mrg vfprintf (stderr, message, ap); 6462 1.1 mrg fprintf (stderr, ".\n"); 6463 1.1 mrg 6464 1.1 mrg if (exit_status >= 0) 6465 1.1 mrg exit (exit_status); 6466 1.1 mrg } 6467 1.1 mrg 6468 1.1 mrg void 6469 1.1 mrg lt_fatal (const char *file, int line, const char *message, ...) 6470 1.1 mrg { 6471 1.1 mrg va_list ap; 6472 1.1 mrg va_start (ap, message); 6473 1.1 mrg lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap); 6474 1.1 mrg va_end (ap); 6475 1.1 mrg } 6476 1.1 mrg 6477 1.1 mrg static const char * 6478 1.1 mrg nonnull (const char *s) 6479 1.1 mrg { 6480 1.1 mrg return s ? s : "(null)"; 6481 1.1 mrg } 6482 1.1 mrg 6483 1.1 mrg static const char * 6484 1.1 mrg nonempty (const char *s) 6485 1.1 mrg { 6486 1.1 mrg return (s && !*s) ? "(empty)" : nonnull (s); 6487 1.1 mrg } 6488 1.1 mrg 6489 1.1 mrg void 6490 1.1 mrg lt_setenv (const char *name, const char *value) 6491 1.1 mrg { 6492 1.1 mrg lt_debugprintf (__FILE__, __LINE__, 6493 1.1 mrg "(lt_setenv) setting '%s' to '%s'\n", 6494 1.1 mrg nonnull (name), nonnull (value)); 6495 1.1 mrg { 6496 1.1 mrg #ifdef HAVE_SETENV 6497 1.1 mrg /* always make a copy, for consistency with !HAVE_SETENV */ 6498 1.1 mrg char *str = xstrdup (value); 6499 1.1 mrg setenv (name, str, 1); 6500 1.1 mrg #else 6501 1.1 mrg size_t len = strlen (name) + 1 + strlen (value) + 1; 6502 1.1 mrg char *str = XMALLOC (char, len); 6503 1.1 mrg sprintf (str, "%s=%s", name, value); 6504 1.1 mrg if (putenv (str) != EXIT_SUCCESS) 6505 1.1 mrg { 6506 1.1 mrg XFREE (str); 6507 1.1 mrg } 6508 1.1 mrg #endif 6509 1.1 mrg } 6510 1.1 mrg } 6511 1.1 mrg 6512 1.1 mrg char * 6513 1.1 mrg lt_extend_str (const char *orig_value, const char *add, int to_end) 6514 1.1 mrg { 6515 1.1 mrg char *new_value; 6516 1.1 mrg if (orig_value && *orig_value) 6517 1.1 mrg { 6518 1.1 mrg size_t orig_value_len = strlen (orig_value); 6519 1.1 mrg size_t add_len = strlen (add); 6520 1.1 mrg new_value = XMALLOC (char, add_len + orig_value_len + 1); 6521 1.1 mrg if (to_end) 6522 1.1 mrg { 6523 1.1 mrg strcpy (new_value, orig_value); 6524 1.1 mrg strcpy (new_value + orig_value_len, add); 6525 1.1 mrg } 6526 1.1 mrg else 6527 1.1 mrg { 6528 1.1 mrg strcpy (new_value, add); 6529 1.1 mrg strcpy (new_value + add_len, orig_value); 6530 1.1 mrg } 6531 1.1 mrg } 6532 1.1 mrg else 6533 1.1 mrg { 6534 1.1 mrg new_value = xstrdup (add); 6535 1.1 mrg } 6536 1.1 mrg return new_value; 6537 1.1 mrg } 6538 1.1 mrg 6539 1.1 mrg void 6540 1.1 mrg lt_update_exe_path (const char *name, const char *value) 6541 1.1 mrg { 6542 1.1 mrg lt_debugprintf (__FILE__, __LINE__, 6543 1.1 mrg "(lt_update_exe_path) modifying '%s' by prepending '%s'\n", 6544 1.1 mrg nonnull (name), nonnull (value)); 6545 1.1 mrg 6546 1.1 mrg if (name && *name && value && *value) 6547 1.1 mrg { 6548 1.1 mrg char *new_value = lt_extend_str (getenv (name), value, 0); 6549 1.1 mrg /* some systems can't cope with a ':'-terminated path #' */ 6550 1.1 mrg size_t len = strlen (new_value); 6551 1.1 mrg while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1])) 6552 1.1 mrg { 6553 1.1 mrg new_value[--len] = '\0'; 6554 1.1 mrg } 6555 1.1 mrg lt_setenv (name, new_value); 6556 1.1 mrg XFREE (new_value); 6557 1.1 mrg } 6558 1.1 mrg } 6559 1.1 mrg 6560 1.1 mrg void 6561 1.1 mrg lt_update_lib_path (const char *name, const char *value) 6562 1.1 mrg { 6563 1.1 mrg lt_debugprintf (__FILE__, __LINE__, 6564 1.1 mrg "(lt_update_lib_path) modifying '%s' by prepending '%s'\n", 6565 1.1 mrg nonnull (name), nonnull (value)); 6566 1.1 mrg 6567 1.1 mrg if (name && *name && value && *value) 6568 1.1 mrg { 6569 1.1 mrg char *new_value = lt_extend_str (getenv (name), value, 0); 6570 1.1 mrg lt_setenv (name, new_value); 6571 1.1 mrg XFREE (new_value); 6572 1.1 mrg } 6573 1.1 mrg } 6574 1.1 mrg 6575 1.1 mrg EOF 6576 1.1 mrg case $host_os in 6577 1.1 mrg mingw*) 6578 1.1 mrg cat <<"EOF" 6579 1.1 mrg 6580 1.1 mrg /* Prepares an argument vector before calling spawn(). 6581 1.1 mrg Note that spawn() does not by itself call the command interpreter 6582 1.1 mrg (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") : 6583 1.1 mrg ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO); 6584 1.1 mrg GetVersionEx(&v); 6585 1.1 mrg v.dwPlatformId == VER_PLATFORM_WIN32_NT; 6586 1.1 mrg }) ? "cmd.exe" : "command.com"). 6587 1.1 mrg Instead it simply concatenates the arguments, separated by ' ', and calls 6588 1.1 mrg CreateProcess(). We must quote the arguments since Win32 CreateProcess() 6589 1.1 mrg interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a 6590 1.1 mrg special way: 6591 1.1 mrg - Space and tab are interpreted as delimiters. They are not treated as 6592 1.1 mrg delimiters if they are surrounded by double quotes: "...". 6593 1.1 mrg - Unescaped double quotes are removed from the input. Their only effect is 6594 1.1 mrg that within double quotes, space and tab are treated like normal 6595 1.1 mrg characters. 6596 1.1 mrg - Backslashes not followed by double quotes are not special. 6597 1.1 mrg - But 2*n+1 backslashes followed by a double quote become 6598 1.1 mrg n backslashes followed by a double quote (n >= 0): 6599 1.1 mrg \" -> " 6600 1.1 mrg \\\" -> \" 6601 1.1 mrg \\\\\" -> \\" 6602 1.1 mrg */ 6603 1.1 mrg #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" 6604 1.1 mrg #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" 6605 1.1 mrg char ** 6606 1.1 mrg prepare_spawn (char **argv) 6607 1.1 mrg { 6608 1.1 mrg size_t argc; 6609 1.1 mrg char **new_argv; 6610 1.1 mrg size_t i; 6611 1.1 mrg 6612 1.1 mrg /* Count number of arguments. */ 6613 1.1 mrg for (argc = 0; argv[argc] != NULL; argc++) 6614 1.1 mrg ; 6615 1.1 mrg 6616 1.1 mrg /* Allocate new argument vector. */ 6617 1.1 mrg new_argv = XMALLOC (char *, argc + 1); 6618 1.1 mrg 6619 1.1 mrg /* Put quoted arguments into the new argument vector. */ 6620 1.1 mrg for (i = 0; i < argc; i++) 6621 1.1 mrg { 6622 1.1 mrg const char *string = argv[i]; 6623 1.1 mrg 6624 1.1 mrg if (string[0] == '\0') 6625 1.1 mrg new_argv[i] = xstrdup ("\"\""); 6626 1.1 mrg else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL) 6627 1.1 mrg { 6628 1.1 mrg int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL); 6629 1.1 mrg size_t length; 6630 1.1 mrg unsigned int backslashes; 6631 1.1 mrg const char *s; 6632 1.1 mrg char *quoted_string; 6633 1.1 mrg char *p; 6634 1.1 mrg 6635 1.1 mrg length = 0; 6636 1.1 mrg backslashes = 0; 6637 1.1 mrg if (quote_around) 6638 1.1 mrg length++; 6639 1.1 mrg for (s = string; *s != '\0'; s++) 6640 1.1 mrg { 6641 1.1 mrg char c = *s; 6642 1.1 mrg if (c == '"') 6643 1.1 mrg length += backslashes + 1; 6644 1.1 mrg length++; 6645 1.1 mrg if (c == '\\') 6646 1.1 mrg backslashes++; 6647 1.1 mrg else 6648 1.1 mrg backslashes = 0; 6649 1.1 mrg } 6650 1.1 mrg if (quote_around) 6651 1.1 mrg length += backslashes + 1; 6652 1.1 mrg 6653 1.1 mrg quoted_string = XMALLOC (char, length + 1); 6654 1.1 mrg 6655 1.1 mrg p = quoted_string; 6656 1.1 mrg backslashes = 0; 6657 1.1 mrg if (quote_around) 6658 1.1 mrg *p++ = '"'; 6659 1.1 mrg for (s = string; *s != '\0'; s++) 6660 1.1 mrg { 6661 1.1 mrg char c = *s; 6662 1.1 mrg if (c == '"') 6663 1.1 mrg { 6664 1.1 mrg unsigned int j; 6665 1.1 mrg for (j = backslashes + 1; j > 0; j--) 6666 1.1 mrg *p++ = '\\'; 6667 1.1 mrg } 6668 1.1 mrg *p++ = c; 6669 1.1 mrg if (c == '\\') 6670 1.1 mrg backslashes++; 6671 1.1 mrg else 6672 1.1 mrg backslashes = 0; 6673 1.1 mrg } 6674 1.1 mrg if (quote_around) 6675 1.1 mrg { 6676 1.1 mrg unsigned int j; 6677 1.1 mrg for (j = backslashes; j > 0; j--) 6678 1.1 mrg *p++ = '\\'; 6679 1.1 mrg *p++ = '"'; 6680 1.1 mrg } 6681 1.1 mrg *p = '\0'; 6682 1.1 mrg 6683 1.1 mrg new_argv[i] = quoted_string; 6684 1.1 mrg } 6685 1.1 mrg else 6686 1.1 mrg new_argv[i] = (char *) string; 6687 1.1 mrg } 6688 1.1 mrg new_argv[argc] = NULL; 6689 1.1 mrg 6690 1.1 mrg return new_argv; 6691 1.1 mrg } 6692 1.1 mrg EOF 6693 1.1 mrg ;; 6694 1.1 mrg esac 6695 1.1 mrg 6696 1.1 mrg cat <<"EOF" 6697 1.1 mrg void lt_dump_script (FILE* f) 6698 1.1 mrg { 6699 1.1 mrg EOF 6700 1.1 mrg func_emit_wrapper yes | 6701 1.1 mrg $SED -n -e ' 6702 1.1 mrg s/^\(.\{79\}\)\(..*\)/\1\ 6703 1.1 mrg \2/ 6704 1.1 mrg h 6705 1.1 mrg s/\([\\"]\)/\\\1/g 6706 1.1 mrg s/$/\\n/ 6707 1.1 mrg s/\([^\n]*\).*/ fputs ("\1", f);/p 6708 1.1 mrg g 6709 1.1 mrg D' 6710 1.1 mrg cat <<"EOF" 6711 1.1 mrg } 6712 1.1 mrg EOF 6713 1.1 mrg } 6714 1.1 mrg # end: func_emit_cwrapperexe_src 6715 1.1 mrg 6716 1.1 mrg # func_win32_import_lib_p ARG 6717 1.1 mrg # True if ARG is an import lib, as indicated by $file_magic_cmd 6718 1.1 mrg func_win32_import_lib_p () 6719 1.1 mrg { 6720 1.1 mrg $debug_cmd 6721 1.1 mrg 6722 1.1 mrg case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in 6723 1.1 mrg *import*) : ;; 6724 1.1 mrg *) false ;; 6725 1.1 mrg esac 6726 1.1 mrg } 6727 1.1 mrg 6728 1.1 mrg # func_suncc_cstd_abi 6729 1.1 mrg # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!! 6730 1.1 mrg # Several compiler flags select an ABI that is incompatible with the 6731 1.1 mrg # Cstd library. Avoid specifying it if any are in CXXFLAGS. 6732 1.1 mrg func_suncc_cstd_abi () 6733 1.1 mrg { 6734 1.1 mrg $debug_cmd 6735 1.1 mrg 6736 1.1 mrg case " $compile_command " in 6737 1.1 mrg *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*) 6738 1.1 mrg suncc_use_cstd_abi=no 6739 1.1 mrg ;; 6740 1.1 mrg *) 6741 1.1 mrg suncc_use_cstd_abi=yes 6742 1.1 mrg ;; 6743 1.1 mrg esac 6744 1.1 mrg } 6745 1.1 mrg 6746 1.1 mrg # func_mode_link arg... 6747 1.1 mrg func_mode_link () 6748 1.1 mrg { 6749 1.1 mrg $debug_cmd 6750 1.1 mrg 6751 1.1 mrg case $host in 6752 1.1 mrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 6753 1.1 mrg # It is impossible to link a dll without this setting, and 6754 1.1 mrg # we shouldn't force the makefile maintainer to figure out 6755 1.1 mrg # what system we are compiling for in order to pass an extra 6756 1.1 mrg # flag for every libtool invocation. 6757 1.1 mrg # allow_undefined=no 6758 1.1 mrg 6759 1.1 mrg # FIXME: Unfortunately, there are problems with the above when trying 6760 1.1 mrg # to make a dll that has undefined symbols, in which case not 6761 1.1 mrg # even a static library is built. For now, we need to specify 6762 1.1 mrg # -no-undefined on the libtool link line when we can be certain 6763 1.1 mrg # that all symbols are satisfied, otherwise we get a static library. 6764 1.1 mrg allow_undefined=yes 6765 1.1 mrg ;; 6766 1.1 mrg *) 6767 1.1 mrg allow_undefined=yes 6768 1.1 mrg ;; 6769 1.1 mrg esac 6770 1.1 mrg libtool_args=$nonopt 6771 1.1 mrg base_compile="$nonopt $@" 6772 1.1 mrg compile_command=$nonopt 6773 1.1 mrg finalize_command=$nonopt 6774 1.1 mrg 6775 1.1 mrg compile_rpath= 6776 1.1 mrg finalize_rpath= 6777 1.1 mrg compile_shlibpath= 6778 1.1 mrg finalize_shlibpath= 6779 1.1 mrg convenience= 6780 1.1 mrg old_convenience= 6781 1.1 mrg deplibs= 6782 1.1 mrg old_deplibs= 6783 1.1 mrg compiler_flags= 6784 1.1 mrg linker_flags= 6785 1.1 mrg dllsearchpath= 6786 1.1 mrg lib_search_path=`pwd` 6787 1.1 mrg inst_prefix_dir= 6788 1.1 mrg new_inherited_linker_flags= 6789 1.1 mrg 6790 1.1 mrg avoid_version=no 6791 1.1 mrg bindir= 6792 1.1 mrg dlfiles= 6793 1.1 mrg dlprefiles= 6794 1.1 mrg dlself=no 6795 1.1 mrg export_dynamic=no 6796 1.1 mrg export_symbols= 6797 1.1 mrg export_symbols_regex= 6798 1.1 mrg generated= 6799 1.1 mrg libobjs= 6800 1.1 mrg ltlibs= 6801 1.1 mrg module=no 6802 1.1 mrg no_install=no 6803 1.1 mrg objs= 6804 1.1 mrg os2dllname= 6805 1.1 mrg non_pic_objects= 6806 1.1 mrg precious_files_regex= 6807 1.1 mrg prefer_static_libs=no 6808 1.1 mrg preload=false 6809 1.1 mrg prev= 6810 1.1 mrg prevarg= 6811 1.1 mrg release= 6812 1.1 mrg rpath= 6813 1.1 mrg xrpath= 6814 1.1 mrg perm_rpath= 6815 1.1 mrg temp_rpath= 6816 1.1 mrg thread_safe=no 6817 1.1 mrg vinfo= 6818 1.1 mrg vinfo_number=no 6819 1.1 mrg weak_libs= 6820 1.1 mrg single_module=$wl-single_module 6821 1.1 mrg func_infer_tag $base_compile 6822 1.1 mrg 6823 1.1 mrg # We need to know -static, to get the right output filenames. 6824 1.1 mrg for arg 6825 1.1 mrg do 6826 1.1 mrg case $arg in 6827 1.1 mrg -shared) 6828 1.1 mrg test yes != "$build_libtool_libs" \ 6829 1.1 mrg && func_fatal_configuration "cannot build a shared library" 6830 1.1 mrg build_old_libs=no 6831 1.1 mrg break 6832 1.1 mrg ;; 6833 1.1 mrg -all-static | -static | -static-libtool-libs) 6834 1.1 mrg case $arg in 6835 1.1 mrg -all-static) 6836 1.1 mrg if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then 6837 1.1 mrg func_warning "complete static linking is impossible in this configuration" 6838 1.1 mrg fi 6839 1.1 mrg if test -n "$link_static_flag"; then 6840 1.1 mrg dlopen_self=$dlopen_self_static 6841 1.1 mrg fi 6842 1.1 mrg prefer_static_libs=yes 6843 1.1 mrg ;; 6844 1.1 mrg -static) 6845 1.1 mrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6846 1.1 mrg dlopen_self=$dlopen_self_static 6847 1.1 mrg fi 6848 1.1 mrg prefer_static_libs=built 6849 1.1 mrg ;; 6850 1.1 mrg -static-libtool-libs) 6851 1.1 mrg if test -z "$pic_flag" && test -n "$link_static_flag"; then 6852 1.1 mrg dlopen_self=$dlopen_self_static 6853 1.1 mrg fi 6854 1.1 mrg prefer_static_libs=yes 6855 1.1 mrg ;; 6856 1.1 mrg esac 6857 1.1 mrg build_libtool_libs=no 6858 1.1 mrg build_old_libs=yes 6859 1.1 mrg break 6860 1.1 mrg ;; 6861 1.1 mrg esac 6862 1.1 mrg done 6863 1.1 mrg 6864 1.1 mrg # See if our shared archives depend on static archives. 6865 1.1 mrg test -n "$old_archive_from_new_cmds" && build_old_libs=yes 6866 1.1 mrg 6867 1.1 mrg # Go through the arguments, transforming them on the way. 6868 1.1 mrg while test "$#" -gt 0; do 6869 1.1 mrg arg=$1 6870 1.1 mrg shift 6871 1.1.1.2 mrg func_quote_arg pretty,unquoted "$arg" 6872 1.1.1.2 mrg qarg=$func_quote_arg_unquoted_result 6873 1.1.1.2 mrg func_append libtool_args " $func_quote_arg_result" 6874 1.1 mrg 6875 1.1 mrg # If the previous option needs an argument, assign it. 6876 1.1 mrg if test -n "$prev"; then 6877 1.1 mrg case $prev in 6878 1.1 mrg output) 6879 1.1 mrg func_append compile_command " @OUTPUT@" 6880 1.1 mrg func_append finalize_command " @OUTPUT@" 6881 1.1 mrg ;; 6882 1.1 mrg esac 6883 1.1 mrg 6884 1.1 mrg case $prev in 6885 1.1 mrg bindir) 6886 1.1 mrg bindir=$arg 6887 1.1 mrg prev= 6888 1.1 mrg continue 6889 1.1 mrg ;; 6890 1.1 mrg dlfiles|dlprefiles) 6891 1.1 mrg $preload || { 6892 1.1 mrg # Add the symbol object into the linking commands. 6893 1.1 mrg func_append compile_command " @SYMFILE@" 6894 1.1 mrg func_append finalize_command " @SYMFILE@" 6895 1.1 mrg preload=: 6896 1.1 mrg } 6897 1.1 mrg case $arg in 6898 1.1 mrg *.la | *.lo) ;; # We handle these cases below. 6899 1.1 mrg force) 6900 1.1 mrg if test no = "$dlself"; then 6901 1.1 mrg dlself=needless 6902 1.1 mrg export_dynamic=yes 6903 1.1 mrg fi 6904 1.1 mrg prev= 6905 1.1 mrg continue 6906 1.1 mrg ;; 6907 1.1 mrg self) 6908 1.1 mrg if test dlprefiles = "$prev"; then 6909 1.1 mrg dlself=yes 6910 1.1 mrg elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then 6911 1.1 mrg dlself=yes 6912 1.1 mrg else 6913 1.1 mrg dlself=needless 6914 1.1 mrg export_dynamic=yes 6915 1.1 mrg fi 6916 1.1 mrg prev= 6917 1.1 mrg continue 6918 1.1 mrg ;; 6919 1.1 mrg *) 6920 1.1 mrg if test dlfiles = "$prev"; then 6921 1.1 mrg func_append dlfiles " $arg" 6922 1.1 mrg else 6923 1.1 mrg func_append dlprefiles " $arg" 6924 1.1 mrg fi 6925 1.1 mrg prev= 6926 1.1 mrg continue 6927 1.1 mrg ;; 6928 1.1 mrg esac 6929 1.1 mrg ;; 6930 1.1 mrg expsyms) 6931 1.1 mrg export_symbols=$arg 6932 1.1 mrg test -f "$arg" \ 6933 1.1 mrg || func_fatal_error "symbol file '$arg' does not exist" 6934 1.1 mrg prev= 6935 1.1 mrg continue 6936 1.1 mrg ;; 6937 1.1 mrg expsyms_regex) 6938 1.1 mrg export_symbols_regex=$arg 6939 1.1 mrg prev= 6940 1.1 mrg continue 6941 1.1 mrg ;; 6942 1.1 mrg framework) 6943 1.1 mrg case $host in 6944 1.1 mrg *-*-darwin*) 6945 1.1 mrg case "$deplibs " in 6946 1.1 mrg *" $qarg.ltframework "*) ;; 6947 1.1 mrg *) func_append deplibs " $qarg.ltframework" # this is fixed later 6948 1.1 mrg ;; 6949 1.1 mrg esac 6950 1.1 mrg ;; 6951 1.1 mrg esac 6952 1.1 mrg prev= 6953 1.1 mrg continue 6954 1.1 mrg ;; 6955 1.1 mrg inst_prefix) 6956 1.1 mrg inst_prefix_dir=$arg 6957 1.1 mrg prev= 6958 1.1 mrg continue 6959 1.1 mrg ;; 6960 1.1 mrg mllvm) 6961 1.1 mrg # Clang does not use LLVM to link, so we can simply discard any 6962 1.1 mrg # '-mllvm $arg' options when doing the link step. 6963 1.1 mrg prev= 6964 1.1 mrg continue 6965 1.1 mrg ;; 6966 1.1 mrg objectlist) 6967 1.1 mrg if test -f "$arg"; then 6968 1.1 mrg save_arg=$arg 6969 1.1 mrg moreargs= 6970 1.1 mrg for fil in `cat "$save_arg"` 6971 1.1 mrg do 6972 1.1 mrg # func_append moreargs " $fil" 6973 1.1 mrg arg=$fil 6974 1.1 mrg # A libtool-controlled object. 6975 1.1 mrg 6976 1.1 mrg # Check to see that this really is a libtool object. 6977 1.1 mrg if func_lalib_unsafe_p "$arg"; then 6978 1.1 mrg pic_object= 6979 1.1 mrg non_pic_object= 6980 1.1 mrg 6981 1.1 mrg # Read the .lo file 6982 1.1 mrg func_source "$arg" 6983 1.1 mrg 6984 1.1 mrg if test -z "$pic_object" || 6985 1.1 mrg test -z "$non_pic_object" || 6986 1.1 mrg test none = "$pic_object" && 6987 1.1 mrg test none = "$non_pic_object"; then 6988 1.1 mrg func_fatal_error "cannot find name of object for '$arg'" 6989 1.1 mrg fi 6990 1.1 mrg 6991 1.1 mrg # Extract subdirectory from the argument. 6992 1.1 mrg func_dirname "$arg" "/" "" 6993 1.1 mrg xdir=$func_dirname_result 6994 1.1 mrg 6995 1.1 mrg if test none != "$pic_object"; then 6996 1.1 mrg # Prepend the subdirectory the object is found in. 6997 1.1 mrg pic_object=$xdir$pic_object 6998 1.1 mrg 6999 1.1 mrg if test dlfiles = "$prev"; then 7000 1.1 mrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7001 1.1 mrg func_append dlfiles " $pic_object" 7002 1.1 mrg prev= 7003 1.1 mrg continue 7004 1.1 mrg else 7005 1.1 mrg # If libtool objects are unsupported, then we need to preload. 7006 1.1 mrg prev=dlprefiles 7007 1.1 mrg fi 7008 1.1 mrg fi 7009 1.1 mrg 7010 1.1 mrg # CHECK ME: I think I busted this. -Ossama 7011 1.1 mrg if test dlprefiles = "$prev"; then 7012 1.1 mrg # Preload the old-style object. 7013 1.1 mrg func_append dlprefiles " $pic_object" 7014 1.1 mrg prev= 7015 1.1 mrg fi 7016 1.1 mrg 7017 1.1 mrg # A PIC object. 7018 1.1 mrg func_append libobjs " $pic_object" 7019 1.1 mrg arg=$pic_object 7020 1.1 mrg fi 7021 1.1 mrg 7022 1.1 mrg # Non-PIC object. 7023 1.1 mrg if test none != "$non_pic_object"; then 7024 1.1 mrg # Prepend the subdirectory the object is found in. 7025 1.1 mrg non_pic_object=$xdir$non_pic_object 7026 1.1 mrg 7027 1.1 mrg # A standard non-PIC object 7028 1.1 mrg func_append non_pic_objects " $non_pic_object" 7029 1.1 mrg if test -z "$pic_object" || test none = "$pic_object"; then 7030 1.1 mrg arg=$non_pic_object 7031 1.1 mrg fi 7032 1.1 mrg else 7033 1.1 mrg # If the PIC object exists, use it instead. 7034 1.1 mrg # $xdir was prepended to $pic_object above. 7035 1.1 mrg non_pic_object=$pic_object 7036 1.1 mrg func_append non_pic_objects " $non_pic_object" 7037 1.1 mrg fi 7038 1.1 mrg else 7039 1.1 mrg # Only an error if not doing a dry-run. 7040 1.1 mrg if $opt_dry_run; then 7041 1.1 mrg # Extract subdirectory from the argument. 7042 1.1 mrg func_dirname "$arg" "/" "" 7043 1.1 mrg xdir=$func_dirname_result 7044 1.1 mrg 7045 1.1 mrg func_lo2o "$arg" 7046 1.1 mrg pic_object=$xdir$objdir/$func_lo2o_result 7047 1.1 mrg non_pic_object=$xdir$func_lo2o_result 7048 1.1 mrg func_append libobjs " $pic_object" 7049 1.1 mrg func_append non_pic_objects " $non_pic_object" 7050 1.1 mrg else 7051 1.1 mrg func_fatal_error "'$arg' is not a valid libtool object" 7052 1.1 mrg fi 7053 1.1 mrg fi 7054 1.1 mrg done 7055 1.1 mrg else 7056 1.1 mrg func_fatal_error "link input file '$arg' does not exist" 7057 1.1 mrg fi 7058 1.1 mrg arg=$save_arg 7059 1.1 mrg prev= 7060 1.1 mrg continue 7061 1.1 mrg ;; 7062 1.1 mrg os2dllname) 7063 1.1 mrg os2dllname=$arg 7064 1.1 mrg prev= 7065 1.1 mrg continue 7066 1.1 mrg ;; 7067 1.1 mrg precious_regex) 7068 1.1 mrg precious_files_regex=$arg 7069 1.1 mrg prev= 7070 1.1 mrg continue 7071 1.1 mrg ;; 7072 1.1 mrg release) 7073 1.1 mrg release=-$arg 7074 1.1 mrg prev= 7075 1.1 mrg continue 7076 1.1 mrg ;; 7077 1.1 mrg rpath | xrpath) 7078 1.1 mrg # We need an absolute path. 7079 1.1 mrg case $arg in 7080 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7081 1.1 mrg *) 7082 1.1 mrg func_fatal_error "only absolute run-paths are allowed" 7083 1.1 mrg ;; 7084 1.1 mrg esac 7085 1.1 mrg if test rpath = "$prev"; then 7086 1.1 mrg case "$rpath " in 7087 1.1 mrg *" $arg "*) ;; 7088 1.1 mrg *) func_append rpath " $arg" ;; 7089 1.1 mrg esac 7090 1.1 mrg else 7091 1.1 mrg case "$xrpath " in 7092 1.1 mrg *" $arg "*) ;; 7093 1.1 mrg *) func_append xrpath " $arg" ;; 7094 1.1 mrg esac 7095 1.1 mrg fi 7096 1.1 mrg prev= 7097 1.1 mrg continue 7098 1.1 mrg ;; 7099 1.1 mrg shrext) 7100 1.1 mrg shrext_cmds=$arg 7101 1.1 mrg prev= 7102 1.1 mrg continue 7103 1.1 mrg ;; 7104 1.1 mrg weak) 7105 1.1 mrg func_append weak_libs " $arg" 7106 1.1 mrg prev= 7107 1.1 mrg continue 7108 1.1 mrg ;; 7109 1.1.1.2 mrg xassembler) 7110 1.1.1.2 mrg func_append compiler_flags " -Xassembler $qarg" 7111 1.1.1.2 mrg prev= 7112 1.1.1.2 mrg func_append compile_command " -Xassembler $qarg" 7113 1.1.1.2 mrg func_append finalize_command " -Xassembler $qarg" 7114 1.1.1.2 mrg continue 7115 1.1.1.2 mrg ;; 7116 1.1 mrg xcclinker) 7117 1.1 mrg func_append linker_flags " $qarg" 7118 1.1 mrg func_append compiler_flags " $qarg" 7119 1.1 mrg prev= 7120 1.1 mrg func_append compile_command " $qarg" 7121 1.1 mrg func_append finalize_command " $qarg" 7122 1.1 mrg continue 7123 1.1 mrg ;; 7124 1.1 mrg xcompiler) 7125 1.1 mrg func_append compiler_flags " $qarg" 7126 1.1 mrg prev= 7127 1.1 mrg func_append compile_command " $qarg" 7128 1.1 mrg func_append finalize_command " $qarg" 7129 1.1 mrg continue 7130 1.1 mrg ;; 7131 1.1 mrg xlinker) 7132 1.1 mrg func_append linker_flags " $qarg" 7133 1.1 mrg func_append compiler_flags " $wl$qarg" 7134 1.1 mrg prev= 7135 1.1 mrg func_append compile_command " $wl$qarg" 7136 1.1 mrg func_append finalize_command " $wl$qarg" 7137 1.1 mrg continue 7138 1.1 mrg ;; 7139 1.1 mrg *) 7140 1.1 mrg eval "$prev=\"\$arg\"" 7141 1.1 mrg prev= 7142 1.1 mrg continue 7143 1.1 mrg ;; 7144 1.1 mrg esac 7145 1.1 mrg fi # test -n "$prev" 7146 1.1 mrg 7147 1.1 mrg prevarg=$arg 7148 1.1 mrg 7149 1.1 mrg case $arg in 7150 1.1 mrg -all-static) 7151 1.1 mrg if test -n "$link_static_flag"; then 7152 1.1 mrg # See comment for -static flag below, for more details. 7153 1.1 mrg func_append compile_command " $link_static_flag" 7154 1.1 mrg func_append finalize_command " $link_static_flag" 7155 1.1 mrg fi 7156 1.1 mrg continue 7157 1.1 mrg ;; 7158 1.1 mrg 7159 1.1 mrg -allow-undefined) 7160 1.1 mrg # FIXME: remove this flag sometime in the future. 7161 1.1 mrg func_fatal_error "'-allow-undefined' must not be used because it is the default" 7162 1.1 mrg ;; 7163 1.1 mrg 7164 1.1 mrg -avoid-version) 7165 1.1 mrg avoid_version=yes 7166 1.1 mrg continue 7167 1.1 mrg ;; 7168 1.1 mrg 7169 1.1 mrg -bindir) 7170 1.1 mrg prev=bindir 7171 1.1 mrg continue 7172 1.1 mrg ;; 7173 1.1 mrg 7174 1.1 mrg -dlopen) 7175 1.1 mrg prev=dlfiles 7176 1.1 mrg continue 7177 1.1 mrg ;; 7178 1.1 mrg 7179 1.1 mrg -dlpreopen) 7180 1.1 mrg prev=dlprefiles 7181 1.1 mrg continue 7182 1.1 mrg ;; 7183 1.1 mrg 7184 1.1 mrg -export-dynamic) 7185 1.1 mrg export_dynamic=yes 7186 1.1 mrg continue 7187 1.1 mrg ;; 7188 1.1 mrg 7189 1.1 mrg -export-symbols | -export-symbols-regex) 7190 1.1 mrg if test -n "$export_symbols" || test -n "$export_symbols_regex"; then 7191 1.1 mrg func_fatal_error "more than one -exported-symbols argument is not allowed" 7192 1.1 mrg fi 7193 1.1 mrg if test X-export-symbols = "X$arg"; then 7194 1.1 mrg prev=expsyms 7195 1.1 mrg else 7196 1.1 mrg prev=expsyms_regex 7197 1.1 mrg fi 7198 1.1 mrg continue 7199 1.1 mrg ;; 7200 1.1 mrg 7201 1.1 mrg -framework) 7202 1.1 mrg prev=framework 7203 1.1 mrg continue 7204 1.1 mrg ;; 7205 1.1 mrg 7206 1.1 mrg -inst-prefix-dir) 7207 1.1 mrg prev=inst_prefix 7208 1.1 mrg continue 7209 1.1 mrg ;; 7210 1.1 mrg 7211 1.1 mrg # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:* 7212 1.1 mrg # so, if we see these flags be careful not to treat them like -L 7213 1.1 mrg -L[A-Z][A-Z]*:*) 7214 1.1 mrg case $with_gcc/$host in 7215 1.1 mrg no/*-*-irix* | /*-*-irix*) 7216 1.1 mrg func_append compile_command " $arg" 7217 1.1 mrg func_append finalize_command " $arg" 7218 1.1 mrg ;; 7219 1.1 mrg esac 7220 1.1 mrg continue 7221 1.1 mrg ;; 7222 1.1 mrg 7223 1.1 mrg -L*) 7224 1.1 mrg func_stripname "-L" '' "$arg" 7225 1.1 mrg if test -z "$func_stripname_result"; then 7226 1.1 mrg if test "$#" -gt 0; then 7227 1.1 mrg func_fatal_error "require no space between '-L' and '$1'" 7228 1.1 mrg else 7229 1.1 mrg func_fatal_error "need path for '-L' option" 7230 1.1 mrg fi 7231 1.1 mrg fi 7232 1.1 mrg func_resolve_sysroot "$func_stripname_result" 7233 1.1 mrg dir=$func_resolve_sysroot_result 7234 1.1 mrg # We need an absolute path. 7235 1.1 mrg case $dir in 7236 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7237 1.1 mrg *) 7238 1.1 mrg absdir=`cd "$dir" && pwd` 7239 1.1 mrg test -z "$absdir" && \ 7240 1.1 mrg func_fatal_error "cannot determine absolute directory name of '$dir'" 7241 1.1 mrg dir=$absdir 7242 1.1 mrg ;; 7243 1.1 mrg esac 7244 1.1 mrg case "$deplibs " in 7245 1.1 mrg *" -L$dir "* | *" $arg "*) 7246 1.1 mrg # Will only happen for absolute or sysroot arguments 7247 1.1 mrg ;; 7248 1.1 mrg *) 7249 1.1 mrg # Preserve sysroot, but never include relative directories 7250 1.1 mrg case $dir in 7251 1.1 mrg [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;; 7252 1.1 mrg *) func_append deplibs " -L$dir" ;; 7253 1.1 mrg esac 7254 1.1 mrg func_append lib_search_path " $dir" 7255 1.1 mrg ;; 7256 1.1 mrg esac 7257 1.1 mrg case $host in 7258 1.1 mrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 7259 1.1 mrg testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'` 7260 1.1 mrg case :$dllsearchpath: in 7261 1.1 mrg *":$dir:"*) ;; 7262 1.1 mrg ::) dllsearchpath=$dir;; 7263 1.1 mrg *) func_append dllsearchpath ":$dir";; 7264 1.1 mrg esac 7265 1.1 mrg case :$dllsearchpath: in 7266 1.1 mrg *":$testbindir:"*) ;; 7267 1.1 mrg ::) dllsearchpath=$testbindir;; 7268 1.1 mrg *) func_append dllsearchpath ":$testbindir";; 7269 1.1 mrg esac 7270 1.1 mrg ;; 7271 1.1 mrg esac 7272 1.1 mrg continue 7273 1.1 mrg ;; 7274 1.1 mrg 7275 1.1 mrg -l*) 7276 1.1 mrg if test X-lc = "X$arg" || test X-lm = "X$arg"; then 7277 1.1 mrg case $host in 7278 1.1 mrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*) 7279 1.1 mrg # These systems don't actually have a C or math library (as such) 7280 1.1 mrg continue 7281 1.1 mrg ;; 7282 1.1 mrg *-*-os2*) 7283 1.1 mrg # These systems don't actually have a C library (as such) 7284 1.1 mrg test X-lc = "X$arg" && continue 7285 1.1 mrg ;; 7286 1.1.1.2 mrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7287 1.1 mrg # Do not include libc due to us having libc/libc_r. 7288 1.1 mrg test X-lc = "X$arg" && continue 7289 1.1 mrg ;; 7290 1.1 mrg *-*-rhapsody* | *-*-darwin1.[012]) 7291 1.1 mrg # Rhapsody C and math libraries are in the System framework 7292 1.1 mrg func_append deplibs " System.ltframework" 7293 1.1 mrg continue 7294 1.1 mrg ;; 7295 1.1 mrg *-*-sco3.2v5* | *-*-sco5v6*) 7296 1.1 mrg # Causes problems with __ctype 7297 1.1 mrg test X-lc = "X$arg" && continue 7298 1.1 mrg ;; 7299 1.1 mrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 7300 1.1 mrg # Compiler inserts libc in the correct place for threads to work 7301 1.1 mrg test X-lc = "X$arg" && continue 7302 1.1 mrg ;; 7303 1.1 mrg esac 7304 1.1 mrg elif test X-lc_r = "X$arg"; then 7305 1.1 mrg case $host in 7306 1.1.1.2 mrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-bitrig* | *-*-midnightbsd*) 7307 1.1 mrg # Do not include libc_r directly, use -pthread flag. 7308 1.1 mrg continue 7309 1.1 mrg ;; 7310 1.1 mrg esac 7311 1.1 mrg fi 7312 1.1 mrg func_append deplibs " $arg" 7313 1.1 mrg continue 7314 1.1 mrg ;; 7315 1.1 mrg 7316 1.1 mrg -mllvm) 7317 1.1 mrg prev=mllvm 7318 1.1 mrg continue 7319 1.1 mrg ;; 7320 1.1 mrg 7321 1.1 mrg -module) 7322 1.1 mrg module=yes 7323 1.1 mrg continue 7324 1.1 mrg ;; 7325 1.1 mrg 7326 1.1 mrg # Tru64 UNIX uses -model [arg] to determine the layout of C++ 7327 1.1 mrg # classes, name mangling, and exception handling. 7328 1.1 mrg # Darwin uses the -arch flag to determine output architecture. 7329 1.1 mrg -model|-arch|-isysroot|--sysroot) 7330 1.1 mrg func_append compiler_flags " $arg" 7331 1.1 mrg func_append compile_command " $arg" 7332 1.1 mrg func_append finalize_command " $arg" 7333 1.1 mrg prev=xcompiler 7334 1.1 mrg continue 7335 1.1 mrg ;; 7336 1.1.1.2 mrg # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199. 7337 1.1.1.2 mrg -pthread) 7338 1.1.1.2 mrg case $host in 7339 1.1.1.2 mrg *solaris2*) ;; 7340 1.1.1.2 mrg *) 7341 1.1.1.2 mrg case "$new_inherited_linker_flags " in 7342 1.1.1.2 mrg *" $arg "*) ;; 7343 1.1.1.2 mrg * ) func_append new_inherited_linker_flags " $arg" ;; 7344 1.1.1.2 mrg esac 7345 1.1.1.2 mrg ;; 7346 1.1.1.2 mrg esac 7347 1.1.1.2 mrg continue 7348 1.1.1.2 mrg ;; 7349 1.1.1.2 mrg -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \ 7350 1.1 mrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7351 1.1 mrg func_append compiler_flags " $arg" 7352 1.1 mrg func_append compile_command " $arg" 7353 1.1 mrg func_append finalize_command " $arg" 7354 1.1 mrg case "$new_inherited_linker_flags " in 7355 1.1 mrg *" $arg "*) ;; 7356 1.1 mrg * ) func_append new_inherited_linker_flags " $arg" ;; 7357 1.1 mrg esac 7358 1.1 mrg continue 7359 1.1 mrg ;; 7360 1.1 mrg 7361 1.1 mrg -multi_module) 7362 1.1 mrg single_module=$wl-multi_module 7363 1.1 mrg continue 7364 1.1 mrg ;; 7365 1.1 mrg 7366 1.1 mrg -no-fast-install) 7367 1.1 mrg fast_install=no 7368 1.1 mrg continue 7369 1.1 mrg ;; 7370 1.1 mrg 7371 1.1 mrg -no-install) 7372 1.1 mrg case $host in 7373 1.1 mrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*) 7374 1.1 mrg # The PATH hackery in wrapper scripts is required on Windows 7375 1.1 mrg # and Darwin in order for the loader to find any dlls it needs. 7376 1.1 mrg func_warning "'-no-install' is ignored for $host" 7377 1.1 mrg func_warning "assuming '-no-fast-install' instead" 7378 1.1 mrg fast_install=no 7379 1.1 mrg ;; 7380 1.1 mrg *) no_install=yes ;; 7381 1.1 mrg esac 7382 1.1 mrg continue 7383 1.1 mrg ;; 7384 1.1 mrg 7385 1.1 mrg -no-undefined) 7386 1.1 mrg allow_undefined=no 7387 1.1 mrg continue 7388 1.1 mrg ;; 7389 1.1 mrg 7390 1.1 mrg -objectlist) 7391 1.1 mrg prev=objectlist 7392 1.1 mrg continue 7393 1.1 mrg ;; 7394 1.1 mrg 7395 1.1 mrg -os2dllname) 7396 1.1 mrg prev=os2dllname 7397 1.1 mrg continue 7398 1.1 mrg ;; 7399 1.1 mrg 7400 1.1 mrg -o) prev=output ;; 7401 1.1 mrg 7402 1.1 mrg -precious-files-regex) 7403 1.1 mrg prev=precious_regex 7404 1.1 mrg continue 7405 1.1 mrg ;; 7406 1.1 mrg 7407 1.1 mrg -release) 7408 1.1 mrg prev=release 7409 1.1 mrg continue 7410 1.1 mrg ;; 7411 1.1 mrg 7412 1.1 mrg -rpath) 7413 1.1 mrg prev=rpath 7414 1.1 mrg continue 7415 1.1 mrg ;; 7416 1.1 mrg 7417 1.1 mrg -R) 7418 1.1 mrg prev=xrpath 7419 1.1 mrg continue 7420 1.1 mrg ;; 7421 1.1 mrg 7422 1.1 mrg -R*) 7423 1.1 mrg func_stripname '-R' '' "$arg" 7424 1.1 mrg dir=$func_stripname_result 7425 1.1 mrg # We need an absolute path. 7426 1.1 mrg case $dir in 7427 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) ;; 7428 1.1 mrg =*) 7429 1.1 mrg func_stripname '=' '' "$dir" 7430 1.1 mrg dir=$lt_sysroot$func_stripname_result 7431 1.1 mrg ;; 7432 1.1 mrg *) 7433 1.1 mrg func_fatal_error "only absolute run-paths are allowed" 7434 1.1 mrg ;; 7435 1.1 mrg esac 7436 1.1 mrg case "$xrpath " in 7437 1.1 mrg *" $dir "*) ;; 7438 1.1 mrg *) func_append xrpath " $dir" ;; 7439 1.1 mrg esac 7440 1.1 mrg continue 7441 1.1 mrg ;; 7442 1.1 mrg 7443 1.1 mrg -shared) 7444 1.1 mrg # The effects of -shared are defined in a previous loop. 7445 1.1 mrg continue 7446 1.1 mrg ;; 7447 1.1 mrg 7448 1.1 mrg -shrext) 7449 1.1 mrg prev=shrext 7450 1.1 mrg continue 7451 1.1 mrg ;; 7452 1.1 mrg 7453 1.1 mrg -static | -static-libtool-libs) 7454 1.1 mrg # The effects of -static are defined in a previous loop. 7455 1.1 mrg # We used to do the same as -all-static on platforms that 7456 1.1 mrg # didn't have a PIC flag, but the assumption that the effects 7457 1.1 mrg # would be equivalent was wrong. It would break on at least 7458 1.1 mrg # Digital Unix and AIX. 7459 1.1 mrg continue 7460 1.1 mrg ;; 7461 1.1 mrg 7462 1.1 mrg -thread-safe) 7463 1.1 mrg thread_safe=yes 7464 1.1 mrg continue 7465 1.1 mrg ;; 7466 1.1 mrg 7467 1.1 mrg -version-info) 7468 1.1 mrg prev=vinfo 7469 1.1 mrg continue 7470 1.1 mrg ;; 7471 1.1 mrg 7472 1.1 mrg -version-number) 7473 1.1 mrg prev=vinfo 7474 1.1 mrg vinfo_number=yes 7475 1.1 mrg continue 7476 1.1 mrg ;; 7477 1.1 mrg 7478 1.1 mrg -weak) 7479 1.1 mrg prev=weak 7480 1.1 mrg continue 7481 1.1 mrg ;; 7482 1.1 mrg 7483 1.1 mrg -Wc,*) 7484 1.1 mrg func_stripname '-Wc,' '' "$arg" 7485 1.1 mrg args=$func_stripname_result 7486 1.1 mrg arg= 7487 1.1 mrg save_ifs=$IFS; IFS=, 7488 1.1 mrg for flag in $args; do 7489 1.1 mrg IFS=$save_ifs 7490 1.1.1.2 mrg func_quote_arg pretty "$flag" 7491 1.1.1.2 mrg func_append arg " $func_quote_arg_result" 7492 1.1.1.2 mrg func_append compiler_flags " $func_quote_arg_result" 7493 1.1 mrg done 7494 1.1 mrg IFS=$save_ifs 7495 1.1 mrg func_stripname ' ' '' "$arg" 7496 1.1 mrg arg=$func_stripname_result 7497 1.1 mrg ;; 7498 1.1 mrg 7499 1.1 mrg -Wl,*) 7500 1.1 mrg func_stripname '-Wl,' '' "$arg" 7501 1.1 mrg args=$func_stripname_result 7502 1.1 mrg arg= 7503 1.1 mrg save_ifs=$IFS; IFS=, 7504 1.1 mrg for flag in $args; do 7505 1.1 mrg IFS=$save_ifs 7506 1.1.1.2 mrg func_quote_arg pretty "$flag" 7507 1.1.1.2 mrg func_append arg " $wl$func_quote_arg_result" 7508 1.1.1.2 mrg func_append compiler_flags " $wl$func_quote_arg_result" 7509 1.1.1.2 mrg func_append linker_flags " $func_quote_arg_result" 7510 1.1 mrg done 7511 1.1 mrg IFS=$save_ifs 7512 1.1 mrg func_stripname ' ' '' "$arg" 7513 1.1 mrg arg=$func_stripname_result 7514 1.1 mrg ;; 7515 1.1 mrg 7516 1.1.1.2 mrg -Xassembler) 7517 1.1.1.2 mrg prev=xassembler 7518 1.1.1.2 mrg continue 7519 1.1.1.2 mrg ;; 7520 1.1.1.2 mrg 7521 1.1 mrg -Xcompiler) 7522 1.1 mrg prev=xcompiler 7523 1.1 mrg continue 7524 1.1 mrg ;; 7525 1.1 mrg 7526 1.1 mrg -Xlinker) 7527 1.1 mrg prev=xlinker 7528 1.1 mrg continue 7529 1.1 mrg ;; 7530 1.1 mrg 7531 1.1 mrg -XCClinker) 7532 1.1 mrg prev=xcclinker 7533 1.1 mrg continue 7534 1.1 mrg ;; 7535 1.1 mrg 7536 1.1 mrg # -msg_* for osf cc 7537 1.1 mrg -msg_*) 7538 1.1.1.2 mrg func_quote_arg pretty "$arg" 7539 1.1.1.2 mrg arg=$func_quote_arg_result 7540 1.1 mrg ;; 7541 1.1 mrg 7542 1.1 mrg # Flags to be passed through unchanged, with rationale: 7543 1.1 mrg # -64, -mips[0-9] enable 64-bit mode for the SGI compiler 7544 1.1 mrg # -r[0-9][0-9]* specify processor for the SGI compiler 7545 1.1 mrg # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler 7546 1.1 mrg # +DA*, +DD* enable 64-bit mode for the HP compiler 7547 1.1 mrg # -q* compiler args for the IBM compiler 7548 1.1 mrg # -m*, -t[45]*, -txscale* architecture-specific flags for GCC 7549 1.1 mrg # -F/path path to uninstalled frameworks, gcc on darwin 7550 1.1 mrg # -p, -pg, --coverage, -fprofile-* profiling flags for GCC 7551 1.1 mrg # -fstack-protector* stack protector flags for GCC 7552 1.1 mrg # @file GCC response files 7553 1.1 mrg # -tp=* Portland pgcc target processor selection 7554 1.1 mrg # --sysroot=* for sysroot support 7555 1.1 mrg # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization 7556 1.1.1.2 mrg # -specs=* GCC specs files 7557 1.1 mrg # -stdlib=* select c++ std lib with clang 7558 1.1.1.2 mrg # -fsanitize=* Clang/GCC memory and address sanitizer 7559 1.1.1.2 mrg # -fuse-ld=* Linker select flags for GCC 7560 1.1.1.2 mrg # -Wa,* Pass flags directly to the assembler 7561 1.1 mrg -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \ 7562 1.1 mrg -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \ 7563 1.1.1.2 mrg -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-stdlib=*| \ 7564 1.1.1.2 mrg -specs=*|-fsanitize=*|-fuse-ld=*|-Wa,*) 7565 1.1.1.2 mrg func_quote_arg pretty "$arg" 7566 1.1.1.2 mrg arg=$func_quote_arg_result 7567 1.1 mrg func_append compile_command " $arg" 7568 1.1 mrg func_append finalize_command " $arg" 7569 1.1 mrg func_append compiler_flags " $arg" 7570 1.1 mrg continue 7571 1.1 mrg ;; 7572 1.1 mrg 7573 1.1 mrg -Z*) 7574 1.1 mrg if test os2 = "`expr $host : '.*\(os2\)'`"; then 7575 1.1 mrg # OS/2 uses -Zxxx to specify OS/2-specific options 7576 1.1 mrg compiler_flags="$compiler_flags $arg" 7577 1.1 mrg func_append compile_command " $arg" 7578 1.1 mrg func_append finalize_command " $arg" 7579 1.1 mrg case $arg in 7580 1.1 mrg -Zlinker | -Zstack) 7581 1.1 mrg prev=xcompiler 7582 1.1 mrg ;; 7583 1.1 mrg esac 7584 1.1 mrg continue 7585 1.1 mrg else 7586 1.1 mrg # Otherwise treat like 'Some other compiler flag' below 7587 1.1.1.2 mrg func_quote_arg pretty "$arg" 7588 1.1.1.2 mrg arg=$func_quote_arg_result 7589 1.1 mrg fi 7590 1.1 mrg ;; 7591 1.1 mrg 7592 1.1 mrg # Some other compiler flag. 7593 1.1 mrg -* | +*) 7594 1.1.1.2 mrg func_quote_arg pretty "$arg" 7595 1.1.1.2 mrg arg=$func_quote_arg_result 7596 1.1 mrg ;; 7597 1.1 mrg 7598 1.1 mrg *.$objext) 7599 1.1 mrg # A standard object. 7600 1.1 mrg func_append objs " $arg" 7601 1.1 mrg ;; 7602 1.1 mrg 7603 1.1 mrg *.lo) 7604 1.1 mrg # A libtool-controlled object. 7605 1.1 mrg 7606 1.1 mrg # Check to see that this really is a libtool object. 7607 1.1 mrg if func_lalib_unsafe_p "$arg"; then 7608 1.1 mrg pic_object= 7609 1.1 mrg non_pic_object= 7610 1.1 mrg 7611 1.1 mrg # Read the .lo file 7612 1.1 mrg func_source "$arg" 7613 1.1 mrg 7614 1.1 mrg if test -z "$pic_object" || 7615 1.1 mrg test -z "$non_pic_object" || 7616 1.1 mrg test none = "$pic_object" && 7617 1.1 mrg test none = "$non_pic_object"; then 7618 1.1 mrg func_fatal_error "cannot find name of object for '$arg'" 7619 1.1 mrg fi 7620 1.1 mrg 7621 1.1 mrg # Extract subdirectory from the argument. 7622 1.1 mrg func_dirname "$arg" "/" "" 7623 1.1 mrg xdir=$func_dirname_result 7624 1.1 mrg 7625 1.1 mrg test none = "$pic_object" || { 7626 1.1 mrg # Prepend the subdirectory the object is found in. 7627 1.1 mrg pic_object=$xdir$pic_object 7628 1.1 mrg 7629 1.1 mrg if test dlfiles = "$prev"; then 7630 1.1 mrg if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then 7631 1.1 mrg func_append dlfiles " $pic_object" 7632 1.1 mrg prev= 7633 1.1 mrg continue 7634 1.1 mrg else 7635 1.1 mrg # If libtool objects are unsupported, then we need to preload. 7636 1.1 mrg prev=dlprefiles 7637 1.1 mrg fi 7638 1.1 mrg fi 7639 1.1 mrg 7640 1.1 mrg # CHECK ME: I think I busted this. -Ossama 7641 1.1 mrg if test dlprefiles = "$prev"; then 7642 1.1 mrg # Preload the old-style object. 7643 1.1 mrg func_append dlprefiles " $pic_object" 7644 1.1 mrg prev= 7645 1.1 mrg fi 7646 1.1 mrg 7647 1.1 mrg # A PIC object. 7648 1.1 mrg func_append libobjs " $pic_object" 7649 1.1 mrg arg=$pic_object 7650 1.1 mrg } 7651 1.1 mrg 7652 1.1 mrg # Non-PIC object. 7653 1.1 mrg if test none != "$non_pic_object"; then 7654 1.1 mrg # Prepend the subdirectory the object is found in. 7655 1.1 mrg non_pic_object=$xdir$non_pic_object 7656 1.1 mrg 7657 1.1 mrg # A standard non-PIC object 7658 1.1 mrg func_append non_pic_objects " $non_pic_object" 7659 1.1 mrg if test -z "$pic_object" || test none = "$pic_object"; then 7660 1.1 mrg arg=$non_pic_object 7661 1.1 mrg fi 7662 1.1 mrg else 7663 1.1 mrg # If the PIC object exists, use it instead. 7664 1.1 mrg # $xdir was prepended to $pic_object above. 7665 1.1 mrg non_pic_object=$pic_object 7666 1.1 mrg func_append non_pic_objects " $non_pic_object" 7667 1.1 mrg fi 7668 1.1 mrg else 7669 1.1 mrg # Only an error if not doing a dry-run. 7670 1.1 mrg if $opt_dry_run; then 7671 1.1 mrg # Extract subdirectory from the argument. 7672 1.1 mrg func_dirname "$arg" "/" "" 7673 1.1 mrg xdir=$func_dirname_result 7674 1.1 mrg 7675 1.1 mrg func_lo2o "$arg" 7676 1.1 mrg pic_object=$xdir$objdir/$func_lo2o_result 7677 1.1 mrg non_pic_object=$xdir$func_lo2o_result 7678 1.1 mrg func_append libobjs " $pic_object" 7679 1.1 mrg func_append non_pic_objects " $non_pic_object" 7680 1.1 mrg else 7681 1.1 mrg func_fatal_error "'$arg' is not a valid libtool object" 7682 1.1 mrg fi 7683 1.1 mrg fi 7684 1.1 mrg ;; 7685 1.1 mrg 7686 1.1 mrg *.$libext) 7687 1.1 mrg # An archive. 7688 1.1 mrg func_append deplibs " $arg" 7689 1.1 mrg func_append old_deplibs " $arg" 7690 1.1 mrg continue 7691 1.1 mrg ;; 7692 1.1 mrg 7693 1.1 mrg *.la) 7694 1.1 mrg # A libtool-controlled library. 7695 1.1 mrg 7696 1.1 mrg func_resolve_sysroot "$arg" 7697 1.1 mrg if test dlfiles = "$prev"; then 7698 1.1 mrg # This library was specified with -dlopen. 7699 1.1 mrg func_append dlfiles " $func_resolve_sysroot_result" 7700 1.1 mrg prev= 7701 1.1 mrg elif test dlprefiles = "$prev"; then 7702 1.1 mrg # The library was specified with -dlpreopen. 7703 1.1 mrg func_append dlprefiles " $func_resolve_sysroot_result" 7704 1.1 mrg prev= 7705 1.1 mrg else 7706 1.1 mrg func_append deplibs " $func_resolve_sysroot_result" 7707 1.1 mrg fi 7708 1.1 mrg continue 7709 1.1 mrg ;; 7710 1.1 mrg 7711 1.1 mrg # Some other compiler argument. 7712 1.1 mrg *) 7713 1.1 mrg # Unknown arguments in both finalize_command and compile_command need 7714 1.1 mrg # to be aesthetically quoted because they are evaled later. 7715 1.1.1.2 mrg func_quote_arg pretty "$arg" 7716 1.1.1.2 mrg arg=$func_quote_arg_result 7717 1.1 mrg ;; 7718 1.1 mrg esac # arg 7719 1.1 mrg 7720 1.1 mrg # Now actually substitute the argument into the commands. 7721 1.1 mrg if test -n "$arg"; then 7722 1.1 mrg func_append compile_command " $arg" 7723 1.1 mrg func_append finalize_command " $arg" 7724 1.1 mrg fi 7725 1.1 mrg done # argument parsing loop 7726 1.1 mrg 7727 1.1 mrg test -n "$prev" && \ 7728 1.1 mrg func_fatal_help "the '$prevarg' option requires an argument" 7729 1.1 mrg 7730 1.1 mrg if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then 7731 1.1 mrg eval arg=\"$export_dynamic_flag_spec\" 7732 1.1 mrg func_append compile_command " $arg" 7733 1.1 mrg func_append finalize_command " $arg" 7734 1.1 mrg fi 7735 1.1 mrg 7736 1.1 mrg oldlibs= 7737 1.1 mrg # calculate the name of the file, without its directory 7738 1.1 mrg func_basename "$output" 7739 1.1 mrg outputname=$func_basename_result 7740 1.1 mrg libobjs_save=$libobjs 7741 1.1 mrg 7742 1.1 mrg if test -n "$shlibpath_var"; then 7743 1.1 mrg # get the directories listed in $shlibpath_var 7744 1.1 mrg eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\` 7745 1.1 mrg else 7746 1.1 mrg shlib_search_path= 7747 1.1 mrg fi 7748 1.1 mrg eval sys_lib_search_path=\"$sys_lib_search_path_spec\" 7749 1.1 mrg eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\" 7750 1.1 mrg 7751 1.1 mrg # Definition is injected by LT_CONFIG during libtool generation. 7752 1.1 mrg func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH" 7753 1.1 mrg 7754 1.1 mrg func_dirname "$output" "/" "" 7755 1.1 mrg output_objdir=$func_dirname_result$objdir 7756 1.1 mrg func_to_tool_file "$output_objdir/" 7757 1.1 mrg tool_output_objdir=$func_to_tool_file_result 7758 1.1 mrg # Create the object directory. 7759 1.1 mrg func_mkdir_p "$output_objdir" 7760 1.1 mrg 7761 1.1 mrg # Determine the type of output 7762 1.1 mrg case $output in 7763 1.1 mrg "") 7764 1.1 mrg func_fatal_help "you must specify an output file" 7765 1.1 mrg ;; 7766 1.1 mrg *.$libext) linkmode=oldlib ;; 7767 1.1 mrg *.lo | *.$objext) linkmode=obj ;; 7768 1.1 mrg *.la) linkmode=lib ;; 7769 1.1 mrg *) linkmode=prog ;; # Anything else should be a program. 7770 1.1 mrg esac 7771 1.1 mrg 7772 1.1 mrg specialdeplibs= 7773 1.1 mrg 7774 1.1 mrg libs= 7775 1.1 mrg # Find all interdependent deplibs by searching for libraries 7776 1.1 mrg # that are linked more than once (e.g. -la -lb -la) 7777 1.1 mrg for deplib in $deplibs; do 7778 1.1 mrg if $opt_preserve_dup_deps; then 7779 1.1 mrg case "$libs " in 7780 1.1 mrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 7781 1.1 mrg esac 7782 1.1 mrg fi 7783 1.1 mrg func_append libs " $deplib" 7784 1.1 mrg done 7785 1.1 mrg 7786 1.1 mrg if test lib = "$linkmode"; then 7787 1.1 mrg libs="$predeps $libs $compiler_lib_search_path $postdeps" 7788 1.1 mrg 7789 1.1 mrg # Compute libraries that are listed more than once in $predeps 7790 1.1 mrg # $postdeps and mark them as special (i.e., whose duplicates are 7791 1.1 mrg # not to be eliminated). 7792 1.1 mrg pre_post_deps= 7793 1.1 mrg if $opt_duplicate_compiler_generated_deps; then 7794 1.1 mrg for pre_post_dep in $predeps $postdeps; do 7795 1.1 mrg case "$pre_post_deps " in 7796 1.1 mrg *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;; 7797 1.1 mrg esac 7798 1.1 mrg func_append pre_post_deps " $pre_post_dep" 7799 1.1 mrg done 7800 1.1 mrg fi 7801 1.1 mrg pre_post_deps= 7802 1.1 mrg fi 7803 1.1 mrg 7804 1.1 mrg deplibs= 7805 1.1 mrg newdependency_libs= 7806 1.1 mrg newlib_search_path= 7807 1.1 mrg need_relink=no # whether we're linking any uninstalled libtool libraries 7808 1.1 mrg notinst_deplibs= # not-installed libtool libraries 7809 1.1 mrg notinst_path= # paths that contain not-installed libtool libraries 7810 1.1 mrg 7811 1.1 mrg case $linkmode in 7812 1.1 mrg lib) 7813 1.1 mrg passes="conv dlpreopen link" 7814 1.1 mrg for file in $dlfiles $dlprefiles; do 7815 1.1 mrg case $file in 7816 1.1 mrg *.la) ;; 7817 1.1 mrg *) 7818 1.1 mrg func_fatal_help "libraries can '-dlopen' only libtool libraries: $file" 7819 1.1 mrg ;; 7820 1.1 mrg esac 7821 1.1 mrg done 7822 1.1 mrg ;; 7823 1.1 mrg prog) 7824 1.1 mrg compile_deplibs= 7825 1.1 mrg finalize_deplibs= 7826 1.1 mrg alldeplibs=false 7827 1.1 mrg newdlfiles= 7828 1.1 mrg newdlprefiles= 7829 1.1 mrg passes="conv scan dlopen dlpreopen link" 7830 1.1 mrg ;; 7831 1.1 mrg *) passes="conv" 7832 1.1 mrg ;; 7833 1.1 mrg esac 7834 1.1 mrg 7835 1.1 mrg for pass in $passes; do 7836 1.1 mrg # The preopen pass in lib mode reverses $deplibs; put it back here 7837 1.1 mrg # so that -L comes before libs that need it for instance... 7838 1.1 mrg if test lib,link = "$linkmode,$pass"; then 7839 1.1 mrg ## FIXME: Find the place where the list is rebuilt in the wrong 7840 1.1 mrg ## order, and fix it there properly 7841 1.1 mrg tmp_deplibs= 7842 1.1 mrg for deplib in $deplibs; do 7843 1.1 mrg tmp_deplibs="$deplib $tmp_deplibs" 7844 1.1 mrg done 7845 1.1 mrg deplibs=$tmp_deplibs 7846 1.1 mrg fi 7847 1.1 mrg 7848 1.1 mrg if test lib,link = "$linkmode,$pass" || 7849 1.1 mrg test prog,scan = "$linkmode,$pass"; then 7850 1.1 mrg libs=$deplibs 7851 1.1 mrg deplibs= 7852 1.1 mrg fi 7853 1.1 mrg if test prog = "$linkmode"; then 7854 1.1 mrg case $pass in 7855 1.1 mrg dlopen) libs=$dlfiles ;; 7856 1.1 mrg dlpreopen) libs=$dlprefiles ;; 7857 1.1 mrg link) libs="$deplibs %DEPLIBS% $dependency_libs" ;; 7858 1.1 mrg esac 7859 1.1 mrg fi 7860 1.1 mrg if test lib,dlpreopen = "$linkmode,$pass"; then 7861 1.1 mrg # Collect and forward deplibs of preopened libtool libs 7862 1.1 mrg for lib in $dlprefiles; do 7863 1.1 mrg # Ignore non-libtool-libs 7864 1.1 mrg dependency_libs= 7865 1.1 mrg func_resolve_sysroot "$lib" 7866 1.1 mrg case $lib in 7867 1.1 mrg *.la) func_source "$func_resolve_sysroot_result" ;; 7868 1.1 mrg esac 7869 1.1 mrg 7870 1.1 mrg # Collect preopened libtool deplibs, except any this library 7871 1.1 mrg # has declared as weak libs 7872 1.1 mrg for deplib in $dependency_libs; do 7873 1.1 mrg func_basename "$deplib" 7874 1.1 mrg deplib_base=$func_basename_result 7875 1.1 mrg case " $weak_libs " in 7876 1.1 mrg *" $deplib_base "*) ;; 7877 1.1 mrg *) func_append deplibs " $deplib" ;; 7878 1.1 mrg esac 7879 1.1 mrg done 7880 1.1 mrg done 7881 1.1 mrg libs=$dlprefiles 7882 1.1 mrg fi 7883 1.1 mrg if test dlopen = "$pass"; then 7884 1.1 mrg # Collect dlpreopened libraries 7885 1.1 mrg save_deplibs=$deplibs 7886 1.1 mrg deplibs= 7887 1.1 mrg fi 7888 1.1 mrg 7889 1.1 mrg for deplib in $libs; do 7890 1.1 mrg lib= 7891 1.1 mrg found=false 7892 1.1 mrg case $deplib in 7893 1.1 mrg -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \ 7894 1.1 mrg |-threads|-fopenmp|-openmp|-mp|-xopenmp|-omp|-qsmp=*) 7895 1.1 mrg if test prog,link = "$linkmode,$pass"; then 7896 1.1 mrg compile_deplibs="$deplib $compile_deplibs" 7897 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs" 7898 1.1 mrg else 7899 1.1 mrg func_append compiler_flags " $deplib" 7900 1.1 mrg if test lib = "$linkmode"; then 7901 1.1 mrg case "$new_inherited_linker_flags " in 7902 1.1 mrg *" $deplib "*) ;; 7903 1.1 mrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7904 1.1 mrg esac 7905 1.1 mrg fi 7906 1.1 mrg fi 7907 1.1 mrg continue 7908 1.1 mrg ;; 7909 1.1 mrg -l*) 7910 1.1 mrg if test lib != "$linkmode" && test prog != "$linkmode"; then 7911 1.1 mrg func_warning "'-l' is ignored for archives/objects" 7912 1.1 mrg continue 7913 1.1 mrg fi 7914 1.1 mrg func_stripname '-l' '' "$deplib" 7915 1.1 mrg name=$func_stripname_result 7916 1.1 mrg if test lib = "$linkmode"; then 7917 1.1 mrg searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path" 7918 1.1 mrg else 7919 1.1 mrg searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path" 7920 1.1 mrg fi 7921 1.1 mrg for searchdir in $searchdirs; do 7922 1.1 mrg for search_ext in .la $std_shrext .so .a; do 7923 1.1 mrg # Search the libtool library 7924 1.1 mrg lib=$searchdir/lib$name$search_ext 7925 1.1 mrg if test -f "$lib"; then 7926 1.1 mrg if test .la = "$search_ext"; then 7927 1.1 mrg found=: 7928 1.1 mrg else 7929 1.1 mrg found=false 7930 1.1 mrg fi 7931 1.1 mrg break 2 7932 1.1 mrg fi 7933 1.1 mrg done 7934 1.1 mrg done 7935 1.1 mrg if $found; then 7936 1.1 mrg # deplib is a libtool library 7937 1.1 mrg # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib, 7938 1.1 mrg # We need to do some special things here, and not later. 7939 1.1 mrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 7940 1.1 mrg case " $predeps $postdeps " in 7941 1.1 mrg *" $deplib "*) 7942 1.1 mrg if func_lalib_p "$lib"; then 7943 1.1 mrg library_names= 7944 1.1 mrg old_library= 7945 1.1 mrg func_source "$lib" 7946 1.1 mrg for l in $old_library $library_names; do 7947 1.1 mrg ll=$l 7948 1.1 mrg done 7949 1.1 mrg if test "X$ll" = "X$old_library"; then # only static version available 7950 1.1 mrg found=false 7951 1.1 mrg func_dirname "$lib" "" "." 7952 1.1 mrg ladir=$func_dirname_result 7953 1.1 mrg lib=$ladir/$old_library 7954 1.1 mrg if test prog,link = "$linkmode,$pass"; then 7955 1.1 mrg compile_deplibs="$deplib $compile_deplibs" 7956 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs" 7957 1.1 mrg else 7958 1.1 mrg deplibs="$deplib $deplibs" 7959 1.1 mrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7960 1.1 mrg fi 7961 1.1 mrg continue 7962 1.1 mrg fi 7963 1.1 mrg fi 7964 1.1 mrg ;; 7965 1.1 mrg *) ;; 7966 1.1 mrg esac 7967 1.1 mrg fi 7968 1.1 mrg else 7969 1.1 mrg # deplib doesn't seem to be a libtool library 7970 1.1 mrg if test prog,link = "$linkmode,$pass"; then 7971 1.1 mrg compile_deplibs="$deplib $compile_deplibs" 7972 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs" 7973 1.1 mrg else 7974 1.1 mrg deplibs="$deplib $deplibs" 7975 1.1 mrg test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs" 7976 1.1 mrg fi 7977 1.1 mrg continue 7978 1.1 mrg fi 7979 1.1 mrg ;; # -l 7980 1.1 mrg *.ltframework) 7981 1.1 mrg if test prog,link = "$linkmode,$pass"; then 7982 1.1 mrg compile_deplibs="$deplib $compile_deplibs" 7983 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs" 7984 1.1 mrg else 7985 1.1 mrg deplibs="$deplib $deplibs" 7986 1.1 mrg if test lib = "$linkmode"; then 7987 1.1 mrg case "$new_inherited_linker_flags " in 7988 1.1 mrg *" $deplib "*) ;; 7989 1.1 mrg * ) func_append new_inherited_linker_flags " $deplib" ;; 7990 1.1 mrg esac 7991 1.1 mrg fi 7992 1.1 mrg fi 7993 1.1 mrg continue 7994 1.1 mrg ;; 7995 1.1 mrg -L*) 7996 1.1 mrg case $linkmode in 7997 1.1 mrg lib) 7998 1.1 mrg deplibs="$deplib $deplibs" 7999 1.1 mrg test conv = "$pass" && continue 8000 1.1 mrg newdependency_libs="$deplib $newdependency_libs" 8001 1.1 mrg func_stripname '-L' '' "$deplib" 8002 1.1 mrg func_resolve_sysroot "$func_stripname_result" 8003 1.1 mrg func_append newlib_search_path " $func_resolve_sysroot_result" 8004 1.1 mrg ;; 8005 1.1 mrg prog) 8006 1.1 mrg if test conv = "$pass"; then 8007 1.1 mrg deplibs="$deplib $deplibs" 8008 1.1 mrg continue 8009 1.1 mrg fi 8010 1.1 mrg if test scan = "$pass"; then 8011 1.1 mrg deplibs="$deplib $deplibs" 8012 1.1 mrg else 8013 1.1 mrg compile_deplibs="$deplib $compile_deplibs" 8014 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs" 8015 1.1 mrg fi 8016 1.1 mrg func_stripname '-L' '' "$deplib" 8017 1.1 mrg func_resolve_sysroot "$func_stripname_result" 8018 1.1 mrg func_append newlib_search_path " $func_resolve_sysroot_result" 8019 1.1 mrg ;; 8020 1.1 mrg *) 8021 1.1 mrg func_warning "'-L' is ignored for archives/objects" 8022 1.1 mrg ;; 8023 1.1 mrg esac # linkmode 8024 1.1 mrg continue 8025 1.1 mrg ;; # -L 8026 1.1 mrg -R*) 8027 1.1 mrg if test link = "$pass"; then 8028 1.1 mrg func_stripname '-R' '' "$deplib" 8029 1.1 mrg func_resolve_sysroot "$func_stripname_result" 8030 1.1 mrg dir=$func_resolve_sysroot_result 8031 1.1 mrg # Make sure the xrpath contains only unique directories. 8032 1.1 mrg case "$xrpath " in 8033 1.1 mrg *" $dir "*) ;; 8034 1.1 mrg *) func_append xrpath " $dir" ;; 8035 1.1 mrg esac 8036 1.1 mrg fi 8037 1.1 mrg deplibs="$deplib $deplibs" 8038 1.1 mrg continue 8039 1.1 mrg ;; 8040 1.1 mrg *.la) 8041 1.1 mrg func_resolve_sysroot "$deplib" 8042 1.1 mrg lib=$func_resolve_sysroot_result 8043 1.1 mrg ;; 8044 1.1 mrg *.$libext) 8045 1.1 mrg if test conv = "$pass"; then 8046 1.1 mrg deplibs="$deplib $deplibs" 8047 1.1 mrg continue 8048 1.1 mrg fi 8049 1.1 mrg case $linkmode in 8050 1.1 mrg lib) 8051 1.1 mrg # Linking convenience modules into shared libraries is allowed, 8052 1.1 mrg # but linking other static libraries is non-portable. 8053 1.1 mrg case " $dlpreconveniencelibs " in 8054 1.1 mrg *" $deplib "*) ;; 8055 1.1 mrg *) 8056 1.1 mrg valid_a_lib=false 8057 1.1 mrg case $deplibs_check_method in 8058 1.1 mrg match_pattern*) 8059 1.1 mrg set dummy $deplibs_check_method; shift 8060 1.1 mrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 8061 1.1 mrg if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \ 8062 1.1 mrg | $EGREP "$match_pattern_regex" > /dev/null; then 8063 1.1 mrg valid_a_lib=: 8064 1.1 mrg fi 8065 1.1 mrg ;; 8066 1.1 mrg pass_all) 8067 1.1 mrg valid_a_lib=: 8068 1.1 mrg ;; 8069 1.1 mrg esac 8070 1.1 mrg if $valid_a_lib; then 8071 1.1 mrg echo 8072 1.1 mrg $ECHO "*** Warning: Linking the shared library $output against the" 8073 1.1 mrg $ECHO "*** static library $deplib is not portable!" 8074 1.1 mrg deplibs="$deplib $deplibs" 8075 1.1 mrg else 8076 1.1 mrg echo 8077 1.1 mrg $ECHO "*** Warning: Trying to link with static lib archive $deplib." 8078 1.1 mrg echo "*** I have the capability to make that library automatically link in when" 8079 1.1 mrg echo "*** you link to this library. But I can only do this if you have a" 8080 1.1 mrg echo "*** shared version of the library, which you do not appear to have" 8081 1.1 mrg echo "*** because the file extensions .$libext of this argument makes me believe" 8082 1.1 mrg echo "*** that it is just a static archive that I should not use here." 8083 1.1 mrg fi 8084 1.1 mrg ;; 8085 1.1 mrg esac 8086 1.1 mrg continue 8087 1.1 mrg ;; 8088 1.1 mrg prog) 8089 1.1 mrg if test link != "$pass"; then 8090 1.1 mrg deplibs="$deplib $deplibs" 8091 1.1 mrg else 8092 1.1 mrg compile_deplibs="$deplib $compile_deplibs" 8093 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs" 8094 1.1 mrg fi 8095 1.1 mrg continue 8096 1.1 mrg ;; 8097 1.1 mrg esac # linkmode 8098 1.1 mrg ;; # *.$libext 8099 1.1 mrg *.lo | *.$objext) 8100 1.1 mrg if test conv = "$pass"; then 8101 1.1 mrg deplibs="$deplib $deplibs" 8102 1.1 mrg elif test prog = "$linkmode"; then 8103 1.1 mrg if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then 8104 1.1 mrg # If there is no dlopen support or we're linking statically, 8105 1.1 mrg # we need to preload. 8106 1.1 mrg func_append newdlprefiles " $deplib" 8107 1.1 mrg compile_deplibs="$deplib $compile_deplibs" 8108 1.1 mrg finalize_deplibs="$deplib $finalize_deplibs" 8109 1.1 mrg else 8110 1.1 mrg func_append newdlfiles " $deplib" 8111 1.1 mrg fi 8112 1.1 mrg fi 8113 1.1 mrg continue 8114 1.1 mrg ;; 8115 1.1 mrg %DEPLIBS%) 8116 1.1 mrg alldeplibs=: 8117 1.1 mrg continue 8118 1.1 mrg ;; 8119 1.1 mrg esac # case $deplib 8120 1.1 mrg 8121 1.1 mrg $found || test -f "$lib" \ 8122 1.1 mrg || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'" 8123 1.1 mrg 8124 1.1 mrg # Check to see that this really is a libtool archive. 8125 1.1 mrg func_lalib_unsafe_p "$lib" \ 8126 1.1 mrg || func_fatal_error "'$lib' is not a valid libtool archive" 8127 1.1 mrg 8128 1.1 mrg func_dirname "$lib" "" "." 8129 1.1 mrg ladir=$func_dirname_result 8130 1.1 mrg 8131 1.1 mrg dlname= 8132 1.1 mrg dlopen= 8133 1.1 mrg dlpreopen= 8134 1.1 mrg libdir= 8135 1.1 mrg library_names= 8136 1.1 mrg old_library= 8137 1.1 mrg inherited_linker_flags= 8138 1.1 mrg # If the library was installed with an old release of libtool, 8139 1.1 mrg # it will not redefine variables installed, or shouldnotlink 8140 1.1 mrg installed=yes 8141 1.1 mrg shouldnotlink=no 8142 1.1 mrg avoidtemprpath= 8143 1.1 mrg 8144 1.1 mrg 8145 1.1 mrg # Read the .la file 8146 1.1 mrg func_source "$lib" 8147 1.1 mrg 8148 1.1 mrg # Convert "-framework foo" to "foo.ltframework" 8149 1.1 mrg if test -n "$inherited_linker_flags"; then 8150 1.1 mrg tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'` 8151 1.1 mrg for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do 8152 1.1 mrg case " $new_inherited_linker_flags " in 8153 1.1 mrg *" $tmp_inherited_linker_flag "*) ;; 8154 1.1 mrg *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";; 8155 1.1 mrg esac 8156 1.1 mrg done 8157 1.1 mrg fi 8158 1.1 mrg dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8159 1.1 mrg if test lib,link = "$linkmode,$pass" || 8160 1.1 mrg test prog,scan = "$linkmode,$pass" || 8161 1.1 mrg { test prog != "$linkmode" && test lib != "$linkmode"; }; then 8162 1.1 mrg test -n "$dlopen" && func_append dlfiles " $dlopen" 8163 1.1 mrg test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen" 8164 1.1 mrg fi 8165 1.1 mrg 8166 1.1 mrg if test conv = "$pass"; then 8167 1.1 mrg # Only check for convenience libraries 8168 1.1 mrg deplibs="$lib $deplibs" 8169 1.1 mrg if test -z "$libdir"; then 8170 1.1 mrg if test -z "$old_library"; then 8171 1.1 mrg func_fatal_error "cannot find name of link library for '$lib'" 8172 1.1 mrg fi 8173 1.1 mrg # It is a libtool convenience library, so add in its objects. 8174 1.1 mrg func_append convenience " $ladir/$objdir/$old_library" 8175 1.1 mrg func_append old_convenience " $ladir/$objdir/$old_library" 8176 1.1 mrg elif test prog != "$linkmode" && test lib != "$linkmode"; then 8177 1.1 mrg func_fatal_error "'$lib' is not a convenience library" 8178 1.1 mrg fi 8179 1.1 mrg tmp_libs= 8180 1.1 mrg for deplib in $dependency_libs; do 8181 1.1 mrg deplibs="$deplib $deplibs" 8182 1.1 mrg if $opt_preserve_dup_deps; then 8183 1.1 mrg case "$tmp_libs " in 8184 1.1 mrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8185 1.1 mrg esac 8186 1.1 mrg fi 8187 1.1 mrg func_append tmp_libs " $deplib" 8188 1.1 mrg done 8189 1.1 mrg continue 8190 1.1 mrg fi # $pass = conv 8191 1.1 mrg 8192 1.1 mrg 8193 1.1 mrg # Get the name of the library we link against. 8194 1.1 mrg linklib= 8195 1.1 mrg if test -n "$old_library" && 8196 1.1 mrg { test yes = "$prefer_static_libs" || 8197 1.1 mrg test built,no = "$prefer_static_libs,$installed"; }; then 8198 1.1 mrg linklib=$old_library 8199 1.1 mrg else 8200 1.1 mrg for l in $old_library $library_names; do 8201 1.1 mrg linklib=$l 8202 1.1 mrg done 8203 1.1 mrg fi 8204 1.1 mrg if test -z "$linklib"; then 8205 1.1 mrg func_fatal_error "cannot find name of link library for '$lib'" 8206 1.1 mrg fi 8207 1.1 mrg 8208 1.1 mrg # This library was specified with -dlopen. 8209 1.1 mrg if test dlopen = "$pass"; then 8210 1.1 mrg test -z "$libdir" \ 8211 1.1 mrg && func_fatal_error "cannot -dlopen a convenience library: '$lib'" 8212 1.1 mrg if test -z "$dlname" || 8213 1.1 mrg test yes != "$dlopen_support" || 8214 1.1 mrg test no = "$build_libtool_libs" 8215 1.1 mrg then 8216 1.1 mrg # If there is no dlname, no dlopen support or we're linking 8217 1.1 mrg # statically, we need to preload. We also need to preload any 8218 1.1 mrg # dependent libraries so libltdl's deplib preloader doesn't 8219 1.1 mrg # bomb out in the load deplibs phase. 8220 1.1 mrg func_append dlprefiles " $lib $dependency_libs" 8221 1.1 mrg else 8222 1.1 mrg func_append newdlfiles " $lib" 8223 1.1 mrg fi 8224 1.1 mrg continue 8225 1.1 mrg fi # $pass = dlopen 8226 1.1 mrg 8227 1.1 mrg # We need an absolute path. 8228 1.1 mrg case $ladir in 8229 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;; 8230 1.1 mrg *) 8231 1.1 mrg abs_ladir=`cd "$ladir" && pwd` 8232 1.1 mrg if test -z "$abs_ladir"; then 8233 1.1 mrg func_warning "cannot determine absolute directory name of '$ladir'" 8234 1.1 mrg func_warning "passing it literally to the linker, although it might fail" 8235 1.1 mrg abs_ladir=$ladir 8236 1.1 mrg fi 8237 1.1 mrg ;; 8238 1.1 mrg esac 8239 1.1 mrg func_basename "$lib" 8240 1.1 mrg laname=$func_basename_result 8241 1.1 mrg 8242 1.1 mrg # Find the relevant object directory and library name. 8243 1.1 mrg if test yes = "$installed"; then 8244 1.1 mrg if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8245 1.1 mrg func_warning "library '$lib' was moved." 8246 1.1 mrg dir=$ladir 8247 1.1 mrg absdir=$abs_ladir 8248 1.1 mrg libdir=$abs_ladir 8249 1.1 mrg else 8250 1.1 mrg dir=$lt_sysroot$libdir 8251 1.1 mrg absdir=$lt_sysroot$libdir 8252 1.1 mrg fi 8253 1.1 mrg test yes = "$hardcode_automatic" && avoidtemprpath=yes 8254 1.1 mrg else 8255 1.1 mrg if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then 8256 1.1 mrg dir=$ladir 8257 1.1 mrg absdir=$abs_ladir 8258 1.1 mrg # Remove this search path later 8259 1.1 mrg func_append notinst_path " $abs_ladir" 8260 1.1 mrg else 8261 1.1 mrg dir=$ladir/$objdir 8262 1.1 mrg absdir=$abs_ladir/$objdir 8263 1.1 mrg # Remove this search path later 8264 1.1 mrg func_append notinst_path " $abs_ladir" 8265 1.1 mrg fi 8266 1.1 mrg fi # $installed = yes 8267 1.1 mrg func_stripname 'lib' '.la' "$laname" 8268 1.1 mrg name=$func_stripname_result 8269 1.1 mrg 8270 1.1 mrg # This library was specified with -dlpreopen. 8271 1.1 mrg if test dlpreopen = "$pass"; then 8272 1.1 mrg if test -z "$libdir" && test prog = "$linkmode"; then 8273 1.1 mrg func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'" 8274 1.1 mrg fi 8275 1.1 mrg case $host in 8276 1.1 mrg # special handling for platforms with PE-DLLs. 8277 1.1 mrg *cygwin* | *mingw* | *cegcc* ) 8278 1.1 mrg # Linker will automatically link against shared library if both 8279 1.1 mrg # static and shared are present. Therefore, ensure we extract 8280 1.1 mrg # symbols from the import library if a shared library is present 8281 1.1 mrg # (otherwise, the dlopen module name will be incorrect). We do 8282 1.1 mrg # this by putting the import library name into $newdlprefiles. 8283 1.1 mrg # We recover the dlopen module name by 'saving' the la file 8284 1.1 mrg # name in a special purpose variable, and (later) extracting the 8285 1.1 mrg # dlname from the la file. 8286 1.1 mrg if test -n "$dlname"; then 8287 1.1 mrg func_tr_sh "$dir/$linklib" 8288 1.1 mrg eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname" 8289 1.1 mrg func_append newdlprefiles " $dir/$linklib" 8290 1.1 mrg else 8291 1.1 mrg func_append newdlprefiles " $dir/$old_library" 8292 1.1 mrg # Keep a list of preopened convenience libraries to check 8293 1.1 mrg # that they are being used correctly in the link pass. 8294 1.1 mrg test -z "$libdir" && \ 8295 1.1 mrg func_append dlpreconveniencelibs " $dir/$old_library" 8296 1.1 mrg fi 8297 1.1 mrg ;; 8298 1.1 mrg * ) 8299 1.1 mrg # Prefer using a static library (so that no silly _DYNAMIC symbols 8300 1.1 mrg # are required to link). 8301 1.1 mrg if test -n "$old_library"; then 8302 1.1 mrg func_append newdlprefiles " $dir/$old_library" 8303 1.1 mrg # Keep a list of preopened convenience libraries to check 8304 1.1 mrg # that they are being used correctly in the link pass. 8305 1.1 mrg test -z "$libdir" && \ 8306 1.1 mrg func_append dlpreconveniencelibs " $dir/$old_library" 8307 1.1 mrg # Otherwise, use the dlname, so that lt_dlopen finds it. 8308 1.1 mrg elif test -n "$dlname"; then 8309 1.1 mrg func_append newdlprefiles " $dir/$dlname" 8310 1.1 mrg else 8311 1.1 mrg func_append newdlprefiles " $dir/$linklib" 8312 1.1 mrg fi 8313 1.1 mrg ;; 8314 1.1 mrg esac 8315 1.1 mrg fi # $pass = dlpreopen 8316 1.1 mrg 8317 1.1 mrg if test -z "$libdir"; then 8318 1.1 mrg # Link the convenience library 8319 1.1 mrg if test lib = "$linkmode"; then 8320 1.1 mrg deplibs="$dir/$old_library $deplibs" 8321 1.1 mrg elif test prog,link = "$linkmode,$pass"; then 8322 1.1 mrg compile_deplibs="$dir/$old_library $compile_deplibs" 8323 1.1 mrg finalize_deplibs="$dir/$old_library $finalize_deplibs" 8324 1.1 mrg else 8325 1.1 mrg deplibs="$lib $deplibs" # used for prog,scan pass 8326 1.1 mrg fi 8327 1.1 mrg continue 8328 1.1 mrg fi 8329 1.1 mrg 8330 1.1 mrg 8331 1.1 mrg if test prog = "$linkmode" && test link != "$pass"; then 8332 1.1 mrg func_append newlib_search_path " $ladir" 8333 1.1 mrg deplibs="$lib $deplibs" 8334 1.1 mrg 8335 1.1 mrg linkalldeplibs=false 8336 1.1 mrg if test no != "$link_all_deplibs" || test -z "$library_names" || 8337 1.1 mrg test no = "$build_libtool_libs"; then 8338 1.1 mrg linkalldeplibs=: 8339 1.1 mrg fi 8340 1.1 mrg 8341 1.1 mrg tmp_libs= 8342 1.1 mrg for deplib in $dependency_libs; do 8343 1.1 mrg case $deplib in 8344 1.1 mrg -L*) func_stripname '-L' '' "$deplib" 8345 1.1 mrg func_resolve_sysroot "$func_stripname_result" 8346 1.1 mrg func_append newlib_search_path " $func_resolve_sysroot_result" 8347 1.1 mrg ;; 8348 1.1 mrg esac 8349 1.1 mrg # Need to link against all dependency_libs? 8350 1.1 mrg if $linkalldeplibs; then 8351 1.1 mrg deplibs="$deplib $deplibs" 8352 1.1 mrg else 8353 1.1 mrg # Need to hardcode shared library paths 8354 1.1 mrg # or/and link against static libraries 8355 1.1 mrg newdependency_libs="$deplib $newdependency_libs" 8356 1.1 mrg fi 8357 1.1 mrg if $opt_preserve_dup_deps; then 8358 1.1 mrg case "$tmp_libs " in 8359 1.1 mrg *" $deplib "*) func_append specialdeplibs " $deplib" ;; 8360 1.1 mrg esac 8361 1.1 mrg fi 8362 1.1 mrg func_append tmp_libs " $deplib" 8363 1.1 mrg done # for deplib 8364 1.1 mrg continue 8365 1.1 mrg fi # $linkmode = prog... 8366 1.1 mrg 8367 1.1 mrg if test prog,link = "$linkmode,$pass"; then 8368 1.1 mrg if test -n "$library_names" && 8369 1.1 mrg { { test no = "$prefer_static_libs" || 8370 1.1 mrg test built,yes = "$prefer_static_libs,$installed"; } || 8371 1.1 mrg test -z "$old_library"; }; then 8372 1.1 mrg # We need to hardcode the library path 8373 1.1 mrg if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then 8374 1.1 mrg # Make sure the rpath contains only unique directories. 8375 1.1 mrg case $temp_rpath: in 8376 1.1 mrg *"$absdir:"*) ;; 8377 1.1 mrg *) func_append temp_rpath "$absdir:" ;; 8378 1.1 mrg esac 8379 1.1 mrg fi 8380 1.1 mrg 8381 1.1 mrg # Hardcode the library path. 8382 1.1 mrg # Skip directories that are in the system default run-time 8383 1.1 mrg # search path. 8384 1.1 mrg case " $sys_lib_dlsearch_path " in 8385 1.1 mrg *" $absdir "*) ;; 8386 1.1 mrg *) 8387 1.1 mrg case "$compile_rpath " in 8388 1.1 mrg *" $absdir "*) ;; 8389 1.1 mrg *) func_append compile_rpath " $absdir" ;; 8390 1.1 mrg esac 8391 1.1 mrg ;; 8392 1.1 mrg esac 8393 1.1 mrg case " $sys_lib_dlsearch_path " in 8394 1.1 mrg *" $libdir "*) ;; 8395 1.1 mrg *) 8396 1.1 mrg case "$finalize_rpath " in 8397 1.1 mrg *" $libdir "*) ;; 8398 1.1 mrg *) func_append finalize_rpath " $libdir" ;; 8399 1.1 mrg esac 8400 1.1 mrg ;; 8401 1.1 mrg esac 8402 1.1 mrg fi # $linkmode,$pass = prog,link... 8403 1.1 mrg 8404 1.1 mrg if $alldeplibs && 8405 1.1 mrg { test pass_all = "$deplibs_check_method" || 8406 1.1 mrg { test yes = "$build_libtool_libs" && 8407 1.1 mrg test -n "$library_names"; }; }; then 8408 1.1 mrg # We only need to search for static libraries 8409 1.1 mrg continue 8410 1.1 mrg fi 8411 1.1 mrg fi 8412 1.1 mrg 8413 1.1 mrg link_static=no # Whether the deplib will be linked statically 8414 1.1 mrg use_static_libs=$prefer_static_libs 8415 1.1 mrg if test built = "$use_static_libs" && test yes = "$installed"; then 8416 1.1 mrg use_static_libs=no 8417 1.1 mrg fi 8418 1.1 mrg if test -n "$library_names" && 8419 1.1 mrg { test no = "$use_static_libs" || test -z "$old_library"; }; then 8420 1.1 mrg case $host in 8421 1.1 mrg *cygwin* | *mingw* | *cegcc* | *os2*) 8422 1.1 mrg # No point in relinking DLLs because paths are not encoded 8423 1.1 mrg func_append notinst_deplibs " $lib" 8424 1.1 mrg need_relink=no 8425 1.1 mrg ;; 8426 1.1 mrg *) 8427 1.1 mrg if test no = "$installed"; then 8428 1.1 mrg func_append notinst_deplibs " $lib" 8429 1.1 mrg need_relink=yes 8430 1.1 mrg fi 8431 1.1 mrg ;; 8432 1.1 mrg esac 8433 1.1 mrg # This is a shared library 8434 1.1 mrg 8435 1.1 mrg # Warn about portability, can't link against -module's on some 8436 1.1 mrg # systems (darwin). Don't bleat about dlopened modules though! 8437 1.1 mrg dlopenmodule= 8438 1.1 mrg for dlpremoduletest in $dlprefiles; do 8439 1.1 mrg if test "X$dlpremoduletest" = "X$lib"; then 8440 1.1 mrg dlopenmodule=$dlpremoduletest 8441 1.1 mrg break 8442 1.1 mrg fi 8443 1.1 mrg done 8444 1.1 mrg if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then 8445 1.1 mrg echo 8446 1.1 mrg if test prog = "$linkmode"; then 8447 1.1 mrg $ECHO "*** Warning: Linking the executable $output against the loadable module" 8448 1.1 mrg else 8449 1.1 mrg $ECHO "*** Warning: Linking the shared library $output against the loadable module" 8450 1.1 mrg fi 8451 1.1 mrg $ECHO "*** $linklib is not portable!" 8452 1.1 mrg fi 8453 1.1 mrg if test lib = "$linkmode" && 8454 1.1 mrg test yes = "$hardcode_into_libs"; then 8455 1.1 mrg # Hardcode the library path. 8456 1.1 mrg # Skip directories that are in the system default run-time 8457 1.1 mrg # search path. 8458 1.1 mrg case " $sys_lib_dlsearch_path " in 8459 1.1 mrg *" $absdir "*) ;; 8460 1.1 mrg *) 8461 1.1 mrg case "$compile_rpath " in 8462 1.1 mrg *" $absdir "*) ;; 8463 1.1 mrg *) func_append compile_rpath " $absdir" ;; 8464 1.1 mrg esac 8465 1.1 mrg ;; 8466 1.1 mrg esac 8467 1.1 mrg case " $sys_lib_dlsearch_path " in 8468 1.1 mrg *" $libdir "*) ;; 8469 1.1 mrg *) 8470 1.1 mrg case "$finalize_rpath " in 8471 1.1 mrg *" $libdir "*) ;; 8472 1.1 mrg *) func_append finalize_rpath " $libdir" ;; 8473 1.1 mrg esac 8474 1.1 mrg ;; 8475 1.1 mrg esac 8476 1.1 mrg fi 8477 1.1 mrg 8478 1.1 mrg if test -n "$old_archive_from_expsyms_cmds"; then 8479 1.1 mrg # figure out the soname 8480 1.1 mrg set dummy $library_names 8481 1.1 mrg shift 8482 1.1 mrg realname=$1 8483 1.1 mrg shift 8484 1.1 mrg libname=`eval "\\$ECHO \"$libname_spec\""` 8485 1.1 mrg # use dlname if we got it. it's perfectly good, no? 8486 1.1 mrg if test -n "$dlname"; then 8487 1.1 mrg soname=$dlname 8488 1.1 mrg elif test -n "$soname_spec"; then 8489 1.1 mrg # bleh windows 8490 1.1 mrg case $host in 8491 1.1 mrg *cygwin* | mingw* | *cegcc* | *os2*) 8492 1.1 mrg func_arith $current - $age 8493 1.1 mrg major=$func_arith_result 8494 1.1 mrg versuffix=-$major 8495 1.1 mrg ;; 8496 1.1 mrg esac 8497 1.1 mrg eval soname=\"$soname_spec\" 8498 1.1 mrg else 8499 1.1 mrg soname=$realname 8500 1.1 mrg fi 8501 1.1 mrg 8502 1.1 mrg # Make a new name for the extract_expsyms_cmds to use 8503 1.1 mrg soroot=$soname 8504 1.1 mrg func_basename "$soroot" 8505 1.1 mrg soname=$func_basename_result 8506 1.1 mrg func_stripname 'lib' '.dll' "$soname" 8507 1.1 mrg newlib=libimp-$func_stripname_result.a 8508 1.1 mrg 8509 1.1 mrg # If the library has no export list, then create one now 8510 1.1 mrg if test -f "$output_objdir/$soname-def"; then : 8511 1.1 mrg else 8512 1.1 mrg func_verbose "extracting exported symbol list from '$soname'" 8513 1.1 mrg func_execute_cmds "$extract_expsyms_cmds" 'exit $?' 8514 1.1 mrg fi 8515 1.1 mrg 8516 1.1 mrg # Create $newlib 8517 1.1 mrg if test -f "$output_objdir/$newlib"; then :; else 8518 1.1 mrg func_verbose "generating import library for '$soname'" 8519 1.1 mrg func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?' 8520 1.1 mrg fi 8521 1.1 mrg # make sure the library variables are pointing to the new library 8522 1.1 mrg dir=$output_objdir 8523 1.1 mrg linklib=$newlib 8524 1.1 mrg fi # test -n "$old_archive_from_expsyms_cmds" 8525 1.1 mrg 8526 1.1 mrg if test prog = "$linkmode" || test relink != "$opt_mode"; then 8527 1.1 mrg add_shlibpath= 8528 1.1 mrg add_dir= 8529 1.1 mrg add= 8530 1.1 mrg lib_linked=yes 8531 1.1 mrg case $hardcode_action in 8532 1.1 mrg immediate | unsupported) 8533 1.1 mrg if test no = "$hardcode_direct"; then 8534 1.1 mrg add=$dir/$linklib 8535 1.1 mrg case $host in 8536 1.1 mrg *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;; 8537 1.1 mrg *-*-sysv4*uw2*) add_dir=-L$dir ;; 8538 1.1 mrg *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \ 8539 1.1 mrg *-*-unixware7*) add_dir=-L$dir ;; 8540 1.1 mrg *-*-darwin* ) 8541 1.1 mrg # if the lib is a (non-dlopened) module then we cannot 8542 1.1 mrg # link against it, someone is ignoring the earlier warnings 8543 1.1 mrg if /usr/bin/file -L $add 2> /dev/null | 8544 1.1 mrg $GREP ": [^:]* bundle" >/dev/null; then 8545 1.1 mrg if test "X$dlopenmodule" != "X$lib"; then 8546 1.1 mrg $ECHO "*** Warning: lib $linklib is a module, not a shared library" 8547 1.1 mrg if test -z "$old_library"; then 8548 1.1 mrg echo 8549 1.1 mrg echo "*** And there doesn't seem to be a static archive available" 8550 1.1 mrg echo "*** The link will probably fail, sorry" 8551 1.1 mrg else 8552 1.1 mrg add=$dir/$old_library 8553 1.1 mrg fi 8554 1.1 mrg elif test -n "$old_library"; then 8555 1.1 mrg add=$dir/$old_library 8556 1.1 mrg fi 8557 1.1 mrg fi 8558 1.1 mrg esac 8559 1.1 mrg elif test no = "$hardcode_minus_L"; then 8560 1.1 mrg case $host in 8561 1.1 mrg *-*-sunos*) add_shlibpath=$dir ;; 8562 1.1 mrg esac 8563 1.1 mrg add_dir=-L$dir 8564 1.1 mrg add=-l$name 8565 1.1 mrg elif test no = "$hardcode_shlibpath_var"; then 8566 1.1 mrg add_shlibpath=$dir 8567 1.1 mrg add=-l$name 8568 1.1 mrg else 8569 1.1 mrg lib_linked=no 8570 1.1 mrg fi 8571 1.1 mrg ;; 8572 1.1 mrg relink) 8573 1.1 mrg if test yes = "$hardcode_direct" && 8574 1.1 mrg test no = "$hardcode_direct_absolute"; then 8575 1.1 mrg add=$dir/$linklib 8576 1.1 mrg elif test yes = "$hardcode_minus_L"; then 8577 1.1 mrg add_dir=-L$absdir 8578 1.1 mrg # Try looking first in the location we're being installed to. 8579 1.1 mrg if test -n "$inst_prefix_dir"; then 8580 1.1 mrg case $libdir in 8581 1.1 mrg [\\/]*) 8582 1.1 mrg func_append add_dir " -L$inst_prefix_dir$libdir" 8583 1.1 mrg ;; 8584 1.1 mrg esac 8585 1.1 mrg fi 8586 1.1 mrg add=-l$name 8587 1.1 mrg elif test yes = "$hardcode_shlibpath_var"; then 8588 1.1 mrg add_shlibpath=$dir 8589 1.1 mrg add=-l$name 8590 1.1 mrg else 8591 1.1 mrg lib_linked=no 8592 1.1 mrg fi 8593 1.1 mrg ;; 8594 1.1 mrg *) lib_linked=no ;; 8595 1.1 mrg esac 8596 1.1 mrg 8597 1.1 mrg if test yes != "$lib_linked"; then 8598 1.1 mrg func_fatal_configuration "unsupported hardcode properties" 8599 1.1 mrg fi 8600 1.1 mrg 8601 1.1 mrg if test -n "$add_shlibpath"; then 8602 1.1 mrg case :$compile_shlibpath: in 8603 1.1 mrg *":$add_shlibpath:"*) ;; 8604 1.1 mrg *) func_append compile_shlibpath "$add_shlibpath:" ;; 8605 1.1 mrg esac 8606 1.1 mrg fi 8607 1.1 mrg if test prog = "$linkmode"; then 8608 1.1 mrg test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs" 8609 1.1 mrg test -n "$add" && compile_deplibs="$add $compile_deplibs" 8610 1.1 mrg else 8611 1.1 mrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8612 1.1 mrg test -n "$add" && deplibs="$add $deplibs" 8613 1.1 mrg if test yes != "$hardcode_direct" && 8614 1.1 mrg test yes != "$hardcode_minus_L" && 8615 1.1 mrg test yes = "$hardcode_shlibpath_var"; then 8616 1.1 mrg case :$finalize_shlibpath: in 8617 1.1 mrg *":$libdir:"*) ;; 8618 1.1 mrg *) func_append finalize_shlibpath "$libdir:" ;; 8619 1.1 mrg esac 8620 1.1 mrg fi 8621 1.1 mrg fi 8622 1.1 mrg fi 8623 1.1 mrg 8624 1.1 mrg if test prog = "$linkmode" || test relink = "$opt_mode"; then 8625 1.1 mrg add_shlibpath= 8626 1.1 mrg add_dir= 8627 1.1 mrg add= 8628 1.1 mrg # Finalize command for both is simple: just hardcode it. 8629 1.1 mrg if test yes = "$hardcode_direct" && 8630 1.1 mrg test no = "$hardcode_direct_absolute"; then 8631 1.1 mrg add=$libdir/$linklib 8632 1.1 mrg elif test yes = "$hardcode_minus_L"; then 8633 1.1 mrg add_dir=-L$libdir 8634 1.1 mrg add=-l$name 8635 1.1 mrg elif test yes = "$hardcode_shlibpath_var"; then 8636 1.1 mrg case :$finalize_shlibpath: in 8637 1.1 mrg *":$libdir:"*) ;; 8638 1.1 mrg *) func_append finalize_shlibpath "$libdir:" ;; 8639 1.1 mrg esac 8640 1.1 mrg add=-l$name 8641 1.1 mrg elif test yes = "$hardcode_automatic"; then 8642 1.1 mrg if test -n "$inst_prefix_dir" && 8643 1.1 mrg test -f "$inst_prefix_dir$libdir/$linklib"; then 8644 1.1 mrg add=$inst_prefix_dir$libdir/$linklib 8645 1.1 mrg else 8646 1.1 mrg add=$libdir/$linklib 8647 1.1 mrg fi 8648 1.1 mrg else 8649 1.1 mrg # We cannot seem to hardcode it, guess we'll fake it. 8650 1.1 mrg add_dir=-L$libdir 8651 1.1 mrg # Try looking first in the location we're being installed to. 8652 1.1 mrg if test -n "$inst_prefix_dir"; then 8653 1.1 mrg case $libdir in 8654 1.1 mrg [\\/]*) 8655 1.1 mrg func_append add_dir " -L$inst_prefix_dir$libdir" 8656 1.1 mrg ;; 8657 1.1 mrg esac 8658 1.1 mrg fi 8659 1.1 mrg add=-l$name 8660 1.1 mrg fi 8661 1.1 mrg 8662 1.1 mrg if test prog = "$linkmode"; then 8663 1.1 mrg test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs" 8664 1.1 mrg test -n "$add" && finalize_deplibs="$add $finalize_deplibs" 8665 1.1 mrg else 8666 1.1 mrg test -n "$add_dir" && deplibs="$add_dir $deplibs" 8667 1.1 mrg test -n "$add" && deplibs="$add $deplibs" 8668 1.1 mrg fi 8669 1.1 mrg fi 8670 1.1 mrg elif test prog = "$linkmode"; then 8671 1.1 mrg # Here we assume that one of hardcode_direct or hardcode_minus_L 8672 1.1 mrg # is not unsupported. This is valid on all known static and 8673 1.1 mrg # shared platforms. 8674 1.1 mrg if test unsupported != "$hardcode_direct"; then 8675 1.1 mrg test -n "$old_library" && linklib=$old_library 8676 1.1 mrg compile_deplibs="$dir/$linklib $compile_deplibs" 8677 1.1 mrg finalize_deplibs="$dir/$linklib $finalize_deplibs" 8678 1.1 mrg else 8679 1.1 mrg compile_deplibs="-l$name -L$dir $compile_deplibs" 8680 1.1 mrg finalize_deplibs="-l$name -L$dir $finalize_deplibs" 8681 1.1 mrg fi 8682 1.1 mrg elif test yes = "$build_libtool_libs"; then 8683 1.1 mrg # Not a shared library 8684 1.1 mrg if test pass_all != "$deplibs_check_method"; then 8685 1.1 mrg # We're trying link a shared library against a static one 8686 1.1 mrg # but the system doesn't support it. 8687 1.1 mrg 8688 1.1 mrg # Just print a warning and add the library to dependency_libs so 8689 1.1 mrg # that the program can be linked against the static library. 8690 1.1 mrg echo 8691 1.1 mrg $ECHO "*** Warning: This system cannot link to static lib archive $lib." 8692 1.1 mrg echo "*** I have the capability to make that library automatically link in when" 8693 1.1 mrg echo "*** you link to this library. But I can only do this if you have a" 8694 1.1 mrg echo "*** shared version of the library, which you do not appear to have." 8695 1.1 mrg if test yes = "$module"; then 8696 1.1 mrg echo "*** But as you try to build a module library, libtool will still create " 8697 1.1 mrg echo "*** a static module, that should work as long as the dlopening application" 8698 1.1 mrg echo "*** is linked with the -dlopen flag to resolve symbols at runtime." 8699 1.1 mrg if test -z "$global_symbol_pipe"; then 8700 1.1 mrg echo 8701 1.1 mrg echo "*** However, this would only work if libtool was able to extract symbol" 8702 1.1 mrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 8703 1.1 mrg echo "*** not find such a program. So, this module is probably useless." 8704 1.1 mrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 8705 1.1 mrg fi 8706 1.1 mrg if test no = "$build_old_libs"; then 8707 1.1 mrg build_libtool_libs=module 8708 1.1 mrg build_old_libs=yes 8709 1.1 mrg else 8710 1.1 mrg build_libtool_libs=no 8711 1.1 mrg fi 8712 1.1 mrg fi 8713 1.1 mrg else 8714 1.1 mrg deplibs="$dir/$old_library $deplibs" 8715 1.1 mrg link_static=yes 8716 1.1 mrg fi 8717 1.1 mrg fi # link shared/static library? 8718 1.1 mrg 8719 1.1 mrg if test lib = "$linkmode"; then 8720 1.1 mrg if test -n "$dependency_libs" && 8721 1.1 mrg { test yes != "$hardcode_into_libs" || 8722 1.1 mrg test yes = "$build_old_libs" || 8723 1.1 mrg test yes = "$link_static"; }; then 8724 1.1 mrg # Extract -R from dependency_libs 8725 1.1 mrg temp_deplibs= 8726 1.1 mrg for libdir in $dependency_libs; do 8727 1.1 mrg case $libdir in 8728 1.1 mrg -R*) func_stripname '-R' '' "$libdir" 8729 1.1 mrg temp_xrpath=$func_stripname_result 8730 1.1 mrg case " $xrpath " in 8731 1.1 mrg *" $temp_xrpath "*) ;; 8732 1.1 mrg *) func_append xrpath " $temp_xrpath";; 8733 1.1 mrg esac;; 8734 1.1 mrg *) func_append temp_deplibs " $libdir";; 8735 1.1 mrg esac 8736 1.1 mrg done 8737 1.1 mrg dependency_libs=$temp_deplibs 8738 1.1 mrg fi 8739 1.1 mrg 8740 1.1 mrg func_append newlib_search_path " $absdir" 8741 1.1 mrg # Link against this library 8742 1.1 mrg test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs" 8743 1.1 mrg # ... and its dependency_libs 8744 1.1 mrg tmp_libs= 8745 1.1 mrg for deplib in $dependency_libs; do 8746 1.1 mrg newdependency_libs="$deplib $newdependency_libs" 8747 1.1 mrg case $deplib in 8748 1.1 mrg -L*) func_stripname '-L' '' "$deplib" 8749 1.1 mrg func_resolve_sysroot "$func_stripname_result";; 8750 1.1 mrg *) func_resolve_sysroot "$deplib" ;; 8751 1.1 mrg esac 8752 1.1 mrg if $opt_preserve_dup_deps; then 8753 1.1 mrg case "$tmp_libs " in 8754 1.1 mrg *" $func_resolve_sysroot_result "*) 8755 1.1 mrg func_append specialdeplibs " $func_resolve_sysroot_result" ;; 8756 1.1 mrg esac 8757 1.1 mrg fi 8758 1.1 mrg func_append tmp_libs " $func_resolve_sysroot_result" 8759 1.1 mrg done 8760 1.1 mrg 8761 1.1 mrg if test no != "$link_all_deplibs"; then 8762 1.1 mrg # Add the search paths of all dependency libraries 8763 1.1 mrg for deplib in $dependency_libs; do 8764 1.1 mrg path= 8765 1.1 mrg case $deplib in 8766 1.1 mrg -L*) path=$deplib ;; 8767 1.1 mrg *.la) 8768 1.1 mrg func_resolve_sysroot "$deplib" 8769 1.1 mrg deplib=$func_resolve_sysroot_result 8770 1.1 mrg func_dirname "$deplib" "" "." 8771 1.1 mrg dir=$func_dirname_result 8772 1.1 mrg # We need an absolute path. 8773 1.1 mrg case $dir in 8774 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;; 8775 1.1 mrg *) 8776 1.1 mrg absdir=`cd "$dir" && pwd` 8777 1.1 mrg if test -z "$absdir"; then 8778 1.1 mrg func_warning "cannot determine absolute directory name of '$dir'" 8779 1.1 mrg absdir=$dir 8780 1.1 mrg fi 8781 1.1 mrg ;; 8782 1.1 mrg esac 8783 1.1 mrg if $GREP "^installed=no" $deplib > /dev/null; then 8784 1.1 mrg case $host in 8785 1.1 mrg *-*-darwin*) 8786 1.1 mrg depdepl= 8787 1.1 mrg eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib` 8788 1.1 mrg if test -n "$deplibrary_names"; then 8789 1.1 mrg for tmp in $deplibrary_names; do 8790 1.1 mrg depdepl=$tmp 8791 1.1 mrg done 8792 1.1 mrg if test -f "$absdir/$objdir/$depdepl"; then 8793 1.1 mrg depdepl=$absdir/$objdir/$depdepl 8794 1.1 mrg darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8795 1.1 mrg if test -z "$darwin_install_name"; then 8796 1.1 mrg darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'` 8797 1.1 mrg fi 8798 1.1 mrg func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl" 8799 1.1 mrg func_append linker_flags " -dylib_file $darwin_install_name:$depdepl" 8800 1.1 mrg path= 8801 1.1 mrg fi 8802 1.1 mrg fi 8803 1.1 mrg ;; 8804 1.1 mrg *) 8805 1.1 mrg path=-L$absdir/$objdir 8806 1.1 mrg ;; 8807 1.1 mrg esac 8808 1.1 mrg else 8809 1.1 mrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib` 8810 1.1 mrg test -z "$libdir" && \ 8811 1.1 mrg func_fatal_error "'$deplib' is not a valid libtool archive" 8812 1.1 mrg test "$absdir" != "$libdir" && \ 8813 1.1 mrg func_warning "'$deplib' seems to be moved" 8814 1.1 mrg 8815 1.1 mrg path=-L$absdir 8816 1.1 mrg fi 8817 1.1 mrg ;; 8818 1.1 mrg esac 8819 1.1 mrg case " $deplibs " in 8820 1.1 mrg *" $path "*) ;; 8821 1.1 mrg *) deplibs="$path $deplibs" ;; 8822 1.1 mrg esac 8823 1.1 mrg done 8824 1.1 mrg fi # link_all_deplibs != no 8825 1.1 mrg fi # linkmode = lib 8826 1.1 mrg done # for deplib in $libs 8827 1.1 mrg if test link = "$pass"; then 8828 1.1 mrg if test prog = "$linkmode"; then 8829 1.1 mrg compile_deplibs="$new_inherited_linker_flags $compile_deplibs" 8830 1.1 mrg finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs" 8831 1.1 mrg else 8832 1.1 mrg compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 8833 1.1 mrg fi 8834 1.1 mrg fi 8835 1.1 mrg dependency_libs=$newdependency_libs 8836 1.1 mrg if test dlpreopen = "$pass"; then 8837 1.1 mrg # Link the dlpreopened libraries before other libraries 8838 1.1 mrg for deplib in $save_deplibs; do 8839 1.1 mrg deplibs="$deplib $deplibs" 8840 1.1 mrg done 8841 1.1 mrg fi 8842 1.1 mrg if test dlopen != "$pass"; then 8843 1.1 mrg test conv = "$pass" || { 8844 1.1 mrg # Make sure lib_search_path contains only unique directories. 8845 1.1 mrg lib_search_path= 8846 1.1 mrg for dir in $newlib_search_path; do 8847 1.1 mrg case "$lib_search_path " in 8848 1.1 mrg *" $dir "*) ;; 8849 1.1 mrg *) func_append lib_search_path " $dir" ;; 8850 1.1 mrg esac 8851 1.1 mrg done 8852 1.1 mrg newlib_search_path= 8853 1.1 mrg } 8854 1.1 mrg 8855 1.1 mrg if test prog,link = "$linkmode,$pass"; then 8856 1.1 mrg vars="compile_deplibs finalize_deplibs" 8857 1.1 mrg else 8858 1.1 mrg vars=deplibs 8859 1.1 mrg fi 8860 1.1 mrg for var in $vars dependency_libs; do 8861 1.1 mrg # Add libraries to $var in reverse order 8862 1.1 mrg eval tmp_libs=\"\$$var\" 8863 1.1 mrg new_libs= 8864 1.1 mrg for deplib in $tmp_libs; do 8865 1.1 mrg # FIXME: Pedantically, this is the right thing to do, so 8866 1.1 mrg # that some nasty dependency loop isn't accidentally 8867 1.1 mrg # broken: 8868 1.1 mrg #new_libs="$deplib $new_libs" 8869 1.1 mrg # Pragmatically, this seems to cause very few problems in 8870 1.1 mrg # practice: 8871 1.1 mrg case $deplib in 8872 1.1 mrg -L*) new_libs="$deplib $new_libs" ;; 8873 1.1 mrg -R*) ;; 8874 1.1 mrg *) 8875 1.1 mrg # And here is the reason: when a library appears more 8876 1.1 mrg # than once as an explicit dependence of a library, or 8877 1.1 mrg # is implicitly linked in more than once by the 8878 1.1 mrg # compiler, it is considered special, and multiple 8879 1.1 mrg # occurrences thereof are not removed. Compare this 8880 1.1 mrg # with having the same library being listed as a 8881 1.1 mrg # dependency of multiple other libraries: in this case, 8882 1.1 mrg # we know (pedantically, we assume) the library does not 8883 1.1 mrg # need to be listed more than once, so we keep only the 8884 1.1 mrg # last copy. This is not always right, but it is rare 8885 1.1 mrg # enough that we require users that really mean to play 8886 1.1 mrg # such unportable linking tricks to link the library 8887 1.1 mrg # using -Wl,-lname, so that libtool does not consider it 8888 1.1 mrg # for duplicate removal. 8889 1.1 mrg case " $specialdeplibs " in 8890 1.1 mrg *" $deplib "*) new_libs="$deplib $new_libs" ;; 8891 1.1 mrg *) 8892 1.1 mrg case " $new_libs " in 8893 1.1 mrg *" $deplib "*) ;; 8894 1.1 mrg *) new_libs="$deplib $new_libs" ;; 8895 1.1 mrg esac 8896 1.1 mrg ;; 8897 1.1 mrg esac 8898 1.1 mrg ;; 8899 1.1 mrg esac 8900 1.1 mrg done 8901 1.1 mrg tmp_libs= 8902 1.1 mrg for deplib in $new_libs; do 8903 1.1 mrg case $deplib in 8904 1.1 mrg -L*) 8905 1.1 mrg case " $tmp_libs " in 8906 1.1 mrg *" $deplib "*) ;; 8907 1.1 mrg *) func_append tmp_libs " $deplib" ;; 8908 1.1 mrg esac 8909 1.1 mrg ;; 8910 1.1 mrg *) func_append tmp_libs " $deplib" ;; 8911 1.1 mrg esac 8912 1.1 mrg done 8913 1.1 mrg eval $var=\"$tmp_libs\" 8914 1.1 mrg done # for var 8915 1.1 mrg fi 8916 1.1 mrg 8917 1.1 mrg # Add Sun CC postdeps if required: 8918 1.1 mrg test CXX = "$tagname" && { 8919 1.1 mrg case $host_os in 8920 1.1 mrg linux*) 8921 1.1.1.2 mrg case `$CC -V 2>&1 | $SED 5q` in 8922 1.1 mrg *Sun\ C*) # Sun C++ 5.9 8923 1.1 mrg func_suncc_cstd_abi 8924 1.1 mrg 8925 1.1 mrg if test no != "$suncc_use_cstd_abi"; then 8926 1.1 mrg func_append postdeps ' -library=Cstd -library=Crun' 8927 1.1 mrg fi 8928 1.1 mrg ;; 8929 1.1 mrg esac 8930 1.1 mrg ;; 8931 1.1 mrg 8932 1.1 mrg solaris*) 8933 1.1 mrg func_cc_basename "$CC" 8934 1.1 mrg case $func_cc_basename_result in 8935 1.1 mrg CC* | sunCC*) 8936 1.1 mrg func_suncc_cstd_abi 8937 1.1 mrg 8938 1.1 mrg if test no != "$suncc_use_cstd_abi"; then 8939 1.1 mrg func_append postdeps ' -library=Cstd -library=Crun' 8940 1.1 mrg fi 8941 1.1 mrg ;; 8942 1.1 mrg esac 8943 1.1 mrg ;; 8944 1.1 mrg esac 8945 1.1 mrg } 8946 1.1 mrg 8947 1.1 mrg # Last step: remove runtime libs from dependency_libs 8948 1.1 mrg # (they stay in deplibs) 8949 1.1 mrg tmp_libs= 8950 1.1 mrg for i in $dependency_libs; do 8951 1.1 mrg case " $predeps $postdeps $compiler_lib_search_path " in 8952 1.1 mrg *" $i "*) 8953 1.1 mrg i= 8954 1.1 mrg ;; 8955 1.1 mrg esac 8956 1.1 mrg if test -n "$i"; then 8957 1.1 mrg func_append tmp_libs " $i" 8958 1.1 mrg fi 8959 1.1 mrg done 8960 1.1 mrg dependency_libs=$tmp_libs 8961 1.1 mrg done # for pass 8962 1.1 mrg if test prog = "$linkmode"; then 8963 1.1 mrg dlfiles=$newdlfiles 8964 1.1 mrg fi 8965 1.1 mrg if test prog = "$linkmode" || test lib = "$linkmode"; then 8966 1.1 mrg dlprefiles=$newdlprefiles 8967 1.1 mrg fi 8968 1.1 mrg 8969 1.1 mrg case $linkmode in 8970 1.1 mrg oldlib) 8971 1.1 mrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 8972 1.1 mrg func_warning "'-dlopen' is ignored for archives" 8973 1.1 mrg fi 8974 1.1 mrg 8975 1.1 mrg case " $deplibs" in 8976 1.1 mrg *\ -l* | *\ -L*) 8977 1.1 mrg func_warning "'-l' and '-L' are ignored for archives" ;; 8978 1.1 mrg esac 8979 1.1 mrg 8980 1.1 mrg test -n "$rpath" && \ 8981 1.1 mrg func_warning "'-rpath' is ignored for archives" 8982 1.1 mrg 8983 1.1 mrg test -n "$xrpath" && \ 8984 1.1 mrg func_warning "'-R' is ignored for archives" 8985 1.1 mrg 8986 1.1 mrg test -n "$vinfo" && \ 8987 1.1 mrg func_warning "'-version-info/-version-number' is ignored for archives" 8988 1.1 mrg 8989 1.1 mrg test -n "$release" && \ 8990 1.1 mrg func_warning "'-release' is ignored for archives" 8991 1.1 mrg 8992 1.1 mrg test -n "$export_symbols$export_symbols_regex" && \ 8993 1.1 mrg func_warning "'-export-symbols' is ignored for archives" 8994 1.1 mrg 8995 1.1 mrg # Now set the variables for building old libraries. 8996 1.1 mrg build_libtool_libs=no 8997 1.1 mrg oldlibs=$output 8998 1.1 mrg func_append objs "$old_deplibs" 8999 1.1 mrg ;; 9000 1.1 mrg 9001 1.1 mrg lib) 9002 1.1 mrg # Make sure we only generate libraries of the form 'libNAME.la'. 9003 1.1 mrg case $outputname in 9004 1.1 mrg lib*) 9005 1.1 mrg func_stripname 'lib' '.la' "$outputname" 9006 1.1 mrg name=$func_stripname_result 9007 1.1 mrg eval shared_ext=\"$shrext_cmds\" 9008 1.1 mrg eval libname=\"$libname_spec\" 9009 1.1 mrg ;; 9010 1.1 mrg *) 9011 1.1 mrg test no = "$module" \ 9012 1.1 mrg && func_fatal_help "libtool library '$output' must begin with 'lib'" 9013 1.1 mrg 9014 1.1 mrg if test no != "$need_lib_prefix"; then 9015 1.1 mrg # Add the "lib" prefix for modules if required 9016 1.1 mrg func_stripname '' '.la' "$outputname" 9017 1.1 mrg name=$func_stripname_result 9018 1.1 mrg eval shared_ext=\"$shrext_cmds\" 9019 1.1 mrg eval libname=\"$libname_spec\" 9020 1.1 mrg else 9021 1.1 mrg func_stripname '' '.la' "$outputname" 9022 1.1 mrg libname=$func_stripname_result 9023 1.1 mrg fi 9024 1.1 mrg ;; 9025 1.1 mrg esac 9026 1.1 mrg 9027 1.1 mrg if test -n "$objs"; then 9028 1.1 mrg if test pass_all != "$deplibs_check_method"; then 9029 1.1 mrg func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs" 9030 1.1 mrg else 9031 1.1 mrg echo 9032 1.1 mrg $ECHO "*** Warning: Linking the shared library $output against the non-libtool" 9033 1.1 mrg $ECHO "*** objects $objs is not portable!" 9034 1.1 mrg func_append libobjs " $objs" 9035 1.1 mrg fi 9036 1.1 mrg fi 9037 1.1 mrg 9038 1.1 mrg test no = "$dlself" \ 9039 1.1 mrg || func_warning "'-dlopen self' is ignored for libtool libraries" 9040 1.1 mrg 9041 1.1 mrg set dummy $rpath 9042 1.1 mrg shift 9043 1.1 mrg test 1 -lt "$#" \ 9044 1.1 mrg && func_warning "ignoring multiple '-rpath's for a libtool library" 9045 1.1 mrg 9046 1.1 mrg install_libdir=$1 9047 1.1 mrg 9048 1.1 mrg oldlibs= 9049 1.1 mrg if test -z "$rpath"; then 9050 1.1 mrg if test yes = "$build_libtool_libs"; then 9051 1.1 mrg # Building a libtool convenience library. 9052 1.1 mrg # Some compilers have problems with a '.al' extension so 9053 1.1 mrg # convenience libraries should have the same extension an 9054 1.1 mrg # archive normally would. 9055 1.1 mrg oldlibs="$output_objdir/$libname.$libext $oldlibs" 9056 1.1 mrg build_libtool_libs=convenience 9057 1.1 mrg build_old_libs=yes 9058 1.1 mrg fi 9059 1.1 mrg 9060 1.1 mrg test -n "$vinfo" && \ 9061 1.1 mrg func_warning "'-version-info/-version-number' is ignored for convenience libraries" 9062 1.1 mrg 9063 1.1 mrg test -n "$release" && \ 9064 1.1 mrg func_warning "'-release' is ignored for convenience libraries" 9065 1.1 mrg else 9066 1.1 mrg 9067 1.1 mrg # Parse the version information argument. 9068 1.1 mrg save_ifs=$IFS; IFS=: 9069 1.1 mrg set dummy $vinfo 0 0 0 9070 1.1 mrg shift 9071 1.1 mrg IFS=$save_ifs 9072 1.1 mrg 9073 1.1 mrg test -n "$7" && \ 9074 1.1 mrg func_fatal_help "too many parameters to '-version-info'" 9075 1.1 mrg 9076 1.1 mrg # convert absolute version numbers to libtool ages 9077 1.1 mrg # this retains compatibility with .la files and attempts 9078 1.1 mrg # to make the code below a bit more comprehensible 9079 1.1 mrg 9080 1.1 mrg case $vinfo_number in 9081 1.1 mrg yes) 9082 1.1 mrg number_major=$1 9083 1.1 mrg number_minor=$2 9084 1.1 mrg number_revision=$3 9085 1.1 mrg # 9086 1.1 mrg # There are really only two kinds -- those that 9087 1.1 mrg # use the current revision as the major version 9088 1.1 mrg # and those that subtract age and use age as 9089 1.1 mrg # a minor version. But, then there is irix 9090 1.1 mrg # that has an extra 1 added just for fun 9091 1.1 mrg # 9092 1.1 mrg case $version_type in 9093 1.1 mrg # correct linux to gnu/linux during the next big refactor 9094 1.1.1.2 mrg darwin|freebsd-elf|linux|midnightbsd-elf|osf|windows|none) 9095 1.1 mrg func_arith $number_major + $number_minor 9096 1.1 mrg current=$func_arith_result 9097 1.1 mrg age=$number_minor 9098 1.1 mrg revision=$number_revision 9099 1.1 mrg ;; 9100 1.1 mrg freebsd-aout|qnx|sunos) 9101 1.1 mrg current=$number_major 9102 1.1 mrg revision=$number_minor 9103 1.1 mrg age=0 9104 1.1 mrg ;; 9105 1.1 mrg irix|nonstopux) 9106 1.1 mrg func_arith $number_major + $number_minor 9107 1.1 mrg current=$func_arith_result 9108 1.1 mrg age=$number_minor 9109 1.1 mrg revision=$number_minor 9110 1.1 mrg lt_irix_increment=no 9111 1.1 mrg ;; 9112 1.1 mrg esac 9113 1.1 mrg ;; 9114 1.1 mrg no) 9115 1.1 mrg current=$1 9116 1.1 mrg revision=$2 9117 1.1 mrg age=$3 9118 1.1 mrg ;; 9119 1.1 mrg esac 9120 1.1 mrg 9121 1.1 mrg # Check that each of the things are valid numbers. 9122 1.1 mrg case $current in 9123 1.1 mrg 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]) ;; 9124 1.1 mrg *) 9125 1.1 mrg func_error "CURRENT '$current' must be a nonnegative integer" 9126 1.1 mrg func_fatal_error "'$vinfo' is not valid version information" 9127 1.1 mrg ;; 9128 1.1 mrg esac 9129 1.1 mrg 9130 1.1 mrg case $revision in 9131 1.1 mrg 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]) ;; 9132 1.1 mrg *) 9133 1.1 mrg func_error "REVISION '$revision' must be a nonnegative integer" 9134 1.1 mrg func_fatal_error "'$vinfo' is not valid version information" 9135 1.1 mrg ;; 9136 1.1 mrg esac 9137 1.1 mrg 9138 1.1 mrg case $age in 9139 1.1 mrg 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]) ;; 9140 1.1 mrg *) 9141 1.1 mrg func_error "AGE '$age' must be a nonnegative integer" 9142 1.1 mrg func_fatal_error "'$vinfo' is not valid version information" 9143 1.1 mrg ;; 9144 1.1 mrg esac 9145 1.1 mrg 9146 1.1 mrg if test "$age" -gt "$current"; then 9147 1.1 mrg func_error "AGE '$age' is greater than the current interface number '$current'" 9148 1.1 mrg func_fatal_error "'$vinfo' is not valid version information" 9149 1.1 mrg fi 9150 1.1 mrg 9151 1.1 mrg # Calculate the version variables. 9152 1.1 mrg major= 9153 1.1 mrg versuffix= 9154 1.1 mrg verstring= 9155 1.1 mrg case $version_type in 9156 1.1 mrg none) ;; 9157 1.1 mrg 9158 1.1 mrg darwin) 9159 1.1 mrg # Like Linux, but with the current version available in 9160 1.1 mrg # verstring for coding it into the library header 9161 1.1 mrg func_arith $current - $age 9162 1.1 mrg major=.$func_arith_result 9163 1.1 mrg versuffix=$major.$age.$revision 9164 1.1 mrg # Darwin ld doesn't like 0 for these options... 9165 1.1 mrg func_arith $current + 1 9166 1.1 mrg minor_current=$func_arith_result 9167 1.1 mrg xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9168 1.1 mrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9169 1.1 mrg # On Darwin other compilers 9170 1.1 mrg case $CC in 9171 1.1 mrg nagfor*) 9172 1.1 mrg verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision" 9173 1.1 mrg ;; 9174 1.1 mrg *) 9175 1.1 mrg verstring="-compatibility_version $minor_current -current_version $minor_current.$revision" 9176 1.1 mrg ;; 9177 1.1 mrg esac 9178 1.1 mrg ;; 9179 1.1 mrg 9180 1.1 mrg freebsd-aout) 9181 1.1 mrg major=.$current 9182 1.1 mrg versuffix=.$current.$revision 9183 1.1 mrg ;; 9184 1.1 mrg 9185 1.1.1.2 mrg freebsd-elf | midnightbsd-elf) 9186 1.1 mrg func_arith $current - $age 9187 1.1 mrg major=.$func_arith_result 9188 1.1 mrg versuffix=$major.$age.$revision 9189 1.1 mrg ;; 9190 1.1 mrg 9191 1.1 mrg irix | nonstopux) 9192 1.1 mrg if test no = "$lt_irix_increment"; then 9193 1.1 mrg func_arith $current - $age 9194 1.1 mrg else 9195 1.1 mrg func_arith $current - $age + 1 9196 1.1 mrg fi 9197 1.1 mrg major=$func_arith_result 9198 1.1 mrg 9199 1.1 mrg case $version_type in 9200 1.1 mrg nonstopux) verstring_prefix=nonstopux ;; 9201 1.1 mrg *) verstring_prefix=sgi ;; 9202 1.1 mrg esac 9203 1.1 mrg verstring=$verstring_prefix$major.$revision 9204 1.1 mrg 9205 1.1 mrg # Add in all the interfaces that we are compatible with. 9206 1.1 mrg loop=$revision 9207 1.1 mrg while test 0 -ne "$loop"; do 9208 1.1 mrg func_arith $revision - $loop 9209 1.1 mrg iface=$func_arith_result 9210 1.1 mrg func_arith $loop - 1 9211 1.1 mrg loop=$func_arith_result 9212 1.1 mrg verstring=$verstring_prefix$major.$iface:$verstring 9213 1.1 mrg done 9214 1.1 mrg 9215 1.1 mrg # Before this point, $major must not contain '.'. 9216 1.1 mrg major=.$major 9217 1.1 mrg versuffix=$major.$revision 9218 1.1 mrg ;; 9219 1.1 mrg 9220 1.1 mrg linux) # correct to gnu/linux during the next big refactor 9221 1.1 mrg func_arith $current - $age 9222 1.1 mrg major=.$func_arith_result 9223 1.1 mrg versuffix=$major.$age.$revision 9224 1.1 mrg ;; 9225 1.1 mrg 9226 1.1 mrg osf) 9227 1.1 mrg func_arith $current - $age 9228 1.1 mrg major=.$func_arith_result 9229 1.1 mrg versuffix=.$current.$age.$revision 9230 1.1 mrg verstring=$current.$age.$revision 9231 1.1 mrg 9232 1.1 mrg # Add in all the interfaces that we are compatible with. 9233 1.1 mrg loop=$age 9234 1.1 mrg while test 0 -ne "$loop"; do 9235 1.1 mrg func_arith $current - $loop 9236 1.1 mrg iface=$func_arith_result 9237 1.1 mrg func_arith $loop - 1 9238 1.1 mrg loop=$func_arith_result 9239 1.1 mrg verstring=$verstring:$iface.0 9240 1.1 mrg done 9241 1.1 mrg 9242 1.1 mrg # Make executables depend on our current version. 9243 1.1 mrg func_append verstring ":$current.0" 9244 1.1 mrg ;; 9245 1.1 mrg 9246 1.1 mrg qnx) 9247 1.1 mrg major=.$current 9248 1.1 mrg versuffix=.$current 9249 1.1 mrg ;; 9250 1.1 mrg 9251 1.1 mrg sco) 9252 1.1 mrg major=.$current 9253 1.1 mrg versuffix=.$current 9254 1.1 mrg ;; 9255 1.1 mrg 9256 1.1 mrg sunos) 9257 1.1 mrg major=.$current 9258 1.1 mrg versuffix=.$current.$revision 9259 1.1 mrg ;; 9260 1.1 mrg 9261 1.1 mrg windows) 9262 1.1 mrg # Use '-' rather than '.', since we only want one 9263 1.1 mrg # extension on DOS 8.3 file systems. 9264 1.1 mrg func_arith $current - $age 9265 1.1 mrg major=$func_arith_result 9266 1.1 mrg versuffix=-$major 9267 1.1 mrg ;; 9268 1.1 mrg 9269 1.1 mrg *) 9270 1.1 mrg func_fatal_configuration "unknown library version type '$version_type'" 9271 1.1 mrg ;; 9272 1.1 mrg esac 9273 1.1 mrg 9274 1.1 mrg # Clear the version info if we defaulted, and they specified a release. 9275 1.1 mrg if test -z "$vinfo" && test -n "$release"; then 9276 1.1 mrg major= 9277 1.1 mrg case $version_type in 9278 1.1 mrg darwin) 9279 1.1 mrg # we can't check for "0.0" in archive_cmds due to quoting 9280 1.1 mrg # problems, so we reset it completely 9281 1.1 mrg verstring= 9282 1.1 mrg ;; 9283 1.1 mrg *) 9284 1.1 mrg verstring=0.0 9285 1.1 mrg ;; 9286 1.1 mrg esac 9287 1.1 mrg if test no = "$need_version"; then 9288 1.1 mrg versuffix= 9289 1.1 mrg else 9290 1.1 mrg versuffix=.0.0 9291 1.1 mrg fi 9292 1.1 mrg fi 9293 1.1 mrg 9294 1.1 mrg # Remove version info from name if versioning should be avoided 9295 1.1 mrg if test yes,no = "$avoid_version,$need_version"; then 9296 1.1 mrg major= 9297 1.1 mrg versuffix= 9298 1.1 mrg verstring= 9299 1.1 mrg fi 9300 1.1 mrg 9301 1.1 mrg # Check to see if the archive will have undefined symbols. 9302 1.1 mrg if test yes = "$allow_undefined"; then 9303 1.1 mrg if test unsupported = "$allow_undefined_flag"; then 9304 1.1 mrg if test yes = "$build_old_libs"; then 9305 1.1 mrg func_warning "undefined symbols not allowed in $host shared libraries; building static only" 9306 1.1 mrg build_libtool_libs=no 9307 1.1 mrg else 9308 1.1 mrg func_fatal_error "can't build $host shared library unless -no-undefined is specified" 9309 1.1 mrg fi 9310 1.1 mrg fi 9311 1.1 mrg else 9312 1.1 mrg # Don't allow undefined symbols. 9313 1.1 mrg allow_undefined_flag=$no_undefined_flag 9314 1.1 mrg fi 9315 1.1 mrg 9316 1.1 mrg fi 9317 1.1 mrg 9318 1.1 mrg func_generate_dlsyms "$libname" "$libname" : 9319 1.1 mrg func_append libobjs " $symfileobj" 9320 1.1 mrg test " " = "$libobjs" && libobjs= 9321 1.1 mrg 9322 1.1 mrg if test relink != "$opt_mode"; then 9323 1.1 mrg # Remove our outputs, but don't remove object files since they 9324 1.1 mrg # may have been created when compiling PIC objects. 9325 1.1 mrg removelist= 9326 1.1 mrg tempremovelist=`$ECHO "$output_objdir/*"` 9327 1.1 mrg for p in $tempremovelist; do 9328 1.1 mrg case $p in 9329 1.1 mrg *.$objext | *.gcno) 9330 1.1 mrg ;; 9331 1.1 mrg $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*) 9332 1.1 mrg if test -n "$precious_files_regex"; then 9333 1.1 mrg if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1 9334 1.1 mrg then 9335 1.1 mrg continue 9336 1.1 mrg fi 9337 1.1 mrg fi 9338 1.1 mrg func_append removelist " $p" 9339 1.1 mrg ;; 9340 1.1 mrg *) ;; 9341 1.1 mrg esac 9342 1.1 mrg done 9343 1.1 mrg test -n "$removelist" && \ 9344 1.1 mrg func_show_eval "${RM}r \$removelist" 9345 1.1 mrg fi 9346 1.1 mrg 9347 1.1 mrg # Now set the variables for building old libraries. 9348 1.1 mrg if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then 9349 1.1 mrg func_append oldlibs " $output_objdir/$libname.$libext" 9350 1.1 mrg 9351 1.1 mrg # Transform .lo files to .o files. 9352 1.1 mrg oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP` 9353 1.1 mrg fi 9354 1.1 mrg 9355 1.1 mrg # Eliminate all temporary directories. 9356 1.1 mrg #for path in $notinst_path; do 9357 1.1 mrg # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"` 9358 1.1 mrg # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"` 9359 1.1 mrg # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"` 9360 1.1 mrg #done 9361 1.1 mrg 9362 1.1 mrg if test -n "$xrpath"; then 9363 1.1 mrg # If the user specified any rpath flags, then add them. 9364 1.1 mrg temp_xrpath= 9365 1.1 mrg for libdir in $xrpath; do 9366 1.1 mrg func_replace_sysroot "$libdir" 9367 1.1 mrg func_append temp_xrpath " -R$func_replace_sysroot_result" 9368 1.1 mrg case "$finalize_rpath " in 9369 1.1 mrg *" $libdir "*) ;; 9370 1.1 mrg *) func_append finalize_rpath " $libdir" ;; 9371 1.1 mrg esac 9372 1.1 mrg done 9373 1.1 mrg if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then 9374 1.1 mrg dependency_libs="$temp_xrpath $dependency_libs" 9375 1.1 mrg fi 9376 1.1 mrg fi 9377 1.1 mrg 9378 1.1 mrg # Make sure dlfiles contains only unique files that won't be dlpreopened 9379 1.1 mrg old_dlfiles=$dlfiles 9380 1.1 mrg dlfiles= 9381 1.1 mrg for lib in $old_dlfiles; do 9382 1.1 mrg case " $dlprefiles $dlfiles " in 9383 1.1 mrg *" $lib "*) ;; 9384 1.1 mrg *) func_append dlfiles " $lib" ;; 9385 1.1 mrg esac 9386 1.1 mrg done 9387 1.1 mrg 9388 1.1 mrg # Make sure dlprefiles contains only unique files 9389 1.1 mrg old_dlprefiles=$dlprefiles 9390 1.1 mrg dlprefiles= 9391 1.1 mrg for lib in $old_dlprefiles; do 9392 1.1 mrg case "$dlprefiles " in 9393 1.1 mrg *" $lib "*) ;; 9394 1.1 mrg *) func_append dlprefiles " $lib" ;; 9395 1.1 mrg esac 9396 1.1 mrg done 9397 1.1 mrg 9398 1.1 mrg if test yes = "$build_libtool_libs"; then 9399 1.1 mrg if test -n "$rpath"; then 9400 1.1 mrg case $host in 9401 1.1 mrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*) 9402 1.1 mrg # these systems don't actually have a c library (as such)! 9403 1.1 mrg ;; 9404 1.1 mrg *-*-rhapsody* | *-*-darwin1.[012]) 9405 1.1 mrg # Rhapsody C library is in the System framework 9406 1.1 mrg func_append deplibs " System.ltframework" 9407 1.1 mrg ;; 9408 1.1 mrg *-*-netbsd*) 9409 1.1 mrg # Don't link with libc until the a.out ld.so is fixed. 9410 1.1 mrg ;; 9411 1.1.1.2 mrg *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*) 9412 1.1 mrg # Do not include libc due to us having libc/libc_r. 9413 1.1 mrg ;; 9414 1.1 mrg *-*-sco3.2v5* | *-*-sco5v6*) 9415 1.1 mrg # Causes problems with __ctype 9416 1.1 mrg ;; 9417 1.1 mrg *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*) 9418 1.1 mrg # Compiler inserts libc in the correct place for threads to work 9419 1.1 mrg ;; 9420 1.1 mrg *) 9421 1.1 mrg # Add libc to deplibs on all other systems if necessary. 9422 1.1 mrg if test yes = "$build_libtool_need_lc"; then 9423 1.1 mrg func_append deplibs " -lc" 9424 1.1 mrg fi 9425 1.1 mrg ;; 9426 1.1 mrg esac 9427 1.1 mrg fi 9428 1.1 mrg 9429 1.1 mrg # Transform deplibs into only deplibs that can be linked in shared. 9430 1.1 mrg name_save=$name 9431 1.1 mrg libname_save=$libname 9432 1.1 mrg release_save=$release 9433 1.1 mrg versuffix_save=$versuffix 9434 1.1 mrg major_save=$major 9435 1.1 mrg # I'm not sure if I'm treating the release correctly. I think 9436 1.1 mrg # release should show up in the -l (ie -lgmp5) so we don't want to 9437 1.1 mrg # add it in twice. Is that correct? 9438 1.1 mrg release= 9439 1.1 mrg versuffix= 9440 1.1 mrg major= 9441 1.1 mrg newdeplibs= 9442 1.1 mrg droppeddeps=no 9443 1.1 mrg case $deplibs_check_method in 9444 1.1 mrg pass_all) 9445 1.1 mrg # Don't check for shared/static. Everything works. 9446 1.1 mrg # This might be a little naive. We might want to check 9447 1.1 mrg # whether the library exists or not. But this is on 9448 1.1 mrg # osf3 & osf4 and I'm not really sure... Just 9449 1.1 mrg # implementing what was already the behavior. 9450 1.1 mrg newdeplibs=$deplibs 9451 1.1 mrg ;; 9452 1.1 mrg test_compile) 9453 1.1 mrg # This code stresses the "libraries are programs" paradigm to its 9454 1.1 mrg # limits. Maybe even breaks it. We compile a program, linking it 9455 1.1 mrg # against the deplibs as a proxy for the library. Then we can check 9456 1.1 mrg # whether they linked in statically or dynamically with ldd. 9457 1.1 mrg $opt_dry_run || $RM conftest.c 9458 1.1 mrg cat > conftest.c <<EOF 9459 1.1 mrg int main() { return 0; } 9460 1.1 mrg EOF 9461 1.1 mrg $opt_dry_run || $RM conftest 9462 1.1 mrg if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then 9463 1.1 mrg ldd_output=`ldd conftest` 9464 1.1 mrg for i in $deplibs; do 9465 1.1 mrg case $i in 9466 1.1 mrg -l*) 9467 1.1 mrg func_stripname -l '' "$i" 9468 1.1 mrg name=$func_stripname_result 9469 1.1 mrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9470 1.1 mrg case " $predeps $postdeps " in 9471 1.1 mrg *" $i "*) 9472 1.1 mrg func_append newdeplibs " $i" 9473 1.1 mrg i= 9474 1.1 mrg ;; 9475 1.1 mrg esac 9476 1.1 mrg fi 9477 1.1 mrg if test -n "$i"; then 9478 1.1 mrg libname=`eval "\\$ECHO \"$libname_spec\""` 9479 1.1 mrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9480 1.1 mrg set dummy $deplib_matches; shift 9481 1.1 mrg deplib_match=$1 9482 1.1 mrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9483 1.1 mrg func_append newdeplibs " $i" 9484 1.1 mrg else 9485 1.1 mrg droppeddeps=yes 9486 1.1 mrg echo 9487 1.1 mrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9488 1.1 mrg echo "*** I have the capability to make that library automatically link in when" 9489 1.1 mrg echo "*** you link to this library. But I can only do this if you have a" 9490 1.1 mrg echo "*** shared version of the library, which I believe you do not have" 9491 1.1 mrg echo "*** because a test_compile did reveal that the linker did not use it for" 9492 1.1 mrg echo "*** its dynamic dependency list that programs get resolved with at runtime." 9493 1.1 mrg fi 9494 1.1 mrg fi 9495 1.1 mrg ;; 9496 1.1 mrg *) 9497 1.1 mrg func_append newdeplibs " $i" 9498 1.1 mrg ;; 9499 1.1 mrg esac 9500 1.1 mrg done 9501 1.1 mrg else 9502 1.1 mrg # Error occurred in the first compile. Let's try to salvage 9503 1.1 mrg # the situation: Compile a separate program for each library. 9504 1.1 mrg for i in $deplibs; do 9505 1.1 mrg case $i in 9506 1.1 mrg -l*) 9507 1.1 mrg func_stripname -l '' "$i" 9508 1.1 mrg name=$func_stripname_result 9509 1.1 mrg $opt_dry_run || $RM conftest 9510 1.1 mrg if $LTCC $LTCFLAGS -o conftest conftest.c $i; then 9511 1.1 mrg ldd_output=`ldd conftest` 9512 1.1 mrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9513 1.1 mrg case " $predeps $postdeps " in 9514 1.1 mrg *" $i "*) 9515 1.1 mrg func_append newdeplibs " $i" 9516 1.1 mrg i= 9517 1.1 mrg ;; 9518 1.1 mrg esac 9519 1.1 mrg fi 9520 1.1 mrg if test -n "$i"; then 9521 1.1 mrg libname=`eval "\\$ECHO \"$libname_spec\""` 9522 1.1 mrg deplib_matches=`eval "\\$ECHO \"$library_names_spec\""` 9523 1.1 mrg set dummy $deplib_matches; shift 9524 1.1 mrg deplib_match=$1 9525 1.1 mrg if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0; then 9526 1.1 mrg func_append newdeplibs " $i" 9527 1.1 mrg else 9528 1.1 mrg droppeddeps=yes 9529 1.1 mrg echo 9530 1.1 mrg $ECHO "*** Warning: dynamic linker does not accept needed library $i." 9531 1.1 mrg echo "*** I have the capability to make that library automatically link in when" 9532 1.1 mrg echo "*** you link to this library. But I can only do this if you have a" 9533 1.1 mrg echo "*** shared version of the library, which you do not appear to have" 9534 1.1 mrg echo "*** because a test_compile did reveal that the linker did not use this one" 9535 1.1 mrg echo "*** as a dynamic dependency that programs can get resolved with at runtime." 9536 1.1 mrg fi 9537 1.1 mrg fi 9538 1.1 mrg else 9539 1.1 mrg droppeddeps=yes 9540 1.1 mrg echo 9541 1.1 mrg $ECHO "*** Warning! Library $i is needed by this library but I was not able to" 9542 1.1 mrg echo "*** make it link in! You will probably need to install it or some" 9543 1.1 mrg echo "*** library that it depends on before this library will be fully" 9544 1.1 mrg echo "*** functional. Installing it before continuing would be even better." 9545 1.1 mrg fi 9546 1.1 mrg ;; 9547 1.1 mrg *) 9548 1.1 mrg func_append newdeplibs " $i" 9549 1.1 mrg ;; 9550 1.1 mrg esac 9551 1.1 mrg done 9552 1.1 mrg fi 9553 1.1 mrg ;; 9554 1.1 mrg file_magic*) 9555 1.1 mrg set dummy $deplibs_check_method; shift 9556 1.1 mrg file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9557 1.1 mrg for a_deplib in $deplibs; do 9558 1.1 mrg case $a_deplib in 9559 1.1 mrg -l*) 9560 1.1 mrg func_stripname -l '' "$a_deplib" 9561 1.1 mrg name=$func_stripname_result 9562 1.1 mrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9563 1.1 mrg case " $predeps $postdeps " in 9564 1.1 mrg *" $a_deplib "*) 9565 1.1 mrg func_append newdeplibs " $a_deplib" 9566 1.1 mrg a_deplib= 9567 1.1 mrg ;; 9568 1.1 mrg esac 9569 1.1 mrg fi 9570 1.1 mrg if test -n "$a_deplib"; then 9571 1.1 mrg libname=`eval "\\$ECHO \"$libname_spec\""` 9572 1.1 mrg if test -n "$file_magic_glob"; then 9573 1.1 mrg libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob` 9574 1.1 mrg else 9575 1.1 mrg libnameglob=$libname 9576 1.1 mrg fi 9577 1.1 mrg test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob` 9578 1.1 mrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9579 1.1 mrg if test yes = "$want_nocaseglob"; then 9580 1.1 mrg shopt -s nocaseglob 9581 1.1 mrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9582 1.1 mrg $nocaseglob 9583 1.1 mrg else 9584 1.1 mrg potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null` 9585 1.1 mrg fi 9586 1.1 mrg for potent_lib in $potential_libs; do 9587 1.1 mrg # Follow soft links. 9588 1.1 mrg if ls -lLd "$potent_lib" 2>/dev/null | 9589 1.1 mrg $GREP " -> " >/dev/null; then 9590 1.1 mrg continue 9591 1.1 mrg fi 9592 1.1 mrg # The statement above tries to avoid entering an 9593 1.1 mrg # endless loop below, in case of cyclic links. 9594 1.1 mrg # We might still enter an endless loop, since a link 9595 1.1 mrg # loop can be closed while we follow links, 9596 1.1 mrg # but so what? 9597 1.1 mrg potlib=$potent_lib 9598 1.1 mrg while test -h "$potlib" 2>/dev/null; do 9599 1.1 mrg potliblink=`ls -ld $potlib | $SED 's/.* -> //'` 9600 1.1 mrg case $potliblink in 9601 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;; 9602 1.1 mrg *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";; 9603 1.1 mrg esac 9604 1.1 mrg done 9605 1.1 mrg if eval $file_magic_cmd \"\$potlib\" 2>/dev/null | 9606 1.1 mrg $SED -e 10q | 9607 1.1 mrg $EGREP "$file_magic_regex" > /dev/null; then 9608 1.1 mrg func_append newdeplibs " $a_deplib" 9609 1.1 mrg a_deplib= 9610 1.1 mrg break 2 9611 1.1 mrg fi 9612 1.1 mrg done 9613 1.1 mrg done 9614 1.1 mrg fi 9615 1.1 mrg if test -n "$a_deplib"; then 9616 1.1 mrg droppeddeps=yes 9617 1.1 mrg echo 9618 1.1 mrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9619 1.1 mrg echo "*** I have the capability to make that library automatically link in when" 9620 1.1 mrg echo "*** you link to this library. But I can only do this if you have a" 9621 1.1 mrg echo "*** shared version of the library, which you do not appear to have" 9622 1.1 mrg echo "*** because I did check the linker path looking for a file starting" 9623 1.1 mrg if test -z "$potlib"; then 9624 1.1 mrg $ECHO "*** with $libname but no candidates were found. (...for file magic test)" 9625 1.1 mrg else 9626 1.1 mrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9627 1.1 mrg $ECHO "*** using a file magic. Last file checked: $potlib" 9628 1.1 mrg fi 9629 1.1 mrg fi 9630 1.1 mrg ;; 9631 1.1 mrg *) 9632 1.1 mrg # Add a -L argument. 9633 1.1 mrg func_append newdeplibs " $a_deplib" 9634 1.1 mrg ;; 9635 1.1 mrg esac 9636 1.1 mrg done # Gone through all deplibs. 9637 1.1 mrg ;; 9638 1.1 mrg match_pattern*) 9639 1.1 mrg set dummy $deplibs_check_method; shift 9640 1.1 mrg match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"` 9641 1.1 mrg for a_deplib in $deplibs; do 9642 1.1 mrg case $a_deplib in 9643 1.1 mrg -l*) 9644 1.1 mrg func_stripname -l '' "$a_deplib" 9645 1.1 mrg name=$func_stripname_result 9646 1.1 mrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9647 1.1 mrg case " $predeps $postdeps " in 9648 1.1 mrg *" $a_deplib "*) 9649 1.1 mrg func_append newdeplibs " $a_deplib" 9650 1.1 mrg a_deplib= 9651 1.1 mrg ;; 9652 1.1 mrg esac 9653 1.1 mrg fi 9654 1.1 mrg if test -n "$a_deplib"; then 9655 1.1 mrg libname=`eval "\\$ECHO \"$libname_spec\""` 9656 1.1 mrg for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do 9657 1.1 mrg potential_libs=`ls $i/$libname[.-]* 2>/dev/null` 9658 1.1 mrg for potent_lib in $potential_libs; do 9659 1.1 mrg potlib=$potent_lib # see symlink-check above in file_magic test 9660 1.1 mrg if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \ 9661 1.1 mrg $EGREP "$match_pattern_regex" > /dev/null; then 9662 1.1 mrg func_append newdeplibs " $a_deplib" 9663 1.1 mrg a_deplib= 9664 1.1 mrg break 2 9665 1.1 mrg fi 9666 1.1 mrg done 9667 1.1 mrg done 9668 1.1 mrg fi 9669 1.1 mrg if test -n "$a_deplib"; then 9670 1.1 mrg droppeddeps=yes 9671 1.1 mrg echo 9672 1.1 mrg $ECHO "*** Warning: linker path does not have real file for library $a_deplib." 9673 1.1 mrg echo "*** I have the capability to make that library automatically link in when" 9674 1.1 mrg echo "*** you link to this library. But I can only do this if you have a" 9675 1.1 mrg echo "*** shared version of the library, which you do not appear to have" 9676 1.1 mrg echo "*** because I did check the linker path looking for a file starting" 9677 1.1 mrg if test -z "$potlib"; then 9678 1.1 mrg $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)" 9679 1.1 mrg else 9680 1.1 mrg $ECHO "*** with $libname and none of the candidates passed a file format test" 9681 1.1 mrg $ECHO "*** using a regex pattern. Last file checked: $potlib" 9682 1.1 mrg fi 9683 1.1 mrg fi 9684 1.1 mrg ;; 9685 1.1 mrg *) 9686 1.1 mrg # Add a -L argument. 9687 1.1 mrg func_append newdeplibs " $a_deplib" 9688 1.1 mrg ;; 9689 1.1 mrg esac 9690 1.1 mrg done # Gone through all deplibs. 9691 1.1 mrg ;; 9692 1.1 mrg none | unknown | *) 9693 1.1 mrg newdeplibs= 9694 1.1 mrg tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'` 9695 1.1 mrg if test yes = "$allow_libtool_libs_with_static_runtimes"; then 9696 1.1 mrg for i in $predeps $postdeps; do 9697 1.1 mrg # can't use Xsed below, because $i might contain '/' 9698 1.1 mrg tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"` 9699 1.1 mrg done 9700 1.1 mrg fi 9701 1.1 mrg case $tmp_deplibs in 9702 1.1 mrg *[!\ \ ]*) 9703 1.1 mrg echo 9704 1.1 mrg if test none = "$deplibs_check_method"; then 9705 1.1 mrg echo "*** Warning: inter-library dependencies are not supported in this platform." 9706 1.1 mrg else 9707 1.1 mrg echo "*** Warning: inter-library dependencies are not known to be supported." 9708 1.1 mrg fi 9709 1.1 mrg echo "*** All declared inter-library dependencies are being dropped." 9710 1.1 mrg droppeddeps=yes 9711 1.1 mrg ;; 9712 1.1 mrg esac 9713 1.1 mrg ;; 9714 1.1 mrg esac 9715 1.1 mrg versuffix=$versuffix_save 9716 1.1 mrg major=$major_save 9717 1.1 mrg release=$release_save 9718 1.1 mrg libname=$libname_save 9719 1.1 mrg name=$name_save 9720 1.1 mrg 9721 1.1 mrg case $host in 9722 1.1 mrg *-*-rhapsody* | *-*-darwin1.[012]) 9723 1.1 mrg # On Rhapsody replace the C library with the System framework 9724 1.1 mrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'` 9725 1.1 mrg ;; 9726 1.1 mrg esac 9727 1.1 mrg 9728 1.1 mrg if test yes = "$droppeddeps"; then 9729 1.1 mrg if test yes = "$module"; then 9730 1.1 mrg echo 9731 1.1 mrg echo "*** Warning: libtool could not satisfy all declared inter-library" 9732 1.1 mrg $ECHO "*** dependencies of module $libname. Therefore, libtool will create" 9733 1.1 mrg echo "*** a static module, that should work as long as the dlopening" 9734 1.1 mrg echo "*** application is linked with the -dlopen flag." 9735 1.1 mrg if test -z "$global_symbol_pipe"; then 9736 1.1 mrg echo 9737 1.1 mrg echo "*** However, this would only work if libtool was able to extract symbol" 9738 1.1 mrg echo "*** lists from a program, using 'nm' or equivalent, but libtool could" 9739 1.1 mrg echo "*** not find such a program. So, this module is probably useless." 9740 1.1 mrg echo "*** 'nm' from GNU binutils and a full rebuild may help." 9741 1.1 mrg fi 9742 1.1 mrg if test no = "$build_old_libs"; then 9743 1.1 mrg oldlibs=$output_objdir/$libname.$libext 9744 1.1 mrg build_libtool_libs=module 9745 1.1 mrg build_old_libs=yes 9746 1.1 mrg else 9747 1.1 mrg build_libtool_libs=no 9748 1.1 mrg fi 9749 1.1 mrg else 9750 1.1 mrg echo "*** The inter-library dependencies that have been dropped here will be" 9751 1.1 mrg echo "*** automatically added whenever a program is linked with this library" 9752 1.1 mrg echo "*** or is declared to -dlopen it." 9753 1.1 mrg 9754 1.1 mrg if test no = "$allow_undefined"; then 9755 1.1 mrg echo 9756 1.1 mrg echo "*** Since this library must not contain undefined symbols," 9757 1.1 mrg echo "*** because either the platform does not support them or" 9758 1.1 mrg echo "*** it was explicitly requested with -no-undefined," 9759 1.1 mrg echo "*** libtool will only create a static version of it." 9760 1.1 mrg if test no = "$build_old_libs"; then 9761 1.1 mrg oldlibs=$output_objdir/$libname.$libext 9762 1.1 mrg build_libtool_libs=module 9763 1.1 mrg build_old_libs=yes 9764 1.1 mrg else 9765 1.1 mrg build_libtool_libs=no 9766 1.1 mrg fi 9767 1.1 mrg fi 9768 1.1 mrg fi 9769 1.1 mrg fi 9770 1.1 mrg # Done checking deplibs! 9771 1.1 mrg deplibs=$newdeplibs 9772 1.1 mrg fi 9773 1.1 mrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 9774 1.1 mrg case $host in 9775 1.1 mrg *-*-darwin*) 9776 1.1 mrg newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9777 1.1 mrg new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9778 1.1 mrg deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 9779 1.1 mrg ;; 9780 1.1 mrg esac 9781 1.1 mrg 9782 1.1 mrg # move library search paths that coincide with paths to not yet 9783 1.1 mrg # installed libraries to the beginning of the library search list 9784 1.1 mrg new_libs= 9785 1.1 mrg for path in $notinst_path; do 9786 1.1 mrg case " $new_libs " in 9787 1.1 mrg *" -L$path/$objdir "*) ;; 9788 1.1 mrg *) 9789 1.1 mrg case " $deplibs " in 9790 1.1 mrg *" -L$path/$objdir "*) 9791 1.1 mrg func_append new_libs " -L$path/$objdir" ;; 9792 1.1 mrg esac 9793 1.1 mrg ;; 9794 1.1 mrg esac 9795 1.1 mrg done 9796 1.1 mrg for deplib in $deplibs; do 9797 1.1 mrg case $deplib in 9798 1.1 mrg -L*) 9799 1.1 mrg case " $new_libs " in 9800 1.1 mrg *" $deplib "*) ;; 9801 1.1 mrg *) func_append new_libs " $deplib" ;; 9802 1.1 mrg esac 9803 1.1 mrg ;; 9804 1.1 mrg *) func_append new_libs " $deplib" ;; 9805 1.1 mrg esac 9806 1.1 mrg done 9807 1.1 mrg deplibs=$new_libs 9808 1.1 mrg 9809 1.1 mrg # All the library-specific variables (install_libdir is set above). 9810 1.1 mrg library_names= 9811 1.1 mrg old_library= 9812 1.1 mrg dlname= 9813 1.1 mrg 9814 1.1 mrg # Test again, we may have decided not to build it any more 9815 1.1 mrg if test yes = "$build_libtool_libs"; then 9816 1.1 mrg # Remove $wl instances when linking with ld. 9817 1.1 mrg # FIXME: should test the right _cmds variable. 9818 1.1 mrg case $archive_cmds in 9819 1.1 mrg *\$LD\ *) wl= ;; 9820 1.1 mrg esac 9821 1.1 mrg if test yes = "$hardcode_into_libs"; then 9822 1.1 mrg # Hardcode the library paths 9823 1.1 mrg hardcode_libdirs= 9824 1.1 mrg dep_rpath= 9825 1.1 mrg rpath=$finalize_rpath 9826 1.1 mrg test relink = "$opt_mode" || rpath=$compile_rpath$rpath 9827 1.1 mrg for libdir in $rpath; do 9828 1.1 mrg if test -n "$hardcode_libdir_flag_spec"; then 9829 1.1 mrg if test -n "$hardcode_libdir_separator"; then 9830 1.1 mrg func_replace_sysroot "$libdir" 9831 1.1 mrg libdir=$func_replace_sysroot_result 9832 1.1 mrg if test -z "$hardcode_libdirs"; then 9833 1.1 mrg hardcode_libdirs=$libdir 9834 1.1 mrg else 9835 1.1 mrg # Just accumulate the unique libdirs. 9836 1.1 mrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 9837 1.1 mrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 9838 1.1 mrg ;; 9839 1.1 mrg *) 9840 1.1 mrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 9841 1.1 mrg ;; 9842 1.1 mrg esac 9843 1.1 mrg fi 9844 1.1 mrg else 9845 1.1 mrg eval flag=\"$hardcode_libdir_flag_spec\" 9846 1.1 mrg func_append dep_rpath " $flag" 9847 1.1 mrg fi 9848 1.1 mrg elif test -n "$runpath_var"; then 9849 1.1 mrg case "$perm_rpath " in 9850 1.1 mrg *" $libdir "*) ;; 9851 1.1 mrg *) func_append perm_rpath " $libdir" ;; 9852 1.1 mrg esac 9853 1.1 mrg fi 9854 1.1 mrg done 9855 1.1 mrg # Substitute the hardcoded libdirs into the rpath. 9856 1.1 mrg if test -n "$hardcode_libdir_separator" && 9857 1.1 mrg test -n "$hardcode_libdirs"; then 9858 1.1 mrg libdir=$hardcode_libdirs 9859 1.1 mrg eval "dep_rpath=\"$hardcode_libdir_flag_spec\"" 9860 1.1 mrg fi 9861 1.1 mrg if test -n "$runpath_var" && test -n "$perm_rpath"; then 9862 1.1 mrg # We should set the runpath_var. 9863 1.1 mrg rpath= 9864 1.1 mrg for dir in $perm_rpath; do 9865 1.1 mrg func_append rpath "$dir:" 9866 1.1 mrg done 9867 1.1 mrg eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var" 9868 1.1 mrg fi 9869 1.1 mrg test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs" 9870 1.1 mrg fi 9871 1.1 mrg 9872 1.1 mrg shlibpath=$finalize_shlibpath 9873 1.1 mrg test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath 9874 1.1 mrg if test -n "$shlibpath"; then 9875 1.1 mrg eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var" 9876 1.1 mrg fi 9877 1.1 mrg 9878 1.1 mrg # Get the real and link names of the library. 9879 1.1 mrg eval shared_ext=\"$shrext_cmds\" 9880 1.1 mrg eval library_names=\"$library_names_spec\" 9881 1.1 mrg set dummy $library_names 9882 1.1 mrg shift 9883 1.1 mrg realname=$1 9884 1.1 mrg shift 9885 1.1 mrg 9886 1.1 mrg if test -n "$soname_spec"; then 9887 1.1 mrg eval soname=\"$soname_spec\" 9888 1.1 mrg else 9889 1.1 mrg soname=$realname 9890 1.1 mrg fi 9891 1.1 mrg if test -z "$dlname"; then 9892 1.1 mrg dlname=$soname 9893 1.1 mrg fi 9894 1.1 mrg 9895 1.1 mrg lib=$output_objdir/$realname 9896 1.1 mrg linknames= 9897 1.1 mrg for link 9898 1.1 mrg do 9899 1.1 mrg func_append linknames " $link" 9900 1.1 mrg done 9901 1.1 mrg 9902 1.1 mrg # Use standard objects if they are pic 9903 1.1 mrg test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP` 9904 1.1 mrg test "X$libobjs" = "X " && libobjs= 9905 1.1 mrg 9906 1.1 mrg delfiles= 9907 1.1 mrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9908 1.1 mrg $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp" 9909 1.1 mrg export_symbols=$output_objdir/$libname.uexp 9910 1.1 mrg func_append delfiles " $export_symbols" 9911 1.1 mrg fi 9912 1.1 mrg 9913 1.1 mrg orig_export_symbols= 9914 1.1 mrg case $host_os in 9915 1.1 mrg cygwin* | mingw* | cegcc*) 9916 1.1 mrg if test -n "$export_symbols" && test -z "$export_symbols_regex"; then 9917 1.1 mrg # exporting using user supplied symfile 9918 1.1 mrg func_dll_def_p "$export_symbols" || { 9919 1.1 mrg # and it's NOT already a .def file. Must figure out 9920 1.1 mrg # which of the given symbols are data symbols and tag 9921 1.1 mrg # them as such. So, trigger use of export_symbols_cmds. 9922 1.1 mrg # export_symbols gets reassigned inside the "prepare 9923 1.1 mrg # the list of exported symbols" if statement, so the 9924 1.1 mrg # include_expsyms logic still works. 9925 1.1 mrg orig_export_symbols=$export_symbols 9926 1.1 mrg export_symbols= 9927 1.1 mrg always_export_symbols=yes 9928 1.1 mrg } 9929 1.1 mrg fi 9930 1.1 mrg ;; 9931 1.1 mrg esac 9932 1.1 mrg 9933 1.1 mrg # Prepare the list of exported symbols 9934 1.1 mrg if test -z "$export_symbols"; then 9935 1.1 mrg if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then 9936 1.1 mrg func_verbose "generating symbol list for '$libname.la'" 9937 1.1 mrg export_symbols=$output_objdir/$libname.exp 9938 1.1 mrg $opt_dry_run || $RM $export_symbols 9939 1.1 mrg cmds=$export_symbols_cmds 9940 1.1 mrg save_ifs=$IFS; IFS='~' 9941 1.1 mrg for cmd1 in $cmds; do 9942 1.1 mrg IFS=$save_ifs 9943 1.1 mrg # Take the normal branch if the nm_file_list_spec branch 9944 1.1 mrg # doesn't work or if tool conversion is not needed. 9945 1.1 mrg case $nm_file_list_spec~$to_tool_file_cmd in 9946 1.1 mrg *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*) 9947 1.1 mrg try_normal_branch=yes 9948 1.1 mrg eval cmd=\"$cmd1\" 9949 1.1 mrg func_len " $cmd" 9950 1.1 mrg len=$func_len_result 9951 1.1 mrg ;; 9952 1.1 mrg *) 9953 1.1 mrg try_normal_branch=no 9954 1.1 mrg ;; 9955 1.1 mrg esac 9956 1.1 mrg if test yes = "$try_normal_branch" \ 9957 1.1 mrg && { test "$len" -lt "$max_cmd_len" \ 9958 1.1 mrg || test "$max_cmd_len" -le -1; } 9959 1.1 mrg then 9960 1.1 mrg func_show_eval "$cmd" 'exit $?' 9961 1.1 mrg skipped_export=false 9962 1.1 mrg elif test -n "$nm_file_list_spec"; then 9963 1.1 mrg func_basename "$output" 9964 1.1 mrg output_la=$func_basename_result 9965 1.1 mrg save_libobjs=$libobjs 9966 1.1 mrg save_output=$output 9967 1.1 mrg output=$output_objdir/$output_la.nm 9968 1.1 mrg func_to_tool_file "$output" 9969 1.1 mrg libobjs=$nm_file_list_spec$func_to_tool_file_result 9970 1.1 mrg func_append delfiles " $output" 9971 1.1 mrg func_verbose "creating $NM input file list: $output" 9972 1.1 mrg for obj in $save_libobjs; do 9973 1.1 mrg func_to_tool_file "$obj" 9974 1.1 mrg $ECHO "$func_to_tool_file_result" 9975 1.1 mrg done > "$output" 9976 1.1 mrg eval cmd=\"$cmd1\" 9977 1.1 mrg func_show_eval "$cmd" 'exit $?' 9978 1.1 mrg output=$save_output 9979 1.1 mrg libobjs=$save_libobjs 9980 1.1 mrg skipped_export=false 9981 1.1 mrg else 9982 1.1 mrg # The command line is too long to execute in one step. 9983 1.1 mrg func_verbose "using reloadable object file for export list..." 9984 1.1 mrg skipped_export=: 9985 1.1 mrg # Break out early, otherwise skipped_export may be 9986 1.1 mrg # set to false by a later but shorter cmd. 9987 1.1 mrg break 9988 1.1 mrg fi 9989 1.1 mrg done 9990 1.1 mrg IFS=$save_ifs 9991 1.1 mrg if test -n "$export_symbols_regex" && test : != "$skipped_export"; then 9992 1.1 mrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 9993 1.1 mrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 9994 1.1 mrg fi 9995 1.1 mrg fi 9996 1.1 mrg fi 9997 1.1 mrg 9998 1.1 mrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 9999 1.1 mrg tmp_export_symbols=$export_symbols 10000 1.1 mrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10001 1.1 mrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10002 1.1 mrg fi 10003 1.1 mrg 10004 1.1 mrg if test : != "$skipped_export" && test -n "$orig_export_symbols"; then 10005 1.1 mrg # The given exports_symbols file has to be filtered, so filter it. 10006 1.1 mrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10007 1.1 mrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10008 1.1 mrg # 's' commands, which not all seds can handle. GNU sed should be fine 10009 1.1 mrg # though. Also, the filter scales superlinearly with the number of 10010 1.1 mrg # global variables. join(1) would be nice here, but unfortunately 10011 1.1 mrg # isn't a blessed tool. 10012 1.1 mrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10013 1.1 mrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10014 1.1 mrg export_symbols=$output_objdir/$libname.def 10015 1.1 mrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10016 1.1 mrg fi 10017 1.1 mrg 10018 1.1 mrg tmp_deplibs= 10019 1.1 mrg for test_deplib in $deplibs; do 10020 1.1 mrg case " $convenience " in 10021 1.1 mrg *" $test_deplib "*) ;; 10022 1.1 mrg *) 10023 1.1 mrg func_append tmp_deplibs " $test_deplib" 10024 1.1 mrg ;; 10025 1.1 mrg esac 10026 1.1 mrg done 10027 1.1 mrg deplibs=$tmp_deplibs 10028 1.1 mrg 10029 1.1 mrg if test -n "$convenience"; then 10030 1.1 mrg if test -n "$whole_archive_flag_spec" && 10031 1.1 mrg test yes = "$compiler_needs_object" && 10032 1.1 mrg test -z "$libobjs"; then 10033 1.1 mrg # extract the archives, so we have objects to list. 10034 1.1 mrg # TODO: could optimize this to just extract one archive. 10035 1.1 mrg whole_archive_flag_spec= 10036 1.1 mrg fi 10037 1.1 mrg if test -n "$whole_archive_flag_spec"; then 10038 1.1 mrg save_libobjs=$libobjs 10039 1.1 mrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10040 1.1 mrg test "X$libobjs" = "X " && libobjs= 10041 1.1 mrg else 10042 1.1 mrg gentop=$output_objdir/${outputname}x 10043 1.1 mrg func_append generated " $gentop" 10044 1.1 mrg 10045 1.1 mrg func_extract_archives $gentop $convenience 10046 1.1 mrg func_append libobjs " $func_extract_archives_result" 10047 1.1 mrg test "X$libobjs" = "X " && libobjs= 10048 1.1 mrg fi 10049 1.1 mrg fi 10050 1.1 mrg 10051 1.1 mrg if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then 10052 1.1 mrg eval flag=\"$thread_safe_flag_spec\" 10053 1.1 mrg func_append linker_flags " $flag" 10054 1.1 mrg fi 10055 1.1 mrg 10056 1.1 mrg # Make a backup of the uninstalled library when relinking 10057 1.1 mrg if test relink = "$opt_mode"; then 10058 1.1 mrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $? 10059 1.1 mrg fi 10060 1.1 mrg 10061 1.1 mrg # Do each of the archive commands. 10062 1.1 mrg if test yes = "$module" && test -n "$module_cmds"; then 10063 1.1 mrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10064 1.1 mrg eval test_cmds=\"$module_expsym_cmds\" 10065 1.1 mrg cmds=$module_expsym_cmds 10066 1.1 mrg else 10067 1.1 mrg eval test_cmds=\"$module_cmds\" 10068 1.1 mrg cmds=$module_cmds 10069 1.1 mrg fi 10070 1.1 mrg else 10071 1.1 mrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10072 1.1 mrg eval test_cmds=\"$archive_expsym_cmds\" 10073 1.1 mrg cmds=$archive_expsym_cmds 10074 1.1 mrg else 10075 1.1 mrg eval test_cmds=\"$archive_cmds\" 10076 1.1 mrg cmds=$archive_cmds 10077 1.1 mrg fi 10078 1.1 mrg fi 10079 1.1 mrg 10080 1.1 mrg if test : != "$skipped_export" && 10081 1.1 mrg func_len " $test_cmds" && 10082 1.1 mrg len=$func_len_result && 10083 1.1 mrg test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10084 1.1 mrg : 10085 1.1 mrg else 10086 1.1 mrg # The command line is too long to link in one step, link piecewise 10087 1.1 mrg # or, if using GNU ld and skipped_export is not :, use a linker 10088 1.1 mrg # script. 10089 1.1 mrg 10090 1.1 mrg # Save the value of $output and $libobjs because we want to 10091 1.1 mrg # use them later. If we have whole_archive_flag_spec, we 10092 1.1 mrg # want to use save_libobjs as it was before 10093 1.1 mrg # whole_archive_flag_spec was expanded, because we can't 10094 1.1 mrg # assume the linker understands whole_archive_flag_spec. 10095 1.1 mrg # This may have to be revisited, in case too many 10096 1.1 mrg # convenience libraries get linked in and end up exceeding 10097 1.1 mrg # the spec. 10098 1.1 mrg if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then 10099 1.1 mrg save_libobjs=$libobjs 10100 1.1 mrg fi 10101 1.1 mrg save_output=$output 10102 1.1 mrg func_basename "$output" 10103 1.1 mrg output_la=$func_basename_result 10104 1.1 mrg 10105 1.1 mrg # Clear the reloadable object creation command queue and 10106 1.1 mrg # initialize k to one. 10107 1.1 mrg test_cmds= 10108 1.1 mrg concat_cmds= 10109 1.1 mrg objlist= 10110 1.1 mrg last_robj= 10111 1.1 mrg k=1 10112 1.1 mrg 10113 1.1 mrg if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then 10114 1.1 mrg output=$output_objdir/$output_la.lnkscript 10115 1.1 mrg func_verbose "creating GNU ld script: $output" 10116 1.1 mrg echo 'INPUT (' > $output 10117 1.1 mrg for obj in $save_libobjs 10118 1.1 mrg do 10119 1.1 mrg func_to_tool_file "$obj" 10120 1.1 mrg $ECHO "$func_to_tool_file_result" >> $output 10121 1.1 mrg done 10122 1.1 mrg echo ')' >> $output 10123 1.1 mrg func_append delfiles " $output" 10124 1.1 mrg func_to_tool_file "$output" 10125 1.1 mrg output=$func_to_tool_file_result 10126 1.1 mrg elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then 10127 1.1 mrg output=$output_objdir/$output_la.lnk 10128 1.1 mrg func_verbose "creating linker input file list: $output" 10129 1.1 mrg : > $output 10130 1.1 mrg set x $save_libobjs 10131 1.1 mrg shift 10132 1.1 mrg firstobj= 10133 1.1 mrg if test yes = "$compiler_needs_object"; then 10134 1.1 mrg firstobj="$1 " 10135 1.1 mrg shift 10136 1.1 mrg fi 10137 1.1 mrg for obj 10138 1.1 mrg do 10139 1.1 mrg func_to_tool_file "$obj" 10140 1.1 mrg $ECHO "$func_to_tool_file_result" >> $output 10141 1.1 mrg done 10142 1.1 mrg func_append delfiles " $output" 10143 1.1 mrg func_to_tool_file "$output" 10144 1.1 mrg output=$firstobj\"$file_list_spec$func_to_tool_file_result\" 10145 1.1 mrg else 10146 1.1 mrg if test -n "$save_libobjs"; then 10147 1.1 mrg func_verbose "creating reloadable object files..." 10148 1.1 mrg output=$output_objdir/$output_la-$k.$objext 10149 1.1 mrg eval test_cmds=\"$reload_cmds\" 10150 1.1 mrg func_len " $test_cmds" 10151 1.1 mrg len0=$func_len_result 10152 1.1 mrg len=$len0 10153 1.1 mrg 10154 1.1 mrg # Loop over the list of objects to be linked. 10155 1.1 mrg for obj in $save_libobjs 10156 1.1 mrg do 10157 1.1 mrg func_len " $obj" 10158 1.1 mrg func_arith $len + $func_len_result 10159 1.1 mrg len=$func_arith_result 10160 1.1 mrg if test -z "$objlist" || 10161 1.1 mrg test "$len" -lt "$max_cmd_len"; then 10162 1.1 mrg func_append objlist " $obj" 10163 1.1 mrg else 10164 1.1 mrg # The command $test_cmds is almost too long, add a 10165 1.1 mrg # command to the queue. 10166 1.1 mrg if test 1 -eq "$k"; then 10167 1.1 mrg # The first file doesn't have a previous command to add. 10168 1.1 mrg reload_objs=$objlist 10169 1.1 mrg eval concat_cmds=\"$reload_cmds\" 10170 1.1 mrg else 10171 1.1 mrg # All subsequent reloadable object files will link in 10172 1.1 mrg # the last one created. 10173 1.1 mrg reload_objs="$objlist $last_robj" 10174 1.1 mrg eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\" 10175 1.1 mrg fi 10176 1.1 mrg last_robj=$output_objdir/$output_la-$k.$objext 10177 1.1 mrg func_arith $k + 1 10178 1.1 mrg k=$func_arith_result 10179 1.1 mrg output=$output_objdir/$output_la-$k.$objext 10180 1.1 mrg objlist=" $obj" 10181 1.1 mrg func_len " $last_robj" 10182 1.1 mrg func_arith $len0 + $func_len_result 10183 1.1 mrg len=$func_arith_result 10184 1.1 mrg fi 10185 1.1 mrg done 10186 1.1 mrg # Handle the remaining objects by creating one last 10187 1.1 mrg # reloadable object file. All subsequent reloadable object 10188 1.1 mrg # files will link in the last one created. 10189 1.1 mrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10190 1.1 mrg reload_objs="$objlist $last_robj" 10191 1.1 mrg eval concat_cmds=\"\$concat_cmds$reload_cmds\" 10192 1.1 mrg if test -n "$last_robj"; then 10193 1.1 mrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10194 1.1 mrg fi 10195 1.1 mrg func_append delfiles " $output" 10196 1.1 mrg 10197 1.1 mrg else 10198 1.1 mrg output= 10199 1.1 mrg fi 10200 1.1 mrg 10201 1.1 mrg ${skipped_export-false} && { 10202 1.1 mrg func_verbose "generating symbol list for '$libname.la'" 10203 1.1 mrg export_symbols=$output_objdir/$libname.exp 10204 1.1 mrg $opt_dry_run || $RM $export_symbols 10205 1.1 mrg libobjs=$output 10206 1.1 mrg # Append the command to create the export file. 10207 1.1 mrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 10208 1.1 mrg eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\" 10209 1.1 mrg if test -n "$last_robj"; then 10210 1.1 mrg eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\" 10211 1.1 mrg fi 10212 1.1 mrg } 10213 1.1 mrg 10214 1.1 mrg test -n "$save_libobjs" && 10215 1.1 mrg func_verbose "creating a temporary reloadable object file: $output" 10216 1.1 mrg 10217 1.1 mrg # Loop through the commands generated above and execute them. 10218 1.1 mrg save_ifs=$IFS; IFS='~' 10219 1.1 mrg for cmd in $concat_cmds; do 10220 1.1 mrg IFS=$save_ifs 10221 1.1 mrg $opt_quiet || { 10222 1.1.1.2 mrg func_quote_arg expand,pretty "$cmd" 10223 1.1.1.2 mrg eval "func_echo $func_quote_arg_result" 10224 1.1 mrg } 10225 1.1 mrg $opt_dry_run || eval "$cmd" || { 10226 1.1 mrg lt_exit=$? 10227 1.1 mrg 10228 1.1 mrg # Restore the uninstalled library and exit 10229 1.1 mrg if test relink = "$opt_mode"; then 10230 1.1 mrg ( cd "$output_objdir" && \ 10231 1.1 mrg $RM "${realname}T" && \ 10232 1.1 mrg $MV "${realname}U" "$realname" ) 10233 1.1 mrg fi 10234 1.1 mrg 10235 1.1 mrg exit $lt_exit 10236 1.1 mrg } 10237 1.1 mrg done 10238 1.1 mrg IFS=$save_ifs 10239 1.1 mrg 10240 1.1 mrg if test -n "$export_symbols_regex" && ${skipped_export-false}; then 10241 1.1 mrg func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"' 10242 1.1 mrg func_show_eval '$MV "${export_symbols}T" "$export_symbols"' 10243 1.1 mrg fi 10244 1.1 mrg fi 10245 1.1 mrg 10246 1.1 mrg ${skipped_export-false} && { 10247 1.1 mrg if test -n "$export_symbols" && test -n "$include_expsyms"; then 10248 1.1 mrg tmp_export_symbols=$export_symbols 10249 1.1 mrg test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols 10250 1.1 mrg $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"' 10251 1.1 mrg fi 10252 1.1 mrg 10253 1.1 mrg if test -n "$orig_export_symbols"; then 10254 1.1 mrg # The given exports_symbols file has to be filtered, so filter it. 10255 1.1 mrg func_verbose "filter symbol list for '$libname.la' to tag DATA exports" 10256 1.1 mrg # FIXME: $output_objdir/$libname.filter potentially contains lots of 10257 1.1 mrg # 's' commands, which not all seds can handle. GNU sed should be fine 10258 1.1 mrg # though. Also, the filter scales superlinearly with the number of 10259 1.1 mrg # global variables. join(1) would be nice here, but unfortunately 10260 1.1 mrg # isn't a blessed tool. 10261 1.1 mrg $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter 10262 1.1 mrg func_append delfiles " $export_symbols $output_objdir/$libname.filter" 10263 1.1 mrg export_symbols=$output_objdir/$libname.def 10264 1.1 mrg $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols 10265 1.1 mrg fi 10266 1.1 mrg } 10267 1.1 mrg 10268 1.1 mrg libobjs=$output 10269 1.1 mrg # Restore the value of output. 10270 1.1 mrg output=$save_output 10271 1.1 mrg 10272 1.1 mrg if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then 10273 1.1 mrg eval libobjs=\"\$libobjs $whole_archive_flag_spec\" 10274 1.1 mrg test "X$libobjs" = "X " && libobjs= 10275 1.1 mrg fi 10276 1.1 mrg # Expand the library linking commands again to reset the 10277 1.1 mrg # value of $libobjs for piecewise linking. 10278 1.1 mrg 10279 1.1 mrg # Do each of the archive commands. 10280 1.1 mrg if test yes = "$module" && test -n "$module_cmds"; then 10281 1.1 mrg if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then 10282 1.1 mrg cmds=$module_expsym_cmds 10283 1.1 mrg else 10284 1.1 mrg cmds=$module_cmds 10285 1.1 mrg fi 10286 1.1 mrg else 10287 1.1 mrg if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then 10288 1.1 mrg cmds=$archive_expsym_cmds 10289 1.1 mrg else 10290 1.1 mrg cmds=$archive_cmds 10291 1.1 mrg fi 10292 1.1 mrg fi 10293 1.1 mrg fi 10294 1.1 mrg 10295 1.1 mrg if test -n "$delfiles"; then 10296 1.1 mrg # Append the command to remove temporary files to $cmds. 10297 1.1 mrg eval cmds=\"\$cmds~\$RM $delfiles\" 10298 1.1 mrg fi 10299 1.1 mrg 10300 1.1 mrg # Add any objects from preloaded convenience libraries 10301 1.1 mrg if test -n "$dlprefiles"; then 10302 1.1 mrg gentop=$output_objdir/${outputname}x 10303 1.1 mrg func_append generated " $gentop" 10304 1.1 mrg 10305 1.1 mrg func_extract_archives $gentop $dlprefiles 10306 1.1 mrg func_append libobjs " $func_extract_archives_result" 10307 1.1 mrg test "X$libobjs" = "X " && libobjs= 10308 1.1 mrg fi 10309 1.1 mrg 10310 1.1 mrg save_ifs=$IFS; IFS='~' 10311 1.1 mrg for cmd in $cmds; do 10312 1.1 mrg IFS=$sp$nl 10313 1.1 mrg eval cmd=\"$cmd\" 10314 1.1 mrg IFS=$save_ifs 10315 1.1 mrg $opt_quiet || { 10316 1.1.1.2 mrg func_quote_arg expand,pretty "$cmd" 10317 1.1.1.2 mrg eval "func_echo $func_quote_arg_result" 10318 1.1 mrg } 10319 1.1 mrg $opt_dry_run || eval "$cmd" || { 10320 1.1 mrg lt_exit=$? 10321 1.1 mrg 10322 1.1 mrg # Restore the uninstalled library and exit 10323 1.1 mrg if test relink = "$opt_mode"; then 10324 1.1 mrg ( cd "$output_objdir" && \ 10325 1.1 mrg $RM "${realname}T" && \ 10326 1.1 mrg $MV "${realname}U" "$realname" ) 10327 1.1 mrg fi 10328 1.1 mrg 10329 1.1 mrg exit $lt_exit 10330 1.1 mrg } 10331 1.1 mrg done 10332 1.1 mrg IFS=$save_ifs 10333 1.1 mrg 10334 1.1 mrg # Restore the uninstalled library and exit 10335 1.1 mrg if test relink = "$opt_mode"; then 10336 1.1 mrg $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $? 10337 1.1 mrg 10338 1.1 mrg if test -n "$convenience"; then 10339 1.1 mrg if test -z "$whole_archive_flag_spec"; then 10340 1.1 mrg func_show_eval '${RM}r "$gentop"' 10341 1.1 mrg fi 10342 1.1 mrg fi 10343 1.1 mrg 10344 1.1 mrg exit $EXIT_SUCCESS 10345 1.1 mrg fi 10346 1.1 mrg 10347 1.1 mrg # Create links to the real library. 10348 1.1 mrg for linkname in $linknames; do 10349 1.1 mrg if test "$realname" != "$linkname"; then 10350 1.1 mrg func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?' 10351 1.1 mrg fi 10352 1.1 mrg done 10353 1.1 mrg 10354 1.1 mrg # If -module or -export-dynamic was specified, set the dlname. 10355 1.1 mrg if test yes = "$module" || test yes = "$export_dynamic"; then 10356 1.1 mrg # On all known operating systems, these are identical. 10357 1.1 mrg dlname=$soname 10358 1.1 mrg fi 10359 1.1 mrg fi 10360 1.1 mrg ;; 10361 1.1 mrg 10362 1.1 mrg obj) 10363 1.1 mrg if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then 10364 1.1 mrg func_warning "'-dlopen' is ignored for objects" 10365 1.1 mrg fi 10366 1.1 mrg 10367 1.1 mrg case " $deplibs" in 10368 1.1 mrg *\ -l* | *\ -L*) 10369 1.1 mrg func_warning "'-l' and '-L' are ignored for objects" ;; 10370 1.1 mrg esac 10371 1.1 mrg 10372 1.1 mrg test -n "$rpath" && \ 10373 1.1 mrg func_warning "'-rpath' is ignored for objects" 10374 1.1 mrg 10375 1.1 mrg test -n "$xrpath" && \ 10376 1.1 mrg func_warning "'-R' is ignored for objects" 10377 1.1 mrg 10378 1.1 mrg test -n "$vinfo" && \ 10379 1.1 mrg func_warning "'-version-info' is ignored for objects" 10380 1.1 mrg 10381 1.1 mrg test -n "$release" && \ 10382 1.1 mrg func_warning "'-release' is ignored for objects" 10383 1.1 mrg 10384 1.1 mrg case $output in 10385 1.1 mrg *.lo) 10386 1.1 mrg test -n "$objs$old_deplibs" && \ 10387 1.1 mrg func_fatal_error "cannot build library object '$output' from non-libtool objects" 10388 1.1 mrg 10389 1.1 mrg libobj=$output 10390 1.1 mrg func_lo2o "$libobj" 10391 1.1 mrg obj=$func_lo2o_result 10392 1.1 mrg ;; 10393 1.1 mrg *) 10394 1.1 mrg libobj= 10395 1.1 mrg obj=$output 10396 1.1 mrg ;; 10397 1.1 mrg esac 10398 1.1 mrg 10399 1.1 mrg # Delete the old objects. 10400 1.1 mrg $opt_dry_run || $RM $obj $libobj 10401 1.1 mrg 10402 1.1 mrg # Objects from convenience libraries. This assumes 10403 1.1 mrg # single-version convenience libraries. Whenever we create 10404 1.1 mrg # different ones for PIC/non-PIC, this we'll have to duplicate 10405 1.1 mrg # the extraction. 10406 1.1 mrg reload_conv_objs= 10407 1.1 mrg gentop= 10408 1.1 mrg # if reload_cmds runs $LD directly, get rid of -Wl from 10409 1.1 mrg # whole_archive_flag_spec and hope we can get by with turning comma 10410 1.1 mrg # into space. 10411 1.1 mrg case $reload_cmds in 10412 1.1 mrg *\$LD[\ \$]*) wl= ;; 10413 1.1 mrg esac 10414 1.1 mrg if test -n "$convenience"; then 10415 1.1 mrg if test -n "$whole_archive_flag_spec"; then 10416 1.1 mrg eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\" 10417 1.1 mrg test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'` 10418 1.1 mrg reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags 10419 1.1 mrg else 10420 1.1 mrg gentop=$output_objdir/${obj}x 10421 1.1 mrg func_append generated " $gentop" 10422 1.1 mrg 10423 1.1 mrg func_extract_archives $gentop $convenience 10424 1.1 mrg reload_conv_objs="$reload_objs $func_extract_archives_result" 10425 1.1 mrg fi 10426 1.1 mrg fi 10427 1.1 mrg 10428 1.1 mrg # If we're not building shared, we need to use non_pic_objs 10429 1.1 mrg test yes = "$build_libtool_libs" || libobjs=$non_pic_objects 10430 1.1 mrg 10431 1.1 mrg # Create the old-style object. 10432 1.1 mrg reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs 10433 1.1 mrg 10434 1.1 mrg output=$obj 10435 1.1 mrg func_execute_cmds "$reload_cmds" 'exit $?' 10436 1.1 mrg 10437 1.1 mrg # Exit if we aren't doing a library object file. 10438 1.1 mrg if test -z "$libobj"; then 10439 1.1 mrg if test -n "$gentop"; then 10440 1.1 mrg func_show_eval '${RM}r "$gentop"' 10441 1.1 mrg fi 10442 1.1 mrg 10443 1.1 mrg exit $EXIT_SUCCESS 10444 1.1 mrg fi 10445 1.1 mrg 10446 1.1 mrg test yes = "$build_libtool_libs" || { 10447 1.1 mrg if test -n "$gentop"; then 10448 1.1 mrg func_show_eval '${RM}r "$gentop"' 10449 1.1 mrg fi 10450 1.1 mrg 10451 1.1 mrg # Create an invalid libtool object if no PIC, so that we don't 10452 1.1 mrg # accidentally link it into a program. 10453 1.1 mrg # $show "echo timestamp > $libobj" 10454 1.1 mrg # $opt_dry_run || eval "echo timestamp > $libobj" || exit $? 10455 1.1 mrg exit $EXIT_SUCCESS 10456 1.1 mrg } 10457 1.1 mrg 10458 1.1 mrg if test -n "$pic_flag" || test default != "$pic_mode"; then 10459 1.1 mrg # Only do commands if we really have different PIC objects. 10460 1.1 mrg reload_objs="$libobjs $reload_conv_objs" 10461 1.1 mrg output=$libobj 10462 1.1 mrg func_execute_cmds "$reload_cmds" 'exit $?' 10463 1.1 mrg fi 10464 1.1 mrg 10465 1.1 mrg if test -n "$gentop"; then 10466 1.1 mrg func_show_eval '${RM}r "$gentop"' 10467 1.1 mrg fi 10468 1.1 mrg 10469 1.1 mrg exit $EXIT_SUCCESS 10470 1.1 mrg ;; 10471 1.1 mrg 10472 1.1 mrg prog) 10473 1.1 mrg case $host in 10474 1.1 mrg *cygwin*) func_stripname '' '.exe' "$output" 10475 1.1 mrg output=$func_stripname_result.exe;; 10476 1.1 mrg esac 10477 1.1 mrg test -n "$vinfo" && \ 10478 1.1 mrg func_warning "'-version-info' is ignored for programs" 10479 1.1 mrg 10480 1.1 mrg test -n "$release" && \ 10481 1.1 mrg func_warning "'-release' is ignored for programs" 10482 1.1 mrg 10483 1.1 mrg $preload \ 10484 1.1 mrg && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \ 10485 1.1 mrg && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support." 10486 1.1 mrg 10487 1.1 mrg case $host in 10488 1.1 mrg *-*-rhapsody* | *-*-darwin1.[012]) 10489 1.1 mrg # On Rhapsody replace the C library is the System framework 10490 1.1 mrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'` 10491 1.1 mrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'` 10492 1.1 mrg ;; 10493 1.1 mrg esac 10494 1.1 mrg 10495 1.1 mrg case $host in 10496 1.1 mrg *-*-darwin*) 10497 1.1 mrg # Don't allow lazy linking, it breaks C++ global constructors 10498 1.1 mrg # But is supposedly fixed on 10.4 or later (yay!). 10499 1.1 mrg if test CXX = "$tagname"; then 10500 1.1 mrg case ${MACOSX_DEPLOYMENT_TARGET-10.0} in 10501 1.1 mrg 10.[0123]) 10502 1.1 mrg func_append compile_command " $wl-bind_at_load" 10503 1.1 mrg func_append finalize_command " $wl-bind_at_load" 10504 1.1 mrg ;; 10505 1.1 mrg esac 10506 1.1 mrg fi 10507 1.1 mrg # Time to change all our "foo.ltframework" stuff back to "-framework foo" 10508 1.1 mrg compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10509 1.1 mrg finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'` 10510 1.1 mrg ;; 10511 1.1 mrg esac 10512 1.1 mrg 10513 1.1 mrg 10514 1.1 mrg # move library search paths that coincide with paths to not yet 10515 1.1 mrg # installed libraries to the beginning of the library search list 10516 1.1 mrg new_libs= 10517 1.1 mrg for path in $notinst_path; do 10518 1.1 mrg case " $new_libs " in 10519 1.1 mrg *" -L$path/$objdir "*) ;; 10520 1.1 mrg *) 10521 1.1 mrg case " $compile_deplibs " in 10522 1.1 mrg *" -L$path/$objdir "*) 10523 1.1 mrg func_append new_libs " -L$path/$objdir" ;; 10524 1.1 mrg esac 10525 1.1 mrg ;; 10526 1.1 mrg esac 10527 1.1 mrg done 10528 1.1 mrg for deplib in $compile_deplibs; do 10529 1.1 mrg case $deplib in 10530 1.1 mrg -L*) 10531 1.1 mrg case " $new_libs " in 10532 1.1 mrg *" $deplib "*) ;; 10533 1.1 mrg *) func_append new_libs " $deplib" ;; 10534 1.1 mrg esac 10535 1.1 mrg ;; 10536 1.1 mrg *) func_append new_libs " $deplib" ;; 10537 1.1 mrg esac 10538 1.1 mrg done 10539 1.1 mrg compile_deplibs=$new_libs 10540 1.1 mrg 10541 1.1 mrg 10542 1.1 mrg func_append compile_command " $compile_deplibs" 10543 1.1 mrg func_append finalize_command " $finalize_deplibs" 10544 1.1 mrg 10545 1.1 mrg if test -n "$rpath$xrpath"; then 10546 1.1 mrg # If the user specified any rpath flags, then add them. 10547 1.1 mrg for libdir in $rpath $xrpath; do 10548 1.1 mrg # This is the magic to use -rpath. 10549 1.1 mrg case "$finalize_rpath " in 10550 1.1 mrg *" $libdir "*) ;; 10551 1.1 mrg *) func_append finalize_rpath " $libdir" ;; 10552 1.1 mrg esac 10553 1.1 mrg done 10554 1.1 mrg fi 10555 1.1 mrg 10556 1.1 mrg # Now hardcode the library paths 10557 1.1 mrg rpath= 10558 1.1 mrg hardcode_libdirs= 10559 1.1 mrg for libdir in $compile_rpath $finalize_rpath; do 10560 1.1 mrg if test -n "$hardcode_libdir_flag_spec"; then 10561 1.1 mrg if test -n "$hardcode_libdir_separator"; then 10562 1.1 mrg if test -z "$hardcode_libdirs"; then 10563 1.1 mrg hardcode_libdirs=$libdir 10564 1.1 mrg else 10565 1.1 mrg # Just accumulate the unique libdirs. 10566 1.1 mrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10567 1.1 mrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10568 1.1 mrg ;; 10569 1.1 mrg *) 10570 1.1 mrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10571 1.1 mrg ;; 10572 1.1 mrg esac 10573 1.1 mrg fi 10574 1.1 mrg else 10575 1.1 mrg eval flag=\"$hardcode_libdir_flag_spec\" 10576 1.1 mrg func_append rpath " $flag" 10577 1.1 mrg fi 10578 1.1 mrg elif test -n "$runpath_var"; then 10579 1.1 mrg case "$perm_rpath " in 10580 1.1 mrg *" $libdir "*) ;; 10581 1.1 mrg *) func_append perm_rpath " $libdir" ;; 10582 1.1 mrg esac 10583 1.1 mrg fi 10584 1.1 mrg case $host in 10585 1.1 mrg *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*) 10586 1.1 mrg testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'` 10587 1.1 mrg case :$dllsearchpath: in 10588 1.1 mrg *":$libdir:"*) ;; 10589 1.1 mrg ::) dllsearchpath=$libdir;; 10590 1.1 mrg *) func_append dllsearchpath ":$libdir";; 10591 1.1 mrg esac 10592 1.1 mrg case :$dllsearchpath: in 10593 1.1 mrg *":$testbindir:"*) ;; 10594 1.1 mrg ::) dllsearchpath=$testbindir;; 10595 1.1 mrg *) func_append dllsearchpath ":$testbindir";; 10596 1.1 mrg esac 10597 1.1 mrg ;; 10598 1.1 mrg esac 10599 1.1 mrg done 10600 1.1 mrg # Substitute the hardcoded libdirs into the rpath. 10601 1.1 mrg if test -n "$hardcode_libdir_separator" && 10602 1.1 mrg test -n "$hardcode_libdirs"; then 10603 1.1 mrg libdir=$hardcode_libdirs 10604 1.1 mrg eval rpath=\" $hardcode_libdir_flag_spec\" 10605 1.1 mrg fi 10606 1.1 mrg compile_rpath=$rpath 10607 1.1 mrg 10608 1.1 mrg rpath= 10609 1.1 mrg hardcode_libdirs= 10610 1.1 mrg for libdir in $finalize_rpath; do 10611 1.1 mrg if test -n "$hardcode_libdir_flag_spec"; then 10612 1.1 mrg if test -n "$hardcode_libdir_separator"; then 10613 1.1 mrg if test -z "$hardcode_libdirs"; then 10614 1.1 mrg hardcode_libdirs=$libdir 10615 1.1 mrg else 10616 1.1 mrg # Just accumulate the unique libdirs. 10617 1.1 mrg case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in 10618 1.1 mrg *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*) 10619 1.1 mrg ;; 10620 1.1 mrg *) 10621 1.1 mrg func_append hardcode_libdirs "$hardcode_libdir_separator$libdir" 10622 1.1 mrg ;; 10623 1.1 mrg esac 10624 1.1 mrg fi 10625 1.1 mrg else 10626 1.1 mrg eval flag=\"$hardcode_libdir_flag_spec\" 10627 1.1 mrg func_append rpath " $flag" 10628 1.1 mrg fi 10629 1.1 mrg elif test -n "$runpath_var"; then 10630 1.1 mrg case "$finalize_perm_rpath " in 10631 1.1 mrg *" $libdir "*) ;; 10632 1.1 mrg *) func_append finalize_perm_rpath " $libdir" ;; 10633 1.1 mrg esac 10634 1.1 mrg fi 10635 1.1 mrg done 10636 1.1 mrg # Substitute the hardcoded libdirs into the rpath. 10637 1.1 mrg if test -n "$hardcode_libdir_separator" && 10638 1.1 mrg test -n "$hardcode_libdirs"; then 10639 1.1 mrg libdir=$hardcode_libdirs 10640 1.1 mrg eval rpath=\" $hardcode_libdir_flag_spec\" 10641 1.1 mrg fi 10642 1.1 mrg finalize_rpath=$rpath 10643 1.1 mrg 10644 1.1 mrg if test -n "$libobjs" && test yes = "$build_old_libs"; then 10645 1.1 mrg # Transform all the library objects into standard objects. 10646 1.1 mrg compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10647 1.1 mrg finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP` 10648 1.1 mrg fi 10649 1.1 mrg 10650 1.1 mrg func_generate_dlsyms "$outputname" "@PROGRAM@" false 10651 1.1 mrg 10652 1.1 mrg # template prelinking step 10653 1.1 mrg if test -n "$prelink_cmds"; then 10654 1.1 mrg func_execute_cmds "$prelink_cmds" 'exit $?' 10655 1.1 mrg fi 10656 1.1 mrg 10657 1.1 mrg wrappers_required=: 10658 1.1 mrg case $host in 10659 1.1 mrg *cegcc* | *mingw32ce*) 10660 1.1 mrg # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway. 10661 1.1 mrg wrappers_required=false 10662 1.1 mrg ;; 10663 1.1 mrg *cygwin* | *mingw* ) 10664 1.1 mrg test yes = "$build_libtool_libs" || wrappers_required=false 10665 1.1 mrg ;; 10666 1.1 mrg *) 10667 1.1 mrg if test no = "$need_relink" || test yes != "$build_libtool_libs"; then 10668 1.1 mrg wrappers_required=false 10669 1.1 mrg fi 10670 1.1 mrg ;; 10671 1.1 mrg esac 10672 1.1 mrg $wrappers_required || { 10673 1.1 mrg # Replace the output file specification. 10674 1.1 mrg compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10675 1.1 mrg link_command=$compile_command$compile_rpath 10676 1.1 mrg 10677 1.1 mrg # We have no uninstalled library dependencies, so finalize right now. 10678 1.1 mrg exit_status=0 10679 1.1 mrg func_show_eval "$link_command" 'exit_status=$?' 10680 1.1 mrg 10681 1.1 mrg if test -n "$postlink_cmds"; then 10682 1.1 mrg func_to_tool_file "$output" 10683 1.1 mrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10684 1.1 mrg func_execute_cmds "$postlink_cmds" 'exit $?' 10685 1.1 mrg fi 10686 1.1 mrg 10687 1.1 mrg # Delete the generated files. 10688 1.1 mrg if test -f "$output_objdir/${outputname}S.$objext"; then 10689 1.1 mrg func_show_eval '$RM "$output_objdir/${outputname}S.$objext"' 10690 1.1 mrg fi 10691 1.1 mrg 10692 1.1 mrg exit $exit_status 10693 1.1 mrg } 10694 1.1 mrg 10695 1.1 mrg if test -n "$compile_shlibpath$finalize_shlibpath"; then 10696 1.1 mrg compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command" 10697 1.1 mrg fi 10698 1.1 mrg if test -n "$finalize_shlibpath"; then 10699 1.1 mrg finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command" 10700 1.1 mrg fi 10701 1.1 mrg 10702 1.1 mrg compile_var= 10703 1.1 mrg finalize_var= 10704 1.1 mrg if test -n "$runpath_var"; then 10705 1.1 mrg if test -n "$perm_rpath"; then 10706 1.1 mrg # We should set the runpath_var. 10707 1.1 mrg rpath= 10708 1.1 mrg for dir in $perm_rpath; do 10709 1.1 mrg func_append rpath "$dir:" 10710 1.1 mrg done 10711 1.1 mrg compile_var="$runpath_var=\"$rpath\$$runpath_var\" " 10712 1.1 mrg fi 10713 1.1 mrg if test -n "$finalize_perm_rpath"; then 10714 1.1 mrg # We should set the runpath_var. 10715 1.1 mrg rpath= 10716 1.1 mrg for dir in $finalize_perm_rpath; do 10717 1.1 mrg func_append rpath "$dir:" 10718 1.1 mrg done 10719 1.1 mrg finalize_var="$runpath_var=\"$rpath\$$runpath_var\" " 10720 1.1 mrg fi 10721 1.1 mrg fi 10722 1.1 mrg 10723 1.1 mrg if test yes = "$no_install"; then 10724 1.1 mrg # We don't need to create a wrapper script. 10725 1.1 mrg link_command=$compile_var$compile_command$compile_rpath 10726 1.1 mrg # Replace the output file specification. 10727 1.1 mrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'` 10728 1.1 mrg # Delete the old output file. 10729 1.1 mrg $opt_dry_run || $RM $output 10730 1.1 mrg # Link the executable and exit 10731 1.1 mrg func_show_eval "$link_command" 'exit $?' 10732 1.1 mrg 10733 1.1 mrg if test -n "$postlink_cmds"; then 10734 1.1 mrg func_to_tool_file "$output" 10735 1.1 mrg postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'` 10736 1.1 mrg func_execute_cmds "$postlink_cmds" 'exit $?' 10737 1.1 mrg fi 10738 1.1 mrg 10739 1.1 mrg exit $EXIT_SUCCESS 10740 1.1 mrg fi 10741 1.1 mrg 10742 1.1 mrg case $hardcode_action,$fast_install in 10743 1.1 mrg relink,*) 10744 1.1 mrg # Fast installation is not supported 10745 1.1 mrg link_command=$compile_var$compile_command$compile_rpath 10746 1.1 mrg relink_command=$finalize_var$finalize_command$finalize_rpath 10747 1.1 mrg 10748 1.1 mrg func_warning "this platform does not like uninstalled shared libraries" 10749 1.1 mrg func_warning "'$output' will be relinked during installation" 10750 1.1 mrg ;; 10751 1.1 mrg *,yes) 10752 1.1 mrg link_command=$finalize_var$compile_command$finalize_rpath 10753 1.1 mrg relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'` 10754 1.1 mrg ;; 10755 1.1 mrg *,no) 10756 1.1 mrg link_command=$compile_var$compile_command$compile_rpath 10757 1.1 mrg relink_command=$finalize_var$finalize_command$finalize_rpath 10758 1.1 mrg ;; 10759 1.1 mrg *,needless) 10760 1.1 mrg link_command=$finalize_var$compile_command$finalize_rpath 10761 1.1 mrg relink_command= 10762 1.1 mrg ;; 10763 1.1 mrg esac 10764 1.1 mrg 10765 1.1 mrg # Replace the output file specification. 10766 1.1 mrg link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'` 10767 1.1 mrg 10768 1.1 mrg # Delete the old output files. 10769 1.1 mrg $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname 10770 1.1 mrg 10771 1.1 mrg func_show_eval "$link_command" 'exit $?' 10772 1.1 mrg 10773 1.1 mrg if test -n "$postlink_cmds"; then 10774 1.1 mrg func_to_tool_file "$output_objdir/$outputname" 10775 1.1 mrg 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'` 10776 1.1 mrg func_execute_cmds "$postlink_cmds" 'exit $?' 10777 1.1 mrg fi 10778 1.1 mrg 10779 1.1 mrg # Now create the wrapper script. 10780 1.1 mrg func_verbose "creating $output" 10781 1.1 mrg 10782 1.1 mrg # Quote the relink command for shipping. 10783 1.1 mrg if test -n "$relink_command"; then 10784 1.1 mrg # Preserve any variables that may affect compiler behavior 10785 1.1 mrg for var in $variables_saved_for_relink; do 10786 1.1 mrg if eval test -z \"\${$var+set}\"; then 10787 1.1 mrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 10788 1.1 mrg elif eval var_value=\$$var; test -z "$var_value"; then 10789 1.1 mrg relink_command="$var=; export $var; $relink_command" 10790 1.1 mrg else 10791 1.1.1.2 mrg func_quote_arg pretty "$var_value" 10792 1.1.1.2 mrg relink_command="$var=$func_quote_arg_result; export $var; $relink_command" 10793 1.1 mrg fi 10794 1.1 mrg done 10795 1.1.1.2 mrg func_quote eval cd "`pwd`" 10796 1.1.1.2 mrg func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)" 10797 1.1.1.2 mrg relink_command=$func_quote_arg_unquoted_result 10798 1.1 mrg fi 10799 1.1 mrg 10800 1.1 mrg # Only actually do things if not in dry run mode. 10801 1.1 mrg $opt_dry_run || { 10802 1.1 mrg # win32 will think the script is a binary if it has 10803 1.1 mrg # a .exe suffix, so we strip it off here. 10804 1.1 mrg case $output in 10805 1.1 mrg *.exe) func_stripname '' '.exe' "$output" 10806 1.1 mrg output=$func_stripname_result ;; 10807 1.1 mrg esac 10808 1.1 mrg # test for cygwin because mv fails w/o .exe extensions 10809 1.1 mrg case $host in 10810 1.1 mrg *cygwin*) 10811 1.1 mrg exeext=.exe 10812 1.1 mrg func_stripname '' '.exe' "$outputname" 10813 1.1 mrg outputname=$func_stripname_result ;; 10814 1.1 mrg *) exeext= ;; 10815 1.1 mrg esac 10816 1.1 mrg case $host in 10817 1.1 mrg *cygwin* | *mingw* ) 10818 1.1 mrg func_dirname_and_basename "$output" "" "." 10819 1.1 mrg output_name=$func_basename_result 10820 1.1 mrg output_path=$func_dirname_result 10821 1.1 mrg cwrappersource=$output_path/$objdir/lt-$output_name.c 10822 1.1 mrg cwrapper=$output_path/$output_name.exe 10823 1.1 mrg $RM $cwrappersource $cwrapper 10824 1.1 mrg trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15 10825 1.1 mrg 10826 1.1 mrg func_emit_cwrapperexe_src > $cwrappersource 10827 1.1 mrg 10828 1.1 mrg # The wrapper executable is built using the $host compiler, 10829 1.1 mrg # because it contains $host paths and files. If cross- 10830 1.1 mrg # compiling, it, like the target executable, must be 10831 1.1 mrg # executed on the $host or under an emulation environment. 10832 1.1 mrg $opt_dry_run || { 10833 1.1 mrg $LTCC $LTCFLAGS -o $cwrapper $cwrappersource 10834 1.1 mrg $STRIP $cwrapper 10835 1.1 mrg } 10836 1.1 mrg 10837 1.1 mrg # Now, create the wrapper script for func_source use: 10838 1.1 mrg func_ltwrapper_scriptname $cwrapper 10839 1.1 mrg $RM $func_ltwrapper_scriptname_result 10840 1.1 mrg trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15 10841 1.1 mrg $opt_dry_run || { 10842 1.1 mrg # note: this script will not be executed, so do not chmod. 10843 1.1 mrg if test "x$build" = "x$host"; then 10844 1.1 mrg $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result 10845 1.1 mrg else 10846 1.1 mrg func_emit_wrapper no > $func_ltwrapper_scriptname_result 10847 1.1 mrg fi 10848 1.1 mrg } 10849 1.1 mrg ;; 10850 1.1 mrg * ) 10851 1.1 mrg $RM $output 10852 1.1 mrg trap "$RM $output; exit $EXIT_FAILURE" 1 2 15 10853 1.1 mrg 10854 1.1 mrg func_emit_wrapper no > $output 10855 1.1 mrg chmod +x $output 10856 1.1 mrg ;; 10857 1.1 mrg esac 10858 1.1 mrg } 10859 1.1 mrg exit $EXIT_SUCCESS 10860 1.1 mrg ;; 10861 1.1 mrg esac 10862 1.1 mrg 10863 1.1 mrg # See if we need to build an old-fashioned archive. 10864 1.1 mrg for oldlib in $oldlibs; do 10865 1.1 mrg 10866 1.1 mrg case $build_libtool_libs in 10867 1.1 mrg convenience) 10868 1.1 mrg oldobjs="$libobjs_save $symfileobj" 10869 1.1 mrg addlibs=$convenience 10870 1.1 mrg build_libtool_libs=no 10871 1.1 mrg ;; 10872 1.1 mrg module) 10873 1.1 mrg oldobjs=$libobjs_save 10874 1.1 mrg addlibs=$old_convenience 10875 1.1 mrg build_libtool_libs=no 10876 1.1 mrg ;; 10877 1.1 mrg *) 10878 1.1 mrg oldobjs="$old_deplibs $non_pic_objects" 10879 1.1 mrg $preload && test -f "$symfileobj" \ 10880 1.1 mrg && func_append oldobjs " $symfileobj" 10881 1.1 mrg addlibs=$old_convenience 10882 1.1 mrg ;; 10883 1.1 mrg esac 10884 1.1 mrg 10885 1.1 mrg if test -n "$addlibs"; then 10886 1.1 mrg gentop=$output_objdir/${outputname}x 10887 1.1 mrg func_append generated " $gentop" 10888 1.1 mrg 10889 1.1 mrg func_extract_archives $gentop $addlibs 10890 1.1 mrg func_append oldobjs " $func_extract_archives_result" 10891 1.1 mrg fi 10892 1.1 mrg 10893 1.1 mrg # Do each command in the archive commands. 10894 1.1 mrg if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then 10895 1.1 mrg cmds=$old_archive_from_new_cmds 10896 1.1 mrg else 10897 1.1 mrg 10898 1.1 mrg # Add any objects from preloaded convenience libraries 10899 1.1 mrg if test -n "$dlprefiles"; then 10900 1.1 mrg gentop=$output_objdir/${outputname}x 10901 1.1 mrg func_append generated " $gentop" 10902 1.1 mrg 10903 1.1 mrg func_extract_archives $gentop $dlprefiles 10904 1.1 mrg func_append oldobjs " $func_extract_archives_result" 10905 1.1 mrg fi 10906 1.1 mrg 10907 1.1 mrg # POSIX demands no paths to be encoded in archives. We have 10908 1.1 mrg # to avoid creating archives with duplicate basenames if we 10909 1.1 mrg # might have to extract them afterwards, e.g., when creating a 10910 1.1 mrg # static archive out of a convenience library, or when linking 10911 1.1 mrg # the entirety of a libtool archive into another (currently 10912 1.1 mrg # not supported by libtool). 10913 1.1 mrg if (for obj in $oldobjs 10914 1.1 mrg do 10915 1.1 mrg func_basename "$obj" 10916 1.1 mrg $ECHO "$func_basename_result" 10917 1.1 mrg done | sort | sort -uc >/dev/null 2>&1); then 10918 1.1 mrg : 10919 1.1 mrg else 10920 1.1 mrg echo "copying selected object files to avoid basename conflicts..." 10921 1.1 mrg gentop=$output_objdir/${outputname}x 10922 1.1 mrg func_append generated " $gentop" 10923 1.1 mrg func_mkdir_p "$gentop" 10924 1.1 mrg save_oldobjs=$oldobjs 10925 1.1 mrg oldobjs= 10926 1.1 mrg counter=1 10927 1.1 mrg for obj in $save_oldobjs 10928 1.1 mrg do 10929 1.1 mrg func_basename "$obj" 10930 1.1 mrg objbase=$func_basename_result 10931 1.1 mrg case " $oldobjs " in 10932 1.1 mrg " ") oldobjs=$obj ;; 10933 1.1 mrg *[\ /]"$objbase "*) 10934 1.1 mrg while :; do 10935 1.1 mrg # Make sure we don't pick an alternate name that also 10936 1.1 mrg # overlaps. 10937 1.1 mrg newobj=lt$counter-$objbase 10938 1.1 mrg func_arith $counter + 1 10939 1.1 mrg counter=$func_arith_result 10940 1.1 mrg case " $oldobjs " in 10941 1.1 mrg *[\ /]"$newobj "*) ;; 10942 1.1 mrg *) if test ! -f "$gentop/$newobj"; then break; fi ;; 10943 1.1 mrg esac 10944 1.1 mrg done 10945 1.1 mrg func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj" 10946 1.1 mrg func_append oldobjs " $gentop/$newobj" 10947 1.1 mrg ;; 10948 1.1 mrg *) func_append oldobjs " $obj" ;; 10949 1.1 mrg esac 10950 1.1 mrg done 10951 1.1 mrg fi 10952 1.1 mrg func_to_tool_file "$oldlib" func_convert_file_msys_to_w32 10953 1.1 mrg tool_oldlib=$func_to_tool_file_result 10954 1.1 mrg eval cmds=\"$old_archive_cmds\" 10955 1.1 mrg 10956 1.1 mrg func_len " $cmds" 10957 1.1 mrg len=$func_len_result 10958 1.1 mrg if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then 10959 1.1 mrg cmds=$old_archive_cmds 10960 1.1 mrg elif test -n "$archiver_list_spec"; then 10961 1.1 mrg func_verbose "using command file archive linking..." 10962 1.1 mrg for obj in $oldobjs 10963 1.1 mrg do 10964 1.1 mrg func_to_tool_file "$obj" 10965 1.1 mrg $ECHO "$func_to_tool_file_result" 10966 1.1 mrg done > $output_objdir/$libname.libcmd 10967 1.1 mrg func_to_tool_file "$output_objdir/$libname.libcmd" 10968 1.1 mrg oldobjs=" $archiver_list_spec$func_to_tool_file_result" 10969 1.1 mrg cmds=$old_archive_cmds 10970 1.1 mrg else 10971 1.1 mrg # the command line is too long to link in one step, link in parts 10972 1.1 mrg func_verbose "using piecewise archive linking..." 10973 1.1 mrg save_RANLIB=$RANLIB 10974 1.1 mrg RANLIB=: 10975 1.1 mrg objlist= 10976 1.1 mrg concat_cmds= 10977 1.1 mrg save_oldobjs=$oldobjs 10978 1.1 mrg oldobjs= 10979 1.1 mrg # Is there a better way of finding the last object in the list? 10980 1.1 mrg for obj in $save_oldobjs 10981 1.1 mrg do 10982 1.1 mrg last_oldobj=$obj 10983 1.1 mrg done 10984 1.1 mrg eval test_cmds=\"$old_archive_cmds\" 10985 1.1 mrg func_len " $test_cmds" 10986 1.1 mrg len0=$func_len_result 10987 1.1 mrg len=$len0 10988 1.1 mrg for obj in $save_oldobjs 10989 1.1 mrg do 10990 1.1 mrg func_len " $obj" 10991 1.1 mrg func_arith $len + $func_len_result 10992 1.1 mrg len=$func_arith_result 10993 1.1 mrg func_append objlist " $obj" 10994 1.1 mrg if test "$len" -lt "$max_cmd_len"; then 10995 1.1 mrg : 10996 1.1 mrg else 10997 1.1 mrg # the above command should be used before it gets too long 10998 1.1 mrg oldobjs=$objlist 10999 1.1 mrg if test "$obj" = "$last_oldobj"; then 11000 1.1 mrg RANLIB=$save_RANLIB 11001 1.1 mrg fi 11002 1.1 mrg test -z "$concat_cmds" || concat_cmds=$concat_cmds~ 11003 1.1 mrg eval concat_cmds=\"\$concat_cmds$old_archive_cmds\" 11004 1.1 mrg objlist= 11005 1.1 mrg len=$len0 11006 1.1 mrg fi 11007 1.1 mrg done 11008 1.1 mrg RANLIB=$save_RANLIB 11009 1.1 mrg oldobjs=$objlist 11010 1.1 mrg if test -z "$oldobjs"; then 11011 1.1 mrg eval cmds=\"\$concat_cmds\" 11012 1.1 mrg else 11013 1.1 mrg eval cmds=\"\$concat_cmds~\$old_archive_cmds\" 11014 1.1 mrg fi 11015 1.1 mrg fi 11016 1.1 mrg fi 11017 1.1 mrg func_execute_cmds "$cmds" 'exit $?' 11018 1.1 mrg done 11019 1.1 mrg 11020 1.1 mrg test -n "$generated" && \ 11021 1.1 mrg func_show_eval "${RM}r$generated" 11022 1.1 mrg 11023 1.1 mrg # Now create the libtool archive. 11024 1.1 mrg case $output in 11025 1.1 mrg *.la) 11026 1.1 mrg old_library= 11027 1.1 mrg test yes = "$build_old_libs" && old_library=$libname.$libext 11028 1.1 mrg func_verbose "creating $output" 11029 1.1 mrg 11030 1.1 mrg # Preserve any variables that may affect compiler behavior 11031 1.1 mrg for var in $variables_saved_for_relink; do 11032 1.1 mrg if eval test -z \"\${$var+set}\"; then 11033 1.1 mrg relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command" 11034 1.1 mrg elif eval var_value=\$$var; test -z "$var_value"; then 11035 1.1 mrg relink_command="$var=; export $var; $relink_command" 11036 1.1 mrg else 11037 1.1.1.2 mrg func_quote_arg pretty,unquoted "$var_value" 11038 1.1.1.2 mrg relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command" 11039 1.1 mrg fi 11040 1.1 mrg done 11041 1.1 mrg # Quote the link command for shipping. 11042 1.1.1.2 mrg func_quote eval cd "`pwd`" 11043 1.1.1.2 mrg relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)" 11044 1.1.1.2 mrg func_quote_arg pretty,unquoted "$relink_command" 11045 1.1.1.2 mrg relink_command=$func_quote_arg_unquoted_result 11046 1.1 mrg if test yes = "$hardcode_automatic"; then 11047 1.1 mrg relink_command= 11048 1.1 mrg fi 11049 1.1 mrg 11050 1.1 mrg # Only create the output if not a dry run. 11051 1.1 mrg $opt_dry_run || { 11052 1.1 mrg for installed in no yes; do 11053 1.1 mrg if test yes = "$installed"; then 11054 1.1 mrg if test -z "$install_libdir"; then 11055 1.1 mrg break 11056 1.1 mrg fi 11057 1.1 mrg output=$output_objdir/${outputname}i 11058 1.1 mrg # Replace all uninstalled libtool libraries with the installed ones 11059 1.1 mrg newdependency_libs= 11060 1.1 mrg for deplib in $dependency_libs; do 11061 1.1 mrg case $deplib in 11062 1.1 mrg *.la) 11063 1.1 mrg func_basename "$deplib" 11064 1.1 mrg name=$func_basename_result 11065 1.1 mrg func_resolve_sysroot "$deplib" 11066 1.1 mrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result` 11067 1.1 mrg test -z "$libdir" && \ 11068 1.1 mrg func_fatal_error "'$deplib' is not a valid libtool archive" 11069 1.1 mrg func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name" 11070 1.1 mrg ;; 11071 1.1 mrg -L*) 11072 1.1 mrg func_stripname -L '' "$deplib" 11073 1.1 mrg func_replace_sysroot "$func_stripname_result" 11074 1.1 mrg func_append newdependency_libs " -L$func_replace_sysroot_result" 11075 1.1 mrg ;; 11076 1.1 mrg -R*) 11077 1.1 mrg func_stripname -R '' "$deplib" 11078 1.1 mrg func_replace_sysroot "$func_stripname_result" 11079 1.1 mrg func_append newdependency_libs " -R$func_replace_sysroot_result" 11080 1.1 mrg ;; 11081 1.1 mrg *) func_append newdependency_libs " $deplib" ;; 11082 1.1 mrg esac 11083 1.1 mrg done 11084 1.1 mrg dependency_libs=$newdependency_libs 11085 1.1 mrg newdlfiles= 11086 1.1 mrg 11087 1.1 mrg for lib in $dlfiles; do 11088 1.1 mrg case $lib in 11089 1.1 mrg *.la) 11090 1.1 mrg func_basename "$lib" 11091 1.1 mrg name=$func_basename_result 11092 1.1 mrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11093 1.1 mrg test -z "$libdir" && \ 11094 1.1 mrg func_fatal_error "'$lib' is not a valid libtool archive" 11095 1.1 mrg func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name" 11096 1.1 mrg ;; 11097 1.1 mrg *) func_append newdlfiles " $lib" ;; 11098 1.1 mrg esac 11099 1.1 mrg done 11100 1.1 mrg dlfiles=$newdlfiles 11101 1.1 mrg newdlprefiles= 11102 1.1 mrg for lib in $dlprefiles; do 11103 1.1 mrg case $lib in 11104 1.1 mrg *.la) 11105 1.1 mrg # Only pass preopened files to the pseudo-archive (for 11106 1.1 mrg # eventual linking with the app. that links it) if we 11107 1.1 mrg # didn't already link the preopened objects directly into 11108 1.1 mrg # the library: 11109 1.1 mrg func_basename "$lib" 11110 1.1 mrg name=$func_basename_result 11111 1.1 mrg eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib` 11112 1.1 mrg test -z "$libdir" && \ 11113 1.1 mrg func_fatal_error "'$lib' is not a valid libtool archive" 11114 1.1 mrg func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name" 11115 1.1 mrg ;; 11116 1.1 mrg esac 11117 1.1 mrg done 11118 1.1 mrg dlprefiles=$newdlprefiles 11119 1.1 mrg else 11120 1.1 mrg newdlfiles= 11121 1.1 mrg for lib in $dlfiles; do 11122 1.1 mrg case $lib in 11123 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11124 1.1 mrg *) abs=`pwd`"/$lib" ;; 11125 1.1 mrg esac 11126 1.1 mrg func_append newdlfiles " $abs" 11127 1.1 mrg done 11128 1.1 mrg dlfiles=$newdlfiles 11129 1.1 mrg newdlprefiles= 11130 1.1 mrg for lib in $dlprefiles; do 11131 1.1 mrg case $lib in 11132 1.1 mrg [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;; 11133 1.1 mrg *) abs=`pwd`"/$lib" ;; 11134 1.1 mrg esac 11135 1.1 mrg func_append newdlprefiles " $abs" 11136 1.1 mrg done 11137 1.1 mrg dlprefiles=$newdlprefiles 11138 1.1 mrg fi 11139 1.1 mrg $RM $output 11140 1.1 mrg # place dlname in correct position for cygwin 11141 1.1 mrg # In fact, it would be nice if we could use this code for all target 11142 1.1 mrg # systems that can't hard-code library paths into their executables 11143 1.1 mrg # and that have no shared library path variable independent of PATH, 11144 1.1 mrg # but it turns out we can't easily determine that from inspecting 11145 1.1 mrg # libtool variables, so we have to hard-code the OSs to which it 11146 1.1 mrg # applies here; at the moment, that means platforms that use the PE 11147 1.1 mrg # object format with DLL files. See the long comment at the top of 11148 1.1 mrg # tests/bindir.at for full details. 11149 1.1 mrg tdlname=$dlname 11150 1.1 mrg case $host,$output,$installed,$module,$dlname in 11151 1.1 mrg *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) 11152 1.1 mrg # If a -bindir argument was supplied, place the dll there. 11153 1.1 mrg if test -n "$bindir"; then 11154 1.1 mrg func_relative_path "$install_libdir" "$bindir" 11155 1.1 mrg tdlname=$func_relative_path_result/$dlname 11156 1.1 mrg else 11157 1.1 mrg # Otherwise fall back on heuristic. 11158 1.1 mrg tdlname=../bin/$dlname 11159 1.1 mrg fi 11160 1.1 mrg ;; 11161 1.1 mrg esac 11162 1.1 mrg $ECHO > $output "\ 11163 1.1 mrg # $outputname - a libtool library file 11164 1.1 mrg # Generated by $PROGRAM (GNU $PACKAGE) $VERSION 11165 1.1 mrg # 11166 1.1 mrg # Please DO NOT delete this file! 11167 1.1 mrg # It is necessary for linking the library. 11168 1.1 mrg 11169 1.1 mrg # The name that we can dlopen(3). 11170 1.1 mrg dlname='$tdlname' 11171 1.1 mrg 11172 1.1 mrg # Names of this library. 11173 1.1 mrg library_names='$library_names' 11174 1.1 mrg 11175 1.1 mrg # The name of the static archive. 11176 1.1 mrg old_library='$old_library' 11177 1.1 mrg 11178 1.1 mrg # Linker flags that cannot go in dependency_libs. 11179 1.1 mrg inherited_linker_flags='$new_inherited_linker_flags' 11180 1.1 mrg 11181 1.1 mrg # Libraries that this one depends upon. 11182 1.1 mrg dependency_libs='$dependency_libs' 11183 1.1 mrg 11184 1.1 mrg # Names of additional weak libraries provided by this library 11185 1.1 mrg weak_library_names='$weak_libs' 11186 1.1 mrg 11187 1.1 mrg # Version information for $libname. 11188 1.1 mrg current=$current 11189 1.1 mrg age=$age 11190 1.1 mrg revision=$revision 11191 1.1 mrg 11192 1.1 mrg # Is this an already installed library? 11193 1.1 mrg installed=$installed 11194 1.1 mrg 11195 1.1 mrg # Should we warn about portability when linking against -modules? 11196 1.1 mrg shouldnotlink=$module 11197 1.1 mrg 11198 1.1 mrg # Files to dlopen/dlpreopen 11199 1.1 mrg dlopen='$dlfiles' 11200 1.1 mrg dlpreopen='$dlprefiles' 11201 1.1 mrg 11202 1.1 mrg # Directory that this library needs to be installed in: 11203 1.1 mrg libdir='$install_libdir'" 11204 1.1 mrg if test no,yes = "$installed,$need_relink"; then 11205 1.1 mrg $ECHO >> $output "\ 11206 1.1 mrg relink_command=\"$relink_command\"" 11207 1.1 mrg fi 11208 1.1 mrg done 11209 1.1 mrg } 11210 1.1 mrg 11211 1.1 mrg # Do a symbolic link so that the libtool archive can be found in 11212 1.1 mrg # LD_LIBRARY_PATH before the program is installed. 11213 1.1 mrg func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?' 11214 1.1 mrg ;; 11215 1.1 mrg esac 11216 1.1 mrg exit $EXIT_SUCCESS 11217 1.1 mrg } 11218 1.1 mrg 11219 1.1 mrg if test link = "$opt_mode" || test relink = "$opt_mode"; then 11220 1.1 mrg func_mode_link ${1+"$@"} 11221 1.1 mrg fi 11222 1.1 mrg 11223 1.1 mrg 11224 1.1 mrg # func_mode_uninstall arg... 11225 1.1 mrg func_mode_uninstall () 11226 1.1 mrg { 11227 1.1 mrg $debug_cmd 11228 1.1 mrg 11229 1.1 mrg RM=$nonopt 11230 1.1 mrg files= 11231 1.1 mrg rmforce=false 11232 1.1 mrg exit_status=0 11233 1.1 mrg 11234 1.1 mrg # This variable tells wrapper scripts just to set variables rather 11235 1.1 mrg # than running their programs. 11236 1.1 mrg libtool_install_magic=$magic 11237 1.1 mrg 11238 1.1 mrg for arg 11239 1.1 mrg do 11240 1.1 mrg case $arg in 11241 1.1 mrg -f) func_append RM " $arg"; rmforce=: ;; 11242 1.1 mrg -*) func_append RM " $arg" ;; 11243 1.1 mrg *) func_append files " $arg" ;; 11244 1.1 mrg esac 11245 1.1 mrg done 11246 1.1 mrg 11247 1.1 mrg test -z "$RM" && \ 11248 1.1 mrg func_fatal_help "you must specify an RM program" 11249 1.1 mrg 11250 1.1 mrg rmdirs= 11251 1.1 mrg 11252 1.1 mrg for file in $files; do 11253 1.1 mrg func_dirname "$file" "" "." 11254 1.1 mrg dir=$func_dirname_result 11255 1.1 mrg if test . = "$dir"; then 11256 1.1 mrg odir=$objdir 11257 1.1 mrg else 11258 1.1 mrg odir=$dir/$objdir 11259 1.1 mrg fi 11260 1.1 mrg func_basename "$file" 11261 1.1 mrg name=$func_basename_result 11262 1.1 mrg test uninstall = "$opt_mode" && odir=$dir 11263 1.1 mrg 11264 1.1 mrg # Remember odir for removal later, being careful to avoid duplicates 11265 1.1 mrg if test clean = "$opt_mode"; then 11266 1.1 mrg case " $rmdirs " in 11267 1.1 mrg *" $odir "*) ;; 11268 1.1 mrg *) func_append rmdirs " $odir" ;; 11269 1.1 mrg esac 11270 1.1 mrg fi 11271 1.1 mrg 11272 1.1 mrg # Don't error if the file doesn't exist and rm -f was used. 11273 1.1 mrg if { test -L "$file"; } >/dev/null 2>&1 || 11274 1.1 mrg { test -h "$file"; } >/dev/null 2>&1 || 11275 1.1 mrg test -f "$file"; then 11276 1.1 mrg : 11277 1.1 mrg elif test -d "$file"; then 11278 1.1 mrg exit_status=1 11279 1.1 mrg continue 11280 1.1 mrg elif $rmforce; then 11281 1.1 mrg continue 11282 1.1 mrg fi 11283 1.1 mrg 11284 1.1 mrg rmfiles=$file 11285 1.1 mrg 11286 1.1 mrg case $name in 11287 1.1 mrg *.la) 11288 1.1 mrg # Possibly a libtool archive, so verify it. 11289 1.1 mrg if func_lalib_p "$file"; then 11290 1.1 mrg func_source $dir/$name 11291 1.1 mrg 11292 1.1 mrg # Delete the libtool libraries and symlinks. 11293 1.1 mrg for n in $library_names; do 11294 1.1 mrg func_append rmfiles " $odir/$n" 11295 1.1 mrg done 11296 1.1 mrg test -n "$old_library" && func_append rmfiles " $odir/$old_library" 11297 1.1 mrg 11298 1.1 mrg case $opt_mode in 11299 1.1 mrg clean) 11300 1.1 mrg case " $library_names " in 11301 1.1 mrg *" $dlname "*) ;; 11302 1.1 mrg *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;; 11303 1.1 mrg esac 11304 1.1 mrg test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i" 11305 1.1 mrg ;; 11306 1.1 mrg uninstall) 11307 1.1 mrg if test -n "$library_names"; then 11308 1.1 mrg # Do each command in the postuninstall commands. 11309 1.1 mrg func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1' 11310 1.1 mrg fi 11311 1.1 mrg 11312 1.1 mrg if test -n "$old_library"; then 11313 1.1 mrg # Do each command in the old_postuninstall commands. 11314 1.1 mrg func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1' 11315 1.1 mrg fi 11316 1.1 mrg # FIXME: should reinstall the best remaining shared library. 11317 1.1 mrg ;; 11318 1.1 mrg esac 11319 1.1 mrg fi 11320 1.1 mrg ;; 11321 1.1 mrg 11322 1.1 mrg *.lo) 11323 1.1 mrg # Possibly a libtool object, so verify it. 11324 1.1 mrg if func_lalib_p "$file"; then 11325 1.1 mrg 11326 1.1 mrg # Read the .lo file 11327 1.1 mrg func_source $dir/$name 11328 1.1 mrg 11329 1.1 mrg # Add PIC object to the list of files to remove. 11330 1.1 mrg if test -n "$pic_object" && test none != "$pic_object"; then 11331 1.1 mrg func_append rmfiles " $dir/$pic_object" 11332 1.1 mrg fi 11333 1.1 mrg 11334 1.1 mrg # Add non-PIC object to the list of files to remove. 11335 1.1 mrg if test -n "$non_pic_object" && test none != "$non_pic_object"; then 11336 1.1 mrg func_append rmfiles " $dir/$non_pic_object" 11337 1.1 mrg fi 11338 1.1 mrg fi 11339 1.1 mrg ;; 11340 1.1 mrg 11341 1.1 mrg *) 11342 1.1 mrg if test clean = "$opt_mode"; then 11343 1.1 mrg noexename=$name 11344 1.1 mrg case $file in 11345 1.1 mrg *.exe) 11346 1.1 mrg func_stripname '' '.exe' "$file" 11347 1.1 mrg file=$func_stripname_result 11348 1.1 mrg func_stripname '' '.exe' "$name" 11349 1.1 mrg noexename=$func_stripname_result 11350 1.1 mrg # $file with .exe has already been added to rmfiles, 11351 1.1 mrg # add $file without .exe 11352 1.1 mrg func_append rmfiles " $file" 11353 1.1 mrg ;; 11354 1.1 mrg esac 11355 1.1 mrg # Do a test to see if this is a libtool program. 11356 1.1 mrg if func_ltwrapper_p "$file"; then 11357 1.1 mrg if func_ltwrapper_executable_p "$file"; then 11358 1.1 mrg func_ltwrapper_scriptname "$file" 11359 1.1 mrg relink_command= 11360 1.1 mrg func_source $func_ltwrapper_scriptname_result 11361 1.1 mrg func_append rmfiles " $func_ltwrapper_scriptname_result" 11362 1.1 mrg else 11363 1.1 mrg relink_command= 11364 1.1 mrg func_source $dir/$noexename 11365 1.1 mrg fi 11366 1.1 mrg 11367 1.1 mrg # note $name still contains .exe if it was in $file originally 11368 1.1 mrg # as does the version of $file that was added into $rmfiles 11369 1.1 mrg func_append rmfiles " $odir/$name $odir/${name}S.$objext" 11370 1.1 mrg if test yes = "$fast_install" && test -n "$relink_command"; then 11371 1.1 mrg func_append rmfiles " $odir/lt-$name" 11372 1.1 mrg fi 11373 1.1 mrg if test "X$noexename" != "X$name"; then 11374 1.1 mrg func_append rmfiles " $odir/lt-$noexename.c" 11375 1.1 mrg fi 11376 1.1 mrg fi 11377 1.1 mrg fi 11378 1.1 mrg ;; 11379 1.1 mrg esac 11380 1.1 mrg func_show_eval "$RM $rmfiles" 'exit_status=1' 11381 1.1 mrg done 11382 1.1 mrg 11383 1.1 mrg # Try to remove the $objdir's in the directories where we deleted files 11384 1.1 mrg for dir in $rmdirs; do 11385 1.1 mrg if test -d "$dir"; then 11386 1.1 mrg func_show_eval "rmdir $dir >/dev/null 2>&1" 11387 1.1 mrg fi 11388 1.1 mrg done 11389 1.1 mrg 11390 1.1 mrg exit $exit_status 11391 1.1 mrg } 11392 1.1 mrg 11393 1.1 mrg if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then 11394 1.1 mrg func_mode_uninstall ${1+"$@"} 11395 1.1 mrg fi 11396 1.1 mrg 11397 1.1 mrg test -z "$opt_mode" && { 11398 1.1 mrg help=$generic_help 11399 1.1 mrg func_fatal_help "you must specify a MODE" 11400 1.1 mrg } 11401 1.1 mrg 11402 1.1 mrg test -z "$exec_cmd" && \ 11403 1.1 mrg func_fatal_help "invalid operation mode '$opt_mode'" 11404 1.1 mrg 11405 1.1 mrg if test -n "$exec_cmd"; then 11406 1.1 mrg eval exec "$exec_cmd" 11407 1.1 mrg exit $EXIT_FAILURE 11408 1.1 mrg fi 11409 1.1 mrg 11410 1.1 mrg exit $exit_status 11411 1.1 mrg 11412 1.1 mrg 11413 1.1 mrg # The TAGs below are defined such that we never get into a situation 11414 1.1 mrg # where we disable both kinds of libraries. Given conflicting 11415 1.1 mrg # choices, we go for a static library, that is the most portable, 11416 1.1 mrg # since we can't tell whether shared libraries were disabled because 11417 1.1 mrg # the user asked for that or because the platform doesn't support 11418 1.1 mrg # them. This is particularly important on AIX, because we don't 11419 1.1 mrg # support having both static and shared libraries enabled at the same 11420 1.1 mrg # time on that platform, so we default to a shared-only configuration. 11421 1.1 mrg # If a disable-shared tag is given, we'll fallback to a static-only 11422 1.1 mrg # configuration. But we'll never go from static-only to shared-only. 11423 1.1 mrg 11424 1.1 mrg # ### BEGIN LIBTOOL TAG CONFIG: disable-shared 11425 1.1 mrg build_libtool_libs=no 11426 1.1 mrg build_old_libs=yes 11427 1.1 mrg # ### END LIBTOOL TAG CONFIG: disable-shared 11428 1.1 mrg 11429 1.1 mrg # ### BEGIN LIBTOOL TAG CONFIG: disable-static 11430 1.1 mrg build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac` 11431 1.1 mrg # ### END LIBTOOL TAG CONFIG: disable-static 11432 1.1 mrg 11433 1.1 mrg # Local Variables: 11434 1.1 mrg # mode:shell-script 11435 1.1 mrg # sh-indentation:2 11436 1.1 mrg # End: 11437