]> CyberLeo.Net >> Repos - FreeBSD/releng/7.2.git/blob - contrib/bind9/ltmain.sh
Create releng/7.2 from stable/7 in preparation for 7.2-RELEASE.
[FreeBSD/releng/7.2.git] / contrib / bind9 / ltmain.sh
1 # ltmain.sh - Provide generalized library-building support services.
2 # NOTE: Changing this file will not affect anything until you rerun configure.
3 #
4 # Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2003, 2004
5 # Free Software Foundation, Inc.
6 # Originally by Gordon Matzigkeit <gord@gnu.ai.mit.edu>, 1996
7 #
8 # This program is free software; you can redistribute it and/or modify
9 # it under the terms of the GNU General Public License as published by
10 # the Free Software Foundation; either version 2 of the License, or
11 # (at your option) any later version.
12 #
13 # This program is distributed in the hope that it will be useful, but
14 # WITHOUT ANY WARRANTY; without even the implied warranty of
15 # MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
16 # General Public License for more details.
17 #
18 # You should have received a copy of the GNU General Public License
19 # along with this program; if not, write to the Free Software
20 # Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
21 #
22 # As a special exception to the GNU General Public License, if you
23 # distribute this file as part of a program that contains a
24 # configuration script generated by Autoconf, you may include it under
25 # the same distribution terms that you use for the rest of that program.
26
27 basename="s,^.*/,,g"
28
29 # Work around backward compatibility issue on IRIX 6.5. On IRIX 6.4+, sh
30 # is ksh but when the shell is invoked as "sh" and the current value of
31 # the _XPG environment variable is not equal to 1 (one), the special
32 # positional parameter $0, within a function call, is the name of the
33 # function.
34 progpath="$0"
35
36 # The name of this program:
37 progname=`echo "$progpath" | $SED $basename`
38 modename="$progname"
39
40 # Global variables:
41 EXIT_SUCCESS=0
42 EXIT_FAILURE=1
43
44 PROGRAM=ltmain.sh
45 PACKAGE=libtool
46 VERSION=1.5.10
47 TIMESTAMP=" (1.1220.2.131 2004/09/19 12:46:56)"
48
49 # See if we are running on zsh, and set the options which allow our
50 # commands through without removal of \ escapes.
51 if test -n "${ZSH_VERSION+set}" ; then
52   setopt NO_GLOB_SUBST
53 fi
54
55 # Check that we have a working $echo.
56 if test "X$1" = X--no-reexec; then
57   # Discard the --no-reexec flag, and continue.
58   shift
59 elif test "X$1" = X--fallback-echo; then
60   # Avoid inline document here, it may be left over
61   :
62 elif test "X`($echo '\t') 2>/dev/null`" = 'X\t'; then
63   # Yippee, $echo works!
64   :
65 else
66   # Restart under the correct shell, and then maybe $echo will work.
67   exec $SHELL "$progpath" --no-reexec ${1+"$@"}
68 fi
69
70 if test "X$1" = X--fallback-echo; then
71   # used as fallback echo
72   shift
73   cat <<EOF
74 $*
75 EOF
76   exit $EXIT_SUCCESS
77 fi
78
79 default_mode=
80 help="Try \`$progname --help' for more information."
81 magic="%%%MAGIC variable%%%"
82 mkdir="mkdir"
83 mv="mv -f"
84 rm="rm -f"
85
86 # Sed substitution that helps us do robust quoting.  It backslashifies
87 # metacharacters that are still active within double-quoted strings.
88 Xsed="${SED}"' -e 1s/^X//'
89 sed_quote_subst='s/\([\\`\\"$\\\\]\)/\\\1/g'
90 # test EBCDIC or ASCII
91 case `echo A|tr A '\301'` in
92  A) # EBCDIC based system
93   SP2NL="tr '\100' '\n'"
94   NL2SP="tr '\r\n' '\100\100'"
95   ;;
96  *) # Assume ASCII based system
97   SP2NL="tr '\040' '\012'"
98   NL2SP="tr '\015\012' '\040\040'"
99   ;;
100 esac
101
102 # NLS nuisances.
103 # Only set LANG and LC_ALL to C if already set.
104 # These must not be set unconditionally because not all systems understand
105 # e.g. LANG=C (notably SCO).
106 # We save the old values to restore during execute mode.
107 if test "${LC_ALL+set}" = set; then
108   save_LC_ALL="$LC_ALL"; LC_ALL=C; export LC_ALL
109 fi
110 if test "${LANG+set}" = set; then
111   save_LANG="$LANG"; LANG=C; export LANG
112 fi
113
114 # Make sure IFS has a sensible default
115 : ${IFS="       
116 "}
117
118 if test "$build_libtool_libs" != yes && test "$build_old_libs" != yes; then
119   $echo "$modename: not configured to build any kind of library" 1>&2
120   $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
121   exit $EXIT_FAILURE
122 fi
123
124 # Global variables.
125 mode=$default_mode
126 nonopt=
127 prev=
128 prevopt=
129 run=
130 show="$echo"
131 show_help=
132 execute_dlfiles=
133 lo2o="s/\\.lo\$/.${objext}/"
134 o2lo="s/\\.${objext}\$/.lo/"
135
136 #####################################
137 # Shell function definitions:
138 # This seems to be the best place for them
139
140 # func_win32_libid arg
141 # return the library type of file 'arg'
142 #
143 # Need a lot of goo to handle *both* DLLs and import libs
144 # Has to be a shell function in order to 'eat' the argument
145 # that is supplied when $file_magic_command is called.
146 func_win32_libid () {
147   win32_libid_type="unknown"
148   win32_fileres=`file -L $1 2>/dev/null`
149   case $win32_fileres in
150   *ar\ archive\ import\ library*) # definitely import
151     win32_libid_type="x86 archive import"
152     ;;
153   *ar\ archive*) # could be an import, or static
154     if eval $OBJDUMP -f $1 | $SED -e '10q' 2>/dev/null | \
155       $EGREP -e 'file format pe-i386(.*architecture: i386)?' >/dev/null ; then
156       win32_nmres=`eval $NM -f posix -A $1 | \
157         sed -n -e '1,100{/ I /{x;/import/!{s/^/import/;h;p;};x;};}'`
158       if test "X$win32_nmres" = "Ximport" ; then
159         win32_libid_type="x86 archive import"
160       else
161         win32_libid_type="x86 archive static"
162       fi
163     fi
164     ;;
165   *DLL*)
166     win32_libid_type="x86 DLL"
167     ;;
168   *executable*) # but shell scripts are "executable" too...
169     case $win32_fileres in
170     *MS\ Windows\ PE\ Intel*)
171       win32_libid_type="x86 DLL"
172       ;;
173     esac
174     ;;
175   esac
176   $echo $win32_libid_type
177 }
178
179
180 # func_infer_tag arg
181 # Infer tagged configuration to use if any are available and
182 # if one wasn't chosen via the "--tag" command line option.
183 # Only attempt this if the compiler in the base compile
184 # command doesn't match the default compiler.
185 # arg is usually of the form 'gcc ...'
186 func_infer_tag () {
187     if test -n "$available_tags" && test -z "$tagname"; then
188       CC_quoted=
189       for arg in $CC; do
190         case $arg in
191           *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \ ]*|*]*|"")
192           arg="\"$arg\""
193           ;;
194         esac
195         CC_quoted="$CC_quoted $arg"
196       done
197       case $@ in
198       # Blanks in the command may have been stripped by the calling shell,
199       # but not from the CC environment variable when configure was run.
200       " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*) ;;
201       # Blanks at the start of $base_compile will cause this to fail
202       # if we don't check for them as well.
203       *)
204         for z in $available_tags; do
205           if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $z$" < "$progpath" > /dev/null; then
206             # Evaluate the configuration.
207             eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$z'$/,/^# ### END LIBTOOL TAG CONFIG: '$z'$/p' < $progpath`"
208             CC_quoted=
209             for arg in $CC; do
210             # Double-quote args containing other shell metacharacters.
211             case $arg in
212               *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
213               arg="\"$arg\""
214               ;;
215             esac
216             CC_quoted="$CC_quoted $arg"
217           done
218             case "$@ " in
219               " $CC "* | "$CC "* | " `$echo $CC` "* | "`$echo $CC` "* | " $CC_quoted"* | "$CC_quoted "* | " `$echo $CC_quoted` "* | "`$echo $CC_quoted` "*)
220               # The compiler in the base compile command matches
221               # the one in the tagged configuration.
222               # Assume this is the tagged configuration we want.
223               tagname=$z
224               break
225               ;;
226             esac
227           fi
228         done
229         # If $tagname still isn't set, then no tagged configuration
230         # was found and let the user know that the "--tag" command
231         # line option must be used.
232         if test -z "$tagname"; then
233           $echo "$modename: unable to infer tagged configuration"
234           $echo "$modename: specify a tag with \`--tag'" 1>&2
235           exit $EXIT_FAILURE
236 #        else
237 #          $echo "$modename: using $tagname tagged configuration"
238         fi
239         ;;
240       esac
241     fi
242 }
243
244
245 # func_extract_archives gentop oldlib ...
246 func_extract_archives () {
247     my_gentop="$1"; shift
248     my_oldlibs=${1+"$@"}
249     my_oldobjs=""
250     my_xlib=""
251     my_xabs=""
252     my_xdir=""
253     my_status=""
254
255     $show "${rm}r $my_gentop"
256     $run ${rm}r "$my_gentop"
257     $show "$mkdir $my_gentop"
258     $run $mkdir "$my_gentop"
259     my_status=$?
260     if test "$my_status" -ne 0 && test ! -d "$my_gentop"; then
261       exit $my_status
262     fi
263
264     for my_xlib in $my_oldlibs; do
265       # Extract the objects.
266       case $my_xlib in
267         [\\/]* | [A-Za-z]:[\\/]*) my_xabs="$my_xlib" ;;
268         *) my_xabs=`pwd`"/$my_xlib" ;;
269       esac
270       my_xlib=`$echo "X$my_xlib" | $Xsed -e 's%^.*/%%'`
271       my_xdir="$my_gentop/$my_xlib"
272
273       $show "${rm}r $my_xdir"
274       $run ${rm}r "$my_xdir"
275       $show "$mkdir $my_xdir"
276       $run $mkdir "$my_xdir"
277       status=$?
278       if test "$status" -ne 0 && test ! -d "$my_xdir"; then
279         exit $status
280       fi
281       case $host in
282       *-darwin*)
283         $show "Extracting $my_xabs"
284         # Do not bother doing anything if just a dry run
285         if test -z "$run"; then
286           darwin_orig_dir=`pwd`
287           cd $my_xdir || exit $?
288           darwin_archive=$my_xabs
289           darwin_curdir=`pwd`
290           darwin_base_archive=`basename $darwin_archive`
291           darwin_arches=`lipo -info "$darwin_archive" 2>/dev/null | $EGREP Architectures 2>/dev/null`
292           if test -n "$darwin_arches"; then 
293             darwin_arches=`echo "$darwin_arches" | $SED -e 's/.*are://'`
294             darwin_arch=
295             $show "$darwin_base_archive has multiple architectures $darwin_arches"
296             for darwin_arch in  $darwin_arches ; do
297               mkdir -p "unfat-$$/${darwin_base_archive}-${darwin_arch}"
298               lipo -thin $darwin_arch -output "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" "${darwin_archive}"
299               # Remove the table of contents from the thin files.
300               $AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF 2>/dev/null || true
301               $AR -d "unfat-$$/${darwin_base_archive}-${darwin_arch}/${darwin_base_archive}" __.SYMDEF\ SORTED 2>/dev/null || true
302               cd "unfat-$$/${darwin_base_archive}-${darwin_arch}"
303               $AR -xo "${darwin_base_archive}"
304               rm "${darwin_base_archive}"
305               cd "$darwin_curdir"
306             done # $darwin_arches
307       ## Okay now we have a bunch of thin objects, gotta fatten them up :)
308             darwin_filelist=`find unfat-$$ -type f | xargs basename | sort -u | $NL2SP`
309             darwin_file=
310             darwin_files=
311             for darwin_file in $darwin_filelist; do
312               darwin_files=`find unfat-$$ -name $darwin_file -print | $NL2SP`
313               lipo -create -output "$darwin_file" $darwin_files
314             done # $darwin_filelist
315             rm -rf unfat-$$
316             cd "$darwin_orig_dir"
317           else
318             cd $darwin_orig_dir
319             (cd $my_xdir && $AR x $my_xabs) || exit $?
320           fi # $darwin_arches
321         fi # $run
322       ;;
323       *)
324         # We will extract separately just the conflicting names and we will
325         # no longer touch any unique names. It is faster to leave these
326         # extract automatically by $AR in one run.
327         $show "(cd $my_xdir && $AR x $my_xabs)"
328         $run eval "(cd \$my_xdir && $AR x \$my_xabs)" || exit $?
329         if ($AR t "$my_xabs" | sort | sort -uc >/dev/null 2>&1); then
330           :
331         else
332           $echo "$modename: warning: object name conflicts; renaming object files" 1>&2
333           $echo "$modename: warning: to ensure that they will not overwrite" 1>&2
334           $AR t "$my_xabs" | sort | uniq -cd | while read -r count name
335           do
336             i=1
337             while test "$i" -le "$count"
338             do
339               # Put our $i before any first dot (extension)
340               # Never overwrite any file
341               name_to="$name"
342               while test "X$name_to" = "X$name" || test -f "$my_xdir/$name_to"
343               do
344                 name_to=`$echo "X$name_to" | $Xsed -e "s/\([^.]*\)/\1-$i/"`
345               done
346               $show "(cd $my_xdir && $AR xN $i $my_xabs '$name' && $mv '$name' '$name_to')"
347               $run eval "(cd \$my_xdir && $AR xN $i \$my_xabs '$name' && $mv '$name' '$name_to')" || exit $?
348               i=`expr $i + 1`
349             done
350           done
351         fi
352         ;;
353       esac
354       my_oldobjs="$my_oldobjs "`find $my_xdir -name \*.$objext -print -o -name \*.lo -print | $NL2SP`
355     done
356
357     func_extract_archives_result="$my_oldobjs"
358 }
359 # End of Shell function definitions
360 #####################################
361
362 # Darwin sucks
363 eval std_shrext=\"$shrext_cmds\"
364
365 # Parse our command line options once, thoroughly.
366 while test "$#" -gt 0
367 do
368   arg="$1"
369   shift
370
371   case $arg in
372   -*=*) optarg=`$echo "X$arg" | $Xsed -e 's/[-_a-zA-Z0-9]*=//'` ;;
373   *) optarg= ;;
374   esac
375
376   # If the previous option needs an argument, assign it.
377   if test -n "$prev"; then
378     case $prev in
379     execute_dlfiles)
380       execute_dlfiles="$execute_dlfiles $arg"
381       ;;
382     tag)
383       tagname="$arg"
384       preserve_args="${preserve_args}=$arg"
385
386       # Check whether tagname contains only valid characters
387       case $tagname in
388       *[!-_A-Za-z0-9,/]*)
389         $echo "$progname: invalid tag name: $tagname" 1>&2
390         exit $EXIT_FAILURE
391         ;;
392       esac
393
394       case $tagname in
395       CC)
396         # Don't test for the "default" C tag, as we know, it's there, but
397         # not specially marked.
398         ;;
399       *)
400         if grep "^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$" < "$progpath" > /dev/null; then
401           taglist="$taglist $tagname"
402           # Evaluate the configuration.
403           eval "`${SED} -n -e '/^# ### BEGIN LIBTOOL TAG CONFIG: '$tagname'$/,/^# ### END LIBTOOL TAG CONFIG: '$tagname'$/p' < $progpath`"
404         else
405           $echo "$progname: ignoring unknown tag $tagname" 1>&2
406         fi
407         ;;
408       esac
409       ;;
410     *)
411       eval "$prev=\$arg"
412       ;;
413     esac
414
415     prev=
416     prevopt=
417     continue
418   fi
419
420   # Have we seen a non-optional argument yet?
421   case $arg in
422   --help)
423     show_help=yes
424     ;;
425
426   --version)
427     $echo "$PROGRAM (GNU $PACKAGE) $VERSION$TIMESTAMP"
428     $echo
429     $echo "Copyright (C) 2003  Free Software Foundation, Inc."
430     $echo "This is free software; see the source for copying conditions.  There is NO"
431     $echo "warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE."
432     exit $EXIT_SUCCESS
433     ;;
434
435   --config)
436     ${SED} -e '1,/^# ### BEGIN LIBTOOL CONFIG/d' -e '/^# ### END LIBTOOL CONFIG/,$d' $progpath
437     # Now print the configurations for the tags.
438     for tagname in $taglist; do
439       ${SED} -n -e "/^# ### BEGIN LIBTOOL TAG CONFIG: $tagname$/,/^# ### END LIBTOOL TAG CONFIG: $tagname$/p" < "$progpath"
440     done
441     exit $EXIT_SUCCESS
442     ;;
443
444   --debug)
445     $echo "$progname: enabling shell trace mode"
446     set -x
447     preserve_args="$preserve_args $arg"
448     ;;
449
450   --dry-run | -n)
451     run=:
452     ;;
453
454   --features)
455     $echo "host: $host"
456     if test "$build_libtool_libs" = yes; then
457       $echo "enable shared libraries"
458     else
459       $echo "disable shared libraries"
460     fi
461     if test "$build_old_libs" = yes; then
462       $echo "enable static libraries"
463     else
464       $echo "disable static libraries"
465     fi
466     exit $EXIT_SUCCESS
467     ;;
468
469   --finish) mode="finish" ;;
470
471   --mode) prevopt="--mode" prev=mode ;;
472   --mode=*) mode="$optarg" ;;
473
474   --preserve-dup-deps) duplicate_deps="yes" ;;
475
476   --quiet | --silent)
477     show=:
478     preserve_args="$preserve_args $arg"
479     ;;
480
481   --tag) prevopt="--tag" prev=tag ;;
482   --tag=*)
483     set tag "$optarg" ${1+"$@"}
484     shift
485     prev=tag
486     preserve_args="$preserve_args --tag"
487     ;;
488
489   -dlopen)
490     prevopt="-dlopen"
491     prev=execute_dlfiles
492     ;;
493
494   -*)
495     $echo "$modename: unrecognized option \`$arg'" 1>&2
496     $echo "$help" 1>&2
497     exit $EXIT_FAILURE
498     ;;
499
500   *)
501     nonopt="$arg"
502     break
503     ;;
504   esac
505 done
506
507 if test -n "$prevopt"; then
508   $echo "$modename: option \`$prevopt' requires an argument" 1>&2
509   $echo "$help" 1>&2
510   exit $EXIT_FAILURE
511 fi
512
513 # If this variable is set in any of the actions, the command in it
514 # will be execed at the end.  This prevents here-documents from being
515 # left over by shells.
516 exec_cmd=
517
518 if test -z "$show_help"; then
519
520   # Infer the operation mode.
521   if test -z "$mode"; then
522     $echo "*** Warning: inferring the mode of operation is deprecated." 1>&2
523     $echo "*** Future versions of Libtool will require -mode=MODE be specified." 1>&2
524     case $nonopt in
525     *cc | cc* | *++ | gcc* | *-gcc* | g++* | xlc*)
526       mode=link
527       for arg
528       do
529         case $arg in
530         -c)
531            mode=compile
532            break
533            ;;
534         esac
535       done
536       ;;
537     *db | *dbx | *strace | *truss)
538       mode=execute
539       ;;
540     *install*|cp|mv)
541       mode=install
542       ;;
543     *rm)
544       mode=uninstall
545       ;;
546     *)
547       # If we have no mode, but dlfiles were specified, then do execute mode.
548       test -n "$execute_dlfiles" && mode=execute
549
550       # Just use the default operation mode.
551       if test -z "$mode"; then
552         if test -n "$nonopt"; then
553           $echo "$modename: warning: cannot infer operation mode from \`$nonopt'" 1>&2
554         else
555           $echo "$modename: warning: cannot infer operation mode without MODE-ARGS" 1>&2
556         fi
557       fi
558       ;;
559     esac
560   fi
561
562   # Only execute mode is allowed to have -dlopen flags.
563   if test -n "$execute_dlfiles" && test "$mode" != execute; then
564     $echo "$modename: unrecognized option \`-dlopen'" 1>&2
565     $echo "$help" 1>&2
566     exit $EXIT_FAILURE
567   fi
568
569   # Change the help message to a mode-specific one.
570   generic_help="$help"
571   help="Try \`$modename --help --mode=$mode' for more information."
572
573   # These modes are in order of execution frequency so that they run quickly.
574   case $mode in
575   # libtool compile mode
576   compile)
577     modename="$modename: compile"
578     # Get the compilation command and the source file.
579     base_compile=
580     srcfile="$nonopt"  #  always keep a non-empty value in "srcfile"
581     suppress_opt=yes
582     suppress_output=
583     arg_mode=normal
584     libobj=
585     later=
586
587     for arg
588     do
589       case "$arg_mode" in
590       arg  )
591         # do not "continue".  Instead, add this to base_compile
592         lastarg="$arg"
593         arg_mode=normal
594         ;;
595
596       target )
597         libobj="$arg"
598         arg_mode=normal
599         continue
600         ;;
601
602       normal )
603         # Accept any command-line options.
604         case $arg in
605         -o)
606           if test -n "$libobj" ; then
607             $echo "$modename: you cannot specify \`-o' more than once" 1>&2
608             exit $EXIT_FAILURE
609           fi
610           arg_mode=target
611           continue
612           ;;
613
614         -static | -prefer-pic | -prefer-non-pic)
615           later="$later $arg"
616           continue
617           ;;
618
619         -no-suppress)
620           suppress_opt=no
621           continue
622           ;;
623
624         -Xcompiler)
625           arg_mode=arg  #  the next one goes into the "base_compile" arg list
626           continue      #  The current "srcfile" will either be retained or
627           ;;            #  replaced later.  I would guess that would be a bug.
628
629         -Wc,*)
630           args=`$echo "X$arg" | $Xsed -e "s/^-Wc,//"`
631           lastarg=
632           save_ifs="$IFS"; IFS=','
633           for arg in $args; do
634             IFS="$save_ifs"
635
636             # Double-quote args containing other shell metacharacters.
637             # Many Bourne shells cannot handle close brackets correctly
638             # in scan sets, so we specify it separately.
639             case $arg in
640               *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
641               arg="\"$arg\""
642               ;;
643             esac
644             lastarg="$lastarg $arg"
645           done
646           IFS="$save_ifs"
647           lastarg=`$echo "X$lastarg" | $Xsed -e "s/^ //"`
648
649           # Add the arguments to base_compile.
650           base_compile="$base_compile $lastarg"
651           continue
652           ;;
653
654         * )
655           # Accept the current argument as the source file.
656           # The previous "srcfile" becomes the current argument.
657           #
658           lastarg="$srcfile"
659           srcfile="$arg"
660           ;;
661         esac  #  case $arg
662         ;;
663       esac    #  case $arg_mode
664
665       # Aesthetically quote the previous argument.
666       lastarg=`$echo "X$lastarg" | $Xsed -e "$sed_quote_subst"`
667
668       case $lastarg in
669       # Double-quote args containing other shell metacharacters.
670       # Many Bourne shells cannot handle close brackets correctly
671       # in scan sets, so we specify it separately.
672       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
673         lastarg="\"$lastarg\""
674         ;;
675       esac
676
677       base_compile="$base_compile $lastarg"
678     done # for arg
679
680     case $arg_mode in
681     arg)
682       $echo "$modename: you must specify an argument for -Xcompile"
683       exit $EXIT_FAILURE
684       ;;
685     target)
686       $echo "$modename: you must specify a target with \`-o'" 1>&2
687       exit $EXIT_FAILURE
688       ;;
689     *)
690       # Get the name of the library object.
691       [ -z "$libobj" ] && libobj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%'`
692       ;;
693     esac
694
695     # Recognize several different file suffixes.
696     # If the user specifies -o file.o, it is replaced with file.lo
697     xform='[cCFSifmso]'
698     case $libobj in
699     *.ada) xform=ada ;;
700     *.adb) xform=adb ;;
701     *.ads) xform=ads ;;
702     *.asm) xform=asm ;;
703     *.c++) xform=c++ ;;
704     *.cc) xform=cc ;;
705     *.ii) xform=ii ;;
706     *.class) xform=class ;;
707     *.cpp) xform=cpp ;;
708     *.cxx) xform=cxx ;;
709     *.f90) xform=f90 ;;
710     *.for) xform=for ;;
711     *.java) xform=java ;;
712     esac
713
714     libobj=`$echo "X$libobj" | $Xsed -e "s/\.$xform$/.lo/"`
715
716     case $libobj in
717     *.lo) obj=`$echo "X$libobj" | $Xsed -e "$lo2o"` ;;
718     *)
719       $echo "$modename: cannot determine name of library object from \`$libobj'" 1>&2
720       exit $EXIT_FAILURE
721       ;;
722     esac
723
724     func_infer_tag $base_compile
725
726     for arg in $later; do
727       case $arg in
728       -static)
729         build_old_libs=yes
730         continue
731         ;;
732
733       -prefer-pic)
734         pic_mode=yes
735         continue
736         ;;
737
738       -prefer-non-pic)
739         pic_mode=no
740         continue
741         ;;
742       esac
743     done
744
745     objname=`$echo "X$obj" | $Xsed -e 's%^.*/%%'`
746     xdir=`$echo "X$obj" | $Xsed -e 's%/[^/]*$%%'`
747     if test "X$xdir" = "X$obj"; then
748       xdir=
749     else
750       xdir=$xdir/
751     fi
752     lobj=${xdir}$objdir/$objname
753
754     if test -z "$base_compile"; then
755       $echo "$modename: you must specify a compilation command" 1>&2
756       $echo "$help" 1>&2
757       exit $EXIT_FAILURE
758     fi
759
760     # Delete any leftover library objects.
761     if test "$build_old_libs" = yes; then
762       removelist="$obj $lobj $libobj ${libobj}T"
763     else
764       removelist="$lobj $libobj ${libobj}T"
765     fi
766
767     $run $rm $removelist
768     trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
769
770     # On Cygwin there's no "real" PIC flag so we must build both object types
771     case $host_os in
772     cygwin* | mingw* | pw32* | os2*)
773       pic_mode=default
774       ;;
775     esac
776     if test "$pic_mode" = no && test "$deplibs_check_method" != pass_all; then
777       # non-PIC code in shared libraries is not supported
778       pic_mode=default
779     fi
780
781     # Calculate the filename of the output object if compiler does
782     # not support -o with -c
783     if test "$compiler_c_o" = no; then
784       output_obj=`$echo "X$srcfile" | $Xsed -e 's%^.*/%%' -e 's%\.[^.]*$%%'`.${objext}
785       lockfile="$output_obj.lock"
786       removelist="$removelist $output_obj $lockfile"
787       trap "$run $rm $removelist; exit $EXIT_FAILURE" 1 2 15
788     else
789       output_obj=
790       need_locks=no
791       lockfile=
792     fi
793
794     # Lock this critical section if it is needed
795     # We use this script file to make the link, it avoids creating a new file
796     if test "$need_locks" = yes; then
797       until $run ln "$progpath" "$lockfile" 2>/dev/null; do
798         $show "Waiting for $lockfile to be removed"
799         sleep 2
800       done
801     elif test "$need_locks" = warn; then
802       if test -f "$lockfile"; then
803         $echo "\
804 *** ERROR, $lockfile exists and contains:
805 `cat $lockfile 2>/dev/null`
806
807 This indicates that another process is trying to use the same
808 temporary object file, and libtool could not work around it because
809 your compiler does not support \`-c' and \`-o' together.  If you
810 repeat this compilation, it may succeed, by chance, but you had better
811 avoid parallel builds (make -j) in this platform, or get a better
812 compiler."
813
814         $run $rm $removelist
815         exit $EXIT_FAILURE
816       fi
817       $echo $srcfile > "$lockfile"
818     fi
819
820     if test -n "$fix_srcfile_path"; then
821       eval srcfile=\"$fix_srcfile_path\"
822     fi
823
824     $run $rm "$libobj" "${libobj}T"
825
826     # Create a libtool object file (analogous to a ".la" file),
827     # but don't create it if we're doing a dry run.
828     test -z "$run" && cat > ${libobj}T <<EOF
829 # $libobj - a libtool object file
830 # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
831 #
832 # Please DO NOT delete this file!
833 # It is necessary for linking the library.
834
835 # Name of the PIC object.
836 EOF
837
838     # Only build a PIC object if we are building libtool libraries.
839     if test "$build_libtool_libs" = yes; then
840       # Without this assignment, base_compile gets emptied.
841       fbsd_hideous_sh_bug=$base_compile
842
843       if test "$pic_mode" != no; then
844         command="$base_compile $srcfile $pic_flag"
845       else
846         # Don't build PIC code
847         command="$base_compile $srcfile"
848       fi
849
850       if test ! -d "${xdir}$objdir"; then
851         $show "$mkdir ${xdir}$objdir"
852         $run $mkdir ${xdir}$objdir
853         status=$?
854         if test "$status" -ne 0 && test ! -d "${xdir}$objdir"; then
855           exit $status
856         fi
857       fi
858
859       if test -z "$output_obj"; then
860         # Place PIC objects in $objdir
861         command="$command -o $lobj"
862       fi
863
864       $run $rm "$lobj" "$output_obj"
865
866       $show "$command"
867       if $run eval "$command"; then :
868       else
869         test -n "$output_obj" && $run $rm $removelist
870         exit $EXIT_FAILURE
871       fi
872
873       if test "$need_locks" = warn &&
874          test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
875         $echo "\
876 *** ERROR, $lockfile contains:
877 `cat $lockfile 2>/dev/null`
878
879 but it should contain:
880 $srcfile
881
882 This indicates that another process is trying to use the same
883 temporary object file, and libtool could not work around it because
884 your compiler does not support \`-c' and \`-o' together.  If you
885 repeat this compilation, it may succeed, by chance, but you had better
886 avoid parallel builds (make -j) in this platform, or get a better
887 compiler."
888
889         $run $rm $removelist
890         exit $EXIT_FAILURE
891       fi
892
893       # Just move the object if needed, then go on to compile the next one
894       if test -n "$output_obj" && test "X$output_obj" != "X$lobj"; then
895         $show "$mv $output_obj $lobj"
896         if $run $mv $output_obj $lobj; then :
897         else
898           error=$?
899           $run $rm $removelist
900           exit $error
901         fi
902       fi
903
904       # Append the name of the PIC object to the libtool object file.
905       test -z "$run" && cat >> ${libobj}T <<EOF
906 pic_object='$objdir/$objname'
907
908 EOF
909
910       # Allow error messages only from the first compilation.
911       if test "$suppress_opt" = yes; then
912         suppress_output=' >/dev/null 2>&1'
913       fi
914     else
915       # No PIC object so indicate it doesn't exist in the libtool
916       # object file.
917       test -z "$run" && cat >> ${libobj}T <<EOF
918 pic_object=none
919
920 EOF
921     fi
922
923     # Only build a position-dependent object if we build old libraries.
924     if test "$build_old_libs" = yes; then
925       if test "$pic_mode" != yes; then
926         # Don't build PIC code
927         command="$base_compile $srcfile"
928       else
929         command="$base_compile $srcfile $pic_flag"
930       fi
931       if test "$compiler_c_o" = yes; then
932         command="$command -o $obj"
933       fi
934
935       # Suppress compiler output if we already did a PIC compilation.
936       command="$command$suppress_output"
937       $run $rm "$obj" "$output_obj"
938       $show "$command"
939       if $run eval "$command"; then :
940       else
941         $run $rm $removelist
942         exit $EXIT_FAILURE
943       fi
944
945       if test "$need_locks" = warn &&
946          test "X`cat $lockfile 2>/dev/null`" != "X$srcfile"; then
947         $echo "\
948 *** ERROR, $lockfile contains:
949 `cat $lockfile 2>/dev/null`
950
951 but it should contain:
952 $srcfile
953
954 This indicates that another process is trying to use the same
955 temporary object file, and libtool could not work around it because
956 your compiler does not support \`-c' and \`-o' together.  If you
957 repeat this compilation, it may succeed, by chance, but you had better
958 avoid parallel builds (make -j) in this platform, or get a better
959 compiler."
960
961         $run $rm $removelist
962         exit $EXIT_FAILURE
963       fi
964
965       # Just move the object if needed
966       if test -n "$output_obj" && test "X$output_obj" != "X$obj"; then
967         $show "$mv $output_obj $obj"
968         if $run $mv $output_obj $obj; then :
969         else
970           error=$?
971           $run $rm $removelist
972           exit $error
973         fi
974       fi
975
976       # Append the name of the non-PIC object the libtool object file.
977       # Only append if the libtool object file exists.
978       test -z "$run" && cat >> ${libobj}T <<EOF
979 # Name of the non-PIC object.
980 non_pic_object='$objname'
981
982 EOF
983     else
984       # Append the name of the non-PIC object the libtool object file.
985       # Only append if the libtool object file exists.
986       test -z "$run" && cat >> ${libobj}T <<EOF
987 # Name of the non-PIC object.
988 non_pic_object=none
989
990 EOF
991     fi
992
993     $run $mv "${libobj}T" "${libobj}"
994
995     # Unlock the critical section if it was locked
996     if test "$need_locks" != no; then
997       $run $rm "$lockfile"
998     fi
999
1000     exit $EXIT_SUCCESS
1001     ;;
1002
1003   # libtool link mode
1004   link | relink)
1005     modename="$modename: link"
1006     case $host in
1007     *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1008       # It is impossible to link a dll without this setting, and
1009       # we shouldn't force the makefile maintainer to figure out
1010       # which system we are compiling for in order to pass an extra
1011       # flag for every libtool invocation.
1012       # allow_undefined=no
1013
1014       # FIXME: Unfortunately, there are problems with the above when trying
1015       # to make a dll which has undefined symbols, in which case not
1016       # even a static library is built.  For now, we need to specify
1017       # -no-undefined on the libtool link line when we can be certain
1018       # that all symbols are satisfied, otherwise we get a static library.
1019       allow_undefined=yes
1020       ;;
1021     *)
1022       allow_undefined=yes
1023       ;;
1024     esac
1025     libtool_args="$nonopt"
1026     base_compile="$nonopt $@"
1027     compile_command="$nonopt"
1028     finalize_command="$nonopt"
1029
1030     compile_rpath=
1031     finalize_rpath=
1032     compile_shlibpath=
1033     finalize_shlibpath=
1034     convenience=
1035     old_convenience=
1036     deplibs=
1037     old_deplibs=
1038     compiler_flags=
1039     linker_flags=
1040     dllsearchpath=
1041     lib_search_path=`pwd`
1042     inst_prefix_dir=
1043
1044     avoid_version=no
1045     dlfiles=
1046     dlprefiles=
1047     dlself=no
1048     export_dynamic=no
1049     export_symbols=
1050     export_symbols_regex=
1051     generated=
1052     libobjs=
1053     ltlibs=
1054     module=no
1055     no_install=no
1056     objs=
1057     non_pic_objects=
1058     precious_files_regex=
1059     prefer_static_libs=no
1060     preload=no
1061     prev=
1062     prevarg=
1063     release=
1064     rpath=
1065     xrpath=
1066     perm_rpath=
1067     temp_rpath=
1068     thread_safe=no
1069     vinfo=
1070     vinfo_number=no
1071
1072     func_infer_tag $base_compile
1073
1074     # We need to know -static, to get the right output filenames.
1075     for arg
1076     do
1077       case $arg in
1078       -all-static | -static)
1079         if test "X$arg" = "X-all-static"; then
1080           if test "$build_libtool_libs" = yes && test -z "$link_static_flag"; then
1081             $echo "$modename: warning: complete static linking is impossible in this configuration" 1>&2
1082           fi
1083           if test -n "$link_static_flag"; then
1084             dlopen_self=$dlopen_self_static
1085           fi
1086         else
1087           if test -z "$pic_flag" && test -n "$link_static_flag"; then
1088             dlopen_self=$dlopen_self_static
1089           fi
1090         fi
1091         build_libtool_libs=no
1092         build_old_libs=yes
1093         prefer_static_libs=yes
1094         break
1095         ;;
1096       esac
1097     done
1098
1099     # See if our shared archives depend on static archives.
1100     test -n "$old_archive_from_new_cmds" && build_old_libs=yes
1101
1102     # Go through the arguments, transforming them on the way.
1103     while test "$#" -gt 0; do
1104       arg="$1"
1105       shift
1106       case $arg in
1107       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*|"")
1108         qarg=\"`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`\" ### testsuite: skip nested quoting test
1109         ;;
1110       *) qarg=$arg ;;
1111       esac
1112       libtool_args="$libtool_args $qarg"
1113
1114       # If the previous option needs an argument, assign it.
1115       if test -n "$prev"; then
1116         case $prev in
1117         output)
1118           compile_command="$compile_command @OUTPUT@"
1119           finalize_command="$finalize_command @OUTPUT@"
1120           ;;
1121         esac
1122
1123         case $prev in
1124         dlfiles|dlprefiles)
1125           if test "$preload" = no; then
1126             # Add the symbol object into the linking commands.
1127             compile_command="$compile_command @SYMFILE@"
1128             finalize_command="$finalize_command @SYMFILE@"
1129             preload=yes
1130           fi
1131           case $arg in
1132           *.la | *.lo) ;;  # We handle these cases below.
1133           force)
1134             if test "$dlself" = no; then
1135               dlself=needless
1136               export_dynamic=yes
1137             fi
1138             prev=
1139             continue
1140             ;;
1141           self)
1142             if test "$prev" = dlprefiles; then
1143               dlself=yes
1144             elif test "$prev" = dlfiles && test "$dlopen_self" != yes; then
1145               dlself=yes
1146             else
1147               dlself=needless
1148               export_dynamic=yes
1149             fi
1150             prev=
1151             continue
1152             ;;
1153           *)
1154             if test "$prev" = dlfiles; then
1155               dlfiles="$dlfiles $arg"
1156             else
1157               dlprefiles="$dlprefiles $arg"
1158             fi
1159             prev=
1160             continue
1161             ;;
1162           esac
1163           ;;
1164         expsyms)
1165           export_symbols="$arg"
1166           if test ! -f "$arg"; then
1167             $echo "$modename: symbol file \`$arg' does not exist"
1168             exit $EXIT_FAILURE
1169           fi
1170           prev=
1171           continue
1172           ;;
1173         expsyms_regex)
1174           export_symbols_regex="$arg"
1175           prev=
1176           continue
1177           ;;
1178         inst_prefix)
1179           inst_prefix_dir="$arg"
1180           prev=
1181           continue
1182           ;;
1183         precious_regex)
1184           precious_files_regex="$arg"
1185           prev=
1186           continue
1187           ;;
1188         release)
1189           release="-$arg"
1190           prev=
1191           continue
1192           ;;
1193         objectlist)
1194           if test -f "$arg"; then
1195             save_arg=$arg
1196             moreargs=
1197             for fil in `cat $save_arg`
1198             do
1199 #             moreargs="$moreargs $fil"
1200               arg=$fil
1201               # A libtool-controlled object.
1202
1203               # Check to see that this really is a libtool object.
1204               if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1205                 pic_object=
1206                 non_pic_object=
1207
1208                 # Read the .lo file
1209                 # If there is no directory component, then add one.
1210                 case $arg in
1211                 */* | *\\*) . $arg ;;
1212                 *) . ./$arg ;;
1213                 esac
1214
1215                 if test -z "$pic_object" || \
1216                    test -z "$non_pic_object" ||
1217                    test "$pic_object" = none && \
1218                    test "$non_pic_object" = none; then
1219                   $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1220                   exit $EXIT_FAILURE
1221                 fi
1222
1223                 # Extract subdirectory from the argument.
1224                 xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1225                 if test "X$xdir" = "X$arg"; then
1226                   xdir=
1227                 else
1228                   xdir="$xdir/"
1229                 fi
1230
1231                 if test "$pic_object" != none; then
1232                   # Prepend the subdirectory the object is found in.
1233                   pic_object="$xdir$pic_object"
1234
1235                   if test "$prev" = dlfiles; then
1236                     if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1237                       dlfiles="$dlfiles $pic_object"
1238                       prev=
1239                       continue
1240                     else
1241                       # If libtool objects are unsupported, then we need to preload.
1242                       prev=dlprefiles
1243                     fi
1244                   fi
1245
1246                   # CHECK ME:  I think I busted this.  -Ossama
1247                   if test "$prev" = dlprefiles; then
1248                     # Preload the old-style object.
1249                     dlprefiles="$dlprefiles $pic_object"
1250                     prev=
1251                   fi
1252
1253                   # A PIC object.
1254                   libobjs="$libobjs $pic_object"
1255                   arg="$pic_object"
1256                 fi
1257
1258                 # Non-PIC object.
1259                 if test "$non_pic_object" != none; then
1260                   # Prepend the subdirectory the object is found in.
1261                   non_pic_object="$xdir$non_pic_object"
1262
1263                   # A standard non-PIC object
1264                   non_pic_objects="$non_pic_objects $non_pic_object"
1265                   if test -z "$pic_object" || test "$pic_object" = none ; then
1266                     arg="$non_pic_object"
1267                   fi
1268                 fi
1269               else
1270                 # Only an error if not doing a dry-run.
1271                 if test -z "$run"; then
1272                   $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1273                   exit $EXIT_FAILURE
1274                 else
1275                   # Dry-run case.
1276
1277                   # Extract subdirectory from the argument.
1278                   xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1279                   if test "X$xdir" = "X$arg"; then
1280                     xdir=
1281                   else
1282                     xdir="$xdir/"
1283                   fi
1284
1285                   pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1286                   non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1287                   libobjs="$libobjs $pic_object"
1288                   non_pic_objects="$non_pic_objects $non_pic_object"
1289                 fi
1290               fi
1291             done
1292           else
1293             $echo "$modename: link input file \`$save_arg' does not exist"
1294             exit $EXIT_FAILURE
1295           fi
1296           arg=$save_arg
1297           prev=
1298           continue
1299           ;;
1300         rpath | xrpath)
1301           # We need an absolute path.
1302           case $arg in
1303           [\\/]* | [A-Za-z]:[\\/]*) ;;
1304           *)
1305             $echo "$modename: only absolute run-paths are allowed" 1>&2
1306             exit $EXIT_FAILURE
1307             ;;
1308           esac
1309           if test "$prev" = rpath; then
1310             case "$rpath " in
1311             *" $arg "*) ;;
1312             *) rpath="$rpath $arg" ;;
1313             esac
1314           else
1315             case "$xrpath " in
1316             *" $arg "*) ;;
1317             *) xrpath="$xrpath $arg" ;;
1318             esac
1319           fi
1320           prev=
1321           continue
1322           ;;
1323         xcompiler)
1324           compiler_flags="$compiler_flags $qarg"
1325           prev=
1326           compile_command="$compile_command $qarg"
1327           finalize_command="$finalize_command $qarg"
1328           continue
1329           ;;
1330         xlinker)
1331           linker_flags="$linker_flags $qarg"
1332           compiler_flags="$compiler_flags $wl$qarg"
1333           prev=
1334           compile_command="$compile_command $wl$qarg"
1335           finalize_command="$finalize_command $wl$qarg"
1336           continue
1337           ;;
1338         xcclinker)
1339           linker_flags="$linker_flags $qarg"
1340           compiler_flags="$compiler_flags $qarg"
1341           prev=
1342           compile_command="$compile_command $qarg"
1343           finalize_command="$finalize_command $qarg"
1344           continue
1345           ;;
1346         shrext)
1347           shrext_cmds="$arg"
1348           prev=
1349           continue
1350           ;;
1351         *)
1352           eval "$prev=\"\$arg\""
1353           prev=
1354           continue
1355           ;;
1356         esac
1357       fi # test -n "$prev"
1358
1359       prevarg="$arg"
1360
1361       case $arg in
1362       -all-static)
1363         if test -n "$link_static_flag"; then
1364           compile_command="$compile_command $link_static_flag"
1365           finalize_command="$finalize_command $link_static_flag"
1366         fi
1367         continue
1368         ;;
1369
1370       -allow-undefined)
1371         # FIXME: remove this flag sometime in the future.
1372         $echo "$modename: \`-allow-undefined' is deprecated because it is the default" 1>&2
1373         continue
1374         ;;
1375
1376       -avoid-version)
1377         avoid_version=yes
1378         continue
1379         ;;
1380
1381       -dlopen)
1382         prev=dlfiles
1383         continue
1384         ;;
1385
1386       -dlpreopen)
1387         prev=dlprefiles
1388         continue
1389         ;;
1390
1391       -export-dynamic)
1392         export_dynamic=yes
1393         continue
1394         ;;
1395
1396       -export-symbols | -export-symbols-regex)
1397         if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
1398           $echo "$modename: more than one -exported-symbols argument is not allowed"
1399           exit $EXIT_FAILURE
1400         fi
1401         if test "X$arg" = "X-export-symbols"; then
1402           prev=expsyms
1403         else
1404           prev=expsyms_regex
1405         fi
1406         continue
1407         ;;
1408
1409       -inst-prefix-dir)
1410         prev=inst_prefix
1411         continue
1412         ;;
1413
1414       # The native IRIX linker understands -LANG:*, -LIST:* and -LNO:*
1415       # so, if we see these flags be careful not to treat them like -L
1416       -L[A-Z][A-Z]*:*)
1417         case $with_gcc/$host in
1418         no/*-*-irix* | /*-*-irix*)
1419           compile_command="$compile_command $arg"
1420           finalize_command="$finalize_command $arg"
1421           ;;
1422         esac
1423         continue
1424         ;;
1425
1426       -L*)
1427         dir=`$echo "X$arg" | $Xsed -e 's/^-L//'`
1428         # We need an absolute path.
1429         case $dir in
1430         [\\/]* | [A-Za-z]:[\\/]*) ;;
1431         *)
1432           absdir=`cd "$dir" && pwd`
1433           if test -z "$absdir"; then
1434             $echo "$modename: cannot determine absolute directory name of \`$dir'" 1>&2
1435             exit $EXIT_FAILURE
1436           fi
1437           dir="$absdir"
1438           ;;
1439         esac
1440         case "$deplibs " in
1441         *" -L$dir "*) ;;
1442         *)
1443           deplibs="$deplibs -L$dir"
1444           lib_search_path="$lib_search_path $dir"
1445           ;;
1446         esac
1447         case $host in
1448         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1449           case :$dllsearchpath: in
1450           *":$dir:"*) ;;
1451           *) dllsearchpath="$dllsearchpath:$dir";;
1452           esac
1453           ;;
1454         esac
1455         continue
1456         ;;
1457
1458       -l*)
1459         if test "X$arg" = "X-lc" || test "X$arg" = "X-lm"; then
1460           case $host in
1461           *-*-cygwin* | *-*-pw32* | *-*-beos*)
1462             # These systems don't actually have a C or math library (as such)
1463             continue
1464             ;;
1465           *-*-mingw* | *-*-os2*)
1466             # These systems don't actually have a C library (as such)
1467             test "X$arg" = "X-lc" && continue
1468             ;;
1469           *-*-openbsd* | *-*-freebsd*)
1470             # Do not include libc due to us having libc/libc_r.
1471             test "X$arg" = "X-lc" && continue
1472             ;;
1473           *-*-rhapsody* | *-*-darwin1.[012])
1474             # Rhapsody C and math libraries are in the System framework
1475             deplibs="$deplibs -framework System"
1476             continue
1477           esac
1478         elif test "X$arg" = "X-lc_r"; then
1479          case $host in
1480          *-*-openbsd* | *-*-freebsd*)
1481            # Do not include libc_r directly, use -pthread flag.
1482            continue
1483            ;;
1484          esac
1485         fi
1486         deplibs="$deplibs $arg"
1487         continue
1488         ;;
1489
1490      -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1491         case $host in
1492         *-*-freebsd*)
1493            compile_command="$compile_command $arg"
1494            finalize_command="$finalize_command $arg"
1495            ;;
1496         *)
1497            case "$archive_cmds" in
1498              *"\$LD"*) ;;
1499              *) deplibs="$deplibs $arg";;
1500            esac
1501            ;;
1502         esac
1503         continue
1504         ;;
1505
1506       -module)
1507         module=yes
1508         continue
1509         ;;
1510
1511       # gcc -m* arguments should be passed to the linker via $compiler_flags
1512       # in order to pass architecture information to the linker
1513       # (e.g. 32 vs 64-bit).  This may also be accomplished via -Wl,-mfoo
1514       # but this is not reliable with gcc because gcc may use -mfoo to
1515       # select a different linker, different libraries, etc, while
1516       # -Wl,-mfoo simply passes -mfoo to the linker.
1517       -m*)
1518         # Unknown arguments in both finalize_command and compile_command need
1519         # to be aesthetically quoted because they are evaled later.
1520         arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1521         case $arg in
1522         *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
1523           arg="\"$arg\""
1524           ;;
1525         esac
1526         compile_command="$compile_command $arg"
1527         finalize_command="$finalize_command $arg"
1528         if test "$with_gcc" = "yes" ; then
1529           compiler_flags="$compiler_flags $arg"
1530         fi
1531         continue
1532         ;;
1533
1534       -shrext)
1535         prev=shrext
1536         continue
1537         ;;
1538
1539       -no-fast-install)
1540         fast_install=no
1541         continue
1542         ;;
1543
1544       -no-install)
1545         case $host in
1546         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
1547           # The PATH hackery in wrapper scripts is required on Windows
1548           # in order for the loader to find any dlls it needs.
1549           $echo "$modename: warning: \`-no-install' is ignored for $host" 1>&2
1550           $echo "$modename: warning: assuming \`-no-fast-install' instead" 1>&2
1551           fast_install=no
1552           ;;
1553         *) no_install=yes ;;
1554         esac
1555         continue
1556         ;;
1557
1558       -no-undefined)
1559         allow_undefined=no
1560         continue
1561         ;;
1562
1563       -objectlist)
1564         prev=objectlist
1565         continue
1566         ;;
1567
1568       -o) prev=output ;;
1569
1570       -precious-files-regex)
1571         prev=precious_regex
1572         continue
1573         ;;
1574
1575       -release)
1576         prev=release
1577         continue
1578         ;;
1579
1580       -rpath)
1581         prev=rpath
1582         continue
1583         ;;
1584
1585       -R)
1586         prev=xrpath
1587         continue
1588         ;;
1589
1590       -R*)
1591         dir=`$echo "X$arg" | $Xsed -e 's/^-R//'`
1592         # We need an absolute path.
1593         case $dir in
1594         [\\/]* | [A-Za-z]:[\\/]*) ;;
1595         *)
1596           $echo "$modename: only absolute run-paths are allowed" 1>&2
1597           exit $EXIT_FAILURE
1598           ;;
1599         esac
1600         case "$xrpath " in
1601         *" $dir "*) ;;
1602         *) xrpath="$xrpath $dir" ;;
1603         esac
1604         continue
1605         ;;
1606
1607       -static)
1608         # The effects of -static are defined in a previous loop.
1609         # We used to do the same as -all-static on platforms that
1610         # didn't have a PIC flag, but the assumption that the effects
1611         # would be equivalent was wrong.  It would break on at least
1612         # Digital Unix and AIX.
1613         continue
1614         ;;
1615
1616       -thread-safe)
1617         thread_safe=yes
1618         continue
1619         ;;
1620
1621       -version-info)
1622         prev=vinfo
1623         continue
1624         ;;
1625       -version-number)
1626         prev=vinfo
1627         vinfo_number=yes
1628         continue
1629         ;;
1630
1631       -Wc,*)
1632         args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wc,//'`
1633         arg=
1634         save_ifs="$IFS"; IFS=','
1635         for flag in $args; do
1636           IFS="$save_ifs"
1637           case $flag in
1638             *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
1639             flag="\"$flag\""
1640             ;;
1641           esac
1642           arg="$arg $wl$flag"
1643           compiler_flags="$compiler_flags $flag"
1644         done
1645         IFS="$save_ifs"
1646         arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1647         ;;
1648
1649       -Wl,*)
1650         args=`$echo "X$arg" | $Xsed -e "$sed_quote_subst" -e 's/^-Wl,//'`
1651         arg=
1652         save_ifs="$IFS"; IFS=','
1653         for flag in $args; do
1654           IFS="$save_ifs"
1655           case $flag in
1656             *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*|"")
1657             flag="\"$flag\""
1658             ;;
1659           esac
1660           arg="$arg $wl$flag"
1661           compiler_flags="$compiler_flags $wl$flag"
1662           linker_flags="$linker_flags $flag"
1663         done
1664         IFS="$save_ifs"
1665         arg=`$echo "X$arg" | $Xsed -e "s/^ //"`
1666         ;;
1667
1668       -Xcompiler)
1669         prev=xcompiler
1670         continue
1671         ;;
1672
1673       -Xlinker)
1674         prev=xlinker
1675         continue
1676         ;;
1677
1678       -XCClinker)
1679         prev=xcclinker
1680         continue
1681         ;;
1682
1683       # Some other compiler flag.
1684       -* | +*)
1685         # Unknown arguments in both finalize_command and compile_command need
1686         # to be aesthetically quoted because they are evaled later.
1687         arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1688         case $arg in
1689         *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
1690           arg="\"$arg\""
1691           ;;
1692         esac
1693         ;;
1694
1695       *.$objext)
1696         # A standard object.
1697         objs="$objs $arg"
1698         ;;
1699
1700       *.lo)
1701         # A libtool-controlled object.
1702
1703         # Check to see that this really is a libtool object.
1704         if (${SED} -e '2q' $arg | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
1705           pic_object=
1706           non_pic_object=
1707
1708           # Read the .lo file
1709           # If there is no directory component, then add one.
1710           case $arg in
1711           */* | *\\*) . $arg ;;
1712           *) . ./$arg ;;
1713           esac
1714
1715           if test -z "$pic_object" || \
1716              test -z "$non_pic_object" ||
1717              test "$pic_object" = none && \
1718              test "$non_pic_object" = none; then
1719             $echo "$modename: cannot find name of object for \`$arg'" 1>&2
1720             exit $EXIT_FAILURE
1721           fi
1722
1723           # Extract subdirectory from the argument.
1724           xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1725           if test "X$xdir" = "X$arg"; then
1726             xdir=
1727           else
1728             xdir="$xdir/"
1729           fi
1730
1731           if test "$pic_object" != none; then
1732             # Prepend the subdirectory the object is found in.
1733             pic_object="$xdir$pic_object"
1734
1735             if test "$prev" = dlfiles; then
1736               if test "$build_libtool_libs" = yes && test "$dlopen_support" = yes; then
1737                 dlfiles="$dlfiles $pic_object"
1738                 prev=
1739                 continue
1740               else
1741                 # If libtool objects are unsupported, then we need to preload.
1742                 prev=dlprefiles
1743               fi
1744             fi
1745
1746             # CHECK ME:  I think I busted this.  -Ossama
1747             if test "$prev" = dlprefiles; then
1748               # Preload the old-style object.
1749               dlprefiles="$dlprefiles $pic_object"
1750               prev=
1751             fi
1752
1753             # A PIC object.
1754             libobjs="$libobjs $pic_object"
1755             arg="$pic_object"
1756           fi
1757
1758           # Non-PIC object.
1759           if test "$non_pic_object" != none; then
1760             # Prepend the subdirectory the object is found in.
1761             non_pic_object="$xdir$non_pic_object"
1762
1763             # A standard non-PIC object
1764             non_pic_objects="$non_pic_objects $non_pic_object"
1765             if test -z "$pic_object" || test "$pic_object" = none ; then
1766               arg="$non_pic_object"
1767             fi
1768           fi
1769         else
1770           # Only an error if not doing a dry-run.
1771           if test -z "$run"; then
1772             $echo "$modename: \`$arg' is not a valid libtool object" 1>&2
1773             exit $EXIT_FAILURE
1774           else
1775             # Dry-run case.
1776
1777             # Extract subdirectory from the argument.
1778             xdir=`$echo "X$arg" | $Xsed -e 's%/[^/]*$%%'`
1779             if test "X$xdir" = "X$arg"; then
1780               xdir=
1781             else
1782               xdir="$xdir/"
1783             fi
1784
1785             pic_object=`$echo "X${xdir}${objdir}/${arg}" | $Xsed -e "$lo2o"`
1786             non_pic_object=`$echo "X${xdir}${arg}" | $Xsed -e "$lo2o"`
1787             libobjs="$libobjs $pic_object"
1788             non_pic_objects="$non_pic_objects $non_pic_object"
1789           fi
1790         fi
1791         ;;
1792
1793       *.$libext)
1794         # An archive.
1795         deplibs="$deplibs $arg"
1796         old_deplibs="$old_deplibs $arg"
1797         continue
1798         ;;
1799
1800       *.la)
1801         # A libtool-controlled library.
1802
1803         if test "$prev" = dlfiles; then
1804           # This library was specified with -dlopen.
1805           dlfiles="$dlfiles $arg"
1806           prev=
1807         elif test "$prev" = dlprefiles; then
1808           # The library was specified with -dlpreopen.
1809           dlprefiles="$dlprefiles $arg"
1810           prev=
1811         else
1812           deplibs="$deplibs $arg"
1813         fi
1814         continue
1815         ;;
1816
1817       # Some other compiler argument.
1818       *)
1819         # Unknown arguments in both finalize_command and compile_command need
1820         # to be aesthetically quoted because they are evaled later.
1821         arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
1822         case $arg in
1823         *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \   ]*|*]*|"")
1824           arg="\"$arg\""
1825           ;;
1826         esac
1827         ;;
1828       esac # arg
1829
1830       # Now actually substitute the argument into the commands.
1831       if test -n "$arg"; then
1832         compile_command="$compile_command $arg"
1833         finalize_command="$finalize_command $arg"
1834       fi
1835     done # argument parsing loop
1836
1837     if test -n "$prev"; then
1838       $echo "$modename: the \`$prevarg' option requires an argument" 1>&2
1839       $echo "$help" 1>&2
1840       exit $EXIT_FAILURE
1841     fi
1842
1843     if test "$export_dynamic" = yes && test -n "$export_dynamic_flag_spec"; then
1844       eval arg=\"$export_dynamic_flag_spec\"
1845       compile_command="$compile_command $arg"
1846       finalize_command="$finalize_command $arg"
1847     fi
1848
1849     oldlibs=
1850     # calculate the name of the file, without its directory
1851     outputname=`$echo "X$output" | $Xsed -e 's%^.*/%%'`
1852     libobjs_save="$libobjs"
1853
1854     if test -n "$shlibpath_var"; then
1855       # get the directories listed in $shlibpath_var
1856       eval shlib_search_path=\`\$echo \"X\${$shlibpath_var}\" \| \$Xsed -e \'s/:/ /g\'\`
1857     else
1858       shlib_search_path=
1859     fi
1860     eval sys_lib_search_path=\"$sys_lib_search_path_spec\"
1861     eval sys_lib_dlsearch_path=\"$sys_lib_dlsearch_path_spec\"
1862
1863     output_objdir=`$echo "X$output" | $Xsed -e 's%/[^/]*$%%'`
1864     if test "X$output_objdir" = "X$output"; then
1865       output_objdir="$objdir"
1866     else
1867       output_objdir="$output_objdir/$objdir"
1868     fi
1869     # Create the object directory.
1870     if test ! -d "$output_objdir"; then
1871       $show "$mkdir $output_objdir"
1872       $run $mkdir $output_objdir
1873       status=$?
1874       if test "$status" -ne 0 && test ! -d "$output_objdir"; then
1875         exit $status
1876       fi
1877     fi
1878
1879     # Determine the type of output
1880     case $output in
1881     "")
1882       $echo "$modename: you must specify an output file" 1>&2
1883       $echo "$help" 1>&2
1884       exit $EXIT_FAILURE
1885       ;;
1886     *.$libext) linkmode=oldlib ;;
1887     *.lo | *.$objext) linkmode=obj ;;
1888     *.la) linkmode=lib ;;
1889     *) linkmode=prog ;; # Anything else should be a program.
1890     esac
1891
1892     case $host in
1893     *cygwin* | *mingw* | *pw32*)
1894       # don't eliminate duplications in $postdeps and $predeps
1895       duplicate_compiler_generated_deps=yes
1896       ;;
1897     *)
1898       duplicate_compiler_generated_deps=$duplicate_deps
1899       ;;
1900     esac
1901     specialdeplibs=
1902
1903     libs=
1904     # Find all interdependent deplibs by searching for libraries
1905     # that are linked more than once (e.g. -la -lb -la)
1906     for deplib in $deplibs; do
1907       if test "X$duplicate_deps" = "Xyes" ; then
1908         case "$libs " in
1909         *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
1910         esac
1911       fi
1912       libs="$libs $deplib"
1913     done
1914
1915     if test "$linkmode" = lib; then
1916       libs="$predeps $libs $compiler_lib_search_path $postdeps"
1917
1918       # Compute libraries that are listed more than once in $predeps
1919       # $postdeps and mark them as special (i.e., whose duplicates are
1920       # not to be eliminated).
1921       pre_post_deps=
1922       if test "X$duplicate_compiler_generated_deps" = "Xyes" ; then
1923         for pre_post_dep in $predeps $postdeps; do
1924           case "$pre_post_deps " in
1925           *" $pre_post_dep "*) specialdeplibs="$specialdeplibs $pre_post_deps" ;;
1926           esac
1927           pre_post_deps="$pre_post_deps $pre_post_dep"
1928         done
1929       fi
1930       pre_post_deps=
1931     fi
1932
1933     deplibs=
1934     newdependency_libs=
1935     newlib_search_path=
1936     need_relink=no # whether we're linking any uninstalled libtool libraries
1937     notinst_deplibs= # not-installed libtool libraries
1938     notinst_path= # paths that contain not-installed libtool libraries
1939     case $linkmode in
1940     lib)
1941         passes="conv link"
1942         for file in $dlfiles $dlprefiles; do
1943           case $file in
1944           *.la) ;;
1945           *)
1946             $echo "$modename: libraries can \`-dlopen' only libtool libraries: $file" 1>&2
1947             exit $EXIT_FAILURE
1948             ;;
1949           esac
1950         done
1951         ;;
1952     prog)
1953         compile_deplibs=
1954         finalize_deplibs=
1955         alldeplibs=no
1956         newdlfiles=
1957         newdlprefiles=
1958         passes="conv scan dlopen dlpreopen link"
1959         ;;
1960     *)  passes="conv"
1961         ;;
1962     esac
1963     for pass in $passes; do
1964       if test "$linkmode,$pass" = "lib,link" ||
1965          test "$linkmode,$pass" = "prog,scan"; then
1966         libs="$deplibs"
1967         deplibs=
1968       fi
1969       if test "$linkmode" = prog; then
1970         case $pass in
1971         dlopen) libs="$dlfiles" ;;
1972         dlpreopen) libs="$dlprefiles" ;;
1973         link) libs="$deplibs %DEPLIBS% $dependency_libs" ;;
1974         esac
1975       fi
1976       if test "$pass" = dlopen; then
1977         # Collect dlpreopened libraries
1978         save_deplibs="$deplibs"
1979         deplibs=
1980       fi
1981       for deplib in $libs; do
1982         lib=
1983         found=no
1984         case $deplib in
1985         -mt|-mthreads|-kthread|-Kthread|-pthread|-pthreads|--thread-safe)
1986           if test "$linkmode,$pass" = "prog,link"; then
1987             compile_deplibs="$deplib $compile_deplibs"
1988             finalize_deplibs="$deplib $finalize_deplibs"
1989           else
1990             case "$archive_cmds" in
1991               *"\$LD"*) ;;
1992               *) deplibs="$deplibs $arg";;
1993             esac
1994           fi
1995           continue
1996           ;;
1997         -l*)
1998           if test "$linkmode" != lib && test "$linkmode" != prog; then
1999             $echo "$modename: warning: \`-l' is ignored for archives/objects" 1>&2
2000             continue
2001           fi
2002           if test "$pass" = conv; then
2003             deplibs="$deplib $deplibs"
2004             continue
2005           fi
2006           name=`$echo "X$deplib" | $Xsed -e 's/^-l//'`
2007           for searchdir in $newlib_search_path $lib_search_path $sys_lib_search_path $shlib_search_path; do
2008             for search_ext in .la $std_shrext .so .a; do
2009               # Search the libtool library
2010               lib="$searchdir/lib${name}${search_ext}"
2011               if test -f "$lib"; then
2012                 if test "$search_ext" = ".la"; then
2013                   found=yes
2014                 else
2015                   found=no
2016                 fi
2017                 break 2
2018               fi
2019             done
2020           done
2021           if test "$found" != yes; then
2022             # deplib doesn't seem to be a libtool library
2023             if test "$linkmode,$pass" = "prog,link"; then
2024               compile_deplibs="$deplib $compile_deplibs"
2025               finalize_deplibs="$deplib $finalize_deplibs"
2026             else
2027               deplibs="$deplib $deplibs"
2028               test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2029             fi
2030             continue
2031           else # deplib is a libtool library
2032             # If $allow_libtool_libs_with_static_runtimes && $deplib is a stdlib,
2033             # We need to do some special things here, and not later.
2034             if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
2035               case " $predeps $postdeps " in
2036               *" $deplib "*)
2037                 if (${SED} -e '2q' $lib |
2038                     grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
2039                   library_names=
2040                   old_library=
2041                   case $lib in
2042                   */* | *\\*) . $lib ;;
2043                   *) . ./$lib ;;
2044                   esac
2045                   for l in $old_library $library_names; do
2046                     ll="$l"
2047                   done
2048                   if test "X$ll" = "X$old_library" ; then # only static version available
2049                     found=no
2050                     ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2051                     test "X$ladir" = "X$lib" && ladir="."
2052                     lib=$ladir/$old_library
2053                     if test "$linkmode,$pass" = "prog,link"; then
2054                       compile_deplibs="$deplib $compile_deplibs"
2055                       finalize_deplibs="$deplib $finalize_deplibs"
2056                     else
2057                       deplibs="$deplib $deplibs"
2058                       test "$linkmode" = lib && newdependency_libs="$deplib $newdependency_libs"
2059                     fi
2060                     continue
2061                   fi
2062                 fi
2063                 ;;
2064               *) ;;
2065               esac
2066             fi
2067           fi
2068           ;; # -l
2069         -L*)
2070           case $linkmode in
2071           lib)
2072             deplibs="$deplib $deplibs"
2073             test "$pass" = conv && continue
2074             newdependency_libs="$deplib $newdependency_libs"
2075             newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2076             ;;
2077           prog)
2078             if test "$pass" = conv; then
2079               deplibs="$deplib $deplibs"
2080               continue
2081             fi
2082             if test "$pass" = scan; then
2083               deplibs="$deplib $deplibs"
2084             else
2085               compile_deplibs="$deplib $compile_deplibs"
2086               finalize_deplibs="$deplib $finalize_deplibs"
2087             fi
2088             newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`
2089             ;;
2090           *)
2091             $echo "$modename: warning: \`-L' is ignored for archives/objects" 1>&2
2092             ;;
2093           esac # linkmode
2094           continue
2095           ;; # -L
2096         -R*)
2097           if test "$pass" = link; then
2098             dir=`$echo "X$deplib" | $Xsed -e 's/^-R//'`
2099             # Make sure the xrpath contains only unique directories.
2100             case "$xrpath " in
2101             *" $dir "*) ;;
2102             *) xrpath="$xrpath $dir" ;;
2103             esac
2104           fi
2105           deplibs="$deplib $deplibs"
2106           continue
2107           ;;
2108         *.la) lib="$deplib" ;;
2109         *.$libext)
2110           if test "$pass" = conv; then
2111             deplibs="$deplib $deplibs"
2112             continue
2113           fi
2114           case $linkmode in
2115           lib)
2116             valid_a_lib=no
2117             case $deplibs_check_method in
2118               match_pattern*)
2119                 set dummy $deplibs_check_method
2120                 match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
2121                 if eval $echo \"$deplib\" 2>/dev/null \
2122                     | $SED 10q \
2123                     | $EGREP "$match_pattern_regex" > /dev/null; then
2124                   valid_a_lib=yes
2125                 fi
2126                 ;;
2127               pass_all)
2128                 valid_a_lib=yes
2129                 ;;
2130             esac
2131             if test "$valid_a_lib" != yes; then
2132               $echo
2133               $echo "*** Warning: Trying to link with static lib archive $deplib."
2134               $echo "*** I have the capability to make that library automatically link in when"
2135               $echo "*** you link to this library.  But I can only do this if you have a"
2136               $echo "*** shared version of the library, which you do not appear to have"
2137               $echo "*** because the file extensions .$libext of this argument makes me believe"
2138               $echo "*** that it is just a static archive that I should not used here."
2139             else
2140               $echo
2141               $echo "*** Warning: Linking the shared library $output against the"
2142               $echo "*** static library $deplib is not portable!"
2143               deplibs="$deplib $deplibs"
2144             fi
2145             continue
2146             ;;
2147           prog)
2148             if test "$pass" != link; then
2149               deplibs="$deplib $deplibs"
2150             else
2151               compile_deplibs="$deplib $compile_deplibs"
2152               finalize_deplibs="$deplib $finalize_deplibs"
2153             fi
2154             continue
2155             ;;
2156           esac # linkmode
2157           ;; # *.$libext
2158         *.lo | *.$objext)
2159           if test "$pass" = conv; then
2160             deplibs="$deplib $deplibs"
2161           elif test "$linkmode" = prog; then
2162             if test "$pass" = dlpreopen || test "$dlopen_support" != yes || test "$build_libtool_libs" = no; then
2163               # If there is no dlopen support or we're linking statically,
2164               # we need to preload.
2165               newdlprefiles="$newdlprefiles $deplib"
2166               compile_deplibs="$deplib $compile_deplibs"
2167               finalize_deplibs="$deplib $finalize_deplibs"
2168             else
2169               newdlfiles="$newdlfiles $deplib"
2170             fi
2171           fi
2172           continue
2173           ;;
2174         %DEPLIBS%)
2175           alldeplibs=yes
2176           continue
2177           ;;
2178         esac # case $deplib
2179         if test "$found" = yes || test -f "$lib"; then :
2180         else
2181           $echo "$modename: cannot find the library \`$lib'" 1>&2
2182           exit $EXIT_FAILURE
2183         fi
2184
2185         # Check to see that this really is a libtool archive.
2186         if (${SED} -e '2q' $lib | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
2187         else
2188           $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
2189           exit $EXIT_FAILURE
2190         fi
2191
2192         ladir=`$echo "X$lib" | $Xsed -e 's%/[^/]*$%%'`
2193         test "X$ladir" = "X$lib" && ladir="."
2194
2195         dlname=
2196         dlopen=
2197         dlpreopen=
2198         libdir=
2199         library_names=
2200         old_library=
2201         # If the library was installed with an old release of libtool,
2202         # it will not redefine variables installed, or shouldnotlink
2203         installed=yes
2204         shouldnotlink=no
2205
2206         # Read the .la file
2207         case $lib in
2208         */* | *\\*) . $lib ;;
2209         *) . ./$lib ;;
2210         esac
2211
2212         if test "$linkmode,$pass" = "lib,link" ||
2213            test "$linkmode,$pass" = "prog,scan" ||
2214            { test "$linkmode" != prog && test "$linkmode" != lib; }; then
2215           test -n "$dlopen" && dlfiles="$dlfiles $dlopen"
2216           test -n "$dlpreopen" && dlprefiles="$dlprefiles $dlpreopen"
2217         fi
2218
2219         if test "$pass" = conv; then
2220           # Only check for convenience libraries
2221           deplibs="$lib $deplibs"
2222           if test -z "$libdir"; then
2223             if test -z "$old_library"; then
2224               $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2225               exit $EXIT_FAILURE
2226             fi
2227             # It is a libtool convenience library, so add in its objects.
2228             convenience="$convenience $ladir/$objdir/$old_library"
2229             old_convenience="$old_convenience $ladir/$objdir/$old_library"
2230             tmp_libs=
2231             for deplib in $dependency_libs; do
2232               deplibs="$deplib $deplibs"
2233               if test "X$duplicate_deps" = "Xyes" ; then
2234                 case "$tmp_libs " in
2235                 *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2236                 esac
2237               fi
2238               tmp_libs="$tmp_libs $deplib"
2239             done
2240           elif test "$linkmode" != prog && test "$linkmode" != lib; then
2241             $echo "$modename: \`$lib' is not a convenience library" 1>&2
2242             exit $EXIT_FAILURE
2243           fi
2244           continue
2245         fi # $pass = conv
2246
2247
2248         # Get the name of the library we link against.
2249         linklib=
2250         for l in $old_library $library_names; do
2251           linklib="$l"
2252         done
2253         if test -z "$linklib"; then
2254           $echo "$modename: cannot find name of link library for \`$lib'" 1>&2
2255           exit $EXIT_FAILURE
2256         fi
2257
2258         # This library was specified with -dlopen.
2259         if test "$pass" = dlopen; then
2260           if test -z "$libdir"; then
2261             $echo "$modename: cannot -dlopen a convenience library: \`$lib'" 1>&2
2262             exit $EXIT_FAILURE
2263           fi
2264           if test -z "$dlname" ||
2265              test "$dlopen_support" != yes ||
2266              test "$build_libtool_libs" = no; then
2267             # If there is no dlname, no dlopen support or we're linking
2268             # statically, we need to preload.  We also need to preload any
2269             # dependent libraries so libltdl's deplib preloader doesn't
2270             # bomb out in the load deplibs phase.
2271             dlprefiles="$dlprefiles $lib $dependency_libs"
2272           else
2273             newdlfiles="$newdlfiles $lib"
2274           fi
2275           continue
2276         fi # $pass = dlopen
2277
2278         # We need an absolute path.
2279         case $ladir in
2280         [\\/]* | [A-Za-z]:[\\/]*) abs_ladir="$ladir" ;;
2281         *)
2282           abs_ladir=`cd "$ladir" && pwd`
2283           if test -z "$abs_ladir"; then
2284             $echo "$modename: warning: cannot determine absolute directory name of \`$ladir'" 1>&2
2285             $echo "$modename: passing it literally to the linker, although it might fail" 1>&2
2286             abs_ladir="$ladir"
2287           fi
2288           ;;
2289         esac
2290         laname=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
2291
2292         # Find the relevant object directory and library name.
2293         if test "X$installed" = Xyes; then
2294           if test ! -f "$libdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2295             $echo "$modename: warning: library \`$lib' was moved." 1>&2
2296             dir="$ladir"
2297             absdir="$abs_ladir"
2298             libdir="$abs_ladir"
2299           else
2300             dir="$libdir"
2301             absdir="$libdir"
2302           fi
2303         else
2304           if test ! -f "$ladir/$objdir/$linklib" && test -f "$abs_ladir/$linklib"; then
2305             dir="$ladir"
2306             absdir="$abs_ladir"
2307             # Remove this search path later
2308             notinst_path="$notinst_path $abs_ladir"
2309           else
2310             dir="$ladir/$objdir"
2311             absdir="$abs_ladir/$objdir"
2312             # Remove this search path later
2313             notinst_path="$notinst_path $abs_ladir"
2314           fi
2315         fi # $installed = yes
2316         name=`$echo "X$laname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2317
2318         # This library was specified with -dlpreopen.
2319         if test "$pass" = dlpreopen; then
2320           if test -z "$libdir"; then
2321             $echo "$modename: cannot -dlpreopen a convenience library: \`$lib'" 1>&2
2322             exit $EXIT_FAILURE
2323           fi
2324           # Prefer using a static library (so that no silly _DYNAMIC symbols
2325           # are required to link).
2326           if test -n "$old_library"; then
2327             newdlprefiles="$newdlprefiles $dir/$old_library"
2328           # Otherwise, use the dlname, so that lt_dlopen finds it.
2329           elif test -n "$dlname"; then
2330             newdlprefiles="$newdlprefiles $dir/$dlname"
2331           else
2332             newdlprefiles="$newdlprefiles $dir/$linklib"
2333           fi
2334         fi # $pass = dlpreopen
2335
2336         if test -z "$libdir"; then
2337           # Link the convenience library
2338           if test "$linkmode" = lib; then
2339             deplibs="$dir/$old_library $deplibs"
2340           elif test "$linkmode,$pass" = "prog,link"; then
2341             compile_deplibs="$dir/$old_library $compile_deplibs"
2342             finalize_deplibs="$dir/$old_library $finalize_deplibs"
2343           else
2344             deplibs="$lib $deplibs" # used for prog,scan pass
2345           fi
2346           continue
2347         fi
2348
2349
2350         if test "$linkmode" = prog && test "$pass" != link; then
2351           newlib_search_path="$newlib_search_path $ladir"
2352           deplibs="$lib $deplibs"
2353
2354           linkalldeplibs=no
2355           if test "$link_all_deplibs" != no || test -z "$library_names" ||
2356              test "$build_libtool_libs" = no; then
2357             linkalldeplibs=yes
2358           fi
2359
2360           tmp_libs=
2361           for deplib in $dependency_libs; do
2362             case $deplib in
2363             -L*) newlib_search_path="$newlib_search_path "`$echo "X$deplib" | $Xsed -e 's/^-L//'`;; ### testsuite: skip nested quoting test
2364             esac
2365             # Need to link against all dependency_libs?
2366             if test "$linkalldeplibs" = yes; then
2367               deplibs="$deplib $deplibs"
2368             else
2369               # Need to hardcode shared library paths
2370               # or/and link against static libraries
2371               newdependency_libs="$deplib $newdependency_libs"
2372             fi
2373             if test "X$duplicate_deps" = "Xyes" ; then
2374               case "$tmp_libs " in
2375               *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2376               esac
2377             fi
2378             tmp_libs="$tmp_libs $deplib"
2379           done # for deplib
2380           continue
2381         fi # $linkmode = prog...
2382
2383         if test "$linkmode,$pass" = "prog,link"; then
2384           if test -n "$library_names" &&
2385              { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2386             # We need to hardcode the library path
2387             if test -n "$shlibpath_var"; then
2388               # Make sure the rpath contains only unique directories.
2389               case "$temp_rpath " in
2390               *" $dir "*) ;;
2391               *" $absdir "*) ;;
2392               *) temp_rpath="$temp_rpath $dir" ;;
2393               esac
2394             fi
2395
2396             # Hardcode the library path.
2397             # Skip directories that are in the system default run-time
2398             # search path.
2399             case " $sys_lib_dlsearch_path " in
2400             *" $absdir "*) ;;
2401             *)
2402               case "$compile_rpath " in
2403               *" $absdir "*) ;;
2404               *) compile_rpath="$compile_rpath $absdir"
2405               esac
2406               ;;
2407             esac
2408             case " $sys_lib_dlsearch_path " in
2409             *" $libdir "*) ;;
2410             *)
2411               case "$finalize_rpath " in
2412               *" $libdir "*) ;;
2413               *) finalize_rpath="$finalize_rpath $libdir"
2414               esac
2415               ;;
2416             esac
2417           fi # $linkmode,$pass = prog,link...
2418
2419           if test "$alldeplibs" = yes &&
2420              { test "$deplibs_check_method" = pass_all ||
2421                { test "$build_libtool_libs" = yes &&
2422                  test -n "$library_names"; }; }; then
2423             # We only need to search for static libraries
2424             continue
2425           fi
2426         fi
2427
2428         link_static=no # Whether the deplib will be linked statically
2429         if test -n "$library_names" &&
2430            { test "$prefer_static_libs" = no || test -z "$old_library"; }; then
2431           if test "$installed" = no; then
2432             notinst_deplibs="$notinst_deplibs $lib"
2433             need_relink=yes
2434           fi
2435           # This is a shared library
2436
2437           # Warn about portability, can't link against -module's on
2438           # some systems (darwin)
2439           if test "$shouldnotlink" = yes && test "$pass" = link ; then
2440             $echo
2441             if test "$linkmode" = prog; then
2442               $echo "*** Warning: Linking the executable $output against the loadable module"
2443             else
2444               $echo "*** Warning: Linking the shared library $output against the loadable module"
2445             fi
2446             $echo "*** $linklib is not portable!"
2447           fi
2448           if test "$linkmode" = lib &&
2449              test "$hardcode_into_libs" = yes; then
2450             # Hardcode the library path.
2451             # Skip directories that are in the system default run-time
2452             # search path.
2453             case " $sys_lib_dlsearch_path " in
2454             *" $absdir "*) ;;
2455             *)
2456               case "$compile_rpath " in
2457               *" $absdir "*) ;;
2458               *) compile_rpath="$compile_rpath $absdir"
2459               esac
2460               ;;
2461             esac
2462             case " $sys_lib_dlsearch_path " in
2463             *" $libdir "*) ;;
2464             *)
2465               case "$finalize_rpath " in
2466               *" $libdir "*) ;;
2467               *) finalize_rpath="$finalize_rpath $libdir"
2468               esac
2469               ;;
2470             esac
2471           fi
2472
2473           if test -n "$old_archive_from_expsyms_cmds"; then
2474             # figure out the soname
2475             set dummy $library_names
2476             realname="$2"
2477             shift; shift
2478             libname=`eval \\$echo \"$libname_spec\"`
2479             # use dlname if we got it. it's perfectly good, no?
2480             if test -n "$dlname"; then
2481               soname="$dlname"
2482             elif test -n "$soname_spec"; then
2483               # bleh windows
2484               case $host in
2485               *cygwin* | mingw*)
2486                 major=`expr $current - $age`
2487                 versuffix="-$major"
2488                 ;;
2489               esac
2490               eval soname=\"$soname_spec\"
2491             else
2492               soname="$realname"
2493             fi
2494
2495             # Make a new name for the extract_expsyms_cmds to use
2496             soroot="$soname"
2497             soname=`$echo $soroot | ${SED} -e 's/^.*\///'`
2498             newlib="libimp-`$echo $soname | ${SED} 's/^lib//;s/\.dll$//'`.a"
2499
2500             # If the library has no export list, then create one now
2501             if test -f "$output_objdir/$soname-def"; then :
2502             else
2503               $show "extracting exported symbol list from \`$soname'"
2504               save_ifs="$IFS"; IFS='~'
2505               cmds=$extract_expsyms_cmds
2506               for cmd in $cmds; do
2507                 IFS="$save_ifs"
2508                 eval cmd=\"$cmd\"
2509                 $show "$cmd"
2510                 $run eval "$cmd" || exit $?
2511               done
2512               IFS="$save_ifs"
2513             fi
2514
2515             # Create $newlib
2516             if test -f "$output_objdir/$newlib"; then :; else
2517               $show "generating import library for \`$soname'"
2518               save_ifs="$IFS"; IFS='~'
2519               cmds=$old_archive_from_expsyms_cmds
2520               for cmd in $cmds; do
2521                 IFS="$save_ifs"
2522                 eval cmd=\"$cmd\"
2523                 $show "$cmd"
2524                 $run eval "$cmd" || exit $?
2525               done
2526               IFS="$save_ifs"
2527             fi
2528             # make sure the library variables are pointing to the new library
2529             dir=$output_objdir
2530             linklib=$newlib
2531           fi # test -n "$old_archive_from_expsyms_cmds"
2532
2533           if test "$linkmode" = prog || test "$mode" != relink; then
2534             add_shlibpath=
2535             add_dir=
2536             add=
2537             lib_linked=yes
2538             case $hardcode_action in
2539             immediate | unsupported)
2540               if test "$hardcode_direct" = no; then
2541                 add="$dir/$linklib"
2542                 case $host in
2543                   *-*-sco3.2v5* ) add_dir="-L$dir" ;;
2544                   *-*-darwin* )
2545                     # if the lib is a module then we can not link against
2546                     # it, someone is ignoring the new warnings I added
2547                     if /usr/bin/file -L $add 2> /dev/null | $EGREP "bundle" >/dev/null ; then
2548                       $echo "** Warning, lib $linklib is a module, not a shared library"
2549                       if test -z "$old_library" ; then
2550                         $echo
2551                         $echo "** And there doesn't seem to be a static archive available"
2552                         $echo "** The link will probably fail, sorry"
2553                       else
2554                         add="$dir/$old_library"
2555                       fi
2556                     fi
2557                 esac
2558               elif test "$hardcode_minus_L" = no; then
2559                 case $host in
2560                 *-*-sunos*) add_shlibpath="$dir" ;;
2561                 esac
2562                 add_dir="-L$dir"
2563                 add="-l$name"
2564               elif test "$hardcode_shlibpath_var" = no; then
2565                 add_shlibpath="$dir"
2566                 add="-l$name"
2567               else
2568                 lib_linked=no
2569               fi
2570               ;;
2571             relink)
2572               if test "$hardcode_direct" = yes; then
2573                 add="$dir/$linklib"
2574               elif test "$hardcode_minus_L" = yes; then
2575                 add_dir="-L$dir"
2576                 # Try looking first in the location we're being installed to.
2577                 if test -n "$inst_prefix_dir"; then
2578                   case "$libdir" in
2579                     [\\/]*)
2580                       add_dir="$add_dir -L$inst_prefix_dir$libdir"
2581                       ;;
2582                   esac
2583                 fi
2584                 add="-l$name"
2585               elif test "$hardcode_shlibpath_var" = yes; then
2586                 add_shlibpath="$dir"
2587                 add="-l$name"
2588               else
2589                 lib_linked=no
2590               fi
2591               ;;
2592             *) lib_linked=no ;;
2593             esac
2594
2595             if test "$lib_linked" != yes; then
2596               $echo "$modename: configuration error: unsupported hardcode properties"
2597               exit $EXIT_FAILURE
2598             fi
2599
2600             if test -n "$add_shlibpath"; then
2601               case :$compile_shlibpath: in
2602               *":$add_shlibpath:"*) ;;
2603               *) compile_shlibpath="$compile_shlibpath$add_shlibpath:" ;;
2604               esac
2605             fi
2606             if test "$linkmode" = prog; then
2607               test -n "$add_dir" && compile_deplibs="$add_dir $compile_deplibs"
2608               test -n "$add" && compile_deplibs="$add $compile_deplibs"
2609             else
2610               test -n "$add_dir" && deplibs="$add_dir $deplibs"
2611               test -n "$add" && deplibs="$add $deplibs"
2612               if test "$hardcode_direct" != yes && \
2613                  test "$hardcode_minus_L" != yes && \
2614                  test "$hardcode_shlibpath_var" = yes; then
2615                 case :$finalize_shlibpath: in
2616                 *":$libdir:"*) ;;
2617                 *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2618                 esac
2619               fi
2620             fi
2621           fi
2622
2623           if test "$linkmode" = prog || test "$mode" = relink; then
2624             add_shlibpath=
2625             add_dir=
2626             add=
2627             # Finalize command for both is simple: just hardcode it.
2628             if test "$hardcode_direct" = yes; then
2629               add="$libdir/$linklib"
2630             elif test "$hardcode_minus_L" = yes; then
2631               add_dir="-L$libdir"
2632               add="-l$name"
2633             elif test "$hardcode_shlibpath_var" = yes; then
2634               case :$finalize_shlibpath: in
2635               *":$libdir:"*) ;;
2636               *) finalize_shlibpath="$finalize_shlibpath$libdir:" ;;
2637               esac
2638               add="-l$name"
2639             elif test "$hardcode_automatic" = yes; then
2640               if test -n "$inst_prefix_dir" &&
2641                  test -f "$inst_prefix_dir$libdir/$linklib" ; then
2642                 add="$inst_prefix_dir$libdir/$linklib"
2643               else
2644                 add="$libdir/$linklib"
2645               fi
2646             else
2647               # We cannot seem to hardcode it, guess we'll fake it.
2648               add_dir="-L$libdir"
2649               # Try looking first in the location we're being installed to.
2650               if test -n "$inst_prefix_dir"; then
2651                 case "$libdir" in
2652                   [\\/]*)
2653                     add_dir="$add_dir -L$inst_prefix_dir$libdir"
2654                     ;;
2655                 esac
2656               fi
2657               add="-l$name"
2658             fi
2659
2660             if test "$linkmode" = prog; then
2661               test -n "$add_dir" && finalize_deplibs="$add_dir $finalize_deplibs"
2662               test -n "$add" && finalize_deplibs="$add $finalize_deplibs"
2663             else
2664               test -n "$add_dir" && deplibs="$add_dir $deplibs"
2665               test -n "$add" && deplibs="$add $deplibs"
2666             fi
2667           fi
2668         elif test "$linkmode" = prog; then
2669           # Here we assume that one of hardcode_direct or hardcode_minus_L
2670           # is not unsupported.  This is valid on all known static and
2671           # shared platforms.
2672           if test "$hardcode_direct" != unsupported; then
2673             test -n "$old_library" && linklib="$old_library"
2674             compile_deplibs="$dir/$linklib $compile_deplibs"
2675             finalize_deplibs="$dir/$linklib $finalize_deplibs"
2676           else
2677             compile_deplibs="-l$name -L$dir $compile_deplibs"
2678             finalize_deplibs="-l$name -L$dir $finalize_deplibs"
2679           fi
2680         elif test "$build_libtool_libs" = yes; then
2681           # Not a shared library
2682           if test "$deplibs_check_method" != pass_all; then
2683             # We're trying link a shared library against a static one
2684             # but the system doesn't support it.
2685
2686             # Just print a warning and add the library to dependency_libs so
2687             # that the program can be linked against the static library.
2688             $echo
2689             $echo "*** Warning: This system can not link to static lib archive $lib."
2690             $echo "*** I have the capability to make that library automatically link in when"
2691             $echo "*** you link to this library.  But I can only do this if you have a"
2692             $echo "*** shared version of the library, which you do not appear to have."
2693             if test "$module" = yes; then
2694               $echo "*** But as you try to build a module library, libtool will still create "
2695               $echo "*** a static module, that should work as long as the dlopening application"
2696               $echo "*** is linked with the -dlopen flag to resolve symbols at runtime."
2697               if test -z "$global_symbol_pipe"; then
2698                 $echo
2699                 $echo "*** However, this would only work if libtool was able to extract symbol"
2700                 $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
2701                 $echo "*** not find such a program.  So, this module is probably useless."
2702                 $echo "*** \`nm' from GNU binutils and a full rebuild may help."
2703               fi
2704               if test "$build_old_libs" = no; then
2705                 build_libtool_libs=module
2706                 build_old_libs=yes
2707               else
2708                 build_libtool_libs=no
2709               fi
2710             fi
2711           else
2712             convenience="$convenience $dir/$old_library"
2713             old_convenience="$old_convenience $dir/$old_library"
2714             deplibs="$dir/$old_library $deplibs"
2715             link_static=yes
2716           fi
2717         fi # link shared/static library?
2718
2719         if test "$linkmode" = lib; then
2720           if test -n "$dependency_libs" &&
2721              { test "$hardcode_into_libs" != yes ||
2722                test "$build_old_libs" = yes ||
2723                test "$link_static" = yes; }; then
2724             # Extract -R from dependency_libs
2725             temp_deplibs=
2726             for libdir in $dependency_libs; do
2727               case $libdir in
2728               -R*) temp_xrpath=`$echo "X$libdir" | $Xsed -e 's/^-R//'`
2729                    case " $xrpath " in
2730                    *" $temp_xrpath "*) ;;
2731                    *) xrpath="$xrpath $temp_xrpath";;
2732                    esac;;
2733               *) temp_deplibs="$temp_deplibs $libdir";;
2734               esac
2735             done
2736             dependency_libs="$temp_deplibs"
2737           fi
2738
2739           newlib_search_path="$newlib_search_path $absdir"
2740           # Link against this library
2741           test "$link_static" = no && newdependency_libs="$abs_ladir/$laname $newdependency_libs"
2742           # ... and its dependency_libs
2743           tmp_libs=
2744           for deplib in $dependency_libs; do
2745             newdependency_libs="$deplib $newdependency_libs"
2746             if test "X$duplicate_deps" = "Xyes" ; then
2747               case "$tmp_libs " in
2748               *" $deplib "*) specialdeplibs="$specialdeplibs $deplib" ;;
2749               esac
2750             fi
2751             tmp_libs="$tmp_libs $deplib"
2752           done
2753
2754           if test "$link_all_deplibs" != no; then
2755             # Add the search paths of all dependency libraries
2756             for deplib in $dependency_libs; do
2757               case $deplib in
2758               -L*) path="$deplib" ;;
2759               *.la)
2760                 dir=`$echo "X$deplib" | $Xsed -e 's%/[^/]*$%%'`
2761                 test "X$dir" = "X$deplib" && dir="."
2762                 # We need an absolute path.
2763                 case $dir in
2764                 [\\/]* | [A-Za-z]:[\\/]*) absdir="$dir" ;;
2765                 *)
2766                   absdir=`cd "$dir" && pwd`
2767                   if test -z "$absdir"; then
2768                     $echo "$modename: warning: cannot determine absolute directory name of \`$dir'" 1>&2
2769                     absdir="$dir"
2770                   fi
2771                   ;;
2772                 esac
2773                 if grep "^installed=no" $deplib > /dev/null; then
2774                   path="$absdir/$objdir"
2775                 else
2776                   eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
2777                   if test -z "$libdir"; then
2778                     $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
2779                     exit $EXIT_FAILURE
2780                   fi
2781                   if test "$absdir" != "$libdir"; then
2782                     $echo "$modename: warning: \`$deplib' seems to be moved" 1>&2
2783                   fi
2784                   path="$absdir"
2785                 fi
2786                 depdepl=
2787                 case $host in
2788                 *-*-darwin*)
2789                   # we do not want to link against static libs,
2790                   # but need to link against shared
2791                   eval deplibrary_names=`${SED} -n -e 's/^library_names=\(.*\)$/\1/p' $deplib`
2792                   if test -n "$deplibrary_names" ; then
2793                     for tmp in $deplibrary_names ; do
2794                       depdepl=$tmp
2795                     done
2796                     if test -f "$path/$depdepl" ; then
2797                       depdepl="$path/$depdepl"
2798                     fi
2799                     # do not add paths which are already there
2800                     case " $newlib_search_path " in
2801                     *" $path "*) ;;
2802                     *) newlib_search_path="$newlib_search_path $path";;
2803                     esac
2804                   fi
2805                   path=""
2806                   ;;
2807                 *)
2808                   path="-L$path"
2809                   ;;
2810                 esac
2811                 ;;
2812               -l*)
2813                 case $host in
2814                 *-*-darwin*)
2815                   # Again, we only want to link against shared libraries
2816                   eval tmp_libs=`$echo "X$deplib" | $Xsed -e "s,^\-l,,"`
2817                   for tmp in $newlib_search_path ; do
2818                     if test -f "$tmp/lib$tmp_libs.dylib" ; then
2819                       eval depdepl="$tmp/lib$tmp_libs.dylib"
2820                       break
2821                     fi
2822                   done
2823                   path=""
2824                   ;;
2825                 *) continue ;;
2826                 esac
2827                 ;;
2828               *) continue ;;
2829               esac
2830               case " $deplibs " in
2831               *" $depdepl "*) ;;
2832               *) deplibs="$depdepl $deplibs" ;;
2833               esac
2834               case " $deplibs " in
2835               *" $path "*) ;;
2836               *) deplibs="$deplibs $path" ;;
2837               esac
2838             done
2839           fi # link_all_deplibs != no
2840         fi # linkmode = lib
2841       done # for deplib in $libs
2842       dependency_libs="$newdependency_libs"
2843       if test "$pass" = dlpreopen; then
2844         # Link the dlpreopened libraries before other libraries
2845         for deplib in $save_deplibs; do
2846           deplibs="$deplib $deplibs"
2847         done
2848       fi
2849       if test "$pass" != dlopen; then
2850         if test "$pass" != conv; then
2851           # Make sure lib_search_path contains only unique directories.
2852           lib_search_path=
2853           for dir in $newlib_search_path; do
2854             case "$lib_search_path " in
2855             *" $dir "*) ;;
2856             *) lib_search_path="$lib_search_path $dir" ;;
2857             esac
2858           done
2859           newlib_search_path=
2860         fi
2861
2862         if test "$linkmode,$pass" != "prog,link"; then
2863           vars="deplibs"
2864         else
2865           vars="compile_deplibs finalize_deplibs"
2866         fi
2867         for var in $vars dependency_libs; do
2868           # Add libraries to $var in reverse order
2869           eval tmp_libs=\"\$$var\"
2870           new_libs=
2871           for deplib in $tmp_libs; do
2872             # FIXME: Pedantically, this is the right thing to do, so
2873             #        that some nasty dependency loop isn't accidentally
2874             #        broken:
2875             #new_libs="$deplib $new_libs"
2876             # Pragmatically, this seems to cause very few problems in
2877             # practice:
2878             case $deplib in
2879             -L*) new_libs="$deplib $new_libs" ;;
2880             -R*) ;;
2881             *)
2882               # And here is the reason: when a library appears more
2883               # than once as an explicit dependence of a library, or
2884               # is implicitly linked in more than once by the
2885               # compiler, it is considered special, and multiple
2886               # occurrences thereof are not removed.  Compare this
2887               # with having the same library being listed as a
2888               # dependency of multiple other libraries: in this case,
2889               # we know (pedantically, we assume) the library does not
2890               # need to be listed more than once, so we keep only the
2891               # last copy.  This is not always right, but it is rare
2892               # enough that we require users that really mean to play
2893               # such unportable linking tricks to link the library
2894               # using -Wl,-lname, so that libtool does not consider it
2895               # for duplicate removal.
2896               case " $specialdeplibs " in
2897               *" $deplib "*) new_libs="$deplib $new_libs" ;;
2898               *)
2899                 case " $new_libs " in
2900                 *" $deplib "*) ;;
2901                 *) new_libs="$deplib $new_libs" ;;
2902                 esac
2903                 ;;
2904               esac
2905               ;;
2906             esac
2907           done
2908           tmp_libs=
2909           for deplib in $new_libs; do
2910             case $deplib in
2911             -L*)
2912               case " $tmp_libs " in
2913               *" $deplib "*) ;;
2914               *) tmp_libs="$tmp_libs $deplib" ;;
2915               esac
2916               ;;
2917             *) tmp_libs="$tmp_libs $deplib" ;;
2918             esac
2919           done
2920           eval $var=\"$tmp_libs\"
2921         done # for var
2922       fi
2923       # Last step: remove runtime libs from dependency_libs
2924       # (they stay in deplibs)
2925       tmp_libs=
2926       for i in $dependency_libs ; do
2927         case " $predeps $postdeps $compiler_lib_search_path " in
2928         *" $i "*)
2929           i=""
2930           ;;
2931         esac
2932         if test -n "$i" ; then
2933           tmp_libs="$tmp_libs $i"
2934         fi
2935       done
2936       dependency_libs=$tmp_libs
2937     done # for pass
2938     if test "$linkmode" = prog; then
2939       dlfiles="$newdlfiles"
2940       dlprefiles="$newdlprefiles"
2941     fi
2942
2943     case $linkmode in
2944     oldlib)
2945       if test -n "$deplibs"; then
2946         $echo "$modename: warning: \`-l' and \`-L' are ignored for archives" 1>&2
2947       fi
2948
2949       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
2950         $echo "$modename: warning: \`-dlopen' is ignored for archives" 1>&2
2951       fi
2952
2953       if test -n "$rpath"; then
2954         $echo "$modename: warning: \`-rpath' is ignored for archives" 1>&2
2955       fi
2956
2957       if test -n "$xrpath"; then
2958         $echo "$modename: warning: \`-R' is ignored for archives" 1>&2
2959       fi
2960
2961       if test -n "$vinfo"; then
2962         $echo "$modename: warning: \`-version-info/-version-number' is ignored for archives" 1>&2
2963       fi
2964
2965       if test -n "$release"; then
2966         $echo "$modename: warning: \`-release' is ignored for archives" 1>&2
2967       fi
2968
2969       if test -n "$export_symbols" || test -n "$export_symbols_regex"; then
2970         $echo "$modename: warning: \`-export-symbols' is ignored for archives" 1>&2
2971       fi
2972
2973       # Now set the variables for building old libraries.
2974       build_libtool_libs=no
2975       oldlibs="$output"
2976       objs="$objs$old_deplibs"
2977       ;;
2978
2979     lib)
2980       # Make sure we only generate libraries of the form `libNAME.la'.
2981       case $outputname in
2982       lib*)
2983         name=`$echo "X$outputname" | $Xsed -e 's/\.la$//' -e 's/^lib//'`
2984         eval shared_ext=\"$shrext_cmds\"
2985         eval libname=\"$libname_spec\"
2986         ;;
2987       *)
2988         if test "$module" = no; then
2989           $echo "$modename: libtool library \`$output' must begin with \`lib'" 1>&2
2990           $echo "$help" 1>&2
2991           exit $EXIT_FAILURE
2992         fi
2993         if test "$need_lib_prefix" != no; then
2994           # Add the "lib" prefix for modules if required
2995           name=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
2996           eval shared_ext=\"$shrext_cmds\"
2997           eval libname=\"$libname_spec\"
2998         else
2999           libname=`$echo "X$outputname" | $Xsed -e 's/\.la$//'`
3000         fi
3001         ;;
3002       esac
3003
3004       if test -n "$objs"; then
3005         if test "$deplibs_check_method" != pass_all; then
3006           $echo "$modename: cannot build libtool library \`$output' from non-libtool objects on this host:$objs" 2>&1
3007           exit $EXIT_FAILURE
3008         else
3009           $echo
3010           $echo "*** Warning: Linking the shared library $output against the non-libtool"
3011           $echo "*** objects $objs is not portable!"
3012           libobjs="$libobjs $objs"
3013         fi
3014       fi
3015
3016       if test "$dlself" != no; then
3017         $echo "$modename: warning: \`-dlopen self' is ignored for libtool libraries" 1>&2
3018       fi
3019
3020       set dummy $rpath
3021       if test "$#" -gt 2; then
3022         $echo "$modename: warning: ignoring multiple \`-rpath's for a libtool library" 1>&2
3023       fi
3024       install_libdir="$2"
3025
3026       oldlibs=
3027       if test -z "$rpath"; then
3028         if test "$build_libtool_libs" = yes; then
3029           # Building a libtool convenience library.
3030           # Some compilers have problems with a `.al' extension so
3031           # convenience libraries should have the same extension an
3032           # archive normally would.
3033           oldlibs="$output_objdir/$libname.$libext $oldlibs"
3034           build_libtool_libs=convenience
3035           build_old_libs=yes
3036         fi
3037
3038         if test -n "$vinfo"; then
3039           $echo "$modename: warning: \`-version-info/-version-number' is ignored for convenience libraries" 1>&2
3040         fi
3041
3042         if test -n "$release"; then
3043           $echo "$modename: warning: \`-release' is ignored for convenience libraries" 1>&2
3044         fi
3045       else
3046
3047         # Parse the version information argument.
3048         save_ifs="$IFS"; IFS=':'
3049         set dummy $vinfo 0 0 0
3050         IFS="$save_ifs"
3051
3052         if test -n "$8"; then
3053           $echo "$modename: too many parameters to \`-version-info'" 1>&2
3054           $echo "$help" 1>&2
3055           exit $EXIT_FAILURE
3056         fi
3057
3058         # convert absolute version numbers to libtool ages
3059         # this retains compatibility with .la files and attempts
3060         # to make the code below a bit more comprehensible
3061
3062         case $vinfo_number in
3063         yes)
3064           number_major="$2"
3065           number_minor="$3"
3066           number_revision="$4"
3067           #
3068           # There are really only two kinds -- those that
3069           # use the current revision as the major version
3070           # and those that subtract age and use age as
3071           # a minor version.  But, then there is irix
3072           # which has an extra 1 added just for fun
3073           #
3074           case $version_type in
3075           darwin|linux|osf|windows)
3076             current=`expr $number_major + $number_minor`
3077             age="$number_minor"
3078             revision="$number_revision"
3079             ;;
3080           freebsd-aout|freebsd-elf|sunos)
3081             current="$number_major"
3082             revision="$number_minor"
3083             age="0"
3084             ;;
3085           irix|nonstopux)
3086             current=`expr $number_major + $number_minor - 1`
3087             age="$number_minor"
3088             revision="$number_minor"
3089             ;;
3090           esac
3091           ;;
3092         no)
3093           current="$2"
3094           revision="$3"
3095           age="$4"
3096           ;;
3097         esac
3098
3099         # Check that each of the things are valid numbers.
3100         case $current in
3101         0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
3102         *)
3103           $echo "$modename: CURRENT \`$current' is not a nonnegative integer" 1>&2
3104           $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3105           exit $EXIT_FAILURE
3106           ;;
3107         esac
3108
3109         case $revision in
3110         0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
3111         *)
3112           $echo "$modename: REVISION \`$revision' is not a nonnegative integer" 1>&2
3113           $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3114           exit $EXIT_FAILURE
3115           ;;
3116         esac
3117
3118         case $age in
3119         0 | [1-9] | [1-9][0-9] | [1-9][0-9][0-9]) ;;
3120         *)
3121           $echo "$modename: AGE \`$age' is not a nonnegative integer" 1>&2
3122           $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3123           exit $EXIT_FAILURE
3124           ;;
3125         esac
3126
3127         if test "$age" -gt "$current"; then
3128           $echo "$modename: AGE \`$age' is greater than the current interface number \`$current'" 1>&2
3129           $echo "$modename: \`$vinfo' is not valid version information" 1>&2
3130           exit $EXIT_FAILURE
3131         fi
3132
3133         # Calculate the version variables.
3134         major=
3135         versuffix=
3136         verstring=
3137         case $version_type in
3138         none) ;;
3139
3140         darwin)
3141           # Like Linux, but with the current version available in
3142           # verstring for coding it into the library header
3143           major=.`expr $current - $age`
3144           versuffix="$major.$age.$revision"
3145           # Darwin ld doesn't like 0 for these options...
3146           minor_current=`expr $current + 1`
3147           verstring="${wl}-compatibility_version ${wl}$minor_current ${wl}-current_version ${wl}$minor_current.$revision"
3148           ;;
3149
3150         freebsd-aout)
3151           major=".$current"
3152           versuffix=".$current.$revision";
3153           ;;
3154
3155         freebsd-elf)
3156           major=".$current"
3157           versuffix=".$current";
3158           ;;
3159
3160         irix | nonstopux)
3161           major=`expr $current - $age + 1`
3162
3163           case $version_type in
3164             nonstopux) verstring_prefix=nonstopux ;;
3165             *)         verstring_prefix=sgi ;;
3166           esac
3167           verstring="$verstring_prefix$major.$revision"
3168
3169           # Add in all the interfaces that we are compatible with.
3170           loop=$revision
3171           while test "$loop" -ne 0; do
3172             iface=`expr $revision - $loop`
3173             loop=`expr $loop - 1`
3174             verstring="$verstring_prefix$major.$iface:$verstring"
3175           done
3176
3177           # Before this point, $major must not contain `.'.
3178           major=.$major
3179           versuffix="$major.$revision"
3180           ;;
3181
3182         linux)
3183           major=.`expr $current - $age`
3184           versuffix="$major.$age.$revision"
3185           ;;
3186
3187         osf)
3188           major=.`expr $current - $age`
3189           versuffix=".$current.$age.$revision"
3190           verstring="$current.$age.$revision"
3191
3192           # Add in all the interfaces that we are compatible with.
3193           loop=$age
3194           while test "$loop" -ne 0; do
3195             iface=`expr $current - $loop`
3196             loop=`expr $loop - 1`
3197             verstring="$verstring:${iface}.0"
3198           done
3199
3200           # Make executables depend on our current version.
3201           verstring="$verstring:${current}.0"
3202           ;;
3203
3204         sunos)
3205           major=".$current"
3206           versuffix=".$current.$revision"
3207           ;;
3208
3209         windows)
3210           # Use '-' rather than '.', since we only want one
3211           # extension on DOS 8.3 filesystems.
3212           major=`expr $current - $age`
3213           versuffix="-$major"
3214           ;;
3215
3216         *)
3217           $echo "$modename: unknown library version type \`$version_type'" 1>&2
3218           $echo "Fatal configuration error.  See the $PACKAGE docs for more information." 1>&2
3219           exit $EXIT_FAILURE
3220           ;;
3221         esac
3222
3223         # Clear the version info if we defaulted, and they specified a release.
3224         if test -z "$vinfo" && test -n "$release"; then
3225           major=
3226           case $version_type in
3227           darwin)
3228             # we can't check for "0.0" in archive_cmds due to quoting
3229             # problems, so we reset it completely
3230             verstring=
3231             ;;
3232           *)
3233             verstring="0.0"
3234             ;;
3235           esac
3236           if test "$need_version" = no; then
3237             versuffix=
3238           else
3239             versuffix=".0.0"
3240           fi
3241         fi
3242
3243         # Remove version info from name if versioning should be avoided
3244         if test "$avoid_version" = yes && test "$need_version" = no; then
3245           major=
3246           versuffix=
3247           verstring=""
3248         fi
3249
3250         # Check to see if the archive will have undefined symbols.
3251         if test "$allow_undefined" = yes; then
3252           if test "$allow_undefined_flag" = unsupported; then
3253             $echo "$modename: warning: undefined symbols not allowed in $host shared libraries" 1>&2
3254             build_libtool_libs=no
3255             build_old_libs=yes
3256           fi
3257         else
3258           # Don't allow undefined symbols.
3259           allow_undefined_flag="$no_undefined_flag"
3260         fi
3261       fi
3262
3263       if test "$mode" != relink; then
3264         # Remove our outputs, but don't remove object files since they
3265         # may have been created when compiling PIC objects.
3266         removelist=
3267         tempremovelist=`$echo "$output_objdir/*"`
3268         for p in $tempremovelist; do
3269           case $p in
3270             *.$objext)
3271                ;;
3272             $output_objdir/$outputname | $output_objdir/$libname.* | $output_objdir/${libname}${release}.*)
3273                if test "X$precious_files_regex" != "X"; then
3274                  if echo $p | $EGREP -e "$precious_files_regex" >/dev/null 2>&1
3275                  then
3276                    continue
3277                  fi
3278                fi
3279                removelist="$removelist $p"
3280                ;;
3281             *) ;;
3282           esac
3283         done
3284         if test -n "$removelist"; then
3285           $show "${rm}r $removelist"
3286           $run ${rm}r $removelist
3287         fi
3288       fi
3289
3290       # Now set the variables for building old libraries.
3291       if test "$build_old_libs" = yes && test "$build_libtool_libs" != convenience ; then
3292         oldlibs="$oldlibs $output_objdir/$libname.$libext"
3293
3294         # Transform .lo files to .o files.
3295         oldobjs="$objs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}'$/d' -e "$lo2o" | $NL2SP`
3296       fi
3297
3298       # Eliminate all temporary directories.
3299       for path in $notinst_path; do
3300         lib_search_path=`$echo "$lib_search_path " | ${SED} -e 's% $path % %g'`
3301         deplibs=`$echo "$deplibs " | ${SED} -e 's% -L$path % %g'`
3302         dependency_libs=`$echo "$dependency_libs " | ${SED} -e 's% -L$path % %g'`
3303       done
3304
3305       if test -n "$xrpath"; then
3306         # If the user specified any rpath flags, then add them.
3307         temp_xrpath=
3308         for libdir in $xrpath; do
3309           temp_xrpath="$temp_xrpath -R$libdir"
3310           case "$finalize_rpath " in
3311           *" $libdir "*) ;;
3312           *) finalize_rpath="$finalize_rpath $libdir" ;;
3313           esac
3314         done
3315         if test "$hardcode_into_libs" != yes || test "$build_old_libs" = yes; then
3316           dependency_libs="$temp_xrpath $dependency_libs"
3317         fi
3318       fi
3319
3320       # Make sure dlfiles contains only unique files that won't be dlpreopened
3321       old_dlfiles="$dlfiles"
3322       dlfiles=
3323       for lib in $old_dlfiles; do
3324         case " $dlprefiles $dlfiles " in
3325         *" $lib "*) ;;
3326         *) dlfiles="$dlfiles $lib" ;;
3327         esac
3328       done
3329
3330       # Make sure dlprefiles contains only unique files
3331       old_dlprefiles="$dlprefiles"
3332       dlprefiles=
3333       for lib in $old_dlprefiles; do
3334         case "$dlprefiles " in
3335         *" $lib "*) ;;
3336         *) dlprefiles="$dlprefiles $lib" ;;
3337         esac
3338       done
3339
3340       if test "$build_libtool_libs" = yes; then
3341         if test -n "$rpath"; then
3342           case $host in
3343           *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2* | *-*-beos*)
3344             # these systems don't actually have a c library (as such)!
3345             ;;
3346           *-*-rhapsody* | *-*-darwin1.[012])
3347             # Rhapsody C library is in the System framework
3348             deplibs="$deplibs -framework System"
3349             ;;
3350           *-*-netbsd*)
3351             # Don't link with libc until the a.out ld.so is fixed.
3352             ;;
3353           *-*-openbsd* | *-*-freebsd*)
3354             # Do not include libc due to us having libc/libc_r.
3355             test "X$arg" = "X-lc" && continue
3356             ;;
3357           *)
3358             # Add libc to deplibs on all other systems if necessary.
3359             if test "$build_libtool_need_lc" = "yes"; then
3360               deplibs="$deplibs -lc"
3361             fi
3362             ;;
3363           esac
3364         fi
3365
3366         # Transform deplibs into only deplibs that can be linked in shared.
3367         name_save=$name
3368         libname_save=$libname
3369         release_save=$release
3370         versuffix_save=$versuffix
3371         major_save=$major
3372         # I'm not sure if I'm treating the release correctly.  I think
3373         # release should show up in the -l (ie -lgmp5) so we don't want to
3374         # add it in twice.  Is that correct?
3375         release=""
3376         versuffix=""
3377         major=""
3378         newdeplibs=
3379         droppeddeps=no
3380         case $deplibs_check_method in
3381         pass_all)
3382           # Don't check for shared/static.  Everything works.
3383           # This might be a little naive.  We might want to check
3384           # whether the library exists or not.  But this is on
3385           # osf3 & osf4 and I'm not really sure... Just
3386           # implementing what was already the behavior.
3387           newdeplibs=$deplibs
3388           ;;
3389         test_compile)
3390           # This code stresses the "libraries are programs" paradigm to its
3391           # limits. Maybe even breaks it.  We compile a program, linking it
3392           # against the deplibs as a proxy for the library.  Then we can check
3393           # whether they linked in statically or dynamically with ldd.
3394           $rm conftest.c
3395           cat > conftest.c <<EOF
3396           int main() { return 0; }
3397 EOF
3398           $rm conftest
3399           $LTCC -o conftest conftest.c $deplibs
3400           if test "$?" -eq 0 ; then
3401             ldd_output=`ldd conftest`
3402             for i in $deplibs; do
3403               name="`expr $i : '-l\(.*\)'`"
3404               # If $name is empty we are operating on a -L argument.
3405               if test "$name" != "" && test "$name" -ne "0"; then
3406                 if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3407                   case " $predeps $postdeps " in
3408                   *" $i "*)
3409                     newdeplibs="$newdeplibs $i"
3410                     i=""
3411                     ;;
3412                   esac
3413                 fi
3414                 if test -n "$i" ; then
3415                   libname=`eval \\$echo \"$libname_spec\"`
3416                   deplib_matches=`eval \\$echo \"$library_names_spec\"`
3417                   set dummy $deplib_matches
3418                   deplib_match=$2
3419                   if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3420                     newdeplibs="$newdeplibs $i"
3421                   else
3422                     droppeddeps=yes
3423                     $echo
3424                     $echo "*** Warning: dynamic linker does not accept needed library $i."
3425                     $echo "*** I have the capability to make that library automatically link in when"
3426                     $echo "*** you link to this library.  But I can only do this if you have a"
3427                     $echo "*** shared version of the library, which I believe you do not have"
3428                     $echo "*** because a test_compile did reveal that the linker did not use it for"
3429                     $echo "*** its dynamic dependency list that programs get resolved with at runtime."
3430                   fi
3431                 fi
3432               else
3433                 newdeplibs="$newdeplibs $i"
3434               fi
3435             done
3436           else
3437             # Error occurred in the first compile.  Let's try to salvage
3438             # the situation: Compile a separate program for each library.
3439             for i in $deplibs; do
3440               name="`expr $i : '-l\(.*\)'`"
3441               # If $name is empty we are operating on a -L argument.
3442               if test "$name" != "" && test "$name" != "0"; then
3443                 $rm conftest
3444                 $LTCC -o conftest conftest.c $i
3445                 # Did it work?
3446                 if test "$?" -eq 0 ; then
3447                   ldd_output=`ldd conftest`
3448                   if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3449                     case " $predeps $postdeps " in
3450                     *" $i "*)
3451                       newdeplibs="$newdeplibs $i"
3452                       i=""
3453                       ;;
3454                     esac
3455                   fi
3456                   if test -n "$i" ; then
3457                     libname=`eval \\$echo \"$libname_spec\"`
3458                     deplib_matches=`eval \\$echo \"$library_names_spec\"`
3459                     set dummy $deplib_matches
3460                     deplib_match=$2
3461                     if test `expr "$ldd_output" : ".*$deplib_match"` -ne 0 ; then
3462                       newdeplibs="$newdeplibs $i"
3463                     else
3464                       droppeddeps=yes
3465                       $echo
3466                       $echo "*** Warning: dynamic linker does not accept needed library $i."
3467                       $echo "*** I have the capability to make that library automatically link in when"
3468                       $echo "*** you link to this library.  But I can only do this if you have a"
3469                       $echo "*** shared version of the library, which you do not appear to have"
3470                       $echo "*** because a test_compile did reveal that the linker did not use this one"
3471                       $echo "*** as a dynamic dependency that programs can get resolved with at runtime."
3472                     fi
3473                   fi
3474                 else
3475                   droppeddeps=yes
3476                   $echo
3477                   $echo "*** Warning!  Library $i is needed by this library but I was not able to"
3478                   $echo "***  make it link in!  You will probably need to install it or some"
3479                   $echo "*** library that it depends on before this library will be fully"
3480                   $echo "*** functional.  Installing it before continuing would be even better."
3481                 fi
3482               else
3483                 newdeplibs="$newdeplibs $i"
3484               fi
3485             done
3486           fi
3487           ;;
3488         file_magic*)
3489           set dummy $deplibs_check_method
3490           file_magic_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3491           for a_deplib in $deplibs; do
3492             name="`expr $a_deplib : '-l\(.*\)'`"
3493             # If $name is empty we are operating on a -L argument.
3494             if test "$name" != "" && test  "$name" != "0"; then
3495               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3496                 case " $predeps $postdeps " in
3497                 *" $a_deplib "*)
3498                   newdeplibs="$newdeplibs $a_deplib"
3499                   a_deplib=""
3500                   ;;
3501                 esac
3502               fi
3503               if test -n "$a_deplib" ; then
3504                 libname=`eval \\$echo \"$libname_spec\"`
3505                 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3506                   potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3507                   for potent_lib in $potential_libs; do
3508                       # Follow soft links.
3509                       if ls -lLd "$potent_lib" 2>/dev/null \
3510                          | grep " -> " >/dev/null; then
3511                         continue
3512                       fi
3513                       # The statement above tries to avoid entering an
3514                       # endless loop below, in case of cyclic links.
3515                       # We might still enter an endless loop, since a link
3516                       # loop can be closed while we follow links,
3517                       # but so what?
3518                       potlib="$potent_lib"
3519                       while test -h "$potlib" 2>/dev/null; do
3520                         potliblink=`ls -ld $potlib | ${SED} 's/.* -> //'`
3521                         case $potliblink in
3522                         [\\/]* | [A-Za-z]:[\\/]*) potlib="$potliblink";;
3523                         *) potlib=`$echo "X$potlib" | $Xsed -e 's,[^/]*$,,'`"$potliblink";;
3524                         esac
3525                       done
3526                       if eval $file_magic_cmd \"\$potlib\" 2>/dev/null \
3527                          | ${SED} 10q \
3528                          | $EGREP "$file_magic_regex" > /dev/null; then
3529                         newdeplibs="$newdeplibs $a_deplib"
3530                         a_deplib=""
3531                         break 2
3532                       fi
3533                   done
3534                 done
3535               fi
3536               if test -n "$a_deplib" ; then
3537                 droppeddeps=yes
3538                 $echo
3539                 $echo "*** Warning: linker path does not have real file for library $a_deplib."
3540                 $echo "*** I have the capability to make that library automatically link in when"
3541                 $echo "*** you link to this library.  But I can only do this if you have a"
3542                 $echo "*** shared version of the library, which you do not appear to have"
3543                 $echo "*** because I did check the linker path looking for a file starting"
3544                 if test -z "$potlib" ; then
3545                   $echo "*** with $libname but no candidates were found. (...for file magic test)"
3546                 else
3547                   $echo "*** with $libname and none of the candidates passed a file format test"
3548                   $echo "*** using a file magic. Last file checked: $potlib"
3549                 fi
3550               fi
3551             else
3552               # Add a -L argument.
3553               newdeplibs="$newdeplibs $a_deplib"
3554             fi
3555           done # Gone through all deplibs.
3556           ;;
3557         match_pattern*)
3558           set dummy $deplibs_check_method
3559           match_pattern_regex=`expr "$deplibs_check_method" : "$2 \(.*\)"`
3560           for a_deplib in $deplibs; do
3561             name="`expr $a_deplib : '-l\(.*\)'`"
3562             # If $name is empty we are operating on a -L argument.
3563             if test -n "$name" && test "$name" != "0"; then
3564               if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3565                 case " $predeps $postdeps " in
3566                 *" $a_deplib "*)
3567                   newdeplibs="$newdeplibs $a_deplib"
3568                   a_deplib=""
3569                   ;;
3570                 esac
3571               fi
3572               if test -n "$a_deplib" ; then
3573                 libname=`eval \\$echo \"$libname_spec\"`
3574                 for i in $lib_search_path $sys_lib_search_path $shlib_search_path; do
3575                   potential_libs=`ls $i/$libname[.-]* 2>/dev/null`
3576                   for potent_lib in $potential_libs; do
3577                     potlib="$potent_lib" # see symlink-check above in file_magic test
3578                     if eval $echo \"$potent_lib\" 2>/dev/null \
3579                         | ${SED} 10q \
3580                         | $EGREP "$match_pattern_regex" > /dev/null; then
3581                       newdeplibs="$newdeplibs $a_deplib"
3582                       a_deplib=""
3583                       break 2
3584                     fi
3585                   done
3586                 done
3587               fi
3588               if test -n "$a_deplib" ; then
3589                 droppeddeps=yes
3590                 $echo
3591                 $echo "*** Warning: linker path does not have real file for library $a_deplib."
3592                 $echo "*** I have the capability to make that library automatically link in when"
3593                 $echo "*** you link to this library.  But I can only do this if you have a"
3594                 $echo "*** shared version of the library, which you do not appear to have"
3595                 $echo "*** because I did check the linker path looking for a file starting"
3596                 if test -z "$potlib" ; then
3597                   $echo "*** with $libname but no candidates were found. (...for regex pattern test)"
3598                 else
3599                   $echo "*** with $libname and none of the candidates passed a file format test"
3600                   $echo "*** using a regex pattern. Last file checked: $potlib"
3601                 fi
3602               fi
3603             else
3604               # Add a -L argument.
3605               newdeplibs="$newdeplibs $a_deplib"
3606             fi
3607           done # Gone through all deplibs.
3608           ;;
3609         none | unknown | *)
3610           newdeplibs=""
3611           tmp_deplibs=`$echo "X $deplibs" | $Xsed -e 's/ -lc$//' \
3612             -e 's/ -[LR][^ ]*//g'`
3613           if test "X$allow_libtool_libs_with_static_runtimes" = "Xyes" ; then
3614             for i in $predeps $postdeps ; do
3615               # can't use Xsed below, because $i might contain '/'
3616               tmp_deplibs=`$echo "X $tmp_deplibs" | ${SED} -e "1s,^X,," -e "s,$i,,"`
3617             done
3618           fi
3619           if $echo "X $tmp_deplibs" | $Xsed -e 's/[     ]//g' \
3620             | grep . >/dev/null; then
3621             $echo
3622             if test "X$deplibs_check_method" = "Xnone"; then
3623               $echo "*** Warning: inter-library dependencies are not supported in this platform."
3624             else
3625               $echo "*** Warning: inter-library dependencies are not known to be supported."
3626             fi
3627             $echo "*** All declared inter-library dependencies are being dropped."
3628             droppeddeps=yes
3629           fi
3630           ;;
3631         esac
3632         versuffix=$versuffix_save
3633         major=$major_save
3634         release=$release_save
3635         libname=$libname_save
3636         name=$name_save
3637
3638         case $host in
3639         *-*-rhapsody* | *-*-darwin1.[012])
3640           # On Rhapsody replace the C library is the System framework
3641           newdeplibs=`$echo "X $newdeplibs" | $Xsed -e 's/ -lc / -framework System /'`
3642           ;;
3643         esac
3644
3645         if test "$droppeddeps" = yes; then
3646           if test "$module" = yes; then
3647             $echo
3648             $echo "*** Warning: libtool could not satisfy all declared inter-library"
3649             $echo "*** dependencies of module $libname.  Therefore, libtool will create"
3650             $echo "*** a static module, that should work as long as the dlopening"
3651             $echo "*** application is linked with the -dlopen flag."
3652             if test -z "$global_symbol_pipe"; then
3653               $echo
3654               $echo "*** However, this would only work if libtool was able to extract symbol"
3655               $echo "*** lists from a program, using \`nm' or equivalent, but libtool could"
3656               $echo "*** not find such a program.  So, this module is probably useless."
3657               $echo "*** \`nm' from GNU binutils and a full rebuild may help."
3658             fi
3659             if test "$build_old_libs" = no; then
3660               oldlibs="$output_objdir/$libname.$libext"
3661               build_libtool_libs=module
3662               build_old_libs=yes
3663             else
3664               build_libtool_libs=no
3665             fi
3666           else
3667             $echo "*** The inter-library dependencies that have been dropped here will be"
3668             $echo "*** automatically added whenever a program is linked with this library"
3669             $echo "*** or is declared to -dlopen it."
3670
3671             if test "$allow_undefined" = no; then
3672               $echo
3673               $echo "*** Since this library must not contain undefined symbols,"
3674               $echo "*** because either the platform does not support them or"
3675               $echo "*** it was explicitly requested with -no-undefined,"
3676               $echo "*** libtool will only create a static version of it."
3677               if test "$build_old_libs" = no; then
3678                 oldlibs="$output_objdir/$libname.$libext"
3679                 build_libtool_libs=module
3680                 build_old_libs=yes
3681               else
3682                 build_libtool_libs=no
3683               fi
3684             fi
3685           fi
3686         fi
3687         # Done checking deplibs!
3688         deplibs=$newdeplibs
3689       fi
3690
3691       # All the library-specific variables (install_libdir is set above).
3692       library_names=
3693       old_library=
3694       dlname=
3695
3696       # Test again, we may have decided not to build it any more
3697       if test "$build_libtool_libs" = yes; then
3698         if test "$hardcode_into_libs" = yes; then
3699           # Hardcode the library paths
3700           hardcode_libdirs=
3701           dep_rpath=
3702           rpath="$finalize_rpath"
3703           test "$mode" != relink && rpath="$compile_rpath$rpath"
3704           for libdir in $rpath; do
3705             if test -n "$hardcode_libdir_flag_spec"; then
3706               if test -n "$hardcode_libdir_separator"; then
3707                 if test -z "$hardcode_libdirs"; then
3708                   hardcode_libdirs="$libdir"
3709                 else
3710                   # Just accumulate the unique libdirs.
3711                   case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
3712                   *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
3713                     ;;
3714                   *)
3715                     hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
3716                     ;;
3717                   esac
3718                 fi
3719               else
3720                 eval flag=\"$hardcode_libdir_flag_spec\"
3721                 dep_rpath="$dep_rpath $flag"
3722               fi
3723             elif test -n "$runpath_var"; then
3724               case "$perm_rpath " in
3725               *" $libdir "*) ;;
3726               *) perm_rpath="$perm_rpath $libdir" ;;
3727               esac
3728             fi
3729           done
3730           # Substitute the hardcoded libdirs into the rpath.
3731           if test -n "$hardcode_libdir_separator" &&
3732              test -n "$hardcode_libdirs"; then
3733             libdir="$hardcode_libdirs"
3734             if test -n "$hardcode_libdir_flag_spec_ld"; then
3735               eval dep_rpath=\"$hardcode_libdir_flag_spec_ld\"
3736             else
3737               eval dep_rpath=\"$hardcode_libdir_flag_spec\"
3738             fi
3739           fi
3740           if test -n "$runpath_var" && test -n "$perm_rpath"; then
3741             # We should set the runpath_var.
3742             rpath=
3743             for dir in $perm_rpath; do
3744               rpath="$rpath$dir:"
3745             done
3746             eval "$runpath_var='$rpath\$$runpath_var'; export $runpath_var"
3747           fi
3748           test -n "$dep_rpath" && deplibs="$dep_rpath $deplibs"
3749         fi
3750
3751         shlibpath="$finalize_shlibpath"
3752         test "$mode" != relink && shlibpath="$compile_shlibpath$shlibpath"
3753         if test -n "$shlibpath"; then
3754           eval "$shlibpath_var='$shlibpath\$$shlibpath_var'; export $shlibpath_var"
3755         fi
3756
3757         # Get the real and link names of the library.
3758         eval shared_ext=\"$shrext_cmds\"
3759         eval library_names=\"$library_names_spec\"
3760         set dummy $library_names
3761         realname="$2"
3762         shift; shift
3763
3764         if test -n "$soname_spec"; then
3765           eval soname=\"$soname_spec\"
3766         else
3767           soname="$realname"
3768         fi
3769         if test -z "$dlname"; then
3770           dlname=$soname
3771         fi
3772
3773         lib="$output_objdir/$realname"
3774         for link
3775         do
3776           linknames="$linknames $link"
3777         done
3778
3779         # Use standard objects if they are pic
3780         test -z "$pic_flag" && libobjs=`$echo "X$libobjs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
3781
3782         # Prepare the list of exported symbols
3783         if test -z "$export_symbols"; then
3784           if test "$always_export_symbols" = yes || test -n "$export_symbols_regex"; then
3785             $show "generating symbol list for \`$libname.la'"
3786             export_symbols="$output_objdir/$libname.exp"
3787             $run $rm $export_symbols
3788             cmds=$export_symbols_cmds
3789             save_ifs="$IFS"; IFS='~'
3790             for cmd in $cmds; do
3791               IFS="$save_ifs"
3792               eval cmd=\"$cmd\"
3793               if len=`expr "X$cmd" : ".*"` &&
3794                test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
3795                 $show "$cmd"
3796                 $run eval "$cmd" || exit $?
3797                 skipped_export=false
3798               else
3799                 # The command line is too long to execute in one step.
3800                 $show "using reloadable object file for export list..."
3801                 skipped_export=:
3802               fi
3803             done
3804             IFS="$save_ifs"
3805             if test -n "$export_symbols_regex"; then
3806               $show "$EGREP -e \"$export_symbols_regex\" \"$export_symbols\" > \"${export_symbols}T\""
3807               $run eval '$EGREP -e "$export_symbols_regex" "$export_symbols" > "${export_symbols}T"'
3808               $show "$mv \"${export_symbols}T\" \"$export_symbols\""
3809               $run eval '$mv "${export_symbols}T" "$export_symbols"'
3810             fi
3811           fi
3812         fi
3813
3814         if test -n "$export_symbols" && test -n "$include_expsyms"; then
3815           $run eval '$echo "X$include_expsyms" | $SP2NL >> "$export_symbols"'
3816         fi
3817
3818         tmp_deplibs=
3819         for test_deplib in $deplibs; do
3820                 case " $convenience " in
3821                 *" $test_deplib "*) ;;
3822                 *)
3823                         tmp_deplibs="$tmp_deplibs $test_deplib"
3824                         ;;
3825                 esac
3826         done
3827         deplibs="$tmp_deplibs"
3828
3829         if test -n "$convenience"; then
3830           if test -n "$whole_archive_flag_spec"; then
3831             save_libobjs=$libobjs
3832             eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3833           else
3834             gentop="$output_objdir/${outputname}x"
3835             generated="$generated $gentop"
3836
3837             func_extract_archives $gentop $convenience
3838             libobjs="$libobjs $func_extract_archives_result"
3839           fi
3840         fi
3841         
3842         if test "$thread_safe" = yes && test -n "$thread_safe_flag_spec"; then
3843           eval flag=\"$thread_safe_flag_spec\"
3844           linker_flags="$linker_flags $flag"
3845         fi
3846
3847         # Make a backup of the uninstalled library when relinking
3848         if test "$mode" = relink; then
3849           $run eval '(cd $output_objdir && $rm ${realname}U && $mv $realname ${realname}U)' || exit $?
3850         fi
3851
3852         # Do each of the archive commands.
3853         if test "$module" = yes && test -n "$module_cmds" ; then
3854           if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
3855             eval test_cmds=\"$module_expsym_cmds\"
3856             cmds=$module_expsym_cmds
3857           else
3858             eval test_cmds=\"$module_cmds\"
3859             cmds=$module_cmds
3860           fi
3861         else
3862         if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
3863           eval test_cmds=\"$archive_expsym_cmds\"
3864           cmds=$archive_expsym_cmds
3865         else
3866           eval test_cmds=\"$archive_cmds\"
3867           cmds=$archive_cmds
3868           fi
3869         fi
3870
3871         if test "X$skipped_export" != "X:" && len=`expr "X$test_cmds" : ".*"` &&
3872            test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
3873           :
3874         else
3875           # The command line is too long to link in one step, link piecewise.
3876           $echo "creating reloadable object files..."
3877
3878           # Save the value of $output and $libobjs because we want to
3879           # use them later.  If we have whole_archive_flag_spec, we
3880           # want to use save_libobjs as it was before
3881           # whole_archive_flag_spec was expanded, because we can't
3882           # assume the linker understands whole_archive_flag_spec.
3883           # This may have to be revisited, in case too many
3884           # convenience libraries get linked in and end up exceeding
3885           # the spec.
3886           if test -z "$convenience" || test -z "$whole_archive_flag_spec"; then
3887             save_libobjs=$libobjs
3888           fi
3889           save_output=$output
3890
3891           # Clear the reloadable object creation command queue and
3892           # initialize k to one.
3893           test_cmds=
3894           concat_cmds=
3895           objlist=
3896           delfiles=
3897           last_robj=
3898           k=1
3899           output=$output_objdir/$save_output-${k}.$objext
3900           # Loop over the list of objects to be linked.
3901           for obj in $save_libobjs
3902           do
3903             eval test_cmds=\"$reload_cmds $objlist $last_robj\"
3904             if test "X$objlist" = X ||
3905                { len=`expr "X$test_cmds" : ".*"` &&
3906                  test "$len" -le "$max_cmd_len"; }; then
3907               objlist="$objlist $obj"
3908             else
3909               # The command $test_cmds is almost too long, add a
3910               # command to the queue.
3911               if test "$k" -eq 1 ; then
3912                 # The first file doesn't have a previous command to add.
3913                 eval concat_cmds=\"$reload_cmds $objlist $last_robj\"
3914               else
3915                 # All subsequent reloadable object files will link in
3916                 # the last one created.
3917                 eval concat_cmds=\"\$concat_cmds~$reload_cmds $objlist $last_robj\"
3918               fi
3919               last_robj=$output_objdir/$save_output-${k}.$objext
3920               k=`expr $k + 1`
3921               output=$output_objdir/$save_output-${k}.$objext
3922               objlist=$obj
3923               len=1
3924             fi
3925           done
3926           # Handle the remaining objects by creating one last
3927           # reloadable object file.  All subsequent reloadable object
3928           # files will link in the last one created.
3929           test -z "$concat_cmds" || concat_cmds=$concat_cmds~
3930           eval concat_cmds=\"\${concat_cmds}$reload_cmds $objlist $last_robj\"
3931
3932           if ${skipped_export-false}; then
3933             $show "generating symbol list for \`$libname.la'"
3934             export_symbols="$output_objdir/$libname.exp"
3935             $run $rm $export_symbols
3936             libobjs=$output
3937             # Append the command to create the export file.
3938             eval concat_cmds=\"\$concat_cmds~$export_symbols_cmds\"
3939           fi
3940
3941           # Set up a command to remove the reloadale object files
3942           # after they are used.
3943           i=0
3944           while test "$i" -lt "$k"
3945           do
3946             i=`expr $i + 1`
3947             delfiles="$delfiles $output_objdir/$save_output-${i}.$objext"
3948           done
3949
3950           $echo "creating a temporary reloadable object file: $output"
3951
3952           # Loop through the commands generated above and execute them.
3953           save_ifs="$IFS"; IFS='~'
3954           for cmd in $concat_cmds; do
3955             IFS="$save_ifs"
3956             $show "$cmd"
3957             $run eval "$cmd" || exit $?
3958           done
3959           IFS="$save_ifs"
3960
3961           libobjs=$output
3962           # Restore the value of output.
3963           output=$save_output
3964
3965           if test -n "$convenience" && test -n "$whole_archive_flag_spec"; then
3966             eval libobjs=\"\$libobjs $whole_archive_flag_spec\"
3967           fi
3968           # Expand the library linking commands again to reset the
3969           # value of $libobjs for piecewise linking.
3970
3971           # Do each of the archive commands.
3972           if test "$module" = yes && test -n "$module_cmds" ; then
3973             if test -n "$export_symbols" && test -n "$module_expsym_cmds"; then
3974               cmds=$module_expsym_cmds
3975             else
3976               cmds=$module_cmds
3977             fi
3978           else
3979           if test -n "$export_symbols" && test -n "$archive_expsym_cmds"; then
3980             cmds=$archive_expsym_cmds
3981           else
3982             cmds=$archive_cmds
3983             fi
3984           fi
3985
3986           # Append the command to remove the reloadable object files
3987           # to the just-reset $cmds.
3988           eval cmds=\"\$cmds~\$rm $delfiles\"
3989         fi
3990         save_ifs="$IFS"; IFS='~'
3991         for cmd in $cmds; do
3992           IFS="$save_ifs"
3993           eval cmd=\"$cmd\"
3994           $show "$cmd"
3995           $run eval "$cmd" || exit $?
3996         done
3997         IFS="$save_ifs"
3998
3999         # Restore the uninstalled library and exit
4000         if test "$mode" = relink; then
4001           $run eval '(cd $output_objdir && $rm ${realname}T && $mv $realname ${realname}T && $mv "$realname"U $realname)' || exit $?
4002           exit $EXIT_SUCCESS
4003         fi
4004
4005         # Create links to the real library.
4006         for linkname in $linknames; do
4007           if test "$realname" != "$linkname"; then
4008             $show "(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)"
4009             $run eval '(cd $output_objdir && $rm $linkname && $LN_S $realname $linkname)' || exit $?
4010           fi
4011         done
4012
4013         # If -module or -export-dynamic was specified, set the dlname.
4014         if test "$module" = yes || test "$export_dynamic" = yes; then
4015           # On all known operating systems, these are identical.
4016           dlname="$soname"
4017         fi
4018       fi
4019       ;;
4020
4021     obj)
4022       if test -n "$deplibs"; then
4023         $echo "$modename: warning: \`-l' and \`-L' are ignored for objects" 1>&2
4024       fi
4025
4026       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4027         $echo "$modename: warning: \`-dlopen' is ignored for objects" 1>&2
4028       fi
4029
4030       if test -n "$rpath"; then
4031         $echo "$modename: warning: \`-rpath' is ignored for objects" 1>&2
4032       fi
4033
4034       if test -n "$xrpath"; then
4035         $echo "$modename: warning: \`-R' is ignored for objects" 1>&2
4036       fi
4037
4038       if test -n "$vinfo"; then
4039         $echo "$modename: warning: \`-version-info' is ignored for objects" 1>&2
4040       fi
4041
4042       if test -n "$release"; then
4043         $echo "$modename: warning: \`-release' is ignored for objects" 1>&2
4044       fi
4045
4046       case $output in
4047       *.lo)
4048         if test -n "$objs$old_deplibs"; then
4049           $echo "$modename: cannot build library object \`$output' from non-libtool objects" 1>&2
4050           exit $EXIT_FAILURE
4051         fi
4052         libobj="$output"
4053         obj=`$echo "X$output" | $Xsed -e "$lo2o"`
4054         ;;
4055       *)
4056         libobj=
4057         obj="$output"
4058         ;;
4059       esac
4060
4061       # Delete the old objects.
4062       $run $rm $obj $libobj
4063
4064       # Objects from convenience libraries.  This assumes
4065       # single-version convenience libraries.  Whenever we create
4066       # different ones for PIC/non-PIC, this we'll have to duplicate
4067       # the extraction.
4068       reload_conv_objs=
4069       gentop=
4070       # reload_cmds runs $LD directly, so let us get rid of
4071       # -Wl from whole_archive_flag_spec
4072       wl=
4073
4074       if test -n "$convenience"; then
4075         if test -n "$whole_archive_flag_spec"; then
4076           eval reload_conv_objs=\"\$reload_objs $whole_archive_flag_spec\"
4077         else
4078           gentop="$output_objdir/${obj}x"
4079           generated="$generated $gentop"
4080
4081           func_extract_archives $gentop $convenience
4082           reload_conv_objs="$reload_objs $func_extract_archives_result"
4083         fi
4084       fi
4085
4086       # Create the old-style object.
4087       reload_objs="$objs$old_deplibs "`$echo "X$libobjs" | $SP2NL | $Xsed -e '/\.'${libext}$'/d' -e '/\.lib$/d' -e "$lo2o" | $NL2SP`" $reload_conv_objs" ### testsuite: skip nested quoting test
4088
4089       output="$obj"
4090       cmds=$reload_cmds
4091       save_ifs="$IFS"; IFS='~'
4092       for cmd in $cmds; do
4093         IFS="$save_ifs"
4094         eval cmd=\"$cmd\"
4095         $show "$cmd"
4096         $run eval "$cmd" || exit $?
4097       done
4098       IFS="$save_ifs"
4099
4100       # Exit if we aren't doing a library object file.
4101       if test -z "$libobj"; then
4102         if test -n "$gentop"; then
4103           $show "${rm}r $gentop"
4104           $run ${rm}r $gentop
4105         fi
4106
4107         exit $EXIT_SUCCESS
4108       fi
4109
4110       if test "$build_libtool_libs" != yes; then
4111         if test -n "$gentop"; then
4112           $show "${rm}r $gentop"
4113           $run ${rm}r $gentop
4114         fi
4115
4116         # Create an invalid libtool object if no PIC, so that we don't
4117         # accidentally link it into a program.
4118         # $show "echo timestamp > $libobj"
4119         # $run eval "echo timestamp > $libobj" || exit $?
4120         exit $EXIT_SUCCESS
4121       fi
4122
4123       if test -n "$pic_flag" || test "$pic_mode" != default; then
4124         # Only do commands if we really have different PIC objects.
4125         reload_objs="$libobjs $reload_conv_objs"
4126         output="$libobj"
4127         cmds=$reload_cmds
4128         save_ifs="$IFS"; IFS='~'
4129         for cmd in $cmds; do
4130           IFS="$save_ifs"
4131           eval cmd=\"$cmd\"
4132           $show "$cmd"
4133           $run eval "$cmd" || exit $?
4134         done
4135         IFS="$save_ifs"
4136       fi
4137
4138       if test -n "$gentop"; then
4139         $show "${rm}r $gentop"
4140         $run ${rm}r $gentop
4141       fi
4142
4143       exit $EXIT_SUCCESS
4144       ;;
4145
4146     prog)
4147       case $host in
4148         *cygwin*) output=`$echo $output | ${SED} -e 's,.exe$,,;s,$,.exe,'` ;;
4149       esac
4150       if test -n "$vinfo"; then
4151         $echo "$modename: warning: \`-version-info' is ignored for programs" 1>&2
4152       fi
4153
4154       if test -n "$release"; then
4155         $echo "$modename: warning: \`-release' is ignored for programs" 1>&2
4156       fi
4157
4158       if test "$preload" = yes; then
4159         if test "$dlopen_support" = unknown && test "$dlopen_self" = unknown &&
4160            test "$dlopen_self_static" = unknown; then
4161           $echo "$modename: warning: \`AC_LIBTOOL_DLOPEN' not used. Assuming no dlopen support."
4162         fi
4163       fi
4164
4165       case $host in
4166       *-*-rhapsody* | *-*-darwin1.[012])
4167         # On Rhapsody replace the C library is the System framework
4168         compile_deplibs=`$echo "X $compile_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4169         finalize_deplibs=`$echo "X $finalize_deplibs" | $Xsed -e 's/ -lc / -framework System /'`
4170         ;;
4171       esac
4172
4173       case $host in
4174       *darwin*)
4175         # Don't allow lazy linking, it breaks C++ global constructors
4176         if test "$tagname" = CXX ; then
4177         compile_command="$compile_command ${wl}-bind_at_load"
4178         finalize_command="$finalize_command ${wl}-bind_at_load"
4179         fi
4180         ;;
4181       esac
4182
4183       compile_command="$compile_command $compile_deplibs"
4184       finalize_command="$finalize_command $finalize_deplibs"
4185
4186       if test -n "$rpath$xrpath"; then
4187         # If the user specified any rpath flags, then add them.
4188         for libdir in $rpath $xrpath; do
4189           # This is the magic to use -rpath.
4190           case "$finalize_rpath " in
4191           *" $libdir "*) ;;
4192           *) finalize_rpath="$finalize_rpath $libdir" ;;
4193           esac
4194         done
4195       fi
4196
4197       # Now hardcode the library paths
4198       rpath=
4199       hardcode_libdirs=
4200       for libdir in $compile_rpath $finalize_rpath; do
4201         if test -n "$hardcode_libdir_flag_spec"; then
4202           if test -n "$hardcode_libdir_separator"; then
4203             if test -z "$hardcode_libdirs"; then
4204               hardcode_libdirs="$libdir"
4205             else
4206               # Just accumulate the unique libdirs.
4207               case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4208               *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4209                 ;;
4210               *)
4211                 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4212                 ;;
4213               esac
4214             fi
4215           else
4216             eval flag=\"$hardcode_libdir_flag_spec\"
4217             rpath="$rpath $flag"
4218           fi
4219         elif test -n "$runpath_var"; then
4220           case "$perm_rpath " in
4221           *" $libdir "*) ;;
4222           *) perm_rpath="$perm_rpath $libdir" ;;
4223           esac
4224         fi
4225         case $host in
4226         *-*-cygwin* | *-*-mingw* | *-*-pw32* | *-*-os2*)
4227           case :$dllsearchpath: in
4228           *":$libdir:"*) ;;
4229           *) dllsearchpath="$dllsearchpath:$libdir";;
4230           esac
4231           ;;
4232         esac
4233       done
4234       # Substitute the hardcoded libdirs into the rpath.
4235       if test -n "$hardcode_libdir_separator" &&
4236          test -n "$hardcode_libdirs"; then
4237         libdir="$hardcode_libdirs"
4238         eval rpath=\" $hardcode_libdir_flag_spec\"
4239       fi
4240       compile_rpath="$rpath"
4241
4242       rpath=
4243       hardcode_libdirs=
4244       for libdir in $finalize_rpath; do
4245         if test -n "$hardcode_libdir_flag_spec"; then
4246           if test -n "$hardcode_libdir_separator"; then
4247             if test -z "$hardcode_libdirs"; then
4248               hardcode_libdirs="$libdir"
4249             else
4250               # Just accumulate the unique libdirs.
4251               case $hardcode_libdir_separator$hardcode_libdirs$hardcode_libdir_separator in
4252               *"$hardcode_libdir_separator$libdir$hardcode_libdir_separator"*)
4253                 ;;
4254               *)
4255                 hardcode_libdirs="$hardcode_libdirs$hardcode_libdir_separator$libdir"
4256                 ;;
4257               esac
4258             fi
4259           else
4260             eval flag=\"$hardcode_libdir_flag_spec\"
4261             rpath="$rpath $flag"
4262           fi
4263         elif test -n "$runpath_var"; then
4264           case "$finalize_perm_rpath " in
4265           *" $libdir "*) ;;
4266           *) finalize_perm_rpath="$finalize_perm_rpath $libdir" ;;
4267           esac
4268         fi
4269       done
4270       # Substitute the hardcoded libdirs into the rpath.
4271       if test -n "$hardcode_libdir_separator" &&
4272          test -n "$hardcode_libdirs"; then
4273         libdir="$hardcode_libdirs"
4274         eval rpath=\" $hardcode_libdir_flag_spec\"
4275       fi
4276       finalize_rpath="$rpath"
4277
4278       if test -n "$libobjs" && test "$build_old_libs" = yes; then
4279         # Transform all the library objects into standard objects.
4280         compile_command=`$echo "X$compile_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4281         finalize_command=`$echo "X$finalize_command" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4282       fi
4283
4284       dlsyms=
4285       if test -n "$dlfiles$dlprefiles" || test "$dlself" != no; then
4286         if test -n "$NM" && test -n "$global_symbol_pipe"; then
4287           dlsyms="${outputname}S.c"
4288         else
4289           $echo "$modename: not configured to extract global symbols from dlpreopened files" 1>&2
4290         fi
4291       fi
4292
4293       if test -n "$dlsyms"; then
4294         case $dlsyms in
4295         "") ;;
4296         *.c)
4297           # Discover the nlist of each of the dlfiles.
4298           nlist="$output_objdir/${outputname}.nm"
4299
4300           $show "$rm $nlist ${nlist}S ${nlist}T"
4301           $run $rm "$nlist" "${nlist}S" "${nlist}T"
4302
4303           # Parse the name list into a source file.
4304           $show "creating $output_objdir/$dlsyms"
4305
4306           test -z "$run" && $echo > "$output_objdir/$dlsyms" "\
4307 /* $dlsyms - symbol resolution table for \`$outputname' dlsym emulation. */
4308 /* Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP */
4309
4310 #ifdef __cplusplus
4311 extern \"C\" {
4312 #endif
4313
4314 /* Prevent the only kind of declaration conflicts we can make. */
4315 #define lt_preloaded_symbols some_other_symbol
4316
4317 /* External symbol declarations for the compiler. */\
4318 "
4319
4320           if test "$dlself" = yes; then
4321             $show "generating symbol list for \`$output'"
4322
4323             test -z "$run" && $echo ': @PROGRAM@ ' > "$nlist"
4324
4325             # Add our own program objects to the symbol list.
4326             progfiles=`$echo "X$objs$old_deplibs" | $SP2NL | $Xsed -e "$lo2o" | $NL2SP`
4327             for arg in $progfiles; do
4328               $show "extracting global C symbols from \`$arg'"
4329               $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4330             done
4331
4332             if test -n "$exclude_expsyms"; then
4333               $run eval '$EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T'
4334               $run eval '$mv "$nlist"T "$nlist"'
4335             fi
4336
4337             if test -n "$export_symbols_regex"; then
4338               $run eval '$EGREP -e "$export_symbols_regex" "$nlist" > "$nlist"T'
4339               $run eval '$mv "$nlist"T "$nlist"'
4340             fi
4341
4342             # Prepare the list of exported symbols
4343             if test -z "$export_symbols"; then
4344               export_symbols="$output_objdir/$output.exp"
4345               $run $rm $export_symbols
4346               $run eval "${SED} -n -e '/^: @PROGRAM@$/d' -e 's/^.* \(.*\)$/\1/p' "'< "$nlist" > "$export_symbols"'
4347             else
4348               $run eval "${SED} -e 's/\([][.*^$]\)/\\\1/g' -e 's/^/ /' -e 's/$/$/'"' < "$export_symbols" > "$output_objdir/$output.exp"'
4349               $run eval 'grep -f "$output_objdir/$output.exp" < "$nlist" > "$nlist"T'
4350               $run eval 'mv "$nlist"T "$nlist"'
4351             fi
4352           fi
4353
4354           for arg in $dlprefiles; do
4355             $show "extracting global C symbols from \`$arg'"
4356             name=`$echo "$arg" | ${SED} -e 's%^.*/%%'`
4357             $run eval '$echo ": $name " >> "$nlist"'
4358             $run eval "$NM $arg | $global_symbol_pipe >> '$nlist'"
4359           done
4360
4361           if test -z "$run"; then
4362             # Make sure we have at least an empty file.
4363             test -f "$nlist" || : > "$nlist"
4364
4365             if test -n "$exclude_expsyms"; then
4366               $EGREP -v " ($exclude_expsyms)$" "$nlist" > "$nlist"T
4367               $mv "$nlist"T "$nlist"
4368             fi
4369
4370             # Try sorting and uniquifying the output.
4371             if grep -v "^: " < "$nlist" |
4372                 if sort -k 3 </dev/null >/dev/null 2>&1; then
4373                   sort -k 3
4374                 else
4375                   sort +2
4376                 fi |
4377                 uniq > "$nlist"S; then
4378               :
4379             else
4380               grep -v "^: " < "$nlist" > "$nlist"S
4381             fi
4382
4383             if test -f "$nlist"S; then
4384               eval "$global_symbol_to_cdecl"' < "$nlist"S >> "$output_objdir/$dlsyms"'
4385             else
4386               $echo '/* NONE */' >> "$output_objdir/$dlsyms"
4387             fi
4388
4389             $echo >> "$output_objdir/$dlsyms" "\
4390
4391 #undef lt_preloaded_symbols
4392
4393 #if defined (__STDC__) && __STDC__
4394 # define lt_ptr void *
4395 #else
4396 # define lt_ptr char *
4397 # define const
4398 #endif
4399
4400 /* The mapping between symbol names and symbols. */
4401 const struct {
4402   const char *name;
4403   lt_ptr address;
4404 }
4405 lt_preloaded_symbols[] =
4406 {\
4407 "
4408
4409             eval "$global_symbol_to_c_name_address" < "$nlist" >> "$output_objdir/$dlsyms"
4410
4411             $echo >> "$output_objdir/$dlsyms" "\
4412   {0, (lt_ptr) 0}
4413 };
4414
4415 /* This works around a problem in FreeBSD linker */
4416 #ifdef FREEBSD_WORKAROUND
4417 static const void *lt_preloaded_setup() {
4418   return lt_preloaded_symbols;
4419 }
4420 #endif
4421
4422 #ifdef __cplusplus
4423 }
4424 #endif\
4425 "
4426           fi
4427
4428           pic_flag_for_symtable=
4429           case $host in
4430           # compiling the symbol table file with pic_flag works around
4431           # a FreeBSD bug that causes programs to crash when -lm is
4432           # linked before any other PIC object.  But we must not use
4433           # pic_flag when linking with -static.  The problem exists in
4434           # FreeBSD 2.2.6 and is fixed in FreeBSD 3.1.
4435           *-*-freebsd2*|*-*-freebsd3.0*|*-*-freebsdelf3.0*)
4436             case "$compile_command " in
4437             *" -static "*) ;;
4438             *) pic_flag_for_symtable=" $pic_flag -DFREEBSD_WORKAROUND";;
4439             esac;;
4440           *-*-hpux*)
4441             case "$compile_command " in
4442             *" -static "*) ;;
4443             *) pic_flag_for_symtable=" $pic_flag";;
4444             esac
4445           esac
4446
4447           # Now compile the dynamic symbol file.
4448           $show "(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable \"$dlsyms\")"
4449           $run eval '(cd $output_objdir && $LTCC -c$no_builtin_flag$pic_flag_for_symtable "$dlsyms")' || exit $?
4450
4451           # Clean up the generated files.
4452           $show "$rm $output_objdir/$dlsyms $nlist ${nlist}S ${nlist}T"
4453           $run $rm "$output_objdir/$dlsyms" "$nlist" "${nlist}S" "${nlist}T"
4454
4455           # Transform the symbol file into the correct name.
4456           compile_command=`$echo "X$compile_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4457           finalize_command=`$echo "X$finalize_command" | $Xsed -e "s%@SYMFILE@%$output_objdir/${outputname}S.${objext}%"`
4458           ;;
4459         *)
4460           $echo "$modename: unknown suffix for \`$dlsyms'" 1>&2
4461           exit $EXIT_FAILURE
4462           ;;
4463         esac
4464       else
4465         # We keep going just in case the user didn't refer to
4466         # lt_preloaded_symbols.  The linker will fail if global_symbol_pipe
4467         # really was required.
4468
4469         # Nullify the symbol file.
4470         compile_command=`$echo "X$compile_command" | $Xsed -e "s% @SYMFILE@%%"`
4471         finalize_command=`$echo "X$finalize_command" | $Xsed -e "s% @SYMFILE@%%"`
4472       fi
4473
4474       if test "$need_relink" = no || test "$build_libtool_libs" != yes; then
4475         # Replace the output file specification.
4476         compile_command=`$echo "X$compile_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4477         link_command="$compile_command$compile_rpath"
4478
4479         # We have no uninstalled library dependencies, so finalize right now.
4480         $show "$link_command"
4481         $run eval "$link_command"
4482         status=$?
4483
4484         # Delete the generated files.
4485         if test -n "$dlsyms"; then
4486           $show "$rm $output_objdir/${outputname}S.${objext}"
4487           $run $rm "$output_objdir/${outputname}S.${objext}"
4488         fi
4489
4490         exit $status
4491       fi
4492
4493       if test -n "$shlibpath_var"; then
4494         # We should set the shlibpath_var
4495         rpath=
4496         for dir in $temp_rpath; do
4497           case $dir in
4498           [\\/]* | [A-Za-z]:[\\/]*)
4499             # Absolute path.
4500             rpath="$rpath$dir:"
4501             ;;
4502           *)
4503             # Relative path: add a thisdir entry.
4504             rpath="$rpath\$thisdir/$dir:"
4505             ;;
4506           esac
4507         done
4508         temp_rpath="$rpath"
4509       fi
4510
4511       if test -n "$compile_shlibpath$finalize_shlibpath"; then
4512         compile_command="$shlibpath_var=\"$compile_shlibpath$finalize_shlibpath\$$shlibpath_var\" $compile_command"
4513       fi
4514       if test -n "$finalize_shlibpath"; then
4515         finalize_command="$shlibpath_var=\"$finalize_shlibpath\$$shlibpath_var\" $finalize_command"
4516       fi
4517
4518       compile_var=
4519       finalize_var=
4520       if test -n "$runpath_var"; then
4521         if test -n "$perm_rpath"; then
4522           # We should set the runpath_var.
4523           rpath=
4524           for dir in $perm_rpath; do
4525             rpath="$rpath$dir:"
4526           done
4527           compile_var="$runpath_var=\"$rpath\$$runpath_var\" "
4528         fi
4529         if test -n "$finalize_perm_rpath"; then
4530           # We should set the runpath_var.
4531           rpath=
4532           for dir in $finalize_perm_rpath; do
4533             rpath="$rpath$dir:"
4534           done
4535           finalize_var="$runpath_var=\"$rpath\$$runpath_var\" "
4536         fi
4537       fi
4538
4539       if test "$no_install" = yes; then
4540         # We don't need to create a wrapper script.
4541         link_command="$compile_var$compile_command$compile_rpath"
4542         # Replace the output file specification.
4543         link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output"'%g'`
4544         # Delete the old output file.
4545         $run $rm $output
4546         # Link the executable and exit
4547         $show "$link_command"
4548         $run eval "$link_command" || exit $?
4549         exit $EXIT_SUCCESS
4550       fi
4551
4552       if test "$hardcode_action" = relink; then
4553         # Fast installation is not supported
4554         link_command="$compile_var$compile_command$compile_rpath"
4555         relink_command="$finalize_var$finalize_command$finalize_rpath"
4556
4557         $echo "$modename: warning: this platform does not like uninstalled shared libraries" 1>&2
4558         $echo "$modename: \`$output' will be relinked during installation" 1>&2
4559       else
4560         if test "$fast_install" != no; then
4561           link_command="$finalize_var$compile_command$finalize_rpath"
4562           if test "$fast_install" = yes; then
4563             relink_command=`$echo "X$compile_var$compile_command$compile_rpath" | $Xsed -e 's%@OUTPUT@%\$progdir/\$file%g'`
4564           else
4565             # fast_install is set to needless
4566             relink_command=
4567           fi
4568         else
4569           link_command="$compile_var$compile_command$compile_rpath"
4570           relink_command="$finalize_var$finalize_command$finalize_rpath"
4571         fi
4572       fi
4573
4574       # Replace the output file specification.
4575       link_command=`$echo "X$link_command" | $Xsed -e 's%@OUTPUT@%'"$output_objdir/$outputname"'%g'`
4576
4577       # Delete the old output files.
4578       $run $rm $output $output_objdir/$outputname $output_objdir/lt-$outputname
4579
4580       $show "$link_command"
4581       $run eval "$link_command" || exit $?
4582
4583       # Now create the wrapper script.
4584       $show "creating $output"
4585
4586       # Quote the relink command for shipping.
4587       if test -n "$relink_command"; then
4588         # Preserve any variables that may affect compiler behavior
4589         for var in $variables_saved_for_relink; do
4590           if eval test -z \"\${$var+set}\"; then
4591             relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
4592           elif eval var_value=\$$var; test -z "$var_value"; then
4593             relink_command="$var=; export $var; $relink_command"
4594           else
4595             var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
4596             relink_command="$var=\"$var_value\"; export $var; $relink_command"
4597           fi
4598         done
4599         relink_command="(cd `pwd`; $relink_command)"
4600         relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
4601       fi
4602
4603       # Quote $echo for shipping.
4604       if test "X$echo" = "X$SHELL $progpath --fallback-echo"; then
4605         case $progpath in
4606         [\\/]* | [A-Za-z]:[\\/]*) qecho="$SHELL $progpath --fallback-echo";;
4607         *) qecho="$SHELL `pwd`/$progpath --fallback-echo";;
4608         esac
4609         qecho=`$echo "X$qecho" | $Xsed -e "$sed_quote_subst"`
4610       else
4611         qecho=`$echo "X$echo" | $Xsed -e "$sed_quote_subst"`
4612       fi
4613
4614       # Only actually do things if our run command is non-null.
4615       if test -z "$run"; then
4616         # win32 will think the script is a binary if it has
4617         # a .exe suffix, so we strip it off here.
4618         case $output in
4619           *.exe) output=`$echo $output|${SED} 's,.exe$,,'` ;;
4620         esac
4621         # test for cygwin because mv fails w/o .exe extensions
4622         case $host in
4623           *cygwin*)
4624             exeext=.exe
4625             outputname=`$echo $outputname|${SED} 's,.exe$,,'` ;;
4626           *) exeext= ;;
4627         esac
4628         case $host in
4629           *cygwin* | *mingw* )
4630             cwrappersource=`$echo ${objdir}/lt-${output}.c`
4631             cwrapper=`$echo ${output}.exe`
4632             $rm $cwrappersource $cwrapper
4633             trap "$rm $cwrappersource $cwrapper; exit $EXIT_FAILURE" 1 2 15
4634
4635             cat > $cwrappersource <<EOF
4636
4637 /* $cwrappersource - temporary wrapper executable for $objdir/$outputname
4638    Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
4639
4640    The $output program cannot be directly executed until all the libtool
4641    libraries that it depends on are installed.
4642
4643    This wrapper executable should never be moved out of the build directory.
4644    If it is, it will not operate correctly.
4645
4646    Currently, it simply execs the wrapper *script* "/bin/sh $output",
4647    but could eventually absorb all of the scripts functionality and
4648    exec $objdir/$outputname directly.
4649 */
4650 EOF
4651             cat >> $cwrappersource<<"EOF"
4652 #include <stdio.h>
4653 #include <stdlib.h>
4654 #include <unistd.h>
4655 #include <malloc.h>
4656 #include <stdarg.h>
4657 #include <assert.h>
4658
4659 #if defined(PATH_MAX)
4660 # define LT_PATHMAX PATH_MAX
4661 #elif defined(MAXPATHLEN)
4662 # define LT_PATHMAX MAXPATHLEN
4663 #else
4664 # define LT_PATHMAX 1024
4665 #endif
4666
4667 #ifndef DIR_SEPARATOR
4668 #define DIR_SEPARATOR '/'
4669 #endif
4670
4671 #if defined (_WIN32) || defined (__MSDOS__) || defined (__DJGPP__) || \
4672   defined (__OS2__)
4673 #define HAVE_DOS_BASED_FILE_SYSTEM
4674 #ifndef DIR_SEPARATOR_2
4675 #define DIR_SEPARATOR_2 '\\'
4676 #endif
4677 #endif
4678
4679 #ifndef DIR_SEPARATOR_2
4680 # define IS_DIR_SEPARATOR(ch) ((ch) == DIR_SEPARATOR)
4681 #else /* DIR_SEPARATOR_2 */
4682 # define IS_DIR_SEPARATOR(ch) \
4683         (((ch) == DIR_SEPARATOR) || ((ch) == DIR_SEPARATOR_2))
4684 #endif /* DIR_SEPARATOR_2 */
4685
4686 #define XMALLOC(type, num)      ((type *) xmalloc ((num) * sizeof(type)))
4687 #define XFREE(stale) do { \
4688   if (stale) { free ((void *) stale); stale = 0; } \
4689 } while (0)
4690
4691 const char *program_name = NULL;
4692
4693 void * xmalloc (size_t num);
4694 char * xstrdup (const char *string);
4695 char * basename (const char *name);
4696 char * fnqualify(const char *path);
4697 char * strendzap(char *str, const char *pat);
4698 void lt_fatal (const char *message, ...);
4699
4700 int
4701 main (int argc, char *argv[])
4702 {
4703   char **newargz;
4704   int i;
4705
4706   program_name = (char *) xstrdup ((char *) basename (argv[0]));
4707   newargz = XMALLOC(char *, argc+2);
4708 EOF
4709
4710             cat >> $cwrappersource <<EOF
4711   newargz[0] = "$SHELL";
4712 EOF
4713
4714             cat >> $cwrappersource <<"EOF"
4715   newargz[1] = fnqualify(argv[0]);
4716   /* we know the script has the same name, without the .exe */
4717   /* so make sure newargz[1] doesn't end in .exe */
4718   strendzap(newargz[1],".exe");
4719   for (i = 1; i < argc; i++)
4720     newargz[i+1] = xstrdup(argv[i]);
4721   newargz[argc+1] = NULL;
4722 EOF
4723
4724             cat >> $cwrappersource <<EOF
4725   execv("$SHELL",newargz);
4726 EOF
4727
4728             cat >> $cwrappersource <<"EOF"
4729 }
4730
4731 void *
4732 xmalloc (size_t num)
4733 {
4734   void * p = (void *) malloc (num);
4735   if (!p)
4736     lt_fatal ("Memory exhausted");
4737
4738   return p;
4739 }
4740
4741 char *
4742 xstrdup (const char *string)
4743 {
4744   return string ? strcpy ((char *) xmalloc (strlen (string) + 1), string) : NULL
4745 ;
4746 }
4747
4748 char *
4749 basename (const char *name)
4750 {
4751   const char *base;
4752
4753 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4754   /* Skip over the disk name in MSDOS pathnames. */
4755   if (isalpha (name[0]) && name[1] == ':')
4756     name += 2;
4757 #endif
4758
4759   for (base = name; *name; name++)
4760     if (IS_DIR_SEPARATOR (*name))
4761       base = name + 1;
4762   return (char *) base;
4763 }
4764
4765 char *
4766 fnqualify(const char *path)
4767 {
4768   size_t size;
4769   char *p;
4770   char tmp[LT_PATHMAX + 1];
4771
4772   assert(path != NULL);
4773
4774   /* Is it qualified already? */
4775 #if defined (HAVE_DOS_BASED_FILE_SYSTEM)
4776   if (isalpha (path[0]) && path[1] == ':')
4777     return xstrdup (path);
4778 #endif
4779   if (IS_DIR_SEPARATOR (path[0]))
4780     return xstrdup (path);
4781
4782   /* prepend the current directory */
4783   /* doesn't handle '~' */
4784   if (getcwd (tmp, LT_PATHMAX) == NULL)
4785     lt_fatal ("getcwd failed");
4786   size = strlen(tmp) + 1 + strlen(path) + 1; /* +2 for '/' and '\0' */
4787   p = XMALLOC(char, size);
4788   sprintf(p, "%s%c%s", tmp, DIR_SEPARATOR, path);
4789   return p;
4790 }
4791
4792 char *
4793 strendzap(char *str, const char *pat)
4794 {
4795   size_t len, patlen;
4796
4797   assert(str != NULL);
4798   assert(pat != NULL);
4799
4800   len = strlen(str);
4801   patlen = strlen(pat);
4802
4803   if (patlen <= len)
4804   {
4805     str += len - patlen;
4806     if (strcmp(str, pat) == 0)
4807       *str = '\0';
4808   }
4809   return str;
4810 }
4811
4812 static void
4813 lt_error_core (int exit_status, const char * mode,
4814           const char * message, va_list ap)
4815 {
4816   fprintf (stderr, "%s: %s: ", program_name, mode);
4817   vfprintf (stderr, message, ap);
4818   fprintf (stderr, ".\n");
4819
4820   if (exit_status >= 0)
4821     exit (exit_status);
4822 }
4823
4824 void
4825 lt_fatal (const char *message, ...)
4826 {
4827   va_list ap;
4828   va_start (ap, message);
4829   lt_error_core (EXIT_FAILURE, "FATAL", message, ap);
4830   va_end (ap);
4831 }
4832 EOF
4833           # we should really use a build-platform specific compiler
4834           # here, but OTOH, the wrappers (shell script and this C one)
4835           # are only useful if you want to execute the "real" binary.
4836           # Since the "real" binary is built for $host, then this
4837           # wrapper might as well be built for $host, too.
4838           $run $LTCC -s -o $cwrapper $cwrappersource
4839           ;;
4840         esac
4841         $rm $output
4842         trap "$rm $output; exit $EXIT_FAILURE" 1 2 15
4843
4844         $echo > $output "\
4845 #! $SHELL
4846
4847 # $output - temporary wrapper script for $objdir/$outputname
4848 # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
4849 #
4850 # The $output program cannot be directly executed until all the libtool
4851 # libraries that it depends on are installed.
4852 #
4853 # This wrapper script should never be moved out of the build directory.
4854 # If it is, it will not operate correctly.
4855
4856 # Sed substitution that helps us do robust quoting.  It backslashifies
4857 # metacharacters that are still active within double-quoted strings.
4858 Xsed='${SED} -e 1s/^X//'
4859 sed_quote_subst='$sed_quote_subst'
4860
4861 # The HP-UX ksh and POSIX shell print the target directory to stdout
4862 # if CDPATH is set.
4863 (unset CDPATH) >/dev/null 2>&1 && unset CDPATH
4864
4865 relink_command=\"$relink_command\"
4866
4867 # This environment variable determines our operation mode.
4868 if test \"\$libtool_install_magic\" = \"$magic\"; then
4869   # install mode needs the following variable:
4870   notinst_deplibs='$notinst_deplibs'
4871 else
4872   # When we are sourced in execute mode, \$file and \$echo are already set.
4873   if test \"\$libtool_execute_magic\" != \"$magic\"; then
4874     echo=\"$qecho\"
4875     file=\"\$0\"
4876     # Make sure echo works.
4877     if test \"X\$1\" = X--no-reexec; then
4878       # Discard the --no-reexec flag, and continue.
4879       shift
4880     elif test \"X\`(\$echo '\t') 2>/dev/null\`\" = 'X\t'; then
4881       # Yippee, \$echo works!
4882       :
4883     else
4884       # Restart under the correct shell, and then maybe \$echo will work.
4885       exec $SHELL \"\$0\" --no-reexec \${1+\"\$@\"}
4886     fi
4887   fi\
4888 "
4889         $echo >> $output "\
4890
4891   # Find the directory that this script lives in.
4892   thisdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*$%%'\`
4893   test \"x\$thisdir\" = \"x\$file\" && thisdir=.
4894
4895   # Follow symbolic links until we get to the real thisdir.
4896   file=\`ls -ld \"\$file\" | ${SED} -n 's/.*-> //p'\`
4897   while test -n \"\$file\"; do
4898     destdir=\`\$echo \"X\$file\" | \$Xsed -e 's%/[^/]*\$%%'\`
4899
4900     # If there was a directory component, then change thisdir.
4901     if test \"x\$destdir\" != \"x\$file\"; then
4902       case \"\$destdir\" in
4903       [\\\\/]* | [A-Za-z]:[\\\\/]*) thisdir=\"\$destdir\" ;;
4904       *) thisdir=\"\$thisdir/\$destdir\" ;;
4905       esac
4906     fi
4907
4908     file=\`\$echo \"X\$file\" | \$Xsed -e 's%^.*/%%'\`
4909     file=\`ls -ld \"\$thisdir/\$file\" | ${SED} -n 's/.*-> //p'\`
4910   done
4911
4912   # Try to get the absolute directory name.
4913   absdir=\`cd \"\$thisdir\" && pwd\`
4914   test -n \"\$absdir\" && thisdir=\"\$absdir\"
4915 "
4916
4917         if test "$fast_install" = yes; then
4918           $echo >> $output "\
4919   program=lt-'$outputname'$exeext
4920   progdir=\"\$thisdir/$objdir\"
4921
4922   if test ! -f \"\$progdir/\$program\" || \\
4923      { file=\`ls -1dt \"\$progdir/\$program\" \"\$progdir/../\$program\" 2>/dev/null | ${SED} 1q\`; \\
4924        test \"X\$file\" != \"X\$progdir/\$program\"; }; then
4925
4926     file=\"\$\$-\$program\"
4927
4928     if test ! -d \"\$progdir\"; then
4929       $mkdir \"\$progdir\"
4930     else
4931       $rm \"\$progdir/\$file\"
4932     fi"
4933
4934           $echo >> $output "\
4935
4936     # relink executable if necessary
4937     if test -n \"\$relink_command\"; then
4938       if relink_command_output=\`eval \$relink_command 2>&1\`; then :
4939       else
4940         $echo \"\$relink_command_output\" >&2
4941         $rm \"\$progdir/\$file\"
4942         exit $EXIT_FAILURE
4943       fi
4944     fi
4945
4946     $mv \"\$progdir/\$file\" \"\$progdir/\$program\" 2>/dev/null ||
4947     { $rm \"\$progdir/\$program\";
4948       $mv \"\$progdir/\$file\" \"\$progdir/\$program\"; }
4949     $rm \"\$progdir/\$file\"
4950   fi"
4951         else
4952           $echo >> $output "\
4953   program='$outputname'
4954   progdir=\"\$thisdir/$objdir\"
4955 "
4956         fi
4957
4958         $echo >> $output "\
4959
4960   if test -f \"\$progdir/\$program\"; then"
4961
4962         # Export our shlibpath_var if we have one.
4963         if test "$shlibpath_overrides_runpath" = yes && test -n "$shlibpath_var" && test -n "$temp_rpath"; then
4964           $echo >> $output "\
4965     # Add our own library path to $shlibpath_var
4966     $shlibpath_var=\"$temp_rpath\$$shlibpath_var\"
4967
4968     # Some systems cannot cope with colon-terminated $shlibpath_var
4969     # The second colon is a workaround for a bug in BeOS R4 sed
4970     $shlibpath_var=\`\$echo \"X\$$shlibpath_var\" | \$Xsed -e 's/::*\$//'\`
4971
4972     export $shlibpath_var
4973 "
4974         fi
4975
4976         # fixup the dll searchpath if we need to.
4977         if test -n "$dllsearchpath"; then
4978           $echo >> $output "\
4979     # Add the dll search path components to the executable PATH
4980     PATH=$dllsearchpath:\$PATH
4981 "
4982         fi
4983
4984         $echo >> $output "\
4985     if test \"\$libtool_execute_magic\" != \"$magic\"; then
4986       # Run the actual program with our arguments.
4987 "
4988         case $host in
4989         # Backslashes separate directories on plain windows
4990         *-*-mingw | *-*-os2*)
4991           $echo >> $output "\
4992       exec \$progdir\\\\\$program \${1+\"\$@\"}
4993 "
4994           ;;
4995
4996         *)
4997           $echo >> $output "\
4998       exec \$progdir/\$program \${1+\"\$@\"}
4999 "
5000           ;;
5001         esac
5002         $echo >> $output "\
5003       \$echo \"\$0: cannot exec \$program \${1+\"\$@\"}\"
5004       exit $EXIT_FAILURE
5005     fi
5006   else
5007     # The program doesn't exist.
5008     \$echo \"\$0: error: \$progdir/\$program does not exist\" 1>&2
5009     \$echo \"This script is just a wrapper for \$program.\" 1>&2
5010     $echo \"See the $PACKAGE documentation for more information.\" 1>&2
5011     exit $EXIT_FAILURE
5012   fi
5013 fi\
5014 "
5015         chmod +x $output
5016       fi
5017       exit $EXIT_SUCCESS
5018       ;;
5019     esac
5020
5021     # See if we need to build an old-fashioned archive.
5022     for oldlib in $oldlibs; do
5023
5024       if test "$build_libtool_libs" = convenience; then
5025         oldobjs="$libobjs_save"
5026         addlibs="$convenience"
5027         build_libtool_libs=no
5028       else
5029         if test "$build_libtool_libs" = module; then
5030           oldobjs="$libobjs_save"
5031           build_libtool_libs=no
5032         else
5033           oldobjs="$old_deplibs $non_pic_objects"
5034         fi
5035         addlibs="$old_convenience"
5036       fi
5037
5038       if test -n "$addlibs"; then
5039         gentop="$output_objdir/${outputname}x"
5040         generated="$generated $gentop"
5041
5042         func_extract_archives $gentop $addlibs
5043         oldobjs="$oldobjs $func_extract_archives_result"
5044       fi
5045
5046       # Do each command in the archive commands.
5047       if test -n "$old_archive_from_new_cmds" && test "$build_libtool_libs" = yes; then
5048        cmds=$old_archive_from_new_cmds
5049       else
5050         eval cmds=\"$old_archive_cmds\"
5051
5052         if len=`expr "X$cmds" : ".*"` &&
5053              test "$len" -le "$max_cmd_len" || test "$max_cmd_len" -le -1; then
5054           cmds=$old_archive_cmds
5055         else
5056           # the command line is too long to link in one step, link in parts
5057           $echo "using piecewise archive linking..."
5058           save_RANLIB=$RANLIB
5059           RANLIB=:
5060           objlist=
5061           concat_cmds=
5062           save_oldobjs=$oldobjs
5063           # GNU ar 2.10+ was changed to match POSIX; thus no paths are
5064           # encoded into archives.  This makes 'ar r' malfunction in
5065           # this piecewise linking case whenever conflicting object
5066           # names appear in distinct ar calls; check, warn and compensate.
5067             if (for obj in $save_oldobjs
5068             do
5069               $echo "X$obj" | $Xsed -e 's%^.*/%%'
5070             done | sort | sort -uc >/dev/null 2>&1); then
5071             :
5072           else
5073             $echo "$modename: warning: object name conflicts; overriding AR_FLAGS to 'cq'" 1>&2
5074             $echo "$modename: warning: to ensure that POSIX-compatible ar will work" 1>&2
5075             AR_FLAGS=cq
5076           fi
5077           # Is there a better way of finding the last object in the list?
5078           for obj in $save_oldobjs
5079           do
5080             last_oldobj=$obj
5081           done
5082           for obj in $save_oldobjs
5083           do
5084             oldobjs="$objlist $obj"
5085             objlist="$objlist $obj"
5086             eval test_cmds=\"$old_archive_cmds\"
5087             if len=`expr "X$test_cmds" : ".*"` &&
5088                test "$len" -le "$max_cmd_len"; then
5089               :
5090             else
5091               # the above command should be used before it gets too long
5092               oldobjs=$objlist
5093               if test "$obj" = "$last_oldobj" ; then
5094                 RANLIB=$save_RANLIB
5095               fi
5096               test -z "$concat_cmds" || concat_cmds=$concat_cmds~
5097               eval concat_cmds=\"\${concat_cmds}$old_archive_cmds\"
5098               objlist=
5099             fi
5100           done
5101           RANLIB=$save_RANLIB
5102           oldobjs=$objlist
5103           if test "X$oldobjs" = "X" ; then
5104             eval cmds=\"\$concat_cmds\"
5105           else
5106             eval cmds=\"\$concat_cmds~\$old_archive_cmds\"
5107           fi
5108         fi
5109       fi
5110       save_ifs="$IFS"; IFS='~'
5111       for cmd in $cmds; do
5112         eval cmd=\"$cmd\"
5113         IFS="$save_ifs"
5114         $show "$cmd"
5115         $run eval "$cmd" || exit $?
5116       done
5117       IFS="$save_ifs"
5118     done
5119
5120     if test -n "$generated"; then
5121       $show "${rm}r$generated"
5122       $run ${rm}r$generated
5123     fi
5124
5125     # Now create the libtool archive.
5126     case $output in
5127     *.la)
5128       old_library=
5129       test "$build_old_libs" = yes && old_library="$libname.$libext"
5130       $show "creating $output"
5131
5132       # Preserve any variables that may affect compiler behavior
5133       for var in $variables_saved_for_relink; do
5134         if eval test -z \"\${$var+set}\"; then
5135           relink_command="{ test -z \"\${$var+set}\" || unset $var || { $var=; export $var; }; }; $relink_command"
5136         elif eval var_value=\$$var; test -z "$var_value"; then
5137           relink_command="$var=; export $var; $relink_command"
5138         else
5139           var_value=`$echo "X$var_value" | $Xsed -e "$sed_quote_subst"`
5140           relink_command="$var=\"$var_value\"; export $var; $relink_command"
5141         fi
5142       done
5143       # Quote the link command for shipping.
5144       relink_command="(cd `pwd`; $SHELL $progpath $preserve_args --mode=relink $libtool_args @inst_prefix_dir@)"
5145       relink_command=`$echo "X$relink_command" | $Xsed -e "$sed_quote_subst"`
5146       if test "$hardcode_automatic" = yes ; then
5147         relink_command=
5148       fi
5149
5150
5151       # Only create the output if not a dry run.
5152       if test -z "$run"; then
5153         for installed in no yes; do
5154           if test "$installed" = yes; then
5155             if test -z "$install_libdir"; then
5156               break
5157             fi
5158             output="$output_objdir/$outputname"i
5159             # Replace all uninstalled libtool libraries with the installed ones
5160             newdependency_libs=
5161             for deplib in $dependency_libs; do
5162               case $deplib in
5163               *.la)
5164                 name=`$echo "X$deplib" | $Xsed -e 's%^.*/%%'`
5165                 eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $deplib`
5166                 if test -z "$libdir"; then
5167                   $echo "$modename: \`$deplib' is not a valid libtool archive" 1>&2
5168                   exit $EXIT_FAILURE
5169                 fi
5170                 newdependency_libs="$newdependency_libs $libdir/$name"
5171                 ;;
5172               *) newdependency_libs="$newdependency_libs $deplib" ;;
5173               esac
5174             done
5175             dependency_libs="$newdependency_libs"
5176             newdlfiles=
5177             for lib in $dlfiles; do
5178               name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5179               eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5180               if test -z "$libdir"; then
5181                 $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5182                 exit $EXIT_FAILURE
5183               fi
5184               newdlfiles="$newdlfiles $libdir/$name"
5185             done
5186             dlfiles="$newdlfiles"
5187             newdlprefiles=
5188             for lib in $dlprefiles; do
5189               name=`$echo "X$lib" | $Xsed -e 's%^.*/%%'`
5190               eval libdir=`${SED} -n -e 's/^libdir=\(.*\)$/\1/p' $lib`
5191               if test -z "$libdir"; then
5192                 $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5193                 exit $EXIT_FAILURE
5194               fi
5195               newdlprefiles="$newdlprefiles $libdir/$name"
5196             done
5197             dlprefiles="$newdlprefiles"
5198           else
5199             newdlfiles=
5200             for lib in $dlfiles; do
5201               case $lib in
5202                 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5203                 *) abs=`pwd`"/$lib" ;;
5204               esac
5205               newdlfiles="$newdlfiles $abs"
5206             done
5207             dlfiles="$newdlfiles"
5208             newdlprefiles=
5209             for lib in $dlprefiles; do
5210               case $lib in
5211                 [\\/]* | [A-Za-z]:[\\/]*) abs="$lib" ;;
5212                 *) abs=`pwd`"/$lib" ;;
5213               esac
5214               newdlprefiles="$newdlprefiles $abs"
5215             done
5216             dlprefiles="$newdlprefiles"
5217           fi
5218           $rm $output
5219           # place dlname in correct position for cygwin
5220           tdlname=$dlname
5221           case $host,$output,$installed,$module,$dlname in
5222             *cygwin*,*lai,yes,no,*.dll | *mingw*,*lai,yes,no,*.dll) tdlname=../bin/$dlname ;;
5223           esac
5224           $echo > $output "\
5225 # $outputname - a libtool library file
5226 # Generated by $PROGRAM - GNU $PACKAGE $VERSION$TIMESTAMP
5227 #
5228 # Please DO NOT delete this file!
5229 # It is necessary for linking the library.
5230
5231 # The name that we can dlopen(3).
5232 dlname='$tdlname'
5233
5234 # Names of this library.
5235 library_names='$library_names'
5236
5237 # The name of the static archive.
5238 old_library='$old_library'
5239
5240 # Libraries that this one depends upon.
5241 dependency_libs='$dependency_libs'
5242
5243 # Version information for $libname.
5244 current=$current
5245 age=$age
5246 revision=$revision
5247
5248 # Is this an already installed library?
5249 installed=$installed
5250
5251 # Should we warn about portability when linking against -modules?
5252 shouldnotlink=$module
5253
5254 # Files to dlopen/dlpreopen
5255 dlopen='$dlfiles'
5256 dlpreopen='$dlprefiles'
5257
5258 # Directory that this library needs to be installed in:
5259 libdir='$install_libdir'"
5260           if test "$installed" = no && test "$need_relink" = yes; then
5261             $echo >> $output "\
5262 relink_command=\"$relink_command\""
5263           fi
5264         done
5265       fi
5266
5267       # Do a symbolic link so that the libtool archive can be found in
5268       # LD_LIBRARY_PATH before the program is installed.
5269       $show "(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)"
5270       $run eval '(cd $output_objdir && $rm $outputname && $LN_S ../$outputname $outputname)' || exit $?
5271       ;;
5272     esac
5273     exit $EXIT_SUCCESS
5274     ;;
5275
5276   # libtool install mode
5277   install)
5278     modename="$modename: install"
5279
5280     # There may be an optional sh(1) argument at the beginning of
5281     # install_prog (especially on Windows NT).
5282     if test "$nonopt" = "$SHELL" || test "$nonopt" = /bin/sh ||
5283        # Allow the use of GNU shtool's install command.
5284        $echo "X$nonopt" | $Xsed | grep shtool > /dev/null; then
5285       # Aesthetically quote it.
5286       arg=`$echo "X$nonopt" | $Xsed -e "$sed_quote_subst"`
5287       case $arg in
5288       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*)
5289         arg="\"$arg\""
5290         ;;
5291       esac
5292       install_prog="$arg "
5293       arg="$1"
5294       shift
5295     else
5296       install_prog=
5297       arg="$nonopt"
5298     fi
5299
5300     # The real first argument should be the name of the installation program.
5301     # Aesthetically quote it.
5302     arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5303     case $arg in
5304     *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \       ]*|*]*)
5305       arg="\"$arg\""
5306       ;;
5307     esac
5308     install_prog="$install_prog$arg"
5309
5310     # We need to accept at least all the BSD install flags.
5311     dest=
5312     files=
5313     opts=
5314     prev=
5315     install_type=
5316     isdir=no
5317     stripme=
5318     for arg
5319     do
5320       if test -n "$dest"; then
5321         files="$files $dest"
5322         dest="$arg"
5323         continue
5324       fi
5325
5326       case $arg in
5327       -d) isdir=yes ;;
5328       -f) prev="-f" ;;
5329       -g) prev="-g" ;;
5330       -m) prev="-m" ;;
5331       -o) prev="-o" ;;
5332       -s)
5333         stripme=" -s"
5334         continue
5335         ;;
5336       -*) ;;
5337
5338       *)
5339         # If the previous option needed an argument, then skip it.
5340         if test -n "$prev"; then
5341           prev=
5342         else
5343           dest="$arg"
5344           continue
5345         fi
5346         ;;
5347       esac
5348
5349       # Aesthetically quote the argument.
5350       arg=`$echo "X$arg" | $Xsed -e "$sed_quote_subst"`
5351       case $arg in
5352       *[\[\~\#\^\&\*\(\)\{\}\|\;\<\>\?\'\ \     ]*|*]*)
5353         arg="\"$arg\""
5354         ;;
5355       esac
5356       install_prog="$install_prog $arg"
5357     done
5358
5359     if test -z "$install_prog"; then
5360       $echo "$modename: you must specify an install program" 1>&2
5361       $echo "$help" 1>&2
5362       exit $EXIT_FAILURE
5363     fi
5364
5365     if test -n "$prev"; then
5366       $echo "$modename: the \`$prev' option requires an argument" 1>&2
5367       $echo "$help" 1>&2
5368       exit $EXIT_FAILURE
5369     fi
5370
5371     if test -z "$files"; then
5372       if test -z "$dest"; then
5373         $echo "$modename: no file or destination specified" 1>&2
5374       else
5375         $echo "$modename: you must specify a destination" 1>&2
5376       fi
5377       $echo "$help" 1>&2
5378       exit $EXIT_FAILURE
5379     fi
5380
5381     # Strip any trailing slash from the destination.
5382     dest=`$echo "X$dest" | $Xsed -e 's%/$%%'`
5383
5384     # Check to see that the destination is a directory.
5385     test -d "$dest" && isdir=yes
5386     if test "$isdir" = yes; then
5387       destdir="$dest"
5388       destname=
5389     else
5390       destdir=`$echo "X$dest" | $Xsed -e 's%/[^/]*$%%'`
5391       test "X$destdir" = "X$dest" && destdir=.
5392       destname=`$echo "X$dest" | $Xsed -e 's%^.*/%%'`
5393
5394       # Not a directory, so check to see that there is only one file specified.
5395       set dummy $files
5396       if test "$#" -gt 2; then
5397         $echo "$modename: \`$dest' is not a directory" 1>&2
5398         $echo "$help" 1>&2
5399         exit $EXIT_FAILURE
5400       fi
5401     fi
5402     case $destdir in
5403     [\\/]* | [A-Za-z]:[\\/]*) ;;
5404     *)
5405       for file in $files; do
5406         case $file in
5407         *.lo) ;;
5408         *)
5409           $echo "$modename: \`$destdir' must be an absolute directory name" 1>&2
5410           $echo "$help" 1>&2
5411           exit $EXIT_FAILURE
5412           ;;
5413         esac
5414       done
5415       ;;
5416     esac
5417
5418     # This variable tells wrapper scripts just to set variables rather
5419     # than running their programs.
5420     libtool_install_magic="$magic"
5421
5422     staticlibs=
5423     future_libdirs=
5424     current_libdirs=
5425     for file in $files; do
5426
5427       # Do each installation.
5428       case $file in
5429       *.$libext)
5430         # Do the static libraries later.
5431         staticlibs="$staticlibs $file"
5432         ;;
5433
5434       *.la)
5435         # Check to see that this really is a libtool archive.
5436         if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
5437         else
5438           $echo "$modename: \`$file' is not a valid libtool archive" 1>&2
5439           $echo "$help" 1>&2
5440           exit $EXIT_FAILURE
5441         fi
5442
5443         library_names=
5444         old_library=
5445         relink_command=
5446         # If there is no directory component, then add one.
5447         case $file in
5448         */* | *\\*) . $file ;;
5449         *) . ./$file ;;
5450         esac
5451
5452         # Add the libdir to current_libdirs if it is the destination.
5453         if test "X$destdir" = "X$libdir"; then
5454           case "$current_libdirs " in
5455           *" $libdir "*) ;;
5456           *) current_libdirs="$current_libdirs $libdir" ;;
5457           esac
5458         else
5459           # Note the libdir as a future libdir.
5460           case "$future_libdirs " in
5461           *" $libdir "*) ;;
5462           *) future_libdirs="$future_libdirs $libdir" ;;
5463           esac
5464         fi
5465
5466         dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`/
5467         test "X$dir" = "X$file/" && dir=
5468         dir="$dir$objdir"
5469
5470         if test -n "$relink_command"; then
5471           # Determine the prefix the user has applied to our future dir.
5472           inst_prefix_dir=`$echo "$destdir" | $SED "s%$libdir\$%%"`
5473
5474           # Don't allow the user to place us outside of our expected
5475           # location b/c this prevents finding dependent libraries that
5476           # are installed to the same prefix.
5477           # At present, this check doesn't affect windows .dll's that
5478           # are installed into $libdir/../bin (currently, that works fine)
5479           # but it's something to keep an eye on.
5480           if test "$inst_prefix_dir" = "$destdir"; then
5481             $echo "$modename: error: cannot install \`$file' to a directory not ending in $libdir" 1>&2
5482             exit $EXIT_FAILURE
5483           fi
5484
5485           if test -n "$inst_prefix_dir"; then
5486             # Stick the inst_prefix_dir data into the link command.
5487             relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%-inst-prefix-dir $inst_prefix_dir%"`
5488           else
5489             relink_command=`$echo "$relink_command" | $SED "s%@inst_prefix_dir@%%"`
5490           fi
5491
5492           $echo "$modename: warning: relinking \`$file'" 1>&2
5493           $show "$relink_command"
5494           if $run eval "$relink_command"; then :
5495           else
5496             $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
5497             exit $EXIT_FAILURE
5498           fi
5499         fi
5500
5501         # See the names of the shared library.
5502         set dummy $library_names
5503         if test -n "$2"; then
5504           realname="$2"
5505           shift
5506           shift
5507
5508           srcname="$realname"
5509           test -n "$relink_command" && srcname="$realname"T
5510
5511           # Install the shared library and build the symlinks.
5512           $show "$install_prog $dir/$srcname $destdir/$realname"
5513           $run eval "$install_prog $dir/$srcname $destdir/$realname" || exit $?
5514           if test -n "$stripme" && test -n "$striplib"; then
5515             $show "$striplib $destdir/$realname"
5516             $run eval "$striplib $destdir/$realname" || exit $?
5517           fi
5518
5519           if test "$#" -gt 0; then
5520             # Delete the old symlinks, and create new ones.
5521             for linkname
5522             do
5523               if test "$linkname" != "$realname"; then
5524                 $show "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
5525                 $run eval "(cd $destdir && $rm $linkname && $LN_S $realname $linkname)"
5526               fi
5527             done
5528           fi
5529
5530           # Do each command in the postinstall commands.
5531           lib="$destdir/$realname"
5532           cmds=$postinstall_cmds
5533           save_ifs="$IFS"; IFS='~'
5534           for cmd in $cmds; do
5535             IFS="$save_ifs"
5536             eval cmd=\"$cmd\"
5537             $show "$cmd"
5538             $run eval "$cmd" || exit $?
5539           done
5540           IFS="$save_ifs"
5541         fi
5542
5543         # Install the pseudo-library for information purposes.
5544         name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
5545         instname="$dir/$name"i
5546         $show "$install_prog $instname $destdir/$name"
5547         $run eval "$install_prog $instname $destdir/$name" || exit $?
5548
5549         # Maybe install the static library, too.
5550         test -n "$old_library" && staticlibs="$staticlibs $dir/$old_library"
5551         ;;
5552
5553       *.lo)
5554         # Install (i.e. copy) a libtool object.
5555
5556         # Figure out destination file name, if it wasn't already specified.
5557         if test -n "$destname"; then
5558           destfile="$destdir/$destname"
5559         else
5560           destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
5561           destfile="$destdir/$destfile"
5562         fi
5563
5564         # Deduce the name of the destination old-style object file.
5565         case $destfile in
5566         *.lo)
5567           staticdest=`$echo "X$destfile" | $Xsed -e "$lo2o"`
5568           ;;
5569         *.$objext)
5570           staticdest="$destfile"
5571           destfile=
5572           ;;
5573         *)
5574           $echo "$modename: cannot copy a libtool object to \`$destfile'" 1>&2
5575           $echo "$help" 1>&2
5576           exit $EXIT_FAILURE
5577           ;;
5578         esac
5579
5580         # Install the libtool object if requested.
5581         if test -n "$destfile"; then
5582           $show "$install_prog $file $destfile"
5583           $run eval "$install_prog $file $destfile" || exit $?
5584         fi
5585
5586         # Install the old object if enabled.
5587         if test "$build_old_libs" = yes; then
5588           # Deduce the name of the old-style object file.
5589           staticobj=`$echo "X$file" | $Xsed -e "$lo2o"`
5590
5591           $show "$install_prog $staticobj $staticdest"
5592           $run eval "$install_prog \$staticobj \$staticdest" || exit $?
5593         fi
5594         exit $EXIT_SUCCESS
5595         ;;
5596
5597       *)
5598         # Figure out destination file name, if it wasn't already specified.
5599         if test -n "$destname"; then
5600           destfile="$destdir/$destname"
5601         else
5602           destfile=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
5603           destfile="$destdir/$destfile"
5604         fi
5605
5606         # If the file is missing, and there is a .exe on the end, strip it
5607         # because it is most likely a libtool script we actually want to
5608         # install
5609         stripped_ext=""
5610         case $file in
5611           *.exe)
5612             if test ! -f "$file"; then
5613               file=`$echo $file|${SED} 's,.exe$,,'`
5614               stripped_ext=".exe"
5615             fi
5616             ;;
5617         esac
5618
5619         # Do a test to see if this is really a libtool program.
5620         case $host in
5621         *cygwin*|*mingw*)
5622             wrapper=`$echo $file | ${SED} -e 's,.exe$,,'`
5623             ;;
5624         *)
5625             wrapper=$file
5626             ;;
5627         esac
5628         if (${SED} -e '4q' $wrapper | grep "^# Generated by .*$PACKAGE")>/dev/null 2>&1; then
5629           notinst_deplibs=
5630           relink_command=
5631
5632           # To insure that "foo" is sourced, and not "foo.exe",
5633           # finese the cygwin/MSYS system by explicitly sourcing "foo."
5634           # which disallows the automatic-append-.exe behavior.
5635           case $build in
5636           *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
5637           *) wrapperdot=${wrapper} ;;
5638           esac
5639           # If there is no directory component, then add one.
5640           case $file in
5641           */* | *\\*) . ${wrapperdot} ;;
5642           *) . ./${wrapperdot} ;;
5643           esac
5644
5645           # Check the variables that should have been set.
5646           if test -z "$notinst_deplibs"; then
5647             $echo "$modename: invalid libtool wrapper script \`$wrapper'" 1>&2
5648             exit $EXIT_FAILURE
5649           fi
5650
5651           finalize=yes
5652           for lib in $notinst_deplibs; do
5653             # Check to see that each library is installed.
5654             libdir=
5655             if test -f "$lib"; then
5656               # If there is no directory component, then add one.
5657               case $lib in
5658               */* | *\\*) . $lib ;;
5659               *) . ./$lib ;;
5660               esac
5661             fi
5662             libfile="$libdir/"`$echo "X$lib" | $Xsed -e 's%^.*/%%g'` ### testsuite: skip nested quoting test
5663             if test -n "$libdir" && test ! -f "$libfile"; then
5664               $echo "$modename: warning: \`$lib' has not been installed in \`$libdir'" 1>&2
5665               finalize=no
5666             fi
5667           done
5668
5669           relink_command=
5670           # To insure that "foo" is sourced, and not "foo.exe",
5671           # finese the cygwin/MSYS system by explicitly sourcing "foo."
5672           # which disallows the automatic-append-.exe behavior.
5673           case $build in
5674           *cygwin* | *mingw*) wrapperdot=${wrapper}. ;;
5675           *) wrapperdot=${wrapper} ;;
5676           esac
5677           # If there is no directory component, then add one.
5678           case $file in
5679           */* | *\\*) . ${wrapperdot} ;;
5680           *) . ./${wrapperdot} ;;
5681           esac
5682
5683           outputname=
5684           if test "$fast_install" = no && test -n "$relink_command"; then
5685             if test "$finalize" = yes && test -z "$run"; then
5686               tmpdir="/tmp"
5687               test -n "$TMPDIR" && tmpdir="$TMPDIR"
5688               tmpdir="$tmpdir/libtool-$$"
5689               save_umask=`umask`
5690               umask 0077
5691               if $mkdir "$tmpdir"; then
5692                 umask $save_umask
5693               else
5694                 umask $save_umask
5695                 $echo "$modename: error: cannot create temporary directory \`$tmpdir'" 1>&2
5696                 continue
5697               fi
5698               file=`$echo "X$file$stripped_ext" | $Xsed -e 's%^.*/%%'`
5699               outputname="$tmpdir/$file"
5700               # Replace the output file specification.
5701               relink_command=`$echo "X$relink_command" | $Xsed -e 's%@OUTPUT@%'"$outputname"'%g'`
5702
5703               $show "$relink_command"
5704               if $run eval "$relink_command"; then :
5705               else
5706                 $echo "$modename: error: relink \`$file' with the above command before installing it" 1>&2
5707                 ${rm}r "$tmpdir"
5708                 continue
5709               fi
5710               file="$outputname"
5711             else
5712               $echo "$modename: warning: cannot relink \`$file'" 1>&2
5713             fi
5714           else
5715             # Install the binary that we compiled earlier.
5716             file=`$echo "X$file$stripped_ext" | $Xsed -e "s%\([^/]*\)$%$objdir/\1%"`
5717           fi
5718         fi
5719
5720         # remove .exe since cygwin /usr/bin/install will append another
5721         # one anyways
5722         case $install_prog,$host in
5723         */usr/bin/install*,*cygwin*)
5724           case $file:$destfile in
5725           *.exe:*.exe)
5726             # this is ok
5727             ;;
5728           *.exe:*)
5729             destfile=$destfile.exe
5730             ;;
5731           *:*.exe)
5732             destfile=`$echo $destfile | ${SED} -e 's,.exe$,,'`
5733             ;;
5734           esac
5735           ;;
5736         esac
5737         $show "$install_prog$stripme $file $destfile"
5738         $run eval "$install_prog\$stripme \$file \$destfile" || exit $?
5739         test -n "$outputname" && ${rm}r "$tmpdir"
5740         ;;
5741       esac
5742     done
5743
5744     for file in $staticlibs; do
5745       name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
5746
5747       # Set up the ranlib parameters.
5748       oldlib="$destdir/$name"
5749
5750       $show "$install_prog $file $oldlib"
5751       $run eval "$install_prog \$file \$oldlib" || exit $?
5752
5753       if test -n "$stripme" && test -n "$old_striplib"; then
5754         $show "$old_striplib $oldlib"
5755         $run eval "$old_striplib $oldlib" || exit $?
5756       fi
5757
5758       # Do each command in the postinstall commands.
5759       cmds=$old_postinstall_cmds
5760       save_ifs="$IFS"; IFS='~'
5761       for cmd in $cmds; do
5762         IFS="$save_ifs"
5763         eval cmd=\"$cmd\"
5764         $show "$cmd"
5765         $run eval "$cmd" || exit $?
5766       done
5767       IFS="$save_ifs"
5768     done
5769
5770     if test -n "$future_libdirs"; then
5771       $echo "$modename: warning: remember to run \`$progname --finish$future_libdirs'" 1>&2
5772     fi
5773
5774     if test -n "$current_libdirs"; then
5775       # Maybe just do a dry run.
5776       test -n "$run" && current_libdirs=" -n$current_libdirs"
5777       exec_cmd='$SHELL $progpath $preserve_args --finish$current_libdirs'
5778     else
5779       exit $EXIT_SUCCESS
5780     fi
5781     ;;
5782
5783   # libtool finish mode
5784   finish)
5785     modename="$modename: finish"
5786     libdirs="$nonopt"
5787     admincmds=
5788
5789     if test -n "$finish_cmds$finish_eval" && test -n "$libdirs"; then
5790       for dir
5791       do
5792         libdirs="$libdirs $dir"
5793       done
5794
5795       for libdir in $libdirs; do
5796         if test -n "$finish_cmds"; then
5797           # Do each command in the finish commands.
5798           cmds=$finish_cmds
5799           save_ifs="$IFS"; IFS='~'
5800           for cmd in $cmds; do
5801             IFS="$save_ifs"
5802             eval cmd=\"$cmd\"
5803             $show "$cmd"
5804             $run eval "$cmd" || admincmds="$admincmds
5805        $cmd"
5806           done
5807           IFS="$save_ifs"
5808         fi
5809         if test -n "$finish_eval"; then
5810           # Do the single finish_eval.
5811           eval cmds=\"$finish_eval\"
5812           $run eval "$cmds" || admincmds="$admincmds
5813        $cmds"
5814         fi
5815       done
5816     fi
5817
5818     # Exit here if they wanted silent mode.
5819     test "$show" = : && exit $EXIT_SUCCESS
5820
5821     $echo "----------------------------------------------------------------------"
5822     $echo "Libraries have been installed in:"
5823     for libdir in $libdirs; do
5824       $echo "   $libdir"
5825     done
5826     $echo
5827     $echo "If you ever happen to want to link against installed libraries"
5828     $echo "in a given directory, LIBDIR, you must either use libtool, and"
5829     $echo "specify the full pathname of the library, or use the \`-LLIBDIR'"
5830     $echo "flag during linking and do at least one of the following:"
5831     if test -n "$shlibpath_var"; then
5832       $echo "   - add LIBDIR to the \`$shlibpath_var' environment variable"
5833       $echo "     during execution"
5834     fi
5835     if test -n "$runpath_var"; then
5836       $echo "   - add LIBDIR to the \`$runpath_var' environment variable"
5837       $echo "     during linking"
5838     fi
5839     if test -n "$hardcode_libdir_flag_spec"; then
5840       libdir=LIBDIR
5841       eval flag=\"$hardcode_libdir_flag_spec\"
5842
5843       $echo "   - use the \`$flag' linker flag"
5844     fi
5845     if test -n "$admincmds"; then
5846       $echo "   - have your system administrator run these commands:$admincmds"
5847     fi
5848     if test -f /etc/ld.so.conf; then
5849       $echo "   - have your system administrator add LIBDIR to \`/etc/ld.so.conf'"
5850     fi
5851     $echo
5852     $echo "See any operating system documentation about shared libraries for"
5853     $echo "more information, such as the ld(1) and ld.so(8) manual pages."
5854     $echo "----------------------------------------------------------------------"
5855     exit $EXIT_SUCCESS
5856     ;;
5857
5858   # libtool execute mode
5859   execute)
5860     modename="$modename: execute"
5861
5862     # The first argument is the command name.
5863     cmd="$nonopt"
5864     if test -z "$cmd"; then
5865       $echo "$modename: you must specify a COMMAND" 1>&2
5866       $echo "$help"
5867       exit $EXIT_FAILURE
5868     fi
5869
5870     # Handle -dlopen flags immediately.
5871     for file in $execute_dlfiles; do
5872       if test ! -f "$file"; then
5873         $echo "$modename: \`$file' is not a file" 1>&2
5874         $echo "$help" 1>&2
5875         exit $EXIT_FAILURE
5876       fi
5877
5878       dir=
5879       case $file in
5880       *.la)
5881         # Check to see that this really is a libtool archive.
5882         if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then :
5883         else
5884           $echo "$modename: \`$lib' is not a valid libtool archive" 1>&2
5885           $echo "$help" 1>&2
5886           exit $EXIT_FAILURE
5887         fi
5888
5889         # Read the libtool library.
5890         dlname=
5891         library_names=
5892
5893         # If there is no directory component, then add one.
5894         case $file in
5895         */* | *\\*) . $file ;;
5896         *) . ./$file ;;
5897         esac
5898
5899         # Skip this library if it cannot be dlopened.
5900         if test -z "$dlname"; then
5901           # Warn if it was a shared library.
5902           test -n "$library_names" && $echo "$modename: warning: \`$file' was not linked with \`-export-dynamic'"
5903           continue
5904         fi
5905
5906         dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
5907         test "X$dir" = "X$file" && dir=.
5908
5909         if test -f "$dir/$objdir/$dlname"; then
5910           dir="$dir/$objdir"
5911         else
5912           $echo "$modename: cannot find \`$dlname' in \`$dir' or \`$dir/$objdir'" 1>&2
5913           exit $EXIT_FAILURE
5914         fi
5915         ;;
5916
5917       *.lo)
5918         # Just add the directory containing the .lo file.
5919         dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
5920         test "X$dir" = "X$file" && dir=.
5921         ;;
5922
5923       *)
5924         $echo "$modename: warning \`-dlopen' is ignored for non-libtool libraries and objects" 1>&2
5925         continue
5926         ;;
5927       esac
5928
5929       # Get the absolute pathname.
5930       absdir=`cd "$dir" && pwd`
5931       test -n "$absdir" && dir="$absdir"
5932
5933       # Now add the directory to shlibpath_var.
5934       if eval "test -z \"\$$shlibpath_var\""; then
5935         eval "$shlibpath_var=\"\$dir\""
5936       else
5937         eval "$shlibpath_var=\"\$dir:\$$shlibpath_var\""
5938       fi
5939     done
5940
5941     # This variable tells wrapper scripts just to set shlibpath_var
5942     # rather than running their programs.
5943     libtool_execute_magic="$magic"
5944
5945     # Check if any of the arguments is a wrapper script.
5946     args=
5947     for file
5948     do
5949       case $file in
5950       -*) ;;
5951       *)
5952         # Do a test to see if this is really a libtool program.
5953         if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
5954           # If there is no directory component, then add one.
5955           case $file in
5956           */* | *\\*) . $file ;;
5957           *) . ./$file ;;
5958           esac
5959
5960           # Transform arg to wrapped name.
5961           file="$progdir/$program"
5962         fi
5963         ;;
5964       esac
5965       # Quote arguments (to preserve shell metacharacters).
5966       file=`$echo "X$file" | $Xsed -e "$sed_quote_subst"`
5967       args="$args \"$file\""
5968     done
5969
5970     if test -z "$run"; then
5971       if test -n "$shlibpath_var"; then
5972         # Export the shlibpath_var.
5973         eval "export $shlibpath_var"
5974       fi
5975
5976       # Restore saved environment variables
5977       if test "${save_LC_ALL+set}" = set; then
5978         LC_ALL="$save_LC_ALL"; export LC_ALL
5979       fi
5980       if test "${save_LANG+set}" = set; then
5981         LANG="$save_LANG"; export LANG
5982       fi
5983
5984       # Now prepare to actually exec the command.
5985       exec_cmd="\$cmd$args"
5986     else
5987       # Display what would be done.
5988       if test -n "$shlibpath_var"; then
5989         eval "\$echo \"\$shlibpath_var=\$$shlibpath_var\""
5990         $echo "export $shlibpath_var"
5991       fi
5992       $echo "$cmd$args"
5993       exit $EXIT_SUCCESS
5994     fi
5995     ;;
5996
5997   # libtool clean and uninstall mode
5998   clean | uninstall)
5999     modename="$modename: $mode"
6000     rm="$nonopt"
6001     files=
6002     rmforce=
6003     exit_status=0
6004
6005     # This variable tells wrapper scripts just to set variables rather
6006     # than running their programs.
6007     libtool_install_magic="$magic"
6008
6009     for arg
6010     do
6011       case $arg in
6012       -f) rm="$rm $arg"; rmforce=yes ;;
6013       -*) rm="$rm $arg" ;;
6014       *) files="$files $arg" ;;
6015       esac
6016     done
6017
6018     if test -z "$rm"; then
6019       $echo "$modename: you must specify an RM program" 1>&2
6020       $echo "$help" 1>&2
6021       exit $EXIT_FAILURE
6022     fi
6023
6024     rmdirs=
6025
6026     origobjdir="$objdir"
6027     for file in $files; do
6028       dir=`$echo "X$file" | $Xsed -e 's%/[^/]*$%%'`
6029       if test "X$dir" = "X$file"; then
6030         dir=.
6031         objdir="$origobjdir"
6032       else
6033         objdir="$dir/$origobjdir"
6034       fi
6035       name=`$echo "X$file" | $Xsed -e 's%^.*/%%'`
6036       test "$mode" = uninstall && objdir="$dir"
6037
6038       # Remember objdir for removal later, being careful to avoid duplicates
6039       if test "$mode" = clean; then
6040         case " $rmdirs " in
6041           *" $objdir "*) ;;
6042           *) rmdirs="$rmdirs $objdir" ;;
6043         esac
6044       fi
6045
6046       # Don't error if the file doesn't exist and rm -f was used.
6047       if (test -L "$file") >/dev/null 2>&1 \
6048         || (test -h "$file") >/dev/null 2>&1 \
6049         || test -f "$file"; then
6050         :
6051       elif test -d "$file"; then
6052         exit_status=1
6053         continue
6054       elif test "$rmforce" = yes; then
6055         continue
6056       fi
6057
6058       rmfiles="$file"
6059
6060       case $name in
6061       *.la)
6062         # Possibly a libtool archive, so verify it.
6063         if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6064           . $dir/$name
6065
6066           # Delete the libtool libraries and symlinks.
6067           for n in $library_names; do
6068             rmfiles="$rmfiles $objdir/$n"
6069           done
6070           test -n "$old_library" && rmfiles="$rmfiles $objdir/$old_library"
6071           test "$mode" = clean && rmfiles="$rmfiles $objdir/$name $objdir/${name}i"
6072
6073           if test "$mode" = uninstall; then
6074             if test -n "$library_names"; then
6075               # Do each command in the postuninstall commands.
6076               cmds=$postuninstall_cmds
6077               save_ifs="$IFS"; IFS='~'
6078               for cmd in $cmds; do
6079                 IFS="$save_ifs"
6080                 eval cmd=\"$cmd\"
6081                 $show "$cmd"
6082                 $run eval "$cmd"
6083                 if test "$?" -ne 0 && test "$rmforce" != yes; then
6084                   exit_status=1
6085                 fi
6086               done
6087               IFS="$save_ifs"
6088             fi
6089
6090             if test -n "$old_library"; then
6091               # Do each command in the old_postuninstall commands.
6092               cmds=$old_postuninstall_cmds
6093               save_ifs="$IFS"; IFS='~'
6094               for cmd in $cmds; do
6095                 IFS="$save_ifs"
6096                 eval cmd=\"$cmd\"
6097                 $show "$cmd"
6098                 $run eval "$cmd"
6099                 if test "$?" -ne 0 && test "$rmforce" != yes; then
6100                   exit_status=1
6101                 fi
6102               done
6103               IFS="$save_ifs"
6104             fi
6105             # FIXME: should reinstall the best remaining shared library.
6106           fi
6107         fi
6108         ;;
6109
6110       *.lo)
6111         # Possibly a libtool object, so verify it.
6112         if (${SED} -e '2q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6113
6114           # Read the .lo file
6115           . $dir/$name
6116
6117           # Add PIC object to the list of files to remove.
6118           if test -n "$pic_object" \
6119              && test "$pic_object" != none; then
6120             rmfiles="$rmfiles $dir/$pic_object"
6121           fi
6122
6123           # Add non-PIC object to the list of files to remove.
6124           if test -n "$non_pic_object" \
6125              && test "$non_pic_object" != none; then
6126             rmfiles="$rmfiles $dir/$non_pic_object"
6127           fi
6128         fi
6129         ;;
6130
6131       *)
6132         if test "$mode" = clean ; then
6133           noexename=$name
6134           case $file in
6135           *.exe)
6136             file=`$echo $file|${SED} 's,.exe$,,'`
6137             noexename=`$echo $name|${SED} 's,.exe$,,'`
6138             # $file with .exe has already been added to rmfiles,
6139             # add $file without .exe
6140             rmfiles="$rmfiles $file"
6141             ;;
6142           esac
6143           # Do a test to see if this is a libtool program.
6144           if (${SED} -e '4q' $file | grep "^# Generated by .*$PACKAGE") >/dev/null 2>&1; then
6145             relink_command=
6146             . $dir/$noexename
6147
6148             # note $name still contains .exe if it was in $file originally
6149             # as does the version of $file that was added into $rmfiles
6150             rmfiles="$rmfiles $objdir/$name $objdir/${name}S.${objext}"
6151             if test "$fast_install" = yes && test -n "$relink_command"; then
6152               rmfiles="$rmfiles $objdir/lt-$name"
6153             fi
6154             if test "X$noexename" != "X$name" ; then
6155               rmfiles="$rmfiles $objdir/lt-${noexename}.c"
6156             fi
6157           fi
6158         fi
6159         ;;
6160       esac
6161       $show "$rm $rmfiles"
6162       $run $rm $rmfiles || exit_status=1
6163     done
6164     objdir="$origobjdir"
6165
6166     # Try to remove the ${objdir}s in the directories where we deleted files
6167     for dir in $rmdirs; do
6168       if test -d "$dir"; then
6169         $show "rmdir $dir"
6170         $run rmdir $dir >/dev/null 2>&1
6171       fi
6172     done
6173
6174     exit $exit_status
6175     ;;
6176
6177   "")
6178     $echo "$modename: you must specify a MODE" 1>&2
6179     $echo "$generic_help" 1>&2
6180     exit $EXIT_FAILURE
6181     ;;
6182   esac
6183
6184   if test -z "$exec_cmd"; then
6185     $echo "$modename: invalid operation mode \`$mode'" 1>&2
6186     $echo "$generic_help" 1>&2
6187     exit $EXIT_FAILURE
6188   fi
6189 fi # test -z "$show_help"
6190
6191 if test -n "$exec_cmd"; then
6192   eval exec $exec_cmd
6193   exit $EXIT_FAILURE
6194 fi
6195
6196 # We need to display help for each of the modes.
6197 case $mode in
6198 "") $echo \
6199 "Usage: $modename [OPTION]... [MODE-ARG]...
6200
6201 Provide generalized library-building support services.
6202
6203     --config          show all configuration variables
6204     --debug           enable verbose shell tracing
6205 -n, --dry-run         display commands without modifying any files
6206     --features        display basic configuration information and exit
6207     --finish          same as \`--mode=finish'
6208     --help            display this help message and exit
6209     --mode=MODE       use operation mode MODE [default=inferred from MODE-ARGS]
6210     --quiet           same as \`--silent'
6211     --silent          don't print informational messages
6212     --tag=TAG         use configuration variables from tag TAG
6213     --version         print version information
6214
6215 MODE must be one of the following:
6216
6217       clean           remove files from the build directory
6218       compile         compile a source file into a libtool object
6219       execute         automatically set library path, then run a program
6220       finish          complete the installation of libtool libraries
6221       install         install libraries or executables
6222       link            create a library or an executable
6223       uninstall       remove libraries from an installed directory
6224
6225 MODE-ARGS vary depending on the MODE.  Try \`$modename --help --mode=MODE' for
6226 a more detailed description of MODE.
6227
6228 Report bugs to <bug-libtool@gnu.org>."
6229   exit $EXIT_SUCCESS
6230   ;;
6231
6232 clean)
6233   $echo \
6234 "Usage: $modename [OPTION]... --mode=clean RM [RM-OPTION]... FILE...
6235
6236 Remove files from the build directory.
6237
6238 RM is the name of the program to use to delete files associated with each FILE
6239 (typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6240 to RM.
6241
6242 If FILE is a libtool library, object or program, all the files associated
6243 with it are deleted. Otherwise, only FILE itself is deleted using RM."
6244   ;;
6245
6246 compile)
6247   $echo \
6248 "Usage: $modename [OPTION]... --mode=compile COMPILE-COMMAND... SOURCEFILE
6249
6250 Compile a source file into a libtool library object.
6251
6252 This mode accepts the following additional options:
6253
6254   -o OUTPUT-FILE    set the output file name to OUTPUT-FILE
6255   -prefer-pic       try to building PIC objects only
6256   -prefer-non-pic   try to building non-PIC objects only
6257   -static           always build a \`.o' file suitable for static linking
6258
6259 COMPILE-COMMAND is a command to be used in creating a \`standard' object file
6260 from the given SOURCEFILE.
6261
6262 The output file name is determined by removing the directory component from
6263 SOURCEFILE, then substituting the C source code suffix \`.c' with the
6264 library object suffix, \`.lo'."
6265   ;;
6266
6267 execute)
6268   $echo \
6269 "Usage: $modename [OPTION]... --mode=execute COMMAND [ARGS]...
6270
6271 Automatically set library path, then run a program.
6272
6273 This mode accepts the following additional options:
6274
6275   -dlopen FILE      add the directory containing FILE to the library path
6276
6277 This mode sets the library path environment variable according to \`-dlopen'
6278 flags.
6279
6280 If any of the ARGS are libtool executable wrappers, then they are translated
6281 into their corresponding uninstalled binary, and any of their required library
6282 directories are added to the library path.
6283
6284 Then, COMMAND is executed, with ARGS as arguments."
6285   ;;
6286
6287 finish)
6288   $echo \
6289 "Usage: $modename [OPTION]... --mode=finish [LIBDIR]...
6290
6291 Complete the installation of libtool libraries.
6292
6293 Each LIBDIR is a directory that contains libtool libraries.
6294
6295 The commands that this mode executes may require superuser privileges.  Use
6296 the \`--dry-run' option if you just want to see what would be executed."
6297   ;;
6298
6299 install)
6300   $echo \
6301 "Usage: $modename [OPTION]... --mode=install INSTALL-COMMAND...
6302
6303 Install executables or libraries.
6304
6305 INSTALL-COMMAND is the installation command.  The first component should be
6306 either the \`install' or \`cp' program.
6307
6308 The rest of the components are interpreted as arguments to that command (only
6309 BSD-compatible install options are recognized)."
6310   ;;
6311
6312 link)
6313   $echo \
6314 "Usage: $modename [OPTION]... --mode=link LINK-COMMAND...
6315
6316 Link object files or libraries together to form another library, or to
6317 create an executable program.
6318
6319 LINK-COMMAND is a command using the C compiler that you would use to create
6320 a program from several object files.
6321
6322 The following components of LINK-COMMAND are treated specially:
6323
6324   -all-static       do not do any dynamic linking at all
6325   -avoid-version    do not add a version suffix if possible
6326   -dlopen FILE      \`-dlpreopen' FILE if it cannot be dlopened at runtime
6327   -dlpreopen FILE   link in FILE and add its symbols to lt_preloaded_symbols
6328   -export-dynamic   allow symbols from OUTPUT-FILE to be resolved with dlsym(3)
6329   -export-symbols SYMFILE
6330                     try to export only the symbols listed in SYMFILE
6331   -export-symbols-regex REGEX
6332                     try to export only the symbols matching REGEX
6333   -LLIBDIR          search LIBDIR for required installed libraries
6334   -lNAME            OUTPUT-FILE requires the installed library libNAME
6335   -module           build a library that can dlopened
6336   -no-fast-install  disable the fast-install mode
6337   -no-install       link a not-installable executable
6338   -no-undefined     declare that a library does not refer to external symbols
6339   -o OUTPUT-FILE    create OUTPUT-FILE from the specified objects
6340   -objectlist FILE  Use a list of object files found in FILE to specify objects
6341   -precious-files-regex REGEX
6342                     don't remove output files matching REGEX
6343   -release RELEASE  specify package release information
6344   -rpath LIBDIR     the created library will eventually be installed in LIBDIR
6345   -R[ ]LIBDIR       add LIBDIR to the runtime path of programs and libraries
6346   -static           do not do any dynamic linking of libtool libraries
6347   -version-info CURRENT[:REVISION[:AGE]]
6348                     specify library version info [each variable defaults to 0]
6349
6350 All other options (arguments beginning with \`-') are ignored.
6351
6352 Every other argument is treated as a filename.  Files ending in \`.la' are
6353 treated as uninstalled libtool libraries, other files are standard or library
6354 object files.
6355
6356 If the OUTPUT-FILE ends in \`.la', then a libtool library is created,
6357 only library objects (\`.lo' files) may be specified, and \`-rpath' is
6358 required, except when creating a convenience library.
6359
6360 If OUTPUT-FILE ends in \`.a' or \`.lib', then a standard library is created
6361 using \`ar' and \`ranlib', or on Windows using \`lib'.
6362
6363 If OUTPUT-FILE ends in \`.lo' or \`.${objext}', then a reloadable object file
6364 is created, otherwise an executable program is created."
6365   ;;
6366
6367 uninstall)
6368   $echo \
6369 "Usage: $modename [OPTION]... --mode=uninstall RM [RM-OPTION]... FILE...
6370
6371 Remove libraries from an installation directory.
6372
6373 RM is the name of the program to use to delete files associated with each FILE
6374 (typically \`/bin/rm').  RM-OPTIONS are options (such as \`-f') to be passed
6375 to RM.
6376
6377 If FILE is a libtool library, all the files associated with it are deleted.
6378 Otherwise, only FILE itself is deleted using RM."
6379   ;;
6380
6381 *)
6382   $echo "$modename: invalid operation mode \`$mode'" 1>&2
6383   $echo "$help" 1>&2
6384   exit $EXIT_FAILURE
6385   ;;
6386 esac
6387
6388 $echo
6389 $echo "Try \`$modename --help' for more information about other modes."
6390
6391 exit $EXIT_SUCCESS
6392
6393 # The TAGs below are defined such that we never get into a situation
6394 # in which we disable both kinds of libraries.  Given conflicting
6395 # choices, we go for a static library, that is the most portable,
6396 # since we can't tell whether shared libraries were disabled because
6397 # the user asked for that or because the platform doesn't support
6398 # them.  This is particularly important on AIX, because we don't
6399 # support having both static and shared libraries enabled at the same
6400 # time on that platform, so we default to a shared-only configuration.
6401 # If a disable-shared tag is given, we'll fallback to a static-only
6402 # configuration.  But we'll never go from static-only to shared-only.
6403
6404 # ### BEGIN LIBTOOL TAG CONFIG: disable-shared
6405 build_libtool_libs=no
6406 build_old_libs=yes
6407 # ### END LIBTOOL TAG CONFIG: disable-shared
6408
6409 # ### BEGIN LIBTOOL TAG CONFIG: disable-static
6410 build_old_libs=`case $build_libtool_libs in yes) $echo no;; *) $echo yes;; esac`
6411 # ### END LIBTOOL TAG CONFIG: disable-static
6412
6413 # Local Variables:
6414 # mode:shell-script
6415 # sh-indentation:2
6416 # End: