Meson WrapDB for Google's cityhash.
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.

9636 lines
276 KiB

  1. # libtool (GNU libtool) 2.4
  2. # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
  3. # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006,
  4. # 2007, 2008, 2009, 2010 Free Software Foundation, Inc.
  5. # This is free software; see the source for copying conditions. There is NO
  6. # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  7. # GNU Libtool is free software; you can redistribute it and/or modify
  8. # it under the terms of the GNU General Public License as published by
  9. # the Free Software Foundation; either version 2 of the License, or
  10. # (at your option) any later version.
  11. #
  12. # As a special exception to the GNU General Public License,
  13. # if you distribute this file as part of a program or library that
  14. # is built using GNU Libtool, you may include this file under the
  15. # same distribution terms that you use for the rest of that program.
  16. #
  17. # GNU Libtool is distributed in the hope that it will be useful, but
  18. # WITHOUT ANY WARRANTY; without even the implied warranty of
  19. # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  20. # General Public License for more details.
  21. #
  22. # You should have received a copy of the GNU General Public License
  23. # along with GNU Libtool; see the file COPYING. If not, a copy
  24. # can be downloaded from http://www.gnu.org/licenses/gpl.html,
  25. # or obtained by writing to the Free Software Foundation, Inc.,
  26. # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
  27. # Usage: $progname [OPTION]... [MODE-ARG]...
  28. #
  29. # Provide generalized library-building support services.
  30. #
  31. # --config show all configuration variables
  32. # --debug enable verbose shell tracing
  33. # -n, --dry-run display commands without modifying any files
  34. # --features display basic configuration information and exit
  35. # --mode=MODE use operation mode MODE
  36. # --preserve-dup-deps don't remove duplicate dependency libraries
  37. # --quiet, --silent don't print informational messages
  38. # --no-quiet, --no-silent
  39. # print informational messages (default)
  40. # --tag=TAG use configuration variables from tag TAG
  41. # -v, --verbose print more informational messages than default
  42. # --no-verbose don't print the extra informational messages
  43. # --version print version information
  44. # -h, --help, --help-all print short, long, or detailed help message
  45. #
  46. # MODE must be one of the following:
  47. #
  48. # clean remove files from the build directory
  49. # compile compile a source file into a libtool object
  50. # execute automatically set library path, then run a program
  51. # finish complete the installation of libtool libraries
  52. # install install libraries or executables
  53. # link create a library or an executable
  54. # uninstall remove libraries from an installed directory
  55. #
  56. # MODE-ARGS vary depending on the MODE. When passed as first option,
  57. # `--mode=MODE' may be abbreviated as `MODE' or a unique abbreviation of that.
  58. # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
  59. #
  60. # When reporting a bug, please describe a test case to reproduce it and
  61. # include the following information:
  62. #
  63. # host-triplet: $host
  64. # shell: $SHELL
  65. # compiler: $LTCC
  66. # compiler flags: $LTCFLAGS
  67. # linker: $LD (gnu? $with_gnu_ld)
  68. # $progname: (GNU libtool) 2.4
  69. # automake: $automake_version
  70. # autoconf: $autoconf_version
  71. #
  72. # Report bugs to <bug-libtool@gnu.org>.
  73. # GNU libtool home page: <http://www.gnu.org/software/libtool/>.
  74. # General help using GNU software: <http://www.gnu.org/gethelp/>.
  75. PROGRAM=libtool
  76. PACKAGE=libtool
  77. VERSION=2.4
  78. TIMESTAMP=""
  79. package_revision=1.3293
  80. # Be Bourne compatible
  81. if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
  82. emulate sh
  83. NULLCMD=:
  84. # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
  85. # is contrary to our usage. Disable this feature.
  86. alias -g '${1+"$@"}'='"$@"'
  87. setopt NO_GLOB_SUBST
  88. else
  89. case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
  90. fi
  91. BIN_SH=xpg4; export BIN_SH # for Tru64
  92. DUALCASE=1; export DUALCASE # for MKS sh
  93. # A function that is used when there is no print builtin or printf.
  94. func_fallback_echo ()
  95. {
  96. eval 'cat <<_LTECHO_EOF
  97. $1
  98. _LTECHO_EOF'
  99. }
  100. # NLS nuisances: We save the old values to restore during execute mode.
  101. lt_user_locale=
  102. lt_safe_locale=
  103. for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
  104. do
  105. eval "if test \"\${$lt_var+set}\" = set; then
  106. save_$lt_var=\$$lt_var
  107. $lt_var=C
  108. export $lt_var
  109. lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
  110. lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
  111. fi"
  112. done
  113. LC_ALL=C
  114. LANGUAGE=C
  115. export LANGUAGE LC_ALL
  116. $lt_unset CDPATH
  117. # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
  118. # is ksh but when the shell is invoked as "sh" and the current value of
  119. # the _XPG environment variable is not equal to 1 (one), the special
  120. # positional parameter $0, within a function call, is the name of the
  121. # function.
  122. progpath="$0"
  123. : ${CP="cp -f"}
  124. test "${ECHO+set}" = set || ECHO=${as_echo-'printf %s\n'}
  125. : ${EGREP="grep -E"}
  126. : ${FGREP="grep -F"}
  127. : ${GREP="grep"}
  128. : ${LN_S="ln -s"}
  129. : ${MAKE="make"}
  130. : ${MKDIR="mkdir"}
  131. : ${MV="mv -f"}
  132. : ${RM="rm -f"}
  133. : ${SED="sed"}
  134. : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
  135. : ${Xsed="$SED -e 1s/^X//"}
  136. # Global variables:
  137. EXIT_SUCCESS=0
  138. EXIT_FAILURE=1
  139. EXIT_MISMATCH=63 # $? = 63 is used to indicate version mismatch to missing.
  140. EXIT_SKIP=77 # $? = 77 is used to indicate a skipped test to automake.
  141. exit_status=$EXIT_SUCCESS
  142. # Make sure IFS has a sensible default
  143. lt_nl='
  144. '
  145. IFS=" $lt_nl"
  146. dirname="s,/[^/]*$,,"
  147. basename="s,^.*/,,"
  148. # func_dirname file append nondir_replacement
  149. # Compute the dirname of FILE. If nonempty, add APPEND to the result,
  150. # otherwise set result to NONDIR_REPLACEMENT.
  151. func_dirname ()
  152. {
  153. func_dirname_result=`$ECHO "${1}" | $SED "$dirname"`
  154. if test "X$func_dirname_result" = "X${1}"; then
  155. func_dirname_result="${3}"
  156. else
  157. func_dirname_result="$func_dirname_result${2}"
  158. fi
  159. } # func_dirname may be replaced by extended shell implementation
  160. # func_basename file
  161. func_basename ()
  162. {
  163. func_basename_result=`$ECHO "${1}" | $SED "$basename"`
  164. } # func_basename may be replaced by extended shell implementation
  165. # func_dirname_and_basename file append nondir_replacement
  166. # perform func_basename and func_dirname in a single function
  167. # call:
  168. # dirname: Compute the dirname of FILE. If nonempty,
  169. # add APPEND to the result, otherwise set result
  170. # to NONDIR_REPLACEMENT.
  171. # value returned in "$func_dirname_result"
  172. # basename: Compute filename of FILE.
  173. # value retuned in "$func_basename_result"
  174. # Implementation must be kept synchronized with func_dirname
  175. # and func_basename. For efficiency, we do not delegate to
  176. # those functions but instead duplicate the functionality here.
  177. func_dirname_and_basename ()
  178. {
  179. # Extract subdirectory from the argument.
  180. func_dirname_result=`$ECHO "${1}" | $SED -e "$dirname"`
  181. if test "X$func_dirname_result" = "X${1}"; then
  182. func_dirname_result="${3}"
  183. else
  184. func_dirname_result="$func_dirname_result${2}"
  185. fi
  186. func_basename_result=`$ECHO "${1}" | $SED -e "$basename"`
  187. } # func_dirname_and_basename may be replaced by extended shell implementation
  188. # func_stripname prefix suffix name
  189. # strip PREFIX and SUFFIX off of NAME.
  190. # PREFIX and SUFFIX must not contain globbing or regex special
  191. # characters, hashes, percent signs, but SUFFIX may contain a leading
  192. # dot (in which case that matches only a dot).
  193. # func_strip_suffix prefix name
  194. func_stripname ()
  195. {
  196. case ${2} in
  197. .*) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%\\\\${2}\$%%"`;;
  198. *) func_stripname_result=`$ECHO "${3}" | $SED "s%^${1}%%; s%${2}\$%%"`;;
  199. esac
  200. } # func_stripname may be replaced by extended shell implementation
  201. # These SED scripts presuppose an absolute path with a trailing slash.
  202. pathcar='s,^/\([^/]*\).*$,\1,'
  203. pathcdr='s,^/[^/]*,,'
  204. removedotparts=':dotsl
  205. s@/\./@/@g
  206. t dotsl
  207. s,/\.$,/,'
  208. collapseslashes='s@/\{1,\}@/@g'
  209. finalslash='s,/*$,/,'
  210. # func_normal_abspath PATH
  211. # Remove doubled-up and trailing slashes, "." path components,
  212. # and cancel out any ".." path components in PATH after making
  213. # it an absolute path.
  214. # value returned in "$func_normal_abspath_result"
  215. func_normal_abspath ()
  216. {
  217. # Start from root dir and reassemble the path.
  218. func_normal_abspath_result=
  219. func_normal_abspath_tpath=$1
  220. func_normal_abspath_altnamespace=
  221. case $func_normal_abspath_tpath in
  222. "")
  223. # Empty path, that just means $cwd.
  224. func_stripname '' '/' "`pwd`"
  225. func_normal_abspath_result=$func_stripname_result
  226. return
  227. ;;
  228. # The next three entries are used to spot a run of precisely
  229. # two leading slashes without using negated character classes;
  230. # we take advantage of case's first-match behaviour.
  231. ///*)
  232. # Unusual form of absolute path, do nothing.
  233. ;;
  234. //*)
  235. # Not necessarily an ordinary path; POSIX reserves leading '//'
  236. # and for example Cygwin uses it to access remote file shares
  237. # over CIFS/SMB, so we conserve a leading double slash if found.
  238. func_normal_abspath_altnamespace=/
  239. ;;
  240. /*)
  241. # Absolute path, do nothing.
  242. ;;
  243. *)
  244. # Relative path, prepend $cwd.
  245. func_normal_abspath_tpath=`pwd`/$func_normal_abspath_tpath
  246. ;;
  247. esac
  248. # Cancel out all the simple stuff to save iterations. We also want
  249. # the path to end with a slash for ease of parsing, so make sure
  250. # there is one (and only one) here.
  251. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
  252. -e "$removedotparts" -e "$collapseslashes" -e "$finalslash"`
  253. while :; do
  254. # Processed it all yet?
  255. if test "$func_normal_abspath_tpath" = / ; then
  256. # If we ascended to the root using ".." the result may be empty now.
  257. if test -z "$func_normal_abspath_result" ; then
  258. func_normal_abspath_result=/
  259. fi
  260. break
  261. fi
  262. func_normal_abspath_tcomponent=`$ECHO "$func_normal_abspath_tpath" | $SED \
  263. -e "$pathcar"`
  264. func_normal_abspath_tpath=`$ECHO "$func_normal_abspath_tpath" | $SED \
  265. -e "$pathcdr"`
  266. # Figure out what to do with it
  267. case $func_normal_abspath_tcomponent in
  268. "")
  269. # Trailing empty path component, ignore it.
  270. ;;
  271. ..)
  272. # Parent dir; strip last assembled component from result.
  273. func_dirname "$func_normal_abspath_result"
  274. func_normal_abspath_result=$func_dirname_result
  275. ;;
  276. *)
  277. # Actual path component, append it.
  278. func_normal_abspath_result=$func_normal_abspath_result/$func_normal_abspath_tcomponent
  279. ;;
  280. esac
  281. done
  282. # Restore leading double-slash if one was found on entry.
  283. func_normal_abspath_result=$func_normal_abspath_altnamespace$func_normal_abspath_result
  284. }
  285. # func_relative_path SRCDIR DSTDIR
  286. # generates a relative path from SRCDIR to DSTDIR, with a trailing
  287. # slash if non-empty, suitable for immediately appending a filename
  288. # without needing to append a separator.
  289. # value returned in "$func_relative_path_result"
  290. func_relative_path ()
  291. {
  292. func_relative_path_result=
  293. func_normal_abspath "$1"
  294. func_relative_path_tlibdir=$func_normal_abspath_result
  295. func_normal_abspath "$2"
  296. func_relative_path_tbindir=$func_normal_abspath_result
  297. # Ascend the tree starting from libdir
  298. while :; do
  299. # check if we have found a prefix of bindir
  300. case $func_relative_path_tbindir in
  301. $func_relative_path_tlibdir)
  302. # found an exact match
  303. func_relative_path_tcancelled=
  304. break
  305. ;;
  306. $func_relative_path_tlibdir*)
  307. # found a matching prefix
  308. func_stripname "$func_relative_path_tlibdir" '' "$func_relative_path_tbindir"
  309. func_relative_path_tcancelled=$func_stripname_result
  310. if test -z "$func_relative_path_result"; then
  311. func_relative_path_result=.
  312. fi
  313. break
  314. ;;
  315. *)
  316. func_dirname $func_relative_path_tlibdir
  317. func_relative_path_tlibdir=${func_dirname_result}
  318. if test "x$func_relative_path_tlibdir" = x ; then
  319. # Have to descend all the way to the root!
  320. func_relative_path_result=../$func_relative_path_result
  321. func_relative_path_tcancelled=$func_relative_path_tbindir
  322. break
  323. fi
  324. func_relative_path_result=../$func_relative_path_result
  325. ;;
  326. esac
  327. done
  328. # Now calculate path; take care to avoid doubling-up slashes.
  329. func_stripname '' '/' "$func_relative_path_result"
  330. func_relative_path_result=$func_stripname_result
  331. func_stripname '/' '/' "$func_relative_path_tcancelled"
  332. if test "x$func_stripname_result" != x ; then
  333. func_relative_path_result=${func_relative_path_result}/${func_stripname_result}
  334. fi
  335. # Normalisation. If bindir is libdir, return empty string,
  336. # else relative path ending with a slash; either way, target
  337. # file name can be directly appended.
  338. if test ! -z "$func_relative_path_result"; then
  339. func_stripname './' '' "$func_relative_path_result/"
  340. func_relative_path_result=$func_stripname_result
  341. fi
  342. }
  343. # The name of this program:
  344. func_dirname_and_basename "$progpath"
  345. progname=$func_basename_result
  346. # Make sure we have an absolute path for reexecution:
  347. case $progpath in
  348. [\\/]*|[A-Za-z]:\\*) ;;
  349. *[\\/]*)
  350. progdir=$func_dirname_result
  351. progdir=`cd "$progdir" && pwd`
  352. progpath="$progdir/$progname"
  353. ;;
  354. *)
  355. save_IFS="$IFS"
  356. IFS=:
  357. for progdir in $PATH; do
  358. IFS="$save_IFS"
  359. test -x "$progdir/$progname" && break
  360. done
  361. IFS="$save_IFS"
  362. test -n "$progdir" || progdir=`pwd`
  363. progpath="$progdir/$progname"
  364. ;;
  365. esac
  366. # Sed substitution that helps us do robust quoting. It backslashifies
  367. # metacharacters that are still active within double-quoted strings.
  368. Xsed="${SED}"' -e 1s/^X//'
  369. sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
  370. # Same as above, but do not quote variable references.
  371. double_quote_subst='s/\(["`\\]\)/\\\1/g'
  372. # Sed substitution that turns a string into a regex matching for the
  373. # string literally.
  374. sed_make_literal_regex='s,[].[^$\\*\/],\\&,g'
  375. # Sed substitution that converts a w32 file name or path
  376. # which contains forward slashes, into one that contains
  377. # (escaped) backslashes. A very naive implementation.
  378. lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
  379. # Re-`\' parameter expansions in output of double_quote_subst that were
  380. # `\'-ed in input to the same. If an odd number of `\' preceded a '$'
  381. # in input to double_quote_subst, that '$' was protected from expansion.
  382. # Since each input `\' is now two `\'s, look for any number of runs of
  383. # four `\'s followed by two `\'s and then a '$'. `\' that '$'.
  384. bs='\\'
  385. bs2='\\\\'
  386. bs4='\\\\\\\\'
  387. dollar='\$'
  388. sed_double_backslash="\
  389. s/$bs4/&\\
  390. /g
  391. s/^$bs2$dollar/$bs&/
  392. s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
  393. s/\n//g"
  394. # Standard options:
  395. opt_dry_run=false
  396. opt_help=false
  397. opt_quiet=false
  398. opt_verbose=false
  399. opt_warning=:
  400. # func_echo arg...
  401. # Echo program name prefixed message, along with the current mode
  402. # name if it has been set yet.
  403. func_echo ()
  404. {
  405. $ECHO "$progname: ${opt_mode+$opt_mode: }$*"
  406. }
  407. # func_verbose arg...
  408. # Echo program name prefixed message in verbose mode only.
  409. func_verbose ()
  410. {
  411. $opt_verbose && func_echo ${1+"$@"}
  412. # A bug in bash halts the script if the last line of a function
  413. # fails when set -e is in force, so we need another command to
  414. # work around that:
  415. :
  416. }
  417. # func_echo_all arg...
  418. # Invoke $ECHO with all args, space-separated.
  419. func_echo_all ()
  420. {
  421. $ECHO "$*"
  422. }
  423. # func_error arg...
  424. # Echo program name prefixed message to standard error.
  425. func_error ()
  426. {
  427. $ECHO "$progname: ${opt_mode+$opt_mode: }"${1+"$@"} 1>&2
  428. }
  429. # func_warning arg...
  430. # Echo program name prefixed warning message to standard error.
  431. func_warning ()
  432. {
  433. $opt_warning && $ECHO "$progname: ${opt_mode+$opt_mode: }warning: "${1+"$@"} 1>&2
  434. # bash bug again:
  435. :
  436. }
  437. # func_fatal_error arg...
  438. # Echo program name prefixed message to standard error, and exit.
  439. func_fatal_error ()
  440. {
  441. func_error ${1+"$@"}
  442. exit $EXIT_FAILURE
  443. }
  444. # func_fatal_help arg...
  445. # Echo program name prefixed message to standard error, followed by
  446. # a help hint, and exit.
  447. func_fatal_help ()
  448. {
  449. func_error ${1+"$@"}
  450. func_fatal_error "$help"
  451. }
  452. help="Try \`$progname --help' for more information." ## default
  453. # func_grep expression filename
  454. # Check whether EXPRESSION matches any line of FILENAME, without output.
  455. func_grep ()
  456. {
  457. $GREP "$1" "$2" >/dev/null 2>&1
  458. }
  459. # func_mkdir_p directory-path
  460. # Make sure the entire path to DIRECTORY-PATH is available.
  461. func_mkdir_p ()
  462. {
  463. my_directory_path="$1"
  464. my_dir_list=
  465. if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
  466. # Protect directory names starting with `-'
  467. case $my_directory_path in
  468. -*) my_directory_path="./$my_directory_path" ;;
  469. esac
  470. # While some portion of DIR does not yet exist...
  471. while test ! -d "$my_directory_path"; do
  472. # ...make a list in topmost first order. Use a colon delimited
  473. # list incase some portion of path contains whitespace.
  474. my_dir_list="$my_directory_path:$my_dir_list"
  475. # If the last portion added has no slash in it, the list is done
  476. case $my_directory_path in */*) ;; *) break ;; esac
  477. # ...otherwise throw away the child directory and loop
  478. my_directory_path=`$ECHO "$my_directory_path" | $SED -e "$dirname"`
  479. done
  480. my_dir_list=`$ECHO "$my_dir_list" | $SED 's,:*$,,'`
  481. save_mkdir_p_IFS="$IFS"; IFS=':'
  482. for my_dir in $my_dir_list; do
  483. IFS="$save_mkdir_p_IFS"
  484. # mkdir can fail with a `File exist' error if two processes
  485. # try to create one of the directories concurrently. Don't
  486. # stop in that case!
  487. $MKDIR "$my_dir" 2>/dev/null || :
  488. done
  489. IFS="$save_mkdir_p_IFS"
  490. # Bail out if we (or some other process) failed to create a directory.
  491. test -d "$my_directory_path" || \
  492. func_fatal_error "Failed to create \`$1'"
  493. fi
  494. }
  495. # func_mktempdir [string]
  496. # Make a temporary directory that won't clash with other running
  497. # libtool processes, and avoids race conditions if possible. If
  498. # given, STRING is the basename for that directory.
  499. func_mktempdir ()
  500. {
  501. my_template="${TMPDIR-/tmp}/${1-$progname}"
  502. if test "$opt_dry_run" = ":"; then
  503. # Return a directory name, but don't create it in dry-run mode
  504. my_tmpdir="${my_template}-$$"
  505. else
  506. # If mktemp works, use that first and foremost
  507. my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
  508. if test ! -d "$my_tmpdir"; then
  509. # Failing that, at least try and use $RANDOM to avoid a race
  510. my_tmpdir="${my_template}-${RANDOM-0}$$"
  511. save_mktempdir_umask=`umask`
  512. umask 0077
  513. $MKDIR "$my_tmpdir"
  514. umask $save_mktempdir_umask
  515. fi
  516. # If we're not in dry-run mode, bomb out on failure
  517. test -d "$my_tmpdir" || \
  518. func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
  519. fi
  520. $ECHO "$my_tmpdir"
  521. }
  522. # func_quote_for_eval arg
  523. # Aesthetically quote ARG to be evaled later.
  524. # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
  525. # is double-quoted, suitable for a subsequent eval, whereas
  526. # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
  527. # which are still active within double quotes backslashified.
  528. func_quote_for_eval ()
  529. {
  530. case $1 in
  531. *[\\\`\"\$]*)
  532. func_quote_for_eval_unquoted_result=`$ECHO "$1" | $SED "$sed_quote_subst"` ;;
  533. *)
  534. func_quote_for_eval_unquoted_result="$1" ;;
  535. esac
  536. case $func_quote_for_eval_unquoted_result in
  537. # Double-quote args containing shell metacharacters to delay
  538. # word splitting, command substitution and and variable
  539. # expansion for a subsequent eval.
  540. # Many Bourne shells cannot handle close brackets correctly
  541. # in scan sets, so we specify it separately.
  542. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  543. func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
  544. ;;
  545. *)
  546. func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
  547. esac
  548. }
  549. # func_quote_for_expand arg
  550. # Aesthetically quote ARG to be evaled later; same as above,
  551. # but do not quote variable references.
  552. func_quote_for_expand ()
  553. {
  554. case $1 in
  555. *[\\\`\"]*)
  556. my_arg=`$ECHO "$1" | $SED \
  557. -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
  558. *)
  559. my_arg="$1" ;;
  560. esac
  561. case $my_arg in
  562. # Double-quote args containing shell metacharacters to delay
  563. # word splitting and command substitution for a subsequent eval.
  564. # Many Bourne shells cannot handle close brackets correctly
  565. # in scan sets, so we specify it separately.
  566. *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
  567. my_arg="\"$my_arg\""
  568. ;;
  569. esac
  570. func_quote_for_expand_result="$my_arg"
  571. }
  572. # func_show_eval cmd [fail_exp]
  573. # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
  574. # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
  575. # is given, then evaluate it.
  576. func_show_eval ()
  577. {
  578. my_cmd="$1"
  579. my_fail_exp="${2-:}"
  580. ${opt_silent-false} || {
  581. func_quote_for_expand "$my_cmd"
  582. eval "func_echo $func_quote_for_expand_result"
  583. }
  584. if ${opt_dry_run-false}; then :; else
  585. eval "$my_cmd"
  586. my_status=$?
  587. if test "$my_status" -eq 0; then :; else
  588. eval "(exit $my_status); $my_fail_exp"
  589. fi
  590. fi
  591. }
  592. # func_show_eval_locale cmd [fail_exp]
  593. # Unless opt_silent is true, then output CMD. Then, if opt_dryrun is
  594. # not true, evaluate CMD. If the evaluation of CMD fails, and FAIL_EXP
  595. # is given, then evaluate it. Use the saved locale for evaluation.
  596. func_show_eval_locale ()
  597. {
  598. my_cmd="$1"
  599. my_fail_exp="${2-:}"
  600. ${opt_silent-false} || {
  601. func_quote_for_expand "$my_cmd"
  602. eval "func_echo $func_quote_for_expand_result"
  603. }
  604. if ${opt_dry_run-false}; then :; else
  605. eval "$lt_user_locale
  606. $my_cmd"
  607. my_status=$?
  608. eval "$lt_safe_locale"
  609. if test "$my_status" -eq 0; then :; else
  610. eval "(exit $my_status); $my_fail_exp"
  611. fi
  612. fi
  613. }
  614. # func_tr_sh
  615. # Turn $1 into a string suitable for a shell variable name.
  616. # Result is stored in $func_tr_sh_result. All characters
  617. # not in the set a-zA-Z0-9_ are replaced with '_'. Further,
  618. # if $1 begins with a digit, a '_' is prepended as well.
  619. func_tr_sh ()
  620. {
  621. case $1 in
  622. [0-9]* | *[!a-zA-Z0-9_]*)
  623. func_tr_sh_result=`$ECHO "$1" | $SED 's/^\([0-9]\)/_\1/; s/[^a-zA-Z0-9_]/_/g'`
  624. ;;
  625. * )
  626. func_tr_sh_result=$1
  627. ;;
  628. esac
  629. }
  630. # func_version
  631. # Echo version message to standard output and exit.
  632. func_version ()
  633. {
  634. $opt_debug
  635. $SED -n '/(C)/!b go
  636. :more
  637. /\./!{
  638. N
  639. s/\n# / /
  640. b more
  641. }
  642. :go
  643. /^# '$PROGRAM' (GNU /,/# warranty; / {
  644. s/^# //
  645. s/^# *$//
  646. s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
  647. p
  648. }' < "$progpath"
  649. exit $?
  650. }
  651. # func_usage
  652. # Echo short help message to standard output and exit.
  653. func_usage ()
  654. {
  655. $opt_debug
  656. $SED -n '/^# Usage:/,/^# *.*--help/ {
  657. s/^# //
  658. s/^# *$//
  659. s/\$progname/'$progname'/
  660. p
  661. }' < "$progpath"
  662. echo
  663. $ECHO "run \`$progname --help | more' for full usage"
  664. exit $?
  665. }
  666. # func_help [NOEXIT]
  667. # Echo long help message to standard output and exit,
  668. # unless 'noexit' is passed as argument.
  669. func_help ()
  670. {
  671. $opt_debug
  672. $SED -n '/^# Usage:/,/# Report bugs to/ {
  673. :print
  674. s/^# //
  675. s/^# *$//
  676. s*\$progname*'$progname'*
  677. s*\$host*'"$host"'*
  678. s*\$SHELL*'"$SHELL"'*
  679. s*\$LTCC*'"$LTCC"'*
  680. s*\$LTCFLAGS*'"$LTCFLAGS"'*
  681. s*\$LD*'"$LD"'*
  682. s/\$with_gnu_ld/'"$with_gnu_ld"'/
  683. s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
  684. s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
  685. p
  686. d
  687. }
  688. /^# .* home page:/b print
  689. /^# General help using/b print
  690. ' < "$progpath"
  691. ret=$?
  692. if test -z "$1"; then
  693. exit $ret
  694. fi
  695. }
  696. # func_missing_arg argname
  697. # Echo program name prefixed message to standard error and set global
  698. # exit_cmd.
  699. func_missing_arg ()
  700. {
  701. $opt_debug
  702. func_error "missing argument for $1."
  703. exit_cmd=exit
  704. }
  705. # func_split_short_opt shortopt
  706. # Set func_split_short_opt_name and func_split_short_opt_arg shell
  707. # variables after splitting SHORTOPT after the 2nd character.
  708. func_split_short_opt ()
  709. {
  710. my_sed_short_opt='1s/^\(..\).*$/\1/;q'
  711. my_sed_short_rest='1s/^..\(.*\)$/\1/;q'
  712. func_split_short_opt_name=`$ECHO "$1" | $SED "$my_sed_short_opt"`
  713. func_split_short_opt_arg=`$ECHO "$1" | $SED "$my_sed_short_rest"`
  714. } # func_split_short_opt may be replaced by extended shell implementation
  715. # func_split_long_opt longopt
  716. # Set func_split_long_opt_name and func_split_long_opt_arg shell
  717. # variables after splitting LONGOPT at the `=' sign.
  718. func_split_long_opt ()
  719. {
  720. my_sed_long_opt='1s/^\(--[^=]*\)=.*/\1/;q'
  721. my_sed_long_arg='1s/^--[^=]*=//'
  722. func_split_long_opt_name=`$ECHO "$1" | $SED "$my_sed_long_opt"`
  723. func_split_long_opt_arg=`$ECHO "$1" | $SED "$my_sed_long_arg"`
  724. } # func_split_long_opt may be replaced by extended shell implementation
  725. exit_cmd=:
  726. magic="%%%MAGIC variable%%%"
  727. magic_exe="%%%MAGIC EXE variable%%%"
  728. # Global variables.
  729. nonopt=
  730. preserve_args=
  731. lo2o="s/\\.lo\$/.${objext}/"
  732. o2lo="s/\\.${objext}\$/.lo/"
  733. extracted_archives=
  734. extracted_serial=0
  735. # If this variable is set in any of the actions, the command in it
  736. # will be execed at the end. This prevents here-documents from being
  737. # left over by shells.
  738. exec_cmd=
  739. # func_append var value
  740. # Append VALUE to the end of shell variable VAR.
  741. func_append ()
  742. {
  743. eval "${1}=\$${1}\${2}"
  744. } # func_append may be replaced by extended shell implementation
  745. # func_append_quoted var value
  746. # Quote VALUE and append to the end of shell variable VAR, separated
  747. # by a space.
  748. func_append_quoted ()
  749. {
  750. func_quote_for_eval "${2}"
  751. eval "${1}=\$${1}\\ \$func_quote_for_eval_result"
  752. } # func_append_quoted may be replaced by extended shell implementation
  753. # func_arith arithmetic-term...
  754. func_arith ()
  755. {
  756. func_arith_result=`expr "${@}"`
  757. } # func_arith may be replaced by extended shell implementation
  758. # func_len string
  759. # STRING may not start with a hyphen.
  760. func_len ()
  761. {
  762. func_len_result=`expr "${1}" : ".*" 2>/dev/null || echo $max_cmd_len`
  763. } # func_len may be replaced by extended shell implementation
  764. # func_lo2o object
  765. func_lo2o ()
  766. {
  767. func_lo2o_result=`$ECHO "${1}" | $SED "$lo2o"`
  768. } # func_lo2o may be replaced by extended shell implementation
  769. # func_xform libobj-or-source
  770. func_xform ()
  771. {
  772. func_xform_result=`$ECHO "${1}" | $SED 's/\.[^.]*$/.lo/'`
  773. } # func_xform may be replaced by extended shell implementation
  774. # func_fatal_configuration arg...
  775. # Echo program name prefixed message to standard error, followed by
  776. # a configuration failure hint, and exit.
  777. func_fatal_configuration ()
  778. {
  779. func_error ${1+"$@"}
  780. func_error "See the $PACKAGE documentation for more information."
  781. func_fatal_error "Fatal configuration error."
  782. }
  783. # func_config
  784. # Display the configuration for all the tags in this script.
  785. func_config ()
  786. {
  787. re_begincf='^# ### BEGIN LIBTOOL'
  788. re_endcf='^# ### END LIBTOOL'
  789. # Default configuration.
  790. $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
  791. # Now print the configurations for the tags.
  792. for tagname in $taglist; do
  793. $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
  794. done
  795. exit $?
  796. }
  797. # func_features
  798. # Display the features supported by this script.
  799. func_features ()
  800. {
  801. echo "host: $host"
  802. if test "$build_libtool_libs" = yes; then
  803. echo "enable shared libraries"
  804. else
  805. echo "disable shared libraries"
  806. fi
  807. if test "$build_old_libs" = yes; then
  808. echo "enable static libraries"
  809. else
  810. echo "disable static libraries"
  811. fi
  812. exit $?
  813. }
  814. # func_enable_tag tagname
  815. # Verify that TAGNAME is valid, and either flag an error and exit, or
  816. # enable the TAGNAME tag. We also add TAGNAME to the global $taglist
  817. # variable here.
  818. func_enable_tag ()
  819. {
  820. # Global variable:
  821. tagname="$1"
  822. re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
  823. re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
  824. sed_extractcf="/$re_begincf/,/$re_endcf/p"
  825. # Validate tagname.
  826. case $tagname in
  827. *[!-_A-Za-z0-9,/]*)
  828. func_fatal_error "invalid tag name: $tagname"
  829. ;;
  830. esac
  831. # Don't test for the "default" C tag, as we know it's
  832. # there but not specially marked.
  833. case $tagname in
  834. CC) ;;
  835. *)
  836. if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
  837. taglist="$taglist $tagname"
  838. # Evaluate the configuration. Be careful to quote the path
  839. # and the sed script, to avoid splitting on whitespace, but
  840. # also don't use non-portable quotes within backquotes within
  841. # quotes we have to do it in 2 steps:
  842. extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
  843. eval "$extractedcf"
  844. else
  845. func_error "ignoring unknown tag $tagname"
  846. fi
  847. ;;
  848. esac
  849. }
  850. # func_check_version_match
  851. # Ensure that we are using m4 macros, and libtool script from the same
  852. # release of libtool.
  853. func_check_version_match ()
  854. {
  855. if test "$package_revision" != "$macro_revision"; then
  856. if test "$VERSION" != "$macro_version"; then
  857. if test -z "$macro_version"; then
  858. cat >&2 <<_LT_EOF
  859. $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
  860. $progname: definition of this LT_INIT comes from an older release.
  861. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
  862. $progname: and run autoconf again.
  863. _LT_EOF
  864. else
  865. cat >&2 <<_LT_EOF
  866. $progname: Version mismatch error. This is $PACKAGE $VERSION, but the
  867. $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
  868. $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
  869. $progname: and run autoconf again.
  870. _LT_EOF
  871. fi
  872. else
  873. cat >&2 <<_LT_EOF
  874. $progname: Version mismatch error. This is $PACKAGE $VERSION, revision $package_revision,
  875. $progname: but the definition of this LT_INIT comes from revision $macro_revision.
  876. $progname: You should recreate aclocal.m4 with macros from revision $package_revision
  877. $progname: of $PACKAGE $VERSION and run autoconf again.
  878. _LT_EOF
  879. fi
  880. exit $EXIT_MISMATCH
  881. fi
  882. }
  883. # Shorthand for --mode=foo, only valid as the first argument
  884. case $1 in
  885. clean|clea|cle|cl)
  886. shift; set dummy --mode clean ${1+"$@"}; shift
  887. ;;
  888. compile|compil|compi|comp|com|co|c)
  889. shift; set dummy --mode compile ${1+"$@"}; shift
  890. ;;
  891. execute|execut|execu|exec|exe|ex|e)
  892. shift; set dummy --mode execute ${1+"$@"}; shift
  893. ;;
  894. finish|finis|fini|fin|fi|f)
  895. shift; set dummy --mode finish ${1+"$@"}; shift
  896. ;;
  897. install|instal|insta|inst|ins|in|i)
  898. shift; set dummy --mode install ${1+"$@"}; shift
  899. ;;
  900. link|lin|li|l)
  901. shift; set dummy --mode link ${1+"$@"}; shift
  902. ;;
  903. uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
  904. shift; set dummy --mode uninstall ${1+"$@"}; shift
  905. ;;
  906. esac
  907. # Option defaults:
  908. opt_debug=:
  909. opt_dry_run=false
  910. opt_config=false
  911. opt_preserve_dup_deps=false
  912. opt_features=false
  913. opt_finish=false
  914. opt_help=false
  915. opt_help_all=false
  916. opt_silent=:
  917. opt_verbose=:
  918. opt_silent=false
  919. opt_verbose=false
  920. # Parse options once, thoroughly. This comes as soon as possible in the
  921. # script to make things like `--version' happen as quickly as we can.
  922. {
  923. # this just eases exit handling
  924. while test $# -gt 0; do
  925. opt="$1"
  926. shift
  927. case $opt in
  928. --debug|-x) opt_debug='set -x'
  929. func_echo "enabling shell trace mode"
  930. $opt_debug
  931. ;;
  932. --dry-run|--dryrun|-n)
  933. opt_dry_run=:
  934. ;;
  935. --config)
  936. opt_config=:
  937. func_config
  938. ;;
  939. --dlopen|-dlopen)
  940. optarg="$1"
  941. opt_dlopen="${opt_dlopen+$opt_dlopen
  942. }$optarg"
  943. shift
  944. ;;
  945. --preserve-dup-deps)
  946. opt_preserve_dup_deps=:
  947. ;;
  948. --features)
  949. opt_features=:
  950. func_features
  951. ;;
  952. --finish)
  953. opt_finish=:
  954. set dummy --mode finish ${1+"$@"}; shift
  955. ;;
  956. --help)
  957. opt_help=:
  958. ;;
  959. --help-all)
  960. opt_help_all=:
  961. opt_help=': help-all'
  962. ;;
  963. --mode)
  964. test $# = 0 && func_missing_arg $opt && break
  965. optarg="$1"
  966. opt_mode="$optarg"
  967. case $optarg in
  968. # Valid mode arguments:
  969. clean|compile|execute|finish|install|link|relink|uninstall) ;;
  970. # Catch anything else as an error
  971. *) func_error "invalid argument for $opt"
  972. exit_cmd=exit
  973. break
  974. ;;
  975. esac
  976. shift
  977. ;;
  978. --no-silent|--no-quiet)
  979. opt_silent=false
  980. func_append preserve_args " $opt"
  981. ;;
  982. --no-verbose)
  983. opt_verbose=false
  984. func_append preserve_args " $opt"
  985. ;;
  986. --silent|--quiet)
  987. opt_silent=:
  988. func_append preserve_args " $opt"
  989. opt_verbose=false
  990. ;;
  991. --verbose|-v)
  992. opt_verbose=:
  993. func_append preserve_args " $opt"
  994. opt_silent=false
  995. ;;
  996. --tag)
  997. test $# = 0 && func_missing_arg $opt && break
  998. optarg="$1"
  999. opt_tag="$optarg"
  1000. func_append preserve_args " $opt $optarg"
  1001. func_enable_tag "$optarg"
  1002. shift
  1003. ;;
  1004. -\?|-h) func_usage ;;
  1005. --help) func_help ;;
  1006. --version) func_version ;;
  1007. # Separate optargs to long options:
  1008. --*=*)
  1009. func_split_long_opt "$opt"
  1010. set dummy "$func_split_long_opt_name" "$func_split_long_opt_arg" ${1+"$@"}
  1011. shift
  1012. ;;
  1013. # Separate non-argument short options:
  1014. -\?*|-h*|-n*|-v*)
  1015. func_split_short_opt "$opt"
  1016. set dummy "$func_split_short_opt_name" "-$func_split_short_opt_arg" ${1+"$@"}
  1017. shift
  1018. ;;
  1019. --) break ;;
  1020. -*) func_fatal_help "unrecognized option \`$opt'" ;;
  1021. *) set dummy "$opt" ${1+"$@"}; shift; break ;;
  1022. esac
  1023. done
  1024. # Validate options:
  1025. # save first non-option argument
  1026. if test "$#" -gt 0; then
  1027. nonopt="$opt"
  1028. shift
  1029. fi
  1030. # preserve --debug
  1031. test "$opt_debug" = : || func_append preserve_args " --debug"
  1032. case $host in
  1033. *cygwin* | *mingw* | *pw32* | *cegcc*)
  1034. # don't eliminate duplications in $postdeps and $predeps
  1035. opt_duplicate_compiler_generated_deps=:
  1036. ;;
  1037. *)
  1038. opt_duplicate_compiler_generated_deps=$opt_preserve_dup_deps
  1039. ;;
  1040. esac
  1041. $opt_help || {
  1042. # Sanity checks first:
  1043. func_check_version_match
  1044. if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
  1045. func_fatal_configuration "not configured to build any kind of library"
  1046. fi
  1047. # Darwin sucks
  1048. eval std_shrext=\"$shrext_cmds\"
  1049. # Only execute mode is allowed to have -dlopen flags.
  1050. if test -n "$opt_dlopen" && test "$opt_mode" != execute; then
  1051. func_error "unrecognized option \`-dlopen'"
  1052. $ECHO "$help" 1>&2
  1053. exit $EXIT_FAILURE
  1054. fi
  1055. # Change the help message to a mode-specific one.
  1056. generic_help="$help"
  1057. help="Try \`$progname --help --mode=$opt_mode' for more information."
  1058. }
  1059. # Bail if the options were screwed
  1060. $exit_cmd $EXIT_FAILURE
  1061. }
  1062. ## ----------- ##
  1063. ## Main. ##
  1064. ## ----------- ##
  1065. # func_lalib_p file
  1066. # True iff FILE is a libtool `.la' library or `.lo' object file.
  1067. # This function is only a basic sanity check; it will hardly flush out
  1068. # determined imposters.
  1069. func_lalib_p ()
  1070. {
  1071. test -f "$1" &&
  1072. $SED -e 4q "$1" 2>/dev/null \
  1073. | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
  1074. }
  1075. # func_lalib_unsafe_p file
  1076. # True iff FILE is a libtool `.la' library or `.lo' object file.
  1077. # This function implements the same check as func_lalib_p without
  1078. # resorting to external programs. To this end, it redirects stdin and
  1079. # closes it afterwards, without saving the original file descriptor.
  1080. # As a safety measure, use it only where a negative result would be
  1081. # fatal anyway. Works if `file' does not exist.
  1082. func_lalib_unsafe_p ()
  1083. {
  1084. lalib_p=no
  1085. if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
  1086. for lalib_p_l in 1 2 3 4
  1087. do
  1088. read lalib_p_line
  1089. case "$lalib_p_line" in
  1090. \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
  1091. esac
  1092. done
  1093. exec 0<&5 5<&-
  1094. fi
  1095. test "$lalib_p" = yes
  1096. }
  1097. # func_ltwrapper_script_p file
  1098. # True iff FILE is a libtool wrapper script
  1099. # This function is only a basic sanity check; it will hardly flush out
  1100. # determined imposters.
  1101. func_ltwrapper_script_p ()
  1102. {
  1103. func_lalib_p "$1"
  1104. }
  1105. # func_ltwrapper_executable_p file
  1106. # True iff FILE is a libtool wrapper executable
  1107. # This function is only a basic sanity check; it will hardly flush out
  1108. # determined imposters.
  1109. func_ltwrapper_executable_p ()
  1110. {
  1111. func_ltwrapper_exec_suffix=
  1112. case $1 in
  1113. *.exe) ;;
  1114. *) func_ltwrapper_exec_suffix=.exe ;;
  1115. esac
  1116. $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
  1117. }
  1118. # func_ltwrapper_scriptname file
  1119. # Assumes file is an ltwrapper_executable
  1120. # uses $file to determine the appropriate filename for a
  1121. # temporary ltwrapper_script.
  1122. func_ltwrapper_scriptname ()
  1123. {
  1124. func_dirname_and_basename "$1" "" "."
  1125. func_stripname '' '.exe' "$func_basename_result"
  1126. func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
  1127. }
  1128. # func_ltwrapper_p file
  1129. # True iff FILE is a libtool wrapper script or wrapper executable
  1130. # This function is only a basic sanity check; it will hardly flush out
  1131. # determined imposters.
  1132. func_ltwrapper_p ()
  1133. {
  1134. func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
  1135. }
  1136. # func_execute_cmds commands fail_cmd
  1137. # Execute tilde-delimited COMMANDS.
  1138. # If FAIL_CMD is given, eval that upon failure.
  1139. # FAIL_CMD may read-access the current command in variable CMD!
  1140. func_execute_cmds ()
  1141. {
  1142. $opt_debug
  1143. save_ifs=$IFS; IFS='~'
  1144. for cmd in $1; do
  1145. IFS=$save_ifs
  1146. eval cmd=\"$cmd\"
  1147. func_show_eval "$cmd" "${2-:}"
  1148. done
  1149. IFS=$save_ifs
  1150. }
  1151. # func_source file
  1152. # Source FILE, adding directory component if necessary.
  1153. # Note that it is not necessary on cygwin/mingw to append a dot to
  1154. # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
  1155. # behavior happens only for exec(3), not for open(2)! Also, sourcing
  1156. # `FILE.' does not work on cygwin managed mounts.
  1157. func_source ()
  1158. {
  1159. $opt_debug
  1160. case $1 in
  1161. */* | *\\*) . "$1" ;;
  1162. *) . "./$1" ;;
  1163. esac
  1164. }
  1165. # f