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