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