github的一些开源项目
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

11338 lines
323 KiB

  1. #! /usr/bin/env sh
  2. ## DO NOT EDIT - This file generated from ./build-aux/ltmain.in
  3. ## by inline-source v2019-02-19.15
  4. # libtool (GNU libtool) 2.5.0.1-38c1-dirty
  5. # Provide generalized library-building support services.
  6. # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
  7. # Copyright (C) 1996-2019, 2021-2024 Free Software Foundation, Inc.
  8. # This is free software; see the source for copying conditions. There is NO
  9. # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  10. # GNU Libtool is free software; you can redistribute it and/or modify
  11. # it under the terms of the GNU General Public License as published by
  12. # the Free Software Foundation; either version 2 of the License, or
  13. # (at your option) any later version.
  14. #
  15. # As a special exception to the GNU General Public License,
  16. # if you distribute this file as part of a program or library that
  17. # is built using GNU Libtool, you may include this file under the
  18. # same distribution terms that you use for the rest of that program.
  19. #
  20. # GNU Libtool is distributed in the hope that it will be useful, but
  21. # WITHOUT ANY WARRANTY; without even the implied warranty of
  22. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  23. # General Public License for more details.
  24. #
  25. # You should have received a copy of the GNU General Public License
  26. # along with this program. If not, see <http://www.gnu.org/licenses/>.
  27. PROGRAM=libtool
  28. PACKAGE=libtool
  29. VERSION=2.5.0.1-38c1-dirty
  30. package_revision=2.5.0.1
  31. ## ------ ##
  32. ## Usage. ##
  33. ## ------ ##
  34. # Run './libtool --help' for help with using this script from the
  35. # command line.
  36. ## ------------------------------- ##
  37. ## User overridable command paths. ##
  38. ## ------------------------------- ##
  39. # After configure completes, it has a better idea of some of the
  40. # shell tools we need than the defaults used by the functions shared
  41. # with bootstrap, so set those here where they can still be over-
  42. # ridden by the user, but otherwise take precedence.
  43. : ${AUTOCONF="autoconf"}
  44. : ${AUTOMAKE="automake"}
  45. ## -------------------------- ##
  46. ## Source external libraries. ##
  47. ## -------------------------- ##
  48. # Much of our low-level functionality needs to be sourced from external
  49. # libraries, which are installed to $pkgauxdir.
  50. # Set a version string for this script.
  51. scriptversion=2019-02-19.15; # UTC
  52. # General shell script boiler plate, and helper functions.
  53. # Written by Gary V. Vaughan, 2004
  54. # This is free software. There is NO warranty; not even for
  55. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  56. #
  57. # Copyright (C) 2004-2019, 2021, 2023 Bootstrap Authors
  58. #
  59. # This file is dual licensed under the terms of the MIT license
  60. # <https://opensource.org/licenses/MIT>, and GPL version 2 or later
  61. # <https://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of
  62. # these licenses when using or redistributing this software or any of
  63. # the files within it. See the URLs above, or the file `LICENSE`
  64. # included in the Bootstrap distribution for the full license texts.
  65. # Please report bugs or propose patches to:
  66. # <https://github.com/gnulib-modules/bootstrap/issues>
  67. ## ------ ##
  68. ## Usage. ##
  69. ## ------ ##
  70. # Evaluate this file near the top of your script to gain access to
  71. # the functions and variables defined here:
  72. #
  73. # . `echo "$0" | ${SED-sed} 's|[^/]*$||'`/build-aux/funclib.sh
  74. #
  75. # If you need to override any of the default environment variable
  76. # settings, do that before evaluating this file.
  77. ## -------------------- ##
  78. ## Shell normalisation. ##
  79. ## -------------------- ##
  80. # Some shells need a little help to be as Bourne compatible as possible.
  81. # Before doing anything else, make sure all that help has been provided!
  82. DUALCASE=1; export DUALCASE # for MKS sh
  83. if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then :
  84. emulate sh
  85. NULLCMD=:
  86. # Pre-4.2 versions of Zsh do word splitting on ${1+"$@"}, which
  87. # is contrary to our usage. Disable this feature.
  88. alias -g '${1+"$@"}'='"$@"'
  89. setopt NO_GLOB_SUBST
  90. else
  91. case `(set -o) 2>/dev/null` in *posix*) set -o posix ;; esac
  92. fi
  93. # NLS nuisances: We save the old values in case they are required later.
  94. _G_user_locale=
  95. _G_safe_locale=
  96. for _G_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
  97. do
  98. eval "if test set = \"\${$_G_var+set}\"; then
  99. save_$_G_var=\$$_G_var
  100. $_G_var=C
  101. export $_G_var
  102. _G_user_locale=\"$_G_var=\\\$save_\$_G_var; \$_G_user_locale\"
  103. _G_safe_locale=\"$_G_var=C; \$_G_safe_locale\"
  104. fi"
  105. done
  106. # These NLS vars are set unconditionally (bootstrap issue #24). Unset those
  107. # in case the environment reset is needed later and the $save_* variant is not
  108. # defined (see the code above).
  109. LC_ALL=C
  110. LANGUAGE=C
  111. export LANGUAGE LC_ALL
  112. # Make sure IFS has a sensible default
  113. sp=' '
  114. nl='
  115. '
  116. IFS="$sp $nl"
  117. # There are apparently some systems that use ';' as a PATH separator!
  118. if test "${PATH_SEPARATOR+set}" != set; then
  119. PATH_SEPARATOR=:
  120. (PATH='/bin;/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 && {
  121. (PATH='/bin:/bin'; FPATH=$PATH; sh -c :) >/dev/null 2>&1 ||
  122. PATH_SEPARATOR=';'
  123. }
  124. fi
  125. # func_unset VAR
  126. # --------------
  127. # Portably unset VAR.
  128. # In some shells, an 'unset VAR' statement leaves a non-zero return
  129. # status if VAR is already unset, which might be problematic if the
  130. # statement is used at the end of a function (thus poisoning its return
  131. # value) or when 'set -e' is active (causing even a spurious abort of
  132. # the script in this case).
  133. func_unset ()
  134. {
  135. { eval $1=; (eval unset $1) >/dev/null 2>&1 && eval unset $1 || : ; }
  136. }
  137. # Make sure CDPATH doesn't cause `cd` commands to output the target dir.
  138. func_unset CDPATH
  139. # Make sure ${,E,F}GREP behave sanely.
  140. func_unset GREP_OPTIONS
  141. ## ------------------------- ##
  142. ## Locate command utilities. ##
  143. ## ------------------------- ##
  144. # func_executable_p FILE
  145. # ----------------------
  146. # Check that FILE is an executable regular file.
  147. func_executable_p ()
  148. {
  149. test -f "$1" && test -x "$1"
  150. }
  151. # func_path_progs PROGS_LIST CHECK_FUNC [PATH]
  152. # --------------------------------------------
  153. # Search for either a program that responds to --version with output
  154. # containing "GNU", or else returned by CHECK_FUNC otherwise, by
  155. # trying all the directories in PATH with each of the elements of
  156. # PROGS_LIST.
  157. #
  158. # CHECK_FUNC should accept the path to a candidate program, and
  159. # set $func_check_prog_result if it truncates its output less than
  160. # $_G_path_prog_max characters.
  161. func_path_progs ()
  162. {
  163. _G_progs_list=$1
  164. _G_check_func=$2
  165. _G_PATH=${3-"$PATH"}
  166. _G_path_prog_max=0
  167. _G_path_prog_found=false
  168. _G_save_IFS=$IFS; IFS=${PATH_SEPARATOR-:}
  169. for _G_dir in $_G_PATH; do
  170. IFS=$_G_save_IFS
  171. test -z "$_G_dir" && _G_dir=.
  172. for _G_prog_name in $_G_progs_list; do
  173. for _exeext in '' .EXE; do
  174. _G_path_prog=$_G_dir/$_G_prog_name$_exeext
  175. func_executable_p "$_G_path_prog" || continue
  176. case `"$_G_path_prog" --version 2>&1` in
  177. *GNU*) func_path_progs_result=$_G_path_prog _G_path_prog_found=: ;;
  178. *) $_G_check_func $_G_path_prog
  179. func_path_progs_result=$func_check_prog_result
  180. ;;
  181. esac
  182. $_G_path_prog_found && break 3
  183. done
  184. done
  185. done
  186. IFS=$_G_save_IFS
  187. test -z "$func_path_progs_result" && {
  188. echo "no acceptable sed could be found in \$PATH" >&2
  189. exit 1
  190. }
  191. }
  192. # We want to be able to use the functions in this file before configure
  193. # has figured out where the best binaries are kept, which means we have
  194. # to search for them ourselves - except when the results are already set
  195. # where we skip the searches.
  196. # Unless the user overrides by setting SED, search the path for either GNU
  197. # sed, or the sed that truncates its output the least.
  198. test -z "$SED" && {
  199. _G_sed_script=s/aaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaaa/bbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbbb/
  200. for _G_i in 1 2 3 4 5 6 7; do
  201. _G_sed_script=$_G_sed_script$nl$_G_sed_script
  202. done
  203. echo "$_G_sed_script" 2>/dev/null | sed 99q >conftest.sed
  204. _G_sed_script=
  205. func_check_prog_sed ()
  206. {
  207. _G_path_prog=$1
  208. _G_count=0
  209. printf 0123456789 >conftest.in
  210. while :
  211. do
  212. cat conftest.in conftest.in >conftest.tmp
  213. mv conftest.tmp conftest.in
  214. cp conftest.in conftest.nl
  215. echo '' >> conftest.nl
  216. "$_G_path_prog" -f conftest.sed <conftest.nl >conftest.out 2>/dev/null || break
  217. diff conftest.out conftest.nl >/dev/null 2>&1 || break
  218. _G_count=`expr $_G_count + 1`
  219. if test "$_G_count" -gt "$_G_path_prog_max"; then
  220. # Best one so far, save it but keep looking for a better one
  221. func_check_prog_result=$_G_path_prog
  222. _G_path_prog_max=$_G_count
  223. fi
  224. # 10*(2^10) chars as input seems more than enough
  225. test 10 -lt "$_G_count" && break
  226. done
  227. rm -f conftest.in conftest.tmp conftest.nl conftest.out
  228. }
  229. func_path_progs "sed gsed" func_check_prog_sed "$PATH:/usr/xpg4/bin"
  230. rm -f conftest.sed
  231. SED=$func_path_progs_result
  232. }
  233. # Unless the user overrides by setting GREP, search the path for either GNU
  234. # grep, or the grep that truncates its output the least.
  235. test -z "$GREP" && {
  236. func_check_prog_grep ()
  237. {
  238. _G_path_prog=$1
  239. _G_count=0
  240. _G_path_prog_max=0
  241. printf 0123456789 >conftest.in
  242. while :
  243. do
  244. cat conftest.in conftest.in >conftest.tmp
  245. mv conftest.tmp conftest.in
  246. cp conftest.in conftest.nl
  247. echo 'GREP' >> conftest.nl
  248. "$_G_path_prog" -e 'GREP$' -e '-(cannot match)-' <conftest.nl >conftest.out 2>/dev/null || break
  249. diff conftest.out conftest.nl >/dev/null 2>&1 || break
  250. _G_count=`expr $_G_count + 1`
  251. if test "$_G_count" -gt "$_G_path_prog_max"; then
  252. # Best one so far, save it but keep looking for a better one
  253. func_check_prog_result=$_G_path_prog
  254. _G_path_prog_max=$_G_count
  255. fi
  256. # 10*(2^10) chars as input seems more than enough
  257. test 10 -lt "$_G_count" && break
  258. done
  259. rm -f conftest.in conftest.tmp conftest.nl conftest.out
  260. }
  261. func_path_progs "grep ggrep" func_check_prog_grep "$PATH:/usr/xpg4/bin"
  262. GREP=$func_path_progs_result
  263. }
  264. ## ------------------------------- ##
  265. ## User overridable command paths. ##
  266. ## ------------------------------- ##
  267. # All uppercase variable names are used for environment variables. These
  268. # variables can be overridden by the user before calling a script that
  269. # uses them if a suitable command of that name is not already available
  270. # in the command search PATH.
  271. : ${CP="cp -f"}
  272. : ${ECHO="printf %s\n"}
  273. : ${EGREP="$GREP -E"}
  274. : ${FGREP="$GREP -F"}
  275. : ${LN_S="ln -s"}
  276. : ${MAKE="make"}
  277. : ${MKDIR="mkdir"}
  278. : ${MV="mv -f"}
  279. : ${RM="rm -f"}
  280. : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
  281. ## -------------------- ##
  282. ## Useful sed snippets. ##
  283. ## -------------------- ##
  284. sed_dirname='s|/[^/]*$||'
  285. sed_basename='s|^.*/||'
  286. # Sed substitution that helps us do robust quoting. It backslashifies
  287. # metacharacters that are still active within double-quoted strings.
  288. sed_quote_subst='s|\([`"$\\]\)|\\\1|g'
  289. # Same as above, but do not quote variable references.
  290. sed_double_quote_subst='s/\(["`\\]\)/\\\1/g'
  291. # Sed substitution that turns a string into a regex matching for the
  292. # string literally.
  293. sed_make_literal_regex='s|[].[^$\\*\/]|\\&|g'
  294. # Sed substitution that converts a w32 file name or path
  295. # that contains forward slashes, into one that contains
  296. # (escaped) backslashes. A very naive implementation.
  297. sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
  298. # Re-'\' parameter expansions in output of sed_double_quote_subst that
  299. # were '\'-ed in input to the same. If an odd number of '\' preceded a
  300. # '$' in input to sed_double_quote_subst, that '$' was protected from
  301. # expansion. Since each input '\' is now two '\'s, look for any number
  302. # of runs of four '\'s followed by two '\'s and then a '$'. '\' that '$'.
  303. _G_bs='\\'
  304. _G_bs2='\\\\'
  305. _G_bs4='\\\\\\\\'
  306. _G_dollar='\$'
  307. sed_double_backslash="\
  308. s/$_G_bs4/&\\
  309. /g
  310. s/^$_G_bs2$_G_dollar/$_G_bs&/
  311. s/\\([^$_G_bs]\\)$_G_bs2$_G_dollar/\\1$_G_bs2$_G_bs$_G_dollar/g
  312. s/\n//g"
  313. # require_check_ifs_backslash
  314. # ---------------------------
  315. # Check if we can use backslash as IFS='\' separator, and set
  316. # $check_ifs_backshlash_broken to ':' or 'false'.
  317. require_check_ifs_backslash=func_require_check_ifs_backslash
  318. func_require_check_ifs_backslash ()
  319. {
  320. _G_save_IFS=$IFS
  321. IFS='\'
  322. _G_check_ifs_backshlash='a\\b'
  323. for _G_i in $_G_check_ifs_backshlash
  324. do
  325. case $_G_i in
  326. a)
  327. check_ifs_backshlash_broken=false
  328. ;;
  329. '')
  330. break
  331. ;;
  332. *)
  333. check_ifs_backshlash_broken=:
  334. break
  335. ;;
  336. esac
  337. done
  338. IFS=$_G_save_IFS
  339. require_check_ifs_backslash=:
  340. }
  341. ## ----------------- ##
  342. ## Global variables. ##
  343. ## ----------------- ##
  344. # Except for the global variables explicitly listed below, the following
  345. # functions in the '^func_' namespace, and the '^require_' namespace
  346. # variables initialised in the 'Resource management' section, sourcing
  347. # this file will not pollute your global namespace with anything
  348. # else. There's no portable way to scope variables in Bourne shell
  349. # though, so actually running these functions will sometimes place
  350. # results into a variable named after the function, and often use
  351. # temporary variables in the '^_G_' namespace. If you are careful to
  352. # avoid using those namespaces casually in your sourcing script, things
  353. # should continue to work as you expect. And, of course, you can freely
  354. # overwrite any of the functions or variables defined here before
  355. # calling anything to customize them.
  356. EXIT_SUCCESS=0
  357. EXIT_FAILURE=1
  358. EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
  359. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
  360. # Allow overriding, eg assuming that you follow the convention of
  361. # putting '$debug_cmd' at the start of all your functions, you can get
  362. # bash to show function call trace with:
  363. #
  364. # debug_cmd='eval echo "${FUNCNAME[0]} $*" >&2' bash your-script-name
  365. debug_cmd=${debug_cmd-":"}
  366. exit_cmd=:
  367. # By convention, finish your script with:
  368. #
  369. # exit $exit_status
  370. #
  371. # so that you can set exit_status to non-zero if you want to indicate
  372. # something went wrong during execution without actually bailing out at
  373. # the point of failure.
  374. exit_status=$EXIT_SUCCESS
  375. # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
  376. # is ksh but when the shell is invoked as "sh" and the current value of
  377. # the _XPG environment variable is not equal to 1 (one), the special
  378. # positional parameter $0, within a function call, is the name of the
  379. # function.
  380. progpath=$0
  381. # The name of this program.
  382. progname=`$ECHO "$progpath" |$SED "$sed_basename"`
  383. # Make sure we have an absolute progpath for reexecution:
  384. case $progpath in
  385. [\\/]*|[A-Za-z]:\\*) ;;
  386. *[\\/]*)
  387. progdir=`$ECHO "$progpath" |$SED "$sed_dirname"`
  388. progdir=`cd "$progdir" && pwd`
  389. progpath=$progdir/$progname
  390. ;;
  391. *)
  392. _G_IFS=$IFS
  393. IFS=${PATH_SEPARATOR-:}
  394. for progdir in $PATH; do
  395. IFS=$_G_IFS
  396. test -x "$progdir/$progname" && break
  397. done
  398. IFS=$_G_IFS
  399. test -n "$progdir" || progdir=`pwd`
  400. progpath=$progdir/$progname
  401. ;;
  402. esac
  403. ## ----------------- ##
  404. ## Standard options. ##
  405. ## ----------------- ##
  406. # The following options affect the operation of the functions defined
  407. # below, and should be set appropriately depending on run-time para-
  408. # meters passed on the command line.
  409. opt_dry_run=false
  410. opt_quiet=false
  411. opt_verbose=false
  412. # Categories 'all' and 'none' are always available. Append any others
  413. # you will pass as the first argument to func_warning from your own
  414. # code.
  415. warning_categories=
  416. # By default, display warnings according to 'opt_warning_types'. Set
  417. # 'warning_func' to ':' to elide all warnings, or func_fatal_error to
  418. # treat the next displayed warning as a fatal error.
  419. warning_func=func_warn_and_continue
  420. # Set to 'all' to display all warnings, 'none' to suppress all
  421. # warnings, or a space delimited list of some subset of
  422. # 'warning_categories' to display only the listed warnings.
  423. opt_warning_types=all
  424. ## -------------------- ##
  425. ## Resource management. ##
  426. ## -------------------- ##
  427. # This section contains definitions for functions that each ensure a
  428. # particular resource (a file, or a non-empty configuration variable for
  429. # example) is available, and if appropriate to extract default values
  430. # from pertinent package files. Call them using their associated
  431. # 'require_*' variable to ensure that they are executed, at most, once.
  432. #
  433. # It's entirely deliberate that calling these functions can set
  434. # variables that don't obey the namespace limitations obeyed by the rest
  435. # of this file, in order that that they be as useful as possible to
  436. # callers.
  437. # require_term_colors
  438. # -------------------
  439. # Allow display of bold text on terminals that support it.
  440. require_term_colors=func_require_term_colors
  441. func_require_term_colors ()
  442. {
  443. $debug_cmd
  444. test -t 1 && {
  445. # COLORTERM and USE_ANSI_COLORS environment variables take
  446. # precedence, because most terminfo databases neglect to describe
  447. # whether color sequences are supported.
  448. test -n "${COLORTERM+set}" && : ${USE_ANSI_COLORS="1"}
  449. if test 1 = "$USE_ANSI_COLORS"; then
  450. # Standard ANSI escape sequences
  451. tc_reset=''
  452. tc_bold=''; tc_standout=''
  453. tc_red=''; tc_green=''
  454. tc_blue=''; tc_cyan=''
  455. else
  456. # Otherwise trust the terminfo database after all.
  457. test -n "`tput sgr0 2>/dev/null`" && {
  458. tc_reset=`tput sgr0`
  459. test -n "`tput bold 2>/dev/null`" && tc_bold=`tput bold`
  460. tc_standout=$tc_bold
  461. test -n "`tput smso 2>/dev/null`" && tc_standout=`tput smso`
  462. test -n "`tput setaf 1 2>/dev/null`" && tc_red=`tput setaf 1`
  463. test -n "`tput setaf 2 2>/dev/null`" && tc_green=`tput setaf 2`
  464. test -n "`tput setaf 4 2>/dev/null`" && tc_blue=`tput setaf 4`
  465. test -n "`tput setaf 5 2>/dev/null`" && tc_cyan=`tput setaf 5`
  466. }
  467. fi
  468. }
  469. require_term_colors=:
  470. }
  471. ## ----------------- ##
  472. ## Function library. ##
  473. ## ----------------- ##
  474. # This section contains a variety of useful functions to call in your
  475. # scripts. Take note of the portable wrappers for features provided by
  476. # some modern shells, which will fall back to slower equivalents on
  477. # less featureful shells.
  478. # func_append VAR VALUE
  479. # ---------------------
  480. # Append VALUE onto the existing contents of VAR.
  481. # We should try to minimise forks, especially on Windows where they are
  482. # unreasonably slow, so skip the feature probes when bash or zsh are
  483. # being used:
  484. if test set = "${BASH_VERSION+set}${ZSH_VERSION+set}"; then
  485. : ${_G_HAVE_ARITH_OP="yes"}
  486. : ${_G_HAVE_XSI_OPS="yes"}
  487. # The += operator was introduced in bash 3.1
  488. case $BASH_VERSION in
  489. [12].* | 3.0 | 3.0*) ;;
  490. *)
  491. : ${_G_HAVE_PLUSEQ_OP="yes"}
  492. ;;
  493. esac
  494. fi
  495. # _G_HAVE_PLUSEQ_OP
  496. # Can be empty, in which case the shell is probed, "yes" if += is
  497. # useable or anything else if it does not work.
  498. test -z "$_G_HAVE_PLUSEQ_OP" \
  499. && (eval 'x=a; x+=" b"; test "a b" = "$x"') 2>/dev/null \
  500. && _G_HAVE_PLUSEQ_OP=yes
  501. if test yes = "$_G_HAVE_PLUSEQ_OP"
  502. then
  503. # This is an XSI compatible shell, allowing a faster implementation...
  504. eval 'func_append ()
  505. {
  506. $debug_cmd
  507. eval "$1+=\$2"
  508. }'
  509. else
  510. # ...otherwise fall back to using expr, which is often a shell builtin.
  511. func_append ()
  512. {
  513. $debug_cmd
  514. eval "$1=\$$1\$2"
  515. }
  516. fi
  517. # func_append_quoted VAR VALUE
  518. # ----------------------------
  519. # Quote VALUE and append to the end of shell variable VAR, separated
  520. # by a space.
  521. if test yes = "$_G_HAVE_PLUSEQ_OP"; then
  522. eval 'func_append_quoted ()
  523. {
  524. $debug_cmd
  525. func_quote_arg pretty "$2"
  526. eval "$1+=\\ \$func_quote_arg_result"
  527. }'
  528. else
  529. func_append_quoted ()
  530. {
  531. $debug_cmd
  532. func_quote_arg pretty "$2"
  533. eval "$1=\$$1\\ \$func_quote_arg_result"
  534. }
  535. fi
  536. # func_append_uniq VAR VALUE
  537. # --------------------------
  538. # Append unique VALUE onto the existing contents of VAR, assuming
  539. # entries are delimited by the first character of VALUE. For example:
  540. #
  541. # func_append_uniq options " --another-option option-argument"
  542. #
  543. # will only append to $options if " --another-option option-argument "
  544. # is not already present somewhere in $options already (note spaces at
  545. # each end implied by leading space in second argument).
  546. func_append_uniq ()
  547. {
  548. $debug_cmd
  549. eval _G_current_value='`$ECHO $'$1'`'
  550. _G_delim=`expr "$2" : '\(.\)'`
  551. case $_G_delim$_G_current_value$_G_delim in
  552. *"$2$_G_delim"*) ;;
  553. *) func_append "$@" ;;
  554. esac
  555. }
  556. # func_arith TERM...
  557. # ------------------
  558. # Set func_arith_result to the result of evaluating TERMs.
  559. test -z "$_G_HAVE_ARITH_OP" \
  560. && (eval 'test 2 = $(( 1 + 1 ))') 2>/dev/null \
  561. && _G_HAVE_ARITH_OP=yes
  562. if test yes = "$_G_HAVE_ARITH_OP"; then
  563. eval 'func_arith ()
  564. {
  565. $debug_cmd
  566. func_arith_result=$(( $* ))
  567. }'
  568. else
  569. func_arith ()
  570. {
  571. $debug_cmd
  572. func_arith_result=`expr "$@"`
  573. }
  574. fi
  575. # func_basename FILE
  576. # ------------------
  577. # Set func_basename_result to FILE with everything up to and including
  578. # the last / stripped.
  579. if test yes = "$_G_HAVE_XSI_OPS"; then
  580. # If this shell supports suffix pattern removal, then use it to avoid
  581. # forking. Hide the definitions single quotes in case the shell chokes
  582. # on unsupported syntax...
  583. _b='func_basename_result=${1##*/}'
  584. _d='case $1 in
  585. */*) func_dirname_result=${1%/*}$2 ;;
  586. * ) func_dirname_result=$3 ;;
  587. esac'
  588. else
  589. # ...otherwise fall back to using sed.
  590. _b='func_basename_result=`$ECHO "$1" |$SED "$sed_basename"`'
  591. _d='func_dirname_result=`$ECHO "$1" |$SED "$sed_dirname"`
  592. if test "X$func_dirname_result" = "X$1"; then
  593. func_dirname_result=$3
  594. else
  595. func_append func_dirname_result "$2"
  596. fi'
  597. fi
  598. eval 'func_basename ()
  599. {
  600. $debug_cmd
  601. '"$_b"'
  602. }'
  603. # func_dirname FILE APPEND NONDIR_REPLACEMENT
  604. # -------------------------------------------
  605. # Compute the dirname of FILE. If nonempty, add APPEND to the result,
  606. # otherwise set result to NONDIR_REPLACEMENT.
  607. eval 'func_dirname ()
  608. {
  609. $debug_cmd
  610. '"$_d"'
  611. }'
  612. # func_dirname_and_basename FILE APPEND NONDIR_REPLACEMENT
  613. # --------------------------------------------------------
  614. # Perform func_basename and func_dirname in a single function
  615. # call:
  616. # dirname: Compute the dirname of FILE. If nonempty,
  617. # add APPEND to the result, otherwise set result
  618. # to NONDIR_REPLACEMENT.
  619. # value returned in "$func_dirname_result"
  620. # basename: Compute filename of FILE.
  621. # value retuned in "$func_basename_result"
  622. # For efficiency, we do not delegate to the functions above but instead
  623. # duplicate the functionality here.
  624. eval 'func_dirname_and_basename ()
  625. {
  626. $debug_cmd
  627. '"$_b"'
  628. '"$_d"'
  629. }'
  630. # func_echo ARG...
  631. # ----------------
  632. # Echo program name prefixed message.
  633. func_echo ()
  634. {
  635. $debug_cmd
  636. _G_message=$*
  637. func_echo_IFS=$IFS
  638. IFS=$nl
  639. for _G_line in $_G_message; do
  640. IFS=$func_echo_IFS
  641. $ECHO "$progname: $_G_line"
  642. done
  643. IFS=$func_echo_IFS
  644. }
  645. # func_echo_all ARG...
  646. # --------------------
  647. # Invoke $ECHO with all args, space-separated.
  648. func_echo_all ()
  649. {
  650. $ECHO "$*"
  651. }
  652. # func_echo_infix_1 INFIX ARG...
  653. # ------------------------------
  654. # Echo program name, followed by INFIX on the first line, with any
  655. # additional lines not showing INFIX.
  656. func_echo_infix_1 ()
  657. {
  658. $debug_cmd
  659. $require_term_colors
  660. _G_infix=$1; shift
  661. _G_indent=$_G_infix
  662. _G_prefix="$progname: $_G_infix: "
  663. _G_message=$*
  664. # Strip color escape sequences before counting printable length
  665. for _G_tc in "$tc_reset" "$tc_bold" "$tc_standout" "$tc_red" "$tc_green" "$tc_blue" "$tc_cyan"
  666. do
  667. test -n "$_G_tc" && {
  668. _G_esc_tc=`$ECHO "$_G_tc" | $SED "$sed_make_literal_regex"`
  669. _G_indent=`$ECHO "$_G_indent" | $SED "s|$_G_esc_tc||g"`
  670. }
  671. done
  672. _G_indent="$progname: "`echo "$_G_indent" | $SED 's|.| |g'`" " ## exclude from sc_prohibit_nested_quotes
  673. func_echo_infix_1_IFS=$IFS
  674. IFS=$nl
  675. for _G_line in $_G_message; do
  676. IFS=$func_echo_infix_1_IFS
  677. $ECHO "$_G_prefix$tc_bold$_G_line$tc_reset" >&2
  678. _G_prefix=$_G_indent
  679. done
  680. IFS=$func_echo_infix_1_IFS
  681. }
  682. # func_error ARG...
  683. # -----------------
  684. # Echo program name prefixed message to standard error.
  685. func_error ()
  686. {
  687. $debug_cmd
  688. $require_term_colors
  689. func_echo_infix_1 " $tc_standout${tc_red}error$tc_reset" "$*" >&2
  690. }
  691. # func_fatal_error ARG...
  692. # -----------------------
  693. # Echo program name prefixed message to standard error, and exit.
  694. func_fatal_error ()
  695. {
  696. $debug_cmd
  697. func_error "$*"
  698. exit $EXIT_FAILURE
  699. }
  700. # func_grep EXPRESSION FILENAME
  701. # -----------------------------
  702. # Check whether EXPRESSION matches any line of FILENAME, without output.
  703. func_grep ()
  704. {
  705. $debug_cmd
  706. $GREP "$1" "$2" >/dev/null 2>&1
  707. }
  708. # func_len STRING
  709. # ---------------
  710. # Set func_len_result to the length of STRING. STRING may not
  711. # start with a hyphen.
  712. test -z "$_G_HAVE_XSI_OPS" \
  713. && (eval 'x=a/b/c;
  714. test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
  715. && _G_HAVE_XSI_OPS=yes
  716. if test yes = "$_G_HAVE_XSI_OPS"; then
  717. eval 'func_len ()
  718. {
  719. $debug_cmd
  720. func_len_result=${#1}
  721. }'
  722. else
  723. func_len ()
  724. {
  725. $debug_cmd
  726. func_len_result=`expr "$1" : ".*" 2>/dev/null || echo $max_cmd_len`
  727. }
  728. fi
  729. # func_mkdir_p DIRECTORY-PATH
  730. # ---------------------------
  731. # Make sure the entire path to DIRECTORY-PATH is available.
  732. func_mkdir_p ()
  733. {
  734. $debug_cmd
  735. _G_directory_path=$1
  736. _G_dir_list=
  737. if test -n "$_G_directory_path" && test : != "$opt_dry_run"; then
  738. # Protect directory names starting with '-'
  739. case $_G_directory_path in
  740. -*) _G_directory_path=./$_G_directory_path ;;
  741. esac
  742. # While some portion of DIR does not yet exist...
  743. while test ! -d "$_G_directory_path"; do
  744. # ...make a list in topmost first order. Use a colon delimited
  745. # list incase some portion of path contains whitespace.
  746. _G_dir_list=$_G_directory_path:$_G_dir_list
  747. # If the last portion added has no slash in it, the list is done
  748. case $_G_directory_path in */*) ;; *) break ;; esac
  749. # ...otherwise throw away the child directory and loop
  750. _G_directory_path=`$ECHO "$_G_directory_path" | $SED -e "$sed_dirname"`
  751. done
  752. _G_dir_list=`$ECHO "$_G_dir_list" | $SED 's|:*$||'`
  753. func_mkdir_p_IFS=$IFS; IFS=:
  754. for _G_dir in $_G_dir_list; do
  755. IFS=$func_mkdir_p_IFS
  756. # mkdir can fail with a 'File exist' error if two processes
  757. # try to create one of the directories concurrently. Don't
  758. # stop in that case!
  759. $MKDIR "$_G_dir" 2>/dev/null || :
  760. done
  761. IFS=$func_mkdir_p_IFS
  762. # Bail out if we (or some other process) failed to create a directory.
  763. test -d "$_G_directory_path" || \
  764. func_fatal_error "Failed to create '$1'"
  765. fi
  766. }
  767. # func_mktempdir [BASENAME]
  768. # -------------------------
  769. # Make a temporary directory that won't clash with other running
  770. # libtool processes, and avoids race conditions if possible. If
  771. # given, BASENAME is the basename for that directory.
  772. func_mktempdir ()
  773. {
  774. $debug_cmd
  775. _G_template=${TMPDIR-/tmp}/${1-$progname}
  776. if test : = "$opt_dry_run"; then
  777. # Return a directory name, but don't create it in dry-run mode
  778. _G_tmpdir=$_G_template-$$
  779. else
  780. # If mktemp works, use that first and foremost
  781. _G_tmpdir=`mktemp -d "$_G_template-XXXXXXXX" 2>/dev/null`
  782. if test ! -d "$_G_tmpdir"; then
  783. # Failing that, at least try and use $RANDOM to avoid a race
  784. _G_tmpdir=$_G_template-${RANDOM-0}$$
  785. func_mktempdir_umask=`umask`
  786. umask 0077
  787. $MKDIR "$_G_tmpdir"
  788. umask $func_mktempdir_umask
  789. fi
  790. # If we're not in dry-run mode, bomb out on failure
  791. test -d "$_G_tmpdir" || \
  792. func_fatal_error "cannot create temporary directory '$_G_tmpdir'"
  793. fi
  794. $ECHO "$_G_tmpdir"
  795. }
  796. # func_normal_abspath PATH
  797. # ------------------------
  798. # Remove doubled-up and trailing slashes, "." path components,
  799. # and cancel out any ".." path components in PATH after making
  800. # it an absolute path.
  801. func_normal_abspath ()
  802. {
  803. $debug_cmd
  804. # These SED scripts presuppose an absolute path with a trailing slash.
  805. _G_pathcar='s|^/\([^/]*\).*$|\1|'
  806. _G_pathcdr='s|^/[^/]*||'
  807. _G_removedotparts=':dotsl
  808. s|/\./|/|g
  809. t dotsl
  810. s|/\.$|/|'
  811. _G_collapseslashes='s|/\{1,\}|/|g'
  812. _G_finalslash='s|/*$|/|'
  813. # Start from root dir and reassemble the path.
  814. func_normal_abspath_result=
  815. func_normal_abspath_tpath=$1
  816. func_normal_abspath_altnamespace=
  817. case $func_normal_abspath_tpath in
  818. "")
  819. # Empty path, that just means $cwd.
  820. func_stripname '' '/' "`pwd`"
  821. func_normal_abspath_result=$func_stripname_result
  822. return
  823. ;;
  824. # The next three entries are used to spot a run of precisely
  825. # two leading slashes without using negated character classes;
  826. # we take advantage of case's first-match behaviour.
  827. ///*)
  828. # Unusual form of absolute path, do nothing.
  829. ;;
  830. //*)
  831. # Not necessarily an ordinary path; POSIX reserves leading '//'
  832. # and for example Cygwin uses it to access remote file shares
  833. # over CIFS/SMB, so we conserve a leading double slash if found.
  834. func_normal_abspath_altnamespace=/
  835. ;;
  836. /*)
  837. # Absolute path, do nothing.
  838. ;;
  839. *)
  840. # Relative path, prepend $cwd.
  841. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
  842. ;;
  843. esac
  844. # Cancel out all the simple stuff to save iterations. We also want
  845. # the path to end with a slash for ease of parsing, so make sure
  846. # there is one (and only one) here.
  847. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
  848. -e "$_G_removedotparts" -e "$_G_collapseslashes" -e "$_G_finalslash"`
  849. while :; do
  850. # Processed it all yet?
  851. if test / = "$func_normal_abspath_tpath"; then
  852. # If we ascended to the root using ".." the result may be empty now.
  853. if test -z "$func_normal_abspath_result"; then
  854. func_normal_abspath_result=/
  855. fi
  856. break
  857. fi
  858. func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
  859. -e "$_G_pathcar"`
  860. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
  861. -e "$_G_pathcdr"`
  862. # Figure out what to do with it
  863. case $func_normal_abspath_tcomponent in
  864. "")
  865. # Trailing empty path component, ignore it.
  866. ;;
  867. ..)
  868. # Parent dir; strip last assembled component from result.
  869. func_dirname "$func_normal_abspath_result"
  870. func_normal_abspath_result=$func_dirname_result
  871. ;;
  872. *)
  873. # Actual path component, append it.
  874. func_append func_normal_abspath_result "/$func_normal_abspath_tcomponent"
  875. ;;
  876. esac
  877. done
  878. # Restore leading double-slash if one was found on entry.
  879. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
  880. }
  881. # func_notquiet ARG...
  882. # --------------------
  883. # Echo program name prefixed message only when not in quiet mode.
  884. func_notquiet ()
  885. {
  886. $debug_cmd
  887. $opt_quiet || func_echo ${1+"$@"}
  888. # A bug in bash halts the script if the last line of a function
  889. # fails when set -e is in force, so we need another command to
  890. # work around that:
  891. :
  892. }
  893. # func_relative_path SRCDIR DSTDIR
  894. # --------------------------------
  895. # Set func_relative_path_result to the relative path from SRCDIR to DSTDIR.
  896. func_relative_path ()
  897. {
  898. $debug_cmd
  899. func_relative_path_result=
  900. func_normal_abspath "$1"
  901. func_relative_path_tlibdir=$func_normal_abspath_result
  902. func_normal_abspath "$2"
  903. func_relative_path_tbindir=$func_normal_abspath_result
  904. # Ascend the tree starting from libdir
  905. while :; do
  906. # check if we have found a prefix of bindir
  907. case $func_relative_path_tbindir in
  908. $func_relative_path_tlibdir)
  909. # found an exact match
  910. func_relative_path_tcancelled=
  911. break
  912. ;;
  913. $func_relative_path_tlibdir*)
  914. # found a matching prefix
  915. func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
  916. func_relative_path_tcancelled=$func_stripname_result
  917. if test -z "$func_relative_path_result"; then
  918. func_relative_path_result=.
  919. fi
  920. break
  921. ;;
  922. *)
  923. func_dirname $func_relative_path_tlibdir
  924. func_relative_path_tlibdir=$func_dirname_result
  925. if test -z "$func_relative_path_tlibdir"; then
  926. # Have to descend all the way to the root!
  927. func_relative_path_result=../$func_relative_path_result
  928. func_relative_path_tcancelled=$func_relative_path_tbindir
  929. break
  930. fi
  931. func_relative_path_result=../$func_relative_path_result
  932. ;;
  933. esac
  934. done
  935. # Now calculate path; take care to avoid doubling-up slashes.
  936. func_stripname '' '/' "$func_relative_path_result"
  937. func_relative_path_result=$func_stripname_result
  938. func_stripname '/' '/' "$func_relative_path_tcancelled"
  939. if test -n "$func_stripname_result"; then
  940. func_append func_relative_path_result "/$func_stripname_result"
  941. fi
  942. # Normalisation. If bindir is libdir, return '.' else relative path.
  943. if test -n "$func_relative_path_result"; then
  944. func_stripname './' '' "$func_relative_path_result"
  945. func_relative_path_result=$func_stripname_result
  946. fi
  947. test -n "$func_relative_path_result" || func_relative_path_result=.
  948. :
  949. }
  950. # func_quote_portable EVAL ARG
  951. # ----------------------------
  952. # Internal function to portably implement func_quote_arg. Note that we still
  953. # keep attention to performance here so we as much as possible try to avoid
  954. # calling sed binary (so far O(N) complexity as long as func_append is O(1)).
  955. func_quote_portable ()
  956. {
  957. $debug_cmd
  958. $require_check_ifs_backslash
  959. func_quote_portable_result=$2
  960. # one-time-loop (easy break)
  961. while true
  962. do
  963. if $1; then
  964. func_quote_portable_result=`$ECHO "$2" | $SED \
  965. -e "$sed_double_quote_subst" -e "$sed_double_backslash"`
  966. break
  967. fi
  968. # Quote for eval.
  969. case $func_quote_portable_result in
  970. *[\\\`\"\$]*)
  971. # Fallback to sed for $func_check_bs_ifs_broken=:, or when the string
  972. # contains the shell wildcard characters.
  973. case $check_ifs_backshlash_broken$func_quote_portable_result in
  974. :*|*[\[\*\?]*)
  975. func_quote_portable_result=`$ECHO "$func_quote_portable_result" \
  976. | $SED "$sed_quote_subst"`
  977. break
  978. ;;
  979. esac
  980. func_quote_portable_old_IFS=$IFS
  981. for _G_char in '\' '`' '"' '$'
  982. do
  983. # STATE($1) PREV($2) SEPARATOR($3)
  984. set start "" ""
  985. func_quote_portable_result=dummy"$_G_char$func_quote_portable_result$_G_char"dummy
  986. IFS=$_G_char
  987. for _G_part in $func_quote_portable_result
  988. do
  989. case $1 in
  990. quote)
  991. func_append func_quote_portable_result "$3$2"
  992. set quote "$_G_part" "\\$_G_char"
  993. ;;
  994. start)
  995. set first "" ""
  996. func_quote_portable_result=
  997. ;;
  998. first)
  999. set quote "$_G_part" ""
  1000. ;;
  1001. esac
  1002. done
  1003. done
  1004. IFS=$func_quote_portable_old_IFS
  1005. ;;
  1006. *) ;;
  1007. esac
  1008. break
  1009. done
  1010. func_quote_portable_unquoted_result=$func_quote_portable_result
  1011. case $func_quote_portable_result in
  1012. # double-quote args containing shell metacharacters to delay
  1013. # word splitting, command substitution and variable expansion
  1014. # for a subsequent eval.
  1015. # many bourne shells cannot handle close brackets correctly
  1016. # in scan sets, so we specify it separately.
  1017. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  1018. func_quote_portable_result=\"$func_quote_portable_result\"
  1019. ;;
  1020. esac
  1021. }
  1022. # func_quotefast_eval ARG
  1023. # -----------------------
  1024. # Quote one ARG (internal). This is equivalent to 'func_quote_arg eval ARG',
  1025. # but optimized for speed. Result is stored in $func_quotefast_eval.
  1026. if test xyes = `(x=; printf -v x %q yes; echo x"$x") 2>/dev/null`; then
  1027. printf -v _GL_test_printf_tilde %q '~'
  1028. if test '\~' = "$_GL_test_printf_tilde"; then
  1029. func_quotefast_eval ()
  1030. {
  1031. printf -v func_quotefast_eval_result %q "$1"
  1032. }
  1033. else
  1034. # Broken older Bash implementations. Make those faster too if possible.
  1035. func_quotefast_eval ()
  1036. {
  1037. case $1 in
  1038. '~'*)
  1039. func_quote_portable false "$1"
  1040. func_quotefast_eval_result=$func_quote_portable_result
  1041. ;;
  1042. *)
  1043. printf -v func_quotefast_eval_result %q "$1"
  1044. ;;
  1045. esac
  1046. }
  1047. fi
  1048. else
  1049. func_quotefast_eval ()
  1050. {
  1051. func_quote_portable false "$1"
  1052. func_quotefast_eval_result=$func_quote_portable_result
  1053. }
  1054. fi
  1055. # func_quote_arg MODEs ARG
  1056. # ------------------------
  1057. # Quote one ARG to be evaled later. MODEs argument may contain zero or more
  1058. # specifiers listed below separated by ',' character. This function returns two
  1059. # values:
  1060. # i) func_quote_arg_result
  1061. # double-quoted (when needed), suitable for a subsequent eval
  1062. # ii) func_quote_arg_unquoted_result
  1063. # has all characters that are still active within double
  1064. # quotes backslashified. Available only if 'unquoted' is specified.
  1065. #
  1066. # Available modes:
  1067. # ----------------
  1068. # 'eval' (default)
  1069. # - escape shell special characters
  1070. # 'expand'
  1071. # - the same as 'eval'; but do not quote variable references
  1072. # 'pretty'
  1073. # - request aesthetic output, i.e. '"a b"' instead of 'a\ b'. This might
  1074. # be used later in func_quote to get output like: 'echo "a b"' instead
  1075. # of 'echo a\ b'. This is slower than default on some shells.
  1076. # 'unquoted'
  1077. # - produce also $func_quote_arg_unquoted_result which does not contain
  1078. # wrapping double-quotes.
  1079. #
  1080. # Examples for 'func_quote_arg pretty,unquoted string':
  1081. #
  1082. # string | *_result | *_unquoted_result
  1083. # ------------+-----------------------+-------------------
  1084. # " | \" | \"
  1085. # a b | "a b" | a b
  1086. # "a b" | "\"a b\"" | \"a b\"
  1087. # * | "*" | *
  1088. # z="${x-$y}" | "z=\"\${x-\$y}\"" | z=\"\${x-\$y}\"
  1089. #
  1090. # Examples for 'func_quote_arg pretty,unquoted,expand string':
  1091. #
  1092. # string | *_result | *_unquoted_result
  1093. # --------------+---------------------+--------------------
  1094. # z="${x-$y}" | "z=\"${x-$y}\"" | z=\"${x-$y}\"
  1095. func_quote_arg ()
  1096. {
  1097. _G_quote_expand=false
  1098. case ,$1, in
  1099. *,expand,*)
  1100. _G_quote_expand=:
  1101. ;;
  1102. esac
  1103. case ,$1, in
  1104. *,pretty,*|*,expand,*|*,unquoted,*)
  1105. func_quote_portable $_G_quote_expand "$2"
  1106. func_quote_arg_result=$func_quote_portable_result
  1107. func_quote_arg_unquoted_result=$func_quote_portable_unquoted_result
  1108. ;;
  1109. *)
  1110. # Faster quote-for-eval for some shells.
  1111. func_quotefast_eval "$2"
  1112. func_quote_arg_result=$func_quotefast_eval_result
  1113. ;;
  1114. esac
  1115. }
  1116. # func_quote MODEs ARGs...
  1117. # ------------------------
  1118. # Quote all ARGs to be evaled later and join them into single command. See
  1119. # func_quote_arg's description for more info.
  1120. func_quote ()
  1121. {
  1122. $debug_cmd
  1123. _G_func_quote_mode=$1 ; shift
  1124. func_quote_result=
  1125. while test 0 -lt $#; do
  1126. func_quote_arg "$_G_func_quote_mode" "$1"
  1127. if test -n "$func_quote_result"; then
  1128. func_append func_quote_result " $func_quote_arg_result"
  1129. else
  1130. func_append func_quote_result "$func_quote_arg_result"
  1131. fi
  1132. shift
  1133. done
  1134. }
  1135. # func_stripname PREFIX SUFFIX NAME
  1136. # ---------------------------------
  1137. # strip PREFIX and SUFFIX from NAME, and store in func_stripname_result.
  1138. # PREFIX and SUFFIX must not contain globbing or regex special
  1139. # characters, hashes, percent signs, but SUFFIX may contain a leading
  1140. # dot (in which case that matches only a dot).
  1141. if test yes = "$_G_HAVE_XSI_OPS"; then
  1142. eval 'func_stripname ()
  1143. {
  1144. $debug_cmd
  1145. # pdksh 5.2.14 does not do ${X%$Y} correctly if both X and Y are
  1146. # positional parameters, so assign one to ordinary variable first.
  1147. func_stripname_result=$3
  1148. func_stripname_result=${func_stripname_result#"$1"}
  1149. func_stripname_result=${func_stripname_result%"$2"}
  1150. }'
  1151. else
  1152. func_stripname ()
  1153. {
  1154. $debug_cmd
  1155. case $2 in
  1156. .*) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%\\\\$2\$%%"`;;
  1157. *) func_stripname_result=`$ECHO "$3" | $SED -e "s%^$1%%" -e "s%$2\$%%"`;;
  1158. esac
  1159. }
  1160. fi
  1161. # func_show_eval CMD [FAIL_EXP]
  1162. # -----------------------------
  1163. # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
  1164. # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
  1165. # is given, then evaluate it.
  1166. func_show_eval ()
  1167. {
  1168. $debug_cmd
  1169. _G_cmd=$1
  1170. _G_fail_exp=${2-':'}
  1171. func_quote_arg pretty,expand "$_G_cmd"
  1172. eval "func_notquiet $func_quote_arg_result"
  1173. $opt_dry_run || {
  1174. eval "$_G_cmd"
  1175. _G_status=$?
  1176. if test 0 -ne "$_G_status"; then
  1177. eval "(exit $_G_status); $_G_fail_exp"
  1178. fi
  1179. }
  1180. }
  1181. # func_show_eval_locale CMD [FAIL_EXP]
  1182. # ------------------------------------
  1183. # Unless opt_quiet is true, then output CMD. Then, if opt_dryrun is
  1184. # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
  1185. # is given, then evaluate it. Use the saved locale for evaluation.
  1186. func_show_eval_locale ()
  1187. {
  1188. $debug_cmd
  1189. _G_cmd=$1
  1190. _G_fail_exp=${2-':'}
  1191. $opt_quiet || {
  1192. func_quote_arg expand,pretty "$_G_cmd"
  1193. eval "func_echo $func_quote_arg_result"
  1194. }
  1195. $opt_dry_run || {
  1196. eval "$_G_user_locale
  1197. $_G_cmd"
  1198. _G_status=$?
  1199. eval "$_G_safe_locale"
  1200. if test 0 -ne "$_G_status"; then
  1201. eval "(exit $_G_status); $_G_fail_exp"
  1202. fi
  1203. }
  1204. }
  1205. # func_tr_sh
  1206. # ----------
  1207. # Turn $1 into a string suitable for a shell variable name.
  1208. # Result is stored in $func_tr_sh_result. All characters
  1209. # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
  1210. # if $1 begins with a digit, a '_' is prepended as well.
  1211. func_tr_sh ()
  1212. {
  1213. $debug_cmd
  1214. case $1 in
  1215. [0-9]* | *[!a-zA-Z0-9_]*)
  1216. func_tr_sh_result=`$ECHO "$1" | $SED -e 's/^\([0-9]\)/_\1/' -e 's/[^a-zA-Z0-9_]/_/g'`
  1217. ;;
  1218. * )
  1219. func_tr_sh_result=$1
  1220. ;;
  1221. esac
  1222. }
  1223. # func_verbose ARG...
  1224. # -------------------
  1225. # Echo program name prefixed message in verbose mode only.
  1226. func_verbose ()
  1227. {
  1228. $debug_cmd
  1229. $opt_verbose && func_echo "$*"
  1230. :
  1231. }
  1232. # func_warn_and_continue ARG...
  1233. # -----------------------------
  1234. # Echo program name prefixed warning message to standard error.
  1235. func_warn_and_continue ()
  1236. {
  1237. $debug_cmd
  1238. $require_term_colors
  1239. func_echo_infix_1 "${tc_red}warning$tc_reset" "$*" >&2
  1240. }
  1241. # func_warning CATEGORY ARG...
  1242. # ----------------------------
  1243. # Echo program name prefixed warning message to standard error. Warning
  1244. # messages can be filtered according to CATEGORY, where this function
  1245. # elides messages where CATEGORY is not listed in the global variable
  1246. # 'opt_warning_types'.
  1247. func_warning ()
  1248. {
  1249. $debug_cmd
  1250. # CATEGORY must be in the warning_categories list!
  1251. case " $warning_categories " in
  1252. *" $1 "*) ;;
  1253. *) func_internal_error "invalid warning category '$1'" ;;
  1254. esac
  1255. _G_category=$1
  1256. shift
  1257. case " $opt_warning_types " in
  1258. *" $_G_category "*) $warning_func ${1+"$@"} ;;
  1259. esac
  1260. }
  1261. # func_sort_ver VER1 VER2
  1262. # -----------------------
  1263. # 'sort -V' is not generally available.
  1264. # Note this deviates from the version comparison in automake
  1265. # in that it treats 1.5 < 1.5.0, and treats 1.4.4a < 1.4-p3a
  1266. # but this should suffice as we won't be specifying old
  1267. # version formats or redundant trailing .0 in bootstrap.conf.
  1268. # If we did want full compatibility then we should probably
  1269. # use m4_version_compare from autoconf.
  1270. func_sort_ver ()
  1271. {
  1272. $debug_cmd
  1273. printf '%s\n%s\n' "$1" "$2" \
  1274. | 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
  1275. }
  1276. # func_lt_ver PREV CURR
  1277. # ---------------------
  1278. # Return true if PREV and CURR are in the correct order according to
  1279. # func_sort_ver, otherwise false. Use it like this:
  1280. #
  1281. # func_lt_ver "$prev_ver" "$proposed_ver" || func_fatal_error "..."
  1282. func_lt_ver ()
  1283. {
  1284. $debug_cmd
  1285. test "x$1" = x`func_sort_ver "$1" "$2" | $SED 1q`
  1286. }
  1287. # Local variables:
  1288. # mode: shell-script
  1289. # sh-indentation: 2
  1290. # eval: (add-hook 'before-save-hook 'time-stamp)
  1291. # time-stamp-pattern: "10/scriptversion=%:y-%02m-%02d.%02H; # UTC"
  1292. # time-stamp-time-zone: "UTC"
  1293. # End:
  1294. #! /bin/sh
  1295. # A portable, pluggable option parser for Bourne shell.
  1296. # Written by Gary V. Vaughan, 2010
  1297. # This is free software. There is NO warranty; not even for
  1298. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  1299. #
  1300. # Copyright (C) 2010-2019, 2021, 2023 Bootstrap Authors
  1301. #
  1302. # This file is dual licensed under the terms of the MIT license
  1303. # <https://opensource.org/licenses/MIT>, and GPL version 2 or later
  1304. # <https://www.gnu.org/licenses/gpl-2.0.html>. You must apply one of
  1305. # these licenses when using or redistributing this software or any of
  1306. # the files within it. See the URLs above, or the file `LICENSE`
  1307. # included in the Bootstrap distribution for the full license texts.
  1308. # Please report bugs or propose patches to:
  1309. # <https://github.com/gnulib-modules/bootstrap/issues>
  1310. # Set a version string for this script.
  1311. scriptversion=2019-02-19.15; # UTC
  1312. ## ------ ##
  1313. ## Usage. ##
  1314. ## ------ ##
  1315. # This file is a library for parsing options in your shell scripts along
  1316. # with assorted other useful supporting features that you can make use
  1317. # of too.
  1318. #
  1319. # For the simplest scripts you might need only:
  1320. #
  1321. # #!/bin/sh
  1322. # . relative/path/to/funclib.sh
  1323. # . relative/path/to/options-parser
  1324. # scriptversion=1.0
  1325. # func_options ${1+"$@"}
  1326. # eval set dummy "$func_options_result"; shift
  1327. # ...rest of your script...
  1328. #
  1329. # In order for the '--version' option to work, you will need to have a
  1330. # suitably formatted comment like the one at the top of this file
  1331. # starting with '# Written by ' and ending with '# Copyright'.
  1332. #
  1333. # For '-h' and '--help' to work, you will also need a one line
  1334. # description of your script's purpose in a comment directly above the
  1335. # '# Written by ' line, like the one at the top of this file.
  1336. #
  1337. # The default options also support '--debug', which will turn on shell
  1338. # execution tracing (see the comment above debug_cmd below for another
  1339. # use), and '--verbose' and the func_verbose function to allow your script
  1340. # to display verbose messages only when your user has specified
  1341. # '--verbose'.
  1342. #
  1343. # After sourcing this file, you can plug in processing for additional
  1344. # options by amending the variables from the 'Configuration' section
  1345. # below, and following the instructions in the 'Option parsing'
  1346. # section further down.
  1347. ## -------------- ##
  1348. ## Configuration. ##
  1349. ## -------------- ##
  1350. # You should override these variables in your script after sourcing this
  1351. # file so that they reflect the customisations you have added to the
  1352. # option parser.
  1353. # The usage line for option parsing errors and the start of '-h' and
  1354. # '--help' output messages. You can embed shell variables for delayed
  1355. # expansion at the time the message is displayed, but you will need to
  1356. # quote other shell meta-characters carefully to prevent them being
  1357. # expanded when the contents are evaled.
  1358. usage='$progpath [OPTION]...'
  1359. # Short help message in response to '-h' and '--help'. Add to this or
  1360. # override it after sourcing this library to reflect the full set of
  1361. # options your script accepts.
  1362. usage_message="\
  1363. --debug enable verbose shell tracing
  1364. -W, --warnings=CATEGORY
  1365. report the warnings falling in CATEGORY [all]
  1366. -v, --verbose verbosely report processing
  1367. --version print version information and exit
  1368. -h, --help print short or long help message and exit
  1369. "
  1370. # Additional text appended to 'usage_message' in response to '--help'.
  1371. long_help_message="
  1372. Warning categories include:
  1373. 'all' show all warnings
  1374. 'none' turn off all the warnings
  1375. 'error' warnings are treated as fatal errors"
  1376. # Help message printed before fatal option parsing errors.
  1377. fatal_help="Try '\$progname --help' for more information."
  1378. ## ------------------------- ##
  1379. ## Hook function management. ##
  1380. ## ------------------------- ##
  1381. # This section contains functions for adding, removing, and running hooks
  1382. # in the main code. A hook is just a list of function names that can be
  1383. # run in order later on.
  1384. # func_hookable FUNC_NAME
  1385. # -----------------------
  1386. # Declare that FUNC_NAME will run hooks added with
  1387. # 'func_add_hook FUNC_NAME ...'.
  1388. func_hookable ()
  1389. {
  1390. $debug_cmd
  1391. func_append hookable_fns " $1"
  1392. }
  1393. # func_add_hook FUNC_NAME HOOK_FUNC
  1394. # ---------------------------------
  1395. # Request that FUNC_NAME call HOOK_FUNC before it returns. FUNC_NAME must
  1396. # first have been declared "hookable" by a call to 'func_hookable'.
  1397. func_add_hook ()
  1398. {
  1399. $debug_cmd
  1400. case " $hookable_fns " in
  1401. *" $1 "*) ;;
  1402. *) func_fatal_error "'$1' does not accept hook functions." ;;
  1403. esac
  1404. eval func_append ${1}_hooks '" $2"'
  1405. }
  1406. # func_remove_hook FUNC_NAME HOOK_FUNC
  1407. # ------------------------------------
  1408. # Remove HOOK_FUNC from the list of hook functions to be called by
  1409. # FUNC_NAME.
  1410. func_remove_hook ()
  1411. {
  1412. $debug_cmd
  1413. eval ${1}_hooks='`$ECHO "\$'$1'_hooks" |$SED "s| '$2'||"`'
  1414. }
  1415. # func_propagate_result FUNC_NAME_A FUNC_NAME_B
  1416. # ---------------------------------------------
  1417. # If the *_result variable of FUNC_NAME_A _is set_, assign its value to
  1418. # *_result variable of FUNC_NAME_B.
  1419. func_propagate_result ()
  1420. {
  1421. $debug_cmd
  1422. func_propagate_result_result=:
  1423. if eval "test \"\${${1}_result+set}\" = set"
  1424. then
  1425. eval "${2}_result=\$${1}_result"
  1426. else
  1427. func_propagate_result_result=false
  1428. fi
  1429. }
  1430. # func_run_hooks FUNC_NAME [ARG]...
  1431. # ---------------------------------
  1432. # Run all hook functions registered to FUNC_NAME.
  1433. # It's assumed that the list of hook functions contains nothing more
  1434. # than a whitespace-delimited list of legal shell function names, and
  1435. # no effort is wasted trying to catch shell meta-characters or preserve
  1436. # whitespace.
  1437. func_run_hooks ()
  1438. {
  1439. $debug_cmd
  1440. case " $hookable_fns " in
  1441. *" $1 "*) ;;
  1442. *) func_fatal_error "'$1' does not support hook functions." ;;
  1443. esac
  1444. eval _G_hook_fns=\$$1_hooks; shift
  1445. for _G_hook in $_G_hook_fns; do
  1446. func_unset "${_G_hook}_result"
  1447. eval $_G_hook '${1+"$@"}'
  1448. func_propagate_result $_G_hook func_run_hooks
  1449. if $func_propagate_result_result; then
  1450. eval set dummy "$func_run_hooks_result"; shift
  1451. fi
  1452. done
  1453. }
  1454. ## --------------- ##
  1455. ## Option parsing. ##
  1456. ## --------------- ##
  1457. # In order to add your own option parsing hooks, you must accept the
  1458. # full positional parameter list from your hook function. You may remove
  1459. # or edit any options that you action, and then pass back the remaining
  1460. # unprocessed options in '<hooked_function_name>_result', escaped
  1461. # suitably for 'eval'.
  1462. #
  1463. # The '<hooked_function_name>_result' variable is automatically unset
  1464. # before your hook gets called; for best performance, only set the
  1465. # *_result variable when necessary (i.e. don't call the 'func_quote'
  1466. # function unnecessarily because it can be an expensive operation on some
  1467. # machines).
  1468. #
  1469. # Like this:
  1470. #
  1471. # my_options_prep ()
  1472. # {
  1473. # $debug_cmd
  1474. #
  1475. # # Extend the existing usage message.
  1476. # usage_message=$usage_message'
  1477. # -s, --silent don'\''t print informational messages
  1478. # '
  1479. # # No change in '$@' (ignored completely by this hook). Leave
  1480. # # my_options_prep_result variable intact.
  1481. # }
  1482. # func_add_hook func_options_prep my_options_prep
  1483. #
  1484. #
  1485. # my_silent_option ()
  1486. # {
  1487. # $debug_cmd
  1488. #
  1489. # args_changed=false
  1490. #
  1491. # # Note that, for efficiency, we parse as many options as we can
  1492. # # recognise in a loop before passing the remainder back to the
  1493. # # caller on the first unrecognised argument we encounter.
  1494. # while test $# -gt 0; do
  1495. # opt=$1; shift
  1496. # case $opt in
  1497. # --silent|-s) opt_silent=:
  1498. # args_changed=:
  1499. # ;;
  1500. # # Separate non-argument short options:
  1501. # -s*) func_split_short_opt "$_G_opt"
  1502. # set dummy "$func_split_short_opt_name" \
  1503. # "-$func_split_short_opt_arg" ${1+"$@"}
  1504. # shift
  1505. # args_changed=:
  1506. # ;;
  1507. # *) # Make sure the first unrecognised option "$_G_opt"
  1508. # # is added back to "$@" in case we need it later,
  1509. # # if $args_changed was set to 'true'.
  1510. # set dummy "$_G_opt" ${1+"$@"}; shift; break ;;
  1511. # esac
  1512. # done
  1513. #
  1514. # # Only call 'func_quote' here if we processed at least one argument.
  1515. # if $args_changed; then
  1516. # func_quote eval ${1+"$@"}
  1517. # my_silent_option_result=$func_quote_result
  1518. # fi
  1519. # }
  1520. # func_add_hook func_parse_options my_silent_option
  1521. #
  1522. #
  1523. # my_option_validation ()
  1524. # {
  1525. # $debug_cmd
  1526. #
  1527. # $opt_silent && $opt_verbose && func_fatal_help "\
  1528. # '--silent' and '--verbose' options are mutually exclusive."
  1529. # }
  1530. # func_add_hook func_validate_options my_option_validation
  1531. #
  1532. # You'll also need to manually amend $usage_message to reflect the extra
  1533. # options you parse. It's preferable to append if you can, so that
  1534. # multiple option parsing hooks can be added safely.
  1535. # func_options_finish [ARG]...
  1536. # ----------------------------
  1537. # Finishing the option parse loop (call 'func_options' hooks ATM).
  1538. func_options_finish ()
  1539. {
  1540. $debug_cmd
  1541. func_run_hooks func_options ${1+"$@"}
  1542. func_propagate_result func_run_hooks func_options_finish
  1543. }
  1544. # func_options [ARG]...
  1545. # ---------------------
  1546. # All the functions called inside func_options are hookable. See the
  1547. # individual implementations for details.
  1548. func_hookable func_options
  1549. func_options ()
  1550. {
  1551. $debug_cmd
  1552. _G_options_quoted=false
  1553. for my_func in options_prep parse_options validate_options options_finish
  1554. do
  1555. func_unset func_${my_func}_result
  1556. func_unset func_run_hooks_result
  1557. eval func_$my_func '${1+"$@"}'
  1558. func_propagate_result func_$my_func func_options
  1559. if $func_propagate_result_result; then
  1560. eval set dummy "$func_options_result"; shift
  1561. _G_options_quoted=:
  1562. fi
  1563. done
  1564. $_G_options_quoted || {
  1565. # As we (func_options) are top-level options-parser function and
  1566. # nobody quoted "$@" for us yet, we need to do it explicitly for
  1567. # caller.
  1568. func_quote eval ${1+"$@"}
  1569. func_options_result=$func_quote_result
  1570. }
  1571. }
  1572. # func_options_prep [ARG]...
  1573. # --------------------------
  1574. # All initialisations required before starting the option parse loop.
  1575. # Note that when calling hook functions, we pass through the list of
  1576. # positional parameters. If a hook function modifies that list, and
  1577. # needs to propagate that back to rest of this script, then the complete
  1578. # modified list must be put in 'func_run_hooks_result' before returning.
  1579. func_hookable func_options_prep
  1580. func_options_prep ()
  1581. {
  1582. $debug_cmd
  1583. # Option defaults:
  1584. opt_verbose=false
  1585. opt_warning_types=
  1586. func_run_hooks func_options_prep ${1+"$@"}
  1587. func_propagate_result func_run_hooks func_options_prep
  1588. }
  1589. # func_parse_options [ARG]...
  1590. # ---------------------------
  1591. # The main option parsing loop.
  1592. func_hookable func_parse_options
  1593. func_parse_options ()
  1594. {
  1595. $debug_cmd
  1596. _G_parse_options_requote=false
  1597. # this just eases exit handling
  1598. while test $# -gt 0; do
  1599. # Defer to hook functions for initial option parsing, so they
  1600. # get priority in the event of reusing an option name.
  1601. func_run_hooks func_parse_options ${1+"$@"}
  1602. func_propagate_result func_run_hooks func_parse_options
  1603. if $func_propagate_result_result; then
  1604. eval set dummy "$func_parse_options_result"; shift
  1605. # Even though we may have changed "$@", we passed the "$@" array
  1606. # down into the hook and it quoted it for us (because we are in
  1607. # this if-branch). No need to quote it again.
  1608. _G_parse_options_requote=false
  1609. fi
  1610. # Break out of the loop if we already parsed every option.
  1611. test $# -gt 0 || break
  1612. # We expect that one of the options parsed in this function matches
  1613. # and thus we remove _G_opt from "$@" and need to re-quote.
  1614. _G_match_parse_options=:
  1615. _G_opt=$1
  1616. shift
  1617. case $_G_opt in
  1618. --debug|-x) debug_cmd='set -x'
  1619. func_echo "enabling shell trace mode" >&2
  1620. $debug_cmd
  1621. ;;
  1622. --no-warnings|--no-warning|--no-warn)
  1623. set dummy --warnings none ${1+"$@"}
  1624. shift
  1625. ;;
  1626. --warnings|--warning|-W)
  1627. if test $# = 0 && func_missing_arg $_G_opt; then
  1628. _G_parse_options_requote=:
  1629. break
  1630. fi
  1631. case " $warning_categories $1" in
  1632. *" $1 "*)
  1633. # trailing space prevents matching last $1 above
  1634. func_append_uniq opt_warning_types " $1"
  1635. ;;
  1636. *all)
  1637. opt_warning_types=$warning_categories
  1638. ;;
  1639. *none)
  1640. opt_warning_types=none
  1641. warning_func=:
  1642. ;;
  1643. *error)
  1644. opt_warning_types=$warning_categories
  1645. warning_func=func_fatal_error
  1646. ;;
  1647. *)
  1648. func_fatal_error \
  1649. "unsupported warning category: '$1'"
  1650. ;;
  1651. esac
  1652. shift
  1653. ;;
  1654. --verbose|-v) opt_verbose=: ;;
  1655. --version) func_version ;;
  1656. -\?|-h) func_usage ;;
  1657. --help) func_help ;;
  1658. # Separate optargs to long options (plugins may need this):
  1659. --*=*) func_split_equals "$_G_opt"
  1660. set dummy "$func_split_equals_lhs" \
  1661. "$func_split_equals_rhs" ${1+"$@"}
  1662. shift
  1663. ;;
  1664. # Separate optargs to short options:
  1665. -W*)
  1666. func_split_short_opt "$_G_opt"
  1667. set dummy "$func_split_short_opt_name" \
  1668. "$func_split_short_opt_arg" ${1+"$@"}
  1669. shift
  1670. ;;
  1671. # Separate non-argument short options:
  1672. -\?*|-h*|-v*|-x*)
  1673. func_split_short_opt "$_G_opt"
  1674. set dummy "$func_split_short_opt_name" \
  1675. "-$func_split_short_opt_arg" ${1+"$@"}
  1676. shift
  1677. ;;
  1678. --) _G_parse_options_requote=: ; break ;;
  1679. -*) func_fatal_help "unrecognised option: '$_G_opt'" ;;
  1680. *) set dummy "$_G_opt" ${1+"$@"}; shift
  1681. _G_match_parse_options=false
  1682. break
  1683. ;;
  1684. esac
  1685. if $_G_match_parse_options; then
  1686. _G_parse_options_requote=:
  1687. fi
  1688. done
  1689. if $_G_parse_options_requote; then
  1690. # save modified positional parameters for caller
  1691. func_quote eval ${1+"$@"}
  1692. func_parse_options_result=$func_quote_result
  1693. fi
  1694. }
  1695. # func_validate_options [ARG]...
  1696. # ------------------------------
  1697. # Perform any sanity checks on option settings and/or unconsumed
  1698. # arguments.
  1699. func_hookable func_validate_options
  1700. func_validate_options ()
  1701. {
  1702. $debug_cmd
  1703. # Display all warnings if -W was not given.
  1704. test -n "$opt_warning_types" || opt_warning_types=" $warning_categories"
  1705. func_run_hooks func_validate_options ${1+"$@"}
  1706. func_propagate_result func_run_hooks func_validate_options
  1707. # Bail if the options were screwed!
  1708. $exit_cmd $EXIT_FAILURE
  1709. }
  1710. ## ----------------- ##
  1711. ## Helper functions. ##
  1712. ## ----------------- ##
  1713. # This section contains the helper functions used by the rest of the
  1714. # hookable option parser framework in ascii-betical order.
  1715. # func_fatal_help ARG...
  1716. # ----------------------
  1717. # Echo program name prefixed message to standard error, followed by
  1718. # a help hint, and exit.
  1719. func_fatal_help ()
  1720. {
  1721. $debug_cmd
  1722. eval \$ECHO \""Usage: $usage"\"
  1723. eval \$ECHO \""$fatal_help"\"
  1724. func_error ${1+"$@"}
  1725. exit $EXIT_FAILURE
  1726. }
  1727. # func_help
  1728. # ---------
  1729. # Echo long help message to standard output and exit.
  1730. func_help ()
  1731. {
  1732. $debug_cmd
  1733. func_usage_message
  1734. $ECHO "$long_help_message"
  1735. exit 0
  1736. }
  1737. # func_missing_arg ARGNAME
  1738. # ------------------------
  1739. # Echo program name prefixed message to standard error and set global
  1740. # exit_cmd.
  1741. func_missing_arg ()
  1742. {
  1743. $debug_cmd
  1744. func_error "Missing argument for '$1'."
  1745. exit_cmd=exit
  1746. }
  1747. # func_split_equals STRING
  1748. # ------------------------
  1749. # Set func_split_equals_lhs and func_split_equals_rhs shell variables
  1750. # after splitting STRING at the '=' sign.
  1751. test -z "$_G_HAVE_XSI_OPS" \
  1752. && (eval 'x=a/b/c;
  1753. test 5aa/bb/cc = "${#x}${x%%/*}${x%/*}${x#*/}${x##*/}"') 2>/dev/null \
  1754. && _G_HAVE_XSI_OPS=yes
  1755. if test yes = "$_G_HAVE_XSI_OPS"
  1756. then
  1757. # This is an XSI compatible shell, allowing a faster implementation...
  1758. eval 'func_split_equals ()
  1759. {
  1760. $debug_cmd
  1761. func_split_equals_lhs=${1%%=*}
  1762. func_split_equals_rhs=${1#*=}
  1763. if test "x$func_split_equals_lhs" = "x$1"; then
  1764. func_split_equals_rhs=
  1765. fi
  1766. }'
  1767. else
  1768. # ...otherwise fall back to using expr, which is often a shell builtin.
  1769. func_split_equals ()
  1770. {
  1771. $debug_cmd
  1772. func_split_equals_lhs=`expr "x$1" : 'x\([^=]*\)'`
  1773. func_split_equals_rhs=
  1774. test "x$func_split_equals_lhs=" = "x$1" \
  1775. || func_split_equals_rhs=`expr "x$1" : 'x[^=]*=\(.*\)$'`
  1776. }
  1777. fi #func_split_equals
  1778. # func_split_short_opt SHORTOPT
  1779. # -----------------------------
  1780. # Set func_split_short_opt_name and func_split_short_opt_arg shell
  1781. # variables after splitting SHORTOPT after the 2nd character.
  1782. if test yes = "$_G_HAVE_XSI_OPS"
  1783. then
  1784. # This is an XSI compatible shell, allowing a faster implementation...
  1785. eval 'func_split_short_opt ()
  1786. {
  1787. $debug_cmd
  1788. func_split_short_opt_arg=${1#??}
  1789. func_split_short_opt_name=${1%"$func_split_short_opt_arg"}
  1790. }'
  1791. else
  1792. # ...otherwise fall back to using expr, which is often a shell builtin.
  1793. func_split_short_opt ()
  1794. {
  1795. $debug_cmd
  1796. func_split_short_opt_name=`expr "x$1" : 'x\(-.\)'`
  1797. func_split_short_opt_arg=`expr "x$1" : 'x-.\(.*\)$'`
  1798. }
  1799. fi #func_split_short_opt
  1800. # func_usage
  1801. # ----------
  1802. # Echo short help message to standard output and exit.
  1803. func_usage ()
  1804. {
  1805. $debug_cmd
  1806. func_usage_message
  1807. $ECHO "Run '$progname --help |${PAGER-more}' for full usage"
  1808. exit 0
  1809. }
  1810. # func_usage_message
  1811. # ------------------
  1812. # Echo short help message to standard output.
  1813. func_usage_message ()
  1814. {
  1815. $debug_cmd
  1816. eval \$ECHO \""Usage: $usage"\"
  1817. echo
  1818. $SED -n 's|^# ||
  1819. /^Written by/{
  1820. x;p;x
  1821. }
  1822. h
  1823. /^Written by/q' < "$progpath"
  1824. echo
  1825. eval \$ECHO \""$usage_message"\"
  1826. }
  1827. # func_version
  1828. # ------------
  1829. # Echo version message to standard output and exit.
  1830. # The version message is extracted from the calling file's header
  1831. # comments, with leading '# ' stripped:
  1832. # 1. First display the progname and version
  1833. # 2. Followed by the header comment line matching /^# Written by /
  1834. # 3. Then a blank line followed by the first following line matching
  1835. # /^# Copyright /
  1836. # 4. Immediately followed by any lines between the previous matches,
  1837. # except lines preceding the intervening completely blank line.
  1838. # For example, see the header comments of this file.
  1839. func_version ()
  1840. {
  1841. $debug_cmd
  1842. printf '%s\n' "$progname $scriptversion"
  1843. $SED -n '
  1844. /^# Written by /!b
  1845. s|^# ||; p; n
  1846. :fwd2blnk
  1847. /./ {
  1848. n
  1849. b fwd2blnk
  1850. }
  1851. p; n
  1852. :holdwrnt
  1853. s|^# ||
  1854. s|^# *$||
  1855. /^Copyright /!{
  1856. /./H
  1857. n
  1858. b holdwrnt
  1859. }
  1860. s|\((C)\)[ 0-9,-]*[ ,-]\([1-9][0-9]* \)|\1 \2|
  1861. G
  1862. s|\(\n\)\n*|\1|g
  1863. p; q' < "$progpath"
  1864. exit $?
  1865. }
  1866. # Local variables:
  1867. # mode: shell-script
  1868. # sh-indentation: 2
  1869. # eval: (add-hook 'before-save-hook 'time-stamp)
  1870. # time-stamp-pattern: "30/scriptversion=%:y-%02m-%02d.%02H; # UTC"
  1871. # time-stamp-time-zone: "UTC"
  1872. # End:
  1873. # Set a version string.
  1874. scriptversion='(GNU libtool) 2.5.0.1-38c1-dirty'
  1875. # func_echo ARG...
  1876. # ----------------
  1877. # Libtool also displays the current mode in messages, so override
  1878. # funclib.sh func_echo with this custom definition.
  1879. func_echo ()
  1880. {
  1881. $debug_cmd
  1882. _G_message=$*
  1883. func_echo_IFS=$IFS
  1884. IFS=$nl
  1885. for _G_line in $_G_message; do
  1886. IFS=$func_echo_IFS
  1887. $ECHO "$progname${opt_mode+: $opt_mode}: $_G_line"
  1888. done
  1889. IFS=$func_echo_IFS
  1890. }
  1891. # func_warning ARG...
  1892. # -------------------
  1893. # Libtool warnings are not categorized, so override funclib.sh
  1894. # func_warning with this simpler definition.
  1895. func_warning ()
  1896. {
  1897. $debug_cmd
  1898. $warning_func ${1+"$@"}
  1899. }
  1900. ## ---------------- ##
  1901. ## Options parsing. ##
  1902. ## ---------------- ##
  1903. # Hook in the functions to make sure our own options are parsed during
  1904. # the option parsing loop.
  1905. usage='$progpath [OPTION]... [MODE-ARG]...'
  1906. # Short help message in response to '-h'.
  1907. usage_message="Options:
  1908. --config show all configuration variables
  1909. --debug enable verbose shell tracing
  1910. -n, --dry-run display commands without modifying any files
  1911. --features display basic configuration information and exit
  1912. --mode=MODE use operation mode MODE
  1913. --no-warnings equivalent to '-Wnone'
  1914. --preserve-dup-deps don't remove duplicate dependency libraries
  1915. --quiet, --silent don't print informational messages
  1916. --tag=TAG use configuration variables from tag TAG
  1917. -v, --verbose print more informational messages than default
  1918. --version print version information
  1919. -W, --warnings=CATEGORY report the warnings falling in CATEGORY [all]
  1920. -h, --help, --help-all print short, long, or detailed help message
  1921. "
  1922. # Additional text appended to 'usage_message' in response to '--help'.
  1923. func_help ()
  1924. {
  1925. $debug_cmd
  1926. func_usage_message
  1927. $ECHO "$long_help_message
  1928. MODE must be one of the following:
  1929. clean remove files from the build directory
  1930. compile compile a source file into a libtool object
  1931. execute automatically set library path, then run a program
  1932. finish complete the installation of libtool libraries
  1933. install install libraries or executables
  1934. link create a library or an executable
  1935. uninstall remove libraries from an installed directory
  1936. MODE-ARGS vary depending on the MODE. When passed as first option,
  1937. '--mode=MODE' may be abbreviated as 'MODE' or a unique abbreviation of that.
  1938. Try '$progname --help --mode=MODE' for a more detailed description of MODE.
  1939. When reporting a bug, please describe a test case to reproduce it and
  1940. include the following information:
  1941. host-triplet: $host
  1942. shell: $SHELL
  1943. compiler: $LTCC
  1944. compiler flags: $LTCFLAGS
  1945. linker: $LD (gnu? $with_gnu_ld)
  1946. version: $progname (GNU libtool) 2.5.0.1-38c1-dirty
  1947. automake: `($AUTOMAKE --version) 2>/dev/null |$SED 1q`
  1948. autoconf: `($AUTOCONF --version) 2>/dev/null |$SED 1q`
  1949. Report bugs to <bug-libtool@gnu.org>.
  1950. GNU libtool home page: <https://www.gnu.org/s/libtool/>.
  1951. General help using GNU software: <https://www.gnu.org/gethelp/>."
  1952. exit 0
  1953. }
  1954. # func_lo2o OBJECT-NAME
  1955. # ---------------------
  1956. # Transform OBJECT-NAME from a '.lo' suffix to the platform specific
  1957. # object suffix.
  1958. lo2o=s/\\.lo\$/.$objext/
  1959. o2lo=s/\\.$objext\$/.lo/
  1960. if test yes = "$_G_HAVE_XSI_OPS"; then
  1961. eval 'func_lo2o ()
  1962. {
  1963. case $1 in
  1964. *.lo) func_lo2o_result=${1%.lo}.$objext ;;
  1965. * ) func_lo2o_result=$1 ;;
  1966. esac
  1967. }'
  1968. # func_xform LIBOBJ-OR-SOURCE
  1969. # ---------------------------
  1970. # Transform LIBOBJ-OR-SOURCE from a '.o' or '.c' (or otherwise)
  1971. # suffix to a '.lo' libtool-object suffix.
  1972. eval 'func_xform ()
  1973. {
  1974. func_xform_result=${1%.*}.lo
  1975. }'
  1976. else
  1977. # ...otherwise fall back to using sed.
  1978. func_lo2o ()
  1979. {
  1980. func_lo2o_result=`$ECHO "$1" | $SED "$lo2o"`
  1981. }
  1982. func_xform ()
  1983. {
  1984. func_xform_result=`$ECHO "$1" | $SED 's|\.[^.]*$|.lo|'`
  1985. }
  1986. fi
  1987. # func_fatal_configuration ARG...
  1988. # -------------------------------
  1989. # Echo program name prefixed message to standard error, followed by
  1990. # a configuration failure hint, and exit.
  1991. func_fatal_configuration ()
  1992. {
  1993. func_fatal_error ${1+"$@"} \
  1994. "See the $PACKAGE documentation for more information." \
  1995. "Fatal configuration error."
  1996. }
  1997. # func_config
  1998. # -----------
  1999. # Display the configuration for all the tags in this script.
  2000. func_config ()
  2001. {
  2002. re_begincf='^# ### BEGIN LIBTOOL'
  2003. re_endcf='^# ### END LIBTOOL'
  2004. # Default configuration.
  2005. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
  2006. # Now print the configurations for the tags.
  2007. for tagname in $taglist; do
  2008. $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
  2009. done
  2010. exit $?
  2011. }
  2012. # func_features
  2013. # -------------
  2014. # Display the features supported by this script.
  2015. func_features ()
  2016. {
  2017. echo "host: $host"
  2018. if test yes = "$build_libtool_libs"; then
  2019. echo "enable shared libraries"
  2020. else
  2021. echo "disable shared libraries"
  2022. fi
  2023. if test yes = "$build_old_libs"; then
  2024. echo "enable static libraries"
  2025. else
  2026. echo "disable static libraries"
  2027. fi
  2028. exit $?
  2029. }
  2030. # func_enable_tag TAGNAME
  2031. # -----------------------
  2032. # Verify that TAGNAME is valid, and either flag an error and exit, or
  2033. # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
  2034. # variable here.
  2035. func_enable_tag ()
  2036. {
  2037. # Global variable:
  2038. tagname=$1
  2039. re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
  2040. re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
  2041. sed_extractcf=/$re_begincf/,/$re_endcf/p
  2042. # Validate tagname.
  2043. case $tagname in
  2044. *[!-_A-Za-z0-9,/]*)
  2045. func_fatal_error "invalid tag name: $tagname"
  2046. ;;
  2047. esac
  2048. # Don't test for the "default" C tag, as we know it's
  2049. # there but not specially marked.
  2050. case $tagname in
  2051. CC) ;;
  2052. *)
  2053. if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
  2054. taglist="$taglist $tagname"
  2055. # Evaluate the configuration. Be careful to quote the path
  2056. # and the sed script, to avoid splitting on whitespace, but
  2057. # also don't use non-portable quotes within backquotes within
  2058. # quotes we have to do it in 2 steps:
  2059. extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
  2060. eval "$extractedcf"
  2061. else
  2062. func_error "ignoring unknown tag $tagname"
  2063. fi
  2064. ;;
  2065. esac
  2066. }
  2067. # func_check_version_match
  2068. # ------------------------
  2069. # Ensure that we are using m4 macros, and libtool script from the same
  2070. # release of libtool.
  2071. func_check_version_match ()
  2072. {
  2073. if test "$package_revision" != "$macro_revision"; then
  2074. if test "$VERSION" != "$macro_version"; then
  2075. if test -z "$macro_version"; then
  2076. cat >&2 <<_LT_EOF
  2077. $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
  2078. $progname: definition of this LT_INIT comes from an older release.
  2079. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
  2080. $progname: and run autoconf again.
  2081. _LT_EOF
  2082. else
  2083. cat >&2 <<_LT_EOF
  2084. $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
  2085. $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
  2086. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
  2087. $progname: and run autoconf again.
  2088. _LT_EOF
  2089. fi
  2090. else
  2091. cat >&2 <<_LT_EOF
  2092. $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
  2093. $progname: but the definition of this LT_INIT comes from revision $macro_revision.
  2094. $progname: You should recreate aclocal.m4 with macros from revision $package_revision
  2095. $progname: of $PACKAGE $VERSION and run autoconf again.
  2096. _LT_EOF
  2097. fi
  2098. exit $EXIT_MISMATCH
  2099. fi
  2100. }
  2101. # libtool_options_prep [ARG]...
  2102. # -----------------------------
  2103. # Preparation for options parsed by libtool.
  2104. libtool_options_prep ()
  2105. {
  2106. $debug_mode
  2107. # Option defaults:
  2108. opt_config=false
  2109. opt_dlopen=
  2110. opt_dry_run=false
  2111. opt_help=false
  2112. opt_mode=
  2113. opt_preserve_dup_deps=false
  2114. opt_quiet=false
  2115. nonopt=
  2116. preserve_args=
  2117. _G_rc_lt_options_prep=:
  2118. # Shorthand for --mode=foo, only valid as the first argument
  2119. case $1 in
  2120. clean|clea|cle|cl)
  2121. shift; set dummy --mode clean ${1+"$@"}; shift
  2122. ;;
  2123. compile|compil|compi|comp|com|co|c)
  2124. shift; set dummy --mode compile ${1+"$@"}; shift
  2125. ;;
  2126. execute|execut|execu|exec|exe|ex|e)
  2127. shift; set dummy --mode execute ${1+"$@"}; shift
  2128. ;;
  2129. finish|finis|fini|fin|fi|f)
  2130. shift; set dummy --mode finish ${1+"$@"}; shift
  2131. ;;
  2132. install|instal|insta|inst|ins|in|i)
  2133. shift; set dummy --mode install ${1+"$@"}; shift
  2134. ;;
  2135. link|lin|li|l)
  2136. shift; set dummy --mode link ${1+"$@"}; shift
  2137. ;;
  2138. uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
  2139. shift; set dummy --mode uninstall ${1+"$@"}; shift
  2140. ;;
  2141. *)
  2142. _G_rc_lt_options_prep=false
  2143. ;;
  2144. esac
  2145. if $_G_rc_lt_options_prep; then
  2146. # Pass back the list of options.
  2147. func_quote eval ${1+"$@"}
  2148. libtool_options_prep_result=$func_quote_result
  2149. fi
  2150. }
  2151. func_add_hook func_options_prep libtool_options_prep
  2152. # libtool_parse_options [ARG]...
  2153. # ---------------------------------
  2154. # Provide handling for libtool specific options.
  2155. libtool_parse_options ()
  2156. {
  2157. $debug_cmd
  2158. _G_rc_lt_parse_options=false
  2159. # Perform our own loop to consume as many options as possible in
  2160. # each iteration.
  2161. while test $# -gt 0; do
  2162. _G_match_lt_parse_options=:
  2163. _G_opt=$1
  2164. shift
  2165. case $_G_opt in
  2166. --dry-run|--dryrun|-n)
  2167. opt_dry_run=:
  2168. ;;
  2169. --config) func_config ;;
  2170. --dlopen|-dlopen)
  2171. opt_dlopen="${opt_dlopen+$opt_dlopen
  2172. }$1"
  2173. shift
  2174. ;;
  2175. --preserve-dup-deps)
  2176. opt_preserve_dup_deps=: ;;
  2177. --features) func_features ;;
  2178. --finish) set dummy --mode finish ${1+"$@"}; shift ;;
  2179. --help) opt_help=: ;;
  2180. --help-all) opt_help=': help-all' ;;
  2181. --mode) test $# = 0 && func_missing_arg $_G_opt && break
  2182. opt_mode=$1
  2183. case $1 in
  2184. # Valid mode arguments:
  2185. clean|compile|execute|finish|install|link|relink|uninstall) ;;
  2186. # Catch anything else as an error
  2187. *) func_error "invalid argument for $_G_opt"
  2188. exit_cmd=exit
  2189. break
  2190. ;;
  2191. esac
  2192. shift
  2193. ;;
  2194. --no-silent|--no-quiet)
  2195. opt_quiet=false
  2196. func_append preserve_args " $_G_opt"
  2197. ;;
  2198. --no-warnings|--no-warning|--no-warn)
  2199. opt_warning=false
  2200. func_append preserve_args " $_G_opt"
  2201. ;;
  2202. --no-verbose)
  2203. opt_verbose=false
  2204. func_append preserve_args " $_G_opt"
  2205. ;;
  2206. --silent|--quiet)
  2207. opt_quiet=:
  2208. opt_verbose=false
  2209. func_append preserve_args " $_G_opt"
  2210. ;;
  2211. --tag) test $# = 0 && func_missing_arg $_G_opt && break
  2212. opt_tag=$1
  2213. func_append preserve_args " $_G_opt $1"
  2214. func_enable_tag "$1"
  2215. shift
  2216. ;;
  2217. --verbose|-v) opt_quiet=false
  2218. opt_verbose=:
  2219. func_append preserve_args " $_G_opt"
  2220. ;;
  2221. # An option not handled by this hook function:
  2222. *) set dummy "$_G_opt" ${1+"$@"} ; shift
  2223. _G_match_lt_parse_options=false
  2224. break
  2225. ;;
  2226. esac
  2227. $_G_match_lt_parse_options && _G_rc_lt_parse_options=:
  2228. done
  2229. if $_G_rc_lt_parse_options; then
  2230. # save modified positional parameters for caller
  2231. func_quote eval ${1+"$@"}
  2232. libtool_parse_options_result=$func_quote_result
  2233. fi
  2234. }
  2235. func_add_hook func_parse_options libtool_parse_options
  2236. # libtool_validate_options [ARG]...
  2237. # ---------------------------------
  2238. # Perform any sanity checks on option settings and/or unconsumed
  2239. # arguments.
  2240. libtool_validate_options ()
  2241. {
  2242. # save first non-option argument
  2243. if test 0 -lt $#; then
  2244. nonopt=$1
  2245. shift
  2246. fi
  2247. # preserve --debug
  2248. test : = "$debug_cmd" || func_append preserve_args " --debug"
  2249. case $host_os in
  2250. # Solaris2 added to fix http://debbugs.gnu.org/cgi/bugreport.cgi?bug=16452
  2251. # see also: http://gcc.gnu.org/bugzilla/show_bug.cgi?id=59788
  2252. cygwin* | mingw* | windows* | pw32* | cegcc* | solaris2* | os2*)
  2253. # don't eliminate duplications in $postdeps and $predeps
  2254. opt_duplicate_compiler_generated_deps=:
  2255. ;;
  2256. *)
  2257. opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
  2258. ;;
  2259. esac
  2260. $opt_help || {
  2261. # Sanity checks first:
  2262. func_check_version_match
  2263. test yes != "$build_libtool_libs" \
  2264. && test yes != "$build_old_libs" \
  2265. && func_fatal_configuration "not configured to build any kind of library"
  2266. # Darwin sucks
  2267. eval std_shrext=\"$shrext_cmds\"
  2268. # Only execute mode is allowed to have -dlopen flags.
  2269. if test -n "$opt_dlopen" && test execute != "$opt_mode"; then
  2270. func_error "unrecognized option '-dlopen'"
  2271. $ECHO "$help" 1>&2
  2272. exit $EXIT_FAILURE
  2273. fi
  2274. # Change the help message to a mode-specific one.
  2275. generic_help=$help
  2276. help="Try '$progname --help --mode=$opt_mode' for more information."
  2277. }
  2278. # Pass back the unparsed argument list
  2279. func_quote eval ${1+"$@"}
  2280. libtool_validate_options_result=$func_quote_result
  2281. }
  2282. func_add_hook func_validate_options libtool_validate_options
  2283. # Process options as early as possible so that --help and --version
  2284. # can return quickly.
  2285. func_options ${1+"$@"}
  2286. eval set dummy "$func_options_result"; shift
  2287. ## ----------- ##
  2288. ## Main. ##
  2289. ## ----------- ##
  2290. magic='%%%MAGIC variable%%%'
  2291. magic_exe='%%%MAGIC EXE variable%%%'
  2292. # Global variables.
  2293. extracted_archives=
  2294. extracted_serial=0
  2295. # If this variable is set in any of the actions, the command in it
  2296. # will be execed at the end. This prevents here-documents from being
  2297. # left over by shells.
  2298. exec_cmd=
  2299. # A function that is used when there is no print builtin or printf.
  2300. func_fallback_echo ()
  2301. {
  2302. eval 'cat <<_LTECHO_EOF
  2303. $1
  2304. _LTECHO_EOF'
  2305. }
  2306. # func_generated_by_libtool
  2307. # True iff stdin has been generated by Libtool. This function is only
  2308. # a basic sanity check; it will hardly flush out determined imposters.
  2309. func_generated_by_libtool_p ()
  2310. {
  2311. $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
  2312. }
  2313. # func_lalib_p file
  2314. # True iff FILE is a libtool '.la' library or '.lo' object file.
  2315. # This function is only a basic sanity check; it will hardly flush out
  2316. # determined imposters.
  2317. func_lalib_p ()
  2318. {
  2319. test -f "$1" &&
  2320. $SED -e 4q "$1" 2>/dev/null | func_generated_by_libtool_p
  2321. }
  2322. # func_lalib_unsafe_p file
  2323. # True iff FILE is a libtool '.la' library or '.lo' object file.
  2324. # This function implements the same check as func_lalib_p without
  2325. # resorting to external programs. To this end, it redirects stdin and
  2326. # closes it afterwards, without saving the original file descriptor.
  2327. # As a safety measure, use it only where a negative result would be
  2328. # fatal anyway. Works if 'file' does not exist.
  2329. func_lalib_unsafe_p ()
  2330. {
  2331. lalib_p=no
  2332. if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
  2333. for lalib_p_l in 1 2 3 4
  2334. do
  2335. read lalib_p_line
  2336. case $lalib_p_line in
  2337. \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
  2338. esac
  2339. done
  2340. exec 0<&5 5<&-
  2341. fi
  2342. test yes = "$lalib_p"
  2343. }
  2344. # func_ltwrapper_script_p file
  2345. # True iff FILE is a libtool wrapper script
  2346. # This function is only a basic sanity check; it will hardly flush out
  2347. # determined imposters.
  2348. func_ltwrapper_script_p ()
  2349. {
  2350. test -f "$1" &&
  2351. $lt_truncate_bin < "$1" 2>/dev/null | func_generated_by_libtool_p
  2352. }
  2353. # func_ltwrapper_executable_p file
  2354. # True iff FILE is a libtool wrapper executable
  2355. # This function is only a basic sanity check; it will hardly flush out
  2356. # determined imposters.
  2357. func_ltwrapper_executable_p ()
  2358. {
  2359. func_ltwrapper_exec_suffix=
  2360. case $1 in
  2361. *.exe) ;;
  2362. *) func_ltwrapper_exec_suffix=.exe ;;
  2363. esac
  2364. $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
  2365. }
  2366. # func_ltwrapper_scriptname file
  2367. # Assumes file is an ltwrapper_executable
  2368. # uses $file to determine the appropriate filename for a
  2369. # temporary ltwrapper_script.
  2370. func_ltwrapper_scriptname ()
  2371. {
  2372. func_dirname_and_basename "$1" "" "."
  2373. func_stripname '' '.exe' "$func_basename_result"
  2374. func_ltwrapper_scriptname_result=$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper
  2375. }
  2376. # func_ltwrapper_p file
  2377. # True iff FILE is a libtool wrapper script or wrapper executable
  2378. # This function is only a basic sanity check; it will hardly flush out
  2379. # determined imposters.
  2380. func_ltwrapper_p ()
  2381. {
  2382. func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
  2383. }
  2384. # func_execute_cmds commands fail_cmd
  2385. # Execute tilde-delimited COMMANDS.
  2386. # If FAIL_CMD is given, eval that upon failure.
  2387. # FAIL_CMD may read-access the current command in variable CMD!
  2388. func_execute_cmds ()
  2389. {
  2390. $debug_cmd
  2391. save_ifs=$IFS; IFS='~'
  2392. for cmd in $1; do
  2393. IFS=$sp$nl
  2394. eval cmd=\"$cmd\"
  2395. IFS=$save_ifs
  2396. func_show_eval "$cmd" "${2-:}"
  2397. done
  2398. IFS=$save_ifs
  2399. }
  2400. # func_source file
  2401. # Source FILE, adding directory component if necessary.
  2402. # Note that it is not necessary on cygwin/mingw to append a dot to
  2403. # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
  2404. # behavior happens only for exec(3), not for open(2)! Also, sourcing
  2405. # 'FILE.' does not work on cygwin managed mounts.
  2406. func_source ()
  2407. {
  2408. $debug_cmd
  2409. case $1 in
  2410. */* | *\\*) . "$1" ;;
  2411. *) . "./$1" ;;
  2412. esac
  2413. }
  2414. # func_resolve_sysroot PATH
  2415. # Replace a leading = in PATH with a sysroot. Store the result into
  2416. # func_resolve_sysroot_result
  2417. func_resolve_sysroot ()
  2418. {
  2419. func_resolve_sysroot_result=$1
  2420. case $func_resolve_sysroot_result in
  2421. =*)
  2422. func_stripname '=' '' "$func_resolve_sysroot_result"
  2423. func_resolve_sysroot_result=$lt_sysroot$func_stripname_result
  2424. ;;
  2425. esac
  2426. }
  2427. # func_replace_sysroot PATH
  2428. # If PATH begins with the sysroot, replace it with = and
  2429. # store the result into func_replace_sysroot_result.
  2430. func_replace_sysroot ()
  2431. {
  2432. case $lt_sysroot:$1 in
  2433. ?*:"$lt_sysroot"*)
  2434. func_stripname "$lt_sysroot" '' "$1"
  2435. func_replace_sysroot_result='='$func_stripname_result
  2436. ;;
  2437. *)
  2438. # Including no sysroot.
  2439. func_replace_sysroot_result=$1
  2440. ;;
  2441. esac
  2442. }
  2443. # func_infer_tag arg
  2444. # Infer tagged configuration to use if any are available and
  2445. # if one wasn't chosen via the "--tag" command line option.
  2446. # Only attempt this if the compiler in the base compile
  2447. # command doesn't match the default compiler.
  2448. # arg is usually of the form 'gcc ...'
  2449. func_infer_tag ()
  2450. {
  2451. $debug_cmd
  2452. if test -n "$available_tags" && test -z "$tagname"; then
  2453. CC_quoted=
  2454. for arg in $CC; do
  2455. func_append_quoted CC_quoted "$arg"
  2456. done
  2457. CC_expanded=`func_echo_all $CC`
  2458. CC_quoted_expanded=`func_echo_all $CC_quoted`
  2459. case $@ in
  2460. # Blanks in the command may have been stripped by the calling shell,
  2461. # but not from the CC environment variable when configure was run.
  2462. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
  2463. " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*) ;;
  2464. # Blanks at the start of $base_compile will cause this to fail
  2465. # if we don't check for them as well.
  2466. *)
  2467. for z in $available_tags; do
  2468. if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
  2469. # Evaluate the configuration.
  2470. eval "`$SED -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
  2471. CC_quoted=
  2472. for arg in $CC; do
  2473. # Double-quote args containing other shell metacharacters.
  2474. func_append_quoted CC_quoted "$arg"
  2475. done
  2476. CC_expanded=`func_echo_all $CC`
  2477. CC_quoted_expanded=`func_echo_all $CC_quoted`
  2478. case "$@ " in
  2479. " $CC "* | "$CC "* | " $CC_expanded "* | "$CC_expanded "* | \
  2480. " $CC_quoted"* | "$CC_quoted "* | " $CC_quoted_expanded "* | "$CC_quoted_expanded "*)
  2481. # The compiler in the base compile command matches
  2482. # the one in the tagged configuration.
  2483. # Assume this is the tagged configuration we want.
  2484. tagname=$z
  2485. break
  2486. ;;
  2487. esac
  2488. fi
  2489. done
  2490. # If $tagname still isn't set, then no tagged configuration
  2491. # was found and let the user know that the "--tag" command
  2492. # line option must be used.
  2493. if test -z "$tagname"; then
  2494. func_echo "unable to infer tagged configuration"
  2495. func_fatal_error "specify a tag with '--tag'"
  2496. # else
  2497. # func_verbose "using $tagname tagged configuration"
  2498. fi
  2499. ;;
  2500. esac
  2501. fi
  2502. }
  2503. # func_write_libtool_object output_name pic_name nonpic_name
  2504. # Create a libtool object file (analogous to a ".la" file),
  2505. # but don't create it if we're doing a dry run.
  2506. func_write_libtool_object ()
  2507. {
  2508. write_libobj=$1
  2509. if test yes = "$build_libtool_libs"; then
  2510. write_lobj=\'$2\'
  2511. else
  2512. write_lobj=none
  2513. fi
  2514. if test yes = "$build_old_libs"; then
  2515. write_oldobj=\'$3\'
  2516. else
  2517. write_oldobj=none
  2518. fi
  2519. $opt_dry_run || {
  2520. cat >${write_libobj}T <<EOF
  2521. # $write_libobj - a libtool object file
  2522. # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
  2523. #
  2524. # Please DO NOT delete this file!
  2525. # It is necessary for linking the library.
  2526. # Name of the PIC object.
  2527. pic_object=$write_lobj
  2528. # Name of the non-PIC object
  2529. non_pic_object=$write_oldobj
  2530. EOF
  2531. $MV "${write_libobj}T" "$write_libobj"
  2532. }
  2533. }
  2534. ##################################################
  2535. # FILE NAME AND PATH CONVERSION HELPER FUNCTIONS #
  2536. ##################################################
  2537. # func_convert_core_file_wine_to_w32 ARG
  2538. # Helper function used by file name conversion functions when $build is *nix,
  2539. # and $host is mingw, windows, cygwin, or some other w32 environment. Relies on a
  2540. # correctly configured wine environment available, with the winepath program
  2541. # in $build's $PATH.
  2542. #
  2543. # ARG is the $build file name to be converted to w32 format.
  2544. # Result is available in $func_convert_core_file_wine_to_w32_result, and will
  2545. # be empty on error (or when ARG is empty)
  2546. func_convert_core_file_wine_to_w32 ()
  2547. {
  2548. $debug_cmd
  2549. func_convert_core_file_wine_to_w32_result=$1
  2550. if test -n "$1"; then
  2551. # Unfortunately, winepath does not exit with a non-zero error code, so we
  2552. # are forced to check the contents of stdout. On the other hand, if the
  2553. # command is not found, the shell will set an exit code of 127 and print
  2554. # *an error message* to stdout. So we must check for both error code of
  2555. # zero AND non-empty stdout, which explains the odd construction:
  2556. func_convert_core_file_wine_to_w32_tmp=`winepath -w "$1" 2>/dev/null`
  2557. if test "$?" -eq 0 && test -n "$func_convert_core_file_wine_to_w32_tmp"; then
  2558. func_convert_core_file_wine_to_w32_result=`$ECHO "$func_convert_core_file_wine_to_w32_tmp" |
  2559. $SED -e "$sed_naive_backslashify"`
  2560. else
  2561. func_convert_core_file_wine_to_w32_result=
  2562. fi
  2563. fi
  2564. }
  2565. # end: func_convert_core_file_wine_to_w32
  2566. # func_convert_core_path_wine_to_w32 ARG
  2567. # Helper function used by path conversion functions when $build is *nix, and
  2568. # $host is mingw, windows, cygwin, or some other w32 environment. Relies on a
  2569. # correctly configured wine environment available, with the winepath program
  2570. # in $build's $PATH. Assumes ARG has no leading or trailing path separator
  2571. # characters.
  2572. #
  2573. # ARG is path to be converted from $build format to win32.
  2574. # Result is available in $func_convert_core_path_wine_to_w32_result.
  2575. # Unconvertible file (directory) names in ARG are skipped; if no directory names
  2576. # are convertible, then the result may be empty.
  2577. func_convert_core_path_wine_to_w32 ()
  2578. {
  2579. $debug_cmd
  2580. # unfortunately, winepath doesn't convert paths, only file names
  2581. func_convert_core_path_wine_to_w32_result=
  2582. if test -n "$1"; then
  2583. oldIFS=$IFS
  2584. IFS=:
  2585. for func_convert_core_path_wine_to_w32_f in $1; do
  2586. IFS=$oldIFS
  2587. func_convert_core_file_wine_to_w32 "$func_convert_core_path_wine_to_w32_f"
  2588. if test -n "$func_convert_core_file_wine_to_w32_result"; then
  2589. if test -z "$func_convert_core_path_wine_to_w32_result"; then
  2590. func_convert_core_path_wine_to_w32_result=$func_convert_core_file_wine_to_w32_result
  2591. else
  2592. func_append func_convert_core_path_wine_to_w32_result ";$func_convert_core_file_wine_to_w32_result"
  2593. fi
  2594. fi
  2595. done
  2596. IFS=$oldIFS
  2597. fi
  2598. }
  2599. # end: func_convert_core_path_wine_to_w32
  2600. # func_cygpath ARGS...
  2601. # Wrapper around calling the cygpath program via LT_CYGPATH. This is used when
  2602. # when (1) $build is *nix and Cygwin is hosted via a wine environment; or (2)
  2603. # $build is MSYS and $host is Cygwin, or (3) $build is Cygwin. In case (1) or
  2604. # (2), returns the Cygwin file name or path in func_cygpath_result (input
  2605. # file name or path is assumed to be in w32 format, as previously converted
  2606. # from $build's *nix or MSYS format). In case (3), returns the w32 file name
  2607. # or path in func_cygpath_result (input file name or path is assumed to be in
  2608. # Cygwin format). Returns an empty string on error.
  2609. #
  2610. # ARGS are passed to cygpath, with the last one being the file name or path to
  2611. # be converted.
  2612. #
  2613. # Specify the absolute *nix (or w32) name to cygpath in the LT_CYGPATH
  2614. # environment variable; do not put it in $PATH.
  2615. func_cygpath ()
  2616. {
  2617. $debug_cmd
  2618. if test -n "$LT_CYGPATH" && test -f "$LT_CYGPATH"; then
  2619. func_cygpath_result=`$LT_CYGPATH "$@" 2>/dev/null`
  2620. if test "$?" -ne 0; then
  2621. # on failure, ensure result is empty
  2622. func_cygpath_result=
  2623. fi
  2624. else
  2625. func_cygpath_result=
  2626. func_error "LT_CYGPATH is empty or specifies non-existent file: '$LT_CYGPATH'"
  2627. fi
  2628. }
  2629. #end: func_cygpath
  2630. # func_convert_core_msys_to_w32 ARG
  2631. # Convert file name or path ARG from MSYS format to w32 format. Return
  2632. # result in func_convert_core_msys_to_w32_result.
  2633. func_convert_core_msys_to_w32 ()
  2634. {
  2635. $debug_cmd
  2636. # awkward: cmd appends spaces to result
  2637. func_convert_core_msys_to_w32_result=`( cmd //c echo "$1" ) 2>/dev/null |
  2638. $SED -e 's/[ ]*$//' -e "$sed_naive_backslashify"`
  2639. }
  2640. #end: func_convert_core_msys_to_w32
  2641. # func_convert_file_check ARG1 ARG2
  2642. # Verify that ARG1 (a file name in $build format) was converted to $host
  2643. # format in ARG2. Otherwise, emit an error message, but continue (resetting
  2644. # func_to_host_file_result to ARG1).
  2645. func_convert_file_check ()
  2646. {
  2647. $debug_cmd
  2648. if test -z "$2" && test -n "$1"; then
  2649. func_error "Could not determine host file name corresponding to"
  2650. func_error " '$1'"
  2651. func_error "Continuing, but uninstalled executables may not work."
  2652. # Fallback:
  2653. func_to_host_file_result=$1
  2654. fi
  2655. }
  2656. # end func_convert_file_check
  2657. # func_convert_path_check FROM_PATHSEP TO_PATHSEP FROM_PATH TO_PATH
  2658. # Verify that FROM_PATH (a path in $build format) was converted to $host
  2659. # format in TO_PATH. Otherwise, emit an error message, but continue, resetting
  2660. # func_to_host_file_result to a simplistic fallback value (see below).
  2661. func_convert_path_check ()
  2662. {
  2663. $debug_cmd
  2664. if test -z "$4" && test -n "$3"; then
  2665. func_error "Could not determine the host path corresponding to"
  2666. func_error " '$3'"
  2667. func_error "Continuing, but uninstalled executables may not work."
  2668. # Fallback. This is a deliberately simplistic "conversion" and
  2669. # should not be "improved". See libtool.info.
  2670. if test "x$1" != "x$2"; then
  2671. lt_replace_pathsep_chars="s|$1|$2|g"
  2672. func_to_host_path_result=`echo "$3" |
  2673. $SED -e "$lt_replace_pathsep_chars"`
  2674. else
  2675. func_to_host_path_result=$3
  2676. fi
  2677. fi
  2678. }
  2679. # end func_convert_path_check
  2680. # func_convert_path_front_back_pathsep FRONTPAT BACKPAT REPL ORIG
  2681. # Modifies func_to_host_path_result by prepending REPL if ORIG matches FRONTPAT
  2682. # and appending REPL if ORIG matches BACKPAT.
  2683. func_convert_path_front_back_pathsep ()
  2684. {
  2685. $debug_cmd
  2686. case $4 in
  2687. $1 ) func_to_host_path_result=$3$func_to_host_path_result
  2688. ;;
  2689. esac
  2690. case $4 in
  2691. $2 ) func_append func_to_host_path_result "$3"
  2692. ;;
  2693. esac
  2694. }
  2695. # end func_convert_path_front_back_pathsep
  2696. ##################################################
  2697. # $build to $host FILE NAME CONVERSION FUNCTIONS #
  2698. ##################################################
  2699. # invoked via '$to_host_file_cmd ARG'
  2700. #
  2701. # In each case, ARG is the path to be converted from $build to $host format.
  2702. # Result will be available in $func_to_host_file_result.
  2703. # func_to_host_file ARG
  2704. # Converts the file name ARG from $build format to $host format. Return result
  2705. # in func_to_host_file_result.
  2706. func_to_host_file ()
  2707. {
  2708. $debug_cmd
  2709. $to_host_file_cmd "$1"
  2710. }
  2711. # end func_to_host_file
  2712. # func_to_tool_file ARG LAZY
  2713. # converts the file name ARG from $build format to toolchain format. Return
  2714. # result in func_to_tool_file_result. If the conversion in use is listed
  2715. # in (the comma separated) LAZY, no conversion takes place.
  2716. func_to_tool_file ()
  2717. {
  2718. $debug_cmd
  2719. case ,$2, in
  2720. *,"$to_tool_file_cmd",*)
  2721. func_to_tool_file_result=$1
  2722. ;;
  2723. *)
  2724. $to_tool_file_cmd "$1"
  2725. func_to_tool_file_result=$func_to_host_file_result
  2726. ;;
  2727. esac
  2728. }
  2729. # end func_to_tool_file
  2730. # func_convert_file_noop ARG
  2731. # Copy ARG to func_to_host_file_result.
  2732. func_convert_file_noop ()
  2733. {
  2734. func_to_host_file_result=$1
  2735. }
  2736. # end func_convert_file_noop
  2737. # func_convert_file_msys_to_w32 ARG
  2738. # Convert file name ARG from (mingw) MSYS to (mingw) w32 format; automatic
  2739. # conversion to w32 is not available inside the cwrapper. Returns result in
  2740. # func_to_host_file_result.
  2741. func_convert_file_msys_to_w32 ()
  2742. {
  2743. $debug_cmd
  2744. func_to_host_file_result=$1
  2745. if test -n "$1"; then
  2746. func_convert_core_msys_to_w32 "$1"
  2747. func_to_host_file_result=$func_convert_core_msys_to_w32_result
  2748. fi
  2749. func_convert_file_check "$1" "$func_to_host_file_result"
  2750. }
  2751. # end func_convert_file_msys_to_w32
  2752. # func_convert_file_cygwin_to_w32 ARG
  2753. # Convert file name ARG from Cygwin to w32 format. Returns result in
  2754. # func_to_host_file_result.
  2755. func_convert_file_cygwin_to_w32 ()
  2756. {
  2757. $debug_cmd
  2758. func_to_host_file_result=$1
  2759. if test -n "$1"; then
  2760. # because $build is cygwin, we call "the" cygpath in $PATH; no need to use
  2761. # LT_CYGPATH in this case.
  2762. func_to_host_file_result=`cygpath -m "$1"`
  2763. fi
  2764. func_convert_file_check "$1" "$func_to_host_file_result"
  2765. }
  2766. # end func_convert_file_cygwin_to_w32
  2767. # func_convert_file_nix_to_w32 ARG
  2768. # Convert file name ARG from *nix to w32 format. Requires a wine environment
  2769. # and a working winepath. Returns result in func_to_host_file_result.
  2770. func_convert_file_nix_to_w32 ()
  2771. {
  2772. $debug_cmd
  2773. func_to_host_file_result=$1
  2774. if test -n "$1"; then
  2775. func_convert_core_file_wine_to_w32 "$1"
  2776. func_to_host_file_result=$func_convert_core_file_wine_to_w32_result
  2777. fi
  2778. func_convert_file_check "$1" "$func_to_host_file_result"
  2779. }
  2780. # end func_convert_file_nix_to_w32
  2781. # func_convert_file_msys_to_cygwin ARG
  2782. # Convert file name ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
  2783. # Returns result in func_to_host_file_result.
  2784. func_convert_file_msys_to_cygwin ()
  2785. {
  2786. $debug_cmd
  2787. func_to_host_file_result=$1
  2788. if test -n "$1"; then
  2789. func_convert_core_msys_to_w32 "$1"
  2790. func_cygpath -u "$func_convert_core_msys_to_w32_result"
  2791. func_to_host_file_result=$func_cygpath_result
  2792. fi
  2793. func_convert_file_check "$1" "$func_to_host_file_result"
  2794. }
  2795. # end func_convert_file_msys_to_cygwin
  2796. # func_convert_file_nix_to_cygwin ARG
  2797. # Convert file name ARG from *nix to Cygwin format. Requires Cygwin installed
  2798. # in a wine environment, working winepath, and LT_CYGPATH set. Returns result
  2799. # in func_to_host_file_result.
  2800. func_convert_file_nix_to_cygwin ()
  2801. {
  2802. $debug_cmd
  2803. func_to_host_file_result=$1
  2804. if test -n "$1"; then
  2805. # convert from *nix to w32, then use cygpath to convert from w32 to cygwin.
  2806. func_convert_core_file_wine_to_w32 "$1"
  2807. func_cygpath -u "$func_convert_core_file_wine_to_w32_result"
  2808. func_to_host_file_result=$func_cygpath_result
  2809. fi
  2810. func_convert_file_check "$1" "$func_to_host_file_result"
  2811. }
  2812. # end func_convert_file_nix_to_cygwin
  2813. #############################################
  2814. # $build to $host PATH CONVERSION FUNCTIONS #
  2815. #############################################
  2816. # invoked via '$to_host_path_cmd ARG'
  2817. #
  2818. # In each case, ARG is the path to be converted from $build to $host format.
  2819. # The result will be available in $func_to_host_path_result.
  2820. #
  2821. # Path separators are also converted from $build format to $host format. If
  2822. # ARG begins or ends with a path separator character, it is preserved (but
  2823. # converted to $host format) on output.
  2824. #
  2825. # All path conversion functions are named using the following convention:
  2826. # file name conversion function : func_convert_file_X_to_Y ()
  2827. # path conversion function : func_convert_path_X_to_Y ()
  2828. # where, for any given $build/$host combination the 'X_to_Y' value is the
  2829. # same. If conversion functions are added for new $build/$host combinations,
  2830. # the two new functions must follow this pattern, or func_init_to_host_path_cmd
  2831. # will break.
  2832. # func_init_to_host_path_cmd
  2833. # Ensures that function "pointer" variable $to_host_path_cmd is set to the
  2834. # appropriate value, based on the value of $to_host_file_cmd.
  2835. to_host_path_cmd=
  2836. func_init_to_host_path_cmd ()
  2837. {
  2838. $debug_cmd
  2839. if test -z "$to_host_path_cmd"; then
  2840. func_stripname 'func_convert_file_' '' "$to_host_file_cmd"
  2841. to_host_path_cmd=func_convert_path_$func_stripname_result
  2842. fi
  2843. }
  2844. # func_to_host_path ARG
  2845. # Converts the path ARG from $build format to $host format. Return result
  2846. # in func_to_host_path_result.
  2847. func_to_host_path ()
  2848. {
  2849. $debug_cmd
  2850. func_init_to_host_path_cmd
  2851. $to_host_path_cmd "$1"
  2852. }
  2853. # end func_to_host_path
  2854. # func_convert_path_noop ARG
  2855. # Copy ARG to func_to_host_path_result.
  2856. func_convert_path_noop ()
  2857. {
  2858. func_to_host_path_result=$1
  2859. }
  2860. # end func_convert_path_noop
  2861. # func_convert_path_msys_to_w32 ARG
  2862. # Convert path ARG from (mingw) MSYS to (mingw) w32 format; automatic
  2863. # conversion to w32 is not available inside the cwrapper. Returns result in
  2864. # func_to_host_path_result.
  2865. func_convert_path_msys_to_w32 ()
  2866. {
  2867. $debug_cmd
  2868. func_to_host_path_result=$1
  2869. if test -n "$1"; then
  2870. # Remove leading and trailing path separator characters from ARG. MSYS
  2871. # behavior is inconsistent here; cygpath turns them into '.;' and ';.';
  2872. # and winepath ignores them completely.
  2873. func_stripname : : "$1"
  2874. func_to_host_path_tmp1=$func_stripname_result
  2875. func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
  2876. func_to_host_path_result=$func_convert_core_msys_to_w32_result
  2877. func_convert_path_check : ";" \
  2878. "$func_to_host_path_tmp1" "$func_to_host_path_result"
  2879. func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
  2880. fi
  2881. }
  2882. # end func_convert_path_msys_to_w32
  2883. # func_convert_path_cygwin_to_w32 ARG
  2884. # Convert path ARG from Cygwin to w32 format. Returns result in
  2885. # func_to_host_file_result.
  2886. func_convert_path_cygwin_to_w32 ()
  2887. {
  2888. $debug_cmd
  2889. func_to_host_path_result=$1
  2890. if test -n "$1"; then
  2891. # See func_convert_path_msys_to_w32:
  2892. func_stripname : : "$1"
  2893. func_to_host_path_tmp1=$func_stripname_result
  2894. func_to_host_path_result=`cygpath -m -p "$func_to_host_path_tmp1"`
  2895. func_convert_path_check : ";" \
  2896. "$func_to_host_path_tmp1" "$func_to_host_path_result"
  2897. func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
  2898. fi
  2899. }
  2900. # end func_convert_path_cygwin_to_w32
  2901. # func_convert_path_nix_to_w32 ARG
  2902. # Convert path ARG from *nix to w32 format. Requires a wine environment and
  2903. # a working winepath. Returns result in func_to_host_file_result.
  2904. func_convert_path_nix_to_w32 ()
  2905. {
  2906. $debug_cmd
  2907. func_to_host_path_result=$1
  2908. if test -n "$1"; then
  2909. # See func_convert_path_msys_to_w32:
  2910. func_stripname : : "$1"
  2911. func_to_host_path_tmp1=$func_stripname_result
  2912. func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
  2913. func_to_host_path_result=$func_convert_core_path_wine_to_w32_result
  2914. func_convert_path_check : ";" \
  2915. "$func_to_host_path_tmp1" "$func_to_host_path_result"
  2916. func_convert_path_front_back_pathsep ":*" "*:" ";" "$1"
  2917. fi
  2918. }
  2919. # end func_convert_path_nix_to_w32
  2920. # func_convert_path_msys_to_cygwin ARG
  2921. # Convert path ARG from MSYS to Cygwin format. Requires LT_CYGPATH set.
  2922. # Returns result in func_to_host_file_result.
  2923. func_convert_path_msys_to_cygwin ()
  2924. {
  2925. $debug_cmd
  2926. func_to_host_path_result=$1
  2927. if test -n "$1"; then
  2928. # See func_convert_path_msys_to_w32:
  2929. func_stripname : : "$1"
  2930. func_to_host_path_tmp1=$func_stripname_result
  2931. func_convert_core_msys_to_w32 "$func_to_host_path_tmp1"
  2932. func_cygpath -u -p "$func_convert_core_msys_to_w32_result"
  2933. func_to_host_path_result=$func_cygpath_result
  2934. func_convert_path_check : : \
  2935. "$func_to_host_path_tmp1" "$func_to_host_path_result"
  2936. func_convert_path_front_back_pathsep ":*" "*:" : "$1"
  2937. fi
  2938. }
  2939. # end func_convert_path_msys_to_cygwin
  2940. # func_convert_path_nix_to_cygwin ARG
  2941. # Convert path ARG from *nix to Cygwin format. Requires Cygwin installed in a
  2942. # a wine environment, working winepath, and LT_CYGPATH set. Returns result in
  2943. # func_to_host_file_result.
  2944. func_convert_path_nix_to_cygwin ()
  2945. {
  2946. $debug_cmd
  2947. func_to_host_path_result=$1
  2948. if test -n "$1"; then
  2949. # Remove leading and trailing path separator characters from
  2950. # ARG. msys behavior is inconsistent here, cygpath turns them
  2951. # into '.;' and ';.', and winepath ignores them completely.
  2952. func_stripname : : "$1"
  2953. func_to_host_path_tmp1=$func_stripname_result
  2954. func_convert_core_path_wine_to_w32 "$func_to_host_path_tmp1"
  2955. func_cygpath -u -p "$func_convert_core_path_wine_to_w32_result"
  2956. func_to_host_path_result=$func_cygpath_result
  2957. func_convert_path_check : : \
  2958. "$func_to_host_path_tmp1" "$func_to_host_path_result"
  2959. func_convert_path_front_back_pathsep ":*" "*:" : "$1"
  2960. fi
  2961. }
  2962. # end func_convert_path_nix_to_cygwin
  2963. # func_dll_def_p FILE
  2964. # True iff FILE is a Windows DLL '.def' file.
  2965. # Keep in sync with _LT_DLL_DEF_P in libtool.m4
  2966. func_dll_def_p ()
  2967. {
  2968. $debug_cmd
  2969. func_dll_def_p_tmp=`$SED -n \
  2970. -e 's/^[ ]*//' \
  2971. -e '/^\(;.*\)*$/d' \
  2972. -e 's/^\(EXPORTS\|LIBRARY\)\([ ].*\)*$/DEF/p' \
  2973. -e q \
  2974. "$1"`
  2975. test DEF = "$func_dll_def_p_tmp"
  2976. }
  2977. # func_mode_compile arg...
  2978. func_mode_compile ()
  2979. {
  2980. $debug_cmd
  2981. # Get the compilation command and the source file.
  2982. base_compile=
  2983. srcfile=$nonopt # always keep a non-empty value in "srcfile"
  2984. suppress_opt=yes
  2985. suppress_output=
  2986. arg_mode=normal
  2987. libobj=
  2988. later=
  2989. pie_flag=
  2990. for arg
  2991. do
  2992. case $arg_mode in
  2993. arg )
  2994. # do not "continue". Instead, add this to base_compile
  2995. lastarg=$arg
  2996. arg_mode=normal
  2997. ;;
  2998. target )
  2999. libobj=$arg
  3000. arg_mode=normal
  3001. continue
  3002. ;;
  3003. normal )
  3004. # Accept any command-line options.
  3005. case $arg in
  3006. -o)
  3007. test -n "$libobj" && \
  3008. func_fatal_error "you cannot specify '-o' more than once"
  3009. arg_mode=target
  3010. continue
  3011. ;;
  3012. -pie | -fpie | -fPIE)
  3013. func_append pie_flag " $arg"
  3014. continue
  3015. ;;
  3016. -shared | -static | -prefer-pic | -prefer-non-pic)
  3017. func_append later " $arg"
  3018. continue
  3019. ;;
  3020. -no-suppress)
  3021. suppress_opt=no
  3022. continue
  3023. ;;
  3024. -Xcompiler)
  3025. arg_mode=arg # the next one goes into the "base_compile" arg list
  3026. continue # The current "srcfile" will either be retained or
  3027. ;; # replaced later. I would guess that would be a bug.
  3028. -Wc,*)
  3029. func_stripname '-Wc,' '' "$arg"
  3030. args=$func_stripname_result
  3031. lastarg=
  3032. save_ifs=$IFS; IFS=,
  3033. for arg in $args; do
  3034. IFS=$save_ifs
  3035. func_append_quoted lastarg "$arg"
  3036. done
  3037. IFS=$save_ifs
  3038. func_stripname ' ' '' "$lastarg"
  3039. lastarg=$func_stripname_result
  3040. # Add the arguments to base_compile.
  3041. func_append base_compile " $lastarg"
  3042. continue
  3043. ;;
  3044. *)
  3045. # Accept the current argument as the source file.
  3046. # The previous "srcfile" becomes the current argument.
  3047. #
  3048. lastarg=$srcfile
  3049. srcfile=$arg
  3050. ;;
  3051. esac # case $arg
  3052. ;;
  3053. esac # case $arg_mode
  3054. # Aesthetically quote the previous argument.
  3055. func_append_quoted base_compile "$lastarg"
  3056. done # for arg
  3057. case $arg_mode in
  3058. arg)
  3059. func_fatal_error "you must specify an argument for -Xcompile"
  3060. ;;
  3061. target)
  3062. func_fatal_error "you must specify a target with '-o'"
  3063. ;;
  3064. *)
  3065. # Get the name of the library object.
  3066. test -z "$libobj" && {
  3067. func_basename "$srcfile"
  3068. libobj=$func_basename_result
  3069. }
  3070. ;;
  3071. esac
  3072. # Recognize several different file suffixes.
  3073. # If the user specifies -o file.o, it is replaced with file.lo
  3074. case $libobj in
  3075. *.[cCFSifmso] | \
  3076. *.ada | *.adb | *.ads | *.asm | \
  3077. *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
  3078. *.[fF][09]? | *.for | *.java | *.go | *.obj | *.sx | *.cu | *.cup)
  3079. func_xform "$libobj"
  3080. libobj=$func_xform_result
  3081. ;;
  3082. esac
  3083. case $libobj in
  3084. *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
  3085. *)
  3086. func_fatal_error "cannot determine name of library object from '$libobj'"
  3087. ;;
  3088. esac
  3089. func_infer_tag $base_compile
  3090. for arg in $later; do
  3091. case $arg in
  3092. -shared)
  3093. test yes = "$build_libtool_libs" \
  3094. || func_fatal_configuration "cannot build a shared library"
  3095. build_old_libs=no
  3096. continue
  3097. ;;
  3098. -static)
  3099. build_libtool_libs=no
  3100. build_old_libs=yes
  3101. continue
  3102. ;;
  3103. -prefer-pic)
  3104. pic_mode=yes
  3105. continue
  3106. ;;
  3107. -prefer-non-pic)
  3108. pic_mode=no
  3109. continue
  3110. ;;
  3111. esac
  3112. done
  3113. func_quote_arg pretty "$libobj"
  3114. test "X$libobj" != "X$func_quote_arg_result" \
  3115. && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"' &()|`$[]' \
  3116. && func_warning "libobj name '$libobj' may not contain shell special characters."
  3117. func_dirname_and_basename "$obj" "/" ""
  3118. objname=$func_basename_result
  3119. xdir=$func_dirname_result
  3120. lobj=$xdir$objdir/$objname
  3121. test -z "$base_compile" && \
  3122. func_fatal_help "you must specify a compilation command"
  3123. # Delete any leftover library objects.
  3124. if test yes = "$build_old_libs"; then
  3125. removelist="$obj $lobj $libobj ${libobj}T"
  3126. else
  3127. removelist="$lobj $libobj ${libobj}T"
  3128. fi
  3129. # On Cygwin there's no "real" PIC flag so we must build both object types
  3130. case $host_os in
  3131. cygwin* | mingw* | windows* | pw32* | os2* | cegcc*)
  3132. pic_mode=default
  3133. ;;
  3134. esac
  3135. if test no = "$pic_mode" && test pass_all != "$deplibs_check_method"; then
  3136. # non-PIC code in shared libraries is not supported
  3137. pic_mode=default
  3138. fi
  3139. # Calculate the filename of the output object if compiler does
  3140. # not support -o with -c
  3141. if test no = "$compiler_c_o"; then
  3142. output_obj=`$ECHO "$srcfile" | $SED 's%^.*/%%; s%\.[^.]*$%%'`.$objext
  3143. lockfile=$output_obj.lock
  3144. else
  3145. output_obj=
  3146. need_locks=no
  3147. lockfile=
  3148. fi
  3149. # Lock this critical section if it is needed
  3150. # We use this script file to make the link, it avoids creating a new file
  3151. if test yes = "$need_locks"; then
  3152. until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
  3153. func_echo "Waiting for $lockfile to be removed"
  3154. sleep 2
  3155. done
  3156. elif test warn = "$need_locks"; then
  3157. if test -f "$lockfile"; then
  3158. $ECHO "\
  3159. *** ERROR, $lockfile exists and contains:
  3160. `cat $lockfile 2>/dev/null`
  3161. This indicates that another process is trying to use the same
  3162. temporary object file, and libtool could not work around it because
  3163. your compiler does not support '-c' and '-o' together. If you
  3164. repeat this compilation, it may succeed, by chance, but you had better
  3165. avoid parallel builds (make -j) in this platform, or get a better
  3166. compiler."
  3167. $opt_dry_run || $RM $removelist
  3168. exit $EXIT_FAILURE
  3169. fi
  3170. func_append removelist " $output_obj"
  3171. $ECHO "$srcfile" > "$lockfile"
  3172. fi
  3173. $opt_dry_run || $RM $removelist
  3174. func_append removelist " $lockfile"
  3175. trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
  3176. func_to_tool_file "$srcfile" func_convert_file_msys_to_w32
  3177. srcfile=$func_to_tool_file_result
  3178. func_quote_arg pretty "$srcfile"
  3179. qsrcfile=$func_quote_arg_result
  3180. # Only build a PIC object if we are building libtool libraries.
  3181. if test yes = "$build_libtool_libs"; then
  3182. # Without this assignment, base_compile gets emptied.
  3183. fbsd_hideous_sh_bug=$base_compile
  3184. if test no != "$pic_mode"; then
  3185. command="$base_compile $qsrcfile $pic_flag"
  3186. else
  3187. # Don't build PIC code
  3188. command="$base_compile $qsrcfile"
  3189. fi
  3190. func_mkdir_p "$xdir$objdir"
  3191. if test -z "$output_obj"; then
  3192. # Place PIC objects in $objdir
  3193. func_append command " -o $lobj"
  3194. fi
  3195. func_show_eval_locale "$command" \
  3196. 'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
  3197. if test warn = "$need_locks" &&
  3198. test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
  3199. $ECHO "\
  3200. *** ERROR, $lockfile contains:
  3201. `cat $lockfile 2>/dev/null`
  3202. but it should contain:
  3203. $srcfile
  3204. This indicates that another process is trying to use the same
  3205. temporary object file, and libtool could not work around it because
  3206. your compiler does not support '-c' and '-o' together. If you
  3207. repeat this compilation, it may succeed, by chance, but you had better
  3208. avoid parallel builds (make -j) in this platform, or get a better
  3209. compiler."
  3210. $opt_dry_run || $RM $removelist
  3211. exit $EXIT_FAILURE
  3212. fi
  3213. # Just move the object if needed, then go on to compile the next one
  3214. if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
  3215. func_show_eval '$MV "$output_obj" "$lobj"' \
  3216. 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
  3217. fi
  3218. # Allow error messages only from the first compilation.
  3219. if test yes = "$suppress_opt"; then
  3220. suppress_output=' >/dev/null 2>&1'
  3221. fi
  3222. fi
  3223. # Only build a position-dependent object if we build old libraries.
  3224. if test yes = "$build_old_libs"; then
  3225. if test yes != "$pic_mode"; then
  3226. # Don't build PIC code
  3227. command="$base_compile $qsrcfile$pie_flag"
  3228. else
  3229. command="$base_compile $qsrcfile $pic_flag"
  3230. fi
  3231. if test yes = "$compiler_c_o"; then
  3232. func_append command " -o $obj"
  3233. fi
  3234. # Suppress compiler output if we already did a PIC compilation.
  3235. func_append command "$suppress_output"
  3236. func_show_eval_locale "$command" \
  3237. '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
  3238. if test warn = "$need_locks" &&
  3239. test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
  3240. $ECHO "\
  3241. *** ERROR, $lockfile contains:
  3242. `cat $lockfile 2>/dev/null`
  3243. but it should contain:
  3244. $srcfile
  3245. This indicates that another process is trying to use the same
  3246. temporary object file, and libtool could not work around it because
  3247. your compiler does not support '-c' and '-o' together. If you
  3248. repeat this compilation, it may succeed, by chance, but you had better
  3249. avoid parallel builds (make -j) in this platform, or get a better
  3250. compiler."
  3251. $opt_dry_run || $RM $removelist
  3252. exit $EXIT_FAILURE
  3253. fi
  3254. # Just move the object if needed
  3255. if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
  3256. func_show_eval '$MV "$output_obj" "$obj"' \
  3257. 'error=$?; $opt_dry_run || $RM $removelist; exit $error'
  3258. fi
  3259. fi
  3260. $opt_dry_run || {
  3261. func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
  3262. # Unlock the critical section if it was locked
  3263. if test no != "$need_locks"; then
  3264. removelist=$lockfile
  3265. $RM "$lockfile"
  3266. fi
  3267. }
  3268. exit $EXIT_SUCCESS
  3269. }
  3270. $opt_help || {
  3271. test compile = "$opt_mode" && func_mode_compile ${1+"$@"}
  3272. }
  3273. func_mode_help ()
  3274. {
  3275. # We need to display help for each of the modes.
  3276. case $opt_mode in
  3277. "")
  3278. # Generic help is extracted from the usage comments
  3279. # at the start of this file.
  3280. func_help
  3281. ;;
  3282. clean)
  3283. $ECHO \
  3284. "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
  3285. Remove files from the build directory.
  3286. RM is the name of the program to use to delete files associated with each FILE
  3287. (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
  3288. to RM.
  3289. If FILE is a libtool library, object or program, all the files associated
  3290. with it are deleted. Otherwise, only FILE itself is deleted using RM."
  3291. ;;
  3292. compile)
  3293. $ECHO \
  3294. "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
  3295. Compile a source file into a libtool library object.
  3296. This mode accepts the following additional options:
  3297. -o OUTPUT-FILE set the output file name to OUTPUT-FILE
  3298. -no-suppress do not suppress compiler output for multiple passes
  3299. -prefer-pic try to build PIC objects only
  3300. -prefer-non-pic try to build non-PIC objects only
  3301. -shared do not build a '.o' file suitable for static linking
  3302. -static only build a '.o' file suitable for static linking
  3303. -Wc,FLAG
  3304. -Xcompiler FLAG pass FLAG directly to the compiler
  3305. COMPILE-COMMAND is a command to be used in creating a 'standard' object file
  3306. from the given SOURCEFILE.
  3307. The output file name is determined by removing the directory component from
  3308. SOURCEFILE, then substituting the C source code suffix '.c' with the
  3309. library object suffix, '.lo'."
  3310. ;;
  3311. execute)
  3312. $ECHO \
  3313. "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
  3314. Automatically set library path, then run a program.
  3315. This mode accepts the following additional options:
  3316. -dlopen FILE add the directory containing FILE to the library path
  3317. This mode sets the library path environment variable according to '-dlopen'
  3318. flags.
  3319. If any of the ARGS are libtool executable wrappers, then they are translated
  3320. into their corresponding uninstalled binary, and any of their required library
  3321. directories are added to the library path.
  3322. Then, COMMAND is executed, with ARGS as arguments."
  3323. ;;
  3324. finish)
  3325. $ECHO \
  3326. "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
  3327. Complete the installation of libtool libraries.
  3328. Each LIBDIR is a directory that contains libtool libraries.
  3329. The commands that this mode executes may require superuser privileges. Use
  3330. the '--dry-run' option if you just want to see what would be executed."
  3331. ;;
  3332. install)
  3333. $ECHO \
  3334. "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
  3335. Install executables or libraries.
  3336. INSTALL-COMMAND is the installation command. The first component should be
  3337. either the 'install' or 'cp' program.
  3338. The following components of INSTALL-COMMAND are treated specially:
  3339. -inst-prefix-dir PREFIX-DIR Use PREFIX-DIR as a staging area for installation
  3340. The rest of the components are interpreted as arguments to that command (only
  3341. BSD-compatible install options are recognized)."
  3342. ;;
  3343. link)
  3344. $ECHO \
  3345. "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
  3346. Link object files or libraries together to form another library, or to
  3347. create an executable program.
  3348. LINK-COMMAND is a command using the C compiler that you would use to create
  3349. a program from several object files.
  3350. The following components of LINK-COMMAND are treated specially:
  3351. -all-static do not do any dynamic linking at all
  3352. -avoid-version do not add a version suffix if possible
  3353. -bindir BINDIR specify path to binaries directory (for systems where
  3354. libraries must be found in the PATH setting at runtime)
  3355. -dlopen FILE '-dlpreopen' FILE if it cannot be dlopened at runtime
  3356. -dlpreopen FILE link in FILE and add its symbols to lt_preloaded_symbols
  3357. -export-dynamic allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
  3358. -export-symbols SYMFILE
  3359. try to export only the symbols listed in SYMFILE
  3360. -export-symbols-regex REGEX
  3361. try to export only the symbols matching REGEX
  3362. -LLIBDIR search LIBDIR for required installed libraries
  3363. -lNAME OUTPUT-FILE requires the installed library libNAME
  3364. -module build a library that can dlopened
  3365. -no-fast-install disable the fast-install mode
  3366. -no-install link a not-installable executable
  3367. -no-undefined declare that a library does not refer to external symbols
  3368. -o OUTPUT-FILE create OUTPUT-FILE from the specified objects
  3369. -objectlist FILE use a list of object files found in FILE to specify objects
  3370. -os2dllname NAME force a short DLL name on OS/2 (no effect on other OSes)
  3371. -precious-files-regex REGEX
  3372. don't remove output files matching REGEX
  3373. -release RELEASE specify package release information
  3374. -rpath LIBDIR the created library will eventually be installed in LIBDIR
  3375. -R[ ]LIBDIR add LIBDIR to the runtime path of programs and libraries
  3376. -shared only do dynamic linking of libtool libraries
  3377. -shrext SUFFIX override the standard shared library file extension
  3378. -static do not do any dynamic linking of uninstalled libtool libraries
  3379. -static-libtool-libs
  3380. do not do any dynamic linking of libtool libraries
  3381. -version-info CURRENT[:REVISION[:AGE]]
  3382. specify library version info [each variable defaults to 0]
  3383. -weak LIBNAME declare that the target provides the LIBNAME interface
  3384. -Wc,FLAG
  3385. -Xcompiler FLAG pass linker-specific FLAG directly to the compiler
  3386. -Wa,FLAG
  3387. -Xassembler FLAG pass linker-specific FLAG directly to the assembler
  3388. -Wl,FLAG
  3389. -Xlinker FLAG pass linker-specific FLAG directly to the linker
  3390. -XCClinker FLAG pass link-specific FLAG to the compiler driver (CC)
  3391. All other options (arguments beginning with '-') are ignored.
  3392. Every other argument is treated as a filename. Files ending in '.la' are
  3393. treated as uninstalled libtool libraries, other files are standard or library
  3394. object files.
  3395. If the OUTPUT-FILE ends in '.la', then a libtool library is created,
  3396. only library objects ('.lo' files) may be specified, and '-rpath' is
  3397. required, except when creating a convenience library.
  3398. If OUTPUT-FILE ends in '.a' or '.lib', then a standard library is created
  3399. using 'ar' and 'ranlib', or on Windows using 'lib'.
  3400. If OUTPUT-FILE ends in '.lo' or '.$objext', then a reloadable object file
  3401. is created, otherwise an executable program is created."
  3402. ;;
  3403. uninstall)
  3404. $ECHO \
  3405. "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
  3406. Remove libraries from an installation directory.
  3407. RM is the name of the program to use to delete files associated with each FILE
  3408. (typically '/bin/rm'). RM-OPTIONS are options (such as '-f') to be passed
  3409. to RM.
  3410. If FILE is a libtool library, all the files associated with it are deleted.
  3411. Otherwise, only FILE itself is deleted using RM."
  3412. ;;
  3413. *)
  3414. func_fatal_help "invalid operation mode '$opt_mode'"
  3415. ;;
  3416. esac
  3417. echo
  3418. $ECHO "Try '$progname --help' for more information about other modes."
  3419. }
  3420. # Now that we've collected a possible --mode arg, show help if necessary
  3421. if $opt_help; then
  3422. if test : = "$opt_help"; then
  3423. func_mode_help
  3424. else
  3425. {
  3426. func_help noexit
  3427. for opt_mode in compile link execute install finish uninstall clean; do
  3428. func_mode_help
  3429. done
  3430. } | $SED -n '1p; 2,$s/^Usage:/ or: /p'
  3431. {
  3432. func_help noexit
  3433. for opt_mode in compile link execute install finish uninstall clean; do
  3434. echo
  3435. func_mode_help
  3436. done
  3437. } |
  3438. $SED '1d
  3439. /^When reporting/,/^Report/{
  3440. H
  3441. d
  3442. }
  3443. $x
  3444. /information about other modes/d
  3445. /more detailed .*MODE/d
  3446. s/^Usage:.*--mode=\([^ ]*\) .*/Description of \1 mode:/'
  3447. fi
  3448. exit $?
  3449. fi
  3450. # func_mode_execute arg...
  3451. func_mode_execute ()
  3452. {
  3453. $debug_cmd
  3454. # The first argument is the command name.
  3455. cmd=$nonopt
  3456. test -z "$cmd" && \
  3457. func_fatal_help "you must specify a COMMAND"
  3458. # Handle -dlopen flags immediately.
  3459. for file in $opt_dlopen; do
  3460. test -f "$file" \
  3461. || func_fatal_help "'$file' is not a file"
  3462. dir=
  3463. case $file in
  3464. *.la)
  3465. func_resolve_sysroot "$file"
  3466. file=$func_resolve_sysroot_result
  3467. # Check to see that this really is a libtool archive.
  3468. func_lalib_unsafe_p "$file" \
  3469. || func_fatal_help "'$lib' is not a valid libtool archive"
  3470. # Read the libtool library.
  3471. dlname=
  3472. library_names=
  3473. func_source "$file"
  3474. # Skip this library if it cannot be dlopened.
  3475. if test -z "$dlname"; then
  3476. # Warn if it was a shared library.
  3477. test -n "$library_names" && \
  3478. func_warning "'$file' was not linked with '-export-dynamic'"
  3479. continue
  3480. fi
  3481. func_dirname "$file" "" "."
  3482. dir=$func_dirname_result
  3483. if test -f "$dir/$objdir/$dlname"; then
  3484. func_append dir "/$objdir"
  3485. else
  3486. if test ! -f "$dir/$dlname"; then
  3487. func_fatal_error "cannot find '$dlname' in '$dir' or '$dir/$objdir'"
  3488. fi
  3489. fi
  3490. ;;
  3491. *.lo)
  3492. # Just add the directory containing the .lo file.
  3493. func_dirname "$file" "" "."
  3494. dir=$func_dirname_result
  3495. ;;
  3496. *)
  3497. func_warning "'-dlopen' is ignored for non-libtool libraries and objects"
  3498. continue
  3499. ;;
  3500. esac
  3501. # Get the absolute pathname.
  3502. absdir=`cd "$dir" && pwd`
  3503. test -n "$absdir" && dir=$absdir
  3504. # Now add the directory to shlibpath_var.
  3505. if eval "test -z \"\$$shlibpath_var\""; then
  3506. eval "$shlibpath_var=\"\$dir\""
  3507. else
  3508. eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
  3509. fi
  3510. done
  3511. # This variable tells wrapper scripts just to set shlibpath_var
  3512. # rather than running their programs.
  3513. libtool_execute_magic=$magic
  3514. # Check if any of the arguments is a wrapper script.
  3515. args=
  3516. for file
  3517. do
  3518. case $file in
  3519. -* | *.la | *.lo ) ;;
  3520. *)
  3521. # Do a test to see if this is really a libtool program.
  3522. if func_ltwrapper_script_p "$file"; then
  3523. func_source "$file"
  3524. # Transform arg to wrapped name.
  3525. file=$progdir/$program
  3526. elif func_ltwrapper_executable_p "$file"; then
  3527. func_ltwrapper_scriptname "$file"
  3528. func_source "$func_ltwrapper_scriptname_result"
  3529. # Transform arg to wrapped name.
  3530. file=$progdir/$program
  3531. fi
  3532. ;;
  3533. esac
  3534. # Quote arguments (to preserve shell metacharacters).
  3535. func_append_quoted args "$file"
  3536. done
  3537. if $opt_dry_run; then
  3538. # Display what would be done.
  3539. if test -n "$shlibpath_var"; then
  3540. eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
  3541. echo "export $shlibpath_var"
  3542. fi
  3543. $ECHO "$cmd$args"
  3544. exit $EXIT_SUCCESS
  3545. else
  3546. if test -n "$shlibpath_var"; then
  3547. # Export the shlibpath_var.
  3548. eval "export $shlibpath_var"
  3549. fi
  3550. # Restore saved environment variables
  3551. for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
  3552. do
  3553. eval "if test \"\${save_$lt_var+set}\" = set; then
  3554. $lt_var=\$save_$lt_var; export $lt_var
  3555. else
  3556. $lt_unset $lt_var
  3557. fi"
  3558. done
  3559. # Now prepare to actually exec the command.
  3560. exec_cmd=\$cmd$args
  3561. fi
  3562. }
  3563. test execute = "$opt_mode" && func_mode_execute ${1+"$@"}
  3564. # func_mode_finish arg...
  3565. func_mode_finish ()
  3566. {
  3567. $debug_cmd
  3568. libs=
  3569. libdirs=
  3570. admincmds=
  3571. for opt in "$nonopt" ${1+"$@"}
  3572. do
  3573. if test -d "$opt"; then
  3574. func_append libdirs " $opt"
  3575. elif test -f "$opt"; then
  3576. if func_lalib_unsafe_p "$opt"; then
  3577. func_append libs " $opt"
  3578. else
  3579. func_warning "'$opt' is not a valid libtool archive"
  3580. fi
  3581. else
  3582. func_fatal_error "invalid argument '$opt'"
  3583. fi
  3584. done
  3585. if test -n "$libs"; then
  3586. if test -n "$lt_sysroot"; then
  3587. sysroot_regex=`$ECHO "$lt_sysroot" | $SED "$sed_make_literal_regex"`
  3588. sysroot_cmd="s/\([ ']\)$sysroot_regex/\1/g;"
  3589. else
  3590. sysroot_cmd=
  3591. fi
  3592. # Remove sysroot references
  3593. if $opt_dry_run; then
  3594. for lib in $libs; do
  3595. echo "removing references to $lt_sysroot and '=' prefixes from $lib"
  3596. done
  3597. else
  3598. tmpdir=`func_mktempdir`
  3599. for lib in $libs; do
  3600. $SED -e "$sysroot_cmd s/\([ ']-[LR]\)=/\1/g; s/\([ ']\)=/\1/g" $lib \
  3601. > $tmpdir/tmp-la
  3602. mv -f $tmpdir/tmp-la $lib
  3603. done
  3604. ${RM}r "$tmpdir"
  3605. fi
  3606. fi
  3607. if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
  3608. for libdir in $libdirs; do
  3609. if test -n "$finish_cmds"; then
  3610. # Do each command in the finish commands.
  3611. func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
  3612. '"$cmd"'"'
  3613. fi
  3614. if test -n "$finish_eval"; then
  3615. # Do the single finish_eval.
  3616. eval cmds=\"$finish_eval\"
  3617. $opt_dry_run || eval "$cmds" || func_append admincmds "
  3618. $cmds"
  3619. fi
  3620. done
  3621. fi
  3622. # Exit here if they wanted silent mode.
  3623. $opt_quiet && exit $EXIT_SUCCESS
  3624. if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
  3625. echo "----------------------------------------------------------------------"
  3626. echo "Libraries have been installed in:"
  3627. for libdir in $libdirs; do
  3628. $ECHO " $libdir"
  3629. done
  3630. echo
  3631. echo "If you ever happen to want to link against installed libraries"
  3632. echo "in a given directory, LIBDIR, you must either use libtool, and"
  3633. echo "specify the full pathname of the library, or use the '-LLIBDIR'"
  3634. echo "flag during linking and do at least one of the following:"
  3635. if test -n "$shlibpath_var"; then
  3636. echo " - add LIBDIR to the '$shlibpath_var' environment variable"
  3637. echo " during execution"
  3638. fi
  3639. if test -n "$runpath_var"; then
  3640. echo " - add LIBDIR to the '$runpath_var' environment variable"
  3641. echo " during linking"
  3642. fi
  3643. if test -n "$hardcode_libdir_flag_spec"; then
  3644. libdir=LIBDIR
  3645. eval flag=\"$hardcode_libdir_flag_spec\"
  3646. $ECHO " - use the '$flag' linker flag"
  3647. fi
  3648. if test -n "$admincmds"; then
  3649. $ECHO " - have your system administrator run these commands:$admincmds"
  3650. fi
  3651. if test -f /etc/ld.so.conf; then
  3652. echo " - have your system administrator add LIBDIR to '/etc/ld.so.conf'"
  3653. fi
  3654. echo
  3655. echo "See any operating system documentation about shared libraries for"
  3656. case $host in
  3657. solaris2.[6789]|solaris2.1[0-9])
  3658. echo "more information, such as the ld(1), crle(1) and ld.so(8) manual"
  3659. echo "pages."
  3660. ;;
  3661. *)
  3662. echo "more information, such as the ld(1) and ld.so(8) manual pages."
  3663. ;;
  3664. esac
  3665. echo "----------------------------------------------------------------------"
  3666. fi
  3667. exit $EXIT_SUCCESS
  3668. }
  3669. test finish = "$opt_mode" && func_mode_finish ${1+"$@"}
  3670. # func_mode_install arg...
  3671. func_mode_install ()
  3672. {
  3673. $debug_cmd
  3674. # There may be an optional sh(1) argument at the beginning of
  3675. # install_prog (especially on Windows NT).
  3676. if test "$SHELL" = "$nonopt" || test /bin/sh = "$nonopt" ||
  3677. # Allow the use of GNU shtool's install command.
  3678. case $nonopt in *shtool*) :;; *) false;; esac
  3679. then
  3680. # Aesthetically quote it.
  3681. func_quote_arg pretty "$nonopt"
  3682. install_prog="$func_quote_arg_result "
  3683. arg=$1
  3684. shift
  3685. else
  3686. install_prog=
  3687. arg=$nonopt
  3688. fi
  3689. # The real first argument should be the name of the installation program.
  3690. # Aesthetically quote it.
  3691. func_quote_arg pretty "$arg"
  3692. func_append install_prog "$func_quote_arg_result"
  3693. install_shared_prog=$install_prog
  3694. case " $install_prog " in
  3695. *[\\\ /]cp\ *) install_cp=: ;;
  3696. *) install_cp=false ;;
  3697. esac
  3698. # We need to accept at least all the BSD install flags.
  3699. dest=
  3700. files=
  3701. opts=
  3702. prev=
  3703. install_type=
  3704. isdir=false
  3705. stripme=
  3706. no_mode=:
  3707. for arg
  3708. do
  3709. arg2=
  3710. if test -n "$dest"; then
  3711. func_append files " $dest"
  3712. dest=$arg
  3713. continue
  3714. fi
  3715. case $arg in
  3716. -d) isdir=: ;;
  3717. -f)
  3718. if $install_cp; then :; else
  3719. prev=$arg
  3720. fi
  3721. ;;
  3722. -g | -m | -o)
  3723. prev=$arg
  3724. ;;
  3725. -s)
  3726. stripme=" -s"
  3727. continue
  3728. ;;
  3729. -*)
  3730. ;;
  3731. *)
  3732. # If the previous option needed an argument, then skip it.
  3733. if test -n "$prev"; then
  3734. if test X-m = "X$prev" && test -n "$install_override_mode"; then
  3735. arg2=$install_override_mode
  3736. no_mode=false
  3737. fi
  3738. prev=
  3739. else
  3740. dest=$arg
  3741. continue
  3742. fi
  3743. ;;
  3744. esac
  3745. # Aesthetically quote the argument.
  3746. func_quote_arg pretty "$arg"
  3747. func_append install_prog " $func_quote_arg_result"
  3748. if test -n "$arg2"; then
  3749. func_quote_arg pretty "$arg2"
  3750. fi
  3751. func_append install_shared_prog " $func_quote_arg_result"
  3752. done
  3753. test -z "$install_prog" && \
  3754. func_fatal_help "you must specify an install program"
  3755. test -n "$prev" && \
  3756. func_fatal_help "the '$prev' option requires an argument"
  3757. if test -n "$install_override_mode" && $no_mode; then
  3758. if $install_cp; then :; else
  3759. func_quote_arg pretty "$install_override_mode"
  3760. func_append install_shared_prog " -m $func_quote_arg_result"
  3761. fi
  3762. fi
  3763. if test -z "$files"; then
  3764. if test -z "$dest"; then
  3765. func_fatal_help "no file or destination specified"
  3766. else
  3767. func_fatal_help "you must specify a destination"
  3768. fi
  3769. fi
  3770. # Strip any trailing slash from the destination.
  3771. func_stripname '' '/' "$dest"
  3772. dest=$func_stripname_result
  3773. # Check to see that the destination is a directory.
  3774. test -d "$dest" && isdir=:
  3775. if $isdir; then
  3776. destdir=$dest
  3777. destname=
  3778. else
  3779. func_dirname_and_basename "$dest" "" "."
  3780. destdir=$func_dirname_result
  3781. destname=$func_basename_result
  3782. # Not a directory, so check to see that there is only one file specified.
  3783. set dummy $files; shift
  3784. test "$#" -gt 1 && \
  3785. func_fatal_help "'$dest' is not a directory"
  3786. fi
  3787. case $destdir in
  3788. [\\/]* | [A-Za-z]:[\\/]*) ;;
  3789. *)
  3790. for file in $files; do
  3791. case $file in
  3792. *.lo) ;;
  3793. *)
  3794. func_fatal_help "'$destdir' must be an absolute directory name"
  3795. ;;
  3796. esac
  3797. done
  3798. ;;
  3799. esac
  3800. # This variable tells wrapper scripts just to set variables rather
  3801. # than running their programs.
  3802. libtool_install_magic=$magic
  3803. staticlibs=
  3804. future_libdirs=
  3805. current_libdirs=
  3806. for file in $files; do
  3807. # Do each installation.
  3808. case $file in
  3809. *.$libext)
  3810. # Do the static libraries later.
  3811. func_append staticlibs " $file"
  3812. ;;
  3813. *.la)
  3814. func_resolve_sysroot "$file"
  3815. file=$func_resolve_sysroot_result
  3816. # Check to see that this really is a libtool archive.
  3817. func_lalib_unsafe_p "$file" \
  3818. || func_fatal_help "'$file' is not a valid libtool archive"
  3819. library_names=
  3820. old_library=
  3821. relink_command=
  3822. func_source "$file"
  3823. # Add the libdir to current_libdirs if it is the destination.
  3824. if test "X$destdir" = "X$libdir"; then
  3825. case "$current_libdirs " in
  3826. *" $libdir "*) ;;
  3827. *) func_append current_libdirs " $libdir" ;;
  3828. esac
  3829. else
  3830. # Note the libdir as a future libdir.
  3831. case "$future_libdirs " in
  3832. *" $libdir "*) ;;
  3833. *) func_append future_libdirs " $libdir" ;;
  3834. esac
  3835. fi
  3836. func_dirname "$file" "/" ""
  3837. dir=$func_dirname_result
  3838. func_append dir "$objdir"
  3839. if test -n "$relink_command"; then
  3840. # Determine the prefix the user has applied to our future dir.
  3841. inst_prefix_dir=`$ECHO "$destdir" | $SED -e "s%$libdir\$%%"`
  3842. # Don't allow the user to place us outside of our expected
  3843. # location b/c this prevents finding dependent libraries that
  3844. # are installed to the same prefix.
  3845. # At present, this check doesn't affect windows .dll's that
  3846. # are installed into $libdir/../bin (currently, that works fine)
  3847. # but it's something to keep an eye on.
  3848. test "$inst_prefix_dir" = "$destdir" && \
  3849. func_fatal_error "error: cannot install '$file' to a directory not ending in $libdir"
  3850. if test -n "$inst_prefix_dir"; then
  3851. # Stick the inst_prefix_dir data into the link command.
  3852. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
  3853. else
  3854. relink_command=`$ECHO "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
  3855. fi
  3856. func_warning "relinking '$file'"
  3857. func_show_eval "$relink_command" \
  3858. 'func_fatal_error "error: relink '\''$file'\'' with the above command before installing it"'
  3859. fi
  3860. # See the names of the shared library.
  3861. set dummy $library_names; shift
  3862. if test -n "$1"; then
  3863. realname=$1
  3864. shift
  3865. srcname=$realname
  3866. test -n "$relink_command" && srcname=${realname}T
  3867. # Install the shared library and build the symlinks.
  3868. func_show_eval "$install_shared_prog $dir/$srcname $destdir/$realname" \
  3869. 'exit $?'
  3870. tstripme=$stripme
  3871. case $host_os in
  3872. cygwin* | mingw* | windows* | pw32* | cegcc*)
  3873. case $realname in
  3874. *.dll.a)
  3875. tstripme=
  3876. ;;
  3877. esac
  3878. ;;
  3879. os2*)
  3880. case $realname in
  3881. *_dll.a)
  3882. tstripme=
  3883. ;;
  3884. esac
  3885. ;;
  3886. esac
  3887. if test -n "$tstripme" && test -n "$striplib"; then
  3888. func_show_eval "$striplib $destdir/$realname" 'exit $?'
  3889. fi
  3890. if test "$#" -gt 0; then
  3891. # Delete the old symlinks, and create new ones.
  3892. # Try 'ln -sf' first, because the 'ln' binary might depend on
  3893. # the symlink we replace! Solaris /bin/ln does not understand -f,
  3894. # so we also need to try rm && ln -s.
  3895. for linkname
  3896. do
  3897. test "$linkname" != "$realname" \
  3898. && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
  3899. done
  3900. fi
  3901. # Do each command in the postinstall commands.
  3902. lib=$destdir/$realname
  3903. func_execute_cmds "$postinstall_cmds" 'exit $?'
  3904. fi
  3905. # Install the pseudo-library for information purposes.
  3906. func_basename "$file"
  3907. name=$func_basename_result
  3908. instname=$dir/${name}i
  3909. func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
  3910. # Maybe install the static library, too.
  3911. test -n "$old_library" && func_append staticlibs " $dir/$old_library"
  3912. ;;
  3913. *.lo)
  3914. # Install (i.e. copy) a libtool object.
  3915. # Figure out destination file name, if it wasn't already specified.
  3916. if test -n "$destname"; then
  3917. destfile=$destdir/$destname
  3918. else
  3919. func_basename "$file"
  3920. destfile=$func_basename_result
  3921. destfile=$destdir/$destfile
  3922. fi
  3923. # Deduce the name of the destination old-style object file.
  3924. case $destfile in
  3925. *.lo)
  3926. func_lo2o "$destfile"
  3927. staticdest=$func_lo2o_result
  3928. ;;
  3929. *.$objext)
  3930. staticdest=$destfile
  3931. destfile=
  3932. ;;
  3933. *)
  3934. func_fatal_help "cannot copy a libtool object to '$destfile'"
  3935. ;;
  3936. esac
  3937. # Install the libtool object if requested.
  3938. test -n "$destfile" && \
  3939. func_show_eval "$install_prog $file $destfile" 'exit $?'
  3940. # Install the old object if enabled.
  3941. if test yes = "$build_old_libs"; then
  3942. # Deduce the name of the old-style object file.
  3943. func_lo2o "$file"
  3944. staticobj=$func_lo2o_result
  3945. func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
  3946. fi
  3947. exit $EXIT_SUCCESS
  3948. ;;
  3949. *)
  3950. # Figure out destination file name, if it wasn't already specified.
  3951. if test -n "$destname"; then
  3952. destfile=$destdir/$destname
  3953. else
  3954. func_basename "$file"
  3955. destfile=$func_basename_result
  3956. destfile=$destdir/$destfile
  3957. fi
  3958. # If the file is missing, and there is a .exe on the end, strip it
  3959. # because it is most likely a libtool script we actually want to
  3960. # install
  3961. stripped_ext=
  3962. case $file in
  3963. *.exe)
  3964. if test ! -f "$file"; then
  3965. func_stripname '' '.exe' "$file"
  3966. file=$func_stripname_result
  3967. stripped_ext=.exe
  3968. fi
  3969. ;;
  3970. esac
  3971. # Do a test to see if this is really a libtool program.
  3972. case $host in
  3973. *cygwin* | *mingw* | *windows*)
  3974. if func_ltwrapper_executable_p "$file"; then
  3975. func_ltwrapper_scriptname "$file"
  3976. wrapper=$func_ltwrapper_scriptname_result
  3977. else
  3978. func_stripname '' '.exe' "$file"
  3979. wrapper=$func_stripname_result
  3980. fi
  3981. ;;
  3982. *)
  3983. wrapper=$file
  3984. ;;
  3985. esac
  3986. if func_ltwrapper_script_p "$wrapper"; then
  3987. notinst_deplibs=
  3988. relink_command=
  3989. func_source "$wrapper"
  3990. # Check the variables that should have been set.
  3991. test -z "$generated_by_libtool_version" && \
  3992. func_fatal_error "invalid libtool wrapper script '$wrapper'"
  3993. finalize=:
  3994. for lib in $notinst_deplibs; do
  3995. # Check to see that each library is installed.
  3996. libdir=
  3997. if test -f "$lib"; then
  3998. func_source "$lib"
  3999. fi
  4000. libfile=$libdir/`$ECHO "$lib" | $SED 's%^.*/%%g'`
  4001. if test -n "$libdir" && test ! -f "$libfile"; then
  4002. func_warning "'$lib' has not been installed in '$libdir'"
  4003. finalize=false
  4004. fi
  4005. done
  4006. relink_command=
  4007. func_source "$wrapper"
  4008. outputname=
  4009. if test no = "$fast_install" && test -n "$relink_command"; then
  4010. $opt_dry_run || {
  4011. if $finalize; then
  4012. tmpdir=`func_mktempdir`
  4013. func_basename "$file$stripped_ext"
  4014. file=$func_basename_result
  4015. outputname=$tmpdir/$file
  4016. # Replace the output file specification.
  4017. relink_command=`$ECHO "$relink_command" | $SED 's%@OUTPUT@%'"$outputname"'%g'`
  4018. $opt_quiet || {
  4019. func_quote_arg expand,pretty "$relink_command"
  4020. eval "func_echo $func_quote_arg_result"
  4021. }
  4022. if eval "$relink_command"; then :
  4023. else
  4024. func_error "error: relink '$file' with the above command before installing it"
  4025. $opt_dry_run || ${RM}r "$tmpdir"
  4026. continue
  4027. fi
  4028. file=$outputname
  4029. else
  4030. func_warning "cannot relink '$file'"
  4031. fi
  4032. }
  4033. else
  4034. # Install the binary that we compiled earlier.
  4035. file=`$ECHO "$file$stripped_ext" | $SED "s%\([^/]*\)$%$objdir/\1%"`
  4036. fi
  4037. fi
  4038. # remove .exe since cygwin /usr/bin/install will append another
  4039. # one anyway
  4040. case $install_prog,$host in
  4041. */usr/bin/install*,*cygwin*)
  4042. case $file:$destfile in
  4043. *.exe:*.exe)
  4044. # this is ok
  4045. ;;
  4046. *.exe:*)
  4047. destfile=$destfile.exe
  4048. ;;
  4049. *:*.exe)
  4050. func_stripname '' '.exe' "$destfile"
  4051. destfile=$func_stripname_result
  4052. ;;
  4053. esac
  4054. ;;
  4055. esac
  4056. func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
  4057. $opt_dry_run || if test -n "$outputname"; then
  4058. ${RM}r "$tmpdir"
  4059. fi
  4060. ;;
  4061. esac
  4062. done
  4063. for file in $staticlibs; do
  4064. func_basename "$file"
  4065. name=$func_basename_result
  4066. # Set up the ranlib parameters.
  4067. oldlib=$destdir/$name
  4068. func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
  4069. tool_oldlib=$func_to_tool_file_result
  4070. func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
  4071. if test -n "$stripme" && test -n "$old_striplib"; then
  4072. func_show_eval "$old_striplib $tool_oldlib" 'exit $?'
  4073. fi
  4074. # Do each command in the postinstall commands.
  4075. func_execute_cmds "$old_postinstall_cmds" 'exit $?'
  4076. done
  4077. test -n "$future_libdirs" && \
  4078. func_warning "remember to run '$progname --finish$future_libdirs'"
  4079. if test -n "$current_libdirs"; then
  4080. # Maybe just do a dry run.
  4081. $opt_dry_run && current_libdirs=" -n$current_libdirs"
  4082. exec_cmd='$SHELL "$progpath" $preserve_args --finish$current_libdirs'
  4083. else
  4084. exit $EXIT_SUCCESS
  4085. fi
  4086. }
  4087. test install = "$opt_mode" && func_mode_install ${1+"$@"}
  4088. # func_generate_dlsyms outputname originator pic_p
  4089. # Extract symbols from dlprefiles and create ${outputname}S.o with
  4090. # a dlpreopen symbol table.
  4091. func_generate_dlsyms ()
  4092. {
  4093. $debug_cmd
  4094. my_outputname=$1
  4095. my_originator=$2
  4096. my_pic_p=${3-false}
  4097. my_prefix=`$ECHO "$my_originator" | $SED 's%[^a-zA-Z0-9]%_%g'`
  4098. my_dlsyms=
  4099. if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
  4100. if test -n "$NM" && test -n "$global_symbol_pipe"; then
  4101. my_dlsyms=${my_outputname}S.c
  4102. else
  4103. func_error "not configured to extract global symbols from dlpreopened files"
  4104. fi
  4105. fi
  4106. if test -n "$my_dlsyms"; then
  4107. case $my_dlsyms in
  4108. "") ;;
  4109. *.c)
  4110. # Discover the nlist of each of the dlfiles.
  4111. nlist=$output_objdir/$my_outputname.nm
  4112. func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
  4113. # Parse the name list into a source file.
  4114. func_verbose "creating $output_objdir/$my_dlsyms"
  4115. $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
  4116. /* $my_dlsyms - symbol resolution table for '$my_outputname' dlsym emulation. */
  4117. /* Generated by $PROGRAM (GNU $PACKAGE) $VERSION */
  4118. #ifdef __cplusplus
  4119. extern \"C\" {
  4120. #endif
  4121. #if defined __GNUC__ && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
  4122. #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
  4123. #endif
  4124. /* Keep this code in sync between libtool.m4, ltmain, lt_system.h, and tests. */
  4125. #if defined _WIN32 || defined __CYGWIN__ || defined _WIN32_WCE
  4126. /* DATA imports from DLLs on WIN32 can't be const, because runtime
  4127. relocations are performed -- see ld's documentation on pseudo-relocs. */
  4128. # define LT_DLSYM_CONST
  4129. #elif defined __osf__
  4130. /* This system does not cope well with relocations in const data. */
  4131. # define LT_DLSYM_CONST
  4132. #else
  4133. # define LT_DLSYM_CONST const
  4134. #endif
  4135. #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
  4136. /* External symbol declarations for the compiler. */\
  4137. "
  4138. if test yes = "$dlself"; then
  4139. func_verbose "generating symbol list for '$output'"
  4140. $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
  4141. # Add our own program objects to the symbol list.
  4142. progfiles=`$ECHO "$objs$old_deplibs" | $SP2NL | $SED "$lo2o" | $NL2SP`
  4143. for progfile in $progfiles; do
  4144. func_to_tool_file "$progfile" func_convert_file_msys_to_w32
  4145. func_verbose "extracting global C symbols from '$func_to_tool_file_result'"
  4146. $opt_dry_run || eval "$NM $func_to_tool_file_result | $global_symbol_pipe >> '$nlist'"
  4147. done
  4148. if test -n "$exclude_expsyms"; then
  4149. $opt_dry_run || {
  4150. eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
  4151. eval '$MV "$nlist"T "$nlist"'
  4152. }
  4153. fi
  4154. if test -n "$export_symbols_regex"; then
  4155. $opt_dry_run || {
  4156. eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
  4157. eval '$MV "$nlist"T "$nlist"'
  4158. }
  4159. fi
  4160. # Prepare the list of exported symbols
  4161. if test -z "$export_symbols"; then
  4162. export_symbols=$output_objdir/$outputname.exp
  4163. $opt_dry_run || {
  4164. $RM $export_symbols
  4165. eval "$SED -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
  4166. case $host in
  4167. *cygwin* | *mingw* | *windows* | *cegcc* )
  4168. eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
  4169. eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
  4170. ;;
  4171. esac
  4172. }
  4173. else
  4174. $opt_dry_run || {
  4175. eval "$SED -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
  4176. eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
  4177. eval '$MV "$nlist"T "$nlist"'
  4178. case $host in
  4179. *cygwin* | *mingw* | *windows* | *cegcc* )
  4180. eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
  4181. eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
  4182. ;;
  4183. esac
  4184. }
  4185. fi
  4186. fi
  4187. for dlprefile in $dlprefiles; do
  4188. func_verbose "extracting global C symbols from '$dlprefile'"
  4189. func_basename "$dlprefile"
  4190. name=$func_basename_result
  4191. case $host in
  4192. *cygwin* | *mingw* | *windows* | *cegcc* )
  4193. # if an import library, we need to obtain dlname
  4194. if func_win32_import_lib_p "$dlprefile"; then
  4195. func_tr_sh "$dlprefile"
  4196. eval "curr_lafile=\$libfile_$func_tr_sh_result"
  4197. dlprefile_dlbasename=
  4198. if test -n "$curr_lafile" && func_lalib_p "$curr_lafile"; then
  4199. # Use subshell, to avoid clobbering current variable values
  4200. dlprefile_dlname=`source "$curr_lafile" && echo "$dlname"`
  4201. if test -n "$dlprefile_dlname"; then
  4202. func_basename "$dlprefile_dlname"
  4203. dlprefile_dlbasename=$func_basename_result
  4204. else
  4205. # no lafile. user explicitly requested -dlpreopen <import library>.
  4206. $sharedlib_from_linklib_cmd "$dlprefile"
  4207. dlprefile_dlbasename=$sharedlib_from_linklib_result
  4208. fi
  4209. fi
  4210. $opt_dry_run || {
  4211. if test -n "$dlprefile_dlbasename"; then
  4212. eval '$ECHO ": $dlprefile_dlbasename" >> "$nlist"'
  4213. else
  4214. func_warning "Could not compute DLL name from $name"
  4215. eval '$ECHO ": $name " >> "$nlist"'
  4216. fi
  4217. func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
  4218. eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe |
  4219. $SED -e '/I __imp/d' -e 's/I __nm_/D /;s/_nm__//' >> '$nlist'"
  4220. }
  4221. else # not an import lib
  4222. $opt_dry_run || {
  4223. eval '$ECHO ": $name " >> "$nlist"'
  4224. func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
  4225. eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
  4226. }
  4227. fi
  4228. ;;
  4229. *)
  4230. $opt_dry_run || {
  4231. eval '$ECHO ": $name " >> "$nlist"'
  4232. func_to_tool_file "$dlprefile" func_convert_file_msys_to_w32
  4233. eval "$NM \"$func_to_tool_file_result\" 2>/dev/null | $global_symbol_pipe >> '$nlist'"
  4234. }
  4235. ;;
  4236. esac
  4237. done
  4238. $opt_dry_run || {
  4239. # Make sure we have at least an empty file.
  4240. test -f "$nlist" || : > "$nlist"
  4241. if test -n "$exclude_expsyms"; then
  4242. $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
  4243. $MV "$nlist"T "$nlist"
  4244. fi
  4245. # Try sorting and uniquifying the output.
  4246. if $GREP -v "^: " < "$nlist" |
  4247. if sort -k 3 </dev/null >/dev/null 2>&1; then
  4248. sort -k 3
  4249. else
  4250. sort +2
  4251. fi |
  4252. uniq > "$nlist"S; then
  4253. :
  4254. else
  4255. $GREP -v "^: " < "$nlist" > "$nlist"S
  4256. fi
  4257. if test -f "$nlist"S; then
  4258. eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
  4259. else
  4260. echo '/* NONE */' >> "$output_objdir/$my_dlsyms"
  4261. fi
  4262. func_show_eval '$RM "${nlist}I"'
  4263. if test -n "$global_symbol_to_import"; then
  4264. eval "$global_symbol_to_import"' < "$nlist"S > "$nlist"I'
  4265. fi
  4266. echo >> "$output_objdir/$my_dlsyms" "\
  4267. /* The mapping between symbol names and symbols. */
  4268. typedef struct {
  4269. const char *name;
  4270. void *address;
  4271. } lt_dlsymlist;
  4272. extern LT_DLSYM_CONST lt_dlsymlist
  4273. lt_${my_prefix}_LTX_preloaded_symbols[];\
  4274. "
  4275. if test -s "$nlist"I; then
  4276. echo >> "$output_objdir/$my_dlsyms" "\
  4277. static void lt_syminit(void)
  4278. {
  4279. LT_DLSYM_CONST lt_dlsymlist *symbol = lt_${my_prefix}_LTX_preloaded_symbols;
  4280. for (; symbol->name; ++symbol)
  4281. {"
  4282. $SED 's/.*/ if (STREQ (symbol->name, \"&\")) symbol->address = (void *) \&&;/' < "$nlist"I >> "$output_objdir/$my_dlsyms"
  4283. echo >> "$output_objdir/$my_dlsyms" "\
  4284. }
  4285. }"
  4286. fi
  4287. echo >> "$output_objdir/$my_dlsyms" "\
  4288. LT_DLSYM_CONST lt_dlsymlist
  4289. lt_${my_prefix}_LTX_preloaded_symbols[] =
  4290. { {\"$my_originator\", (void *) 0},"
  4291. if test -s "$nlist"I; then
  4292. echo >> "$output_objdir/$my_dlsyms" "\
  4293. {\"@INIT@\", (void *) &lt_syminit},"
  4294. fi
  4295. case $need_lib_prefix in
  4296. no)
  4297. eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
  4298. ;;
  4299. *)
  4300. eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
  4301. ;;
  4302. esac
  4303. echo >> "$output_objdir/$my_dlsyms" "\
  4304. {0, (void *) 0}
  4305. };
  4306. /* This works around a problem in FreeBSD linker */
  4307. #ifdef FREEBSD_WORKAROUND
  4308. static const void *lt_preloaded_setup() {
  4309. return lt_${my_prefix}_LTX_preloaded_symbols;
  4310. }
  4311. #endif
  4312. #ifdef __cplusplus
  4313. }
  4314. #endif\
  4315. "
  4316. } # !$opt_dry_run
  4317. pic_flag_for_symtable=
  4318. case "$compile_command " in
  4319. *" -static "*) ;;
  4320. *)
  4321. case $host in
  4322. # compiling the symbol table file with pic_flag works around
  4323. # a FreeBSD bug that causes programs to crash when -lm is
  4324. # linked before any other PIC object. But we must not use
  4325. # pic_flag when linking with -static. The problem exists in
  4326. # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
  4327. *-*-freebsd2.*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
  4328. pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
  4329. *-*-hpux*)
  4330. pic_flag_for_symtable=" $pic_flag" ;;
  4331. *)
  4332. $my_pic_p && pic_flag_for_symtable=" $pic_flag"
  4333. ;;
  4334. esac
  4335. ;;
  4336. esac
  4337. symtab_cflags=
  4338. for arg in $LTCFLAGS; do
  4339. case $arg in
  4340. -pie | -fpie | -fPIE) ;;
  4341. *) func_append symtab_cflags " $arg" ;;
  4342. esac
  4343. done
  4344. # Now compile the dynamic symbol file.
  4345. func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
  4346. # Clean up the generated files.
  4347. func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T" "${nlist}I"'
  4348. # Transform the symbol file into the correct name.
  4349. symfileobj=$output_objdir/${my_outputname}S.$objext
  4350. case $host in
  4351. *cygwin* | *mingw* | *windows* | *cegcc* )
  4352. if test -f "$output_objdir/$my_outputname.def"; then
  4353. compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
  4354. finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
  4355. else
  4356. compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
  4357. finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
  4358. fi
  4359. ;;
  4360. *)
  4361. compile_command=`$ECHO "$compile_command" | $SED "s%@SYMFILE@%$symfileobj%"`
  4362. finalize_command=`$ECHO "$finalize_command" | $SED "s%@SYMFILE@%$symfileobj%"`
  4363. ;;
  4364. esac
  4365. ;;
  4366. *)
  4367. func_fatal_error "unknown suffix for '$my_dlsyms'"
  4368. ;;
  4369. esac
  4370. else
  4371. # We keep going just in case the user didn't refer to
  4372. # lt_preloaded_symbols. The linker will fail if global_symbol_pipe
  4373. # really was required.
  4374. # Nullify the symbol file.
  4375. compile_command=`$ECHO "$compile_command" | $SED "s% @SYMFILE@%%"`
  4376. finalize_command=`$ECHO "$finalize_command" | $SED "s% @SYMFILE@%%"`
  4377. fi
  4378. }
  4379. # func_cygming_gnu_implib_p ARG
  4380. # This predicate returns with zero status (TRUE) if
  4381. # ARG is a GNU/binutils-style import library. Returns
  4382. # with nonzero status (FALSE) otherwise.
  4383. func_cygming_gnu_implib_p ()
  4384. {
  4385. $debug_cmd
  4386. func_to_tool_file "$1" func_convert_file_msys_to_w32
  4387. 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)$'`
  4388. test -n "$func_cygming_gnu_implib_tmp"
  4389. }
  4390. # func_cygming_ms_implib_p ARG
  4391. # This predicate returns with zero status (TRUE) if
  4392. # ARG is an MS-style import library. Returns
  4393. # with nonzero status (FALSE) otherwise.
  4394. func_cygming_ms_implib_p ()
  4395. {
  4396. $debug_cmd
  4397. func_to_tool_file "$1" func_convert_file_msys_to_w32
  4398. func_cygming_ms_implib_tmp=`$NM "$func_to_tool_file_result" | eval "$global_symbol_pipe" | $GREP '_NULL_IMPORT_DESCRIPTOR'`
  4399. test -n "$func_cygming_ms_implib_tmp"
  4400. }
  4401. # func_win32_libid arg
  4402. # return the library type of file 'arg'
  4403. #
  4404. # Need a lot of goo to handle *both* DLLs and import libs
  4405. # Has to be a shell function in order to 'eat' the argument
  4406. # that is supplied when $file_magic_command is called.
  4407. # Despite the name, also deal with 64 bit binaries.
  4408. func_win32_libid ()
  4409. {
  4410. $debug_cmd
  4411. win32_libid_type=unknown
  4412. win32_fileres=`file -L $1 2>/dev/null`
  4413. case $win32_fileres in
  4414. *ar\ archive\ import\ library*) # definitely import
  4415. win32_libid_type="x86 archive import"
  4416. ;;
  4417. *ar\ archive*) # could be an import, or static
  4418. # Keep the egrep pattern in sync with the one in _LT_CHECK_MAGIC_METHOD.
  4419. if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
  4420. $EGREP 'file format (pei*-i386(.*architecture: i386)?|pe-arm-wince|pe-x86-64)' >/dev/null; then
  4421. case $nm_interface in
  4422. "MS dumpbin")
  4423. if func_cygming_ms_implib_p "$1" ||
  4424. func_cygming_gnu_implib_p "$1"
  4425. then
  4426. win32_nmres=import
  4427. else
  4428. win32_nmres=
  4429. fi
  4430. ;;
  4431. *)
  4432. func_to_tool_file "$1" func_convert_file_msys_to_w32
  4433. win32_nmres=`eval $NM -f posix -A \"$func_to_tool_file_result\" |
  4434. $SED -n -e '
  4435. 1,100{
  4436. / I /{
  4437. s|.*|import|
  4438. p
  4439. q
  4440. }
  4441. }'`
  4442. ;;
  4443. esac
  4444. case $win32_nmres in
  4445. import*) win32_libid_type="x86 archive import";;
  4446. *) win32_libid_type="x86 archive static";;
  4447. esac
  4448. fi
  4449. ;;
  4450. *DLL*)
  4451. win32_libid_type="x86 DLL"
  4452. ;;
  4453. *executable*) # but shell scripts are "executable" too...
  4454. case $win32_fileres in
  4455. *MS\ Windows\ PE\ Intel*)
  4456. win32_libid_type="x86 DLL"
  4457. ;;
  4458. esac
  4459. ;;
  4460. esac
  4461. $ECHO "$win32_libid_type"
  4462. }
  4463. # func_cygming_dll_for_implib ARG
  4464. #
  4465. # Platform-specific function to extract the
  4466. # name of the DLL associated with the specified
  4467. # import library ARG.
  4468. # Invoked by eval'ing the libtool variable
  4469. # $sharedlib_from_linklib_cmd
  4470. # Result is available in the variable
  4471. # $sharedlib_from_linklib_result
  4472. func_cygming_dll_for_implib ()
  4473. {
  4474. $debug_cmd
  4475. sharedlib_from_linklib_result=`$DLLTOOL --identify-strict --identify "$1"`
  4476. }
  4477. # func_cygming_dll_for_implib_fallback_core SECTION_NAME LIBNAMEs
  4478. #
  4479. # The is the core of a fallback implementation of a
  4480. # platform-specific function to extract the name of the
  4481. # DLL associated with the specified import library LIBNAME.
  4482. #
  4483. # SECTION_NAME is either .idata$6 or .idata$7, depending
  4484. # on the platform and compiler that created the implib.
  4485. #
  4486. # Echos the name of the DLL associated with the
  4487. # specified import library.
  4488. func_cygming_dll_for_implib_fallback_core ()
  4489. {
  4490. $debug_cmd
  4491. match_literal=`$ECHO "$1" | $SED "$sed_make_literal_regex"`
  4492. $OBJDUMP -s --section "$1" "$2" 2>/dev/null |
  4493. $SED '/^Contents of section '"$match_literal"':/{
  4494. # Place marker at beginning of archive member dllname section
  4495. s/.*/====MARK====/
  4496. p
  4497. d
  4498. }
  4499. # These lines can sometimes be longer than 43 characters, but
  4500. # are always uninteresting
  4501. /:[ ]*file format pe[i]\{,1\}-/d
  4502. /^In archive [^:]*:/d
  4503. # Ensure marker is printed
  4504. /^====MARK====/p
  4505. # Remove all lines with less than 43 characters
  4506. /^.\{43\}/!d
  4507. # From remaining lines, remove first 43 characters
  4508. s/^.\{43\}//' |
  4509. $SED -n '
  4510. # Join marker and all lines until next marker into a single line
  4511. /^====MARK====/ b para
  4512. H
  4513. $ b para
  4514. b
  4515. :para
  4516. x
  4517. s/\n//g
  4518. # Remove the marker
  4519. s/^====MARK====//
  4520. # Remove trailing dots and whitespace
  4521. s/[\. \t]*$//
  4522. # Print
  4523. /./p' |
  4524. # we now have a list, one entry per line, of the stringified
  4525. # contents of the appropriate section of all members of the
  4526. # archive that possess that section. Heuristic: eliminate
  4527. # all those that have a first or second character that is
  4528. # a '.' (that is, objdump's representation of an unprintable
  4529. # character.) This should work for all archives with less than
  4530. # 0x302f exports -- but will fail for DLLs whose name actually
  4531. # begins with a literal '.' or a single character followed by
  4532. # a '.'.
  4533. #
  4534. # Of those that remain, print the first one.
  4535. $SED -e '/^\./d;/^.\./d;q'
  4536. }
  4537. # func_cygming_dll_for_implib_fallback ARG
  4538. # Platform-specific function to extract the
  4539. # name of the DLL associated with the specified
  4540. # import library ARG.
  4541. #
  4542. # This fallback implementation is for use when $DLLTOOL
  4543. # does not support the --identify-strict option.
  4544. # Invoked by eval'ing the libtool variable
  4545. # $sharedlib_from_linklib_cmd
  4546. # Result is available in the variable
  4547. # $sharedlib_from_linklib_result
  4548. func_cygming_dll_for_implib_fallback ()
  4549. {
  4550. $debug_cmd
  4551. if func_cygming_gnu_implib_p "$1"; then
  4552. # binutils import library
  4553. sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$7' "$1"`
  4554. elif func_cygming_ms_implib_p "$1"; then
  4555. # ms-generated import library
  4556. sharedlib_from_linklib_result=`func_cygming_dll_for_implib_fallback_core '.idata$6' "$1"`
  4557. else
  4558. # unknown
  4559. sharedlib_from_linklib_result=
  4560. fi
  4561. }
  4562. # func_extract_an_archive dir oldlib
  4563. func_extract_an_archive ()
  4564. {
  4565. $debug_cmd
  4566. f_ex_an_ar_dir=$1; shift
  4567. f_ex_an_ar_oldlib=$1
  4568. if test yes = "$lock_old_archive_extraction"; then
  4569. lockfile=$f_ex_an_ar_oldlib.lock
  4570. until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
  4571. func_echo "Waiting for $lockfile to be removed"
  4572. sleep 2
  4573. done
  4574. fi
  4575. func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" \
  4576. 'stat=$?; rm -f "$lockfile"; exit $stat'
  4577. if test yes = "$lock_old_archive_extraction"; then
  4578. $opt_dry_run || rm -f "$lockfile"
  4579. fi
  4580. if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
  4581. :
  4582. else
  4583. func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
  4584. fi
  4585. }
  4586. # func_extract_archives gentop oldlib ...
  4587. func_extract_archives ()
  4588. {
  4589. $debug_cmd
  4590. my_gentop=$1; shift
  4591. my_oldlibs=${1+"$@"}
  4592. my_oldobjs=
  4593. my_xlib=
  4594. my_xabs=
  4595. my_xdir=
  4596. for my_xlib in $my_oldlibs; do
  4597. # Extract the objects.
  4598. case $my_xlib in
  4599. [\\/]* | [A-Za-z]:[\\/]*) my_xabs=$my_xlib ;;
  4600. *) my_xabs=`pwd`"/$my_xlib" ;;
  4601. esac
  4602. func_basename "$my_xlib"
  4603. my_xlib=$func_basename_result
  4604. my_xlib_u=$my_xlib
  4605. while :; do
  4606. case " $extracted_archives " in
  4607. *" $my_xlib_u "*)
  4608. func_arith $extracted_serial + 1
  4609. extracted_serial=$func_arith_result
  4610. my_xlib_u=lt$extracted_serial-$my_xlib ;;
  4611. *) break ;;
  4612. esac
  4613. done
  4614. extracted_archives="$extracted_archives $my_xlib_u"
  4615. my_xdir=$my_gentop/$my_xlib_u
  4616. func_mkdir_p "$my_xdir"
  4617. case $host in
  4618. *-darwin*)
  4619. func_verbose "Extracting $my_xabs"
  4620. # Do not bother doing anything if just a dry run
  4621. $opt_dry_run || {
  4622. darwin_orig_dir=`pwd`
  4623. cd $my_xdir || exit $?
  4624. darwin_archive=$my_xabs
  4625. darwin_curdir=`pwd`
  4626. func_basename "$darwin_archive"
  4627. darwin_base_archive=$func_basename_result
  4628. darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
  4629. if test -n "$darwin_arches"; then
  4630. darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
  4631. darwin_arch=
  4632. func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
  4633. for darwin_arch in $darwin_arches; do
  4634. func_mkdir_p "unfat-$$/$darwin_base_archive-$darwin_arch"
  4635. $LIPO -thin $darwin_arch -output "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive" "$darwin_archive"
  4636. cd "unfat-$$/$darwin_base_archive-$darwin_arch"
  4637. func_extract_an_archive "`pwd`" "$darwin_base_archive"
  4638. cd "$darwin_curdir"
  4639. $RM "unfat-$$/$darwin_base_archive-$darwin_arch/$darwin_base_archive"
  4640. done # $darwin_arches
  4641. ## Okay now we've a bunch of thin objects, gotta fatten them up :)
  4642. darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$sed_basename" | sort -u`
  4643. darwin_file=
  4644. darwin_files=
  4645. for darwin_file in $darwin_filelist; do
  4646. darwin_files=`find unfat-$$ -name $darwin_file -print | sort | $NL2SP`
  4647. $LIPO -create -output "$darwin_file" $darwin_files
  4648. done # $darwin_filelist
  4649. $RM -rf unfat-$$
  4650. cd "$darwin_orig_dir"
  4651. else
  4652. cd $darwin_orig_dir
  4653. func_extract_an_archive "$my_xdir" "$my_xabs"
  4654. fi # $darwin_arches
  4655. } # !$opt_dry_run
  4656. ;;
  4657. *)
  4658. func_extract_an_archive "$my_xdir" "$my_xabs"
  4659. ;;
  4660. esac
  4661. my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | sort | $NL2SP`
  4662. done
  4663. func_extract_archives_result=$my_oldobjs
  4664. }
  4665. # func_emit_wrapper [arg=no]
  4666. #
  4667. # Emit a libtool wrapper script on stdout.
  4668. # Don't directly open a file because we may want to
  4669. # incorporate the script contents within a cygwin/mingw/windows
  4670. # wrapper executable. Must ONLY be called from within
  4671. # func_mode_link because it depends on a number of variables
  4672. # set therein.
  4673. #
  4674. # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
  4675. # variable will take. If 'yes', then the emitted script
  4676. # will assume that the directory where it is stored is
  4677. # the $objdir directory. This is a cygwin/mingw/windows-specific
  4678. # behavior.
  4679. func_emit_wrapper ()
  4680. {
  4681. func_emit_wrapper_arg1=${1-no}
  4682. $ECHO "\
  4683. #! $SHELL
  4684. # $output - temporary wrapper script for $objdir/$outputname
  4685. # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
  4686. #
  4687. # The $output program cannot be directly executed until all the libtool
  4688. # libraries that it depends on are installed.
  4689. #
  4690. # This wrapper script should never be moved out of the build directory.
  4691. # If it is, it will not operate correctly.
  4692. # Sed substitution that helps us do robust quoting. It backslashifies
  4693. # metacharacters that are still active within double-quoted strings.
  4694. sed_quote_subst='$sed_quote_subst'
  4695. # Be Bourne compatible
  4696. if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
  4697. emulate sh
  4698. NULLCMD=:
  4699. # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
  4700. # is contrary to our usage. Disable this feature.
  4701. alias -g '\${1+\"\$@\"}'='\"\$@\"'
  4702. setopt NO_GLOB_SUBST
  4703. else
  4704. case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
  4705. fi
  4706. BIN_SH=xpg4; export BIN_SH # for Tru64
  4707. DUALCASE=1; export DUALCASE # for MKS sh
  4708. # The HP-UX ksh and POSIX shell print the target directory to stdout
  4709. # if CDPATH is set.
  4710. (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
  4711. relink_command=\"$relink_command\"
  4712. # This environment variable determines our operation mode.
  4713. if test \"\$libtool_install_magic\" = \"$magic\"; then
  4714. # install mode needs the following variables:
  4715. generated_by_libtool_version='$macro_version'
  4716. notinst_deplibs='$notinst_deplibs'
  4717. else
  4718. # When we are sourced in execute mode, \$file and \$ECHO are already set.
  4719. if test \"\$libtool_execute_magic\" != \"$magic\"; then
  4720. file=\"\$0\""
  4721. func_quote_arg pretty "$ECHO"
  4722. qECHO=$func_quote_arg_result
  4723. $ECHO "\
  4724. # A function that is used when there is no print builtin or printf.
  4725. func_fallback_echo ()
  4726. {
  4727. eval 'cat <<_LTECHO_EOF
  4728. \$1
  4729. _LTECHO_EOF'
  4730. }
  4731. ECHO=$qECHO
  4732. fi
  4733. # Very basic option parsing. These options are (a) specific to
  4734. # the libtool wrapper, (b) are identical between the wrapper
  4735. # /script/ and the wrapper /executable/ that is used only on
  4736. # windows platforms, and (c) all begin with the string "--lt-"
  4737. # (application programs are unlikely to have options that match
  4738. # this pattern).
  4739. #
  4740. # There are only two supported options: --lt-debug and
  4741. # --lt-dump-script. There is, deliberately, no --lt-help.
  4742. #
  4743. # The first argument to this parsing function should be the
  4744. # script's $0 value, followed by "$@".
  4745. lt_option_debug=
  4746. func_parse_lt_options ()
  4747. {
  4748. lt_script_arg0=\$0
  4749. shift
  4750. for lt_opt
  4751. do
  4752. case \"\$lt_opt\" in
  4753. --lt-debug) lt_option_debug=1 ;;
  4754. --lt-dump-script)
  4755. lt_dump_D=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%/[^/]*$%%'\`
  4756. test \"X\$lt_dump_D\" = \"X\$lt_script_arg0\" && lt_dump_D=.
  4757. lt_dump_F=\`\$ECHO \"X\$lt_script_arg0\" | $SED -e 's/^X//' -e 's%^.*/%%'\`
  4758. cat \"\$lt_dump_D/\$lt_dump_F\"
  4759. exit 0
  4760. ;;
  4761. --lt-*)
  4762. \$ECHO \"Unrecognized --lt- option: '\$lt_opt'\" 1>&2
  4763. exit 1
  4764. ;;
  4765. esac
  4766. done
  4767. # Print the debug banner immediately:
  4768. if test -n \"\$lt_option_debug\"; then
  4769. echo \"$outputname:$output:\$LINENO: libtool wrapper (GNU $PACKAGE) $VERSION\" 1>&2
  4770. fi
  4771. }
  4772. # Used when --lt-debug. Prints its arguments to stdout
  4773. # (redirection is the responsibility of the caller)
  4774. func_lt_dump_args ()
  4775. {
  4776. lt_dump_args_N=1;
  4777. for lt_arg
  4778. do
  4779. \$ECHO \"$outputname:$output:\$LINENO: newargv[\$lt_dump_args_N]: \$lt_arg\"
  4780. lt_dump_args_N=\`expr \$lt_dump_args_N + 1\`
  4781. done
  4782. }
  4783. # Core function for launching the target application
  4784. func_exec_program_core ()
  4785. {
  4786. "
  4787. case $host in
  4788. # Backslashes separate directories on plain windows
  4789. *-*-mingw* | *-*-windows* | *-*-os2* | *-cegcc*)
  4790. $ECHO "\
  4791. if test -n \"\$lt_option_debug\"; then
  4792. \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir\\\\\$program\" 1>&2
  4793. func_lt_dump_args \${1+\"\$@\"} 1>&2
  4794. fi
  4795. exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
  4796. "
  4797. ;;
  4798. *)
  4799. $ECHO "\
  4800. if test -n \"\$lt_option_debug\"; then
  4801. \$ECHO \"$outputname:$output:\$LINENO: newargv[0]: \$progdir/\$program\" 1>&2
  4802. func_lt_dump_args \${1+\"\$@\"} 1>&2
  4803. fi
  4804. exec \"\$progdir/\$program\" \${1+\"\$@\"}
  4805. "
  4806. ;;
  4807. esac
  4808. $ECHO "\
  4809. \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
  4810. exit 1
  4811. }
  4812. # A function to encapsulate launching the target application
  4813. # Strips options in the --lt-* namespace from \$@ and
  4814. # launches target application with the remaining arguments.
  4815. func_exec_program ()
  4816. {
  4817. case \" \$* \" in
  4818. *\\ --lt-*)
  4819. for lt_wr_arg
  4820. do
  4821. case \$lt_wr_arg in
  4822. --lt-*) ;;
  4823. *) set x \"\$@\" \"\$lt_wr_arg\"; shift;;
  4824. esac
  4825. shift
  4826. done ;;
  4827. esac
  4828. func_exec_program_core \${1+\"\$@\"}
  4829. }
  4830. # Parse options
  4831. func_parse_lt_options \"\$0\" \${1+\"\$@\"}
  4832. # Find the directory that this script lives in.
  4833. thisdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*$%%'\`
  4834. test \"x\$thisdir\" = \"x\$file\" && thisdir=.
  4835. # Follow symbolic links until we get to the real thisdir.
  4836. file=\`ls -ld \"\$file\" | $SED -n 's/.*-> //p'\`
  4837. while test -n \"\$file\"; do
  4838. destdir=\`\$ECHO \"\$file\" | $SED 's%/[^/]*\$%%'\`
  4839. # If there was a directory component, then change thisdir.
  4840. if test \"x\$destdir\" != \"x\$file\"; then
  4841. case \"\$destdir\" in
  4842. [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
  4843. *) thisdir=\"\$thisdir/\$destdir\" ;;
  4844. esac
  4845. fi
  4846. file=\`\$ECHO \"\$file\" | $SED 's%^.*/%%'\`
  4847. file=\`ls -ld \"\$thisdir/\$file\" | $SED -n 's/.*-> //p'\`
  4848. done
  4849. # Usually 'no', except on cygwin/mingw/windows when embedded into
  4850. # the cwrapper.
  4851. WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_arg1
  4852. if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
  4853. # special case for '.'
  4854. if test \"\$thisdir\" = \".\"; then
  4855. thisdir=\`pwd\`
  4856. fi
  4857. # remove .libs from thisdir
  4858. case \"\$thisdir\" in
  4859. *[\\\\/]$objdir ) thisdir=\`\$ECHO \"\$thisdir\" | $SED 's%[\\\\/][^\\\\/]*$%%'\` ;;
  4860. $objdir ) thisdir=. ;;
  4861. esac
  4862. fi
  4863. # Try to get the absolute directory name.
  4864. absdir=\`cd \"\$thisdir\" && pwd\`
  4865. test -n \"\$absdir\" && thisdir=\"\$absdir\"
  4866. "
  4867. if test yes = "$fast_install"; then
  4868. $ECHO "\
  4869. program=lt-'$outputname'$exeext
  4870. progdir=\"\$thisdir/$objdir\"
  4871. if test ! -f \"\$progdir/\$program\" ||
  4872. { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | $SED 1q\`; \\
  4873. test \"X\$file\" != \"X\$progdir/\$program\"; }; then
  4874. file=\"\$\$-\$program\"
  4875. if test ! -d \"\$progdir\"; then
  4876. $MKDIR \"\$progdir\"
  4877. else
  4878. $RM \"\$progdir/\$file\"
  4879. fi"
  4880. $ECHO "\
  4881. # relink executable if necessary
  4882. if test -n \"\$relink_command\"; then
  4883. if relink_command_output=\`eval \$relink_command 2>&1\`; then :
  4884. else
  4885. \$ECHO \"\$relink_command_output\" >&2
  4886. $RM \"\$progdir/\$file\"
  4887. exit 1
  4888. fi
  4889. fi
  4890. $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
  4891. { $RM \"\$progdir/\$program\";
  4892. $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
  4893. $RM \"\$progdir/\$file\"
  4894. fi"
  4895. else
  4896. $ECHO "\
  4897. program='$outputname'
  4898. progdir=\"\$thisdir/$objdir\"
  4899. "
  4900. fi
  4901. $ECHO "\
  4902. if test -f \"\$progdir/\$program\"; then"
  4903. # fixup the dll searchpath if we need to.
  4904. #
  4905. # Fix the DLL searchpath if we need to. Do this before prepending
  4906. # to shlibpath, because on Windows, both are PATH and uninstalled
  4907. # libraries must come first.
  4908. if test -n "$dllsearchpath"; then
  4909. $ECHO "\
  4910. # Add the dll search path components to the executable PATH
  4911. PATH=$dllsearchpath:\$PATH
  4912. "
  4913. fi
  4914. # Export our shlibpath_var if we have one.
  4915. if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
  4916. $ECHO "\
  4917. # Add our own library path to $shlibpath_var
  4918. $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
  4919. # Some systems cannot cope with colon-terminated $shlibpath_var
  4920. # The second colon is a workaround for a bug in BeOS R4 sed
  4921. $shlibpath_var=\`\$ECHO \"\$$shlibpath_var\" | $SED 's/::*\$//'\`
  4922. export $shlibpath_var
  4923. "
  4924. fi
  4925. $ECHO "\
  4926. if test \"\$libtool_execute_magic\" != \"$magic\"; then
  4927. # Run the actual program with our arguments.
  4928. func_exec_program \${1+\"\$@\"}
  4929. fi
  4930. else
  4931. # The program doesn't exist.
  4932. \$ECHO \"\$0: error: '\$progdir/\$program' does not exist\" 1>&2
  4933. \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
  4934. \$ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
  4935. exit 1
  4936. fi
  4937. fi\
  4938. "
  4939. }
  4940. # func_emit_cwrapperexe_src
  4941. # emit the source code for a wrapper executable on stdout
  4942. # Must ONLY be called from within func_mode_link because
  4943. # it depends on a number of variable set therein.
  4944. func_emit_cwrapperexe_src ()
  4945. {
  4946. cat <<EOF
  4947. /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
  4948. Generated by $PROGRAM (GNU $PACKAGE) $VERSION
  4949. The $output program cannot be directly executed until all the libtool
  4950. libraries that it depends on are installed.
  4951. This wrapper executable should never be moved out of the build directory.
  4952. If it is, it will not operate correctly.
  4953. */
  4954. EOF
  4955. cat <<"EOF"
  4956. #ifdef _MSC_VER
  4957. # define _CRT_SECURE_NO_DEPRECATE 1
  4958. #endif
  4959. #include <stdio.h>
  4960. #include <stdlib.h>
  4961. #if defined _WIN32 && !defined __GNUC__
  4962. # include <direct.h>
  4963. # include <process.h>
  4964. # include <io.h>
  4965. #else
  4966. # include <unistd.h>
  4967. # include <stdint.h>
  4968. # ifdef __CYGWIN__
  4969. # include <io.h>
  4970. # endif
  4971. #endif
  4972. #include <malloc.h>
  4973. #include <stdarg.h>
  4974. #include <assert.h>
  4975. #include <string.h>
  4976. #include <ctype.h>
  4977. #include <errno.h>
  4978. #include <fcntl.h>
  4979. #include <sys/stat.h>
  4980. #define STREQ(s1, s2) (strcmp ((s1), (s2)) == 0)
  4981. /* declarations of non-ANSI functions */
  4982. #if defined __MINGW32__
  4983. # ifdef __STRICT_ANSI__
  4984. _CRTIMP int __cdecl _putenv (const char *);
  4985. # endif
  4986. #elif defined __CYGWIN__
  4987. # ifdef __STRICT_ANSI__
  4988. char *realpath (const char *, char *);
  4989. int putenv (char *);
  4990. int setenv (const char *, const char *, int);
  4991. # endif
  4992. /* #elif defined other_platform || defined ... */
  4993. #endif
  4994. /* portability defines, excluding path handling macros */
  4995. #if defined _MSC_VER
  4996. # define setmode _setmode
  4997. # define stat _stat
  4998. # define chmod _chmod
  4999. # define getcwd _getcwd
  5000. # define putenv _putenv
  5001. # define S_IXUSR _S_IEXEC
  5002. #elif defined __MINGW32__
  5003. # define setmode _setmode
  5004. # define stat _stat
  5005. # define chmod _chmod
  5006. # define getcwd _getcwd
  5007. # define putenv _putenv
  5008. #elif defined __CYGWIN__
  5009. # define HAVE_SETENV
  5010. # define FOPEN_WB "wb"
  5011. /* #elif defined other platforms ... */
  5012. #endif
  5013. #if defined PATH_MAX
  5014. # define LT_PATHMAX PATH_MAX
  5015. #elif defined MAXPATHLEN
  5016. # define LT_PATHMAX MAXPATHLEN
  5017. #else
  5018. # define LT_PATHMAX 1024
  5019. #endif
  5020. #ifndef S_IXOTH
  5021. # define S_IXOTH 0
  5022. #endif
  5023. #ifndef S_IXGRP
  5024. # define S_IXGRP 0
  5025. #endif
  5026. /* path handling portability macros */
  5027. #ifndef DIR_SEPARATOR
  5028. # define DIR_SEPARATOR '/'
  5029. # define PATH_SEPARATOR ':'
  5030. #endif
  5031. #if defined _WIN32 || defined __MSDOS__ || defined __DJGPP__ || \
  5032. defined __OS2__
  5033. # define HAVE_DOS_BASED_FILE_SYSTEM
  5034. # define FOPEN_WB "wb"
  5035. # ifndef DIR_SEPARATOR_2
  5036. # define DIR_SEPARATOR_2 '\\'
  5037. # endif
  5038. # ifndef PATH_SEPARATOR_2
  5039. # define PATH_SEPARATOR_2 ';'
  5040. # endif
  5041. #endif
  5042. #ifndef DIR_SEPARATOR_2
  5043. # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
  5044. #else /* DIR_SEPARATOR_2 */
  5045. # define IS_DIR_SEPARATOR(ch) \
  5046. (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
  5047. #endif /* DIR_SEPARATOR_2 */
  5048. #ifndef PATH_SEPARATOR_2
  5049. # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
  5050. #else /* PATH_SEPARATOR_2 */
  5051. # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
  5052. #endif /* PATH_SEPARATOR_2 */
  5053. #ifndef FOPEN_WB
  5054. # define FOPEN_WB "w"
  5055. #endif
  5056. #ifndef _O_BINARY
  5057. # define _O_BINARY 0
  5058. #endif
  5059. #define XMALLOC(type, num) ((type *) xmalloc ((num) * sizeof(type)))
  5060. #define XFREE(stale) do { \
  5061. if (stale) { free (stale); stale = 0; } \
  5062. } while (0)
  5063. #if defined LT_DEBUGWRAPPER
  5064. static int lt_debug = 1;
  5065. #else
  5066. static int lt_debug = 0;
  5067. #endif
  5068. const char *program_name = "libtool-wrapper"; /* in case xstrdup fails */
  5069. void *xmalloc (size_t num);
  5070. char *xstrdup (const char *string);
  5071. const char *base_name (const char *name);
  5072. char *find_executable (const char *wrapper);
  5073. char *chase_symlinks (const char *pathspec);
  5074. int make_executable (const char *path);
  5075. int check_executable (const char *path);
  5076. char *strendzap (char *str, const char *pat);
  5077. void lt_debugprintf (const char *file, int line, const char *fmt, ...);
  5078. void lt_fatal (const char *file, int line, const char *message, ...);
  5079. static const char *nonnull (const char *s);
  5080. static const char *nonempty (const char *s);
  5081. void lt_setenv (const char *name, const char *value);
  5082. char *lt_extend_str (const char *orig_value, const char *add, int to_end);
  5083. void lt_update_exe_path (const char *name, const char *value);
  5084. void lt_update_lib_path (const char *name, const char *value);
  5085. char **prepare_spawn (char **argv);
  5086. void lt_dump_script (FILE *f);
  5087. EOF
  5088. cat <<EOF
  5089. #if __GNUC__ < 4 || (__GNUC__ == 4 && __GNUC_MINOR__ < 5)
  5090. # define externally_visible volatile
  5091. #else
  5092. # define externally_visible __attribute__((externally_visible)) volatile
  5093. #endif
  5094. externally_visible const char * MAGIC_EXE = "$magic_exe";
  5095. const char * LIB_PATH_VARNAME = "$shlibpath_var";
  5096. EOF
  5097. if test yes = "$shlibpath_overrides_runpath" && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
  5098. func_to_host_path "$temp_rpath"
  5099. cat <<EOF
  5100. const char * LIB_PATH_VALUE = "$func_to_host_path_result";
  5101. EOF
  5102. else
  5103. cat <<"EOF"
  5104. const char * LIB_PATH_VALUE = "";
  5105. EOF
  5106. fi
  5107. if test -n "$dllsearchpath"; then
  5108. func_to_host_path "$dllsearchpath:"
  5109. cat <<EOF
  5110. const char * EXE_PATH_VARNAME = "PATH";
  5111. const char * EXE_PATH_VALUE = "$func_to_host_path_result";
  5112. EOF
  5113. else
  5114. cat <<"EOF"
  5115. const char * EXE_PATH_VARNAME = "";
  5116. const char * EXE_PATH_VALUE = "";
  5117. EOF
  5118. fi
  5119. if test yes = "$fast_install"; then
  5120. cat <<EOF
  5121. const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
  5122. EOF
  5123. else
  5124. cat <<EOF
  5125. const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
  5126. EOF
  5127. fi
  5128. cat <<"EOF"
  5129. #define LTWRAPPER_OPTION_PREFIX "--lt-"
  5130. static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
  5131. static const char *dumpscript_opt = LTWRAPPER_OPTION_PREFIX "dump-script";
  5132. static const char *debug_opt = LTWRAPPER_OPTION_PREFIX "debug";
  5133. int
  5134. main (int argc, char *argv[])
  5135. {
  5136. char **newargz;
  5137. int newargc;
  5138. char *tmp_pathspec;
  5139. char *actual_cwrapper_path;
  5140. char *actual_cwrapper_name;
  5141. char *target_name;
  5142. char *lt_argv_zero;
  5143. int rval = 127;
  5144. int i;
  5145. program_name = (char *) xstrdup (base_name (argv[0]));
  5146. newargz = XMALLOC (char *, (size_t) argc + 1);
  5147. /* very simple arg parsing; don't want to rely on getopt
  5148. * also, copy all non cwrapper options to newargz, except
  5149. * argz[0], which is handled differently
  5150. */
  5151. newargc=0;
  5152. for (i = 1; i < argc; i++)
  5153. {
  5154. if (STREQ (argv[i], dumpscript_opt))
  5155. {
  5156. EOF
  5157. case $host in
  5158. *mingw* | *windows* | *cygwin* )
  5159. # make stdout use "unix" line endings
  5160. echo " setmode(1,_O_BINARY);"
  5161. ;;
  5162. esac
  5163. cat <<"EOF"
  5164. lt_dump_script (stdout);
  5165. return 0;
  5166. }
  5167. if (STREQ (argv[i], debug_opt))
  5168. {
  5169. lt_debug = 1;
  5170. continue;
  5171. }
  5172. if (STREQ (argv[i], ltwrapper_option_prefix))
  5173. {
  5174. /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
  5175. namespace, but it is not one of the ones we know about and
  5176. have already dealt with, above (including dump-script), then
  5177. report an error. Otherwise, targets might begin to believe
  5178. they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
  5179. namespace. The first time any user complains about this, we'll
  5180. need to make LTWRAPPER_OPTION_PREFIX a configure-time option
  5181. or a configure.ac-settable value.
  5182. */
  5183. lt_fatal (__FILE__, __LINE__,
  5184. "unrecognized %s option: '%s'",
  5185. ltwrapper_option_prefix, argv[i]);
  5186. }
  5187. /* otherwise ... */
  5188. newargz[++newargc] = xstrdup (argv[i]);
  5189. }
  5190. newargz[++newargc] = NULL;
  5191. EOF
  5192. cat <<EOF
  5193. /* The GNU banner must be the first non-error debug message */
  5194. lt_debugprintf (__FILE__, __LINE__, "libtool wrapper (GNU $PACKAGE) $VERSION\n");
  5195. EOF
  5196. cat <<"EOF"
  5197. lt_debugprintf (__FILE__, __LINE__, "(main) argv[0]: %s\n", argv[0]);
  5198. lt_debugprintf (__FILE__, __LINE__, "(main) program_name: %s\n", program_name);
  5199. tmp_pathspec = find_executable (argv[0]);
  5200. if (tmp_pathspec == NULL)
  5201. lt_fatal (__FILE__, __LINE__, "couldn't find %s", argv[0]);
  5202. lt_debugprintf (__FILE__, __LINE__,
  5203. "(main) found exe (before symlink chase) at: %s\n",
  5204. tmp_pathspec);
  5205. actual_cwrapper_path = chase_symlinks (tmp_pathspec);
  5206. lt_debugprintf (__FILE__, __LINE__,
  5207. "(main) found exe (after symlink chase) at: %s\n",
  5208. actual_cwrapper_path);
  5209. XFREE (tmp_pathspec);
  5210. actual_cwrapper_name = xstrdup (base_name (actual_cwrapper_path));
  5211. strendzap (actual_cwrapper_path, actual_cwrapper_name);
  5212. /* wrapper name transforms */
  5213. strendzap (actual_cwrapper_name, ".exe");
  5214. tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
  5215. XFREE (actual_cwrapper_name);
  5216. actual_cwrapper_name = tmp_pathspec;
  5217. tmp_pathspec = 0;
  5218. /* target_name transforms -- use actual target program name; might have lt- prefix */
  5219. target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
  5220. strendzap (target_name, ".exe");
  5221. tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
  5222. XFREE (target_name);
  5223. target_name = tmp_pathspec;
  5224. tmp_pathspec = 0;
  5225. lt_debugprintf (__FILE__, __LINE__,
  5226. "(main) libtool target name: %s\n",
  5227. target_name);
  5228. EOF
  5229. cat <<EOF
  5230. newargz[0] =
  5231. XMALLOC (char, (strlen (actual_cwrapper_path) +
  5232. strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
  5233. strcpy (newargz[0], actual_cwrapper_path);
  5234. strcat (newargz[0], "$objdir");
  5235. strcat (newargz[0], "/");
  5236. EOF
  5237. cat <<"EOF"
  5238. /* stop here, and copy so we don't have to do this twice */
  5239. tmp_pathspec = xstrdup (newargz[0]);
  5240. /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
  5241. strcat (newargz[0], actual_cwrapper_name);
  5242. /* DO want the lt- prefix here if it exists, so use target_name */
  5243. lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
  5244. XFREE (tmp_pathspec);
  5245. tmp_pathspec = NULL;
  5246. EOF
  5247. case $host_os in
  5248. mingw* | windows*)
  5249. cat <<"EOF"
  5250. {
  5251. char* p;
  5252. while ((p = strchr (newargz[0], '\\')) != NULL)
  5253. {
  5254. *p = '/';
  5255. }
  5256. while ((p = strchr (lt_argv_zero, '\\')) != NULL)
  5257. {
  5258. *p = '/';
  5259. }
  5260. }
  5261. EOF
  5262. ;;
  5263. esac
  5264. cat <<"EOF"
  5265. XFREE (target_name);
  5266. XFREE (actual_cwrapper_path);
  5267. XFREE (actual_cwrapper_name);
  5268. lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
  5269. lt_setenv ("DUALCASE", "1"); /* for MSK sh */
  5270. /* Update the DLL searchpath. EXE_PATH_VALUE ($dllsearchpath) must
  5271. be prepended before (that is, appear after) LIB_PATH_VALUE ($temp_rpath)
  5272. because on Windows, both *_VARNAMEs are PATH but uninstalled
  5273. libraries must come first. */
  5274. lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
  5275. lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
  5276. lt_debugprintf (__FILE__, __LINE__, "(main) lt_argv_zero: %s\n",
  5277. nonnull (lt_argv_zero));
  5278. for (i = 0; i < newargc; i++)
  5279. {
  5280. lt_debugprintf (__FILE__, __LINE__, "(main) newargz[%d]: %s\n",
  5281. i, nonnull (newargz[i]));
  5282. }
  5283. EOF
  5284. case $host_os in
  5285. mingw* | windows*)
  5286. cat <<"EOF"
  5287. /* execv doesn't actually work on mingw as expected on unix */
  5288. newargz = prepare_spawn (newargz);
  5289. rval = (int) _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
  5290. if (rval == -1)
  5291. {
  5292. /* failed to start process */
  5293. lt_debugprintf (__FILE__, __LINE__,
  5294. "(main) failed to launch target \"%s\": %s\n",
  5295. lt_argv_zero, nonnull (strerror (errno)));
  5296. return 127;
  5297. }
  5298. return rval;
  5299. EOF
  5300. ;;
  5301. *)
  5302. cat <<"EOF"
  5303. execv (lt_argv_zero, newargz);
  5304. return rval; /* =127, but avoids unused variable warning */
  5305. EOF
  5306. ;;
  5307. esac
  5308. cat <<"EOF"
  5309. }
  5310. void *
  5311. xmalloc (size_t num)
  5312. {
  5313. void *p = (void *) malloc (num);
  5314. if (!p)
  5315. lt_fatal (__FILE__, __LINE__, "memory exhausted");
  5316. return p;
  5317. }
  5318. char *
  5319. xstrdup (const char *string)
  5320. {
  5321. return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
  5322. string) : NULL;
  5323. }
  5324. const char *
  5325. base_name (const char *name)
  5326. {
  5327. const char *base;
  5328. #if defined HAVE_DOS_BASED_FILE_SYSTEM
  5329. /* Skip over the disk name in MSDOS pathnames. */
  5330. if (isalpha ((unsigned char) name[0]) && name[1] == ':')
  5331. name += 2;
  5332. #endif
  5333. for (base = name; *name; name++)
  5334. if (IS_DIR_SEPARATOR (*name))
  5335. base = name + 1;
  5336. return base;
  5337. }
  5338. int
  5339. check_executable (const char *path)
  5340. {
  5341. struct stat st;
  5342. lt_debugprintf (__FILE__, __LINE__, "(check_executable): %s\n",
  5343. nonempty (path));
  5344. if ((!path) || (!*path))
  5345. return 0;
  5346. if ((stat (path, &st) >= 0)
  5347. && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
  5348. return 1;
  5349. else
  5350. return 0;
  5351. }
  5352. int
  5353. make_executable (const char *path)
  5354. {
  5355. int rval = 0;
  5356. struct stat st;
  5357. lt_debugprintf (__FILE__, __LINE__, "(make_executable): %s\n",
  5358. nonempty (path));
  5359. if ((!path) || (!*path))
  5360. return 0;
  5361. if (stat (path, &st) >= 0)
  5362. {
  5363. rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
  5364. }
  5365. return rval;
  5366. }
  5367. /* Searches for the full path of the wrapper. Returns
  5368. newly allocated full path name if found, NULL otherwise
  5369. Does not chase symlinks, even on platforms that support them.
  5370. */
  5371. char *
  5372. find_executable (const char *wrapper)
  5373. {
  5374. int has_slash = 0;
  5375. const char *p;
  5376. const char *p_next;
  5377. /* static buffer for getcwd */
  5378. char tmp[LT_PATHMAX + 1];
  5379. size_t tmp_len;
  5380. char *concat_name;
  5381. lt_debugprintf (__FILE__, __LINE__, "(find_executable): %s\n",
  5382. nonempty (wrapper));
  5383. if ((wrapper == NULL) || (*wrapper == '\0'))
  5384. return NULL;
  5385. /* Absolute path? */
  5386. #if defined HAVE_DOS_BASED_FILE_SYSTEM
  5387. if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
  5388. {
  5389. concat_name = xstrdup (wrapper);
  5390. if (check_executable (concat_name))
  5391. return concat_name;
  5392. XFREE (concat_name);
  5393. }
  5394. else
  5395. {
  5396. #endif
  5397. if (IS_DIR_SEPARATOR (wrapper[0]))
  5398. {
  5399. concat_name = xstrdup (wrapper);
  5400. if (check_executable (concat_name))
  5401. return concat_name;
  5402. XFREE (concat_name);
  5403. }
  5404. #if defined HAVE_DOS_BASED_FILE_SYSTEM
  5405. }
  5406. #endif
  5407. for (p = wrapper; *p; p++)
  5408. if (*p == '/')
  5409. {
  5410. has_slash = 1;
  5411. break;
  5412. }
  5413. if (!has_slash)
  5414. {
  5415. /* no slashes; search PATH */
  5416. const char *path = getenv ("PATH");
  5417. if (path != NULL)
  5418. {
  5419. for (p = path; *p; p = p_next)
  5420. {
  5421. const char *q;
  5422. size_t p_len;
  5423. for (q = p; *q; q++)
  5424. if (IS_PATH_SEPARATOR (*q))
  5425. break;
  5426. p_len = (size_t) (q - p);
  5427. p_next = (*q == '\0' ? q : q + 1);
  5428. if (p_len == 0)
  5429. {
  5430. /* empty path: current directory */
  5431. if (getcwd (tmp, LT_PATHMAX) == NULL)
  5432. lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
  5433. nonnull (strerror (errno)));
  5434. tmp_len = strlen (tmp);
  5435. concat_name =
  5436. XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
  5437. memcpy (concat_name, tmp, tmp_len);
  5438. concat_name[tmp_len] = '/';
  5439. strcpy (concat_name + tmp_len + 1, wrapper);
  5440. }
  5441. else
  5442. {
  5443. concat_name =
  5444. XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
  5445. memcpy (concat_name, p, p_len);
  5446. concat_name[p_len] = '/';
  5447. strcpy (concat_name + p_len + 1, wrapper);
  5448. }
  5449. if (check_executable (concat_name))
  5450. return concat_name;
  5451. XFREE (concat_name);
  5452. }
  5453. }
  5454. /* not found in PATH; assume curdir */
  5455. }
  5456. /* Relative path | not found in path: prepend cwd */
  5457. if (getcwd (tmp, LT_PATHMAX) == NULL)
  5458. lt_fatal (__FILE__, __LINE__, "getcwd failed: %s",
  5459. nonnull (strerror (errno)));
  5460. tmp_len = strlen (tmp);
  5461. concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
  5462. memcpy (concat_name, tmp, tmp_len);
  5463. concat_name[tmp_len] = '/';
  5464. strcpy (concat_name + tmp_len + 1, wrapper);
  5465. if (check_executable (concat_name))
  5466. return concat_name;
  5467. XFREE (concat_name);
  5468. return NULL;
  5469. }
  5470. char *
  5471. chase_symlinks (const char *pathspec)
  5472. {
  5473. #ifndef S_ISLNK
  5474. return xstrdup (pathspec);
  5475. #else
  5476. char buf[LT_PATHMAX];
  5477. struct stat s;
  5478. char *tmp_pathspec = xstrdup (pathspec);
  5479. char *p;
  5480. int has_symlinks = 0;
  5481. while (strlen (tmp_pathspec) && !has_symlinks)
  5482. {
  5483. lt_debugprintf (__FILE__, __LINE__,
  5484. "checking path component for symlinks: %s\n",
  5485. tmp_pathspec);
  5486. if (lstat (tmp_pathspec, &s) == 0)
  5487. {
  5488. if (S_ISLNK (s.st_mode) != 0)
  5489. {
  5490. has_symlinks = 1;
  5491. break;
  5492. }
  5493. /* search backwards for last DIR_SEPARATOR */
  5494. p = tmp_pathspec + strlen (tmp_pathspec) - 1;
  5495. while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
  5496. p--;
  5497. if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
  5498. {
  5499. /* no more DIR_SEPARATORS left */
  5500. break;
  5501. }
  5502. *p = '\0';
  5503. }
  5504. else
  5505. {
  5506. lt_fatal (__FILE__, __LINE__,
  5507. "error accessing file \"%s\": %s",
  5508. tmp_pathspec, nonnull (strerror (errno)));
  5509. }
  5510. }
  5511. XFREE (tmp_pathspec);
  5512. if (!has_symlinks)
  5513. {
  5514. return xstrdup (pathspec);
  5515. }
  5516. tmp_pathspec = realpath (pathspec, buf);
  5517. if (tmp_pathspec == 0)
  5518. {
  5519. lt_fatal (__FILE__, __LINE__,
  5520. "could not follow symlinks for %s", pathspec);
  5521. }
  5522. return xstrdup (tmp_pathspec);
  5523. #endif
  5524. }
  5525. char *
  5526. strendzap (char *str, const char *pat)
  5527. {
  5528. size_t len, patlen;
  5529. assert (str != NULL);
  5530. assert (pat != NULL);
  5531. len = strlen (str);
  5532. patlen = strlen (pat);
  5533. if (patlen <= len)
  5534. {
  5535. str += len - patlen;
  5536. if (STREQ (str, pat))
  5537. *str = '\0';
  5538. }
  5539. return str;
  5540. }
  5541. void
  5542. lt_debugprintf (const char *file, int line, const char *fmt, ...)
  5543. {
  5544. va_list args;
  5545. if (lt_debug)
  5546. {
  5547. (void) fprintf (stderr, "%s:%s:%d: ", program_name, file, line);
  5548. va_start (args, fmt);
  5549. (void) vfprintf (stderr, fmt, args);
  5550. va_end (args);
  5551. }
  5552. }
  5553. static void
  5554. lt_error_core (int exit_status, const char *file,
  5555. int line, const char *mode,
  5556. const char *message, va_list ap)
  5557. {
  5558. fprintf (stderr, "%s:%s:%d: %s: ", program_name, file, line, mode);
  5559. vfprintf (stderr, message, ap);
  5560. fprintf (stderr, ".\n");
  5561. if (exit_status >= 0)
  5562. exit (exit_status);
  5563. }
  5564. void
  5565. lt_fatal (const char *file, int line, const char *message, ...)
  5566. {
  5567. va_list ap;
  5568. va_start (ap, message);
  5569. lt_error_core (EXIT_FAILURE, file, line, "FATAL", message, ap);
  5570. va_end (ap);
  5571. }
  5572. static const char *
  5573. nonnull (const char *s)
  5574. {
  5575. return s ? s : "(null)";
  5576. }
  5577. static const char *
  5578. nonempty (const char *s)
  5579. {
  5580. return (s && !*s) ? "(empty)" : nonnull (s);
  5581. }
  5582. void
  5583. lt_setenv (const char *name, const char *value)
  5584. {
  5585. lt_debugprintf (__FILE__, __LINE__,
  5586. "(lt_setenv) setting '%s' to '%s'\n",
  5587. nonnull (name), nonnull (value));
  5588. {
  5589. #ifdef HAVE_SETENV
  5590. /* always make a copy, for consistency with !HAVE_SETENV */
  5591. char *str = xstrdup (value);
  5592. setenv (name, str, 1);
  5593. #else
  5594. size_t len = strlen (name) + 1 + strlen (value) + 1;
  5595. char *str = XMALLOC (char, len);
  5596. sprintf (str, "%s=%s", name, value);
  5597. if (putenv (str) != EXIT_SUCCESS)
  5598. {
  5599. XFREE (str);
  5600. }
  5601. #endif
  5602. }
  5603. }
  5604. char *
  5605. lt_extend_str (const char *orig_value, const char *add, int to_end)
  5606. {
  5607. char *new_value;
  5608. if (orig_value && *orig_value)
  5609. {
  5610. size_t orig_value_len = strlen (orig_value);
  5611. size_t add_len = strlen (add);
  5612. new_value = XMALLOC (char, add_len + orig_value_len + 1);
  5613. if (to_end)
  5614. {
  5615. strcpy (new_value, orig_value);
  5616. strcpy (new_value + orig_value_len, add);
  5617. }
  5618. else
  5619. {
  5620. strcpy (new_value, add);
  5621. strcpy (new_value + add_len, orig_value);
  5622. }
  5623. }
  5624. else
  5625. {
  5626. new_value = xstrdup (add);
  5627. }
  5628. return new_value;
  5629. }
  5630. void
  5631. lt_update_exe_path (const char *name, const char *value)
  5632. {
  5633. lt_debugprintf (__FILE__, __LINE__,
  5634. "(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
  5635. nonnull (name), nonnull (value));
  5636. if (name && *name && value && *value)
  5637. {
  5638. char *new_value = lt_extend_str (getenv (name), value, 0);
  5639. /* some systems can't cope with a ':'-terminated path #' */
  5640. size_t len = strlen (new_value);
  5641. while ((len > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
  5642. {
  5643. new_value[--len] = '\0';
  5644. }
  5645. lt_setenv (name, new_value);
  5646. XFREE (new_value);
  5647. }
  5648. }
  5649. void
  5650. lt_update_lib_path (const char *name, const char *value)
  5651. {
  5652. lt_debugprintf (__FILE__, __LINE__,
  5653. "(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
  5654. nonnull (name), nonnull (value));
  5655. if (name && *name && value && *value)
  5656. {
  5657. char *new_value = lt_extend_str (getenv (name), value, 0);
  5658. lt_setenv (name, new_value);
  5659. XFREE (new_value);
  5660. }
  5661. }
  5662. EOF
  5663. case $host_os in
  5664. mingw* | windows*)
  5665. cat <<"EOF"
  5666. /* Prepares an argument vector before calling spawn().
  5667. Note that spawn() does not by itself call the command interpreter
  5668. (getenv ("COMSPEC") != NULL ? getenv ("COMSPEC") :
  5669. ({ OSVERSIONINFO v; v.dwOSVersionInfoSize = sizeof(OSVERSIONINFO);
  5670. GetVersionEx(&v);
  5671. v.dwPlatformId == VER_PLATFORM_WIN32_NT;
  5672. }) ? "cmd.exe" : "command.com").
  5673. Instead it simply concatenates the arguments, separated by ' ', and calls
  5674. CreateProcess(). We must quote the arguments since Win32 CreateProcess()
  5675. interprets characters like ' ', '\t', '\\', '"' (but not '<' and '>') in a
  5676. special way:
  5677. - Space and tab are interpreted as delimiters. They are not treated as
  5678. delimiters if they are surrounded by double quotes: "...".
  5679. - Unescaped double quotes are removed from the input. Their only effect is
  5680. that within double quotes, space and tab are treated like normal
  5681. characters.
  5682. - Backslashes not followed by double quotes are not special.
  5683. - But 2*n+1 backslashes followed by a double quote become
  5684. n backslashes followed by a double quote (n >= 0):
  5685. \" -> "
  5686. \\\" -> \"
  5687. \\\\\" -> \\"
  5688. */
  5689. #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"
  5690. #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"
  5691. char **
  5692. prepare_spawn (char **argv)
  5693. {
  5694. size_t argc;
  5695. char **new_argv;
  5696. size_t i;
  5697. /* Count number of arguments. */
  5698. for (argc = 0; argv[argc] != NULL; argc++)
  5699. ;
  5700. /* Allocate new argument vector. */
  5701. new_argv = XMALLOC (char *, argc + 1);
  5702. /* Put quoted arguments into the new argument vector. */
  5703. for (i = 0; i < argc; i++)
  5704. {
  5705. const char *string = argv[i];
  5706. if (string[0] == '\0')
  5707. new_argv[i] = xstrdup ("\"\"");
  5708. else if (strpbrk (string, SHELL_SPECIAL_CHARS) != NULL)
  5709. {
  5710. int quote_around = (strpbrk (string, SHELL_SPACE_CHARS) != NULL);
  5711. size_t length;
  5712. unsigned int backslashes;
  5713. const char *s;
  5714. char *quoted_string;
  5715. char *p;
  5716. length = 0;
  5717. backslashes = 0;
  5718. if (quote_around)
  5719. length++;
  5720. for (s = string; *s != '\0'; s++)
  5721. {
  5722. char c = *s;
  5723. if (c == '"')
  5724. length += backslashes + 1;
  5725. length++;
  5726. if (c == '\\')
  5727. backslashes++;
  5728. else
  5729. backslashes = 0;
  5730. }
  5731. if (quote_around)
  5732. length += backslashes + 1;
  5733. quoted_string = XMALLOC (char, length + 1);
  5734. p = quoted_string;
  5735. backslashes = 0;
  5736. if (quote_around)
  5737. *p++ = '"';
  5738. for (s = string; *s != '\0'; s++)
  5739. {
  5740. char c = *s;
  5741. if (c == '"')
  5742. {
  5743. unsigned int j;
  5744. for (j = backslashes + 1; j > 0; j--)
  5745. *p++ = '\\';
  5746. }
  5747. *p++ = c;
  5748. if (c == '\\')
  5749. backslashes++;
  5750. else
  5751. backslashes = 0;
  5752. }
  5753. if (quote_around)
  5754. {
  5755. unsigned int j;
  5756. for (j = backslashes; j > 0; j--)
  5757. *p++ = '\\';
  5758. *p++ = '"';
  5759. }
  5760. *p = '\0';
  5761. new_argv[i] = quoted_string;
  5762. }
  5763. else
  5764. new_argv[i] = (char *) string;
  5765. }
  5766. new_argv[argc] = NULL;
  5767. return new_argv;
  5768. }
  5769. EOF
  5770. ;;
  5771. esac
  5772. cat <<"EOF"
  5773. void lt_dump_script (FILE* f)
  5774. {
  5775. EOF
  5776. func_emit_wrapper yes |
  5777. $SED -n -e '
  5778. s/^\(.\{79\}\)\(..*\)/\1\
  5779. \2/
  5780. h
  5781. s/\([\\"]\)/\\\1/g
  5782. s/$/\\n/
  5783. s/\([^\n]*\).*/ fputs ("\1", f);/p
  5784. g
  5785. D'
  5786. cat <<"EOF"
  5787. }
  5788. EOF
  5789. }
  5790. # end: func_emit_cwrapperexe_src
  5791. # func_win32_import_lib_p ARG
  5792. # True if ARG is an import lib, as indicated by $file_magic_cmd
  5793. func_win32_import_lib_p ()
  5794. {
  5795. $debug_cmd
  5796. case `eval $file_magic_cmd \"\$1\" 2>/dev/null | $SED -e 10q` in
  5797. *import*) : ;;
  5798. *) false ;;
  5799. esac
  5800. }
  5801. # func_suncc_cstd_abi
  5802. # !!ONLY CALL THIS FOR SUN CC AFTER $compile_command IS FULLY EXPANDED!!
  5803. # Several compiler flags select an ABI that is incompatible with the
  5804. # Cstd library. Avoid specifying it if any are in CXXFLAGS.
  5805. func_suncc_cstd_abi ()
  5806. {
  5807. $debug_cmd
  5808. case " $compile_command " in
  5809. *" -compat=g "*|*\ -std=c++[0-9][0-9]\ *|*" -library=stdcxx4 "*|*" -library=stlport4 "*)
  5810. suncc_use_cstd_abi=no
  5811. ;;
  5812. *)
  5813. suncc_use_cstd_abi=yes
  5814. ;;
  5815. esac
  5816. }
  5817. # func_mode_link arg...
  5818. func_mode_link ()
  5819. {
  5820. $debug_cmd
  5821. case $host in
  5822. *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*)
  5823. # It is impossible to link a dll without this setting, and
  5824. # we shouldn't force the makefile maintainer to figure out
  5825. # what system we are compiling for in order to pass an extra
  5826. # flag for every libtool invocation.
  5827. # allow_undefined=no
  5828. # FIXME: Unfortunately, there are problems with the above when trying
  5829. # to make a dll that has undefined symbols, in which case not
  5830. # even a static library is built. For now, we need to specify
  5831. # -no-undefined on the libtool link line when we can be certain
  5832. # that all symbols are satisfied, otherwise we get a static library.
  5833. allow_undefined=yes
  5834. ;;
  5835. *)
  5836. allow_undefined=yes
  5837. ;;
  5838. esac
  5839. libtool_args=$nonopt
  5840. base_compile="$nonopt $@"
  5841. compile_command=$nonopt
  5842. finalize_command=$nonopt
  5843. compile_rpath=
  5844. finalize_rpath=
  5845. compile_shlibpath=
  5846. finalize_shlibpath=
  5847. convenience=
  5848. old_convenience=
  5849. deplibs=
  5850. old_deplibs=
  5851. compiler_flags=
  5852. linker_flags=
  5853. dllsearchpath=
  5854. lib_search_path=`pwd`
  5855. inst_prefix_dir=
  5856. new_inherited_linker_flags=
  5857. avoid_version=no
  5858. bindir=
  5859. dlfiles=
  5860. dlprefiles=
  5861. dlself=no
  5862. export_dynamic=no
  5863. export_symbols=
  5864. export_symbols_regex=
  5865. generated=
  5866. libobjs=
  5867. ltlibs=
  5868. module=no
  5869. no_install=no
  5870. objs=
  5871. os2dllname=
  5872. non_pic_objects=
  5873. precious_files_regex=
  5874. prefer_static_libs=no
  5875. preload=false
  5876. prev=
  5877. prevarg=
  5878. release=
  5879. rpath=
  5880. xrpath=
  5881. perm_rpath=
  5882. temp_rpath=
  5883. thread_safe=no
  5884. vinfo=
  5885. vinfo_number=no
  5886. weak_libs=
  5887. single_module=$wl-single_module
  5888. func_infer_tag $base_compile
  5889. # We need to know -static, to get the right output filenames.
  5890. for arg
  5891. do
  5892. case $arg in
  5893. -shared)
  5894. test yes != "$build_libtool_libs" \
  5895. && func_fatal_configuration "cannot build a shared library"
  5896. build_old_libs=no
  5897. break
  5898. ;;
  5899. -all-static | -static | -static-libtool-libs)
  5900. case $arg in
  5901. -all-static)
  5902. if test yes = "$build_libtool_libs" && test -z "$link_static_flag"; then
  5903. func_warning "complete static linking is impossible in this configuration"
  5904. fi
  5905. if test -n "$link_static_flag"; then
  5906. dlopen_self=$dlopen_self_static
  5907. fi
  5908. prefer_static_libs=yes
  5909. ;;
  5910. -static)
  5911. if test -z "$pic_flag" && test -n "$link_static_flag"; then
  5912. dlopen_self=$dlopen_self_static
  5913. fi
  5914. prefer_static_libs=built
  5915. ;;
  5916. -static-libtool-libs)
  5917. if test -z "$pic_flag" && test -n "$link_static_flag"; then
  5918. dlopen_self=$dlopen_self_static
  5919. fi
  5920. prefer_static_libs=yes
  5921. ;;
  5922. esac
  5923. build_libtool_libs=no
  5924. build_old_libs=yes
  5925. break
  5926. ;;
  5927. esac
  5928. done
  5929. # See if our shared archives depend on static archives.
  5930. test -n "$old_archive_from_new_cmds" && build_old_libs=yes
  5931. # Go through the arguments, transforming them on the way.
  5932. while test "$#" -gt 0; do
  5933. arg=$1
  5934. shift
  5935. func_quote_arg pretty,unquoted "$arg"
  5936. qarg=$func_quote_arg_unquoted_result
  5937. func_append libtool_args " $func_quote_arg_result"
  5938. # If the previous option needs an argument, assign it.
  5939. if test -n "$prev"; then
  5940. case $prev in
  5941. output)
  5942. func_append compile_command " @OUTPUT@"
  5943. func_append finalize_command " @OUTPUT@"
  5944. ;;
  5945. esac
  5946. case $prev in
  5947. bindir)
  5948. bindir=$arg
  5949. prev=
  5950. continue
  5951. ;;
  5952. dlfiles|dlprefiles)
  5953. $preload || {
  5954. # Add the symbol object into the linking commands.
  5955. func_append compile_command " @SYMFILE@"
  5956. func_append finalize_command " @SYMFILE@"
  5957. preload=:
  5958. }
  5959. case $arg in
  5960. *.la | *.lo) ;; # We handle these cases below.
  5961. force)
  5962. if test no = "$dlself"; then
  5963. dlself=needless
  5964. export_dynamic=yes
  5965. fi
  5966. prev=
  5967. continue
  5968. ;;
  5969. self)
  5970. if test dlprefiles = "$prev"; then
  5971. dlself=yes
  5972. elif test dlfiles = "$prev" && test yes != "$dlopen_self"; then
  5973. dlself=yes
  5974. else
  5975. dlself=needless
  5976. export_dynamic=yes
  5977. fi
  5978. prev=
  5979. continue
  5980. ;;
  5981. *)
  5982. if test dlfiles = "$prev"; then
  5983. func_append dlfiles " $arg"
  5984. else
  5985. func_append dlprefiles " $arg"
  5986. fi
  5987. prev=
  5988. continue
  5989. ;;
  5990. esac
  5991. ;;
  5992. expsyms)
  5993. export_symbols=$arg
  5994. test -f "$arg" \
  5995. || func_fatal_error "symbol file '$arg' does not exist"
  5996. prev=
  5997. continue
  5998. ;;
  5999. expsyms_regex)
  6000. export_symbols_regex=$arg
  6001. prev=
  6002. continue
  6003. ;;
  6004. framework)
  6005. case $host in
  6006. *-*-darwin*)
  6007. case "$deplibs " in
  6008. *" $qarg.ltframework "*) ;;
  6009. *) func_append deplibs " $qarg.ltframework" # this is fixed later
  6010. ;;
  6011. esac
  6012. ;;
  6013. esac
  6014. prev=
  6015. continue
  6016. ;;
  6017. inst_prefix)
  6018. inst_prefix_dir=$arg
  6019. prev=
  6020. continue
  6021. ;;
  6022. mllvm)
  6023. # Clang does not use LLVM to link, so we can simply discard any
  6024. # '-mllvm $arg' options when doing the link step.
  6025. prev=
  6026. continue
  6027. ;;
  6028. objectlist)
  6029. if test -f "$arg"; then
  6030. save_arg=$arg
  6031. moreargs=
  6032. for fil in `cat "$save_arg"`
  6033. do
  6034. # func_append moreargs " $fil"
  6035. arg=$fil
  6036. # A libtool-controlled object.
  6037. # Check to see that this really is a libtool object.
  6038. if func_lalib_unsafe_p "$arg"; then
  6039. pic_object=
  6040. non_pic_object=
  6041. # Read the .lo file
  6042. func_source "$arg"
  6043. if test -z "$pic_object" ||
  6044. test -z "$non_pic_object" ||
  6045. test none = "$pic_object" &&
  6046. test none = "$non_pic_object"; then
  6047. func_fatal_error "cannot find name of object for '$arg'"
  6048. fi
  6049. # Extract subdirectory from the argument.
  6050. func_dirname "$arg" "/" ""
  6051. xdir=$func_dirname_result
  6052. if test none != "$pic_object"; then
  6053. # Prepend the subdirectory the object is found in.
  6054. pic_object=$xdir$pic_object
  6055. if test dlfiles = "$prev"; then
  6056. if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
  6057. func_append dlfiles " $pic_object"
  6058. prev=
  6059. continue
  6060. else
  6061. # If libtool objects are unsupported, then we need to preload.
  6062. prev=dlprefiles
  6063. fi
  6064. fi
  6065. # CHECK ME: I think I busted this. -Ossama
  6066. if test dlprefiles = "$prev"; then
  6067. # Preload the old-style object.
  6068. func_append dlprefiles " $pic_object"
  6069. prev=
  6070. fi
  6071. # A PIC object.
  6072. func_append libobjs " $pic_object"
  6073. arg=$pic_object
  6074. fi
  6075. # Non-PIC object.
  6076. if test none != "$non_pic_object"; then
  6077. # Prepend the subdirectory the object is found in.
  6078. non_pic_object=$xdir$non_pic_object
  6079. # A standard non-PIC object
  6080. func_append non_pic_objects " $non_pic_object"
  6081. if test -z "$pic_object" || test none = "$pic_object"; then
  6082. arg=$non_pic_object
  6083. fi
  6084. else
  6085. # If the PIC object exists, use it instead.
  6086. # $xdir was prepended to $pic_object above.
  6087. non_pic_object=$pic_object
  6088. func_append non_pic_objects " $non_pic_object"
  6089. fi
  6090. else
  6091. # Only an error if not doing a dry-run.
  6092. if $opt_dry_run; then
  6093. # Extract subdirectory from the argument.
  6094. func_dirname "$arg" "/" ""
  6095. xdir=$func_dirname_result
  6096. func_lo2o "$arg"
  6097. pic_object=$xdir$objdir/$func_lo2o_result
  6098. non_pic_object=$xdir$func_lo2o_result
  6099. func_append libobjs " $pic_object"
  6100. func_append non_pic_objects " $non_pic_object"
  6101. else
  6102. func_fatal_error "'$arg' is not a valid libtool object"
  6103. fi
  6104. fi
  6105. done
  6106. else
  6107. func_fatal_error "link input file '$arg' does not exist"
  6108. fi
  6109. arg=$save_arg
  6110. prev=
  6111. continue
  6112. ;;
  6113. os2dllname)
  6114. os2dllname=$arg
  6115. prev=
  6116. continue
  6117. ;;
  6118. precious_regex)
  6119. precious_files_regex=$arg
  6120. prev=
  6121. continue
  6122. ;;
  6123. release)
  6124. release=-$arg
  6125. prev=
  6126. continue
  6127. ;;
  6128. rpath | xrpath)
  6129. # We need an absolute path.
  6130. case $arg in
  6131. [\\/]* | [A-Za-z]:[\\/]*) ;;
  6132. *)
  6133. func_fatal_error "only absolute run-paths are allowed"
  6134. ;;
  6135. esac
  6136. if test rpath = "$prev"; then
  6137. case "$rpath " in
  6138. *" $arg "*) ;;
  6139. *) func_append rpath " $arg" ;;
  6140. esac
  6141. else
  6142. case "$xrpath " in
  6143. *" $arg "*) ;;
  6144. *) func_append xrpath " $arg" ;;
  6145. esac
  6146. fi
  6147. prev=
  6148. continue
  6149. ;;
  6150. shrext)
  6151. shrext_cmds=$arg
  6152. prev=
  6153. continue
  6154. ;;
  6155. weak)
  6156. func_append weak_libs " $arg"
  6157. prev=
  6158. continue
  6159. ;;
  6160. xassembler)
  6161. func_append compiler_flags " -Xassembler $qarg"
  6162. prev=
  6163. func_append compile_command " -Xassembler $qarg"
  6164. func_append finalize_command " -Xassembler $qarg"
  6165. continue
  6166. ;;
  6167. xcclinker)
  6168. func_append linker_flags " $qarg"
  6169. func_append compiler_flags " $qarg"
  6170. prev=
  6171. func_append compile_command " $qarg"
  6172. func_append finalize_command " $qarg"
  6173. continue
  6174. ;;
  6175. xcompiler)
  6176. func_append compiler_flags " $qarg"
  6177. prev=
  6178. func_append compile_command " $qarg"
  6179. func_append finalize_command " $qarg"
  6180. continue
  6181. ;;
  6182. xlinker)
  6183. func_append linker_flags " $qarg"
  6184. func_append compiler_flags " $wl$qarg"
  6185. prev=
  6186. func_append compile_command " $wl$qarg"
  6187. func_append finalize_command " $wl$qarg"
  6188. continue
  6189. ;;
  6190. *)
  6191. eval "$prev=\"\$arg\""
  6192. prev=
  6193. continue
  6194. ;;
  6195. esac
  6196. fi # test -n "$prev"
  6197. prevarg=$arg
  6198. case $arg in
  6199. -all-static)
  6200. if test -n "$link_static_flag"; then
  6201. # See comment for -static flag below, for more details.
  6202. func_append compile_command " $link_static_flag"
  6203. func_append finalize_command " $link_static_flag"
  6204. fi
  6205. continue
  6206. ;;
  6207. -allow-undefined)
  6208. # FIXME: remove this flag sometime in the future.
  6209. func_fatal_error "'-allow-undefined' must not be used because it is the default"
  6210. ;;
  6211. -avoid-version)
  6212. avoid_version=yes
  6213. continue
  6214. ;;
  6215. -bindir)
  6216. prev=bindir
  6217. continue
  6218. ;;
  6219. -dlopen)
  6220. prev=dlfiles
  6221. continue
  6222. ;;
  6223. -dlpreopen)
  6224. prev=dlprefiles
  6225. continue
  6226. ;;
  6227. -export-dynamic)
  6228. export_dynamic=yes
  6229. continue
  6230. ;;
  6231. -export-symbols | -export-symbols-regex)
  6232. if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
  6233. func_fatal_error "more than one -exported-symbols argument is not allowed"
  6234. fi
  6235. if test X-export-symbols = "X$arg"; then
  6236. prev=expsyms
  6237. else
  6238. prev=expsyms_regex
  6239. fi
  6240. continue
  6241. ;;
  6242. -framework)
  6243. prev=framework
  6244. continue
  6245. ;;
  6246. -inst-prefix-dir)
  6247. prev=inst_prefix
  6248. continue
  6249. ;;
  6250. # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
  6251. # so, if we see these flags be careful not to treat them like -L
  6252. -L[A-Z][A-Z]*:*)
  6253. case $with_gcc/$host in
  6254. no/*-*-irix* | /*-*-irix*)
  6255. func_append compile_command " $arg"
  6256. func_append finalize_command " $arg"
  6257. ;;
  6258. esac
  6259. continue
  6260. ;;
  6261. -L*)
  6262. func_stripname "-L" '' "$arg"
  6263. if test -z "$func_stripname_result"; then
  6264. if test "$#" -gt 0; then
  6265. func_fatal_error "require no space between '-L' and '$1'"
  6266. else
  6267. func_fatal_error "need path for '-L' option"
  6268. fi
  6269. fi
  6270. func_resolve_sysroot "$func_stripname_result"
  6271. dir=$func_resolve_sysroot_result
  6272. # We need an absolute path.
  6273. case $dir in
  6274. [\\/]* | [A-Za-z]:[\\/]*) ;;
  6275. *)
  6276. absdir=`cd "$dir" && pwd`
  6277. test -z "$absdir" && \
  6278. func_fatal_error "cannot determine absolute directory name of '$dir'"
  6279. dir=$absdir
  6280. ;;
  6281. esac
  6282. case "$deplibs " in
  6283. *" -L$dir "* | *" $arg "*)
  6284. # Will only happen for absolute or sysroot arguments
  6285. ;;
  6286. *)
  6287. # Preserve sysroot, but never include relative directories
  6288. case $dir in
  6289. [\\/]* | [A-Za-z]:[\\/]* | =*) func_append deplibs " $arg" ;;
  6290. *) func_append deplibs " -L$dir" ;;
  6291. esac
  6292. func_append lib_search_path " $dir"
  6293. ;;
  6294. esac
  6295. case $host in
  6296. *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*)
  6297. testbindir=`$ECHO "$dir" | $SED 's*/lib$*/bin*'`
  6298. case :$dllsearchpath: in
  6299. *":$dir:"*) ;;
  6300. ::) dllsearchpath=$dir;;
  6301. *) func_append dllsearchpath ":$dir";;
  6302. esac
  6303. case :$dllsearchpath: in
  6304. *":$testbindir:"*) ;;
  6305. ::) dllsearchpath=$testbindir;;
  6306. *) func_append dllsearchpath ":$testbindir";;
  6307. esac
  6308. ;;
  6309. esac
  6310. continue
  6311. ;;
  6312. -l*)
  6313. if test X-lc = "X$arg" || test X-lm = "X$arg"; then
  6314. case $host in
  6315. *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-beos* | *-cegcc* | *-*-haiku*)
  6316. # These systems don't actually have a C or math library (as such)
  6317. continue
  6318. ;;
  6319. *-*-os2*)
  6320. # These systems don't actually have a C library (as such)
  6321. test X-lc = "X$arg" && continue
  6322. ;;
  6323. *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
  6324. # Do not include libc due to us having libc/libc_r.
  6325. test X-lc = "X$arg" && continue
  6326. ;;
  6327. *-*-rhapsody* | *-*-darwin1.[012])
  6328. # Rhapsody C and math libraries are in the System framework
  6329. func_append deplibs " System.ltframework"
  6330. continue
  6331. ;;
  6332. *-*-sco3.2v5* | *-*-sco5v6*)
  6333. # Causes problems with __ctype
  6334. test X-lc = "X$arg" && continue
  6335. ;;
  6336. *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
  6337. # Compiler inserts libc in the correct place for threads to work
  6338. test X-lc = "X$arg" && continue
  6339. ;;
  6340. esac
  6341. elif test X-lc_r = "X$arg"; then
  6342. case $host in
  6343. *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
  6344. # Do not include libc_r directly, use -pthread flag.
  6345. continue
  6346. ;;
  6347. esac
  6348. fi
  6349. func_append deplibs " $arg"
  6350. continue
  6351. ;;
  6352. -mllvm)
  6353. prev=mllvm
  6354. continue
  6355. ;;
  6356. -module)
  6357. module=yes
  6358. continue
  6359. ;;
  6360. # Tru64 UNIX uses -model [arg] to determine the layout of C++
  6361. # classes, name mangling, and exception handling.
  6362. # Darwin uses the -arch flag to determine output architecture.
  6363. -model|-arch|-isysroot|--sysroot)
  6364. func_append compiler_flags " $arg"
  6365. func_append compile_command " $arg"
  6366. func_append finalize_command " $arg"
  6367. prev=xcompiler
  6368. continue
  6369. ;;
  6370. # Solaris ld rejects as of 11.4. Refer to Oracle bug 22985199.
  6371. -pthread)
  6372. case $host in
  6373. *solaris2*) ;;
  6374. *)
  6375. case "$new_inherited_linker_flags " in
  6376. *" $arg "*) ;;
  6377. * ) func_append new_inherited_linker_flags " $arg" ;;
  6378. esac
  6379. ;;
  6380. esac
  6381. continue
  6382. ;;
  6383. -mt|-mthreads|-kthread|-Kthread|-pthreads|--thread-safe \
  6384. |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
  6385. func_append compiler_flags " $arg"
  6386. func_append compile_command " $arg"
  6387. func_append finalize_command " $arg"
  6388. case "$new_inherited_linker_flags " in
  6389. *" $arg "*) ;;
  6390. * ) func_append new_inherited_linker_flags " $arg" ;;
  6391. esac
  6392. continue
  6393. ;;
  6394. -multi_module)
  6395. single_module=$wl-multi_module
  6396. continue
  6397. ;;
  6398. -no-fast-install)
  6399. fast_install=no
  6400. continue
  6401. ;;
  6402. -no-install)
  6403. case $host in
  6404. *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
  6405. # The PATH hackery in wrapper scripts is required on Windows
  6406. # and Darwin in order for the loader to find any dlls it needs.
  6407. func_warning "'-no-install' is ignored for $host"
  6408. func_warning "assuming '-no-fast-install' instead"
  6409. fast_install=no
  6410. ;;
  6411. *) no_install=yes ;;
  6412. esac
  6413. continue
  6414. ;;
  6415. -no-undefined)
  6416. allow_undefined=no
  6417. continue
  6418. ;;
  6419. -objectlist)
  6420. prev=objectlist
  6421. continue
  6422. ;;
  6423. -os2dllname)
  6424. prev=os2dllname
  6425. continue
  6426. ;;
  6427. -o) prev=output ;;
  6428. -precious-files-regex)
  6429. prev=precious_regex
  6430. continue
  6431. ;;
  6432. -release)
  6433. prev=release
  6434. continue
  6435. ;;
  6436. -rpath)
  6437. prev=rpath
  6438. continue
  6439. ;;
  6440. -R)
  6441. prev=xrpath
  6442. continue
  6443. ;;
  6444. -R*)
  6445. func_stripname '-R' '' "$arg"
  6446. dir=$func_stripname_result
  6447. # We need an absolute path.
  6448. case $dir in
  6449. [\\/]* | [A-Za-z]:[\\/]*) ;;
  6450. =*)
  6451. func_stripname '=' '' "$dir"
  6452. dir=$lt_sysroot$func_stripname_result
  6453. ;;
  6454. *)
  6455. func_fatal_error "only absolute run-paths are allowed"
  6456. ;;
  6457. esac
  6458. case "$xrpath " in
  6459. *" $dir "*) ;;
  6460. *) func_append xrpath " $dir" ;;
  6461. esac
  6462. continue
  6463. ;;
  6464. -shared)
  6465. # The effects of -shared are defined in a previous loop.
  6466. continue
  6467. ;;
  6468. -shrext)
  6469. prev=shrext
  6470. continue
  6471. ;;
  6472. -static | -static-libtool-libs)
  6473. # The effects of -static are defined in a previous loop.
  6474. # We used to do the same as -all-static on platforms that
  6475. # didn't have a PIC flag, but the assumption that the effects
  6476. # would be equivalent was wrong. It would break on at least
  6477. # Digital Unix and AIX.
  6478. continue
  6479. ;;
  6480. -thread-safe)
  6481. thread_safe=yes
  6482. continue
  6483. ;;
  6484. -version-info)
  6485. prev=vinfo
  6486. continue
  6487. ;;
  6488. -version-number)
  6489. prev=vinfo
  6490. vinfo_number=yes
  6491. continue
  6492. ;;
  6493. -weak)
  6494. prev=weak
  6495. continue
  6496. ;;
  6497. -Wc,*)
  6498. func_stripname '-Wc,' '' "$arg"
  6499. args=$func_stripname_result
  6500. arg=
  6501. save_ifs=$IFS; IFS=,
  6502. for flag in $args; do
  6503. IFS=$save_ifs
  6504. func_quote_arg pretty "$flag"
  6505. func_append arg " $func_quote_arg_result"
  6506. func_append compiler_flags " $func_quote_arg_result"
  6507. done
  6508. IFS=$save_ifs
  6509. func_stripname ' ' '' "$arg"
  6510. arg=$func_stripname_result
  6511. ;;
  6512. -Wl,*)
  6513. func_stripname '-Wl,' '' "$arg"
  6514. args=$func_stripname_result
  6515. arg=
  6516. save_ifs=$IFS; IFS=,
  6517. for flag in $args; do
  6518. IFS=$save_ifs
  6519. func_quote_arg pretty "$flag"
  6520. func_append arg " $wl$func_quote_arg_result"
  6521. func_append compiler_flags " $wl$func_quote_arg_result"
  6522. func_append linker_flags " $func_quote_arg_result"
  6523. done
  6524. IFS=$save_ifs
  6525. func_stripname ' ' '' "$arg"
  6526. arg=$func_stripname_result
  6527. ;;
  6528. -Xassembler)
  6529. prev=xassembler
  6530. continue
  6531. ;;
  6532. -Xcompiler)
  6533. prev=xcompiler
  6534. continue
  6535. ;;
  6536. -Xlinker)
  6537. prev=xlinker
  6538. continue
  6539. ;;
  6540. -XCClinker)
  6541. prev=xcclinker
  6542. continue
  6543. ;;
  6544. # -msg_* for osf cc
  6545. -msg_*)
  6546. func_quote_arg pretty "$arg"
  6547. arg=$func_quote_arg_result
  6548. ;;
  6549. # Flags to be passed through unchanged, with rationale:
  6550. # -64, -mips[0-9] enable 64-bit mode for the SGI compiler
  6551. # -r[0-9][0-9]* specify processor for the SGI compiler
  6552. # -xarch=*, -xtarget=* enable 64-bit mode for the Sun compiler
  6553. # +DA*, +DD* enable 64-bit mode for the HP compiler
  6554. # -q* compiler args for the IBM compiler
  6555. # -m*, -t[45]*, -txscale* architecture-specific flags for GCC
  6556. # -F/path path to uninstalled frameworks, gcc on darwin
  6557. # -p, -pg, --coverage, -fprofile-* profiling flags for GCC
  6558. # -fstack-protector* stack protector flags for GCC
  6559. # @file GCC response files
  6560. # -tp=* Portland pgcc target processor selection
  6561. # --sysroot=* for sysroot support
  6562. # -O*, -g*, -flto*, -fwhopr*, -fuse-linker-plugin GCC link-time optimization
  6563. # -specs=* GCC specs files
  6564. # -stdlib=* select c++ std lib with clang
  6565. # -fdiagnostics-color* simply affects output
  6566. # -frecord-gcc-switches used to verify flags were respected
  6567. # -fsanitize=* Clang/GCC memory and address sanitizer
  6568. # -fno-sanitize* Clang/GCC memory and address sanitizer
  6569. # -shared-libsan Link with shared sanitizer runtimes (Clang)
  6570. # -static-libsan Link with static sanitizer runtimes (Clang)
  6571. # -no-canonical-prefixes Do not expand any symbolic links
  6572. # -fuse-ld=* Linker select flags for GCC
  6573. # -rtlib=* select c runtime lib with clang
  6574. # --unwindlib=* select unwinder library with clang
  6575. # -f{file|debug|macro|profile}-prefix-map=* needed for lto linking
  6576. # -Wa,* Pass flags directly to the assembler
  6577. # -Werror, -Werror=* Report (specified) warnings as errors
  6578. -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
  6579. -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*|-tp=*|--sysroot=*| \
  6580. -O*|-g*|-flto*|-fwhopr*|-fuse-linker-plugin|-fstack-protector*|-no-canonical-prefixes| \
  6581. -stdlib=*|-rtlib=*|--unwindlib=*| \
  6582. -specs=*|-fsanitize=*|-fno-sanitize*|-shared-libsan|-static-libsan| \
  6583. -ffile-prefix-map=*|-fdebug-prefix-map=*|-fmacro-prefix-map=*|-fprofile-prefix-map=*| \
  6584. -fdiagnostics-color*|-frecord-gcc-switches| \
  6585. -fuse-ld=*|-Wa,*|-Werror|-Werror=*)
  6586. func_quote_arg pretty "$arg"
  6587. arg=$func_quote_arg_result
  6588. func_append compile_command " $arg"
  6589. func_append finalize_command " $arg"
  6590. func_append compiler_flags " $arg"
  6591. continue
  6592. ;;
  6593. -Z*)
  6594. if test os2 = "`expr $host : '.*\(os2\)'`"; then
  6595. # OS/2 uses -Zxxx to specify OS/2-specific options
  6596. compiler_flags="$compiler_flags $arg"
  6597. func_append compile_command " $arg"
  6598. func_append finalize_command " $arg"
  6599. case $arg in
  6600. -Zlinker | -Zstack)
  6601. prev=xcompiler
  6602. ;;
  6603. esac
  6604. continue
  6605. else
  6606. # Otherwise treat like 'Some other compiler flag' below
  6607. func_quote_arg pretty "$arg"
  6608. arg=$func_quote_arg_result
  6609. fi
  6610. ;;
  6611. # Some other compiler flag.
  6612. -* | +*)
  6613. func_quote_arg pretty "$arg"
  6614. arg=$func_quote_arg_result
  6615. ;;
  6616. *.$objext)
  6617. # A standard object.
  6618. func_append objs " $arg"
  6619. ;;
  6620. *.lo)
  6621. # A libtool-controlled object.
  6622. # Check to see that this really is a libtool object.
  6623. if func_lalib_unsafe_p "$arg"; then
  6624. pic_object=
  6625. non_pic_object=
  6626. # Read the .lo file
  6627. func_source "$arg"
  6628. if test -z "$pic_object" ||
  6629. test -z "$non_pic_object" ||
  6630. test none = "$pic_object" &&
  6631. test none = "$non_pic_object"; then
  6632. func_fatal_error "cannot find name of object for '$arg'"
  6633. fi
  6634. # Extract subdirectory from the argument.
  6635. func_dirname "$arg" "/" ""
  6636. xdir=$func_dirname_result
  6637. test none = "$pic_object" || {
  6638. # Prepend the subdirectory the object is found in.
  6639. pic_object=$xdir$pic_object
  6640. if test dlfiles = "$prev"; then
  6641. if test yes = "$build_libtool_libs" && test yes = "$dlopen_support"; then
  6642. func_append dlfiles " $pic_object"
  6643. prev=
  6644. continue
  6645. else
  6646. # If libtool objects are unsupported, then we need to preload.
  6647. prev=dlprefiles
  6648. fi
  6649. fi
  6650. # CHECK ME: I think I busted this. -Ossama
  6651. if test dlprefiles = "$prev"; then
  6652. # Preload the old-style object.
  6653. func_append dlprefiles " $pic_object"
  6654. prev=
  6655. fi
  6656. # A PIC object.
  6657. func_append libobjs " $pic_object"
  6658. arg=$pic_object
  6659. }
  6660. # Non-PIC object.
  6661. if test none != "$non_pic_object"; then
  6662. # Prepend the subdirectory the object is found in.
  6663. non_pic_object=$xdir$non_pic_object
  6664. # A standard non-PIC object
  6665. func_append non_pic_objects " $non_pic_object"
  6666. if test -z "$pic_object" || test none = "$pic_object"; then
  6667. arg=$non_pic_object
  6668. fi
  6669. else
  6670. # If the PIC object exists, use it instead.
  6671. # $xdir was prepended to $pic_object above.
  6672. non_pic_object=$pic_object
  6673. func_append non_pic_objects " $non_pic_object"
  6674. fi
  6675. else
  6676. # Only an error if not doing a dry-run.
  6677. if $opt_dry_run; then
  6678. # Extract subdirectory from the argument.
  6679. func_dirname "$arg" "/" ""
  6680. xdir=$func_dirname_result
  6681. func_lo2o "$arg"
  6682. pic_object=$xdir$objdir/$func_lo2o_result
  6683. non_pic_object=$xdir$func_lo2o_result
  6684. func_append libobjs " $pic_object"
  6685. func_append non_pic_objects " $non_pic_object"
  6686. else
  6687. func_fatal_error "'$arg' is not a valid libtool object"
  6688. fi
  6689. fi
  6690. ;;
  6691. *.$libext)
  6692. # An archive.
  6693. func_append deplibs " $arg"
  6694. func_append old_deplibs " $arg"
  6695. continue
  6696. ;;
  6697. *.la)
  6698. # A libtool-controlled library.
  6699. func_resolve_sysroot "$arg"
  6700. if test dlfiles = "$prev"; then
  6701. # This library was specified with -dlopen.
  6702. func_append dlfiles " $func_resolve_sysroot_result"
  6703. prev=
  6704. elif test dlprefiles = "$prev"; then
  6705. # The library was specified with -dlpreopen.
  6706. func_append dlprefiles " $func_resolve_sysroot_result"
  6707. prev=
  6708. else
  6709. func_append deplibs " $func_resolve_sysroot_result"
  6710. fi
  6711. continue
  6712. ;;
  6713. # Some other compiler argument.
  6714. *)
  6715. # Unknown arguments in both finalize_command and compile_command need
  6716. # to be aesthetically quoted because they are evaled later.
  6717. func_quote_arg pretty "$arg"
  6718. arg=$func_quote_arg_result
  6719. ;;
  6720. esac # arg
  6721. # Now actually substitute the argument into the commands.
  6722. if test -n "$arg"; then
  6723. func_append compile_command " $arg"
  6724. func_append finalize_command " $arg"
  6725. fi
  6726. done # argument parsing loop
  6727. test -n "$prev" && \
  6728. func_fatal_help "the '$prevarg' option requires an argument"
  6729. if test yes = "$export_dynamic" && test -n "$export_dynamic_flag_spec"; then
  6730. eval arg=\"$export_dynamic_flag_spec\"
  6731. func_append compile_command " $arg"
  6732. func_append finalize_command " $arg"
  6733. fi
  6734. oldlibs=
  6735. # calculate the name of the file, without its directory
  6736. func_basename "$output"
  6737. outputname=$func_basename_result
  6738. libobjs_save=$libobjs
  6739. if test -n "$shlibpath_var"; then
  6740. # get the directories listed in $shlibpath_var
  6741. eval shlib_search_path=\`\$ECHO \"\$$shlibpath_var\" \| \$SED \'s/:/ /g\'\`
  6742. else
  6743. shlib_search_path=
  6744. fi
  6745. eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
  6746. eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
  6747. # Definition is injected by LT_CONFIG during libtool generation.
  6748. func_munge_path_list sys_lib_dlsearch_path "$LT_SYS_LIBRARY_PATH"
  6749. func_dirname "$output" "/" ""
  6750. output_objdir=$func_dirname_result$objdir
  6751. func_to_tool_file "$output_objdir/"
  6752. tool_output_objdir=$func_to_tool_file_result
  6753. # Create the object directory.
  6754. func_mkdir_p "$output_objdir"
  6755. # Determine the type of output
  6756. case $output in
  6757. "")
  6758. func_fatal_help "you must specify an output file"
  6759. ;;
  6760. *.$libext) linkmode=oldlib ;;
  6761. *.lo | *.$objext) linkmode=obj ;;
  6762. *.la) linkmode=lib ;;
  6763. *) linkmode=prog ;; # Anything else should be a program.
  6764. esac
  6765. specialdeplibs=
  6766. libs=
  6767. # Find all interdependent deplibs by searching for libraries
  6768. # that are linked more than once (e.g. -la -lb -la)
  6769. for deplib in $deplibs; do
  6770. if $opt_preserve_dup_deps; then
  6771. case "$libs " in
  6772. *" $deplib "*) func_append specialdeplibs " $deplib" ;;
  6773. esac
  6774. fi
  6775. func_append libs " $deplib"
  6776. done
  6777. if test lib = "$linkmode"; then
  6778. libs="$predeps $libs $compiler_lib_search_path $postdeps"
  6779. # Compute libraries that are listed more than once in $predeps
  6780. # $postdeps and mark them as special (i.e., whose duplicates are
  6781. # not to be eliminated).
  6782. pre_post_deps=
  6783. if $opt_duplicate_compiler_generated_deps; then
  6784. for pre_post_dep in $predeps $postdeps; do
  6785. case "$pre_post_deps " in
  6786. *" $pre_post_dep "*) func_append specialdeplibs " $pre_post_deps" ;;
  6787. esac
  6788. func_append pre_post_deps " $pre_post_dep"
  6789. done
  6790. fi
  6791. pre_post_deps=
  6792. fi
  6793. deplibs=
  6794. newdependency_libs=
  6795. newlib_search_path=
  6796. need_relink=no # whether we're linking any uninstalled libtool libraries
  6797. notinst_deplibs= # not-installed libtool libraries
  6798. notinst_path= # paths that contain not-installed libtool libraries
  6799. case $linkmode in
  6800. lib)
  6801. passes="conv dlpreopen link"
  6802. for file in $dlfiles $dlprefiles; do
  6803. case $file in
  6804. *.la) ;;
  6805. *)
  6806. func_fatal_help "libraries can '-dlopen' only libtool libraries: $file"
  6807. ;;
  6808. esac
  6809. done
  6810. ;;
  6811. prog)
  6812. compile_deplibs=
  6813. finalize_deplibs=
  6814. alldeplibs=false
  6815. newdlfiles=
  6816. newdlprefiles=
  6817. passes="conv scan dlopen dlpreopen link"
  6818. ;;
  6819. *) passes="conv"
  6820. ;;
  6821. esac
  6822. for pass in $passes; do
  6823. # The preopen pass in lib mode reverses $deplibs; put it back here
  6824. # so that -L comes before libs that need it for instance...
  6825. if test lib,link = "$linkmode,$pass"; then
  6826. ## FIXME: Find the place where the list is rebuilt in the wrong
  6827. ## order, and fix it there properly
  6828. tmp_deplibs=
  6829. for deplib in $deplibs; do
  6830. tmp_deplibs="$deplib $tmp_deplibs"
  6831. done
  6832. deplibs=$tmp_deplibs
  6833. fi
  6834. if test lib,link = "$linkmode,$pass" ||
  6835. test prog,scan = "$linkmode,$pass"; then
  6836. libs=$deplibs
  6837. deplibs=
  6838. fi
  6839. if test prog = "$linkmode"; then
  6840. case $pass in
  6841. dlopen) libs=$dlfiles ;;
  6842. dlpreopen) libs=$dlprefiles ;;
  6843. link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
  6844. esac
  6845. fi
  6846. if test lib,dlpreopen = "$linkmode,$pass"; then
  6847. # Collect and forward deplibs of preopened libtool libs
  6848. for lib in $dlprefiles; do
  6849. # Ignore non-libtool-libs
  6850. dependency_libs=
  6851. func_resolve_sysroot "$lib"
  6852. case $lib in
  6853. *.la) func_source "$func_resolve_sysroot_result" ;;
  6854. esac
  6855. # Collect preopened libtool deplibs, except any this library
  6856. # has declared as weak libs
  6857. for deplib in $dependency_libs; do
  6858. func_basename "$deplib"
  6859. deplib_base=$func_basename_result
  6860. case " $weak_libs " in
  6861. *" $deplib_base "*) ;;
  6862. *) func_append deplibs " $deplib" ;;
  6863. esac
  6864. done
  6865. done
  6866. libs=$dlprefiles
  6867. fi
  6868. if test dlopen = "$pass"; then
  6869. # Collect dlpreopened libraries
  6870. save_deplibs=$deplibs
  6871. deplibs=
  6872. fi
  6873. for deplib in $libs; do
  6874. lib=
  6875. found=false
  6876. case $deplib in
  6877. -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe \
  6878. |-threads|-fopenmp|-fopenmp=*|-openmp|-mp|-xopenmp|-omp|-qsmp=*)
  6879. if test prog,link = "$linkmode,$pass"; then
  6880. compile_deplibs="$deplib $compile_deplibs"
  6881. finalize_deplibs="$deplib $finalize_deplibs"
  6882. else
  6883. func_append compiler_flags " $deplib"
  6884. if test lib = "$linkmode"; then
  6885. case "$new_inherited_linker_flags " in
  6886. *" $deplib "*) ;;
  6887. * ) func_append new_inherited_linker_flags " $deplib" ;;
  6888. esac
  6889. fi
  6890. fi
  6891. continue
  6892. ;;
  6893. -l*)
  6894. if test lib != "$linkmode" && test prog != "$linkmode"; then
  6895. func_warning "'-l' is ignored for archives/objects"
  6896. continue
  6897. fi
  6898. func_stripname '-l' '' "$deplib"
  6899. name=$func_stripname_result
  6900. if test lib = "$linkmode"; then
  6901. searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
  6902. else
  6903. searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
  6904. fi
  6905. for searchdir in $searchdirs; do
  6906. for search_ext in .la $std_shrext .so .a; do
  6907. # Search the libtool library
  6908. lib=$searchdir/lib$name$search_ext
  6909. if test -f "$lib"; then
  6910. if test .la = "$search_ext"; then
  6911. found=:
  6912. else
  6913. found=false
  6914. fi
  6915. break 2
  6916. fi
  6917. done
  6918. done
  6919. if $found; then
  6920. # deplib is a libtool library
  6921. # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
  6922. # We need to do some special things here, and not later.
  6923. if test yes = "$allow_libtool_libs_with_static_runtimes"; then
  6924. case " $predeps $postdeps " in
  6925. *" $deplib "*)
  6926. if func_lalib_p "$lib"; then
  6927. library_names=
  6928. old_library=
  6929. func_source "$lib"
  6930. for l in $old_library $library_names; do
  6931. ll=$l
  6932. done
  6933. if test "X$ll" = "X$old_library"; then # only static version available
  6934. found=false
  6935. func_dirname "$lib" "" "."
  6936. ladir=$func_dirname_result
  6937. lib=$ladir/$old_library
  6938. if test prog,link = "$linkmode,$pass"; then
  6939. compile_deplibs="$deplib $compile_deplibs"
  6940. finalize_deplibs="$deplib $finalize_deplibs"
  6941. else
  6942. deplibs="$deplib $deplibs"
  6943. test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
  6944. fi
  6945. continue
  6946. fi
  6947. fi
  6948. ;;
  6949. *) ;;
  6950. esac
  6951. fi
  6952. else
  6953. # deplib doesn't seem to be a libtool library
  6954. if test prog,link = "$linkmode,$pass"; then
  6955. compile_deplibs="$deplib $compile_deplibs"
  6956. finalize_deplibs="$deplib $finalize_deplibs"
  6957. else
  6958. deplibs="$deplib $deplibs"
  6959. test lib = "$linkmode" && newdependency_libs="$deplib $newdependency_libs"
  6960. fi
  6961. continue
  6962. fi
  6963. ;; # -l
  6964. *.ltframework)
  6965. if test prog,link = "$linkmode,$pass"; then
  6966. compile_deplibs="$deplib $compile_deplibs"
  6967. finalize_deplibs="$deplib $finalize_deplibs"
  6968. else
  6969. deplibs="$deplib $deplibs"
  6970. if test lib = "$linkmode"; then
  6971. case "$new_inherited_linker_flags " in
  6972. *" $deplib "*) ;;
  6973. * ) func_append new_inherited_linker_flags " $deplib" ;;
  6974. esac
  6975. fi
  6976. fi
  6977. continue
  6978. ;;
  6979. -L*)
  6980. case $linkmode in
  6981. lib)
  6982. deplibs="$deplib $deplibs"
  6983. test conv = "$pass" && continue
  6984. newdependency_libs="$deplib $newdependency_libs"
  6985. func_stripname '-L' '' "$deplib"
  6986. func_resolve_sysroot "$func_stripname_result"
  6987. func_append newlib_search_path " $func_resolve_sysroot_result"
  6988. ;;
  6989. prog)
  6990. if test conv = "$pass"; then
  6991. deplibs="$deplib $deplibs"
  6992. continue
  6993. fi
  6994. if test scan = "$pass"; then
  6995. deplibs="$deplib $deplibs"
  6996. else
  6997. compile_deplibs="$deplib $compile_deplibs"
  6998. finalize_deplibs="$deplib $finalize_deplibs"
  6999. fi
  7000. func_stripname '-L' '' "$deplib"
  7001. func_resolve_sysroot "$func_stripname_result"
  7002. func_append newlib_search_path " $func_resolve_sysroot_result"
  7003. ;;
  7004. *)
  7005. func_warning "'-L' is ignored for archives/objects"
  7006. ;;
  7007. esac # linkmode
  7008. continue
  7009. ;; # -L
  7010. -R*)
  7011. if test link = "$pass"; then
  7012. func_stripname '-R' '' "$deplib"
  7013. func_resolve_sysroot "$func_stripname_result"
  7014. dir=$func_resolve_sysroot_result
  7015. # Make sure the xrpath contains only unique directories.
  7016. case "$xrpath " in
  7017. *" $dir "*) ;;
  7018. *) func_append xrpath " $dir" ;;
  7019. esac
  7020. fi
  7021. deplibs="$deplib $deplibs"
  7022. continue
  7023. ;;
  7024. *.la)
  7025. func_resolve_sysroot "$deplib"
  7026. lib=$func_resolve_sysroot_result
  7027. ;;
  7028. *.$libext)
  7029. if test conv = "$pass"; then
  7030. deplibs="$deplib $deplibs"
  7031. continue
  7032. fi
  7033. case $linkmode in
  7034. lib)
  7035. # Linking convenience modules into shared libraries is allowed,
  7036. # but linking other static libraries is non-portable.
  7037. case " $dlpreconveniencelibs " in
  7038. *" $deplib "*) ;;
  7039. *)
  7040. valid_a_lib=false
  7041. case $deplibs_check_method in
  7042. match_pattern*)
  7043. set dummy $deplibs_check_method; shift
  7044. match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
  7045. if eval "\$ECHO \"$deplib\"" 2>/dev/null | $SED 10q \
  7046. | $EGREP "$match_pattern_regex" > /dev/null; then
  7047. valid_a_lib=:
  7048. fi
  7049. ;;
  7050. pass_all)
  7051. valid_a_lib=:
  7052. ;;
  7053. esac
  7054. if $valid_a_lib; then
  7055. func_warning "Linking the shared library $output against the static library $deplib is not portable!"
  7056. deplibs="$deplib $deplibs"
  7057. else
  7058. func_warning "Trying to link with static lib archive $deplib."
  7059. func_warning "I have the capability to make that library automatically link in when"
  7060. func_warning "you link to this library. But I can only do this if you have a"
  7061. func_warning "shared version of the library, which you do not appear to have"
  7062. func_warning "because the file extensions .$libext of this argument makes me believe"
  7063. func_warning "that it is just a static archive that I should not use here."
  7064. fi
  7065. ;;
  7066. esac
  7067. continue
  7068. ;;
  7069. prog)
  7070. if test link != "$pass"; then
  7071. deplibs="$deplib $deplibs"
  7072. else
  7073. compile_deplibs="$deplib $compile_deplibs"
  7074. finalize_deplibs="$deplib $finalize_deplibs"
  7075. fi
  7076. continue
  7077. ;;
  7078. esac # linkmode
  7079. ;; # *.$libext
  7080. *.lo | *.$objext)
  7081. if test conv = "$pass"; then
  7082. deplibs="$deplib $deplibs"
  7083. elif test prog = "$linkmode"; then
  7084. if test dlpreopen = "$pass" || test yes != "$dlopen_support" || test no = "$build_libtool_libs"; then
  7085. # If there is no dlopen support or we're linking statically,
  7086. # we need to preload.
  7087. func_append newdlprefiles " $deplib"
  7088. compile_deplibs="$deplib $compile_deplibs"
  7089. finalize_deplibs="$deplib $finalize_deplibs"
  7090. else
  7091. func_append newdlfiles " $deplib"
  7092. fi
  7093. fi
  7094. continue
  7095. ;;
  7096. %DEPLIBS%)
  7097. alldeplibs=:
  7098. continue
  7099. ;;
  7100. esac # case $deplib
  7101. $found || test -f "$lib" \
  7102. || func_fatal_error "cannot find the library '$lib' or unhandled argument '$deplib'"
  7103. # Check to see that this really is a libtool archive.
  7104. func_lalib_unsafe_p "$lib" \
  7105. || func_fatal_error "'$lib' is not a valid libtool archive"
  7106. func_dirname "$lib" "" "."
  7107. ladir=$func_dirname_result
  7108. dlname=
  7109. dlopen=
  7110. dlpreopen=
  7111. libdir=
  7112. library_names=
  7113. old_library=
  7114. inherited_linker_flags=
  7115. # If the library was installed with an old release of libtool,
  7116. # it will not redefine variables installed, or shouldnotlink
  7117. installed=yes
  7118. shouldnotlink=no
  7119. avoidtemprpath=
  7120. # Read the .la file
  7121. func_source "$lib"
  7122. # Convert "-framework foo" to "foo.ltframework"
  7123. if test -n "$inherited_linker_flags"; then
  7124. tmp_inherited_linker_flags=`$ECHO "$inherited_linker_flags" | $SED 's/-framework \([^ $]*\)/\1.ltframework/g'`
  7125. for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
  7126. case " $new_inherited_linker_flags " in
  7127. *" $tmp_inherited_linker_flag "*) ;;
  7128. *) func_append new_inherited_linker_flags " $tmp_inherited_linker_flag";;
  7129. esac
  7130. done
  7131. fi
  7132. dependency_libs=`$ECHO " $dependency_libs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  7133. if test lib,link = "$linkmode,$pass" ||
  7134. test prog,scan = "$linkmode,$pass" ||
  7135. { test prog != "$linkmode" && test lib != "$linkmode"; }; then
  7136. test -n "$dlopen" && func_append dlfiles " $dlopen"
  7137. test -n "$dlpreopen" && func_append dlprefiles " $dlpreopen"
  7138. fi
  7139. if test conv = "$pass"; then
  7140. # Only check for convenience libraries
  7141. deplibs="$lib $deplibs"
  7142. if test -z "$libdir"; then
  7143. if test -z "$old_library"; then
  7144. func_fatal_error "cannot find name of link library for '$lib'"
  7145. fi
  7146. # It is a libtool convenience library, so add in its objects.
  7147. func_append convenience " $ladir/$objdir/$old_library"
  7148. func_append old_convenience " $ladir/$objdir/$old_library"
  7149. elif test prog != "$linkmode" && test lib != "$linkmode"; then
  7150. func_fatal_error "'$lib' is not a convenience library"
  7151. fi
  7152. tmp_libs=
  7153. for deplib in $dependency_libs; do
  7154. deplibs="$deplib $deplibs"
  7155. if $opt_preserve_dup_deps; then
  7156. case "$tmp_libs " in
  7157. *" $deplib "*) func_append specialdeplibs " $deplib" ;;
  7158. esac
  7159. fi
  7160. func_append tmp_libs " $deplib"
  7161. done
  7162. continue
  7163. fi # $pass = conv
  7164. # Get the name of the library we link against.
  7165. linklib=
  7166. if test -n "$old_library" &&
  7167. { test yes = "$prefer_static_libs" ||
  7168. test built,no = "$prefer_static_libs,$installed"; }; then
  7169. linklib=$old_library
  7170. else
  7171. for l in $old_library $library_names; do
  7172. linklib=$l
  7173. done
  7174. fi
  7175. if test -z "$linklib"; then
  7176. func_fatal_error "cannot find name of link library for '$lib'"
  7177. fi
  7178. # This library was specified with -dlopen.
  7179. if test dlopen = "$pass"; then
  7180. test -z "$libdir" \
  7181. && func_fatal_error "cannot -dlopen a convenience library: '$lib'"
  7182. if test -z "$dlname" ||
  7183. test yes != "$dlopen_support" ||
  7184. test no = "$build_libtool_libs"
  7185. then
  7186. # If there is no dlname, no dlopen support or we're linking
  7187. # statically, we need to preload. We also need to preload any
  7188. # dependent libraries so libltdl's deplib preloader doesn't
  7189. # bomb out in the load deplibs phase.
  7190. func_append dlprefiles " $lib $dependency_libs"
  7191. else
  7192. func_append newdlfiles " $lib"
  7193. fi
  7194. continue
  7195. fi # $pass = dlopen
  7196. # We need an absolute path.
  7197. case $ladir in
  7198. [\\/]* | [A-Za-z]:[\\/]*) abs_ladir=$ladir ;;
  7199. *)
  7200. abs_ladir=`cd "$ladir" && pwd`
  7201. if test -z "$abs_ladir"; then
  7202. func_warning "cannot determine absolute directory name of '$ladir'"
  7203. func_warning "passing it literally to the linker, although it might fail"
  7204. abs_ladir=$ladir
  7205. fi
  7206. ;;
  7207. esac
  7208. func_basename "$lib"
  7209. laname=$func_basename_result
  7210. # Find the relevant object directory and library name.
  7211. if test yes = "$installed"; then
  7212. if test ! -f "$lt_sysroot$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
  7213. func_warning "library '$lib' was moved."
  7214. dir=$ladir
  7215. absdir=$abs_ladir
  7216. libdir=$abs_ladir
  7217. else
  7218. dir=$lt_sysroot$libdir
  7219. absdir=$lt_sysroot$libdir
  7220. fi
  7221. test yes = "$hardcode_automatic" && avoidtemprpath=yes
  7222. else
  7223. if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
  7224. dir=$ladir
  7225. absdir=$abs_ladir
  7226. # Remove this search path later
  7227. func_append notinst_path " $abs_ladir"
  7228. else
  7229. dir=$ladir/$objdir
  7230. absdir=$abs_ladir/$objdir
  7231. # Remove this search path later
  7232. func_append notinst_path " $abs_ladir"
  7233. fi
  7234. fi # $installed = yes
  7235. func_stripname 'lib' '.la' "$laname"
  7236. name=$func_stripname_result
  7237. # This library was specified with -dlpreopen.
  7238. if test dlpreopen = "$pass"; then
  7239. if test -z "$libdir" && test prog = "$linkmode"; then
  7240. func_fatal_error "only libraries may -dlpreopen a convenience library: '$lib'"
  7241. fi
  7242. case $host in
  7243. # special handling for platforms with PE-DLLs.
  7244. *cygwin* | *mingw* | *windows* | *cegcc* )
  7245. # Linker will automatically link against shared library if both
  7246. # static and shared are present. Therefore, ensure we extract
  7247. # symbols from the import library if a shared library is present
  7248. # (otherwise, the dlopen module name will be incorrect). We do
  7249. # this by putting the import library name into $newdlprefiles.
  7250. # We recover the dlopen module name by 'saving' the la file
  7251. # name in a special purpose variable, and (later) extracting the
  7252. # dlname from the la file.
  7253. if test -n "$dlname"; then
  7254. func_tr_sh "$dir/$linklib"
  7255. eval "libfile_$func_tr_sh_result=\$abs_ladir/\$laname"
  7256. func_append newdlprefiles " $dir/$linklib"
  7257. else
  7258. func_append newdlprefiles " $dir/$old_library"
  7259. # Keep a list of preopened convenience libraries to check
  7260. # that they are being used correctly in the link pass.
  7261. test -z "$libdir" && \
  7262. func_append dlpreconveniencelibs " $dir/$old_library"
  7263. fi
  7264. ;;
  7265. * )
  7266. # Prefer using a static library (so that no silly _DYNAMIC symbols
  7267. # are required to link).
  7268. if test -n "$old_library"; then
  7269. func_append newdlprefiles " $dir/$old_library"
  7270. # Keep a list of preopened convenience libraries to check
  7271. # that they are being used correctly in the link pass.
  7272. test -z "$libdir" && \
  7273. func_append dlpreconveniencelibs " $dir/$old_library"
  7274. # Otherwise, use the dlname, so that lt_dlopen finds it.
  7275. elif test -n "$dlname"; then
  7276. func_append newdlprefiles " $dir/$dlname"
  7277. else
  7278. func_append newdlprefiles " $dir/$linklib"
  7279. fi
  7280. ;;
  7281. esac
  7282. fi # $pass = dlpreopen
  7283. if test -z "$libdir"; then
  7284. # Link the convenience library
  7285. if test lib = "$linkmode"; then
  7286. deplibs="$dir/$old_library $deplibs"
  7287. elif test prog,link = "$linkmode,$pass"; then
  7288. compile_deplibs="$dir/$old_library $compile_deplibs"
  7289. finalize_deplibs="$dir/$old_library $finalize_deplibs"
  7290. else
  7291. deplibs="$lib $deplibs" # used for prog,scan pass
  7292. fi
  7293. continue
  7294. fi
  7295. if test prog = "$linkmode" && test link != "$pass"; then
  7296. func_append newlib_search_path " $ladir"
  7297. deplibs="$lib $deplibs"
  7298. linkalldeplibs=false
  7299. if test no != "$link_all_deplibs" || test -z "$library_names" ||
  7300. test no = "$build_libtool_libs"; then
  7301. linkalldeplibs=:
  7302. fi
  7303. tmp_libs=
  7304. for deplib in $dependency_libs; do
  7305. case $deplib in
  7306. -L*) func_stripname '-L' '' "$deplib"
  7307. func_resolve_sysroot "$func_stripname_result"
  7308. func_append newlib_search_path " $func_resolve_sysroot_result"
  7309. ;;
  7310. esac
  7311. # Need to link against all dependency_libs?
  7312. if $linkalldeplibs; then
  7313. deplibs="$deplib $deplibs"
  7314. else
  7315. # Need to hardcode shared library paths
  7316. # or/and link against static libraries
  7317. newdependency_libs="$deplib $newdependency_libs"
  7318. fi
  7319. if $opt_preserve_dup_deps; then
  7320. case "$tmp_libs " in
  7321. *" $deplib "*) func_append specialdeplibs " $deplib" ;;
  7322. esac
  7323. fi
  7324. func_append tmp_libs " $deplib"
  7325. done # for deplib
  7326. continue
  7327. fi # $linkmode = prog...
  7328. if test prog,link = "$linkmode,$pass"; then
  7329. if test -n "$library_names" &&
  7330. { { test no = "$prefer_static_libs" ||
  7331. test built,yes = "$prefer_static_libs,$installed"; } ||
  7332. test -z "$old_library"; }; then
  7333. # We need to hardcode the library path
  7334. if test -n "$shlibpath_var" && test -z "$avoidtemprpath"; then
  7335. # Make sure the rpath contains only unique directories.
  7336. case $temp_rpath: in
  7337. *"$absdir:"*) ;;
  7338. *) func_append temp_rpath "$absdir:" ;;
  7339. esac
  7340. fi
  7341. # Hardcode the library path.
  7342. # Skip directories that are in the system default run-time
  7343. # search path.
  7344. case " $sys_lib_dlsearch_path " in
  7345. *" $absdir "*) ;;
  7346. *)
  7347. case "$compile_rpath " in
  7348. *" $absdir "*) ;;
  7349. *) func_append compile_rpath " $absdir" ;;
  7350. esac
  7351. ;;
  7352. esac
  7353. case " $sys_lib_dlsearch_path " in
  7354. *" $libdir "*) ;;
  7355. *)
  7356. case "$finalize_rpath " in
  7357. *" $libdir "*) ;;
  7358. *) func_append finalize_rpath " $libdir" ;;
  7359. esac
  7360. ;;
  7361. esac
  7362. fi # $linkmode,$pass = prog,link...
  7363. if $alldeplibs &&
  7364. { test pass_all = "$deplibs_check_method" ||
  7365. { test yes = "$build_libtool_libs" &&
  7366. test -n "$library_names"; }; }; then
  7367. # We only need to search for static libraries
  7368. continue
  7369. fi
  7370. fi
  7371. link_static=no # Whether the deplib will be linked statically
  7372. use_static_libs=$prefer_static_libs
  7373. if test built = "$use_static_libs" && test yes = "$installed"; then
  7374. use_static_libs=no
  7375. fi
  7376. if test -n "$library_names" &&
  7377. { test no = "$use_static_libs" || test -z "$old_library"; }; then
  7378. case $host_os in
  7379. cygwin* | mingw* | windows* | cegcc* | os2*)
  7380. # No point in relinking DLLs because paths are not encoded
  7381. func_append notinst_deplibs " $lib"
  7382. need_relink=no
  7383. ;;
  7384. *)
  7385. if test no = "$installed"; then
  7386. func_append notinst_deplibs " $lib"
  7387. need_relink=yes
  7388. fi
  7389. ;;
  7390. esac
  7391. # This is a shared library
  7392. # Warn about portability, can't link against -module's on some
  7393. # systems (darwin). Don't bleat about dlopened modules though!
  7394. dlopenmodule=
  7395. for dlpremoduletest in $dlprefiles; do
  7396. if test "X$dlpremoduletest" = "X$lib"; then
  7397. dlopenmodule=$dlpremoduletest
  7398. break
  7399. fi
  7400. done
  7401. if test -z "$dlopenmodule" && test yes = "$shouldnotlink" && test link = "$pass"; then
  7402. echo
  7403. if test prog = "$linkmode"; then
  7404. func_warning "Linking the executable $output against the loadable module"
  7405. else
  7406. func_warning "Linking the shared library $output against the loadable module"
  7407. fi
  7408. func_warning "$linklib is not portable!"
  7409. fi
  7410. if test lib = "$linkmode" &&
  7411. test yes = "$hardcode_into_libs"; then
  7412. # Hardcode the library path.
  7413. # Skip directories that are in the system default run-time
  7414. # search path.
  7415. case " $sys_lib_dlsearch_path " in
  7416. *" $absdir "*) ;;
  7417. *)
  7418. case "$compile_rpath " in
  7419. *" $absdir "*) ;;
  7420. *) func_append compile_rpath " $absdir" ;;
  7421. esac
  7422. ;;
  7423. esac
  7424. case " $sys_lib_dlsearch_path " in
  7425. *" $libdir "*) ;;
  7426. *)
  7427. case "$finalize_rpath " in
  7428. *" $libdir "*) ;;
  7429. *) func_append finalize_rpath " $libdir" ;;
  7430. esac
  7431. ;;
  7432. esac
  7433. fi
  7434. if test -n "$old_archive_from_expsyms_cmds"; then
  7435. # figure out the soname
  7436. set dummy $library_names
  7437. shift
  7438. realname=$1
  7439. shift
  7440. libname=`eval "\\$ECHO \"$libname_spec\""`
  7441. # use dlname if we got it. it's perfectly good, no?
  7442. if test -n "$dlname"; then
  7443. soname=$dlname
  7444. elif test -n "$soname_spec"; then
  7445. # bleh windows
  7446. case $host_os in
  7447. cygwin* | mingw* | windows* | cegcc* | os2*)
  7448. func_arith $current - $age
  7449. major=$func_arith_result
  7450. versuffix=-$major
  7451. ;;
  7452. esac
  7453. eval soname=\"$soname_spec\"
  7454. else
  7455. soname=$realname
  7456. fi
  7457. # Make a new name for the extract_expsyms_cmds to use
  7458. soroot=$soname
  7459. func_basename "$soroot"
  7460. soname=$func_basename_result
  7461. func_stripname 'lib' '.dll' "$soname"
  7462. newlib=libimp-$func_stripname_result.a
  7463. # If the library has no export list, then create one now
  7464. if test -f "$output_objdir/$soname-def"; then :
  7465. else
  7466. func_verbose "extracting exported symbol list from '$soname'"
  7467. func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
  7468. fi
  7469. # Create $newlib
  7470. if test -f "$output_objdir/$newlib"; then :; else
  7471. func_verbose "generating import library for '$soname'"
  7472. func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
  7473. fi
  7474. # make sure the library variables are pointing to the new library
  7475. dir=$output_objdir
  7476. linklib=$newlib
  7477. fi # test -n "$old_archive_from_expsyms_cmds"
  7478. if test prog = "$linkmode" || test relink != "$opt_mode"; then
  7479. add_shlibpath=
  7480. add_dir=
  7481. add=
  7482. lib_linked=yes
  7483. case $hardcode_action in
  7484. immediate | unsupported)
  7485. if test no = "$hardcode_direct"; then
  7486. add=$dir/$linklib
  7487. case $host in
  7488. *-*-sco3.2v5.0.[024]*) add_dir=-L$dir ;;
  7489. *-*-sysv4*uw2*) add_dir=-L$dir ;;
  7490. *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
  7491. *-*-unixware7*) add_dir=-L$dir ;;
  7492. *-*-darwin* )
  7493. # if the lib is a (non-dlopened) module then we cannot
  7494. # link against it, someone is ignoring the earlier warnings
  7495. if /usr/bin/file -L $add 2> /dev/null |
  7496. $GREP ": [^:]* bundle" >/dev/null; then
  7497. if test "X$dlopenmodule" != "X$lib"; then
  7498. func_warning "lib $linklib is a module, not a shared library"
  7499. if test -z "$old_library"; then
  7500. func_warning "And there doesn't seem to be a static archive available"
  7501. func_warning "The link will probably fail, sorry"
  7502. else
  7503. add=$dir/$old_library
  7504. fi
  7505. elif test -n "$old_library"; then
  7506. add=$dir/$old_library
  7507. fi
  7508. fi
  7509. esac
  7510. elif test no = "$hardcode_minus_L"; then
  7511. case $host in
  7512. *-*-sunos*) add_shlibpath=$dir ;;
  7513. esac
  7514. add_dir=-L$dir
  7515. add=-l$name
  7516. elif test no = "$hardcode_shlibpath_var"; then
  7517. add_shlibpath=$dir
  7518. add=-l$name
  7519. else
  7520. lib_linked=no
  7521. fi
  7522. ;;
  7523. relink)
  7524. if test yes = "$hardcode_direct" &&
  7525. test no = "$hardcode_direct_absolute"; then
  7526. add=$dir/$linklib
  7527. elif test yes = "$hardcode_minus_L"; then
  7528. add_dir=-L$absdir
  7529. # Try looking first in the location we're being installed to.
  7530. if test -n "$inst_prefix_dir"; then
  7531. case $libdir in
  7532. [\\/]*)
  7533. func_append add_dir " -L$inst_prefix_dir$libdir"
  7534. ;;
  7535. esac
  7536. fi
  7537. add=-l$name
  7538. elif test yes = "$hardcode_shlibpath_var"; then
  7539. add_shlibpath=$dir
  7540. add=-l$name
  7541. else
  7542. lib_linked=no
  7543. fi
  7544. ;;
  7545. *) lib_linked=no ;;
  7546. esac
  7547. if test yes != "$lib_linked"; then
  7548. func_fatal_configuration "unsupported hardcode properties"
  7549. fi
  7550. if test -n "$add_shlibpath"; then
  7551. case :$compile_shlibpath: in
  7552. *":$add_shlibpath:"*) ;;
  7553. *) func_append compile_shlibpath "$add_shlibpath:" ;;
  7554. esac
  7555. fi
  7556. if test prog = "$linkmode"; then
  7557. test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
  7558. test -n "$add" && compile_deplibs="$add $compile_deplibs"
  7559. else
  7560. test -n "$add_dir" && deplibs="$add_dir $deplibs"
  7561. test -n "$add" && deplibs="$add $deplibs"
  7562. if test yes != "$hardcode_direct" &&
  7563. test yes != "$hardcode_minus_L" &&
  7564. test yes = "$hardcode_shlibpath_var"; then
  7565. case :$finalize_shlibpath: in
  7566. *":$libdir:"*) ;;
  7567. *) func_append finalize_shlibpath "$libdir:" ;;
  7568. esac
  7569. fi
  7570. fi
  7571. fi
  7572. if test prog = "$linkmode" || test relink = "$opt_mode"; then
  7573. add_shlibpath=
  7574. add_dir=
  7575. add=
  7576. # Finalize command for both is simple: just hardcode it.
  7577. if test yes = "$hardcode_direct" &&
  7578. test no = "$hardcode_direct_absolute"; then
  7579. add=$libdir/$linklib
  7580. elif test yes = "$hardcode_minus_L"; then
  7581. add_dir=-L$libdir
  7582. add=-l$name
  7583. elif test yes = "$hardcode_shlibpath_var"; then
  7584. case :$finalize_shlibpath: in
  7585. *":$libdir:"*) ;;
  7586. *) func_append finalize_shlibpath "$libdir:" ;;
  7587. esac
  7588. add=-l$name
  7589. elif test yes = "$hardcode_automatic"; then
  7590. if test -n "$inst_prefix_dir" &&
  7591. test -f "$inst_prefix_dir$libdir/$linklib"; then
  7592. add=$inst_prefix_dir$libdir/$linklib
  7593. else
  7594. add=$libdir/$linklib
  7595. fi
  7596. else
  7597. # We cannot seem to hardcode it, guess we'll fake it.
  7598. add_dir=-L$libdir
  7599. # Try looking first in the location we're being installed to.
  7600. if test -n "$inst_prefix_dir"; then
  7601. case $libdir in
  7602. [\\/]*)
  7603. func_append add_dir " -L$inst_prefix_dir$libdir"
  7604. ;;
  7605. esac
  7606. fi
  7607. add=-l$name
  7608. fi
  7609. if test prog = "$linkmode"; then
  7610. test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
  7611. test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
  7612. else
  7613. test -n "$add_dir" && deplibs="$add_dir $deplibs"
  7614. test -n "$add" && deplibs="$add $deplibs"
  7615. fi
  7616. fi
  7617. elif test prog = "$linkmode"; then
  7618. # Here we assume that one of hardcode_direct or hardcode_minus_L
  7619. # is not unsupported. This is valid on all known static and
  7620. # shared platforms.
  7621. if test unsupported != "$hardcode_direct"; then
  7622. test -n "$old_library" && linklib=$old_library
  7623. compile_deplibs="$dir/$linklib $compile_deplibs"
  7624. finalize_deplibs="$dir/$linklib $finalize_deplibs"
  7625. else
  7626. compile_deplibs="-l$name -L$dir $compile_deplibs"
  7627. finalize_deplibs="-l$name -L$dir $finalize_deplibs"
  7628. fi
  7629. elif test yes = "$build_libtool_libs"; then
  7630. # Not a shared library
  7631. if test pass_all != "$deplibs_check_method"; then
  7632. # We're trying link a shared library against a static one
  7633. # but the system doesn't support it.
  7634. # Just print a warning and add the library to dependency_libs so
  7635. # that the program can be linked against the static library.
  7636. func_warning "This system cannot link to static lib archive $lib."
  7637. func_warning "I have the capability to make that library automatically link in when"
  7638. func_warning "you link to this library. But I can only do this if you have a"
  7639. func_warning "shared version of the library, which you do not appear to have."
  7640. if test yes = "$module"; then
  7641. func_warning "But as you try to build a module library, libtool will still create "
  7642. func_warning "a static module, that should work as long as the dlopening application"
  7643. func_warning "is linked with the -dlopen flag to resolve symbols at runtime."
  7644. if test -z "$global_symbol_pipe"; then
  7645. func_warning "However, this would only work if libtool was able to extract symbol"
  7646. func_warning "lists from a program, using 'nm' or equivalent, but libtool could"
  7647. func_warning "not find such a program. So, this module is probably useless."
  7648. func_warning "'nm' from GNU binutils and a full rebuild may help."
  7649. fi
  7650. if test no = "$build_old_libs"; then
  7651. build_libtool_libs=module
  7652. build_old_libs=yes
  7653. else
  7654. build_libtool_libs=no
  7655. fi
  7656. fi
  7657. else
  7658. deplibs="$dir/$old_library $deplibs"
  7659. link_static=yes
  7660. fi
  7661. fi # link shared/static library?
  7662. if test lib = "$linkmode"; then
  7663. if test -n "$dependency_libs" &&
  7664. { test yes != "$hardcode_into_libs" ||
  7665. test yes = "$build_old_libs" ||
  7666. test yes = "$link_static"; }; then
  7667. # Extract -R from dependency_libs
  7668. temp_deplibs=
  7669. for libdir in $dependency_libs; do
  7670. case $libdir in
  7671. -R*) func_stripname '-R' '' "$libdir"
  7672. temp_xrpath=$func_stripname_result
  7673. case " $xrpath " in
  7674. *" $temp_xrpath "*) ;;
  7675. *) func_append xrpath " $temp_xrpath";;
  7676. esac;;
  7677. *) func_append temp_deplibs " $libdir";;
  7678. esac
  7679. done
  7680. dependency_libs=$temp_deplibs
  7681. fi
  7682. func_append newlib_search_path " $absdir"
  7683. # Link against this library
  7684. test no = "$link_static" && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
  7685. # ... and its dependency_libs
  7686. tmp_libs=
  7687. for deplib in $dependency_libs; do
  7688. newdependency_libs="$deplib $newdependency_libs"
  7689. case $deplib in
  7690. -L*) func_stripname '-L' '' "$deplib"
  7691. func_resolve_sysroot "$func_stripname_result";;
  7692. *) func_resolve_sysroot "$deplib" ;;
  7693. esac
  7694. if $opt_preserve_dup_deps; then
  7695. case "$tmp_libs " in
  7696. *" $func_resolve_sysroot_result "*)
  7697. func_append specialdeplibs " $func_resolve_sysroot_result" ;;
  7698. esac
  7699. fi
  7700. func_append tmp_libs " $func_resolve_sysroot_result"
  7701. done
  7702. if test no != "$link_all_deplibs"; then
  7703. # Add the search paths of all dependency libraries
  7704. for deplib in $dependency_libs; do
  7705. path=
  7706. case $deplib in
  7707. -L*) path=$deplib ;;
  7708. *.la)
  7709. func_resolve_sysroot "$deplib"
  7710. deplib=$func_resolve_sysroot_result
  7711. func_dirname "$deplib" "" "."
  7712. dir=$func_dirname_result
  7713. # We need an absolute path.
  7714. case $dir in
  7715. [\\/]* | [A-Za-z]:[\\/]*) absdir=$dir ;;
  7716. *)
  7717. absdir=`cd "$dir" && pwd`
  7718. if test -z "$absdir"; then
  7719. func_warning "cannot determine absolute directory name of '$dir'"
  7720. absdir=$dir
  7721. fi
  7722. ;;
  7723. esac
  7724. if $GREP "^installed=no" $deplib > /dev/null; then
  7725. case $host in
  7726. *-*-darwin*)
  7727. depdepl=
  7728. eval deplibrary_names=`$SED -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
  7729. if test -n "$deplibrary_names"; then
  7730. for tmp in $deplibrary_names; do
  7731. depdepl=$tmp
  7732. done
  7733. if test -f "$absdir/$objdir/$depdepl"; then
  7734. depdepl=$absdir/$objdir/$depdepl
  7735. darwin_install_name=`$OTOOL -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
  7736. if test -z "$darwin_install_name"; then
  7737. darwin_install_name=`$OTOOL64 -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
  7738. fi
  7739. func_append compiler_flags " $wl-dylib_file $wl$darwin_install_name:$depdepl"
  7740. func_append linker_flags " -dylib_file $darwin_install_name:$depdepl"
  7741. path=
  7742. fi
  7743. fi
  7744. ;;
  7745. *)
  7746. path=-L$absdir/$objdir
  7747. ;;
  7748. esac
  7749. else
  7750. eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
  7751. test -z "$libdir" && \
  7752. func_fatal_error "'$deplib' is not a valid libtool archive"
  7753. test "$absdir" != "$libdir" && \
  7754. func_warning "'$deplib' seems to be moved"
  7755. path=-L$absdir
  7756. fi
  7757. ;;
  7758. esac
  7759. case " $deplibs " in
  7760. *" $path "*) ;;
  7761. *) deplibs="$path $deplibs" ;;
  7762. esac
  7763. done
  7764. fi # link_all_deplibs != no
  7765. fi # linkmode = lib
  7766. done # for deplib in $libs
  7767. if test link = "$pass"; then
  7768. if test prog = "$linkmode"; then
  7769. compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
  7770. finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
  7771. else
  7772. compiler_flags="$compiler_flags "`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  7773. fi
  7774. fi
  7775. dependency_libs=$newdependency_libs
  7776. if test dlpreopen = "$pass"; then
  7777. # Link the dlpreopened libraries before other libraries
  7778. for deplib in $save_deplibs; do
  7779. deplibs="$deplib $deplibs"
  7780. done
  7781. fi
  7782. if test dlopen != "$pass"; then
  7783. test conv = "$pass" || {
  7784. # Make sure lib_search_path contains only unique directories.
  7785. lib_search_path=
  7786. for dir in $newlib_search_path; do
  7787. case "$lib_search_path " in
  7788. *" $dir "*) ;;
  7789. *) func_append lib_search_path " $dir" ;;
  7790. esac
  7791. done
  7792. newlib_search_path=
  7793. }
  7794. if test prog,link = "$linkmode,$pass"; then
  7795. vars="compile_deplibs finalize_deplibs"
  7796. else
  7797. vars=deplibs
  7798. fi
  7799. for var in $vars dependency_libs; do
  7800. # Add libraries to $var in reverse order
  7801. eval tmp_libs=\"\$$var\"
  7802. new_libs=
  7803. for deplib in $tmp_libs; do
  7804. # FIXME: Pedantically, this is the right thing to do, so
  7805. # that some nasty dependency loop isn't accidentally
  7806. # broken:
  7807. #new_libs="$deplib $new_libs"
  7808. # Pragmatically, this seems to cause very few problems in
  7809. # practice:
  7810. case $deplib in
  7811. -L*) new_libs="$deplib $new_libs" ;;
  7812. -R*) ;;
  7813. *)
  7814. # And here is the reason: when a library appears more
  7815. # than once as an explicit dependence of a library, or
  7816. # is implicitly linked in more than once by the
  7817. # compiler, it is considered special, and multiple
  7818. # occurrences thereof are not removed. Compare this
  7819. # with having the same library being listed as a
  7820. # dependency of multiple other libraries: in this case,
  7821. # we know (pedantically, we assume) the library does not
  7822. # need to be listed more than once, so we keep only the
  7823. # last copy. This is not always right, but it is rare
  7824. # enough that we require users that really mean to play
  7825. # such unportable linking tricks to link the library
  7826. # using -Wl,-lname, so that libtool does not consider it
  7827. # for duplicate removal.
  7828. case " $specialdeplibs " in
  7829. *" $deplib "*) new_libs="$deplib $new_libs" ;;
  7830. *)
  7831. case " $new_libs " in
  7832. *" $deplib "*) ;;
  7833. *) new_libs="$deplib $new_libs" ;;
  7834. esac
  7835. ;;
  7836. esac
  7837. ;;
  7838. esac
  7839. done
  7840. tmp_libs=
  7841. for deplib in $new_libs; do
  7842. case $deplib in
  7843. -L*)
  7844. case " $tmp_libs " in
  7845. *" $deplib "*) ;;
  7846. *) func_append tmp_libs " $deplib" ;;
  7847. esac
  7848. ;;
  7849. *) func_append tmp_libs " $deplib" ;;
  7850. esac
  7851. done
  7852. eval $var=\"$tmp_libs\"
  7853. done # for var
  7854. fi
  7855. # Add Sun CC postdeps if required:
  7856. test CXX = "$tagname" && {
  7857. case $host_os in
  7858. linux*)
  7859. case `$CC -V 2>&1 | $SED 5q` in
  7860. *Sun\ C*) # Sun C++ 5.9
  7861. func_suncc_cstd_abi
  7862. if test no != "$suncc_use_cstd_abi"; then
  7863. func_append postdeps ' -library=Cstd -library=Crun'
  7864. fi
  7865. ;;
  7866. esac
  7867. ;;
  7868. solaris*)
  7869. func_cc_basename "$CC"
  7870. case $func_cc_basename_result in
  7871. CC* | sunCC*)
  7872. func_suncc_cstd_abi
  7873. if test no != "$suncc_use_cstd_abi"; then
  7874. func_append postdeps ' -library=Cstd -library=Crun'
  7875. fi
  7876. ;;
  7877. esac
  7878. ;;
  7879. esac
  7880. }
  7881. # Last step: remove runtime libs from dependency_libs
  7882. # (they stay in deplibs)
  7883. tmp_libs=
  7884. for i in $dependency_libs; do
  7885. case " $predeps $postdeps $compiler_lib_search_path " in
  7886. *" $i "*)
  7887. i=
  7888. ;;
  7889. esac
  7890. if test -n "$i"; then
  7891. func_append tmp_libs " $i"
  7892. fi
  7893. done
  7894. dependency_libs=$tmp_libs
  7895. done # for pass
  7896. if test prog = "$linkmode"; then
  7897. dlfiles=$newdlfiles
  7898. fi
  7899. if test prog = "$linkmode" || test lib = "$linkmode"; then
  7900. dlprefiles=$newdlprefiles
  7901. fi
  7902. case $linkmode in
  7903. oldlib)
  7904. if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
  7905. func_warning "'-dlopen' is ignored for archives"
  7906. fi
  7907. case " $deplibs" in
  7908. *\ -l* | *\ -L*)
  7909. func_warning "'-l' and '-L' are ignored for archives" ;;
  7910. esac
  7911. test -n "$rpath" && \
  7912. func_warning "'-rpath' is ignored for archives"
  7913. test -n "$xrpath" && \
  7914. func_warning "'-R' is ignored for archives"
  7915. test -n "$vinfo" && \
  7916. func_warning "'-version-info/-version-number' is ignored for archives"
  7917. test -n "$release" && \
  7918. func_warning "'-release' is ignored for archives"
  7919. test -n "$export_symbols$export_symbols_regex" && \
  7920. func_warning "'-export-symbols' is ignored for archives"
  7921. # Now set the variables for building old libraries.
  7922. build_libtool_libs=no
  7923. oldlibs=$output
  7924. func_append objs "$old_deplibs"
  7925. ;;
  7926. lib)
  7927. # Make sure we only generate libraries of the form 'libNAME.la'.
  7928. case $outputname in
  7929. lib*)
  7930. func_stripname 'lib' '.la' "$outputname"
  7931. name=$func_stripname_result
  7932. eval shared_ext=\"$shrext_cmds\"
  7933. eval libname=\"$libname_spec\"
  7934. ;;
  7935. *)
  7936. test no = "$module" \
  7937. && func_fatal_help "libtool library '$output' must begin with 'lib'"
  7938. if test no != "$need_lib_prefix"; then
  7939. # Add the "lib" prefix for modules if required
  7940. func_stripname '' '.la' "$outputname"
  7941. name=$func_stripname_result
  7942. eval shared_ext=\"$shrext_cmds\"
  7943. eval libname=\"$libname_spec\"
  7944. else
  7945. func_stripname '' '.la' "$outputname"
  7946. libname=$func_stripname_result
  7947. fi
  7948. ;;
  7949. esac
  7950. if test -n "$objs"; then
  7951. if test pass_all != "$deplibs_check_method"; then
  7952. func_fatal_error "cannot build libtool library '$output' from non-libtool objects on this host:$objs"
  7953. else
  7954. func_warning "Linking the shared library $output against the non-libtool objects $objs is not portable!"
  7955. func_append libobjs " $objs"
  7956. fi
  7957. fi
  7958. test no = "$dlself" \
  7959. || func_warning "'-dlopen self' is ignored for libtool libraries"
  7960. set dummy $rpath
  7961. shift
  7962. test 1 -lt "$#" \
  7963. && func_warning "ignoring multiple '-rpath's for a libtool library"
  7964. install_libdir=$1
  7965. oldlibs=
  7966. if test -z "$rpath"; then
  7967. if test yes = "$build_libtool_libs"; then
  7968. # Building a libtool convenience library.
  7969. # Some compilers have problems with a '.al' extension so
  7970. # convenience libraries should have the same extension an
  7971. # archive normally would.
  7972. oldlibs="$output_objdir/$libname.$libext $oldlibs"
  7973. build_libtool_libs=convenience
  7974. build_old_libs=yes
  7975. fi
  7976. test -n "$vinfo" && \
  7977. func_warning "'-version-info/-version-number' is ignored for convenience libraries"
  7978. test -n "$release" && \
  7979. func_warning "'-release' is ignored for convenience libraries"
  7980. else
  7981. # Parse the version information argument.
  7982. save_ifs=$IFS; IFS=:
  7983. set dummy $vinfo 0 0 0
  7984. shift
  7985. IFS=$save_ifs
  7986. test -n "$7" && \
  7987. func_fatal_help "too many parameters to '-version-info'"
  7988. # convert absolute version numbers to libtool ages
  7989. # this retains compatibility with .la files and attempts
  7990. # to make the code below a bit more comprehensible
  7991. case $vinfo_number in
  7992. yes)
  7993. number_major=$1
  7994. number_minor=$2
  7995. number_revision=$3
  7996. #
  7997. # There are really only two kinds -- those that
  7998. # use the current revision as the major version
  7999. # and those that subtract age and use age as
  8000. # a minor version. But, then there is irix
  8001. # that has an extra 1 added just for fun
  8002. #
  8003. case $version_type in
  8004. # correct linux to gnu/linux during the next big refactor
  8005. darwin|freebsd-elf|linux|midnightbsd-elf|osf|qnx|windows|none)
  8006. func_arith $number_major + $number_minor
  8007. current=$func_arith_result
  8008. age=$number_minor
  8009. revision=$number_revision
  8010. ;;
  8011. freebsd-aout|sco|sunos)
  8012. current=$number_major
  8013. revision=$number_minor
  8014. age=0
  8015. ;;
  8016. irix|nonstopux)
  8017. func_arith $number_major + $number_minor
  8018. current=$func_arith_result
  8019. age=$number_minor
  8020. revision=$number_minor
  8021. lt_irix_increment=no
  8022. ;;
  8023. esac
  8024. ;;
  8025. no)
  8026. current=$1
  8027. revision=$2
  8028. age=$3
  8029. ;;
  8030. esac
  8031. # Check that each of the things are valid numbers.
  8032. case $current in
  8033. 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]) ;;
  8034. *)
  8035. func_error "CURRENT '$current' must be a nonnegative integer"
  8036. func_fatal_error "'$vinfo' is not valid version information"
  8037. ;;
  8038. esac
  8039. case $revision in
  8040. 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]) ;;
  8041. *)
  8042. func_error "REVISION '$revision' must be a nonnegative integer"
  8043. func_fatal_error "'$vinfo' is not valid version information"
  8044. ;;
  8045. esac
  8046. case $age in
  8047. 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]) ;;
  8048. *)
  8049. func_error "AGE '$age' must be a nonnegative integer"
  8050. func_fatal_error "'$vinfo' is not valid version information"
  8051. ;;
  8052. esac
  8053. if test "$age" -gt "$current"; then
  8054. func_error "AGE '$age' is greater than the current interface number '$current'"
  8055. func_fatal_error "'$vinfo' is not valid version information"
  8056. fi
  8057. # Calculate the version variables.
  8058. major=
  8059. versuffix=
  8060. verstring=
  8061. case $version_type in
  8062. none) ;;
  8063. darwin)
  8064. # Like Linux, but with the current version available in
  8065. # verstring for coding it into the library header
  8066. func_arith $current - $age
  8067. major=.$func_arith_result
  8068. versuffix=$major.$age.$revision
  8069. # Darwin ld doesn't like 0 for these options...
  8070. func_arith $current + 1
  8071. minor_current=$func_arith_result
  8072. xlcverstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
  8073. verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
  8074. # On Darwin other compilers
  8075. case $CC in
  8076. nagfor*)
  8077. verstring="$wl-compatibility_version $wl$minor_current $wl-current_version $wl$minor_current.$revision"
  8078. ;;
  8079. *)
  8080. verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
  8081. ;;
  8082. esac
  8083. ;;
  8084. freebsd-aout)
  8085. major=.$current
  8086. versuffix=.$current.$revision
  8087. ;;
  8088. freebsd-elf | midnightbsd-elf)
  8089. func_arith $current - $age
  8090. major=.$func_arith_result
  8091. versuffix=$major.$age.$revision
  8092. ;;
  8093. irix | nonstopux)
  8094. if test no = "$lt_irix_increment"; then
  8095. func_arith $current - $age
  8096. else
  8097. func_arith $current - $age + 1
  8098. fi
  8099. major=$func_arith_result
  8100. case $version_type in
  8101. nonstopux) verstring_prefix=nonstopux ;;
  8102. *) verstring_prefix=sgi ;;
  8103. esac
  8104. verstring=$verstring_prefix$major.$revision
  8105. # Add in all the interfaces that we are compatible with.
  8106. loop=$revision
  8107. while test 0 -ne "$loop"; do
  8108. func_arith $revision - $loop
  8109. iface=$func_arith_result
  8110. func_arith $loop - 1
  8111. loop=$func_arith_result
  8112. verstring=$verstring_prefix$major.$iface:$verstring
  8113. done
  8114. # Before this point, $major must not contain '.'.
  8115. major=.$major
  8116. versuffix=$major.$revision
  8117. ;;
  8118. linux) # correct to gnu/linux during the next big refactor
  8119. func_arith $current - $age
  8120. major=.$func_arith_result
  8121. versuffix=$major.$age.$revision
  8122. ;;
  8123. osf)
  8124. func_arith $current - $age
  8125. major=.$func_arith_result
  8126. versuffix=.$current.$age.$revision
  8127. verstring=$current.$age.$revision
  8128. # Add in all the interfaces that we are compatible with.
  8129. loop=$age
  8130. while test 0 -ne "$loop"; do
  8131. func_arith $current - $loop
  8132. iface=$func_arith_result
  8133. func_arith $loop - 1
  8134. loop=$func_arith_result
  8135. verstring=$verstring:$iface.0
  8136. done
  8137. # Make executables depend on our current version.
  8138. func_append verstring ":$current.0"
  8139. ;;
  8140. qnx)
  8141. func_arith $current - $age
  8142. major=.$func_arith_result
  8143. versuffix=$major.$age.$revision
  8144. ;;
  8145. sco)
  8146. major=.$current
  8147. versuffix=.$current
  8148. ;;
  8149. sunos)
  8150. major=.$current
  8151. versuffix=.$current.$revision
  8152. ;;
  8153. windows)
  8154. # Use '-' rather than '.', since we only want one
  8155. # extension on DOS 8.3 file systems.
  8156. func_arith $current - $age
  8157. major=$func_arith_result
  8158. versuffix=-$major
  8159. ;;
  8160. *)
  8161. func_fatal_configuration "unknown library version type '$version_type'"
  8162. ;;
  8163. esac
  8164. # Clear the version info if we defaulted, and they specified a release.
  8165. if test -z "$vinfo" && test -n "$release"; then
  8166. major=
  8167. case $version_type in
  8168. darwin)
  8169. # we can't check for "0.0" in archive_cmds due to quoting
  8170. # problems, so we reset it completely
  8171. verstring=
  8172. ;;
  8173. *)
  8174. verstring=0.0
  8175. ;;
  8176. esac
  8177. if test no = "$need_version"; then
  8178. versuffix=
  8179. else
  8180. versuffix=.0.0
  8181. fi
  8182. fi
  8183. # Remove version info from name if versioning should be avoided
  8184. if test yes,no = "$avoid_version,$need_version"; then
  8185. major=
  8186. versuffix=
  8187. verstring=
  8188. fi
  8189. # Check to see if the archive will have undefined symbols.
  8190. if test yes = "$allow_undefined"; then
  8191. if test unsupported = "$allow_undefined_flag"; then
  8192. if test yes = "$build_old_libs"; then
  8193. func_warning "undefined symbols not allowed in $host shared libraries; building static only"
  8194. build_libtool_libs=no
  8195. else
  8196. func_fatal_error "can't build $host shared library unless -no-undefined is specified"
  8197. fi
  8198. fi
  8199. else
  8200. # Don't allow undefined symbols.
  8201. allow_undefined_flag=$no_undefined_flag
  8202. fi
  8203. fi
  8204. func_generate_dlsyms "$libname" "$libname" :
  8205. func_append libobjs " $symfileobj"
  8206. test " " = "$libobjs" && libobjs=
  8207. if test relink != "$opt_mode"; then
  8208. # Remove our outputs, but don't remove object files since they
  8209. # may have been created when compiling PIC objects.
  8210. removelist=
  8211. tempremovelist=`$ECHO "$output_objdir/*"`
  8212. for p in $tempremovelist; do
  8213. case $p in
  8214. *.$objext | *.gcno)
  8215. ;;
  8216. $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/$libname$release.*)
  8217. if test -n "$precious_files_regex"; then
  8218. if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
  8219. then
  8220. continue
  8221. fi
  8222. fi
  8223. func_append removelist " $p"
  8224. ;;
  8225. *) ;;
  8226. esac
  8227. done
  8228. test -n "$removelist" && \
  8229. func_show_eval "${RM}r \$removelist"
  8230. fi
  8231. # Now set the variables for building old libraries.
  8232. if test yes = "$build_old_libs" && test convenience != "$build_libtool_libs"; then
  8233. func_append oldlibs " $output_objdir/$libname.$libext"
  8234. # Transform .lo files to .o files.
  8235. oldobjs="$objs "`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; $lo2o" | $NL2SP`
  8236. fi
  8237. # Eliminate all temporary directories.
  8238. #for path in $notinst_path; do
  8239. # lib_search_path=`$ECHO "$lib_search_path " | $SED "s% $path % %g"`
  8240. # deplibs=`$ECHO "$deplibs " | $SED "s% -L$path % %g"`
  8241. # dependency_libs=`$ECHO "$dependency_libs " | $SED "s% -L$path % %g"`
  8242. #done
  8243. if test -n "$xrpath"; then
  8244. # If the user specified any rpath flags, then add them.
  8245. temp_xrpath=
  8246. for libdir in $xrpath; do
  8247. func_replace_sysroot "$libdir"
  8248. func_append temp_xrpath " -R$func_replace_sysroot_result"
  8249. case "$finalize_rpath " in
  8250. *" $libdir "*) ;;
  8251. *) func_append finalize_rpath " $libdir" ;;
  8252. esac
  8253. done
  8254. if test yes != "$hardcode_into_libs" || test yes = "$build_old_libs"; then
  8255. dependency_libs="$temp_xrpath $dependency_libs"
  8256. fi
  8257. fi
  8258. # Make sure dlfiles contains only unique files that won't be dlpreopened
  8259. old_dlfiles=$dlfiles
  8260. dlfiles=
  8261. for lib in $old_dlfiles; do
  8262. case " $dlprefiles $dlfiles " in
  8263. *" $lib "*) ;;
  8264. *) func_append dlfiles " $lib" ;;
  8265. esac
  8266. done
  8267. # Make sure dlprefiles contains only unique files
  8268. old_dlprefiles=$dlprefiles
  8269. dlprefiles=
  8270. for lib in $old_dlprefiles; do
  8271. case "$dlprefiles " in
  8272. *" $lib "*) ;;
  8273. *) func_append dlprefiles " $lib" ;;
  8274. esac
  8275. done
  8276. if test yes = "$build_libtool_libs"; then
  8277. if test -n "$rpath"; then
  8278. case $host in
  8279. *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc* | *-*-haiku*)
  8280. # these systems don't actually have a c library (as such)!
  8281. ;;
  8282. *-*-rhapsody* | *-*-darwin1.[012])
  8283. # Rhapsody C library is in the System framework
  8284. func_append deplibs " System.ltframework"
  8285. ;;
  8286. *-*-netbsd*)
  8287. # Don't link with libc until the a.out ld.so is fixed.
  8288. ;;
  8289. *-*-openbsd* | *-*-freebsd* | *-*-dragonfly* | *-*-midnightbsd*)
  8290. # Do not include libc due to us having libc/libc_r.
  8291. ;;
  8292. *-*-sco3.2v5* | *-*-sco5v6*)
  8293. # Causes problems with __ctype
  8294. ;;
  8295. *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
  8296. # Compiler inserts libc in the correct place for threads to work
  8297. ;;
  8298. *)
  8299. # Add libc to deplibs on all other systems if necessary.
  8300. if test yes = "$build_libtool_need_lc"; then
  8301. func_append deplibs " -lc"
  8302. fi
  8303. ;;
  8304. esac
  8305. fi
  8306. # Transform deplibs into only deplibs that can be linked in shared.
  8307. name_save=$name
  8308. libname_save=$libname
  8309. release_save=$release
  8310. versuffix_save=$versuffix
  8311. major_save=$major
  8312. # I'm not sure if I'm treating the release correctly. I think
  8313. # release should show up in the -l (ie -lgmp5) so we don't want to
  8314. # add it in twice. Is that correct?
  8315. release=
  8316. versuffix=
  8317. major=
  8318. newdeplibs=
  8319. droppeddeps=no
  8320. case $deplibs_check_method in
  8321. pass_all)
  8322. # Don't check for shared/static. Everything works.
  8323. # This might be a little naive. We might want to check
  8324. # whether the library exists or not. But this is on
  8325. # osf3 & osf4 and I'm not really sure... Just
  8326. # implementing what was already the behavior.
  8327. newdeplibs=$deplibs
  8328. ;;
  8329. file_magic*)
  8330. set dummy $deplibs_check_method; shift
  8331. file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
  8332. for a_deplib in $deplibs; do
  8333. case $a_deplib in
  8334. -l*)
  8335. func_stripname -l '' "$a_deplib"
  8336. name=$func_stripname_result
  8337. if test yes = "$allow_libtool_libs_with_static_runtimes"; then
  8338. case " $predeps $postdeps " in
  8339. *" $a_deplib "*)
  8340. func_append newdeplibs " $a_deplib"
  8341. a_deplib=
  8342. ;;
  8343. esac
  8344. fi
  8345. if test -n "$a_deplib"; then
  8346. libname=`eval "\\$ECHO \"$libname_spec\""`
  8347. if test -n "$file_magic_glob"; then
  8348. libnameglob=`func_echo_all "$libname" | $SED -e $file_magic_glob`
  8349. else
  8350. libnameglob=$libname
  8351. fi
  8352. test yes = "$want_nocaseglob" && nocaseglob=`shopt -p nocaseglob`
  8353. for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
  8354. if test yes = "$want_nocaseglob"; then
  8355. shopt -s nocaseglob
  8356. potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
  8357. $nocaseglob
  8358. else
  8359. potential_libs=`ls $i/$libnameglob[.-]* 2>/dev/null`
  8360. fi
  8361. for potent_lib in $potential_libs; do
  8362. # Follow soft links.
  8363. if ls -lLd "$potent_lib" 2>/dev/null |
  8364. $GREP " -> " >/dev/null; then
  8365. continue
  8366. fi
  8367. # The statement above tries to avoid entering an
  8368. # endless loop below, in case of cyclic links.
  8369. # We might still enter an endless loop, since a link
  8370. # loop can be closed while we follow links,
  8371. # but so what?
  8372. potlib=$potent_lib
  8373. while test -h "$potlib" 2>/dev/null; do
  8374. potliblink=`ls -ld $potlib | $SED 's/.* -> //'`
  8375. case $potliblink in
  8376. [\\/]* | [A-Za-z]:[\\/]*) potlib=$potliblink;;
  8377. *) potlib=`$ECHO "$potlib" | $SED 's|[^/]*$||'`"$potliblink";;
  8378. esac
  8379. done
  8380. if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
  8381. $SED -e 10q |
  8382. $EGREP "$file_magic_regex" > /dev/null; then
  8383. func_append newdeplibs " $a_deplib"
  8384. a_deplib=
  8385. break 2
  8386. fi
  8387. done
  8388. done
  8389. fi
  8390. if test -n "$a_deplib"; then
  8391. droppeddeps=yes
  8392. func_warning "Linker path does not have real file for library $a_deplib."
  8393. func_warning "I have the capability to make that library automatically link in when"
  8394. func_warning "you link to this library. But I can only do this if you have a"
  8395. func_warning "shared version of the library, which you do not appear to have"
  8396. func_warning "because I did check the linker path looking for a file starting"
  8397. if test -z "$potlib"; then
  8398. func_warning "with $libname but no candidates were found. (...for file magic test)"
  8399. else
  8400. func_warning "with $libname and none of the candidates passed a file format test"
  8401. func_warning "using a file magic. Last file checked: $potlib"
  8402. fi
  8403. fi
  8404. ;;
  8405. *)
  8406. # Add a -L argument.
  8407. func_append newdeplibs " $a_deplib"
  8408. ;;
  8409. esac
  8410. done # Gone through all deplibs.
  8411. ;;
  8412. match_pattern*)
  8413. set dummy $deplibs_check_method; shift
  8414. match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
  8415. for a_deplib in $deplibs; do
  8416. case $a_deplib in
  8417. -l*)
  8418. func_stripname -l '' "$a_deplib"
  8419. name=$func_stripname_result
  8420. if test yes = "$allow_libtool_libs_with_static_runtimes"; then
  8421. case " $predeps $postdeps " in
  8422. *" $a_deplib "*)
  8423. func_append newdeplibs " $a_deplib"
  8424. a_deplib=
  8425. ;;
  8426. esac
  8427. fi
  8428. if test -n "$a_deplib"; then
  8429. libname=`eval "\\$ECHO \"$libname_spec\""`
  8430. for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
  8431. potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
  8432. for potent_lib in $potential_libs; do
  8433. potlib=$potent_lib # see symlink-check above in file_magic test
  8434. if eval "\$ECHO \"$potent_lib\"" 2>/dev/null | $SED 10q | \
  8435. $EGREP "$match_pattern_regex" > /dev/null; then
  8436. func_append newdeplibs " $a_deplib"
  8437. a_deplib=
  8438. break 2
  8439. fi
  8440. done
  8441. done
  8442. fi
  8443. if test -n "$a_deplib"; then
  8444. droppeddeps=yes
  8445. func_warning "Linker path does not have real file for library $a_deplib."
  8446. func_warning "I have the capability to make that library automatically link in when"
  8447. func_warning "you link to this library. But I can only do this if you have a"
  8448. func_warning "shared version of the library, which you do not appear to have"
  8449. func_warning "because I did check the linker path looking for a file starting"
  8450. if test -z "$potlib"; then
  8451. func_warning "with $libname but no candidates were found. (...for regex pattern test)"
  8452. else
  8453. func_warning "with $libname and none of the candidates passed a file format test"
  8454. func_warning "using a regex pattern. Last file checked: $potlib"
  8455. fi
  8456. fi
  8457. ;;
  8458. *)
  8459. # Add a -L argument.
  8460. func_append newdeplibs " $a_deplib"
  8461. ;;
  8462. esac
  8463. done # Gone through all deplibs.
  8464. ;;
  8465. none | unknown | *)
  8466. newdeplibs=
  8467. tmp_deplibs=`$ECHO " $deplibs" | $SED 's/ -lc$//; s/ -[LR][^ ]*//g'`
  8468. if test yes = "$allow_libtool_libs_with_static_runtimes"; then
  8469. for i in $predeps $postdeps; do
  8470. # can't use Xsed below, because $i might contain '/'
  8471. tmp_deplibs=`$ECHO " $tmp_deplibs" | $SED "s|$i||"`
  8472. done
  8473. fi
  8474. case $tmp_deplibs in
  8475. *[!\ \ ]*)
  8476. echo
  8477. if test none = "$deplibs_check_method"; then
  8478. func_warning "Inter-library dependencies are not supported in this platform."
  8479. else
  8480. func_warning "Inter-library dependencies are not known to be supported."
  8481. fi
  8482. func_warning "All declared inter-library dependencies are being dropped."
  8483. droppeddeps=yes
  8484. ;;
  8485. esac
  8486. ;;
  8487. esac
  8488. versuffix=$versuffix_save
  8489. major=$major_save
  8490. release=$release_save
  8491. libname=$libname_save
  8492. name=$name_save
  8493. case $host in
  8494. *-*-rhapsody* | *-*-darwin1.[012])
  8495. # On Rhapsody replace the C library with the System framework
  8496. newdeplibs=`$ECHO " $newdeplibs" | $SED 's/ -lc / System.ltframework /'`
  8497. ;;
  8498. esac
  8499. if test yes = "$droppeddeps"; then
  8500. if test yes = "$module"; then
  8501. func_warning "libtool could not satisfy all declared inter-library"
  8502. func_warning "dependencies of module $libname. Therefore, libtool will create"
  8503. func_warning "a static module, that should work as long as the dlopening"
  8504. func_warning "application is linked with the -dlopen flag."
  8505. if test -z "$global_symbol_pipe"; then
  8506. func_warning "However, this would only work if libtool was able to extract symbol"
  8507. func_warning "lists from a program, using 'nm' or equivalent, but libtool could"
  8508. func_warning "not find such a program. So, this module is probably useless."
  8509. func_warning "'nm' from GNU binutils and a full rebuild may help."
  8510. fi
  8511. if test no = "$build_old_libs"; then
  8512. oldlibs=$output_objdir/$libname.$libext
  8513. build_libtool_libs=module
  8514. build_old_libs=yes
  8515. else
  8516. build_libtool_libs=no
  8517. fi
  8518. else
  8519. echo "*** The inter-library dependencies that have been dropped here will be"
  8520. echo "*** automatically added whenever a program is linked with this library"
  8521. echo "*** or is declared to -dlopen it."
  8522. if test no = "$allow_undefined"; then
  8523. echo
  8524. echo "*** Since this library must not contain undefined symbols,"
  8525. echo "*** because either the platform does not support them or"
  8526. echo "*** it was explicitly requested with -no-undefined,"
  8527. echo "*** libtool will only create a static version of it."
  8528. if test no = "$build_old_libs"; then
  8529. oldlibs=$output_objdir/$libname.$libext
  8530. build_libtool_libs=module
  8531. build_old_libs=yes
  8532. else
  8533. build_libtool_libs=no
  8534. fi
  8535. fi
  8536. fi
  8537. fi
  8538. # Done checking deplibs!
  8539. deplibs=$newdeplibs
  8540. fi
  8541. # Time to change all our "foo.ltframework" stuff back to "-framework foo"
  8542. case $host in
  8543. *-*-darwin*)
  8544. newdeplibs=`$ECHO " $newdeplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  8545. new_inherited_linker_flags=`$ECHO " $new_inherited_linker_flags" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  8546. deplibs=`$ECHO " $deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  8547. ;;
  8548. esac
  8549. # move library search paths that coincide with paths to not yet
  8550. # installed libraries to the beginning of the library search list
  8551. new_libs=
  8552. for path in $notinst_path; do
  8553. case " $new_libs " in
  8554. *" -L$path/$objdir "*) ;;
  8555. *)
  8556. case " $deplibs " in
  8557. *" -L$path/$objdir "*)
  8558. func_append new_libs " -L$path/$objdir" ;;
  8559. esac
  8560. ;;
  8561. esac
  8562. done
  8563. for deplib in $deplibs; do
  8564. case $deplib in
  8565. -L*)
  8566. case " $new_libs " in
  8567. *" $deplib "*) ;;
  8568. *) func_append new_libs " $deplib" ;;
  8569. esac
  8570. ;;
  8571. *) func_append new_libs " $deplib" ;;
  8572. esac
  8573. done
  8574. deplibs=$new_libs
  8575. # All the library-specific variables (install_libdir is set above).
  8576. library_names=
  8577. old_library=
  8578. dlname=
  8579. # Test again, we may have decided not to build it any more
  8580. if test yes = "$build_libtool_libs"; then
  8581. # Remove $wl instances when linking with ld.
  8582. # FIXME: should test the right _cmds variable.
  8583. case $archive_cmds in
  8584. *\$LD\ *) wl= ;;
  8585. esac
  8586. if test yes = "$hardcode_into_libs"; then
  8587. # Hardcode the library paths
  8588. hardcode_libdirs=
  8589. dep_rpath=
  8590. rpath=$finalize_rpath
  8591. test relink = "$opt_mode" || rpath=$compile_rpath$rpath
  8592. for libdir in $rpath; do
  8593. if test -n "$hardcode_libdir_flag_spec"; then
  8594. if test -n "$hardcode_libdir_separator"; then
  8595. func_replace_sysroot "$libdir"
  8596. libdir=$func_replace_sysroot_result
  8597. if test -z "$hardcode_libdirs"; then
  8598. hardcode_libdirs=$libdir
  8599. else
  8600. # Just accumulate the unique libdirs.
  8601. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
  8602. *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
  8603. ;;
  8604. *)
  8605. func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
  8606. ;;
  8607. esac
  8608. fi
  8609. else
  8610. eval flag=\"$hardcode_libdir_flag_spec\"
  8611. func_append dep_rpath " $flag"
  8612. fi
  8613. elif test -n "$runpath_var"; then
  8614. case "$perm_rpath " in
  8615. *" $libdir "*) ;;
  8616. *) func_append perm_rpath " $libdir" ;;
  8617. esac
  8618. fi
  8619. done
  8620. # Substitute the hardcoded libdirs into the rpath.
  8621. if test -n "$hardcode_libdir_separator" &&
  8622. test -n "$hardcode_libdirs"; then
  8623. libdir=$hardcode_libdirs
  8624. eval "dep_rpath=\"$hardcode_libdir_flag_spec\""
  8625. fi
  8626. if test -n "$runpath_var" && test -n "$perm_rpath"; then
  8627. # We should set the runpath_var.
  8628. rpath=
  8629. for dir in $perm_rpath; do
  8630. func_append rpath "$dir:"
  8631. done
  8632. eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
  8633. fi
  8634. test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
  8635. fi
  8636. shlibpath=$finalize_shlibpath
  8637. test relink = "$opt_mode" || shlibpath=$compile_shlibpath$shlibpath
  8638. if test -n "$shlibpath"; then
  8639. eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
  8640. fi
  8641. # Get the real and link names of the library.
  8642. eval shared_ext=\"$shrext_cmds\"
  8643. eval library_names=\"$library_names_spec\"
  8644. set dummy $library_names
  8645. shift
  8646. realname=$1
  8647. shift
  8648. if test -n "$soname_spec"; then
  8649. eval soname=\"$soname_spec\"
  8650. else
  8651. soname=$realname
  8652. fi
  8653. if test -z "$dlname"; then
  8654. dlname=$soname
  8655. fi
  8656. lib=$output_objdir/$realname
  8657. linknames=
  8658. for link
  8659. do
  8660. func_append linknames " $link"
  8661. done
  8662. # Use standard objects if they are pic
  8663. test -z "$pic_flag" && libobjs=`$ECHO "$libobjs" | $SP2NL | $SED "$lo2o" | $NL2SP`
  8664. test "X$libobjs" = "X " && libobjs=
  8665. delfiles=
  8666. if test -n "$export_symbols" && test -n "$include_expsyms"; then
  8667. $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
  8668. export_symbols=$output_objdir/$libname.uexp
  8669. func_append delfiles " $export_symbols"
  8670. fi
  8671. orig_export_symbols=
  8672. case $host_os in
  8673. cygwin* | mingw* | windows* | cegcc*)
  8674. if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
  8675. # exporting using user supplied symfile
  8676. func_dll_def_p "$export_symbols" || {
  8677. # and it's NOT already a .def file. Must figure out
  8678. # which of the given symbols are data symbols and tag
  8679. # them as such. So, trigger use of export_symbols_cmds.
  8680. # export_symbols gets reassigned inside the "prepare
  8681. # the list of exported symbols" if statement, so the
  8682. # include_expsyms logic still works.
  8683. orig_export_symbols=$export_symbols
  8684. export_symbols=
  8685. always_export_symbols=yes
  8686. }
  8687. fi
  8688. ;;
  8689. esac
  8690. # Prepare the list of exported symbols
  8691. if test -z "$export_symbols"; then
  8692. if test yes = "$always_export_symbols" || test -n "$export_symbols_regex"; then
  8693. func_verbose "generating symbol list for '$libname.la'"
  8694. export_symbols=$output_objdir/$libname.exp
  8695. $opt_dry_run || $RM $export_symbols
  8696. cmds=$export_symbols_cmds
  8697. save_ifs=$IFS; IFS='~'
  8698. for cmd1 in $cmds; do
  8699. IFS=$save_ifs
  8700. # Take the normal branch if the nm_file_list_spec branch
  8701. # doesn't work or if tool conversion is not needed.
  8702. case $nm_file_list_spec~$to_tool_file_cmd in
  8703. *~func_convert_file_noop | *~func_convert_file_msys_to_w32 | ~*)
  8704. try_normal_branch=yes
  8705. eval cmd=\"$cmd1\"
  8706. func_len " $cmd"
  8707. len=$func_len_result
  8708. ;;
  8709. *)
  8710. try_normal_branch=no
  8711. ;;
  8712. esac
  8713. if test yes = "$try_normal_branch" \
  8714. && { test "$len" -lt "$max_cmd_len" \
  8715. || test "$max_cmd_len" -le -1; }
  8716. then
  8717. func_show_eval "$cmd" 'exit $?'
  8718. skipped_export=false
  8719. elif test -n "$nm_file_list_spec"; then
  8720. func_basename "$output"
  8721. output_la=$func_basename_result
  8722. save_libobjs=$libobjs
  8723. save_output=$output
  8724. output=$output_objdir/$output_la.nm
  8725. func_to_tool_file "$output"
  8726. libobjs=$nm_file_list_spec$func_to_tool_file_result
  8727. func_append delfiles " $output"
  8728. func_verbose "creating $NM input file list: $output"
  8729. for obj in $save_libobjs; do
  8730. func_to_tool_file "$obj"
  8731. $ECHO "$func_to_tool_file_result"
  8732. done > "$output"
  8733. eval cmd=\"$cmd1\"
  8734. func_show_eval "$cmd" 'exit $?'
  8735. output=$save_output
  8736. libobjs=$save_libobjs
  8737. skipped_export=false
  8738. else
  8739. # The command line is too long to execute in one step.
  8740. func_verbose "using reloadable object file for export list..."
  8741. skipped_export=:
  8742. # Break out early, otherwise skipped_export may be
  8743. # set to false by a later but shorter cmd.
  8744. break
  8745. fi
  8746. done
  8747. IFS=$save_ifs
  8748. if test -n "$export_symbols_regex" && test : != "$skipped_export"; then
  8749. func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
  8750. func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
  8751. fi
  8752. fi
  8753. fi
  8754. if test -n "$export_symbols" && test -n "$include_expsyms"; then
  8755. tmp_export_symbols=$export_symbols
  8756. test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
  8757. $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
  8758. fi
  8759. if test : != "$skipped_export" && test -n "$orig_export_symbols"; then
  8760. # The given exports_symbols file has to be filtered, so filter it.
  8761. func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
  8762. # FIXME: $output_objdir/$libname.filter potentially contains lots of
  8763. # 's' commands, which not all seds can handle. GNU sed should be fine
  8764. # though. Also, the filter scales superlinearly with the number of
  8765. # global variables. join(1) would be nice here, but unfortunately
  8766. # isn't a blessed tool.
  8767. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
  8768. func_append delfiles " $export_symbols $output_objdir/$libname.filter"
  8769. export_symbols=$output_objdir/$libname.def
  8770. $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
  8771. fi
  8772. tmp_deplibs=
  8773. for test_deplib in $deplibs; do
  8774. case " $convenience " in
  8775. *" $test_deplib "*) ;;
  8776. *)
  8777. func_append tmp_deplibs " $test_deplib"
  8778. ;;
  8779. esac
  8780. done
  8781. deplibs=$tmp_deplibs
  8782. if test -n "$convenience"; then
  8783. if test -n "$whole_archive_flag_spec" &&
  8784. test yes = "$compiler_needs_object" &&
  8785. test -z "$libobjs"; then
  8786. # extract the archives, so we have objects to list.
  8787. # TODO: could optimize this to just extract one archive.
  8788. whole_archive_flag_spec=
  8789. fi
  8790. if test -n "$whole_archive_flag_spec"; then
  8791. save_libobjs=$libobjs
  8792. eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
  8793. test "X$libobjs" = "X " && libobjs=
  8794. else
  8795. gentop=$output_objdir/${outputname}x
  8796. func_append generated " $gentop"
  8797. func_extract_archives $gentop $convenience
  8798. func_append libobjs " $func_extract_archives_result"
  8799. test "X$libobjs" = "X " && libobjs=
  8800. fi
  8801. fi
  8802. if test yes = "$thread_safe" && test -n "$thread_safe_flag_spec"; then
  8803. eval flag=\"$thread_safe_flag_spec\"
  8804. func_append linker_flags " $flag"
  8805. fi
  8806. # Make a backup of the uninstalled library when relinking
  8807. if test relink = "$opt_mode"; then
  8808. $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
  8809. fi
  8810. # Do each of the archive commands.
  8811. if test yes = "$module" && test -n "$module_cmds"; then
  8812. if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
  8813. eval test_cmds=\"$module_expsym_cmds\"
  8814. cmds=$module_expsym_cmds
  8815. else
  8816. eval test_cmds=\"$module_cmds\"
  8817. cmds=$module_cmds
  8818. fi
  8819. else
  8820. if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
  8821. eval test_cmds=\"$archive_expsym_cmds\"
  8822. cmds=$archive_expsym_cmds
  8823. else
  8824. eval test_cmds=\"$archive_cmds\"
  8825. cmds=$archive_cmds
  8826. fi
  8827. fi
  8828. if test : != "$skipped_export" &&
  8829. func_len " $test_cmds" &&
  8830. len=$func_len_result &&
  8831. test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
  8832. :
  8833. else
  8834. # The command line is too long to link in one step, link piecewise
  8835. # or, if using GNU ld and skipped_export is not :, use a linker
  8836. # script.
  8837. # Save the value of $output and $libobjs because we want to
  8838. # use them later. If we have whole_archive_flag_spec, we
  8839. # want to use save_libobjs as it was before
  8840. # whole_archive_flag_spec was expanded, because we can't
  8841. # assume the linker understands whole_archive_flag_spec.
  8842. # This may have to be revisited, in case too many
  8843. # convenience libraries get linked in and end up exceeding
  8844. # the spec.
  8845. if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
  8846. save_libobjs=$libobjs
  8847. fi
  8848. save_output=$output
  8849. func_basename "$output"
  8850. output_la=$func_basename_result
  8851. # Clear the reloadable object creation command queue and
  8852. # initialize k to one.
  8853. test_cmds=
  8854. concat_cmds=
  8855. objlist=
  8856. last_robj=
  8857. k=1
  8858. if test -n "$save_libobjs" && test : != "$skipped_export" && test yes = "$with_gnu_ld"; then
  8859. output=$output_objdir/$output_la.lnkscript
  8860. func_verbose "creating GNU ld script: $output"
  8861. echo 'INPUT (' > $output
  8862. for obj in $save_libobjs
  8863. do
  8864. func_to_tool_file "$obj"
  8865. $ECHO "$func_to_tool_file_result" >> $output
  8866. done
  8867. echo ')' >> $output
  8868. func_append delfiles " $output"
  8869. func_to_tool_file "$output"
  8870. output=$func_to_tool_file_result
  8871. elif test -n "$save_libobjs" && test : != "$skipped_export" && test -n "$file_list_spec"; then
  8872. output=$output_objdir/$output_la.lnk
  8873. func_verbose "creating linker input file list: $output"
  8874. : > $output
  8875. set x $save_libobjs
  8876. shift
  8877. firstobj=
  8878. if test yes = "$compiler_needs_object"; then
  8879. firstobj="$1 "
  8880. shift
  8881. fi
  8882. for obj
  8883. do
  8884. func_to_tool_file "$obj"
  8885. $ECHO "$func_to_tool_file_result" >> $output
  8886. done
  8887. func_append delfiles " $output"
  8888. func_to_tool_file "$output"
  8889. output=$firstobj\"$file_list_spec$func_to_tool_file_result\"
  8890. else
  8891. if test -n "$save_libobjs"; then
  8892. func_verbose "creating reloadable object files..."
  8893. output=$output_objdir/$output_la-$k.$objext
  8894. eval test_cmds=\"$reload_cmds\"
  8895. func_len " $test_cmds"
  8896. len0=$func_len_result
  8897. len=$len0
  8898. # Loop over the list of objects to be linked.
  8899. for obj in $save_libobjs
  8900. do
  8901. func_len " $obj"
  8902. func_arith $len + $func_len_result
  8903. len=$func_arith_result
  8904. if test -z "$objlist" ||
  8905. test "$len" -lt "$max_cmd_len"; then
  8906. func_append objlist " $obj"
  8907. else
  8908. # The command $test_cmds is almost too long, add a
  8909. # command to the queue.
  8910. if test 1 -eq "$k"; then
  8911. # The first file doesn't have a previous command to add.
  8912. reload_objs=$objlist
  8913. eval concat_cmds=\"$reload_cmds\"
  8914. else
  8915. # All subsequent reloadable object files will link in
  8916. # the last one created.
  8917. reload_objs="$objlist $last_robj"
  8918. eval concat_cmds=\"\$concat_cmds~$reload_cmds~\$RM $last_robj\"
  8919. fi
  8920. last_robj=$output_objdir/$output_la-$k.$objext
  8921. func_arith $k + 1
  8922. k=$func_arith_result
  8923. output=$output_objdir/$output_la-$k.$objext
  8924. objlist=" $obj"
  8925. func_len " $last_robj"
  8926. func_arith $len0 + $func_len_result
  8927. len=$func_arith_result
  8928. fi
  8929. done
  8930. # Handle the remaining objects by creating one last
  8931. # reloadable object file. All subsequent reloadable object
  8932. # files will link in the last one created.
  8933. test -z "$concat_cmds" || concat_cmds=$concat_cmds~
  8934. reload_objs="$objlist $last_robj"
  8935. eval concat_cmds=\"\$concat_cmds$reload_cmds\"
  8936. if test -n "$last_robj"; then
  8937. eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
  8938. fi
  8939. func_append delfiles " $output"
  8940. else
  8941. output=
  8942. fi
  8943. ${skipped_export-false} && {
  8944. func_verbose "generating symbol list for '$libname.la'"
  8945. export_symbols=$output_objdir/$libname.exp
  8946. $opt_dry_run || $RM $export_symbols
  8947. libobjs=$output
  8948. # Append the command to create the export file.
  8949. test -z "$concat_cmds" || concat_cmds=$concat_cmds~
  8950. eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
  8951. if test -n "$last_robj"; then
  8952. eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
  8953. fi
  8954. }
  8955. test -n "$save_libobjs" &&
  8956. func_verbose "creating a temporary reloadable object file: $output"
  8957. # Loop through the commands generated above and execute them.
  8958. save_ifs=$IFS; IFS='~'
  8959. for cmd in $concat_cmds; do
  8960. IFS=$save_ifs
  8961. $opt_quiet || {
  8962. func_quote_arg expand,pretty "$cmd"
  8963. eval "func_echo $func_quote_arg_result"
  8964. }
  8965. $opt_dry_run || eval "$cmd" || {
  8966. lt_exit=$?
  8967. # Restore the uninstalled library and exit
  8968. if test relink = "$opt_mode"; then
  8969. ( cd "$output_objdir" && \
  8970. $RM "${realname}T" && \
  8971. $MV "${realname}U" "$realname" )
  8972. fi
  8973. exit $lt_exit
  8974. }
  8975. done
  8976. IFS=$save_ifs
  8977. if test -n "$export_symbols_regex" && ${skipped_export-false}; then
  8978. func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
  8979. func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
  8980. fi
  8981. fi
  8982. ${skipped_export-false} && {
  8983. if test -n "$export_symbols" && test -n "$include_expsyms"; then
  8984. tmp_export_symbols=$export_symbols
  8985. test -n "$orig_export_symbols" && tmp_export_symbols=$orig_export_symbols
  8986. $opt_dry_run || eval '$ECHO "$include_expsyms" | $SP2NL >> "$tmp_export_symbols"'
  8987. fi
  8988. if test -n "$orig_export_symbols"; then
  8989. # The given exports_symbols file has to be filtered, so filter it.
  8990. func_verbose "filter symbol list for '$libname.la' to tag DATA exports"
  8991. # FIXME: $output_objdir/$libname.filter potentially contains lots of
  8992. # 's' commands, which not all seds can handle. GNU sed should be fine
  8993. # though. Also, the filter scales superlinearly with the number of
  8994. # global variables. join(1) would be nice here, but unfortunately
  8995. # isn't a blessed tool.
  8996. $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
  8997. func_append delfiles " $export_symbols $output_objdir/$libname.filter"
  8998. export_symbols=$output_objdir/$libname.def
  8999. $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
  9000. fi
  9001. }
  9002. libobjs=$output
  9003. # Restore the value of output.
  9004. output=$save_output
  9005. if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
  9006. eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
  9007. test "X$libobjs" = "X " && libobjs=
  9008. fi
  9009. # Expand the library linking commands again to reset the
  9010. # value of $libobjs for piecewise linking.
  9011. # Do each of the archive commands.
  9012. if test yes = "$module" && test -n "$module_cmds"; then
  9013. if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
  9014. cmds=$module_expsym_cmds
  9015. else
  9016. cmds=$module_cmds
  9017. fi
  9018. else
  9019. if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
  9020. cmds=$archive_expsym_cmds
  9021. else
  9022. cmds=$archive_cmds
  9023. fi
  9024. fi
  9025. fi
  9026. if test -n "$delfiles"; then
  9027. # Append the command to remove temporary files to $cmds.
  9028. eval cmds=\"\$cmds~\$RM $delfiles\"
  9029. fi
  9030. # Add any objects from preloaded convenience libraries
  9031. if test -n "$dlprefiles"; then
  9032. gentop=$output_objdir/${outputname}x
  9033. func_append generated " $gentop"
  9034. func_extract_archives $gentop $dlprefiles
  9035. func_append libobjs " $func_extract_archives_result"
  9036. test "X$libobjs" = "X " && libobjs=
  9037. fi
  9038. save_ifs=$IFS; IFS='~'
  9039. for cmd in $cmds; do
  9040. IFS=$sp$nl
  9041. eval cmd=\"$cmd\"
  9042. IFS=$save_ifs
  9043. $opt_quiet || {
  9044. func_quote_arg expand,pretty "$cmd"
  9045. eval "func_echo $func_quote_arg_result"
  9046. }
  9047. $opt_dry_run || eval "$cmd" || {
  9048. lt_exit=$?
  9049. # Restore the uninstalled library and exit
  9050. if test relink = "$opt_mode"; then
  9051. ( cd "$output_objdir" && \
  9052. $RM "${realname}T" && \
  9053. $MV "${realname}U" "$realname" )
  9054. fi
  9055. exit $lt_exit
  9056. }
  9057. done
  9058. IFS=$save_ifs
  9059. # Restore the uninstalled library and exit
  9060. if test relink = "$opt_mode"; then
  9061. $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
  9062. if test -n "$convenience"; then
  9063. if test -z "$whole_archive_flag_spec"; then
  9064. func_show_eval '${RM}r "$gentop"'
  9065. fi
  9066. fi
  9067. exit $EXIT_SUCCESS
  9068. fi
  9069. # Create links to the real library.
  9070. for linkname in $linknames; do
  9071. if test "$realname" != "$linkname"; then
  9072. func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
  9073. fi
  9074. done
  9075. # If -module or -export-dynamic was specified, set the dlname.
  9076. if test yes = "$module" || test yes = "$export_dynamic"; then
  9077. # On all known operating systems, these are identical.
  9078. dlname=$soname
  9079. fi
  9080. fi
  9081. ;;
  9082. obj)
  9083. if test -n "$dlfiles$dlprefiles" || test no != "$dlself"; then
  9084. func_warning "'-dlopen' is ignored for objects"
  9085. fi
  9086. case " $deplibs" in
  9087. *\ -l* | *\ -L*)
  9088. func_warning "'-l' and '-L' are ignored for objects" ;;
  9089. esac
  9090. test -n "$rpath" && \
  9091. func_warning "'-rpath' is ignored for objects"
  9092. test -n "$xrpath" && \
  9093. func_warning "'-R' is ignored for objects"
  9094. test -n "$vinfo" && \
  9095. func_warning "'-version-info' is ignored for objects"
  9096. test -n "$release" && \
  9097. func_warning "'-release' is ignored for objects"
  9098. case $output in
  9099. *.lo)
  9100. test -n "$objs$old_deplibs" && \
  9101. func_fatal_error "cannot build library object '$output' from non-libtool objects"
  9102. libobj=$output
  9103. func_lo2o "$libobj"
  9104. obj=$func_lo2o_result
  9105. ;;
  9106. *)
  9107. libobj=
  9108. obj=$output
  9109. ;;
  9110. esac
  9111. # Delete the old objects.
  9112. $opt_dry_run || $RM $obj $libobj
  9113. # Objects from convenience libraries. This assumes
  9114. # single-version convenience libraries. Whenever we create
  9115. # different ones for PIC/non-PIC, this we'll have to duplicate
  9116. # the extraction.
  9117. reload_conv_objs=
  9118. gentop=
  9119. # if reload_cmds runs $LD directly, get rid of -Wl from
  9120. # whole_archive_flag_spec and hope we can get by with turning comma
  9121. # into space.
  9122. case $reload_cmds in
  9123. *\$LD[\ \$]*) wl= ;;
  9124. esac
  9125. if test -n "$convenience"; then
  9126. if test -n "$whole_archive_flag_spec"; then
  9127. eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
  9128. test -n "$wl" || tmp_whole_archive_flags=`$ECHO "$tmp_whole_archive_flags" | $SED 's|,| |g'`
  9129. reload_conv_objs=$reload_objs\ $tmp_whole_archive_flags
  9130. else
  9131. gentop=$output_objdir/${obj}x
  9132. func_append generated " $gentop"
  9133. func_extract_archives $gentop $convenience
  9134. reload_conv_objs="$reload_objs $func_extract_archives_result"
  9135. fi
  9136. fi
  9137. # If we're not building shared, we need to use non_pic_objs
  9138. test yes = "$build_libtool_libs" || libobjs=$non_pic_objects
  9139. # Create the old-style object.
  9140. reload_objs=$objs$old_deplibs' '`$ECHO "$libobjs" | $SP2NL | $SED "/\.$libext$/d; /\.lib$/d; $lo2o" | $NL2SP`' '$reload_conv_objs
  9141. output=$obj
  9142. func_execute_cmds "$reload_cmds" 'exit $?'
  9143. # Exit if we aren't doing a library object file.
  9144. if test -z "$libobj"; then
  9145. if test -n "$gentop"; then
  9146. func_show_eval '${RM}r "$gentop"'
  9147. fi
  9148. exit $EXIT_SUCCESS
  9149. fi
  9150. test yes = "$build_libtool_libs" || {
  9151. if test -n "$gentop"; then
  9152. func_show_eval '${RM}r "$gentop"'
  9153. fi
  9154. # Create an invalid libtool object if no PIC, so that we don't
  9155. # accidentally link it into a program.
  9156. # $show "echo timestamp > $libobj"
  9157. # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
  9158. exit $EXIT_SUCCESS
  9159. }
  9160. if test -n "$pic_flag" || test default != "$pic_mode"; then
  9161. # Only do commands if we really have different PIC objects.
  9162. reload_objs="$libobjs $reload_conv_objs"
  9163. output=$libobj
  9164. func_execute_cmds "$reload_cmds" 'exit $?'
  9165. fi
  9166. if test -n "$gentop"; then
  9167. func_show_eval '${RM}r "$gentop"'
  9168. fi
  9169. exit $EXIT_SUCCESS
  9170. ;;
  9171. prog)
  9172. case $host in
  9173. *cygwin*) func_stripname '' '.exe' "$output"
  9174. output=$func_stripname_result.exe;;
  9175. esac
  9176. test -n "$vinfo" && \
  9177. func_warning "'-version-info' is ignored for programs"
  9178. test -n "$release" && \
  9179. func_warning "'-release' is ignored for programs"
  9180. $preload \
  9181. && test unknown,unknown,unknown = "$dlopen_support,$dlopen_self,$dlopen_self_static" \
  9182. && func_warning "'LT_INIT([dlopen])' not used. Assuming no dlopen support."
  9183. case $host in
  9184. *-*-rhapsody* | *-*-darwin1.[012])
  9185. # On Rhapsody replace the C library is the System framework
  9186. compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's/ -lc / System.ltframework /'`
  9187. finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's/ -lc / System.ltframework /'`
  9188. ;;
  9189. esac
  9190. case $host in
  9191. *-*-darwin*)
  9192. # Don't allow lazy linking, it breaks C++ global constructors
  9193. # But is supposedly fixed on 10.4 or later (yay!).
  9194. if test CXX = "$tagname"; then
  9195. case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
  9196. 10.[0123])
  9197. func_append compile_command " $wl-bind_at_load"
  9198. func_append finalize_command " $wl-bind_at_load"
  9199. ;;
  9200. esac
  9201. fi
  9202. # Time to change all our "foo.ltframework" stuff back to "-framework foo"
  9203. compile_deplibs=`$ECHO " $compile_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  9204. finalize_deplibs=`$ECHO " $finalize_deplibs" | $SED 's% \([^ $]*\).ltframework% -framework \1%g'`
  9205. ;;
  9206. esac
  9207. # move library search paths that coincide with paths to not yet
  9208. # installed libraries to the beginning of the library search list
  9209. new_libs=
  9210. for path in $notinst_path; do
  9211. case " $new_libs " in
  9212. *" -L$path/$objdir "*) ;;
  9213. *)
  9214. case " $compile_deplibs " in
  9215. *" -L$path/$objdir "*)
  9216. func_append new_libs " -L$path/$objdir" ;;
  9217. esac
  9218. ;;
  9219. esac
  9220. done
  9221. for deplib in $compile_deplibs; do
  9222. case $deplib in
  9223. -L*)
  9224. case " $new_libs " in
  9225. *" $deplib "*) ;;
  9226. *) func_append new_libs " $deplib" ;;
  9227. esac
  9228. ;;
  9229. *) func_append new_libs " $deplib" ;;
  9230. esac
  9231. done
  9232. compile_deplibs=$new_libs
  9233. func_append compile_command " $compile_deplibs"
  9234. func_append finalize_command " $finalize_deplibs"
  9235. if test -n "$rpath$xrpath"; then
  9236. # If the user specified any rpath flags, then add them.
  9237. for libdir in $rpath $xrpath; do
  9238. # This is the magic to use -rpath.
  9239. case "$finalize_rpath " in
  9240. *" $libdir "*) ;;
  9241. *) func_append finalize_rpath " $libdir" ;;
  9242. esac
  9243. done
  9244. fi
  9245. # Now hardcode the library paths
  9246. rpath=
  9247. hardcode_libdirs=
  9248. for libdir in $compile_rpath $finalize_rpath; do
  9249. if test -n "$hardcode_libdir_flag_spec"; then
  9250. if test -n "$hardcode_libdir_separator"; then
  9251. if test -z "$hardcode_libdirs"; then
  9252. hardcode_libdirs=$libdir
  9253. else
  9254. # Just accumulate the unique libdirs.
  9255. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
  9256. *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
  9257. ;;
  9258. *)
  9259. func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
  9260. ;;
  9261. esac
  9262. fi
  9263. else
  9264. eval flag=\"$hardcode_libdir_flag_spec\"
  9265. func_append rpath " $flag"
  9266. fi
  9267. elif test -n "$runpath_var"; then
  9268. case "$perm_rpath " in
  9269. *" $libdir "*) ;;
  9270. *) func_append perm_rpath " $libdir" ;;
  9271. esac
  9272. fi
  9273. case $host in
  9274. *-*-cygwin* | *-*-mingw* | *-*-windows* | *-*-pw32* | *-*-os2* | *-cegcc*)
  9275. testbindir=`$ECHO "$libdir" | $SED -e 's*/lib$*/bin*'`
  9276. case :$dllsearchpath: in
  9277. *":$libdir:"*) ;;
  9278. ::) dllsearchpath=$libdir;;
  9279. *) func_append dllsearchpath ":$libdir";;
  9280. esac
  9281. case :$dllsearchpath: in
  9282. *":$testbindir:"*) ;;
  9283. ::) dllsearchpath=$testbindir;;
  9284. *) func_append dllsearchpath ":$testbindir";;
  9285. esac
  9286. ;;
  9287. esac
  9288. done
  9289. # Substitute the hardcoded libdirs into the rpath.
  9290. if test -n "$hardcode_libdir_separator" &&
  9291. test -n "$hardcode_libdirs"; then
  9292. libdir=$hardcode_libdirs
  9293. eval rpath=\" $hardcode_libdir_flag_spec\"
  9294. fi
  9295. compile_rpath=$rpath
  9296. rpath=
  9297. hardcode_libdirs=
  9298. for libdir in $finalize_rpath; do
  9299. if test -n "$hardcode_libdir_flag_spec"; then
  9300. if test -n "$hardcode_libdir_separator"; then
  9301. if test -z "$hardcode_libdirs"; then
  9302. hardcode_libdirs=$libdir
  9303. else
  9304. # Just accumulate the unique libdirs.
  9305. case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
  9306. *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
  9307. ;;
  9308. *)
  9309. func_append hardcode_libdirs "$hardcode_libdir_separator$libdir"
  9310. ;;
  9311. esac
  9312. fi
  9313. else
  9314. eval flag=\"$hardcode_libdir_flag_spec\"
  9315. func_append rpath " $flag"
  9316. fi
  9317. elif test -n "$runpath_var"; then
  9318. case "$finalize_perm_rpath " in
  9319. *" $libdir "*) ;;
  9320. *) func_append finalize_perm_rpath " $libdir" ;;
  9321. esac
  9322. fi
  9323. done
  9324. # Substitute the hardcoded libdirs into the rpath.
  9325. if test -n "$hardcode_libdir_separator" &&
  9326. test -n "$hardcode_libdirs"; then
  9327. libdir=$hardcode_libdirs
  9328. eval rpath=\" $hardcode_libdir_flag_spec\"
  9329. fi
  9330. finalize_rpath=$rpath
  9331. if test -n "$libobjs" && test yes = "$build_old_libs"; then
  9332. # Transform all the library objects into standard objects.
  9333. compile_command=`$ECHO "$compile_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
  9334. finalize_command=`$ECHO "$finalize_command" | $SP2NL | $SED "$lo2o" | $NL2SP`
  9335. fi
  9336. func_generate_dlsyms "$outputname" "@PROGRAM@" false
  9337. # template prelinking step
  9338. if test -n "$prelink_cmds"; then
  9339. func_execute_cmds "$prelink_cmds" 'exit $?'
  9340. fi
  9341. wrappers_required=:
  9342. case $host in
  9343. *cegcc* | *mingw32ce*)
  9344. # Disable wrappers for cegcc and mingw32ce hosts, we are cross compiling anyway.
  9345. wrappers_required=false
  9346. ;;
  9347. *cygwin* | *mingw* | *windows* )
  9348. test yes = "$build_libtool_libs" || wrappers_required=false
  9349. ;;
  9350. *)
  9351. if test no = "$need_relink" || test yes != "$build_libtool_libs"; then
  9352. wrappers_required=false
  9353. fi
  9354. ;;
  9355. esac
  9356. $wrappers_required || {
  9357. # Replace the output file specification.
  9358. compile_command=`$ECHO "$compile_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
  9359. link_command=$compile_command$compile_rpath
  9360. # We have no uninstalled library dependencies, so finalize right now.
  9361. exit_status=0
  9362. func_show_eval "$link_command" 'exit_status=$?'
  9363. if test -n "$postlink_cmds"; then
  9364. func_to_tool_file "$output"
  9365. postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
  9366. func_execute_cmds "$postlink_cmds" 'exit $?'
  9367. fi
  9368. # Delete the generated files.
  9369. if test -f "$output_objdir/${outputname}S.$objext"; then
  9370. func_show_eval '$RM "$output_objdir/${outputname}S.$objext"'
  9371. fi
  9372. exit $exit_status
  9373. }
  9374. if test -n "$compile_shlibpath$finalize_shlibpath"; then
  9375. compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
  9376. fi
  9377. if test -n "$finalize_shlibpath"; then
  9378. finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
  9379. fi
  9380. compile_var=
  9381. finalize_var=
  9382. if test -n "$runpath_var"; then
  9383. if test -n "$perm_rpath"; then
  9384. # We should set the runpath_var.
  9385. rpath=
  9386. for dir in $perm_rpath; do
  9387. func_append rpath "$dir:"
  9388. done
  9389. compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
  9390. fi
  9391. if test -n "$finalize_perm_rpath"; then
  9392. # We should set the runpath_var.
  9393. rpath=
  9394. for dir in $finalize_perm_rpath; do
  9395. func_append rpath "$dir:"
  9396. done
  9397. finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
  9398. fi
  9399. fi
  9400. if test yes = "$no_install"; then
  9401. # We don't need to create a wrapper script.
  9402. link_command=$compile_var$compile_command$compile_rpath
  9403. # Replace the output file specification.
  9404. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output"'%g'`
  9405. # Delete the old output file.
  9406. $opt_dry_run || $RM $output
  9407. # Link the executable and exit
  9408. func_show_eval "$link_command" 'exit $?'
  9409. if test -n "$postlink_cmds"; then
  9410. func_to_tool_file "$output"
  9411. postlink_cmds=`func_echo_all "$postlink_cmds" | $SED -e 's%@OUTPUT@%'"$output"'%g' -e 's%@TOOL_OUTPUT@%'"$func_to_tool_file_result"'%g'`
  9412. func_execute_cmds "$postlink_cmds" 'exit $?'
  9413. fi
  9414. exit $EXIT_SUCCESS
  9415. fi
  9416. case $hardcode_action,$fast_install in
  9417. relink,*)
  9418. # Fast installation is not supported
  9419. link_command=$compile_var$compile_command$compile_rpath
  9420. relink_command=$finalize_var$finalize_command$finalize_rpath
  9421. func_warning "this platform does not like uninstalled shared libraries"
  9422. func_warning "'$output' will be relinked during installation"
  9423. ;;
  9424. *,yes)
  9425. link_command=$finalize_var$compile_command$finalize_rpath
  9426. relink_command=`$ECHO "$compile_var$compile_command$compile_rpath" | $SED 's%@OUTPUT@%\$progdir/\$file%g'`
  9427. ;;
  9428. *,no)
  9429. link_command=$compile_var$compile_command$compile_rpath
  9430. relink_command=$finalize_var$finalize_command$finalize_rpath
  9431. ;;
  9432. *,needless)
  9433. link_command=$finalize_var$compile_command$finalize_rpath
  9434. relink_command=
  9435. ;;
  9436. esac
  9437. # Replace the output file specification.
  9438. link_command=`$ECHO "$link_command" | $SED 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
  9439. # Delete the old output files.
  9440. $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
  9441. func_show_eval "$link_command" 'exit $?'
  9442. if test -n "$postlink_cmds"; then
  9443. func_to_tool_file "$output_objdir/$outputname"
  9444. 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'`
  9445. func_execute_cmds "$postlink_cmds" 'exit $?'
  9446. fi
  9447. # Now create the wrapper script.
  9448. func_verbose "creating $output"
  9449. # Quote the relink command for shipping.
  9450. if test -n "$relink_command"; then
  9451. # Preserve any variables that may affect compiler behavior
  9452. for var in $variables_saved_for_relink; do
  9453. if eval test -z \"\${$var+set}\"; then
  9454. relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
  9455. elif eval var_value=\$$var; test -z "$var_value"; then
  9456. relink_command="$var=; export $var; $relink_command"
  9457. else
  9458. func_quote_arg pretty "$var_value"
  9459. relink_command="$var=$func_quote_arg_result; export $var; $relink_command"
  9460. fi
  9461. done
  9462. func_quote eval cd "`pwd`"
  9463. func_quote_arg pretty,unquoted "($func_quote_result; $relink_command)"
  9464. relink_command=$func_quote_arg_unquoted_result
  9465. fi
  9466. # Only actually do things if not in dry run mode.
  9467. $opt_dry_run || {
  9468. # win32 will think the script is a binary if it has
  9469. # a .exe suffix, so we strip it off here.
  9470. case $output in
  9471. *.exe) func_stripname '' '.exe' "$output"
  9472. output=$func_stripname_result ;;
  9473. esac
  9474. # test for cygwin because mv fails w/o .exe extensions
  9475. case $host in
  9476. *cygwin*)
  9477. exeext=.exe
  9478. func_stripname '' '.exe' "$outputname"
  9479. outputname=$func_stripname_result ;;
  9480. *) exeext= ;;
  9481. esac
  9482. case $host in
  9483. *cygwin* | *mingw* | windows* )
  9484. func_dirname_and_basename "$output" "" "."
  9485. output_name=$func_basename_result
  9486. output_path=$func_dirname_result
  9487. cwrappersource=$output_path/$objdir/lt-$output_name.c
  9488. cwrapper=$output_path/$output_name.exe
  9489. $RM $cwrappersource $cwrapper
  9490. trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
  9491. func_emit_cwrapperexe_src > $cwrappersource
  9492. # The wrapper executable is built using the $host compiler,
  9493. # because it contains $host paths and files. If cross-
  9494. # compiling, it, like the target executable, must be
  9495. # executed on the $host or under an emulation environment.
  9496. $opt_dry_run || {
  9497. $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
  9498. $STRIP $cwrapper
  9499. }
  9500. # Now, create the wrapper script for func_source use:
  9501. func_ltwrapper_scriptname $cwrapper
  9502. $RM $func_ltwrapper_scriptname_result
  9503. trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
  9504. $opt_dry_run || {
  9505. # note: this script will not be executed, so do not chmod.
  9506. if test "x$build" = "x$host"; then
  9507. $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
  9508. else
  9509. func_emit_wrapper no > $func_ltwrapper_scriptname_result
  9510. fi
  9511. }
  9512. ;;
  9513. * )
  9514. $RM $output
  9515. trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
  9516. func_emit_wrapper no > $output
  9517. chmod +x $output
  9518. ;;
  9519. esac
  9520. }
  9521. exit $EXIT_SUCCESS
  9522. ;;
  9523. esac
  9524. # See if we need to build an old-fashioned archive.
  9525. for oldlib in $oldlibs; do
  9526. case $build_libtool_libs in
  9527. convenience)
  9528. oldobjs="$libobjs_save $symfileobj"
  9529. addlibs=$convenience
  9530. build_libtool_libs=no
  9531. ;;
  9532. module)
  9533. oldobjs=$libobjs_save
  9534. addlibs=$old_convenience
  9535. build_libtool_libs=no
  9536. ;;
  9537. *)
  9538. oldobjs="$old_deplibs $non_pic_objects"
  9539. $preload && test -f "$symfileobj" \
  9540. && func_append oldobjs " $symfileobj"
  9541. addlibs=$old_convenience
  9542. ;;
  9543. esac
  9544. if test -n "$addlibs"; then
  9545. gentop=$output_objdir/${outputname}x
  9546. func_append generated " $gentop"
  9547. func_extract_archives $gentop $addlibs
  9548. func_append oldobjs " $func_extract_archives_result"
  9549. fi
  9550. # Do each command in the archive commands.
  9551. if test -n "$old_archive_from_new_cmds" && test yes = "$build_libtool_libs"; then
  9552. cmds=$old_archive_from_new_cmds
  9553. else
  9554. # Add any objects from preloaded convenience libraries
  9555. if test -n "$dlprefiles"; then
  9556. gentop=$output_objdir/${outputname}x
  9557. func_append generated " $gentop"
  9558. func_extract_archives $gentop $dlprefiles
  9559. func_append oldobjs " $func_extract_archives_result"
  9560. fi
  9561. # POSIX demands no paths to be encoded in archives. We have
  9562. # to avoid creating archives with duplicate basenames if we
  9563. # might have to extract them afterwards, e.g., when creating a
  9564. # static archive out of a convenience library, or when linking
  9565. # the entirety of a libtool archive into another (currently
  9566. # not supported by libtool).
  9567. if (for obj in $oldobjs
  9568. do
  9569. func_basename "$obj"
  9570. $ECHO "$func_basename_result"
  9571. done | sort | sort -uc >/dev/null 2>&1); then
  9572. :
  9573. else
  9574. echo "copying selected object files to avoid basename conflicts..."
  9575. gentop=$output_objdir/${outputname}x
  9576. func_append generated " $gentop"
  9577. func_mkdir_p "$gentop"
  9578. save_oldobjs=$oldobjs
  9579. oldobjs=
  9580. counter=1
  9581. for obj in $save_oldobjs
  9582. do
  9583. func_basename "$obj"
  9584. objbase=$func_basename_result
  9585. case " $oldobjs " in
  9586. " ") oldobjs=$obj ;;
  9587. *[\ /]"$objbase "*)
  9588. while :; do
  9589. # Make sure we don't pick an alternate name that also
  9590. # overlaps.
  9591. newobj=lt$counter-$objbase
  9592. func_arith $counter + 1
  9593. counter=$func_arith_result
  9594. case " $oldobjs " in
  9595. *[\ /]"$newobj "*) ;;
  9596. *) if test ! -f "$gentop/$newobj"; then break; fi ;;
  9597. esac
  9598. done
  9599. func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
  9600. func_append oldobjs " $gentop/$newobj"
  9601. ;;
  9602. *) func_append oldobjs " $obj" ;;
  9603. esac
  9604. done
  9605. fi
  9606. func_to_tool_file "$oldlib" func_convert_file_msys_to_w32
  9607. tool_oldlib=$func_to_tool_file_result
  9608. eval cmds=\"$old_archive_cmds\"
  9609. func_len " $cmds"
  9610. len=$func_len_result
  9611. if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
  9612. cmds=$old_archive_cmds
  9613. elif test -n "$archiver_list_spec"; then
  9614. func_verbose "using command file archive linking..."
  9615. for obj in $oldobjs
  9616. do
  9617. func_to_tool_file "$obj"
  9618. $ECHO "$func_to_tool_file_result"
  9619. done > $output_objdir/$libname.libcmd
  9620. func_to_tool_file "$output_objdir/$libname.libcmd"
  9621. oldobjs=" $archiver_list_spec$func_to_tool_file_result"
  9622. cmds=$old_archive_cmds
  9623. else
  9624. # the command line is too long to link in one step, link in parts
  9625. func_verbose "using piecewise archive linking..."
  9626. save_RANLIB=$RANLIB
  9627. RANLIB=:
  9628. objlist=
  9629. concat_cmds=
  9630. save_oldobjs=$oldobjs
  9631. oldobjs=
  9632. # Is there a better way of finding the last object in the list?
  9633. for obj in $save_oldobjs
  9634. do
  9635. last_oldobj=$obj
  9636. done
  9637. eval test_cmds=\"$old_archive_cmds\"
  9638. func_len " $test_cmds"
  9639. len0=$func_len_result
  9640. len=$len0
  9641. for obj in $save_oldobjs
  9642. do
  9643. func_len " $obj"
  9644. func_arith $len + $func_len_result
  9645. len=$func_arith_result
  9646. func_append objlist " $obj"
  9647. if test "$len" -lt "$max_cmd_len"; then
  9648. :
  9649. else
  9650. # the above command should be used before it gets too long
  9651. oldobjs=$objlist
  9652. if test "$obj" = "$last_oldobj"; then
  9653. RANLIB=$save_RANLIB
  9654. fi
  9655. test -z "$concat_cmds" || concat_cmds=$concat_cmds~
  9656. eval concat_cmds=\"\$concat_cmds$old_archive_cmds\"
  9657. objlist=
  9658. len=$len0
  9659. fi
  9660. done
  9661. RANLIB=$save_RANLIB
  9662. oldobjs=$objlist
  9663. if test -z "$oldobjs"; then
  9664. eval cmds=\"\$concat_cmds\"
  9665. else
  9666. eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
  9667. fi
  9668. fi
  9669. fi
  9670. func_execute_cmds "$cmds" 'exit $?'
  9671. done
  9672. test -n "$generated" && \
  9673. func_show_eval "${RM}r$generated"
  9674. # Now create the libtool archive.
  9675. case $output in
  9676. *.la)
  9677. old_library=
  9678. test yes = "$build_old_libs" && old_library=$libname.$libext
  9679. func_verbose "creating $output"
  9680. # Preserve any variables that may affect compiler behavior
  9681. for var in $variables_saved_for_relink; do
  9682. if eval test -z \"\${$var+set}\"; then
  9683. relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
  9684. elif eval var_value=\$$var; test -z "$var_value"; then
  9685. relink_command="$var=; export $var; $relink_command"
  9686. else
  9687. func_quote_arg pretty,unquoted "$var_value"
  9688. relink_command="$var=$func_quote_arg_unquoted_result; export $var; $relink_command"
  9689. fi
  9690. done
  9691. # Quote the link command for shipping.
  9692. func_quote eval cd "`pwd`"
  9693. relink_command="($func_quote_result; $SHELL \"$progpath\" $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
  9694. func_quote_arg pretty,unquoted "$relink_command"
  9695. relink_command=$func_quote_arg_unquoted_result
  9696. if test yes = "$hardcode_automatic"; then
  9697. relink_command=
  9698. fi
  9699. # Only create the output if not a dry run.
  9700. $opt_dry_run || {
  9701. for installed in no yes; do
  9702. if test yes = "$installed"; then
  9703. if test -z "$install_libdir"; then
  9704. break
  9705. fi
  9706. output=$output_objdir/${outputname}i
  9707. # Replace all uninstalled libtool libraries with the installed ones
  9708. newdependency_libs=
  9709. for deplib in $dependency_libs; do
  9710. case $deplib in
  9711. *.la)
  9712. func_basename "$deplib"
  9713. name=$func_basename_result
  9714. func_resolve_sysroot "$deplib"
  9715. eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $func_resolve_sysroot_result`
  9716. test -z "$libdir" && \
  9717. func_fatal_error "'$deplib' is not a valid libtool archive"
  9718. func_append newdependency_libs " ${lt_sysroot:+=}$libdir/$name"
  9719. ;;
  9720. -L*)
  9721. func_stripname -L '' "$deplib"
  9722. func_replace_sysroot "$func_stripname_result"
  9723. func_append newdependency_libs " -L$func_replace_sysroot_result"
  9724. ;;
  9725. -R*)
  9726. func_stripname -R '' "$deplib"
  9727. func_replace_sysroot "$func_stripname_result"
  9728. func_append newdependency_libs " -R$func_replace_sysroot_result"
  9729. ;;
  9730. *) func_append newdependency_libs " $deplib" ;;
  9731. esac
  9732. done
  9733. dependency_libs=$newdependency_libs
  9734. newdlfiles=
  9735. for lib in $dlfiles; do
  9736. case $lib in
  9737. *.la)
  9738. func_basename "$lib"
  9739. name=$func_basename_result
  9740. eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
  9741. test -z "$libdir" && \
  9742. func_fatal_error "'$lib' is not a valid libtool archive"
  9743. func_append newdlfiles " ${lt_sysroot:+=}$libdir/$name"
  9744. ;;
  9745. *) func_append newdlfiles " $lib" ;;
  9746. esac
  9747. done
  9748. dlfiles=$newdlfiles
  9749. newdlprefiles=
  9750. for lib in $dlprefiles; do
  9751. case $lib in
  9752. *.la)
  9753. # Only pass preopened files to the pseudo-archive (for
  9754. # eventual linking with the app. that links it) if we
  9755. # didn't already link the preopened objects directly into
  9756. # the library:
  9757. func_basename "$lib"
  9758. name=$func_basename_result
  9759. eval libdir=`$SED -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
  9760. test -z "$libdir" && \
  9761. func_fatal_error "'$lib' is not a valid libtool archive"
  9762. func_append newdlprefiles " ${lt_sysroot:+=}$libdir/$name"
  9763. ;;
  9764. esac
  9765. done
  9766. dlprefiles=$newdlprefiles
  9767. else
  9768. newdlfiles=
  9769. for lib in $dlfiles; do
  9770. case $lib in
  9771. [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
  9772. *) abs=`pwd`"/$lib" ;;
  9773. esac
  9774. func_append newdlfiles " $abs"
  9775. done
  9776. dlfiles=$newdlfiles
  9777. newdlprefiles=
  9778. for lib in $dlprefiles; do
  9779. case $lib in
  9780. [\\/]* | [A-Za-z]:[\\/]*) abs=$lib ;;
  9781. *) abs=`pwd`"/$lib" ;;
  9782. esac
  9783. func_append newdlprefiles " $abs"
  9784. done
  9785. dlprefiles=$newdlprefiles
  9786. fi
  9787. $RM $output
  9788. # place dlname in correct position for cygwin
  9789. # In fact, it would be nice if we could use this code for all target
  9790. # systems that can't hard-code library paths into their executables
  9791. # and that have no shared library path variable independent of PATH,
  9792. # but it turns out we can't easily determine that from inspecting
  9793. # libtool variables, so we have to hard-code the OSs to which it
  9794. # applies here; at the moment, that means platforms that use the PE
  9795. # object format with DLL files. See the long comment at the top of
  9796. # tests/bindir.at for full details.
  9797. tdlname=$dlname
  9798. case $host,$output,$installed,$module,$dlname in
  9799. *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *windows*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll)
  9800. # If a -bindir argument was supplied, place the dll there.
  9801. if test -n "$bindir"; then
  9802. func_relative_path "$install_libdir" "$bindir"
  9803. tdlname=$func_relative_path_result/$dlname
  9804. else
  9805. # Otherwise fall back on heuristic.
  9806. tdlname=../bin/$dlname
  9807. fi
  9808. ;;
  9809. esac
  9810. $ECHO > $output "\
  9811. # $outputname - a libtool library file
  9812. # Generated by $PROGRAM (GNU $PACKAGE) $VERSION
  9813. #
  9814. # Please DO NOT delete this file!
  9815. # It is necessary for linking the library.
  9816. # The name that we can dlopen(3).
  9817. dlname='$tdlname'
  9818. # Names of this library.
  9819. library_names='$library_names'
  9820. # The name of the static archive.
  9821. old_library='$old_library'
  9822. # Linker flags that cannot go in dependency_libs.
  9823. inherited_linker_flags='$new_inherited_linker_flags'
  9824. # Libraries that this one depends upon.
  9825. dependency_libs='$dependency_libs'
  9826. # Names of additional weak libraries provided by this library
  9827. weak_library_names='$weak_libs'
  9828. # Version information for $libname.
  9829. current=$current
  9830. age=$age
  9831. revision=$revision
  9832. # Is this an already installed library?
  9833. installed=$installed
  9834. # Should we warn about portability when linking against -modules?
  9835. shouldnotlink=$module
  9836. # Files to dlopen/dlpreopen
  9837. dlopen='$dlfiles'
  9838. dlpreopen='$dlprefiles'
  9839. # Directory that this library needs to be installed in:
  9840. libdir='$install_libdir'"
  9841. if test no,yes = "$installed,$need_relink"; then
  9842. $ECHO >> $output "\
  9843. relink_command=\"$relink_command\""
  9844. fi
  9845. done
  9846. }
  9847. # Do a symbolic link so that the libtool archive can be found in
  9848. # LD_LIBRARY_PATH before the program is installed.
  9849. func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
  9850. ;;
  9851. esac
  9852. exit $EXIT_SUCCESS
  9853. }
  9854. if test link = "$opt_mode" || test relink = "$opt_mode"; then
  9855. func_mode_link ${1+"$@"}
  9856. fi
  9857. # func_mode_uninstall arg...
  9858. func_mode_uninstall ()
  9859. {
  9860. $debug_cmd
  9861. RM=$nonopt
  9862. files=
  9863. rmforce=false
  9864. exit_status=0
  9865. # This variable tells wrapper scripts just to set variables rather
  9866. # than running their programs.
  9867. libtool_install_magic=$magic
  9868. for arg
  9869. do
  9870. case $arg in
  9871. -f) func_append RM " $arg"; rmforce=: ;;
  9872. -*) func_append RM " $arg" ;;
  9873. *) func_append files " $arg" ;;
  9874. esac
  9875. done
  9876. test -z "$RM" && \
  9877. func_fatal_help "you must specify an RM program"
  9878. rmdirs=
  9879. for file in $files; do
  9880. func_dirname "$file" "" "."
  9881. dir=$func_dirname_result
  9882. if test . = "$dir"; then
  9883. odir=$objdir
  9884. else
  9885. odir=$dir/$objdir
  9886. fi
  9887. func_basename "$file"
  9888. name=$func_basename_result
  9889. test uninstall = "$opt_mode" && odir=$dir
  9890. # Remember odir for removal later, being careful to avoid duplicates
  9891. if test clean = "$opt_mode"; then
  9892. case " $rmdirs " in
  9893. *" $odir "*) ;;
  9894. *) func_append rmdirs " $odir" ;;
  9895. esac
  9896. fi
  9897. # Don't error if the file doesn't exist and rm -f was used.
  9898. if { test -L "$file"; } >/dev/null 2>&1 ||
  9899. { test -h "$file"; } >/dev/null 2>&1 ||
  9900. test -f "$file"; then
  9901. :
  9902. elif test -d "$file"; then
  9903. exit_status=1
  9904. continue
  9905. elif $rmforce; then
  9906. continue
  9907. fi
  9908. rmfiles=$file
  9909. case $name in
  9910. *.la)
  9911. # Possibly a libtool archive, so verify it.
  9912. if func_lalib_p "$file"; then
  9913. func_source $dir/$name
  9914. # Delete the libtool libraries and symlinks.
  9915. for n in $library_names; do
  9916. func_append rmfiles " $odir/$n"
  9917. done
  9918. test -n "$old_library" && func_append rmfiles " $odir/$old_library"
  9919. case $opt_mode in
  9920. clean)
  9921. case " $library_names " in
  9922. *" $dlname "*) ;;
  9923. *) test -n "$dlname" && func_append rmfiles " $odir/$dlname" ;;
  9924. esac
  9925. test -n "$libdir" && func_append rmfiles " $odir/$name $odir/${name}i"
  9926. ;;
  9927. uninstall)
  9928. if test -n "$library_names"; then
  9929. # Do each command in the postuninstall commands.
  9930. func_execute_cmds "$postuninstall_cmds" '$rmforce || exit_status=1'
  9931. fi
  9932. if test -n "$old_library"; then
  9933. # Do each command in the old_postuninstall commands.
  9934. func_execute_cmds "$old_postuninstall_cmds" '$rmforce || exit_status=1'
  9935. fi
  9936. # FIXME: should reinstall the best remaining shared library.
  9937. ;;
  9938. esac
  9939. fi
  9940. ;;
  9941. *.lo)
  9942. # Possibly a libtool object, so verify it.
  9943. if func_lalib_p "$file"; then
  9944. # Read the .lo file
  9945. func_source $dir/$name
  9946. # Add PIC object to the list of files to remove.
  9947. if test -n "$pic_object" && test none != "$pic_object"; then
  9948. func_append rmfiles " $dir/$pic_object"
  9949. fi
  9950. # Add non-PIC object to the list of files to remove.
  9951. if test -n "$non_pic_object" && test none != "$non_pic_object"; then
  9952. func_append rmfiles " $dir/$non_pic_object"
  9953. fi
  9954. fi
  9955. ;;
  9956. *)
  9957. if test clean = "$opt_mode"; then
  9958. noexename=$name
  9959. case $file in
  9960. *.exe)
  9961. func_stripname '' '.exe' "$file"
  9962. file=$func_stripname_result
  9963. func_stripname '' '.exe' "$name"
  9964. noexename=$func_stripname_result
  9965. # $file with .exe has already been added to rmfiles,
  9966. # add $file without .exe
  9967. func_append rmfiles " $file"
  9968. ;;
  9969. esac
  9970. # Do a test to see if this is a libtool program.
  9971. if func_ltwrapper_p "$file"; then
  9972. if func_ltwrapper_executable_p "$file"; then
  9973. func_ltwrapper_scriptname "$file"
  9974. relink_command=
  9975. func_source $func_ltwrapper_scriptname_result
  9976. func_append rmfiles " $func_ltwrapper_scriptname_result"
  9977. else
  9978. relink_command=
  9979. func_source $dir/$noexename
  9980. fi
  9981. # note $name still contains .exe if it was in $file originally
  9982. # as does the version of $file that was added into $rmfiles
  9983. func_append rmfiles " $odir/$name $odir/${name}S.$objext"
  9984. if test yes = "$fast_install" && test -n "$relink_command"; then
  9985. func_append rmfiles " $odir/lt-$name"
  9986. fi
  9987. if test "X$noexename" != "X$name"; then
  9988. func_append rmfiles " $odir/lt-$noexename.c"
  9989. fi
  9990. fi
  9991. fi
  9992. ;;
  9993. esac
  9994. func_show_eval "$RM $rmfiles" 'exit_status=1'
  9995. done
  9996. # Try to remove the $objdir's in the directories where we deleted files
  9997. for dir in $rmdirs; do
  9998. if test -d "$dir"; then
  9999. func_show_eval "rmdir $dir >/dev/null 2>&1"
  10000. fi
  10001. done
  10002. exit $exit_status
  10003. }
  10004. if test uninstall = "$opt_mode" || test clean = "$opt_mode"; then
  10005. func_mode_uninstall ${1+"$@"}
  10006. fi
  10007. test -z "$opt_mode" && {
  10008. help=$generic_help
  10009. func_fatal_help "you must specify a MODE"
  10010. }
  10011. test -z "$exec_cmd" && \
  10012. func_fatal_help "invalid operation mode '$opt_mode'"
  10013. if test -n "$exec_cmd"; then
  10014. eval exec "$exec_cmd"
  10015. exit $EXIT_FAILURE
  10016. fi
  10017. exit $exit_status
  10018. # The TAGs below are defined such that we never get into a situation
  10019. # where we disable both kinds of libraries. Given conflicting
  10020. # choices, we go for a static library, that is the most portable,
  10021. # since we can't tell whether shared libraries were disabled because
  10022. # the user asked for that or because the platform doesn't support
  10023. # them. This is particularly important on AIX, because we don't
  10024. # support having both static and shared libraries enabled at the same
  10025. # time on that platform, so we default to a shared-only configuration.
  10026. # If a disable-shared tag is given, we'll fallback to a static-only
  10027. # configuration. But we'll never go from static-only to shared-only.
  10028. # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
  10029. build_libtool_libs=no
  10030. build_old_libs=yes
  10031. # ### END LIBTOOL TAG CONFIG: disable-shared
  10032. # ### BEGIN LIBTOOL TAG CONFIG: disable-static
  10033. build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
  10034. # ### END LIBTOOL TAG CONFIG: disable-static
  10035. # Local Variables:
  10036. # mode:shell-script
  10037. # sh-indentation:2
  10038. # End: