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