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