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