resetting manifest requested domain to floor
[platform/upstream/libasyncns.git] / ltmain.sh
1 # Generated from ltmain.m4sh.
2
3 # ltmain.sh (GNU libtool) 2.2.6
4 # Written by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
5
6 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004, 2005, 2006, 2007 2008 Free Software Foundation, Inc.
7 # This is free software; see the source for copying conditions.  There is NO
8 # warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
9
10 # GNU Libtool is free software; you can redistribute it and/or modify
11 # it under the terms of the GNU General Public License as published by
12 # the Free Software Foundation; either version 2 of the License, or
13 # (at your option) any later version.
14 #
15 # As a special exception to the GNU General Public License,
16 # if you distribute this file as part of a program or library that
17 # is built using GNU Libtool, you may include this file under the
18 # same distribution terms that you use for the rest of that program.
19 #
20 # GNU Libtool is distributed in the hope that it will be useful, but
21 # WITHOUT ANY WARRANTY; without even the implied warranty of
22 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
23 # General Public License for more details.
24 #
25 # You should have received a copy of the GNU General Public License
26 # along with GNU Libtool; see the file COPYING.  If not, a copy
27 # can be downloaded from http://www.gnu.org/licenses/gpl.html,
28 # or obtained by writing to the Free Software Foundation, Inc.,
29 # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
30
31 # Usage: $progname [OPTION]... [MODE-ARG]...
32 #
33 # Provide generalized library-building support services.
34 #
35 #     --config             show all configuration variables
36 #     --debug              enable verbose shell tracing
37 # -n, --dry-run            display commands without modifying any files
38 #     --features           display basic configuration information and exit
39 #     --mode=MODE          use operation mode MODE
40 #     --preserve-dup-deps  don't remove duplicate dependency libraries
41 #     --quiet, --silent    don't print informational messages
42 #     --tag=TAG            use configuration variables from tag TAG
43 # -v, --verbose            print informational messages (default)
44 #     --version            print version information
45 # -h, --help               print short or long help message
46 #
47 # MODE must be one of the following:
48 #
49 #       clean              remove files from the build directory
50 #       compile            compile a source file into a libtool object
51 #       execute            automatically set library path, then run a program
52 #       finish             complete the installation of libtool libraries
53 #       install            install libraries or executables
54 #       link               create a library or an executable
55 #       uninstall          remove libraries from an installed directory
56 #
57 # MODE-ARGS vary depending on the MODE.
58 # Try `$progname --help --mode=MODE' for a more detailed description of MODE.
59 #
60 # When reporting a bug, please describe a test case to reproduce it and
61 # include the following information:
62 #
63 #       host-triplet:   $host
64 #       shell:          $SHELL
65 #       compiler:               $LTCC
66 #       compiler flags:         $LTCFLAGS
67 #       linker:         $LD (gnu? $with_gnu_ld)
68 #       $progname:              (GNU libtool) 2.2.6
69 #       automake:               $automake_version
70 #       autoconf:               $autoconf_version
71 #
72 # Report bugs to <bug-libtool@gnu.org>.
73
74 PROGRAM=ltmain.sh
75 PACKAGE=libtool
76 VERSION=2.2.6
77 TIMESTAMP=""
78 package_revision=1.3012
79
80 # Be Bourne compatible
81 if test -n "${ZSH_VERSION+set}" && (emulate sh) >/dev/null 2>&1; then
82   emulate sh
83   NULLCMD=:
84   # Zsh 3.x and 4.x performs word splitting on ${1+"$@"}, which
85   # is contrary to our usage.  Disable this feature.
86   alias -g '${1+"$@"}'='"$@"'
87   setopt NO_GLOB_SUBST
88 else
89   case `(set -o) 2>/dev/null` in *posix*) set -o posix;; esac
90 fi
91 BIN_SH=xpg4; export BIN_SH # for Tru64
92 DUALCASE=1; export DUALCASE # for MKS sh
93
94 # NLS nuisances: We save the old values to restore during execute mode.
95 # Only set LANG and LC_ALL to C if already set.
96 # These must not be set unconditionally because not all systems understand
97 # e.g. LANG=C (notably SCO).
98 lt_user_locale=
99 lt_safe_locale=
100 for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
101 do
102   eval "if test \"\${$lt_var+set}\" = set; then
103           save_$lt_var=\$$lt_var
104           $lt_var=C
105           export $lt_var
106           lt_user_locale=\"$lt_var=\\\$save_\$lt_var; \$lt_user_locale\"
107           lt_safe_locale=\"$lt_var=C; \$lt_safe_locale\"
108         fi"
109 done
110
111 $lt_unset CDPATH
112
113
114
115
116
117 : ${CP="cp -f"}
118 : ${ECHO="echo"}
119 : ${EGREP="/bin/grep -E"}
120 : ${FGREP="/bin/grep -F"}
121 : ${GREP="/bin/grep"}
122 : ${LN_S="ln -s"}
123 : ${MAKE="make"}
124 : ${MKDIR="mkdir"}
125 : ${MV="mv -f"}
126 : ${RM="rm -f"}
127 : ${SED="/bin/sed"}
128 : ${SHELL="${CONFIG_SHELL-/bin/sh}"}
129 : ${Xsed="$SED -e 1s/^X//"}
130
131 # Global variables:
132 EXIT_SUCCESS=0
133 EXIT_FAILURE=1
134 EXIT_MISMATCH=63  # $? = 63 is used to indicate version mismatch to missing.
135 EXIT_SKIP=77      # $? = 77 is used to indicate a skipped test to automake.
136
137 exit_status=$EXIT_SUCCESS
138
139 # Make sure IFS has a sensible default
140 lt_nl='
141 '
142 IFS="   $lt_nl"
143
144 dirname="s,/[^/]*$,,"
145 basename="s,^.*/,,"
146
147 # func_dirname_and_basename file append nondir_replacement
148 # perform func_basename and func_dirname in a single function
149 # call:
150 #   dirname:  Compute the dirname of FILE.  If nonempty,
151 #             add APPEND to the result, otherwise set result
152 #             to NONDIR_REPLACEMENT.
153 #             value returned in "$func_dirname_result"
154 #   basename: Compute filename of FILE.
155 #             value retuned in "$func_basename_result"
156 # Implementation must be kept synchronized with func_dirname
157 # and func_basename. For efficiency, we do not delegate to
158 # those functions but instead duplicate the functionality here.
159 func_dirname_and_basename ()
160 {
161   # Extract subdirectory from the argument.
162   func_dirname_result=`$ECHO "X${1}" | $Xsed -e "$dirname"`
163   if test "X$func_dirname_result" = "X${1}"; then
164     func_dirname_result="${3}"
165   else
166     func_dirname_result="$func_dirname_result${2}"
167   fi
168   func_basename_result=`$ECHO "X${1}" | $Xsed -e "$basename"`
169 }
170
171 # Generated shell functions inserted here.
172
173 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
174 # is ksh but when the shell is invoked as "sh" and the current value of
175 # the _XPG environment variable is not equal to 1 (one), the special
176 # positional parameter $0, within a function call, is the name of the
177 # function.
178 progpath="$0"
179
180 # The name of this program:
181 # In the unlikely event $progname began with a '-', it would play havoc with
182 # func_echo (imagine progname=-n), so we prepend ./ in that case:
183 func_dirname_and_basename "$progpath"
184 progname=$func_basename_result
185 case $progname in
186   -*) progname=./$progname ;;
187 esac
188
189 # Make sure we have an absolute path for reexecution:
190 case $progpath in
191   [\\/]*|[A-Za-z]:\\*) ;;
192   *[\\/]*)
193      progdir=$func_dirname_result
194      progdir=`cd "$progdir" && pwd`
195      progpath="$progdir/$progname"
196      ;;
197   *)
198      save_IFS="$IFS"
199      IFS=:
200      for progdir in $PATH; do
201        IFS="$save_IFS"
202        test -x "$progdir/$progname" && break
203      done
204      IFS="$save_IFS"
205      test -n "$progdir" || progdir=`pwd`
206      progpath="$progdir/$progname"
207      ;;
208 esac
209
210 # Sed substitution that helps us do robust quoting.  It backslashifies
211 # metacharacters that are still active within double-quoted strings.
212 Xsed="${SED}"' -e 1s/^X//'
213 sed_quote_subst='s/\([`"$\\]\)/\\\1/g'
214
215 # Same as above, but do not quote variable references.
216 double_quote_subst='s/\(["`\\]\)/\\\1/g'
217
218 # Re-`\' parameter expansions in output of double_quote_subst that were
219 # `\'-ed in input to the same.  If an odd number of `\' preceded a '$'
220 # in input to double_quote_subst, that '$' was protected from expansion.
221 # Since each input `\' is now two `\'s, look for any number of runs of
222 # four `\'s followed by two `\'s and then a '$'.  `\' that '$'.
223 bs='\\'
224 bs2='\\\\'
225 bs4='\\\\\\\\'
226 dollar='\$'
227 sed_double_backslash="\
228   s/$bs4/&\\
229 /g
230   s/^$bs2$dollar/$bs&/
231   s/\\([^$bs]\\)$bs2$dollar/\\1$bs2$bs$dollar/g
232   s/\n//g"
233
234 # Standard options:
235 opt_dry_run=false
236 opt_help=false
237 opt_quiet=false
238 opt_verbose=false
239 opt_warning=:
240
241 # func_echo arg...
242 # Echo program name prefixed message, along with the current mode
243 # name if it has been set yet.
244 func_echo ()
245 {
246     $ECHO "$progname${mode+: }$mode: $*"
247 }
248
249 # func_verbose arg...
250 # Echo program name prefixed message in verbose mode only.
251 func_verbose ()
252 {
253     $opt_verbose && func_echo ${1+"$@"}
254
255     # A bug in bash halts the script if the last line of a function
256     # fails when set -e is in force, so we need another command to
257     # work around that:
258     :
259 }
260
261 # func_error arg...
262 # Echo program name prefixed message to standard error.
263 func_error ()
264 {
265     $ECHO "$progname${mode+: }$mode: "${1+"$@"} 1>&2
266 }
267
268 # func_warning arg...
269 # Echo program name prefixed warning message to standard error.
270 func_warning ()
271 {
272     $opt_warning && $ECHO "$progname${mode+: }$mode: warning: "${1+"$@"} 1>&2
273
274     # bash bug again:
275     :
276 }
277
278 # func_fatal_error arg...
279 # Echo program name prefixed message to standard error, and exit.
280 func_fatal_error ()
281 {
282     func_error ${1+"$@"}
283     exit $EXIT_FAILURE
284 }
285
286 # func_fatal_help arg...
287 # Echo program name prefixed message to standard error, followed by
288 # a help hint, and exit.
289 func_fatal_help ()
290 {
291     func_error ${1+"$@"}
292     func_fatal_error "$help"
293 }
294 help="Try \`$progname --help' for more information."  ## default
295
296
297 # func_grep expression filename
298 # Check whether EXPRESSION matches any line of FILENAME, without output.
299 func_grep ()
300 {
301     $GREP "$1" "$2" >/dev/null 2>&1
302 }
303
304
305 # func_mkdir_p directory-path
306 # Make sure the entire path to DIRECTORY-PATH is available.
307 func_mkdir_p ()
308 {
309     my_directory_path="$1"
310     my_dir_list=
311
312     if test -n "$my_directory_path" && test "$opt_dry_run" != ":"; then
313
314       # Protect directory names starting with `-'
315       case $my_directory_path in
316         -*) my_directory_path="./$my_directory_path" ;;
317       esac
318
319       # While some portion of DIR does not yet exist...
320       while test ! -d "$my_directory_path"; do
321         # ...make a list in topmost first order.  Use a colon delimited
322         # list incase some portion of path contains whitespace.
323         my_dir_list="$my_directory_path:$my_dir_list"
324
325         # If the last portion added has no slash in it, the list is done
326         case $my_directory_path in */*) ;; *) break ;; esac
327
328         # ...otherwise throw away the child directory and loop
329         my_directory_path=`$ECHO "X$my_directory_path" | $Xsed -e "$dirname"`
330       done
331       my_dir_list=`$ECHO "X$my_dir_list" | $Xsed -e 's,:*$,,'`
332
333       save_mkdir_p_IFS="$IFS"; IFS=':'
334       for my_dir in $my_dir_list; do
335         IFS="$save_mkdir_p_IFS"
336         # mkdir can fail with a `File exist' error if two processes
337         # try to create one of the directories concurrently.  Don't
338         # stop in that case!
339         $MKDIR "$my_dir" 2>/dev/null || :
340       done
341       IFS="$save_mkdir_p_IFS"
342
343       # Bail out if we (or some other process) failed to create a directory.
344       test -d "$my_directory_path" || \
345         func_fatal_error "Failed to create \`$1'"
346     fi
347 }
348
349
350 # func_mktempdir [string]
351 # Make a temporary directory that won't clash with other running
352 # libtool processes, and avoids race conditions if possible.  If
353 # given, STRING is the basename for that directory.
354 func_mktempdir ()
355 {
356     my_template="${TMPDIR-/tmp}/${1-$progname}"
357
358     if test "$opt_dry_run" = ":"; then
359       # Return a directory name, but don't create it in dry-run mode
360       my_tmpdir="${my_template}-$$"
361     else
362
363       # If mktemp works, use that first and foremost
364       my_tmpdir=`mktemp -d "${my_template}-XXXXXXXX" 2>/dev/null`
365
366       if test ! -d "$my_tmpdir"; then
367         # Failing that, at least try and use $RANDOM to avoid a race
368         my_tmpdir="${my_template}-${RANDOM-0}$$"
369
370         save_mktempdir_umask=`umask`
371         umask 0077
372         $MKDIR "$my_tmpdir"
373         umask $save_mktempdir_umask
374       fi
375
376       # If we're not in dry-run mode, bomb out on failure
377       test -d "$my_tmpdir" || \
378         func_fatal_error "cannot create temporary directory \`$my_tmpdir'"
379     fi
380
381     $ECHO "X$my_tmpdir" | $Xsed
382 }
383
384
385 # func_quote_for_eval arg
386 # Aesthetically quote ARG to be evaled later.
387 # This function returns two values: FUNC_QUOTE_FOR_EVAL_RESULT
388 # is double-quoted, suitable for a subsequent eval, whereas
389 # FUNC_QUOTE_FOR_EVAL_UNQUOTED_RESULT has merely all characters
390 # which are still active within double quotes backslashified.
391 func_quote_for_eval ()
392 {
393     case $1 in
394       *[\\\`\"\$]*)
395         func_quote_for_eval_unquoted_result=`$ECHO "X$1" | $Xsed -e "$sed_quote_subst"` ;;
396       *)
397         func_quote_for_eval_unquoted_result="$1" ;;
398     esac
399
400     case $func_quote_for_eval_unquoted_result in
401       # Double-quote args containing shell metacharacters to delay
402       # word splitting, command substitution and and variable
403       # expansion for a subsequent eval.
404       # Many Bourne shells cannot handle close brackets correctly
405       # in scan sets, so we specify it separately.
406       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
407         func_quote_for_eval_result="\"$func_quote_for_eval_unquoted_result\""
408         ;;
409       *)
410         func_quote_for_eval_result="$func_quote_for_eval_unquoted_result"
411     esac
412 }
413
414
415 # func_quote_for_expand arg
416 # Aesthetically quote ARG to be evaled later; same as above,
417 # but do not quote variable references.
418 func_quote_for_expand ()
419 {
420     case $1 in
421       *[\\\`\"]*)
422         my_arg=`$ECHO "X$1" | $Xsed \
423             -e "$double_quote_subst" -e "$sed_double_backslash"` ;;
424       *)
425         my_arg="$1" ;;
426     esac
427
428     case $my_arg in
429       # Double-quote args containing shell metacharacters to delay
430       # word splitting and command substitution for a subsequent eval.
431       # Many Bourne shells cannot handle close brackets correctly
432       # in scan sets, so we specify it separately.
433       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
434         my_arg="\"$my_arg\""
435         ;;
436     esac
437
438     func_quote_for_expand_result="$my_arg"
439 }
440
441
442 # func_show_eval cmd [fail_exp]
443 # Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
444 # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
445 # is given, then evaluate it.
446 func_show_eval ()
447 {
448     my_cmd="$1"
449     my_fail_exp="${2-:}"
450
451     ${opt_silent-false} || {
452       func_quote_for_expand "$my_cmd"
453       eval "func_echo $func_quote_for_expand_result"
454     }
455
456     if ${opt_dry_run-false}; then :; else
457       eval "$my_cmd"
458       my_status=$?
459       if test "$my_status" -eq 0; then :; else
460         eval "(exit $my_status); $my_fail_exp"
461       fi
462     fi
463 }
464
465
466 # func_show_eval_locale cmd [fail_exp]
467 # Unless opt_silent is true, then output CMD.  Then, if opt_dryrun is
468 # not true, evaluate CMD.  If the evaluation of CMD fails, and FAIL_EXP
469 # is given, then evaluate it.  Use the saved locale for evaluation.
470 func_show_eval_locale ()
471 {
472     my_cmd="$1"
473     my_fail_exp="${2-:}"
474
475     ${opt_silent-false} || {
476       func_quote_for_expand "$my_cmd"
477       eval "func_echo $func_quote_for_expand_result"
478     }
479
480     if ${opt_dry_run-false}; then :; else
481       eval "$lt_user_locale
482             $my_cmd"
483       my_status=$?
484       eval "$lt_safe_locale"
485       if test "$my_status" -eq 0; then :; else
486         eval "(exit $my_status); $my_fail_exp"
487       fi
488     fi
489 }
490
491
492
493
494
495 # func_version
496 # Echo version message to standard output and exit.
497 func_version ()
498 {
499     $SED -n '/^# '$PROGRAM' (GNU /,/# warranty; / {
500         s/^# //
501         s/^# *$//
502         s/\((C)\)[ 0-9,-]*\( [1-9][0-9]*\)/\1\2/
503         p
504      }' < "$progpath"
505      exit $?
506 }
507
508 # func_usage
509 # Echo short help message to standard output and exit.
510 func_usage ()
511 {
512     $SED -n '/^# Usage:/,/# -h/ {
513         s/^# //
514         s/^# *$//
515         s/\$progname/'$progname'/
516         p
517     }' < "$progpath"
518     $ECHO
519     $ECHO "run \`$progname --help | more' for full usage"
520     exit $?
521 }
522
523 # func_help
524 # Echo long help message to standard output and exit.
525 func_help ()
526 {
527     $SED -n '/^# Usage:/,/# Report bugs to/ {
528         s/^# //
529         s/^# *$//
530         s*\$progname*'$progname'*
531         s*\$host*'"$host"'*
532         s*\$SHELL*'"$SHELL"'*
533         s*\$LTCC*'"$LTCC"'*
534         s*\$LTCFLAGS*'"$LTCFLAGS"'*
535         s*\$LD*'"$LD"'*
536         s/\$with_gnu_ld/'"$with_gnu_ld"'/
537         s/\$automake_version/'"`(automake --version) 2>/dev/null |$SED 1q`"'/
538         s/\$autoconf_version/'"`(autoconf --version) 2>/dev/null |$SED 1q`"'/
539         p
540      }' < "$progpath"
541     exit $?
542 }
543
544 # func_missing_arg argname
545 # Echo program name prefixed message to standard error and set global
546 # exit_cmd.
547 func_missing_arg ()
548 {
549     func_error "missing argument for $1"
550     exit_cmd=exit
551 }
552
553 exit_cmd=:
554
555
556
557
558
559 # Check that we have a working $ECHO.
560 if test "X$1" = X--no-reexec; then
561   # Discard the --no-reexec flag, and continue.
562   shift
563 elif test "X$1" = X--fallback-echo; then
564   # Avoid inline document here, it may be left over
565   :
566 elif test "X`{ $ECHO '\t'; } 2>/dev/null`" = 'X\t'; then
567   # Yippee, $ECHO works!
568   :
569 else
570   # Restart under the correct shell, and then maybe $ECHO will work.
571   exec $SHELL "$progpath" --no-reexec ${1+"$@"}
572 fi
573
574 if test "X$1" = X--fallback-echo; then
575   # used as fallback echo
576   shift
577   cat <<EOF
578 $*
579 EOF
580   exit $EXIT_SUCCESS
581 fi
582
583 magic="%%%MAGIC variable%%%"
584 magic_exe="%%%MAGIC EXE variable%%%"
585
586 # Global variables.
587 # $mode is unset
588 nonopt=
589 execute_dlfiles=
590 preserve_args=
591 lo2o="s/\\.lo\$/.${objext}/"
592 o2lo="s/\\.${objext}\$/.lo/"
593 extracted_archives=
594 extracted_serial=0
595
596 opt_dry_run=false
597 opt_duplicate_deps=false
598 opt_silent=false
599 opt_debug=:
600
601 # If this variable is set in any of the actions, the command in it
602 # will be execed at the end.  This prevents here-documents from being
603 # left over by shells.
604 exec_cmd=
605
606 # func_fatal_configuration arg...
607 # Echo program name prefixed message to standard error, followed by
608 # a configuration failure hint, and exit.
609 func_fatal_configuration ()
610 {
611     func_error ${1+"$@"}
612     func_error "See the $PACKAGE documentation for more information."
613     func_fatal_error "Fatal configuration error."
614 }
615
616
617 # func_config
618 # Display the configuration for all the tags in this script.
619 func_config ()
620 {
621     re_begincf='^# ### BEGIN LIBTOOL'
622     re_endcf='^# ### END LIBTOOL'
623
624     # Default configuration.
625     $SED "1,/$re_begincf CONFIG/d;/$re_endcf CONFIG/,\$d" < "$progpath"
626
627     # Now print the configurations for the tags.
628     for tagname in $taglist; do
629       $SED -n "/$re_begincf TAG CONFIG: $tagname\$/,/$re_endcf TAG CONFIG: $tagname\$/p" < "$progpath"
630     done
631
632     exit $?
633 }
634
635 # func_features
636 # Display the features supported by this script.
637 func_features ()
638 {
639     $ECHO "host: $host"
640     if test "$build_libtool_libs" = yes; then
641       $ECHO "enable shared libraries"
642     else
643       $ECHO "disable shared libraries"
644     fi
645     if test "$build_old_libs" = yes; then
646       $ECHO "enable static libraries"
647     else
648       $ECHO "disable static libraries"
649     fi
650
651     exit $?
652 }
653
654 # func_enable_tag tagname
655 # Verify that TAGNAME is valid, and either flag an error and exit, or
656 # enable the TAGNAME tag.  We also add TAGNAME to the global $taglist
657 # variable here.
658 func_enable_tag ()
659 {
660   # Global variable:
661   tagname="$1"
662
663   re_begincf="^# ### BEGIN LIBTOOL TAG CONFIG: $tagname\$"
664   re_endcf="^# ### END LIBTOOL TAG CONFIG: $tagname\$"
665   sed_extractcf="/$re_begincf/,/$re_endcf/p"
666
667   # Validate tagname.
668   case $tagname in
669     *[!-_A-Za-z0-9,/]*)
670       func_fatal_error "invalid tag name: $tagname"
671       ;;
672   esac
673
674   # Don't test for the "default" C tag, as we know it's
675   # there but not specially marked.
676   case $tagname in
677     CC) ;;
678     *)
679       if $GREP "$re_begincf" "$progpath" >/dev/null 2>&1; then
680         taglist="$taglist $tagname"
681
682         # Evaluate the configuration.  Be careful to quote the path
683         # and the sed script, to avoid splitting on whitespace, but
684         # also don't use non-portable quotes within backquotes within
685         # quotes we have to do it in 2 steps:
686         extractedcf=`$SED -n -e "$sed_extractcf" < "$progpath"`
687         eval "$extractedcf"
688       else
689         func_error "ignoring unknown tag $tagname"
690       fi
691       ;;
692   esac
693 }
694
695 # Parse options once, thoroughly.  This comes as soon as possible in
696 # the script to make things like `libtool --version' happen quickly.
697 {
698
699   # Shorthand for --mode=foo, only valid as the first argument
700   case $1 in
701   clean|clea|cle|cl)
702     shift; set dummy --mode clean ${1+"$@"}; shift
703     ;;
704   compile|compil|compi|comp|com|co|c)
705     shift; set dummy --mode compile ${1+"$@"}; shift
706     ;;
707   execute|execut|execu|exec|exe|ex|e)
708     shift; set dummy --mode execute ${1+"$@"}; shift
709     ;;
710   finish|finis|fini|fin|fi|f)
711     shift; set dummy --mode finish ${1+"$@"}; shift
712     ;;
713   install|instal|insta|inst|ins|in|i)
714     shift; set dummy --mode install ${1+"$@"}; shift
715     ;;
716   link|lin|li|l)
717     shift; set dummy --mode link ${1+"$@"}; shift
718     ;;
719   uninstall|uninstal|uninsta|uninst|unins|unin|uni|un|u)
720     shift; set dummy --mode uninstall ${1+"$@"}; shift
721     ;;
722   esac
723
724   # Parse non-mode specific arguments:
725   while test "$#" -gt 0; do
726     opt="$1"
727     shift
728
729     case $opt in
730       --config)         func_config                                     ;;
731
732       --debug)          preserve_args="$preserve_args $opt"
733                         func_echo "enabling shell trace mode"
734                         opt_debug='set -x'
735                         $opt_debug
736                         ;;
737
738       -dlopen)          test "$#" -eq 0 && func_missing_arg "$opt" && break
739                         execute_dlfiles="$execute_dlfiles $1"
740                         shift
741                         ;;
742
743       --dry-run | -n)   opt_dry_run=:                                   ;;
744       --features)       func_features                                   ;;
745       --finish)         mode="finish"                                   ;;
746
747       --mode)           test "$#" -eq 0 && func_missing_arg "$opt" && break
748                         case $1 in
749                           # Valid mode arguments:
750                           clean)        ;;
751                           compile)      ;;
752                           execute)      ;;
753                           finish)       ;;
754                           install)      ;;
755                           link)         ;;
756                           relink)       ;;
757                           uninstall)    ;;
758
759                           # Catch anything else as an error
760                           *) func_error "invalid argument for $opt"
761                              exit_cmd=exit
762                              break
763                              ;;
764                         esac
765
766                         mode="$1"
767                         shift
768                         ;;
769
770       --preserve-dup-deps)
771                         opt_duplicate_deps=:                            ;;
772
773       --quiet|--silent) preserve_args="$preserve_args $opt"
774                         opt_silent=:
775                         ;;
776
777       --verbose| -v)    preserve_args="$preserve_args $opt"
778                         opt_silent=false
779                         ;;
780
781       --tag)            test "$#" -eq 0 && func_missing_arg "$opt" && break
782                         preserve_args="$preserve_args $opt $1"
783                         func_enable_tag "$1"    # tagname is set here
784                         shift
785                         ;;
786
787       # Separate optargs to long options:
788       -dlopen=*|--mode=*|--tag=*)
789                         func_opt_split "$opt"
790                         set dummy "$func_opt_split_opt" "$func_opt_split_arg" ${1+"$@"}
791                         shift
792                         ;;
793
794       -\?|-h)           func_usage                                      ;;
795       --help)           opt_help=:                                      ;;
796       --version)        func_version                                    ;;
797
798       -*)               func_fatal_help "unrecognized option \`$opt'"   ;;
799
800       *)                nonopt="$opt"
801                         break
802                         ;;
803     esac
804   done
805
806
807   case $host in
808     *cygwin* | *mingw* | *pw32* | *cegcc*)
809       # don't eliminate duplications in $postdeps and $predeps
810       opt_duplicate_compiler_generated_deps=:
811       ;;
812     *)
813       opt_duplicate_compiler_generated_deps=$opt_duplicate_deps
814       ;;
815   esac
816
817   # Having warned about all mis-specified options, bail out if
818   # anything was wrong.
819   $exit_cmd $EXIT_FAILURE
820 }
821
822 # func_check_version_match
823 # Ensure that we are using m4 macros, and libtool script from the same
824 # release of libtool.
825 func_check_version_match ()
826 {
827   if test "$package_revision" != "$macro_revision"; then
828     if test "$VERSION" != "$macro_version"; then
829       if test -z "$macro_version"; then
830         cat >&2 <<_LT_EOF
831 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
832 $progname: definition of this LT_INIT comes from an older release.
833 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
834 $progname: and run autoconf again.
835 _LT_EOF
836       else
837         cat >&2 <<_LT_EOF
838 $progname: Version mismatch error.  This is $PACKAGE $VERSION, but the
839 $progname: definition of this LT_INIT comes from $PACKAGE $macro_version.
840 $progname: You should recreate aclocal.m4 with macros from $PACKAGE $VERSION
841 $progname: and run autoconf again.
842 _LT_EOF
843       fi
844     else
845       cat >&2 <<_LT_EOF
846 $progname: Version mismatch error.  This is $PACKAGE $VERSION, revision $package_revision,
847 $progname: but the definition of this LT_INIT comes from revision $macro_revision.
848 $progname: You should recreate aclocal.m4 with macros from revision $package_revision
849 $progname: of $PACKAGE $VERSION and run autoconf again.
850 _LT_EOF
851     fi
852
853     exit $EXIT_MISMATCH
854   fi
855 }
856
857
858 ## ----------- ##
859 ##    Main.    ##
860 ## ----------- ##
861
862 $opt_help || {
863   # Sanity checks first:
864   func_check_version_match
865
866   if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
867     func_fatal_configuration "not configured to build any kind of library"
868   fi
869
870   test -z "$mode" && func_fatal_error "error: you must specify a MODE."
871
872
873   # Darwin sucks
874   eval std_shrext=\"$shrext_cmds\"
875
876
877   # Only execute mode is allowed to have -dlopen flags.
878   if test -n "$execute_dlfiles" && test "$mode" != execute; then
879     func_error "unrecognized option \`-dlopen'"
880     $ECHO "$help" 1>&2
881     exit $EXIT_FAILURE
882   fi
883
884   # Change the help message to a mode-specific one.
885   generic_help="$help"
886   help="Try \`$progname --help --mode=$mode' for more information."
887 }
888
889
890 # func_lalib_p file
891 # True iff FILE is a libtool `.la' library or `.lo' object file.
892 # This function is only a basic sanity check; it will hardly flush out
893 # determined imposters.
894 func_lalib_p ()
895 {
896     test -f "$1" &&
897       $SED -e 4q "$1" 2>/dev/null \
898         | $GREP "^# Generated by .*$PACKAGE" > /dev/null 2>&1
899 }
900
901 # func_lalib_unsafe_p file
902 # True iff FILE is a libtool `.la' library or `.lo' object file.
903 # This function implements the same check as func_lalib_p without
904 # resorting to external programs.  To this end, it redirects stdin and
905 # closes it afterwards, without saving the original file descriptor.
906 # As a safety measure, use it only where a negative result would be
907 # fatal anyway.  Works if `file' does not exist.
908 func_lalib_unsafe_p ()
909 {
910     lalib_p=no
911     if test -f "$1" && test -r "$1" && exec 5<&0 <"$1"; then
912         for lalib_p_l in 1 2 3 4
913         do
914             read lalib_p_line
915             case "$lalib_p_line" in
916                 \#\ Generated\ by\ *$PACKAGE* ) lalib_p=yes; break;;
917             esac
918         done
919         exec 0<&5 5<&-
920     fi
921     test "$lalib_p" = yes
922 }
923
924 # func_ltwrapper_script_p file
925 # True iff FILE is a libtool wrapper script
926 # This function is only a basic sanity check; it will hardly flush out
927 # determined imposters.
928 func_ltwrapper_script_p ()
929 {
930     func_lalib_p "$1"
931 }
932
933 # func_ltwrapper_executable_p file
934 # True iff FILE is a libtool wrapper executable
935 # This function is only a basic sanity check; it will hardly flush out
936 # determined imposters.
937 func_ltwrapper_executable_p ()
938 {
939     func_ltwrapper_exec_suffix=
940     case $1 in
941     *.exe) ;;
942     *) func_ltwrapper_exec_suffix=.exe ;;
943     esac
944     $GREP "$magic_exe" "$1$func_ltwrapper_exec_suffix" >/dev/null 2>&1
945 }
946
947 # func_ltwrapper_scriptname file
948 # Assumes file is an ltwrapper_executable
949 # uses $file to determine the appropriate filename for a
950 # temporary ltwrapper_script.
951 func_ltwrapper_scriptname ()
952 {
953     func_ltwrapper_scriptname_result=""
954     if func_ltwrapper_executable_p "$1"; then
955         func_dirname_and_basename "$1" "" "."
956         func_stripname '' '.exe' "$func_basename_result"
957         func_ltwrapper_scriptname_result="$func_dirname_result/$objdir/${func_stripname_result}_ltshwrapper"
958     fi
959 }
960
961 # func_ltwrapper_p file
962 # True iff FILE is a libtool wrapper script or wrapper executable
963 # This function is only a basic sanity check; it will hardly flush out
964 # determined imposters.
965 func_ltwrapper_p ()
966 {
967     func_ltwrapper_script_p "$1" || func_ltwrapper_executable_p "$1"
968 }
969
970
971 # func_execute_cmds commands fail_cmd
972 # Execute tilde-delimited COMMANDS.
973 # If FAIL_CMD is given, eval that upon failure.
974 # FAIL_CMD may read-access the current command in variable CMD!
975 func_execute_cmds ()
976 {
977     $opt_debug
978     save_ifs=$IFS; IFS='~'
979     for cmd in $1; do
980       IFS=$save_ifs
981       eval cmd=\"$cmd\"
982       func_show_eval "$cmd" "${2-:}"
983     done
984     IFS=$save_ifs
985 }
986
987
988 # func_source file
989 # Source FILE, adding directory component if necessary.
990 # Note that it is not necessary on cygwin/mingw to append a dot to
991 # FILE even if both FILE and FILE.exe exist: automatic-append-.exe
992 # behavior happens only for exec(3), not for open(2)!  Also, sourcing
993 # `FILE.' does not work on cygwin managed mounts.
994 func_source ()
995 {
996     $opt_debug
997     case $1 in
998     */* | *\\*) . "$1" ;;
999     *)          . "./$1" ;;
1000     esac
1001 }
1002
1003
1004 # func_infer_tag arg
1005 # Infer tagged configuration to use if any are available and
1006 # if one wasn't chosen via the "--tag" command line option.
1007 # Only attempt this if the compiler in the base compile
1008 # command doesn't match the default compiler.
1009 # arg is usually of the form 'gcc ...'
1010 func_infer_tag ()
1011 {
1012     $opt_debug
1013     if test -n "$available_tags" && test -z "$tagname"; then
1014       CC_quoted=
1015       for arg in $CC; do
1016         func_quote_for_eval "$arg"
1017         CC_quoted="$CC_quoted $func_quote_for_eval_result"
1018       done
1019       case $@ in
1020       # Blanks in the command may have been stripped by the calling shell,
1021       # but not from the CC environment variable when configure was run.
1022       " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*) ;;
1023       # Blanks at the start of $base_compile will cause this to fail
1024       # if we don't check for them as well.
1025       *)
1026         for z in $available_tags; do
1027           if $GREP "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
1028             # Evaluate the configuration.
1029             eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
1030             CC_quoted=
1031             for arg in $CC; do
1032               # Double-quote args containing other shell metacharacters.
1033               func_quote_for_eval "$arg"
1034               CC_quoted="$CC_quoted $func_quote_for_eval_result"
1035             done
1036             case "$@ " in
1037               " $CC "* | "$CC "* | " `$ECHO $CC` "* | "`$ECHO $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$ECHO $CC_quoted` "* | "`$ECHO $CC_quoted` "*)
1038               # The compiler in the base compile command matches
1039               # the one in the tagged configuration.
1040               # Assume this is the tagged configuration we want.
1041               tagname=$z
1042               break
1043               ;;
1044             esac
1045           fi
1046         done
1047         # If $tagname still isn't set, then no tagged configuration
1048         # was found and let the user know that the "--tag" command
1049         # line option must be used.
1050         if test -z "$tagname"; then
1051           func_echo "unable to infer tagged configuration"
1052           func_fatal_error "specify a tag with \`--tag'"
1053 #       else
1054 #         func_verbose "using $tagname tagged configuration"
1055         fi
1056         ;;
1057       esac
1058     fi
1059 }
1060
1061
1062
1063 # func_write_libtool_object output_name pic_name nonpic_name
1064 # Create a libtool object file (analogous to a ".la" file),
1065 # but don't create it if we're doing a dry run.
1066 func_write_libtool_object ()
1067 {
1068     write_libobj=${1}
1069     if test "$build_libtool_libs" = yes; then
1070       write_lobj=\'${2}\'
1071     else
1072       write_lobj=none
1073     fi
1074
1075     if test "$build_old_libs" = yes; then
1076       write_oldobj=\'${3}\'
1077     else
1078       write_oldobj=none
1079     fi
1080
1081     $opt_dry_run || {
1082       cat >${write_libobj}T <<EOF
1083 # $write_libobj - a libtool object file
1084 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
1085 #
1086 # Please DO NOT delete this file!
1087 # It is necessary for linking the library.
1088
1089 # Name of the PIC object.
1090 pic_object=$write_lobj
1091
1092 # Name of the non-PIC object
1093 non_pic_object=$write_oldobj
1094
1095 EOF
1096       $MV "${write_libobj}T" "${write_libobj}"
1097     }
1098 }
1099
1100 # func_mode_compile arg...
1101 func_mode_compile ()
1102 {
1103     $opt_debug
1104     # Get the compilation command and the source file.
1105     base_compile=
1106     srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
1107     suppress_opt=yes
1108     suppress_output=
1109     arg_mode=normal
1110     libobj=
1111     later=
1112     pie_flag=
1113
1114     for arg
1115     do
1116       case $arg_mode in
1117       arg  )
1118         # do not "continue".  Instead, add this to base_compile
1119         lastarg="$arg"
1120         arg_mode=normal
1121         ;;
1122
1123       target )
1124         libobj="$arg"
1125         arg_mode=normal
1126         continue
1127         ;;
1128
1129       normal )
1130         # Accept any command-line options.
1131         case $arg in
1132         -o)
1133           test -n "$libobj" && \
1134             func_fatal_error "you cannot specify \`-o' more than once"
1135           arg_mode=target
1136           continue
1137           ;;
1138
1139         -pie | -fpie | -fPIE)
1140           pie_flag="$pie_flag $arg"
1141           continue
1142           ;;
1143
1144         -shared | -static | -prefer-pic | -prefer-non-pic)
1145           later="$later $arg"
1146           continue
1147           ;;
1148
1149         -no-suppress)
1150           suppress_opt=no
1151           continue
1152           ;;
1153
1154         -Xcompiler)
1155           arg_mode=arg  #  the next one goes into the "base_compile" arg list
1156           continue      #  The current "srcfile" will either be retained or
1157           ;;            #  replaced later.  I would guess that would be a bug.
1158
1159         -Wc,*)
1160           func_stripname '-Wc,' '' "$arg"
1161           args=$func_stripname_result
1162           lastarg=
1163           save_ifs="$IFS"; IFS=','
1164           for arg in $args; do
1165             IFS="$save_ifs"
1166             func_quote_for_eval "$arg"
1167             lastarg="$lastarg $func_quote_for_eval_result"
1168           done
1169           IFS="$save_ifs"
1170           func_stripname ' ' '' "$lastarg"
1171           lastarg=$func_stripname_result
1172
1173           # Add the arguments to base_compile.
1174           base_compile="$base_compile $lastarg"
1175           continue
1176           ;;
1177
1178         *)
1179           # Accept the current argument as the source file.
1180           # The previous "srcfile" becomes the current argument.
1181           #
1182           lastarg="$srcfile"
1183           srcfile="$arg"
1184           ;;
1185         esac  #  case $arg
1186         ;;
1187       esac    #  case $arg_mode
1188
1189       # Aesthetically quote the previous argument.
1190       func_quote_for_eval "$lastarg"
1191       base_compile="$base_compile $func_quote_for_eval_result"
1192     done # for arg
1193
1194     case $arg_mode in
1195     arg)
1196       func_fatal_error "you must specify an argument for -Xcompile"
1197       ;;
1198     target)
1199       func_fatal_error "you must specify a target with \`-o'"
1200       ;;
1201     *)
1202       # Get the name of the library object.
1203       test -z "$libobj" && {
1204         func_basename "$srcfile"
1205         libobj="$func_basename_result"
1206       }
1207       ;;
1208     esac
1209
1210     # Recognize several different file suffixes.
1211     # If the user specifies -o file.o, it is replaced with file.lo
1212     case $libobj in
1213     *.[cCFSifmso] | \
1214     *.ada | *.adb | *.ads | *.asm | \
1215     *.c++ | *.cc | *.ii | *.class | *.cpp | *.cxx | \
1216     *.[fF][09]? | *.for | *.java | *.obj | *.sx)
1217       func_xform "$libobj"
1218       libobj=$func_xform_result
1219       ;;
1220     esac
1221
1222     case $libobj in
1223     *.lo) func_lo2o "$libobj"; obj=$func_lo2o_result ;;
1224     *)
1225       func_fatal_error "cannot determine name of library object from \`$libobj'"
1226       ;;
1227     esac
1228
1229     func_infer_tag $base_compile
1230
1231     for arg in $later; do
1232       case $arg in
1233       -shared)
1234         test "$build_libtool_libs" != yes && \
1235           func_fatal_configuration "can not build a shared library"
1236         build_old_libs=no
1237         continue
1238         ;;
1239
1240       -static)
1241         build_libtool_libs=no
1242         build_old_libs=yes
1243         continue
1244         ;;
1245
1246       -prefer-pic)
1247         pic_mode=yes
1248         continue
1249         ;;
1250
1251       -prefer-non-pic)
1252         pic_mode=no
1253         continue
1254         ;;
1255       esac
1256     done
1257
1258     func_quote_for_eval "$libobj"
1259     test "X$libobj" != "X$func_quote_for_eval_result" \
1260       && $ECHO "X$libobj" | $GREP '[]~#^*{};<>?"'"'"'    &()|`$[]' \
1261       && func_warning "libobj name \`$libobj' may not contain shell special characters."
1262     func_dirname_and_basename "$obj" "/" ""
1263     objname="$func_basename_result"
1264     xdir="$func_dirname_result"
1265     lobj=${xdir}$objdir/$objname
1266
1267     test -z "$base_compile" && \
1268       func_fatal_help "you must specify a compilation command"
1269
1270     # Delete any leftover library objects.
1271     if test "$build_old_libs" = yes; then
1272       removelist="$obj $lobj $libobj ${libobj}T"
1273     else
1274       removelist="$lobj $libobj ${libobj}T"
1275     fi
1276
1277     # On Cygwin there's no "real" PIC flag so we must build both object types
1278     case $host_os in
1279     cygwin* | mingw* | pw32* | os2* | cegcc*)
1280       pic_mode=default
1281       ;;
1282     esac
1283     if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
1284       # non-PIC code in shared libraries is not supported
1285       pic_mode=default
1286     fi
1287
1288     # Calculate the filename of the output object if compiler does
1289     # not support -o with -c
1290     if test "$compiler_c_o" = no; then
1291       output_obj=`$ECHO "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
1292       lockfile="$output_obj.lock"
1293     else
1294       output_obj=
1295       need_locks=no
1296       lockfile=
1297     fi
1298
1299     # Lock this critical section if it is needed
1300     # We use this script file to make the link, it avoids creating a new file
1301     if test "$need_locks" = yes; then
1302       until $opt_dry_run || ln "$progpath" "$lockfile" 2>/dev/null; do
1303         func_echo "Waiting for $lockfile to be removed"
1304         sleep 2
1305       done
1306     elif test "$need_locks" = warn; then
1307       if test -f "$lockfile"; then
1308         $ECHO "\
1309 *** ERROR, $lockfile exists and contains:
1310 `cat $lockfile 2>/dev/null`
1311
1312 This indicates that another process is trying to use the same
1313 temporary object file, and libtool could not work around it because
1314 your compiler does not support \`-c' and \`-o' together.  If you
1315 repeat this compilation, it may succeed, by chance, but you had better
1316 avoid parallel builds (make -j) in this platform, or get a better
1317 compiler."
1318
1319         $opt_dry_run || $RM $removelist
1320         exit $EXIT_FAILURE
1321       fi
1322       removelist="$removelist $output_obj"
1323       $ECHO "$srcfile" > "$lockfile"
1324     fi
1325
1326     $opt_dry_run || $RM $removelist
1327     removelist="$removelist $lockfile"
1328     trap '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE' 1 2 15
1329
1330     if test -n "$fix_srcfile_path"; then
1331       eval srcfile=\"$fix_srcfile_path\"
1332     fi
1333     func_quote_for_eval "$srcfile"
1334     qsrcfile=$func_quote_for_eval_result
1335
1336     # Only build a PIC object if we are building libtool libraries.
1337     if test "$build_libtool_libs" = yes; then
1338       # Without this assignment, base_compile gets emptied.
1339       fbsd_hideous_sh_bug=$base_compile
1340
1341       if test "$pic_mode" != no; then
1342         command="$base_compile $qsrcfile $pic_flag"
1343       else
1344         # Don't build PIC code
1345         command="$base_compile $qsrcfile"
1346       fi
1347
1348       func_mkdir_p "$xdir$objdir"
1349
1350       if test -z "$output_obj"; then
1351         # Place PIC objects in $objdir
1352         command="$command -o $lobj"
1353       fi
1354
1355       func_show_eval_locale "$command"  \
1356           'test -n "$output_obj" && $RM $removelist; exit $EXIT_FAILURE'
1357
1358       if test "$need_locks" = warn &&
1359          test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1360         $ECHO "\
1361 *** ERROR, $lockfile contains:
1362 `cat $lockfile 2>/dev/null`
1363
1364 but it should contain:
1365 $srcfile
1366
1367 This indicates that another process is trying to use the same
1368 temporary object file, and libtool could not work around it because
1369 your compiler does not support \`-c' and \`-o' together.  If you
1370 repeat this compilation, it may succeed, by chance, but you had better
1371 avoid parallel builds (make -j) in this platform, or get a better
1372 compiler."
1373
1374         $opt_dry_run || $RM $removelist
1375         exit $EXIT_FAILURE
1376       fi
1377
1378       # Just move the object if needed, then go on to compile the next one
1379       if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
1380         func_show_eval '$MV "$output_obj" "$lobj"' \
1381           'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1382       fi
1383
1384       # Allow error messages only from the first compilation.
1385       if test "$suppress_opt" = yes; then
1386         suppress_output=' >/dev/null 2>&1'
1387       fi
1388     fi
1389
1390     # Only build a position-dependent object if we build old libraries.
1391     if test "$build_old_libs" = yes; then
1392       if test "$pic_mode" != yes; then
1393         # Don't build PIC code
1394         command="$base_compile $qsrcfile$pie_flag"
1395       else
1396         command="$base_compile $qsrcfile $pic_flag"
1397       fi
1398       if test "$compiler_c_o" = yes; then
1399         command="$command -o $obj"
1400       fi
1401
1402       # Suppress compiler output if we already did a PIC compilation.
1403       command="$command$suppress_output"
1404       func_show_eval_locale "$command" \
1405         '$opt_dry_run || $RM $removelist; exit $EXIT_FAILURE'
1406
1407       if test "$need_locks" = warn &&
1408          test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
1409         $ECHO "\
1410 *** ERROR, $lockfile contains:
1411 `cat $lockfile 2>/dev/null`
1412
1413 but it should contain:
1414 $srcfile
1415
1416 This indicates that another process is trying to use the same
1417 temporary object file, and libtool could not work around it because
1418 your compiler does not support \`-c' and \`-o' together.  If you
1419 repeat this compilation, it may succeed, by chance, but you had better
1420 avoid parallel builds (make -j) in this platform, or get a better
1421 compiler."
1422
1423         $opt_dry_run || $RM $removelist
1424         exit $EXIT_FAILURE
1425       fi
1426
1427       # Just move the object if needed
1428       if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
1429         func_show_eval '$MV "$output_obj" "$obj"' \
1430           'error=$?; $opt_dry_run || $RM $removelist; exit $error'
1431       fi
1432     fi
1433
1434     $opt_dry_run || {
1435       func_write_libtool_object "$libobj" "$objdir/$objname" "$objname"
1436
1437       # Unlock the critical section if it was locked
1438       if test "$need_locks" != no; then
1439         removelist=$lockfile
1440         $RM "$lockfile"
1441       fi
1442     }
1443
1444     exit $EXIT_SUCCESS
1445 }
1446
1447 $opt_help || {
1448 test "$mode" = compile && func_mode_compile ${1+"$@"}
1449 }
1450
1451 func_mode_help ()
1452 {
1453     # We need to display help for each of the modes.
1454     case $mode in
1455       "")
1456         # Generic help is extracted from the usage comments
1457         # at the start of this file.
1458         func_help
1459         ;;
1460
1461       clean)
1462         $ECHO \
1463 "Usage: $progname [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
1464
1465 Remove files from the build directory.
1466
1467 RM is the name of the program to use to delete files associated with each FILE
1468 (typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1469 to RM.
1470
1471 If FILE is a libtool library, object or program, all the files associated
1472 with it are deleted. Otherwise, only FILE itself is deleted using RM."
1473         ;;
1474
1475       compile)
1476       $ECHO \
1477 "Usage: $progname [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
1478
1479 Compile a source file into a libtool library object.
1480
1481 This mode accepts the following additional options:
1482
1483   -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
1484   -no-suppress      do not suppress compiler output for multiple passes
1485   -prefer-pic       try to building PIC objects only
1486   -prefer-non-pic   try to building non-PIC objects only
1487   -shared           do not build a \`.o' file suitable for static linking
1488   -static           only build a \`.o' file suitable for static linking
1489
1490 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
1491 from the given SOURCEFILE.
1492
1493 The output file name is determined by removing the directory component from
1494 SOURCEFILE, then substituting the C source code suffix \`.c' with the
1495 library object suffix, \`.lo'."
1496         ;;
1497
1498       execute)
1499         $ECHO \
1500 "Usage: $progname [OPTION]... --mode=execute COMMAND [ARGS]...
1501
1502 Automatically set library path, then run a program.
1503
1504 This mode accepts the following additional options:
1505
1506   -dlopen FILE      add the directory containing FILE to the library path
1507
1508 This mode sets the library path environment variable according to \`-dlopen'
1509 flags.
1510
1511 If any of the ARGS are libtool executable wrappers, then they are translated
1512 into their corresponding uninstalled binary, and any of their required library
1513 directories are added to the library path.
1514
1515 Then, COMMAND is executed, with ARGS as arguments."
1516         ;;
1517
1518       finish)
1519         $ECHO \
1520 "Usage: $progname [OPTION]... --mode=finish [LIBDIR]...
1521
1522 Complete the installation of libtool libraries.
1523
1524 Each LIBDIR is a directory that contains libtool libraries.
1525
1526 The commands that this mode executes may require superuser privileges.  Use
1527 the \`--dry-run' option if you just want to see what would be executed."
1528         ;;
1529
1530       install)
1531         $ECHO \
1532 "Usage: $progname [OPTION]... --mode=install INSTALL-COMMAND...
1533
1534 Install executables or libraries.
1535
1536 INSTALL-COMMAND is the installation command.  The first component should be
1537 either the \`install' or \`cp' program.
1538
1539 The following components of INSTALL-COMMAND are treated specially:
1540
1541   -inst-prefix PREFIX-DIR  Use PREFIX-DIR as a staging area for installation
1542
1543 The rest of the components are interpreted as arguments to that command (only
1544 BSD-compatible install options are recognized)."
1545         ;;
1546
1547       link)
1548         $ECHO \
1549 "Usage: $progname [OPTION]... --mode=link LINK-COMMAND...
1550
1551 Link object files or libraries together to form another library, or to
1552 create an executable program.
1553
1554 LINK-COMMAND is a command using the C compiler that you would use to create
1555 a program from several object files.
1556
1557 The following components of LINK-COMMAND are treated specially:
1558
1559   -all-static       do not do any dynamic linking at all
1560   -avoid-version    do not add a version suffix if possible
1561   -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
1562   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
1563   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
1564   -export-symbols SYMFILE
1565                     try to export only the symbols listed in SYMFILE
1566   -export-symbols-regex REGEX
1567                     try to export only the symbols matching REGEX
1568   -LLIBDIR          search LIBDIR for required installed libraries
1569   -lNAME            OUTPUT-FILE requires the installed library libNAME
1570   -module           build a library that can dlopened
1571   -no-fast-install  disable the fast-install mode
1572   -no-install       link a not-installable executable
1573   -no-undefined     declare that a library does not refer to external symbols
1574   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
1575   -objectlist FILE  Use a list of object files found in FILE to specify objects
1576   -precious-files-regex REGEX
1577                     don't remove output files matching REGEX
1578   -release RELEASE  specify package release information
1579   -rpath LIBDIR     the created library will eventually be installed in LIBDIR
1580   -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
1581   -shared           only do dynamic linking of libtool libraries
1582   -shrext SUFFIX    override the standard shared library file extension
1583   -static           do not do any dynamic linking of uninstalled libtool libraries
1584   -static-libtool-libs
1585                     do not do any dynamic linking of libtool libraries
1586   -version-info CURRENT[:REVISION[:AGE]]
1587                     specify library version info [each variable defaults to 0]
1588   -weak LIBNAME     declare that the target provides the LIBNAME interface
1589
1590 All other options (arguments beginning with \`-') are ignored.
1591
1592 Every other argument is treated as a filename.  Files ending in \`.la' are
1593 treated as uninstalled libtool libraries, other files are standard or library
1594 object files.
1595
1596 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
1597 only library objects (\`.lo' files) may be specified, and \`-rpath' is
1598 required, except when creating a convenience library.
1599
1600 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
1601 using \`ar' and \`ranlib', or on Windows using \`lib'.
1602
1603 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
1604 is created, otherwise an executable program is created."
1605         ;;
1606
1607       uninstall)
1608         $ECHO \
1609 "Usage: $progname [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
1610
1611 Remove libraries from an installation directory.
1612
1613 RM is the name of the program to use to delete files associated with each FILE
1614 (typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
1615 to RM.
1616
1617 If FILE is a libtool library, all the files associated with it are deleted.
1618 Otherwise, only FILE itself is deleted using RM."
1619         ;;
1620
1621       *)
1622         func_fatal_help "invalid operation mode \`$mode'"
1623         ;;
1624     esac
1625
1626     $ECHO
1627     $ECHO "Try \`$progname --help' for more information about other modes."
1628
1629     exit $?
1630 }
1631
1632   # Now that we've collected a possible --mode arg, show help if necessary
1633   $opt_help && func_mode_help
1634
1635
1636 # func_mode_execute arg...
1637 func_mode_execute ()
1638 {
1639     $opt_debug
1640     # The first argument is the command name.
1641     cmd="$nonopt"
1642     test -z "$cmd" && \
1643       func_fatal_help "you must specify a COMMAND"
1644
1645     # Handle -dlopen flags immediately.
1646     for file in $execute_dlfiles; do
1647       test -f "$file" \
1648         || func_fatal_help "\`$file' is not a file"
1649
1650       dir=
1651       case $file in
1652       *.la)
1653         # Check to see that this really is a libtool archive.
1654         func_lalib_unsafe_p "$file" \
1655           || func_fatal_help "\`$lib' is not a valid libtool archive"
1656
1657         # Read the libtool library.
1658         dlname=
1659         library_names=
1660         func_source "$file"
1661
1662         # Skip this library if it cannot be dlopened.
1663         if test -z "$dlname"; then
1664           # Warn if it was a shared library.
1665           test -n "$library_names" && \
1666             func_warning "\`$file' was not linked with \`-export-dynamic'"
1667           continue
1668         fi
1669
1670         func_dirname "$file" "" "."
1671         dir="$func_dirname_result"
1672
1673         if test -f "$dir/$objdir/$dlname"; then
1674           dir="$dir/$objdir"
1675         else
1676           if test ! -f "$dir/$dlname"; then
1677             func_fatal_error "cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'"
1678           fi
1679         fi
1680         ;;
1681
1682       *.lo)
1683         # Just add the directory containing the .lo file.
1684         func_dirname "$file" "" "."
1685         dir="$func_dirname_result"
1686         ;;
1687
1688       *)
1689         func_warning "\`-dlopen' is ignored for non-libtool libraries and objects"
1690         continue
1691         ;;
1692       esac
1693
1694       # Get the absolute pathname.
1695       absdir=`cd "$dir" && pwd`
1696       test -n "$absdir" && dir="$absdir"
1697
1698       # Now add the directory to shlibpath_var.
1699       if eval "test -z \"\$$shlibpath_var\""; then
1700         eval "$shlibpath_var=\"\$dir\""
1701       else
1702         eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
1703       fi
1704     done
1705
1706     # This variable tells wrapper scripts just to set shlibpath_var
1707     # rather than running their programs.
1708     libtool_execute_magic="$magic"
1709
1710     # Check if any of the arguments is a wrapper script.
1711     args=
1712     for file
1713     do
1714       case $file in
1715       -*) ;;
1716       *)
1717         # Do a test to see if this is really a libtool program.
1718         if func_ltwrapper_script_p "$file"; then
1719           func_source "$file"
1720           # Transform arg to wrapped name.
1721           file="$progdir/$program"
1722         elif func_ltwrapper_executable_p "$file"; then
1723           func_ltwrapper_scriptname "$file"
1724           func_source "$func_ltwrapper_scriptname_result"
1725           # Transform arg to wrapped name.
1726           file="$progdir/$program"
1727         fi
1728         ;;
1729       esac
1730       # Quote arguments (to preserve shell metacharacters).
1731       func_quote_for_eval "$file"
1732       args="$args $func_quote_for_eval_result"
1733     done
1734
1735     if test "X$opt_dry_run" = Xfalse; then
1736       if test -n "$shlibpath_var"; then
1737         # Export the shlibpath_var.
1738         eval "export $shlibpath_var"
1739       fi
1740
1741       # Restore saved environment variables
1742       for lt_var in LANG LANGUAGE LC_ALL LC_CTYPE LC_COLLATE LC_MESSAGES
1743       do
1744         eval "if test \"\${save_$lt_var+set}\" = set; then
1745                 $lt_var=\$save_$lt_var; export $lt_var
1746               else
1747                 $lt_unset $lt_var
1748               fi"
1749       done
1750
1751       # Now prepare to actually exec the command.
1752       exec_cmd="\$cmd$args"
1753     else
1754       # Display what would be done.
1755       if test -n "$shlibpath_var"; then
1756         eval "\$ECHO \"\$shlibpath_var=\$$shlibpath_var\""
1757         $ECHO "export $shlibpath_var"
1758       fi
1759       $ECHO "$cmd$args"
1760       exit $EXIT_SUCCESS
1761     fi
1762 }
1763
1764 test "$mode" = execute && func_mode_execute ${1+"$@"}
1765
1766
1767 # func_mode_finish arg...
1768 func_mode_finish ()
1769 {
1770     $opt_debug
1771     libdirs="$nonopt"
1772     admincmds=
1773
1774     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
1775       for dir
1776       do
1777         libdirs="$libdirs $dir"
1778       done
1779
1780       for libdir in $libdirs; do
1781         if test -n "$finish_cmds"; then
1782           # Do each command in the finish commands.
1783           func_execute_cmds "$finish_cmds" 'admincmds="$admincmds
1784 '"$cmd"'"'
1785         fi
1786         if test -n "$finish_eval"; then
1787           # Do the single finish_eval.
1788           eval cmds=\"$finish_eval\"
1789           $opt_dry_run || eval "$cmds" || admincmds="$admincmds
1790        $cmds"
1791         fi
1792       done
1793     fi
1794
1795     # Exit here if they wanted silent mode.
1796     $opt_silent && exit $EXIT_SUCCESS
1797
1798     $ECHO "X----------------------------------------------------------------------" | $Xsed
1799     $ECHO "Libraries have been installed in:"
1800     for libdir in $libdirs; do
1801       $ECHO "   $libdir"
1802     done
1803     $ECHO
1804     $ECHO "If you ever happen to want to link against installed libraries"
1805     $ECHO "in a given directory, LIBDIR, you must either use libtool, and"
1806     $ECHO "specify the full pathname of the library, or use the \`-LLIBDIR'"
1807     $ECHO "flag during linking and do at least one of the following:"
1808     if test -n "$shlibpath_var"; then
1809       $ECHO "   - add LIBDIR to the \`$shlibpath_var' environment variable"
1810       $ECHO "     during execution"
1811     fi
1812     if test -n "$runpath_var"; then
1813       $ECHO "   - add LIBDIR to the \`$runpath_var' environment variable"
1814       $ECHO "     during linking"
1815     fi
1816     if test -n "$hardcode_libdir_flag_spec"; then
1817       libdir=LIBDIR
1818       eval flag=\"$hardcode_libdir_flag_spec\"
1819
1820       $ECHO "   - use the \`$flag' linker flag"
1821     fi
1822     if test -n "$admincmds"; then
1823       $ECHO "   - have your system administrator run these commands:$admincmds"
1824     fi
1825     if test -f /etc/ld.so.conf; then
1826       $ECHO "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
1827     fi
1828     $ECHO
1829
1830     $ECHO "See any operating system documentation about shared libraries for"
1831     case $host in
1832       solaris2.[6789]|solaris2.1[0-9])
1833         $ECHO "more information, such as the ld(1), crle(1) and ld.so(8) manual"
1834         $ECHO "pages."
1835         ;;
1836       *)
1837         $ECHO "more information, such as the ld(1) and ld.so(8) manual pages."
1838         ;;
1839     esac
1840     $ECHO "X----------------------------------------------------------------------" | $Xsed
1841     exit $EXIT_SUCCESS
1842 }
1843
1844 test "$mode" = finish && func_mode_finish ${1+"$@"}
1845
1846
1847 # func_mode_install arg...
1848 func_mode_install ()
1849 {
1850     $opt_debug
1851     # There may be an optional sh(1) argument at the beginning of
1852     # install_prog (especially on Windows NT).
1853     if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
1854        # Allow the use of GNU shtool's install command.
1855        $ECHO "X$nonopt" | $GREP shtool >/dev/null; then
1856       # Aesthetically quote it.
1857       func_quote_for_eval "$nonopt"
1858       install_prog="$func_quote_for_eval_result "
1859       arg=$1
1860       shift
1861     else
1862       install_prog=
1863       arg=$nonopt
1864     fi
1865
1866     # The real first argument should be the name of the installation program.
1867     # Aesthetically quote it.
1868     func_quote_for_eval "$arg"
1869     install_prog="$install_prog$func_quote_for_eval_result"
1870
1871     # We need to accept at least all the BSD install flags.
1872     dest=
1873     files=
1874     opts=
1875     prev=
1876     install_type=
1877     isdir=no
1878     stripme=
1879     for arg
1880     do
1881       if test -n "$dest"; then
1882         files="$files $dest"
1883         dest=$arg
1884         continue
1885       fi
1886
1887       case $arg in
1888       -d) isdir=yes ;;
1889       -f)
1890         case " $install_prog " in
1891         *[\\\ /]cp\ *) ;;
1892         *) prev=$arg ;;
1893         esac
1894         ;;
1895       -g | -m | -o)
1896         prev=$arg
1897         ;;
1898       -s)
1899         stripme=" -s"
1900         continue
1901         ;;
1902       -*)
1903         ;;
1904       *)
1905         # If the previous option needed an argument, then skip it.
1906         if test -n "$prev"; then
1907           prev=
1908         else
1909           dest=$arg
1910           continue
1911         fi
1912         ;;
1913       esac
1914
1915       # Aesthetically quote the argument.
1916       func_quote_for_eval "$arg"
1917       install_prog="$install_prog $func_quote_for_eval_result"
1918     done
1919
1920     test -z "$install_prog" && \
1921       func_fatal_help "you must specify an install program"
1922
1923     test -n "$prev" && \
1924       func_fatal_help "the \`$prev' option requires an argument"
1925
1926     if test -z "$files"; then
1927       if test -z "$dest"; then
1928         func_fatal_help "no file or destination specified"
1929       else
1930         func_fatal_help "you must specify a destination"
1931       fi
1932     fi
1933
1934     # Strip any trailing slash from the destination.
1935     func_stripname '' '/' "$dest"
1936     dest=$func_stripname_result
1937
1938     # Check to see that the destination is a directory.
1939     test -d "$dest" && isdir=yes
1940     if test "$isdir" = yes; then
1941       destdir="$dest"
1942       destname=
1943     else
1944       func_dirname_and_basename "$dest" "" "."
1945       destdir="$func_dirname_result"
1946       destname="$func_basename_result"
1947
1948       # Not a directory, so check to see that there is only one file specified.
1949       set dummy $files; shift
1950       test "$#" -gt 1 && \
1951         func_fatal_help "\`$dest' is not a directory"
1952     fi
1953     case $destdir in
1954     [\\/]* | [A-Za-z]:[\\/]*) ;;
1955     *)
1956       for file in $files; do
1957         case $file in
1958         *.lo) ;;
1959         *)
1960           func_fatal_help "\`$destdir' must be an absolute directory name"
1961           ;;
1962         esac
1963       done
1964       ;;
1965     esac
1966
1967     # This variable tells wrapper scripts just to set variables rather
1968     # than running their programs.
1969     libtool_install_magic="$magic"
1970
1971     staticlibs=
1972     future_libdirs=
1973     current_libdirs=
1974     for file in $files; do
1975
1976       # Do each installation.
1977       case $file in
1978       *.$libext)
1979         # Do the static libraries later.
1980         staticlibs="$staticlibs $file"
1981         ;;
1982
1983       *.la)
1984         # Check to see that this really is a libtool archive.
1985         func_lalib_unsafe_p "$file" \
1986           || func_fatal_help "\`$file' is not a valid libtool archive"
1987
1988         library_names=
1989         old_library=
1990         relink_command=
1991         func_source "$file"
1992
1993         # Add the libdir to current_libdirs if it is the destination.
1994         if test "X$destdir" = "X$libdir"; then
1995           case "$current_libdirs " in
1996           *" $libdir "*) ;;
1997           *) current_libdirs="$current_libdirs $libdir" ;;
1998           esac
1999         else
2000           # Note the libdir as a future libdir.
2001           case "$future_libdirs " in
2002           *" $libdir "*) ;;
2003           *) future_libdirs="$future_libdirs $libdir" ;;
2004           esac
2005         fi
2006
2007         func_dirname "$file" "/" ""
2008         dir="$func_dirname_result"
2009         dir="$dir$objdir"
2010
2011         if test -n "$relink_command"; then
2012           # Determine the prefix the user has applied to our future dir.
2013           inst_prefix_dir=`$ECHO "X$destdir" | $Xsed -e "s%$libdir\$%%"`
2014
2015           # Don't allow the user to place us outside of our expected
2016           # location b/c this prevents finding dependent libraries that
2017           # are installed to the same prefix.
2018           # At present, this check doesn't affect windows .dll's that
2019           # are installed into $libdir/../bin (currently, that works fine)
2020           # but it's something to keep an eye on.
2021           test "$inst_prefix_dir" = "$destdir" && \
2022             func_fatal_error "error: cannot install \`$file' to a directory not ending in $libdir"
2023
2024           if test -n "$inst_prefix_dir"; then
2025             # Stick the inst_prefix_dir data into the link command.
2026             relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
2027           else
2028             relink_command=`$ECHO "X$relink_command" | $Xsed -e "s%@inst_prefix_dir@%%"`
2029           fi
2030
2031           func_warning "relinking \`$file'"
2032           func_show_eval "$relink_command" \
2033             'func_fatal_error "error: relink \`$file'\'' with the above command before installing it"'
2034         fi
2035
2036         # See the names of the shared library.
2037         set dummy $library_names; shift
2038         if test -n "$1"; then
2039           realname="$1"
2040           shift
2041
2042           srcname="$realname"
2043           test -n "$relink_command" && srcname="$realname"T
2044
2045           # Install the shared library and build the symlinks.
2046           func_show_eval "$install_prog $dir/$srcname $destdir/$realname" \
2047               'exit $?'
2048           tstripme="$stripme"
2049           case $host_os in
2050           cygwin* | mingw* | pw32* | cegcc*)
2051             case $realname in
2052             *.dll.a)
2053               tstripme=""
2054               ;;
2055             esac
2056             ;;
2057           esac
2058           if test -n "$tstripme" && test -n "$striplib"; then
2059             func_show_eval "$striplib $destdir/$realname" 'exit $?'
2060           fi
2061
2062           if test "$#" -gt 0; then
2063             # Delete the old symlinks, and create new ones.
2064             # Try `ln -sf' first, because the `ln' binary might depend on
2065             # the symlink we replace!  Solaris /bin/ln does not understand -f,
2066             # so we also need to try rm && ln -s.
2067             for linkname
2068             do
2069               test "$linkname" != "$realname" \
2070                 && func_show_eval "(cd $destdir && { $LN_S -f $realname $linkname || { $RM $linkname && $LN_S $realname $linkname; }; })"
2071             done
2072           fi
2073
2074           # Do each command in the postinstall commands.
2075           lib="$destdir/$realname"
2076           func_execute_cmds "$postinstall_cmds" 'exit $?'
2077         fi
2078
2079         # Install the pseudo-library for information purposes.
2080         func_basename "$file"
2081         name="$func_basename_result"
2082         instname="$dir/$name"i
2083         func_show_eval "$install_prog $instname $destdir/$name" 'exit $?'
2084
2085         # Maybe install the static library, too.
2086         test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
2087         ;;
2088
2089       *.lo)
2090         # Install (i.e. copy) a libtool object.
2091
2092         # Figure out destination file name, if it wasn't already specified.
2093         if test -n "$destname"; then
2094           destfile="$destdir/$destname"
2095         else
2096           func_basename "$file"
2097           destfile="$func_basename_result"
2098           destfile="$destdir/$destfile"
2099         fi
2100
2101         # Deduce the name of the destination old-style object file.
2102         case $destfile in
2103         *.lo)
2104           func_lo2o "$destfile"
2105           staticdest=$func_lo2o_result
2106           ;;
2107         *.$objext)
2108           staticdest="$destfile"
2109           destfile=
2110           ;;
2111         *)
2112           func_fatal_help "cannot copy a libtool object to \`$destfile'"
2113           ;;
2114         esac
2115
2116         # Install the libtool object if requested.
2117         test -n "$destfile" && \
2118           func_show_eval "$install_prog $file $destfile" 'exit $?'
2119
2120         # Install the old object if enabled.
2121         if test "$build_old_libs" = yes; then
2122           # Deduce the name of the old-style object file.
2123           func_lo2o "$file"
2124           staticobj=$func_lo2o_result
2125           func_show_eval "$install_prog \$staticobj \$staticdest" 'exit $?'
2126         fi
2127         exit $EXIT_SUCCESS
2128         ;;
2129
2130       *)
2131         # Figure out destination file name, if it wasn't already specified.
2132         if test -n "$destname"; then
2133           destfile="$destdir/$destname"
2134         else
2135           func_basename "$file"
2136           destfile="$func_basename_result"
2137           destfile="$destdir/$destfile"
2138         fi
2139
2140         # If the file is missing, and there is a .exe on the end, strip it
2141         # because it is most likely a libtool script we actually want to
2142         # install
2143         stripped_ext=""
2144         case $file in
2145           *.exe)
2146             if test ! -f "$file"; then
2147               func_stripname '' '.exe' "$file"
2148               file=$func_stripname_result
2149               stripped_ext=".exe"
2150             fi
2151             ;;
2152         esac
2153
2154         # Do a test to see if this is really a libtool program.
2155         case $host in
2156         *cygwin* | *mingw*)
2157             if func_ltwrapper_executable_p "$file"; then
2158               func_ltwrapper_scriptname "$file"
2159               wrapper=$func_ltwrapper_scriptname_result
2160             else
2161               func_stripname '' '.exe' "$file"
2162               wrapper=$func_stripname_result
2163             fi
2164             ;;
2165         *)
2166             wrapper=$file
2167             ;;
2168         esac
2169         if func_ltwrapper_script_p "$wrapper"; then
2170           notinst_deplibs=
2171           relink_command=
2172
2173           func_source "$wrapper"
2174
2175           # Check the variables that should have been set.
2176           test -z "$generated_by_libtool_version" && \
2177             func_fatal_error "invalid libtool wrapper script \`$wrapper'"
2178
2179           finalize=yes
2180           for lib in $notinst_deplibs; do
2181             # Check to see that each library is installed.
2182             libdir=
2183             if test -f "$lib"; then
2184               func_source "$lib"
2185             fi
2186             libfile="$libdir/"`$ECHO "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
2187             if test -n "$libdir" && test ! -f "$libfile"; then
2188               func_warning "\`$lib' has not been installed in \`$libdir'"
2189               finalize=no
2190             fi
2191           done
2192
2193           relink_command=
2194           func_source "$wrapper"
2195
2196           outputname=
2197           if test "$fast_install" = no && test -n "$relink_command"; then
2198             $opt_dry_run || {
2199               if test "$finalize" = yes; then
2200                 tmpdir=`func_mktempdir`
2201                 func_basename "$file$stripped_ext"
2202                 file="$func_basename_result"
2203                 outputname="$tmpdir/$file"
2204                 # Replace the output file specification.
2205                 relink_command=`$ECHO "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
2206
2207                 $opt_silent || {
2208                   func_quote_for_expand "$relink_command"
2209                   eval "func_echo $func_quote_for_expand_result"
2210                 }
2211                 if eval "$relink_command"; then :
2212                   else
2213                   func_error "error: relink \`$file' with the above command before installing it"
2214                   $opt_dry_run || ${RM}r "$tmpdir"
2215                   continue
2216                 fi
2217                 file="$outputname"
2218               else
2219                 func_warning "cannot relink \`$file'"
2220               fi
2221             }
2222           else
2223             # Install the binary that we compiled earlier.
2224             file=`$ECHO "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
2225           fi
2226         fi
2227
2228         # remove .exe since cygwin /usr/bin/install will append another
2229         # one anyway
2230         case $install_prog,$host in
2231         */usr/bin/install*,*cygwin*)
2232           case $file:$destfile in
2233           *.exe:*.exe)
2234             # this is ok
2235             ;;
2236           *.exe:*)
2237             destfile=$destfile.exe
2238             ;;
2239           *:*.exe)
2240             func_stripname '' '.exe' "$destfile"
2241             destfile=$func_stripname_result
2242             ;;
2243           esac
2244           ;;
2245         esac
2246         func_show_eval "$install_prog\$stripme \$file \$destfile" 'exit $?'
2247         $opt_dry_run || if test -n "$outputname"; then
2248           ${RM}r "$tmpdir"
2249         fi
2250         ;;
2251       esac
2252     done
2253
2254     for file in $staticlibs; do
2255       func_basename "$file"
2256       name="$func_basename_result"
2257
2258       # Set up the ranlib parameters.
2259       oldlib="$destdir/$name"
2260
2261       func_show_eval "$install_prog \$file \$oldlib" 'exit $?'
2262
2263       if test -n "$stripme" && test -n "$old_striplib"; then
2264         func_show_eval "$old_striplib $oldlib" 'exit $?'
2265       fi
2266
2267       # Do each command in the postinstall commands.
2268       func_execute_cmds "$old_postinstall_cmds" 'exit $?'
2269     done
2270
2271     test -n "$future_libdirs" && \
2272       func_warning "remember to run \`$progname --finish$future_libdirs'"
2273
2274     if test -n "$current_libdirs"; then
2275       # Maybe just do a dry run.
2276       $opt_dry_run && current_libdirs=" -n$current_libdirs"
2277       exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
2278     else
2279       exit $EXIT_SUCCESS
2280     fi
2281 }
2282
2283 test "$mode" = install && func_mode_install ${1+"$@"}
2284
2285
2286 # func_generate_dlsyms outputname originator pic_p
2287 # Extract symbols from dlprefiles and create ${outputname}S.o with
2288 # a dlpreopen symbol table.
2289 func_generate_dlsyms ()
2290 {
2291     $opt_debug
2292     my_outputname="$1"
2293     my_originator="$2"
2294     my_pic_p="${3-no}"
2295     my_prefix=`$ECHO "$my_originator" | sed 's%[^a-zA-Z0-9]%_%g'`
2296     my_dlsyms=
2297
2298     if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2299       if test -n "$NM" && test -n "$global_symbol_pipe"; then
2300         my_dlsyms="${my_outputname}S.c"
2301       else
2302         func_error "not configured to extract global symbols from dlpreopened files"
2303       fi
2304     fi
2305
2306     if test -n "$my_dlsyms"; then
2307       case $my_dlsyms in
2308       "") ;;
2309       *.c)
2310         # Discover the nlist of each of the dlfiles.
2311         nlist="$output_objdir/${my_outputname}.nm"
2312
2313         func_show_eval "$RM $nlist ${nlist}S ${nlist}T"
2314
2315         # Parse the name list into a source file.
2316         func_verbose "creating $output_objdir/$my_dlsyms"
2317
2318         $opt_dry_run || $ECHO > "$output_objdir/$my_dlsyms" "\
2319 /* $my_dlsyms - symbol resolution table for \`$my_outputname' dlsym emulation. */
2320 /* Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION */
2321
2322 #ifdef __cplusplus
2323 extern \"C\" {
2324 #endif
2325
2326 #if defined(__GNUC__) && (((__GNUC__ == 4) && (__GNUC_MINOR__ >= 4)) || (__GNUC__ > 4))
2327 #pragma GCC diagnostic ignored \"-Wstrict-prototypes\"
2328 #endif
2329
2330 /* External symbol declarations for the compiler. */\
2331 "
2332
2333         if test "$dlself" = yes; then
2334           func_verbose "generating symbol list for \`$output'"
2335
2336           $opt_dry_run || echo ': @PROGRAM@ ' > "$nlist"
2337
2338           # Add our own program objects to the symbol list.
2339           progfiles=`$ECHO "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
2340           for progfile in $progfiles; do
2341             func_verbose "extracting global C symbols from \`$progfile'"
2342             $opt_dry_run || eval "$NM $progfile | $global_symbol_pipe >> '$nlist'"
2343           done
2344
2345           if test -n "$exclude_expsyms"; then
2346             $opt_dry_run || {
2347               eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
2348               eval '$MV "$nlist"T "$nlist"'
2349             }
2350           fi
2351
2352           if test -n "$export_symbols_regex"; then
2353             $opt_dry_run || {
2354               eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
2355               eval '$MV "$nlist"T "$nlist"'
2356             }
2357           fi
2358
2359           # Prepare the list of exported symbols
2360           if test -z "$export_symbols"; then
2361             export_symbols="$output_objdir/$outputname.exp"
2362             $opt_dry_run || {
2363               $RM $export_symbols
2364               eval "${SED} -n -e '/^: @PROGRAM@ $/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
2365               case $host in
2366               *cygwin* | *mingw* | *cegcc* )
2367                 eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2368                 eval 'cat "$export_symbols" >> "$output_objdir/$outputname.def"'
2369                 ;;
2370               esac
2371             }
2372           else
2373             $opt_dry_run || {
2374               eval "${SED} -e 's/\([].[*^$]\)/\\\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$outputname.exp"'
2375               eval '$GREP -f "$output_objdir/$outputname.exp" < "$nlist" > "$nlist"T'
2376               eval '$MV "$nlist"T "$nlist"'
2377               case $host in
2378                 *cygwin | *mingw* | *cegcc* )
2379                   eval "echo EXPORTS "'> "$output_objdir/$outputname.def"'
2380                   eval 'cat "$nlist" >> "$output_objdir/$outputname.def"'
2381                   ;;
2382               esac
2383             }
2384           fi
2385         fi
2386
2387         for dlprefile in $dlprefiles; do
2388           func_verbose "extracting global C symbols from \`$dlprefile'"
2389           func_basename "$dlprefile"
2390           name="$func_basename_result"
2391           $opt_dry_run || {
2392             eval '$ECHO ": $name " >> "$nlist"'
2393             eval "$NM $dlprefile 2>/dev/null | $global_symbol_pipe >> '$nlist'"
2394           }
2395         done
2396
2397         $opt_dry_run || {
2398           # Make sure we have at least an empty file.
2399           test -f "$nlist" || : > "$nlist"
2400
2401           if test -n "$exclude_expsyms"; then
2402             $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
2403             $MV "$nlist"T "$nlist"
2404           fi
2405
2406           # Try sorting and uniquifying the output.
2407           if $GREP -v "^: " < "$nlist" |
2408               if sort -k 3 </dev/null >/dev/null 2>&1; then
2409                 sort -k 3
2410               else
2411                 sort +2
2412               fi |
2413               uniq > "$nlist"S; then
2414             :
2415           else
2416             $GREP -v "^: " < "$nlist" > "$nlist"S
2417           fi
2418
2419           if test -f "$nlist"S; then
2420             eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$my_dlsyms"'
2421           else
2422             $ECHO '/* NONE */' >> "$output_objdir/$my_dlsyms"
2423           fi
2424
2425           $ECHO >> "$output_objdir/$my_dlsyms" "\
2426
2427 /* The mapping between symbol names and symbols.  */
2428 typedef struct {
2429   const char *name;
2430   void *address;
2431 } lt_dlsymlist;
2432 "
2433           case $host in
2434           *cygwin* | *mingw* | *cegcc* )
2435             $ECHO >> "$output_objdir/$my_dlsyms" "\
2436 /* DATA imports from DLLs on WIN32 con't be const, because
2437    runtime relocations are performed -- see ld's documentation
2438    on pseudo-relocs.  */"
2439             lt_dlsym_const= ;;
2440           *osf5*)
2441             echo >> "$output_objdir/$my_dlsyms" "\
2442 /* This system does not cope well with relocations in const data */"
2443             lt_dlsym_const= ;;
2444           *)
2445             lt_dlsym_const=const ;;
2446           esac
2447
2448           $ECHO >> "$output_objdir/$my_dlsyms" "\
2449 extern $lt_dlsym_const lt_dlsymlist
2450 lt_${my_prefix}_LTX_preloaded_symbols[];
2451 $lt_dlsym_const lt_dlsymlist
2452 lt_${my_prefix}_LTX_preloaded_symbols[] =
2453 {\
2454   { \"$my_originator\", (void *) 0 },"
2455
2456           case $need_lib_prefix in
2457           no)
2458             eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$my_dlsyms"
2459             ;;
2460           *)
2461             eval "$global_symbol_to_c_name_address_lib_prefix" < "$nlist" >> "$output_objdir/$my_dlsyms"
2462             ;;
2463           esac
2464           $ECHO >> "$output_objdir/$my_dlsyms" "\
2465   {0, (void *) 0}
2466 };
2467
2468 /* This works around a problem in FreeBSD linker */
2469 #ifdef FREEBSD_WORKAROUND
2470 static const void *lt_preloaded_setup() {
2471   return lt_${my_prefix}_LTX_preloaded_symbols;
2472 }
2473 #endif
2474
2475 #ifdef __cplusplus
2476 }
2477 #endif\
2478 "
2479         } # !$opt_dry_run
2480
2481         pic_flag_for_symtable=
2482         case "$compile_command " in
2483         *" -static "*) ;;
2484         *)
2485           case $host in
2486           # compiling the symbol table file with pic_flag works around
2487           # a FreeBSD bug that causes programs to crash when -lm is
2488           # linked before any other PIC object.  But we must not use
2489           # pic_flag when linking with -static.  The problem exists in
2490           # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
2491           *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
2492             pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND" ;;
2493           *-*-hpux*)
2494             pic_flag_for_symtable=" $pic_flag"  ;;
2495           *)
2496             if test "X$my_pic_p" != Xno; then
2497               pic_flag_for_symtable=" $pic_flag"
2498             fi
2499             ;;
2500           esac
2501           ;;
2502         esac
2503         symtab_cflags=
2504         for arg in $LTCFLAGS; do
2505           case $arg in
2506           -pie | -fpie | -fPIE) ;;
2507           *) symtab_cflags="$symtab_cflags $arg" ;;
2508           esac
2509         done
2510
2511         # Now compile the dynamic symbol file.
2512         func_show_eval '(cd $output_objdir && $LTCC$symtab_cflags -c$no_builtin_flag$pic_flag_for_symtable "$my_dlsyms")' 'exit $?'
2513
2514         # Clean up the generated files.
2515         func_show_eval '$RM "$output_objdir/$my_dlsyms" "$nlist" "${nlist}S" "${nlist}T"'
2516
2517         # Transform the symbol file into the correct name.
2518         symfileobj="$output_objdir/${my_outputname}S.$objext"
2519         case $host in
2520         *cygwin* | *mingw* | *cegcc* )
2521           if test -f "$output_objdir/$my_outputname.def"; then
2522             compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2523             finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/$my_outputname.def $symfileobj%"`
2524           else
2525             compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2526             finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2527           fi
2528           ;;
2529         *)
2530           compile_command=`$ECHO "X$compile_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2531           finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$symfileobj%"`
2532           ;;
2533         esac
2534         ;;
2535       *)
2536         func_fatal_error "unknown suffix for \`$my_dlsyms'"
2537         ;;
2538       esac
2539     else
2540       # We keep going just in case the user didn't refer to
2541       # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
2542       # really was required.
2543
2544       # Nullify the symbol file.
2545       compile_command=`$ECHO "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
2546       finalize_command=`$ECHO "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
2547     fi
2548 }
2549
2550 # func_win32_libid arg
2551 # return the library type of file 'arg'
2552 #
2553 # Need a lot of goo to handle *both* DLLs and import libs
2554 # Has to be a shell function in order to 'eat' the argument
2555 # that is supplied when $file_magic_command is called.
2556 func_win32_libid ()
2557 {
2558   $opt_debug
2559   win32_libid_type="unknown"
2560   win32_fileres=`file -L $1 2>/dev/null`
2561   case $win32_fileres in
2562   *ar\ archive\ import\ library*) # definitely import
2563     win32_libid_type="x86 archive import"
2564     ;;
2565   *ar\ archive*) # could be an import, or static
2566     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null |
2567        $EGREP 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
2568       win32_nmres=`eval $NM -f posix -A $1 |
2569         $SED -n -e '
2570             1,100{
2571                 / I /{
2572                     s,.*,import,
2573                     p
2574                     q
2575                 }
2576             }'`
2577       case $win32_nmres in
2578       import*)  win32_libid_type="x86 archive import";;
2579       *)        win32_libid_type="x86 archive static";;
2580       esac
2581     fi
2582     ;;
2583   *DLL*)
2584     win32_libid_type="x86 DLL"
2585     ;;
2586   *executable*) # but shell scripts are "executable" too...
2587     case $win32_fileres in
2588     *MS\ Windows\ PE\ Intel*)
2589       win32_libid_type="x86 DLL"
2590       ;;
2591     esac
2592     ;;
2593   esac
2594   $ECHO "$win32_libid_type"
2595 }
2596
2597
2598
2599 # func_extract_an_archive dir oldlib
2600 func_extract_an_archive ()
2601 {
2602     $opt_debug
2603     f_ex_an_ar_dir="$1"; shift
2604     f_ex_an_ar_oldlib="$1"
2605     func_show_eval "(cd \$f_ex_an_ar_dir && $AR x \"\$f_ex_an_ar_oldlib\")" 'exit $?'
2606     if ($AR t "$f_ex_an_ar_oldlib" | sort | sort -uc >/dev/null 2>&1); then
2607      :
2608     else
2609       func_fatal_error "object name conflicts in archive: $f_ex_an_ar_dir/$f_ex_an_ar_oldlib"
2610     fi
2611 }
2612
2613
2614 # func_extract_archives gentop oldlib ...
2615 func_extract_archives ()
2616 {
2617     $opt_debug
2618     my_gentop="$1"; shift
2619     my_oldlibs=${1+"$@"}
2620     my_oldobjs=""
2621     my_xlib=""
2622     my_xabs=""
2623     my_xdir=""
2624
2625     for my_xlib in $my_oldlibs; do
2626       # Extract the objects.
2627       case $my_xlib in
2628         [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
2629         *) my_xabs=`pwd`"/$my_xlib" ;;
2630       esac
2631       func_basename "$my_xlib"
2632       my_xlib="$func_basename_result"
2633       my_xlib_u=$my_xlib
2634       while :; do
2635         case " $extracted_archives " in
2636         *" $my_xlib_u "*)
2637           func_arith $extracted_serial + 1
2638           extracted_serial=$func_arith_result
2639           my_xlib_u=lt$extracted_serial-$my_xlib ;;
2640         *) break ;;
2641         esac
2642       done
2643       extracted_archives="$extracted_archives $my_xlib_u"
2644       my_xdir="$my_gentop/$my_xlib_u"
2645
2646       func_mkdir_p "$my_xdir"
2647
2648       case $host in
2649       *-darwin*)
2650         func_verbose "Extracting $my_xabs"
2651         # Do not bother doing anything if just a dry run
2652         $opt_dry_run || {
2653           darwin_orig_dir=`pwd`
2654           cd $my_xdir || exit $?
2655           darwin_archive=$my_xabs
2656           darwin_curdir=`pwd`
2657           darwin_base_archive=`basename "$darwin_archive"`
2658           darwin_arches=`$LIPO -info "$darwin_archive" 2>/dev/null | $GREP Architectures 2>/dev/null || true`
2659           if test -n "$darwin_arches"; then
2660             darwin_arches=`$ECHO "$darwin_arches" | $SED -e 's/.*are://'`
2661             darwin_arch=
2662             func_verbose "$darwin_base_archive has multiple architectures $darwin_arches"
2663             for darwin_arch in  $darwin_arches ; do
2664               func_mkdir_p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2665               $LIPO -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
2666               cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
2667               func_extract_an_archive "`pwd`" "${darwin_base_archive}"
2668               cd "$darwin_curdir"
2669               $RM "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}"
2670             done # $darwin_arches
2671             ## Okay now we've a bunch of thin objects, gotta fatten them up :)
2672             darwin_filelist=`find unfat-$$ -type f -name \*.o -print -o -name \*.lo -print | $SED -e "$basename" | sort -u`
2673             darwin_file=
2674             darwin_files=
2675             for darwin_file in $darwin_filelist; do
2676               darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
2677               $LIPO -create -output "$darwin_file" $darwin_files
2678             done # $darwin_filelist
2679             $RM -rf unfat-$$
2680             cd "$darwin_orig_dir"
2681           else
2682             cd $darwin_orig_dir
2683             func_extract_an_archive "$my_xdir" "$my_xabs"
2684           fi # $darwin_arches
2685         } # !$opt_dry_run
2686         ;;
2687       *)
2688         func_extract_an_archive "$my_xdir" "$my_xabs"
2689         ;;
2690       esac
2691       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
2692     done
2693
2694     func_extract_archives_result="$my_oldobjs"
2695 }
2696
2697
2698
2699 # func_emit_wrapper_part1 [arg=no]
2700 #
2701 # Emit the first part of a libtool wrapper script on stdout.
2702 # For more information, see the description associated with
2703 # func_emit_wrapper(), below.
2704 func_emit_wrapper_part1 ()
2705 {
2706         func_emit_wrapper_part1_arg1=no
2707         if test -n "$1" ; then
2708           func_emit_wrapper_part1_arg1=$1
2709         fi
2710
2711         $ECHO "\
2712 #! $SHELL
2713
2714 # $output - temporary wrapper script for $objdir/$outputname
2715 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
2716 #
2717 # The $output program cannot be directly executed until all the libtool
2718 # libraries that it depends on are installed.
2719 #
2720 # This wrapper script should never be moved out of the build directory.
2721 # If it is, it will not operate correctly.
2722
2723 # Sed substitution that helps us do robust quoting.  It backslashifies
2724 # metacharacters that are still active within double-quoted strings.
2725 Xsed='${SED} -e 1s/^X//'
2726 sed_quote_subst='$sed_quote_subst'
2727
2728 # Be Bourne compatible
2729 if test -n \"\${ZSH_VERSION+set}\" && (emulate sh) >/dev/null 2>&1; then
2730   emulate sh
2731   NULLCMD=:
2732   # Zsh 3.x and 4.x performs word splitting on \${1+\"\$@\"}, which
2733   # is contrary to our usage.  Disable this feature.
2734   alias -g '\${1+\"\$@\"}'='\"\$@\"'
2735   setopt NO_GLOB_SUBST
2736 else
2737   case \`(set -o) 2>/dev/null\` in *posix*) set -o posix;; esac
2738 fi
2739 BIN_SH=xpg4; export BIN_SH # for Tru64
2740 DUALCASE=1; export DUALCASE # for MKS sh
2741
2742 # The HP-UX ksh and POSIX shell print the target directory to stdout
2743 # if CDPATH is set.
2744 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
2745
2746 relink_command=\"$relink_command\"
2747
2748 # This environment variable determines our operation mode.
2749 if test \"\$libtool_install_magic\" = \"$magic\"; then
2750   # install mode needs the following variables:
2751   generated_by_libtool_version='$macro_version'
2752   notinst_deplibs='$notinst_deplibs'
2753 else
2754   # When we are sourced in execute mode, \$file and \$ECHO are already set.
2755   if test \"\$libtool_execute_magic\" != \"$magic\"; then
2756     ECHO=\"$qecho\"
2757     file=\"\$0\"
2758     # Make sure echo works.
2759     if test \"X\$1\" = X--no-reexec; then
2760       # Discard the --no-reexec flag, and continue.
2761       shift
2762     elif test \"X\`{ \$ECHO '\t'; } 2>/dev/null\`\" = 'X\t'; then
2763       # Yippee, \$ECHO works!
2764       :
2765     else
2766       # Restart under the correct shell, and then maybe \$ECHO will work.
2767       exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
2768     fi
2769   fi\
2770 "
2771         $ECHO "\
2772
2773   # Find the directory that this script lives in.
2774   thisdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
2775   test \"x\$thisdir\" = \"x\$file\" && thisdir=.
2776
2777   # Follow symbolic links until we get to the real thisdir.
2778   file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
2779   while test -n \"\$file\"; do
2780     destdir=\`\$ECHO \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
2781
2782     # If there was a directory component, then change thisdir.
2783     if test \"x\$destdir\" != \"x\$file\"; then
2784       case \"\$destdir\" in
2785       [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
2786       *) thisdir=\"\$thisdir/\$destdir\" ;;
2787       esac
2788     fi
2789
2790     file=\`\$ECHO \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
2791     file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
2792   done
2793 "
2794 }
2795 # end: func_emit_wrapper_part1
2796
2797 # func_emit_wrapper_part2 [arg=no]
2798 #
2799 # Emit the second part of a libtool wrapper script on stdout.
2800 # For more information, see the description associated with
2801 # func_emit_wrapper(), below.
2802 func_emit_wrapper_part2 ()
2803 {
2804         func_emit_wrapper_part2_arg1=no
2805         if test -n "$1" ; then
2806           func_emit_wrapper_part2_arg1=$1
2807         fi
2808
2809         $ECHO "\
2810
2811   # Usually 'no', except on cygwin/mingw when embedded into
2812   # the cwrapper.
2813   WRAPPER_SCRIPT_BELONGS_IN_OBJDIR=$func_emit_wrapper_part2_arg1
2814   if test \"\$WRAPPER_SCRIPT_BELONGS_IN_OBJDIR\" = \"yes\"; then
2815     # special case for '.'
2816     if test \"\$thisdir\" = \".\"; then
2817       thisdir=\`pwd\`
2818     fi
2819     # remove .libs from thisdir
2820     case \"\$thisdir\" in
2821     *[\\\\/]$objdir ) thisdir=\`\$ECHO \"X\$thisdir\" | \$Xsed -e 's%[\\\\/][^\\\\/]*$%%'\` ;;
2822     $objdir )   thisdir=. ;;
2823     esac
2824   fi
2825
2826   # Try to get the absolute directory name.
2827   absdir=\`cd \"\$thisdir\" && pwd\`
2828   test -n \"\$absdir\" && thisdir=\"\$absdir\"
2829 "
2830
2831         if test "$fast_install" = yes; then
2832           $ECHO "\
2833   program=lt-'$outputname'$exeext
2834   progdir=\"\$thisdir/$objdir\"
2835
2836   if test ! -f \"\$progdir/\$program\" ||
2837      { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
2838        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
2839
2840     file=\"\$\$-\$program\"
2841
2842     if test ! -d \"\$progdir\"; then
2843       $MKDIR \"\$progdir\"
2844     else
2845       $RM \"\$progdir/\$file\"
2846     fi"
2847
2848           $ECHO "\
2849
2850     # relink executable if necessary
2851     if test -n \"\$relink_command\"; then
2852       if relink_command_output=\`eval \$relink_command 2>&1\`; then :
2853       else
2854         $ECHO \"\$relink_command_output\" >&2
2855         $RM \"\$progdir/\$file\"
2856         exit 1
2857       fi
2858     fi
2859
2860     $MV \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
2861     { $RM \"\$progdir/\$program\";
2862       $MV \"\$progdir/\$file\" \"\$progdir/\$program\"; }
2863     $RM \"\$progdir/\$file\"
2864   fi"
2865         else
2866           $ECHO "\
2867   program='$outputname'
2868   progdir=\"\$thisdir/$objdir\"
2869 "
2870         fi
2871
2872         $ECHO "\
2873
2874   if test -f \"\$progdir/\$program\"; then"
2875
2876         # Export our shlibpath_var if we have one.
2877         if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
2878           $ECHO "\
2879     # Add our own library path to $shlibpath_var
2880     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
2881
2882     # Some systems cannot cope with colon-terminated $shlibpath_var
2883     # The second colon is a workaround for a bug in BeOS R4 sed
2884     $shlibpath_var=\`\$ECHO \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
2885
2886     export $shlibpath_var
2887 "
2888         fi
2889
2890         # fixup the dll searchpath if we need to.
2891         if test -n "$dllsearchpath"; then
2892           $ECHO "\
2893     # Add the dll search path components to the executable PATH
2894     PATH=$dllsearchpath:\$PATH
2895 "
2896         fi
2897
2898         $ECHO "\
2899     if test \"\$libtool_execute_magic\" != \"$magic\"; then
2900       # Run the actual program with our arguments.
2901 "
2902         case $host in
2903         # Backslashes separate directories on plain windows
2904         *-*-mingw | *-*-os2* | *-cegcc*)
2905           $ECHO "\
2906       exec \"\$progdir\\\\\$program\" \${1+\"\$@\"}
2907 "
2908           ;;
2909
2910         *)
2911           $ECHO "\
2912       exec \"\$progdir/\$program\" \${1+\"\$@\"}
2913 "
2914           ;;
2915         esac
2916         $ECHO "\
2917       \$ECHO \"\$0: cannot exec \$program \$*\" 1>&2
2918       exit 1
2919     fi
2920   else
2921     # The program doesn't exist.
2922     \$ECHO \"\$0: error: \\\`\$progdir/\$program' does not exist\" 1>&2
2923     \$ECHO \"This script is just a wrapper for \$program.\" 1>&2
2924     $ECHO \"See the $PACKAGE documentation for more information.\" 1>&2
2925     exit 1
2926   fi
2927 fi\
2928 "
2929 }
2930 # end: func_emit_wrapper_part2
2931
2932
2933 # func_emit_wrapper [arg=no]
2934 #
2935 # Emit a libtool wrapper script on stdout.
2936 # Don't directly open a file because we may want to
2937 # incorporate the script contents within a cygwin/mingw
2938 # wrapper executable.  Must ONLY be called from within
2939 # func_mode_link because it depends on a number of variables
2940 # set therein.
2941 #
2942 # ARG is the value that the WRAPPER_SCRIPT_BELONGS_IN_OBJDIR
2943 # variable will take.  If 'yes', then the emitted script
2944 # will assume that the directory in which it is stored is
2945 # the $objdir directory.  This is a cygwin/mingw-specific
2946 # behavior.
2947 func_emit_wrapper ()
2948 {
2949         func_emit_wrapper_arg1=no
2950         if test -n "$1" ; then
2951           func_emit_wrapper_arg1=$1
2952         fi
2953
2954         # split this up so that func_emit_cwrapperexe_src
2955         # can call each part independently.
2956         func_emit_wrapper_part1 "${func_emit_wrapper_arg1}"
2957         func_emit_wrapper_part2 "${func_emit_wrapper_arg1}"
2958 }
2959
2960
2961 # func_to_host_path arg
2962 #
2963 # Convert paths to host format when used with build tools.
2964 # Intended for use with "native" mingw (where libtool itself
2965 # is running under the msys shell), or in the following cross-
2966 # build environments:
2967 #    $build          $host
2968 #    mingw (msys)    mingw  [e.g. native]
2969 #    cygwin          mingw
2970 #    *nix + wine     mingw
2971 # where wine is equipped with the `winepath' executable.
2972 # In the native mingw case, the (msys) shell automatically
2973 # converts paths for any non-msys applications it launches,
2974 # but that facility isn't available from inside the cwrapper.
2975 # Similar accommodations are necessary for $host mingw and
2976 # $build cygwin.  Calling this function does no harm for other
2977 # $host/$build combinations not listed above.
2978 #
2979 # ARG is the path (on $build) that should be converted to
2980 # the proper representation for $host. The result is stored
2981 # in $func_to_host_path_result.
2982 func_to_host_path ()
2983 {
2984   func_to_host_path_result="$1"
2985   if test -n "$1" ; then
2986     case $host in
2987       *mingw* )
2988         lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
2989         case $build in
2990           *mingw* ) # actually, msys
2991             # awkward: cmd appends spaces to result
2992             lt_sed_strip_trailing_spaces="s/[ ]*\$//"
2993             func_to_host_path_tmp1=`( cmd //c echo "$1" |\
2994               $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
2995             func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
2996               $SED -e "$lt_sed_naive_backslashify"`
2997             ;;
2998           *cygwin* )
2999             func_to_host_path_tmp1=`cygpath -w "$1"`
3000             func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3001               $SED -e "$lt_sed_naive_backslashify"`
3002             ;;
3003           * )
3004             # Unfortunately, winepath does not exit with a non-zero
3005             # error code, so we are forced to check the contents of
3006             # stdout. On the other hand, if the command is not
3007             # found, the shell will set an exit code of 127 and print
3008             # *an error message* to stdout. So we must check for both
3009             # error code of zero AND non-empty stdout, which explains
3010             # the odd construction:
3011             func_to_host_path_tmp1=`winepath -w "$1" 2>/dev/null`
3012             if test "$?" -eq 0 && test -n "${func_to_host_path_tmp1}"; then
3013               func_to_host_path_result=`echo "$func_to_host_path_tmp1" |\
3014                 $SED -e "$lt_sed_naive_backslashify"`
3015             else
3016               # Allow warning below.
3017               func_to_host_path_result=""
3018             fi
3019             ;;
3020         esac
3021         if test -z "$func_to_host_path_result" ; then
3022           func_error "Could not determine host path corresponding to"
3023           func_error "  '$1'"
3024           func_error "Continuing, but uninstalled executables may not work."
3025           # Fallback:
3026           func_to_host_path_result="$1"
3027         fi
3028         ;;
3029     esac
3030   fi
3031 }
3032 # end: func_to_host_path
3033
3034 # func_to_host_pathlist arg
3035 #
3036 # Convert pathlists to host format when used with build tools.
3037 # See func_to_host_path(), above. This function supports the
3038 # following $build/$host combinations (but does no harm for
3039 # combinations not listed here):
3040 #    $build          $host
3041 #    mingw (msys)    mingw  [e.g. native]
3042 #    cygwin          mingw
3043 #    *nix + wine     mingw
3044 #
3045 # Path separators are also converted from $build format to
3046 # $host format. If ARG begins or ends with a path separator
3047 # character, it is preserved (but converted to $host format)
3048 # on output.
3049 #
3050 # ARG is a pathlist (on $build) that should be converted to
3051 # the proper representation on $host. The result is stored
3052 # in $func_to_host_pathlist_result.
3053 func_to_host_pathlist ()
3054 {
3055   func_to_host_pathlist_result="$1"
3056   if test -n "$1" ; then
3057     case $host in
3058       *mingw* )
3059         lt_sed_naive_backslashify='s|\\\\*|\\|g;s|/|\\|g;s|\\|\\\\|g'
3060         # Remove leading and trailing path separator characters from
3061         # ARG. msys behavior is inconsistent here, cygpath turns them
3062         # into '.;' and ';.', and winepath ignores them completely.
3063         func_to_host_pathlist_tmp2="$1"
3064         # Once set for this call, this variable should not be
3065         # reassigned. It is used in tha fallback case.
3066         func_to_host_pathlist_tmp1=`echo "$func_to_host_pathlist_tmp2" |\
3067           $SED -e 's|^:*||' -e 's|:*$||'`
3068         case $build in
3069           *mingw* ) # Actually, msys.
3070             # Awkward: cmd appends spaces to result.
3071             lt_sed_strip_trailing_spaces="s/[ ]*\$//"
3072             func_to_host_pathlist_tmp2=`( cmd //c echo "$func_to_host_pathlist_tmp1" |\
3073               $SED -e "$lt_sed_strip_trailing_spaces" ) 2>/dev/null || echo ""`
3074             func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3075               $SED -e "$lt_sed_naive_backslashify"`
3076             ;;
3077           *cygwin* )
3078             func_to_host_pathlist_tmp2=`cygpath -w -p "$func_to_host_pathlist_tmp1"`
3079             func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp2" |\
3080               $SED -e "$lt_sed_naive_backslashify"`
3081             ;;
3082           * )
3083             # unfortunately, winepath doesn't convert pathlists
3084             func_to_host_pathlist_result=""
3085             func_to_host_pathlist_oldIFS=$IFS
3086             IFS=:
3087             for func_to_host_pathlist_f in $func_to_host_pathlist_tmp1 ; do
3088               IFS=$func_to_host_pathlist_oldIFS
3089               if test -n "$func_to_host_pathlist_f" ; then
3090                 func_to_host_path "$func_to_host_pathlist_f"
3091                 if test -n "$func_to_host_path_result" ; then
3092                   if test -z "$func_to_host_pathlist_result" ; then
3093                     func_to_host_pathlist_result="$func_to_host_path_result"
3094                   else
3095                     func_to_host_pathlist_result="$func_to_host_pathlist_result;$func_to_host_path_result"
3096                   fi
3097                 fi
3098               fi
3099               IFS=:
3100             done
3101             IFS=$func_to_host_pathlist_oldIFS
3102             ;;
3103         esac
3104         if test -z "$func_to_host_pathlist_result" ; then
3105           func_error "Could not determine the host path(s) corresponding to"
3106           func_error "  '$1'"
3107           func_error "Continuing, but uninstalled executables may not work."
3108           # Fallback. This may break if $1 contains DOS-style drive
3109           # specifications. The fix is not to complicate the expression
3110           # below, but for the user to provide a working wine installation
3111           # with winepath so that path translation in the cross-to-mingw
3112           # case works properly.
3113           lt_replace_pathsep_nix_to_dos="s|:|;|g"
3114           func_to_host_pathlist_result=`echo "$func_to_host_pathlist_tmp1" |\
3115             $SED -e "$lt_replace_pathsep_nix_to_dos"`
3116         fi
3117         # Now, add the leading and trailing path separators back
3118         case "$1" in
3119           :* ) func_to_host_pathlist_result=";$func_to_host_pathlist_result"
3120             ;;
3121         esac
3122         case "$1" in
3123           *: ) func_to_host_pathlist_result="$func_to_host_pathlist_result;"
3124             ;;
3125         esac
3126         ;;
3127     esac
3128   fi
3129 }
3130 # end: func_to_host_pathlist
3131
3132 # func_emit_cwrapperexe_src
3133 # emit the source code for a wrapper executable on stdout
3134 # Must ONLY be called from within func_mode_link because
3135 # it depends on a number of variable set therein.
3136 func_emit_cwrapperexe_src ()
3137 {
3138         cat <<EOF
3139
3140 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
3141    Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
3142
3143    The $output program cannot be directly executed until all the libtool
3144    libraries that it depends on are installed.
3145
3146    This wrapper executable should never be moved out of the build directory.
3147    If it is, it will not operate correctly.
3148
3149    Currently, it simply execs the wrapper *script* "$SHELL $output",
3150    but could eventually absorb all of the scripts functionality and
3151    exec $objdir/$outputname directly.
3152 */
3153 EOF
3154             cat <<"EOF"
3155 #include <stdio.h>
3156 #include <stdlib.h>
3157 #ifdef _MSC_VER
3158 # include <direct.h>
3159 # include <process.h>
3160 # include <io.h>
3161 # define setmode _setmode
3162 #else
3163 # include <unistd.h>
3164 # include <stdint.h>
3165 # ifdef __CYGWIN__
3166 #  include <io.h>
3167 #  define HAVE_SETENV
3168 #  ifdef __STRICT_ANSI__
3169 char *realpath (const char *, char *);
3170 int putenv (char *);
3171 int setenv (const char *, const char *, int);
3172 #  endif
3173 # endif
3174 #endif
3175 #include <malloc.h>
3176 #include <stdarg.h>
3177 #include <assert.h>
3178 #include <string.h>
3179 #include <ctype.h>
3180 #include <errno.h>
3181 #include <fcntl.h>
3182 #include <sys/stat.h>
3183
3184 #if defined(PATH_MAX)
3185 # define LT_PATHMAX PATH_MAX
3186 #elif defined(MAXPATHLEN)
3187 # define LT_PATHMAX MAXPATHLEN
3188 #else
3189 # define LT_PATHMAX 1024
3190 #endif
3191
3192 #ifndef S_IXOTH
3193 # define S_IXOTH 0
3194 #endif
3195 #ifndef S_IXGRP
3196 # define S_IXGRP 0
3197 #endif
3198
3199 #ifdef _MSC_VER
3200 # define S_IXUSR _S_IEXEC
3201 # define stat _stat
3202 # ifndef _INTPTR_T_DEFINED
3203 #  define intptr_t int
3204 # endif
3205 #endif
3206
3207 #ifndef DIR_SEPARATOR
3208 # define DIR_SEPARATOR '/'
3209 # define PATH_SEPARATOR ':'
3210 #endif
3211
3212 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
3213   defined (__OS2__)
3214 # define HAVE_DOS_BASED_FILE_SYSTEM
3215 # define FOPEN_WB "wb"
3216 # ifndef DIR_SEPARATOR_2
3217 #  define DIR_SEPARATOR_2 '\\'
3218 # endif
3219 # ifndef PATH_SEPARATOR_2
3220 #  define PATH_SEPARATOR_2 ';'
3221 # endif
3222 #endif
3223
3224 #ifndef DIR_SEPARATOR_2
3225 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
3226 #else /* DIR_SEPARATOR_2 */
3227 # define IS_DIR_SEPARATOR(ch) \
3228         (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
3229 #endif /* DIR_SEPARATOR_2 */
3230
3231 #ifndef PATH_SEPARATOR_2
3232 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR)
3233 #else /* PATH_SEPARATOR_2 */
3234 # define IS_PATH_SEPARATOR(ch) ((ch) == PATH_SEPARATOR_2)
3235 #endif /* PATH_SEPARATOR_2 */
3236
3237 #ifdef __CYGWIN__
3238 # define FOPEN_WB "wb"
3239 #endif
3240
3241 #ifndef FOPEN_WB
3242 # define FOPEN_WB "w"
3243 #endif
3244 #ifndef _O_BINARY
3245 # define _O_BINARY 0
3246 #endif
3247
3248 #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
3249 #define XFREE(stale) do { \
3250   if (stale) { free ((void *) stale); stale = 0; } \
3251 } while (0)
3252
3253 #undef LTWRAPPER_DEBUGPRINTF
3254 #if defined DEBUGWRAPPER
3255 # define LTWRAPPER_DEBUGPRINTF(args) ltwrapper_debugprintf args
3256 static void
3257 ltwrapper_debugprintf (const char *fmt, ...)
3258 {
3259     va_list args;
3260     va_start (args, fmt);
3261     (void) vfprintf (stderr, fmt, args);
3262     va_end (args);
3263 }
3264 #else
3265 # define LTWRAPPER_DEBUGPRINTF(args)
3266 #endif
3267
3268 const char *program_name = NULL;
3269
3270 void *xmalloc (size_t num);
3271 char *xstrdup (const char *string);
3272 const char *base_name (const char *name);
3273 char *find_executable (const char *wrapper);
3274 char *chase_symlinks (const char *pathspec);
3275 int make_executable (const char *path);
3276 int check_executable (const char *path);
3277 char *strendzap (char *str, const char *pat);
3278 void lt_fatal (const char *message, ...);
3279 void lt_setenv (const char *name, const char *value);
3280 char *lt_extend_str (const char *orig_value, const char *add, int to_end);
3281 void lt_opt_process_env_set (const char *arg);
3282 void lt_opt_process_env_prepend (const char *arg);
3283 void lt_opt_process_env_append (const char *arg);
3284 int lt_split_name_value (const char *arg, char** name, char** value);
3285 void lt_update_exe_path (const char *name, const char *value);
3286 void lt_update_lib_path (const char *name, const char *value);
3287
3288 static const char *script_text_part1 =
3289 EOF
3290
3291             func_emit_wrapper_part1 yes |
3292                 $SED -e 's/\([\\"]\)/\\\1/g' \
3293                      -e 's/^/  "/' -e 's/$/\\n"/'
3294             echo ";"
3295             cat <<EOF
3296
3297 static const char *script_text_part2 =
3298 EOF
3299             func_emit_wrapper_part2 yes |
3300                 $SED -e 's/\([\\"]\)/\\\1/g' \
3301                      -e 's/^/  "/' -e 's/$/\\n"/'
3302             echo ";"
3303
3304             cat <<EOF
3305 const char * MAGIC_EXE = "$magic_exe";
3306 const char * LIB_PATH_VARNAME = "$shlibpath_var";
3307 EOF
3308
3309             if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
3310               func_to_host_pathlist "$temp_rpath"
3311               cat <<EOF
3312 const char * LIB_PATH_VALUE   = "$func_to_host_pathlist_result";
3313 EOF
3314             else
3315               cat <<"EOF"
3316 const char * LIB_PATH_VALUE   = "";
3317 EOF
3318             fi
3319
3320             if test -n "$dllsearchpath"; then
3321               func_to_host_pathlist "$dllsearchpath:"
3322               cat <<EOF
3323 const char * EXE_PATH_VARNAME = "PATH";
3324 const char * EXE_PATH_VALUE   = "$func_to_host_pathlist_result";
3325 EOF
3326             else
3327               cat <<"EOF"
3328 const char * EXE_PATH_VARNAME = "";
3329 const char * EXE_PATH_VALUE   = "";
3330 EOF
3331             fi
3332
3333             if test "$fast_install" = yes; then
3334               cat <<EOF
3335 const char * TARGET_PROGRAM_NAME = "lt-$outputname"; /* hopefully, no .exe */
3336 EOF
3337             else
3338               cat <<EOF
3339 const char * TARGET_PROGRAM_NAME = "$outputname"; /* hopefully, no .exe */
3340 EOF
3341             fi
3342
3343
3344             cat <<"EOF"
3345
3346 #define LTWRAPPER_OPTION_PREFIX         "--lt-"
3347 #define LTWRAPPER_OPTION_PREFIX_LENGTH  5
3348
3349 static const size_t opt_prefix_len         = LTWRAPPER_OPTION_PREFIX_LENGTH;
3350 static const char *ltwrapper_option_prefix = LTWRAPPER_OPTION_PREFIX;
3351
3352 static const char *dumpscript_opt       = LTWRAPPER_OPTION_PREFIX "dump-script";
3353
3354 static const size_t env_set_opt_len     = LTWRAPPER_OPTION_PREFIX_LENGTH + 7;
3355 static const char *env_set_opt          = LTWRAPPER_OPTION_PREFIX "env-set";
3356   /* argument is putenv-style "foo=bar", value of foo is set to bar */
3357
3358 static const size_t env_prepend_opt_len = LTWRAPPER_OPTION_PREFIX_LENGTH + 11;
3359 static const char *env_prepend_opt      = LTWRAPPER_OPTION_PREFIX "env-prepend";
3360   /* argument is putenv-style "foo=bar", new value of foo is bar${foo} */
3361
3362 static const size_t env_append_opt_len  = LTWRAPPER_OPTION_PREFIX_LENGTH + 10;
3363 static const char *env_append_opt       = LTWRAPPER_OPTION_PREFIX "env-append";
3364   /* argument is putenv-style "foo=bar", new value of foo is ${foo}bar */
3365
3366 int
3367 main (int argc, char *argv[])
3368 {
3369   char **newargz;
3370   int  newargc;
3371   char *tmp_pathspec;
3372   char *actual_cwrapper_path;
3373   char *actual_cwrapper_name;
3374   char *target_name;
3375   char *lt_argv_zero;
3376   intptr_t rval = 127;
3377
3378   int i;
3379
3380   program_name = (char *) xstrdup (base_name (argv[0]));
3381   LTWRAPPER_DEBUGPRINTF (("(main) argv[0]      : %s\n", argv[0]));
3382   LTWRAPPER_DEBUGPRINTF (("(main) program_name : %s\n", program_name));
3383
3384   /* very simple arg parsing; don't want to rely on getopt */
3385   for (i = 1; i < argc; i++)
3386     {
3387       if (strcmp (argv[i], dumpscript_opt) == 0)
3388         {
3389 EOF
3390             case "$host" in
3391               *mingw* | *cygwin* )
3392                 # make stdout use "unix" line endings
3393                 echo "          setmode(1,_O_BINARY);"
3394                 ;;
3395               esac
3396
3397             cat <<"EOF"
3398           printf ("%s", script_text_part1);
3399           printf ("%s", script_text_part2);
3400           return 0;
3401         }
3402     }
3403
3404   newargz = XMALLOC (char *, argc + 1);
3405   tmp_pathspec = find_executable (argv[0]);
3406   if (tmp_pathspec == NULL)
3407     lt_fatal ("Couldn't find %s", argv[0]);
3408   LTWRAPPER_DEBUGPRINTF (("(main) found exe (before symlink chase) at : %s\n",
3409                           tmp_pathspec));
3410
3411   actual_cwrapper_path = chase_symlinks (tmp_pathspec);
3412   LTWRAPPER_DEBUGPRINTF (("(main) found exe (after symlink chase) at : %s\n",
3413                           actual_cwrapper_path));
3414   XFREE (tmp_pathspec);
3415
3416   actual_cwrapper_name = xstrdup( base_name (actual_cwrapper_path));
3417   strendzap (actual_cwrapper_path, actual_cwrapper_name);
3418
3419   /* wrapper name transforms */
3420   strendzap (actual_cwrapper_name, ".exe");
3421   tmp_pathspec = lt_extend_str (actual_cwrapper_name, ".exe", 1);
3422   XFREE (actual_cwrapper_name);
3423   actual_cwrapper_name = tmp_pathspec;
3424   tmp_pathspec = 0;
3425
3426   /* target_name transforms -- use actual target program name; might have lt- prefix */
3427   target_name = xstrdup (base_name (TARGET_PROGRAM_NAME));
3428   strendzap (target_name, ".exe");
3429   tmp_pathspec = lt_extend_str (target_name, ".exe", 1);
3430   XFREE (target_name);
3431   target_name = tmp_pathspec;
3432   tmp_pathspec = 0;
3433
3434   LTWRAPPER_DEBUGPRINTF (("(main) libtool target name: %s\n",
3435                           target_name));
3436 EOF
3437
3438             cat <<EOF
3439   newargz[0] =
3440     XMALLOC (char, (strlen (actual_cwrapper_path) +
3441                     strlen ("$objdir") + 1 + strlen (actual_cwrapper_name) + 1));
3442   strcpy (newargz[0], actual_cwrapper_path);
3443   strcat (newargz[0], "$objdir");
3444   strcat (newargz[0], "/");
3445 EOF
3446
3447             cat <<"EOF"
3448   /* stop here, and copy so we don't have to do this twice */
3449   tmp_pathspec = xstrdup (newargz[0]);
3450
3451   /* do NOT want the lt- prefix here, so use actual_cwrapper_name */
3452   strcat (newargz[0], actual_cwrapper_name);
3453
3454   /* DO want the lt- prefix here if it exists, so use target_name */
3455   lt_argv_zero = lt_extend_str (tmp_pathspec, target_name, 1);
3456   XFREE (tmp_pathspec);
3457   tmp_pathspec = NULL;
3458 EOF
3459
3460             case $host_os in
3461               mingw*)
3462             cat <<"EOF"
3463   {
3464     char* p;
3465     while ((p = strchr (newargz[0], '\\')) != NULL)
3466       {
3467         *p = '/';
3468       }
3469     while ((p = strchr (lt_argv_zero, '\\')) != NULL)
3470       {
3471         *p = '/';
3472       }
3473   }
3474 EOF
3475             ;;
3476             esac
3477
3478             cat <<"EOF"
3479   XFREE (target_name);
3480   XFREE (actual_cwrapper_path);
3481   XFREE (actual_cwrapper_name);
3482
3483   lt_setenv ("BIN_SH", "xpg4"); /* for Tru64 */
3484   lt_setenv ("DUALCASE", "1");  /* for MSK sh */
3485   lt_update_lib_path (LIB_PATH_VARNAME, LIB_PATH_VALUE);
3486   lt_update_exe_path (EXE_PATH_VARNAME, EXE_PATH_VALUE);
3487
3488   newargc=0;
3489   for (i = 1; i < argc; i++)
3490     {
3491       if (strncmp (argv[i], env_set_opt, env_set_opt_len) == 0)
3492         {
3493           if (argv[i][env_set_opt_len] == '=')
3494             {
3495               const char *p = argv[i] + env_set_opt_len + 1;
3496               lt_opt_process_env_set (p);
3497             }
3498           else if (argv[i][env_set_opt_len] == '\0' && i + 1 < argc)
3499             {
3500               lt_opt_process_env_set (argv[++i]); /* don't copy */
3501             }
3502           else
3503             lt_fatal ("%s missing required argument", env_set_opt);
3504           continue;
3505         }
3506       if (strncmp (argv[i], env_prepend_opt, env_prepend_opt_len) == 0)
3507         {
3508           if (argv[i][env_prepend_opt_len] == '=')
3509             {
3510               const char *p = argv[i] + env_prepend_opt_len + 1;
3511               lt_opt_process_env_prepend (p);
3512             }
3513           else if (argv[i][env_prepend_opt_len] == '\0' && i + 1 < argc)
3514             {
3515               lt_opt_process_env_prepend (argv[++i]); /* don't copy */
3516             }
3517           else
3518             lt_fatal ("%s missing required argument", env_prepend_opt);
3519           continue;
3520         }
3521       if (strncmp (argv[i], env_append_opt, env_append_opt_len) == 0)
3522         {
3523           if (argv[i][env_append_opt_len] == '=')
3524             {
3525               const char *p = argv[i] + env_append_opt_len + 1;
3526               lt_opt_process_env_append (p);
3527             }
3528           else if (argv[i][env_append_opt_len] == '\0' && i + 1 < argc)
3529             {
3530               lt_opt_process_env_append (argv[++i]); /* don't copy */
3531             }
3532           else
3533             lt_fatal ("%s missing required argument", env_append_opt);
3534           continue;
3535         }
3536       if (strncmp (argv[i], ltwrapper_option_prefix, opt_prefix_len) == 0)
3537         {
3538           /* however, if there is an option in the LTWRAPPER_OPTION_PREFIX
3539              namespace, but it is not one of the ones we know about and
3540              have already dealt with, above (inluding dump-script), then
3541              report an error. Otherwise, targets might begin to believe
3542              they are allowed to use options in the LTWRAPPER_OPTION_PREFIX
3543              namespace. The first time any user complains about this, we'll
3544              need to make LTWRAPPER_OPTION_PREFIX a configure-time option
3545              or a configure.ac-settable value.
3546            */
3547           lt_fatal ("Unrecognized option in %s namespace: '%s'",
3548                     ltwrapper_option_prefix, argv[i]);
3549         }
3550       /* otherwise ... */
3551       newargz[++newargc] = xstrdup (argv[i]);
3552     }
3553   newargz[++newargc] = NULL;
3554
3555   LTWRAPPER_DEBUGPRINTF     (("(main) lt_argv_zero : %s\n", (lt_argv_zero ? lt_argv_zero : "<NULL>")));
3556   for (i = 0; i < newargc; i++)
3557     {
3558       LTWRAPPER_DEBUGPRINTF (("(main) newargz[%d]   : %s\n", i, (newargz[i] ? newargz[i] : "<NULL>")));
3559     }
3560
3561 EOF
3562
3563             case $host_os in
3564               mingw*)
3565                 cat <<"EOF"
3566   /* execv doesn't actually work on mingw as expected on unix */
3567   rval = _spawnv (_P_WAIT, lt_argv_zero, (const char * const *) newargz);
3568   if (rval == -1)
3569     {
3570       /* failed to start process */
3571       LTWRAPPER_DEBUGPRINTF (("(main) failed to launch target \"%s\": errno = %d\n", lt_argv_zero, errno));
3572       return 127;
3573     }
3574   return rval;
3575 EOF
3576                 ;;
3577               *)
3578                 cat <<"EOF"
3579   execv (lt_argv_zero, newargz);
3580   return rval; /* =127, but avoids unused variable warning */
3581 EOF
3582                 ;;
3583             esac
3584
3585             cat <<"EOF"
3586 }
3587
3588 void *
3589 xmalloc (size_t num)
3590 {
3591   void *p = (void *) malloc (num);
3592   if (!p)
3593     lt_fatal ("Memory exhausted");
3594
3595   return p;
3596 }
3597
3598 char *
3599 xstrdup (const char *string)
3600 {
3601   return string ? strcpy ((char *) xmalloc (strlen (string) + 1),
3602                           string) : NULL;
3603 }
3604
3605 const char *
3606 base_name (const char *name)
3607 {
3608   const char *base;
3609
3610 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3611   /* Skip over the disk name in MSDOS pathnames. */
3612   if (isalpha ((unsigned char) name[0]) && name[1] == ':')
3613     name += 2;
3614 #endif
3615
3616   for (base = name; *name; name++)
3617     if (IS_DIR_SEPARATOR (*name))
3618       base = name + 1;
3619   return base;
3620 }
3621
3622 int
3623 check_executable (const char *path)
3624 {
3625   struct stat st;
3626
3627   LTWRAPPER_DEBUGPRINTF (("(check_executable)  : %s\n",
3628                           path ? (*path ? path : "EMPTY!") : "NULL!"));
3629   if ((!path) || (!*path))
3630     return 0;
3631
3632   if ((stat (path, &st) >= 0)
3633       && (st.st_mode & (S_IXUSR | S_IXGRP | S_IXOTH)))
3634     return 1;
3635   else
3636     return 0;
3637 }
3638
3639 int
3640 make_executable (const char *path)
3641 {
3642   int rval = 0;
3643   struct stat st;
3644
3645   LTWRAPPER_DEBUGPRINTF (("(make_executable)   : %s\n",
3646                           path ? (*path ? path : "EMPTY!") : "NULL!"));
3647   if ((!path) || (!*path))
3648     return 0;
3649
3650   if (stat (path, &st) >= 0)
3651     {
3652       rval = chmod (path, st.st_mode | S_IXOTH | S_IXGRP | S_IXUSR);
3653     }
3654   return rval;
3655 }
3656
3657 /* Searches for the full path of the wrapper.  Returns
3658    newly allocated full path name if found, NULL otherwise
3659    Does not chase symlinks, even on platforms that support them.
3660 */
3661 char *
3662 find_executable (const char *wrapper)
3663 {
3664   int has_slash = 0;
3665   const char *p;
3666   const char *p_next;
3667   /* static buffer for getcwd */
3668   char tmp[LT_PATHMAX + 1];
3669   int tmp_len;
3670   char *concat_name;
3671
3672   LTWRAPPER_DEBUGPRINTF (("(find_executable)   : %s\n",
3673                           wrapper ? (*wrapper ? wrapper : "EMPTY!") : "NULL!"));
3674
3675   if ((wrapper == NULL) || (*wrapper == '\0'))
3676     return NULL;
3677
3678   /* Absolute path? */
3679 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3680   if (isalpha ((unsigned char) wrapper[0]) && wrapper[1] == ':')
3681     {
3682       concat_name = xstrdup (wrapper);
3683       if (check_executable (concat_name))
3684         return concat_name;
3685       XFREE (concat_name);
3686     }
3687   else
3688     {
3689 #endif
3690       if (IS_DIR_SEPARATOR (wrapper[0]))
3691         {
3692           concat_name = xstrdup (wrapper);
3693           if (check_executable (concat_name))
3694             return concat_name;
3695           XFREE (concat_name);
3696         }
3697 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
3698     }
3699 #endif
3700
3701   for (p = wrapper; *p; p++)
3702     if (*p == '/')
3703       {
3704         has_slash = 1;
3705         break;
3706       }
3707   if (!has_slash)
3708     {
3709       /* no slashes; search PATH */
3710       const char *path = getenv ("PATH");
3711       if (path != NULL)
3712         {
3713           for (p = path; *p; p = p_next)
3714             {
3715               const char *q;
3716               size_t p_len;
3717               for (q = p; *q; q++)
3718                 if (IS_PATH_SEPARATOR (*q))
3719                   break;
3720               p_len = q - p;
3721               p_next = (*q == '\0' ? q : q + 1);
3722               if (p_len == 0)
3723                 {
3724                   /* empty path: current directory */
3725                   if (getcwd (tmp, LT_PATHMAX) == NULL)
3726                     lt_fatal ("getcwd failed");
3727                   tmp_len = strlen (tmp);
3728                   concat_name =
3729                     XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3730                   memcpy (concat_name, tmp, tmp_len);
3731                   concat_name[tmp_len] = '/';
3732                   strcpy (concat_name + tmp_len + 1, wrapper);
3733                 }
3734               else
3735                 {
3736                   concat_name =
3737                     XMALLOC (char, p_len + 1 + strlen (wrapper) + 1);
3738                   memcpy (concat_name, p, p_len);
3739                   concat_name[p_len] = '/';
3740                   strcpy (concat_name + p_len + 1, wrapper);
3741                 }
3742               if (check_executable (concat_name))
3743                 return concat_name;
3744               XFREE (concat_name);
3745             }
3746         }
3747       /* not found in PATH; assume curdir */
3748     }
3749   /* Relative path | not found in path: prepend cwd */
3750   if (getcwd (tmp, LT_PATHMAX) == NULL)
3751     lt_fatal ("getcwd failed");
3752   tmp_len = strlen (tmp);
3753   concat_name = XMALLOC (char, tmp_len + 1 + strlen (wrapper) + 1);
3754   memcpy (concat_name, tmp, tmp_len);
3755   concat_name[tmp_len] = '/';
3756   strcpy (concat_name + tmp_len + 1, wrapper);
3757
3758   if (check_executable (concat_name))
3759     return concat_name;
3760   XFREE (concat_name);
3761   return NULL;
3762 }
3763
3764 char *
3765 chase_symlinks (const char *pathspec)
3766 {
3767 #ifndef S_ISLNK
3768   return xstrdup (pathspec);
3769 #else
3770   char buf[LT_PATHMAX];
3771   struct stat s;
3772   char *tmp_pathspec = xstrdup (pathspec);
3773   char *p;
3774   int has_symlinks = 0;
3775   while (strlen (tmp_pathspec) && !has_symlinks)
3776     {
3777       LTWRAPPER_DEBUGPRINTF (("checking path component for symlinks: %s\n",
3778                               tmp_pathspec));
3779       if (lstat (tmp_pathspec, &s) == 0)
3780         {
3781           if (S_ISLNK (s.st_mode) != 0)
3782             {
3783               has_symlinks = 1;
3784               break;
3785             }
3786
3787           /* search backwards for last DIR_SEPARATOR */
3788           p = tmp_pathspec + strlen (tmp_pathspec) - 1;
3789           while ((p > tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3790             p--;
3791           if ((p == tmp_pathspec) && (!IS_DIR_SEPARATOR (*p)))
3792             {
3793               /* no more DIR_SEPARATORS left */
3794               break;
3795             }
3796           *p = '\0';
3797         }
3798       else
3799         {
3800           char *errstr = strerror (errno);
3801           lt_fatal ("Error accessing file %s (%s)", tmp_pathspec, errstr);
3802         }
3803     }
3804   XFREE (tmp_pathspec);
3805
3806   if (!has_symlinks)
3807     {
3808       return xstrdup (pathspec);
3809     }
3810
3811   tmp_pathspec = realpath (pathspec, buf);
3812   if (tmp_pathspec == 0)
3813     {
3814       lt_fatal ("Could not follow symlinks for %s", pathspec);
3815     }
3816   return xstrdup (tmp_pathspec);
3817 #endif
3818 }
3819
3820 char *
3821 strendzap (char *str, const char *pat)
3822 {
3823   size_t len, patlen;
3824
3825   assert (str != NULL);
3826   assert (pat != NULL);
3827
3828   len = strlen (str);
3829   patlen = strlen (pat);
3830
3831   if (patlen <= len)
3832     {
3833       str += len - patlen;
3834       if (strcmp (str, pat) == 0)
3835         *str = '\0';
3836     }
3837   return str;
3838 }
3839
3840 static void
3841 lt_error_core (int exit_status, const char *mode,
3842                const char *message, va_list ap)
3843 {
3844   fprintf (stderr, "%s: %s: ", program_name, mode);
3845   vfprintf (stderr, message, ap);
3846   fprintf (stderr, ".\n");
3847
3848   if (exit_status >= 0)
3849     exit (exit_status);
3850 }
3851
3852 void
3853 lt_fatal (const char *message, ...)
3854 {
3855   va_list ap;
3856   va_start (ap, message);
3857   lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
3858   va_end (ap);
3859 }
3860
3861 void
3862 lt_setenv (const char *name, const char *value)
3863 {
3864   LTWRAPPER_DEBUGPRINTF (("(lt_setenv) setting '%s' to '%s'\n",
3865                           (name ? name : "<NULL>"),
3866                           (value ? value : "<NULL>")));
3867   {
3868 #ifdef HAVE_SETENV
3869     /* always make a copy, for consistency with !HAVE_SETENV */
3870     char *str = xstrdup (value);
3871     setenv (name, str, 1);
3872 #else
3873     int len = strlen (name) + 1 + strlen (value) + 1;
3874     char *str = XMALLOC (char, len);
3875     sprintf (str, "%s=%s", name, value);
3876     if (putenv (str) != EXIT_SUCCESS)
3877       {
3878         XFREE (str);
3879       }
3880 #endif
3881   }
3882 }
3883
3884 char *
3885 lt_extend_str (const char *orig_value, const char *add, int to_end)
3886 {
3887   char *new_value;
3888   if (orig_value && *orig_value)
3889     {
3890       int orig_value_len = strlen (orig_value);
3891       int add_len = strlen (add);
3892       new_value = XMALLOC (char, add_len + orig_value_len + 1);
3893       if (to_end)
3894         {
3895           strcpy (new_value, orig_value);
3896           strcpy (new_value + orig_value_len, add);
3897         }
3898       else
3899         {
3900           strcpy (new_value, add);
3901           strcpy (new_value + add_len, orig_value);
3902         }
3903     }
3904   else
3905     {
3906       new_value = xstrdup (add);
3907     }
3908   return new_value;
3909 }
3910
3911 int
3912 lt_split_name_value (const char *arg, char** name, char** value)
3913 {
3914   const char *p;
3915   int len;
3916   if (!arg || !*arg)
3917     return 1;
3918
3919   p = strchr (arg, (int)'=');
3920
3921   if (!p)
3922     return 1;
3923
3924   *value = xstrdup (++p);
3925
3926   len = strlen (arg) - strlen (*value);
3927   *name = XMALLOC (char, len);
3928   strncpy (*name, arg, len-1);
3929   (*name)[len - 1] = '\0';
3930
3931   return 0;
3932 }
3933
3934 void
3935 lt_opt_process_env_set (const char *arg)
3936 {
3937   char *name = NULL;
3938   char *value = NULL;
3939
3940   if (lt_split_name_value (arg, &name, &value) != 0)
3941     {
3942       XFREE (name);
3943       XFREE (value);
3944       lt_fatal ("bad argument for %s: '%s'", env_set_opt, arg);
3945     }
3946
3947   lt_setenv (name, value);
3948   XFREE (name);
3949   XFREE (value);
3950 }
3951
3952 void
3953 lt_opt_process_env_prepend (const char *arg)
3954 {
3955   char *name = NULL;
3956   char *value = NULL;
3957   char *new_value = NULL;
3958
3959   if (lt_split_name_value (arg, &name, &value) != 0)
3960     {
3961       XFREE (name);
3962       XFREE (value);
3963       lt_fatal ("bad argument for %s: '%s'", env_prepend_opt, arg);
3964     }
3965
3966   new_value = lt_extend_str (getenv (name), value, 0);
3967   lt_setenv (name, new_value);
3968   XFREE (new_value);
3969   XFREE (name);
3970   XFREE (value);
3971 }
3972
3973 void
3974 lt_opt_process_env_append (const char *arg)
3975 {
3976   char *name = NULL;
3977   char *value = NULL;
3978   char *new_value = NULL;
3979
3980   if (lt_split_name_value (arg, &name, &value) != 0)
3981     {
3982       XFREE (name);
3983       XFREE (value);
3984       lt_fatal ("bad argument for %s: '%s'", env_append_opt, arg);
3985     }
3986
3987   new_value = lt_extend_str (getenv (name), value, 1);
3988   lt_setenv (name, new_value);
3989   XFREE (new_value);
3990   XFREE (name);
3991   XFREE (value);
3992 }
3993
3994 void
3995 lt_update_exe_path (const char *name, const char *value)
3996 {
3997   LTWRAPPER_DEBUGPRINTF (("(lt_update_exe_path) modifying '%s' by prepending '%s'\n",
3998                           (name ? name : "<NULL>"),
3999                           (value ? value : "<NULL>")));
4000
4001   if (name && *name && value && *value)
4002     {
4003       char *new_value = lt_extend_str (getenv (name), value, 0);
4004       /* some systems can't cope with a ':'-terminated path #' */
4005       int len = strlen (new_value);
4006       while (((len = strlen (new_value)) > 0) && IS_PATH_SEPARATOR (new_value[len-1]))
4007         {
4008           new_value[len-1] = '\0';
4009         }
4010       lt_setenv (name, new_value);
4011       XFREE (new_value);
4012     }
4013 }
4014
4015 void
4016 lt_update_lib_path (const char *name, const char *value)
4017 {
4018   LTWRAPPER_DEBUGPRINTF (("(lt_update_lib_path) modifying '%s' by prepending '%s'\n",
4019                           (name ? name : "<NULL>"),
4020                           (value ? value : "<NULL>")));
4021
4022   if (name && *name && value && *value)
4023     {
4024       char *new_value = lt_extend_str (getenv (name), value, 0);
4025       lt_setenv (name, new_value);
4026       XFREE (new_value);
4027     }
4028 }
4029
4030
4031 EOF
4032 }
4033 # end: func_emit_cwrapperexe_src
4034
4035 # func_mode_link arg...
4036 func_mode_link ()
4037 {
4038     $opt_debug
4039     case $host in
4040     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4041       # It is impossible to link a dll without this setting, and
4042       # we shouldn't force the makefile maintainer to figure out
4043       # which system we are compiling for in order to pass an extra
4044       # flag for every libtool invocation.
4045       # allow_undefined=no
4046
4047       # FIXME: Unfortunately, there are problems with the above when trying
4048       # to make a dll which has undefined symbols, in which case not
4049       # even a static library is built.  For now, we need to specify
4050       # -no-undefined on the libtool link line when we can be certain
4051       # that all symbols are satisfied, otherwise we get a static library.
4052       allow_undefined=yes
4053       ;;
4054     *)
4055       allow_undefined=yes
4056       ;;
4057     esac
4058     libtool_args=$nonopt
4059     base_compile="$nonopt $@"
4060     compile_command=$nonopt
4061     finalize_command=$nonopt
4062
4063     compile_rpath=
4064     finalize_rpath=
4065     compile_shlibpath=
4066     finalize_shlibpath=
4067     convenience=
4068     old_convenience=
4069     deplibs=
4070     old_deplibs=
4071     compiler_flags=
4072     linker_flags=
4073     dllsearchpath=
4074     lib_search_path=`pwd`
4075     inst_prefix_dir=
4076     new_inherited_linker_flags=
4077
4078     avoid_version=no
4079     dlfiles=
4080     dlprefiles=
4081     dlself=no
4082     export_dynamic=no
4083     export_symbols=
4084     export_symbols_regex=
4085     generated=
4086     libobjs=
4087     ltlibs=
4088     module=no
4089     no_install=no
4090     objs=
4091     non_pic_objects=
4092     precious_files_regex=
4093     prefer_static_libs=no
4094     preload=no
4095     prev=
4096     prevarg=
4097     release=
4098     rpath=
4099     xrpath=
4100     perm_rpath=
4101     temp_rpath=
4102     thread_safe=no
4103     vinfo=
4104     vinfo_number=no
4105     weak_libs=
4106     single_module="${wl}-single_module"
4107     func_infer_tag $base_compile
4108
4109     # We need to know -static, to get the right output filenames.
4110     for arg
4111     do
4112       case $arg in
4113       -shared)
4114         test "$build_libtool_libs" != yes && \
4115           func_fatal_configuration "can not build a shared library"
4116         build_old_libs=no
4117         break
4118         ;;
4119       -all-static | -static | -static-libtool-libs)
4120         case $arg in
4121         -all-static)
4122           if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
4123             func_warning "complete static linking is impossible in this configuration"
4124           fi
4125           if test -n "$link_static_flag"; then
4126             dlopen_self=$dlopen_self_static
4127           fi
4128           prefer_static_libs=yes
4129           ;;
4130         -static)
4131           if test -z "$pic_flag" && test -n "$link_static_flag"; then
4132             dlopen_self=$dlopen_self_static
4133           fi
4134           prefer_static_libs=built
4135           ;;
4136         -static-libtool-libs)
4137           if test -z "$pic_flag" && test -n "$link_static_flag"; then
4138             dlopen_self=$dlopen_self_static
4139           fi
4140           prefer_static_libs=yes
4141           ;;
4142         esac
4143         build_libtool_libs=no
4144         build_old_libs=yes
4145         break
4146         ;;
4147       esac
4148     done
4149
4150     # See if our shared archives depend on static archives.
4151     test -n "$old_archive_from_new_cmds" && build_old_libs=yes
4152
4153     # Go through the arguments, transforming them on the way.
4154     while test "$#" -gt 0; do
4155       arg="$1"
4156       shift
4157       func_quote_for_eval "$arg"
4158       qarg=$func_quote_for_eval_unquoted_result
4159       func_append libtool_args " $func_quote_for_eval_result"
4160
4161       # If the previous option needs an argument, assign it.
4162       if test -n "$prev"; then
4163         case $prev in
4164         output)
4165           func_append compile_command " @OUTPUT@"
4166           func_append finalize_command " @OUTPUT@"
4167           ;;
4168         esac
4169
4170         case $prev in
4171         dlfiles|dlprefiles)
4172           if test "$preload" = no; then
4173             # Add the symbol object into the linking commands.
4174             func_append compile_command " @SYMFILE@"
4175             func_append finalize_command " @SYMFILE@"
4176             preload=yes
4177           fi
4178           case $arg in
4179           *.la | *.lo) ;;  # We handle these cases below.
4180           force)
4181             if test "$dlself" = no; then
4182               dlself=needless
4183               export_dynamic=yes
4184             fi
4185             prev=
4186             continue
4187             ;;
4188           self)
4189             if test "$prev" = dlprefiles; then
4190               dlself=yes
4191             elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
4192               dlself=yes
4193             else
4194               dlself=needless
4195               export_dynamic=yes
4196             fi
4197             prev=
4198             continue
4199             ;;
4200           *)
4201             if test "$prev" = dlfiles; then
4202               dlfiles="$dlfiles $arg"
4203             else
4204               dlprefiles="$dlprefiles $arg"
4205             fi
4206             prev=
4207             continue
4208             ;;
4209           esac
4210           ;;
4211         expsyms)
4212           export_symbols="$arg"
4213           test -f "$arg" \
4214             || func_fatal_error "symbol file \`$arg' does not exist"
4215           prev=
4216           continue
4217           ;;
4218         expsyms_regex)
4219           export_symbols_regex="$arg"
4220           prev=
4221           continue
4222           ;;
4223         framework)
4224           case $host in
4225             *-*-darwin*)
4226               case "$deplibs " in
4227                 *" $qarg.ltframework "*) ;;
4228                 *) deplibs="$deplibs $qarg.ltframework" # this is fixed later
4229                    ;;
4230               esac
4231               ;;
4232           esac
4233           prev=
4234           continue
4235           ;;
4236         inst_prefix)
4237           inst_prefix_dir="$arg"
4238           prev=
4239           continue
4240           ;;
4241         objectlist)
4242           if test -f "$arg"; then
4243             save_arg=$arg
4244             moreargs=
4245             for fil in `cat "$save_arg"`
4246             do
4247 #             moreargs="$moreargs $fil"
4248               arg=$fil
4249               # A libtool-controlled object.
4250
4251               # Check to see that this really is a libtool object.
4252               if func_lalib_unsafe_p "$arg"; then
4253                 pic_object=
4254                 non_pic_object=
4255
4256                 # Read the .lo file
4257                 func_source "$arg"
4258
4259                 if test -z "$pic_object" ||
4260                    test -z "$non_pic_object" ||
4261                    test "$pic_object" = none &&
4262                    test "$non_pic_object" = none; then
4263                   func_fatal_error "cannot find name of object for \`$arg'"
4264                 fi
4265
4266                 # Extract subdirectory from the argument.
4267                 func_dirname "$arg" "/" ""
4268                 xdir="$func_dirname_result"
4269
4270                 if test "$pic_object" != none; then
4271                   # Prepend the subdirectory the object is found in.
4272                   pic_object="$xdir$pic_object"
4273
4274                   if test "$prev" = dlfiles; then
4275                     if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4276                       dlfiles="$dlfiles $pic_object"
4277                       prev=
4278                       continue
4279                     else
4280                       # If libtool objects are unsupported, then we need to preload.
4281                       prev=dlprefiles
4282                     fi
4283                   fi
4284
4285                   # CHECK ME:  I think I busted this.  -Ossama
4286                   if test "$prev" = dlprefiles; then
4287                     # Preload the old-style object.
4288                     dlprefiles="$dlprefiles $pic_object"
4289                     prev=
4290                   fi
4291
4292                   # A PIC object.
4293                   func_append libobjs " $pic_object"
4294                   arg="$pic_object"
4295                 fi
4296
4297                 # Non-PIC object.
4298                 if test "$non_pic_object" != none; then
4299                   # Prepend the subdirectory the object is found in.
4300                   non_pic_object="$xdir$non_pic_object"
4301
4302                   # A standard non-PIC object
4303                   func_append non_pic_objects " $non_pic_object"
4304                   if test -z "$pic_object" || test "$pic_object" = none ; then
4305                     arg="$non_pic_object"
4306                   fi
4307                 else
4308                   # If the PIC object exists, use it instead.
4309                   # $xdir was prepended to $pic_object above.
4310                   non_pic_object="$pic_object"
4311                   func_append non_pic_objects " $non_pic_object"
4312                 fi
4313               else
4314                 # Only an error if not doing a dry-run.
4315                 if $opt_dry_run; then
4316                   # Extract subdirectory from the argument.
4317                   func_dirname "$arg" "/" ""
4318                   xdir="$func_dirname_result"
4319
4320                   func_lo2o "$arg"
4321                   pic_object=$xdir$objdir/$func_lo2o_result
4322                   non_pic_object=$xdir$func_lo2o_result
4323                   func_append libobjs " $pic_object"
4324                   func_append non_pic_objects " $non_pic_object"
4325                 else
4326                   func_fatal_error "\`$arg' is not a valid libtool object"
4327                 fi
4328               fi
4329             done
4330           else
4331             func_fatal_error "link input file \`$arg' does not exist"
4332           fi
4333           arg=$save_arg
4334           prev=
4335           continue
4336           ;;
4337         precious_regex)
4338           precious_files_regex="$arg"
4339           prev=
4340           continue
4341           ;;
4342         release)
4343           release="-$arg"
4344           prev=
4345           continue
4346           ;;
4347         rpath | xrpath)
4348           # We need an absolute path.
4349           case $arg in
4350           [\\/]* | [A-Za-z]:[\\/]*) ;;
4351           *)
4352             func_fatal_error "only absolute run-paths are allowed"
4353             ;;
4354           esac
4355           if test "$prev" = rpath; then
4356             case "$rpath " in
4357             *" $arg "*) ;;
4358             *) rpath="$rpath $arg" ;;
4359             esac
4360           else
4361             case "$xrpath " in
4362             *" $arg "*) ;;
4363             *) xrpath="$xrpath $arg" ;;
4364             esac
4365           fi
4366           prev=
4367           continue
4368           ;;
4369         shrext)
4370           shrext_cmds="$arg"
4371           prev=
4372           continue
4373           ;;
4374         weak)
4375           weak_libs="$weak_libs $arg"
4376           prev=
4377           continue
4378           ;;
4379         xcclinker)
4380           linker_flags="$linker_flags $qarg"
4381           compiler_flags="$compiler_flags $qarg"
4382           prev=
4383           func_append compile_command " $qarg"
4384           func_append finalize_command " $qarg"
4385           continue
4386           ;;
4387         xcompiler)
4388           compiler_flags="$compiler_flags $qarg"
4389           prev=
4390           func_append compile_command " $qarg"
4391           func_append finalize_command " $qarg"
4392           continue
4393           ;;
4394         xlinker)
4395           linker_flags="$linker_flags $qarg"
4396           compiler_flags="$compiler_flags $wl$qarg"
4397           prev=
4398           func_append compile_command " $wl$qarg"
4399           func_append finalize_command " $wl$qarg"
4400           continue
4401           ;;
4402         *)
4403           eval "$prev=\"\$arg\""
4404           prev=
4405           continue
4406           ;;
4407         esac
4408       fi # test -n "$prev"
4409
4410       prevarg="$arg"
4411
4412       case $arg in
4413       -all-static)
4414         if test -n "$link_static_flag"; then
4415           # See comment for -static flag below, for more details.
4416           func_append compile_command " $link_static_flag"
4417           func_append finalize_command " $link_static_flag"
4418         fi
4419         continue
4420         ;;
4421
4422       -allow-undefined)
4423         # FIXME: remove this flag sometime in the future.
4424         func_fatal_error "\`-allow-undefined' must not be used because it is the default"
4425         ;;
4426
4427       -avoid-version)
4428         avoid_version=yes
4429         continue
4430         ;;
4431
4432       -dlopen)
4433         prev=dlfiles
4434         continue
4435         ;;
4436
4437       -dlpreopen)
4438         prev=dlprefiles
4439         continue
4440         ;;
4441
4442       -export-dynamic)
4443         export_dynamic=yes
4444         continue
4445         ;;
4446
4447       -export-symbols | -export-symbols-regex)
4448         if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
4449           func_fatal_error "more than one -exported-symbols argument is not allowed"
4450         fi
4451         if test "X$arg" = "X-export-symbols"; then
4452           prev=expsyms
4453         else
4454           prev=expsyms_regex
4455         fi
4456         continue
4457         ;;
4458
4459       -framework)
4460         prev=framework
4461         continue
4462         ;;
4463
4464       -inst-prefix-dir)
4465         prev=inst_prefix
4466         continue
4467         ;;
4468
4469       # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
4470       # so, if we see these flags be careful not to treat them like -L
4471       -L[A-Z][A-Z]*:*)
4472         case $with_gcc/$host in
4473         no/*-*-irix* | /*-*-irix*)
4474           func_append compile_command " $arg"
4475           func_append finalize_command " $arg"
4476           ;;
4477         esac
4478         continue
4479         ;;
4480
4481       -L*)
4482         func_stripname '-L' '' "$arg"
4483         dir=$func_stripname_result
4484         if test -z "$dir"; then
4485           if test "$#" -gt 0; then
4486             func_fatal_error "require no space between \`-L' and \`$1'"
4487           else
4488             func_fatal_error "need path for \`-L' option"
4489           fi
4490         fi
4491         # We need an absolute path.
4492         case $dir in
4493         [\\/]* | [A-Za-z]:[\\/]*) ;;
4494         *)
4495           absdir=`cd "$dir" && pwd`
4496           test -z "$absdir" && \
4497             func_fatal_error "cannot determine absolute directory name of \`$dir'"
4498           dir="$absdir"
4499           ;;
4500         esac
4501         case "$deplibs " in
4502         *" -L$dir "*) ;;
4503         *)
4504           deplibs="$deplibs -L$dir"
4505           lib_search_path="$lib_search_path $dir"
4506           ;;
4507         esac
4508         case $host in
4509         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
4510           testbindir=`$ECHO "X$dir" | $Xsed -e 's*/lib$*/bin*'`
4511           case :$dllsearchpath: in
4512           *":$dir:"*) ;;
4513           ::) dllsearchpath=$dir;;
4514           *) dllsearchpath="$dllsearchpath:$dir";;
4515           esac
4516           case :$dllsearchpath: in
4517           *":$testbindir:"*) ;;
4518           ::) dllsearchpath=$testbindir;;
4519           *) dllsearchpath="$dllsearchpath:$testbindir";;
4520           esac
4521           ;;
4522         esac
4523         continue
4524         ;;
4525
4526       -l*)
4527         if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
4528           case $host in
4529           *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-beos* | *-cegcc*)
4530             # These systems don't actually have a C or math library (as such)
4531             continue
4532             ;;
4533           *-*-os2*)
4534             # These systems don't actually have a C library (as such)
4535             test "X$arg" = "X-lc" && continue
4536             ;;
4537           *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4538             # Do not include libc due to us having libc/libc_r.
4539             test "X$arg" = "X-lc" && continue
4540             ;;
4541           *-*-rhapsody* | *-*-darwin1.[012])
4542             # Rhapsody C and math libraries are in the System framework
4543             deplibs="$deplibs System.ltframework"
4544             continue
4545             ;;
4546           *-*-sco3.2v5* | *-*-sco5v6*)
4547             # Causes problems with __ctype
4548             test "X$arg" = "X-lc" && continue
4549             ;;
4550           *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
4551             # Compiler inserts libc in the correct place for threads to work
4552             test "X$arg" = "X-lc" && continue
4553             ;;
4554           esac
4555         elif test "X$arg" = "X-lc_r"; then
4556          case $host in
4557          *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
4558            # Do not include libc_r directly, use -pthread flag.
4559            continue
4560            ;;
4561          esac
4562         fi
4563         deplibs="$deplibs $arg"
4564         continue
4565         ;;
4566
4567       -module)
4568         module=yes
4569         continue
4570         ;;
4571
4572       # Tru64 UNIX uses -model [arg] to determine the layout of C++
4573       # classes, name mangling, and exception handling.
4574       # Darwin uses the -arch flag to determine output architecture.
4575       -model|-arch|-isysroot)
4576         compiler_flags="$compiler_flags $arg"
4577         func_append compile_command " $arg"
4578         func_append finalize_command " $arg"
4579         prev=xcompiler
4580         continue
4581         ;;
4582
4583       -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
4584         compiler_flags="$compiler_flags $arg"
4585         func_append compile_command " $arg"
4586         func_append finalize_command " $arg"
4587         case "$new_inherited_linker_flags " in
4588             *" $arg "*) ;;
4589             * ) new_inherited_linker_flags="$new_inherited_linker_flags $arg" ;;
4590         esac
4591         continue
4592         ;;
4593
4594       -multi_module)
4595         single_module="${wl}-multi_module"
4596         continue
4597         ;;
4598
4599       -no-fast-install)
4600         fast_install=no
4601         continue
4602         ;;
4603
4604       -no-install)
4605         case $host in
4606         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-darwin* | *-cegcc*)
4607           # The PATH hackery in wrapper scripts is required on Windows
4608           # and Darwin in order for the loader to find any dlls it needs.
4609           func_warning "\`-no-install' is ignored for $host"
4610           func_warning "assuming \`-no-fast-install' instead"
4611           fast_install=no
4612           ;;
4613         *) no_install=yes ;;
4614         esac
4615         continue
4616         ;;
4617
4618       -no-undefined)
4619         allow_undefined=no
4620         continue
4621         ;;
4622
4623       -objectlist)
4624         prev=objectlist
4625         continue
4626         ;;
4627
4628       -o) prev=output ;;
4629
4630       -precious-files-regex)
4631         prev=precious_regex
4632         continue
4633         ;;
4634
4635       -release)
4636         prev=release
4637         continue
4638         ;;
4639
4640       -rpath)
4641         prev=rpath
4642         continue
4643         ;;
4644
4645       -R)
4646         prev=xrpath
4647         continue
4648         ;;
4649
4650       -R*)
4651         func_stripname '-R' '' "$arg"
4652         dir=$func_stripname_result
4653         # We need an absolute path.
4654         case $dir in
4655         [\\/]* | [A-Za-z]:[\\/]*) ;;
4656         *)
4657           func_fatal_error "only absolute run-paths are allowed"
4658           ;;
4659         esac
4660         case "$xrpath " in
4661         *" $dir "*) ;;
4662         *) xrpath="$xrpath $dir" ;;
4663         esac
4664         continue
4665         ;;
4666
4667       -shared)
4668         # The effects of -shared are defined in a previous loop.
4669         continue
4670         ;;
4671
4672       -shrext)
4673         prev=shrext
4674         continue
4675         ;;
4676
4677       -static | -static-libtool-libs)
4678         # The effects of -static are defined in a previous loop.
4679         # We used to do the same as -all-static on platforms that
4680         # didn't have a PIC flag, but the assumption that the effects
4681         # would be equivalent was wrong.  It would break on at least
4682         # Digital Unix and AIX.
4683         continue
4684         ;;
4685
4686       -thread-safe)
4687         thread_safe=yes
4688         continue
4689         ;;
4690
4691       -version-info)
4692         prev=vinfo
4693         continue
4694         ;;
4695
4696       -version-number)
4697         prev=vinfo
4698         vinfo_number=yes
4699         continue
4700         ;;
4701
4702       -weak)
4703         prev=weak
4704         continue
4705         ;;
4706
4707       -Wc,*)
4708         func_stripname '-Wc,' '' "$arg"
4709         args=$func_stripname_result
4710         arg=
4711         save_ifs="$IFS"; IFS=','
4712         for flag in $args; do
4713           IFS="$save_ifs"
4714           func_quote_for_eval "$flag"
4715           arg="$arg $wl$func_quote_for_eval_result"
4716           compiler_flags="$compiler_flags $func_quote_for_eval_result"
4717         done
4718         IFS="$save_ifs"
4719         func_stripname ' ' '' "$arg"
4720         arg=$func_stripname_result
4721         ;;
4722
4723       -Wl,*)
4724         func_stripname '-Wl,' '' "$arg"
4725         args=$func_stripname_result
4726         arg=
4727         save_ifs="$IFS"; IFS=','
4728         for flag in $args; do
4729           IFS="$save_ifs"
4730           func_quote_for_eval "$flag"
4731           arg="$arg $wl$func_quote_for_eval_result"
4732           compiler_flags="$compiler_flags $wl$func_quote_for_eval_result"
4733           linker_flags="$linker_flags $func_quote_for_eval_result"
4734         done
4735         IFS="$save_ifs"
4736         func_stripname ' ' '' "$arg"
4737         arg=$func_stripname_result
4738         ;;
4739
4740       -Xcompiler)
4741         prev=xcompiler
4742         continue
4743         ;;
4744
4745       -Xlinker)
4746         prev=xlinker
4747         continue
4748         ;;
4749
4750       -XCClinker)
4751         prev=xcclinker
4752         continue
4753         ;;
4754
4755       # -msg_* for osf cc
4756       -msg_*)
4757         func_quote_for_eval "$arg"
4758         arg="$func_quote_for_eval_result"
4759         ;;
4760
4761       # -64, -mips[0-9] enable 64-bit mode on the SGI compiler
4762       # -r[0-9][0-9]* specifies the processor on the SGI compiler
4763       # -xarch=*, -xtarget=* enable 64-bit mode on the Sun compiler
4764       # +DA*, +DD* enable 64-bit mode on the HP compiler
4765       # -q* pass through compiler args for the IBM compiler
4766       # -m*, -t[45]*, -txscale* pass through architecture-specific
4767       # compiler args for GCC
4768       # -F/path gives path to uninstalled frameworks, gcc on darwin
4769       # -p, -pg, --coverage, -fprofile-* pass through profiling flag for GCC
4770       # @file GCC response files
4771       -64|-mips[0-9]|-r[0-9][0-9]*|-xarch=*|-xtarget=*|+DA*|+DD*|-q*|-m*| \
4772       -t[45]*|-txscale*|-p|-pg|--coverage|-fprofile-*|-F*|@*)
4773         func_quote_for_eval "$arg"
4774         arg="$func_quote_for_eval_result"
4775         func_append compile_command " $arg"
4776         func_append finalize_command " $arg"
4777         compiler_flags="$compiler_flags $arg"
4778         continue
4779         ;;
4780
4781       # Some other compiler flag.
4782       -* | +*)
4783         func_quote_for_eval "$arg"
4784         arg="$func_quote_for_eval_result"
4785         ;;
4786
4787       *.$objext)
4788         # A standard object.
4789         objs="$objs $arg"
4790         ;;
4791
4792       *.lo)
4793         # A libtool-controlled object.
4794
4795         # Check to see that this really is a libtool object.
4796         if func_lalib_unsafe_p "$arg"; then
4797           pic_object=
4798           non_pic_object=
4799
4800           # Read the .lo file
4801           func_source "$arg"
4802
4803           if test -z "$pic_object" ||
4804              test -z "$non_pic_object" ||
4805              test "$pic_object" = none &&
4806              test "$non_pic_object" = none; then
4807             func_fatal_error "cannot find name of object for \`$arg'"
4808           fi
4809
4810           # Extract subdirectory from the argument.
4811           func_dirname "$arg" "/" ""
4812           xdir="$func_dirname_result"
4813
4814           if test "$pic_object" != none; then
4815             # Prepend the subdirectory the object is found in.
4816             pic_object="$xdir$pic_object"
4817
4818             if test "$prev" = dlfiles; then
4819               if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
4820                 dlfiles="$dlfiles $pic_object"
4821                 prev=
4822                 continue
4823               else
4824                 # If libtool objects are unsupported, then we need to preload.
4825                 prev=dlprefiles
4826               fi
4827             fi
4828
4829             # CHECK ME:  I think I busted this.  -Ossama
4830             if test "$prev" = dlprefiles; then
4831               # Preload the old-style object.
4832               dlprefiles="$dlprefiles $pic_object"
4833               prev=
4834             fi
4835
4836             # A PIC object.
4837             func_append libobjs " $pic_object"
4838             arg="$pic_object"
4839           fi
4840
4841           # Non-PIC object.
4842           if test "$non_pic_object" != none; then
4843             # Prepend the subdirectory the object is found in.
4844             non_pic_object="$xdir$non_pic_object"
4845
4846             # A standard non-PIC object
4847             func_append non_pic_objects " $non_pic_object"
4848             if test -z "$pic_object" || test "$pic_object" = none ; then
4849               arg="$non_pic_object"
4850             fi
4851           else
4852             # If the PIC object exists, use it instead.
4853             # $xdir was prepended to $pic_object above.
4854             non_pic_object="$pic_object"
4855             func_append non_pic_objects " $non_pic_object"
4856           fi
4857         else
4858           # Only an error if not doing a dry-run.
4859           if $opt_dry_run; then
4860             # Extract subdirectory from the argument.
4861             func_dirname "$arg" "/" ""
4862             xdir="$func_dirname_result"
4863
4864             func_lo2o "$arg"
4865             pic_object=$xdir$objdir/$func_lo2o_result
4866             non_pic_object=$xdir$func_lo2o_result
4867             func_append libobjs " $pic_object"
4868             func_append non_pic_objects " $non_pic_object"
4869           else
4870             func_fatal_error "\`$arg' is not a valid libtool object"
4871           fi
4872         fi
4873         ;;
4874
4875       *.$libext)
4876         # An archive.
4877         deplibs="$deplibs $arg"
4878         old_deplibs="$old_deplibs $arg"
4879         continue
4880         ;;
4881
4882       *.la)
4883         # A libtool-controlled library.
4884
4885         if test "$prev" = dlfiles; then
4886           # This library was specified with -dlopen.
4887           dlfiles="$dlfiles $arg"
4888           prev=
4889         elif test "$prev" = dlprefiles; then
4890           # The library was specified with -dlpreopen.
4891           dlprefiles="$dlprefiles $arg"
4892           prev=
4893         else
4894           deplibs="$deplibs $arg"
4895         fi
4896         continue
4897         ;;
4898
4899       # Some other compiler argument.
4900       *)
4901         # Unknown arguments in both finalize_command and compile_command need
4902         # to be aesthetically quoted because they are evaled later.
4903         func_quote_for_eval "$arg"
4904         arg="$func_quote_for_eval_result"
4905         ;;
4906       esac # arg
4907
4908       # Now actually substitute the argument into the commands.
4909       if test -n "$arg"; then
4910         func_append compile_command " $arg"
4911         func_append finalize_command " $arg"
4912       fi
4913     done # argument parsing loop
4914
4915     test -n "$prev" && \
4916       func_fatal_help "the \`$prevarg' option requires an argument"
4917
4918     if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
4919       eval arg=\"$export_dynamic_flag_spec\"
4920       func_append compile_command " $arg"
4921       func_append finalize_command " $arg"
4922     fi
4923
4924     oldlibs=
4925     # calculate the name of the file, without its directory
4926     func_basename "$output"
4927     outputname="$func_basename_result"
4928     libobjs_save="$libobjs"
4929
4930     if test -n "$shlibpath_var"; then
4931       # get the directories listed in $shlibpath_var
4932       eval shlib_search_path=\`\$ECHO \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
4933     else
4934       shlib_search_path=
4935     fi
4936     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
4937     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
4938
4939     func_dirname "$output" "/" ""
4940     output_objdir="$func_dirname_result$objdir"
4941     # Create the object directory.
4942     func_mkdir_p "$output_objdir"
4943
4944     # Determine the type of output
4945     case $output in
4946     "")
4947       func_fatal_help "you must specify an output file"
4948       ;;
4949     *.$libext) linkmode=oldlib ;;
4950     *.lo | *.$objext) linkmode=obj ;;
4951     *.la) linkmode=lib ;;
4952     *) linkmode=prog ;; # Anything else should be a program.
4953     esac
4954
4955     specialdeplibs=
4956
4957     libs=
4958     # Find all interdependent deplibs by searching for libraries
4959     # that are linked more than once (e.g. -la -lb -la)
4960     for deplib in $deplibs; do
4961       if $opt_duplicate_deps ; then
4962         case "$libs " in
4963         *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
4964         esac
4965       fi
4966       libs="$libs $deplib"
4967     done
4968
4969     if test "$linkmode" = lib; then
4970       libs="$predeps $libs $compiler_lib_search_path $postdeps"
4971
4972       # Compute libraries that are listed more than once in $predeps
4973       # $postdeps and mark them as special (i.e., whose duplicates are
4974       # not to be eliminated).
4975       pre_post_deps=
4976       if $opt_duplicate_compiler_generated_deps; then
4977         for pre_post_dep in $predeps $postdeps; do
4978           case "$pre_post_deps " in
4979           *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
4980           esac
4981           pre_post_deps="$pre_post_deps $pre_post_dep"
4982         done
4983       fi
4984       pre_post_deps=
4985     fi
4986
4987     deplibs=
4988     newdependency_libs=
4989     newlib_search_path=
4990     need_relink=no # whether we're linking any uninstalled libtool libraries
4991     notinst_deplibs= # not-installed libtool libraries
4992     notinst_path= # paths that contain not-installed libtool libraries
4993
4994     case $linkmode in
4995     lib)
4996         passes="conv dlpreopen link"
4997         for file in $dlfiles $dlprefiles; do
4998           case $file in
4999           *.la) ;;
5000           *)
5001             func_fatal_help "libraries can \`-dlopen' only libtool libraries: $file"
5002             ;;
5003           esac
5004         done
5005         ;;
5006     prog)
5007         compile_deplibs=
5008         finalize_deplibs=
5009         alldeplibs=no
5010         newdlfiles=
5011         newdlprefiles=
5012         passes="conv scan dlopen dlpreopen link"
5013         ;;
5014     *)  passes="conv"
5015         ;;
5016     esac
5017
5018     for pass in $passes; do
5019       # The preopen pass in lib mode reverses $deplibs; put it back here
5020       # so that -L comes before libs that need it for instance...
5021       if test "$linkmode,$pass" = "lib,link"; then
5022         ## FIXME: Find the place where the list is rebuilt in the wrong
5023         ##        order, and fix it there properly
5024         tmp_deplibs=
5025         for deplib in $deplibs; do
5026           tmp_deplibs="$deplib $tmp_deplibs"
5027         done
5028         deplibs="$tmp_deplibs"
5029       fi
5030
5031       if test "$linkmode,$pass" = "lib,link" ||
5032          test "$linkmode,$pass" = "prog,scan"; then
5033         libs="$deplibs"
5034         deplibs=
5035       fi
5036       if test "$linkmode" = prog; then
5037         case $pass in
5038         dlopen) libs="$dlfiles" ;;
5039         dlpreopen) libs="$dlprefiles" ;;
5040         link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
5041         esac
5042       fi
5043       if test "$linkmode,$pass" = "lib,dlpreopen"; then
5044         # Collect and forward deplibs of preopened libtool libs
5045         for lib in $dlprefiles; do
5046           # Ignore non-libtool-libs
5047           dependency_libs=
5048           case $lib in
5049           *.la) func_source "$lib" ;;
5050           esac
5051
5052           # Collect preopened libtool deplibs, except any this library
5053           # has declared as weak libs
5054           for deplib in $dependency_libs; do
5055             deplib_base=`$ECHO "X$deplib" | $Xsed -e "$basename"`
5056             case " $weak_libs " in
5057             *" $deplib_base "*) ;;
5058             *) deplibs="$deplibs $deplib" ;;
5059             esac
5060           done
5061         done
5062         libs="$dlprefiles"
5063       fi
5064       if test "$pass" = dlopen; then
5065         # Collect dlpreopened libraries
5066         save_deplibs="$deplibs"
5067         deplibs=
5068       fi
5069
5070       for deplib in $libs; do
5071         lib=
5072         found=no
5073         case $deplib in
5074         -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe|-threads)
5075           if test "$linkmode,$pass" = "prog,link"; then
5076             compile_deplibs="$deplib $compile_deplibs"
5077             finalize_deplibs="$deplib $finalize_deplibs"
5078           else
5079             compiler_flags="$compiler_flags $deplib"
5080             if test "$linkmode" = lib ; then
5081                 case "$new_inherited_linker_flags " in
5082                     *" $deplib "*) ;;
5083                     * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5084                 esac
5085             fi
5086           fi
5087           continue
5088           ;;
5089         -l*)
5090           if test "$linkmode" != lib && test "$linkmode" != prog; then
5091             func_warning "\`-l' is ignored for archives/objects"
5092             continue
5093           fi
5094           func_stripname '-l' '' "$deplib"
5095           name=$func_stripname_result
5096           if test "$linkmode" = lib; then
5097             searchdirs="$newlib_search_path $lib_search_path $compiler_lib_search_dirs $sys_lib_search_path $shlib_search_path"
5098           else
5099             searchdirs="$newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path"
5100           fi
5101           for searchdir in $searchdirs; do
5102             for search_ext in .la $std_shrext .so .a; do
5103               # Search the libtool library
5104               lib="$searchdir/lib${name}${search_ext}"
5105               if test -f "$lib"; then
5106                 if test "$search_ext" = ".la"; then
5107                   found=yes
5108                 else
5109                   found=no
5110                 fi
5111                 break 2
5112               fi
5113             done
5114           done
5115           if test "$found" != yes; then
5116             # deplib doesn't seem to be a libtool library
5117             if test "$linkmode,$pass" = "prog,link"; then
5118               compile_deplibs="$deplib $compile_deplibs"
5119               finalize_deplibs="$deplib $finalize_deplibs"
5120             else
5121               deplibs="$deplib $deplibs"
5122               test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5123             fi
5124             continue
5125           else # deplib is a libtool library
5126             # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
5127             # We need to do some special things here, and not later.
5128             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
5129               case " $predeps $postdeps " in
5130               *" $deplib "*)
5131                 if func_lalib_p "$lib"; then
5132                   library_names=
5133                   old_library=
5134                   func_source "$lib"
5135                   for l in $old_library $library_names; do
5136                     ll="$l"
5137                   done
5138                   if test "X$ll" = "X$old_library" ; then # only static version available
5139                     found=no
5140                     func_dirname "$lib" "" "."
5141                     ladir="$func_dirname_result"
5142                     lib=$ladir/$old_library
5143                     if test "$linkmode,$pass" = "prog,link"; then
5144                       compile_deplibs="$deplib $compile_deplibs"
5145                       finalize_deplibs="$deplib $finalize_deplibs"
5146                     else
5147                       deplibs="$deplib $deplibs"
5148                       test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
5149                     fi
5150                     continue
5151                   fi
5152                 fi
5153                 ;;
5154               *) ;;
5155               esac
5156             fi
5157           fi
5158           ;; # -l
5159         *.ltframework)
5160           if test "$linkmode,$pass" = "prog,link"; then
5161             compile_deplibs="$deplib $compile_deplibs"
5162             finalize_deplibs="$deplib $finalize_deplibs"
5163           else
5164             deplibs="$deplib $deplibs"
5165             if test "$linkmode" = lib ; then
5166                 case "$new_inherited_linker_flags " in
5167                     *" $deplib "*) ;;
5168                     * ) new_inherited_linker_flags="$new_inherited_linker_flags $deplib" ;;
5169                 esac
5170             fi
5171           fi
5172           continue
5173           ;;
5174         -L*)
5175           case $linkmode in
5176           lib)
5177             deplibs="$deplib $deplibs"
5178             test "$pass" = conv && continue
5179             newdependency_libs="$deplib $newdependency_libs"
5180             func_stripname '-L' '' "$deplib"
5181             newlib_search_path="$newlib_search_path $func_stripname_result"
5182             ;;
5183           prog)
5184             if test "$pass" = conv; then
5185               deplibs="$deplib $deplibs"
5186               continue
5187             fi
5188             if test "$pass" = scan; then
5189               deplibs="$deplib $deplibs"
5190             else
5191               compile_deplibs="$deplib $compile_deplibs"
5192               finalize_deplibs="$deplib $finalize_deplibs"
5193             fi
5194             func_stripname '-L' '' "$deplib"
5195             newlib_search_path="$newlib_search_path $func_stripname_result"
5196             ;;
5197           *)
5198             func_warning "\`-L' is ignored for archives/objects"
5199             ;;
5200           esac # linkmode
5201           continue
5202           ;; # -L
5203         -R*)
5204           if test "$pass" = link; then
5205             func_stripname '-R' '' "$deplib"
5206             dir=$func_stripname_result
5207             # Make sure the xrpath contains only unique directories.
5208             case "$xrpath " in
5209             *" $dir "*) ;;
5210             *) xrpath="$xrpath $dir" ;;
5211             esac
5212           fi
5213           deplibs="$deplib $deplibs"
5214           continue
5215           ;;
5216         *.la) lib="$deplib" ;;
5217         *.$libext)
5218           if test "$pass" = conv; then
5219             deplibs="$deplib $deplibs"
5220             continue
5221           fi
5222           case $linkmode in
5223           lib)
5224             # Linking convenience modules into shared libraries is allowed,
5225             # but linking other static libraries is non-portable.
5226             case " $dlpreconveniencelibs " in
5227             *" $deplib "*) ;;
5228             *)
5229               valid_a_lib=no
5230               case $deplibs_check_method in
5231                 match_pattern*)
5232                   set dummy $deplibs_check_method; shift
5233                   match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
5234                   if eval "\$ECHO \"X$deplib\"" 2>/dev/null | $Xsed -e 10q \
5235                     | $EGREP "$match_pattern_regex" > /dev/null; then
5236                     valid_a_lib=yes
5237                   fi
5238                 ;;
5239                 pass_all)
5240                   valid_a_lib=yes
5241                 ;;
5242               esac
5243               if test "$valid_a_lib" != yes; then
5244                 $ECHO
5245                 $ECHO "*** Warning: Trying to link with static lib archive $deplib."
5246                 $ECHO "*** I have the capability to make that library automatically link in when"
5247                 $ECHO "*** you link to this library.  But I can only do this if you have a"
5248                 $ECHO "*** shared version of the library, which you do not appear to have"
5249                 $ECHO "*** because the file extensions .$libext of this argument makes me believe"
5250                 $ECHO "*** that it is just a static archive that I should not use here."
5251               else
5252                 $ECHO
5253                 $ECHO "*** Warning: Linking the shared library $output against the"
5254                 $ECHO "*** static library $deplib is not portable!"
5255                 deplibs="$deplib $deplibs"
5256               fi
5257               ;;
5258             esac
5259             continue
5260             ;;
5261           prog)
5262             if test "$pass" != link; then
5263               deplibs="$deplib $deplibs"
5264             else
5265               compile_deplibs="$deplib $compile_deplibs"
5266               finalize_deplibs="$deplib $finalize_deplibs"
5267             fi
5268             continue
5269             ;;
5270           esac # linkmode
5271           ;; # *.$libext
5272         *.lo | *.$objext)
5273           if test "$pass" = conv; then
5274             deplibs="$deplib $deplibs"
5275           elif test "$linkmode" = prog; then
5276             if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
5277               # If there is no dlopen support or we're linking statically,
5278               # we need to preload.
5279               newdlprefiles="$newdlprefiles $deplib"
5280               compile_deplibs="$deplib $compile_deplibs"
5281               finalize_deplibs="$deplib $finalize_deplibs"
5282             else
5283               newdlfiles="$newdlfiles $deplib"
5284             fi
5285           fi
5286           continue
5287           ;;
5288         %DEPLIBS%)
5289           alldeplibs=yes
5290           continue
5291           ;;
5292         esac # case $deplib
5293
5294         if test "$found" = yes || test -f "$lib"; then :
5295         else
5296           func_fatal_error "cannot find the library \`$lib' or unhandled argument \`$deplib'"
5297         fi
5298
5299         # Check to see that this really is a libtool archive.
5300         func_lalib_unsafe_p "$lib" \
5301           || func_fatal_error "\`$lib' is not a valid libtool archive"
5302
5303         func_dirname "$lib" "" "."
5304         ladir="$func_dirname_result"
5305
5306         dlname=
5307         dlopen=
5308         dlpreopen=
5309         libdir=
5310         library_names=
5311         old_library=
5312         inherited_linker_flags=
5313         # If the library was installed with an old release of libtool,
5314         # it will not redefine variables installed, or shouldnotlink
5315         installed=yes
5316         shouldnotlink=no
5317         avoidtemprpath=
5318
5319
5320         # Read the .la file
5321         func_source "$lib"
5322
5323         # Convert "-framework foo" to "foo.ltframework"
5324         if test -n "$inherited_linker_flags"; then
5325           tmp_inherited_linker_flags=`$ECHO "X$inherited_linker_flags" | $Xsed -e 's/-framework \([^ $]*\)/\1.ltframework/g'`
5326           for tmp_inherited_linker_flag in $tmp_inherited_linker_flags; do
5327             case " $new_inherited_linker_flags " in
5328               *" $tmp_inherited_linker_flag "*) ;;
5329               *) new_inherited_linker_flags="$new_inherited_linker_flags $tmp_inherited_linker_flag";;
5330             esac
5331           done
5332         fi
5333         dependency_libs=`$ECHO "X $dependency_libs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5334         if test "$linkmode,$pass" = "lib,link" ||
5335            test "$linkmode,$pass" = "prog,scan" ||
5336            { test "$linkmode" != prog && test "$linkmode" != lib; }; then
5337           test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
5338           test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
5339         fi
5340
5341         if test "$pass" = conv; then
5342           # Only check for convenience libraries
5343           deplibs="$lib $deplibs"
5344           if test -z "$libdir"; then
5345             if test -z "$old_library"; then
5346               func_fatal_error "cannot find name of link library for \`$lib'"
5347             fi
5348             # It is a libtool convenience library, so add in its objects.
5349             convenience="$convenience $ladir/$objdir/$old_library"
5350             old_convenience="$old_convenience $ladir/$objdir/$old_library"
5351           elif test "$linkmode" != prog && test "$linkmode" != lib; then
5352             func_fatal_error "\`$lib' is not a convenience library"
5353           fi
5354           tmp_libs=
5355           for deplib in $dependency_libs; do
5356             deplibs="$deplib $deplibs"
5357             if $opt_duplicate_deps ; then
5358               case "$tmp_libs " in
5359               *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5360               esac
5361             fi
5362             tmp_libs="$tmp_libs $deplib"
5363           done
5364           continue
5365         fi # $pass = conv
5366
5367
5368         # Get the name of the library we link against.
5369         linklib=
5370         for l in $old_library $library_names; do
5371           linklib="$l"
5372         done
5373         if test -z "$linklib"; then
5374           func_fatal_error "cannot find name of link library for \`$lib'"
5375         fi
5376
5377         # This library was specified with -dlopen.
5378         if test "$pass" = dlopen; then
5379           if test -z "$libdir"; then
5380             func_fatal_error "cannot -dlopen a convenience library: \`$lib'"
5381           fi
5382           if test -z "$dlname" ||
5383              test "$dlopen_support" != yes ||
5384              test "$build_libtool_libs" = no; then
5385             # If there is no dlname, no dlopen support or we're linking
5386             # statically, we need to preload.  We also need to preload any
5387             # dependent libraries so libltdl's deplib preloader doesn't
5388             # bomb out in the load deplibs phase.
5389             dlprefiles="$dlprefiles $lib $dependency_libs"
5390           else
5391             newdlfiles="$newdlfiles $lib"
5392           fi
5393           continue
5394         fi # $pass = dlopen
5395
5396         # We need an absolute path.
5397         case $ladir in
5398         [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
5399         *)
5400           abs_ladir=`cd "$ladir" && pwd`
5401           if test -z "$abs_ladir"; then
5402             func_warning "cannot determine absolute directory name of \`$ladir'"
5403             func_warning "passing it literally to the linker, although it might fail"
5404             abs_ladir="$ladir"
5405           fi
5406           ;;
5407         esac
5408         func_basename "$lib"
5409         laname="$func_basename_result"
5410
5411         # Find the relevant object directory and library name.
5412         if test "X$installed" = Xyes; then
5413           if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5414             func_warning "library \`$lib' was moved."
5415             dir="$ladir"
5416             absdir="$abs_ladir"
5417             libdir="$abs_ladir"
5418           else
5419             dir="$libdir"
5420             absdir="$libdir"
5421           fi
5422           test "X$hardcode_automatic" = Xyes && avoidtemprpath=yes
5423         else
5424           if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
5425             dir="$ladir"
5426             absdir="$abs_ladir"
5427             # Remove this search path later
5428             notinst_path="$notinst_path $abs_ladir"
5429           else
5430             dir="$ladir/$objdir"
5431             absdir="$abs_ladir/$objdir"
5432             # Remove this search path later
5433             notinst_path="$notinst_path $abs_ladir"
5434           fi
5435         fi # $installed = yes
5436         func_stripname 'lib' '.la' "$laname"
5437         name=$func_stripname_result
5438
5439         # This library was specified with -dlpreopen.
5440         if test "$pass" = dlpreopen; then
5441           if test -z "$libdir" && test "$linkmode" = prog; then
5442             func_fatal_error "only libraries may -dlpreopen a convenience library: \`$lib'"
5443           fi
5444           # Prefer using a static library (so that no silly _DYNAMIC symbols
5445           # are required to link).
5446           if test -n "$old_library"; then
5447             newdlprefiles="$newdlprefiles $dir/$old_library"
5448             # Keep a list of preopened convenience libraries to check
5449             # that they are being used correctly in the link pass.
5450             test -z "$libdir" && \
5451                 dlpreconveniencelibs="$dlpreconveniencelibs $dir/$old_library"
5452           # Otherwise, use the dlname, so that lt_dlopen finds it.
5453           elif test -n "$dlname"; then
5454             newdlprefiles="$newdlprefiles $dir/$dlname"
5455           else
5456             newdlprefiles="$newdlprefiles $dir/$linklib"
5457           fi
5458         fi # $pass = dlpreopen
5459
5460         if test -z "$libdir"; then
5461           # Link the convenience library
5462           if test "$linkmode" = lib; then
5463             deplibs="$dir/$old_library $deplibs"
5464           elif test "$linkmode,$pass" = "prog,link"; then
5465             compile_deplibs="$dir/$old_library $compile_deplibs"
5466             finalize_deplibs="$dir/$old_library $finalize_deplibs"
5467           else
5468             deplibs="$lib $deplibs" # used for prog,scan pass
5469           fi
5470           continue
5471         fi
5472
5473
5474         if test "$linkmode" = prog && test "$pass" != link; then
5475           newlib_search_path="$newlib_search_path $ladir"
5476           deplibs="$lib $deplibs"
5477
5478           linkalldeplibs=no
5479           if test "$link_all_deplibs" != no || test -z "$library_names" ||
5480              test "$build_libtool_libs" = no; then
5481             linkalldeplibs=yes
5482           fi
5483
5484           tmp_libs=
5485           for deplib in $dependency_libs; do
5486             case $deplib in
5487             -L*) func_stripname '-L' '' "$deplib"
5488                  newlib_search_path="$newlib_search_path $func_stripname_result"
5489                  ;;
5490             esac
5491             # Need to link against all dependency_libs?
5492             if test "$linkalldeplibs" = yes; then
5493               deplibs="$deplib $deplibs"
5494             else
5495               # Need to hardcode shared library paths
5496               # or/and link against static libraries
5497               newdependency_libs="$deplib $newdependency_libs"
5498             fi
5499             if $opt_duplicate_deps ; then
5500               case "$tmp_libs " in
5501               *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5502               esac
5503             fi
5504             tmp_libs="$tmp_libs $deplib"
5505           done # for deplib
5506           continue
5507         fi # $linkmode = prog...
5508
5509         if test "$linkmode,$pass" = "prog,link"; then
5510           if test -n "$library_names" &&
5511              { { test "$prefer_static_libs" = no ||
5512                  test "$prefer_static_libs,$installed" = "built,yes"; } ||
5513                test -z "$old_library"; }; then
5514             # We need to hardcode the library path
5515             if test -n "$shlibpath_var" && test -z "$avoidtemprpath" ; then
5516               # Make sure the rpath contains only unique directories.
5517               case "$temp_rpath:" in
5518               *"$absdir:"*) ;;
5519               *) temp_rpath="$temp_rpath$absdir:" ;;
5520               esac
5521             fi
5522
5523             # Hardcode the library path.
5524             # Skip directories that are in the system default run-time
5525             # search path.
5526             case " $sys_lib_dlsearch_path " in
5527             *" $absdir "*) ;;
5528             *)
5529               case "$compile_rpath " in
5530               *" $absdir "*) ;;
5531               *) compile_rpath="$compile_rpath $absdir"
5532               esac
5533               ;;
5534             esac
5535             case " $sys_lib_dlsearch_path " in
5536             *" $libdir "*) ;;
5537             *)
5538               case "$finalize_rpath " in
5539               *" $libdir "*) ;;
5540               *) finalize_rpath="$finalize_rpath $libdir"
5541               esac
5542               ;;
5543             esac
5544           fi # $linkmode,$pass = prog,link...
5545
5546           if test "$alldeplibs" = yes &&
5547              { test "$deplibs_check_method" = pass_all ||
5548                { test "$build_libtool_libs" = yes &&
5549                  test -n "$library_names"; }; }; then
5550             # We only need to search for static libraries
5551             continue
5552           fi
5553         fi
5554
5555         link_static=no # Whether the deplib will be linked statically
5556         use_static_libs=$prefer_static_libs
5557         if test "$use_static_libs" = built && test "$installed" = yes; then
5558           use_static_libs=no
5559         fi
5560         if test -n "$library_names" &&
5561            { test "$use_static_libs" = no || test -z "$old_library"; }; then
5562           case $host in
5563           *cygwin* | *mingw* | *cegcc*)
5564               # No point in relinking DLLs because paths are not encoded
5565               notinst_deplibs="$notinst_deplibs $lib"
5566               need_relink=no
5567             ;;
5568           *)
5569             if test "$installed" = no; then
5570               notinst_deplibs="$notinst_deplibs $lib"
5571               need_relink=yes
5572             fi
5573             ;;
5574           esac
5575           # This is a shared library
5576
5577           # Warn about portability, can't link against -module's on some
5578           # systems (darwin).  Don't bleat about dlopened modules though!
5579           dlopenmodule=""
5580           for dlpremoduletest in $dlprefiles; do
5581             if test "X$dlpremoduletest" = "X$lib"; then
5582               dlopenmodule="$dlpremoduletest"
5583               break
5584             fi
5585           done
5586           if test -z "$dlopenmodule" && test "$shouldnotlink" = yes && test "$pass" = link; then
5587             $ECHO
5588             if test "$linkmode" = prog; then
5589               $ECHO "*** Warning: Linking the executable $output against the loadable module"
5590             else
5591               $ECHO "*** Warning: Linking the shared library $output against the loadable module"
5592             fi
5593             $ECHO "*** $linklib is not portable!"
5594           fi
5595           if test "$linkmode" = lib &&
5596              test "$hardcode_into_libs" = yes; then
5597             # Hardcode the library path.
5598             # Skip directories that are in the system default run-time
5599             # search path.
5600             case " $sys_lib_dlsearch_path " in
5601             *" $absdir "*) ;;
5602             *)
5603               case "$compile_rpath " in
5604               *" $absdir "*) ;;
5605               *) compile_rpath="$compile_rpath $absdir"
5606               esac
5607               ;;
5608             esac
5609             case " $sys_lib_dlsearch_path " in
5610             *" $libdir "*) ;;
5611             *)
5612               case "$finalize_rpath " in
5613               *" $libdir "*) ;;
5614               *) finalize_rpath="$finalize_rpath $libdir"
5615               esac
5616               ;;
5617             esac
5618           fi
5619
5620           if test -n "$old_archive_from_expsyms_cmds"; then
5621             # figure out the soname
5622             set dummy $library_names
5623             shift
5624             realname="$1"
5625             shift
5626             libname=`eval "\\$ECHO \"$libname_spec\""`
5627             # use dlname if we got it. it's perfectly good, no?
5628             if test -n "$dlname"; then
5629               soname="$dlname"
5630             elif test -n "$soname_spec"; then
5631               # bleh windows
5632               case $host in
5633               *cygwin* | mingw* | *cegcc*)
5634                 func_arith $current - $age
5635                 major=$func_arith_result
5636                 versuffix="-$major"
5637                 ;;
5638               esac
5639               eval soname=\"$soname_spec\"
5640             else
5641               soname="$realname"
5642             fi
5643
5644             # Make a new name for the extract_expsyms_cmds to use
5645             soroot="$soname"
5646             func_basename "$soroot"
5647             soname="$func_basename_result"
5648             func_stripname 'lib' '.dll' "$soname"
5649             newlib=libimp-$func_stripname_result.a
5650
5651             # If the library has no export list, then create one now
5652             if test -f "$output_objdir/$soname-def"; then :
5653             else
5654               func_verbose "extracting exported symbol list from \`$soname'"
5655               func_execute_cmds "$extract_expsyms_cmds" 'exit $?'
5656             fi
5657
5658             # Create $newlib
5659             if test -f "$output_objdir/$newlib"; then :; else
5660               func_verbose "generating import library for \`$soname'"
5661               func_execute_cmds "$old_archive_from_expsyms_cmds" 'exit $?'
5662             fi
5663             # make sure the library variables are pointing to the new library
5664             dir=$output_objdir
5665             linklib=$newlib
5666           fi # test -n "$old_archive_from_expsyms_cmds"
5667
5668           if test "$linkmode" = prog || test "$mode" != relink; then
5669             add_shlibpath=
5670             add_dir=
5671             add=
5672             lib_linked=yes
5673             case $hardcode_action in
5674             immediate | unsupported)
5675               if test "$hardcode_direct" = no; then
5676                 add="$dir/$linklib"
5677                 case $host in
5678                   *-*-sco3.2v5.0.[024]*) add_dir="-L$dir" ;;
5679                   *-*-sysv4*uw2*) add_dir="-L$dir" ;;
5680                   *-*-sysv5OpenUNIX* | *-*-sysv5UnixWare7.[01].[10]* | \
5681                     *-*-unixware7*) add_dir="-L$dir" ;;
5682                   *-*-darwin* )
5683                     # if the lib is a (non-dlopened) module then we can not
5684                     # link against it, someone is ignoring the earlier warnings
5685                     if /usr/bin/file -L $add 2> /dev/null |
5686                          $GREP ": [^:]* bundle" >/dev/null ; then
5687                       if test "X$dlopenmodule" != "X$lib"; then
5688                         $ECHO "*** Warning: lib $linklib is a module, not a shared library"
5689                         if test -z "$old_library" ; then
5690                           $ECHO
5691                           $ECHO "*** And there doesn't seem to be a static archive available"
5692                           $ECHO "*** The link will probably fail, sorry"
5693                         else
5694                           add="$dir/$old_library"
5695                         fi
5696                       elif test -n "$old_library"; then
5697                         add="$dir/$old_library"
5698                       fi
5699                     fi
5700                 esac
5701               elif test "$hardcode_minus_L" = no; then
5702                 case $host in
5703                 *-*-sunos*) add_shlibpath="$dir" ;;
5704                 esac
5705                 add_dir="-L$dir"
5706                 add="-l$name"
5707               elif test "$hardcode_shlibpath_var" = no; then
5708                 add_shlibpath="$dir"
5709                 add="-l$name"
5710               else
5711                 lib_linked=no
5712               fi
5713               ;;
5714             relink)
5715               if test "$hardcode_direct" = yes &&
5716                  test "$hardcode_direct_absolute" = no; then
5717                 add="$dir/$linklib"
5718               elif test "$hardcode_minus_L" = yes; then
5719                 add_dir="-L$dir"
5720                 # Try looking first in the location we're being installed to.
5721                 if test -n "$inst_prefix_dir"; then
5722                   case $libdir in
5723                     [\\/]*)
5724                       add_dir="$add_dir -L$inst_prefix_dir$libdir"
5725                       ;;
5726                   esac
5727                 fi
5728                 add="-l$name"
5729               elif test "$hardcode_shlibpath_var" = yes; then
5730                 add_shlibpath="$dir"
5731                 add="-l$name"
5732               else
5733                 lib_linked=no
5734               fi
5735               ;;
5736             *) lib_linked=no ;;
5737             esac
5738
5739             if test "$lib_linked" != yes; then
5740               func_fatal_configuration "unsupported hardcode properties"
5741             fi
5742
5743             if test -n "$add_shlibpath"; then
5744               case :$compile_shlibpath: in
5745               *":$add_shlibpath:"*) ;;
5746               *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
5747               esac
5748             fi
5749             if test "$linkmode" = prog; then
5750               test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
5751               test -n "$add" && compile_deplibs="$add $compile_deplibs"
5752             else
5753               test -n "$add_dir" && deplibs="$add_dir $deplibs"
5754               test -n "$add" && deplibs="$add $deplibs"
5755               if test "$hardcode_direct" != yes &&
5756                  test "$hardcode_minus_L" != yes &&
5757                  test "$hardcode_shlibpath_var" = yes; then
5758                 case :$finalize_shlibpath: in
5759                 *":$libdir:"*) ;;
5760                 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5761                 esac
5762               fi
5763             fi
5764           fi
5765
5766           if test "$linkmode" = prog || test "$mode" = relink; then
5767             add_shlibpath=
5768             add_dir=
5769             add=
5770             # Finalize command for both is simple: just hardcode it.
5771             if test "$hardcode_direct" = yes &&
5772                test "$hardcode_direct_absolute" = no; then
5773               add="$libdir/$linklib"
5774             elif test "$hardcode_minus_L" = yes; then
5775               add_dir="-L$libdir"
5776               add="-l$name"
5777             elif test "$hardcode_shlibpath_var" = yes; then
5778               case :$finalize_shlibpath: in
5779               *":$libdir:"*) ;;
5780               *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
5781               esac
5782               add="-l$name"
5783             elif test "$hardcode_automatic" = yes; then
5784               if test -n "$inst_prefix_dir" &&
5785                  test -f "$inst_prefix_dir$libdir/$linklib" ; then
5786                 add="$inst_prefix_dir$libdir/$linklib"
5787               else
5788                 add="$libdir/$linklib"
5789               fi
5790             else
5791               # We cannot seem to hardcode it, guess we'll fake it.
5792               add_dir="-L$libdir"
5793               # Try looking first in the location we're being installed to.
5794               if test -n "$inst_prefix_dir"; then
5795                 case $libdir in
5796                   [\\/]*)
5797                     add_dir="$add_dir -L$inst_prefix_dir$libdir"
5798                     ;;
5799                 esac
5800               fi
5801               add="-l$name"
5802             fi
5803
5804             if test "$linkmode" = prog; then
5805               test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
5806               test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
5807             else
5808               test -n "$add_dir" && deplibs="$add_dir $deplibs"
5809               test -n "$add" && deplibs="$add $deplibs"
5810             fi
5811           fi
5812         elif test "$linkmode" = prog; then
5813           # Here we assume that one of hardcode_direct or hardcode_minus_L
5814           # is not unsupported.  This is valid on all known static and
5815           # shared platforms.
5816           if test "$hardcode_direct" != unsupported; then
5817             test -n "$old_library" && linklib="$old_library"
5818             compile_deplibs="$dir/$linklib $compile_deplibs"
5819             finalize_deplibs="$dir/$linklib $finalize_deplibs"
5820           else
5821             compile_deplibs="-l$name -L$dir $compile_deplibs"
5822             finalize_deplibs="-l$name -L$dir $finalize_deplibs"
5823           fi
5824         elif test "$build_libtool_libs" = yes; then
5825           # Not a shared library
5826           if test "$deplibs_check_method" != pass_all; then
5827             # We're trying link a shared library against a static one
5828             # but the system doesn't support it.
5829
5830             # Just print a warning and add the library to dependency_libs so
5831             # that the program can be linked against the static library.
5832             $ECHO
5833             $ECHO "*** Warning: This system can not link to static lib archive $lib."
5834             $ECHO "*** I have the capability to make that library automatically link in when"
5835             $ECHO "*** you link to this library.  But I can only do this if you have a"
5836             $ECHO "*** shared version of the library, which you do not appear to have."
5837             if test "$module" = yes; then
5838               $ECHO "*** But as you try to build a module library, libtool will still create "
5839               $ECHO "*** a static module, that should work as long as the dlopening application"
5840               $ECHO "*** is linked with the -dlopen flag to resolve symbols at runtime."
5841               if test -z "$global_symbol_pipe"; then
5842                 $ECHO
5843                 $ECHO "*** However, this would only work if libtool was able to extract symbol"
5844                 $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
5845                 $ECHO "*** not find such a program.  So, this module is probably useless."
5846                 $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
5847               fi
5848               if test "$build_old_libs" = no; then
5849                 build_libtool_libs=module
5850                 build_old_libs=yes
5851               else
5852                 build_libtool_libs=no
5853               fi
5854             fi
5855           else
5856             deplibs="$dir/$old_library $deplibs"
5857             link_static=yes
5858           fi
5859         fi # link shared/static library?
5860
5861         if test "$linkmode" = lib; then
5862           if test -n "$dependency_libs" &&
5863              { test "$hardcode_into_libs" != yes ||
5864                test "$build_old_libs" = yes ||
5865                test "$link_static" = yes; }; then
5866             # Extract -R from dependency_libs
5867             temp_deplibs=
5868             for libdir in $dependency_libs; do
5869               case $libdir in
5870               -R*) func_stripname '-R' '' "$libdir"
5871                    temp_xrpath=$func_stripname_result
5872                    case " $xrpath " in
5873                    *" $temp_xrpath "*) ;;
5874                    *) xrpath="$xrpath $temp_xrpath";;
5875                    esac;;
5876               *) temp_deplibs="$temp_deplibs $libdir";;
5877               esac
5878             done
5879             dependency_libs="$temp_deplibs"
5880           fi
5881
5882           newlib_search_path="$newlib_search_path $absdir"
5883           # Link against this library
5884           test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
5885           # ... and its dependency_libs
5886           tmp_libs=
5887           for deplib in $dependency_libs; do
5888             newdependency_libs="$deplib $newdependency_libs"
5889             if $opt_duplicate_deps ; then
5890               case "$tmp_libs " in
5891               *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
5892               esac
5893             fi
5894             tmp_libs="$tmp_libs $deplib"
5895           done
5896
5897           if test "$link_all_deplibs" != no; then
5898             # Add the search paths of all dependency libraries
5899             for deplib in $dependency_libs; do
5900               case $deplib in
5901               -L*) path="$deplib" ;;
5902               *.la)
5903                 func_dirname "$deplib" "" "."
5904                 dir="$func_dirname_result"
5905                 # We need an absolute path.
5906                 case $dir in
5907                 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
5908                 *)
5909                   absdir=`cd "$dir" && pwd`
5910                   if test -z "$absdir"; then
5911                     func_warning "cannot determine absolute directory name of \`$dir'"
5912                     absdir="$dir"
5913                   fi
5914                   ;;
5915                 esac
5916                 if $GREP "^installed=no" $deplib > /dev/null; then
5917                 case $host in
5918                 *-*-darwin*)
5919                   depdepl=
5920                   eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
5921                   if test -n "$deplibrary_names" ; then
5922                     for tmp in $deplibrary_names ; do
5923                       depdepl=$tmp
5924                     done
5925                     if test -f "$absdir/$objdir/$depdepl" ; then
5926                       depdepl="$absdir/$objdir/$depdepl"
5927                       darwin_install_name=`${OTOOL} -L $depdepl | awk '{if (NR == 2) {print $1;exit}}'`
5928                       if test -z "$darwin_install_name"; then
5929                           darwin_install_name=`${OTOOL64} -L $depdepl  | awk '{if (NR == 2) {print $1;exit}}'`
5930                       fi
5931                       compiler_flags="$compiler_flags ${wl}-dylib_file ${wl}${darwin_install_name}:${depdepl}"
5932                       linker_flags="$linker_flags -dylib_file ${darwin_install_name}:${depdepl}"
5933                       path=
5934                     fi
5935                   fi
5936                   ;;
5937                 *)
5938                   path="-L$absdir/$objdir"
5939                   ;;
5940                 esac
5941                 else
5942                   eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5943                   test -z "$libdir" && \
5944                     func_fatal_error "\`$deplib' is not a valid libtool archive"
5945                   test "$absdir" != "$libdir" && \
5946                     func_warning "\`$deplib' seems to be moved"
5947
5948                   path="-L$absdir"
5949                 fi
5950                 ;;
5951               esac
5952               case " $deplibs " in
5953               *" $path "*) ;;
5954               *) deplibs="$path $deplibs" ;;
5955               esac
5956             done
5957           fi # link_all_deplibs != no
5958         fi # linkmode = lib
5959       done # for deplib in $libs
5960       if test "$pass" = link; then
5961         if test "$linkmode" = "prog"; then
5962           compile_deplibs="$new_inherited_linker_flags $compile_deplibs"
5963           finalize_deplibs="$new_inherited_linker_flags $finalize_deplibs"
5964         else
5965           compiler_flags="$compiler_flags "`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
5966         fi
5967       fi
5968       dependency_libs="$newdependency_libs"
5969       if test "$pass" = dlpreopen; then
5970         # Link the dlpreopened libraries before other libraries
5971         for deplib in $save_deplibs; do
5972           deplibs="$deplib $deplibs"
5973         done
5974       fi
5975       if test "$pass" != dlopen; then
5976         if test "$pass" != conv; then
5977           # Make sure lib_search_path contains only unique directories.
5978           lib_search_path=
5979           for dir in $newlib_search_path; do
5980             case "$lib_search_path " in
5981             *" $dir "*) ;;
5982             *) lib_search_path="$lib_search_path $dir" ;;
5983             esac
5984           done
5985           newlib_search_path=
5986         fi
5987
5988         if test "$linkmode,$pass" != "prog,link"; then
5989           vars="deplibs"
5990         else
5991           vars="compile_deplibs finalize_deplibs"
5992         fi
5993         for var in $vars dependency_libs; do
5994           # Add libraries to $var in reverse order
5995           eval tmp_libs=\"\$$var\"
5996           new_libs=
5997           for deplib in $tmp_libs; do
5998             # FIXME: Pedantically, this is the right thing to do, so
5999             #        that some nasty dependency loop isn't accidentally
6000             #        broken:
6001             #new_libs="$deplib $new_libs"
6002             # Pragmatically, this seems to cause very few problems in
6003             # practice:
6004             case $deplib in
6005             -L*) new_libs="$deplib $new_libs" ;;
6006             -R*) ;;
6007             *)
6008               # And here is the reason: when a library appears more
6009               # than once as an explicit dependence of a library, or
6010               # is implicitly linked in more than once by the
6011               # compiler, it is considered special, and multiple
6012               # occurrences thereof are not removed.  Compare this
6013               # with having the same library being listed as a
6014               # dependency of multiple other libraries: in this case,
6015               # we know (pedantically, we assume) the library does not
6016               # need to be listed more than once, so we keep only the
6017               # last copy.  This is not always right, but it is rare
6018               # enough that we require users that really mean to play
6019               # such unportable linking tricks to link the library
6020               # using -Wl,-lname, so that libtool does not consider it
6021               # for duplicate removal.
6022               case " $specialdeplibs " in
6023               *" $deplib "*) new_libs="$deplib $new_libs" ;;
6024               *)
6025                 case " $new_libs " in
6026                 *" $deplib "*) ;;
6027                 *) new_libs="$deplib $new_libs" ;;
6028                 esac
6029                 ;;
6030               esac
6031               ;;
6032             esac
6033           done
6034           tmp_libs=
6035           for deplib in $new_libs; do
6036             case $deplib in
6037             -L*)
6038               case " $tmp_libs " in
6039               *" $deplib "*) ;;
6040               *) tmp_libs="$tmp_libs $deplib" ;;
6041               esac
6042               ;;
6043             *) tmp_libs="$tmp_libs $deplib" ;;
6044             esac
6045           done
6046           eval $var=\"$tmp_libs\"
6047         done # for var
6048       fi
6049       # Last step: remove runtime libs from dependency_libs
6050       # (they stay in deplibs)
6051       tmp_libs=
6052       for i in $dependency_libs ; do
6053         case " $predeps $postdeps $compiler_lib_search_path " in
6054         *" $i "*)
6055           i=""
6056           ;;
6057         esac
6058         if test -n "$i" ; then
6059           tmp_libs="$tmp_libs $i"
6060         fi
6061       done
6062       dependency_libs=$tmp_libs
6063     done # for pass
6064     if test "$linkmode" = prog; then
6065       dlfiles="$newdlfiles"
6066     fi
6067     if test "$linkmode" = prog || test "$linkmode" = lib; then
6068       dlprefiles="$newdlprefiles"
6069     fi
6070
6071     case $linkmode in
6072     oldlib)
6073       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
6074         func_warning "\`-dlopen' is ignored for archives"
6075       fi
6076
6077       case " $deplibs" in
6078       *\ -l* | *\ -L*)
6079         func_warning "\`-l' and \`-L' are ignored for archives" ;;
6080       esac
6081
6082       test -n "$rpath" && \
6083         func_warning "\`-rpath' is ignored for archives"
6084
6085       test -n "$xrpath" && \
6086         func_warning "\`-R' is ignored for archives"
6087
6088       test -n "$vinfo" && \
6089         func_warning "\`-version-info/-version-number' is ignored for archives"
6090
6091       test -n "$release" && \
6092         func_warning "\`-release' is ignored for archives"
6093
6094       test -n "$export_symbols$export_symbols_regex" && \
6095         func_warning "\`-export-symbols' is ignored for archives"
6096
6097       # Now set the variables for building old libraries.
6098       build_libtool_libs=no
6099       oldlibs="$output"
6100       objs="$objs$old_deplibs"
6101       ;;
6102
6103     lib)
6104       # Make sure we only generate libraries of the form `libNAME.la'.
6105       case $outputname in
6106       lib*)
6107         func_stripname 'lib' '.la' "$outputname"
6108         name=$func_stripname_result
6109         eval shared_ext=\"$shrext_cmds\"
6110         eval libname=\"$libname_spec\"
6111         ;;
6112       *)
6113         test "$module" = no && \
6114           func_fatal_help "libtool library \`$output' must begin with \`lib'"
6115
6116         if test "$need_lib_prefix" != no; then
6117           # Add the "lib" prefix for modules if required
6118           func_stripname '' '.la' "$outputname"
6119           name=$func_stripname_result
6120           eval shared_ext=\"$shrext_cmds\"
6121           eval libname=\"$libname_spec\"
6122         else
6123           func_stripname '' '.la' "$outputname"
6124           libname=$func_stripname_result
6125         fi
6126         ;;
6127       esac
6128
6129       if test -n "$objs"; then
6130         if test "$deplibs_check_method" != pass_all; then
6131           func_fatal_error "cannot build libtool library \`$output' from non-libtool objects on this host:$objs"
6132         else
6133           $ECHO
6134           $ECHO "*** Warning: Linking the shared library $output against the non-libtool"
6135           $ECHO "*** objects $objs is not portable!"
6136           libobjs="$libobjs $objs"
6137         fi
6138       fi
6139
6140       test "$dlself" != no && \
6141         func_warning "\`-dlopen self' is ignored for libtool libraries"
6142
6143       set dummy $rpath
6144       shift
6145       test "$#" -gt 1 && \
6146         func_warning "ignoring multiple \`-rpath's for a libtool library"
6147
6148       install_libdir="$1"
6149
6150       oldlibs=
6151       if test -z "$rpath"; then
6152         if test "$build_libtool_libs" = yes; then
6153           # Building a libtool convenience library.
6154           # Some compilers have problems with a `.al' extension so
6155           # convenience libraries should have the same extension an
6156           # archive normally would.
6157           oldlibs="$output_objdir/$libname.$libext $oldlibs"
6158           build_libtool_libs=convenience
6159           build_old_libs=yes
6160         fi
6161
6162         test -n "$vinfo" && \
6163           func_warning "\`-version-info/-version-number' is ignored for convenience libraries"
6164
6165         test -n "$release" && \
6166           func_warning "\`-release' is ignored for convenience libraries"
6167       else
6168
6169         # Parse the version information argument.
6170         save_ifs="$IFS"; IFS=':'
6171         set dummy $vinfo 0 0 0
6172         shift
6173         IFS="$save_ifs"
6174
6175         test -n "$7" && \
6176           func_fatal_help "too many parameters to \`-version-info'"
6177
6178         # convert absolute version numbers to libtool ages
6179         # this retains compatibility with .la files and attempts
6180         # to make the code below a bit more comprehensible
6181
6182         case $vinfo_number in
6183         yes)
6184           number_major="$1"
6185           number_minor="$2"
6186           number_revision="$3"
6187           #
6188           # There are really only two kinds -- those that
6189           # use the current revision as the major version
6190           # and those that subtract age and use age as
6191           # a minor version.  But, then there is irix
6192           # which has an extra 1 added just for fun
6193           #
6194           case $version_type in
6195           darwin|linux|osf|windows|none)
6196             func_arith $number_major + $number_minor
6197             current=$func_arith_result
6198             age="$number_minor"
6199             revision="$number_revision"
6200             ;;
6201           freebsd-aout|freebsd-elf|sunos)
6202             current="$number_major"
6203             revision="$number_minor"
6204             age="0"
6205             ;;
6206           irix|nonstopux)
6207             func_arith $number_major + $number_minor
6208             current=$func_arith_result
6209             age="$number_minor"
6210             revision="$number_minor"
6211             lt_irix_increment=no
6212             ;;
6213           esac
6214           ;;
6215         no)
6216           current="$1"
6217           revision="$2"
6218           age="$3"
6219           ;;
6220         esac
6221
6222         # Check that each of the things are valid numbers.
6223         case $current in
6224         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]) ;;
6225         *)
6226           func_error "CURRENT \`$current' must be a nonnegative integer"
6227           func_fatal_error "\`$vinfo' is not valid version information"
6228           ;;
6229         esac
6230
6231         case $revision in
6232         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]) ;;
6233         *)
6234           func_error "REVISION \`$revision' must be a nonnegative integer"
6235           func_fatal_error "\`$vinfo' is not valid version information"
6236           ;;
6237         esac
6238
6239         case $age in
6240         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]) ;;
6241         *)
6242           func_error "AGE \`$age' must be a nonnegative integer"
6243           func_fatal_error "\`$vinfo' is not valid version information"
6244           ;;
6245         esac
6246
6247         if test "$age" -gt "$current"; then
6248           func_error "AGE \`$age' is greater than the current interface number \`$current'"
6249           func_fatal_error "\`$vinfo' is not valid version information"
6250         fi
6251
6252         # Calculate the version variables.
6253         major=
6254         versuffix=
6255         verstring=
6256         case $version_type in
6257         none) ;;
6258
6259         darwin)
6260           # Like Linux, but with the current version available in
6261           # verstring for coding it into the library header
6262           func_arith $current - $age
6263           major=.$func_arith_result
6264           versuffix="$major.$age.$revision"
6265           # Darwin ld doesn't like 0 for these options...
6266           func_arith $current + 1
6267           minor_current=$func_arith_result
6268           xlcverstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
6269           verstring="-compatibility_version $minor_current -current_version $minor_current.$revision"
6270           ;;
6271
6272         freebsd-aout)
6273           major=".$current"
6274           versuffix=".$current.$revision";
6275           ;;
6276
6277         freebsd-elf)
6278           major=".$current"
6279           versuffix=".$current"
6280           ;;
6281
6282         irix | nonstopux)
6283           if test "X$lt_irix_increment" = "Xno"; then
6284             func_arith $current - $age
6285           else
6286             func_arith $current - $age + 1
6287           fi
6288           major=$func_arith_result
6289
6290           case $version_type in
6291             nonstopux) verstring_prefix=nonstopux ;;
6292             *)         verstring_prefix=sgi ;;
6293           esac
6294           verstring="$verstring_prefix$major.$revision"
6295
6296           # Add in all the interfaces that we are compatible with.
6297           loop=$revision
6298           while test "$loop" -ne 0; do
6299             func_arith $revision - $loop
6300             iface=$func_arith_result
6301             func_arith $loop - 1
6302             loop=$func_arith_result
6303             verstring="$verstring_prefix$major.$iface:$verstring"
6304           done
6305
6306           # Before this point, $major must not contain `.'.
6307           major=.$major
6308           versuffix="$major.$revision"
6309           ;;
6310
6311         linux)
6312           func_arith $current - $age
6313           major=.$func_arith_result
6314           versuffix="$major.$age.$revision"
6315           ;;
6316
6317         osf)
6318           func_arith $current - $age
6319           major=.$func_arith_result
6320           versuffix=".$current.$age.$revision"
6321           verstring="$current.$age.$revision"
6322
6323           # Add in all the interfaces that we are compatible with.
6324           loop=$age
6325           while test "$loop" -ne 0; do
6326             func_arith $current - $loop
6327             iface=$func_arith_result
6328             func_arith $loop - 1
6329             loop=$func_arith_result
6330             verstring="$verstring:${iface}.0"
6331           done
6332
6333           # Make executables depend on our current version.
6334           verstring="$verstring:${current}.0"
6335           ;;
6336
6337         qnx)
6338           major=".$current"
6339           versuffix=".$current"
6340           ;;
6341
6342         sunos)
6343           major=".$current"
6344           versuffix=".$current.$revision"
6345           ;;
6346
6347         windows)
6348           # Use '-' rather than '.', since we only want one
6349           # extension on DOS 8.3 filesystems.
6350           func_arith $current - $age
6351           major=$func_arith_result
6352           versuffix="-$major"
6353           ;;
6354
6355         *)
6356           func_fatal_configuration "unknown library version type \`$version_type'"
6357           ;;
6358         esac
6359
6360         # Clear the version info if we defaulted, and they specified a release.
6361         if test -z "$vinfo" && test -n "$release"; then
6362           major=
6363           case $version_type in
6364           darwin)
6365             # we can't check for "0.0" in archive_cmds due to quoting
6366             # problems, so we reset it completely
6367             verstring=
6368             ;;
6369           *)
6370             verstring="0.0"
6371             ;;
6372           esac
6373           if test "$need_version" = no; then
6374             versuffix=
6375           else
6376             versuffix=".0.0"
6377           fi
6378         fi
6379
6380         # Remove version info from name if versioning should be avoided
6381         if test "$avoid_version" = yes && test "$need_version" = no; then
6382           major=
6383           versuffix=
6384           verstring=""
6385         fi
6386
6387         # Check to see if the archive will have undefined symbols.
6388         if test "$allow_undefined" = yes; then
6389           if test "$allow_undefined_flag" = unsupported; then
6390             func_warning "undefined symbols not allowed in $host shared libraries"
6391             build_libtool_libs=no
6392             build_old_libs=yes
6393           fi
6394         else
6395           # Don't allow undefined symbols.
6396           allow_undefined_flag="$no_undefined_flag"
6397         fi
6398
6399       fi
6400
6401       func_generate_dlsyms "$libname" "$libname" "yes"
6402       libobjs="$libobjs $symfileobj"
6403       test "X$libobjs" = "X " && libobjs=
6404
6405       if test "$mode" != relink; then
6406         # Remove our outputs, but don't remove object files since they
6407         # may have been created when compiling PIC objects.
6408         removelist=
6409         tempremovelist=`$ECHO "$output_objdir/*"`
6410         for p in $tempremovelist; do
6411           case $p in
6412             *.$objext | *.gcno)
6413                ;;
6414             $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
6415                if test "X$precious_files_regex" != "X"; then
6416                  if $ECHO "$p" | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
6417                  then
6418                    continue
6419                  fi
6420                fi
6421                removelist="$removelist $p"
6422                ;;
6423             *) ;;
6424           esac
6425         done
6426         test -n "$removelist" && \
6427           func_show_eval "${RM}r \$removelist"
6428       fi
6429
6430       # Now set the variables for building old libraries.
6431       if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
6432         oldlibs="$oldlibs $output_objdir/$libname.$libext"
6433
6434         # Transform .lo files to .o files.
6435         oldobjs="$objs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
6436       fi
6437
6438       # Eliminate all temporary directories.
6439       #for path in $notinst_path; do
6440       # lib_search_path=`$ECHO "X$lib_search_path " | $Xsed -e "s% $path % %g"`
6441       # deplibs=`$ECHO "X$deplibs " | $Xsed -e "s% -L$path % %g"`
6442       # dependency_libs=`$ECHO "X$dependency_libs " | $Xsed -e "s% -L$path % %g"`
6443       #done
6444
6445       if test -n "$xrpath"; then
6446         # If the user specified any rpath flags, then add them.
6447         temp_xrpath=
6448         for libdir in $xrpath; do
6449           temp_xrpath="$temp_xrpath -R$libdir"
6450           case "$finalize_rpath " in
6451           *" $libdir "*) ;;
6452           *) finalize_rpath="$finalize_rpath $libdir" ;;
6453           esac
6454         done
6455         if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
6456           dependency_libs="$temp_xrpath $dependency_libs"
6457         fi
6458       fi
6459
6460       # Make sure dlfiles contains only unique files that won't be dlpreopened
6461       old_dlfiles="$dlfiles"
6462       dlfiles=
6463       for lib in $old_dlfiles; do
6464         case " $dlprefiles $dlfiles " in
6465         *" $lib "*) ;;
6466         *) dlfiles="$dlfiles $lib" ;;
6467         esac
6468       done
6469
6470       # Make sure dlprefiles contains only unique files
6471       old_dlprefiles="$dlprefiles"
6472       dlprefiles=
6473       for lib in $old_dlprefiles; do
6474         case "$dlprefiles " in
6475         *" $lib "*) ;;
6476         *) dlprefiles="$dlprefiles $lib" ;;
6477         esac
6478       done
6479
6480       if test "$build_libtool_libs" = yes; then
6481         if test -n "$rpath"; then
6482           case $host in
6483           *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos* | *-cegcc*)
6484             # these systems don't actually have a c library (as such)!
6485             ;;
6486           *-*-rhapsody* | *-*-darwin1.[012])
6487             # Rhapsody C library is in the System framework
6488             deplibs="$deplibs System.ltframework"
6489             ;;
6490           *-*-netbsd*)
6491             # Don't link with libc until the a.out ld.so is fixed.
6492             ;;
6493           *-*-openbsd* | *-*-freebsd* | *-*-dragonfly*)
6494             # Do not include libc due to us having libc/libc_r.
6495             ;;
6496           *-*-sco3.2v5* | *-*-sco5v6*)
6497             # Causes problems with __ctype
6498             ;;
6499           *-*-sysv4.2uw2* | *-*-sysv5* | *-*-unixware* | *-*-OpenUNIX*)
6500             # Compiler inserts libc in the correct place for threads to work
6501             ;;
6502           *)
6503             # Add libc to deplibs on all other systems if necessary.
6504             if test "$build_libtool_need_lc" = "yes"; then
6505               deplibs="$deplibs -lc"
6506             fi
6507             ;;
6508           esac
6509         fi
6510
6511         # Transform deplibs into only deplibs that can be linked in shared.
6512         name_save=$name
6513         libname_save=$libname
6514         release_save=$release
6515         versuffix_save=$versuffix
6516         major_save=$major
6517         # I'm not sure if I'm treating the release correctly.  I think
6518         # release should show up in the -l (ie -lgmp5) so we don't want to
6519         # add it in twice.  Is that correct?
6520         release=""
6521         versuffix=""
6522         major=""
6523         newdeplibs=
6524         droppeddeps=no
6525         case $deplibs_check_method in
6526         pass_all)
6527           # Don't check for shared/static.  Everything works.
6528           # This might be a little naive.  We might want to check
6529           # whether the library exists or not.  But this is on
6530           # osf3 & osf4 and I'm not really sure... Just
6531           # implementing what was already the behavior.
6532           newdeplibs=$deplibs
6533           ;;
6534         test_compile)
6535           # This code stresses the "libraries are programs" paradigm to its
6536           # limits. Maybe even breaks it.  We compile a program, linking it
6537           # against the deplibs as a proxy for the library.  Then we can check
6538           # whether they linked in statically or dynamically with ldd.
6539           $opt_dry_run || $RM conftest.c
6540           cat > conftest.c <<EOF
6541           int main() { return 0; }
6542 EOF
6543           $opt_dry_run || $RM conftest
6544           if $LTCC $LTCFLAGS -o conftest conftest.c $deplibs; then
6545             ldd_output=`ldd conftest`
6546             for i in $deplibs; do
6547               case $i in
6548               -l*)
6549                 func_stripname -l '' "$i"
6550                 name=$func_stripname_result
6551                 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6552                   case " $predeps $postdeps " in
6553                   *" $i "*)
6554                     newdeplibs="$newdeplibs $i"
6555                     i=""
6556                     ;;
6557                   esac
6558                 fi
6559                 if test -n "$i" ; then
6560                   libname=`eval "\\$ECHO \"$libname_spec\""`
6561                   deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6562                   set dummy $deplib_matches; shift
6563                   deplib_match=$1
6564                   if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6565                     newdeplibs="$newdeplibs $i"
6566                   else
6567                     droppeddeps=yes
6568                     $ECHO
6569                     $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6570                     $ECHO "*** I have the capability to make that library automatically link in when"
6571                     $ECHO "*** you link to this library.  But I can only do this if you have a"
6572                     $ECHO "*** shared version of the library, which I believe you do not have"
6573                     $ECHO "*** because a test_compile did reveal that the linker did not use it for"
6574                     $ECHO "*** its dynamic dependency list that programs get resolved with at runtime."
6575                   fi
6576                 fi
6577                 ;;
6578               *)
6579                 newdeplibs="$newdeplibs $i"
6580                 ;;
6581               esac
6582             done
6583           else
6584             # Error occurred in the first compile.  Let's try to salvage
6585             # the situation: Compile a separate program for each library.
6586             for i in $deplibs; do
6587               case $i in
6588               -l*)
6589                 func_stripname -l '' "$i"
6590                 name=$func_stripname_result
6591                 $opt_dry_run || $RM conftest
6592                 if $LTCC $LTCFLAGS -o conftest conftest.c $i; then
6593                   ldd_output=`ldd conftest`
6594                   if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6595                     case " $predeps $postdeps " in
6596                     *" $i "*)
6597                       newdeplibs="$newdeplibs $i"
6598                       i=""
6599                       ;;
6600                     esac
6601                   fi
6602                   if test -n "$i" ; then
6603                     libname=`eval "\\$ECHO \"$libname_spec\""`
6604                     deplib_matches=`eval "\\$ECHO \"$library_names_spec\""`
6605                     set dummy $deplib_matches; shift
6606                     deplib_match=$1
6607                     if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
6608                       newdeplibs="$newdeplibs $i"
6609                     else
6610                       droppeddeps=yes
6611                       $ECHO
6612                       $ECHO "*** Warning: dynamic linker does not accept needed library $i."
6613                       $ECHO "*** I have the capability to make that library automatically link in when"
6614                       $ECHO "*** you link to this library.  But I can only do this if you have a"
6615                       $ECHO "*** shared version of the library, which you do not appear to have"
6616                       $ECHO "*** because a test_compile did reveal that the linker did not use this one"
6617                       $ECHO "*** as a dynamic dependency that programs can get resolved with at runtime."
6618                     fi
6619                   fi
6620                 else
6621                   droppeddeps=yes
6622                   $ECHO
6623                   $ECHO "*** Warning!  Library $i is needed by this library but I was not able to"
6624                   $ECHO "*** make it link in!  You will probably need to install it or some"
6625                   $ECHO "*** library that it depends on before this library will be fully"
6626                   $ECHO "*** functional.  Installing it before continuing would be even better."
6627                 fi
6628                 ;;
6629               *)
6630                 newdeplibs="$newdeplibs $i"
6631                 ;;
6632               esac
6633             done
6634           fi
6635           ;;
6636         file_magic*)
6637           set dummy $deplibs_check_method; shift
6638           file_magic_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6639           for a_deplib in $deplibs; do
6640             case $a_deplib in
6641             -l*)
6642               func_stripname -l '' "$a_deplib"
6643               name=$func_stripname_result
6644               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6645                 case " $predeps $postdeps " in
6646                 *" $a_deplib "*)
6647                   newdeplibs="$newdeplibs $a_deplib"
6648                   a_deplib=""
6649                   ;;
6650                 esac
6651               fi
6652               if test -n "$a_deplib" ; then
6653                 libname=`eval "\\$ECHO \"$libname_spec\""`
6654                 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6655                   potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6656                   for potent_lib in $potential_libs; do
6657                       # Follow soft links.
6658                       if ls -lLd "$potent_lib" 2>/dev/null |
6659                          $GREP " -> " >/dev/null; then
6660                         continue
6661                       fi
6662                       # The statement above tries to avoid entering an
6663                       # endless loop below, in case of cyclic links.
6664                       # We might still enter an endless loop, since a link
6665                       # loop can be closed while we follow links,
6666                       # but so what?
6667                       potlib="$potent_lib"
6668                       while test -h "$potlib" 2>/dev/null; do
6669                         potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
6670                         case $potliblink in
6671                         [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
6672                         *) potlib=`$ECHO "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
6673                         esac
6674                       done
6675                       if eval $file_magic_cmd \"\$potlib\" 2>/dev/null |
6676                          $SED -e 10q |
6677                          $EGREP "$file_magic_regex" > /dev/null; then
6678                         newdeplibs="$newdeplibs $a_deplib"
6679                         a_deplib=""
6680                         break 2
6681                       fi
6682                   done
6683                 done
6684               fi
6685               if test -n "$a_deplib" ; then
6686                 droppeddeps=yes
6687                 $ECHO
6688                 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6689                 $ECHO "*** I have the capability to make that library automatically link in when"
6690                 $ECHO "*** you link to this library.  But I can only do this if you have a"
6691                 $ECHO "*** shared version of the library, which you do not appear to have"
6692                 $ECHO "*** because I did check the linker path looking for a file starting"
6693                 if test -z "$potlib" ; then
6694                   $ECHO "*** with $libname but no candidates were found. (...for file magic test)"
6695                 else
6696                   $ECHO "*** with $libname and none of the candidates passed a file format test"
6697                   $ECHO "*** using a file magic. Last file checked: $potlib"
6698                 fi
6699               fi
6700               ;;
6701             *)
6702               # Add a -L argument.
6703               newdeplibs="$newdeplibs $a_deplib"
6704               ;;
6705             esac
6706           done # Gone through all deplibs.
6707           ;;
6708         match_pattern*)
6709           set dummy $deplibs_check_method; shift
6710           match_pattern_regex=`expr "$deplibs_check_method" : "$1 \(.*\)"`
6711           for a_deplib in $deplibs; do
6712             case $a_deplib in
6713             -l*)
6714               func_stripname -l '' "$a_deplib"
6715               name=$func_stripname_result
6716               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6717                 case " $predeps $postdeps " in
6718                 *" $a_deplib "*)
6719                   newdeplibs="$newdeplibs $a_deplib"
6720                   a_deplib=""
6721                   ;;
6722                 esac
6723               fi
6724               if test -n "$a_deplib" ; then
6725                 libname=`eval "\\$ECHO \"$libname_spec\""`
6726                 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
6727                   potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
6728                   for potent_lib in $potential_libs; do
6729                     potlib="$potent_lib" # see symlink-check above in file_magic test
6730                     if eval "\$ECHO \"X$potent_lib\"" 2>/dev/null | $Xsed -e 10q | \
6731                        $EGREP "$match_pattern_regex" > /dev/null; then
6732                       newdeplibs="$newdeplibs $a_deplib"
6733                       a_deplib=""
6734                       break 2
6735                     fi
6736                   done
6737                 done
6738               fi
6739               if test -n "$a_deplib" ; then
6740                 droppeddeps=yes
6741                 $ECHO
6742                 $ECHO "*** Warning: linker path does not have real file for library $a_deplib."
6743                 $ECHO "*** I have the capability to make that library automatically link in when"
6744                 $ECHO "*** you link to this library.  But I can only do this if you have a"
6745                 $ECHO "*** shared version of the library, which you do not appear to have"
6746                 $ECHO "*** because I did check the linker path looking for a file starting"
6747                 if test -z "$potlib" ; then
6748                   $ECHO "*** with $libname but no candidates were found. (...for regex pattern test)"
6749                 else
6750                   $ECHO "*** with $libname and none of the candidates passed a file format test"
6751                   $ECHO "*** using a regex pattern. Last file checked: $potlib"
6752                 fi
6753               fi
6754               ;;
6755             *)
6756               # Add a -L argument.
6757               newdeplibs="$newdeplibs $a_deplib"
6758               ;;
6759             esac
6760           done # Gone through all deplibs.
6761           ;;
6762         none | unknown | *)
6763           newdeplibs=""
6764           tmp_deplibs=`$ECHO "X $deplibs" | $Xsed \
6765               -e 's/ -lc$//' -e 's/ -[LR][^ ]*//g'`
6766           if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
6767             for i in $predeps $postdeps ; do
6768               # can't use Xsed below, because $i might contain '/'
6769               tmp_deplibs=`$ECHO "X $tmp_deplibs" | $Xsed -e "s,$i,,"`
6770             done
6771           fi
6772           if $ECHO "X $tmp_deplibs" | $Xsed -e 's/[      ]//g' |
6773              $GREP . >/dev/null; then
6774             $ECHO
6775             if test "X$deplibs_check_method" = "Xnone"; then
6776               $ECHO "*** Warning: inter-library dependencies are not supported in this platform."
6777             else
6778               $ECHO "*** Warning: inter-library dependencies are not known to be supported."
6779             fi
6780             $ECHO "*** All declared inter-library dependencies are being dropped."
6781             droppeddeps=yes
6782           fi
6783           ;;
6784         esac
6785         versuffix=$versuffix_save
6786         major=$major_save
6787         release=$release_save
6788         libname=$libname_save
6789         name=$name_save
6790
6791         case $host in
6792         *-*-rhapsody* | *-*-darwin1.[012])
6793           # On Rhapsody replace the C library with the System framework
6794           newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
6795           ;;
6796         esac
6797
6798         if test "$droppeddeps" = yes; then
6799           if test "$module" = yes; then
6800             $ECHO
6801             $ECHO "*** Warning: libtool could not satisfy all declared inter-library"
6802             $ECHO "*** dependencies of module $libname.  Therefore, libtool will create"
6803             $ECHO "*** a static module, that should work as long as the dlopening"
6804             $ECHO "*** application is linked with the -dlopen flag."
6805             if test -z "$global_symbol_pipe"; then
6806               $ECHO
6807               $ECHO "*** However, this would only work if libtool was able to extract symbol"
6808               $ECHO "*** lists from a program, using \`nm' or equivalent, but libtool could"
6809               $ECHO "*** not find such a program.  So, this module is probably useless."
6810               $ECHO "*** \`nm' from GNU binutils and a full rebuild may help."
6811             fi
6812             if test "$build_old_libs" = no; then
6813               oldlibs="$output_objdir/$libname.$libext"
6814               build_libtool_libs=module
6815               build_old_libs=yes
6816             else
6817               build_libtool_libs=no
6818             fi
6819           else
6820             $ECHO "*** The inter-library dependencies that have been dropped here will be"
6821             $ECHO "*** automatically added whenever a program is linked with this library"
6822             $ECHO "*** or is declared to -dlopen it."
6823
6824             if test "$allow_undefined" = no; then
6825               $ECHO
6826               $ECHO "*** Since this library must not contain undefined symbols,"
6827               $ECHO "*** because either the platform does not support them or"
6828               $ECHO "*** it was explicitly requested with -no-undefined,"
6829               $ECHO "*** libtool will only create a static version of it."
6830               if test "$build_old_libs" = no; then
6831                 oldlibs="$output_objdir/$libname.$libext"
6832                 build_libtool_libs=module
6833                 build_old_libs=yes
6834               else
6835                 build_libtool_libs=no
6836               fi
6837             fi
6838           fi
6839         fi
6840         # Done checking deplibs!
6841         deplibs=$newdeplibs
6842       fi
6843       # Time to change all our "foo.ltframework" stuff back to "-framework foo"
6844       case $host in
6845         *-*-darwin*)
6846           newdeplibs=`$ECHO "X $newdeplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6847           new_inherited_linker_flags=`$ECHO "X $new_inherited_linker_flags" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6848           deplibs=`$ECHO "X $deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
6849           ;;
6850       esac
6851
6852       # move library search paths that coincide with paths to not yet
6853       # installed libraries to the beginning of the library search list
6854       new_libs=
6855       for path in $notinst_path; do
6856         case " $new_libs " in
6857         *" -L$path/$objdir "*) ;;
6858         *)
6859           case " $deplibs " in
6860           *" -L$path/$objdir "*)
6861             new_libs="$new_libs -L$path/$objdir" ;;
6862           esac
6863           ;;
6864         esac
6865       done
6866       for deplib in $deplibs; do
6867         case $deplib in
6868         -L*)
6869           case " $new_libs " in
6870           *" $deplib "*) ;;
6871           *) new_libs="$new_libs $deplib" ;;
6872           esac
6873           ;;
6874         *) new_libs="$new_libs $deplib" ;;
6875         esac
6876       done
6877       deplibs="$new_libs"
6878
6879       # All the library-specific variables (install_libdir is set above).
6880       library_names=
6881       old_library=
6882       dlname=
6883
6884       # Test again, we may have decided not to build it any more
6885       if test "$build_libtool_libs" = yes; then
6886         if test "$hardcode_into_libs" = yes; then
6887           # Hardcode the library paths
6888           hardcode_libdirs=
6889           dep_rpath=
6890           rpath="$finalize_rpath"
6891           test "$mode" != relink && rpath="$compile_rpath$rpath"
6892           for libdir in $rpath; do
6893             if test -n "$hardcode_libdir_flag_spec"; then
6894               if test -n "$hardcode_libdir_separator"; then
6895                 if test -z "$hardcode_libdirs"; then
6896                   hardcode_libdirs="$libdir"
6897                 else
6898                   # Just accumulate the unique libdirs.
6899                   case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
6900                   *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
6901                     ;;
6902                   *)
6903                     hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
6904                     ;;
6905                   esac
6906                 fi
6907               else
6908                 eval flag=\"$hardcode_libdir_flag_spec\"
6909                 dep_rpath="$dep_rpath $flag"
6910               fi
6911             elif test -n "$runpath_var"; then
6912               case "$perm_rpath " in
6913               *" $libdir "*) ;;
6914               *) perm_rpath="$perm_rpath $libdir" ;;
6915               esac
6916             fi
6917           done
6918           # Substitute the hardcoded libdirs into the rpath.
6919           if test -n "$hardcode_libdir_separator" &&
6920              test -n "$hardcode_libdirs"; then
6921             libdir="$hardcode_libdirs"
6922             if test -n "$hardcode_libdir_flag_spec_ld"; then
6923               eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
6924             else
6925               eval dep_rpath=\"$hardcode_libdir_flag_spec\"
6926             fi
6927           fi
6928           if test -n "$runpath_var" && test -n "$perm_rpath"; then
6929             # We should set the runpath_var.
6930             rpath=
6931             for dir in $perm_rpath; do
6932               rpath="$rpath$dir:"
6933             done
6934             eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
6935           fi
6936           test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
6937         fi
6938
6939         shlibpath="$finalize_shlibpath"
6940         test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
6941         if test -n "$shlibpath"; then
6942           eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
6943         fi
6944
6945         # Get the real and link names of the library.
6946         eval shared_ext=\"$shrext_cmds\"
6947         eval library_names=\"$library_names_spec\"
6948         set dummy $library_names
6949         shift
6950         realname="$1"
6951         shift
6952
6953         if test -n "$soname_spec"; then
6954           eval soname=\"$soname_spec\"
6955         else
6956           soname="$realname"
6957         fi
6958         if test -z "$dlname"; then
6959           dlname=$soname
6960         fi
6961
6962         lib="$output_objdir/$realname"
6963         linknames=
6964         for link
6965         do
6966           linknames="$linknames $link"
6967         done
6968
6969         # Use standard objects if they are pic
6970         test -z "$pic_flag" && libobjs=`$ECHO "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
6971         test "X$libobjs" = "X " && libobjs=
6972
6973         delfiles=
6974         if test -n "$export_symbols" && test -n "$include_expsyms"; then
6975           $opt_dry_run || cp "$export_symbols" "$output_objdir/$libname.uexp"
6976           export_symbols="$output_objdir/$libname.uexp"
6977           delfiles="$delfiles $export_symbols"
6978         fi
6979
6980         orig_export_symbols=
6981         case $host_os in
6982         cygwin* | mingw* | cegcc*)
6983           if test -n "$export_symbols" && test -z "$export_symbols_regex"; then
6984             # exporting using user supplied symfile
6985             if test "x`$SED 1q $export_symbols`" != xEXPORTS; then
6986               # and it's NOT already a .def file. Must figure out
6987               # which of the given symbols are data symbols and tag
6988               # them as such. So, trigger use of export_symbols_cmds.
6989               # export_symbols gets reassigned inside the "prepare
6990               # the list of exported symbols" if statement, so the
6991               # include_expsyms logic still works.
6992               orig_export_symbols="$export_symbols"
6993               export_symbols=
6994               always_export_symbols=yes
6995             fi
6996           fi
6997           ;;
6998         esac
6999
7000         # Prepare the list of exported symbols
7001         if test -z "$export_symbols"; then
7002           if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
7003             func_verbose "generating symbol list for \`$libname.la'"
7004             export_symbols="$output_objdir/$libname.exp"
7005             $opt_dry_run || $RM $export_symbols
7006             cmds=$export_symbols_cmds
7007             save_ifs="$IFS"; IFS='~'
7008             for cmd in $cmds; do
7009               IFS="$save_ifs"
7010               eval cmd=\"$cmd\"
7011               func_len " $cmd"
7012               len=$func_len_result
7013               if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7014                 func_show_eval "$cmd" 'exit $?'
7015                 skipped_export=false
7016               else
7017                 # The command line is too long to execute in one step.
7018                 func_verbose "using reloadable object file for export list..."
7019                 skipped_export=:
7020                 # Break out early, otherwise skipped_export may be
7021                 # set to false by a later but shorter cmd.
7022                 break
7023               fi
7024             done
7025             IFS="$save_ifs"
7026             if test -n "$export_symbols_regex" && test "X$skipped_export" != "X:"; then
7027               func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7028               func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7029             fi
7030           fi
7031         fi
7032
7033         if test -n "$export_symbols" && test -n "$include_expsyms"; then
7034           tmp_export_symbols="$export_symbols"
7035           test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7036           $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7037         fi
7038
7039         if test "X$skipped_export" != "X:" && test -n "$orig_export_symbols"; then
7040           # The given exports_symbols file has to be filtered, so filter it.
7041           func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7042           # FIXME: $output_objdir/$libname.filter potentially contains lots of
7043           # 's' commands which not all seds can handle. GNU sed should be fine
7044           # though. Also, the filter scales superlinearly with the number of
7045           # global variables. join(1) would be nice here, but unfortunately
7046           # isn't a blessed tool.
7047           $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7048           delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7049           export_symbols=$output_objdir/$libname.def
7050           $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7051         fi
7052
7053         tmp_deplibs=
7054         for test_deplib in $deplibs; do
7055           case " $convenience " in
7056           *" $test_deplib "*) ;;
7057           *)
7058             tmp_deplibs="$tmp_deplibs $test_deplib"
7059             ;;
7060           esac
7061         done
7062         deplibs="$tmp_deplibs"
7063
7064         if test -n "$convenience"; then
7065           if test -n "$whole_archive_flag_spec" &&
7066             test "$compiler_needs_object" = yes &&
7067             test -z "$libobjs"; then
7068             # extract the archives, so we have objects to list.
7069             # TODO: could optimize this to just extract one archive.
7070             whole_archive_flag_spec=
7071           fi
7072           if test -n "$whole_archive_flag_spec"; then
7073             save_libobjs=$libobjs
7074             eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7075             test "X$libobjs" = "X " && libobjs=
7076           else
7077             gentop="$output_objdir/${outputname}x"
7078             generated="$generated $gentop"
7079
7080             func_extract_archives $gentop $convenience
7081             libobjs="$libobjs $func_extract_archives_result"
7082             test "X$libobjs" = "X " && libobjs=
7083           fi
7084         fi
7085
7086         if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
7087           eval flag=\"$thread_safe_flag_spec\"
7088           linker_flags="$linker_flags $flag"
7089         fi
7090
7091         # Make a backup of the uninstalled library when relinking
7092         if test "$mode" = relink; then
7093           $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}U && $MV $realname ${realname}U)' || exit $?
7094         fi
7095
7096         # Do each of the archive commands.
7097         if test "$module" = yes && test -n "$module_cmds" ; then
7098           if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7099             eval test_cmds=\"$module_expsym_cmds\"
7100             cmds=$module_expsym_cmds
7101           else
7102             eval test_cmds=\"$module_cmds\"
7103             cmds=$module_cmds
7104           fi
7105         else
7106           if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7107             eval test_cmds=\"$archive_expsym_cmds\"
7108             cmds=$archive_expsym_cmds
7109           else
7110             eval test_cmds=\"$archive_cmds\"
7111             cmds=$archive_cmds
7112           fi
7113         fi
7114
7115         if test "X$skipped_export" != "X:" &&
7116            func_len " $test_cmds" &&
7117            len=$func_len_result &&
7118            test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7119           :
7120         else
7121           # The command line is too long to link in one step, link piecewise
7122           # or, if using GNU ld and skipped_export is not :, use a linker
7123           # script.
7124
7125           # Save the value of $output and $libobjs because we want to
7126           # use them later.  If we have whole_archive_flag_spec, we
7127           # want to use save_libobjs as it was before
7128           # whole_archive_flag_spec was expanded, because we can't
7129           # assume the linker understands whole_archive_flag_spec.
7130           # This may have to be revisited, in case too many
7131           # convenience libraries get linked in and end up exceeding
7132           # the spec.
7133           if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
7134             save_libobjs=$libobjs
7135           fi
7136           save_output=$output
7137           output_la=`$ECHO "X$output" | $Xsed -e "$basename"`
7138
7139           # Clear the reloadable object creation command queue and
7140           # initialize k to one.
7141           test_cmds=
7142           concat_cmds=
7143           objlist=
7144           last_robj=
7145           k=1
7146
7147           if test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "$with_gnu_ld" = yes; then
7148             output=${output_objdir}/${output_la}.lnkscript
7149             func_verbose "creating GNU ld script: $output"
7150             $ECHO 'INPUT (' > $output
7151             for obj in $save_libobjs
7152             do
7153               $ECHO "$obj" >> $output
7154             done
7155             $ECHO ')' >> $output
7156             delfiles="$delfiles $output"
7157           elif test -n "$save_libobjs" && test "X$skipped_export" != "X:" && test "X$file_list_spec" != X; then
7158             output=${output_objdir}/${output_la}.lnk
7159             func_verbose "creating linker input file list: $output"
7160             : > $output
7161             set x $save_libobjs
7162             shift
7163             firstobj=
7164             if test "$compiler_needs_object" = yes; then
7165               firstobj="$1 "
7166               shift
7167             fi
7168             for obj
7169             do
7170               $ECHO "$obj" >> $output
7171             done
7172             delfiles="$delfiles $output"
7173             output=$firstobj\"$file_list_spec$output\"
7174           else
7175             if test -n "$save_libobjs"; then
7176               func_verbose "creating reloadable object files..."
7177               output=$output_objdir/$output_la-${k}.$objext
7178               eval test_cmds=\"$reload_cmds\"
7179               func_len " $test_cmds"
7180               len0=$func_len_result
7181               len=$len0
7182
7183               # Loop over the list of objects to be linked.
7184               for obj in $save_libobjs
7185               do
7186                 func_len " $obj"
7187                 func_arith $len + $func_len_result
7188                 len=$func_arith_result
7189                 if test "X$objlist" = X ||
7190                    test "$len" -lt "$max_cmd_len"; then
7191                   func_append objlist " $obj"
7192                 else
7193                   # The command $test_cmds is almost too long, add a
7194                   # command to the queue.
7195                   if test "$k" -eq 1 ; then
7196                     # The first file doesn't have a previous command to add.
7197                     eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
7198                   else
7199                     # All subsequent reloadable object files will link in
7200                     # the last one created.
7201                     eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj~\$RM $last_robj\"
7202                   fi
7203                   last_robj=$output_objdir/$output_la-${k}.$objext
7204                   func_arith $k + 1
7205                   k=$func_arith_result
7206                   output=$output_objdir/$output_la-${k}.$objext
7207                   objlist=$obj
7208                   func_len " $last_robj"
7209                   func_arith $len0 + $func_len_result
7210                   len=$func_arith_result
7211                 fi
7212               done
7213               # Handle the remaining objects by creating one last
7214               # reloadable object file.  All subsequent reloadable object
7215               # files will link in the last one created.
7216               test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7217               eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
7218               if test -n "$last_robj"; then
7219                 eval concat_cmds=\"\${concat_cmds}~\$RM $last_robj\"
7220               fi
7221               delfiles="$delfiles $output"
7222
7223             else
7224               output=
7225             fi
7226
7227             if ${skipped_export-false}; then
7228               func_verbose "generating symbol list for \`$libname.la'"
7229               export_symbols="$output_objdir/$libname.exp"
7230               $opt_dry_run || $RM $export_symbols
7231               libobjs=$output
7232               # Append the command to create the export file.
7233               test -z "$concat_cmds" || concat_cmds=$concat_cmds~
7234               eval concat_cmds=\"\$concat_cmds$export_symbols_cmds\"
7235               if test -n "$last_robj"; then
7236                 eval concat_cmds=\"\$concat_cmds~\$RM $last_robj\"
7237               fi
7238             fi
7239
7240             test -n "$save_libobjs" &&
7241               func_verbose "creating a temporary reloadable object file: $output"
7242
7243             # Loop through the commands generated above and execute them.
7244             save_ifs="$IFS"; IFS='~'
7245             for cmd in $concat_cmds; do
7246               IFS="$save_ifs"
7247               $opt_silent || {
7248                   func_quote_for_expand "$cmd"
7249                   eval "func_echo $func_quote_for_expand_result"
7250               }
7251               $opt_dry_run || eval "$cmd" || {
7252                 lt_exit=$?
7253
7254                 # Restore the uninstalled library and exit
7255                 if test "$mode" = relink; then
7256                   ( cd "$output_objdir" && \
7257                     $RM "${realname}T" && \
7258                     $MV "${realname}U" "$realname" )
7259                 fi
7260
7261                 exit $lt_exit
7262               }
7263             done
7264             IFS="$save_ifs"
7265
7266             if test -n "$export_symbols_regex" && ${skipped_export-false}; then
7267               func_show_eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
7268               func_show_eval '$MV "${export_symbols}T" "$export_symbols"'
7269             fi
7270           fi
7271
7272           if ${skipped_export-false}; then
7273             if test -n "$export_symbols" && test -n "$include_expsyms"; then
7274               tmp_export_symbols="$export_symbols"
7275               test -n "$orig_export_symbols" && tmp_export_symbols="$orig_export_symbols"
7276               $opt_dry_run || eval '$ECHO "X$include_expsyms" | $Xsed | $SP2NL >> "$tmp_export_symbols"'
7277             fi
7278
7279             if test -n "$orig_export_symbols"; then
7280               # The given exports_symbols file has to be filtered, so filter it.
7281               func_verbose "filter symbol list for \`$libname.la' to tag DATA exports"
7282               # FIXME: $output_objdir/$libname.filter potentially contains lots of
7283               # 's' commands which not all seds can handle. GNU sed should be fine
7284               # though. Also, the filter scales superlinearly with the number of
7285               # global variables. join(1) would be nice here, but unfortunately
7286               # isn't a blessed tool.
7287               $opt_dry_run || $SED -e '/[ ,]DATA/!d;s,\(.*\)\([ \,].*\),s|^\1$|\1\2|,' < $export_symbols > $output_objdir/$libname.filter
7288               delfiles="$delfiles $export_symbols $output_objdir/$libname.filter"
7289               export_symbols=$output_objdir/$libname.def
7290               $opt_dry_run || $SED -f $output_objdir/$libname.filter < $orig_export_symbols > $export_symbols
7291             fi
7292           fi
7293
7294           libobjs=$output
7295           # Restore the value of output.
7296           output=$save_output
7297
7298           if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
7299             eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
7300             test "X$libobjs" = "X " && libobjs=
7301           fi
7302           # Expand the library linking commands again to reset the
7303           # value of $libobjs for piecewise linking.
7304
7305           # Do each of the archive commands.
7306           if test "$module" = yes && test -n "$module_cmds" ; then
7307             if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
7308               cmds=$module_expsym_cmds
7309             else
7310               cmds=$module_cmds
7311             fi
7312           else
7313             if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
7314               cmds=$archive_expsym_cmds
7315             else
7316               cmds=$archive_cmds
7317             fi
7318           fi
7319         fi
7320
7321         if test -n "$delfiles"; then
7322           # Append the command to remove temporary files to $cmds.
7323           eval cmds=\"\$cmds~\$RM $delfiles\"
7324         fi
7325
7326         # Add any objects from preloaded convenience libraries
7327         if test -n "$dlprefiles"; then
7328           gentop="$output_objdir/${outputname}x"
7329           generated="$generated $gentop"
7330
7331           func_extract_archives $gentop $dlprefiles
7332           libobjs="$libobjs $func_extract_archives_result"
7333           test "X$libobjs" = "X " && libobjs=
7334         fi
7335
7336         save_ifs="$IFS"; IFS='~'
7337         for cmd in $cmds; do
7338           IFS="$save_ifs"
7339           eval cmd=\"$cmd\"
7340           $opt_silent || {
7341             func_quote_for_expand "$cmd"
7342             eval "func_echo $func_quote_for_expand_result"
7343           }
7344           $opt_dry_run || eval "$cmd" || {
7345             lt_exit=$?
7346
7347             # Restore the uninstalled library and exit
7348             if test "$mode" = relink; then
7349               ( cd "$output_objdir" && \
7350                 $RM "${realname}T" && \
7351                 $MV "${realname}U" "$realname" )
7352             fi
7353
7354             exit $lt_exit
7355           }
7356         done
7357         IFS="$save_ifs"
7358
7359         # Restore the uninstalled library and exit
7360         if test "$mode" = relink; then
7361           $opt_dry_run || eval '(cd $output_objdir && $RM ${realname}T && $MV $realname ${realname}T && $MV ${realname}U $realname)' || exit $?
7362
7363           if test -n "$convenience"; then
7364             if test -z "$whole_archive_flag_spec"; then
7365               func_show_eval '${RM}r "$gentop"'
7366             fi
7367           fi
7368
7369           exit $EXIT_SUCCESS
7370         fi
7371
7372         # Create links to the real library.
7373         for linkname in $linknames; do
7374           if test "$realname" != "$linkname"; then
7375             func_show_eval '(cd "$output_objdir" && $RM "$linkname" && $LN_S "$realname" "$linkname")' 'exit $?'
7376           fi
7377         done
7378
7379         # If -module or -export-dynamic was specified, set the dlname.
7380         if test "$module" = yes || test "$export_dynamic" = yes; then
7381           # On all known operating systems, these are identical.
7382           dlname="$soname"
7383         fi
7384       fi
7385       ;;
7386
7387     obj)
7388       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
7389         func_warning "\`-dlopen' is ignored for objects"
7390       fi
7391
7392       case " $deplibs" in
7393       *\ -l* | *\ -L*)
7394         func_warning "\`-l' and \`-L' are ignored for objects" ;;
7395       esac
7396
7397       test -n "$rpath" && \
7398         func_warning "\`-rpath' is ignored for objects"
7399
7400       test -n "$xrpath" && \
7401         func_warning "\`-R' is ignored for objects"
7402
7403       test -n "$vinfo" && \
7404         func_warning "\`-version-info' is ignored for objects"
7405
7406       test -n "$release" && \
7407         func_warning "\`-release' is ignored for objects"
7408
7409       case $output in
7410       *.lo)
7411         test -n "$objs$old_deplibs" && \
7412           func_fatal_error "cannot build library object \`$output' from non-libtool objects"
7413
7414         libobj=$output
7415         func_lo2o "$libobj"
7416         obj=$func_lo2o_result
7417         ;;
7418       *)
7419         libobj=
7420         obj="$output"
7421         ;;
7422       esac
7423
7424       # Delete the old objects.
7425       $opt_dry_run || $RM $obj $libobj
7426
7427       # Objects from convenience libraries.  This assumes
7428       # single-version convenience libraries.  Whenever we create
7429       # different ones for PIC/non-PIC, this we'll have to duplicate
7430       # the extraction.
7431       reload_conv_objs=
7432       gentop=
7433       # reload_cmds runs $LD directly, so let us get rid of
7434       # -Wl from whole_archive_flag_spec and hope we can get by with
7435       # turning comma into space..
7436       wl=
7437
7438       if test -n "$convenience"; then
7439         if test -n "$whole_archive_flag_spec"; then
7440           eval tmp_whole_archive_flags=\"$whole_archive_flag_spec\"
7441           reload_conv_objs=$reload_objs\ `$ECHO "X$tmp_whole_archive_flags" | $Xsed -e 's|,| |g'`
7442         else
7443           gentop="$output_objdir/${obj}x"
7444           generated="$generated $gentop"
7445
7446           func_extract_archives $gentop $convenience
7447           reload_conv_objs="$reload_objs $func_extract_archives_result"
7448         fi
7449       fi
7450
7451       # Create the old-style object.
7452       reload_objs="$objs$old_deplibs "`$ECHO "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
7453
7454       output="$obj"
7455       func_execute_cmds "$reload_cmds" 'exit $?'
7456
7457       # Exit if we aren't doing a library object file.
7458       if test -z "$libobj"; then
7459         if test -n "$gentop"; then
7460           func_show_eval '${RM}r "$gentop"'
7461         fi
7462
7463         exit $EXIT_SUCCESS
7464       fi
7465
7466       if test "$build_libtool_libs" != yes; then
7467         if test -n "$gentop"; then
7468           func_show_eval '${RM}r "$gentop"'
7469         fi
7470
7471         # Create an invalid libtool object if no PIC, so that we don't
7472         # accidentally link it into a program.
7473         # $show "echo timestamp > $libobj"
7474         # $opt_dry_run || eval "echo timestamp > $libobj" || exit $?
7475         exit $EXIT_SUCCESS
7476       fi
7477
7478       if test -n "$pic_flag" || test "$pic_mode" != default; then
7479         # Only do commands if we really have different PIC objects.
7480         reload_objs="$libobjs $reload_conv_objs"
7481         output="$libobj"
7482         func_execute_cmds "$reload_cmds" 'exit $?'
7483       fi
7484
7485       if test -n "$gentop"; then
7486         func_show_eval '${RM}r "$gentop"'
7487       fi
7488
7489       exit $EXIT_SUCCESS
7490       ;;
7491
7492     prog)
7493       case $host in
7494         *cygwin*) func_stripname '' '.exe' "$output"
7495                   output=$func_stripname_result.exe;;
7496       esac
7497       test -n "$vinfo" && \
7498         func_warning "\`-version-info' is ignored for programs"
7499
7500       test -n "$release" && \
7501         func_warning "\`-release' is ignored for programs"
7502
7503       test "$preload" = yes \
7504         && test "$dlopen_support" = unknown \
7505         && test "$dlopen_self" = unknown \
7506         && test "$dlopen_self_static" = unknown && \
7507           func_warning "\`LT_INIT([dlopen])' not used. Assuming no dlopen support."
7508
7509       case $host in
7510       *-*-rhapsody* | *-*-darwin1.[012])
7511         # On Rhapsody replace the C library is the System framework
7512         compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7513         finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's/ -lc / System.ltframework /'`
7514         ;;
7515       esac
7516
7517       case $host in
7518       *-*-darwin*)
7519         # Don't allow lazy linking, it breaks C++ global constructors
7520         # But is supposedly fixed on 10.4 or later (yay!).
7521         if test "$tagname" = CXX ; then
7522           case ${MACOSX_DEPLOYMENT_TARGET-10.0} in
7523             10.[0123])
7524               compile_command="$compile_command ${wl}-bind_at_load"
7525               finalize_command="$finalize_command ${wl}-bind_at_load"
7526             ;;
7527           esac
7528         fi
7529         # Time to change all our "foo.ltframework" stuff back to "-framework foo"
7530         compile_deplibs=`$ECHO "X $compile_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7531         finalize_deplibs=`$ECHO "X $finalize_deplibs" | $Xsed -e 's% \([^ $]*\).ltframework% -framework \1%g'`
7532         ;;
7533       esac
7534
7535
7536       # move library search paths that coincide with paths to not yet
7537       # installed libraries to the beginning of the library search list
7538       new_libs=
7539       for path in $notinst_path; do
7540         case " $new_libs " in
7541         *" -L$path/$objdir "*) ;;
7542         *)
7543           case " $compile_deplibs " in
7544           *" -L$path/$objdir "*)
7545             new_libs="$new_libs -L$path/$objdir" ;;
7546           esac
7547           ;;
7548         esac
7549       done
7550       for deplib in $compile_deplibs; do
7551         case $deplib in
7552         -L*)
7553           case " $new_libs " in
7554           *" $deplib "*) ;;
7555           *) new_libs="$new_libs $deplib" ;;
7556           esac
7557           ;;
7558         *) new_libs="$new_libs $deplib" ;;
7559         esac
7560       done
7561       compile_deplibs="$new_libs"
7562
7563
7564       compile_command="$compile_command $compile_deplibs"
7565       finalize_command="$finalize_command $finalize_deplibs"
7566
7567       if test -n "$rpath$xrpath"; then
7568         # If the user specified any rpath flags, then add them.
7569         for libdir in $rpath $xrpath; do
7570           # This is the magic to use -rpath.
7571           case "$finalize_rpath " in
7572           *" $libdir "*) ;;
7573           *) finalize_rpath="$finalize_rpath $libdir" ;;
7574           esac
7575         done
7576       fi
7577
7578       # Now hardcode the library paths
7579       rpath=
7580       hardcode_libdirs=
7581       for libdir in $compile_rpath $finalize_rpath; do
7582         if test -n "$hardcode_libdir_flag_spec"; then
7583           if test -n "$hardcode_libdir_separator"; then
7584             if test -z "$hardcode_libdirs"; then
7585               hardcode_libdirs="$libdir"
7586             else
7587               # Just accumulate the unique libdirs.
7588               case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7589               *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7590                 ;;
7591               *)
7592                 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7593                 ;;
7594               esac
7595             fi
7596           else
7597             eval flag=\"$hardcode_libdir_flag_spec\"
7598             rpath="$rpath $flag"
7599           fi
7600         elif test -n "$runpath_var"; then
7601           case "$perm_rpath " in
7602           *" $libdir "*) ;;
7603           *) perm_rpath="$perm_rpath $libdir" ;;
7604           esac
7605         fi
7606         case $host in
7607         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-cegcc*)
7608           testbindir=`${ECHO} "$libdir" | ${SED} -e 's*/lib$*/bin*'`
7609           case :$dllsearchpath: in
7610           *":$libdir:"*) ;;
7611           ::) dllsearchpath=$libdir;;
7612           *) dllsearchpath="$dllsearchpath:$libdir";;
7613           esac
7614           case :$dllsearchpath: in
7615           *":$testbindir:"*) ;;
7616           ::) dllsearchpath=$testbindir;;
7617           *) dllsearchpath="$dllsearchpath:$testbindir";;
7618           esac
7619           ;;
7620         esac
7621       done
7622       # Substitute the hardcoded libdirs into the rpath.
7623       if test -n "$hardcode_libdir_separator" &&
7624          test -n "$hardcode_libdirs"; then
7625         libdir="$hardcode_libdirs"
7626         eval rpath=\" $hardcode_libdir_flag_spec\"
7627       fi
7628       compile_rpath="$rpath"
7629
7630       rpath=
7631       hardcode_libdirs=
7632       for libdir in $finalize_rpath; do
7633         if test -n "$hardcode_libdir_flag_spec"; then
7634           if test -n "$hardcode_libdir_separator"; then
7635             if test -z "$hardcode_libdirs"; then
7636               hardcode_libdirs="$libdir"
7637             else
7638               # Just accumulate the unique libdirs.
7639               case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
7640               *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
7641                 ;;
7642               *)
7643                 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
7644                 ;;
7645               esac
7646             fi
7647           else
7648             eval flag=\"$hardcode_libdir_flag_spec\"
7649             rpath="$rpath $flag"
7650           fi
7651         elif test -n "$runpath_var"; then
7652           case "$finalize_perm_rpath " in
7653           *" $libdir "*) ;;
7654           *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
7655           esac
7656         fi
7657       done
7658       # Substitute the hardcoded libdirs into the rpath.
7659       if test -n "$hardcode_libdir_separator" &&
7660          test -n "$hardcode_libdirs"; then
7661         libdir="$hardcode_libdirs"
7662         eval rpath=\" $hardcode_libdir_flag_spec\"
7663       fi
7664       finalize_rpath="$rpath"
7665
7666       if test -n "$libobjs" && test "$build_old_libs" = yes; then
7667         # Transform all the library objects into standard objects.
7668         compile_command=`$ECHO "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7669         finalize_command=`$ECHO "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
7670       fi
7671
7672       func_generate_dlsyms "$outputname" "@PROGRAM@" "no"
7673
7674       # template prelinking step
7675       if test -n "$prelink_cmds"; then
7676         func_execute_cmds "$prelink_cmds" 'exit $?'
7677       fi
7678
7679       wrappers_required=yes
7680       case $host in
7681       *cygwin* | *mingw* )
7682         if test "$build_libtool_libs" != yes; then
7683           wrappers_required=no
7684         fi
7685         ;;
7686       *cegcc)
7687         # Disable wrappers for cegcc, we are cross compiling anyway.
7688         wrappers_required=no
7689         ;;
7690       *)
7691         if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
7692           wrappers_required=no
7693         fi
7694         ;;
7695       esac
7696       if test "$wrappers_required" = no; then
7697         # Replace the output file specification.
7698         compile_command=`$ECHO "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7699         link_command="$compile_command$compile_rpath"
7700
7701         # We have no uninstalled library dependencies, so finalize right now.
7702         exit_status=0
7703         func_show_eval "$link_command" 'exit_status=$?'
7704
7705         # Delete the generated files.
7706         if test -f "$output_objdir/${outputname}S.${objext}"; then
7707           func_show_eval '$RM "$output_objdir/${outputname}S.${objext}"'
7708         fi
7709
7710         exit $exit_status
7711       fi
7712
7713       if test -n "$compile_shlibpath$finalize_shlibpath"; then
7714         compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
7715       fi
7716       if test -n "$finalize_shlibpath"; then
7717         finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
7718       fi
7719
7720       compile_var=
7721       finalize_var=
7722       if test -n "$runpath_var"; then
7723         if test -n "$perm_rpath"; then
7724           # We should set the runpath_var.
7725           rpath=
7726           for dir in $perm_rpath; do
7727             rpath="$rpath$dir:"
7728           done
7729           compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
7730         fi
7731         if test -n "$finalize_perm_rpath"; then
7732           # We should set the runpath_var.
7733           rpath=
7734           for dir in $finalize_perm_rpath; do
7735             rpath="$rpath$dir:"
7736           done
7737           finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
7738         fi
7739       fi
7740
7741       if test "$no_install" = yes; then
7742         # We don't need to create a wrapper script.
7743         link_command="$compile_var$compile_command$compile_rpath"
7744         # Replace the output file specification.
7745         link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
7746         # Delete the old output file.
7747         $opt_dry_run || $RM $output
7748         # Link the executable and exit
7749         func_show_eval "$link_command" 'exit $?'
7750         exit $EXIT_SUCCESS
7751       fi
7752
7753       if test "$hardcode_action" = relink; then
7754         # Fast installation is not supported
7755         link_command="$compile_var$compile_command$compile_rpath"
7756         relink_command="$finalize_var$finalize_command$finalize_rpath"
7757
7758         func_warning "this platform does not like uninstalled shared libraries"
7759         func_warning "\`$output' will be relinked during installation"
7760       else
7761         if test "$fast_install" != no; then
7762           link_command="$finalize_var$compile_command$finalize_rpath"
7763           if test "$fast_install" = yes; then
7764             relink_command=`$ECHO "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
7765           else
7766             # fast_install is set to needless
7767             relink_command=
7768           fi
7769         else
7770           link_command="$compile_var$compile_command$compile_rpath"
7771           relink_command="$finalize_var$finalize_command$finalize_rpath"
7772         fi
7773       fi
7774
7775       # Replace the output file specification.
7776       link_command=`$ECHO "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
7777
7778       # Delete the old output files.
7779       $opt_dry_run || $RM $output $output_objdir/$outputname $output_objdir/lt-$outputname
7780
7781       func_show_eval "$link_command" 'exit $?'
7782
7783       # Now create the wrapper script.
7784       func_verbose "creating $output"
7785
7786       # Quote the relink command for shipping.
7787       if test -n "$relink_command"; then
7788         # Preserve any variables that may affect compiler behavior
7789         for var in $variables_saved_for_relink; do
7790           if eval test -z \"\${$var+set}\"; then
7791             relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
7792           elif eval var_value=\$$var; test -z "$var_value"; then
7793             relink_command="$var=; export $var; $relink_command"
7794           else
7795             func_quote_for_eval "$var_value"
7796             relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
7797           fi
7798         done
7799         relink_command="(cd `pwd`; $relink_command)"
7800         relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
7801       fi
7802
7803       # Quote $ECHO for shipping.
7804       if test "X$ECHO" = "X$SHELL $progpath --fallback-echo"; then
7805         case $progpath in
7806         [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
7807         *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
7808         esac
7809         qecho=`$ECHO "X$qecho" | $Xsed -e "$sed_quote_subst"`
7810       else
7811         qecho=`$ECHO "X$ECHO" | $Xsed -e "$sed_quote_subst"`
7812       fi
7813
7814       # Only actually do things if not in dry run mode.
7815       $opt_dry_run || {
7816         # win32 will think the script is a binary if it has
7817         # a .exe suffix, so we strip it off here.
7818         case $output in
7819           *.exe) func_stripname '' '.exe' "$output"
7820                  output=$func_stripname_result ;;
7821         esac
7822         # test for cygwin because mv fails w/o .exe extensions
7823         case $host in
7824           *cygwin*)
7825             exeext=.exe
7826             func_stripname '' '.exe' "$outputname"
7827             outputname=$func_stripname_result ;;
7828           *) exeext= ;;
7829         esac
7830         case $host in
7831           *cygwin* | *mingw* )
7832             func_dirname_and_basename "$output" "" "."
7833             output_name=$func_basename_result
7834             output_path=$func_dirname_result
7835             cwrappersource="$output_path/$objdir/lt-$output_name.c"
7836             cwrapper="$output_path/$output_name.exe"
7837             $RM $cwrappersource $cwrapper
7838             trap "$RM $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
7839
7840             func_emit_cwrapperexe_src > $cwrappersource
7841
7842             # The wrapper executable is built using the $host compiler,
7843             # because it contains $host paths and files. If cross-
7844             # compiling, it, like the target executable, must be
7845             # executed on the $host or under an emulation environment.
7846             $opt_dry_run || {
7847               $LTCC $LTCFLAGS -o $cwrapper $cwrappersource
7848               $STRIP $cwrapper
7849             }
7850
7851             # Now, create the wrapper script for func_source use:
7852             func_ltwrapper_scriptname $cwrapper
7853             $RM $func_ltwrapper_scriptname_result
7854             trap "$RM $func_ltwrapper_scriptname_result; exit $EXIT_FAILURE" 1 2 15
7855             $opt_dry_run || {
7856               # note: this script will not be executed, so do not chmod.
7857               if test "x$build" = "x$host" ; then
7858                 $cwrapper --lt-dump-script > $func_ltwrapper_scriptname_result
7859               else
7860                 func_emit_wrapper no > $func_ltwrapper_scriptname_result
7861               fi
7862             }
7863           ;;
7864           * )
7865             $RM $output
7866             trap "$RM $output; exit $EXIT_FAILURE" 1 2 15
7867
7868             func_emit_wrapper no > $output
7869             chmod +x $output
7870           ;;
7871         esac
7872       }
7873       exit $EXIT_SUCCESS
7874       ;;
7875     esac
7876
7877     # See if we need to build an old-fashioned archive.
7878     for oldlib in $oldlibs; do
7879
7880       if test "$build_libtool_libs" = convenience; then
7881         oldobjs="$libobjs_save $symfileobj"
7882         addlibs="$convenience"
7883         build_libtool_libs=no
7884       else
7885         if test "$build_libtool_libs" = module; then
7886           oldobjs="$libobjs_save"
7887           build_libtool_libs=no
7888         else
7889           oldobjs="$old_deplibs $non_pic_objects"
7890           if test "$preload" = yes && test -f "$symfileobj"; then
7891             oldobjs="$oldobjs $symfileobj"
7892           fi
7893         fi
7894         addlibs="$old_convenience"
7895       fi
7896
7897       if test -n "$addlibs"; then
7898         gentop="$output_objdir/${outputname}x"
7899         generated="$generated $gentop"
7900
7901         func_extract_archives $gentop $addlibs
7902         oldobjs="$oldobjs $func_extract_archives_result"
7903       fi
7904
7905       # Do each command in the archive commands.
7906       if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
7907         cmds=$old_archive_from_new_cmds
7908       else
7909
7910         # Add any objects from preloaded convenience libraries
7911         if test -n "$dlprefiles"; then
7912           gentop="$output_objdir/${outputname}x"
7913           generated="$generated $gentop"
7914
7915           func_extract_archives $gentop $dlprefiles
7916           oldobjs="$oldobjs $func_extract_archives_result"
7917         fi
7918
7919         # POSIX demands no paths to be encoded in archives.  We have
7920         # to avoid creating archives with duplicate basenames if we
7921         # might have to extract them afterwards, e.g., when creating a
7922         # static archive out of a convenience library, or when linking
7923         # the entirety of a libtool archive into another (currently
7924         # not supported by libtool).
7925         if (for obj in $oldobjs
7926             do
7927               func_basename "$obj"
7928               $ECHO "$func_basename_result"
7929             done | sort | sort -uc >/dev/null 2>&1); then
7930           :
7931         else
7932           $ECHO "copying selected object files to avoid basename conflicts..."
7933           gentop="$output_objdir/${outputname}x"
7934           generated="$generated $gentop"
7935           func_mkdir_p "$gentop"
7936           save_oldobjs=$oldobjs
7937           oldobjs=
7938           counter=1
7939           for obj in $save_oldobjs
7940           do
7941             func_basename "$obj"
7942             objbase="$func_basename_result"
7943             case " $oldobjs " in
7944             " ") oldobjs=$obj ;;
7945             *[\ /]"$objbase "*)
7946               while :; do
7947                 # Make sure we don't pick an alternate name that also
7948                 # overlaps.
7949                 newobj=lt$counter-$objbase
7950                 func_arith $counter + 1
7951                 counter=$func_arith_result
7952                 case " $oldobjs " in
7953                 *[\ /]"$newobj "*) ;;
7954                 *) if test ! -f "$gentop/$newobj"; then break; fi ;;
7955                 esac
7956               done
7957               func_show_eval "ln $obj $gentop/$newobj || cp $obj $gentop/$newobj"
7958               oldobjs="$oldobjs $gentop/$newobj"
7959               ;;
7960             *) oldobjs="$oldobjs $obj" ;;
7961             esac
7962           done
7963         fi
7964         eval cmds=\"$old_archive_cmds\"
7965
7966         func_len " $cmds"
7967         len=$func_len_result
7968         if test "$len" -lt "$max_cmd_len" || test "$max_cmd_len" -le -1; then
7969           cmds=$old_archive_cmds
7970         else
7971           # the command line is too long to link in one step, link in parts
7972           func_verbose "using piecewise archive linking..."
7973           save_RANLIB=$RANLIB
7974           RANLIB=:
7975           objlist=
7976           concat_cmds=
7977           save_oldobjs=$oldobjs
7978           oldobjs=
7979           # Is there a better way of finding the last object in the list?
7980           for obj in $save_oldobjs
7981           do
7982             last_oldobj=$obj
7983           done
7984           eval test_cmds=\"$old_archive_cmds\"
7985           func_len " $test_cmds"
7986           len0=$func_len_result
7987           len=$len0
7988           for obj in $save_oldobjs
7989           do
7990             func_len " $obj"
7991             func_arith $len + $func_len_result
7992             len=$func_arith_result
7993             func_append objlist " $obj"
7994             if test "$len" -lt "$max_cmd_len"; then
7995               :
7996             else
7997               # the above command should be used before it gets too long
7998               oldobjs=$objlist
7999               if test "$obj" = "$last_oldobj" ; then
8000                 RANLIB=$save_RANLIB
8001               fi
8002               test -z "$concat_cmds" || concat_cmds=$concat_cmds~
8003               eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
8004               objlist=
8005               len=$len0
8006             fi
8007           done
8008           RANLIB=$save_RANLIB
8009           oldobjs=$objlist
8010           if test "X$oldobjs" = "X" ; then
8011             eval cmds=\"\$concat_cmds\"
8012           else
8013             eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
8014           fi
8015         fi
8016       fi
8017       func_execute_cmds "$cmds" 'exit $?'
8018     done
8019
8020     test -n "$generated" && \
8021       func_show_eval "${RM}r$generated"
8022
8023     # Now create the libtool archive.
8024     case $output in
8025     *.la)
8026       old_library=
8027       test "$build_old_libs" = yes && old_library="$libname.$libext"
8028       func_verbose "creating $output"
8029
8030       # Preserve any variables that may affect compiler behavior
8031       for var in $variables_saved_for_relink; do
8032         if eval test -z \"\${$var+set}\"; then
8033           relink_command="{ test -z \"\${$var+set}\" || $lt_unset $var || { $var=; export $var; }; }; $relink_command"
8034         elif eval var_value=\$$var; test -z "$var_value"; then
8035           relink_command="$var=; export $var; $relink_command"
8036         else
8037           func_quote_for_eval "$var_value"
8038           relink_command="$var=$func_quote_for_eval_result; export $var; $relink_command"
8039         fi
8040       done
8041       # Quote the link command for shipping.
8042       relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
8043       relink_command=`$ECHO "X$relink_command" | $Xsed -e "$sed_quote_subst"`
8044       if test "$hardcode_automatic" = yes ; then
8045         relink_command=
8046       fi
8047
8048       # Only create the output if not a dry run.
8049       $opt_dry_run || {
8050         for installed in no yes; do
8051           if test "$installed" = yes; then
8052             if test -z "$install_libdir"; then
8053               break
8054             fi
8055             output="$output_objdir/$outputname"i
8056             # Replace all uninstalled libtool libraries with the installed ones
8057             newdependency_libs=
8058             for deplib in $dependency_libs; do
8059               case $deplib in
8060               *.la)
8061                 func_basename "$deplib"
8062                 name="$func_basename_result"
8063                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
8064                 test -z "$libdir" && \
8065                   func_fatal_error "\`$deplib' is not a valid libtool archive"
8066                 newdependency_libs="$newdependency_libs $libdir/$name"
8067                 ;;
8068               *) newdependency_libs="$newdependency_libs $deplib" ;;
8069               esac
8070             done
8071             dependency_libs="$newdependency_libs"
8072             newdlfiles=
8073
8074             for lib in $dlfiles; do
8075               case $lib in
8076               *.la)
8077                 func_basename "$lib"
8078                 name="$func_basename_result"
8079                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8080                 test -z "$libdir" && \
8081                   func_fatal_error "\`$lib' is not a valid libtool archive"
8082                 newdlfiles="$newdlfiles $libdir/$name"
8083                 ;;
8084               *) newdlfiles="$newdlfiles $lib" ;;
8085               esac
8086             done
8087             dlfiles="$newdlfiles"
8088             newdlprefiles=
8089             for lib in $dlprefiles; do
8090               case $lib in
8091               *.la)
8092                 # Only pass preopened files to the pseudo-archive (for
8093                 # eventual linking with the app. that links it) if we
8094                 # didn't already link the preopened objects directly into
8095                 # the library:
8096                 func_basename "$lib"
8097                 name="$func_basename_result"
8098                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
8099                 test -z "$libdir" && \
8100                   func_fatal_error "\`$lib' is not a valid libtool archive"
8101                 newdlprefiles="$newdlprefiles $libdir/$name"
8102                 ;;
8103               esac
8104             done
8105             dlprefiles="$newdlprefiles"
8106           else
8107             newdlfiles=
8108             for lib in $dlfiles; do
8109               case $lib in
8110                 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8111                 *) abs=`pwd`"/$lib" ;;
8112               esac
8113               newdlfiles="$newdlfiles $abs"
8114             done
8115             dlfiles="$newdlfiles"
8116             newdlprefiles=
8117             for lib in $dlprefiles; do
8118               case $lib in
8119                 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
8120                 *) abs=`pwd`"/$lib" ;;
8121               esac
8122               newdlprefiles="$newdlprefiles $abs"
8123             done
8124             dlprefiles="$newdlprefiles"
8125           fi
8126           $RM $output
8127           # place dlname in correct position for cygwin
8128           tdlname=$dlname
8129           case $host,$output,$installed,$module,$dlname in
8130             *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll | *cegcc*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
8131           esac
8132           $ECHO > $output "\
8133 # $outputname - a libtool library file
8134 # Generated by $PROGRAM (GNU $PACKAGE$TIMESTAMP) $VERSION
8135 #
8136 # Please DO NOT delete this file!
8137 # It is necessary for linking the library.
8138
8139 # The name that we can dlopen(3).
8140 dlname='$tdlname'
8141
8142 # Names of this library.
8143 library_names='$library_names'
8144
8145 # The name of the static archive.
8146 old_library='$old_library'
8147
8148 # Linker flags that can not go in dependency_libs.
8149 inherited_linker_flags='$new_inherited_linker_flags'
8150
8151 # Libraries that this one depends upon.
8152 dependency_libs='$dependency_libs'
8153
8154 # Names of additional weak libraries provided by this library
8155 weak_library_names='$weak_libs'
8156
8157 # Version information for $libname.
8158 current=$current
8159 age=$age
8160 revision=$revision
8161
8162 # Is this an already installed library?
8163 installed=$installed
8164
8165 # Should we warn about portability when linking against -modules?
8166 shouldnotlink=$module
8167
8168 # Files to dlopen/dlpreopen
8169 dlopen='$dlfiles'
8170 dlpreopen='$dlprefiles'
8171
8172 # Directory that this library needs to be installed in:
8173 libdir='$install_libdir'"
8174           if test "$installed" = no && test "$need_relink" = yes; then
8175             $ECHO >> $output "\
8176 relink_command=\"$relink_command\""
8177           fi
8178         done
8179       }
8180
8181       # Do a symbolic link so that the libtool archive can be found in
8182       # LD_LIBRARY_PATH before the program is installed.
8183       func_show_eval '( cd "$output_objdir" && $RM "$outputname" && $LN_S "../$outputname" "$outputname" )' 'exit $?'
8184       ;;
8185     esac
8186     exit $EXIT_SUCCESS
8187 }
8188
8189 { test "$mode" = link || test "$mode" = relink; } &&
8190     func_mode_link ${1+"$@"}
8191
8192
8193 # func_mode_uninstall arg...
8194 func_mode_uninstall ()
8195 {
8196     $opt_debug
8197     RM="$nonopt"
8198     files=
8199     rmforce=
8200     exit_status=0
8201
8202     # This variable tells wrapper scripts just to set variables rather
8203     # than running their programs.
8204     libtool_install_magic="$magic"
8205
8206     for arg
8207     do
8208       case $arg in
8209       -f) RM="$RM $arg"; rmforce=yes ;;
8210       -*) RM="$RM $arg" ;;
8211       *) files="$files $arg" ;;
8212       esac
8213     done
8214
8215     test -z "$RM" && \
8216       func_fatal_help "you must specify an RM program"
8217
8218     rmdirs=
8219
8220     origobjdir="$objdir"
8221     for file in $files; do
8222       func_dirname "$file" "" "."
8223       dir="$func_dirname_result"
8224       if test "X$dir" = X.; then
8225         objdir="$origobjdir"
8226       else
8227         objdir="$dir/$origobjdir"
8228       fi
8229       func_basename "$file"
8230       name="$func_basename_result"
8231       test "$mode" = uninstall && objdir="$dir"
8232
8233       # Remember objdir for removal later, being careful to avoid duplicates
8234       if test "$mode" = clean; then
8235         case " $rmdirs " in
8236           *" $objdir "*) ;;
8237           *) rmdirs="$rmdirs $objdir" ;;
8238         esac
8239       fi
8240
8241       # Don't error if the file doesn't exist and rm -f was used.
8242       if { test -L "$file"; } >/dev/null 2>&1 ||
8243          { test -h "$file"; } >/dev/null 2>&1 ||
8244          test -f "$file"; then
8245         :
8246       elif test -d "$file"; then
8247         exit_status=1
8248         continue
8249       elif test "$rmforce" = yes; then
8250         continue
8251       fi
8252
8253       rmfiles="$file"
8254
8255       case $name in
8256       *.la)
8257         # Possibly a libtool archive, so verify it.
8258         if func_lalib_p "$file"; then
8259           func_source $dir/$name
8260
8261           # Delete the libtool libraries and symlinks.
8262           for n in $library_names; do
8263             rmfiles="$rmfiles $objdir/$n"
8264           done
8265           test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
8266
8267           case "$mode" in
8268           clean)
8269             case "  $library_names " in
8270             # "  " in the beginning catches empty $dlname
8271             *" $dlname "*) ;;
8272             *) rmfiles="$rmfiles $objdir/$dlname" ;;
8273             esac
8274             test -n "$libdir" && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
8275             ;;
8276           uninstall)
8277             if test -n "$library_names"; then
8278               # Do each command in the postuninstall commands.
8279               func_execute_cmds "$postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8280             fi
8281
8282             if test -n "$old_library"; then
8283               # Do each command in the old_postuninstall commands.
8284               func_execute_cmds "$old_postuninstall_cmds" 'test "$rmforce" = yes || exit_status=1'
8285             fi
8286             # FIXME: should reinstall the best remaining shared library.
8287             ;;
8288           esac
8289         fi
8290         ;;
8291
8292       *.lo)
8293         # Possibly a libtool object, so verify it.
8294         if func_lalib_p "$file"; then
8295
8296           # Read the .lo file
8297           func_source $dir/$name
8298
8299           # Add PIC object to the list of files to remove.
8300           if test -n "$pic_object" &&
8301              test "$pic_object" != none; then
8302             rmfiles="$rmfiles $dir/$pic_object"
8303           fi
8304
8305           # Add non-PIC object to the list of files to remove.
8306           if test -n "$non_pic_object" &&
8307              test "$non_pic_object" != none; then
8308             rmfiles="$rmfiles $dir/$non_pic_object"
8309           fi
8310         fi
8311         ;;
8312
8313       *)
8314         if test "$mode" = clean ; then
8315           noexename=$name
8316           case $file in
8317           *.exe)
8318             func_stripname '' '.exe' "$file"
8319             file=$func_stripname_result
8320             func_stripname '' '.exe' "$name"
8321             noexename=$func_stripname_result
8322             # $file with .exe has already been added to rmfiles,
8323             # add $file without .exe
8324             rmfiles="$rmfiles $file"
8325             ;;
8326           esac
8327           # Do a test to see if this is a libtool program.
8328           if func_ltwrapper_p "$file"; then
8329             if func_ltwrapper_executable_p "$file"; then
8330               func_ltwrapper_scriptname "$file"
8331               relink_command=
8332               func_source $func_ltwrapper_scriptname_result
8333               rmfiles="$rmfiles $func_ltwrapper_scriptname_result"
8334             else
8335               relink_command=
8336               func_source $dir/$noexename
8337             fi
8338
8339             # note $name still contains .exe if it was in $file originally
8340             # as does the version of $file that was added into $rmfiles
8341             rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
8342             if test "$fast_install" = yes && test -n "$relink_command"; then
8343               rmfiles="$rmfiles $objdir/lt-$name"
8344             fi
8345             if test "X$noexename" != "X$name" ; then
8346               rmfiles="$rmfiles $objdir/lt-${noexename}.c"
8347             fi
8348           fi
8349         fi
8350         ;;
8351       esac
8352       func_show_eval "$RM $rmfiles" 'exit_status=1'
8353     done
8354     objdir="$origobjdir"
8355
8356     # Try to remove the ${objdir}s in the directories where we deleted files
8357     for dir in $rmdirs; do
8358       if test -d "$dir"; then
8359         func_show_eval "rmdir $dir >/dev/null 2>&1"
8360       fi
8361     done
8362
8363     exit $exit_status
8364 }
8365
8366 { test "$mode" = uninstall || test "$mode" = clean; } &&
8367     func_mode_uninstall ${1+"$@"}
8368
8369 test -z "$mode" && {
8370   help="$generic_help"
8371   func_fatal_help "you must specify a MODE"
8372 }
8373
8374 test -z "$exec_cmd" && \
8375   func_fatal_help "invalid operation mode \`$mode'"
8376
8377 if test -n "$exec_cmd"; then
8378   eval exec "$exec_cmd"
8379   exit $EXIT_FAILURE
8380 fi
8381
8382 exit $exit_status
8383
8384
8385 # The TAGs below are defined such that we never get into a situation
8386 # in which we disable both kinds of libraries.  Given conflicting
8387 # choices, we go for a static library, that is the most portable,
8388 # since we can't tell whether shared libraries were disabled because
8389 # the user asked for that or because the platform doesn't support
8390 # them.  This is particularly important on AIX, because we don't
8391 # support having both static and shared libraries enabled at the same
8392 # time on that platform, so we default to a shared-only configuration.
8393 # If a disable-shared tag is given, we'll fallback to a static-only
8394 # configuration.  But we'll never go from static-only to shared-only.
8395
8396 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
8397 build_libtool_libs=no
8398 build_old_libs=yes
8399 # ### END LIBTOOL TAG CONFIG: disable-shared
8400
8401 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
8402 build_old_libs=`case $build_libtool_libs in yes) echo no;; *) echo yes;; esac`
8403 # ### END LIBTOOL TAG CONFIG: disable-static
8404
8405 # Local Variables:
8406 # mode:shell-script
8407 # sh-indentation:2
8408 # End:
8409 # vi:sw=2
8410