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